From 1527df0d5b1366ad54fd3e425b06734bd8a0bd65 Mon Sep 17 00:00:00 2001 From: James Chiang Date: Thu, 12 Sep 2024 00:46:04 -0700 Subject: [PATCH] yv35-npcm-test: add set i3c pid and trigger hot-join request add set i3c pid and trigger hot-join request. Signed-off-by: James Chiang --- meta-facebook/yv35-npcm-test/CMakeLists.txt | 1 - .../yv35-npcm-test/src/ipmi/plat_ipmi.c | 19 ---- .../yv35-npcm-test/src/platform/plat_class.c | 86 +++++++++++++++++++ .../yv35-npcm-test/src/platform/plat_class.h | 22 +++++ .../yv35-npcm-test/src/platform/plat_init.c | 3 + 5 files changed, 111 insertions(+), 20 deletions(-) create mode 100644 meta-facebook/yv35-npcm-test/src/platform/plat_class.c diff --git a/meta-facebook/yv35-npcm-test/CMakeLists.txt b/meta-facebook/yv35-npcm-test/CMakeLists.txt index 5adb0ca50e..539e44ac62 100644 --- a/meta-facebook/yv35-npcm-test/CMakeLists.txt +++ b/meta-facebook/yv35-npcm-test/CMakeLists.txt @@ -21,7 +21,6 @@ target_sources(app PRIVATE ${nuvoton_sources}) target_sources(app PRIVATE ${nuvoton_shell}) # Common Lib -target_sources(app PRIVATE ${common_path}/lib/expansion_board.c) target_sources(app PRIVATE ${common_path}/lib/libutil.c) target_sources(app PRIVATE ${common_path}/lib/power_status.c) target_sources(app PRIVATE ${common_path}/lib/timer.c) diff --git a/meta-facebook/yv35-npcm-test/src/ipmi/plat_ipmi.c b/meta-facebook/yv35-npcm-test/src/ipmi/plat_ipmi.c index 5efc0da28f..1dcb290295 100644 --- a/meta-facebook/yv35-npcm-test/src/ipmi/plat_ipmi.c +++ b/meta-facebook/yv35-npcm-test/src/ipmi/plat_ipmi.c @@ -51,25 +51,6 @@ bool pal_request_msg_to_BIC_from_HOST(uint8_t netfn, uint8_t cmd) return false; } -void OEM_1S_GET_BOARD_ID(ipmi_msg *msg) -{ - if (msg == NULL) { - LOG_ERR("Failed due to parameter *msg is NULL"); - return; - } - - if (msg->data_len != 0) { - msg->data_len = 0; - msg->completion_code = CC_INVALID_LENGTH; - return; - } - - msg->data_len = 1; - msg->data[0] = get_board_id(); - msg->completion_code = CC_SUCCESS; - return; -} - void OEM_1S_GET_FW_VERSION(ipmi_msg *msg) { CHECK_NULL_ARG(msg); diff --git a/meta-facebook/yv35-npcm-test/src/platform/plat_class.c b/meta-facebook/yv35-npcm-test/src/platform/plat_class.c new file mode 100644 index 0000000000..fb291880aa --- /dev/null +++ b/meta-facebook/yv35-npcm-test/src/platform/plat_class.c @@ -0,0 +1,86 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "plat_class.h" + +#include +#include +#include +#include + +#include "hal_gpio.h" +#include "hal_i3c.h" +#include "libutil.h" +#include "plat_gpio.h" +#include "mctp.h" +#include "mctp_ctrl.h" +#include "plat_mctp.h" + +LOG_MODULE_REGISTER(plat_class); + +uint8_t slot_eid = 0; +uint8_t slot_id = 0; +uint16_t slot_pid = 0; + +void init_platform_config() +{ + I3C_MSG i3c_msg; + + i3c_msg.bus = I3C_BUS_BMC; + + slot_eid = MCTP_DEFAULT_ENDPOINT; + + switch (slot_eid) { + case SLOT1_EID: + slot_id = 1; + slot_pid = SLOT1_PID; + break; + case SLOT2_EID: + slot_id = 2; + slot_pid = SLOT2_PID; + break; + case SLOT3_EID: + slot_id = 3; + slot_pid = SLOT3_PID; + break; + case SLOT4_EID: + slot_id = 4; + slot_pid = SLOT4_PID; + break; + case SLOT5_EID: + slot_id = 5; + slot_pid = SLOT5_PID; + break; + case SLOT6_EID: + slot_id = 6; + slot_pid = SLOT6_PID; + break; + case SLOT7_EID: + slot_id = 7; + slot_pid = SLOT7_PID; + break; + case SLOT8_EID: + slot_id = 8; + slot_pid = SLOT8_PID; + break; + default: + break; + } + + LOG_INF("Slot EID = %d, Slot ID = %d Slot PID = 0x%x\n", slot_eid, slot_id, slot_pid); + + i3c_set_pid(&i3c_msg, slot_pid); +} diff --git a/meta-facebook/yv35-npcm-test/src/platform/plat_class.h b/meta-facebook/yv35-npcm-test/src/platform/plat_class.h index 47a06efc5f..ed7ffc4f98 100644 --- a/meta-facebook/yv35-npcm-test/src/platform/plat_class.h +++ b/meta-facebook/yv35-npcm-test/src/platform/plat_class.h @@ -36,6 +36,28 @@ #define MAX_1OU_M2_COUNT 4 +enum SLOT_EID { + SLOT1_EID = 0x0A, + SLOT2_EID = 0x0B, + SLOT3_EID = 0x0C, + SLOT4_EID = 0x0D, + SLOT5_EID = 0x0E, + SLOT6_EID = 0x0F, + SLOT7_EID = 0x10, + SLOT8_EID = 0x11, +}; + +enum SLOT_PID { + SLOT1_PID = 0x0607, + SLOT2_PID = 0x0608, + SLOT3_PID = 0x0609, + SLOT4_PID = 0x060A, + SLOT5_PID = 0x060B, + SLOT6_PID = 0x060C, + SLOT7_PID = 0x060D, + SLOT8_PID = 0x060E, +}; + enum BIC_BOARD_REVISION { SYS_BOARD_POC = 0x0, SYS_BOARD_EVT, diff --git a/meta-facebook/yv35-npcm-test/src/platform/plat_init.c b/meta-facebook/yv35-npcm-test/src/platform/plat_init.c index af06ed6e1b..82893090bf 100644 --- a/meta-facebook/yv35-npcm-test/src/platform/plat_init.c +++ b/meta-facebook/yv35-npcm-test/src/platform/plat_init.c @@ -22,9 +22,12 @@ #include "pldm.h" #include "plat_mctp.h" #include "plat_ssif.h" +#include "plat_class.h" void pal_pre_init() { + init_platform_config(); + /* init i2c target */ for (int index = 0; index < MAX_TARGET_NUM; index++) { if (I2C_TARGET_ENABLE_TABLE[index])