summaryrefslogtreecommitdiff
path: root/power
diff options
context:
space:
mode:
authorYH Huang <yh.huang@mediatek.com>2016-03-11 09:08:49 +0800
committerchrome-bot <chrome-bot@chromium.org>2016-03-16 06:43:25 -0700
commita595a9cff1607a2b7290482beb6570fc84fe9bdc (patch)
tree99da2f3b4d9df3fc997dd009762042b2b238dfe4 /power
parent74d2e46ea3d3a1c52cfd3802454c016e5812d7e7 (diff)
downloadchrome-ec-a595a9cff1607a2b7290482beb6570fc84fe9bdc.tar.gz
oak: make sure power button is stable when waiting for release
The debounce timer might be too slow to actually update the state of debounced_power_pressed by the time we do power_button_is_pressed in the S3->S5 state transition. Call power_button_wait_for_release() instead of wait_for_power_button_release() to make sure there are no deferred actions. BRANCH=none BUG=chrome-os-partner:50362, chrome-os-partner:51109 TEST=During dev mode screen, press power button, note the device stays off TEST=sudo test_that -b oak <DUT_IP> firmware_FwScreenPressPower Change-Id: Ic60c1847ba461ef874dea5bf7d03675622f24beb Signed-off-by: YH Huang <yh.huang@mediatek.com> Reviewed-on: https://chromium-review.googlesource.com/332310 Reviewed-by: Rong Chang <rongchang@chromium.org>
Diffstat (limited to 'power')
-rw-r--r--power/mediatek.c37
1 files changed, 4 insertions, 33 deletions
diff --git a/power/mediatek.c b/power/mediatek.c
index 97144b0e8e..82efb051ca 100644
--- a/power/mediatek.c
+++ b/power/mediatek.c
@@ -625,37 +625,6 @@ static void power_on(void)
CPRINTS("AP running ...");
}
-/**
- * Wait for the power button to be released
- *
- * @param timeout_us Timeout in microseconds, or -1 to wait forever
- * @return EC_SUCCESS if ok, or
- * EC_ERROR_TIMEOUT if power button failed to release
- */
-static int wait_for_power_button_release(unsigned int timeout_us)
-{
- timestamp_t deadline;
- timestamp_t now = get_time();
-
- deadline.val = now.val + timeout_us;
-
- while (power_button_is_pressed()) {
- now = get_time();
- if (timeout_us < 0) {
- task_wait_event(-1);
- } else if (timestamp_expired(deadline, &now) ||
- (task_wait_event(deadline.val - now.val) ==
- TASK_EVENT_TIMER)) {
- CPRINTS("power button not released in time");
- return EC_ERROR_TIMEOUT;
- }
- }
-
- CPRINTS("power button released");
- power_button_was_pressed = 0;
- return EC_SUCCESS;
-}
-
void chipset_reset(int is_cold)
{
if (is_cold) {
@@ -708,8 +677,9 @@ enum power_state power_handle_state(enum power_state state)
power_on();
if (power_wait_signals(IN_POWER_GOOD) == EC_SUCCESS) {
CPRINTS("POWER_GOOD seen");
- if (wait_for_power_button_release
+ if (power_button_wait_for_release
(DELAY_SHUTDOWN_ON_POWER_HOLD) == EC_SUCCESS) {
+ power_button_was_pressed = 0;
return POWER_S3;
} else {
CPRINTS("long-press button, shutdown");
@@ -772,7 +742,8 @@ enum power_state power_handle_state(enum power_state state)
return POWER_S3;
case POWER_S3S5:
- wait_for_power_button_release(-1);
+ power_button_wait_for_release(-1);
+ power_button_was_pressed = 0;
return POWER_S5;
case POWER_S5G3: