diff options
author | Diana Z <dzigterman@chromium.org> | 2021-04-09 11:24:30 -0600 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-04-10 00:20:48 +0000 |
commit | 4b2f4f2fc57d4ff65eb263bb8dd8169026411e68 (patch) | |
tree | 81ecff59e9010a22b1a9b320a7e36ad87503699d | |
parent | 823654dc07ef9cb0ae4fe0da1414fae4fb6f9ce5 (diff) | |
download | chrome-ec-4b2f4f2fc57d4ff65eb263bb8dd8169026411e68.tar.gz |
Power: Add configurable S5 timeout
Similar to the hibdelay command, allow the time we spend in S5 to be
configurable for the sake of power testing in this state. It may be set
to 0 for an immediate drop, or -1 to stay in S5 forever.
BRANCH=None
BUG=b:184941436
TEST=make -j buildall
Signed-off-by: Diana Z <dzigterman@chromium.org>
Change-Id: If2f8cf91ba982822e2e33cb17f84f38c40907d2e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2818526
Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
-rw-r--r-- | include/config.h | 1 | ||||
-rw-r--r-- | power/common.c | 44 | ||||
-rw-r--r-- | zephyr/Kconfig | 7 | ||||
-rw-r--r-- | zephyr/shim/include/config_chip.h | 5 |
4 files changed, 52 insertions, 5 deletions
diff --git a/include/config.h b/include/config.h index 283d8ff7fb..a001e263b3 100644 --- a/include/config.h +++ b/include/config.h @@ -1411,6 +1411,7 @@ #undef CONFIG_CMD_RTC #undef CONFIG_CMD_RTC_ALARM #define CONFIG_CMD_RW +#undef CONFIG_CMD_S5_TIMEOUT #undef CONFIG_CMD_SCRATCHPAD #undef CONFIG_CMD_SEVEN_SEG_DISPLAY #define CONFIG_CMD_SHMEM diff --git a/power/common.c b/power/common.c index df4dce7827..e4f4027ade 100644 --- a/power/common.c +++ b/power/common.c @@ -36,8 +36,12 @@ */ #define DEFAULT_TIMEOUT SECOND -/* Timeout for dropping back from S5 to G3 */ -#define S5_INACTIVITY_TIMEOUT (10 * SECOND) +/* Timeout for dropping back from S5 to G3 in seconds */ +#ifdef CONFIG_CMD_S5_TIMEOUT +static int s5_inactivity_timeout = 10; +#else +static const int s5_inactivity_timeout = 10; +#endif static const char * const state_names[] = { "G3", @@ -503,10 +507,15 @@ static enum power_state power_common_state(enum power_state state) */ want_g3_exit = 0; - /* Wait for inactivity timeout */ power_wait_signals(0); - if (task_wait_event(S5_INACTIVITY_TIMEOUT) == - TASK_EVENT_TIMER) { + + /* Wait for inactivity timeout, if desired */ + if (s5_inactivity_timeout == 0) { + return POWER_S5G3; + } else if (s5_inactivity_timeout < 0) { + task_wait_event(-1); + } else if (task_wait_event(s5_inactivity_timeout * SECOND) == + TASK_EVENT_TIMER) { /* Prepare to drop to G3; wake not requested yet */ return POWER_S5G3; } @@ -930,6 +939,31 @@ DECLARE_CONSOLE_COMMAND(powerindebug, command_powerindebug, "Get/set power input debug mask"); #endif +#ifdef CONFIG_CMD_S5_TIMEOUT +/* Allow command-line access to configure our S5 delay for power testing */ +static int command_s5_timeout(int argc, char **argv) +{ + char *e; + + if (argc >= 2) { + uint32_t s = strtoi(argv[1], &e, 0); + + if (*e) + return EC_ERROR_PARAM1; + + s5_inactivity_timeout = s; + } + + /* Print the current setting */ + ccprintf("S5 inactivity timeout: %d s\n", s5_inactivity_timeout); + return EC_SUCCESS; +} +DECLARE_CONSOLE_COMMAND(s5_timeout, command_s5_timeout, + "[sec]", + "Set the timeout from S5 to G3 transition, " + "-1 to indicate no transition"); +#endif + #ifdef CONFIG_HIBERNATE static int command_hibernation_delay(int argc, char **argv) { diff --git a/zephyr/Kconfig b/zephyr/Kconfig index b0937203ab..0b5f1dc100 100644 --- a/zephyr/Kconfig +++ b/zephyr/Kconfig @@ -206,6 +206,13 @@ config PLATFORM_EC_CONSOLE_CMD_MEM md - dump memory values rw - read or write in memory +config PLATFORM_EC_CONSOLE_CMD_S5_TIMEOUT + bool "Console command: s5_timeout" + default n + help + This command allows the user to specify a time to remain in S5 before + dropping to G3, in order to help power testing. + config PLATFORM_EC_CONSOLE_CMD_SHMEM bool "Console command: shmem" default y diff --git a/zephyr/shim/include/config_chip.h b/zephyr/shim/include/config_chip.h index 1a02395459..c3e675b008 100644 --- a/zephyr/shim/include/config_chip.h +++ b/zephyr/shim/include/config_chip.h @@ -532,6 +532,11 @@ #define CONFIG_PWM #endif +#undef CONFIG_CMD_S5_TIMEOUT +#ifdef CONFIG_PLATFORM_EC_CONSOLE_CMD_S5_TIMEOUT +#define CONFIG_CMD_S5_TIMEOUT +#endif + #undef CONFIG_CMD_SHMEM #ifdef CONFIG_PLATFORM_EC_CONSOLE_CMD_SHMEM #define CONFIG_CMD_SHMEM |