aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/drivers/watchdog
diff options
context:
space:
mode:
authorJanne Grunau <j@jannau.net>2023-10-16 08:58:01 +0200
committerWim Van Sebroeck <wim@linux-watchdog.org>2023-10-29 19:45:10 +0100
commit78ca4d6902f4a9631ab74cc96d485eb1f1e5fac9 (patch)
tree2b32f1cae1ad0768bb0d2b220116591787f8c03b /drivers/watchdog
parentdt-bindings: watchdog: qcom-wdt: Add MSM8226 and MSM8974 compatibles (diff)
downloadwireguard-linux-78ca4d6902f4a9631ab74cc96d485eb1f1e5fac9.tar.xz
wireguard-linux-78ca4d6902f4a9631ab74cc96d485eb1f1e5fac9.zip
watchdog: apple: Deactivate on suspend
The watchdog remains active after putting the system into suspend. Add PM callbacks to deactivate the watchdog on suspend an re-activate it on resume. Signed-off-by: Janne Grunau <j@jannau.net> Reviewed-by: Eric Curtin <ecurtin@redhat.com> Reviewed-by: Neal Gompa <neal@gompa.dev> Reviewed-by: Guenter Roeck <linux@roeck-us.net> Link: https://lore.kernel.org/r/20231016-apple-watchdog-suspend-v2-1-7ffff8042dbc@jannau.net Signed-off-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Wim Van Sebroeck <wim@linux-watchdog.org>
Diffstat (limited to 'drivers/watchdog')
-rw-r--r--drivers/watchdog/apple_wdt.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/drivers/watchdog/apple_wdt.c b/drivers/watchdog/apple_wdt.c
index eddeb0fede89..d4f739932f0b 100644
--- a/drivers/watchdog/apple_wdt.c
+++ b/drivers/watchdog/apple_wdt.c
@@ -173,6 +173,8 @@ static int apple_wdt_probe(struct platform_device *pdev)
if (!wdt->clk_rate)
return -EINVAL;
+ platform_set_drvdata(pdev, wdt);
+
wdt->wdd.ops = &apple_wdt_ops;
wdt->wdd.info = &apple_wdt_info;
wdt->wdd.max_timeout = U32_MAX / wdt->clk_rate;
@@ -190,6 +192,28 @@ static int apple_wdt_probe(struct platform_device *pdev)
return devm_watchdog_register_device(dev, &wdt->wdd);
}
+static int apple_wdt_resume(struct device *dev)
+{
+ struct apple_wdt *wdt = dev_get_drvdata(dev);
+
+ if (watchdog_active(&wdt->wdd) || watchdog_hw_running(&wdt->wdd))
+ apple_wdt_start(&wdt->wdd);
+
+ return 0;
+}
+
+static int apple_wdt_suspend(struct device *dev)
+{
+ struct apple_wdt *wdt = dev_get_drvdata(dev);
+
+ if (watchdog_active(&wdt->wdd) || watchdog_hw_running(&wdt->wdd))
+ apple_wdt_stop(&wdt->wdd);
+
+ return 0;
+}
+
+static DEFINE_SIMPLE_DEV_PM_OPS(apple_wdt_pm_ops, apple_wdt_suspend, apple_wdt_resume);
+
static const struct of_device_id apple_wdt_of_match[] = {
{ .compatible = "apple,wdt" },
{},
@@ -200,6 +224,7 @@ static struct platform_driver apple_wdt_driver = {
.driver = {
.name = "apple-watchdog",
.of_match_table = apple_wdt_of_match,
+ .pm = pm_sleep_ptr(&apple_wdt_pm_ops),
},
.probe = apple_wdt_probe,
};