Skip to content

Commit 0aad7c4

Browse files
claudiubezneaWim Van Sebroeck
authored andcommitted
watchdog: rzg2l_wdt: Add suspend/resume support
The RZ/G3S supports deep sleep states where power to most of the IP blocks is cut off. To ensure proper working of the watchdog when resuming from such states, the suspend function is stopping the watchdog and the resume function is starting it. There is no need to configure the watchdog in case the watchdog was stopped prior to starting suspend. Signed-off-by: Claudiu Beznea <[email protected]> Reviewed-by: Guenter Roeck <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Guenter Roeck <[email protected]> Signed-off-by: Wim Van Sebroeck <[email protected]>
1 parent d8997ed commit 0aad7c4

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

drivers/watchdog/rzg2l_wdt.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,7 @@ static int rzg2l_wdt_probe(struct platform_device *pdev)
286286
priv->wdev.timeout = WDT_DEFAULT_TIMEOUT;
287287

288288
watchdog_set_drvdata(&priv->wdev, priv);
289+
dev_set_drvdata(dev, priv);
289290
ret = devm_add_action_or_reset(&pdev->dev, rzg2l_wdt_pm_disable, &priv->wdev);
290291
if (ret)
291292
return ret;
@@ -307,10 +308,35 @@ static const struct of_device_id rzg2l_wdt_ids[] = {
307308
};
308309
MODULE_DEVICE_TABLE(of, rzg2l_wdt_ids);
309310

311+
static int rzg2l_wdt_suspend_late(struct device *dev)
312+
{
313+
struct rzg2l_wdt_priv *priv = dev_get_drvdata(dev);
314+
315+
if (!watchdog_active(&priv->wdev))
316+
return 0;
317+
318+
return rzg2l_wdt_stop(&priv->wdev);
319+
}
320+
321+
static int rzg2l_wdt_resume_early(struct device *dev)
322+
{
323+
struct rzg2l_wdt_priv *priv = dev_get_drvdata(dev);
324+
325+
if (!watchdog_active(&priv->wdev))
326+
return 0;
327+
328+
return rzg2l_wdt_start(&priv->wdev);
329+
}
330+
331+
static const struct dev_pm_ops rzg2l_wdt_pm_ops = {
332+
LATE_SYSTEM_SLEEP_PM_OPS(rzg2l_wdt_suspend_late, rzg2l_wdt_resume_early)
333+
};
334+
310335
static struct platform_driver rzg2l_wdt_driver = {
311336
.driver = {
312337
.name = "rzg2l_wdt",
313338
.of_match_table = rzg2l_wdt_ids,
339+
.pm = &rzg2l_wdt_pm_ops,
314340
},
315341
.probe = rzg2l_wdt_probe,
316342
};

0 commit comments

Comments
 (0)