diff options
author | Anton Vorontsov <avorontsov@ru.mvista.com> | 2008-07-04 02:51:32 -0400 |
---|---|---|
committer | Wim Van Sebroeck <wim@iguana.be> | 2008-08-06 09:04:26 -0400 |
commit | ef8ab12ec2d663f9b146c920a4dd589a7e767f2d (patch) | |
tree | d040f166c76bcda1fbbfbea97f4a860517257bc2 | |
parent | c9488520512df659ad21df5d100b52fed96bdf07 (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>
-rw-r--r-- | drivers/watchdog/mpc83xx_wdt.c | 61 |
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 | ||
28 | struct mpc83xx_wdt { | 29 | struct 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 | ||
152 | static int __devinit mpc83xx_wdt_probe(struct platform_device *dev) | 153 | static 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 | |||
191 | err_unmap: | 183 | err_unmap: |
192 | iounmap(wd_base); | 184 | iounmap(wd_base); |
193 | err_out: | ||
194 | return ret; | 185 | return ret; |
195 | } | 186 | } |
196 | 187 | ||
197 | static int __devexit mpc83xx_wdt_remove(struct platform_device *dev) | 188 | static 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 | ||
205 | static struct platform_driver mpc83xx_wdt_driver = { | 196 | static const struct of_device_id mpc83xx_wdt_match[] = { |
197 | { | ||
198 | .compatible = "mpc83xx_wdt", | ||
199 | }, | ||
200 | {}, | ||
201 | }; | ||
202 | MODULE_DEVICE_TABLE(of, mpc83xx_wdt_match); | ||
203 | |||
204 | static 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 | ||
214 | static int __init mpc83xx_wdt_init(void) | 214 | static 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 | ||
219 | static void __exit mpc83xx_wdt_exit(void) | 219 | static 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 | ||
224 | module_init(mpc83xx_wdt_init); | 224 | module_init(mpc83xx_wdt_init); |
@@ -228,4 +228,3 @@ MODULE_AUTHOR("Dave Updegraff, Kumar Gala"); | |||
228 | MODULE_DESCRIPTION("Driver for watchdog timer in MPC83xx uProcessor"); | 228 | MODULE_DESCRIPTION("Driver for watchdog timer in MPC83xx uProcessor"); |
229 | MODULE_LICENSE("GPL"); | 229 | MODULE_LICENSE("GPL"); |
230 | MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); | 230 | MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); |
231 | MODULE_ALIAS("platform:mpc83xx_wdt"); | ||