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@cymru.net>, All Rights Reserved.
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@lxorguk.ukuu.org.uk>
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>
41 static int acq_is_open
=0;
44 * You must set these - there is no sane way to probe for this board.
48 #define WDT_START 0x443
50 #define WD_TIMO (100*60) /* 1 minute */
58 static void acq_ping(void)
60 /* Write a watchdog value */
64 static ssize_t
acq_write(struct file
*file
, const char *buf
, size_t count
, loff_t
*ppos
)
66 /* Can't seek (pwrite) on this device */
67 if (ppos
!= &file
->f_pos
)
78 static ssize_t
acq_read(struct file
*file
, char *buf
, size_t count
, loff_t
*ppos
)
85 static int acq_ioctl(struct inode
*inode
, struct file
*file
, unsigned int cmd
,
88 static struct watchdog_info ident
=
90 WDIOF_KEEPALIVEPING
, 1, "Acquire WDT"
95 case WDIOC_GETSUPPORT
:
96 if (copy_to_user((struct watchdog_info
*)arg
, &ident
, sizeof(ident
)))
100 case WDIOC_GETSTATUS
:
101 if (copy_to_user((int *)arg
, &acq_is_open
, sizeof(int)))
105 case WDIOC_KEEPALIVE
:
115 static int acq_open(struct inode
*inode
, struct file
*file
)
117 switch(MINOR(inode
->i_rdev
))
135 static int acq_close(struct inode
*inode
, struct file
*file
)
137 if(MINOR(inode
->i_rdev
)==WATCHDOG_MINOR
)
139 #ifndef CONFIG_WATCHDOG_NOWAYOUT
149 * Notifier for system down
152 static int acq_notify_sys(struct notifier_block
*this, unsigned long code
,
155 if(code
==SYS_DOWN
|| code
==SYS_HALT
)
157 /* Turn the card off */
168 static struct file_operations acq_fops
= {
172 NULL
, /* No Readdir */
173 NULL
, /* No Select */
181 static struct miscdevice acq_miscdev
=
190 * The WDT card needs to learn about soft shutdowns in order to
191 * turn the timebomb registers off.
194 static struct notifier_block acq_notifier
=
203 #define acq_init init_module
205 void cleanup_module(void)
207 misc_deregister(&acq_miscdev
);
208 unregister_reboot_notifier(&acq_notifier
);
209 release_region(WDT_STOP
,1);
210 release_region(WDT_START
,1);
215 __initfunc(int acq_init(void))
217 printk("WDT driver for Acquire single board computer initialising.\n");
219 misc_register(&acq_miscdev
);
220 request_region(WDT_STOP
, 1, "Acquire WDT");
221 request_region(WDT_START
, 1, "Acquire WDT");
222 unregister_reboot_notifier(&acq_notifier
);