diff options
author | Bill Richardson <wfrichar@chromium.org> | 2016-03-31 11:44:35 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2016-04-04 20:04:59 -0700 |
commit | 65d57259143277f779bf30c07320b6d33542f725 (patch) | |
tree | ef5dc56062197d79ec132231370ee9315a0be523 | |
parent | 79e45936fafe948a618b4e63f9c8ff8830c73bca (diff) | |
download | chrome-ec-65d57259143277f779bf30c07320b6d33542f725.tar.gz |
Cr50: Delay sleeping for longer after console input
Wait at least 10 seconds after the last console input before
invoking sleep or deep sleep.
BUG=chrome-os-partner:49955, chrome-os-partner:50721
BRANCH=none
TEST=make buildall; test on Cr50
Use the "idle d" console command to put the Cr50 into deep sleep
when idle (refer to previous commit messages for the setup
required).
Wake it up, then let it sleep again. It should go back to sleep
quickly when woken via USB, but should take much longer when
awakened by typing on the serial console.
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Change-Id: I7a2b840565f5d82e0dbdf8a3e75061a69cb9e405
Reviewed-on: https://chromium-review.googlesource.com/336835
Reviewed-by: Dominic Rizzo <domrizzo@google.com>
-rw-r--r-- | chip/g/idle.c | 26 |
1 files changed, 8 insertions, 18 deletions
diff --git a/chip/g/idle.c b/chip/g/idle.c index bea1063b83..3123bc14c7 100644 --- a/chip/g/idle.c +++ b/chip/g/idle.c @@ -10,11 +10,6 @@ #include "task.h" #include "util.h" -/* This function is assumed to exist, but we don't use it */ -void clock_refresh_console_in_use(void) -{ -} - /* What to do when we're just waiting */ static enum { IDLE_WFI, /* default */ @@ -123,10 +118,16 @@ void delay_sleep_by(uint32_t us) next_sleep_time = tmp; } +/* Wait a good long time after any console input, in case there's more. */ +void clock_refresh_console_in_use(void) +{ + delay_sleep_by(10 * SECOND); +} + /* Custom idle task, executed when no tasks are ready to be scheduled. */ void __idle(void) { - int sleep_ok, sleep_delay_passed, prev_ok = 0; + int sleep_ok, sleep_delay_passed; /* Preserved across soft reboots, but not hard */ idle_action = GREG32(PMU, PWRDN_SCRATCH17); @@ -138,18 +139,7 @@ void __idle(void) /* Anyone still busy? */ sleep_ok = DEEP_SLEEP_ALLOWED; - /* - * We'll always wait a little bit before sleeping no matter - * what. This is more likely to let any console output finish - * than calling clock_refresh_console_in_use(), because that - * function is called BEFORE waking the console task, not after - * it runs. We can't call cflush() here because that wakes a - * task to do it and so we're not idle any more. - */ - if (sleep_ok && !prev_ok) - delay_sleep_by(200 * MSEC); - - prev_ok = sleep_ok; + /* Wait a bit, just in case */ sleep_delay_passed = timestamp_expired(next_sleep_time, 0); /* If it hasn't yet been long enough, check again when it is */ |