summaryrefslogtreecommitdiff
path: root/drivers/watchdog/rzg2l_wdt.c
diff options
context:
space:
mode:
authorBiju Das <biju.das.jz@bp.renesas.com>2022-02-25 20:53:20 +0300
committerWim Van Sebroeck <wim@linux-watchdog.org>2022-05-08 11:34:04 +0300
commit4055ee81009e606e830af1acd9e2e35a36249713 (patch)
treecf4034ff743d63c33e6a75a495e53c8d7faa586f /drivers/watchdog/rzg2l_wdt.c
parentf43e6ddbd7d7b63b9e71927a1f50860f8d55f9cc (diff)
downloadlinux-4055ee81009e606e830af1acd9e2e35a36249713.tar.xz
watchdog: rzg2l_wdt: Add set_timeout callback
This patch adds support for set_timeout callback. Once WDT is started, the WDT cycle setting register(WDTSET) can be updated only after issuing a module reset. Otherwise, it will ignore the writes and will hold the previous value. This patch updates the WDTSET register if it is active. Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> Reviewed-by: Guenter Roeck <linux@roeck-us.net> Link: https://lore.kernel.org/r/20220225175320.11041-8-biju.das.jz@bp.renesas.com Signed-off-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Wim Van Sebroeck <wim@linux-watchdog.org>
Diffstat (limited to 'drivers/watchdog/rzg2l_wdt.c')
-rw-r--r--drivers/watchdog/rzg2l_wdt.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/drivers/watchdog/rzg2l_wdt.c b/drivers/watchdog/rzg2l_wdt.c
index 4e7107655cc2..6eea0ee4af49 100644
--- a/drivers/watchdog/rzg2l_wdt.c
+++ b/drivers/watchdog/rzg2l_wdt.c
@@ -115,6 +115,25 @@ static int rzg2l_wdt_stop(struct watchdog_device *wdev)
return 0;
}
+static int rzg2l_wdt_set_timeout(struct watchdog_device *wdev, unsigned int timeout)
+{
+ struct rzg2l_wdt_priv *priv = watchdog_get_drvdata(wdev);
+
+ wdev->timeout = timeout;
+
+ /*
+ * If the watchdog is active, reset the module for updating the WDTSET
+ * register so that it is updated with new timeout values.
+ */
+ if (watchdog_active(wdev)) {
+ pm_runtime_put(wdev->parent);
+ reset_control_reset(priv->rstc);
+ rzg2l_wdt_start(wdev);
+ }
+
+ return 0;
+}
+
static int rzg2l_wdt_restart(struct watchdog_device *wdev,
unsigned long action, void *data)
{
@@ -151,6 +170,7 @@ static const struct watchdog_ops rzg2l_wdt_ops = {
.start = rzg2l_wdt_start,
.stop = rzg2l_wdt_stop,
.ping = rzg2l_wdt_ping,
+ .set_timeout = rzg2l_wdt_set_timeout,
.restart = rzg2l_wdt_restart,
};