2 * Intel 21285 watchdog driver
3 * Copyright (c) Phil Blundell <pb@nexus.co.uk>, 1998
7 * SoftDog 0.05: A Software Watchdog Device
9 * (c) Copyright 1996 Alan Cox <alan@cymru.net>, All Rights Reserved.
10 * http://www.cymru.net
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version
15 * 2 of the License, or (at your option) any later version.
19 #include <linux/module.h>
20 #include <linux/types.h>
21 #include <linux/kernel.h>
24 #include <linux/miscdevice.h>
25 #include <linux/watchdog.h>
26 #include <linux/reboot.h>
27 #include <linux/init.h>
28 #include <linux/interrupt.h>
31 #include <asm/uaccess.h>
32 #include <asm/hardware.h>
33 #include <asm/system.h>
34 #include <asm/dec21285.h>
37 * Define this to stop the watchdog actually rebooting the machine.
41 #define TIMER_MARGIN 60 /* (secs) Default is 1 minute */
43 #define FCLK (50*1000*1000) /* 50MHz */
45 static int soft_margin
= TIMER_MARGIN
; /* in seconds */
46 static int timer_alive
= 0;
50 * If the timer expires..
53 static void watchdog_fire(int irq
, void *dev_id
, struct pt_regs
*regs
)
55 printk(KERN_CRIT
"Watchdog: Would Reboot.\n");
61 static void watchdog_ping(void)
66 *CSR_TIMER4_LOAD
= soft_margin
* (FCLK
/ 256);
70 * Allow only one person to hold it open
73 static int watchdog_open(struct inode
*inode
, struct file
*file
)
79 * Ahead watchdog factor ten, Mr Sulu
83 *CSR_TIMER4_CNTL
= TIMER_CNTL_ENABLE
| TIMER_CNTL_AUTORELOAD
86 request_irq(IRQ_TIMER4
, watchdog_fire
, 0, "watchdog", NULL
);
88 *CSR_SA110_CNTL
|= 1 << 13;
94 static int watchdog_release(struct inode
*inode
, struct file
*file
)
97 free_irq(IRQ_TIMER4
, NULL
);
108 static ssize_t
watchdog_write(struct file
*file
, const char *data
, size_t len
, loff_t
*ppos
)
110 /* Can't seek (pwrite) on this device */
111 if (ppos
!= &file
->f_pos
)
125 static int watchdog_ioctl(struct inode
*inode
, struct file
*file
,
126 unsigned int cmd
, unsigned long arg
)
129 static struct watchdog_info ident
=
133 "Footbridge Watchdog"
139 case WDIOC_GETSUPPORT
:
140 i
= verify_area(VERIFY_WRITE
, (void*) arg
, sizeof(struct watchdog_info
));
144 return copy_to_user((struct watchdog_info
*)arg
, &ident
, sizeof(ident
));
145 case WDIOC_GETSTATUS
:
146 case WDIOC_GETBOOTSTATUS
:
147 return put_user(0,(int *)arg
);
148 case WDIOC_KEEPALIVE
:
154 static struct file_operations watchdog_fops
=
156 write
: watchdog_write
,
157 ioctl
: watchdog_ioctl
,
159 release
: watchdog_release
,
162 static struct miscdevice watchdog_miscdev
=
169 static int __init
footbridge_watchdog_init(void)
171 if (machine_is_netwinder())
174 misc_register(&watchdog_miscdev
);
175 printk("Footbridge Watchdog Timer: 0.01, timer margin: %d sec\n",
177 if (machine_is_cats())
178 printk("Warning: Watchdog reset may not work on this machine.\n");
182 static void __exit
footbridge_watchdog_exit(void)
184 misc_deregister(&watchdog_miscdev
);
189 MODULE_AUTHOR("Phil Blundell <pb@nexus.co.uk>");
190 MODULE_DESCRIPTION("21285 watchdog driver");
192 MODULE_PARM(soft_margin
,"i");
193 MODULE_PARM_DESC(soft_margin
,"Watchdog timeout in seconds");
195 module_init(footbridge_watchdog_init
);
196 module_exit(footbridge_watchdog_exit
);