Skip to content

Commit

Permalink
yv35-npcm-test: add set i3c pid and trigger hot-join request
Browse files Browse the repository at this point in the history
add set i3c pid and trigger hot-join request.

Signed-off-by: James Chiang <[email protected]>
  • Loading branch information
James Chiang authored and maxdog988 committed Sep 20, 2024
1 parent 08bcfb3 commit 1527df0
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 20 deletions.
1 change: 0 additions & 1 deletion meta-facebook/yv35-npcm-test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
19 changes: 0 additions & 19 deletions meta-facebook/yv35-npcm-test/src/ipmi/plat_ipmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
86 changes: 86 additions & 0 deletions meta-facebook/yv35-npcm-test/src/platform/plat_class.c
Original file line number Diff line number Diff line change
@@ -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 <logging/log.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#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);
}
22 changes: 22 additions & 0 deletions meta-facebook/yv35-npcm-test/src/platform/plat_class.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions meta-facebook/yv35-npcm-test/src/platform/plat_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down

0 comments on commit 1527df0

Please sign in to comment.