Lines Matching refs:watchdog
22 #include <linux/watchdog.h>
76 watchdog signal */
77 #define WATCHDOG_F71862FG_PIN 63 /* default watchdog reset output
106 MODULE_PARM_DESC(nowayout, "Disable watchdog shutdown on close");
110 MODULE_PARM_DESC(start_withtimeout, "Start watchdog timer on module load with"
152 char caused_reboot; /* last reboot was by the watchdog */
155 static struct watchdog_data watchdog = {
156 .lock = __MUTEX_INITIALIZER(watchdog.lock),
225 pr_err("watchdog timeout out of range\n");
229 mutex_lock(&watchdog.lock);
232 watchdog.timer_val = DIV_ROUND_UP(timeout, 60);
233 watchdog.minutes_mode = true;
234 timeout = watchdog.timer_val * 60;
236 watchdog.timer_val = timeout;
237 watchdog.minutes_mode = false;
240 watchdog.timeout = timeout;
242 mutex_unlock(&watchdog.lock);
252 if (watchdog.type == f71868) {
258 mutex_lock(&watchdog.lock);
261 watchdog.pulse_val = 0;
263 watchdog.pulse_val = 1;
265 watchdog.pulse_val = 2;
267 watchdog.pulse_val = 3;
274 watchdog.pulse_mode = pw;
277 mutex_unlock(&watchdog.lock);
285 mutex_lock(&watchdog.lock);
286 err = superio_enter(watchdog.sioaddr);
289 superio_select(watchdog.sioaddr, SIO_F71808FG_LD_WDT);
291 if (watchdog.minutes_mode)
293 superio_set_bit(watchdog.sioaddr, F71808FG_REG_WDT_CONF,
297 superio_clear_bit(watchdog.sioaddr, F71808FG_REG_WDT_CONF,
301 superio_outb(watchdog.sioaddr, F71808FG_REG_WD_TIME,
302 watchdog.timer_val);
304 superio_exit(watchdog.sioaddr);
307 mutex_unlock(&watchdog.lock);
316 /* Make sure we don't die as soon as the watchdog is enabled below */
321 mutex_lock(&watchdog.lock);
322 err = superio_enter(watchdog.sioaddr);
325 superio_select(watchdog.sioaddr, SIO_F71808FG_LD_WDT);
328 switch (watchdog.type) {
331 superio_clear_bit(watchdog.sioaddr, SIO_REG_MFUNCT2, 3);
332 superio_clear_bit(watchdog.sioaddr, SIO_REG_MFUNCT3, 3);
338 superio_clear_bit(watchdog.sioaddr, SIO_REG_ROM_ADDR_SEL, 6);
339 superio_set_bit(watchdog.sioaddr, SIO_REG_MFUNCT3, 4);
341 superio_set_bit(watchdog.sioaddr, SIO_REG_MFUNCT1, 1);
348 superio_clear_bit(watchdog.sioaddr, SIO_REG_MFUNCT1, 4);
353 superio_set_bit(watchdog.sioaddr, SIO_REG_MFUNCT1, 1);
358 superio_outb(watchdog.sioaddr, SIO_REG_MFUNCT3,
359 superio_inb(watchdog.sioaddr, SIO_REG_MFUNCT3) & 0xcf);
364 superio_clear_bit(watchdog.sioaddr, SIO_REG_CLOCK_SEL, 3);
366 superio_outb(watchdog.sioaddr, SIO_REG_TSI_LEVEL_SEL, 0x5f &
367 superio_inb(watchdog.sioaddr, SIO_REG_TSI_LEVEL_SEL));
372 superio_clear_bit(watchdog.sioaddr, SIO_REG_MFUNCT3, 5);
382 tmp = superio_inb(watchdog.sioaddr, SIO_F81866_REG_PORT_SEL);
385 superio_outb(watchdog.sioaddr, SIO_F81866_REG_PORT_SEL, tmp);
387 superio_clear_bit(watchdog.sioaddr, SIO_F81866_REG_GPIO1, 5);
399 superio_select(watchdog.sioaddr, SIO_F71808FG_LD_WDT);
400 superio_set_bit(watchdog.sioaddr, SIO_REG_ENABLE, 0);
402 if (watchdog.type == f81865 || watchdog.type == f81866)
403 superio_set_bit(watchdog.sioaddr, F81865_REG_WDO_CONF,
406 superio_set_bit(watchdog.sioaddr, F71808FG_REG_WDO_CONF,
409 superio_set_bit(watchdog.sioaddr, F71808FG_REG_WDT_CONF,
412 if (watchdog.pulse_mode) {
414 u8 wdt_conf = superio_inb(watchdog.sioaddr,
418 wdt_conf = (wdt_conf & 0xfc) | (watchdog.pulse_val & 0x03);
422 superio_outb(watchdog.sioaddr, F71808FG_REG_WDT_CONF,
426 superio_clear_bit(watchdog.sioaddr, F71808FG_REG_WDT_CONF,
431 superio_exit(watchdog.sioaddr);
433 mutex_unlock(&watchdog.lock);
442 mutex_lock(&watchdog.lock);
443 err = superio_enter(watchdog.sioaddr);
446 superio_select(watchdog.sioaddr, SIO_F71808FG_LD_WDT);
448 superio_clear_bit(watchdog.sioaddr, F71808FG_REG_WDT_CONF,
451 superio_exit(watchdog.sioaddr);
454 mutex_unlock(&watchdog.lock);
463 mutex_lock(&watchdog.lock);
464 status = (watchdog.caused_reboot) ? WDIOF_CARDRESET : 0;
465 mutex_unlock(&watchdog.lock);
473 * if we fail to determine the watchdog's status assume it to be
478 mutex_lock(&watchdog.lock);
479 if (superio_enter(watchdog.sioaddr))
481 superio_select(watchdog.sioaddr, SIO_F71808FG_LD_WDT);
483 is_running = (superio_inb(watchdog.sioaddr, SIO_REG_ENABLE) & BIT(0))
484 && (superio_inb(watchdog.sioaddr, F71808FG_REG_WDT_CONF)
487 superio_exit(watchdog.sioaddr);
490 mutex_unlock(&watchdog.lock);
494 /* /dev/watchdog api */
500 /* If the watchdog is alive we don't need to start it again */
501 if (test_and_set_bit(0, &watchdog.opened))
506 clear_bit(0, &watchdog.opened);
513 watchdog.expect_close = 0;
519 clear_bit(0, &watchdog.opened);
521 if (!watchdog.expect_close) {
523 pr_crit("Unexpected close, not stopping watchdog!\n");
532 * @file: file handle to the watchdog
537 * A write to a watchdog device is defined as a keepalive signal. Any
560 mutex_lock(&watchdog.lock);
561 watchdog.expect_close = expect_close;
562 mutex_unlock(&watchdog.lock);
575 * @cmd: watchdog command
578 * The watchdog API defines a common set of functions for all watchdogs
596 return copy_to_user(uarg.ident, &watchdog.ident,
597 sizeof(watchdog.ident)) ? -EFAULT : 0;
634 return put_user(watchdog.timeout, uarg.i);
662 .name = "watchdog",
674 /* No need to lock watchdog.lock here because no entry points
677 watchdog.sioaddr = sioaddr;
678 watchdog.ident.options = WDIOF_MAGICCLOSE
682 snprintf(watchdog.ident.identity,
683 sizeof(watchdog.ident.identity), "%s watchdog",
684 f71808e_names[watchdog.type]);
689 superio_select(watchdog.sioaddr, SIO_F71808FG_LD_WDT);
692 watchdog.caused_reboot = wdt_conf & BIT(F71808FG_FLAG_WDTMOUT_STS);
731 pr_err("cannot start watchdog timer\n");
735 mutex_lock(&watchdog.lock);
739 superio_select(watchdog.sioaddr, SIO_F71808FG_LD_WDT);
756 mutex_unlock(&watchdog.lock);
761 pr_info("watchdog started with initial timeout of %u sec\n",
768 mutex_unlock(&watchdog.lock);
794 watchdog.type = f71808fg;
797 watchdog.type = f71862fg;
800 watchdog.type = f71868;
804 watchdog.type = f71869;
807 watchdog.type = f71882fg;
810 watchdog.type = f71889fg;
813 /* Confirmed (by datasheet) not to have a watchdog. */
817 watchdog.type = f81803;
820 watchdog.type = f81865;
823 watchdog.type = f81866;
832 pr_info("Found %s watchdog chip, revision %d\n",
833 f71808e_names[watchdog.type],