Skip to content

Commit

Permalink
fby4: wf: Adjust the E1S-related GPIO settings and sensors access time
Browse files Browse the repository at this point in the history
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
  • Loading branch information
SeanHe-wiwynn committed Oct 29, 2024
1 parent d0ae72b commit 120ff7d
Show file tree
Hide file tree
Showing 10 changed files with 65 additions and 13 deletions.
25 changes: 25 additions & 0 deletions common/lib/power_status.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;
}

4 changes: 4 additions & 0 deletions common/lib/power_status.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 5 additions & 0 deletions common/service/sensor/sensor.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions common/service/sensor/sensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion meta-facebook/yv4-wf/boards/ast1030_evb.overlay
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@
};

&gpio0_e_h {
aspeed,persist-maps = <0x0555505D>;
aspeed,persist-maps = <0x0555555D>;
};

&gpio0_i_l {
Expand Down
9 changes: 5 additions & 4 deletions meta-facebook/yv4-wf/src/platform/plat_gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down Expand Up @@ -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";
}

Expand Down Expand Up @@ -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) &&
Expand Down
14 changes: 12 additions & 2 deletions meta-facebook/yv4-wf/src/platform/plat_isr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion meta-facebook/yv4-wf/src/platform/plat_isr.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
10 changes: 5 additions & 5 deletions meta-facebook/yv4-wf/src/platform/plat_pldm_sensor.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 6 additions & 0 deletions meta-facebook/yv4-wf/src/platform/plat_power_seq.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 120ff7d

Please sign in to comment.