xref: /linux/drivers/watchdog/shwdt.c (revision 6330c7070be6783b82025d2bc259db8413c00182)
1b7e04f8cSWim Van Sebroeck /*
2b1fa888eSPaul Mundt  * drivers/watchdog/shwdt.c
3b7e04f8cSWim Van Sebroeck  *
4b7e04f8cSWim Van Sebroeck  * Watchdog driver for integrated watchdog in the SuperH processors.
5b7e04f8cSWim Van Sebroeck  *
640968126SPaul Mundt  * Copyright (C) 2001 - 2012  Paul Mundt <lethal@linux-sh.org>
7b7e04f8cSWim Van Sebroeck  *
8b7e04f8cSWim Van Sebroeck  * This program is free software; you can redistribute it and/or modify it
9b7e04f8cSWim Van Sebroeck  * under the terms of the GNU General Public License as published by the
10b7e04f8cSWim Van Sebroeck  * Free Software Foundation; either version 2 of the License, or (at your
11b7e04f8cSWim Van Sebroeck  * option) any later version.
12b7e04f8cSWim Van Sebroeck  *
13b7e04f8cSWim Van Sebroeck  * 14-Dec-2001 Matt Domsch <Matt_Domsch@dell.com>
14b7e04f8cSWim Van Sebroeck  *     Added nowayout module option to override CONFIG_WATCHDOG_NOWAYOUT
15b7e04f8cSWim Van Sebroeck  *
16b7e04f8cSWim Van Sebroeck  * 19-Apr-2002 Rob Radez <rob@osinvestor.com>
17b7e04f8cSWim Van Sebroeck  *     Added expect close support, made emulated timeout runtime changeable
18b7e04f8cSWim Van Sebroeck  *     general cleanups, add some ioctls
19b7e04f8cSWim Van Sebroeck  */
2027c766aaSJoe Perches 
2127c766aaSJoe Perches #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
2227c766aaSJoe Perches 
23b7e04f8cSWim Van Sebroeck #include <linux/module.h>
24b7e04f8cSWim Van Sebroeck #include <linux/moduleparam.h>
258f5585ecSPaul Mundt #include <linux/platform_device.h>
26b7e04f8cSWim Van Sebroeck #include <linux/init.h>
27b7e04f8cSWim Van Sebroeck #include <linux/types.h>
28f9fb360cSPaul Mundt #include <linux/spinlock.h>
29b7e04f8cSWim Van Sebroeck #include <linux/miscdevice.h>
30b7e04f8cSWim Van Sebroeck #include <linux/watchdog.h>
318c013d96SPaul Mundt #include <linux/pm_runtime.h>
32b7e04f8cSWim Van Sebroeck #include <linux/fs.h>
33b7e04f8cSWim Van Sebroeck #include <linux/mm.h>
348f5585ecSPaul Mundt #include <linux/slab.h>
3570b814ecSAlan Cox #include <linux/io.h>
369ea64046SPaul Mundt #include <linux/clk.h>
37*6330c707SSachin Kamat #include <linux/err.h>
3858cf4198SAdrian Bunk #include <asm/watchdog.h>
39b7e04f8cSWim Van Sebroeck 
408f5585ecSPaul Mundt #define DRV_NAME "sh-wdt"
41b7e04f8cSWim Van Sebroeck 
42b7e04f8cSWim Van Sebroeck /*
43b7e04f8cSWim Van Sebroeck  * Default clock division ratio is 5.25 msecs. For an additional table of
44b7e04f8cSWim Van Sebroeck  * values, consult the asm-sh/watchdog.h. Overload this at module load
45b7e04f8cSWim Van Sebroeck  * time.
46b7e04f8cSWim Van Sebroeck  *
47b7e04f8cSWim Van Sebroeck  * In order for this to work reliably we need to have HZ set to 1000 or
48b7e04f8cSWim Van Sebroeck  * something quite higher than 100 (or we need a proper high-res timer
49b7e04f8cSWim Van Sebroeck  * implementation that will deal with this properly), otherwise the 10ms
50b7e04f8cSWim Van Sebroeck  * resolution of a jiffy is enough to trigger the overflow. For things like
51b7e04f8cSWim Van Sebroeck  * the SH-4 and SH-5, this isn't necessarily that big of a problem, though
52b7e04f8cSWim Van Sebroeck  * for the SH-2 and SH-3, this isn't recommended unless the WDT is absolutely
53b7e04f8cSWim Van Sebroeck  * necssary.
54b7e04f8cSWim Van Sebroeck  *
55b7e04f8cSWim Van Sebroeck  * As a result of this timing problem, the only modes that are particularly
5625985edcSLucas De Marchi  * feasible are the 4096 and the 2048 divisors, which yield 5.25 and 2.62ms
57b7e04f8cSWim Van Sebroeck  * overflow periods respectively.
58b7e04f8cSWim Van Sebroeck  *
59b7e04f8cSWim Van Sebroeck  * Also, since we can't really expect userspace to be responsive enough
60ee0fc097SJoe Perches  * before the overflow happens, we maintain two separate timers .. One in
61b7e04f8cSWim Van Sebroeck  * the kernel for clearing out WOVF every 2ms or so (again, this depends on
62b7e04f8cSWim Van Sebroeck  * HZ == 1000), and another for monitoring userspace writes to the WDT device.
63b7e04f8cSWim Van Sebroeck  *
64b7e04f8cSWim Van Sebroeck  * As such, we currently use a configurable heartbeat interval which defaults
65b7e04f8cSWim Van Sebroeck  * to 30s. In this case, the userspace daemon is only responsible for periodic
66b7e04f8cSWim Van Sebroeck  * writes to the device before the next heartbeat is scheduled. If the daemon
67b7e04f8cSWim Van Sebroeck  * misses its deadline, the kernel timer will allow the WDT to overflow.
68b7e04f8cSWim Van Sebroeck  */
69b7e04f8cSWim Van Sebroeck static int clock_division_ratio = WTCSR_CKS_4096;
70bea19066SDavid Engraf #define next_ping_period(cks)	(jiffies + msecs_to_jiffies(cks - 4))
71b7e04f8cSWim Van Sebroeck 
72b7e04f8cSWim Van Sebroeck #define WATCHDOG_HEARTBEAT 30			/* 30 sec default heartbeat */
73b7e04f8cSWim Van Sebroeck static int heartbeat = WATCHDOG_HEARTBEAT;	/* in seconds */
7486a1e189SWim Van Sebroeck static bool nowayout = WATCHDOG_NOWAYOUT;
758f5585ecSPaul Mundt static unsigned long next_heartbeat;
76b7e04f8cSWim Van Sebroeck 
778f5585ecSPaul Mundt struct sh_wdt {
788f5585ecSPaul Mundt 	void __iomem		*base;
798f5585ecSPaul Mundt 	struct device		*dev;
809ea64046SPaul Mundt 	struct clk		*clk;
81f9fb360cSPaul Mundt 	spinlock_t		lock;
828f5585ecSPaul Mundt 
838f5585ecSPaul Mundt 	struct timer_list	timer;
848f5585ecSPaul Mundt };
858f5585ecSPaul Mundt 
861950f499SPaul Mundt static int sh_wdt_start(struct watchdog_device *wdt_dev)
87b7e04f8cSWim Van Sebroeck {
881950f499SPaul Mundt 	struct sh_wdt *wdt = watchdog_get_drvdata(wdt_dev);
8970b814ecSAlan Cox 	unsigned long flags;
908f5585ecSPaul Mundt 	u8 csr;
9170b814ecSAlan Cox 
928c013d96SPaul Mundt 	pm_runtime_get_sync(wdt->dev);
93d42c9744SPaul Mundt 	clk_enable(wdt->clk);
948c013d96SPaul Mundt 
95f9fb360cSPaul Mundt 	spin_lock_irqsave(&wdt->lock, flags);
96b7e04f8cSWim Van Sebroeck 
97b7e04f8cSWim Van Sebroeck 	next_heartbeat = jiffies + (heartbeat * HZ);
988f5585ecSPaul Mundt 	mod_timer(&wdt->timer, next_ping_period(clock_division_ratio));
99b7e04f8cSWim Van Sebroeck 
100b7e04f8cSWim Van Sebroeck 	csr = sh_wdt_read_csr();
101b7e04f8cSWim Van Sebroeck 	csr |= WTCSR_WT | clock_division_ratio;
102b7e04f8cSWim Van Sebroeck 	sh_wdt_write_csr(csr);
103b7e04f8cSWim Van Sebroeck 
104b7e04f8cSWim Van Sebroeck 	sh_wdt_write_cnt(0);
105b7e04f8cSWim Van Sebroeck 
106b7e04f8cSWim Van Sebroeck 	/*
107b7e04f8cSWim Van Sebroeck 	 * These processors have a bit of an inconsistent initialization
108b7e04f8cSWim Van Sebroeck 	 * process.. starting with SH-3, RSTS was moved to WTCSR, and the
109b7e04f8cSWim Van Sebroeck 	 * RSTCSR register was removed.
110b7e04f8cSWim Van Sebroeck 	 *
111b7e04f8cSWim Van Sebroeck 	 * On the SH-2 however, in addition with bits being in different
112b7e04f8cSWim Van Sebroeck 	 * locations, we must deal with RSTCSR outright..
113b7e04f8cSWim Van Sebroeck 	 */
114b7e04f8cSWim Van Sebroeck 	csr = sh_wdt_read_csr();
115b7e04f8cSWim Van Sebroeck 	csr |= WTCSR_TME;
116b7e04f8cSWim Van Sebroeck 	csr &= ~WTCSR_RSTS;
117b7e04f8cSWim Van Sebroeck 	sh_wdt_write_csr(csr);
118b7e04f8cSWim Van Sebroeck 
119b7e04f8cSWim Van Sebroeck #ifdef CONFIG_CPU_SH2
120b7e04f8cSWim Van Sebroeck 	csr = sh_wdt_read_rstcsr();
121b7e04f8cSWim Van Sebroeck 	csr &= ~RSTCSR_RSTS;
122b7e04f8cSWim Van Sebroeck 	sh_wdt_write_rstcsr(csr);
123b7e04f8cSWim Van Sebroeck #endif
124f9fb360cSPaul Mundt 	spin_unlock_irqrestore(&wdt->lock, flags);
1251950f499SPaul Mundt 
1261950f499SPaul Mundt 	return 0;
127b7e04f8cSWim Van Sebroeck }
128b7e04f8cSWim Van Sebroeck 
1291950f499SPaul Mundt static int sh_wdt_stop(struct watchdog_device *wdt_dev)
130b7e04f8cSWim Van Sebroeck {
1311950f499SPaul Mundt 	struct sh_wdt *wdt = watchdog_get_drvdata(wdt_dev);
13270b814ecSAlan Cox 	unsigned long flags;
1338f5585ecSPaul Mundt 	u8 csr;
13470b814ecSAlan Cox 
135f9fb360cSPaul Mundt 	spin_lock_irqsave(&wdt->lock, flags);
136b7e04f8cSWim Van Sebroeck 
1378f5585ecSPaul Mundt 	del_timer(&wdt->timer);
138b7e04f8cSWim Van Sebroeck 
139b7e04f8cSWim Van Sebroeck 	csr = sh_wdt_read_csr();
140b7e04f8cSWim Van Sebroeck 	csr &= ~WTCSR_TME;
141b7e04f8cSWim Van Sebroeck 	sh_wdt_write_csr(csr);
1428f5585ecSPaul Mundt 
143f9fb360cSPaul Mundt 	spin_unlock_irqrestore(&wdt->lock, flags);
1441950f499SPaul Mundt 
145d42c9744SPaul Mundt 	clk_disable(wdt->clk);
1468c013d96SPaul Mundt 	pm_runtime_put_sync(wdt->dev);
1478c013d96SPaul Mundt 
1481950f499SPaul Mundt 	return 0;
149b7e04f8cSWim Van Sebroeck }
150b7e04f8cSWim Van Sebroeck 
1511950f499SPaul Mundt static int sh_wdt_keepalive(struct watchdog_device *wdt_dev)
152b7e04f8cSWim Van Sebroeck {
153f9fb360cSPaul Mundt 	struct sh_wdt *wdt = watchdog_get_drvdata(wdt_dev);
15470b814ecSAlan Cox 	unsigned long flags;
15570b814ecSAlan Cox 
156f9fb360cSPaul Mundt 	spin_lock_irqsave(&wdt->lock, flags);
157b7e04f8cSWim Van Sebroeck 	next_heartbeat = jiffies + (heartbeat * HZ);
158f9fb360cSPaul Mundt 	spin_unlock_irqrestore(&wdt->lock, flags);
1591950f499SPaul Mundt 
1601950f499SPaul Mundt 	return 0;
161b7e04f8cSWim Van Sebroeck }
162b7e04f8cSWim Van Sebroeck 
1631950f499SPaul Mundt static int sh_wdt_set_heartbeat(struct watchdog_device *wdt_dev, unsigned t)
164b7e04f8cSWim Van Sebroeck {
165f9fb360cSPaul Mundt 	struct sh_wdt *wdt = watchdog_get_drvdata(wdt_dev);
16670b814ecSAlan Cox 	unsigned long flags;
16770b814ecSAlan Cox 
16870b814ecSAlan Cox 	if (unlikely(t < 1 || t > 3600)) /* arbitrary upper limit */
169b7e04f8cSWim Van Sebroeck 		return -EINVAL;
170b7e04f8cSWim Van Sebroeck 
171f9fb360cSPaul Mundt 	spin_lock_irqsave(&wdt->lock, flags);
172b7e04f8cSWim Van Sebroeck 	heartbeat = t;
1731950f499SPaul Mundt 	wdt_dev->timeout = t;
174f9fb360cSPaul Mundt 	spin_unlock_irqrestore(&wdt->lock, flags);
1751950f499SPaul Mundt 
176b7e04f8cSWim Van Sebroeck 	return 0;
177b7e04f8cSWim Van Sebroeck }
178b7e04f8cSWim Van Sebroeck 
179b7e04f8cSWim Van Sebroeck static void sh_wdt_ping(unsigned long data)
180b7e04f8cSWim Van Sebroeck {
1818f5585ecSPaul Mundt 	struct sh_wdt *wdt = (struct sh_wdt *)data;
18270b814ecSAlan Cox 	unsigned long flags;
18370b814ecSAlan Cox 
184f9fb360cSPaul Mundt 	spin_lock_irqsave(&wdt->lock, flags);
185b7e04f8cSWim Van Sebroeck 	if (time_before(jiffies, next_heartbeat)) {
1868f5585ecSPaul Mundt 		u8 csr;
187b7e04f8cSWim Van Sebroeck 
188b7e04f8cSWim Van Sebroeck 		csr = sh_wdt_read_csr();
189b7e04f8cSWim Van Sebroeck 		csr &= ~WTCSR_IOVF;
190b7e04f8cSWim Van Sebroeck 		sh_wdt_write_csr(csr);
191b7e04f8cSWim Van Sebroeck 
192b7e04f8cSWim Van Sebroeck 		sh_wdt_write_cnt(0);
193b7e04f8cSWim Van Sebroeck 
1948f5585ecSPaul Mundt 		mod_timer(&wdt->timer, next_ping_period(clock_division_ratio));
195b7e04f8cSWim Van Sebroeck 	} else
1968f5585ecSPaul Mundt 		dev_warn(wdt->dev, "Heartbeat lost! Will not ping "
197b7e04f8cSWim Van Sebroeck 		         "the watchdog\n");
198f9fb360cSPaul Mundt 	spin_unlock_irqrestore(&wdt->lock, flags);
199b7e04f8cSWim Van Sebroeck }
200b7e04f8cSWim Van Sebroeck 
20170b814ecSAlan Cox static const struct watchdog_info sh_wdt_info = {
202b7e04f8cSWim Van Sebroeck 	.options		= WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT |
203b7e04f8cSWim Van Sebroeck 				  WDIOF_MAGICCLOSE,
204b7e04f8cSWim Van Sebroeck 	.firmware_version	= 1,
205b7e04f8cSWim Van Sebroeck 	.identity		= "SH WDT",
206b7e04f8cSWim Van Sebroeck };
207b7e04f8cSWim Van Sebroeck 
2081950f499SPaul Mundt static const struct watchdog_ops sh_wdt_ops = {
2091950f499SPaul Mundt 	.owner		= THIS_MODULE,
2101950f499SPaul Mundt 	.start		= sh_wdt_start,
2111950f499SPaul Mundt 	.stop		= sh_wdt_stop,
2121950f499SPaul Mundt 	.ping		= sh_wdt_keepalive,
2131950f499SPaul Mundt 	.set_timeout	= sh_wdt_set_heartbeat,
2141950f499SPaul Mundt };
2151950f499SPaul Mundt 
2161950f499SPaul Mundt static struct watchdog_device sh_wdt_dev = {
2171950f499SPaul Mundt 	.info	= &sh_wdt_info,
2181950f499SPaul Mundt 	.ops	= &sh_wdt_ops,
219b7e04f8cSWim Van Sebroeck };
220b7e04f8cSWim Van Sebroeck 
2212d991a16SBill Pemberton static int sh_wdt_probe(struct platform_device *pdev)
2228f5585ecSPaul Mundt {
2238f5585ecSPaul Mundt 	struct sh_wdt *wdt;
2248f5585ecSPaul Mundt 	struct resource *res;
2258f5585ecSPaul Mundt 	int rc;
2268f5585ecSPaul Mundt 
2278f5585ecSPaul Mundt 	/*
2288f5585ecSPaul Mundt 	 * As this driver only covers the global watchdog case, reject
2298f5585ecSPaul Mundt 	 * any attempts to register per-CPU watchdogs.
2308f5585ecSPaul Mundt 	 */
2318f5585ecSPaul Mundt 	if (pdev->id != -1)
2328f5585ecSPaul Mundt 		return -EINVAL;
2338f5585ecSPaul Mundt 
2348f5585ecSPaul Mundt 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
2358f5585ecSPaul Mundt 	if (unlikely(!res))
2368f5585ecSPaul Mundt 		return -EINVAL;
2378f5585ecSPaul Mundt 
2388f5585ecSPaul Mundt 	wdt = devm_kzalloc(&pdev->dev, sizeof(struct sh_wdt), GFP_KERNEL);
2399ea64046SPaul Mundt 	if (unlikely(!wdt))
2409ea64046SPaul Mundt 		return -ENOMEM;
2418f5585ecSPaul Mundt 
2428f5585ecSPaul Mundt 	wdt->dev = &pdev->dev;
2438f5585ecSPaul Mundt 
2449ea64046SPaul Mundt 	wdt->clk = clk_get(&pdev->dev, NULL);
2459ea64046SPaul Mundt 	if (IS_ERR(wdt->clk)) {
2469ea64046SPaul Mundt 		/*
2479ea64046SPaul Mundt 		 * Clock framework support is optional, continue on
2489ea64046SPaul Mundt 		 * anyways if we don't find a matching clock.
2499ea64046SPaul Mundt 		 */
2509ea64046SPaul Mundt 		wdt->clk = NULL;
2519ea64046SPaul Mundt 	}
2529ea64046SPaul Mundt 
253*6330c707SSachin Kamat 	wdt->base = devm_ioremap_resource(wdt->dev, res);
254*6330c707SSachin Kamat 	if (IS_ERR(wdt->base)) {
255*6330c707SSachin Kamat 		rc = PTR_ERR(wdt->base);
256d42c9744SPaul Mundt 		goto err;
2579ea64046SPaul Mundt 	}
2589ea64046SPaul Mundt 
259f9fb360cSPaul Mundt 	watchdog_set_nowayout(&sh_wdt_dev, nowayout);
260f9fb360cSPaul Mundt 	watchdog_set_drvdata(&sh_wdt_dev, wdt);
261f9fb360cSPaul Mundt 
262f9fb360cSPaul Mundt 	spin_lock_init(&wdt->lock);
263f9fb360cSPaul Mundt 
2641950f499SPaul Mundt 	rc = sh_wdt_set_heartbeat(&sh_wdt_dev, heartbeat);
2658f5585ecSPaul Mundt 	if (unlikely(rc)) {
2661950f499SPaul Mundt 		/* Default timeout if invalid */
2671950f499SPaul Mundt 		sh_wdt_set_heartbeat(&sh_wdt_dev, WATCHDOG_HEARTBEAT);
2681950f499SPaul Mundt 
2691950f499SPaul Mundt 		dev_warn(&pdev->dev,
2701950f499SPaul Mundt 			 "heartbeat value must be 1<=x<=3600, using %d\n",
2711950f499SPaul Mundt 			 sh_wdt_dev.timeout);
2721950f499SPaul Mundt 	}
2731950f499SPaul Mundt 
2741950f499SPaul Mundt 	dev_info(&pdev->dev, "configured with heartbeat=%d sec (nowayout=%d)\n",
2751950f499SPaul Mundt 		 sh_wdt_dev.timeout, nowayout);
2761950f499SPaul Mundt 
2771950f499SPaul Mundt 	rc = watchdog_register_device(&sh_wdt_dev);
2781950f499SPaul Mundt 	if (unlikely(rc)) {
2791950f499SPaul Mundt 		dev_err(&pdev->dev, "Can't register watchdog (err=%d)\n", rc);
280d42c9744SPaul Mundt 		goto err;
2818f5585ecSPaul Mundt 	}
2828f5585ecSPaul Mundt 
2838f5585ecSPaul Mundt 	init_timer(&wdt->timer);
2848f5585ecSPaul Mundt 	wdt->timer.function	= sh_wdt_ping;
2858f5585ecSPaul Mundt 	wdt->timer.data		= (unsigned long)wdt;
2868f5585ecSPaul Mundt 	wdt->timer.expires	= next_ping_period(clock_division_ratio);
2878f5585ecSPaul Mundt 
2888f5585ecSPaul Mundt 	platform_set_drvdata(pdev, wdt);
2898f5585ecSPaul Mundt 
2908f5585ecSPaul Mundt 	dev_info(&pdev->dev, "initialized.\n");
2918f5585ecSPaul Mundt 
2928c013d96SPaul Mundt 	pm_runtime_enable(&pdev->dev);
2938c013d96SPaul Mundt 
2948f5585ecSPaul Mundt 	return 0;
2958f5585ecSPaul Mundt 
296d42c9744SPaul Mundt err:
2979ea64046SPaul Mundt 	clk_put(wdt->clk);
2988f5585ecSPaul Mundt 
2998f5585ecSPaul Mundt 	return rc;
3008f5585ecSPaul Mundt }
3018f5585ecSPaul Mundt 
3024b12b896SBill Pemberton static int sh_wdt_remove(struct platform_device *pdev)
3038f5585ecSPaul Mundt {
3048f5585ecSPaul Mundt 	struct sh_wdt *wdt = platform_get_drvdata(pdev);
3058f5585ecSPaul Mundt 
3068f5585ecSPaul Mundt 	platform_set_drvdata(pdev, NULL);
3078f5585ecSPaul Mundt 
3081950f499SPaul Mundt 	watchdog_unregister_device(&sh_wdt_dev);
3098f5585ecSPaul Mundt 
3108c013d96SPaul Mundt 	pm_runtime_disable(&pdev->dev);
3119ea64046SPaul Mundt 	clk_put(wdt->clk);
3128f5585ecSPaul Mundt 
3138f5585ecSPaul Mundt 	return 0;
3148f5585ecSPaul Mundt }
3158f5585ecSPaul Mundt 
31640968126SPaul Mundt static void sh_wdt_shutdown(struct platform_device *pdev)
31740968126SPaul Mundt {
3181950f499SPaul Mundt 	sh_wdt_stop(&sh_wdt_dev);
31940968126SPaul Mundt }
32040968126SPaul Mundt 
3218f5585ecSPaul Mundt static struct platform_driver sh_wdt_driver = {
3228f5585ecSPaul Mundt 	.driver		= {
3238f5585ecSPaul Mundt 		.name	= DRV_NAME,
3248f5585ecSPaul Mundt 		.owner	= THIS_MODULE,
3258f5585ecSPaul Mundt 	},
3268f5585ecSPaul Mundt 
3278f5585ecSPaul Mundt 	.probe		= sh_wdt_probe,
32882268714SBill Pemberton 	.remove		= sh_wdt_remove,
32940968126SPaul Mundt 	.shutdown	= sh_wdt_shutdown,
3308f5585ecSPaul Mundt };
3318f5585ecSPaul Mundt 
332b7e04f8cSWim Van Sebroeck static int __init sh_wdt_init(void)
333b7e04f8cSWim Van Sebroeck {
3348f5585ecSPaul Mundt 	if (unlikely(clock_division_ratio < 0x5 ||
3358f5585ecSPaul Mundt 		     clock_division_ratio > 0x7)) {
336b7e04f8cSWim Van Sebroeck 		clock_division_ratio = WTCSR_CKS_4096;
3378f5585ecSPaul Mundt 
33827c766aaSJoe Perches 		pr_info("divisor must be 0x5<=x<=0x7, using %d\n",
33927c766aaSJoe Perches 			clock_division_ratio);
340b7e04f8cSWim Van Sebroeck 	}
341b7e04f8cSWim Van Sebroeck 
3428f5585ecSPaul Mundt 	return platform_driver_register(&sh_wdt_driver);
343b7e04f8cSWim Van Sebroeck }
344b7e04f8cSWim Van Sebroeck 
345b7e04f8cSWim Van Sebroeck static void __exit sh_wdt_exit(void)
346b7e04f8cSWim Van Sebroeck {
3478f5585ecSPaul Mundt 	platform_driver_unregister(&sh_wdt_driver);
348b7e04f8cSWim Van Sebroeck }
3498f5585ecSPaul Mundt module_init(sh_wdt_init);
3508f5585ecSPaul Mundt module_exit(sh_wdt_exit);
351b7e04f8cSWim Van Sebroeck 
352b7e04f8cSWim Van Sebroeck MODULE_AUTHOR("Paul Mundt <lethal@linux-sh.org>");
353b7e04f8cSWim Van Sebroeck MODULE_DESCRIPTION("SuperH watchdog driver");
354b7e04f8cSWim Van Sebroeck MODULE_LICENSE("GPL");
3558f5585ecSPaul Mundt MODULE_ALIAS("platform:" DRV_NAME);
356b7e04f8cSWim Van Sebroeck MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
357b7e04f8cSWim Van Sebroeck 
358b7e04f8cSWim Van Sebroeck module_param(clock_division_ratio, int, 0);
359a77dba7eSWim Van Sebroeck MODULE_PARM_DESC(clock_division_ratio,
360a77dba7eSWim Van Sebroeck 	"Clock division ratio. Valid ranges are from 0x5 (1.31ms) "
36176550d32SRandy Dunlap 	"to 0x7 (5.25ms). (default=" __MODULE_STRING(WTCSR_CKS_4096) ")");
362b7e04f8cSWim Van Sebroeck 
363b7e04f8cSWim Van Sebroeck module_param(heartbeat, int, 0);
36470b814ecSAlan Cox MODULE_PARM_DESC(heartbeat,
36570b814ecSAlan Cox 	"Watchdog heartbeat in seconds. (1 <= heartbeat <= 3600, default="
36670b814ecSAlan Cox 				__MODULE_STRING(WATCHDOG_HEARTBEAT) ")");
367b7e04f8cSWim Van Sebroeck 
36886a1e189SWim Van Sebroeck module_param(nowayout, bool, 0);
36970b814ecSAlan Cox MODULE_PARM_DESC(nowayout,
37070b814ecSAlan Cox 	"Watchdog cannot be stopped once started (default="
37170b814ecSAlan Cox 				__MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
372