summaryrefslogtreecommitdiff
path: root/power
diff options
context:
space:
mode:
authorDaisuke Nojiri <dnojiri@chromium.org>2020-06-08 22:12:13 -0700
committerCommit Bot <commit-bot@chromium.org>2020-07-22 00:24:41 +0000
commit27ee378bb78a299a0983379be83eb6d55860b4ae (patch)
tree9e7aad7c30504ddc87a94101c035f6e8d1bd576c /power
parentd3ba44c0619ec84fc5a3615c4fa441ee44e0d645 (diff)
downloadchrome-ec-27ee378bb78a299a0983379be83eb6d55860b4ae.tar.gz
power: Clear AP_IDLE when waking up by PB or LID
Currently, AP_IDLE is cleared when EC wakes up by the power button or the lid open. This patch extends the logic from CONFIG_EXTPOWER_GPIO to CONFIG_EXTPOWER so that the bug (chromium:1073960) can be also fixed on the boards using non-GPIO method for extpower_is_present. Tested as follows on Trembyle: 1. Put DUT in hibernation. 2. Wake up DUT and observe: a. When waking up by power button, AP is turned on. b. When waking up by lid open, AP is turned on. c. When waking up by AC, AP is left idle. BUG=b:157077589, chromium:1073960, b:159350276 BRANCH=none TEST=See above. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: I944aaac036ce58659e81b7021e52a3291f31e951 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2283946 Reviewed-by: Jett Rink <jettrink@chromium.org>
Diffstat (limited to 'power')
-rw-r--r--power/common.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/power/common.c b/power/common.c
index 0cdabca0fa..6dc0ebc666 100644
--- a/power/common.c
+++ b/power/common.c
@@ -440,7 +440,13 @@ static enum power_state power_common_state(enum power_state state)
&target, now)) {
case CRITICAL_SHUTDOWN_HIBERNATE:
CPRINTS("Hibernate due to G3 idle");
- if (IS_ENABLED(CONFIG_EXTPOWER_GPIO) &&
+ /*
+ * Set AP_IDLE when hibernating so that AC plug
+ * won't boot the system. If EFS2 isn't enabled,
+ * we need to boot the AP to get PD power though
+ * it's inconsistent with the S5 behavior.
+ */
+ if (IS_ENABLED(CONFIG_EXTPOWER) &&
IS_ENABLED(CONFIG_VBOOT_EFS2)) {
uint32_t reset_flags;
reset_flags = chip_read_reset_flags() |
@@ -731,6 +737,23 @@ static void power_ac_change(void)
DECLARE_HOOK(HOOK_AC_CHANGE, power_ac_change, HOOK_PRIO_DEFAULT);
#endif
+#if defined(CONFIG_EXTPOWER) && defined(CONFIG_HIBERNATE) \
+ && defined(CONFIG_VBOOT_EFS2)
+static void power_init_ap_idle(void)
+{
+ if (extpower_is_present())
+ return;
+ /*
+ * EC doesn't hibernate from G3 when AC is present. Thus if AC is not
+ * present here, it implies we woke up by the power button or by the
+ * lid. Clear AP_IDLE to avoid interfering with the boot.
+ */
+ CPRINTS("Clear AP_IDLE, assuming wake-up by PB or LID");
+ system_clear_reset_flags(EC_RESET_FLAG_AP_IDLE);
+}
+DECLARE_HOOK(HOOK_INIT, power_init_ap_idle, HOOK_PRIO_INIT_EXTPOWER + 1);
+#endif
+
/*****************************************************************************/
/* Interrupts */