2 * Wdt977 0.01: A Watchdog Device for Netwinder W83977AF chip
4 * (c) Copyright 1998 Rebel.com (Woody Suwalski <woody@netwinder.org>)
6 * -----------------------
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version
11 * 2 of the License, or (at your option) any later version.
13 * -----------------------
16 #include <linux/module.h>
17 #include <linux/config.h>
18 #include <linux/types.h>
19 #include <linux/kernel.h>
21 #include <linux/miscdevice.h>
22 #include <linux/init.h>
23 #include <linux/smp_lock.h>
26 #include <asm/system.h>
27 #include <asm/mach-types.h>
29 #define WATCHDOG_MINOR 130
31 static int timeout
= 3;
32 static int timer_alive
;
36 * Allow only one person to hold it open
39 static int wdt977_open(struct inode
*inode
, struct file
*file
)
43 #ifdef CONFIG_WATCHDOG_NOWAYOUT
48 //max timeout value = 255 minutes (0xFF). Write 0 to disable WatchDog.
52 printk(KERN_INFO
"Watchdog: active, current timeout %d min.\n",timeout
);
54 // unlock the SuperIO chip
58 //select device Aux2 (device=8) and set watchdog regs F2, F3 and F4
59 //F2 has the timeout in minutes
60 //F3 could be set to the POWER LED blink (with GP17 set to PowerLed)
61 // at timeout, and to reset timer on kbd/mouse activity (not now)
62 //F4 is used to just clear the TIMEOUT'ed state (bit 0)
69 outb(0x00,0x371); //another setting is 0E for kbd/mouse/LED
73 //at last select device Aux1 (dev=7) and set GP16 as a watchdog output
82 // lock the SuperIO chip
88 static int wdt977_release(struct inode
*inode
, struct file
*file
)
92 * Lock it in if it's a module and we defined ...NOWAYOUT
94 #ifndef CONFIG_WATCHDOG_NOWAYOUT
97 // unlock the SuperIO chip
101 //select device Aux2 (device=8) and set watchdog regs F2,F3 and F4
102 //F3 is reset to its default state
103 //F4 can clear the TIMEOUT'ed state (bit 0) - back to default
104 //We can not use GP17 as a PowerLed, as we use its usage as a RedLed
117 //at last select device Aux1 (dev=7) and set GP16 as a watchdog output
123 // lock the SuperIO chip
129 printk(KERN_INFO
"Watchdog: shutdown.\n");
134 static ssize_t
wdt977_write(struct file
*file
, const char *data
, size_t len
, loff_t
*ppos
)
137 //max timeout value = 255 minutes (0xFF). Write 0 to disable WatchDog.
145 //we have a hw bug somewhere, so each 977 minute is actually only 30sec
146 //as such limit the max timeout to half of max of 255 minutes...
150 // unlock the SuperIO chip
154 //select device Aux2 (device=8) and kicks watchdog reg F2
155 //F2 has the timeout in minutes
162 // lock the SuperIO chip
168 static struct file_operations wdt977_fops
=
173 release
: wdt977_release
,
176 static struct miscdevice wdt977_miscdev
=
183 static int __init
nwwatchdog_init(void)
185 if (!machine_is_netwinder())
188 misc_register(&wdt977_miscdev
);
189 printk(KERN_INFO
"NetWinder Watchdog sleeping.\n");
193 static void __exit
nwwatchdog_exit(void)
195 misc_deregister(&wdt977_miscdev
);
200 module_init(nwwatchdog_init
);
201 module_exit(nwwatchdog_exit
);