Lines Matching full:watchdog

22 #include <linux/watchdog.h>
26 #define SIO_F71808FG_LD_WDT 0x07 /* Watchdog timer logical device */
76 watchdog signal */
77 #define WATCHDOG_F71862FG_PIN 63 /* default watchdog reset output
88 "Watchdog timeout in seconds. 1<= timeout <="
95 "Watchdog signal pulse width. 0(=level), 1, 25, 30, 125, 150, 5000 or 6000 ms"
101 "Watchdog f71862fg reset output pin configuration. Choose pin 56 or 63"
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 = { variable
156 .lock = __MUTEX_INITIALIZER(watchdog.lock),
225 pr_err("watchdog timeout out of range\n"); in watchdog_set_timeout()
229 mutex_lock(&watchdog.lock); in watchdog_set_timeout()
231 watchdog.timeout = timeout; in watchdog_set_timeout()
233 watchdog.timer_val = DIV_ROUND_UP(timeout, 60); in watchdog_set_timeout()
234 watchdog.minutes_mode = true; in watchdog_set_timeout()
236 watchdog.timer_val = timeout; in watchdog_set_timeout()
237 watchdog.minutes_mode = false; in watchdog_set_timeout()
240 mutex_unlock(&watchdog.lock); in watchdog_set_timeout()
250 if (watchdog.type == f71868) { in watchdog_set_pulse_width()
256 mutex_lock(&watchdog.lock); in watchdog_set_pulse_width()
259 watchdog.pulse_val = 0; in watchdog_set_pulse_width()
261 watchdog.pulse_val = 1; in watchdog_set_pulse_width()
263 watchdog.pulse_val = 2; in watchdog_set_pulse_width()
265 watchdog.pulse_val = 3; in watchdog_set_pulse_width()
272 watchdog.pulse_mode = pw; in watchdog_set_pulse_width()
275 mutex_unlock(&watchdog.lock); in watchdog_set_pulse_width()
283 mutex_lock(&watchdog.lock); in watchdog_keepalive()
284 err = superio_enter(watchdog.sioaddr); in watchdog_keepalive()
287 superio_select(watchdog.sioaddr, SIO_F71808FG_LD_WDT); in watchdog_keepalive()
289 if (watchdog.minutes_mode) in watchdog_keepalive()
291 superio_set_bit(watchdog.sioaddr, F71808FG_REG_WDT_CONF, in watchdog_keepalive()
295 superio_clear_bit(watchdog.sioaddr, F71808FG_REG_WDT_CONF, in watchdog_keepalive()
299 superio_outb(watchdog.sioaddr, F71808FG_REG_WD_TIME, in watchdog_keepalive()
300 watchdog.timer_val); in watchdog_keepalive()
302 superio_exit(watchdog.sioaddr); in watchdog_keepalive()
305 mutex_unlock(&watchdog.lock); in watchdog_keepalive()
314 /* Make sure we don't die as soon as the watchdog is enabled below */ in watchdog_start()
319 mutex_lock(&watchdog.lock); in watchdog_start()
320 err = superio_enter(watchdog.sioaddr); in watchdog_start()
323 superio_select(watchdog.sioaddr, SIO_F71808FG_LD_WDT); in watchdog_start()
325 /* Watchdog pin configuration */ in watchdog_start()
326 switch (watchdog.type) { in watchdog_start()
329 superio_clear_bit(watchdog.sioaddr, SIO_REG_MFUNCT2, 3); in watchdog_start()
330 superio_clear_bit(watchdog.sioaddr, SIO_REG_MFUNCT3, 3); in watchdog_start()
336 superio_clear_bit(watchdog.sioaddr, SIO_REG_ROM_ADDR_SEL, 6); in watchdog_start()
337 superio_set_bit(watchdog.sioaddr, SIO_REG_MFUNCT3, 4); in watchdog_start()
339 superio_set_bit(watchdog.sioaddr, SIO_REG_MFUNCT1, 1); in watchdog_start()
346 superio_clear_bit(watchdog.sioaddr, SIO_REG_MFUNCT1, 4); in watchdog_start()
351 superio_set_bit(watchdog.sioaddr, SIO_REG_MFUNCT1, 1); in watchdog_start()
356 superio_outb(watchdog.sioaddr, SIO_REG_MFUNCT3, in watchdog_start()
357 superio_inb(watchdog.sioaddr, SIO_REG_MFUNCT3) & 0xcf); in watchdog_start()
362 superio_clear_bit(watchdog.sioaddr, SIO_REG_CLOCK_SEL, 3); in watchdog_start()
364 superio_outb(watchdog.sioaddr, SIO_REG_TSI_LEVEL_SEL, 0x5f & in watchdog_start()
365 superio_inb(watchdog.sioaddr, SIO_REG_TSI_LEVEL_SEL)); in watchdog_start()
370 superio_clear_bit(watchdog.sioaddr, SIO_REG_MFUNCT3, 5); in watchdog_start()
380 tmp = superio_inb(watchdog.sioaddr, SIO_F81866_REG_PORT_SEL); in watchdog_start()
383 superio_outb(watchdog.sioaddr, SIO_F81866_REG_PORT_SEL, tmp); in watchdog_start()
385 superio_clear_bit(watchdog.sioaddr, SIO_F81866_REG_GPIO1, 5); in watchdog_start()
397 superio_select(watchdog.sioaddr, SIO_F71808FG_LD_WDT); in watchdog_start()
398 superio_set_bit(watchdog.sioaddr, SIO_REG_ENABLE, 0); in watchdog_start()
400 if (watchdog.type == f81865 || watchdog.type == f81866) in watchdog_start()
401 superio_set_bit(watchdog.sioaddr, F81865_REG_WDO_CONF, in watchdog_start()
404 superio_set_bit(watchdog.sioaddr, F71808FG_REG_WDO_CONF, in watchdog_start()
407 superio_set_bit(watchdog.sioaddr, F71808FG_REG_WDT_CONF, in watchdog_start()
410 if (watchdog.pulse_mode) { in watchdog_start()
412 u8 wdt_conf = superio_inb(watchdog.sioaddr, in watchdog_start()
416 wdt_conf = (wdt_conf & 0xfc) | (watchdog.pulse_val & 0x03); in watchdog_start()
420 superio_outb(watchdog.sioaddr, F71808FG_REG_WDT_CONF, in watchdog_start()
424 superio_clear_bit(watchdog.sioaddr, F71808FG_REG_WDT_CONF, in watchdog_start()
429 superio_exit(watchdog.sioaddr); in watchdog_start()
431 mutex_unlock(&watchdog.lock); in watchdog_start()
440 mutex_lock(&watchdog.lock); in watchdog_stop()
441 err = superio_enter(watchdog.sioaddr); in watchdog_stop()
444 superio_select(watchdog.sioaddr, SIO_F71808FG_LD_WDT); in watchdog_stop()
446 superio_clear_bit(watchdog.sioaddr, F71808FG_REG_WDT_CONF, in watchdog_stop()
449 superio_exit(watchdog.sioaddr); in watchdog_stop()
452 mutex_unlock(&watchdog.lock); in watchdog_stop()
461 mutex_lock(&watchdog.lock); in watchdog_get_status()
462 status = (watchdog.caused_reboot) ? WDIOF_CARDRESET : 0; in watchdog_get_status()
463 mutex_unlock(&watchdog.lock); in watchdog_get_status()
471 * if we fail to determine the watchdog's status assume it to be in watchdog_is_running()
476 mutex_lock(&watchdog.lock); in watchdog_is_running()
477 if (superio_enter(watchdog.sioaddr)) in watchdog_is_running()
479 superio_select(watchdog.sioaddr, SIO_F71808FG_LD_WDT); in watchdog_is_running()
481 is_running = (superio_inb(watchdog.sioaddr, SIO_REG_ENABLE) & BIT(0)) in watchdog_is_running()
482 && (superio_inb(watchdog.sioaddr, F71808FG_REG_WDT_CONF) in watchdog_is_running()
485 superio_exit(watchdog.sioaddr); in watchdog_is_running()
488 mutex_unlock(&watchdog.lock); in watchdog_is_running()
492 /* /dev/watchdog api */
498 /* If the watchdog is alive we don't need to start it again */ in watchdog_open()
499 if (test_and_set_bit(0, &watchdog.opened)) in watchdog_open()
504 clear_bit(0, &watchdog.opened); in watchdog_open()
511 watchdog.expect_close = 0; in watchdog_open()
517 clear_bit(0, &watchdog.opened); in watchdog_release()
519 if (!watchdog.expect_close) { in watchdog_release()
521 pr_crit("Unexpected close, not stopping watchdog!\n"); in watchdog_release()
530 * @file: file handle to the watchdog
535 * A write to a watchdog device is defined as a keepalive signal. Any
558 mutex_lock(&watchdog.lock); in watchdog_write()
559 watchdog.expect_close = expect_close; in watchdog_write()
560 mutex_unlock(&watchdog.lock); in watchdog_write()
573 * @cmd: watchdog command
576 * The watchdog API defines a common set of functions for all watchdogs
594 return copy_to_user(uarg.ident, &watchdog.ident, in watchdog_ioctl()
595 sizeof(watchdog.ident)) ? -EFAULT : 0; in watchdog_ioctl()
632 return put_user(watchdog.timeout, uarg.i); in watchdog_ioctl()
660 .name = "watchdog",
672 /* No need to lock watchdog.lock here because no entry points in watchdog_init()
675 watchdog.sioaddr = sioaddr; in watchdog_init()
676 watchdog.ident.options = WDIOF_MAGICCLOSE in watchdog_init()
680 snprintf(watchdog.ident.identity, in watchdog_init()
681 sizeof(watchdog.ident.identity), "%s watchdog", in watchdog_init()
682 f71808e_names[watchdog.type]); in watchdog_init()
687 superio_select(watchdog.sioaddr, SIO_F71808FG_LD_WDT); in watchdog_init()
690 watchdog.caused_reboot = wdt_conf & BIT(F71808FG_FLAG_WDTMOUT_STS); in watchdog_init()
729 pr_err("cannot start watchdog timer\n"); in watchdog_init()
733 mutex_lock(&watchdog.lock); in watchdog_init()
737 superio_select(watchdog.sioaddr, SIO_F71808FG_LD_WDT); in watchdog_init()
754 mutex_unlock(&watchdog.lock); in watchdog_init()
759 pr_info("watchdog started with initial timeout of %u sec\n", in watchdog_init()
766 mutex_unlock(&watchdog.lock); in watchdog_init()
792 watchdog.type = f71808fg; in f71808e_find()
795 watchdog.type = f71862fg; in f71808e_find()
798 watchdog.type = f71868; in f71808e_find()
802 watchdog.type = f71869; in f71808e_find()
805 watchdog.type = f71882fg; in f71808e_find()
808 watchdog.type = f71889fg; in f71808e_find()
811 /* Confirmed (by datasheet) not to have a watchdog. */ in f71808e_find()
815 watchdog.type = f81803; in f71808e_find()
818 watchdog.type = f81865; in f71808e_find()
821 watchdog.type = f81866; in f71808e_find()
830 pr_info("Found %s watchdog chip, revision %d\n", in f71808e_find()
831 f71808e_names[watchdog.type], in f71808e_find()
863 pr_warn("Watchdog timer still running, stopping it\n"); in f71808e_exit()
870 MODULE_DESCRIPTION("F71808E Watchdog Driver");