aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mfd
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
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')
-rw-r--r--drivers/mfd/t7l66xb.c40
-rw-r--r--drivers/mfd/tc6387xb.c47
2 files changed, 61 insertions, 26 deletions
diff --git a/drivers/mfd/t7l66xb.c b/drivers/mfd/t7l66xb.c
index 49a0fffc02af..9f7024c0f8ec 100644
--- a/drivers/mfd/t7l66xb.c
+++ b/drivers/mfd/t7l66xb.c
@@ -24,8 +24,10 @@
24 24
25#include <linux/kernel.h> 25#include <linux/kernel.h>
26#include <linux/module.h> 26#include <linux/module.h>
27#include <linux/err.h>
27#include <linux/io.h> 28#include <linux/io.h>
28#include <linux/irq.h> 29#include <linux/irq.h>
30#include <linux/clk.h>
29#include <linux/platform_device.h> 31#include <linux/platform_device.h>
30#include <linux/mfd/core.h> 32#include <linux/mfd/core.h>
31#include <linux/mfd/tmio.h> 33#include <linux/mfd/tmio.h>
@@ -56,6 +58,8 @@ struct t7l66xb {
56 spinlock_t lock; 58 spinlock_t lock;
57 59
58 struct resource rscr; 60 struct resource rscr;
61 struct clk *clk48m;
62 struct clk *clk32k;
59 int irq; 63 int irq;
60 int irq_base; 64 int irq_base;
61}; 65};
@@ -65,13 +69,11 @@ struct t7l66xb {
65static int t7l66xb_mmc_enable(struct platform_device *mmc) 69static int t7l66xb_mmc_enable(struct platform_device *mmc)
66{ 70{
67 struct platform_device *dev = to_platform_device(mmc->dev.parent); 71 struct platform_device *dev = to_platform_device(mmc->dev.parent);
68 struct t7l66xb_platform_data *pdata = dev->dev.platform_data;
69 struct t7l66xb *t7l66xb = platform_get_drvdata(dev); 72 struct t7l66xb *t7l66xb = platform_get_drvdata(dev);
70 unsigned long flags; 73 unsigned long flags;
71 u8 dev_ctl; 74 u8 dev_ctl;
72 75
73 if (pdata->enable_clk32k) 76 clk_enable(t7l66xb->clk32k);
74 pdata->enable_clk32k(dev);
75 77
76 spin_lock_irqsave(&t7l66xb->lock, flags); 78 spin_lock_irqsave(&t7l66xb->lock, flags);
77 79
@@ -87,7 +89,6 @@ static int t7l66xb_mmc_enable(struct platform_device *mmc)
87static int t7l66xb_mmc_disable(struct platform_device *mmc) 89static int t7l66xb_mmc_disable(struct platform_device *mmc)
88{ 90{
89 struct platform_device *dev = to_platform_device(mmc->dev.parent); 91 struct platform_device *dev = to_platform_device(mmc->dev.parent);
90 struct t7l66xb_platform_data *pdata = dev->dev.platform_data;
91 struct t7l66xb *t7l66xb = platform_get_drvdata(dev); 92 struct t7l66xb *t7l66xb = platform_get_drvdata(dev);
92 unsigned long flags; 93 unsigned long flags;
93 u8 dev_ctl; 94 u8 dev_ctl;
@@ -100,8 +101,7 @@ static int t7l66xb_mmc_disable(struct platform_device *mmc)
100 101
101 spin_unlock_irqrestore(&t7l66xb->lock, flags); 102 spin_unlock_irqrestore(&t7l66xb->lock, flags);
102 103
103 if (pdata->disable_clk32k) 104 clk_disable(t7l66xb->clk32k);
104 pdata->disable_clk32k(dev);
105 105
106 return 0; 106 return 0;
107} 107}
@@ -258,18 +258,22 @@ static void t7l66xb_detach_irq(struct platform_device *dev)
258#ifdef CONFIG_PM 258#ifdef CONFIG_PM
259static int t7l66xb_suspend(struct platform_device *dev, pm_message_t state) 259static int t7l66xb_suspend(struct platform_device *dev, pm_message_t state)
260{ 260{
261 struct t7l66xb *t7l66xb = platform_get_drvdata(dev);
261 struct t7l66xb_platform_data *pdata = dev->dev.platform_data; 262 struct t7l66xb_platform_data *pdata = dev->dev.platform_data;
262 263
263 if (pdata && pdata->suspend) 264 if (pdata && pdata->suspend)
264 pdata->suspend(dev); 265 pdata->suspend(dev);
266 clk_disable(t7l66xb->clk48m);
265 267
266 return 0; 268 return 0;
267} 269}
268 270
269static int t7l66xb_resume(struct platform_device *dev) 271static int t7l66xb_resume(struct platform_device *dev)
270{ 272{
273 struct t7l66xb *t7l66xb = platform_get_drvdata(dev);
271 struct t7l66xb_platform_data *pdata = dev->dev.platform_data; 274 struct t7l66xb_platform_data *pdata = dev->dev.platform_data;
272 275
276 clk_enable(t7l66xb->clk48m);
273 if (pdata && pdata->resume) 277 if (pdata && pdata->resume)
274 pdata->resume(dev); 278 pdata->resume(dev);
275 279
@@ -309,6 +313,19 @@ static int t7l66xb_probe(struct platform_device *dev)
309 313
310 t7l66xb->irq_base = pdata->irq_base; 314 t7l66xb->irq_base = pdata->irq_base;
311 315
316 t7l66xb->clk32k = clk_get(&dev->dev, "CLK_CK32K");
317 if (IS_ERR(t7l66xb->clk32k)) {
318 ret = PTR_ERR(t7l66xb->clk32k);
319 goto err_clk32k_get;
320 }
321
322 t7l66xb->clk48m = clk_get(&dev->dev, "CLK_CK48M");
323 if (IS_ERR(t7l66xb->clk48m)) {
324 ret = PTR_ERR(t7l66xb->clk48m);
325 clk_put(t7l66xb->clk32k);
326 goto err_clk48m_get;
327 }
328
312 rscr = &t7l66xb->rscr; 329 rscr = &t7l66xb->rscr;
313 rscr->name = "t7l66xb-core"; 330 rscr->name = "t7l66xb-core";
314 rscr->start = iomem->start; 331 rscr->start = iomem->start;
@@ -325,6 +342,8 @@ static int t7l66xb_probe(struct platform_device *dev)
325 goto err_ioremap; 342 goto err_ioremap;
326 } 343 }
327 344
345 clk_enable(t7l66xb->clk48m);
346
328 if (pdata && pdata->enable) 347 if (pdata && pdata->enable)
329 pdata->enable(dev); 348 pdata->enable(dev);
330 349
@@ -359,9 +378,13 @@ static int t7l66xb_probe(struct platform_device *dev)
359 iounmap(t7l66xb->scr); 378 iounmap(t7l66xb->scr);
360err_ioremap: 379err_ioremap:
361 release_resource(&t7l66xb->rscr); 380 release_resource(&t7l66xb->rscr);
362err_noirq:
363err_request_scr: 381err_request_scr:
364 kfree(t7l66xb); 382 kfree(t7l66xb);
383 clk_put(t7l66xb->clk48m);
384err_clk48m_get:
385 clk_put(t7l66xb->clk32k);
386err_clk32k_get:
387err_noirq:
365 return ret; 388 return ret;
366} 389}
367 390
@@ -372,7 +395,8 @@ static int t7l66xb_remove(struct platform_device *dev)
372 int ret; 395 int ret;
373 396
374 ret = pdata->disable(dev); 397 ret = pdata->disable(dev);
375 398 clk_disable(t7l66xb->clk48m);
399 clk_put(t7l66xb->clk48m);
376 t7l66xb_detach_irq(dev); 400 t7l66xb_detach_irq(dev);
377 iounmap(t7l66xb->scr); 401 iounmap(t7l66xb->scr);
378 release_resource(&t7l66xb->rscr); 402 release_resource(&t7l66xb->rscr);
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}