hwmon: (adt7475) Fix temperature fault flags
[safe/jmp/linux-2.6] / drivers / watchdog / omap_wdt.c
index 7bcbb7f..3ed571a 100644 (file)
@@ -16,7 +16,7 @@
  * 20030527: George G. Davis <gdavis@mvista.com>
  *     Initially based on linux-2.4.19-rmk7-pxa1/drivers/char/sa1100_wdt.c
  *     (c) Copyright 2000 Oleg Drokin <green@crimea.edu>
- *     Based on SoftDog driver by Alan Cox <alan@redhat.com>
+ *     Based on SoftDog driver by Alan Cox <alan@lxorguk.ukuu.org.uk>
  *
  * Copyright (c) 2004 Texas Instruments.
  *     1. Modified to support OMAP1610 32-KHz watchdog timer
@@ -60,9 +60,8 @@ struct omap_wdt_dev {
        void __iomem    *base;          /* physical */
        struct device   *dev;
        int             omap_wdt_users;
-       struct clk      *armwdt_ck;
-       struct clk      *mpu_wdt_ick;
-       struct clk      *mpu_wdt_fck;
+       struct clk      *ick;
+       struct clk      *fck;
        struct resource *mem;
        struct miscdevice omap_wdt_miscdev;
 };
@@ -146,13 +145,8 @@ static int omap_wdt_open(struct inode *inode, struct file *file)
        if (test_and_set_bit(1, (unsigned long *)&(wdev->omap_wdt_users)))
                return -EBUSY;
 
-       if (cpu_is_omap16xx())
-               clk_enable(wdev->armwdt_ck);    /* Enable the clock */
-
-       if (cpu_is_omap24xx() || cpu_is_omap34xx()) {
-               clk_enable(wdev->mpu_wdt_ick);    /* Enable the interface clock */
-               clk_enable(wdev->mpu_wdt_fck);    /* Enable the functional clock */
-       }
+       clk_enable(wdev->ick);    /* Enable the interface clock */
+       clk_enable(wdev->fck);    /* Enable the functional clock */
 
        /* initialize prescaler */
        while (__raw_readl(base + OMAP_WATCHDOG_WPS) & 0x01)
@@ -165,6 +159,7 @@ static int omap_wdt_open(struct inode *inode, struct file *file)
        file->private_data = (void *) wdev;
 
        omap_wdt_set_timeout(wdev);
+       omap_wdt_ping(wdev); /* trigger loading of new timeout value */
        omap_wdt_enable(wdev);
 
        return nonseekable_open(inode, file);
@@ -181,13 +176,8 @@ static int omap_wdt_release(struct inode *inode, struct file *file)
 
        omap_wdt_disable(wdev);
 
-       if (cpu_is_omap16xx())
-               clk_disable(wdev->armwdt_ck);   /* Disable the clock */
-
-       if (cpu_is_omap24xx() || cpu_is_omap34xx()) {
-               clk_disable(wdev->mpu_wdt_ick); /* Disable the clock */
-               clk_disable(wdev->mpu_wdt_fck); /* Disable the clock */
-       }
+       clk_disable(wdev->ick);
+       clk_disable(wdev->fck);
 #else
        printk(KERN_CRIT "omap_wdt: Unexpected close, not stopping!\n");
 #endif
@@ -269,7 +259,7 @@ static const struct file_operations omap_wdt_fops = {
        .release = omap_wdt_release,
 };
 
