]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
watchdog: wdt-uclass.c: add wdt_set_force_autostart() helper
authorAntonio Borneo <antonio.borneo@foss.st.com>
Fri, 23 May 2025 09:46:55 +0000 (11:46 +0200)
committerStefan Roese <stefan.roese@mailbox.org>
Wed, 30 Jul 2025 06:01:11 +0000 (08:01 +0200)
The watchdog could have been already started by a previous boot
stage (e.g. bootrom or secure OS). U-Boot has to start and kick
the watchdog even when CONFIG_WATCHDOG_AUTOSTART is not enabled
or when the DT property u-boot,noautostart is present.

Add the helper wdt_set_force_autostart() that can be called by the
driver's probe() when it detects that the watchdog has already
been started and is running.

Co-developed-by: Patrice Chotard <patrice.chotard@foss.st.com>
Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
Signed-off-by: Antonio Borneo <antonio.borneo@foss.st.com>
Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>
drivers/watchdog/wdt-uclass.c
include/wdt.h

index 10be334e9ed3665c8da237a1129cc6fb6a4f6a54..b32590069d97651f02468c70a85dfb6a4442fce6 100644 (file)
@@ -46,6 +46,15 @@ struct wdt_priv {
        struct cyclic_info cyclic;
 };
 
+int wdt_set_force_autostart(struct udevice *dev)
+{
+       struct wdt_priv *priv = dev_get_uclass_priv(dev);
+
+       priv->autostart = true;
+
+       return 0;
+}
+
 static void wdt_cyclic(struct cyclic_info *c)
 {
        struct wdt_priv *priv = container_of(c, struct wdt_priv, cyclic);
index 5026f5a6db48f0b9f8b3cce171306afb281dca9b..1ef656585c420c28fcee7ce62630f5b5ce447cfe 100644 (file)
@@ -18,6 +18,15 @@ struct udevice;
  * which typically include placing the system in a safe, known state.
  */
 
+/*
+ * Force watchdog start during init. Called by driver's probe when the watchdog
+ * is detected as already started.
+ *
+ * @dev: WDT Device
+ * @return: 0 if OK, -ve on error
+ */
+int wdt_set_force_autostart(struct udevice *dev);
+
 /*
  * Start the timer
  *