Skip to content

Commit b1413e6

Browse files
Loic PoulainWim Van Sebroeck
authored andcommitted
watchdog: pm8916_wdt: Add system sleep callbacks
Add suspend and resume pm operations. Tested on dragonboard-410c. Signed-off-by: Loic Poulain <[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 000de54 commit b1413e6

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

drivers/watchdog/pm8916_wdt.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,13 +192,37 @@ static int pm8916_wdt_probe(struct platform_device *pdev)
192192
wdt->wdev.timeout = PM8916_WDT_DEFAULT_TIMEOUT;
193193
wdt->wdev.pretimeout = 0;
194194
watchdog_set_drvdata(&wdt->wdev, wdt);
195+
platform_set_drvdata(pdev, wdt);
195196

196197
watchdog_init_timeout(&wdt->wdev, 0, dev);
197198
pm8916_wdt_configure_timers(&wdt->wdev);
198199

199200
return devm_watchdog_register_device(dev, &wdt->wdev);
200201
}
201202

203+
static int __maybe_unused pm8916_wdt_suspend(struct device *dev)
204+
{
205+
struct pm8916_wdt *wdt = dev_get_drvdata(dev);
206+
207+
if (watchdog_active(&wdt->wdev))
208+
return pm8916_wdt_stop(&wdt->wdev);
209+
210+
return 0;
211+
}
212+
213+
static int __maybe_unused pm8916_wdt_resume(struct device *dev)
214+
{
215+
struct pm8916_wdt *wdt = dev_get_drvdata(dev);
216+
217+
if (watchdog_active(&wdt->wdev))
218+
return pm8916_wdt_start(&wdt->wdev);
219+
220+
return 0;
221+
}
222+
223+
static SIMPLE_DEV_PM_OPS(pm8916_wdt_pm_ops, pm8916_wdt_suspend,
224+
pm8916_wdt_resume);
225+
202226
static const struct of_device_id pm8916_wdt_id_table[] = {
203227
{ .compatible = "qcom,pm8916-wdt" },
204228
{ }
@@ -210,6 +234,7 @@ static struct platform_driver pm8916_wdt_driver = {
210234
.driver = {
211235
.name = "pm8916-wdt",
212236
.of_match_table = of_match_ptr(pm8916_wdt_id_table),
237+
.pm = &pm8916_wdt_pm_ops,
213238
},
214239
};
215240
module_platform_driver(pm8916_wdt_driver);

0 commit comments

Comments
 (0)