Message ID | 20220109114120.386013-2-alistair@alistair23.me (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | watchdog: imx_wdt2: Enable ping on suspend support | expand |
Hi, Am 09.01.22 um 12:41 schrieb Alistair Francis: > The i.MX watchdog cannot be disabled by softwrae once it has been s/softwrae/software/ > enabled. This means that it can't be stopped before suspend. > > For systems that enter low power mode this is fine, as the watchdog will > be automatically stopped by hardwrae in low power mode. Not all i.MX s/hardwrae/hardware/ > platforms support low power mode in the mainline kernel. For example the > i.MX7D does not enter low power mode and so will be rebooted 2 minutes > after entering freeze or mem sleep states. > > This patch introduces a device tree property "fsl,ping-during-suspend" > that can be used to enable ping on suspend support for these systems. Introducing vendor specific properties for Linux behavior should be avoided. The DT should describe just the hardware. In case i.mx7d is affected, how about enabling this workaround for compatible fsl,imx7d-wdt? This has the advantage that in case low power mode will be implemented <https://elixir.bootlin.com/linux/latest/B/ident/fsl%2Cimx7d-wdt>, we don't have to care about DTB files. Best regards > > Signed-off-by: Alistair Francis <alistair@alistair23.me> > --- > .../bindings/watchdog/fsl-imx-wdt.yaml | 7 ++++++ > drivers/watchdog/imx2_wdt.c | 22 +++++++++++++------ > 2 files changed, 22 insertions(+), 7 deletions(-) > > diff --git a/Documentation/devicetree/bindings/watchdog/fsl-imx-wdt.yaml b/Documentation/devicetree/bindings/watchdog/fsl-imx-wdt.yaml > index fb7695515be1..b8660a3c456c 100644 > --- a/Documentation/devicetree/bindings/watchdog/fsl-imx-wdt.yaml > +++ b/Documentation/devicetree/bindings/watchdog/fsl-imx-wdt.yaml > @@ -55,6 +55,13 @@ properties: > If present, the watchdog device is configured to assert its > external reset (WDOG_B) instead of issuing a software reset. > > + fsl,ping-during-suspend: > + $ref: /schemas/types.yaml#/definitions/flag > + description: | > + If present, the kernel will ping the watchdog during suspend. > + This should be used on platforms that don't enter low power mode > + during suspend. > + > required: > - compatible > - interrupts > diff --git a/drivers/watchdog/imx2_wdt.c b/drivers/watchdog/imx2_wdt.c > index 51bfb796898b..9a5fdb3173a8 100644 > --- a/drivers/watchdog/imx2_wdt.c > +++ b/drivers/watchdog/imx2_wdt.c > @@ -66,6 +66,7 @@ struct imx2_wdt_device { > struct watchdog_device wdog; > bool ext_reset; > bool clk_is_on; > + bool no_ping; > }; > > static bool nowayout = WATCHDOG_NOWAYOUT; > @@ -312,12 +313,14 @@ static int __init imx2_wdt_probe(struct platform_device *pdev) > > wdev->ext_reset = of_property_read_bool(dev->of_node, > "fsl,ext-reset-output"); > + wdev->no_ping = !of_property_read_bool(dev->of_node, "fsl,ping-during-suspend"); > platform_set_drvdata(pdev, wdog); > watchdog_set_drvdata(wdog, wdev); > watchdog_set_nowayout(wdog, nowayout); > watchdog_set_restart_priority(wdog, 128); > watchdog_init_timeout(wdog, timeout, dev); > - watchdog_stop_ping_on_suspend(wdog); > + if (wdev->no_ping) > + watchdog_stop_ping_on_suspend(wdog); > > if (imx2_wdt_is_running(wdev)) { > imx2_wdt_set_timeout(wdog, wdog->timeout); > @@ -366,9 +369,11 @@ static int __maybe_unused imx2_wdt_suspend(struct device *dev) > imx2_wdt_ping(wdog); > } > > - clk_disable_unprepare(wdev->clk); > + if (wdev->no_ping) { > + clk_disable_unprepare(wdev->clk); > > - wdev->clk_is_on = false; > + wdev->clk_is_on = false; > + } > > return 0; > } > @@ -380,11 +385,14 @@ static int __maybe_unused imx2_wdt_resume(struct device *dev) > struct imx2_wdt_device *wdev = watchdog_get_drvdata(wdog); > int ret; > > - ret = clk_prepare_enable(wdev->clk); > - if (ret) > - return ret; > + if (wdev->no_ping) { > + ret = clk_prepare_enable(wdev->clk); > > - wdev->clk_is_on = true; > + if (ret) > + return ret; > + > + wdev->clk_is_on = true; > + } > > if (watchdog_active(wdog) && !imx2_wdt_is_running(wdev)) { > /*
On 1/13/22 10:55 AM, Stefan Wahren wrote: > Hi, > > Am 09.01.22 um 12:41 schrieb Alistair Francis: >> The i.MX watchdog cannot be disabled by softwrae once it has been > s/softwrae/software/ >> enabled. This means that it can't be stopped before suspend. >> >> For systems that enter low power mode this is fine, as the watchdog will >> be automatically stopped by hardwrae in low power mode. Not all i.MX > s/hardwrae/hardware/ >> platforms support low power mode in the mainline kernel. For example the >> i.MX7D does not enter low power mode and so will be rebooted 2 minutes >> after entering freeze or mem sleep states. >> >> This patch introduces a device tree property "fsl,ping-during-suspend" >> that can be used to enable ping on suspend support for these systems. > > Introducing vendor specific properties for Linux behavior should be > avoided. The DT should describe just the hardware. > > In case i.mx7d is affected, how about enabling this workaround for > compatible fsl,imx7d-wdt? This has the advantage that in case low power > mode will be implemented > <https://elixir.bootlin.com/linux/latest/B/ident/fsl%2Cimx7d-wdt>, we > don't have to care about DTB files. > Agreed. Guenter
diff --git a/Documentation/devicetree/bindings/watchdog/fsl-imx-wdt.yaml b/Documentation/devicetree/bindings/watchdog/fsl-imx-wdt.yaml index fb7695515be1..b8660a3c456c 100644 --- a/Documentation/devicetree/bindings/watchdog/fsl-imx-wdt.yaml +++ b/Documentation/devicetree/bindings/watchdog/fsl-imx-wdt.yaml @@ -55,6 +55,13 @@ properties: If present, the watchdog device is configured to assert its external reset (WDOG_B) instead of issuing a software reset. + fsl,ping-during-suspend: + $ref: /schemas/types.yaml#/definitions/flag + description: | + If present, the kernel will ping the watchdog during suspend. + This should be used on platforms that don't enter low power mode + during suspend. + required: - compatible - interrupts diff --git a/drivers/watchdog/imx2_wdt.c b/drivers/watchdog/imx2_wdt.c index 51bfb796898b..9a5fdb3173a8 100644 --- a/drivers/watchdog/imx2_wdt.c +++ b/drivers/watchdog/imx2_wdt.c @@ -66,6 +66,7 @@ struct imx2_wdt_device { struct watchdog_device wdog; bool ext_reset; bool clk_is_on; + bool no_ping; }; static bool nowayout = WATCHDOG_NOWAYOUT; @@ -312,12 +313,14 @@ static int __init imx2_wdt_probe(struct platform_device *pdev) wdev->ext_reset = of_property_read_bool(dev->of_node, "fsl,ext-reset-output"); + wdev->no_ping = !of_property_read_bool(dev->of_node, "fsl,ping-during-suspend"); platform_set_drvdata(pdev, wdog); watchdog_set_drvdata(wdog, wdev); watchdog_set_nowayout(wdog, nowayout); watchdog_set_restart_priority(wdog, 128); watchdog_init_timeout(wdog, timeout, dev); - watchdog_stop_ping_on_suspend(wdog); + if (wdev->no_ping) + watchdog_stop_ping_on_suspend(wdog); if (imx2_wdt_is_running(wdev)) { imx2_wdt_set_timeout(wdog, wdog->timeout); @@ -366,9 +369,11 @@ static int __maybe_unused imx2_wdt_suspend(struct device *dev) imx2_wdt_ping(wdog); } - clk_disable_unprepare(wdev->clk); + if (wdev->no_ping) { + clk_disable_unprepare(wdev->clk); - wdev->clk_is_on = false; + wdev->clk_is_on = false; + } return 0; } @@ -380,11 +385,14 @@ static int __maybe_unused imx2_wdt_resume(struct device *dev) struct imx2_wdt_device *wdev = watchdog_get_drvdata(wdog); int ret; - ret = clk_prepare_enable(wdev->clk); - if (ret) - return ret; + if (wdev->no_ping) { + ret = clk_prepare_enable(wdev->clk); - wdev->clk_is_on = true; + if (ret) + return ret; + + wdev->clk_is_on = true; + } if (watchdog_active(wdog) && !imx2_wdt_is_running(wdev)) { /*
The i.MX watchdog cannot be disabled by softwrae once it has been enabled. This means that it can't be stopped before suspend. For systems that enter low power mode this is fine, as the watchdog will be automatically stopped by hardwrae in low power mode. Not all i.MX platforms support low power mode in the mainline kernel. For example the i.MX7D does not enter low power mode and so will be rebooted 2 minutes after entering freeze or mem sleep states. This patch introduces a device tree property "fsl,ping-during-suspend" that can be used to enable ping on suspend support for these systems. Signed-off-by: Alistair Francis <alistair@alistair23.me> --- .../bindings/watchdog/fsl-imx-wdt.yaml | 7 ++++++ drivers/watchdog/imx2_wdt.c | 22 +++++++++++++------ 2 files changed, 22 insertions(+), 7 deletions(-)