1 diff -Nur linux-2.4.29/drivers/char/Config.in linux-2.4.29_geode/drivers/char/Config.in
2 --- linux-2.4.29/drivers/char/Config.in Sun Aug 8 01:26:04 2004
3 +++ linux-2.4.29_geode/drivers/char/Config.in Tue Feb 15 23:41:54 2005
7 tristate ' ZF MachZ Watchdog' CONFIG_MACHZ_WDT
8 + tristate ' Embedded NatSemi SC1x00 Watchdog' CONFIG_WD1100
9 if [ "$CONFIG_SGI_IP22" = "y" ]; then
10 dep_tristate ' Indy/I2 Hardware Watchdog' CONFIG_INDYDOG $CONFIG_SGI_IP22
12 diff -Nur linux-2.4.29/drivers/char/Makefile linux-2.4.29_geode/drivers/char/Makefile
13 --- linux-2.4.29/drivers/char/Makefile Sun Aug 8 01:26:04 2004
14 +++ linux-2.4.29_geode/drivers/char/Makefile Tue Feb 15 23:41:54 2005
16 obj-$(CONFIG_ACQUIRE_WDT) += acquirewdt.o
17 obj-$(CONFIG_ADVANTECH_WDT) += advantechwdt.o
18 obj-$(CONFIG_IB700_WDT) += ib700wdt.o
19 +obj-$(CONFIG_WD1100) += wd1100.o
20 obj-$(CONFIG_MIXCOMWD) += mixcomwd.o
21 obj-$(CONFIG_60XX_WDT) += sbc60xxwdt.o
22 obj-$(CONFIG_W83877F_WDT) += w83877f_wdt.o
23 diff -Nur linux-2.4.29/drivers/char/wd1100.c linux-2.4.29_geode/drivers/char/wd1100.c
24 --- linux-2.4.29/drivers/char/wd1100.c Thu Jan 1 01:00:00 1970
25 +++ linux-2.4.29_geode/drivers/char/wd1100.c Tue Feb 15 23:41:54 2005
28 + * National Semiconductor SC1x00 CPU watchdog driver
29 + * Copyright (c) Inprimis Technologies 2002
31 + * by Mark Grosberg <markg@inprimis.com>
32 + * and Rolando Goldman <rolandog@inprimis.com>
34 + * Minor changes by Kianusch Sayah Karadji <kianusch@sk-tech.net>
35 + * ( Soekris net4801 Support, module-parameter )
37 + * This program is free software; you can redistribute it and/or
38 + * modify it under the terms of the GNU General Public License
39 + * as published by the Free Software Foundation; either version
40 + * 2 of the License, or (at your option) any later version.
44 +#include <linux/module.h>
45 +#include <linux/types.h>
46 +#include <linux/kernel.h>
47 +#include <linux/fs.h>
48 +#include <linux/mm.h>
49 +#include <linux/miscdevice.h>
50 +#include <linux/watchdog.h>
51 +#include <linux/spinlock.h>
52 +#include <linux/sysctl.h>
53 +#include <linux/pci.h>
56 + * Since the SC1100 is an x86 clone, we don't even bother with
57 + * allowing other architectures to compile us.
60 +# error Sorry this driver is only for x86.
63 +#include <asm/system.h>
65 +#include <asm/uaccess.h>
66 +#include <asm/processor.h>
68 +/* #define DEBUG_WD1100 */
70 +static int proc_wd_timeout(ctl_table *ctl,
75 +static int proc_wd_graceful(ctl_table *ctl,
81 +/* Register definitions */
83 +#define SC1100_F5_VENDOR_ID 0x100B
84 +#define SC1100_F5_DEVICE_ID 0x0515
86 +#define CPU_WDTO_REG 0x00 /* watchdog time out, 16 bit register */
87 +#define CPU_WDCNFG_REG 0x02 /* watchdog config , 16 bit register */
88 +#define CPU_WDSTS_REG 0x04 /* watchdog status , 8 bit register */
90 +/* Default timeout: 4 seconds (changeable via sysctl) */
91 +static unsigned int sysctl_wd_timeout = 0;
92 +static unsigned int sysctl_wd_graceful = 0;
94 +static unsigned int timeout = 4;
95 +static unsigned int graceful = 1;
97 +MODULE_PARM (timeout, "i");
98 +MODULE_PARM (graceful, "i");
100 +static int in_use = 0;
101 +static unsigned short cpu_base;
102 +static spinlock_t wd_lock;
104 +/**************************************************************************/
106 +/* XXX To-do: DEV_WATCHDOG must be in include/linux/sysctl.h */
108 +{ DEV_WATCHDOG = 6 };
112 + DEV_WD_TIMEOUT = 1,
113 + DEV_WD_GRACEFUL = 2
116 +static struct ctl_table_header *wd_table_header;
118 +static ctl_table wd_table[] = {
120 + DEV_WD_TIMEOUT, "timeout",
121 + &sysctl_wd_timeout, sizeof(int), 0644, NULL, &proc_wd_timeout
125 + DEV_WD_GRACEFUL, "graceful",
126 + &sysctl_wd_graceful, sizeof(int), 0644, NULL, &proc_wd_graceful
132 +static ctl_table wd_dir_table[] = {
133 + {DEV_WATCHDOG, "wd", NULL, 0, 0555, wd_table},
137 +static ctl_table wd_root_table[] = {
138 + {CTL_DEV, "dev", NULL, 0, 0555, wd_dir_table},
142 +static int proc_wd_timeout(ctl_table *ctl,
150 + rc = proc_dointvec(ctl, write, file, buffer, lenp);
151 + if (write && (rc == 0))
153 + /* Clamp to limits. */
154 + if (sysctl_wd_timeout < 1)
155 + sysctl_wd_timeout = 1;
156 + else if (sysctl_wd_timeout > 65535)
157 + sysctl_wd_timeout = 65535;
163 +static int proc_wd_graceful(ctl_table *ctl,
171 + rc = proc_dointvec(ctl, write, file, buffer, lenp);
172 + if (write && (rc == 0))
174 + /* Clamp to true/false. */
175 + if (sysctl_wd_graceful)
176 + sysctl_wd_graceful = 1;
182 +/**************************************************************************/
184 +static __inline__ void reset_wd(void)
186 + outw(sysctl_wd_timeout * 8, cpu_base + CPU_WDTO_REG);
189 +static int reboot_reason(void)
192 + static int fetched = 0;
198 + sr = inb(cpu_base + CPU_WDSTS_REG);
199 + outb(sr | 1, cpu_base + CPU_WDSTS_REG);
207 +static struct watchdog_info wd_info =
210 + 0, /* Firmware version */
214 +static int wd_ioctl(struct inode *inode,
226 + case WDIOC_GETSUPPORT:
227 + i = verify_area(VERIFY_WRITE, (void *)arg, sizeof(struct watchdog_info));
231 + return copy_to_user((struct watchdog_info *)arg,
236 + case WDIOC_KEEPALIVE:
240 + case WDIOC_GETBOOTSTATUS:
241 + i = reboot_reason();
242 + return (put_user(i, (int *)arg));
244 + case WDIOC_GETSTATUS:
245 + i = inw(cpu_base + CPU_WDTO_REG) / 8;
246 + return (put_user(i, (int *)arg));
250 +static int wd_open(struct inode *inode,
253 + spin_lock(&wd_lock);
256 + spin_unlock(&wd_lock);
262 + spin_unlock(&wd_lock);
267 + * Configure the chip to do a reset if the timer goes to 0.
268 + * Set the clock divisor to 4096.
271 + outw(0xfc, cpu_base + CPU_WDCNFG_REG);
273 + /* Start the watchdog: It won't run until we write the TO reg. */
279 +static int wd_release(struct inode *inode,
282 + spin_lock(&wd_lock);
287 + * If graceful shutdown is not set, then don't bother to stop the
288 + * watchdog timer. This handles the scenario where the user process
289 + * that is poking the watchdog gets terminated due to some error
290 + * (say a SEGV or some VM condition).
292 + * In that case, the kernel would happily close the descriptor for
293 + * us and leave us in a state where we aren't watching the dog...
295 + * To work around this, the "graceful" sysctl prevents reset of the
296 + * watchdog on close.
298 + if (sysctl_wd_graceful)
299 + outw(0, cpu_base + CPU_WDCNFG_REG);
301 + spin_unlock(&wd_lock);
307 +static ssize_t wd_write(struct file *file,
312 + /* Device is non-seekable. */
313 + if (ppos != &file->f_pos)
322 +static struct file_operations wd_fops=
324 + owner: THIS_MODULE,
328 + release: wd_release,
331 +static struct miscdevice sc1x00wd_miscdev=
338 +static int __init wd_init(void)
341 + struct pci_dev *dev;
346 + else if (timeout > 65535)
352 + sysctl_wd_timeout=timeout;
353 + sysctl_wd_graceful=graceful;
355 + if ((strcmp(boot_cpu_data.x86_vendor_id, "Geode by NSC") != 0)
356 + || ((boot_cpu_data.x86_model != 4) && boot_cpu_data.x86_model != 9))
358 + printk(KERN_WARNING "wd1100.c: This is not an SC1100 processor!\n");
362 + /* get the CONFIG BLOCK ADDRESS from scratch pad register */
363 + dev = pci_find_device(SC1100_F5_VENDOR_ID,SC1100_F5_DEVICE_ID,0);
366 + printk(KERN_ERR "wd1100.c: Can not find bridge device.\n");
370 + pci_read_config_dword(dev, 0x64, &cw);
371 + cpu_base = (unsigned short )cw;
374 + printk("wd1100.c: CPU base = 0x%X\n", (unsigned int )cpu_base);
377 + printk(KERN_INFO "SC1x00 Watchdog driver by Inprimis Technolgies.\n");
379 + * We must call reboot_reason() to reset the flag in the WD.
381 + * Even though it is available as an ioctl(), we call it during
382 + * module initialization to perform the clear. You can take out
383 + * the printk(), but don't take out the call to reboot_reason().
385 + if (reboot_reason())
386 + printk(KERN_INFO "Last reboot was by watchdog!\n");
388 + spin_lock_init(&wd_lock);
390 + ret = misc_register(&sc1x00wd_miscdev);
392 + printk(KERN_ERR "wd1100.c: Can't register device.\n");
395 + wd_table_header = register_sysctl_table(wd_root_table, 1);
396 + if (wd_table_header == NULL)
397 + printk(KERN_ERR "wd1100.c: Can't register sysctl.\n");
403 +static void __exit wd_exit(void)
405 + if (wd_table_header != NULL)
406 + unregister_sysctl_table(wd_table_header);
408 + misc_deregister(&sc1x00wd_miscdev);
413 +module_init(wd_init);
414 +module_exit(wd_exit);
416 +MODULE_LICENSE("GPL");