summaryrefslogtreecommitdiffstats
path: root/drivers/watchdog/sama5d4_wdt.c
diff options
context:
space:
mode:
authorAlexandre Belloni <alexandre.belloni@free-electrons.com>2017-01-30 18:18:48 +0100
committerGuenter Roeck <linux@roeck-us.net>2017-02-24 23:00:23 +0100
commitf201353273b6dec71940df01ea6eeb528d907941 (patch)
tree80cb375e273dad5674b10b426c3335150ee7bce1 /drivers/watchdog/sama5d4_wdt.c
parentwatchdog: sama5d4: Cache MR instead of a partial config (diff)
downloadlinux-f201353273b6dec71940df01ea6eeb528d907941.tar.xz
linux-f201353273b6dec71940df01ea6eeb528d907941.zip
watchdog: sama5d4: Implement resume hook
When resuming for the deepest state on sama5d2, it is necessary to restore MR as the registers are lost. Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/watchdog/sama5d4_wdt.c')
-rw-r--r--drivers/watchdog/sama5d4_wdt.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/drivers/watchdog/sama5d4_wdt.c b/drivers/watchdog/sama5d4_wdt.c
index 3230a842d015..f709962018ac 100644
--- a/drivers/watchdog/sama5d4_wdt.c
+++ b/drivers/watchdog/sama5d4_wdt.c
@@ -258,11 +258,28 @@ static const struct of_device_id sama5d4_wdt_of_match[] = {
};
MODULE_DEVICE_TABLE(of, sama5d4_wdt_of_match);
+#ifdef CONFIG_PM_SLEEP
+static int sama5d4_wdt_resume(struct device *dev)
+{
+ struct sama5d4_wdt *wdt = dev_get_drvdata(dev);
+
+ wdt_write(wdt, AT91_WDT_MR, wdt->mr & ~AT91_WDT_WDDIS);
+ if (wdt->mr & AT91_WDT_WDDIS)
+ wdt_write(wdt, AT91_WDT_MR, wdt->mr);
+
+ return 0;
+}
+#endif
+
+static SIMPLE_DEV_PM_OPS(sama5d4_wdt_pm_ops, NULL,
+ sama5d4_wdt_resume);
+
static struct platform_driver sama5d4_wdt_driver = {
.probe = sama5d4_wdt_probe,
.remove = sama5d4_wdt_remove,
.driver = {
.name = "sama5d4_wdt",
+ .pm = &sama5d4_wdt_pm_ops,
.of_match_table = sama5d4_wdt_of_match,
}
};