Skip to content

Commit b9110f1

Browse files
Kevin Huangmeta-codesync[bot]
authored andcommitted
sb: rb: Add multiple new functions. (#2654)
Summary: - add asic board id identification - modify some gpio from input to output - add p3v3 osfp for evb board - add get vr fw version for raa228249 and mp2971 - modify prefix string for pdr sensor aux names - add test info shell command - add the other source for the ubc - enable ubc bmc316/lx6301 - add init_arg for mpc12109 - modify bic addr from 0x40 to 0x42 - add set eid pldm command - fix rns vr sensor type issue - add platform temp status and temp threshold shell command - update EVB sensor LCR and UCR - modify shell file name - add platform voltage shell command - add platform bootstrap shell command - add platform temp_threshold init - black box : vr power fault - delay between stop start sensor polling and vr update - MMC I2C interface to MTIA - I2C: sensor init, sensor reading, Inventory IDs - add i2c target table functions - add all VR Vin pldm sensors - add reading voltage peak value - fix voltae get cmd to show vr voltage issue - fix sensor driver Vin reading - add zephyr_nuvoton new config on i2c bus - add shell commands a.iris_power <steps_on> b.voltage set c.power_sequence <power_up | power_down> d.throttle switch <get | set> - define PLDM_MSG_TIMEOUT_MS to 5000 - update pldm update bic image function - add shell commands a.uart_powerevent enable|disable b.perm_config get|clear c.soc_pcie_perst [N (* 50ms)]|default [perm] d.average_power get <ubc_vr_name>|all e.pwrlevel1 get|set <trip-level in mA>|default [perm] f.soc-pwron-reset <command> <drive-level> - add MTIA image update(hamsa,medha0,medha1) - add different stage will change VR and UBC devices address - add change eid function Pull Request resolved: #2654 Test Plan: - Build code: Pass Reviewed By: jamesatha Differential Revision: D90737668 fbshipit-source-id: fb564e548be6ea4930fe501f5aca4bccbdf9237f
1 parent c1d1a9e commit b9110f1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+8660
-779
lines changed

common/dev/mp2971.c

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "hal_i2c.h"
2323
#include "pmbus.h"
2424
#include "mp2971.h"
25+
#include "util_pmbus.h"
2526

2627
LOG_MODULE_REGISTER(mp2971);
2728

@@ -718,7 +719,7 @@ bool mp2971_get_checksum(uint8_t bus, uint8_t addr, uint32_t *checksum)
718719
return true;
719720
}
720721

