diff options
author | Wealian Liao <whliao@nuvoton.corp-partner.google.com> | 2021-09-06 15:40:50 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-09-13 16:35:33 +0000 |
commit | dabbc85c514a360250d1a49efd271b0465115bb0 (patch) | |
tree | ea01457c1e14c1470869d0dd0105c6a3fcca23ab /zephyr/shim | |
parent | 4a0368676c647d139226011796c7670b0981b9ed (diff) | |
download | chrome-ec-dabbc85c514a360250d1a49efd271b0465115bb0.tar.gz |
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 <whliao@nuvoton.corp-partner.google.com>
Change-Id: If221181358c2a4df758d5bb9b57c3fbba31100aa
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3143633
Reviewed-by: Keith Short <keithshort@chromium.org>
Commit-Queue: Keith Short <keithshort@chromium.org>
Diffstat (limited to 'zephyr/shim')
-rw-r--r-- | zephyr/shim/src/system.c | 21 |
1 files changed, 15 insertions, 6 deletions
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; } |