Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Paul Mundt | b1fa888 | 2010-05-24 10:55:59 +0900 | [diff] [blame^] | 2 | * drivers/watchdog/shwdt.c |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3 | * |
| 4 | * Watchdog driver for integrated watchdog in the SuperH processors. |
| 5 | * |
Paul Mundt | b1fa888 | 2010-05-24 10:55:59 +0900 | [diff] [blame^] | 6 | * Copyright (C) 2001 - 2010 Paul Mundt <lethal@linux-sh.org> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify it |
| 9 | * under the terms of the GNU General Public License as published by the |
| 10 | * Free Software Foundation; either version 2 of the License, or (at your |
| 11 | * option) any later version. |
| 12 | * |
| 13 | * 14-Dec-2001 Matt Domsch <Matt_Domsch@dell.com> |
| 14 | * Added nowayout module option to override CONFIG_WATCHDOG_NOWAYOUT |
| 15 | * |
| 16 | * 19-Apr-2002 Rob Radez <rob@osinvestor.com> |
| 17 | * Added expect close support, made emulated timeout runtime changeable |
| 18 | * general cleanups, add some ioctls |
| 19 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | #include <linux/module.h> |
| 21 | #include <linux/moduleparam.h> |
| 22 | #include <linux/init.h> |
| 23 | #include <linux/types.h> |
| 24 | #include <linux/miscdevice.h> |
| 25 | #include <linux/watchdog.h> |
| 26 | #include <linux/reboot.h> |
| 27 | #include <linux/notifier.h> |
| 28 | #include <linux/ioport.h> |
| 29 | #include <linux/fs.h> |
Paul Mundt | f118420 | 2006-09-27 17:53:59 +0900 | [diff] [blame] | 30 | #include <linux/mm.h> |
Alan Cox | 70b814e | 2008-05-19 14:08:55 +0100 | [diff] [blame] | 31 | #include <linux/io.h> |
| 32 | #include <linux/uaccess.h> |
Adrian Bunk | 58cf419 | 2008-08-08 18:39:11 +0300 | [diff] [blame] | 33 | #include <asm/watchdog.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | |
| 35 | #define PFX "shwdt: " |
| 36 | |
| 37 | /* |
| 38 | * Default clock division ratio is 5.25 msecs. For an additional table of |
| 39 | * values, consult the asm-sh/watchdog.h. Overload this at module load |
| 40 | * time. |
| 41 | * |
| 42 | * In order for this to work reliably we need to have HZ set to 1000 or |
| 43 | * something quite higher than 100 (or we need a proper high-res timer |
| 44 | * implementation that will deal with this properly), otherwise the 10ms |
| 45 | * resolution of a jiffy is enough to trigger the overflow. For things like |
| 46 | * the SH-4 and SH-5, this isn't necessarily that big of a problem, though |
| 47 | * for the SH-2 and SH-3, this isn't recommended unless the WDT is absolutely |
| 48 | * necssary. |
| 49 | * |
| 50 | * As a result of this timing problem, the only modes that are particularly |
| 51 | * feasible are the 4096 and the 2048 divisors, which yeild 5.25 and 2.62ms |
| 52 | * overflow periods respectively. |
| 53 | * |
| 54 | * Also, since we can't really expect userspace to be responsive enough |
Joe Perches | ee0fc09 | 2008-02-03 17:32:52 +0200 | [diff] [blame] | 55 | * before the overflow happens, we maintain two separate timers .. One in |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 56 | * the kernel for clearing out WOVF every 2ms or so (again, this depends on |
| 57 | * HZ == 1000), and another for monitoring userspace writes to the WDT device. |
| 58 | * |
| 59 | * As such, we currently use a configurable heartbeat interval which defaults |
| 60 | * to 30s. In this case, the userspace daemon is only responsible for periodic |
| 61 | * writes to the device before the next heartbeat is scheduled. If the daemon |
| 62 | * misses its deadline, the kernel timer will allow the WDT to overflow. |
| 63 | */ |
| 64 | static int clock_division_ratio = WTCSR_CKS_4096; |
| 65 | |
| 66 | #define next_ping_period(cks) msecs_to_jiffies(cks - 4) |
| 67 | |
Jiri Slaby | 82eb7c5 | 2007-02-08 18:39:36 +0100 | [diff] [blame] | 68 | static void sh_wdt_ping(unsigned long data); |
| 69 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | static unsigned long shwdt_is_open; |
Adrian Bunk | 58cf419 | 2008-08-08 18:39:11 +0300 | [diff] [blame] | 71 | static const struct watchdog_info sh_wdt_info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | static char shwdt_expect_close; |
Jiri Slaby | 82eb7c5 | 2007-02-08 18:39:36 +0100 | [diff] [blame] | 73 | static DEFINE_TIMER(timer, sh_wdt_ping, 0, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | static unsigned long next_heartbeat; |
Alan Cox | 70b814e | 2008-05-19 14:08:55 +0100 | [diff] [blame] | 75 | static DEFINE_SPINLOCK(shwdt_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | |
| 77 | #define WATCHDOG_HEARTBEAT 30 /* 30 sec default heartbeat */ |
| 78 | static int heartbeat = WATCHDOG_HEARTBEAT; /* in seconds */ |
Andrey Panin | 4bfdf37 | 2005-07-27 11:43:58 -0700 | [diff] [blame] | 79 | static int nowayout = WATCHDOG_NOWAYOUT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | static void sh_wdt_start(void) |
| 82 | { |
| 83 | __u8 csr; |
Alan Cox | 70b814e | 2008-05-19 14:08:55 +0100 | [diff] [blame] | 84 | unsigned long flags; |
| 85 | |
Adrian Bunk | 58cf419 | 2008-08-08 18:39:11 +0300 | [diff] [blame] | 86 | spin_lock_irqsave(&shwdt_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 87 | |
| 88 | next_heartbeat = jiffies + (heartbeat * HZ); |
| 89 | mod_timer(&timer, next_ping_period(clock_division_ratio)); |
| 90 | |
| 91 | csr = sh_wdt_read_csr(); |
| 92 | csr |= WTCSR_WT | clock_division_ratio; |
| 93 | sh_wdt_write_csr(csr); |
| 94 | |
| 95 | sh_wdt_write_cnt(0); |
| 96 | |
| 97 | /* |
| 98 | * These processors have a bit of an inconsistent initialization |
| 99 | * process.. starting with SH-3, RSTS was moved to WTCSR, and the |
| 100 | * RSTCSR register was removed. |
| 101 | * |
| 102 | * On the SH-2 however, in addition with bits being in different |
| 103 | * locations, we must deal with RSTCSR outright.. |
| 104 | */ |
| 105 | csr = sh_wdt_read_csr(); |
| 106 | csr |= WTCSR_TME; |
| 107 | csr &= ~WTCSR_RSTS; |
| 108 | sh_wdt_write_csr(csr); |
| 109 | |
| 110 | #ifdef CONFIG_CPU_SH2 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 111 | csr = sh_wdt_read_rstcsr(); |
| 112 | csr &= ~RSTCSR_RSTS; |
| 113 | sh_wdt_write_rstcsr(csr); |
| 114 | #endif |
Adrian Bunk | 58cf419 | 2008-08-08 18:39:11 +0300 | [diff] [blame] | 115 | spin_unlock_irqrestore(&shwdt_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 116 | } |
| 117 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 118 | static void sh_wdt_stop(void) |
| 119 | { |
| 120 | __u8 csr; |
Alan Cox | 70b814e | 2008-05-19 14:08:55 +0100 | [diff] [blame] | 121 | unsigned long flags; |
| 122 | |
Adrian Bunk | 58cf419 | 2008-08-08 18:39:11 +0300 | [diff] [blame] | 123 | spin_lock_irqsave(&shwdt_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 124 | |
| 125 | del_timer(&timer); |
| 126 | |
| 127 | csr = sh_wdt_read_csr(); |
| 128 | csr &= ~WTCSR_TME; |
| 129 | sh_wdt_write_csr(csr); |
Adrian Bunk | 58cf419 | 2008-08-08 18:39:11 +0300 | [diff] [blame] | 130 | spin_unlock_irqrestore(&shwdt_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 131 | } |
| 132 | |
Paul Mundt | e4c2cfe | 2006-09-27 12:31:01 +0900 | [diff] [blame] | 133 | static inline void sh_wdt_keepalive(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 134 | { |
Alan Cox | 70b814e | 2008-05-19 14:08:55 +0100 | [diff] [blame] | 135 | unsigned long flags; |
| 136 | |
Adrian Bunk | 58cf419 | 2008-08-08 18:39:11 +0300 | [diff] [blame] | 137 | spin_lock_irqsave(&shwdt_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 138 | next_heartbeat = jiffies + (heartbeat * HZ); |
Adrian Bunk | 58cf419 | 2008-08-08 18:39:11 +0300 | [diff] [blame] | 139 | spin_unlock_irqrestore(&shwdt_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 140 | } |
| 141 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 142 | static int sh_wdt_set_heartbeat(int t) |
| 143 | { |
Alan Cox | 70b814e | 2008-05-19 14:08:55 +0100 | [diff] [blame] | 144 | unsigned long flags; |
| 145 | |
| 146 | if (unlikely(t < 1 || t > 3600)) /* arbitrary upper limit */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 147 | return -EINVAL; |
| 148 | |
Adrian Bunk | 58cf419 | 2008-08-08 18:39:11 +0300 | [diff] [blame] | 149 | spin_lock_irqsave(&shwdt_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 150 | heartbeat = t; |
Adrian Bunk | 58cf419 | 2008-08-08 18:39:11 +0300 | [diff] [blame] | 151 | spin_unlock_irqrestore(&shwdt_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 152 | return 0; |
| 153 | } |
| 154 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 155 | static void sh_wdt_ping(unsigned long data) |
| 156 | { |
Alan Cox | 70b814e | 2008-05-19 14:08:55 +0100 | [diff] [blame] | 157 | unsigned long flags; |
| 158 | |
Adrian Bunk | 58cf419 | 2008-08-08 18:39:11 +0300 | [diff] [blame] | 159 | spin_lock_irqsave(&shwdt_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 160 | if (time_before(jiffies, next_heartbeat)) { |
| 161 | __u8 csr; |
| 162 | |
| 163 | csr = sh_wdt_read_csr(); |
| 164 | csr &= ~WTCSR_IOVF; |
| 165 | sh_wdt_write_csr(csr); |
| 166 | |
| 167 | sh_wdt_write_cnt(0); |
| 168 | |
| 169 | mod_timer(&timer, next_ping_period(clock_division_ratio)); |
Paul Mundt | e4c2cfe | 2006-09-27 12:31:01 +0900 | [diff] [blame] | 170 | } else |
| 171 | printk(KERN_WARNING PFX "Heartbeat lost! Will not ping " |
| 172 | "the watchdog\n"); |
Adrian Bunk | 58cf419 | 2008-08-08 18:39:11 +0300 | [diff] [blame] | 173 | spin_unlock_irqrestore(&shwdt_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 174 | } |
| 175 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 176 | static int sh_wdt_open(struct inode *inode, struct file *file) |
| 177 | { |
| 178 | if (test_and_set_bit(0, &shwdt_is_open)) |
| 179 | return -EBUSY; |
| 180 | if (nowayout) |
| 181 | __module_get(THIS_MODULE); |
| 182 | |
| 183 | sh_wdt_start(); |
| 184 | |
| 185 | return nonseekable_open(inode, file); |
| 186 | } |
| 187 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 188 | static int sh_wdt_close(struct inode *inode, struct file *file) |
| 189 | { |
| 190 | if (shwdt_expect_close == 42) { |
| 191 | sh_wdt_stop(); |
| 192 | } else { |
Paul Mundt | e4c2cfe | 2006-09-27 12:31:01 +0900 | [diff] [blame] | 193 | printk(KERN_CRIT PFX "Unexpected close, not " |
| 194 | "stopping watchdog!\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 195 | sh_wdt_keepalive(); |
| 196 | } |
| 197 | |
| 198 | clear_bit(0, &shwdt_is_open); |
| 199 | shwdt_expect_close = 0; |
| 200 | |
| 201 | return 0; |
| 202 | } |
| 203 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 204 | static ssize_t sh_wdt_write(struct file *file, const char *buf, |
| 205 | size_t count, loff_t *ppos) |
| 206 | { |
| 207 | if (count) { |
| 208 | if (!nowayout) { |
| 209 | size_t i; |
| 210 | |
| 211 | shwdt_expect_close = 0; |
| 212 | |
| 213 | for (i = 0; i != count; i++) { |
| 214 | char c; |
| 215 | if (get_user(c, buf + i)) |
| 216 | return -EFAULT; |
| 217 | if (c == 'V') |
| 218 | shwdt_expect_close = 42; |
| 219 | } |
| 220 | } |
| 221 | sh_wdt_keepalive(); |
| 222 | } |
| 223 | |
| 224 | return count; |
| 225 | } |
| 226 | |
Alan Cox | 70b814e | 2008-05-19 14:08:55 +0100 | [diff] [blame] | 227 | static long sh_wdt_ioctl(struct file *file, unsigned int cmd, |
| 228 | unsigned long arg) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 229 | { |
| 230 | int new_heartbeat; |
| 231 | int options, retval = -EINVAL; |
| 232 | |
| 233 | switch (cmd) { |
Alan Cox | 70b814e | 2008-05-19 14:08:55 +0100 | [diff] [blame] | 234 | case WDIOC_GETSUPPORT: |
| 235 | return copy_to_user((struct watchdog_info *)arg, |
| 236 | &sh_wdt_info, sizeof(sh_wdt_info)) ? -EFAULT : 0; |
| 237 | case WDIOC_GETSTATUS: |
| 238 | case WDIOC_GETBOOTSTATUS: |
| 239 | return put_user(0, (int *)arg); |
Alan Cox | 70b814e | 2008-05-19 14:08:55 +0100 | [diff] [blame] | 240 | case WDIOC_SETOPTIONS: |
| 241 | if (get_user(options, (int *)arg)) |
| 242 | return -EFAULT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 243 | |
Alan Cox | 70b814e | 2008-05-19 14:08:55 +0100 | [diff] [blame] | 244 | if (options & WDIOS_DISABLECARD) { |
| 245 | sh_wdt_stop(); |
| 246 | retval = 0; |
| 247 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 248 | |
Alan Cox | 70b814e | 2008-05-19 14:08:55 +0100 | [diff] [blame] | 249 | if (options & WDIOS_ENABLECARD) { |
| 250 | sh_wdt_start(); |
| 251 | retval = 0; |
| 252 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 253 | |
Alan Cox | 70b814e | 2008-05-19 14:08:55 +0100 | [diff] [blame] | 254 | return retval; |
Wim Van Sebroeck | 0c06090c | 2008-07-18 11:41:17 +0000 | [diff] [blame] | 255 | case WDIOC_KEEPALIVE: |
| 256 | sh_wdt_keepalive(); |
| 257 | return 0; |
| 258 | case WDIOC_SETTIMEOUT: |
| 259 | if (get_user(new_heartbeat, (int *)arg)) |
| 260 | return -EFAULT; |
| 261 | |
| 262 | if (sh_wdt_set_heartbeat(new_heartbeat)) |
| 263 | return -EINVAL; |
| 264 | |
| 265 | sh_wdt_keepalive(); |
| 266 | /* Fall */ |
| 267 | case WDIOC_GETTIMEOUT: |
| 268 | return put_user(heartbeat, (int *)arg); |
Alan Cox | 70b814e | 2008-05-19 14:08:55 +0100 | [diff] [blame] | 269 | default: |
| 270 | return -ENOTTY; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 271 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 272 | return 0; |
| 273 | } |
| 274 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 275 | static int sh_wdt_notify_sys(struct notifier_block *this, |
| 276 | unsigned long code, void *unused) |
| 277 | { |
Paul Mundt | e4c2cfe | 2006-09-27 12:31:01 +0900 | [diff] [blame] | 278 | if (code == SYS_DOWN || code == SYS_HALT) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 279 | sh_wdt_stop(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 280 | |
| 281 | return NOTIFY_DONE; |
| 282 | } |
| 283 | |
Arjan van de Ven | 62322d2 | 2006-07-03 00:24:21 -0700 | [diff] [blame] | 284 | static const struct file_operations sh_wdt_fops = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 285 | .owner = THIS_MODULE, |
| 286 | .llseek = no_llseek, |
| 287 | .write = sh_wdt_write, |
Alan Cox | 70b814e | 2008-05-19 14:08:55 +0100 | [diff] [blame] | 288 | .unlocked_ioctl = sh_wdt_ioctl, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 289 | .open = sh_wdt_open, |
| 290 | .release = sh_wdt_close, |
| 291 | }; |
| 292 | |
Alan Cox | 70b814e | 2008-05-19 14:08:55 +0100 | [diff] [blame] | 293 | static const struct watchdog_info sh_wdt_info = { |
Paul Mundt | e4c2cfe | 2006-09-27 12:31:01 +0900 | [diff] [blame] | 294 | .options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT | |
| 295 | WDIOF_MAGICCLOSE, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 296 | .firmware_version = 1, |
| 297 | .identity = "SH WDT", |
| 298 | }; |
| 299 | |
| 300 | static struct notifier_block sh_wdt_notifier = { |
| 301 | .notifier_call = sh_wdt_notify_sys, |
| 302 | }; |
| 303 | |
| 304 | static struct miscdevice sh_wdt_miscdev = { |
| 305 | .minor = WATCHDOG_MINOR, |
| 306 | .name = "watchdog", |
| 307 | .fops = &sh_wdt_fops, |
| 308 | }; |
| 309 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 310 | static int __init sh_wdt_init(void) |
| 311 | { |
| 312 | int rc; |
| 313 | |
Alan Cox | 70b814e | 2008-05-19 14:08:55 +0100 | [diff] [blame] | 314 | if (clock_division_ratio < 0x5 || clock_division_ratio > 0x7) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 315 | clock_division_ratio = WTCSR_CKS_4096; |
Alan Cox | 70b814e | 2008-05-19 14:08:55 +0100 | [diff] [blame] | 316 | printk(KERN_INFO PFX |
| 317 | "clock_division_ratio value must be 0x5<=x<=0x7, using %d\n", |
| 318 | clock_division_ratio); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 319 | } |
| 320 | |
Paul Mundt | e4c2cfe | 2006-09-27 12:31:01 +0900 | [diff] [blame] | 321 | rc = sh_wdt_set_heartbeat(heartbeat); |
| 322 | if (unlikely(rc)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 323 | heartbeat = WATCHDOG_HEARTBEAT; |
Alan Cox | 70b814e | 2008-05-19 14:08:55 +0100 | [diff] [blame] | 324 | printk(KERN_INFO PFX |
| 325 | "heartbeat value must be 1<=x<=3600, using %d\n", |
| 326 | heartbeat); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 327 | } |
| 328 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 329 | rc = register_reboot_notifier(&sh_wdt_notifier); |
Paul Mundt | e4c2cfe | 2006-09-27 12:31:01 +0900 | [diff] [blame] | 330 | if (unlikely(rc)) { |
Alan Cox | 70b814e | 2008-05-19 14:08:55 +0100 | [diff] [blame] | 331 | printk(KERN_ERR PFX |
| 332 | "Can't register reboot notifier (err=%d)\n", rc); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 333 | return rc; |
| 334 | } |
| 335 | |
| 336 | rc = misc_register(&sh_wdt_miscdev); |
Paul Mundt | e4c2cfe | 2006-09-27 12:31:01 +0900 | [diff] [blame] | 337 | if (unlikely(rc)) { |
Alan Cox | 70b814e | 2008-05-19 14:08:55 +0100 | [diff] [blame] | 338 | printk(KERN_ERR PFX |
| 339 | "Can't register miscdev on minor=%d (err=%d)\n", |
| 340 | sh_wdt_miscdev.minor, rc); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 341 | unregister_reboot_notifier(&sh_wdt_notifier); |
| 342 | return rc; |
| 343 | } |
| 344 | |
| 345 | printk(KERN_INFO PFX "initialized. heartbeat=%d sec (nowayout=%d)\n", |
| 346 | heartbeat, nowayout); |
| 347 | |
| 348 | return 0; |
| 349 | } |
| 350 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 351 | static void __exit sh_wdt_exit(void) |
| 352 | { |
| 353 | misc_deregister(&sh_wdt_miscdev); |
| 354 | unregister_reboot_notifier(&sh_wdt_notifier); |
| 355 | } |
| 356 | |
| 357 | MODULE_AUTHOR("Paul Mundt <lethal@linux-sh.org>"); |
| 358 | MODULE_DESCRIPTION("SuperH watchdog driver"); |
| 359 | MODULE_LICENSE("GPL"); |
| 360 | MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); |
| 361 | |
| 362 | module_param(clock_division_ratio, int, 0); |
Wim Van Sebroeck | a77dba7 | 2009-04-14 20:20:07 +0000 | [diff] [blame] | 363 | MODULE_PARM_DESC(clock_division_ratio, |
| 364 | "Clock division ratio. Valid ranges are from 0x5 (1.31ms) " |
| 365 | "to 0x7 (5.25ms). (default=" __MODULE_STRING(clock_division_ratio) ")"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 366 | |
| 367 | module_param(heartbeat, int, 0); |
Alan Cox | 70b814e | 2008-05-19 14:08:55 +0100 | [diff] [blame] | 368 | MODULE_PARM_DESC(heartbeat, |
| 369 | "Watchdog heartbeat in seconds. (1 <= heartbeat <= 3600, default=" |
| 370 | __MODULE_STRING(WATCHDOG_HEARTBEAT) ")"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 371 | |
| 372 | module_param(nowayout, int, 0); |
Alan Cox | 70b814e | 2008-05-19 14:08:55 +0100 | [diff] [blame] | 373 | MODULE_PARM_DESC(nowayout, |
| 374 | "Watchdog cannot be stopped once started (default=" |
| 375 | __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 376 | |
| 377 | module_init(sh_wdt_init); |
| 378 | module_exit(sh_wdt_exit); |