// SPDX-License-Identifier: GPL-2.0-or-later /* * National Semiconductor PC87307/PC97307 (ala SC1200) WDT driver * (c) Copyright 2002 Zwane Mwaikambo <zwane@commfireservices.com>, * All Rights Reserved. * Based on wdt.c and wdt977.c by Alan Cox and Woody Suwalski respectively. * * The author(s) of this software shall not be held liable for damages * of any nature resulting due to the use of this software. This * software is provided AS-IS with no warranties. * * Changelog: * 20020220 Zwane Mwaikambo Code based on datasheet, no hardware. * 20020221 Zwane Mwaikambo Cleanups as suggested by Jeff Garzik * and Alan Cox. * 20020222 Zwane Mwaikambo Added probing. * 20020225 Zwane Mwaikambo Added ISAPNP support. * 20020412 Rob Radez Broke out start/stop functions * <rob@osinvestor.com> Return proper status instead of * temperature warning * Add WDIOC_GETBOOTSTATUS and * WDIOC_SETOPTIONS ioctls * Fix CONFIG_WATCHDOG_NOWAYOUT * 20020530 Joel Becker Add Matt Domsch's nowayout module * option * 20030116 Adam Belay Updated to the latest pnp code
*/
__sc1200wdt_read_data(WDCF, ®); /* assert WDO when any of the following interrupts are triggered too */
reg |= (KBC_IRQ | MSE_IRQ | UART1_IRQ | UART2_IRQ);
__sc1200wdt_write_data(WDCF, reg); /* set the timeout and get the ball rolling */
__sc1200wdt_write_data(WDTO, timeout);
/* This returns the status of the WDO signal, inactive high. */ staticinlineint sc1200wdt_status(void)
{ unsignedchar ret;
sc1200wdt_read_data(WDST, &ret); /* If the bit is inactive, the watchdog is enabled, so return * KEEPALIVEPING which is a bit of a kludge because there's nothing * else for enabled/disabled status
*/ return (ret & 0x01) ? 0 : WDIOF_KEEPALIVEPING;
}
staticint sc1200wdt_open(struct inode *inode, struct file *file)
{ /* allow one at a time */ if (test_and_set_bit(0, &open_flag)) return -EBUSY;
switch (cmd) { case WDIOC_GETSUPPORT: if (copy_to_user(argp, &ident, sizeof(ident))) return -EFAULT; return 0;
case WDIOC_GETSTATUS: return put_user(sc1200wdt_status(), p);
case WDIOC_GETBOOTSTATUS: return put_user(0, p);
case WDIOC_SETOPTIONS:
{ int options, retval = -EINVAL;
if (get_user(options, p)) return -EFAULT;
if (options & WDIOS_DISABLECARD) {
sc1200wdt_stop();
retval = 0;
}
if (options & WDIOS_ENABLECARD) {
sc1200wdt_start();
retval = 0;
}
return retval;
} case WDIOC_KEEPALIVE:
sc1200wdt_write_data(WDTO, timeout); return 0;
case WDIOC_SETTIMEOUT: if (get_user(new_timeout, p)) return -EFAULT; /* the API states this is given in secs */
new_timeout /= 60; if (new_timeout < 0 || new_timeout > MAX_TIMEOUT) return -EINVAL;
timeout = new_timeout;
sc1200wdt_write_data(WDTO, timeout);
fallthrough; /* and return the new timeout */
case WDIOC_GETTIMEOUT: return put_user(timeout * 60, p);
staticint __init sc1200wdt_probe(void)
{ /* The probe works by reading the PMC3 register's default value of 0x0e * there is one caveat, if the device disables the parallel port or any * of the UARTs we won't be able to detect it. * NB. This could be done with accuracy by reading the SID registers, * but we don't have access to those io regions.
*/
staticint scl200wdt_pnp_probe(struct pnp_dev *dev, conststruct pnp_device_id *dev_id)
{ /* this driver only supports one card at a time */ if (wdt_dev || !isapnp) return -EBUSY;
#ifdefined CONFIG_PNP if (isapnp) {
ret = pnp_register_driver(&scl200wdt_pnp_driver); if (ret) goto out_clean;
} #endif
if (io == -1) {
pr_err("io parameter must be specified\n");
ret = -EINVAL; goto out_pnp;
}
#ifdefined CONFIG_PNP /* now that the user has specified an IO port and we haven't detected
* any devices, disable pnp support */ if (isapnp)
pnp_unregister_driver(&scl200wdt_pnp_driver);
isapnp = 0; #endif
if (!request_region(io, io_len, SC1200_MODULE_NAME)) {
pr_err("Unable to register IO port %#x\n", io);
ret = -EBUSY; goto out_pnp;
}
ret = sc1200wdt_probe(); if (ret) goto out_io;
ret = register_reboot_notifier(&sc1200wdt_notifier); if (ret) {
pr_err("Unable to register reboot notifier err = %d\n", ret); goto out_io;
}
ret = misc_register(&sc1200wdt_miscdev); if (ret) {
pr_err("Unable to register miscdev on minor %d\n",
WATCHDOG_MINOR); goto out_rbt;
}
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.