linux-watchdog.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] watchdog: renesas_wdt: support handover from bootloader
@ 2019-08-19 17:33 Wolfram Sang
  2019-08-19 17:44 ` Wolfram Sang
  0 siblings, 1 reply; 2+ messages in thread
From: Wolfram Sang @ 2019-08-19 17:33 UTC (permalink / raw)
  To: linux-watchdog
  Cc: linux-renesas-soc, Geert Uytterhoeven, Guenter Roeck, Wolfram Sang

From: Wolfram Sang <wsa+renesas@sang-engineering.com>

Support an already running watchdog by checking its enable bit and set
up the status accordingly before registering the device.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---

Change since v1:

* removed custom code to handle RPM refcnt. The watchdog core does it
  already.

Tested again on a Renesas Salvator-XS (R-Car M3N) with and without the
'open_timeout' command line parameter.

After all these discussions, the patch became quite simple again :/
Still, thanks for all the discussions to make sure we didn't overlook
clock handling.

 drivers/watchdog/renesas_wdt.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/watchdog/renesas_wdt.c b/drivers/watchdog/renesas_wdt.c
index 00662a8e039c..47fce4de0110 100644
--- a/drivers/watchdog/renesas_wdt.c
+++ b/drivers/watchdog/renesas_wdt.c
@@ -194,6 +194,7 @@ static int rwdt_probe(struct platform_device *pdev)
 	struct clk *clk;
 	unsigned long clks_per_sec;
 	int ret, i;
+	u8 csra;
 
 	if (rwdt_blacklisted(dev))
 		return -ENODEV;
@@ -213,8 +214,8 @@ static int rwdt_probe(struct platform_device *pdev)
 	pm_runtime_enable(dev);
 	pm_runtime_get_sync(dev);
 	priv->clk_rate = clk_get_rate(clk);
-	priv->wdev.bootstatus = (readb_relaxed(priv->base + RWTCSRA) &
-				RWTCSRA_WOVF) ? WDIOF_CARDRESET : 0;
+	csra = readb_relaxed(priv->base + RWTCSRA);
+	priv->wdev.bootstatus = csra & RWTCSRA_WOVF ? WDIOF_CARDRESET : 0;
 	pm_runtime_put(dev);
 
 	if (!priv->clk_rate) {
@@ -252,6 +253,13 @@ static int rwdt_probe(struct platform_device *pdev)
 	/* This overrides the default timeout only if DT configuration was found */
 	watchdog_init_timeout(&priv->wdev, 0, dev);
 
+	/* Check if FW enabled the watchdog */
+	if (csra & RWTCSRA_TME) {
+		/* Ensure properly initialized dividers */
+		rwdt_start(&priv->wdev);
+		set_bit(WDOG_HW_RUNNING, &priv->wdev.status);
+	}
+
 	ret = watchdog_register_device(&priv->wdev);
 	if (ret < 0)
 		goto out_pm_disable;
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] watchdog: renesas_wdt: support handover from bootloader
  2019-08-19 17:33 [PATCH v2] watchdog: renesas_wdt: support handover from bootloader Wolfram Sang
@ 2019-08-19 17:44 ` Wolfram Sang
  0 siblings, 0 replies; 2+ messages in thread
From: Wolfram Sang @ 2019-08-19 17:44 UTC (permalink / raw)
  To: linux-watchdog
  Cc: linux-renesas-soc, Geert Uytterhoeven, Guenter Roeck, Wolfram Sang

[-- Attachment #1: Type: text/plain, Size: 218 bytes --]


> After all these discussions, the patch became quite simple again :/
> Still, thanks for all the discussions to make sure we didn't overlook
> clock handling.

Except for the probe error path, sigh... v3 coming up.


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-08-19 17:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-19 17:33 [PATCH v2] watchdog: renesas_wdt: support handover from bootloader Wolfram Sang
2019-08-19 17:44 ` Wolfram Sang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).