Lines Matching +full:dbg +full:- +full:halt
1 // SPDX-License-Identifier: GPL-2.0-only
5 * Copyright (C) 2015-2019 Microchip Technology Inc. and its subsidiaries
26 #define WDT_SEC2TICKS(s) ((s) ? (((s) << 8) - 1) : 0)
51 #define wdt_enabled (!(wdt->mr & AT91_WDT_WDDIS))
54 readl_relaxed((wdt)->reg_base + (field))
66 while (time_before(jiffies, wdt->last_ping + WDT_DELAY)) in wdt_write()
68 writel_relaxed(val, wdt->reg_base + field); in wdt_write()
69 wdt->last_ping = jiffies; in wdt_write()
74 if (time_before(jiffies, wdt->last_ping + WDT_DELAY)) in wdt_write_nosleep()
76 writel_relaxed(val, wdt->reg_base + field); in wdt_write_nosleep()
77 wdt->last_ping = jiffies; in wdt_write_nosleep()
84 if (wdt->sam9x60_support) { in sama5d4_wdt_start()
85 writel_relaxed(wdt->ir, wdt->reg_base + AT91_SAM9X60_IER); in sama5d4_wdt_start()
86 wdt->mr &= ~AT91_SAM9X60_WDDIS; in sama5d4_wdt_start()
88 wdt->mr &= ~AT91_WDT_WDDIS; in sama5d4_wdt_start()
90 wdt_write(wdt, AT91_WDT_MR, wdt->mr); in sama5d4_wdt_start()
99 if (wdt->sam9x60_support) { in sama5d4_wdt_stop()
100 writel_relaxed(wdt->ir, wdt->reg_base + AT91_SAM9X60_IDR); in sama5d4_wdt_stop()
101 wdt->mr |= AT91_SAM9X60_WDDIS; in sama5d4_wdt_stop()
103 wdt->mr |= AT91_WDT_WDDIS; in sama5d4_wdt_stop()
105 wdt_write(wdt, AT91_WDT_MR, wdt->mr); in sama5d4_wdt_stop()
125 if (wdt->sam9x60_support) { in sama5d4_wdt_set_timeout()
129 wdd->timeout = timeout; in sama5d4_wdt_set_timeout()
133 wdt->mr &= ~AT91_WDT_WDV; in sama5d4_wdt_set_timeout()
134 wdt->mr |= AT91_WDT_SET_WDV(value); in sama5d4_wdt_set_timeout()
144 wdt_write(wdt, AT91_WDT_MR, wdt->mr & ~AT91_WDT_WDDIS); in sama5d4_wdt_set_timeout()
146 wdd->timeout = timeout; in sama5d4_wdt_set_timeout()
169 if (wdt->sam9x60_support) in sama5d4_wdt_irq_handler()
187 if (wdt->sam9x60_support) in of_sama5d4_wdt_init()
188 wdt->mr = AT91_SAM9X60_WDDIS; in of_sama5d4_wdt_init()
190 wdt->mr = AT91_WDT_WDDIS; in of_sama5d4_wdt_init()
192 if (!of_property_read_string(np, "atmel,watchdog-type", &tmp) && in of_sama5d4_wdt_init()
194 wdt->need_irq = true; in of_sama5d4_wdt_init()
196 if (of_property_read_bool(np, "atmel,idle-halt")) in of_sama5d4_wdt_init()
197 wdt->mr |= AT91_WDT_WDIDLEHLT; in of_sama5d4_wdt_init()
199 if (of_property_read_bool(np, "atmel,dbg-halt")) in of_sama5d4_wdt_init()
200 wdt->mr |= AT91_WDT_WDDBGHLT; in of_sama5d4_wdt_init()
218 if (wdt->sam9x60_support && (!(reg & AT91_SAM9X60_WDDIS))) in sama5d4_wdt_init()
221 else if (!wdt->sam9x60_support && in sama5d4_wdt_init()
227 if (wdt->sam9x60_support) { in sama5d4_wdt_init()
228 if (wdt->need_irq) in sama5d4_wdt_init()
229 wdt->ir = AT91_SAM9X60_PERINT; in sama5d4_wdt_init()
231 wdt->mr |= AT91_SAM9X60_PERIODRST; in sama5d4_wdt_init()
233 wdt_write(wdt, AT91_SAM9X60_IER, wdt->ir); in sama5d4_wdt_init()
236 wdt->mr |= AT91_WDT_SET_WDD(WDT_SEC2TICKS(MAX_WDT_TIMEOUT)); in sama5d4_wdt_init()
237 wdt->mr |= AT91_WDT_SET_WDV(val); in sama5d4_wdt_init()
239 if (wdt->need_irq) in sama5d4_wdt_init()
240 wdt->mr |= AT91_WDT_WDFIEN; in sama5d4_wdt_init()
242 wdt->mr |= AT91_WDT_WDRSTEN; in sama5d4_wdt_init()
245 wdt_write_nosleep(wdt, AT91_WDT_MR, wdt->mr); in sama5d4_wdt_init()
252 struct device *dev = &pdev->dev; in sama5d4_wdt_probe()
262 return -ENOMEM; in sama5d4_wdt_probe()
264 wdd = &wdt->wdd; in sama5d4_wdt_probe()
265 wdd->timeout = WDT_DEFAULT_TIMEOUT; in sama5d4_wdt_probe()
266 wdd->info = &sama5d4_wdt_info; in sama5d4_wdt_probe()
267 wdd->ops = &sama5d4_wdt_ops; in sama5d4_wdt_probe()
268 wdd->min_timeout = MIN_WDT_TIMEOUT; in sama5d4_wdt_probe()
269 wdd->max_timeout = MAX_WDT_TIMEOUT; in sama5d4_wdt_probe()
270 wdt->last_ping = jiffies; in sama5d4_wdt_probe()
272 if (of_device_is_compatible(dev->of_node, "microchip,sam9x60-wdt") || in sama5d4_wdt_probe()
273 of_device_is_compatible(dev->of_node, "microchip,sama7g5-wdt")) in sama5d4_wdt_probe()
274 wdt->sam9x60_support = true; in sama5d4_wdt_probe()
282 wdt->reg_base = regs; in sama5d4_wdt_probe()
284 ret = of_sama5d4_wdt_init(dev->of_node, wdt); in sama5d4_wdt_probe()
288 if (wdt->need_irq) { in sama5d4_wdt_probe()
289 irq = irq_of_parse_and_map(dev->of_node, 0); in sama5d4_wdt_probe()
292 wdt->need_irq = false; in sama5d4_wdt_probe()
296 if (wdt->need_irq) { in sama5d4_wdt_probe()
299 IRQF_NO_SUSPEND, pdev->name, pdev); in sama5d4_wdt_probe()
310 wdt->mr &= ~AT91_WDT_WDDIS; in sama5d4_wdt_probe()
311 set_bit(WDOG_HW_RUNNING, &wdd->status); in sama5d4_wdt_probe()
328 wdd->timeout, nowayout); in sama5d4_wdt_probe()
335 .compatible = "atmel,sama5d4-wdt",
338 .compatible = "microchip,sam9x60-wdt",
341 .compatible = "microchip,sama7g5-wdt",
352 if (watchdog_active(&wdt->wdd)) in sama5d4_wdt_suspend_late()
353 sama5d4_wdt_stop(&wdt->wdd); in sama5d4_wdt_suspend_late()
369 if (watchdog_active(&wdt->wdd)) in sama5d4_wdt_resume_early()
370 sama5d4_wdt_start(&wdt->wdd); in sama5d4_wdt_resume_early()