diff options
Diffstat (limited to 'drivers/mfd/t7l66xb.c')
-rw-r--r-- | drivers/mfd/t7l66xb.c | 40 |
1 files changed, 32 insertions, 8 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); |