-static int __init omap_wdt_probe(struct platform_device *pdev)
+static int __devinit omap_wdt_probe(struct platform_device *pdev)
 {
        struct resource *res, *mem;
        struct omap_wdt_dev *wdev;
@@ -303,44 +293,19 @@ static int __init omap_wdt_probe(struct platform_device *pdev)
        wdev->omap_wdt_users = 0;
        wdev->mem = mem;
 
-       if (cpu_is_omap16xx()) {
-               wdev->armwdt_ck = clk_get(&pdev->dev, "armwdt_ck");
-               if (IS_ERR(wdev->armwdt_ck)) {
-                       ret = PTR_ERR(wdev->armwdt_ck);
-                       wdev->armwdt_ck = NULL;
-                       goto err_clk;
-               }
+       wdev->ick = clk_get(&pdev->dev, "ick");
+       if (IS_ERR(wdev->ick)) {
+               ret = PTR_ERR(wdev->ick);
+               wdev->ick = NULL;
+               goto err_clk;
        }
-
-       if (cpu_is_omap24xx()) {
-               wdev->mpu_wdt_ick = clk_get(&pdev->dev, "mpu_wdt_ick");
-               if (IS_ERR(wdev->mpu_wdt_ick)) {
-                       ret = PTR_ERR(wdev->mpu_wdt_ick);
-                       wdev->mpu_wdt_ick = NULL;
-                       goto err_clk;
-               }
-               wdev->mpu_wdt_fck = clk_get(&pdev->dev, "mpu_wdt_fck");
-               if (IS_ERR(wdev->mpu_wdt_fck)) {
-                       ret = PTR_ERR(wdev->mpu_wdt_fck);
-                       wdev->mpu_wdt_fck = NULL;
-                       goto err_clk;
-               }
+       wdev->fck = clk_get(&pdev->dev, "fck");
+       if (IS_ERR(wdev->fck)) {
+               ret = PTR_ERR(wdev->fck);
+               wdev->fck = NULL;
+               goto err_clk;
        }
 
-       if (cpu_is_omap34xx()) {
-               wdev->mpu_wdt_ick = clk_get(&pdev->dev, "wdt2_ick");
-               if (IS_ERR(wdev->mpu_wdt_ick)) {
-                       ret = PTR_ERR(wdev->mpu_wdt_ick);
-                       wdev->mpu_wdt_ick = NULL;
-                       goto err_clk;
-               }
-               wdev->mpu_wdt_fck = clk_get(&pdev->dev, "wdt2_fck");
-               if (IS_ERR(wdev->mpu_wdt_fck)) {
-                       ret = PTR_ERR(wdev->mpu_wdt_fck);
-                       wdev->mpu_wdt_fck = NULL;
-                       goto err_clk;
-               }
-       }
        wdev->base = ioremap(res->start, res->end - res->start + 1);
        if (!wdev->base) {
                ret = -ENOMEM;
@@ -349,6 +314,9 @@ static int __init omap_wdt_probe(struct platform_device *pdev)
 
        platform_set_drvdata(pdev, wdev);
 
+       clk_enable(wdev->ick);
+       clk_enable(wdev->fck);
+
        omap_wdt_disable(wdev);
        omap_wdt_adjust_timeout(timer_margin);
 
@@ -368,6 +336,9 @@ static int __init omap_wdt_probe(struct platform_device *pdev)
        /* autogate OCP interface clock */
        __raw_writel(0x01, wdev->base + OMAP_WATCHDOG_SYS_CONFIG);
 
+       clk_disable(wdev->ick);
+       clk_disable(wdev->fck);
+
        omap_wdt_dev = pdev;
 
        return 0;
@@ -380,12 +351,10 @@ err_ioremap:
        wdev->base = NULL;
 
 err_clk:
-       if (wdev->armwdt_ck)
-               clk_put(wdev->armwdt_ck);
-       if (wdev->mpu_wdt_ick)
-               clk_put(wdev->mpu_wdt_ick);
-       if (wdev->mpu_wdt_fck)
-               clk_put(wdev->mpu_wdt_fck);
+       if (wdev->ick)
+               clk_put(wdev->ick);
+       if (wdev->fck)
+               clk_put(wdev->fck);
        kfree(wdev);
 
 err_kzalloc:
@@ -405,7 +374,7 @@ static void omap_wdt_shutdown(struct platform_device *pdev)
                omap_wdt_disable(wdev);
 }
 
-static int omap_wdt_remove(struct platform_device *pdev)
+static int __devexit omap_wdt_remove(struct platform_device *pdev)
 {
        struct omap_wdt_dev *wdev = platform_get_drvdata(pdev);
        struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -417,20 +386,8 @@ static int omap_wdt_remove(struct platform_device *pdev)
        release_mem_region(res->start, res->end - res->start + 1);
        platform_set_drvdata(pdev, NULL);
 
-       if (wdev->armwdt_ck) {
-               clk_put(wdev->armwdt_ck);
-               wdev->armwdt_ck = NULL;
-       }
-
-       if (wdev->mpu_wdt_ick) {
-               clk_put(wdev->mpu_wdt_ick);
-               wdev->mpu_wdt_ick = NULL;
-       }
-
-       if (wdev->mpu_wdt_fck) {
-               clk_put(wdev->mpu_wdt_fck);
-               wdev->mpu_wdt_fck = NULL;
-       }
+       clk_put(wdev->ick);
+       clk_put(wdev->fck);
        iounmap(wdev->base);
 
        kfree(wdev);
@@ -476,7 +433,7 @@ static int omap_wdt_resume(struct platform_device *pdev)
 
 static struct platform_driver omap_wdt_driver = {
        .probe          = omap_wdt_probe,
-       .remove         = omap_wdt_remove,
+       .remove         = __devexit_p(omap_wdt_remove),
        .shutdown       = omap_wdt_shutdown,
        .suspend        = omap_wdt_suspend,
        .resume         = omap_wdt_resume,