diff options
author | Eric Yilun Lin <yllin@chromium.org> | 2020-12-17 17:17:09 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-12-22 07:27:08 +0000 |
commit | a80ebff20a6ee09377f3a296ea17ebf05ec0f39d (patch) | |
tree | d7b1983174daf612133a73f69de55b540d60f827 | |
parent | 3f9e0a2ebb45d4b610ec770d0d2d3c6d455625c9 (diff) | |
download | chrome-ec-a80ebff20a6ee09377f3a296ea17ebf05ec0f39d.tar.gz |
kukui: do not boot AP if low-battery and no charger
BUG=b:134101454
TEST=#define CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON 96;
at batt 93%, no adapter, powerbtn, stay at G3
at batt 93%, with adapter, powerbtn, boot to S0
at batt 97^, without adapter, powerbtn, boot to S0
BRANCH=kukui
Change-Id: Ib0ee742ccd1f04aaa173a34455c1333853e0ce50
Signed-off-by: Eric Yilun Lin <yllin@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2597122
Commit-Queue: Ting Shen <phoenixshen@chromium.org>
Tested-by: Ting Shen <phoenixshen@chromium.org>
Reviewed-by: Ting Shen <phoenixshen@chromium.org>
-rw-r--r-- | power/mt8183.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/power/mt8183.c b/power/mt8183.c index c7647eb294..0acd2bc217 100644 --- a/power/mt8183.c +++ b/power/mt8183.c @@ -273,6 +273,7 @@ enum power_state power_handle_state(enum power_state state) * transition to S5, G3. */ static int ap_shutdown; + uint16_t tries = 0; switch (state) { case POWER_G3: @@ -359,6 +360,24 @@ enum power_state power_handle_state(enum power_state state) } #endif + /* + * Allow time for charger to be initialized, in case we're + * trying to boot the AP with no battery. + */ + while (charge_prevent_power_on(0) && + 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( + CHIPSET_SHUTDOWN_BATTERY_INHIBIT); + return POWER_G3; + } + #if CONFIG_CHIPSET_POWER_SEQ_VERSION == 1 hook_call_deferred(&deassert_en_pp1800_s5_l_data, -1); #endif |