summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--drivers/watchdog/wdt-uclass.c25
-rw-r--r--include/wdt.h8
2 files changed, 33 insertions, 0 deletions
diff --git a/drivers/watchdog/wdt-uclass.c b/drivers/watchdog/wdt-uclass.c
index 358fc68e27..5b1c0df5d6 100644
--- a/drivers/watchdog/wdt-uclass.c
+++ b/drivers/watchdog/wdt-uclass.c
@@ -116,6 +116,31 @@ int wdt_stop(struct udevice *dev)
return ret;
}
+int wdt_stop_all(void)
+{
+ struct wdt_priv *priv;
+ struct udevice *dev;
+ struct uclass *uc;
+ int ret, err;
+
+ ret = uclass_get(UCLASS_WDT, &uc);
+ if (ret)
+ return ret;
+
+ uclass_foreach_dev(dev, uc) {
+ if (!device_active(dev))
+ continue;
+ priv = dev_get_uclass_priv(dev);
+ if (!priv->running)
+ continue;
+ err = wdt_stop(dev);
+ if (!ret)
+ ret = err;
+ }
+
+ return ret;
+}
+
int wdt_reset(struct udevice *dev)
{
const struct wdt_ops *ops = device_get_ops(dev);
diff --git a/include/wdt.h b/include/wdt.h
index bc242c2eb2..baaa9db08a 100644
--- a/include/wdt.h
+++ b/include/wdt.h
@@ -38,6 +38,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()
*