summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/config.h2
-rw-r--r--zephyr/Kconfig9
-rw-r--r--zephyr/Kconfig.watchdog15
-rw-r--r--zephyr/shim/include/config_chip.h26
-rw-r--r--zephyr/shim/src/watchdog.c9
5 files changed, 40 insertions, 21 deletions
diff --git a/include/config.h b/include/config.h
index 561e31ec55..aa3c67c534 100644
--- a/include/config.h
+++ b/include/config.h
@@ -5963,7 +5963,7 @@
* reloads of the watchdog timer should be less than half of the watchdog
* period.
*/
-#if !defined(CONFIG_ZEPHYR) && defined(CONFIG_WATCHDOG)
+#ifdef CONFIG_WATCHDOG
#if (CONFIG_AUX_TIMER_PERIOD_MS) < ((HOOK_TICK_INTERVAL_MS) * 2)
#error "CONFIG_AUX_TIMER_PERIOD_MS must be at least 2x HOOK_TICK_INTERVAL_MS"
#endif
diff --git a/zephyr/Kconfig b/zephyr/Kconfig
index 0b5f1dc100..e5b617d9c3 100644
--- a/zephyr/Kconfig
+++ b/zephyr/Kconfig
@@ -560,7 +560,7 @@ config PLATFORM_EC_VSTORE_SLOT_COUNT
checking on resume. For this, one slot is enough.
menuconfig PLATFORM_EC_WATCHDOG
- bool "watchdog"
+ bool "Watchdog"
depends on WATCHDOG
default y
help
@@ -569,4 +569,11 @@ menuconfig PLATFORM_EC_WATCHDOG
system) gets starved for CPU time and isn't able to fire its
HOOK_TICK event.
+ Chromium EC system uses an auxiliary timer to handle the system
+ warning event. This leaves some time to the system for preparing &
+ printing the debug information. The interval between reloads of the
+ watchdog timer should be less than half of the auxiliary timer
+ (PLATFORM_EC_WATCHDOG_PERIOD_MS -
+ PLATFORM_EC_WATCHDOG_WARNING_LEADING_TIME_MS).
+
endif # PLATFORM_EC
diff --git a/zephyr/Kconfig.watchdog b/zephyr/Kconfig.watchdog
index 57951b6f12..be87e4bce5 100644
--- a/zephyr/Kconfig.watchdog
+++ b/zephyr/Kconfig.watchdog
@@ -10,7 +10,18 @@ config PLATFORM_EC_WATCHDOG_PERIOD_MS
help
Set the timeout of the watchdog timer. The watchdog timer reboots
the system if no one reloads the watchdog timer before the timeout.
- The interval between reloads of the watchdog timer should be less than
- half of the watchdog period.
+
+config PLATFORM_EC_WATCHDOG_WARNING_LEADING_TIME_MS
+ int "Leading time of the watchdog warning timer in ms"
+ default 500
+ depends on !WDT_NPCX
+ help
+ Set the leading time of the watchdog warning timer. Chromium EC system
+ uses an auxiliary timer to handle the system warning event. The
+ auxiliary timer period (CONFIG_AUX_TIMER_PERIOD_MS) is set to
+ PLATFORM_EC_WATCHDOG_PERIOD_MS -
+ PLATFORM_EC_WATCHDOG_WARNING_LEADING_TIME_MS.
+
+ For the NPCX chip, use WDT_NPCX_DELAY_CYCLES instead of this config.
endif # PLATFORM_EC_WATCHDOG
diff --git a/zephyr/shim/include/config_chip.h b/zephyr/shim/include/config_chip.h
index d8ce653fe1..b6fcfd3517 100644
--- a/zephyr/shim/include/config_chip.h
+++ b/zephyr/shim/include/config_chip.h
@@ -58,13 +58,6 @@
/*
* ECOS specific options, not used in Zephyr.
*/
-
- /*
- * The Zephyr npcx watchdog driver provider a delay set by
- * CONFIG_WDT_NPCX_DELAY_CYCLES for displaying the warning message.
- * CONFIG_AUX_TIMER_PERIOD_MS isn't used by the Zephyr code.
- */
-#undef CONFIG_AUX_TIMER_PERIOD_MS
#undef CONFIG_CONSOLE_UART /* Only used by the Chromium EC chip drivers */
#undef CONFIG_I2C_MULTI_PORT_CONTROLLER /* Not required by I2C shim */
#undef CONFIG_IRQ_COUNT /* Only used by Chromium EC core drivers */
@@ -1326,14 +1319,23 @@
#undef CONFIG_WATCHDOG_PERIOD_MS
#ifdef CONFIG_PLATFORM_EC_WATCHDOG_PERIOD_MS
#define CONFIG_WATCHDOG_PERIOD_MS CONFIG_PLATFORM_EC_WATCHDOG_PERIOD_MS
+#endif
+
+#undef CONFIG_WATCHDOG_WARNING_LEADING_TIME_MS
+#if defined(CONFIG_PLATFORM_EC_WATCHDOG_WARNING_LEADING_TIME_MS) || \
+ defined(CONFIG_WDT_NPCX_DELAY_CYCLES)
/*
- * Chromium ec uses hook tick to reload the watchdog. Interval between reloads
- * of the watchdog timer should be less than half of the watchdog period.
+ * Note: NPCX wdt driver uses CONFIG_WDT_NPCX_DELAY_CYCLES to set the leading
+ * time of the watchdog warning timer.
*/
-#if (CONFIG_WATCHDOG_PERIOD_MS) < ((HOOK_TICK_INTERVAL_MS) * 2)
-#error "CONFIG_WATCHDOG_PERIOD_MS must be at least 2x HOOK_TICK_INTERVAL_MS"
+#ifdef CONFIG_WDT_NPCX_DELAY_CYCLES
+#define CONFIG_WATCHDOG_WARNING_LEADING_TIME_MS \
+ (CONFIG_WDT_NPCX_DELAY_CYCLES * 31)
+#else
+#define CONFIG_WATCHDOG_WARNING_LEADING_TIME_MS \
+ CONFIG_PLATFORM_EC_WATCHDOG_WARNING_LEADING_TIME_MS
+#endif
#endif
-#endif /* CONFIG_PLATFORM_EC_WATCHDOG_PERIOD_MS */
#undef CONFIG_VBOOT_EFS
#undef CONFIG_VBOOT_EFS2
diff --git a/zephyr/shim/src/watchdog.c b/zephyr/shim/src/watchdog.c
index 8487fd1d75..13d380bfcb 100644
--- a/zephyr/shim/src/watchdog.c
+++ b/zephyr/shim/src/watchdog.c
@@ -17,7 +17,7 @@ LOG_MODULE_REGISTER(watchdog_shim, LOG_LEVEL_ERR);
static void wdt_warning_handler(const struct device *wdt_dev, int channel_id)
{
/* TODO(b/176523207): watchdog warning message */
- LOG_INF("Watchdog is expired");
+ printk("Watchdog deadline is close!\n");
}
int watchdog_init(void)
@@ -36,12 +36,11 @@ int watchdog_init(void)
wdt_config.flags = WDT_FLAG_RESET_SOC;
/*
- * The Warning timer = CONFIG_WATCHDOG_PERIOD_MS.
- * The watchdog reset time
- * = CONFIG_WATCHDOG_PERIOD_MS + time of CONFIG_WDT_NPCX_DELAY_CYCLES
+ * Set the Warning timer as CONFIG_AUX_TIMER_PERIOD_MS.
+ * Then the watchdog reset time = CONFIG_WATCHDOG_PERIOD_MS.
*/
wdt_config.window.min = 0U;
- wdt_config.window.max = CONFIG_WATCHDOG_PERIOD_MS;
+ wdt_config.window.max = CONFIG_AUX_TIMER_PERIOD_MS;
wdt_config.callback = wdt_warning_handler;
err = wdt_install_timeout(wdt, &wdt_config);