Commit 064319c3 authored by Claudiu Beznea's avatar Claudiu Beznea Committed by Wim Van Sebroeck

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: default avatarClaudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Reviewed-by: default avatarGuenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/20240531065723.1085423-6-claudiu.beznea.uj@bp.renesas.comSigned-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
Signed-off-by: default avatarWim Van Sebroeck <wim@linux-watchdog.org>
parent 471e45a3
...@@ -129,6 +129,12 @@ static int rzg2l_wdt_start(struct watchdog_device *wdev) ...@@ -129,6 +129,12 @@ static int rzg2l_wdt_start(struct watchdog_device *wdev)
if (ret) if (ret)
return ret; return ret;
ret = reset_control_deassert(priv->rstc);
if (ret) {
pm_runtime_put(wdev->parent);
return ret;
}
/* Initialize time out */ /* Initialize time out */
rzg2l_wdt_init_timeout(wdev); rzg2l_wdt_init_timeout(wdev);
...@@ -146,7 +152,9 @@ static int rzg2l_wdt_stop(struct watchdog_device *wdev) ...@@ -146,7 +152,9 @@ static int rzg2l_wdt_stop(struct watchdog_device *wdev)
struct rzg2l_wdt_priv *priv = watchdog_get_drvdata(wdev); struct rzg2l_wdt_priv *priv = watchdog_get_drvdata(wdev);
int ret; int ret;
rzg2l_wdt_reset(priv); ret = reset_control_assert(priv->rstc);
if (ret)
return ret;
ret = pm_runtime_put(wdev->parent); ret = pm_runtime_put(wdev->parent);
if (ret < 0) if (ret < 0)
...@@ -186,6 +194,12 @@ static int rzg2l_wdt_restart(struct watchdog_device *wdev, ...@@ -186,6 +194,12 @@ static int rzg2l_wdt_restart(struct watchdog_device *wdev,
clk_prepare_enable(priv->osc_clk); clk_prepare_enable(priv->osc_clk);
if (priv->devtype == WDT_RZG2L) { if (priv->devtype == WDT_RZG2L) {
int ret;
ret = reset_control_deassert(priv->rstc);
if (ret)
return ret;
/* Generate Reset (WDTRSTB) Signal on parity error */ /* Generate Reset (WDTRSTB) Signal on parity error */
rzg2l_wdt_write(priv, 0, PECR); rzg2l_wdt_write(priv, 0, PECR);
...@@ -236,13 +250,11 @@ static const struct watchdog_ops rzg2l_wdt_ops = { ...@@ -236,13 +250,11 @@ static const struct watchdog_ops rzg2l_wdt_ops = {
.restart = rzg2l_wdt_restart, .restart = rzg2l_wdt_restart,
}; };
static void rzg2l_wdt_reset_assert_pm_disable(void *data) static void rzg2l_wdt_pm_disable(void *data)
{ {
struct watchdog_device *wdev = data; struct watchdog_device *wdev = data;
struct rzg2l_wdt_priv *priv = watchdog_get_drvdata(wdev);
pm_runtime_disable(wdev->parent); pm_runtime_disable(wdev->parent);
reset_control_assert(priv->rstc);
} }
static int rzg2l_wdt_probe(struct platform_device *pdev) static int rzg2l_wdt_probe(struct platform_device *pdev)
...@@ -285,10 +297,6 @@ static int rzg2l_wdt_probe(struct platform_device *pdev) ...@@ -285,10 +297,6 @@ static int rzg2l_wdt_probe(struct platform_device *pdev)
return dev_err_probe(&pdev->dev, PTR_ERR(priv->rstc), return dev_err_probe(&pdev->dev, PTR_ERR(priv->rstc),
"failed to get cpg reset"); "failed to get cpg reset");
ret = reset_control_deassert(priv->rstc);
if (ret)
return dev_err_probe(dev, ret, "failed to deassert");
priv->devtype = (uintptr_t)of_device_get_match_data(dev); priv->devtype = (uintptr_t)of_device_get_match_data(dev);
if (priv->devtype == WDT_RZV2M) { if (priv->devtype == WDT_RZV2M) {
...@@ -309,9 +317,7 @@ static int rzg2l_wdt_probe(struct platform_device *pdev) ...@@ -309,9 +317,7 @@ static int rzg2l_wdt_probe(struct platform_device *pdev)
priv->wdev.timeout = WDT_DEFAULT_TIMEOUT; priv->wdev.timeout = WDT_DEFAULT_TIMEOUT;
watchdog_set_drvdata(&priv->wdev, priv); watchdog_set_drvdata(&priv->wdev, priv);
ret = devm_add_action_or_reset(&pdev->dev, ret = devm_add_action_or_reset(&pdev->dev, rzg2l_wdt_pm_disable, &priv->wdev);
rzg2l_wdt_reset_assert_pm_disable,
&priv->wdev);
if (ret < 0) if (ret < 0)
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment