From cc39b716fbfc35ef51fb558885b58bde42b312c4 Mon Sep 17 00:00:00 2001 From: Ting Shen Date: Tue, 29 Sep 2020 14:08:36 +0800 Subject: power/mt8192: don't boot AP when wake from AC insert Implement the wakeup behavior defined in our spec: AC insert -> wake EC Lid open / Power button -> wake EC + AP BUG=b:163963220 TEST=Verify boot behavior matches the spec BRANCH=none Signed-off-by: Ting Shen Change-Id: Ifc225c07d9a9faf25cf99578d535e63f63fc9bff Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2437238 Reviewed-by: Eric Yilun Lin Commit-Queue: Ting Shen Tested-by: Ting Shen --- power/mt8192.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/power/mt8192.c b/power/mt8192.c index 4c0ca97aa7..c1d545fc86 100644 --- a/power/mt8192.c +++ b/power/mt8192.c @@ -172,6 +172,8 @@ void chipset_reset(enum chipset_reset_reason reason) enum power_state power_chipset_init(void) { + int exit_hard_off = 1; + /* Enable reboot / sleep control inputs from AP */ gpio_enable_interrupt(GPIO_AP_EC_WARM_RST_REQ); gpio_enable_interrupt(GPIO_AP_IN_SLEEP_L); @@ -184,11 +186,17 @@ enum power_state power_chipset_init(void) return POWER_S0; } } else if (system_get_reset_flags() & EC_RESET_FLAG_AP_OFF) { - /* Force shutdown from S5 if the PMIC is already up. */ - if (power_get_signals() & IN_PGOOD_PMIC) { - forcing_shutdown = 1; - return POWER_S5; - } + exit_hard_off = 0; + } else if ((system_get_reset_flags() & EC_RESET_FLAG_HIBERNATE) && + gpio_get_level(GPIO_AC_PRESENT)) { + /* + * If AC present, assume this is a wake-up by AC insert. + * Boot EC only. + * + * Note that extpower module is not initialized at this point, + * the only way is to ask GPIO_AC_PRESENT directly. + */ + exit_hard_off = 0; } if (battery_is_present() == BP_YES) @@ -199,13 +207,17 @@ enum power_state power_chipset_init(void) */ battery_wait_for_stable(); - if (!(system_get_reset_flags() & EC_RESET_FLAG_AP_OFF)) + if (exit_hard_off) /* Auto-power on */ chipset_exit_hard_off(); /* Start from S5 if the PMIC is already up. */ - if (power_get_signals() & IN_PGOOD_PMIC) + if (power_get_signals() & IN_PGOOD_PMIC) { + /* Force shutdown from S5 if the PMIC is already up. */ + if (!exit_hard_off) + forcing_shutdown = 1; return POWER_S5; + } return POWER_G3; } -- cgit v1.2.1