summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Boichat <drinkcat@chromium.org>2019-06-14 13:44:24 +0800
committerCommit Bot <commit-bot@chromium.org>2019-06-24 06:51:34 +0000
commit1722849223efae4aaf87d2476a7ad07d2c7bd8c5 (patch)
treea070c03b6372d234dac6e245c099dd04637bd88a
parentb2c271b54eb87795d21b71c0c6784c89d9e26346 (diff)
downloadchrome-ec-1722849223efae4aaf87d2476a7ad07d2c7bd8c5.tar.gz
power/mt8183: Hold PMIC enable to force S5->G3 transition.
Asserting VSYSSNS should only be done as a last measure. If the PMIC is configured properly, it will shut down upon holding POWER+HOME key for 8+ seconds. This is shorter than the S5->G3 timeout, so we should never need to assert VSYSSNS. BRANCH=none BUG=b:134912821 TEST=reboot ap-off, immediately powerb, see that AP turns on and stays on. TEST=apshutdown, PMIC shuts off gracefully TEST=In power/common.c, change S5_INACTIVITY_TIMEOUT to 3 seconds, see that state machines forces PMIC off using VSYSSNS. TEST=Boot DUT: mosys eventlog clear; poweroff power on DUT, run dut-control power_state:off Wait 8 seconds for EC to go to G3, power on DUT again mosys eventlog list shows events with correct time stamps: 0 | 2019-06-14 15:44:31 | Log area cleared | 79 1 | 2019-06-14 15:44:38 | System boot | 0 2 | 2019-06-14 15:44:38 | Chrome OS Developer Mode 3 | 2019-06-14 15:45:13 | System boot | 0 4 | 2019-06-14 15:45:13 | Chrome OS Developer Mode Change-Id: I9b73d06e07296e47e15fe87dd87fffac2af04d12 Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1660073 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
-rw-r--r--power/mt8183.c34
1 files changed, 31 insertions, 3 deletions
diff --git a/power/mt8183.c b/power/mt8183.c
index e005cb0288..0be256cb89 100644
--- a/power/mt8183.c
+++ b/power/mt8183.c
@@ -254,7 +254,23 @@ enum power_state power_handle_state(enum power_state state)
return POWER_S5S3;
}
- /* Stay in S5, common code will drop to G3 after timeout. */
+ /* Forcing shutdown */
+
+ /* Long press has worked, transition to G3. */
+ if (!(power_get_signals() & IN_PGOOD_PMIC))
+ return POWER_S5G3;
+
+ /*
+ * Try to force PMIC shutdown with a long press. This takes 8s,
+ * shorter than the common code S5->G3 timeout (10s).
+ */
+ CPRINTS("Forcing shutdown with long press.");
+ gpio_set_level(GPIO_PMIC_EN_ODL, 0);
+
+ /*
+ * Stay in S5, common code will drop to G3 after timeout
+ * if the long press does not work.
+ */
return POWER_S5;
case POWER_S3:
@@ -282,8 +298,15 @@ enum power_state power_handle_state(enum power_state state)
return POWER_S5;
case POWER_S5S3:
+ /*
+ * Release power button in case it was pressed by force shutdown
+ * sequence.
+ */
+ gpio_set_level(GPIO_PMIC_EN_ODL, 1);
+
/* If PMIC is off, switch it on by pulsing PMIC enable. */
if (!(power_get_signals() & IN_PGOOD_PMIC)) {
+ msleep(PMIC_EN_PULSE_MS);
gpio_set_level(GPIO_PMIC_EN_ODL, 0);
msleep(PMIC_EN_PULSE_MS);
gpio_set_level(GPIO_PMIC_EN_ODL, 1);
@@ -391,11 +414,16 @@ enum power_state power_handle_state(enum power_state state)
return POWER_S5;
case POWER_S5G3:
+ /* Release the power button, in case it was long pressed. */
+ if (forcing_shutdown)
+ gpio_set_level(GPIO_PMIC_EN_ODL, 1);
+
/*
* If PMIC is still not off, assert PMIC_FORCE_RESET_ODL.
* This should only happen for forced shutdown where the AP is
- * not able to send a command to the PMIC. Also, PMIC will lose
- * RTC state, in that case.
+ * not able to send a command to the PMIC, and where the long
+ * power+home press did not work (if the PMIC is misconfigured).
+ * Also, PMIC will lose RTC state, in that case.
*/
if (power_get_signals() & IN_PGOOD_PMIC) {
CPRINTS("Forcing PMIC off");