aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mfd/tc6387xb.c
diff options
context:
space:
mode:
authorIan Molton <spyro@f2s.com>2008-10-09 14:06:09 -0400
committerSamuel Ortiz <samuel@sortiz.org>2008-10-19 16:54:12 -0400
commit7acb706ca97fce84bda4a902a33de2f3dae10260 (patch)
tree90e6468e55ea1029258dda97a5f2c0e1566ef8d2 /drivers/mfd/tc6387xb.c
parent9297a0e7e033b7f2776610197fcbb9ff563efe32 (diff)
mfd: update TMIO drivers to use the clock API
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>
Diffstat (limited to 'drivers/mfd/tc6387xb.c')
-rw-r--r--drivers/mfd/tc6387xb.c47
1 files changed, 29 insertions, 18 deletions
diff --git a/drivers/mfd/tc6387xb.c b/drivers/mfd/tc6387xb.c
index a22b21ac6cf8..43222c12fec1 100644
--- a/drivers/mfd/tc6387xb.c
+++ b/drivers/mfd/tc6387xb.c
@@ -12,6 +12,7 @@
12 12
13#include <linux/module.h> 13#include <linux/module.h>
14#include <linux/platform_device.h> 14#include <linux/platform_device.h>
15#include <linux/clk.h>
15#include <linux/err.h> 16#include <linux/err.h>
16#include <linux/mfd/core.h> 17#include <linux/mfd/core.h>
17#include <linux/mfd/tmio.h> 18#include <linux/mfd/tmio.h>
@@ -24,18 +25,22 @@ enum {
24#ifdef CONFIG_PM 25#ifdef CONFIG_PM
25static int tc6387xb_suspend(struct platform_device *dev, pm_message_t state) 26static int tc6387xb_suspend(struct platform_device *dev, pm_message_t state)
26{ 27{
27 struct tc6387xb_platform_data *pdata = platform_get_drvdata(dev); 28 struct clk *clk32k = platform_get_drvdata(dev);
29 struct tc6387xb_platform_data *pdata = dev->dev.platform_data;
28 30
29 if (pdata && pdata->suspend) 31 if (pdata && pdata->suspend)
30 pdata->suspend(dev); 32 pdata->suspend(dev);
33 clk_disable(clk32k);
31 34
32 return 0; 35 return 0;
33} 36}
34 37
35static int tc6387xb_resume(struct platform_device *dev) 38static int tc6387xb_resume(struct platform_device *dev)
36{ 39{
37 struct tc6387xb_platform_data *pdata = platform_get_drvdata(dev); 40 struct clk *clk32k = platform_get_drvdata(dev);
41 struct tc6387xb_platform_data *pdata = dev->dev.platform_data;
38 42
43 clk_enable(clk32k);
39 if (pdata && pdata->resume) 44 if (pdata && pdata->resume)
40 pdata->resume(dev); 45 pdata->resume(dev);
41 46
@@ -51,10 +56,9 @@ static int tc6387xb_resume(struct platform_device *dev)
51static int tc6387xb_mmc_enable(struct platform_device *mmc) 56static int tc6387xb_mmc_enable(struct platform_device *mmc)
52{ 57{
53 struct platform_device *dev = to_platform_device(mmc->dev.parent); 58 struct platform_device *dev = to_platform_device(mmc->dev.parent);
54 struct tc6387xb_platform_data *tc6387xb = dev->dev.platform_data; 59 struct clk *clk32k = platform_get_drvdata(dev);
55 60
56 if (tc6387xb->enable_clk32k) 61 clk_enable(clk32k);
57 tc6387xb->enable_clk32k(dev);
58 62
59 return 0; 63 return 0;
60} 64}
@@ -62,10 +66,9 @@ static int tc6387xb_mmc_enable(struct platform_device *mmc)
62static int tc6387xb_mmc_disable(struct platform_device *mmc) 66static int tc6387xb_mmc_disable(struct platform_device *mmc)
63{ 67{
64 struct platform_device *dev = to_platform_device(mmc->dev.parent); 68 struct platform_device *dev = to_platform_device(mmc->dev.parent);
65 struct tc6387xb_platform_data *tc6387xb = dev->dev.platform_data; 69 struct clk *clk32k = platform_get_drvdata(dev);
66 70
67 if (tc6387xb->disable_clk32k) 71 clk_disable(clk32k);
68 tc6387xb->disable_clk32k(dev);
69 72
70 return 0; 73 return 0;
71} 74}
@@ -102,14 +105,14 @@ static struct mfd_cell tc6387xb_cells[] = {
102 105
103static int tc6387xb_probe(struct platform_device *dev) 106static int tc6387xb_probe(struct platform_device *dev)
104{ 107{
105 struct tc6387xb_platform_data *data = platform_get_drvdata(dev); 108 struct tc6387xb_platform_data *pdata = dev->dev.platform_data;
106 struct resource *iomem; 109 struct resource *iomem;
110 struct clk *clk32k;
107 int irq, ret; 111 int irq, ret;
108 112
109 iomem = platform_get_resource(dev, IORESOURCE_MEM, 0); 113 iomem = platform_get_resource(dev, IORESOURCE_MEM, 0);
110 if (!iomem) { 114 if (!iomem) {
111 ret = -EINVAL; 115 return -EINVAL;
112 goto err_resource;
113 } 116 }
114 117
115 ret = platform_get_irq(dev, 0); 118 ret = platform_get_irq(dev, 0);
@@ -118,8 +121,15 @@ static int tc6387xb_probe(struct platform_device *dev)
118 else 121 else
119 goto err_resource; 122 goto err_resource;
120 123
121 if (data && data->enable) 124 clk32k = clk_get(&dev->dev, "CLK_CK32K");
122 data->enable(dev); 125 if (IS_ERR(clk32k)) {
126 ret = PTR_ERR(clk32k);
127 goto err_resource;
128 }
129 platform_set_drvdata(dev, clk32k);
130
131 if (pdata && pdata->enable)
132 pdata->enable(dev);
123 133
124 printk(KERN_INFO "Toshiba tc6387xb initialised\n"); 134 printk(KERN_INFO "Toshiba tc6387xb initialised\n");
125 135
@@ -134,18 +144,19 @@ static int tc6387xb_probe(struct platform_device *dev)
134 if (!ret) 144 if (!ret)
135 return 0; 145 return 0;
136 146
147 clk_put(clk32k);
137err_resource: 148err_resource:
138 return ret; 149 return ret;
139} 150}
140 151
141static int tc6387xb_remove(struct platform_device *dev) 152static int tc6387xb_remove(struct platform_device *dev)
142{ 153{
143 struct tc6387xb_platform_data *data = platform_get_drvdata(dev); 154 struct clk *clk32k = platform_get_drvdata(dev);
144
145 if (data && data->disable)
146 data->disable(dev);
147 155
148 /* FIXME - free the resources! */ 156 mfd_remove_devices(&dev->dev);
157 clk_disable(clk32k);
158 clk_put(clk32k);
159 platform_set_drvdata(dev, NULL);
149 160
150 return 0; 161 return 0;
151} 162}