From 16ac4abe0d0ea0a8d42d6a2a7de2a4a00bbf5b40 Mon Sep 17 00:00:00 2001 From: Viresh Kumar Date: Fri, 24 Feb 2012 15:12:37 +0530 Subject: [PATCH] watchdog: sp805_wdt: add pm callbacks to support standby/S2R/hibernation Signed-off-by: Viresh Kumar Signed-off-by: Wim Van Sebroeck --- drivers/watchdog/sp805_wdt.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/drivers/watchdog/sp805_wdt.c b/drivers/watchdog/sp805_wdt.c index 3ff9e47bd21..2b0939ab61d 100644 --- a/drivers/watchdog/sp805_wdt.c +++ b/drivers/watchdog/sp805_wdt.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -351,6 +352,37 @@ static int __devexit sp805_wdt_remove(struct amba_device *adev) return 0; } +#ifdef CONFIG_PM +static int sp805_wdt_suspend(struct device *dev) +{ + if (test_bit(WDT_BUSY, &wdt->status)) { + wdt_disable(); + clk_disable(wdt->clk); + } + + return 0; +} + +static int sp805_wdt_resume(struct device *dev) +{ + int ret = 0; + + if (test_bit(WDT_BUSY, &wdt->status)) { + ret = clk_enable(wdt->clk); + if (ret) { + dev_err(dev, "clock enable fail"); + return ret; + } + wdt_enable(); + } + + return ret; +} +#endif /* CONFIG_PM */ + +static SIMPLE_DEV_PM_OPS(sp805_wdt_dev_pm_ops, sp805_wdt_suspend, + sp805_wdt_resume); + static struct amba_id sp805_wdt_ids[] = { { .id = 0x00141805, @@ -364,6 +396,7 @@ MODULE_DEVICE_TABLE(amba, sp805_wdt_ids); static struct amba_driver sp805_wdt_driver = { .drv = { .name = MODULE_NAME, + .pm = &sp805_wdt_dev_pm_ops, }, .id_table = sp805_wdt_ids, .probe = sp805_wdt_probe, -- 2.39.5