// SPDX-License-Identifier: GPL-2.0+ /* * sch311x_wdt.c - Driver for the SCH311x Super-I/O chips * integrated watchdog. * * (c) Copyright 2008 Wim Van Sebroeck <wim@iguana.be>. * * Neither Wim Van Sebroeck nor Iguana vzw. admit liability nor * provide warranty for any of this software. This material is * provided "AS-IS" and at no charge.
*/
/* Includes */ #include <linux/module.h> /* For module specific items */ #include <linux/moduleparam.h> /* For new moduleparam's */ #include <linux/types.h> /* For standard types (like size_t) */ #include <linux/errno.h> /* For the -ENODEV/... values */ #include <linux/kernel.h> /* For printk/... */ #include <linux/miscdevice.h> /* For struct miscdevice */ #include <linux/watchdog.h> /* For the watchdog specific items */ #include <linux/init.h> /* For __init/__exit/... */ #include <linux/fs.h> /* For file operations */ #include <linux/platform_device.h> /* For platform_driver framework */ #include <linux/ioport.h> /* For io-port access */ #include <linux/spinlock.h> /* For spin_lock/spin_unlock/... */ #include <linux/uaccess.h> /* For copy_to_user/put_user/... */ #include <linux/io.h> /* For inb/outb/... */
/* Module and version information */ #define DRV_NAME "sch311x_wdt"
staticstruct { /* The devices private data */ /* the Runtime Register base address */ unsignedshort runtime_reg; /* The card's boot status */ int boot_status; /* the lock for io operations */
spinlock_t io_lock;
} sch311x_wdt_data;
/* -- Watchdog timer control -- * Bit 0 Status Bit: 0 = Timer counting, 1 = Timeout occurred * Bit 1 Reserved * Bit 2 Force Timeout: 1 = Forces WD timeout event (self-cleaning) * Bit 3 P20 Force Timeout enabled: * 0 = P20 activity does not generate the WD timeout event * 1 = P20 Allows rising edge of P20, from the keyboard * controller, to force the WD timeout event. * Bit 4-7 Reserved
*/
new_status = inb(sch311x_wdt_data.runtime_reg + WDT_CTRL); if (new_status & 0x01)
*status |= WDIOF_CARDRESET;
if (!request_region(sch311x_wdt_data.runtime_reg + GP60, 1, DRV_NAME)) {
dev_err(dev, "Failed to request region 0x%04x-0x%04x.\n",
sch311x_wdt_data.runtime_reg + GP60,
sch311x_wdt_data.runtime_reg + GP60);
err = -EBUSY; gotoexit;
}
if (!request_region(sch311x_wdt_data.runtime_reg + WDT_TIME_OUT, 4,
DRV_NAME)) {
dev_err(dev, "Failed to request region 0x%04x-0x%04x.\n",
sch311x_wdt_data.runtime_reg + WDT_TIME_OUT,
sch311x_wdt_data.runtime_reg + WDT_CTRL);
err = -EBUSY; goto exit_release_region;
}
/* Make sure that the watchdog is not running */
sch311x_wdt_stop();
/* Disable keyboard and mouse interaction and interrupt */ /* -- Watchdog timer configuration -- * Bit 0 Reserved * Bit 1 Keyboard enable: 0* = No Reset, 1 = Reset WDT upon KBD Intr. * Bit 2 Mouse enable: 0* = No Reset, 1 = Reset WDT upon Mouse Intr * Bit 3 Reserved * Bit 4-7 WDT Interrupt Mapping: (0000* = Disabled, * 0001=IRQ1, 0010=(Invalid), 0011=IRQ3 to 1111=IRQ15)
*/
outb(0, sch311x_wdt_data.runtime_reg + WDT_CFG);
/* Check that the heartbeat value is within it's range ;
* if not reset to the default */ if (sch311x_wdt_set_heartbeat(timeout)) {
sch311x_wdt_set_heartbeat(WATCHDOG_TIMEOUT);
dev_info(dev, "timeout value must be 1<=x<=15300, using %d\n",
timeout);
}
/* Get status at boot */
sch311x_wdt_get_status(&sch311x_wdt_data.boot_status);
sch311x_wdt_miscdev.parent = dev;
err = misc_register(&sch311x_wdt_miscdev); if (err != 0) {
dev_err(dev, "cannot register miscdev on minor=%d (err=%d)\n",
WATCHDOG_MINOR, err); goto exit_release_region2;
}
/* Check if Logical Device Register is currently active */ if ((sch311x_sio_inb(sio_config_port, 0x30) & 0x01) == 0)
pr_info("Seems that LDN 0x0a is not active...\n");
/* Get the base address of the runtime registers */
base_addr = (sch311x_sio_inb(sio_config_port, 0x60) << 8) |
sch311x_sio_inb(sio_config_port, 0x61); if (!base_addr) {
pr_err("Base address not set\n");
err = -ENODEV; gotoexit;
}
*addr = base_addr;
pr_info("Found an SMSC SCH311%d chip at 0x%04x\n", dev_id, base_addr);
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.