]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
mfd: update TMIO drivers to use the clock API
authorIan Molton <spyro@f2s.com>
Thu, 9 Oct 2008 18:06:09 +0000 (20:06 +0200)
committerSamuel Ortiz <samuel@sortiz.org>
Sun, 19 Oct 2008 20:54:12 +0000 (22:54 +0200)
This patch updates the remaining two TMIO drivers to use the clock API
rather than callback hooks into platform code.

Signed-off-by: Ian Molton <spyro@f2s.com>
Signed-off-by: Samuel Ortiz <sameo@openedhand.com>
drivers/mfd/t7l66xb.c
drivers/mfd/tc6387xb.c
include/linux/mfd/t7l66xb.h
include/linux/mfd/tc6387xb.h

index 49a0fffc02afc238813c42ecff698700184b962f..9f7024c0f8ec284843cd70deeefedf51babf84c4 100644 (file)
 
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/err.h>
 #include <linux/io.h>
 #include <linux/irq.h>
+#include <linux/clk.h>
 #include <linux/platform_device.h>
 #include <linux/mfd/core.h>
 #include <linux/mfd/tmio.h>
@@ -56,6 +58,8 @@ struct t7l66xb {
        spinlock_t              lock;
 
        struct resource         rscr;
+       struct clk              *clk48m;
+       struct clk              *clk32k;
        int                     irq;
        int                     irq_base;
 };
