[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>
This commit is contained in:
committed by
Wim Van Sebroeck
parent
c948852051
commit
ef8ab12ec2
@@ -19,11 +19,12 @@
|
|||||||
#include <linux/init.h>
|
#include <linux/init.h>
|
||||||
#include <linux/kernel.h>
|
#include <linux/kernel.h>
|
||||||
#include <linux/miscdevice.h>
|
#include <linux/miscdevice.h>
|
||||||
#include <linux/platform_device.h>
|
#include <linux/of_platform.h>
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/watchdog.h>
|
#include <linux/watchdog.h>
|
||||||
#include <linux/io.h>
|
#include <linux/io.h>
|
||||||
#include <linux/uaccess.h>
|
#include <linux/uaccess.h>
|
||||||
|
#include <sysdev/fsl_soc.h>
|
||||||
|
|
||||||
struct mpc83xx_wdt {
|
struct mpc83xx_wdt {
|
||||||
__be32 res0;
|
__be32 res0;
|
||||||
@@ -149,52 +150,42 @@ static struct miscdevice mpc83xx_wdt_miscdev = {
|
|||||||
.fops = &mpc83xx_wdt_fops,
|
.fops = &mpc83xx_wdt_fops,
|
||||||
};
|
};
|
||||||
|
|
||||||
static int __devinit mpc83xx_wdt_probe(struct platform_device *dev)
|
static int __devinit mpc83xx_wdt_probe(struct of_device *ofdev,
|
||||||
|
const struct of_device_id *match)
|
||||||
{
|
{
|
||||||
struct resource *r;
|
|
||||||
int ret;
|
int ret;
|
||||||
unsigned int *freq = dev->dev.platform_data;
|
u32 freq = fsl_get_sys_freq();
|
||||||
|
|
||||||
/* get a pointer to the register memory */
|
if (!freq || freq == -1)
|
||||||
r = platform_get_resource(dev, IORESOURCE_MEM, 0);
|
return -EINVAL;
|
||||||
|
|
||||||
if (!r) {
|
wd_base = of_iomap(ofdev->node, 0);
|
||||||
ret = -ENODEV;
|
if (!wd_base)
|
||||||
goto err_out;
|
return -ENOMEM;
|
||||||
}
|
|
||||||
|
|
||||||
wd_base = ioremap(r->start, sizeof(struct mpc83xx_wdt));
|
|
||||||
if (wd_base == NULL) {
|
|
||||||
ret = -ENOMEM;
|
|
||||||
goto err_out;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = misc_register(&mpc83xx_wdt_miscdev);
|
ret = misc_register(&mpc83xx_wdt_miscdev);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
printk(KERN_ERR "cannot register miscdev on minor=%d "
|
pr_err("cannot register miscdev on minor=%d (err=%d)\n",
|
||||||
"(err=%d)\n",
|
|
||||||
WATCHDOG_MINOR, ret);
|
WATCHDOG_MINOR, ret);
|
||||||
goto err_unmap;
|
goto err_unmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Calculate the timeout in seconds */
|
/* Calculate the timeout in seconds */
|
||||||
if (prescale)
|
if (prescale)
|
||||||
timeout_sec = (timeout * 0x10000) / (*freq);
|
timeout_sec = (timeout * 0x10000) / freq;
|
||||||
else
|
else
|
||||||
timeout_sec = timeout / (*freq);
|
timeout_sec = timeout / freq;
|
||||||
|
|
||||||
printk(KERN_INFO "WDT driver for MPC83xx initialized. "
|
pr_info("WDT driver for MPC83xx initialized. mode:%s timeout=%d "
|
||||||
"mode:%s timeout=%d (%d seconds)\n",
|
"(%d seconds)\n", reset ? "reset" : "interrupt", timeout,
|
||||||
reset ? "reset":"interrupt", timeout, timeout_sec);
|
timeout_sec);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
err_unmap:
|
err_unmap:
|
||||||
iounmap(wd_base);
|
iounmap(wd_base);
|
||||||
err_out:
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int __devexit mpc83xx_wdt_remove(struct platform_device *dev)
|
static int __devexit mpc83xx_wdt_remove(struct of_device *ofdev)
|
||||||
{
|
{
|
||||||
misc_deregister(&mpc83xx_wdt_miscdev);
|
misc_deregister(&mpc83xx_wdt_miscdev);
|
||||||
iounmap(wd_base);
|
iounmap(wd_base);
|
||||||
@@ -202,7 +193,16 @@ static int __devexit mpc83xx_wdt_remove(struct platform_device *dev)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct platform_driver mpc83xx_wdt_driver = {
|
static const struct of_device_id mpc83xx_wdt_match[] = {
|
||||||
|
{
|
||||||
|
.compatible = "mpc83xx_wdt",
|
||||||
|
},
|
||||||
|
{},
|
||||||
|
};
|
||||||
|
MODULE_DEVICE_TABLE(of, mpc83xx_wdt_match);
|
||||||
|
|
||||||
|
static struct of_platform_driver mpc83xx_wdt_driver = {
|
||||||
|
.match_table = mpc83xx_wdt_match,
|
||||||
.probe = mpc83xx_wdt_probe,
|
.probe = mpc83xx_wdt_probe,
|
||||||
.remove = __devexit_p(mpc83xx_wdt_remove),
|
.remove = __devexit_p(mpc83xx_wdt_remove),
|
||||||
.driver = {
|
.driver = {
|
||||||
@@ -213,12 +213,12 @@ static struct platform_driver mpc83xx_wdt_driver = {
|
|||||||
|
|
||||||
static int __init mpc83xx_wdt_init(void)
|
static int __init mpc83xx_wdt_init(void)
|
||||||
{
|
{
|
||||||
return platform_driver_register(&mpc83xx_wdt_driver);
|
return of_register_platform_driver(&mpc83xx_wdt_driver);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __exit mpc83xx_wdt_exit(void)
|
static void __exit mpc83xx_wdt_exit(void)
|
||||||
{
|
{
|
||||||
platform_driver_unregister(&mpc83xx_wdt_driver);
|
of_unregister_platform_driver(&mpc83xx_wdt_driver);
|
||||||
}
|
}
|
||||||
|
|
||||||
module_init(mpc83xx_wdt_init);
|
module_init(mpc83xx_wdt_init);
|
||||||
@@ -228,4 +228,3 @@ MODULE_AUTHOR("Dave Updegraff, Kumar Gala");
|
|||||||
MODULE_DESCRIPTION("Driver for watchdog timer in MPC83xx uProcessor");
|
MODULE_DESCRIPTION("Driver for watchdog timer in MPC83xx uProcessor");
|
||||||
MODULE_LICENSE("GPL");
|
MODULE_LICENSE("GPL");
|
||||||
MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
|
MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
|
||||||
MODULE_ALIAS("platform:mpc83xx_wdt");
|
|
||||||
|
Reference in New Issue
Block a user