diff options
-rw-r--r-- | zephyr/Kconfig | 12 | ||||
-rw-r--r-- | zephyr/app/ec/ec_app_main.c | 18 |
2 files changed, 30 insertions, 0 deletions
diff --git a/zephyr/Kconfig b/zephyr/Kconfig index 597e6ee250..38e2efe751 100644 --- a/zephyr/Kconfig +++ b/zephyr/Kconfig @@ -137,6 +137,18 @@ config PLATFORM_EC_BOARD_RESET_AFTER_POWER_ON the EC starts up, performs some amount of processing and then gets a reset that it is not expecting. +config PLATFORM_EC_BOOT_NO_SLEEP + bool "Disable deep sleep after boot" + default y if !ZTEST + help + Disable deep sleep for PLATFORM_EC_BOOT_NO_SLEEP_MS after boot. + +config PLATFORM_EC_BOOT_NO_SLEEP_MS + int "No deep sleep after boot duration" + default 15000 + help + Duration for PLATFORM_EC_BOOT_NO_SLEEP in ms. + config PLATFORM_EC_WAIT_RESET_CYCLES_PER_ITERATION int "CPU execution cycle per iteration for waiting the H1 reset" default 4 diff --git a/zephyr/app/ec/ec_app_main.c b/zephyr/app/ec/ec_app_main.c index 961e4f5ce2..d2dad10b2d 100644 --- a/zephyr/app/ec/ec_app_main.c +++ b/zephyr/app/ec/ec_app_main.c @@ -18,9 +18,15 @@ #include "zephyr_espi_shim.h" #include <zephyr/kernel.h> +#include <zephyr/pm/policy.h> #include <zephyr/shell/shell_uart.h> #include <zephyr/sys/printk.h> +static void console_allow_sleep(struct k_timer *timer) +{ + pm_policy_state_lock_put(PM_STATE_SUSPEND_TO_IDLE, PM_ALL_SUBSTATES); +} + /* For testing purposes this is not named main. See main_shim.c for the real * main() function. */ @@ -42,6 +48,18 @@ void ec_app_main(void) watchdog_init(); } + if (IS_ENABLED(CONFIG_PLATFORM_EC_BOOT_NO_SLEEP)) { + struct k_timer timer; + k_timeout_t duration = + K_MSEC(CONFIG_PLATFORM_EC_BOOT_NO_SLEEP_MS); + + k_timer_init(&timer, console_allow_sleep, NULL); + k_timer_start(&timer, duration, K_NO_WAIT); + + pm_policy_state_lock_get(PM_STATE_SUSPEND_TO_IDLE, + PM_ALL_SUBSTATES); + } + /* * Keyboard scan init/Button init can set recovery events to * indicate to host entry into recovery mode. Before this is |