diff options
author | Ian Molton <spyro@f2s.com> | 2008-10-09 14:06:09 -0400 |
---|---|---|
committer | Samuel Ortiz <samuel@sortiz.org> | 2008-10-19 16:54:12 -0400 |
commit | 7acb706ca97fce84bda4a902a33de2f3dae10260 (patch) | |
tree | 90e6468e55ea1029258dda97a5f2c0e1566ef8d2 | |
parent | 9297a0e7e033b7f2776610197fcbb9ff563efe32 (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>
-rw-r--r-- | drivers/mfd/t7l66xb.c | 40 | ||||
-rw-r--r-- | drivers/mfd/tc6387xb.c | 47 | ||||
-rw-r--r-- | include/linux/mfd/t7l66xb.h | 2 | ||||
-rw-r--r-- | include/linux/mfd/tc6387xb.h | 3 |
4 files changed, 61 insertions, 31 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 { | |||
65 | static int t7l66xb_mmc_enable(struct platform_device *mmc) | 69 | static 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) | |||
87 | static int t7l66xb_mmc_disable(struct platform_device *mmc) | 89 | static 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 |
259 | static int t7l66xb_suspend(struct platform_device *dev, pm_message_t state) | 259 | static 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 | ||
269 | static int t7l66xb_resume(struct platform_device *dev) | 271 | static 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); |
360 | err_ioremap: | 379 | err_ioremap: |
361 | release_resource(&t7l66xb->rscr); | 380 | release_resource(&t7l66xb->rscr); |
362 | err_noirq: | ||
363 | err_request_scr: | 381 | err_request_scr: |
364 | kfree(t7l66xb); | 382 | kfree(t7l66xb); |
383 | clk_put(t7l66xb->clk48m); | ||
384 | err_clk48m_get: | ||
385 | clk_put(t7l66xb->clk32k); | ||
386 | err_clk32k_get: | ||
387 | err_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 |
25 | static int tc6387xb_suspend(struct platform_device *dev, pm_message_t state) | 26 | static 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 | ||
35 | static int tc6387xb_resume(struct platform_device *dev) | 38 | static 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) | |||
51 | static int tc6387xb_mmc_enable(struct platform_device *mmc) | 56 | static 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) | |||
62 | static int tc6387xb_mmc_disable(struct platform_device *mmc) | 66 | static 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 | ||
103 | static int tc6387xb_probe(struct platform_device *dev) | 106 | static 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); | ||
137 | err_resource: | 148 | err_resource: |
138 | return ret; | 149 | return ret; |
139 | } | 150 | } |
140 | 151 | ||
141 | static int tc6387xb_remove(struct platform_device *dev) | 152 | static 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 | } |
diff --git a/include/linux/mfd/t7l66xb.h b/include/linux/mfd/t7l66xb.h index e83c7f2036f9..b4629818aea5 100644 --- a/include/linux/mfd/t7l66xb.h +++ b/include/linux/mfd/t7l66xb.h | |||
@@ -15,8 +15,6 @@ | |||
15 | #include <linux/mfd/tmio.h> | 15 | #include <linux/mfd/tmio.h> |
16 | 16 | ||
17 | struct t7l66xb_platform_data { | 17 | struct t7l66xb_platform_data { |
18 | int (*enable_clk32k)(struct platform_device *dev); | ||
19 | void (*disable_clk32k)(struct platform_device *dev); | ||
20 | int (*enable)(struct platform_device *dev); | 18 | int (*enable)(struct platform_device *dev); |
21 | int (*disable)(struct platform_device *dev); | 19 | int (*disable)(struct platform_device *dev); |
22 | int (*suspend)(struct platform_device *dev); | 20 | int (*suspend)(struct platform_device *dev); |
diff --git a/include/linux/mfd/tc6387xb.h b/include/linux/mfd/tc6387xb.h index fa06e0610b8e..b4888209494a 100644 --- a/include/linux/mfd/tc6387xb.h +++ b/include/linux/mfd/tc6387xb.h | |||
@@ -11,9 +11,6 @@ | |||
11 | #define MFD_TC6387XB_H | 11 | #define MFD_TC6387XB_H |
12 | 12 | ||
13 | struct tc6387xb_platform_data { | 13 | struct tc6387xb_platform_data { |
14 | int (*enable_clk32k)(struct platform_device *dev); | ||
15 | void (*disable_clk32k)(struct platform_device *dev); | ||
16 | |||
17 | int (*enable)(struct platform_device *dev); | 14 | int (*enable)(struct platform_device *dev); |
18 | int (*disable)(struct platform_device *dev); | 15 | int (*disable)(struct platform_device *dev); |
19 | int (*suspend)(struct platform_device *dev); | 16 | int (*suspend)(struct platform_device *dev); |