// SPDX-License-Identifier: GPL-2.0+ /* * Eurotech CPU-1220/1410/1420 on board WDT driver * * (c) Copyright 2001 Ascensit <support@ascensit.com> * (c) Copyright 2001 Rodolfo Giometti <giometti@ascensit.com> * (c) Copyright 2002 Rob Radez <rob@osinvestor.com> * * Based on wdt.c. * Original copyright messages: * * (c) Copyright 1996-1997 Alan Cox <alan@lxorguk.ukuu.org.uk>, * All Rights Reserved. * * Neither Alan Cox nor CymruNet Ltd. admit liability nor provide * warranty for any of this software. This material is provided * "AS-IS" and at no charge. * * (c) Copyright 1995 Alan Cox <alan@lxorguk.ukuu.org.uk>*
*/
/* Changelog: * * 2001 - Rodolfo Giometti * Initial release * * 2002/04/25 - Rob Radez * clean up #includes * clean up locking * make __setup param unique * proper options in watchdog_info * add WDIOC_GETSTATUS and WDIOC_SETOPTIONS ioctls * add expect_close support * * 2002.05.30 - Joel Becker <joel.becker@oracle.com> * Added Matt Domsch's nowayout module option.
*/
/* * The eurotech CPU-1220/1410/1420's watchdog is a part * of the on-board SUPER I/O device SMSC FDC 37B782.
*/
/** * eurwdt_ping: * * Reload counter one with the watchdog timeout.
*/
staticvoid eurwdt_ping(void)
{ /* Write the watchdog default value */
eurwdt_set_timeout(eurwdt_timeout);
}
/** * eurwdt_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 don't define content meaning.
*/
for (i = 0; i != count; i++) { char c; if (get_user(c, buf + i)) return -EFAULT; if (c == 'V')
eur_expect_close = 42;
}
}
spin_lock(&eurwdt_lock);
eurwdt_ping(); /* the default timeout */
spin_unlock(&eurwdt_lock);
} return count;
}
/** * eurwdt_ioctl: * @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.
*/
case WDIOC_GETTIMEOUT: return put_user(eurwdt_timeout, p);
default: return -ENOTTY;
}
}
/** * eurwdt_open: * @inode: inode of device * @file: file handle to device * * The misc device has been opened. The watchdog device is single * open and on opening we load the counter.
*/
/** * eurwdt_release: * @inode: inode to board * @file: file handle to board * * The watchdog has a configurable API. There is a religious dispute * between people who want their watchdog to be able to shut down and * those who want to be sure if the watchdog manager dies the machine * reboots. In the former case we disable the counters, in the latter * case you have to open it again very soon.
*/
/** * eurwdt_notify_sys: * @this: our notifier block * @code: the event being reported * @unused: unused * * Our notifier is called on system shutdowns. We want to turn the card * off at reboot otherwise the machine will reboot again during memory * test or worse yet during the following fsck. This would suck, in fact * trust me - if it happens it does suck.
*/
staticint eurwdt_notify_sys(struct notifier_block *this, unsignedlong code, void *unused)
{ if (code == SYS_DOWN || code == SYS_HALT)
eurwdt_disable_timer(); /* Turn the card off */
/** * eurwdt_exit: * * Unload the watchdog. You cannot do this with any file handles open. * If your watchdog is set to continue ticking on close and you unload * it, well it keeps ticking. We won't get the interrupt but the board * will not touch PC memory so all is fine. You just have to load a new * module in 60 seconds or reboot.
*/
/** * eurwdt_init: * * Set up the WDT watchdog board. After grabbing the resources * we require we need also to unlock the device. * The open() function will actually kick the board off.
*/
staticint __init eurwdt_init(void)
{ int ret;
ret = request_irq(irq, eurwdt_interrupt, 0, "eurwdt", NULL); if (ret) {
pr_err("IRQ %d is not free\n", irq); goto out;
}
if (!request_region(io, 2, "eurwdt")) {
pr_err("IO %X is not free\n", io);
ret = -EBUSY; goto outirq;
}
ret = register_reboot_notifier(&eurwdt_notifier); if (ret) {
pr_err("can't register reboot notifier (err=%d)\n", ret); goto outreg;
}
ret = misc_register(&eurwdt_miscdev); if (ret) {
pr_err("can't misc_register on minor=%d\n", WATCHDOG_MINOR); goto outreboot;
}
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.