Lines Matching +full:wdt +full:- +full:enable +full:- +full:once
1 // SPDX-License-Identifier: GPL-2.0
3 * Renesas RZ/G2L WDT Watchdog Driver
42 MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default="
64 ndelay(priv->delay); in rzg2l_wdt_wait_delay()
79 writel_relaxed(val, priv->base + reg); in rzg2l_wdt_write()
93 time_out = (wdev->timeout * (MICRO / 2)) / in rzg2l_wdt_init_timeout()
94 rzg2l_wdt_get_cycle_usec(priv->osc_clk_rate, 0); in rzg2l_wdt_init_timeout()
103 ret = pm_runtime_resume_and_get(wdev->parent); in rzg2l_wdt_start()
107 ret = reset_control_deassert(priv->rstc); in rzg2l_wdt_start()
109 pm_runtime_put(wdev->parent); in rzg2l_wdt_start()
119 /* Enable watchdog timer*/ in rzg2l_wdt_start()
130 ret = reset_control_assert(priv->rstc); in rzg2l_wdt_stop()
134 ret = pm_runtime_put(wdev->parent); in rzg2l_wdt_stop()
145 wdev->timeout = timeout; in rzg2l_wdt_set_timeout()
169 clk_prepare_enable(priv->pclk); in rzg2l_wdt_restart()
170 clk_prepare_enable(priv->osc_clk); in rzg2l_wdt_restart()
172 if (priv->devtype == WDT_RZG2L) { in rzg2l_wdt_restart()
173 ret = reset_control_deassert(priv->rstc); in rzg2l_wdt_restart()
184 ret = reset_control_reset(priv->rstc); in rzg2l_wdt_restart()
188 wdev->timeout = 0; in rzg2l_wdt_restart()
196 /* Enable watchdog timer*/ in rzg2l_wdt_restart()
200 mdelay(DIV_ROUND_UP(2 * 0xFFFFF * 1000, priv->osc_clk_rate)); in rzg2l_wdt_restart()
208 .identity = "Renesas RZ/G2L WDT Watchdog",
233 pm_runtime_disable(wdev->parent); in rzg2l_wdt_pm_disable()
238 struct device *dev = &pdev->dev; in rzg2l_wdt_probe()
245 return -ENOMEM; in rzg2l_wdt_probe()
247 priv->base = devm_platform_ioremap_resource(pdev, 0); in rzg2l_wdt_probe()
248 if (IS_ERR(priv->base)) in rzg2l_wdt_probe()
249 return PTR_ERR(priv->base); in rzg2l_wdt_probe()
252 priv->osc_clk = devm_clk_get(&pdev->dev, "oscclk"); in rzg2l_wdt_probe()
253 if (IS_ERR(priv->osc_clk)) in rzg2l_wdt_probe()
254 return dev_err_probe(&pdev->dev, PTR_ERR(priv->osc_clk), "no oscclk"); in rzg2l_wdt_probe()
256 priv->osc_clk_rate = clk_get_rate(priv->osc_clk); in rzg2l_wdt_probe()
257 if (!priv->osc_clk_rate) in rzg2l_wdt_probe()
258 return dev_err_probe(&pdev->dev, -EINVAL, "oscclk rate is 0"); in rzg2l_wdt_probe()
261 priv->pclk = devm_clk_get(&pdev->dev, "pclk"); in rzg2l_wdt_probe()
262 if (IS_ERR(priv->pclk)) in rzg2l_wdt_probe()
263 return dev_err_probe(&pdev->dev, PTR_ERR(priv->pclk), "no pclk"); in rzg2l_wdt_probe()
265 pclk_rate = clk_get_rate(priv->pclk); in rzg2l_wdt_probe()
267 return dev_err_probe(&pdev->dev, -EINVAL, "pclk rate is 0"); in rzg2l_wdt_probe()
269 priv->delay = F2CYCLE_NSEC(priv->osc_clk_rate) * 6 + F2CYCLE_NSEC(pclk_rate) * 9; in rzg2l_wdt_probe()
271 priv->rstc = devm_reset_control_get_exclusive(&pdev->dev, NULL); in rzg2l_wdt_probe()
272 if (IS_ERR(priv->rstc)) in rzg2l_wdt_probe()
273 return dev_err_probe(&pdev->dev, PTR_ERR(priv->rstc), in rzg2l_wdt_probe()
276 priv->devtype = (uintptr_t)of_device_get_match_data(dev); in rzg2l_wdt_probe()
278 pm_runtime_enable(&pdev->dev); in rzg2l_wdt_probe()
280 priv->wdev.info = &rzg2l_wdt_ident; in rzg2l_wdt_probe()
281 priv->wdev.ops = &rzg2l_wdt_ops; in rzg2l_wdt_probe()
282 priv->wdev.parent = dev; in rzg2l_wdt_probe()
283 priv->wdev.min_timeout = 1; in rzg2l_wdt_probe()
284 priv->wdev.max_timeout = rzg2l_wdt_get_cycle_usec(priv->osc_clk_rate, 0xfff) / in rzg2l_wdt_probe()
286 priv->wdev.timeout = WDT_DEFAULT_TIMEOUT; in rzg2l_wdt_probe()
288 watchdog_set_drvdata(&priv->wdev, priv); in rzg2l_wdt_probe()
290 ret = devm_add_action_or_reset(&pdev->dev, rzg2l_wdt_pm_disable, &priv->wdev); in rzg2l_wdt_probe()
294 watchdog_set_nowayout(&priv->wdev, nowayout); in rzg2l_wdt_probe()
295 watchdog_stop_on_unregister(&priv->wdev); in rzg2l_wdt_probe()
297 ret = watchdog_init_timeout(&priv->wdev, 0, dev); in rzg2l_wdt_probe()
301 return devm_watchdog_register_device(&pdev->dev, &priv->wdev); in rzg2l_wdt_probe()
305 { .compatible = "renesas,rzg2l-wdt", .data = (void *)WDT_RZG2L },
306 { .compatible = "renesas,rzv2m-wdt", .data = (void *)WDT_RZV2M },
315 if (!watchdog_active(&priv->wdev)) in rzg2l_wdt_suspend_late()
318 return rzg2l_wdt_stop(&priv->wdev); in rzg2l_wdt_suspend_late()
325 if (!watchdog_active(&priv->wdev)) in rzg2l_wdt_resume_early()
328 return rzg2l_wdt_start(&priv->wdev); in rzg2l_wdt_resume_early()
345 MODULE_DESCRIPTION("Renesas RZ/G2L WDT Watchdog Driver");