summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/power.h4
-rw-r--r--power/host_sleep.c3
-rw-r--r--zephyr/test/drivers/power_host_sleep/src/test_power_host_sleep.c22
3 files changed, 28 insertions, 1 deletions
diff --git a/include/power.h b/include/power.h
index c32b2714e5..461e69748b 100644
--- a/include/power.h
+++ b/include/power.h
@@ -363,6 +363,10 @@ power_board_handle_sleep_hang(enum sleep_hang_type hang_type);
* power_chipset_handle_sleep_hang() and power_board_handle_sleep_hang() will
* be called when a sleep hang is detected.
*
+ * If called with a sleep_timeout_ms of EC_HOST_SLEEP_TIMEOUT_DEFAULT, the
+ * timeout will be picked based on CONFIG_SLEEP_TIMEOUT_MS or whatever is set as
+ * the default timeout by the sleeptimeout console command.
+ *
* @param ctx Possible sleep parameters and return values, depending on state.
*/
void sleep_start_suspend(struct host_sleep_event_context *ctx);
diff --git a/power/host_sleep.c b/power/host_sleep.c
index b6f0de498e..da7189083a 100644
--- a/power/host_sleep.c
+++ b/power/host_sleep.c
@@ -108,6 +108,7 @@ void sleep_notify_transition(int check_state, int hook_id)
#ifdef CONFIG_POWER_SLEEP_FAILURE_DETECTION
static uint16_t sleep_signal_timeout;
+/* Non-const because it may be set by sleeptimeout console cmd */
static uint16_t host_sleep_timeout_default = CONFIG_SLEEP_TIMEOUT_MS;
static uint32_t sleep_signal_transitions;
static enum sleep_hang_type timeout_hang_type;
@@ -175,7 +176,7 @@ void sleep_start_suspend(struct host_sleep_event_context *ctx)
sleep_signal_transitions = 0;
- /* Use zero internally to indicate no timeout. */
+ /* Use default to indicate no timeout given. */
if (timeout == EC_HOST_SLEEP_TIMEOUT_DEFAULT) {
timeout = host_sleep_timeout_default;
}
diff --git a/zephyr/test/drivers/power_host_sleep/src/test_power_host_sleep.c b/zephyr/test/drivers/power_host_sleep/src/test_power_host_sleep.c
index 47d9d3ed13..f1c3a2bcc9 100644
--- a/zephyr/test/drivers/power_host_sleep/src/test_power_host_sleep.c
+++ b/zephyr/test/drivers/power_host_sleep/src/test_power_host_sleep.c
@@ -178,5 +178,27 @@ ZTEST(power_host_sleep, test_sleep_start_suspend_custom_timeout)
SLEEP_HANG_S0IX_SUSPEND);
}
+ZTEST(power_host_sleep, test_sleep_start_suspend_default_timeout)
+{
+ struct host_sleep_event_context context = {
+ .sleep_timeout_ms = EC_HOST_SLEEP_TIMEOUT_DEFAULT,
+ };
+
+ sleep_start_suspend(&context);
+
+ /*
+ * TODO(b/253284635): Why can't we just wait CONFIG_SLEEP_TIMEOUT_MS?
+ */
+ k_msleep(CONFIG_SLEEP_TIMEOUT_MS * 2);
+
+ zassert_equal(power_chipset_handle_sleep_hang_fake.call_count, 1);
+ zassert_equal(power_board_handle_sleep_hang_fake.call_count, 1);
+
+ zassert_equal(power_chipset_handle_sleep_hang_fake.arg0_val,
+ SLEEP_HANG_S0IX_SUSPEND);
+ zassert_equal(power_board_handle_sleep_hang_fake.arg0_val,
+ SLEEP_HANG_S0IX_SUSPEND);
+}
+
ZTEST_SUITE(power_host_sleep, drivers_predicate_post_main, NULL,
power_host_sleep_before_after, power_host_sleep_before_after, NULL);