@@ -65,13 +69,11 @@ struct t7l66xb {
 static int t7l66xb_mmc_enable(struct platform_device *mmc)
 {
        struct platform_device *dev = to_platform_device(mmc->dev.parent);
-       struct t7l66xb_platform_data   *pdata = dev->dev.platform_data;
        struct t7l66xb *t7l66xb = platform_get_drvdata(dev);
        unsigned long flags;
        u8 dev_ctl;
 
-       if (pdata->enable_clk32k)
-               pdata->enable_clk32k(dev);
+       clk_enable(t7l66xb->clk32k);
 
        spin_lock_irqsave(&t7l66xb->lock, flags);
 
@@ -87,7 +89,6 @@ static int t7l66xb_mmc_enable(struct platform_device *mmc)
 static int t7l66xb_mmc_disable(struct platform_device *mmc)
 {
        struct platform_device *dev = to_platform_device(mmc->dev.parent);
-       struct t7l66xb_platform_data   *pdata = dev->dev.platform_data;
        struct t7l66xb *t7l66xb = platform_get_drvdata(dev);
        unsigned long flags;
        u8 dev_ctl;
@@ -100,8 +101,7 @@ static int t7l66xb_mmc_disable(struct platform_device *mmc)
 
        spin_unlock_irqrestore(&t7l66xb->lock, flags);
 
-       if (pdata->disable_clk32k)
-               pdata->disable_clk32k(dev);
+       clk_disable(t7l66xb->clk32k);
 
        return 0;
 }
@@ -258,18 +258,22 @@ static void t7l66xb_detach_irq(struct platform_device *dev)
 #ifdef CONFIG_PM
 static int t7l66xb_suspend(struct platform_device *dev, pm_message_t state)
 {
+       struct t7l66xb *t7l66xb = platform_get_drvdata(dev);
        struct t7l66xb_platform_data *pdata = dev->dev.platform_data;
 
        if (pdata && pdata->suspend)
                pdata->suspend(dev);
+       clk_disable(t7l66xb->clk48m);
 
        return 0;
 }
 
 static int t7l66xb_resume(struct platform_device *dev)
 {
+       struct t7l66xb *t7l66xb = platform_get_drvdata(dev);
        struct t7l66xb_platform_data *pdata = dev->dev.platform_data;
 
+       clk_enable(t7l66xb->clk48m);
        if (pdata && pdata->resume)
                pdata->resume(dev);
 
@@ -309,6 +313,19 @@ static int t7l66xb_probe(struct platform_device *dev)
 
        t7l66xb->irq_base = pdata->irq_base;
 
+       t7l66xb->clk32k = clk_get(&dev->dev, "CLK_CK32K");
+       if (IS_ERR(t7l66xb->clk32k)) {
+               ret = PTR_ERR(t7l66xb->clk32k);
+               goto err_clk32k_get;
+       }
+
+       t7l66xb->clk48m = clk_get(&dev->dev, "CLK_CK48M");
+       if (IS_ERR(t7l66xb->clk48m)) {
+               ret = PTR_ERR(t7l66xb->clk48m);
+               clk_put(t7l66xb->clk32k);
+               goto err_clk48m_get;
+       }
+
        rscr = &t7l66xb->rscr;
        rscr->name = "t7l66xb-core";
        rscr->start = iomem->start;
@@ -325,6 +342,8 @@ static int t7l66xb_probe(struct platform_device *dev)
                goto err_ioremap;
        }
 
+       clk_enable(t7l66xb->clk48m);
+
        if (pdata && pdata->enable)
                pdata->enable(dev);
 
@@ -359,9 +378,13 @@ static int t7l66xb_probe(struct platform_device *dev)
        iounmap(t7l66xb->scr);
 err_ioremap:
        release_resource(&t7l66xb->rscr);
-err_noirq:
 err_request_scr:
        kfree(t7l66xb);
+       clk_put(t7l66xb->clk48m);
+err_clk48m_get:
+       clk_put(t7l66xb->clk32k);
+err_clk32k_get:
+err_noirq:
        return ret;
 }
 
@@ -372,7 +395,8 @@ static int t7l66xb_remove(struct platform_device *dev)
        int ret;
 
        ret = pdata->disable(dev);
-
+       clk_disable(t7l66xb->clk48m);
+       clk_put(t7l66xb->clk48m);
        t7l66xb_detach_irq(dev);
        iounmap(t7l66xb->scr);
        release_resource(&t7l66xb->rscr);
index a22b21ac6cf83989c0329e7fbb62c45db51b7751..43222c12fec14fc906993322c31f3cbad89f3e41 100644 (file)
@@ -12,6 +12,7 @@
 
 #include <linux/module.h>
 #include <linux/platform_device.h>
+#include <linux/clk.h>
 #include <linux/err.h>
 #include <linux/mfd/core.h>
 #include <linux/mfd/tmio.h>
@@ -24,18 +25,22 @@ enum {
 #ifdef CONFIG_PM
 static int tc6387xb_suspend(struct platform_device *dev, pm_message_t state)
 {
-       struct tc6387xb_platform_data *pdata = platform_get_drvdata(dev);
+       struct clk *clk32k = platform_get_drvdata(dev);
+       struct tc6387xb_platform_data *pdata = dev->dev.platform_data;
 
        if (pdata && pdata->suspend)
                pdata->suspend(dev);
+       clk_disable(clk32k);
 
        return 0;
 }
 
 static int tc6387xb_resume(struct platform_device *dev)
 {
-       struct tc6387xb_platform_data *pdata = platform_get_drvdata(dev);
+       struct clk *clk32k = platform_get_drvdata(dev);
+       struct tc6387xb_platform_data *pdata = dev->dev.platform_data;
 
+       clk_enable(clk32k);
        if (pdata && pdata->resume)
                pdata->resume(dev);
 
@@ -51,10 +56,9 @@ static int tc6387xb_resume(struct platform_device *dev)
 static int tc6387xb_mmc_enable(struct platform_device *mmc)
 {
        struct platform_device *dev      = to_platform_device(mmc->dev.parent);
-       struct tc6387xb_platform_data *tc6387xb = dev->dev.platform_data;
+       struct clk *clk32k = platform_get_drvdata(dev);
 
-       if (tc6387xb->enable_clk32k)
-               tc6387xb->enable_clk32k(dev);
+       clk_enable(clk32k);
 
        return 0;
 }
@@ -62,10 +66,9 @@ static int tc6387xb_mmc_enable(struct platform_device *mmc)
 static int tc6387xb_mmc_disable(struct platform_device *mmc)
 {
        struct platform_device *dev      = to_platform_device(mmc->dev.parent);
-       struct tc6387xb_platform_data *tc6387xb = dev->dev.platform_data;
+       struct clk *clk32k = platform_get_drvdata(dev);
 
-       if (tc6387xb->disable_clk32k)
-               tc6387xb->disable_clk32k(dev);
+       clk_disable(clk32k);
 
        return 0;
 }
@@ -102,14 +105,14 @@ static struct mfd_cell tc6387xb_cells[] = {
 
 static int tc6387xb_probe(struct platform_device *dev)
 {
-       struct tc6387xb_platform_data *data = platform_get_drvdata(dev);
+       struct tc6387xb_platform_data *pdata = dev->dev.platform_data;
        struct resource *iomem;
+       struct clk *clk32k;
        int irq, ret;
 
        iomem = platform_get_resource(dev, IORESOURCE_MEM, 0);
        if (!iomem) {
-               ret = -EINVAL;
-               goto err_resource;
+               return -EINVAL;
        }
 
        ret  = platform_get_irq(dev, 0);
@@ -118,8 +121,15 @@ static int tc6387xb_probe(struct platform_device *dev)
        else
                goto err_resource;
 
-       if (data && data->enable)
-               data->enable(dev);
+       clk32k = clk_get(&dev->dev, "CLK_CK32K");
+       if (IS_ERR(clk32k)) {
+               ret = PTR_ERR(clk32k);
+               goto err_resource;
+       }
+       platform_set_drvdata(dev, clk32k);
+
+       if (pdata && pdata->enable)
+               pdata->enable(dev);
 
        printk(KERN_INFO "Toshiba tc6387xb initialised\n");
 
@@ -134,18 +144,19 @@ static int tc6387xb_probe(struct platform_device *dev)
        if (!ret)
                return 0;
 
+       clk_put(clk32k);
 err_resource:
        return ret;
 }
 
 static int tc6387xb_remove(struct platform_device *dev)
 {
-       struct tc6387xb_platform_data *data = platform_get_drvdata(dev);
-
-       if (data && data->disable)
-               data->disable(dev);
+       struct clk *clk32k = platform_get_drvdata(dev);
 
-       /* FIXME - free the resources! */
+       mfd_remove_devices(&dev->dev);
+       clk_disable(clk32k);
+       clk_put(clk32k);
+       platform_set_drvdata(dev, NULL);
 
        return 0;
 }
index e83c7f2036f9484ce63b3253d6b85fc94a8237c8..b4629818aea581bf33fad4708bda37c42012cec4 100644 (file)
@@ -15,8 +15,6 @@
 #include <linux/mfd/tmio.h>
 
 struct t7l66xb_platform_data {
-       int (*enable_clk32k)(struct platform_device *dev);
-       void (*disable_clk32k)(struct platform_device *dev);
        int (*enable)(struct platform_device *dev);
        int (*disable)(struct platform_device *dev);
        int (*suspend)(struct platform_device *dev);
index fa06e0610b8e79e2545c3debc5529d7072e42aaf..b4888209494a4d04107f7c66a802b5411ca870ca 100644 (file)
@@ -11,9 +11,6 @@
 #define MFD_TC6387XB_H
 
 struct tc6387xb_platform_data {
-       int (*enable_clk32k)(struct platform_device *dev);
-       void (*disable_clk32k)(struct platform_device *dev);
-
        int (*enable)(struct platform_device *dev);
        int (*disable)(struct platform_device *dev);
        int (*suspend)(struct platform_device *dev);