From 27c170587fdcc368f461f87fbc7d62d3d738fa12 Mon Sep 17 00:00:00 2001 From: Wai-Hong Tam Date: Thu, 12 Nov 2020 17:02:48 -0800 Subject: sc7180: Fix forever loop if not enough power to boot AP When the power supply is not enough (<10W adapter and no battery) to boot AP, should clear the boot_from_off flag and go back to S5; otherwise, the boot_from_off flag will trigger the power-on again. Also do the same on power_on() sequence failed. Increase the delay of checking power, such that the messages are not too noisy. BRANCH=None BUG=b:167155164 TEST=Unplugged the battery, plugged a <10W adapter, checked the "Not enough power to boot (-1 %, 7500 mW)" message just showed 10x. Change-Id: Id7c5e66dab62bc71d3e2e00b3be172e13a146ed5 Signed-off-by: Wai-Hong Tam Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2536554 Reviewed-by: Stephen Boyd --- power/sc7180.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/power/sc7180.c b/power/sc7180.c index 08612d1f55..58e859c307 100644 --- a/power/sc7180.c +++ b/power/sc7180.c @@ -77,7 +77,7 @@ #define CAN_BOOT_AP_CHECK_TIMEOUT (1500 * MSEC) /* Wait for polling if the system can boot AP */ -#define CAN_BOOT_AP_CHECK_WAIT (100 * MSEC) +#define CAN_BOOT_AP_CHECK_WAIT (200 * MSEC) /* The timeout of the check if the switchcap outputs good voltage */ #define SWITCHCAP_PG_CHECK_TIMEOUT (50 * MSEC) @@ -945,14 +945,17 @@ enum power_state power_handle_state(enum power_state state) power_button_wait_for_release(-1); /* If no enough power, return back to S5. */ - if (!power_is_enough()) + if (!power_is_enough()) { + boot_from_off = 0; return POWER_S5; + } /* Initialize components to ready state before AP is up. */ hook_notify(HOOK_CHIPSET_PRE_INIT); if (power_on() != EC_SUCCESS) { power_off(); + boot_from_off = 0; return POWER_S5; } CPRINTS("AP running ..."); -- cgit v1.2.1