aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/watchdog
diff options
context:
space:
mode:
authorXiubo Li <Li.Xiubo@freescale.com>2014-09-22 06:00:52 -0400
committerWim Van Sebroeck <wim@iguana.be>2014-12-18 10:01:14 -0500
commitaefbaf3a3fa030ed7ef3cc9456ed82e6611c1dcb (patch)
treebf8ce53c22151c69efb03f333b81becc7b6220d6 /drivers/watchdog
parent44e8967d591686463e84a88b46b03beba3ab49fb (diff)
watchdog: imx2_wdt: Add power management support.
Add power management operations(suspend and resume) as part of dev_pm_ops for IMX2 watchdog driver. Signed-off-by: Xiubo Li <Li.Xiubo@freescale.com> Reviewed-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
Diffstat (limited to 'drivers/watchdog')
-rw-r--r--drivers/watchdog/imx2_wdt.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/drivers/watchdog/imx2_wdt.c b/drivers/watchdog/imx2_wdt.c
index 65b84d8c0b93..51d940beb311 100644
--- a/drivers/watchdog/imx2_wdt.c
+++ b/drivers/watchdog/imx2_wdt.c
@@ -326,6 +326,52 @@ static void imx2_wdt_shutdown(struct platform_device *pdev)
326 } 326 }
327} 327}
328 328
329#ifdef CONFIG_PM_SLEEP
330/* Disable watchdog if it is active during suspend */
331static int imx2_wdt_suspend(struct device *dev)
332{
333 struct watchdog_device *wdog = dev_get_drvdata(dev);
334 struct imx2_wdt_device *wdev = watchdog_get_drvdata(wdog);
335
336 imx2_wdt_set_timeout(wdog, IMX2_WDT_MAX_TIME);
337 imx2_wdt_ping(wdog);
338
339 /* Watchdog has been stopped but IP block is still running */
340 if (!watchdog_active(&wdog) && imx2_wdt_is_running(wdev))
341 del_timer_sync(&wdev->timer);
342
343 clk_disable_unprepare(wdev->clk);
344
345 return 0;
346}
347
348/* Enable watchdog and configure it if necessary */
349static int imx2_wdt_resume(struct device *dev)
350{
351 struct watchdog_device *wdog = dev_get_drvdata(dev);
352 struct imx2_wdt_device *wdev = watchdog_get_drvdata(wdog);
353
354 clk_prepare_enable(wdev->clk);
355
356 if (watchdog_active(wdog) && !imx2_wdt_is_running(wdev)) {
357 /* Resumes from deep sleep we need restart
358 * the watchdog again.
359 */
360 imx2_wdt_setup(wdog);
361 imx2_wdt_set_timeout(wdog, wdog->timeout);
362 imx2_wdt_ping(wdog);
363 } else if (imx2_wdt_is_running(wdev)) {
364 imx2_wdt_ping(wdog);
365 mod_timer(&wdev->timer, jiffies + wdog->timeout * HZ / 2);
366 }
367
368 return 0;
369}
370#endif
371
372static SIMPLE_DEV_PM_OPS(imx2_wdt_pm_ops, imx2_wdt_suspend,
373 imx2_wdt_resume);
374
329static const struct of_device_id imx2_wdt_dt_ids[] = { 375static const struct of_device_id imx2_wdt_dt_ids[] = {
330 { .compatible = "fsl,imx21-wdt", }, 376 { .compatible = "fsl,imx21-wdt", },
331 { /* sentinel */ } 377 { /* sentinel */ }
@@ -337,6 +383,7 @@ static struct platform_driver imx2_wdt_driver = {
337 .shutdown = imx2_wdt_shutdown, 383 .shutdown = imx2_wdt_shutdown,
338 .driver = { 384 .driver = {
339 .name = DRIVER_NAME, 385 .name = DRIVER_NAME,
386 .pm = &imx2_wdt_pm_ops,
340 .of_match_table = imx2_wdt_dt_ids, 387 .of_match_table = imx2_wdt_dt_ids,
341 }, 388 },
342}; 389};