diff options
author | Mary Ruthven <mruthven@chromium.org> | 2016-11-11 13:40:49 -0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2016-12-08 16:38:34 -0800 |
commit | 0175c4b812b9eefd1bf4ff02e0f2f24f0632b0b8 (patch) | |
tree | 9b7393ca26ac89118dd76cddbd0bdd91e67180bb | |
parent | b65e2a895a0622ed323033c9c710a4044b71e869 (diff) | |
download | chrome-ec-0175c4b812b9eefd1bf4ff02e0f2f24f0632b0b8.tar.gz |
g: change default idle behavior based on bus obfuscation availability
Set the default idle action based on whether bus obfuscation is enabled.
BUG=none
BRANCH=none
TEST=verify the idle default is sleep on b1 boards and wfi on b2.
Verify that both types of chips go to sleep and resume
successfully.
Change-Id: Ib5a11c4060aa411ff36c06c7fcadf0bf4c223bf1
Signed-off-by: Mary Ruthven <mruthven@chromium.org>
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/410167
-rw-r--r-- | chip/g/idle.c | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/chip/g/idle.c b/chip/g/idle.c index a4f4dc7db9..7755404252 100644 --- a/chip/g/idle.c +++ b/chip/g/idle.c @@ -7,6 +7,7 @@ #include "console.h" #include "hooks.h" #include "hwtimer.h" +#include "init_chip.h" #include "rdd.h" #include "registers.h" #include "system.h" @@ -14,6 +15,8 @@ #include "timer.h" #include "util.h" +#define CPRINTS(format, args...) cprints(CC_USB, format, ## args) + /* What to do when we're just waiting */ static enum { DONT_KNOW, @@ -23,13 +26,10 @@ static enum { NUM_CHOICES } idle_action; -/* - * TODO(crosbug.com/p/59641): Set the default action to sleep when the new - * boards come in. - */ -#define IDLE_DEFAULT IDLE_WFI #define EVENT_MIN 500 +static int idle_default; + static const char const *idle_name[] = { "invalid", "wfi", @@ -166,7 +166,7 @@ void clock_refresh_console_in_use(void) void disable_deep_sleep(void) { - idle_action = IDLE_DEFAULT; + idle_action = idle_default; } DECLARE_HOOK(HOOK_CHIPSET_RESUME, disable_deep_sleep, HOOK_PRIO_DEFAULT); @@ -176,6 +176,22 @@ void enable_deep_sleep(void) } DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN, enable_deep_sleep, HOOK_PRIO_DEFAULT); +static void idle_init(void) +{ + /* + * If bus obfuscation is enabled disable sleep. + */ + if ((GR_FUSE(OBFUSCATION_EN) == 5) || + (GR_FUSE(FW_DEFINED_BROM_APPLYSEC) & (1 << 3)) || + (runlevel_is_high() && GREAD(GLOBALSEC, OBFS_SW_EN))) { + CPRINTS("bus obfuscation enabled disabling sleep"); + idle_default = IDLE_WFI; + } else { + idle_default = IDLE_SLEEP; + } +} +DECLARE_HOOK(HOOK_INIT, idle_init, HOOK_PRIO_DEFAULT - 1); + /* Custom idle task, executed when no tasks are ready to be scheduled. */ void __idle(void) { @@ -190,7 +206,7 @@ void __idle(void) * this and set the idle_action. */ if (!idle_action) - idle_action = IDLE_DEFAULT; + idle_action = idle_default; /* Disable sleep until 3 minutes after init */ delay_sleep_by(3 * MINUTE); |