2 * Acquire Single Board Computer Watchdog Timer driver for Linux 2.1.x
4 * Based on wdt.c. Original copyright messages:
6 * (c) Copyright 1996 Alan Cox <alan@redhat.com>, All Rights Reserved.
7 * http://www.redhat.com
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version
12 * 2 of the License, or (at your option) any later version.
14 * Neither Alan Cox nor CymruNet Ltd. admit liability nor provide
15 * warranty for any of this software. This material is provided
16 * "AS-IS" and at no charge.
18 * (c) Copyright 1995 Alan Cox <alan@redhat.com>
22 #include <linux/config.h>
23 #include <linux/module.h>
24 #include <linux/version.h>
25 #include <linux/types.h>
26 #include <linux/errno.h>
27 #include <linux/kernel.h>
28 #include <linux/sched.h>
29 #include <linux/miscdevice.h>
30 #include <linux/watchdog.h>
31 #include <linux/malloc.h>
32 #include <linux/ioport.h>
33 #include <linux/fcntl.h>
35 #include <asm/uaccess.h>
36 #include <asm/system.h>
37 #include <linux/notifier.h>
38 #include <linux/reboot.h>
39 #include <linux/init.h>
40 #include <linux/spinlock.h>
41 #include <linux/smp_lock.h>
43 static int acq_is_open
;
44 static spinlock_t acq_lock
;
47 * You must set these - there is no sane way to probe for this board.
51 #define WDT_START 0x443
53 #define WD_TIMO (100*60) /* 1 minute */
61 static void acq_ping(void)
63 /* Write a watchdog value */
67 static ssize_t
acq_write(struct file
*file
, const char *buf
, size_t count
, loff_t
*ppos
)
69 /* Can't seek (pwrite) on this device */
70 if (ppos
!= &file
->f_pos
)
81 static ssize_t
acq_read(struct file
*file
, char *buf
, size_t count
, loff_t
*ppos
)
88 static int acq_ioctl(struct inode
*inode
, struct file
*file
, unsigned int cmd
,
91 static struct watchdog_info ident
=
93 WDIOF_KEEPALIVEPING
, 1, "Acquire WDT"
98 case WDIOC_GETSUPPORT
:
99 if (copy_to_user((struct watchdog_info
*)arg
, &ident
, sizeof(ident
)))
103 case WDIOC_GETSTATUS
:
104 if (copy_to_user((int *)arg
, &acq_is_open
, sizeof(int)))
108 case WDIOC_KEEPALIVE
:
118 static int acq_open(struct inode
*inode
, struct file
*file
)
120 switch(MINOR(inode
->i_rdev
))
123 spin_lock(&acq_lock
);
126 spin_unlock(&acq_lock
);
135 spin_unlock(&acq_lock
);
142 static int acq_close(struct inode
*inode
, struct file
*file
)
145 if(MINOR(inode
->i_rdev
)==WATCHDOG_MINOR
)
147 spin_lock(&acq_lock
);
148 #ifndef CONFIG_WATCHDOG_NOWAYOUT
152 spin_unlock(&acq_lock
);
159 * Notifier for system down
162 static int acq_notify_sys(struct notifier_block
*this, unsigned long code
,
165 if(code
==SYS_DOWN
|| code
==SYS_HALT
)
167 /* Turn the card off */
178 static struct file_operations acq_fops
= {
187 static struct miscdevice acq_miscdev
=
196 * The WDT card needs to learn about soft shutdowns in order to
197 * turn the timebomb registers off.
200 static struct notifier_block acq_notifier
=
207 static int __init
acq_init(void)
209 printk("WDT driver for Acquire single board computer initialising.\n");
211 spin_lock_init(&acq_lock
);
212 misc_register(&acq_miscdev
);
213 request_region(WDT_STOP
, 1, "Acquire WDT");
214 request_region(WDT_START
, 1, "Acquire WDT");
215 register_reboot_notifier(&acq_notifier
);
219 static void __exit
acq_exit(void)
221 misc_deregister(&acq_miscdev
);
222 unregister_reboot_notifier(&acq_notifier
);
223 release_region(WDT_STOP
,1);
224 release_region(WDT_START
,1);
227 module_init(acq_init
);
228 module_exit(acq_exit
);