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

1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
61 #define DWWDT_READ4(sc, reg) bus_read_4((sc)->sc_mem_res, (reg))
63 bus_write_4((sc)->sc_mem_res, (reg), (val))
67 * (pre-restart delay)
88 { "snps,dw-wdt", 1 },
102 &dwwdt_debug_enabled, 0, "Enable debug mode");
139 device_printf(dev, "Clock: %s\n", clk_get_name(sc->sc_clk)); in dwwdt_debug()
140 device_printf(dev, " FREQ: %lu\n", sc->sc_clk_freq); in dwwdt_debug()
156 /* Enable watchdog */ in dwwdt_start()
160 sc->sc_status = DWWDT_RUNNING; in dwwdt_start()
167 sc->sc_status = DWWDT_STOPPED; in dwwdt_stop()
187 if (dwwdt_prevent_restart || sc->sc_status == DWWDT_STOPPED) { in dwwdt_intr()
197 panic("dwwdt pre-timeout interrupt"); in dwwdt_intr()
204 const int exponent = flsl(sc->sc_clk_freq); in dwwdt_event()
209 val = MAX(0, timeout + exponent - DWWDT_EXP_OFFSET + 1); in dwwdt_event()
225 dwwdt_debug(sc->sc_dev); in dwwdt_event()
234 if (!ofw_bus_search_compatible(dev, compat_data)->ocd_data) in dwwdt_probe()
247 sc->sc_dev = dev; in dwwdt_attach()
249 sc->sc_mem_rid = 0; in dwwdt_attach()
250 sc->sc_mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, in dwwdt_attach()
251 &sc->sc_mem_rid, RF_ACTIVE); in dwwdt_attach()
252 if (sc->sc_mem_res == NULL) { in dwwdt_attach()
257 sc->sc_irq_rid = 0; in dwwdt_attach()
258 sc->sc_irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, in dwwdt_attach()
259 &sc->sc_irq_rid, RF_ACTIVE); in dwwdt_attach()
260 if (sc->sc_irq_res == NULL) { in dwwdt_attach()
265 sc->sc_intr_cookie = NULL; in dwwdt_attach()
266 if (bus_setup_intr(dev, sc->sc_irq_res, INTR_MPSAFE | INTR_TYPE_MISC, in dwwdt_attach()
267 NULL, dwwdt_intr, sc, &sc->sc_intr_cookie) != 0) { in dwwdt_attach()
272 if (clk_get_by_ofw_index(dev, 0, 0, &sc->sc_clk) != 0) { in dwwdt_attach()
277 if (clk_enable(sc->sc_clk) != 0) { in dwwdt_attach()
278 device_printf(dev, "cannot enable clock\n"); in dwwdt_attach()
282 if (clk_get_freq(sc->sc_clk, &sc->sc_clk_freq) != 0) { in dwwdt_attach()
287 if (sc->sc_clk_freq == 0UL) in dwwdt_attach()
290 sc->sc_evtag = EVENTHANDLER_REGISTER(watchdog_list, dwwdt_event, sc, 0); in dwwdt_attach()
291 sc->sc_status = DWWDT_STOPPED; in dwwdt_attach()
297 clk_release(sc->sc_clk); in dwwdt_attach()
299 bus_teardown_intr(dev, sc->sc_irq_res, sc->sc_intr_cookie); in dwwdt_attach()
301 bus_release_resource(dev, SYS_RES_IRQ, sc->sc_irq_rid, sc->sc_irq_res); in dwwdt_attach()
303 bus_release_resource(dev, SYS_RES_MEMORY, sc->sc_mem_rid, in dwwdt_attach()
304 sc->sc_mem_res); in dwwdt_attach()
317 * Once started it cannot be stopped. Prevent module unload in dwwdt_detach()
327 EVENTHANDLER_DEREGISTER(watchdog_list, sc->sc_evtag); in dwwdt_detach()
328 sc->sc_evtag = NULL; in dwwdt_detach()
330 if (sc->sc_clk != NULL) in dwwdt_detach()
331 clk_release(sc->sc_clk); in dwwdt_detach()
333 if (sc->sc_intr_cookie != NULL) in dwwdt_detach()
334 bus_teardown_intr(dev, sc->sc_irq_res, sc->sc_intr_cookie); in dwwdt_detach()
336 if (sc->sc_irq_res) { in dwwdt_detach()
337 bus_release_resource(dev, SYS_RES_IRQ, sc->sc_irq_rid, in dwwdt_detach()
338 sc->sc_irq_res); in dwwdt_detach()
341 if (sc->sc_mem_res) { in dwwdt_detach()
342 bus_release_resource(dev, SYS_RES_MEMORY, sc->sc_mem_rid, in dwwdt_detach()
343 sc->sc_mem_res); in dwwdt_detach()