blob: 74a261f36702e6f412ee323b2864dbd650552024 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Paul Mundtb1fa8882010-05-24 10:55:59 +09002 * drivers/watchdog/shwdt.c
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 *
4 * Watchdog driver for integrated watchdog in the SuperH processors.
5 *
Paul Mundt40968122012-05-10 14:21:15 +09006 * Copyright (C) 2001 - 2012 Paul Mundt <lethal@linux-sh.org>
Linus Torvalds1da177e2005-04-16 15:20:36 -07007 *
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 */
Joe Perches27c766a2012-02-15 15:06:19 -080020
21#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
22
Linus Torvalds1da177e2005-04-16 15:20:36 -070023#include <linux/module.h>
24#include <linux/moduleparam.h>
Paul Mundt8f5585e2010-05-25 18:31:12 +090025#include <linux/platform_device.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070026#include <linux/init.h>
27#include <linux/types.h>
28#include <linux/miscdevice.h>
29#include <linux/watchdog.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070030#include <linux/ioport.h>
31#include <linux/fs.h>
Paul Mundtf1184202006-09-27 17:53:59 +090032#include <linux/mm.h>
Paul Mundt8f5585e2010-05-25 18:31:12 +090033#include <linux/slab.h>
Alan Cox70b814e2008-05-19 14:08:55 +010034#include <linux/io.h>
35#include <linux/uaccess.h>
Adrian Bunk58cf4192008-08-08 18:39:11 +030036#include <asm/watchdog.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070037
Paul Mundt8f5585e2010-05-25 18:31:12 +090038#define DRV_NAME "sh-wdt"
Linus Torvalds1da177e2005-04-16 15:20:36 -070039
40/*
41 * Default clock division ratio is 5.25 msecs. For an additional table of
42 * values, consult the asm-sh/watchdog.h. Overload this at module load
43 * time.
44 *
45 * In order for this to work reliably we need to have HZ set to 1000 or
46 * something quite higher than 100 (or we need a proper high-res timer
47 * implementation that will deal with this properly), otherwise the 10ms
48 * resolution of a jiffy is enough to trigger the overflow. For things like
49 * the SH-4 and SH-5, this isn't necessarily that big of a problem, though
50 * for the SH-2 and SH-3, this isn't recommended unless the WDT is absolutely
51 * necssary.
52 *
53 * As a result of this timing problem, the only modes that are particularly
Lucas De Marchi25985ed2011-03-30 22:57:33 -030054 * feasible are the 4096 and the 2048 divisors, which yield 5.25 and 2.62ms
Linus Torvalds1da177e2005-04-16 15:20:36 -070055 * overflow periods respectively.
56 *
57 * Also, since we can't really expect userspace to be responsive enough
Joe Perchesee0fc092008-02-03 17:32:52 +020058 * before the overflow happens, we maintain two separate timers .. One in
Linus Torvalds1da177e2005-04-16 15:20:36 -070059 * the kernel for clearing out WOVF every 2ms or so (again, this depends on
60 * HZ == 1000), and another for monitoring userspace writes to the WDT device.
61 *
62 * As such, we currently use a configurable heartbeat interval which defaults
63 * to 30s. In this case, the userspace daemon is only responsible for periodic
64 * writes to the device before the next heartbeat is scheduled. If the daemon
65 * misses its deadline, the kernel timer will allow the WDT to overflow.
66 */
67static int clock_division_ratio = WTCSR_CKS_4096;
David Engrafbea19062011-07-20 15:03:39 +020068#define next_ping_period(cks) (jiffies + msecs_to_jiffies(cks - 4))
Linus Torvalds1da177e2005-04-16 15:20:36 -070069
Adrian Bunk58cf4192008-08-08 18:39:11 +030070static const struct watchdog_info sh_wdt_info;
Paul Mundt8f5585e2010-05-25 18:31:12 +090071static struct platform_device *sh_wdt_dev;
Alan Cox70b814e2008-05-19 14:08:55 +010072static DEFINE_SPINLOCK(shwdt_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -070073
74#define WATCHDOG_HEARTBEAT 30 /* 30 sec default heartbeat */
75static int heartbeat = WATCHDOG_HEARTBEAT; /* in seconds */
Wim Van Sebroeck86a1e182012-03-05 16:51:11 +010076static bool nowayout = WATCHDOG_NOWAYOUT;
Paul Mundt8f5585e2010-05-25 18:31:12 +090077static unsigned long next_heartbeat;
Linus Torvalds1da177e2005-04-16 15:20:36 -070078
Paul Mundt8f5585e2010-05-25 18:31:12 +090079struct sh_wdt {
80 void __iomem *base;
81 struct device *dev;
82
83 struct timer_list timer;
84
85 unsigned long enabled;
86 char expect_close;
87};
88
89static void sh_wdt_start(struct sh_wdt *wdt)
Linus Torvalds1da177e2005-04-16 15:20:36 -070090{
Alan Cox70b814e2008-05-19 14:08:55 +010091 unsigned long flags;
Paul Mundt8f5585e2010-05-25 18:31:12 +090092 u8 csr;
Alan Cox70b814e2008-05-19 14:08:55 +010093
Adrian Bunk58cf4192008-08-08 18:39:11 +030094 spin_lock_irqsave(&shwdt_lock, flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -070095
96 next_heartbeat = jiffies + (heartbeat * HZ);
Paul Mundt8f5585e2010-05-25 18:31:12 +090097 mod_timer(&wdt->timer, next_ping_period(clock_division_ratio));
Linus Torvalds1da177e2005-04-16 15:20:36 -070098
99 csr = sh_wdt_read_csr();
100 csr |= WTCSR_WT | clock_division_ratio;
101 sh_wdt_write_csr(csr);
102
103 sh_wdt_write_cnt(0);
104
105 /*
106 * These processors have a bit of an inconsistent initialization
107 * process.. starting with SH-3, RSTS was moved to WTCSR, and the
108 * RSTCSR register was removed.
109 *
110 * On the SH-2 however, in addition with bits being in different
111 * locations, we must deal with RSTCSR outright..
112 */
113 csr = sh_wdt_read_csr();
114 csr |= WTCSR_TME;
115 csr &= ~WTCSR_RSTS;
116 sh_wdt_write_csr(csr);
117
118#ifdef CONFIG_CPU_SH2
Linus Torvalds1da177e2005-04-16 15:20:36 -0700119 csr = sh_wdt_read_rstcsr();
120 csr &= ~RSTCSR_RSTS;
121 sh_wdt_write_rstcsr(csr);
122#endif
Adrian Bunk58cf4192008-08-08 18:39:11 +0300123 spin_unlock_irqrestore(&shwdt_lock, flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700124}
125
Paul Mundt8f5585e2010-05-25 18:31:12 +0900126static void sh_wdt_stop(struct sh_wdt *wdt)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700127{
Alan Cox70b814e2008-05-19 14:08:55 +0100128 unsigned long flags;
Paul Mundt8f5585e2010-05-25 18:31:12 +0900129 u8 csr;
Alan Cox70b814e2008-05-19 14:08:55 +0100130
Adrian Bunk58cf4192008-08-08 18:39:11 +0300131 spin_lock_irqsave(&shwdt_lock, flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700132
Paul Mundt8f5585e2010-05-25 18:31:12 +0900133 del_timer(&wdt->timer);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700134
135 csr = sh_wdt_read_csr();
136 csr &= ~WTCSR_TME;
137 sh_wdt_write_csr(csr);
Paul Mundt8f5585e2010-05-25 18:31:12 +0900138
Adrian Bunk58cf4192008-08-08 18:39:11 +0300139 spin_unlock_irqrestore(&shwdt_lock, flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140}
141
Paul Mundt8f5585e2010-05-25 18:31:12 +0900142static inline void sh_wdt_keepalive(struct sh_wdt *wdt)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143{
Alan Cox70b814e2008-05-19 14:08:55 +0100144 unsigned long flags;
145
Adrian Bunk58cf4192008-08-08 18:39:11 +0300146 spin_lock_irqsave(&shwdt_lock, flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700147 next_heartbeat = jiffies + (heartbeat * HZ);
Adrian Bunk58cf4192008-08-08 18:39:11 +0300148 spin_unlock_irqrestore(&shwdt_lock, flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700149}
150
Linus Torvalds1da177e2005-04-16 15:20:36 -0700151static int sh_wdt_set_heartbeat(int t)
152{
Alan Cox70b814e2008-05-19 14:08:55 +0100153 unsigned long flags;
154
155 if (unlikely(t < 1 || t > 3600)) /* arbitrary upper limit */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700156 return -EINVAL;
157
Adrian Bunk58cf4192008-08-08 18:39:11 +0300158 spin_lock_irqsave(&shwdt_lock, flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700159 heartbeat = t;
Adrian Bunk58cf4192008-08-08 18:39:11 +0300160 spin_unlock_irqrestore(&shwdt_lock, flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700161 return 0;
162}
163
Linus Torvalds1da177e2005-04-16 15:20:36 -0700164static void sh_wdt_ping(unsigned long data)
165{
Paul Mundt8f5585e2010-05-25 18:31:12 +0900166 struct sh_wdt *wdt = (struct sh_wdt *)data;
Alan Cox70b814e2008-05-19 14:08:55 +0100167 unsigned long flags;
168
Adrian Bunk58cf4192008-08-08 18:39:11 +0300169 spin_lock_irqsave(&shwdt_lock, flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700170 if (time_before(jiffies, next_heartbeat)) {
Paul Mundt8f5585e2010-05-25 18:31:12 +0900171 u8 csr;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700172
173 csr = sh_wdt_read_csr();
174 csr &= ~WTCSR_IOVF;
175 sh_wdt_write_csr(csr);
176
177 sh_wdt_write_cnt(0);
178
Paul Mundt8f5585e2010-05-25 18:31:12 +0900179 mod_timer(&wdt->timer, next_ping_period(clock_division_ratio));
Paul Mundte4c2cfe2006-09-27 12:31:01 +0900180 } else
Paul Mundt8f5585e2010-05-25 18:31:12 +0900181 dev_warn(wdt->dev, "Heartbeat lost! Will not ping "
182 "the watchdog\n");
Adrian Bunk58cf4192008-08-08 18:39:11 +0300183 spin_unlock_irqrestore(&shwdt_lock, flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700184}
185
Linus Torvalds1da177e2005-04-16 15:20:36 -0700186static int sh_wdt_open(struct inode *inode, struct file *file)
187{
Paul Mundt8f5585e2010-05-25 18:31:12 +0900188 struct sh_wdt *wdt = platform_get_drvdata(sh_wdt_dev);
189
190 if (test_and_set_bit(0, &wdt->enabled))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700191 return -EBUSY;
192 if (nowayout)
193 __module_get(THIS_MODULE);
194
Paul Mundt8f5585e2010-05-25 18:31:12 +0900195 file->private_data = wdt;
196
197 sh_wdt_start(wdt);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700198
199 return nonseekable_open(inode, file);
200}
201
Linus Torvalds1da177e2005-04-16 15:20:36 -0700202static int sh_wdt_close(struct inode *inode, struct file *file)
203{
Paul Mundt8f5585e2010-05-25 18:31:12 +0900204 struct sh_wdt *wdt = file->private_data;
205
206 if (wdt->expect_close == 42) {
207 sh_wdt_stop(wdt);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700208 } else {
Paul Mundt8f5585e2010-05-25 18:31:12 +0900209 dev_crit(wdt->dev, "Unexpected close, not "
210 "stopping watchdog!\n");
211 sh_wdt_keepalive(wdt);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700212 }
213
Paul Mundt8f5585e2010-05-25 18:31:12 +0900214 clear_bit(0, &wdt->enabled);
215 wdt->expect_close = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700216
217 return 0;
218}
219
Linus Torvalds1da177e2005-04-16 15:20:36 -0700220static ssize_t sh_wdt_write(struct file *file, const char *buf,
221 size_t count, loff_t *ppos)
222{
Paul Mundt8f5585e2010-05-25 18:31:12 +0900223 struct sh_wdt *wdt = file->private_data;
224
Linus Torvalds1da177e2005-04-16 15:20:36 -0700225 if (count) {
226 if (!nowayout) {
227 size_t i;
228
Paul Mundt8f5585e2010-05-25 18:31:12 +0900229 wdt->expect_close = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700230
231 for (i = 0; i != count; i++) {
232 char c;
233 if (get_user(c, buf + i))
234 return -EFAULT;
235 if (c == 'V')
Paul Mundt8f5585e2010-05-25 18:31:12 +0900236 wdt->expect_close = 42;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700237 }
238 }
Paul Mundt8f5585e2010-05-25 18:31:12 +0900239 sh_wdt_keepalive(wdt);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700240 }
241
242 return count;
243}
244
Alan Cox70b814e2008-05-19 14:08:55 +0100245static long sh_wdt_ioctl(struct file *file, unsigned int cmd,
246 unsigned long arg)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700247{
Paul Mundt8f5585e2010-05-25 18:31:12 +0900248 struct sh_wdt *wdt = file->private_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700249 int new_heartbeat;
250 int options, retval = -EINVAL;
251
252 switch (cmd) {
Alan Cox70b814e2008-05-19 14:08:55 +0100253 case WDIOC_GETSUPPORT:
254 return copy_to_user((struct watchdog_info *)arg,
255 &sh_wdt_info, sizeof(sh_wdt_info)) ? -EFAULT : 0;
256 case WDIOC_GETSTATUS:
257 case WDIOC_GETBOOTSTATUS:
258 return put_user(0, (int *)arg);
Alan Cox70b814e2008-05-19 14:08:55 +0100259 case WDIOC_SETOPTIONS:
260 if (get_user(options, (int *)arg))
261 return -EFAULT;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700262
Alan Cox70b814e2008-05-19 14:08:55 +0100263 if (options & WDIOS_DISABLECARD) {
Paul Mundt8f5585e2010-05-25 18:31:12 +0900264 sh_wdt_stop(wdt);
Alan Cox70b814e2008-05-19 14:08:55 +0100265 retval = 0;
266 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700267
Alan Cox70b814e2008-05-19 14:08:55 +0100268 if (options & WDIOS_ENABLECARD) {
Paul Mundt8f5585e2010-05-25 18:31:12 +0900269 sh_wdt_start(wdt);
Alan Cox70b814e2008-05-19 14:08:55 +0100270 retval = 0;
271 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700272
Alan Cox70b814e2008-05-19 14:08:55 +0100273 return retval;
Wim Van Sebroeck0c060902008-07-18 11:41:17 +0000274 case WDIOC_KEEPALIVE:
Paul Mundt8f5585e2010-05-25 18:31:12 +0900275 sh_wdt_keepalive(wdt);
Wim Van Sebroeck0c060902008-07-18 11:41:17 +0000276 return 0;
277 case WDIOC_SETTIMEOUT:
278 if (get_user(new_heartbeat, (int *)arg))
279 return -EFAULT;
280
281 if (sh_wdt_set_heartbeat(new_heartbeat))
282 return -EINVAL;
283
Paul Mundt8f5585e2010-05-25 18:31:12 +0900284 sh_wdt_keepalive(wdt);
Wim Van Sebroeck0c060902008-07-18 11:41:17 +0000285 /* Fall */
286 case WDIOC_GETTIMEOUT:
287 return put_user(heartbeat, (int *)arg);
Alan Cox70b814e2008-05-19 14:08:55 +0100288 default:
289 return -ENOTTY;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700290 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700291 return 0;
292}
293
Arjan van de Ven62322d22006-07-03 00:24:21 -0700294static const struct file_operations sh_wdt_fops = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700295 .owner = THIS_MODULE,
296 .llseek = no_llseek,
297 .write = sh_wdt_write,
Alan Cox70b814e2008-05-19 14:08:55 +0100298 .unlocked_ioctl = sh_wdt_ioctl,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700299 .open = sh_wdt_open,
300 .release = sh_wdt_close,
301};
302
Alan Cox70b814e2008-05-19 14:08:55 +0100303static const struct watchdog_info sh_wdt_info = {
Paul Mundte4c2cfe2006-09-27 12:31:01 +0900304 .options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT |
305 WDIOF_MAGICCLOSE,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700306 .firmware_version = 1,
307 .identity = "SH WDT",
308};
309
Linus Torvalds1da177e2005-04-16 15:20:36 -0700310static struct miscdevice sh_wdt_miscdev = {
311 .minor = WATCHDOG_MINOR,
312 .name = "watchdog",
313 .fops = &sh_wdt_fops,
314};
315
Paul Mundt8f5585e2010-05-25 18:31:12 +0900316static int __devinit sh_wdt_probe(struct platform_device *pdev)
317{
318 struct sh_wdt *wdt;
319 struct resource *res;
320 int rc;
321
322 /*
323 * As this driver only covers the global watchdog case, reject
324 * any attempts to register per-CPU watchdogs.
325 */
326 if (pdev->id != -1)
327 return -EINVAL;
328
329 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
330 if (unlikely(!res))
331 return -EINVAL;
332
333 if (!devm_request_mem_region(&pdev->dev, res->start,
334 resource_size(res), DRV_NAME))
335 return -EBUSY;
336
337 wdt = devm_kzalloc(&pdev->dev, sizeof(struct sh_wdt), GFP_KERNEL);
338 if (unlikely(!wdt)) {
339 rc = -ENOMEM;
340 goto out_release;
341 }
342
343 wdt->dev = &pdev->dev;
344
345 wdt->base = devm_ioremap(&pdev->dev, res->start, resource_size(res));
346 if (unlikely(!wdt->base)) {
347 rc = -ENXIO;
348 goto out_err;
349 }
350
Paul Mundt8f5585e2010-05-25 18:31:12 +0900351 sh_wdt_miscdev.parent = wdt->dev;
352
353 rc = misc_register(&sh_wdt_miscdev);
354 if (unlikely(rc)) {
355 dev_err(&pdev->dev,
356 "Can't register miscdev on minor=%d (err=%d)\n",
357 sh_wdt_miscdev.minor, rc);
Paul Mundt40968122012-05-10 14:21:15 +0900358 goto out_unmap;
Paul Mundt8f5585e2010-05-25 18:31:12 +0900359 }
360
361 init_timer(&wdt->timer);
362 wdt->timer.function = sh_wdt_ping;
363 wdt->timer.data = (unsigned long)wdt;
364 wdt->timer.expires = next_ping_period(clock_division_ratio);
365
366 platform_set_drvdata(pdev, wdt);
367 sh_wdt_dev = pdev;
368
369 dev_info(&pdev->dev, "initialized.\n");
370
371 return 0;
372
Paul Mundt8f5585e2010-05-25 18:31:12 +0900373out_unmap:
374 devm_iounmap(&pdev->dev, wdt->base);
375out_err:
376 devm_kfree(&pdev->dev, wdt);
377out_release:
378 devm_release_mem_region(&pdev->dev, res->start, resource_size(res));
379
380 return rc;
381}
382
383static int __devexit sh_wdt_remove(struct platform_device *pdev)
384{
385 struct sh_wdt *wdt = platform_get_drvdata(pdev);
386 struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
387
388 platform_set_drvdata(pdev, NULL);
389
390 misc_deregister(&sh_wdt_miscdev);
391
392 sh_wdt_dev = NULL;
393
Paul Mundt8f5585e2010-05-25 18:31:12 +0900394 devm_release_mem_region(&pdev->dev, res->start, resource_size(res));
395 devm_iounmap(&pdev->dev, wdt->base);
396 devm_kfree(&pdev->dev, wdt);
397
398 return 0;
399}
400
Paul Mundt40968122012-05-10 14:21:15 +0900401static void sh_wdt_shutdown(struct platform_device *pdev)
402{
403 struct sh_wdt *wdt = platform_get_drvdata(pdev);
404
405 sh_wdt_stop(wdt);
406}
407
Paul Mundt8f5585e2010-05-25 18:31:12 +0900408static struct platform_driver sh_wdt_driver = {
409 .driver = {
410 .name = DRV_NAME,
411 .owner = THIS_MODULE,
412 },
413
Paul Mundt40968122012-05-10 14:21:15 +0900414 .probe = sh_wdt_probe,
415 .remove = __devexit_p(sh_wdt_remove),
416 .shutdown = sh_wdt_shutdown,
Paul Mundt8f5585e2010-05-25 18:31:12 +0900417};
418
Linus Torvalds1da177e2005-04-16 15:20:36 -0700419static int __init sh_wdt_init(void)
420{
421 int rc;
422
Paul Mundt8f5585e2010-05-25 18:31:12 +0900423 if (unlikely(clock_division_ratio < 0x5 ||
424 clock_division_ratio > 0x7)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700425 clock_division_ratio = WTCSR_CKS_4096;
Paul Mundt8f5585e2010-05-25 18:31:12 +0900426
Joe Perches27c766a2012-02-15 15:06:19 -0800427 pr_info("divisor must be 0x5<=x<=0x7, using %d\n",
428 clock_division_ratio);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700429 }
430
Paul Mundte4c2cfe2006-09-27 12:31:01 +0900431 rc = sh_wdt_set_heartbeat(heartbeat);
432 if (unlikely(rc)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700433 heartbeat = WATCHDOG_HEARTBEAT;
Paul Mundt8f5585e2010-05-25 18:31:12 +0900434
Joe Perches27c766a2012-02-15 15:06:19 -0800435 pr_info("heartbeat value must be 1<=x<=3600, using %d\n",
436 heartbeat);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700437 }
438
Joe Perches27c766a2012-02-15 15:06:19 -0800439 pr_info("configured with heartbeat=%d sec (nowayout=%d)\n",
440 heartbeat, nowayout);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700441
Paul Mundt8f5585e2010-05-25 18:31:12 +0900442 return platform_driver_register(&sh_wdt_driver);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700443}
444
Linus Torvalds1da177e2005-04-16 15:20:36 -0700445static void __exit sh_wdt_exit(void)
446{
Paul Mundt8f5585e2010-05-25 18:31:12 +0900447 platform_driver_unregister(&sh_wdt_driver);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700448}
Paul Mundt8f5585e2010-05-25 18:31:12 +0900449module_init(sh_wdt_init);
450module_exit(sh_wdt_exit);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700451
452MODULE_AUTHOR("Paul Mundt <lethal@linux-sh.org>");
453MODULE_DESCRIPTION("SuperH watchdog driver");
454MODULE_LICENSE("GPL");
Paul Mundt8f5585e2010-05-25 18:31:12 +0900455MODULE_ALIAS("platform:" DRV_NAME);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700456MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
457
458module_param(clock_division_ratio, int, 0);
Wim Van Sebroecka77dba72009-04-14 20:20:07 +0000459MODULE_PARM_DESC(clock_division_ratio,
460 "Clock division ratio. Valid ranges are from 0x5 (1.31ms) "
Randy Dunlap76550d32010-05-01 09:46:15 -0700461 "to 0x7 (5.25ms). (default=" __MODULE_STRING(WTCSR_CKS_4096) ")");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700462
463module_param(heartbeat, int, 0);
Alan Cox70b814e2008-05-19 14:08:55 +0100464MODULE_PARM_DESC(heartbeat,
465 "Watchdog heartbeat in seconds. (1 <= heartbeat <= 3600, default="
466 __MODULE_STRING(WATCHDOG_HEARTBEAT) ")");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700467
Wim Van Sebroeck86a1e182012-03-05 16:51:11 +0100468module_param(nowayout, bool, 0);
Alan Cox70b814e2008-05-19 14:08:55 +0100469MODULE_PARM_DESC(nowayout,
470 "Watchdog cannot be stopped once started (default="
471 __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");