summaryrefslogtreecommitdiff
path: root/power
diff options
context:
space:
mode:
authorWai-Hong Tam <waihong@google.com>2018-11-07 15:23:25 -0800
committerchrome-bot <chrome-bot@chromium.org>2018-12-06 22:06:39 -0800
commit0568b80369d39b9745099c143f168b941400a0b8 (patch)
tree09f9f5dcacdf05995d7c7439a6dcf80636682213 /power
parent011a5575405bcc1f6f41e82eb5a896265b019467 (diff)
downloadchrome-ec-0568b80369d39b9745099c143f168b941400a0b8.tar.gz
cheza: Execute the power-off sequence on S3S5
Move the power-off call from S0S3 to S3S5, such that the hooks are triggered in an expected order. The console command apreset and apshutdown still have some wrong orders. Will be fixed later. BRANCH=none BUG=b:119050865 TEST=Tried the following cases: * Cold reset: $ dut-control cold_reset:on sleep:0.2 cold_reset:off Result: S3 -> S5S3 -> S3 -> S3S0 -> S0 * Long power press to shutdown: $ dut-control pwr_button:press sleep:20 pwr_button:release Result: S0 8s-> S0S3 -> S3 -> S3S5 12s-> S5 10s-> S5G3 -> G3 * Long power press to power-on but then shutdown: $ dut-control pwr_button:press sleep:20 pwr_button:release Result: G3 -> G3S5 -> S5 -> S5S3 8s-> S3S5 12s-> S5 10s-> S5G3 --> G3 * Not-long power press to power-on: $ dut-control pwr_button:press sleep:5 pwr_button:release Result: G3 -> G3S5 -> S5 -> S5S3 5s-> S3 -> S3S0 -> S0 TEST=Verified the suspend and shutdown hooks are triggered properly. Change-Id: I6350d1535f1c6374eacc710c1b3f0c6e25027d1f Signed-off-by: Wai-Hong Tam <waihong@google.com> Reviewed-on: https://chromium-review.googlesource.com/1325172 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Reviewed-by: Philip Chen <philipchen@chromium.org>
Diffstat (limited to 'power')
-rw-r--r--power/sdm845.c40
1 files changed, 25 insertions, 15 deletions
diff --git a/power/sdm845.c b/power/sdm845.c
index dbca0c06a7..64bafb81ed 100644
--- a/power/sdm845.c
+++ b/power/sdm845.c
@@ -557,7 +557,7 @@ static void power_on(void)
*
* @return non-zero if there has been a power-on event, 0 if not.
*/
-static int check_for_power_on_event(void)
+static uint8_t check_for_power_on_event(void)
{
int ap_off_flag;
@@ -614,7 +614,7 @@ static int check_for_power_on_event(void)
*
* @return non-zero if a shutdown should happen, 0 if not
*/
-static int check_for_power_off_event(void)
+static uint8_t check_for_power_off_event(void)
{
timestamp_t now;
int pressed = 0;
@@ -703,8 +703,8 @@ void chipset_reset(enum chipset_reset_reason reason)
*/
enum power_state power_handle_state(enum power_state state)
{
- int value;
- static int boot_from_g3;
+ uint8_t value;
+ static uint8_t boot_from_g3, shutdown_from_s0;
switch (state) {
case POWER_G3:
@@ -745,21 +745,29 @@ enum power_state power_handle_state(enum power_state state)
return POWER_S3;
}
CPRINTS("long-press button, shutdown");
- power_off();
/*
- * Since the AP may be up already, return S0S3
- * state to go through the suspend hook.
+ * Since the AP may be up already, but the resume
+ * hook is not called, return S3S5 to power off
+ * AP and wait the release of the power button.
*/
- return POWER_S0S3;
+ return POWER_S3S5;
}
CPRINTS("POWER_GOOD not seen in time");
set_system_power(0);
return POWER_S5;
case POWER_S3:
- if (!(power_get_signals() & IN_POWER_GOOD))
- return POWER_S3S5;
+ if (shutdown_from_s0) {
+ value = shutdown_from_s0;
+ shutdown_from_s0 = 0;
+ } else {
+ value = check_for_power_off_event();
+ }
+ if (value) {
+ CPRINTS("power off %d", value);
+ return POWER_S3S5;
+ }
/* Go to S3S0 directly, as don't know if it is in suspend */
return POWER_S3S0;
@@ -768,12 +776,9 @@ enum power_state power_handle_state(enum power_state state)
return POWER_S0;
case POWER_S0:
- value = check_for_power_off_event();
- if (value) {
- CPRINTS("power off %d", value);
- power_off();
+ shutdown_from_s0 = check_for_power_off_event();
+ if (shutdown_from_s0)
return POWER_S0S3;
- }
break;
case POWER_S0S3:
@@ -789,6 +794,11 @@ enum power_state power_handle_state(enum power_state state)
return POWER_S3;
case POWER_S3S5:
+ power_off();
+ /*
+ * Wait forever for the release of the power button; otherwise,
+ * this power button press will then trigger a power-on in S5.
+ */
power_button_wait_for_release(-1);
power_button_was_pressed = 0;
return POWER_S5;