Lines Matching +full:chip +full:- +full:to +full:- +full:chip

1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * With minor abstractions it might be possible to add support for other
33 * different Winbond Super I/O chips as well. Winbond seems to have four
34 * different types of chips, four different ways to get into extended config
75 /* CRF5: Watchdog scale, P20. Mapped to reg_1. */
81 /* CRF6: Watchdog Timeout (0 == off). Mapped to reg_timeout. */
84 /* CRF7: Watchdog mouse, keyb, force, .. Mapped to reg_2. */
88 #define WB_LDN8_CRF7_FORCE 0x20 /* 1: force timeout (self-clear) */
100 enum chips chip; member
107 * Special feature to let the watchdog fire at a different
108 * timeout as set by watchdog(4) but still use that API to
109 * re-load it periodically.
114 * Space to save current state temporary and for sysctls.
115 * We want to know the timeout value and usually need two
117 * register as these might be different by chip.
126 enum chips chip; member
131 .chip = w83627hf,
136 .chip = w83627s,
141 .chip = w83697hf,
146 .chip = w83697ug,
151 .chip = w83637hf,
156 .chip = w83627thf,
161 .chip = w83687thf,
166 .chip = w83627ehf,
171 .chip = w83627dhg,
176 .chip = w83627uhg,
181 .chip = w83667hg,
186 .chip = w83627dhg_p,
187 .descr = "Winbond 83627DHG-P",
191 .chip = w83667hg_b,
192 .descr = "Winbond 83667HG-B",
196 .chip = nct6775,
201 .chip = nct6776,
206 .chip = nct6102,
211 .chip = nct6779,
216 .chip = nct6791,
221 .chip = nct6792,
226 .chip = nct6793,
231 .chip = nct6795,
253 sbuf_printf(&sb, "CR%02X 0x%02x ", sc->ctl_reg, sc->reg_1); in sysctl_wb_debug()
254 sbuf_printf(&sb, "CR%02X 0x%02x ", sc->time_reg, sc->reg_timeout); in sysctl_wb_debug()
255 sbuf_printf(&sb, "CR%02X 0x%02x", sc->csr_reg, sc->reg_2); in sysctl_wb_debug()
265 * be marked CTLFLAG_SKIP to not show up by default.
274 sc->reg_1 = superio_read(sc->dev, sc->ctl_reg); in sysctl_wb_debug_current()
275 sc->reg_timeout = superio_read(sc->dev, sc->time_reg); in sysctl_wb_debug_current()
276 sc->reg_2 = superio_read(sc->dev, sc->csr_reg); in sysctl_wb_debug_current()
282 * Sysctl handlers to force a watchdog timeout or to test the NMI functionality
287 * lot of boards have jumpers to change the action on watchdog timeout or
289 * XXX-BZ notyet: currently no general infrastructure exists to do this.
300 val = sc->test_nmi; in sysctl_wb_force_test_nmi()
305 if (error || !req->newptr) in sysctl_wb_force_test_nmi()
313 sc->test_nmi = 0; in sysctl_wb_force_test_nmi()
322 sc->test_nmi = 1; in sysctl_wb_force_test_nmi()
325 /* Force watchdog to fire. */ in sysctl_wb_force_test_nmi()
326 sc->reg_2 = superio_read(sc->dev, sc->csr_reg); in sysctl_wb_force_test_nmi()
327 sc->reg_2 |= WB_LDN8_CRF7_FORCE; in sysctl_wb_force_test_nmi()
328 superio_write(sc->dev, sc->csr_reg, sc->reg_2); in sysctl_wb_force_test_nmi()
336 * Note: it is the responsibility of the caller to update the registers
343 device_printf(sc->dev, "%s%sWatchdog %sabled. %s" in wb_print_state()
347 (sc->reg_timeout > 0x00) ? "en" : "dis", in wb_print_state()
348 (sc->reg_2 & WB_LDN8_CRF7_TS) ? "Watchdog fired. " : "", in wb_print_state()
349 (sc->reg_1 & WB_LDN8_CRF5_SCALE) ? 60 : 1, in wb_print_state()
350 sc->reg_timeout, in wb_print_state()
351 (sc->reg_timeout > 0x00) ? "<" : "", in wb_print_state()
352 sc->reg_timeout * ((sc->reg_1 & WB_LDN8_CRF5_SCALE) ? 60 : 1), in wb_print_state()
353 (sc->reg_timeout > 0x00) ? " left" : "", in wb_print_state()
354 sc->ctl_reg, sc->reg_1, sc->csr_reg, sc->reg_2); in wb_print_state()
368 * to strange results as we do not check the input of the sysctl. in wb_set_watchdog()
370 if (sc->timeout_override > 0) in wb_set_watchdog()
371 timeout = sc->timeout_override; in wb_set_watchdog()
378 if (sc->debug_verbose) in wb_set_watchdog()
383 sc->reg_timeout = 0; in wb_set_watchdog()
384 superio_write(sc->dev, sc->time_reg, sc->reg_timeout); in wb_set_watchdog()
388 sc->reg_1 = superio_read(sc->dev, sc->ctl_reg); in wb_set_watchdog()
391 /* Set scaling factor to 60s. */ in wb_set_watchdog()
392 sc->reg_1 |= WB_LDN8_CRF5_SCALE; in wb_set_watchdog()
393 sc->reg_timeout = (timeout / 60); in wb_set_watchdog()
395 sc->reg_timeout++; in wb_set_watchdog()
397 /* Set scaling factor to 1s. */ in wb_set_watchdog()
398 sc->reg_1 &= ~WB_LDN8_CRF5_SCALE; in wb_set_watchdog()
399 sc->reg_timeout = timeout; in wb_set_watchdog()
402 /* In case we fired before we need to clear to fire again. */ in wb_set_watchdog()
403 sc->reg_2 = superio_read(sc->dev, sc->csr_reg); in wb_set_watchdog()
404 if (sc->reg_2 & WB_LDN8_CRF7_TS) { in wb_set_watchdog()
405 sc->reg_2 &= ~WB_LDN8_CRF7_TS; in wb_set_watchdog()
406 superio_write(sc->dev, sc->csr_reg, sc->reg_2); in wb_set_watchdog()
410 superio_write(sc->dev, sc->ctl_reg, sc->reg_1); in wb_set_watchdog()
413 superio_write(sc->dev, sc->time_reg, sc->reg_timeout); in wb_set_watchdog()
416 if (sc->debug_verbose) in wb_set_watchdog()
422 * watchdog(9) EVENTHANDLER function implementation to (re)load the counter
447 /* On error, try to make sure the WD is disabled. */ in wb_watchdog_fn()
455 /* Failed to disable watchdog. */ in wb_watchdog_fn()
479 sc->chip = wb_devs[j].chip; in wb_probe()
488 "unrecognized chip: devid 0x%02x, revid 0x%02x\n", in wb_probe()
504 sc->dev = dev; in wb_attach()
509 switch (sc->chip) { in wb_attach()
512 sc->ctl_reg = 0xf3; in wb_attach()
513 sc->time_reg = 0xf4; in wb_attach()
514 sc->csr_reg = 0xf7; in wb_attach()
517 sc->ctl_reg = 0xf0; in wb_attach()
518 sc->time_reg = 0xf1; in wb_attach()
519 sc->csr_reg = 0xf2; in wb_attach()
522 sc->ctl_reg = 0xf5; in wb_attach()
523 sc->time_reg = 0xf6; in wb_attach()
524 sc->csr_reg = 0xf7; in wb_attach()
528 switch (sc->chip) { in wb_attach()
532 superio_write(dev, 0x2B, t); /* set GPIO24 to WDT0 */ in wb_attach()
535 /* Set pin 119 to WDTO# mode (= CR29, WDT0) */ in wb_attach()
541 /* Set pin 118 to WDTO# mode */ in wb_attach()
547 superio_write(dev, 0x2B, t); /* set GPIO3 to WDT0 */ in wb_attach()
551 t = superio_read(dev, 0x2D) & ~0x01; /* PIN77 -> WDT0# */ in wb_attach()
552 superio_write(dev, 0x2D, t); /* set GPIO5 to WDT0 */ in wb_attach()
553 t = superio_read(dev, sc->ctl_reg); in wb_attach()
555 * to the KBRST# pin */ in wb_attach()
556 superio_write(dev, sc->ctl_reg, t); in wb_attach()
561 t = superio_read(dev, 0x2C) & ~0x80; /* PIN47 -> WDT0# */ in wb_attach()
582 t = superio_read(dev, sc->ctl_reg); in wb_attach()
584 * to the KBRST# pin */ in wb_attach()
585 superio_write(dev, sc->ctl_reg, t); in wb_attach()
592 sc->reg_1 = superio_read(dev, sc->ctl_reg); in wb_attach()
593 sc->reg_timeout = superio_read(dev, sc->time_reg); in wb_attach()
594 sc->reg_2 = superio_read(dev, sc->csr_reg); in wb_attach()
597 if (bootverbose || (sc->reg_timeout > 0x00)) in wb_attach()
600 sc->reg_1 &= ~WB_LDN8_CRF5_KEYB_P20; in wb_attach()
601 sc->reg_1 |= WB_LDN8_CRF5_KBRST; in wb_attach()
602 superio_write(dev, sc->ctl_reg, sc->reg_1); in wb_attach()
609 sc->reg_2 &= ~(WB_LDN8_CRF7_MOUSE|WB_LDN8_CRF7_TS); in wb_attach()
610 superio_write(dev, sc->csr_reg, sc->reg_2); in wb_attach()
615 sc->timeout_override = timeout; in wb_attach()
620 "timeout_override", CTLFLAG_RW, &sc->timeout_override, 0, in wb_attach()
623 "debug_verbose", CTLFLAG_RW, &sc->debug_verbose, 0, in wb_attach()
635 sysctl_wb_force_test_nmi, "I", "Enable to force watchdog to fire."); in wb_attach()
638 sc->ev_tag = EVENTHANDLER_REGISTER(watchdog_list, wb_watchdog_fn, sc, in wb_attach()
655 if (sc->ev_tag) in wb_detach()
656 EVENTHANDLER_DEREGISTER(watchdog_list, sc->ev_tag); in wb_detach()