Lines Matching +full:watchdog +full:- +full:timer
1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
30 * This is a driver for watchdog timer present in AMD SB600/SB7xx/SB8xx
34 * - AMD SB600 Register Reference Guide, Public Version, Rev. 3.03 (SB600 RRG)
35 …* http://www.amd.com/us-en/assets/content_type/white_papers_and_tech_docs/46155_sb600_rrg_pub_3.…
36 * - AMD SB700/710/750 Register Reference Guide (RRG)
38 * - AMD SB700/710/750 Register Programming Requirements (RPR)
40 * - AMD SB800-Series Southbridges Register Reference Guide (RRG)
42 * Please see the following for Watchdog Resource Table specification:
43 * - Watchdog Timer Hardware Requirements for Windows Server 2003 (WDRT)
44 * http://www.microsoft.com/whdc/system/sysinternals/watchdog.mspx
45 * AMD SB600/SB7xx/SB8xx watchdog hardware seems to conform to the above
64 #include <sys/watchdog.h>
71 * Registers in the Watchdog IO space.
149 return (bus_read_4(sc->res_ctrl, 0)); in wdctrl_read()
155 bus_write_4(sc->res_ctrl, 0, val); in wdctrl_write()
161 return (bus_read_4(sc->res_count, 0)); in wdcount_read()
167 bus_write_4(sc->res_count, 0, val); in wdcount_write()
178 sc->active = 1; in amdsbwd_tmr_enable()
179 amdsbwd_verbose_printf(sc->dev, "timer enabled\n"); in amdsbwd_tmr_enable()
190 sc->active = 0; in amdsbwd_tmr_disable()
191 amdsbwd_verbose_printf(sc->dev, "timer disabled\n"); in amdsbwd_tmr_disable()
210 sc->timeout = timeout; in amdsbwd_tmr_set()
211 amdsbwd_verbose_printf(sc->dev, "timeout set to %u ticks\n", timeout); in amdsbwd_tmr_set()
224 timeout = (uint64_t)1 << (cmd - WD_TO_1MS); in amdsbwd_event()
225 timeout = timeout / sc->ms_per_tick; in amdsbwd_event()
230 /* For a too long timeout stop the timer. */ in amdsbwd_event()
231 if (timeout > sc->max_ticks) in amdsbwd_event()
238 if (timeout != sc->timeout) in amdsbwd_event()
240 if (!sc->active) in amdsbwd_event()
245 if (sc->active) in amdsbwd_event()
294 device_printf(dev, "Previous Reset was caused by Watchdog\n"); in amdsbwd_probe_sb7xx()
299 *addr |= pmio_read(pmres, AMDSB_PM_WDT_BASE_MSB - i); in amdsbwd_probe_sb7xx()
303 /* Set watchdog timer tick to 1s. */ in amdsbwd_probe_sb7xx()
309 /* Enable watchdog device (in stopped state). */ in amdsbwd_probe_sb7xx()
315 * XXX TODO: Ensure that watchdog decode is enabled in amdsbwd_probe_sb7xx()
318 device_set_desc(dev, "AMD SB600/SB7xx Watchdog Timer"); in amdsbwd_probe_sb7xx()
335 for (i = 3; i >= 0; i--) { in amdsbwd_probe_sb8xx()
342 device_printf(dev, "Previous Reset was caused by Watchdog\n"); in amdsbwd_probe_sb8xx()
347 *addr |= pmio_read(pmres, AMDSB8_PM_WDT_EN + 3 - i); in amdsbwd_probe_sb8xx()
351 /* Set watchdog timer tick to 1s. */ in amdsbwd_probe_sb8xx()
362 * Enable watchdog device (in stopped state) in amdsbwd_probe_sb8xx()
373 device_set_desc(dev, "AMD SB8xx/SB9xx/Axx Watchdog Timer"); in amdsbwd_probe_sb8xx()
382 * Enable decoding of watchdog MMIO address. in amdsbwd_probe_fch41()
394 /* Fixed offset for the watchdog within ACPI MMIO range. */ in amdsbwd_probe_fch41()
398 /* Special fixed MMIO range for the watchdog. */ in amdsbwd_probe_fch41()
403 * Set watchdog timer tick to 1s and in amdsbwd_probe_fch41()
404 * enable the watchdog device (in stopped state). in amdsbwd_probe_fch41()
417 device_set_descf(dev, "%s FCH Rev 41h+ Watchdog Timer", in amdsbwd_probe_fch41()
487 sc->max_ticks = UINT16_MAX; in amdsbwd_attach_sb()
488 sc->rid_ctrl = 0; in amdsbwd_attach_sb()
489 sc->rid_count = 1; in amdsbwd_attach_sb()
491 sc->ms_per_tick = 1000; in amdsbwd_attach_sb()
493 sc->res_ctrl = bus_alloc_resource_any(dev, SYS_RES_MEMORY, in amdsbwd_attach_sb()
494 &sc->rid_ctrl, RF_ACTIVE); in amdsbwd_attach_sb()
495 if (sc->res_ctrl == NULL) { in amdsbwd_attach_sb()
499 sc->res_count = bus_alloc_resource_any(dev, SYS_RES_MEMORY, in amdsbwd_attach_sb()
500 &sc->rid_count, RF_ACTIVE); in amdsbwd_attach_sb()
501 if (sc->res_count == NULL) { in amdsbwd_attach_sb()
515 sc->dev = dev; in amdsbwd_attach()
526 /* Setup initial state of Watchdog Control. */ in amdsbwd_attach()
530 device_printf(dev, "watchdog hardware is disabled\n"); in amdsbwd_attach()
534 sc->ev_tag = EVENTHANDLER_REGISTER(watchdog_list, amdsbwd_event, sc, in amdsbwd_attach()
550 if (sc->ev_tag != NULL) in amdsbwd_detach()
551 EVENTHANDLER_DEREGISTER(watchdog_list, sc->ev_tag); in amdsbwd_detach()
553 if (sc->active) in amdsbwd_detach()
556 if (sc->res_ctrl != NULL) in amdsbwd_detach()
557 bus_release_resource(dev, SYS_RES_MEMORY, sc->rid_ctrl, in amdsbwd_detach()
558 sc->res_ctrl); in amdsbwd_detach()
560 if (sc->res_count != NULL) in amdsbwd_detach()
561 bus_release_resource(dev, SYS_RES_MEMORY, sc->rid_count, in amdsbwd_detach()
562 sc->res_count); in amdsbwd_detach()
587 if (sc->active) { in amdsbwd_resume()
588 amdsbwd_tmr_set(sc, sc->timeout); in amdsbwd_resume()