721-
bool get_vout_scale(sensor_cfg *cfg, float *vout_scale)
722+
bool get_vout_scale(const sensor_cfg *cfg, float *vout_scale)
722723
{
723724
CHECK_NULL_ARG_WITH_RETURN(vout_scale, false);
724725
uint8_t i2c_max_retry = 5;
@@ -749,7 +750,7 @@ float get_resolution(sensor_cfg *cfg)
749750

750751
bool vout_scale_enable = false;
751752
if (cfg->init_args != NULL) {
752-
mp2971_init_arg *init_arg = (mp2971_init_arg *)cfg->init_args;
753+
const mp2971_init_arg *init_arg = (mp2971_init_arg *)cfg->init_args;
753754
vout_scale_enable = init_arg->vout_scale_enable;
754755
}
755756

@@ -906,6 +907,9 @@ float get_resolution(sensor_cfg *cfg)
906907
pout_reso = pout_reso / vout_scale;
907908
return pout_reso;
908909
break;
910+
case PMBUS_READ_VIN:
911+
return 0.03125; // 1/32V per LSB
912+
break;
909913
default:
910914
LOG_WRN("offset not supported: 0x%x", offset);
911915
break;
@@ -922,7 +926,7 @@ bool mp2971_vid_to_direct(sensor_cfg *cfg, uint8_t rail, uint16_t *millivolt)
922926
float vout_scale = 1.0;
923927

924928
if (cfg->init_args != NULL) {
925-
mp2971_init_arg *init_arg = (mp2971_init_arg *)cfg->init_args;
929+
const mp2971_init_arg *init_arg = (mp2971_init_arg *)cfg->init_args;
926930
if (init_arg->vout_scale_enable) {
927931
if (get_vout_scale(cfg, &vout_scale) == false)
928932
LOG_WRN("get vout scale failed");
@@ -1011,7 +1015,7 @@ bool mp2971_direct_to_vid(sensor_cfg *cfg, uint8_t rail, uint16_t *millivolt)
10111015
float vout_scale = 1.0;
10121016

10131017
if (cfg->init_args != NULL) {
1014-
mp2971_init_arg *init_arg = (mp2971_init_arg *)cfg->init_args;
1018+
const mp2971_init_arg *init_arg = (mp2971_init_arg *)cfg->init_args;
10151019
if (init_arg->vout_scale_enable) {
10161020
if (get_vout_scale(cfg, &vout_scale) == false)
10171021
LOG_WRN("get vout scale failed");
@@ -1277,6 +1281,7 @@ uint8_t mp2971_read(sensor_cfg *cfg, int *reading)
12771281

12781282
uint8_t i2c_max_retry = 5;
12791283
int val = 0;
1284+
float f_val = 0.0;
12801285
sensor_val *sval = (sensor_val *)reading;
12811286
I2C_MSG msg;
12821287
memset(sval, 0, sizeof(sensor_val));
@@ -1312,6 +1317,11 @@ uint8_t mp2971_read(sensor_cfg *cfg, int *reading)
13121317
case PMBUS_READ_POUT:
13131318
val = val & BIT_MASK(11);
13141319
break;
1320+
case PMBUS_READ_VIN:
1321+
val = val & BIT_MASK(9);
1322+
f_val = slinear11_to_float((uint16_t)val);
1323+
val = (uint16_t)f_val;
1324+
break;
13151325
default:
13161326
LOG_WRN("offset not supported: 0x%x", offset);
13171327
return SENSOR_FAIL_TO_ACCESS;

common/dev/mp29816a.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -782,6 +782,11 @@ uint8_t mp29816a_read(sensor_cfg *cfg, int *reading)
782782
cfg->offset == PMBUS_READ_IOUT) {
783783
uint16_t read_value = (msg.data[1] << 8) | msg.data[0];
784784
val = slinear11_to_float(read_value);
785+
} else if (cfg->offset == PMBUS_READ_VIN) {
786+
uint16_t read_value = (msg.data[1] << 8) | msg.data[0];
787+
read_value = read_value & BIT_MASK(10);
788+
val = slinear11_to_float(read_value);
789+
val *= 0.03125; // 31.25mV/LSB
785790
} else {
786791
LOG_ERR("Sensor num 0x%x, offset 0x%x not supported.", cfg->num, cfg->offset);
787792
return SENSOR_FAIL_TO_ACCESS;

common/dev/raa228249.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ LOG_MODULE_REGISTER(raa228249);
2727

2828
#define raa228249_READ_VOUT_RESOLUTION 0.001
2929
#define raa228249_READ_IOUT_RESOLUTION 0.1
30+
#define raa228249_READ_VIN_RESOLUTION 0.01
3031

3132
// RAA GEN3p5
3233
#define VR_RAA_REG_REMAIN_WR 0x35
@@ -653,6 +654,11 @@ uint8_t raa228249_read(sensor_cfg *cfg, int *reading)
653654
int16_t read_value = (msg.data[1] << 8) | msg.data[0];
654655
val = read_value * raa228249_READ_IOUT_RESOLUTION;
655656

657+
} else if (cfg->offset == PMBUS_READ_VIN) {
658+
/* 2's complement */
659+
int16_t read_value = (msg.data[1] << 8) | msg.data[0];
660+
val = read_value * raa228249_READ_VIN_RESOLUTION;
661+
656662
} else {
657663
return SENSOR_FAIL_TO_ACCESS;
658664
}

common/service/pldm/pldm_firmware_update.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -726,6 +726,7 @@ uint8_t fill_descriptor_into_buf(struct pldm_descriptor_string *descriptor, uint
726726
uint8_t *fill_length, uint16_t current_length);
727727
bool is_update_state_download_phase();
728728
bool is_update_state_idle();
729+
uint8_t pldm_fw_update(void *fw_update_param, const int flash_position);
729730

730731
#ifdef __cplusplus
731732
}

common/service/pldm/pldm_oem.h

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ enum oem_event_type {
104104
OS_LOAD_WDT_PWR_CYCLE,
105105
MTIA_FAULT,
106106
POST_TIMEOUTED,
107+
IRIS_FAULT,
107108
};
108109

109110
enum vr_event_source {
@@ -186,7 +187,51 @@ enum mtia_event_source {
186187
MTIA_ATH_GPIO_3,
187188
MTIA_ATH_GPIO_4
188189
};
189-
190+
enum iris_event_source {
191+
// VR Power Fault 1
192+
IRIS_OWL_E_TRVDD0P9 = 0,
193+
IRIS_OWL_W_TRVDD0P9,
194+
IRIS_OWL_E_TRVDD0P75,
195+
IRIS_OWL_W_TRVDD0P75,
196+
IRIS_HAMSA_AVDD_PCIE,
197+
IRIS_HAMSA_VDDHRXTX_PCIE,
198+
// VR Power Fault 2
199+
IRIS_MEDHA1_VDD,
200+
IRIS_MEDHA0_VDD,
201+
IRIS_OWL_E_VDD,
202+
IRIS_OWL_W_VDD,
203+
IRIS_HAMSA_VDD,
204+
IRIS_MAX_S_VDD,
205+
IRIS_MAX_M_VDD,
206+
IRIS_MAX_N_VDD,
207+
// VR Power Fault 3
208+
IRIS_VDDQL_HBM0_HBM2_HBM4_HBM6,
209+
IRIS_VDDQC_HBM0_HBM2_HBM4_HBM6,
210+
IRIS_VPP_HBM0_HBM2_HBM4_HBM6,
211+
IRIS_VDDPHY_HBM0_HBM2_HBM4_HBM6,
212+
IRIS_VDDQL_HBM1_HBM3_HBM5_HBM7,
213+
IRIS_VDDQC_HBM1_HBM3_HBM5_HBM7,
214+
IRIS_VPP_HBM1_HBM3_HBM5_HBM7,
215+
IRIS_VDDPHY_HBM1_HBM3_HBM5_HBM7,
216+
// VR Power Fault 4
217+
IRIS_PLL_VDDA15_HBM0_HBM2,
218+
IRIS_PLL_VDDA15_HBM4_HBM6,
219+
IRIS_PLL_VDDA15_HBM1_HBM3,
220+
IRIS_PLL_VDDA15_HBM5_HBM7,
221+
IRIS_P0V9_OWL_E_PVDD,
222+
IRIS_P0V9_OWL_W_PVDD,
223+
IRIS_P1V5_E_RVDD,
224+
IRIS_P1V5_W_RVDD,
225+
// VR Power Fault 5
226+
IRIS_P12V_UBC_PWRGD,
227+
IRIS_P5V,
228+
IRIS_P3V3,
229+
IRIS_P1V8,
230+
IRIS_LDO_IN_1V2,
231+
IRIS_P1V5_PLL_VDDA_OWL,
232+
IRIS_P1V5_PLL_VDDA_SOC,
233+
IRIS_PVDD1P5,
234+
};
190235
enum READ_FILE_OPTION { READ_FILE_ATTR, READ_FILE_DATA };
191236

192237
struct _cmd_echo_req {

common/service/sensor/pldm_sensor.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ __weak void plat_pldm_sensor_post_load_init(int thread_id)
5858
return;
5959
}
6060

61+
__weak void plat_pldm_sensor_poll_post()
62+
{
63+
return;
64+
}
65+
6166
bool pldm_sensor_is_interval_ready(pldm_sensor_info *pldm_sensor_list)
6267
{
6368
CHECK_NULL_ARG_WITH_RETURN(pldm_sensor_list, false);
@@ -458,7 +463,7 @@ void pldm_sensor_polling_handler(void *arug0, void *arug1, void *arug2)
458463
}
459464
}
460465
}
461-
466+
plat_pldm_sensor_poll_post();
462467
k_msleep(poll_interval_ms);
463468
}
464469
}

