aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/clocksource
diff options
context:
space:
mode:
authorMagnus Damm <damm@opensource.se>2011-04-25 09:40:26 -0400
committerPaul Mundt <lethal@linux-sh.org>2011-05-23 01:34:07 -0400
commit1b842e91fea9447eff5eb687e28ad61c02f5033e (patch)
tree294d8962d4337153597bac12b9b53d39f28be2b3 /drivers/clocksource
parent0aeac458d9ebea5f0dc483e2d3f2c06bfa520c02 (diff)
clocksource: sh_tmu: Runtime PM support
Add Runtime PM support to the TMU driver. The hardware device is enabled as long as the clocksource or the clockevent portion of the driver is used. Signed-off-by: Magnus Damm <damm@opensource.se> Acked-by: John Stultz <johnstul@us.ibm.com> Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'drivers/clocksource')
-rw-r--r--drivers/clocksource/sh_tmu.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/drivers/clocksource/sh_tmu.c b/drivers/clocksource/sh_tmu.c
index 80813576861..17296288a20 100644
--- a/drivers/clocksource/sh_tmu.c
+++ b/drivers/clocksource/sh_tmu.c
@@ -25,6 +25,7 @@
25#include <linux/delay.h> 25#include <linux/delay.h>
26#include <linux/io.h> 26#include <linux/io.h>
27#include <linux/clk.h> 27#include <linux/clk.h>
28#include <linux/pm_runtime.h>
28#include <linux/irq.h> 29#include <linux/irq.h>
29#include <linux/err.h> 30#include <linux/err.h>
30#include <linux/clocksource.h> 31#include <linux/clocksource.h>
@@ -109,10 +110,12 @@ static int sh_tmu_enable(struct sh_tmu_priv *p)
109{ 110{
110 int ret; 111 int ret;
111 112
112 /* enable clock */ 113 /* wake up device and enable clock */
114 pm_runtime_get_sync(&p->pdev->dev);
113 ret = clk_enable(p->clk); 115 ret = clk_enable(p->clk);
114 if (ret) { 116 if (ret) {
115 dev_err(&p->pdev->dev, "cannot enable clock\n"); 117 dev_err(&p->pdev->dev, "cannot enable clock\n");
118 pm_runtime_put_sync(&p->pdev->dev);
116 return ret; 119 return ret;
117 } 120 }
118 121
@@ -141,8 +144,9 @@ static void sh_tmu_disable(struct sh_tmu_priv *p)
141 /* disable interrupts in TMU block */ 144 /* disable interrupts in TMU block */
142 sh_tmu_write(p, TCR, 0x0000); 145 sh_tmu_write(p, TCR, 0x0000);
143 146
144 /* stop clock */ 147 /* stop clock and mark device as idle */
145 clk_disable(p->clk); 148 clk_disable(p->clk);
149 pm_runtime_put_sync(&p->pdev->dev);
146} 150}
147 151
148static void sh_tmu_set_next(struct sh_tmu_priv *p, unsigned long delta, 152static void sh_tmu_set_next(struct sh_tmu_priv *p, unsigned long delta,
@@ -411,6 +415,7 @@ static int __devinit sh_tmu_probe(struct platform_device *pdev)
411 415
412 if (p) { 416 if (p) {
413 dev_info(&pdev->dev, "kept as earlytimer\n"); 417 dev_info(&pdev->dev, "kept as earlytimer\n");
418 pm_runtime_enable(&pdev->dev);
414 return 0; 419 return 0;
415 } 420 }
416 421
@@ -425,6 +430,9 @@ static int __devinit sh_tmu_probe(struct platform_device *pdev)
425 kfree(p); 430 kfree(p);
426 platform_set_drvdata(pdev, NULL); 431 platform_set_drvdata(pdev, NULL);
427 } 432 }
433
434 if (!is_early_platform_device(pdev))
435 pm_runtime_enable(&pdev->dev);
428 return ret; 436 return ret;
429} 437}
430 438