• Home
  • Raw
  • Download

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()
232 watchdog.timer_val = DIV_ROUND_UP(timeout, 60); in watchdog_set_timeout()
233 watchdog.minutes_mode = true; in watchdog_set_timeout()
234 timeout = watchdog.timer_val * 60; in watchdog_set_timeout()
236 watchdog.timer_val = timeout; in watchdog_set_timeout()
237 watchdog.minutes_mode = false; in watchdog_set_timeout()
240 watchdog.timeout = timeout; in watchdog_set_timeout()
242 mutex_unlock(&watchdog.lock); in watchdog_set_timeout()
252 if (watchdog.type == f71868) { in watchdog_set_pulse_width()
258 mutex_lock(&watchdog.lock); in watchdog_set_pulse_width()
261 watchdog.pulse_val = 0; in watchdog_set_pulse_width()
263 watchdog.pulse_val = 1; in watchdog_set_pulse_width()
265 watchdog.pulse_val = 2; in watchdog_set_pulse_width()
267 watchdog.pulse_val = 3; in watchdog_set_pulse_width()
274 watchdog.pulse_mode = pw; in watchdog_set_pulse_width()
277 mutex_unlock(&watchdog.lock); in watchdog_set_pulse_width()
285 mutex_lock(&watchdog.lock); in watchdog_keepalive()
286 err = superio_enter(watchdog.sioaddr); in watchdog_keepalive()
289 superio_select(watchdog.sioaddr, SIO_F71808FG_LD_WDT); in watchdog_keepalive()
291 if (watchdog.minutes_mode) in watchdog_keepalive()
293 superio_set_bit(watchdog.sioaddr, F71808FG_REG_WDT_CONF, in watchdog_keepalive()
297 superio_clear_bit(watchdog.sioaddr, F71808FG_REG_WDT_CONF, in watchdog_keepalive()
301 superio_outb(watchdog.sioaddr, F71808FG_REG_WD_TIME, in watchdog_keepalive()
302 watchdog.timer_val); in watchdog_keepalive()
304 superio_exit(watchdog.sioaddr); in watchdog_keepalive()
307 mutex_unlock(&watchdog.lock); in watchdog_keepalive()
316 /* Make sure we don't die as soon as the watchdog is enabled below */ in watchdog_start()
321 mutex_lock(&watchdog.lock); in watchdog_start()
322 err = superio_enter(watchdog.sioaddr); in watchdog_start()
325 superio_select(watchdog.sioaddr, SIO_F71808FG_LD_WDT); in watchdog_start()
327 /* Watchdog pin configuration */ in watchdog_start()
328 switch (watchdog.type) { in watchdog_start()
331 superio_clear_bit(watchdog.sioaddr, SIO_REG_MFUNCT2, 3); in watchdog_start()
332 superio_clear_bit(watchdog.sioaddr, SIO_REG_MFUNCT3, 3); in watchdog_start()
338 superio_clear_bit(watchdog.sioaddr, SIO_REG_ROM_ADDR_SEL, 6); in watchdog_start()
339 superio_set_bit(watchdog.sioaddr, SIO_REG_MFUNCT3, 4); in watchdog_start()
341 superio_set_bit(watchdog.sioaddr, SIO_REG_MFUNCT1, 1); in watchdog_start()
348 superio_clear_bit(watchdog.sioaddr, SIO_REG_MFUNCT1, 4); in watchdog_start()
353 superio_set_bit(watchdog.sioaddr, SIO_REG_MFUNCT1, 1); in watchdog_start()
358 superio_outb(watchdog.sioaddr, SIO_REG_MFUNCT3, in watchdog_start()
359 superio_inb(watchdog.sioaddr, SIO_REG_MFUNCT3) & 0xcf); in watchdog_start()
364 superio_clear_bit(watchdog.sioaddr, SIO_REG_CLOCK_SEL, 3); in watchdog_start()
366 superio_outb(watchdog.sioaddr, SIO_REG_TSI_LEVEL_SEL, 0x5f & in watchdog_start()
367 superio_inb(watchdog.sioaddr, SIO_REG_TSI_LEVEL_SEL)); in watchdog_start()
372 superio_clear_bit(watchdog.sioaddr, SIO_REG_MFUNCT3, 5); in watchdog_start()
382 tmp = superio_inb(watchdog.sioaddr, SIO_F81866_REG_PORT_SEL); in watchdog_start()
385 superio_outb(watchdog.sioaddr, SIO_F81866_REG_PORT_SEL, tmp); in watchdog_start()
387 superio_clear_bit(watchdog.sioaddr, SIO_F81866_REG_GPIO1, 5); in watchdog_start()
399 superio_select(watchdog.sioaddr, SIO_F71808FG_LD_WDT); in watchdog_start()
400 superio_set_bit(watchdog.sioaddr, SIO_REG_ENABLE, 0); in watchdog_start()
402 if (watchdog.type == f81865 || watchdog.type == f81866) in watchdog_start()
403 superio_set_bit(watchdog.sioaddr, F81865_REG_WDO_CONF, in watchdog_start()
406 superio_set_bit(watchdog.sioaddr, F71808FG_REG_WDO_CONF, in watchdog_start()
409 superio_set_bit(watchdog.sioaddr, F71808FG_REG_WDT_CONF, in watchdog_start()
412 if (watchdog.pulse_mode) { in watchdog_start()
414 u8 wdt_conf = superio_inb(watchdog.sioaddr, in watchdog_start()
418 wdt_conf = (wdt_conf & 0xfc) | (watchdog.pulse_val & 0x03); in watchdog_start()
422 superio_outb(watchdog.sioaddr, F71808FG_REG_WDT_CONF, in watchdog_start()
426 superio_clear_bit(watchdog.sioaddr, F71808FG_REG_WDT_CONF, in watchdog_start()
431 superio_exit(watchdog.sioaddr); in watchdog_start()
433 mutex_unlock(&watchdog.lock); in watchdog_start()
442 mutex_lock(&watchdog.lock); in watchdog_stop()
443 err = superio_enter(watchdog.sioaddr); in watchdog_stop()
446 superio_select(watchdog.sioaddr, SIO_F71808FG_LD_WDT); in watchdog_stop()
448 superio_clear_bit(watchdog.sioaddr, F71808FG_REG_WDT_CONF, in watchdog_stop()
451 superio_exit(watchdog.sioaddr); in watchdog_stop()
454 mutex_unlock(&watchdog.lock); in watchdog_stop()
463 mutex_lock(&watchdog.lock); in watchdog_get_status()
464 status = (watchdog.caused_reboot) ? WDIOF_CARDRESET : 0; in watchdog_get_status()
465 mutex_unlock(&watchdog.lock); in watchdog_get_status()
473 * if we fail to determine the watchdog's status assume it to be in watchdog_is_running()
478 mutex_lock(&watchdog.lock); in watchdog_is_running()
479 if (superio_enter(watchdog.sioaddr)) in watchdog_is_running()
481 superio_select(watchdog.sioaddr, SIO_F71808FG_LD_WDT); in watchdog_is_running()
483 is_running = (superio_inb(watchdog.sioaddr, SIO_REG_ENABLE) & BIT(0)) in watchdog_is_running()
484 && (superio_inb(watchdog.sioaddr, F71808FG_REG_WDT_CONF) in watchdog_is_running()
487 superio_exit(watchdog.sioaddr); in watchdog_is_running()
490 mutex_unlock(&watchdog.lock); in watchdog_is_running()
494 /* /dev/watchdog api */
500 /* If the watchdog is alive we don't need to start it again */ in watchdog_open()
501 if (test_and_set_bit(0, &watchdog.opened)) in watchdog_open()
506 clear_bit(0, &watchdog.opened); in watchdog_open()
513 watchdog.expect_close = 0; in watchdog_open()
519 clear_bit(0, &watchdog.opened); in watchdog_release()
521 if (!watchdog.expect_close) { in watchdog_release()
523 pr_crit("Unexpected close, not stopping watchdog!\n"); in watchdog_release()
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); in watchdog_write()
561 watchdog.expect_close = expect_close; in watchdog_write()
562 mutex_unlock(&watchdog.lock); in watchdog_write()
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, in watchdog_ioctl()
597 sizeof(watchdog.ident)) ? -EFAULT : 0; in watchdog_ioctl()
634 return put_user(watchdog.timeout, uarg.i); in watchdog_ioctl()
662 .name = "watchdog",
674 /* No need to lock watchdog.lock here because no entry points in watchdog_init()
677 watchdog.sioaddr = sioaddr; in watchdog_init()
678 watchdog.ident.options = WDIOF_MAGICCLOSE in watchdog_init()
682 snprintf(watchdog.ident.identity, in watchdog_init()
683 sizeof(watchdog.ident.identity), "%s watchdog", in watchdog_init()
684 f71808e_names[watchdog.type]); in watchdog_init()
689 superio_select(watchdog.sioaddr, SIO_F71808FG_LD_WDT); in watchdog_init()
692 watchdog.caused_reboot = wdt_conf & BIT(F71808FG_FLAG_WDTMOUT_STS); in watchdog_init()
731 pr_err("cannot start watchdog timer\n"); in watchdog_init()
735 mutex_lock(&watchdog.lock); in watchdog_init()
739 superio_select(watchdog.sioaddr, SIO_F71808FG_LD_WDT); in watchdog_init()
756 mutex_unlock(&watchdog.lock); in watchdog_init()
761 pr_info("watchdog started with initial timeout of %u sec\n", in watchdog_init()
768 mutex_unlock(&watchdog.lock); in watchdog_init()
794 watchdog.type = f71808fg; in f71808e_find()
797 watchdog.type = f71862fg; in f71808e_find()
800 watchdog.type = f71868; in f71808e_find()
804 watchdog.type = f71869; in f71808e_find()
807 watchdog.type = f71882fg; in f71808e_find()
810 watchdog.type = f71889fg; in f71808e_find()
813 /* Confirmed (by datasheet) not to have a watchdog. */ in f71808e_find()
817 watchdog.type = f81803; in f71808e_find()
820 watchdog.type = f81865; in f71808e_find()
823 watchdog.type = f81866; in f71808e_find()
832 pr_info("Found %s watchdog chip, revision %d\n", in f71808e_find()
833 f71808e_names[watchdog.type], in f71808e_find()
865 pr_warn("Watchdog timer still running, stopping it\n"); in f71808e_exit()
872 MODULE_DESCRIPTION("F71808E Watchdog Driver");