summaryrefslogtreecommitdiff
path: root/power
diff options
context:
space:
mode:
authorWai-Hong Tam <waihong@google.com>2020-09-02 12:32:50 -0700
committerCommit Bot <commit-bot@chromium.org>2020-09-03 05:14:13 +0000
commita72f9b006f2b66fe40b5e14e1bf258428de01558 (patch)
treeaef329d40ae18f71087f328d33b40c8fcb00d582 /power
parentb7b452bf0accd1fbfddb699b1ab74ffbc4625181 (diff)
downloadchrome-ec-a72f9b006f2b66fe40b5e14e1bf258428de01558.tar.gz
sc7180: Notify RESUME hooks in S3S0 if boot from off
After enabling the suspend hang detection, the RESUME hooks are deferred to S0. When the kernel sets the host sleep event to flag the resume completion, EC notifies the RESUME hooks. However, when it boots from an off state, G3 or S5, the kernel won't set this host sleep event. Should explicitly notify the RESUME hooks in the S3S0 state. The change also renames the flag boot_from_g3 to boot_from_off and carries it forward to S3S0; and renames the flag shutdown_from_s0 to shutdown_from_on and carries it forward to S3S5. BRANCH=None BUG=b:148149387, b:167155164 TEST=Verified the RESUME hooks are called when boot from S5. Change-Id: I48ee09ad66e53363e7a20d9602b37571177ac300 Signed-off-by: Wai-Hong Tam <waihong@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2391202 Reviewed-by: Stephen Boyd <swboyd@chromium.org>
Diffstat (limited to 'power')
-rw-r--r--power/sc7180.c47
1 files changed, 23 insertions, 24 deletions
diff --git a/power/sc7180.c b/power/sc7180.c
index c1585a47ff..f80703f740 100644
--- a/power/sc7180.c
+++ b/power/sc7180.c
@@ -915,13 +915,12 @@ __override void power_chipset_handle_host_sleep_event(
*/
enum power_state power_handle_state(enum power_state state)
{
- uint8_t value;
- static uint8_t boot_from_g3, shutdown_from_s0;
+ static uint8_t boot_from_off, shutdown_from_on;
switch (state) {
case POWER_G3:
- boot_from_g3 = check_for_power_on_event();
- if (boot_from_g3)
+ boot_from_off = check_for_power_on_event();
+ if (boot_from_off)
return POWER_G3S5;
break;
@@ -929,15 +928,11 @@ enum power_state power_handle_state(enum power_state state)
return POWER_S5;
case POWER_S5:
- if (boot_from_g3) {
- value = boot_from_g3;
- boot_from_g3 = 0;
- } else {
- value = check_for_power_on_event();
- }
+ if (!boot_from_off)
+ boot_from_off = check_for_power_on_event();
- if (value) {
- CPRINTS("power on %d", value);
+ if (boot_from_off) {
+ CPRINTS("power on %d", boot_from_off);
return POWER_S5S3;
}
break;
@@ -975,15 +970,11 @@ enum power_state power_handle_state(enum power_state state)
return POWER_S3;
case POWER_S3:
- if (shutdown_from_s0) {
- value = shutdown_from_s0;
- shutdown_from_s0 = 0;
- } else {
- value = check_for_power_off_event();
- }
+ if (!shutdown_from_on)
+ shutdown_from_on = check_for_power_off_event();
- if (value) {
- CPRINTS("power off %d", value);
+ if (shutdown_from_on) {
+ CPRINTS("power off %d", shutdown_from_on);
return POWER_S3S5;
}
@@ -1004,21 +995,27 @@ enum power_state power_handle_state(enum power_state state)
#ifdef CONFIG_CHIPSET_RESUME_INIT_HOOK
/*
* Notify the RESUME_INIT hooks, i.e. enabling SPI driver
- * to receive host commands/events. The normal RESUME hook
- * will be notified later, after receive a host resume event.
+ * to receive host commands/events.
+ *
+ * If boot from an off state, notify the RESUME hooks too;
+ * otherwise (resume from S3), the normal RESUME hooks will
+ * be notified later, after receive a host resume event.
*/
hook_notify(HOOK_CHIPSET_RESUME_INIT);
+ if (boot_from_off)
+ hook_notify(HOOK_CHIPSET_RESUME);
#else
hook_notify(HOOK_CHIPSET_RESUME);
#endif
sleep_resume_transition();
+ boot_from_off = 0;
disable_sleep(SLEEP_MASK_AP_RUN);
return POWER_S0;
case POWER_S0:
- shutdown_from_s0 = check_for_power_off_event();
- if (shutdown_from_s0) {
+ shutdown_from_on = check_for_power_off_event();
+ if (shutdown_from_on) {
return POWER_S0S3;
} else if (power_get_host_sleep_state()
== HOST_SLEEP_EVENT_S3_SUSPEND &&
@@ -1066,6 +1063,8 @@ enum power_state power_handle_state(enum power_state state)
/* Call hooks after we drop power rails */
hook_notify(HOOK_CHIPSET_SHUTDOWN_COMPLETE);
+ shutdown_from_on = 0;
+
/*
* Wait forever for the release of the power button; otherwise,
* this power button press will then trigger a power-on in S5.