Skip to content

Commit 064319c

Browse files
claudiubezneaWim Van Sebroeck
authored andcommitted
watchdog: rzg2l_wdt: Remove reset de-assert from probe
There is no need to de-assert the reset signal on probe as the watchdog is not used prior executing start. Also, the clocks are not enabled in probe (pm_runtime_enable() doesn't do that), thus this is another indicator that the watchdog wasn't used previously like this. Instead, keep the watchdog hardware in its previous state at probe (by default it is in reset state), enable it when it is started and move it to reset state when it is stopped. This saves some extra power when the watchdog is unused. Signed-off-by: Claudiu Beznea <[email protected]> Reviewed-by: Guenter Roeck <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Guenter Roeck <[email protected]> Signed-off-by: Wim Van Sebroeck <[email protected]>
1 parent 471e45a commit 064319c

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

drivers/watchdog/rzg2l_wdt.c

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,12 @@ static int rzg2l_wdt_start(struct watchdog_device *wdev)
129129
if (ret)
130130
return ret;
131131

132+
ret = reset_control_deassert(priv->rstc);
133+
if (ret) {
134+
pm_runtime_put(wdev->parent);
135+
return ret;
136+
}
137+
132138
/* Initialize time out */
133139
rzg2l_wdt_init_timeout(wdev);
134140

@@ -146,7 +152,9 @@ static int rzg2l_wdt_stop(struct watchdog_device *wdev)
146152
struct rzg2l_wdt_priv *priv = watchdog_get_drvdata(wdev);
147153
int ret;
148154

149-
rzg2l_wdt_reset(priv);
155+
ret = reset_control_assert(priv->rstc);
156+
if (ret)
157+
return ret;
150158

151159
ret = pm_runtime_put(wdev->parent);
152160
if (ret < 0)
@@ -186,6 +194,12 @@ static int rzg2l_wdt_restart(struct watchdog_device *wdev,
186194
clk_prepare_enable(priv->osc_clk);
187195

188196
if (priv->devtype == WDT_RZG2L) {
197+
int ret;
198+
199+
ret = reset_control_deassert(priv->rstc);
200+
if (ret)
201+
return ret;
202+
189203
/* Generate Reset (WDTRSTB) Signal on parity error */
190204
rzg2l_wdt_write(priv, 0, PECR);
191205

@@ -236,13 +250,11 @@ static const struct watchdog_ops rzg2l_wdt_ops = {
236250
.restart = rzg2l_wdt_restart,
237251
};
238252

239-
static void rzg2l_wdt_reset_assert_pm_disable(void *data)
253+
static void rzg2l_wdt_pm_disable(void *data)
240254
{
241255
struct watchdog_device *wdev = data;
242-
struct rzg2l_wdt_priv *priv = watchdog_get_drvdata(wdev);
243256

244257
pm_runtime_disable(wdev->parent);
245-
reset_control_assert(priv->rstc);
246258
}
247259

248260
static int rzg2l_wdt_probe(struct platform_device *pdev)
@@ -285,10 +297,6 @@ static int rzg2l_wdt_probe(struct platform_device *pdev)
285297
return dev_err_probe(&pdev->dev, PTR_ERR(priv->rstc),
286298
"failed to get cpg reset");
287299

288-
ret = reset_control_deassert(priv->rstc);
289-
if (ret)
290-
return dev_err_probe(dev, ret, "failed to deassert");
291-
292300
priv->devtype = (uintptr_t)of_device_get_match_data(dev);
293301

294302
if (priv->devtype == WDT_RZV2M) {
@@ -309,9 +317,7 @@ static int rzg2l_wdt_probe(struct platform_device *pdev)
309317
priv->wdev.timeout = WDT_DEFAULT_TIMEOUT;
310318

311319
watchdog_set_drvdata(&priv->wdev, priv);
312-
ret = devm_add_action_or_reset(&pdev->dev,
313-
rzg2l_wdt_reset_assert_pm_disable,
314-
&priv->wdev);
320+
ret = devm_add_action_or_reset(&pdev->dev, rzg2l_wdt_pm_disable, &priv->wdev);
315321
if (ret < 0)
316322
return ret;
317323

0 commit comments

Comments
 (0)