Lines Matching full:wdt
3 * Cadence WDT driver - Used by Xilinx Zynq
85 static inline void cdns_wdt_writereg(struct cdns_wdt *wdt, u32 offset, u32 val) in cdns_wdt_writereg() argument
87 writel_relaxed(val, wdt->regs + offset); in cdns_wdt_writereg()
92 /* Register Offsets for the WDT */
102 #define CDNS_WDT_ZMR_WDEN_MASK 0x00000001 /* Enable the WDT */
126 struct cdns_wdt *wdt = watchdog_get_drvdata(wdd); in cdns_wdt_stop() local
128 spin_lock(&wdt->io_lock); in cdns_wdt_stop()
129 cdns_wdt_writereg(wdt, CDNS_WDT_ZMR_OFFSET, in cdns_wdt_stop()
131 spin_unlock(&wdt->io_lock); in cdns_wdt_stop()
147 struct cdns_wdt *wdt = watchdog_get_drvdata(wdd); in cdns_wdt_reload() local
149 spin_lock(&wdt->io_lock); in cdns_wdt_reload()
150 cdns_wdt_writereg(wdt, CDNS_WDT_RESTART_OFFSET, in cdns_wdt_reload()
152 spin_unlock(&wdt->io_lock); in cdns_wdt_reload()
169 * Sets the WDT (WDEN bit) and either the Reset signal(RSTEN bit)
177 struct cdns_wdt *wdt = watchdog_get_drvdata(wdd); in cdns_wdt_start() local
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()
193 cdns_wdt_writereg(wdt, CDNS_WDT_ZMR_OFFSET, in cdns_wdt_start()
199 data = count | CDNS_WDT_REGISTER_ACCESS_KEY | wdt->ctrl_clksel; in cdns_wdt_start()
200 cdns_wdt_writereg(wdt, CDNS_WDT_CCR_OFFSET, data); in cdns_wdt_start()
205 if (wdt->rst) { in cdns_wdt_start()
212 cdns_wdt_writereg(wdt, CDNS_WDT_ZMR_OFFSET, data); in cdns_wdt_start()
213 cdns_wdt_writereg(wdt, CDNS_WDT_RESTART_OFFSET, in cdns_wdt_start()
215 spin_unlock(&wdt->io_lock); in cdns_wdt_start()
296 struct cdns_wdt *wdt; in cdns_wdt_probe() local
299 wdt = devm_kzalloc(dev, sizeof(*wdt), GFP_KERNEL); in cdns_wdt_probe()
300 if (!wdt) in cdns_wdt_probe()
303 cdns_wdt_device = &wdt->cdns_wdt_device; in cdns_wdt_probe()
310 wdt->regs = devm_platform_ioremap_resource(pdev, 0); in cdns_wdt_probe()
311 if (IS_ERR(wdt->regs)) in cdns_wdt_probe()
312 return PTR_ERR(wdt->regs); in cdns_wdt_probe()
315 wdt->rst = of_property_read_bool(dev->of_node, "reset-on-timeout"); in cdns_wdt_probe()
317 if (!wdt->rst && irq >= 0) { in cdns_wdt_probe()
334 watchdog_set_drvdata(cdns_wdt_device, wdt); in cdns_wdt_probe()
336 wdt->clk = devm_clk_get(dev, NULL); in cdns_wdt_probe()
337 if (IS_ERR(wdt->clk)) in cdns_wdt_probe()
338 return dev_err_probe(dev, PTR_ERR(wdt->clk), in cdns_wdt_probe()
341 ret = clk_prepare_enable(wdt->clk); in cdns_wdt_probe()
347 wdt->clk); in cdns_wdt_probe()
351 clock_f = clk_get_rate(wdt->clk); in cdns_wdt_probe()
353 wdt->prescaler = CDNS_WDT_PRESCALE_512; in cdns_wdt_probe()
354 wdt->ctrl_clksel = CDNS_WDT_PRESCALE_SELECT_512; in cdns_wdt_probe()
356 wdt->prescaler = CDNS_WDT_PRESCALE_4096; in cdns_wdt_probe()
357 wdt->ctrl_clksel = CDNS_WDT_PRESCALE_SELECT_4096; in cdns_wdt_probe()
360 spin_lock_init(&wdt->io_lock); in cdns_wdt_probe()
367 platform_set_drvdata(pdev, wdt); in cdns_wdt_probe()
383 struct cdns_wdt *wdt = dev_get_drvdata(dev); in cdns_wdt_suspend() local
385 if (watchdog_active(&wdt->cdns_wdt_device)) { in cdns_wdt_suspend()
386 cdns_wdt_stop(&wdt->cdns_wdt_device); in cdns_wdt_suspend()
387 clk_disable_unprepare(wdt->clk); in cdns_wdt_suspend()
402 struct cdns_wdt *wdt = dev_get_drvdata(dev); in cdns_wdt_resume() local
404 if (watchdog_active(&wdt->cdns_wdt_device)) { in cdns_wdt_resume()
405 ret = clk_prepare_enable(wdt->clk); in cdns_wdt_resume()
410 cdns_wdt_start(&wdt->cdns_wdt_device); in cdns_wdt_resume()
419 { .compatible = "cdns,wdt-r1p2", },
428 .name = "cdns-wdt",
437 MODULE_DESCRIPTION("Watchdog driver for Cadence WDT");