Lines Matching +full:cmd +full:- +full:timeout +full:- +full:ms

1 /*-
49 #define READ(_sc, _r) bus_read_4((_sc)->res, (_r))
50 #define WRITE(_sc, _r, _v) bus_write_4((_sc)->res, (_r), (_v))
117 {"allwinner,sun4i-a10-wdt", A10_WATCHDOG},
118 {"allwinner,sun6i-a31-wdt", A31_WATCHDOG},
119 {"allwinner,sun20i-d1-wdt", D1_WATCHDOG},
132 switch (ofw_bus_search_compatible(dev, compat_data)->ocd_data) { in aw_wdog_probe()
156 sc->dev = dev; in aw_wdog_attach()
159 sc->res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, RF_ACTIVE); in aw_wdog_attach()
160 if (sc->res == NULL) { in aw_wdog_attach()
167 switch (ofw_bus_search_compatible(dev, compat_data)->ocd_data) { in aw_wdog_attach()
169 sc->wdog_ctrl = A10_WDOG_CTRL; in aw_wdog_attach()
170 sc->wdog_mode = A10_WDOG_MODE; in aw_wdog_attach()
171 sc->wdog_mode_key = 0; in aw_wdog_attach()
172 sc->wdog_mode_intvl_shift = A10_WDOG_MODE_INTVL_SHIFT; in aw_wdog_attach()
173 sc->wdog_mode_en = A10_WDOG_MODE_RST_EN | WDOG_MODE_EN; in aw_wdog_attach()
176 sc->wdog_ctrl = A31_WDOG_CTRL; in aw_wdog_attach()
177 sc->wdog_ctrl_key = A31_WDOG_CTRL_KEY; in aw_wdog_attach()
178 sc->wdog_mode = A31_WDOG_MODE; in aw_wdog_attach()
179 sc->wdog_mode_key = 0; in aw_wdog_attach()
180 sc->wdog_mode_intvl_shift = A31_WDOG_MODE_INTVL_SHIFT; in aw_wdog_attach()
181 sc->wdog_mode_en = WDOG_MODE_EN; in aw_wdog_attach()
182 sc->wdog_config = A31_WDOG_CONFIG; in aw_wdog_attach()
183 sc->wdog_config_value = A31_WDOG_CONFIG_RST_EN_SYSTEM; in aw_wdog_attach()
186 sc->wdog_ctrl = D1_WDOG_CTRL; in aw_wdog_attach()
187 sc->wdog_ctrl_key = D1_WDOG_CTRL_KEY; in aw_wdog_attach()
188 sc->wdog_mode = D1_WDOG_MODE; in aw_wdog_attach()
189 sc->wdog_mode_key = D1_WDOG_MODE_KEY; in aw_wdog_attach()
190 sc->wdog_mode_intvl_shift = D1_WDOG_MODE_INTVL_SHIFT; in aw_wdog_attach()
191 sc->wdog_mode_en = WDOG_MODE_EN; in aw_wdog_attach()
192 sc->wdog_config = D1_WDOG_CONFIG; in aw_wdog_attach()
193 sc->wdog_config_value = D1_WDOG_CONFIG_KEY | D1_WDOG_CONFIG_RST_EN_SYSTEM; in aw_wdog_attach()
196 bus_release_resource(dev, SYS_RES_MEMORY, rid, sc->res); in aw_wdog_attach()
200 mtx_init(&sc->mtx, "AW Watchdog", "aw_wdog", MTX_DEF); in aw_wdog_attach()
203 SHUTDOWN_PRI_LAST - 1); in aw_wdog_attach()
206 WRITE(sc, sc->wdog_mode, sc->wdog_mode_key); in aw_wdog_attach()
212 aw_wdog_watchdog_fn(void *private, u_int cmd, int *error) in aw_wdog_watchdog_fn() argument
215 uint64_t ms; in aw_wdog_watchdog_fn() local
219 mtx_lock(&sc->mtx); in aw_wdog_watchdog_fn()
221 cmd &= WD_INTERVAL; in aw_wdog_watchdog_fn()
223 if (cmd > 0) { in aw_wdog_watchdog_fn()
224 ms = ((uint64_t)1 << (cmd & WD_INTERVAL)) / 1000000; in aw_wdog_watchdog_fn()
227 (ms > wd_intervals[i].milliseconds)) in aw_wdog_watchdog_fn()
230 WRITE(sc, sc->wdog_mode, sc->wdog_mode_key | in aw_wdog_watchdog_fn()
231 (wd_intervals[i].value << sc->wdog_mode_intvl_shift) | in aw_wdog_watchdog_fn()
232 sc->wdog_mode_en); in aw_wdog_watchdog_fn()
233 WRITE(sc, sc->wdog_ctrl, in aw_wdog_watchdog_fn()
234 WDOG_CTRL_RESTART | sc->wdog_ctrl_key); in aw_wdog_watchdog_fn()
235 if (sc->wdog_config) in aw_wdog_watchdog_fn()
236 WRITE(sc, sc->wdog_config, in aw_wdog_watchdog_fn()
237 sc->wdog_config_value); in aw_wdog_watchdog_fn()
245 device_printf(sc->dev, in aw_wdog_watchdog_fn()
246 "Can't arm, timeout is more than 16 sec\n"); in aw_wdog_watchdog_fn()
247 mtx_unlock(&sc->mtx); in aw_wdog_watchdog_fn()
248 WRITE(sc, sc->wdog_mode, sc->wdog_mode_key); in aw_wdog_watchdog_fn()
253 WRITE(sc, sc->wdog_mode, sc->wdog_mode_key); in aw_wdog_watchdog_fn()
255 mtx_unlock(&sc->mtx); in aw_wdog_watchdog_fn()
274 WRITE(aw_wdog_sc, aw_wdog_sc->wdog_mode, aw_wdog_sc->wdog_mode_key | in aw_wdog_watchdog_reset()
275 (wd_intervals[0].value << aw_wdog_sc->wdog_mode_intvl_shift) | in aw_wdog_watchdog_reset()
276 aw_wdog_sc->wdog_mode_en); in aw_wdog_watchdog_reset()
277 if (aw_wdog_sc->wdog_config) in aw_wdog_watchdog_reset()
278 WRITE(aw_wdog_sc, aw_wdog_sc->wdog_config, in aw_wdog_watchdog_reset()
279 aw_wdog_sc->wdog_config_value); in aw_wdog_watchdog_reset()
280 WRITE(aw_wdog_sc, aw_wdog_sc->wdog_ctrl, in aw_wdog_watchdog_reset()
281 WDOG_CTRL_RESTART | aw_wdog_sc->wdog_ctrl_key); in aw_wdog_watchdog_reset()