diff options
Diffstat (limited to 'power')
-rw-r--r-- | power/skylake.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/power/skylake.c b/power/skylake.c index 88c7b5ddae..b30961e689 100644 --- a/power/skylake.c +++ b/power/skylake.c @@ -5,6 +5,7 @@ /* Skylake IMVP8 / ROP PMIC chipset power control module for Chrome EC */ +#include "charge_state.h" #include "chipset.h" #include "common.h" #include "console.h" @@ -38,6 +39,9 @@ #define IN_ALL_S0 (IN_PGOOD_ALL_CORE | IN_ALL_PM_SLP_DEASSERTED) +#define CHARGER_INITIALIZED_DELAY_MS 100 +#define CHARGER_INITIALIZED_TRIES 10 + static int throttle_cpu; /* Throttle CPU? */ static int forcing_shutdown; /* Forced shutdown in progress? */ @@ -128,6 +132,9 @@ enum power_state power_handle_state(enum power_state state) */ int rsmrst_in = gpio_get_level(GPIO_RSMRST_L_PGOOD); int rsmrst_out = gpio_get_level(GPIO_PCH_RSMRST_L); +#ifdef GLADOS_BOARD_V2 + int tries = 0; +#endif if (rsmrst_in != rsmrst_out) { /* @@ -187,6 +194,23 @@ enum power_state power_handle_state(enum power_state state) } #ifdef GLADOS_BOARD_V2 + /* + * Allow up to 1s for charger to be initialized, in case + * we're trying to boot the AP with no battery. + */ + while (charge_prevent_power_on() && + tries++ < CHARGER_INITIALIZED_TRIES) { + msleep(CHARGER_INITIALIZED_DELAY_MS); + } + + /* Return to G3 if battery level is too low */ + if (charge_want_shutdown() || + tries == CHARGER_INITIALIZED_TRIES) { + CPRINTS("power-up inhibited"); + chipset_force_shutdown(); + return POWER_G3; + } + /* Allow AP to power on */ gpio_set_level(GPIO_PMIC_SLP_SUS_L, 1); gpio_set_level(GPIO_PCH_BATLOW_L, 1); |