summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBill Richardson <wfrichar@chromium.org>2016-03-31 11:30:00 -0700
committerchrome-bot <chrome-bot@chromium.org>2016-04-04 20:04:58 -0700
commit79e45936fafe948a618b4e63f9c8ff8830c73bca (patch)
tree629a08a607568f5c64ebf4f1fcec7d099c77cd19
parentbf24d5b26421aff81a8ea032f16e65df10a842dc (diff)
downloadchrome-ec-79e45936fafe948a618b4e63f9c8ff8830c73bca.tar.gz
Cr50: Preserve the idle action across soft reboots
This preserves the selected idle action (wfi, sleep, deep sleep) across soft reboots, which includes deep sleep. Hard reboots will restore the default which is to not sleep at all. 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 the deep sleep state. Change-Id: Iaad82b725d2b32a19205fa403dbaab9a31c35630 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/336834 Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
-rw-r--r--chip/g/idle.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/chip/g/idle.c b/chip/g/idle.c
index a141b80630..bea1063b83 100644
--- a/chip/g/idle.c
+++ b/chip/g/idle.c
@@ -63,6 +63,8 @@ static void prepare_to_deep_sleep(void)
* resume.
*/
GREG32(PMU, PWRDN_SCRATCH18) = GR_USB_DCFG;
+ /* And the idle action */
+ GREG32(PMU, PWRDN_SCRATCH17) = idle_action;
/* Latch the pinmux values */
GREG32(PINMUX, HOLD) = 1;
@@ -126,11 +128,12 @@ void __idle(void)
{
int sleep_ok, sleep_delay_passed, prev_ok = 0;
- while (1) {
+ /* Preserved across soft reboots, but not hard */
+ idle_action = GREG32(PMU, PWRDN_SCRATCH17);
+ if (idle_action >= NUM_CHOICES)
+ idle_action = IDLE_WFI;
- /* Don't even bother unless we've enabled it */
- if (idle_action == IDLE_WFI)
- goto wfi;
+ while (1) {
/* Anyone still busy? */
sleep_ok = DEEP_SLEEP_ALLOWED;
@@ -159,7 +162,6 @@ void __idle(void)
prepare_to_deep_sleep();
/* Normal sleep is not yet implemented */
-wfi:
/* Wait for the next irq event. This stops the CPU clock and
* may trigger sleep or deep sleep if enabled. */
asm("wfi");