Lines Matching +full:watchdog +full:- +full:timers

1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
41 #include <sys/watchdog.h>
69 #define READ(_sc, _r) bus_space_read_4((_sc)->bst, (_sc)->bsh, (_r))
70 #define WRITE(_sc, _r, _v) bus_space_write_4((_sc)->bst, (_sc)->bsh, (_r), (_v))
97 if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0) in apple_wdog_probe()
100 device_set_desc(dev, "Apple Watchdog"); in apple_wdog_probe()
112 sc->dev = dev; in apple_wdog_attach()
115 sc->res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, RF_ACTIVE); in apple_wdog_attach()
116 if (sc->res == NULL) { in apple_wdog_attach()
121 sc->bst = rman_get_bustag(sc->res); in apple_wdog_attach()
122 sc->bsh = rman_get_bushandle(sc->res); in apple_wdog_attach()
124 error = clk_get_by_ofw_index(dev, 0, 0, &sc->clk); in apple_wdog_attach()
129 error = clk_enable(sc->clk); in apple_wdog_attach()
134 error = clk_get_freq(sc->clk, &sc->clk_freq); in apple_wdog_attach()
140 mtx_init(&sc->mtx, "Apple Watchdog", "apple_wdog", MTX_DEF); in apple_wdog_attach()
145 /* Reset the watchdog timers. */ in apple_wdog_attach()
152 clk_disable(sc->clk); in apple_wdog_attach()
154 bus_release_resource(dev, SYS_RES_MEMORY, 0, sc->res); in apple_wdog_attach()
166 mtx_lock(&sc->mtx); in apple_wdog_watchdog_fn()
172 sec_max = UINT_MAX / sc->clk_freq; in apple_wdog_watchdog_fn()
176 * disable watchdog as watchdog(9) requires in apple_wdog_watchdog_fn()
178 device_printf(sc->dev, in apple_wdog_watchdog_fn()
179 "Can't arm, timeout must be between 1-%d seconds\n", in apple_wdog_watchdog_fn()
182 mtx_unlock(&sc->mtx); in apple_wdog_watchdog_fn()
187 ticks = sec * sc->clk_freq; in apple_wdog_watchdog_fn()
196 mtx_unlock(&sc->mtx); in apple_wdog_watchdog_fn()
214 /* Wait for watchdog timeout; should take milliseconds. */ in apple_wdog_reboot_system()