From 90555dc83e886250f029711728939a219c225f2d Mon Sep 17 00:00:00 2001 From: Rasmus Villemoes Date: Thu, 19 Aug 2021 11:57:01 +0200 Subject: watchdog: wdt-uclass.c: add wdt_stop_all() helper Since the watchdog_dev member of struct global_data is going away in favor of the wdt-uclass handling all watchdog devices, prepare for that by adding a helper to call wdt_stop() on all known devices. If an error is encountered, still do wdt_stop() on remaining devices, but remember and return the first error seen. Initially, this will only be used in one single place (board/alliedtelesis/x530/x530.c). Signed-off-by: Rasmus Villemoes --- include/wdt.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'include') diff --git a/include/wdt.h b/include/wdt.h index bc242c2eb26..baaa9db08a0 100644 --- a/include/wdt.h +++ b/include/wdt.h @@ -37,6 +37,14 @@ int wdt_start(struct udevice *dev, u64 timeout_ms, ulong flags); */ int wdt_stop(struct udevice *dev); +/* + * Stop all registered watchdog devices. + * + * @return: 0 if ok, first error encountered otherwise (but wdt_stop() + * is still called on following devices) + */ +int wdt_stop_all(void); + /* * Reset the timer, typically restoring the counter to * the value configured by start() -- cgit v1.2.3 From 492ee6b8d0e780a2ded5d9df7efc916eb4913734 Mon Sep 17 00:00:00 2001 From: Rasmus Villemoes Date: Thu, 19 Aug 2021 11:57:03 +0200 Subject: watchdog: wdt-uclass.c: handle all DM watchdogs in watchdog_reset() A board can have and make use of more than one watchdog device, say one built into the SOC and an external gpio-petted one. Having wdt-uclass only handle the first is both a little arbitrary and unexpected. So change initr_watchdog() so we visit (probe) all DM watchdog devices, and call the init_watchdog_dev helper for each. Similarly let watchdog_reset() loop over the whole uclass - each having their own ratelimiting metadata, and a separate "is this device running" flag. This gets rid of the watchdog_dev member of struct global_data. We do, however, still need the GD_FLG_WDT_READY set in initr_watchdog(). This is because watchdog_reset() can get called before DM is ready, and I don't think we can call uclass_get() that early. The current code just returns 0 if "getting" the first device fails - that can of course happen because there are no devices, but it could also happen if its ->probe call failed. In keeping with that, continue with the handling of the remaining devices even if one fails to probe. This is also why we cannot use uclass_probe_all(). If desired, it's possible to later add a per-device "u-boot,autostart" boolean property, so that one can do CONFIG_WATCHDOG_AUTOSTART per-device. Reviewed-by: Simon Glass Reviewed-by: Stefan Roese Signed-off-by: Rasmus Villemoes --- include/asm-generic/global_data.h | 6 ------ 1 file changed, 6 deletions(-) (limited to 'include') diff --git a/include/asm-generic/global_data.h b/include/asm-generic/global_data.h index a4cf7fd58cc..16fd305a65c 100644 --- a/include/asm-generic/global_data.h +++ b/include/asm-generic/global_data.h @@ -447,12 +447,6 @@ struct global_data { */ fdt_addr_t translation_offset; #endif -#if CONFIG_IS_ENABLED(WDT) - /** - * @watchdog_dev: watchdog device - */ - struct udevice *watchdog_dev; -#endif #ifdef CONFIG_GENERATE_ACPI_TABLE /** * @acpi_ctx: ACPI context pointer -- cgit v1.2.3