summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/config.h1
-rw-r--r--power/common.c44
-rw-r--r--zephyr/Kconfig7
-rw-r--r--zephyr/shim/include/config_chip.h5
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