meta-facebook/sb-rb/boards/npcm400f_evb.overlay

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,10 @@
4949
};
5050

5151
&i2c6a {
52-
clock-frequency = <I2C_BITRATE_STANDARD>;
53-
status = "okay";
52+
clock-frequency = <I2C_BITRATE_STANDARD>;
53+
status = "okay";
54+
multi-master = <1>;
55+
wait_free_time = <1000>;
5456
};
5557

5658
&i2c6b {

meta-facebook/sb-rb/prj.conf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ CONFIG_SHELL_LOG_BACKEND=n
5151

5252
CONFIG_USB=n
5353
CONFIG_LOG_BUFFER_SIZE=16384
54-
CONFIG_ADC_SHELL=y
54+
CONFIG_ADC_SHELL=n
5555
CONFIG_SHELL_ARGC_MAX=40
5656
CONFIG_SHELL_STACK_SIZE=4096
57+
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048

meta-facebook/sb-rb/src/platform/plat_class.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "plat_fru.h"
2424
#include "plat_i2c.h"
2525
#include "plat_util.h"
26+
#include "plat_mctp.h"
2627

2728
LOG_MODULE_REGISTER(plat_class);
2829

@@ -58,20 +59,24 @@ static bool plat_slot_read(uint8_t *data)
5859
void init_plat_config()
5960
{
6061
uint8_t module = 0;
62+
uint8_t board_rev_id = 0;
6163
plat_read_cpld(CPLD_OFFSET_VR_VENDER_TYPE, &module, 1);
62-
64+
plat_read_cpld(CPLD_OFFSET_BOARD_REV_ID, &board_rev_id, 1);
65+
// rev id only support 0, 1, 2 bit
66+
board_rev_id = board_rev_id & 0x07;
6367
vr_module = (module & 0x01);
6468
ubc_module = (module >> 1) & 0x03;
65-
66-
change_sensor_cfg(vr_module, ubc_module);
67-
6869
uint8_t board_id = 0;
6970
plat_read_cpld(CPLD_OFFSET_ASIC_BOARD_ID, &board_id, 1);
70-
7171
asic_board_id = board_id & 0x03;
7272

73+
change_sensor_cfg(asic_board_id, vr_module, ubc_module, board_rev_id);
7374
// cpld fru offset 0: slot
7475
plat_slot_read(&mmc_slot);
76+
// mmc slot 1-4 * 0x0A
77+
uint8_t init_plat_eid = ((get_mmc_slot() + 1) * MCTP_DEFAULT_ENDPOINT);
78+
plat_set_eid(init_plat_eid);
79+
LOG_INF("init_plat_eid: 0x%x", init_plat_eid);
7580
}
7681

7782
uint8_t get_vr_module()

meta-facebook/sb-rb/src/platform/plat_class.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,18 @@ enum ASIC_BOARD_ID {
4141
ASIC_BOARD_ID_UNKNOWN,
4242
};
4343

44+
enum REV_ID {
45+
REV_ID_EVT1A,
46+
REV_ID_EVT1B,
47+
REV_ID_EVT2,
48+
REV_ID_DVT,
49+
REV_ID_PVT,
50+
REV_ID_MP,
51+
REV_ID_RSVD1,
52+
REV_ID_RSVD2,
53+
MAX_REV_ID,
54+
};
55+
4456
void init_plat_config();
4557
uint8_t get_vr_module();
4658
uint8_t get_ubc_module();

0 commit comments

Comments
 (0)