xref: /linux/drivers/watchdog/shwdt.c (revision 9ea6404691a520f734b819cbbd4757b0ea5f99c6)
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>
31b7e04f8cSWim Van Sebroeck #include <linux/fs.h>
32b7e04f8cSWim Van Sebroeck #include <linux/mm.h>
338f5585ecSPaul Mundt #include <linux/slab.h>
3470b814ecSAlan Cox #include <linux/io.h>
35*9ea64046SPaul Mundt #include <linux/clk.h>
3658cf4198SAdrian Bunk #include <asm/watchdog.h>
37b7e04f8cSWim Van Sebroeck 
388f5585ecSPaul Mundt #define DRV_NAME "sh-wdt"
39b7e04f8cSWim Van Sebroeck 
40b7e04f8cSWim Van Sebroeck /*
41b7e04f8cSWim Van Sebroeck  * Default clock division ratio is 5.25 msecs. For an additional table of
42b7e04f8cSWim Van Sebroeck  * values, consult the asm-sh/watchdog.h. Overload this at module load
43b7e04f8cSWim Van Sebroeck  * time.
44b7e04f8cSWim Van Sebroeck  *
45b7e04f8cSWim Van Sebroeck  * In order for this to work reliably we need to have HZ set to 1000 or
46b7e04f8cSWim Van Sebroeck  * something quite higher than 100 (or we need a proper high-res timer
47b7e04f8cSWim Van Sebroeck  * implementation that will deal with this properly), otherwise the 10ms
48b7e04f8cSWim Van Sebroeck  * resolution of a jiffy is enough to trigger the overflow. For things like
49b7e04f8cSWim Van Sebroeck  * the SH-4 and SH-5, this isn't necessarily that big of a problem, though
50b7e04f8cSWim Van Sebroeck  * for the SH-2 and SH-3, this isn't recommended unless the WDT is absolutely
51b7e04f8cSWim Van Sebroeck  * necssary.
52b7e04f8cSWim Van Sebroeck  *
53b7e04f8cSWim Van Sebroeck  * As a result of this timing problem, the only modes that are particularly
5425985edcSLucas De Marchi  * feasible are the 4096 and the 2048 divisors, which yield 5.25 and 2.62ms
55b7e04f8cSWim Van Sebroeck  * overflow periods respectively.
56b7e04f8cSWim Van Sebroeck  *
57b7e04f8cSWim Van Sebroeck  * Also, since we can't really expect userspace to be responsive enough
58ee0fc097SJoe Perches  * before the overflow happens, we maintain two separate timers .. One in
59b7e04f8cSWim Van Sebroeck  * the kernel for clearing out WOVF every 2ms or so (again, this depends on
60b7e04f8cSWim Van Sebroeck  * HZ == 1000), and another for monitoring userspace writes to the WDT device.
61b7e04f8cSWim Van Sebroeck  *
62b7e04f8cSWim Van Sebroeck  * As such, we currently use a configurable heartbeat interval which defaults
63b7e04f8cSWim Van Sebroeck  * to 30s. In this case, the userspace daemon is only responsible for periodic
64b7e04f8cSWim Van Sebroeck  * writes to the device before the next heartbeat is scheduled. If the daemon
65b7e04f8cSWim Van Sebroeck  * misses its deadline, the kernel timer will allow the WDT to overflow.
66b7e04f8cSWim Van Sebroeck  */
67b7e04f8cSWim Van Sebroeck static int clock_division_ratio = WTCSR_CKS_4096;
68bea19066SDavid Engraf #define next_ping_period(cks)	(jiffies + msecs_to_jiffies(cks - 4))
69b7e04f8cSWim Van Sebroeck 
70b7e04f8cSWim Van Sebroeck #define WATCHDOG_HEARTBEAT 30			/* 30 sec default heartbeat */
71b7e04f8cSWim Van Sebroeck static int heartbeat = WATCHDOG_HEARTBEAT;	/* in seconds */
7286a1e189SWim Van Sebroeck static bool nowayout = WATCHDOG_NOWAYOUT;
738f5585ecSPaul Mundt static unsigned long next_heartbeat;
74b7e04f8cSWim Van Sebroeck 
758f5585ecSPaul Mundt struct sh_wdt {
768f5585ecSPaul Mundt 	void __iomem		*base;
778f5585ecSPaul Mundt 	struct device		*dev;
78*9ea64046SPaul Mundt 	struct clk		*clk;
79f9fb360cSPaul Mundt 	spinlock_t		lock;
808f5585ecSPaul Mundt 
818f5585ecSPaul Mundt 	struct timer_list	timer;
828f5585ecSPaul Mundt };
838f5585ecSPaul Mundt 
841950f499SPaul Mundt static int sh_wdt_start(struct watchdog_device *wdt_dev)
85b7e04f8cSWim Van Sebroeck {
861950f499SPaul Mundt 	struct sh_wdt *wdt = watchdog_get_drvdata(wdt_dev);
8770b814ecSAlan Cox 	unsigned long flags;
888f5585ecSPaul Mundt 	u8 csr;
8970b814ecSAlan Cox 
90f9fb360cSPaul Mundt 	spin_lock_irqsave(&wdt->lock, flags);
91b7e04f8cSWim Van Sebroeck 
92b7e04f8cSWim Van Sebroeck 	next_heartbeat = jiffies + (heartbeat * HZ);
938f5585ecSPaul Mundt 	mod_timer(&wdt->timer, next_ping_period(clock_division_ratio));
94b7e04f8cSWim Van Sebroeck 
95b7e04f8cSWim Van Sebroeck 	csr = sh_wdt_read_csr();
96b7e04f8cSWim Van Sebroeck 	csr |= WTCSR_WT | clock_division_ratio;
97b7e04f8cSWim Van Sebroeck 	sh_wdt_write_csr(csr);
98b7e04f8cSWim Van Sebroeck 
99b7e04f8cSWim Van Sebroeck 	sh_wdt_write_cnt(0);
100b7e04f8cSWim Van Sebroeck 
101b7e04f8cSWim Van Sebroeck 	/*
102b7e04f8cSWim Van Sebroeck 	 * These processors have a bit of an inconsistent initialization
103b7e04f8cSWim Van Sebroeck 	 * process.. starting with SH-3, RSTS was moved to WTCSR, and the
104b7e04f8cSWim Van Sebroeck 	 * RSTCSR register was removed.
105b7e04f8cSWim Van Sebroeck 	 *
106b7e04f8cSWim Van Sebroeck 	 * On the SH-2 however, in addition with bits being in different
107b7e04f8cSWim Van Sebroeck 	 * locations, we must deal with RSTCSR outright..
108b7e04f8cSWim Van Sebroeck 	 */
109b7e04f8cSWim Van Sebroeck 	csr = sh_wdt_read_csr();
110b7e04f8cSWim Van Sebroeck 	csr |= WTCSR_TME;
111b7e04f8cSWim Van Sebroeck 	csr &= ~WTCSR_RSTS;
112b7e04f8cSWim Van Sebroeck 	sh_wdt_write_csr(csr);
113b7e04f8cSWim Van Sebroeck 
114b7e04f8cSWim Van Sebroeck #ifdef CONFIG_CPU_SH2
115b7e04f8cSWim Van Sebroeck 	csr = sh_wdt_read_rstcsr();
116b7e04f8cSWim Van Sebroeck 	csr &= ~RSTCSR_RSTS;
117b7e04f8cSWim Van Sebroeck 	sh_wdt_write_rstcsr(csr);
118b7e04f8cSWim Van Sebroeck #endif
119f9fb360cSPaul Mundt 	spin_unlock_irqrestore(&wdt->lock, flags);
1201950f499SPaul Mundt 
1211950f499SPaul Mundt 	return 0;
122b7e04f8cSWim Van Sebroeck }
123b7e04f8cSWim Van Sebroeck 
1241950f499SPaul Mundt static int sh_wdt_stop(struct watchdog_device *wdt_dev)
125b7e04f8cSWim Van Sebroeck {
1261950f499SPaul Mundt 	struct sh_wdt *wdt = watchdog_get_drvdata(wdt_dev);
12770b814ecSAlan Cox 	unsigned long flags;
1288f5585ecSPaul Mundt 	u8 csr;
12970b814ecSAlan Cox 
130f9fb360cSPaul Mundt 	spin_lock_irqsave(&wdt->lock, flags);
131b7e04f8cSWim Van Sebroeck 
1328f5585ecSPaul Mundt 	del_timer(&wdt->timer);
133b7e04f8cSWim Van Sebroeck 
134b7e04f8cSWim Van Sebroeck 	csr = sh_wdt_read_csr();
135b7e04f8cSWim Van Sebroeck 	csr &= ~WTCSR_TME;
136b7e04f8cSWim Van Sebroeck 	sh_wdt_write_csr(csr);
1378f5585ecSPaul Mundt 
138f9fb360cSPaul Mundt 	spin_unlock_irqrestore(&wdt->lock, flags);
1391950f499SPaul Mundt 
1401950f499SPaul Mundt 	return 0;
141b7e04f8cSWim Van Sebroeck }
142b7e04f8cSWim Van Sebroeck 
1431950f499SPaul Mundt static int sh_wdt_keepalive(struct watchdog_device *wdt_dev)
144b7e04f8cSWim Van Sebroeck {
145f9fb360cSPaul Mundt 	struct sh_wdt *wdt = watchdog_get_drvdata(wdt_dev);
14670b814ecSAlan Cox 	unsigned long flags;
14770b814ecSAlan Cox 
148f9fb360cSPaul Mundt 	spin_lock_irqsave(&wdt->lock, flags);
149b7e04f8cSWim Van Sebroeck 	next_heartbeat = jiffies + (heartbeat * HZ);
150f9fb360cSPaul Mundt 	spin_unlock_irqrestore(&wdt->lock, flags);
1511950f499SPaul Mundt 
1521950f499SPaul Mundt 	return 0;
153b7e04f8cSWim Van Sebroeck }
154b7e04f8cSWim Van Sebroeck 
1551950f499SPaul Mundt static int sh_wdt_set_heartbeat(struct watchdog_device *wdt_dev, unsigned t)
156b7e04f8cSWim Van Sebroeck {
157f9fb360cSPaul Mundt 	struct sh_wdt *wdt = watchdog_get_drvdata(wdt_dev);
15870b814ecSAlan Cox 	unsigned long flags;
15970b814ecSAlan Cox 
16070b814ecSAlan Cox 	if (unlikely(t < 1 || t > 3600)) /* arbitrary upper limit */
161b7e04f8cSWim Van Sebroeck 		return -EINVAL;
162b7e04f8cSWim Van Sebroeck 
163f9fb360cSPaul Mundt 	spin_lock_irqsave(&wdt->lock, flags);
164b7e04f8cSWim Van Sebroeck 	heartbeat = t;
1651950f499SPaul Mundt 	wdt_dev->timeout = t;
166f9fb360cSPaul Mundt 	spin_unlock_irqrestore(&wdt->lock, flags);
1671950f499SPaul Mundt 
168b7e04f8cSWim Van Sebroeck 	return 0;
169b7e04f8cSWim Van Sebroeck }
170b7e04f8cSWim Van Sebroeck 
171b7e04f8cSWim Van Sebroeck static void sh_wdt_ping(unsigned long data)
172b7e04f8cSWim Van Sebroeck {
1738f5585ecSPaul Mundt 	struct sh_wdt *wdt = (struct sh_wdt *)data;
17470b814ecSAlan Cox 	unsigned long flags;
17570b814ecSAlan Cox 
176f9fb360cSPaul Mundt 	spin_lock_irqsave(&wdt->lock, flags);
177b7e04f8cSWim Van Sebroeck 	if (time_before(jiffies, next_heartbeat)) {
1788f5585ecSPaul Mundt 		u8 csr;
179b7e04f8cSWim Van Sebroeck 
180b7e04f8cSWim Van Sebroeck 		csr = sh_wdt_read_csr();
181b7e04f8cSWim Van Sebroeck 		csr &= ~WTCSR_IOVF;
182b7e04f8cSWim Van Sebroeck 		sh_wdt_write_csr(csr);
183b7e04f8cSWim Van Sebroeck 
184b7e04f8cSWim Van Sebroeck 		sh_wdt_write_cnt(0);
185b7e04f8cSWim Van Sebroeck 
1868f5585ecSPaul Mundt 		mod_timer(&wdt->timer, next_ping_period(clock_division_ratio));
187b7e04f8cSWim Van Sebroeck 	} else
1888f5585ecSPaul Mundt 		dev_warn(wdt->dev, "Heartbeat lost! Will not ping "
189b7e04f8cSWim Van Sebroeck 		         "the watchdog\n");
190f9fb360cSPaul Mundt 	spin_unlock_irqrestore(&wdt->lock, flags);
191b7e04f8cSWim Van Sebroeck }
192b7e04f8cSWim Van Sebroeck 
19370b814ecSAlan Cox static const struct watchdog_info sh_wdt_info = {
194b7e04f8cSWim Van Sebroeck 	.options		= WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT |
195b7e04f8cSWim Van Sebroeck 				  WDIOF_MAGICCLOSE,
196b7e04f8cSWim Van Sebroeck 	.firmware_version	= 1,
197b7e04f8cSWim Van Sebroeck 	.identity		= "SH WDT",
198b7e04f8cSWim Van Sebroeck };
199b7e04f8cSWim Van Sebroeck 
2001950f499SPaul Mundt static const struct watchdog_ops sh_wdt_ops = {
2011950f499SPaul Mundt 	.owner		= THIS_MODULE,
2021950f499SPaul Mundt 	.start		= sh_wdt_start,
2031950f499SPaul Mundt 	.stop		= sh_wdt_stop,
2041950f499SPaul Mundt 	.ping		= sh_wdt_keepalive,
2051950f499SPaul Mundt 	.set_timeout	= sh_wdt_set_heartbeat,
2061950f499SPaul Mundt };
2071950f499SPaul Mundt 
2081950f499SPaul Mundt static struct watchdog_device sh_wdt_dev = {
2091950f499SPaul Mundt 	.info	= &sh_wdt_info,
2101950f499SPaul Mundt 	.ops	= &sh_wdt_ops,
211b7e04f8cSWim Van Sebroeck };
212b7e04f8cSWim Van Sebroeck 
2138f5585ecSPaul Mundt static int __devinit sh_wdt_probe(struct platform_device *pdev)
2148f5585ecSPaul Mundt {
2158f5585ecSPaul Mundt 	struct sh_wdt *wdt;
2168f5585ecSPaul Mundt 	struct resource *res;
2178f5585ecSPaul Mundt 	int rc;
2188f5585ecSPaul Mundt 
2198f5585ecSPaul Mundt 	/*
2208f5585ecSPaul Mundt 	 * As this driver only covers the global watchdog case, reject
2218f5585ecSPaul Mundt 	 * any attempts to register per-CPU watchdogs.
2228f5585ecSPaul Mundt 	 */
2238f5585ecSPaul Mundt 	if (pdev->id != -1)
2248f5585ecSPaul Mundt 		return -EINVAL;
2258f5585ecSPaul Mundt 
2268f5585ecSPaul Mundt 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
2278f5585ecSPaul Mundt 	if (unlikely(!res))
2288f5585ecSPaul Mundt 		return -EINVAL;
2298f5585ecSPaul Mundt 
2308f5585ecSPaul Mundt 	wdt = devm_kzalloc(&pdev->dev, sizeof(struct sh_wdt), GFP_KERNEL);
231*9ea64046SPaul Mundt 	if (unlikely(!wdt))
232*9ea64046SPaul Mundt 		return -ENOMEM;
2338f5585ecSPaul Mundt 
2348f5585ecSPaul Mundt 	wdt->dev = &pdev->dev;
2358f5585ecSPaul Mundt 
236*9ea64046SPaul Mundt 	wdt->clk = clk_get(&pdev->dev, NULL);
237*9ea64046SPaul Mundt 	if (IS_ERR(wdt->clk)) {
238*9ea64046SPaul Mundt 		/*
239*9ea64046SPaul Mundt 		 * Clock framework support is optional, continue on
240*9ea64046SPaul Mundt 		 * anyways if we don't find a matching clock.
241*9ea64046SPaul Mundt 		 */
242*9ea64046SPaul Mundt 		wdt->clk = NULL;
243*9ea64046SPaul Mundt 	}
244*9ea64046SPaul Mundt 
245*9ea64046SPaul Mundt 	clk_enable(wdt->clk);
246*9ea64046SPaul Mundt 
247*9ea64046SPaul Mundt 	wdt->base = devm_request_and_ioremap(wdt->dev, res);
248*9ea64046SPaul Mundt 	if (unlikely(!wdt->base)) {
249*9ea64046SPaul Mundt 		rc = -EADDRNOTAVAIL;
250*9ea64046SPaul Mundt 		goto out_disable;
251*9ea64046SPaul Mundt 	}
252*9ea64046SPaul Mundt 
253f9fb360cSPaul Mundt 	watchdog_set_nowayout(&sh_wdt_dev, nowayout);
254f9fb360cSPaul Mundt 	watchdog_set_drvdata(&sh_wdt_dev, wdt);
255f9fb360cSPaul Mundt 
256f9fb360cSPaul Mundt 	spin_lock_init(&wdt->lock);
257f9fb360cSPaul Mundt 
2581950f499SPaul Mundt 	rc = sh_wdt_set_heartbeat(&sh_wdt_dev, heartbeat);
2598f5585ecSPaul Mundt 	if (unlikely(rc)) {
2601950f499SPaul Mundt 		/* Default timeout if invalid */
2611950f499SPaul Mundt 		sh_wdt_set_heartbeat(&sh_wdt_dev, WATCHDOG_HEARTBEAT);
2621950f499SPaul Mundt 
2631950f499SPaul Mundt 		dev_warn(&pdev->dev,
2641950f499SPaul Mundt 			 "heartbeat value must be 1<=x<=3600, using %d\n",
2651950f499SPaul Mundt 			 sh_wdt_dev.timeout);
2661950f499SPaul Mundt 	}
2671950f499SPaul Mundt 
2681950f499SPaul Mundt 	dev_info(&pdev->dev, "configured with heartbeat=%d sec (nowayout=%d)\n",
2691950f499SPaul Mundt 		 sh_wdt_dev.timeout, nowayout);
2701950f499SPaul Mundt 
2711950f499SPaul Mundt 	rc = watchdog_register_device(&sh_wdt_dev);
2721950f499SPaul Mundt 	if (unlikely(rc)) {
2731950f499SPaul Mundt 		dev_err(&pdev->dev, "Can't register watchdog (err=%d)\n", rc);
274*9ea64046SPaul Mundt 		goto out_disable;
2758f5585ecSPaul Mundt 	}
2768f5585ecSPaul Mundt 
2778f5585ecSPaul Mundt 	init_timer(&wdt->timer);
2788f5585ecSPaul Mundt 	wdt->timer.function	= sh_wdt_ping;
2798f5585ecSPaul Mundt 	wdt->timer.data		= (unsigned long)wdt;
2808f5585ecSPaul Mundt 	wdt->timer.expires	= next_ping_period(clock_division_ratio);
2818f5585ecSPaul Mundt 
2828f5585ecSPaul Mundt 	platform_set_drvdata(pdev, wdt);
2838f5585ecSPaul Mundt 
2848f5585ecSPaul Mundt 	dev_info(&pdev->dev, "initialized.\n");
2858f5585ecSPaul Mundt 
2868f5585ecSPaul Mundt 	return 0;
2878f5585ecSPaul Mundt 
288*9ea64046SPaul Mundt out_disable:
289*9ea64046SPaul Mundt 	clk_disable(wdt->clk);
290*9ea64046SPaul Mundt 	clk_put(wdt->clk);
2918f5585ecSPaul Mundt 
2928f5585ecSPaul Mundt 	return rc;
2938f5585ecSPaul Mundt }
2948f5585ecSPaul Mundt 
2958f5585ecSPaul Mundt static int __devexit sh_wdt_remove(struct platform_device *pdev)
2968f5585ecSPaul Mundt {
2978f5585ecSPaul Mundt 	struct sh_wdt *wdt = platform_get_drvdata(pdev);
2988f5585ecSPaul Mundt 
2998f5585ecSPaul Mundt 	platform_set_drvdata(pdev, NULL);
3008f5585ecSPaul Mundt 
3011950f499SPaul Mundt 	watchdog_unregister_device(&sh_wdt_dev);
3028f5585ecSPaul Mundt 
303*9ea64046SPaul Mundt 	clk_disable(wdt->clk);
304*9ea64046SPaul Mundt 	clk_put(wdt->clk);
3058f5585ecSPaul Mundt 
3068f5585ecSPaul Mundt 	return 0;
3078f5585ecSPaul Mundt }
3088f5585ecSPaul Mundt 
30940968126SPaul Mundt static void sh_wdt_shutdown(struct platform_device *pdev)
31040968126SPaul Mundt {
3111950f499SPaul Mundt 	sh_wdt_stop(&sh_wdt_dev);
31240968126SPaul Mundt }
31340968126SPaul Mundt 
3148f5585ecSPaul Mundt static struct platform_driver sh_wdt_driver = {
3158f5585ecSPaul Mundt 	.driver		= {
3168f5585ecSPaul Mundt 		.name	= DRV_NAME,
3178f5585ecSPaul Mundt 		.owner	= THIS_MODULE,
3188f5585ecSPaul Mundt 	},
3198f5585ecSPaul Mundt 
3208f5585ecSPaul Mundt 	.probe		= sh_wdt_probe,
3218f5585ecSPaul Mundt 	.remove		= __devexit_p(sh_wdt_remove),
32240968126SPaul Mundt 	.shutdown	= sh_wdt_shutdown,
3238f5585ecSPaul Mundt };
3248f5585ecSPaul Mundt 
325b7e04f8cSWim Van Sebroeck static int __init sh_wdt_init(void)
326b7e04f8cSWim Van Sebroeck {
3278f5585ecSPaul Mundt 	if (unlikely(clock_division_ratio < 0x5 ||
3288f5585ecSPaul Mundt 		     clock_division_ratio > 0x7)) {
329b7e04f8cSWim Van Sebroeck 		clock_division_ratio = WTCSR_CKS_4096;
3308f5585ecSPaul Mundt 
33127c766aaSJoe Perches 		pr_info("divisor must be 0x5<=x<=0x7, using %d\n",
33227c766aaSJoe Perches 			clock_division_ratio);
333b7e04f8cSWim Van Sebroeck 	}
334b7e04f8cSWim Van Sebroeck 
3358f5585ecSPaul Mundt 	return platform_driver_register(&sh_wdt_driver);
336b7e04f8cSWim Van Sebroeck }
337b7e04f8cSWim Van Sebroeck 
338b7e04f8cSWim Van Sebroeck static void __exit sh_wdt_exit(void)
339b7e04f8cSWim Van Sebroeck {
3408f5585ecSPaul Mundt 	platform_driver_unregister(&sh_wdt_driver);
341b7e04f8cSWim Van Sebroeck }
3428f5585ecSPaul Mundt module_init(sh_wdt_init);
3438f5585ecSPaul Mundt module_exit(sh_wdt_exit);
344b7e04f8cSWim Van Sebroeck 
345b7e04f8cSWim Van Sebroeck MODULE_AUTHOR("Paul Mundt <lethal@linux-sh.org>");
346b7e04f8cSWim Van Sebroeck MODULE_DESCRIPTION("SuperH watchdog driver");
347b7e04f8cSWim Van Sebroeck MODULE_LICENSE("GPL");
3488f5585ecSPaul Mundt MODULE_ALIAS("platform:" DRV_NAME);
349b7e04f8cSWim Van Sebroeck MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
350b7e04f8cSWim Van Sebroeck 
351b7e04f8cSWim Van Sebroeck module_param(clock_division_ratio, int, 0);
352a77dba7eSWim Van Sebroeck MODULE_PARM_DESC(clock_division_ratio,
353a77dba7eSWim Van Sebroeck 	"Clock division ratio. Valid ranges are from 0x5 (1.31ms) "
35476550d32SRandy Dunlap 	"to 0x7 (5.25ms). (default=" __MODULE_STRING(WTCSR_CKS_4096) ")");
355b7e04f8cSWim Van Sebroeck 
356b7e04f8cSWim Van Sebroeck module_param(heartbeat, int, 0);
35770b814ecSAlan Cox MODULE_PARM_DESC(heartbeat,
35870b814ecSAlan Cox 	"Watchdog heartbeat in seconds. (1 <= heartbeat <= 3600, default="
35970b814ecSAlan Cox 				__MODULE_STRING(WATCHDOG_HEARTBEAT) ")");
360b7e04f8cSWim Van Sebroeck 
36186a1e189SWim Van Sebroeck module_param(nowayout, bool, 0);
36270b814ecSAlan Cox MODULE_PARM_DESC(nowayout,
36370b814ecSAlan Cox 	"Watchdog cannot be stopped once started (default="
36470b814ecSAlan Cox 				__MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
365