Linux Renesas SOC kernel development
 help / color / mirror / Atom feed
* [PATCH] watchdog: renesas_wdt: adapt timer setup to recommended procedure
@ 2018-02-26 21:49 Wolfram Sang
  2018-02-26 22:38 ` Guenter Roeck
  0 siblings, 1 reply; 7+ messages in thread
From: Wolfram Sang @ 2018-02-26 21:49 UTC (permalink / raw)
  To: linux-watchdog
  Cc: linux-renesas-soc, Yoshihiro Shimoda, Fabrizio Castro,
	Wolfram Sang

The datasheet says we should stop the timer before changing the clock
divider. So, let's meet that recommendation.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
 drivers/watchdog/renesas_wdt.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/watchdog/renesas_wdt.c b/drivers/watchdog/renesas_wdt.c
index 831ef83f6de15b..c4a17d72d02506 100644
--- a/drivers/watchdog/renesas_wdt.c
+++ b/drivers/watchdog/renesas_wdt.c
@@ -74,12 +74,17 @@ static int rwdt_init_timeout(struct watchdog_device *wdev)
 static int rwdt_start(struct watchdog_device *wdev)
 {
 	struct rwdt_priv *priv = watchdog_get_drvdata(wdev);
+	u8 val;
 
 	pm_runtime_get_sync(wdev->parent);
 
-	rwdt_write(priv, 0, RWTCSRB);
-	rwdt_write(priv, priv->cks, RWTCSRA);
+	/* Stop the timer before we modify any register */
+	val = readb_relaxed(priv->base + RWTCSRA) & ~RWTCSRA_TME;
+	rwdt_write(priv, val, RWTCSRA);
+
 	rwdt_init_timeout(wdev);
+	rwdt_write(priv, priv->cks, RWTCSRA);
+	rwdt_write(priv, 0, RWTCSRB);
 
 	while (readb_relaxed(priv->base + RWTCSRA) & RWTCSRA_WRFLG)
 		cpu_relax();
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-02-27 20:36 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-26 21:49 [PATCH] watchdog: renesas_wdt: adapt timer setup to recommended procedure Wolfram Sang
2018-02-26 22:38 ` Guenter Roeck
2018-02-27 13:00   ` Wolfram Sang
2018-02-27 15:03     ` Guenter Roeck
2018-02-27 16:22       ` Wolfram Sang
2018-02-27 17:19         ` Guenter Roeck
2018-02-27 20:36           ` Wolfram Sang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox