/* unlock the SuperIO chip */
outb_p(UNLOCK_DATA, IO_INDEX_PORT);
outb_p(UNLOCK_DATA, IO_INDEX_PORT);
/* select device Aux2 (device=8) and set watchdog regs F2, F3 and F4 * F2 has the timeout in minutes * F3 could be set to the POWER LED blink (with GP17 set to PowerLed) * at timeout, and to reset timer on kbd/mouse activity (not impl.) * F4 is used to just clear the TIMEOUT'ed state (bit 0)
*/
outb_p(DEVICE_REGISTER, IO_INDEX_PORT);
outb_p(0x08, IO_DATA_PORT);
outb_p(0xF2, IO_INDEX_PORT);
outb_p(timeoutM, IO_DATA_PORT);
outb_p(0xF3, IO_INDEX_PORT);
outb_p(0x00, IO_DATA_PORT); /* another setting is 0E for
kbd/mouse/LED */
outb_p(0xF4, IO_INDEX_PORT);
outb_p(0x00, IO_DATA_PORT);
/* At last select device Aux1 (dev=7) and set GP16 as a * watchdog output. In test mode watch the bit 1 on F4 to * indicate "triggered"
*/ if (!testmode) {
outb_p(DEVICE_REGISTER, IO_INDEX_PORT);
outb_p(0x07, IO_DATA_PORT);
outb_p(0xE6, IO_INDEX_PORT);
outb_p(0x08, IO_DATA_PORT);
}
/* lock the SuperIO chip */
outb_p(LOCK_DATA, IO_INDEX_PORT);
/* unlock the SuperIO chip */
outb_p(UNLOCK_DATA, IO_INDEX_PORT);
outb_p(UNLOCK_DATA, IO_INDEX_PORT);
/* select device Aux2 (device=8) and set watchdog regs F2,F3 and F4 * F3 is reset to its default state * F4 can clear the TIMEOUT'ed state (bit 0) - back to default * We can not use GP17 as a PowerLed, as we use its usage as a RedLed
*/
outb_p(DEVICE_REGISTER, IO_INDEX_PORT);
outb_p(0x08, IO_DATA_PORT);
outb_p(0xF2, IO_INDEX_PORT);
outb_p(0xFF, IO_DATA_PORT);
outb_p(0xF3, IO_INDEX_PORT);
outb_p(0x00, IO_DATA_PORT);
outb_p(0xF4, IO_INDEX_PORT);
outb_p(0x00, IO_DATA_PORT);
outb_p(0xF2, IO_INDEX_PORT);
outb_p(0x00, IO_DATA_PORT);
/* at last select device Aux1 (dev=7) and set
GP16 as a watchdog output */
outb_p(DEVICE_REGISTER, IO_INDEX_PORT);
outb_p(0x07, IO_DATA_PORT);
outb_p(0xE6, IO_INDEX_PORT);
outb_p(0x08, IO_DATA_PORT);
/* lock the SuperIO chip */
outb_p(LOCK_DATA, IO_INDEX_PORT);
/* unlock the SuperIO chip */
outb_p(UNLOCK_DATA, IO_INDEX_PORT);
outb_p(UNLOCK_DATA, IO_INDEX_PORT);
/* select device Aux2 (device=8) and kicks watchdog reg F2 */ /* F2 has the timeout in minutes */
outb_p(DEVICE_REGISTER, IO_INDEX_PORT);
outb_p(0x08, IO_DATA_PORT);
outb_p(0xF2, IO_INDEX_PORT);
outb_p(timeoutM, IO_DATA_PORT);
/* lock the SuperIO chip */
outb_p(LOCK_DATA, IO_INDEX_PORT);
spin_unlock_irqrestore(&spinlock, flags);
return 0;
}
/* * Set the watchdog timeout value
*/
staticint wdt977_set_timeout(int t)
{ int tmrval;
/* convert seconds to minutes, rounding up */
tmrval = (t + 59) / 60;
if (machine_is_netwinder()) { /* we have a hw bug somewhere, so each 977 minute is actually * only 30sec. This limits the max timeout to half of device * max of 255 minutes...
*/
tmrval += tmrval;
}
if (tmrval < 1 || tmrval > 255) return -EINVAL;
/* timeout is the timeout in seconds, timeoutM is
the timeout in minutes) */
timeout = t;
timeoutM = tmrval; return 0;
}
/* * Get the watchdog status
*/
staticint wdt977_get_status(int *status)
{ int new_status; unsignedlong flags;
spin_lock_irqsave(&spinlock, flags);
/* unlock the SuperIO chip */
outb_p(UNLOCK_DATA, IO_INDEX_PORT);
outb_p(UNLOCK_DATA, IO_INDEX_PORT);
/* lock the SuperIO chip */
outb_p(LOCK_DATA, IO_INDEX_PORT);
spin_unlock_irqrestore(&spinlock, flags);
*status = 0; if (new_status & 1)
*status |= WDIOF_CARDRESET;
return 0;
}
/* * /dev/watchdog handling
*/
staticint wdt977_open(struct inode *inode, struct file *file)
{ /* If the watchdog is alive we don't need to start it again */ if (test_and_set_bit(0, &timer_alive)) return -EBUSY;
staticint wdt977_release(struct inode *inode, struct file *file)
{ /* * Shut off the timer. * Lock it in if it's a module and we set nowayout
*/ if (expect_close == 42) {
wdt977_stop();
clear_bit(0, &timer_alive);
} else {
wdt977_keepalive();
pr_crit("Unexpected close, not stopping watchdog!\n");
}
expect_close = 0; return 0;
}
/* * wdt977_write: * @file: file handle to the watchdog * @buf: buffer to write (unused as data does not matter here * @count: count of bytes * @ppos: pointer to the position to write. No seeks allowed * * A write to a watchdog device is defined as a keepalive signal. Any * write of data will do, as we we don't define content meaning.
*/
/* * wdt977_ioctl: * @inode: inode of the device * @file: file handle to the device * @cmd: watchdog command * @arg: argument pointer * * The watchdog API defines a common set of functions for all watchdogs * according to their available features.
*/
staticlong wdt977_ioctl(struct file *file, unsignedint cmd, unsignedlong arg)
{ int status; int new_options, retval = -EINVAL; int new_timeout; union { struct watchdog_info __user *ident; int __user *i;
} uarg;
/* Check that the timeout value is within its range;
if not reset to the default */ if (wdt977_set_timeout(timeout)) {
wdt977_set_timeout(DEFAULT_TIMEOUT);
pr_info("timeout value must be 60 < timeout < 15300, using %d\n",
DEFAULT_TIMEOUT);
}
/* on Netwinder the IOports are already reserved by * arch/arm/mach-footbridge/netwinder-hw.c
*/ if (!machine_is_netwinder()) { if (!request_region(IO_INDEX_PORT, 2, WATCHDOG_NAME)) {
pr_err("I/O address 0x%04x already in use\n",
IO_INDEX_PORT);
rc = -EIO; goto err_out;
}
}
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.30Bemerkung:
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.