Reorder power plane detection

This commit is contained in:
Jeremy Soller
2023-02-24 11:42:33 -07:00
parent 0d438a3314
commit 33eaef2dd0

View File

@ -119,38 +119,39 @@ extern uint8_t main_cycle;
enum PowerState power_state = POWER_STATE_OFF; enum PowerState power_state = POWER_STATE_OFF;
enum PowerState calculate_power_state(void) { enum PowerState calculate_power_state(void) {
if (!gpio_get(&EC_RSMRST_N)) {
// S5 plane not powered
return POWER_STATE_OFF;
}
#if CONFIG_BUS_ESPI #if CONFIG_BUS_ESPI
// Use eSPI virtual wires if available // Use eSPI virtual wires if available
if (vw_get(&VW_SLP_S3_N) == VWS_HIGH) { if (vw_get(&VW_SLP_S4_N) != VWS_HIGH) {
// S3, S4, and S5 planes powered // S4 plane not powered
return POWER_STATE_S0; return POWER_STATE_S5;
} }
if (vw_get(&VW_SLP_S4_N) == VWS_HIGH) { if (vw_get(&VW_SLP_S3_N) != VWS_HIGH) {
// S4 and S5 planes powered // S3 plane not powered
return POWER_STATE_S3; return POWER_STATE_S3;
} }
#else // CONFIG_BUS_ESPI #else // CONFIG_BUS_ESPI
// Use dedicated GPIOs if not using ESPI // Use dedicated GPIOs if not using ESPI
if (gpio_get(&SUSB_N_PCH)) { if (!gpio_get(&SUSC_N_PCH)) {
// S3, S4, and S5 planes powered // S4 plane not powered
return POWER_STATE_S0; return POWER_STATE_S5;
} }
if (gpio_get(&SUSC_N_PCH)) { if (!gpio_get(&SUSB_N_PCH)) {
// S4 and S5 planes powered // S3 plane not powered
return POWER_STATE_S3; return POWER_STATE_S3;
} }
#endif // CONFIG_BUS_ESPI #endif // CONFIG_BUS_ESPI
if (gpio_get(&EC_RSMRST_N)) { // All planes are powered
// S5 plane powered return POWER_STATE_S0;
return POWER_STATE_S5;
}
return POWER_STATE_OFF;
} }
void update_power_state(void) { void update_power_state(void) {