Skip to contentSkip to conversation

watchdog: ftwdt010: need to reset watchdog in ftwdt010_wdt_start()

PATCH In review Sergei Antonov 2 participants 3 messages Jul 30, 2023 – Aug 10, 2023 Watchdog device drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 watchdog: ftwdt010: need to reset watchdog in ftwdt010_wdt_start()

ftwdt010_wdt_start() has to call ftwdt010_wdt_reset() after setting-up the timeout in the same fashion ftwdt010_wdt_expire_now() does it.

Without this patch the "wdt start <ms>" command does not actually start the watchdog timer until the "wdt reset" command is executed.

---
 drivers/watchdog/ftwdt010_wdt.c | 40 +++++++++++++++++----------------
 1 file changed, 21 insertions(+), 19 deletions(-)
drivers/watchdog/ftwdt010_wdt.c +21 -19
index a6b33b17209d..1f5f301b1251 100644
@@ -25,8 +25,27 @@ struct ftwdt010_wdt_priv {
 	struct ftwdt010_wdt __iomem *regs;
 };
 
+static int ftwdt010_wdt_reset(struct udevice *dev)
+{
+	struct ftwdt010_wdt_priv *priv = dev_get_priv(dev);
+	struct ftwdt010_wdt *wd = priv->regs;
+
+	debug("Reset WDT..\n");
+
+	/* clear control register */
+	writel(0, &wd->wdcr);
+
+	/* Write Magic number */
+	writel(FTWDT010_WDRESTART_MAGIC, &wd->wdrestart);
+
+	/* Enable WDT */
+	writel(FTWDT010_WDCR_RST | FTWDT010_WDCR_ENABLE, &wd->wdcr);
+
+	return 0;
+}
+
 /*
- * Set the watchdog time interval.
+ * Set the watchdog time interval and start the timer.
  * Counter is 32 bit.
  */
 static int ftwdt010_wdt_start(struct udevice *dev, u64 timeout_ms, ulong flags)
@@ -52,24 +71,7 @@ static int ftwdt010_wdt_start(struct udevice *dev, u64 timeout_ms, ulong flags)
 
 	writel(reg, &wd->wdload);
 
-	return 0;
-}
-
-static int ftwdt010_wdt_reset(struct udevice *dev)
-{
-	struct ftwdt010_wdt_priv *priv = dev_get_priv(dev);
-	struct ftwdt010_wdt *wd = priv->regs;
-
-	/* clear control register */
-	writel(0, &wd->wdcr);
-
-	/* Write Magic number */
-	writel(FTWDT010_WDRESTART_MAGIC, &wd->wdrestart);
-
-	/* Enable WDT */
-	writel((FTWDT010_WDCR_RST | FTWDT010_WDCR_ENABLE), &wd->wdcr);
-
-	return 0;
+	return ftwdt010_wdt_reset(dev);
 }
 
 static int ftwdt010_wdt_stop(struct udevice *dev)
Signature · 1 line
2.37.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Sergei Antonov

ftwdt010_wdt_start() has to call ftwdt010_wdt_reset() after setting-up the timeout in the same fashion ftwdt010_wdt_expire_now() does it.

Without this patch the "wdt start <ms>" command does not actually start the watchdog timer until the "wdt reset" command is executed.

Thanks,
Stefan

Quoted 53 lines
---
  drivers/watchdog/ftwdt010_wdt.c | 40 +++++++++++++++++----------------
  1 file changed, 21 insertions(+), 19 deletions(-)
drivers/watchdog/ftwdt010_wdt.c +20 -13
index a6b33b17209d..1f5f301b1251 100644
@@ -25,8 +25,27 @@ struct ftwdt010_wdt_priv {
  	struct ftwdt010_wdt __iomem *regs;
  };
 
+static int ftwdt010_wdt_reset(struct udevice *dev)
+{
+	struct ftwdt010_wdt_priv *priv = dev_get_priv(dev);
+	struct ftwdt010_wdt *wd = priv->regs;
+
+	debug("Reset WDT..\n");
+
+	/* clear control register */
+	writel(0, &wd->wdcr);
+
+	/* Write Magic number */
+	writel(FTWDT010_WDRESTART_MAGIC, &wd->wdrestart);
+
+	/* Enable WDT */
+	writel(FTWDT010_WDCR_RST | FTWDT010_WDCR_ENABLE, &wd->wdcr);
+
+	return 0;
+}
+
  /*
- * Set the watchdog time interval.
+ * Set the watchdog time interval and start the timer.
   * Counter is 32 bit.
   */
  static int ftwdt010_wdt_start(struct udevice *dev, u64 timeout_ms, ulong flags)
