summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Yilun Lin <yllin@chromium.org>2020-12-17 17:17:09 +0800
committerCommit Bot <commit-bot@chromium.org>2020-12-22 11:25:31 +0000
commitfbf183f3109d07922fcec6e5a59efaf0788e1962 (patch)
treeda57fade2644c74f2163c3340c0945e3defda737
parenta1a14e23346fb1a42b69f14f05e7cb8debdf5dec (diff)
downloadchrome-ec-fbf183f3109d07922fcec6e5a59efaf0788e1962.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/+/2597121
-rw-r--r--power/mt8183.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/power/mt8183.c b/power/mt8183.c
index 1bbd06a05f..313116e5b3 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