Lines Matching +full:smbus +full:- +full:timeout +full:- +full:disable

1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
45 * There is one slight problem on non-ACPI or ACPI 1.x systems: we have no
52 * For details about the ICH WDT, see Intel Application Note AP-725
53 * (document no. 292273-001). The WDT is also described in the individual
55 * (document no. 252516-001) sections 9.10 and 9.11.
58 * SoC PMC support by Denir Li <denir.li@cas-well.com>
106 { DEVICEID_ICH8ME, "Intel ICH8M-E watchdog timer", 8, 2 },
112 { DEVICEID_ICH9ME, "Intel ICH9M-E watchdog timer", 9, 2 },
268 { DEVICEID_LPT_LP0, "Intel Lynx Point-LP watchdog timer", 10, 2 },
269 { DEVICEID_LPT_LP1, "Intel Lynx Point-LP watchdog timer", 10, 2 },
270 { DEVICEID_LPT_LP2, "Intel Lynx Point-LP watchdog timer", 10, 2 },
271 { DEVICEID_LPT_LP3, "Intel Lynx Point-LP watchdog timer", 10, 2 },
272 { DEVICEID_LPT_LP4, "Intel Lynx Point-LP watchdog timer", 10, 2 },
273 { DEVICEID_LPT_LP5, "Intel Lynx Point-LP watchdog timer", 10, 2 },
274 { DEVICEID_LPT_LP6, "Intel Lynx Point-LP watchdog timer", 10, 2 },
275 { DEVICEID_LPT_LP7, "Intel Lynx Point-LP watchdog timer", 10, 2 },
276 { DEVICEID_WCPT_LP1, "Intel Wildcat Point-LP watchdog timer", 10, 2 },
277 { DEVICEID_WCPT_LP2, "Intel Wildcat Point-LP watchdog timer", 10, 2 },
278 { DEVICEID_WCPT_LP3, "Intel Wildcat Point-LP watchdog timer", 10, 2 },
279 { DEVICEID_WCPT_LP5, "Intel Wildcat Point-LP watchdog timer", 10, 2 },
280 { DEVICEID_WCPT_LP6, "Intel Wildcat Point-LP watchdog timer", 10, 2 },
281 { DEVICEID_WCPT_LP7, "Intel Wildcat Point-LP watchdog timer", 10, 2 },
282 { DEVICEID_WCPT_LP9, "Intel Wildcat Point-LP watchdog timer", 10, 2 },
299 { DEVICEID_SRPTLP_SMB, "Sunrise Point-LP watchdog timer", 10, 4 },
305 bus_read_1((sc)->tco_res, (off))
307 bus_read_2((sc)->tco_res, (off))
309 bus_read_4((sc)->tco_res, (off))
311 bus_read_4((sc)->smi_res, (off))
313 bus_read_4((sc)->gcs_res, (off))
316 bus_read_4((sc)->gcs_res, (off))
318 bus_read_4((sc)->gc_res, (off))
321 bus_write_1((sc)->tco_res, (off), (val))
323 bus_write_2((sc)->tco_res, (off), (val))
325 bus_write_4((sc)->tco_res, (off), (val))
327 bus_write_4((sc)->smi_res, (off), (val))
329 bus_write_4((sc)->gcs_res, (off), (val))
332 bus_write_4((sc)->gcs_res, (off), (val))
334 bus_write_4((sc)->gc_res, (off), (val))
343 * Disable the watchdog timeout SMI handler.
345 * Apparently, some BIOSes install handlers that reset or disable the
346 * watchdog timer instead of resetting the system, so we disable the SMI
357 * Enable the watchdog timeout SMI handler. See above for details.
391 if (sc->tco_version < 4) in ichwd_sts_reset()
408 sc->active = 1; in ichwd_tmr_enable()
409 ichwd_verbose_printf(sc->device, "timer enabled\n"); in ichwd_tmr_enable()
413 * Disable the watchdog timer. See above for details.
422 sc->active = 0; in ichwd_tmr_disable()
423 ichwd_verbose_printf(sc->device, "timer disabled\n"); in ichwd_tmr_disable()
434 if (sc->tco_version == 1) in ichwd_tmr_reload()
441 * Set the initial timeout value. Note that this must always be followed
445 ichwd_tmr_set(struct ichwd_softc *sc, unsigned int timeout) in ichwd_tmr_set() argument
448 if (timeout < TCO_RLD_TMR_MIN) in ichwd_tmr_set()
449 timeout = TCO_RLD_TMR_MIN; in ichwd_tmr_set()
451 if (sc->tco_version == 1) { in ichwd_tmr_set()
455 if (timeout > TCO_RLD1_TMR_MAX) in ichwd_tmr_set()
456 timeout = TCO_RLD1_TMR_MAX; in ichwd_tmr_set()
457 tmr_val8 |= timeout; in ichwd_tmr_set()
463 if (timeout > TCO_RLD2_TMR_MAX) in ichwd_tmr_set()
464 timeout = TCO_RLD2_TMR_MAX; in ichwd_tmr_set()
465 tmr_val16 |= timeout; in ichwd_tmr_set()
469 sc->timeout = timeout; in ichwd_tmr_set()
471 ichwd_verbose_printf(sc->device, "timeout set to %u ticks\n", timeout); in ichwd_tmr_set()
481 switch (sc->tco_version) { in ichwd_clear_noreboot()
483 status = pci_read_config(sc->ich, ICH_GEN_STA, 1); in ichwd_clear_noreboot()
485 pci_write_config(sc->ich, ICH_GEN_STA, status, 1); in ichwd_clear_noreboot()
486 status = pci_read_config(sc->ich, ICH_GEN_STA, 1); in ichwd_clear_noreboot()
515 ichwd_verbose_printf(sc->device, in ichwd_clear_noreboot()
517 sc->tco_version); in ichwd_clear_noreboot()
522 device_printf(sc->device, in ichwd_clear_noreboot()
529 * Watchdog event handler - called by the framework to enable or disable
530 * the watchdog or change the initial timeout value.
536 unsigned int timeout; in ichwd_event() local
538 /* convert from power-of-two-ns to WDT ticks */ in ichwd_event()
541 if (sc->tco_version == 3) { in ichwd_event()
542 timeout = ((uint64_t)1 << cmd) / ICHWD_TCO_V3_TICK; in ichwd_event()
544 timeout = ((uint64_t)1 << cmd) / ICHWD_TICK; in ichwd_event()
548 if (!sc->active) in ichwd_event()
550 if (timeout != sc->timeout) in ichwd_event()
551 ichwd_tmr_set(sc, timeout); in ichwd_event()
555 if (sc->active) in ichwd_event()
575 for (id = ichwd_devices; id->desc != NULL; ++id) { in ichwd_find_ich_lpc_bridge()
576 if (devid == id->device) { in ichwd_find_ich_lpc_bridge()
594 * Check if SMBus controller provides TCO configuration. in ichwd_find_smb_dev()
605 for (id = ichwd_smb_devices; id->desc != NULL; ++id) { in ichwd_find_smb_dev()
606 if (devid == id->device) { in ichwd_find_smb_dev()
638 KASSERT(id_p->tco_version >= 1, in ichwd_identify()
639 ("unexpected TCO version %d", id_p->tco_version)); in ichwd_identify()
640 KASSERT(id_p->tco_version != 4 || smb != NULL, in ichwd_identify()
641 ("could not find PCI SMBus device for TCOv4")); in ichwd_identify()
642 KASSERT(id_p->tco_version >= 4 || ich != NULL, in ichwd_identify()
643 ("could not find PCI LPC bridge device for TCOv1-3")); in ichwd_identify()
646 if ((dev = device_find_child(parent, driver->name, 0)) == NULL) in ichwd_identify()
647 dev = BUS_ADD_CHILD(parent, 0, driver->name, 0); in ichwd_identify()
652 switch (id_p->tco_version) { in ichwd_identify()
664 id_p->tco_version); in ichwd_identify()
675 id_p->tco_version); in ichwd_identify()
683 id_p->tco_version); in ichwd_identify()
692 id_p->tco_version, rc); in ichwd_identify()
710 * within the SMBus target port, ID 0xc6. in ichwd_identify()
718 id_p->tco_version, rc); in ichwd_identify()
725 id_p->tco_version); in ichwd_identify()
743 device_set_desc_copy(dev, id_p->desc); in ichwd_probe()
761 sc->ich_version = id_p->ich_version; in ichwd_smb_attach()
762 sc->tco_version = id_p->tco_version; in ichwd_smb_attach()
765 sc->tco_rid = 0; in ichwd_smb_attach()
766 sc->tco_res = bus_alloc_resource_any(dev, SYS_RES_IOPORT, &sc->tco_rid, in ichwd_smb_attach()
768 if (sc->tco_res == NULL) { in ichwd_smb_attach()
777 sc->gc_rid = 1; in ichwd_smb_attach()
778 sc->gc_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &sc->gc_rid, in ichwd_smb_attach()
780 if (sc->gc_res == NULL) { in ichwd_smb_attach()
789 if (id_p->quirks & PMC_HIDDEN) { in ichwd_smb_attach()
809 sc->smi_rid = 2; in ichwd_smb_attach()
810 sc->smi_res = bus_alloc_resource(dev, SYS_RES_IOPORT, &sc->smi_rid, in ichwd_smb_attach()
811 acpi_base + SMI_BASE, acpi_base + SMI_BASE + SMI_LEN - 1, SMI_LEN, in ichwd_smb_attach()
813 if (sc->smi_res == NULL) { in ichwd_smb_attach()
835 sc->ich = ich; in ichwd_lpc_attach()
836 sc->ich_version = id_p->ich_version; in ichwd_lpc_attach()
837 sc->tco_version = id_p->tco_version; in ichwd_lpc_attach()
847 sc->smi_rid = 0; in ichwd_lpc_attach()
848 sc->smi_res = bus_alloc_resource(dev, SYS_RES_IOPORT, &sc->smi_rid, in ichwd_lpc_attach()
849 pmbase + SMI_BASE, pmbase + SMI_BASE + SMI_LEN - 1, SMI_LEN, in ichwd_lpc_attach()
851 if (sc->smi_res == NULL) { in ichwd_lpc_attach()
856 sc->tco_rid = 1; in ichwd_lpc_attach()
857 sc->tco_res = bus_alloc_resource(dev, SYS_RES_IOPORT, &sc->tco_rid, in ichwd_lpc_attach()
858 pmbase + TCO_BASE, pmbase + TCO_BASE + TCO_LEN - 1, TCO_LEN, in ichwd_lpc_attach()
860 if (sc->tco_res == NULL) { in ichwd_lpc_attach()
865 sc->gcs_rid = 0; in ichwd_lpc_attach()
866 if (sc->tco_version >= 2) { in ichwd_lpc_attach()
867 sc->gcs_res = bus_alloc_resource_any(ich, SYS_RES_MEMORY, in ichwd_lpc_attach()
868 &sc->gcs_rid, RF_ACTIVE|RF_SHAREABLE); in ichwd_lpc_attach()
869 if (sc->gcs_res == NULL) { in ichwd_lpc_attach()
884 sc->device = dev; in ichwd_attach()
893 * Determine if we are coming up after a watchdog-induced reset. Some in ichwd_attach()
899 "resuming after hardware watchdog timeout\n"); in ichwd_attach()
908 sc->ev_tag = EVENTHANDLER_REGISTER(watchdog_list, ichwd_event, sc, 0); in ichwd_attach()
910 /* disable the SMI handler */ in ichwd_attach()
911 sc->smi_enabled = ichwd_smi_is_enabled(sc); in ichwd_attach()
917 if (sc->tco_res != NULL) in ichwd_attach()
919 sc->tco_rid, sc->tco_res); in ichwd_attach()
920 if (sc->smi_res != NULL) in ichwd_attach()
922 sc->smi_rid, sc->smi_res); in ichwd_attach()
923 if (sc->gcs_res != NULL) in ichwd_attach()
924 bus_release_resource(sc->ich, SYS_RES_MEMORY, in ichwd_attach()
925 sc->gcs_rid, sc->gcs_res); in ichwd_attach()
926 if (sc->gc_res != NULL) in ichwd_attach()
928 sc->gc_rid, sc->gc_res); in ichwd_attach()
941 if (sc->active) in ichwd_detach()
945 if (sc->smi_enabled != 0) in ichwd_detach()
949 if (sc->ev_tag != NULL) in ichwd_detach()
950 EVENTHANDLER_DEREGISTER(watchdog_list, sc->ev_tag); in ichwd_detach()
951 sc->ev_tag = NULL; in ichwd_detach()
957 bus_release_resource(dev, SYS_RES_IOPORT, sc->tco_rid, sc->tco_res); in ichwd_detach()
958 bus_release_resource(dev, SYS_RES_IOPORT, sc->smi_rid, sc->smi_res); in ichwd_detach()
961 if (sc->gcs_res) in ichwd_detach()
962 bus_release_resource(sc->ich, SYS_RES_MEMORY, sc->gcs_rid, in ichwd_detach()
963 sc->gcs_res); in ichwd_detach()
964 if (sc->gc_res) in ichwd_detach()
965 bus_release_resource(dev, SYS_RES_MEMORY, sc->gc_rid, in ichwd_detach()
966 sc->gc_res); in ichwd_detach()