summaryrefslogtreecommitdiff
path: root/power
diff options
context:
space:
mode:
authorDiana Z <dzigterman@chromium.org>2021-04-09 11:24:30 -0600
committerCommit Bot <commit-bot@chromium.org>2021-04-10 00:20:48 +0000
commit4b2f4f2fc57d4ff65eb263bb8dd8169026411e68 (patch)
tree81ecff59e9010a22b1a9b320a7e36ad87503699d /power
parent823654dc07ef9cb0ae4fe0da1414fae4fb6f9ce5 (diff)
downloadchrome-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>
Diffstat (limited to 'power')
-rw-r--r--power/common.c44
1 files changed, 39 insertions, 5 deletions
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)
{