watchdog: renesas_wdt: support handover from bootloader
PATCH v2 1/1 watchdog: renesas_wdt: support handover from bootloader
From: Wolfram Sang <[email protected]>
Support an already running watchdog by checking its enable bit and set up the status accordingly before registering the device.
---
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(-)
drivers/watchdog/renesas_wdt.c +10 -2
@@ -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;
Signature · 1 line
2.20.1
Quoted 4 lines
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.