diff -drupN a/drivers/watchdog/sunxi_wdt.c b/drivers/watchdog/sunxi_wdt.c --- a/drivers/watchdog/sunxi_wdt.c 2018-08-06 17:23:04.000000000 +0300 +++ b/drivers/watchdog/sunxi_wdt.c 2022-06-12 05:28:14.000000000 +0300 @@ -190,6 +190,32 @@ static int sunxi_wdt_start(struct watchd return 0; } +#ifdef CONFIG_PM +static int sunxi_wdt_suspend(struct platform_device *pdev, pm_message_t state) + +{ + struct sunxi_wdt_dev *sunxi_wdt = platform_get_drvdata(pdev); + + if (watchdog_active(&sunxi_wdt->wdt_dev)) + sunxi_wdt_stop(&sunxi_wdt->wdt_dev); + + return 0; +} + +static int sunxi_wdt_resume(struct platform_device *pdev) +{ + struct sunxi_wdt_dev *sunxi_wdt = platform_get_drvdata(pdev); + + if (watchdog_active(&sunxi_wdt->wdt_dev)) { + sunxi_wdt_set_timeout(&sunxi_wdt->wdt_dev, + sunxi_wdt->wdt_dev.timeout); + sunxi_wdt_start(&sunxi_wdt->wdt_dev); + } + + return 0; +} +#endif /* CONFIG_PM */ + static const struct watchdog_info sunxi_wdt_info = { .identity = DRV_NAME, .options = WDIOF_SETTIMEOUT | @@ -225,8 +251,8 @@ static const struct sunxi_wdt_reg sun6i_ }; static const struct of_device_id sunxi_wdt_dt_ids[] = { - { .compatible = "allwinner,sun4i-a10-wdt", .data = &sun4i_wdt_reg }, - { .compatible = "allwinner,sun6i-a31-wdt", .data = &sun6i_wdt_reg }, + { .compatible = "allwinner,sun4i-wdt", .data = &sun4i_wdt_reg }, + { .compatible = "allwinner,sun50i-wdt", .data = &sun6i_wdt_reg }, { /* sentinel */ } }; MODULE_DEVICE_TABLE(of, sunxi_wdt_dt_ids); @@ -268,7 +294,13 @@ static int sunxi_wdt_probe(struct platfo watchdog_set_drvdata(&sunxi_wdt->wdt_dev, sunxi_wdt); +#ifdef CONFIG_SUNXI_WDOG_BOOTON + sunxi_wdt_set_timeout(&sunxi_wdt->wdt_dev, WDT_MAX_TIMEOUT); + sunxi_wdt_start(&sunxi_wdt->wdt_dev); + sunxi_wdt_ping(&sunxi_wdt->wdt_dev); +#else sunxi_wdt_stop(&sunxi_wdt->wdt_dev); +#endif err = watchdog_register_device(&sunxi_wdt->wdt_dev); if (unlikely(err)) @@ -301,6 +333,10 @@ static struct platform_driver sunxi_wdt_ .probe = sunxi_wdt_probe, .remove = sunxi_wdt_remove, .shutdown = sunxi_wdt_shutdown, +#ifdef CONFIG_PM + .suspend = sunxi_wdt_suspend, + .resume = sunxi_wdt_resume, +#endif .driver = { .name = DRV_NAME, .of_match_table = sunxi_wdt_dt_ids,