aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/watchdog
diff options
context:
space:
mode:
authorAnton Vorontsov <avorontsov@ru.mvista.com>2008-07-04 02:51:32 -0400
committerWim Van Sebroeck <wim@iguana.be>2008-08-06 09:04:26 -0400
commitef8ab12ec2d663f9b146c920a4dd589a7e767f2d (patch)
treed040f166c76bcda1fbbfbea97f4a860517257bc2 /drivers/watchdog
parentc9488520512df659ad21df5d100b52fed96bdf07 (diff)
[WATCHDOG] mpc83xx_wdt: convert to the OF platform driver
This patch simply converts mpc83xx_wdt to the OF platform driver so we can directly work with the device tree without passing various stuff through platform data. Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com> Acked-by: Stephen Rothwell <sfr@canb.auug.org.au> Cc: Kumar Gala <galak@kernel.crashing.org> Signed-off-by: Wim Van Sebroeck <wim@iguana.be> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'drivers/watchdog')
-rw-r--r--drivers/watchdog/mpc83xx_wdt.c61
1 files changed, 30 insertions, 31 deletions
diff --git a/drivers/watchdog/mpc83xx_wdt.c b/drivers/watchdog/mpc83xx_wdt.c
index 109eea0df2d0..5f1b7bff8f12 100644
--- a/drivers/watchdog/mpc83xx_wdt.c
+++ b/drivers/watchdog/mpc83xx_wdt.c
@@ -19,11 +19,12 @@
19#include <linux/init.h> 19#include <linux/init.h>
20#include <linux/kernel.h> 20#include <linux/kernel.h>
21#include <linux/miscdevice.h> 21#include <linux/miscdevice.h>
22#include <linux/platform_device.h> 22#include <linux/of_platform.h>
23#include <linux/module.h> 23#include <linux/module.h>
24#include <linux/watchdog.h> 24#include <linux/watchdog.h>
25#include <linux/io.h> 25#include <linux/io.h>
26#include <linux/uaccess.h> 26#include <linux/uaccess.h>
27#include <sysdev/fsl_soc.h>
27 28
28struct mpc83xx_wdt { 29struct mpc83xx_wdt {
29 __be32 res0; 30 __be32 res0;
@@ -149,52 +150,42 @@ static struct miscdevice mpc83xx_wdt_miscdev = {
149 .fops = &mpc83xx_wdt_fops, 150 .fops = &mpc83xx_wdt_fops,
150}; 151};
151 152
152static int __devinit mpc83xx_wdt_probe(struct platform_device *dev) 153static int __devinit mpc83xx_wdt_probe(struct of_device *ofdev,
154 const struct of_device_id *match)
153{ 155{
154 struct resource *r;
155 int ret; 156 int ret;
156 unsigned int *freq = dev->dev.platform_data; 157 u32 freq = fsl_get_sys_freq();
157 158
158 /* get a pointer to the register memory */ 159 if (!freq || freq == -1)
159 r = platform_get_resource(dev, IORESOURCE_MEM, 0); 160 return -EINVAL;
160 161
161 if (!r) { 162 wd_base = of_iomap(ofdev->node, 0);
162 ret = -ENODEV; 163 if (!wd_base)
163 goto err_out; 164 return -ENOMEM;
164 }
165
166 wd_base = ioremap(r->start, sizeof(struct mpc83xx_wdt));
167 if (wd_base == NULL) {
168 ret = -ENOMEM;
169 goto err_out;
170 }
171 165
172 ret = misc_register(&mpc83xx_wdt_miscdev); 166 ret = misc_register(&mpc83xx_wdt_miscdev);
173 if (ret) { 167 if (ret) {
174 printk(KERN_ERR "cannot register miscdev on minor=%d " 168 pr_err("cannot register miscdev on minor=%d (err=%d)\n",
175 "(err=%d)\n", 169 WATCHDOG_MINOR, ret);
176 WATCHDOG_MINOR, ret);
177 goto err_unmap; 170 goto err_unmap;
178 } 171 }
179 172
180 /* Calculate the timeout in seconds */ 173 /* Calculate the timeout in seconds */
181 if (prescale) 174 if (prescale)
182 timeout_sec = (timeout * 0x10000) / (*freq); 175 timeout_sec = (timeout * 0x10000) / freq;
183 else 176 else
184 timeout_sec = timeout / (*freq); 177 timeout_sec = timeout / freq;
185 178
186 printk(KERN_INFO "WDT driver for MPC83xx initialized. " 179 pr_info("WDT driver for MPC83xx initialized. mode:%s timeout=%d "
187 "mode:%s timeout=%d (%d seconds)\n", 180 "(%d seconds)\n", reset ? "reset" : "interrupt", timeout,
188 reset ? "reset":"interrupt", timeout, timeout_sec); 181 timeout_sec);
189 return 0; 182 return 0;
190
191err_unmap: 183err_unmap:
192 iounmap(wd_base); 184 iounmap(wd_base);
193err_out:
194 return ret; 185 return ret;
195} 186}
196 187
197static int __devexit mpc83xx_wdt_remove(struct platform_device *dev) 188static int __devexit mpc83xx_wdt_remove(struct of_device *ofdev)
198{ 189{
199 misc_deregister(&mpc83xx_wdt_miscdev); 190 misc_deregister(&mpc83xx_wdt_miscdev);
200 iounmap(wd_base); 191 iounmap(wd_base);
@@ -202,7 +193,16 @@ static int __devexit mpc83xx_wdt_remove(struct platform_device *dev)
202 return 0; 193 return 0;
203} 194}
204 195
205static struct platform_driver mpc83xx_wdt_driver = { 196static const struct of_device_id mpc83xx_wdt_match[] = {
197 {
198 .compatible = "mpc83xx_wdt",
199 },
200 {},
201};
202MODULE_DEVICE_TABLE(of, mpc83xx_wdt_match);
203
204static struct of_platform_driver mpc83xx_wdt_driver = {
205 .match_table = mpc83xx_wdt_match,
206 .probe = mpc83xx_wdt_probe, 206 .probe = mpc83xx_wdt_probe,
207 .remove = __devexit_p(mpc83xx_wdt_remove), 207 .remove = __devexit_p(mpc83xx_wdt_remove),
208 .driver = { 208 .driver = {
@@ -213,12 +213,12 @@ static struct platform_driver mpc83xx_wdt_driver = {
213 213
214static int __init mpc83xx_wdt_init(void) 214static int __init mpc83xx_wdt_init(void)
215{ 215{
216 return platform_driver_register(&mpc83xx_wdt_driver); 216 return of_register_platform_driver(&mpc83xx_wdt_driver);
217} 217}
218 218
219static void __exit mpc83xx_wdt_exit(void) 219static void __exit mpc83xx_wdt_exit(void)
220{ 220{
221 platform_driver_unregister(&mpc83xx_wdt_driver); 221 of_unregister_platform_driver(&mpc83xx_wdt_driver);
222} 222}
223 223
224module_init(mpc83xx_wdt_init); 224module_init(mpc83xx_wdt_init);
@@ -228,4 +228,3 @@ MODULE_AUTHOR("Dave Updegraff, Kumar Gala");
228MODULE_DESCRIPTION("Driver for watchdog timer in MPC83xx uProcessor"); 228MODULE_DESCRIPTION("Driver for watchdog timer in MPC83xx uProcessor");
229MODULE_LICENSE("GPL"); 229MODULE_LICENSE("GPL");
230MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); 230MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
231MODULE_ALIAS("platform:mpc83xx_wdt");