Lines Matching +full:watchdog +full:- +full:enable
1 // SPDX-License-Identifier: GPL-2.0+
3 * Cadence WDT driver - Used by Xilinx Zynq
5 * Copyright (C) 2010 - 2014 Xilinx, Inc.
18 #include <linux/watchdog.h>
21 /* Supports 1 - 516 sec */
54 "Watchdog time in seconds. (default="
59 "Watchdog cannot be stopped once started (default="
63 * struct cdns_wdt - Watchdog device structure
70 * @cdns_wdt_device: watchdog device structure
72 * Structure containing parameters specific to cadence watchdog.
87 writel_relaxed(val, wdt->regs + offset); in cdns_wdt_writereg()
99 * Zero Mode Register - This register controls how the time out is indicated
102 #define CDNS_WDT_ZMR_WDEN_MASK 0x00000001 /* Enable the WDT */
103 #define CDNS_WDT_ZMR_RSTEN_MASK 0x00000002 /* Enable the reset output */
104 #define CDNS_WDT_ZMR_IRQEN_MASK 0x00000004 /* Enable IRQ output */
108 * Counter Control register - This register controls how fast the timer runs
115 * cdns_wdt_stop - Stop the watchdog.
117 * @wdd: watchdog device
128 spin_lock(&wdt->io_lock); in cdns_wdt_stop()
131 spin_unlock(&wdt->io_lock); in cdns_wdt_stop()
137 * cdns_wdt_reload - Reload the watchdog timer (i.e. pat the watchdog).
139 * @wdd: watchdog device
149 spin_lock(&wdt->io_lock); in cdns_wdt_reload()
152 spin_unlock(&wdt->io_lock); in cdns_wdt_reload()
158 * cdns_wdt_start - Enable and start the watchdog.
160 * @wdd: watchdog device
180 unsigned long clock_f = clk_get_rate(wdt->clk); in cdns_wdt_start()
186 count = (wdd->timeout * (clock_f / wdt->prescaler)) / in cdns_wdt_start()
192 spin_lock(&wdt->io_lock); in cdns_wdt_start()
199 data = count | CDNS_WDT_REGISTER_ACCESS_KEY | wdt->ctrl_clksel; in cdns_wdt_start()
205 if (wdt->rst) { in cdns_wdt_start()
215 spin_unlock(&wdt->io_lock); in cdns_wdt_start()
221 * cdns_wdt_settimeout - Set a new timeout value for the watchdog device.
223 * @wdd: watchdog device
233 wdd->timeout = new_time; in cdns_wdt_settimeout()
239 * cdns_wdt_irq_handler - Notifies of watchdog timeout.
245 * The handler is invoked when the watchdog times out and a
252 dev_info(&pdev->dev, in cdns_wdt_irq_handler()
253 "Watchdog timed out. Internal reset not enabled\n"); in cdns_wdt_irq_handler()
260 * to the upper layers. This is defined in watchdog.h header file.
263 .identity = "cdns_wdt watchdog",
268 /* Watchdog Core Ops */
279 * cdns_wdt_probe - Probe call for the device.
288 struct device *dev = &pdev->dev; in cdns_wdt_probe()
296 return -ENOMEM; in cdns_wdt_probe()
298 cdns_wdt_device = &wdt->cdns_wdt_device; in cdns_wdt_probe()
299 cdns_wdt_device->info = &cdns_wdt_info; in cdns_wdt_probe()
300 cdns_wdt_device->ops = &cdns_wdt_ops; in cdns_wdt_probe()
301 cdns_wdt_device->timeout = CDNS_WDT_DEFAULT_TIMEOUT; in cdns_wdt_probe()
302 cdns_wdt_device->min_timeout = CDNS_WDT_MIN_TIMEOUT; in cdns_wdt_probe()
303 cdns_wdt_device->max_timeout = CDNS_WDT_MAX_TIMEOUT; in cdns_wdt_probe()
305 wdt->regs = devm_platform_ioremap_resource(pdev, 0); in cdns_wdt_probe()
306 if (IS_ERR(wdt->regs)) in cdns_wdt_probe()
307 return PTR_ERR(wdt->regs); in cdns_wdt_probe()
310 wdt->rst = of_property_read_bool(dev->of_node, "reset-on-timeout"); in cdns_wdt_probe()
312 if (!wdt->rst && irq >= 0) { in cdns_wdt_probe()
314 pdev->name, pdev); in cdns_wdt_probe()
324 cdns_wdt_device->parent = dev; in cdns_wdt_probe()
331 wdt->clk = devm_clk_get_enabled(dev, NULL); in cdns_wdt_probe()
332 if (IS_ERR(wdt->clk)) in cdns_wdt_probe()
333 return dev_err_probe(dev, PTR_ERR(wdt->clk), in cdns_wdt_probe()
336 clock_f = clk_get_rate(wdt->clk); in cdns_wdt_probe()
338 wdt->prescaler = CDNS_WDT_PRESCALE_512; in cdns_wdt_probe()
339 wdt->ctrl_clksel = CDNS_WDT_PRESCALE_SELECT_512; in cdns_wdt_probe()
341 wdt->prescaler = CDNS_WDT_PRESCALE_4096; in cdns_wdt_probe()
342 wdt->ctrl_clksel = CDNS_WDT_PRESCALE_SELECT_4096; in cdns_wdt_probe()
345 spin_lock_init(&wdt->io_lock); in cdns_wdt_probe()
354 dev_info(dev, "Xilinx Watchdog Timer with timeout %ds%s\n", in cdns_wdt_probe()
355 cdns_wdt_device->timeout, nowayout ? ", nowayout" : ""); in cdns_wdt_probe()
361 * cdns_wdt_suspend - Stop the device.
370 if (watchdog_active(&wdt->cdns_wdt_device)) { in cdns_wdt_suspend()
371 cdns_wdt_stop(&wdt->cdns_wdt_device); in cdns_wdt_suspend()
372 clk_disable_unprepare(wdt->clk); in cdns_wdt_suspend()
379 * cdns_wdt_resume - Resume the device.
389 if (watchdog_active(&wdt->cdns_wdt_device)) { in cdns_wdt_resume()
390 ret = clk_prepare_enable(wdt->clk); in cdns_wdt_resume()
392 dev_err(dev, "unable to enable clock\n"); in cdns_wdt_resume()
395 cdns_wdt_start(&wdt->cdns_wdt_device); in cdns_wdt_resume()
404 { .compatible = "cdns,wdt-r1p2", },
413 .name = "cdns-wdt",
422 MODULE_DESCRIPTION("Watchdog driver for Cadence WDT");