From 79e45936fafe948a618b4e63f9c8ff8830c73bca Mon Sep 17 00:00:00 2001 From: Bill Richardson Date: Thu, 31 Mar 2016 11:30:00 -0700 Subject: [PATCH] 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 Reviewed-on: https://chromium-review.googlesource.com/336834 Reviewed-by: Vadim Bendebury --- chip/g/idle.c | 12 +++++++----- 1 file 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");