From 5a7600276d9f2a5eafb87a348f305e875f7e4382 Mon Sep 17 00:00:00 2001 From: Nicolas Boichat Date: Wed, 27 Feb 2019 07:48:33 +0800 Subject: power/mt8183: Detect AP-initiated PMIC shutdown and stay S5/G3 Without this change, EC would go to POWER_S5 state, and immediately go back to S3, which resets the system. BRANCH=none BUG=b:126295807 TEST=poweroff in AP console, systems goes to G3 (without requiring forced PMIC shutdown) and stays there Change-Id: Icbff7eb3962e26a6e2e9cb061f53665b9d94423b Signed-off-by: Nicolas Boichat Reviewed-on: https://chromium-review.googlesource.com/1490791 Reviewed-by: Yilun Lin --- power/mt8183.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'power') diff --git a/power/mt8183.c b/power/mt8183.c index fa9b31271c..9b823a0a8a 100644 --- a/power/mt8183.c +++ b/power/mt8183.c @@ -240,6 +240,12 @@ enum power_state power_handle_state(enum power_state state) /* Retry S5->S3 transition, if not zero. */ static int s5s3_retry; + /* + * PMIC power went away (AP most likely decided to shut down): + * transition to S5, G3. + */ + static int ap_shutdown; + switch (state) { case POWER_G3: /* Go back to S5->G3 if the PMIC unexpectedly starts again. */ @@ -248,7 +254,8 @@ enum power_state power_handle_state(enum power_state state) break; case POWER_S5: - if (forcing_shutdown) { + if (forcing_shutdown || ap_shutdown) { + ap_shutdown = 0; return POWER_S5G3; } else { s5s3_retry = 1; @@ -376,6 +383,10 @@ enum power_state power_handle_state(enum power_state state) return POWER_S3; case POWER_S3S5: + /* PMIC has shutdown, transition to G3. */ + if (!(power_get_signals() & IN_PGOOD_PMIC)) + ap_shutdown = 1; + /* Call hooks before we remove power rails */ hook_notify(HOOK_CHIPSET_SHUTDOWN); -- cgit v1.2.1