diff options
author | Wolfram Sang <[email protected]> | 2018-11-07 20:46:02 +0100 |
---|---|---|
committer | Wim Van Sebroeck <[email protected]> | 2018-12-09 15:03:27 +0100 |
commit | e990e12741877e9bfac402ca468f4007a75f6e2a (patch) | |
tree | 737d8f52e9398f98030fefc24523583a7f01381a | |
parent | 7db706a2184d37ca52a4f5315556ed4adac86e82 (diff) |
watchdog: renesas_wdt: don't set divider while watchdog is running
The datasheet says we must stop the timer before changing the clock
divider. This can happen when the restart handler is called while the
watchdog is running.
Signed-off-by: Wolfram Sang <[email protected]>
Reviewed-by: Fabrizio Castro <[email protected]>
Reviewed-by: Guenter Roeck <[email protected]>
Signed-off-by: Guenter Roeck <[email protected]>
Signed-off-by: Wim Van Sebroeck <[email protected]>
-rw-r--r-- | drivers/watchdog/renesas_wdt.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/drivers/watchdog/renesas_wdt.c b/drivers/watchdog/renesas_wdt.c index b570962e84f3..c450e23e24a8 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(); |