summaryrefslogtreecommitdiff
path: root/power
diff options
context:
space:
mode:
authorWai-Hong Tam <waihong@google.com>2018-11-07 16:38:33 -0800
committerchrome-bot <chrome-bot@chromium.org>2018-12-09 00:48:15 -0800
commit2acbffc2ba687e17f603d458bdef904eb5a8be97 (patch)
tree963f227af3944ac2eec6d10807126f94d8424892 /power
parent014ed9cdd9ebcea19de0873b764aa3f97b381983 (diff)
downloadchrome-ec-2acbffc2ba687e17f603d458bdef904eb5a8be97.tar.gz
cheza: Make apreset and apshutdown calls follow the state machine
The console command 'apreset' and 'apshutdown' now just set flags which trigger state transition in the power state machine. They no longer call the power-off sequence directly. So the hooks should be triggered properly. BRANCH=none BUG=b:119050865 TEST=Ran "apshutdown" and checked the state transition from S0 -> S5. TEST=Ran "apreset" and checked the state transition from S0 -> S5 -> S0. TEST=Call "dut-control warm_reset:on sleep:0.2 warm_reset:off" and checked the state transition from S0 -> S5 -> S0. Change-Id: Idb5af2021273d32ec7f718abf18e43c43b752c7e Signed-off-by: Wai-Hong Tam <waihong@google.com> Reviewed-on: https://chromium-review.googlesource.com/1325173 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Reviewed-by: Stephen Boyd <swboyd@chromium.org>
Diffstat (limited to 'power')
-rw-r--r--power/sdm845.c48
1 files changed, 24 insertions, 24 deletions
diff --git a/power/sdm845.c b/power/sdm845.c
index 64bafb81ed..42cc9843ae 100644
--- a/power/sdm845.c
+++ b/power/sdm845.c
@@ -92,14 +92,6 @@ static char lid_opened;
/* 1 if AP_RST_L and PS_HOLD is overdriven by EC */
static char ap_rst_overdriven;
-/*
- * 1 if power state is controlled by special functions, like a console command
- * or an interrupt handler, for bypassing POWER_GOOD lost trigger. It is
- * because these functions control the PMIC and AP power signals directly and
- * don't want to get preempted by the chipset state machine.
- */
-static uint8_t bypass_power_lost_trigger;
-
/* Time where we will power off, if power button still held down */
static timestamp_t power_off_deadline;
@@ -110,6 +102,7 @@ enum power_request_t {
POWER_REQ_NONE,
POWER_REQ_OFF,
POWER_REQ_ON,
+ POWER_REQ_RESET,
POWER_REQ_COUNT,
};
@@ -124,7 +117,8 @@ enum power_off_event_t {
POWER_OFF_BY_POWER_BUTTON_PRESSED,
POWER_OFF_BY_LONG_PRESS,
POWER_OFF_BY_POWER_GOOD_LOST,
- POWER_OFF_BY_POWER_REQ,
+ POWER_OFF_BY_POWER_REQ_OFF,
+ POWER_OFF_BY_POWER_REQ_RESET,
POWER_OFF_EVENT_COUNT,
};
@@ -138,7 +132,8 @@ enum power_on_event_t {
POWER_ON_BY_AUTO_POWER_ON,
POWER_ON_BY_LID_OPEN,
POWER_ON_BY_POWER_BUTTON_PRESSED,
- POWER_ON_BY_POWER_REQ_NONE,
+ POWER_ON_BY_POWER_REQ_ON,
+ POWER_ON_BY_POWER_REQ_RESET,
POWER_ON_EVENT_COUNT,
};
@@ -600,7 +595,12 @@ static uint8_t check_for_power_on_event(void)
if (power_request == POWER_REQ_ON) {
power_request = POWER_REQ_NONE;
- return POWER_ON_BY_POWER_REQ_NONE;
+ return POWER_ON_BY_POWER_REQ_ON;
+ }
+
+ if (power_request == POWER_REQ_RESET) {
+ power_request = POWER_REQ_NONE;
+ return POWER_ON_BY_POWER_REQ_RESET;
}
return POWER_OFF_CANCEL;
@@ -626,8 +626,13 @@ static uint8_t check_for_power_off_event(void)
pressed = POWER_OFF_BY_POWER_BUTTON_PRESSED;
} else if (power_request == POWER_REQ_OFF) {
power_request = POWER_REQ_NONE;
- /* return non-zero for shudown down */
- return POWER_OFF_BY_POWER_REQ;
+ return POWER_OFF_BY_POWER_REQ_OFF;
+ } else if (power_request == POWER_REQ_RESET) {
+ /*
+ * The power_request flag will be cleared later
+ * in check_for_power_on_event() in S5.
+ */
+ return POWER_OFF_BY_POWER_REQ_RESET;
}
now = get_time();
@@ -652,7 +657,7 @@ static uint8_t check_for_power_off_event(void)
power_button_was_pressed = pressed;
/* POWER_GOOD released by AP : shutdown immediately */
- if (!power_has_signals(IN_POWER_GOOD) && !bypass_power_lost_trigger) {
+ if (!power_has_signals(IN_POWER_GOOD)) {
if (power_button_was_pressed)
timer_cancel(TASK_ID_CHIPSET);
@@ -671,10 +676,9 @@ void chipset_force_shutdown(enum chipset_shutdown_reason reason)
CPRINTS("%s(%d)", __func__, reason);
report_ap_reset(reason);
- power_off();
-
- /* Clean-up internal variable */
- power_request = POWER_REQ_NONE;
+ /* Issue a request to initiate a power-off sequence */
+ power_request = POWER_REQ_OFF;
+ task_wake(TASK_ID_CHIPSET);
}
void chipset_reset(enum chipset_reset_reason reason)
@@ -686,12 +690,8 @@ void chipset_reset(enum chipset_reset_reason reason)
CPRINTS("%s(%d)", __func__, reason);
report_ap_reset(reason);
- bypass_power_lost_trigger = 1;
- power_off();
- bypass_power_lost_trigger = 0;
-
- /* Issue a request to initiate a power-on sequence */
- power_request = POWER_REQ_ON;
+ /* Issue a request to initiate a reset sequence */
+ power_request = POWER_REQ_RESET;
task_wake(TASK_ID_CHIPSET);
}