From 120ff7dac9c8f05209645d3ab6112f2b388fd7a1 Mon Sep 17 00:00:00 2001 From: SeanHe-wiwynn Date: Thu, 17 Oct 2024 09:57:22 +0800 Subject: [PATCH] fby4: wf: Adjust the E1S-related GPIO settings and sensors access time Summary: \#Description - Some of the E1S-related board GPIO settings are not compatible with the corresponding GPIO table. - Adjust the access time of E1S-related sensors after the E1S power is good. \#Motivation - The conflict between the board GPIO settings and the GPIO table will cause the GPIO pin to be set to LOW after the WF BIC update. - E1S-related sensors should only be read after the E1S is power good. Test Plan: Build Code - PASS Sensor Access - PASS --- common/lib/power_status.c | 25 +++++++++++++++++++ common/lib/power_status.h | 4 +++ common/service/sensor/sensor.c | 5 ++++ common/service/sensor/sensor.h | 1 + .../yv4-wf/boards/ast1030_evb.overlay | 2 +- meta-facebook/yv4-wf/src/platform/plat_gpio.c | 9 ++++--- meta-facebook/yv4-wf/src/platform/plat_isr.c | 14 +++++++++-- meta-facebook/yv4-wf/src/platform/plat_isr.h | 2 +- .../yv4-wf/src/platform/plat_pldm_sensor.c | 10 ++++---- .../yv4-wf/src/platform/plat_power_seq.c | 6 +++++ 10 files changed, 65 insertions(+), 13 deletions(-) diff --git a/common/lib/power_status.c b/common/lib/power_status.c index 7abe462667..ee074103c0 100644 --- a/common/lib/power_status.c +++ b/common/lib/power_status.c @@ -30,6 +30,8 @@ static bool is_DC_off_delayed = false; static bool is_CPU_power_good = false; static bool is_post_complete = false; static bool vr_monitor_status = true; +static bool is_P3V3_E1S_power_good = false; +static bool is_P12V_E1S_power_good = false; void set_DC_status(uint8_t gpio_num) { @@ -114,3 +116,26 @@ bool get_vr_monitor_status() { return vr_monitor_status; } + +void set_P3V3_E1S_power_status(uint8_t gpio_num) +{ + is_P3V3_E1S_power_good = gpio_get(gpio_num); + LOG_WRN("P3V3_E1S_PWR_GOOD: %s", (is_P3V3_E1S_power_good) ? "yes" : "no"); +} + +bool P3V3_E1S_power_good() +{ + return is_P3V3_E1S_power_good; +} + +void set_P12V_E1S_power_status(uint8_t gpio_num) +{ + is_P12V_E1S_power_good = gpio_get(gpio_num); + LOG_WRN("P12V_E1S_PWR_GOOD: %s", (is_P12V_E1S_power_good) ? "yes" : "no"); +} + +bool P12V_E1S_power_good() +{ + return is_P12V_E1S_power_good; +} + diff --git a/common/lib/power_status.h b/common/lib/power_status.h index 8011b8d34a..35ff03a6c9 100644 --- a/common/lib/power_status.h +++ b/common/lib/power_status.h @@ -35,5 +35,9 @@ bool CPU_power_good(); void set_post_thread(); void set_vr_monitor_status(bool value); bool get_vr_monitor_status(); +void set_P3V3_E1S_power_status(uint8_t gpio_num); +bool P3V3_E1S_power_good(); +void set_P12V_E1S_power_status(uint8_t gpio_num); +bool P12V_E1S_power_good(); #endif diff --git a/common/service/sensor/sensor.c b/common/service/sensor/sensor.c index dbaf9a18f9..f346d49621 100644 --- a/common/service/sensor/sensor.c +++ b/common/service/sensor/sensor.c @@ -1088,6 +1088,11 @@ bool dc_access(uint8_t sensor_num) return get_DC_on_delayed_status(); } +bool e1s_pwrgd_access(uint8_t sensor_num) +{ + return P3V3_E1S_power_good() && P12V_E1S_power_good(); +} + bool post_access(uint8_t sensor_num) { return get_post_status(); diff --git a/common/service/sensor/sensor.h b/common/service/sensor/sensor.h index ea4ecfc965..de58b0a850 100644 --- a/common/service/sensor/sensor.h +++ b/common/service/sensor/sensor.h @@ -787,6 +787,7 @@ uint8_t get_sensor_reading(sensor_cfg *cfg_table, uint8_t cfg_count, uint8_t sen void pal_set_sensor_poll_interval(int *interval_ms); bool stby_access(uint8_t sensor_num); bool dc_access(uint8_t sensor_num); +bool e1s_pwrgd_access(uint8_t sensor_num); bool post_access(uint8_t sensor_num); bool me_access(uint8_t sensor_num); bool vr_access(uint8_t sensor_num); diff --git a/meta-facebook/yv4-wf/boards/ast1030_evb.overlay b/meta-facebook/yv4-wf/boards/ast1030_evb.overlay index 03a1ebbf3c..9d537c5cae 100644 --- a/meta-facebook/yv4-wf/boards/ast1030_evb.overlay +++ b/meta-facebook/yv4-wf/boards/ast1030_evb.overlay @@ -207,7 +207,7 @@ }; &gpio0_e_h { - aspeed,persist-maps = <0x0555505D>; + aspeed,persist-maps = <0x0555555D>; }; &gpio0_i_l { diff --git a/meta-facebook/yv4-wf/src/platform/plat_gpio.c b/meta-facebook/yv4-wf/src/platform/plat_gpio.c index 4dbb2558d1..7da3010b88 100644 --- a/meta-facebook/yv4-wf/src/platform/plat_gpio.c +++ b/meta-facebook/yv4-wf/src/platform/plat_gpio.c @@ -99,7 +99,7 @@ GPIO_CFG plat_gpio_cfg[] = { { CHIP_GPIO, 40, ENABLE, DISABLE, GPIO_INPUT, GPIO_LOW, PUSH_PULL, GPIO_INT_DISABLE, NULL }, { CHIP_GPIO, 41, ENABLE, DISABLE, GPIO_INPUT, GPIO_LOW, PUSH_PULL, GPIO_INT_DISABLE, NULL }, { CHIP_GPIO, 42, ENABLE, ENABLE, GPIO_OUTPUT, GPIO_LOW, PUSH_PULL, GPIO_INT_DISABLE, NULL }, - { CHIP_GPIO, 43, ENABLE, DISABLE, GPIO_INPUT, GPIO_LOW, PUSH_PULL, GPIO_INT_EDGE_RISING, ISR_E1S_PWR_ON }, + { CHIP_GPIO, 43, ENABLE, DISABLE, GPIO_INPUT, GPIO_LOW, PUSH_PULL, GPIO_INT_EDGE_BOTH, ISR_E1S_PWR_CHANGE }, { CHIP_GPIO, 44, ENABLE, ENABLE, GPIO_OUTPUT, GPIO_LOW, PUSH_PULL, GPIO_INT_DISABLE, NULL }, { CHIP_GPIO, 45, ENABLE, DISABLE, GPIO_INPUT, GPIO_LOW, PUSH_PULL, GPIO_INT_DISABLE, NULL }, { CHIP_GPIO, 46, ENABLE, ENABLE, GPIO_OUTPUT, GPIO_LOW, PUSH_PULL, GPIO_INT_DISABLE, NULL }, @@ -271,8 +271,8 @@ bool pal_load_gpio_config(void) plat_gpio_cfg[POC_EN_P3V3_E1S_0_R].direction = GPIO_OUTPUT; gpio_name[POC_EN_P3V3_E1S_0_R] = "EN_P3V3_E1S_0_R"; - plat_gpio_cfg[POC_PWRGD_P3V3_E1S_0_R].int_type = GPIO_INT_EDGE_RISING; - plat_gpio_cfg[POC_PWRGD_P3V3_E1S_0_R].int_cb = ISR_E1S_PWR_ON; + plat_gpio_cfg[POC_PWRGD_P3V3_E1S_0_R].int_type = GPIO_INT_EDGE_BOTH; + plat_gpio_cfg[POC_PWRGD_P3V3_E1S_0_R].int_cb = ISR_E1S_PWR_CHANGE; gpio_name[POC_PWRGD_P3V3_E1S_0_R] = "PWRGD_P3V3_E1S_0_R"; } @@ -374,7 +374,8 @@ void init_ioe_config() LOG_ERR("Failed to get E1S present from IOE4"); continue; } - ioe_reg_value = (ioe_cfg[i].output_val & init_val_mask) | (ioe_reg_value & init_dir_mask); + ioe_reg_value = (ioe_cfg[i].output_val & init_val_mask) | + (ioe_reg_value & init_dir_mask); } else if ((ioe_cfg[i].addr == ADDR_IOE2) && (ioe_cfg[i].output_reg == TCA9555_OUTPUT_PORT_REG_0) && diff --git a/meta-facebook/yv4-wf/src/platform/plat_isr.c b/meta-facebook/yv4-wf/src/platform/plat_isr.c index 09966cbe1b..72a818f997 100644 --- a/meta-facebook/yv4-wf/src/platform/plat_isr.c +++ b/meta-facebook/yv4-wf/src/platform/plat_isr.c @@ -23,6 +23,7 @@ #include "plat_power_seq.h" #include "plat_mctp.h" #include "plat_isr.h" +#include "plat_class.h" LOG_MODULE_REGISTER(plat_isr); @@ -129,9 +130,18 @@ void ISR_MB_PCIE_RST() K_WORK_DEFINE(e1s_pwr_on_work, set_asic_and_e1s_clk_handler); -void ISR_E1S_PWR_ON() +void ISR_E1S_PWR_CHANGE() { - k_work_submit(&e1s_pwr_on_work); + if (gpio_get(POC_EN_P3V3_E1S_0_R) == GPIO_HIGH || gpio_get(EN_P3V3_E1S_0_R) == GPIO_HIGH || + gpio_get(EN_P12V_E1S_0_R) == GPIO_HIGH) { + k_work_submit(&e1s_pwr_on_work); + } + if (get_board_revision() == BOARD_POC) { + set_P3V3_E1S_power_status(POC_PWRGD_P3V3_E1S_0_R); + } else { + set_P3V3_E1S_power_status(PWRGD_P3V3_E1S_0_R); + } + set_P12V_E1S_power_status(PWRGD_P12V_E1S_0_R); } K_WORK_DEFINE(_set_cxl_led, set_cxl_led); diff --git a/meta-facebook/yv4-wf/src/platform/plat_isr.h b/meta-facebook/yv4-wf/src/platform/plat_isr.h index ed65b18877..8a5c923bc0 100644 --- a/meta-facebook/yv4-wf/src/platform/plat_isr.h +++ b/meta-facebook/yv4-wf/src/platform/plat_isr.h @@ -52,7 +52,7 @@ typedef struct { void ISR_MB_DC_STAGUS_CHAGNE(); void ISR_MB_PCIE_RST(); -void ISR_E1S_PWR_ON(); +void ISR_E1S_PWR_CHANGE(); void ISR_CXL_PG_ON(); void ISR_SET_CXL_LED(); diff --git a/meta-facebook/yv4-wf/src/platform/plat_pldm_sensor.c b/meta-facebook/yv4-wf/src/platform/plat_pldm_sensor.c index 7193b1c10e..026f3f7aa9 100644 --- a/meta-facebook/yv4-wf/src/platform/plat_pldm_sensor.c +++ b/meta-facebook/yv4-wf/src/platform/plat_pldm_sensor.c @@ -194,7 +194,7 @@ pldm_sensor_info plat_pldm_sensor_adc_table[] = { { .type = sensor_dev_ast_adc, .port = ADC_PORT11, - .access_checker = dc_access, + .access_checker = e1s_pwrgd_access, .sample_count = SAMPLE_COUNT_DEFAULT, .arg0 = 2, .arg1 = 1, @@ -1653,7 +1653,7 @@ pldm_sensor_info plat_pldm_sensor_tmp_table[] = { .port = I2C_BUS10, .target_addr = ADDR_NVME, .offset = OFFSET_NVME_TEMP, - .access_checker = dc_access, + .access_checker = e1s_pwrgd_access, .sample_count = SAMPLE_COUNT_DEFAULT, .cache = 0, .cache_status = PLDM_SENSOR_INITIALIZING, @@ -1809,7 +1809,7 @@ pldm_sensor_info plat_pldm_sensor_ina233_table[] = { .port = I2C_BUS6, .target_addr = ADDR_INA233_E1S, .offset = PMBUS_READ_VOUT, - .access_checker = dc_access, + .access_checker = e1s_pwrgd_access, .sample_count = SAMPLE_COUNT_DEFAULT, .cache = 0, .cache_status = PLDM_SENSOR_INITIALIZING, @@ -1963,7 +1963,7 @@ pldm_sensor_info plat_pldm_sensor_ina233_table[] = { .port = I2C_BUS6, .target_addr = ADDR_INA233_E1S, .offset = PMBUS_READ_IOUT, - .access_checker = stby_access, + .access_checker = e1s_pwrgd_access, .sample_count = SAMPLE_COUNT_DEFAULT, .cache = 0, .cache_status = PLDM_SENSOR_INITIALIZING, @@ -2117,7 +2117,7 @@ pldm_sensor_info plat_pldm_sensor_ina233_table[] = { .port = I2C_BUS6, .target_addr = ADDR_INA233_E1S, .offset = PMBUS_READ_POUT, - .access_checker = stby_access, + .access_checker = e1s_pwrgd_access, .sample_count = SAMPLE_COUNT_DEFAULT, .cache = 0, .cache_status = PLDM_SENSOR_INITIALIZING, diff --git a/meta-facebook/yv4-wf/src/platform/plat_power_seq.c b/meta-facebook/yv4-wf/src/platform/plat_power_seq.c index 610adce2fa..9989339a42 100644 --- a/meta-facebook/yv4-wf/src/platform/plat_power_seq.c +++ b/meta-facebook/yv4-wf/src/platform/plat_power_seq.c @@ -146,10 +146,13 @@ void execute_power_on_sequence() // TODO: check E1S present if (get_board_revision() == BOARD_POC) { gpio_set(POC_EN_P3V3_E1S_0_R, POWER_ON); + set_P3V3_E1S_power_status(POC_PWRGD_P3V3_E1S_0_R); } else { gpio_set(EN_P3V3_E1S_0_R, POWER_ON); + set_P3V3_E1S_power_status(PWRGD_P3V3_E1S_0_R); } gpio_set(EN_P12V_E1S_0_R, POWER_ON); + set_P12V_E1S_power_status(PWRGD_P12V_E1S_0_R); ret = power_on_handler(CXL_ID_1, ASIC_POWER_ON_STAGE_1); if (ret == 0) { @@ -377,10 +380,13 @@ void execute_power_off_sequence() // TODO: check E1S present if (get_board_revision() == BOARD_POC) { gpio_set(POC_EN_P3V3_E1S_0_R, POWER_OFF); + set_P3V3_E1S_power_status(POC_PWRGD_P3V3_E1S_0_R); } else { gpio_set(EN_P3V3_E1S_0_R, POWER_OFF); + set_P3V3_E1S_power_status(PWRGD_P3V3_E1S_0_R); } gpio_set(EN_P12V_E1S_0_R, POWER_OFF); + set_P12V_E1S_power_status(PWRGD_P12V_E1S_0_R); is_cxl_ready[CXL_ID_1] = false; is_cxl_ready[CXL_ID_2] = false;