summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Zieba <robertzieba@google.com>2023-01-19 00:43:01 +0000
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2023-01-27 17:24:42 +0000
commit8ebdf9a0f15a0d95c60823c23b479f324d2607b5 (patch)
treec0ca5cad8b7460380dcc6fbd39de896e1a05ad84
parent309c2601586628bdda6c1ab3c644945a4959ce16 (diff)
downloadchrome-ec-8ebdf9a0f15a0d95c60823c23b479f324d2607b5.tar.gz
zephyr/app/ec/ec_app_main: Add support for disabling sleep from boot
Legacy EC code on some platforms disables sleep for the first 15 seconds following boot by default. Add the same functionality to zephyr. BRANCH=none BUG=b:249314949 TEST=Built and ran on skyrim device, verified sleep disabled Change-Id: I9c3f868d6d5a4d55d14b341bc1c4b304edd5be88 Signed-off-by: Robert Zieba <robertzieba@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4179368 Reviewed-by: Diana Z <dzigterman@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org>
-rw-r--r--zephyr/Kconfig12
-rw-r--r--zephyr/app/ec/ec_app_main.c18
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