samples: watchdog: devicetree updates

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 <marti.bolivar@nordicsemi.no>
This commit is contained in:
Martí Bolívar 2020-04-16 14:15:14 -07:00 committed by Kumar Gala
commit aea96bca25

View file

@ -14,15 +14,37 @@
#define WDT_FEED_TRIES 5
#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 sample, 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
/*
* If the devicetree has a watchdog node, get its label property.
*/
#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
static void wdt_callback(struct device *wdt_dev, int channel_id)