From e508ff8f31477e09317b72d1337236c55210b2b8 Mon Sep 17 00:00:00 2001 From: Peter Marheine Date: Wed, 1 Dec 2021 10:38:23 +1100 Subject: zephyr: use a chosen device for watchdog shim This uses a chosen cros-ec,watchdog DT node to locate the watchdog device to shim, rather than assuming it is called twd0. BUG=b:205615358 TEST=zmake buildall BRANCH=none Signed-off-by: Peter Marheine Change-Id: Id6e2dcc8d75740797d6630134c0d4413ac7338ee Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3312504 Reviewed-by: Keith Short --- zephyr/include/cros/ite/it8xxx2.dtsi | 1 + zephyr/include/cros/nuvoton/npcx.dtsi | 1 + zephyr/shim/src/watchdog.c | 7 ++----- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/zephyr/include/cros/ite/it8xxx2.dtsi b/zephyr/include/cros/ite/it8xxx2.dtsi index e6915be45d..1bd3dcfbf8 100644 --- a/zephyr/include/cros/ite/it8xxx2.dtsi +++ b/zephyr/include/cros/ite/it8xxx2.dtsi @@ -10,6 +10,7 @@ cros-ec,adc = &adc0; cros-ec,espi = &espi0; cros-ec,flash = &fiu0; + cros-ec,watchdog = &twd0; }; named-bbram-regions { diff --git a/zephyr/include/cros/nuvoton/npcx.dtsi b/zephyr/include/cros/nuvoton/npcx.dtsi index a749fca9e2..d4103a2bdc 100644 --- a/zephyr/include/cros/nuvoton/npcx.dtsi +++ b/zephyr/include/cros/nuvoton/npcx.dtsi @@ -14,6 +14,7 @@ cros-ec,adc = &adc0; cros-ec,espi = &espi0; cros-ec,flash = &fiu0; + cros-ec,watchdog = &twd0; }; named-bbram-regions { diff --git a/zephyr/shim/src/watchdog.c b/zephyr/shim/src/watchdog.c index 4c78ac9b0f..bf5568c596 100644 --- a/zephyr/shim/src/watchdog.c +++ b/zephyr/shim/src/watchdog.c @@ -14,6 +14,8 @@ LOG_MODULE_REGISTER(watchdog_shim, LOG_LEVEL_ERR); +#define wdt DEVICE_DT_GET(DT_CHOSEN(cros_ec_watchdog)) + static void wdt_warning_handler(const struct device *wdt_dev, int channel_id) { /* TODO(b/176523207): watchdog warning message */ @@ -23,10 +25,8 @@ static void wdt_warning_handler(const struct device *wdt_dev, int channel_id) int watchdog_init(void) { int err; - const struct device *wdt; struct wdt_timeout_cfg wdt_config; - wdt = DEVICE_DT_GET(DT_NODELABEL(twd0)); if (!device_is_ready(wdt)) { LOG_ERR("Error: device %s is not ready", wdt->name); return -1; @@ -67,9 +67,6 @@ int watchdog_init(void) void watchdog_reload(void) { - const struct device *wdt; - - wdt = DEVICE_DT_GET(DT_NODELABEL(twd0)); if (!device_is_ready(wdt)) LOG_ERR("Error: device %s is not ready", wdt->name); -- cgit v1.2.1