]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/char/watchdog/s3c2410_wdt.c
[WATCHDOG] add WDIOC_GETTIMELEFT ioctl
[linux-2.6-omap-h63xx.git] / drivers / char / watchdog / s3c2410_wdt.c
index e7e20a6d64b025795b8d578ad3eefae0611f8bac..1ea04e9b2b0b0938cfc2cbfa04b2eed12b4da01b 100644 (file)
 #include <linux/init.h>
 #include <linux/platform_device.h>
 #include <linux/interrupt.h>
+#include <linux/clk.h>
 
 #include <asm/uaccess.h>
 #include <asm/io.h>
 
 #include <asm/arch/map.h>
-#include <asm/hardware/clock.h>
 
 #undef S3C24XX_VA_WATCHDOG
 #define S3C24XX_VA_WATCHDOG (0)
@@ -347,15 +347,14 @@ static irqreturn_t s3c2410wdt_irq(int irqno, void *param,
 }
 /* device interface */
 
-static int s3c2410wdt_probe(struct device *dev)
+static int s3c2410wdt_probe(struct platform_device *pdev)
 {
-       struct platform_device *pdev = to_platform_device(dev);
        struct resource *res;
        int started = 0;
        int ret;
        int size;
 
-       DBG("%s: probe=%p, device=%p\n", __FUNCTION__, pdev, dev);
+       DBG("%s: probe=%p\n", __FUNCTION__, pdev);
 
        /* get the memory region for the watchdog timer */
 
@@ -386,19 +385,18 @@ static int s3c2410wdt_probe(struct device *dev)
                return -ENOENT;
        }
 
-       ret = request_irq(res->start, s3c2410wdt_irq, 0, pdev->name, dev);
+       ret = request_irq(res->start, s3c2410wdt_irq, 0, pdev->name, pdev);
        if (ret != 0) {
                printk(KERN_INFO PFX "failed to install irq (%d)\n", ret);
                return ret;
        }
 
-       wdt_clock = clk_get(dev, "watchdog");
+       wdt_clock = clk_get(&pdev->dev, "watchdog");
        if (wdt_clock == NULL) {
                printk(KERN_INFO PFX "failed to find watchdog clock source\n");
                return -ENOENT;
        }
 
-       clk_use(wdt_clock);
        clk_enable(wdt_clock);
 
        /* see if we can actually set the requested timer margin, and if
@@ -425,12 +423,18 @@ static int s3c2410wdt_probe(struct device *dev)
        if (tmr_atboot && started == 0) {
                printk(KERN_INFO PFX "Starting Watchdog Timer\n");
                s3c2410wdt_start();
+       } else if (!tmr_atboot) {
+               /* if we're not enabling the watchdog, then ensure it is
+                * disabled if it has been left running from the bootloader
+                * or other source */
+
+               s3c2410wdt_stop();
        }
 
        return 0;
 }
 
-static int s3c2410wdt_remove(struct device *dev)
+static int s3c2410wdt_remove(struct platform_device *dev)
 {
        if (wdt_mem != NULL) {
                release_resource(wdt_mem);
@@ -445,7 +449,6 @@ static int s3c2410wdt_remove(struct device *dev)
 
        if (wdt_clock != NULL) {
                clk_disable(wdt_clock);
-               clk_unuse(wdt_clock);
                clk_put(wdt_clock);
                wdt_clock = NULL;
        }
@@ -454,7 +457,7 @@ static int s3c2410wdt_remove(struct device *dev)
        return 0;
 }
 
-static void s3c2410wdt_shutdown(struct device *dev)
+static void s3c2410wdt_shutdown(struct platform_device *dev)
 {
        s3c2410wdt_stop();      
 }
@@ -464,7 +467,7 @@ static void s3c2410wdt_shutdown(struct device *dev)
 static unsigned long wtcon_save;
 static unsigned long wtdat_save;
 
-static int s3c2410wdt_suspend(struct device *dev, pm_message_t state)
+static int s3c2410wdt_suspend(struct platform_device *dev, pm_message_t state)
 {
        /* Save watchdog state, and turn it off. */
        wtcon_save = readl(wdt_base + S3C2410_WTCON);
@@ -476,7 +479,7 @@ static int s3c2410wdt_suspend(struct device *dev, pm_message_t state)
        return 0;
 }
 
-static int s3c2410wdt_resume(struct device *dev)
+static int s3c2410wdt_resume(struct platform_device *dev)
 {
        /* Restore watchdog state. */
 
@@ -496,14 +499,16 @@ static int s3c2410wdt_resume(struct device *dev)
 #endif /* CONFIG_PM */
 
 
-static struct device_driver s3c2410wdt_driver = {
-       .name           = "s3c2410-wdt",
-       .bus            = &platform_bus_type,
+static struct platform_driver s3c2410wdt_driver = {
        .probe          = s3c2410wdt_probe,
        .remove         = s3c2410wdt_remove,
        .shutdown       = s3c2410wdt_shutdown,
        .suspend        = s3c2410wdt_suspend,
        .resume         = s3c2410wdt_resume,
+       .driver         = {
+               .owner  = THIS_MODULE,
+               .name   = "s3c2410-wdt",
+       },
 };
 
 
@@ -512,12 +517,12 @@ static char banner[] __initdata = KERN_INFO "S3C2410 Watchdog Timer, (c) 2004 Si
 static int __init watchdog_init(void)
 {
        printk(banner);
-       return driver_register(&s3c2410wdt_driver);
+       return platform_driver_register(&s3c2410wdt_driver);
 }
 
 static void __exit watchdog_exit(void)
 {
-       driver_unregister(&s3c2410wdt_driver);
+       platform_driver_unregister(&s3c2410wdt_driver);
 }
 
 module_init(watchdog_init);