diff options
author | Robin Gong <yibin.gong@nxp.com> | 2017-11-27 11:12:42 +0800 |
---|---|---|
committer | Leonard Crestez <leonard.crestez@nxp.com> | 2018-08-24 12:41:33 +0300 |
commit | c5898d6444b245d6d1f6093a01db13b6e488179f (patch) | |
tree | 8b58b661f972c128d746d971b50abb9a5cb05fd3 /drivers/watchdog | |
parent | 169b4749363ff456a27115e8638eb2b39a8bc218 (diff) |
MLK-16988: watchdog: imx8_wdt: stop watchdog while suspend
Since watchdog on i.mx8 is a software watchdog in scfw side, it should be
stopped while kernel enter system suspend if watchdog fired. Otherwise,
unexpected watchdog reset will happen. Restore back if watchdog fired too.
Signed-off-by: Robin Gong <yibin.gong@nxp.com>
Reviewed-by: Anson Huang <Anson.Huang@nxp.com>
Diffstat (limited to 'drivers/watchdog')
-rw-r--r-- | drivers/watchdog/imx8_wdt.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/drivers/watchdog/imx8_wdt.c b/drivers/watchdog/imx8_wdt.c index c78eb0030c85..6564532aca7b 100644 --- a/drivers/watchdog/imx8_wdt.c +++ b/drivers/watchdog/imx8_wdt.c @@ -119,6 +119,36 @@ static struct notifier_block imx8_wdt_notifier = { .notifier_call = imx8_wdt_notify, }; +#ifdef CONFIG_PM_SLEEP +static int imx8_wdt_suspend(struct device *dev) +{ + if (test_bit(WDOG_ACTIVE, &imx8_wdd.status)) + imx8_wdt_stop(&imx8_wdd); + + return 0; +} + +static int imx8_wdt_resume(struct device *dev) +{ + if (test_bit(WDOG_ACTIVE, &imx8_wdd.status)) + imx8_wdt_start(&imx8_wdd); + + return 0; +} + +static const struct dev_pm_ops imx8_wdt_pm_ops = { + .suspend = imx8_wdt_suspend, + .resume = imx8_wdt_resume, +}; + +#define IMX8_WDT_PM_OPS (&imx8_wdt_pm_ops) + +#else + +#define IMX8_WDT_PM_OPS NULL + +#endif + static int imx8_wdt_probe(struct platform_device *pdev) { struct watchdog_device *wdt = &imx8_wdd; @@ -181,6 +211,7 @@ static struct platform_driver imx8_wdt_driver = { .driver = { .name = "imx8-wdt", .of_match_table = imx8_wdt_dt_ids, + .pm = IMX8_WDT_PM_OPS, }, }; |