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

32 #define INTERNAL_REGS_MASK		~(SZ_1M - 1)
72 struct watchdog_device wdt; member
86 dev->clk = clk_get(&pdev->dev, NULL); in orion_wdt_clock_init()
87 if (IS_ERR(dev->clk)) in orion_wdt_clock_init()
88 return PTR_ERR(dev->clk); in orion_wdt_clock_init()
89 ret = clk_prepare_enable(dev->clk); in orion_wdt_clock_init()
91 clk_put(dev->clk); in orion_wdt_clock_init()
95 dev->clk_rate = clk_get_rate(dev->clk); in orion_wdt_clock_init()
104 dev->clk = clk_get(&pdev->dev, NULL); in armada370_wdt_clock_init()
105 if (IS_ERR(dev->clk)) in armada370_wdt_clock_init()
106 return PTR_ERR(dev->clk); in armada370_wdt_clock_init()
107 ret = clk_prepare_enable(dev->clk); in armada370_wdt_clock_init()
109 clk_put(dev->clk); in armada370_wdt_clock_init()
114 atomic_io_modify(dev->reg + TIMER_CTRL, in armada370_wdt_clock_init()
118 dev->clk_rate = clk_get_rate(dev->clk) / WDT_A370_RATIO; in armada370_wdt_clock_init()
127 dev->clk = of_clk_get_by_name(pdev->dev.of_node, "fixed"); in armada375_wdt_clock_init()
128 if (!IS_ERR(dev->clk)) { in armada375_wdt_clock_init()
129 ret = clk_prepare_enable(dev->clk); in armada375_wdt_clock_init()
131 clk_put(dev->clk); in armada375_wdt_clock_init()
135 atomic_io_modify(dev->reg + TIMER_CTRL, in armada375_wdt_clock_init()
138 dev->clk_rate = clk_get_rate(dev->clk); in armada375_wdt_clock_init()
144 dev->clk = clk_get(&pdev->dev, NULL); in armada375_wdt_clock_init()
145 if (IS_ERR(dev->clk)) in armada375_wdt_clock_init()
146 return PTR_ERR(dev->clk); in armada375_wdt_clock_init()
148 ret = clk_prepare_enable(dev->clk); in armada375_wdt_clock_init()
150 clk_put(dev->clk); in armada375_wdt_clock_init()
154 atomic_io_modify(dev->reg + TIMER_CTRL, in armada375_wdt_clock_init()
157 dev->clk_rate = clk_get_rate(dev->clk) / WDT_A370_RATIO; in armada375_wdt_clock_init()
168 dev->clk = of_clk_get_by_name(pdev->dev.of_node, "fixed"); in armadaxp_wdt_clock_init()
169 if (IS_ERR(dev->clk)) in armadaxp_wdt_clock_init()
170 return PTR_ERR(dev->clk); in armadaxp_wdt_clock_init()
171 ret = clk_prepare_enable(dev->clk); in armadaxp_wdt_clock_init()
173 clk_put(dev->clk); in armadaxp_wdt_clock_init()
177 /* Fix the wdt and timer1 clock frequency to 25MHz */ in armadaxp_wdt_clock_init()
179 atomic_io_modify(dev->reg + TIMER_CTRL, val, val); in armadaxp_wdt_clock_init()
181 dev->clk_rate = clk_get_rate(dev->clk); in armadaxp_wdt_clock_init()
189 writel(dev->clk_rate * wdt_dev->timeout, in orion_wdt_ping()
190 dev->reg + dev->data->wdt_counter_offset); in orion_wdt_ping()
191 if (dev->wdt.info->options & WDIOF_PRETIMEOUT) in orion_wdt_ping()
192 writel(dev->clk_rate * (wdt_dev->timeout - wdt_dev->pretimeout), in orion_wdt_ping()
193 dev->reg + TIMER1_VAL_OFF); in orion_wdt_ping()
204 writel(dev->clk_rate * wdt_dev->timeout, in armada375_start()
205 dev->reg + dev->data->wdt_counter_offset); in armada375_start()
206 if (dev->wdt.info->options & WDIOF_PRETIMEOUT) in armada375_start()
207 writel(dev->clk_rate * (wdt_dev->timeout - wdt_dev->pretimeout), in armada375_start()
208 dev->reg + TIMER1_VAL_OFF); in armada375_start()
211 atomic_io_modify(dev->reg + TIMER_A370_STATUS, WDT_A370_EXPIRED, 0); in armada375_start()
213 /* Enable watchdog timer */ in armada375_start()
214 reg = dev->data->wdt_enable_bit; in armada375_start()
215 if (dev->wdt.info->options & WDIOF_PRETIMEOUT) in armada375_start()
217 atomic_io_modify(dev->reg + TIMER_CTRL, reg, reg); in armada375_start()
219 /* Enable reset on watchdog */ in armada375_start()
220 reg = readl(dev->rstout); in armada375_start()
221 reg |= dev->data->rstout_enable_bit; in armada375_start()
222 writel(reg, dev->rstout); in armada375_start()
224 atomic_io_modify(dev->rstout_mask, dev->data->rstout_mask_bit, 0); in armada375_start()
234 writel(dev->clk_rate * wdt_dev->timeout, in armada370_start()
235 dev->reg + dev->data->wdt_counter_offset); in armada370_start()
238 atomic_io_modify(dev->reg + TIMER_A370_STATUS, WDT_A370_EXPIRED, 0); in armada370_start()
240 /* Enable watchdog timer */ in armada370_start()
241 reg = dev->data->wdt_enable_bit; in armada370_start()
242 if (dev->wdt.info->options & WDIOF_PRETIMEOUT) in armada370_start()
244 atomic_io_modify(dev->reg + TIMER_CTRL, reg, reg); in armada370_start()
246 /* Enable reset on watchdog */ in armada370_start()
247 reg = readl(dev->rstout); in armada370_start()
248 reg |= dev->data->rstout_enable_bit; in armada370_start()
249 writel(reg, dev->rstout); in armada370_start()
258 writel(dev->clk_rate * wdt_dev->timeout, in orion_start()
259 dev->reg + dev->data->wdt_counter_offset); in orion_start()
261 /* Enable watchdog timer */ in orion_start()
262 atomic_io_modify(dev->reg + TIMER_CTRL, dev->data->wdt_enable_bit, in orion_start()
263 dev->data->wdt_enable_bit); in orion_start()
265 /* Enable reset on watchdog */ in orion_start()
266 atomic_io_modify(dev->rstout, dev->data->rstout_enable_bit, in orion_start()
267 dev->data->rstout_enable_bit); in orion_start()
276 /* There are some per-SoC quirks to handle */ in orion_wdt_start()
277 return dev->data->start(wdt_dev); in orion_wdt_start()
285 atomic_io_modify(dev->rstout, dev->data->rstout_enable_bit, 0); in orion_stop()
288 atomic_io_modify(dev->reg + TIMER_CTRL, dev->data->wdt_enable_bit, 0); in orion_stop()
299 atomic_io_modify(dev->rstout_mask, dev->data->rstout_mask_bit, in armada375_stop()
300 dev->data->rstout_mask_bit); in armada375_stop()
301 reg = readl(dev->rstout); in armada375_stop()
302 reg &= ~dev->data->rstout_enable_bit; in armada375_stop()
303 writel(reg, dev->rstout); in armada375_stop()
306 mask = dev->data->wdt_enable_bit; in armada375_stop()
307 if (wdt_dev->info->options & WDIOF_PRETIMEOUT) in armada375_stop()
309 atomic_io_modify(dev->reg + TIMER_CTRL, mask, 0); in armada375_stop()
320 reg = readl(dev->rstout); in armada370_stop()
321 reg &= ~dev->data->rstout_enable_bit; in armada370_stop()
322 writel(reg, dev->rstout); in armada370_stop()
325 mask = dev->data->wdt_enable_bit; in armada370_stop()
326 if (wdt_dev->info->options & WDIOF_PRETIMEOUT) in armada370_stop()
328 atomic_io_modify(dev->reg + TIMER_CTRL, mask, 0); in armada370_stop()
337 return dev->data->stop(wdt_dev); in orion_wdt_stop()
344 enabled = readl(dev->rstout) & dev->data->rstout_enable_bit; in orion_enabled()
345 running = readl(dev->reg + TIMER_CTRL) & dev->data->wdt_enable_bit; in orion_enabled()
354 masked = readl(dev->rstout_mask) & dev->data->rstout_mask_bit; in armada375_enabled()
355 enabled = readl(dev->rstout) & dev->data->rstout_enable_bit; in armada375_enabled()
356 running = readl(dev->reg + TIMER_CTRL) & dev->data->wdt_enable_bit; in armada375_enabled()
365 return dev->data->enabled(dev); in orion_wdt_enabled()
371 return readl(dev->reg + dev->data->wdt_counter_offset) / dev->clk_rate; in orion_wdt_get_timeleft()
397 atomic_io_modify(dev->reg + TIMER_A370_STATUS, in orion_wdt_pre_irq()
399 watchdog_notify_pretimeout(&dev->wdt); in orion_wdt_pre_irq()
417 return devm_ioremap(&pdev->dev, res->start, in orion_wdt_ioremap_rstout()
423 return devm_ioremap(&pdev->dev, rstout, 0x4); in orion_wdt_ioremap_rstout()
480 .compatible = "marvell,orion-wdt",
484 .compatible = "marvell,armada-370-wdt",
488 .compatible = "marvell,armada-xp-wdt",
492 .compatible = "marvell,armada-375-wdt",
496 .compatible = "marvell,armada-380-wdt",
506 struct device_node *node = pdev->dev.of_node; in orion_wdt_get_regs()
511 return -ENODEV; in orion_wdt_get_regs()
512 dev->reg = devm_ioremap(&pdev->dev, res->start, in orion_wdt_get_regs()
514 if (!dev->reg) in orion_wdt_get_regs()
515 return -ENOMEM; in orion_wdt_get_regs()
518 if (of_device_is_compatible(node, "marvell,orion-wdt")) { in orion_wdt_get_regs()
520 dev->rstout = orion_wdt_ioremap_rstout(pdev, res->start & in orion_wdt_get_regs()
522 if (!dev->rstout) in orion_wdt_get_regs()
523 return -ENODEV; in orion_wdt_get_regs()
525 } else if (of_device_is_compatible(node, "marvell,armada-370-wdt") || in orion_wdt_get_regs()
526 of_device_is_compatible(node, "marvell,armada-xp-wdt")) { in orion_wdt_get_regs()
529 dev->rstout = devm_platform_ioremap_resource(pdev, 1); in orion_wdt_get_regs()
530 if (IS_ERR(dev->rstout)) in orion_wdt_get_regs()
531 return PTR_ERR(dev->rstout); in orion_wdt_get_regs()
533 } else if (of_device_is_compatible(node, "marvell,armada-375-wdt") || in orion_wdt_get_regs()
534 of_device_is_compatible(node, "marvell,armada-380-wdt")) { in orion_wdt_get_regs()
537 dev->rstout = devm_platform_ioremap_resource(pdev, 1); in orion_wdt_get_regs()
538 if (IS_ERR(dev->rstout)) in orion_wdt_get_regs()
539 return PTR_ERR(dev->rstout); in orion_wdt_get_regs()
543 return -ENODEV; in orion_wdt_get_regs()
544 dev->rstout_mask = devm_ioremap(&pdev->dev, res->start, in orion_wdt_get_regs()
546 if (!dev->rstout_mask) in orion_wdt_get_regs()
547 return -ENOMEM; in orion_wdt_get_regs()
550 return -ENODEV; in orion_wdt_get_regs()
563 dev = devm_kzalloc(&pdev->dev, sizeof(struct orion_watchdog), in orion_wdt_probe()
566 return -ENOMEM; in orion_wdt_probe()
568 match = of_match_device(orion_wdt_of_match_table, &pdev->dev); in orion_wdt_probe()
573 dev->wdt.info = &orion_wdt_info; in orion_wdt_probe()
574 dev->wdt.ops = &orion_wdt_ops; in orion_wdt_probe()
575 dev->wdt.min_timeout = 1; in orion_wdt_probe()
576 dev->data = match->data; in orion_wdt_probe()
582 ret = dev->data->clock_init(pdev, dev); in orion_wdt_probe()
584 dev_err(&pdev->dev, "cannot initialize clock\n"); in orion_wdt_probe()
588 wdt_max_duration = WDT_MAX_CYCLE_COUNT / dev->clk_rate; in orion_wdt_probe()
590 dev->wdt.timeout = wdt_max_duration; in orion_wdt_probe()
591 dev->wdt.max_timeout = wdt_max_duration; in orion_wdt_probe()
592 dev->wdt.parent = &pdev->dev; in orion_wdt_probe()
593 watchdog_init_timeout(&dev->wdt, heartbeat, &pdev->dev); in orion_wdt_probe()
595 platform_set_drvdata(pdev, &dev->wdt); in orion_wdt_probe()
596 watchdog_set_drvdata(&dev->wdt, dev); in orion_wdt_probe()
601 * removed and re-inserted, or if the bootloader explicitly in orion_wdt_probe()
604 if (!orion_wdt_enabled(&dev->wdt)) in orion_wdt_probe()
605 orion_wdt_stop(&dev->wdt); in orion_wdt_probe()
607 set_bit(WDOG_HW_RUNNING, &dev->wdt.status); in orion_wdt_probe()
616 ret = devm_request_irq(&pdev->dev, irq, orion_wdt_irq, 0, in orion_wdt_probe()
617 pdev->name, dev); in orion_wdt_probe()
619 dev_err(&pdev->dev, "failed to request IRQ\n"); in orion_wdt_probe()
628 ret = devm_request_irq(&pdev->dev, irq, orion_wdt_pre_irq, in orion_wdt_probe()
629 0, pdev->name, dev); in orion_wdt_probe()
631 dev_err(&pdev->dev, "failed to request IRQ\n"); in orion_wdt_probe()
637 watchdog_set_nowayout(&dev->wdt, nowayout); in orion_wdt_probe()
638 ret = watchdog_register_device(&dev->wdt); in orion_wdt_probe()
643 dev->wdt.timeout, nowayout ? ", nowayout" : ""); in orion_wdt_probe()
647 clk_disable_unprepare(dev->clk); in orion_wdt_probe()
648 clk_put(dev->clk); in orion_wdt_probe()
658 clk_disable_unprepare(dev->clk); in orion_wdt_remove()
659 clk_put(dev->clk); in orion_wdt_remove()
688 MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default="