]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
platform/x86: portwell-ec: Add suspend/resume support for watchdog
authorYen-Chi Huang <jesse.huang@portwell.com.tw>
Thu, 28 Aug 2025 05:31:17 +0000 (13:31 +0800)
committerIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Thu, 28 Aug 2025 11:52:54 +0000 (14:52 +0300)
Portwell EC does not disable the watchdog during suspend. To avoid unwanted
resets, this patch adds suspend and resume callbacks (pwec_suspend() and
pwec_resume()) to the driver.

The watchdog is stopped in pwec_suspend() and restarted in pwec_resume() if
it was active before suspend.

Signed-off-by: Yen-Chi Huang <jesse.huang@portwell.com.tw>
Link: https://lore.kernel.org/r/c9cfe602-c279-4aa4-9932-76f47f26556c@portwell.com.tw
[ij: removed extra "3"]
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
drivers/platform/x86/portwell-ec.c

index 322f296e93153620d308dea8ef07906aaf6d35f5..d2e91d5c3b3a6013871f092e7b6755d0f4829934 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/ioport.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
+#include <linux/pm.h>
 #include <linux/sizes.h>
 #include <linux/string.h>
 #include <linux/watchdog.h>
@@ -246,9 +247,28 @@ static int pwec_probe(struct platform_device *pdev)
        return 0;
 }
 
+static int pwec_suspend(struct device *dev)
+{
+       if (watchdog_active(&ec_wdt_dev))
+               return pwec_wdt_stop(&ec_wdt_dev);
+
+       return 0;
+}
+
+static int pwec_resume(struct device *dev)
+{
+       if (watchdog_active(&ec_wdt_dev))
+               return pwec_wdt_start(&ec_wdt_dev);
+
+       return 0;
+}
+
+static DEFINE_SIMPLE_DEV_PM_OPS(pwec_dev_pm_ops, pwec_suspend, pwec_resume);
+
 static struct platform_driver pwec_driver = {
        .driver = {
                .name = "portwell-ec",
+               .pm = pm_sleep_ptr(&pwec_dev_pm_ops),
        },
        .probe = pwec_probe,
 };