From 1de7602c7d7dba80933372494499219a8a85c85a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=AD=20Bol=C3=ADvar?= Date: Thu, 16 Apr 2020 14:16:11 -0700 Subject: [PATCH] tests: wdt_basic_api: devicetree updates MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move to the new devicetree API and stop using DT_WDT_0_NAME fixup macros. All existing in-tree SoCs with fixup names are still supported here via compatible. The watchdog0 alias is also still supported. Signed-off-by: Martí Bolívar --- .../watchdog/wdt_basic_api/src/test_wdt.c | 34 +++++++++++++++---- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/tests/drivers/watchdog/wdt_basic_api/src/test_wdt.c b/tests/drivers/watchdog/wdt_basic_api/src/test_wdt.c index 4c68650ef1d..c8b6620d069 100644 --- a/tests/drivers/watchdog/wdt_basic_api/src/test_wdt.c +++ b/tests/drivers/watchdog/wdt_basic_api/src/test_wdt.c @@ -62,14 +62,34 @@ #include #include "test_wdt.h" -#ifdef DT_ALIAS_WATCHDOG0_LABEL -#define WDT_DEV_NAME DT_ALIAS_WATCHDOG0_LABEL -#else -#ifdef CONFIG_WWDG_STM32 -#define WDT_DEV_NAME DT_LABEL(DT_INST(0, st_stm32_window_watchdog)) -#else -#define WDT_DEV_NAME DT_WDT_0_NAME +/* + * To use this test, either the devicetree's /aliases must have a + * 'watchdog0' property, or one of the following watchdog compatibles + * must have an enabled node. + */ +#if DT_HAS_NODE(DT_ALIAS(watchdog0)) +#define WDT_NODE DT_ALIAS(watchdog0) +#elif DT_HAS_COMPAT(st_stm32_window_watchdog) +#define WDT_NODE DT_INST(0, st_stm32_window_watchdog) +#elif DT_HAS_COMPAT(st_stm32_watchdog) +#define WDT_NODE DT_INST(0, st_stm32_watchdog) +#elif DT_HAS_COMPAT(nordic_nrf_watchdog) +#define WDT_NODE DT_INST(0, nordic_nrf_watchdog) +#elif DT_HAS_COMPAT(espressif_esp32_watchdog) +#define WDT_NODE DT_INST(0, espressif_esp32_watchdog) +#elif DT_HAS_COMPAT(silabs_gecko_wdog) +#define WDT_NODE DT_INST(0, silabs_gecko_wdog) +#elif DT_HAS_COMPAT(nxp_kinetis_wdog32) +#define WDT_NODE DT_INST(0, nxp_kinetis_wdog32) +#elif DT_HAS_COMPAT(microchip_xec_watchdog) +#define WDT_NODE DT_INST(0, microchip_xec_watchdog) #endif + +#ifdef WDT_NODE +#define WDT_DEV_NAME DT_LABEL(WDT_NODE) +#else +#define WDT_DEV_NAME "" +#error "Unsupported SoC and no watchdog0 alias in zephyr.dts" #endif #define WDT_TEST_STATE_IDLE 0