Lines Matching +full:wdt +full:- +full:enable +full:- +full:once

1 // SPDX-License-Identifier: GPL-2.0-only
11 * -----
25 * The following table shows how the user-configured timeout relates
29 * -----------------------------------
79 MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started "
91 struct pdc_wdt_dev *wdt = watchdog_get_drvdata(wdt_dev); in pdc_wdt_keepalive() local
93 writel(PDC_WDT_TICKLE1_MAGIC, wdt->base + PDC_WDT_TICKLE1); in pdc_wdt_keepalive()
94 writel(PDC_WDT_TICKLE2_MAGIC, wdt->base + PDC_WDT_TICKLE2); in pdc_wdt_keepalive()
102 struct pdc_wdt_dev *wdt = watchdog_get_drvdata(wdt_dev); in pdc_wdt_stop() local
104 val = readl(wdt->base + PDC_WDT_CONFIG); in pdc_wdt_stop()
106 writel(val, wdt->base + PDC_WDT_CONFIG); in pdc_wdt_stop()
114 static void __pdc_wdt_set_timeout(struct pdc_wdt_dev *wdt) in __pdc_wdt_set_timeout() argument
116 unsigned long clk_rate = clk_get_rate(wdt->wdt_clk); in __pdc_wdt_set_timeout()
119 val = readl(wdt->base + PDC_WDT_CONFIG) & ~PDC_WDT_CONFIG_DELAY_MASK; in __pdc_wdt_set_timeout()
120 val |= order_base_2(wdt->wdt_dev.timeout * clk_rate) - 1; in __pdc_wdt_set_timeout()
121 writel(val, wdt->base + PDC_WDT_CONFIG); in __pdc_wdt_set_timeout()
127 struct pdc_wdt_dev *wdt = watchdog_get_drvdata(wdt_dev); in pdc_wdt_set_timeout() local
129 wdt->wdt_dev.timeout = new_timeout; in pdc_wdt_set_timeout()
131 __pdc_wdt_set_timeout(wdt); in pdc_wdt_set_timeout()
140 struct pdc_wdt_dev *wdt = watchdog_get_drvdata(wdt_dev); in pdc_wdt_start() local
142 __pdc_wdt_set_timeout(wdt); in pdc_wdt_start()
144 val = readl(wdt->base + PDC_WDT_CONFIG); in pdc_wdt_start()
146 writel(val, wdt->base + PDC_WDT_CONFIG); in pdc_wdt_start()
154 struct pdc_wdt_dev *wdt = watchdog_get_drvdata(wdt_dev); in pdc_wdt_restart() local
157 writel(0x1, wdt->base + PDC_WDT_SOFT_RESET); in pdc_wdt_restart()
185 struct device *dev = &pdev->dev; in pdc_wdt_probe()
193 return -ENOMEM; in pdc_wdt_probe()
195 pdc_wdt->base = devm_platform_ioremap_resource(pdev, 0); in pdc_wdt_probe()
196 if (IS_ERR(pdc_wdt->base)) in pdc_wdt_probe()
197 return PTR_ERR(pdc_wdt->base); in pdc_wdt_probe()
199 pdc_wdt->sys_clk = devm_clk_get(dev, "sys"); in pdc_wdt_probe()
200 if (IS_ERR(pdc_wdt->sys_clk)) { in pdc_wdt_probe()
202 return PTR_ERR(pdc_wdt->sys_clk); in pdc_wdt_probe()
205 pdc_wdt->wdt_clk = devm_clk_get(dev, "wdt"); in pdc_wdt_probe()
206 if (IS_ERR(pdc_wdt->wdt_clk)) { in pdc_wdt_probe()
207 dev_err(dev, "failed to get the wdt clock\n"); in pdc_wdt_probe()
208 return PTR_ERR(pdc_wdt->wdt_clk); in pdc_wdt_probe()
211 ret = clk_prepare_enable(pdc_wdt->sys_clk); in pdc_wdt_probe()
213 dev_err(dev, "could not prepare or enable sys clock\n"); in pdc_wdt_probe()
217 pdc_wdt->sys_clk); in pdc_wdt_probe()
221 ret = clk_prepare_enable(pdc_wdt->wdt_clk); in pdc_wdt_probe()
223 dev_err(dev, "could not prepare or enable wdt clock\n"); in pdc_wdt_probe()
227 pdc_wdt->wdt_clk); in pdc_wdt_probe()
232 clk_rate = clk_get_rate(pdc_wdt->wdt_clk); in pdc_wdt_probe()
235 return -EINVAL; in pdc_wdt_probe()
240 return -EINVAL; in pdc_wdt_probe()
244 pdc_wdt->wdt_dev.min_timeout = PDC_WDT_MIN_TIMEOUT + 1; in pdc_wdt_probe()
246 pdc_wdt->wdt_dev.min_timeout = PDC_WDT_MIN_TIMEOUT; in pdc_wdt_probe()
248 pdc_wdt->wdt_dev.info = &pdc_wdt_info; in pdc_wdt_probe()
249 pdc_wdt->wdt_dev.ops = &pdc_wdt_ops; in pdc_wdt_probe()
253 pdc_wdt->wdt_dev.max_timeout = div; in pdc_wdt_probe()
254 pdc_wdt->wdt_dev.timeout = PDC_WDT_DEF_TIMEOUT; in pdc_wdt_probe()
255 pdc_wdt->wdt_dev.parent = dev; in pdc_wdt_probe()
256 watchdog_set_drvdata(&pdc_wdt->wdt_dev, pdc_wdt); in pdc_wdt_probe()
258 watchdog_init_timeout(&pdc_wdt->wdt_dev, heartbeat, dev); in pdc_wdt_probe()
260 pdc_wdt_stop(&pdc_wdt->wdt_dev); in pdc_wdt_probe()
263 val = readl(pdc_wdt->base + PDC_WDT_TICKLE1); in pdc_wdt_probe()
268 pdc_wdt->wdt_dev.bootstatus |= WDIOF_CARDRESET; in pdc_wdt_probe()
288 watchdog_set_nowayout(&pdc_wdt->wdt_dev, nowayout); in pdc_wdt_probe()
289 watchdog_set_restart_priority(&pdc_wdt->wdt_dev, 128); in pdc_wdt_probe()
293 watchdog_stop_on_reboot(&pdc_wdt->wdt_dev); in pdc_wdt_probe()
294 watchdog_stop_on_unregister(&pdc_wdt->wdt_dev); in pdc_wdt_probe()
295 return devm_watchdog_register_device(dev, &pdc_wdt->wdt_dev); in pdc_wdt_probe()
299 { .compatible = "img,pdc-wdt" },
306 .name = "imgpdc-wdt",