@@ -52,24 +71,7 @@ static int ftwdt010_wdt_start(struct udevice *dev, u64 timeout_ms, ulong flags)
 
  	writel(reg, &wd->wdload);
 
-	return 0;
-}
-
-static int ftwdt010_wdt_reset(struct udevice *dev)
-{
-	struct ftwdt010_wdt_priv *priv = dev_get_priv(dev);
-	struct ftwdt010_wdt *wd = priv->regs;
-
-	/* clear control register */
-	writel(0, &wd->wdcr);
-
-	/* Write Magic number */

drivers/watchdog/ftwdt010_wdt.c static int ftwdt010_wdt_start(struct udevice *dev, u64 timeout_ms, ulong flags) · line 77

Quoted 10 lines
drivers/watchdog/ftwdt010_wdt.c +1 -6
-	writel(FTWDT010_WDRESTART_MAGIC, &wd->wdrestart);
-
-	/* Enable WDT */
-	writel((FTWDT010_WDCR_RST | FTWDT010_WDCR_ENABLE), &wd->wdcr);
-
-	return 0;
+	return ftwdt010_wdt_reset(dev);
  }
 
  static int ftwdt010_wdt_stop(struct udevice *dev)

Viele Grüße,
Stefan Roese

Signature · 3 lines
DENX Software Engineering GmbH,      Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: [email protected]
#2 lore raw
In reply to Sergei Antonov
Quoted 7 lines · Sergei Antonov

ftwdt010_wdt_start() has to call ftwdt010_wdt_reset() after setting-up the timeout in the same fashion ftwdt010_wdt_expire_now() does it.

Without this patch the "wdt start <ms>" command does not actually start the watchdog timer until the "wdt reset" command is executed.

Applied to u-boot-watchdog/master

Thanks,
Stefan

Quoted 53 lines
---
  drivers/watchdog/ftwdt010_wdt.c | 40 +++++++++++++++++----------------
  1 file changed, 21 insertions(+), 19 deletions(-)
drivers/watchdog/ftwdt010_wdt.c +20 -13
index a6b33b17209d..1f5f301b1251 100644
@@ -25,8 +25,27 @@ struct ftwdt010_wdt_priv {
  	struct ftwdt010_wdt __iomem *regs;
  };
 
+static int ftwdt010_wdt_reset(struct udevice *dev)
+{
+	struct ftwdt010_wdt_priv *priv = dev_get_priv(dev);
+	struct ftwdt010_wdt *wd = priv->regs;
+
+	debug("Reset WDT..\n");
+
+	/* clear control register */
+	writel(0, &wd->wdcr);
+
+	/* Write Magic number */
+	writel(FTWDT010_WDRESTART_MAGIC, &wd->wdrestart);
+
+	/* Enable WDT */
+	writel(FTWDT010_WDCR_RST | FTWDT010_WDCR_ENABLE, &wd->wdcr);
+
+	return 0;
+}
+
  /*
- * Set the watchdog time interval.
+ * Set the watchdog time interval and start the timer.
   * Counter is 32 bit.
   */
  static int ftwdt010_wdt_start(struct udevice *dev, u64 timeout_ms, ulong flags)
@@ -52,24 +71,7 @@ static int ftwdt010_wdt_start(struct udevice *dev, u64 timeout_ms, ulong flags)
 
  	writel(reg, &wd->wdload);
 
-	return 0;
-}
-
-static int ftwdt010_wdt_reset(struct udevice *dev)
-{
-	struct ftwdt010_wdt_priv *priv = dev_get_priv(dev);
-	struct ftwdt010_wdt *wd = priv->regs;
-
-	/* clear control register */
-	writel(0, &wd->wdcr);
-
-	/* Write Magic number */

drivers/watchdog/ftwdt010_wdt.c static int ftwdt010_wdt_start(struct udevice *dev, u64 timeout_ms, ulong flags) · line 77

Quoted 10 lines
drivers/watchdog/ftwdt010_wdt.c +1 -6
-	writel(FTWDT010_WDRESTART_MAGIC, &wd->wdrestart);
-
-	/* Enable WDT */
-	writel((FTWDT010_WDCR_RST | FTWDT010_WDCR_ENABLE), &wd->wdcr);
-
-	return 0;
+	return ftwdt010_wdt_reset(dev);
  }
 
  static int ftwdt010_wdt_stop(struct udevice *dev)

Viele Grüße,
Stefan Roese

Signature · 3 lines
DENX Software Engineering GmbH,      Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: [email protected]