From dabbc85c514a360250d1a49efd271b0465115bb0 Mon Sep 17 00:00:00 2001 From: Wealian Liao Date: Mon, 6 Sep 2021 15:40:50 +0800 Subject: zephyr: Use NOP to wait for the external reset from H1 The current initial stage couldn't use the kernel delay function. Use CPU nop instruction to wait for the external reset from H1. BUG=b:182875520 BRANCH=none TEST=Enable CONFIG_BOARD_RESET_AFTER_POWER_ON for evb & toggle GPIO. Check the delay is 2 seconds. Signed-off-by: Wealian Liao Change-Id: If221181358c2a4df758d5bb9b57c3fbba31100aa Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3143633 Reviewed-by: Keith Short Commit-Queue: Keith Short --- zephyr/shim/src/system.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'zephyr/shim') diff --git a/zephyr/shim/src/system.c b/zephyr/shim/src/system.c index 2614a1fcb4..8db8ba437a 100644 --- a/zephyr/shim/src/system.c +++ b/zephyr/shim/src/system.c @@ -24,6 +24,11 @@ DT_PROP(DT_PATH(named_bbram_regions, node), offset) #define GET_BBRAM_SIZE(node) DT_PROP(DT_PATH(named_bbram_regions, node), size) +/* 2 second delay for waiting the H1 reset */ +#define WAIT_RESET_TIME \ + (CONFIG_PLATFORM_EC_PREINIT_HW_CYCLES_PER_SEC * 2 / \ + CONFIG_PLATFORM_EC_WAIT_RESET_CYCLES_PER_ITERATION) + LOG_MODULE_REGISTER(shim_system, LOG_LEVEL_ERR); STATIC_IF_NOT(CONFIG_ZTEST) const struct device *bbram_dev; @@ -355,13 +360,17 @@ static int system_preinitialize(const struct device *unused) * previous power-on, and treat the second reset as a power-on instead * of a reset. */ - if (IS_ENABLED(CONFIG_BOARD_RESET_AFTER_POWER_ON) && - system_get_reset_flags() & EC_RESET_FLAG_INITIAL_PWR) { - /* TODO(b/182875520): Change to use 2 second delay. */ - while (1) - continue; +#ifdef CONFIG_BOARD_RESET_AFTER_POWER_ON + if (system_get_reset_flags() & EC_RESET_FLAG_INITIAL_PWR) { + /* + * The current initial stage couldn't use the kernel delay + * function. Use CPU nop instruction to wait for the external + * reset from H1. + */ + for (uint32_t i = WAIT_RESET_TIME; i; i--) + arch_nop(); } - +#endif return 0; } -- cgit v1.2.1