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>
---
drivers/platform/x86/portwell-ec.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/drivers/platform/x86/portwell-ec.c b/drivers/platform/x86/portwell-ec.c
index 3e019c51913e..7f473e3032e2 100644
--- a/drivers/platform/x86/portwell-ec.c
+++ b/drivers/platform/x86/portwell-ec.c
@@ -246,11 +246,29 @@ static int pwec_probe(struct platform_device *pdev)
return 0;
}
+static int pwec_suspend(struct platform_device *pdev, pm_message_t message)
+{
+ if (watchdog_active(&ec_wdt_dev))
+ return pwec_wdt_stop(&ec_wdt_dev);
+
+ return 0;
+}
+
+static int pwec_resume(struct platform_device *pdev)
+{
+ if (watchdog_active(&ec_wdt_dev))
+ return pwec_wdt_start(&ec_wdt_dev);
+
+ return 0;
+}
+
static struct platform_driver pwec_driver = {
.driver = {
.name = "portwell-ec",
},
.probe = pwec_probe,
+ .suspend = pm_ptr(pwec_suspend),
+ .resume = pm_ptr(pwec_resume),
};
static struct platform_device *pwec_dev;
--
2.34.1
On Mon, 28 Jul 2025, Yen-Chi Huang wrote: > 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> > --- > drivers/platform/x86/portwell-ec.c | 18 ++++++++++++++++++ > 1 file changed, 18 insertions(+) > > diff --git a/drivers/platform/x86/portwell-ec.c b/drivers/platform/x86/portwell-ec.c > index 3e019c51913e..7f473e3032e2 100644 > --- a/drivers/platform/x86/portwell-ec.c > +++ b/drivers/platform/x86/portwell-ec.c > @@ -246,11 +246,29 @@ static int pwec_probe(struct platform_device *pdev) > return 0; > } > > +static int pwec_suspend(struct platform_device *pdev, pm_message_t message) > +{ > + if (watchdog_active(&ec_wdt_dev)) > + return pwec_wdt_stop(&ec_wdt_dev); > + > + return 0; > +} > + > +static int pwec_resume(struct platform_device *pdev) > +{ > + if (watchdog_active(&ec_wdt_dev)) > + return pwec_wdt_start(&ec_wdt_dev); > + > + return 0; > +} > + > static struct platform_driver pwec_driver = { > .driver = { > .name = "portwell-ec", > }, > .probe = pwec_probe, > + .suspend = pm_ptr(pwec_suspend), > + .resume = pm_ptr(pwec_resume), These are legacy handlers, please use .pm under .driver and the macros to create the struct dev_pm_ops. -- i.
On 8/19/2025 5:51 PM, Ilpo Jarvinen wrote: > On Mon, 28 Jul 2025, Yen-Chi Huang wrote: >> static struct platform_driver pwec_driver = { >> .driver = { >> .name = "portwell-ec", >> }, >> .probe = pwec_probe, >> + .suspend = pm_ptr(pwec_suspend), >> + .resume = pm_ptr(pwec_resume), > > These are legacy handlers, please use .pm under .driver and the macros to > create the struct dev_pm_ops. > Hi Ilpo, Thanks for pointing this out. For v4, I have switched to .pm with DEFINE_SIMPLE_DEV_PM_OPS as suggested. Best regards, Yen-Chi
© 2016 - 2025 Red Hat, Inc.