diff options
author | Magnus Damm <damm@opensource.se> | 2011-04-25 09:36:10 -0400 |
---|---|---|
committer | Paul Mundt <lethal@linux-sh.org> | 2011-05-23 01:34:02 -0400 |
commit | 01fa68b58492a5d6708a91c1f474b6a099a9509e (patch) | |
tree | c8e19e7f0fed3193945ebf357c2c35ba601817e3 | |
parent | 3593f5fe40a13badf6921ccbc3378b02fbf6a532 (diff) |
clocksource: sh_cmt: Runtime PM support
Add Runtime PM support to the CMT 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>
-rw-r--r-- | drivers/clocksource/sh_cmt.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/drivers/clocksource/sh_cmt.c b/drivers/clocksource/sh_cmt.c index dc7c033ef587..036e5865eb40 100644 --- a/drivers/clocksource/sh_cmt.c +++ b/drivers/clocksource/sh_cmt.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <linux/ioport.h> | 24 | #include <linux/ioport.h> |
25 | #include <linux/io.h> | 25 | #include <linux/io.h> |
26 | #include <linux/clk.h> | 26 | #include <linux/clk.h> |
27 | #include <linux/pm_runtime.h> | ||
27 | #include <linux/irq.h> | 28 | #include <linux/irq.h> |
28 | #include <linux/err.h> | 29 | #include <linux/err.h> |
29 | #include <linux/clocksource.h> | 30 | #include <linux/clocksource.h> |
@@ -152,10 +153,12 @@ static int sh_cmt_enable(struct sh_cmt_priv *p, unsigned long *rate) | |||
152 | { | 153 | { |
153 | int ret; | 154 | int ret; |
154 | 155 | ||
155 | /* enable clock */ | 156 | /* wake up device and enable clock */ |
157 | pm_runtime_get_sync(&p->pdev->dev); | ||
156 | ret = clk_enable(p->clk); | 158 | ret = clk_enable(p->clk); |
157 | if (ret) { | 159 | if (ret) { |
158 | dev_err(&p->pdev->dev, "cannot enable clock\n"); | 160 | dev_err(&p->pdev->dev, "cannot enable clock\n"); |
161 | pm_runtime_put_sync(&p->pdev->dev); | ||
159 | return ret; | 162 | return ret; |
160 | } | 163 | } |
161 | 164 | ||
@@ -187,8 +190,9 @@ static void sh_cmt_disable(struct sh_cmt_priv *p) | |||
187 | /* disable interrupts in CMT block */ | 190 | /* disable interrupts in CMT block */ |
188 | sh_cmt_write(p, CMCSR, 0); | 191 | sh_cmt_write(p, CMCSR, 0); |
189 | 192 | ||
190 | /* stop clock */ | 193 | /* stop clock and mark device as idle */ |
191 | clk_disable(p->clk); | 194 | clk_disable(p->clk); |
195 | pm_runtime_put_sync(&p->pdev->dev); | ||
192 | } | 196 | } |
193 | 197 | ||
194 | /* private flags */ | 198 | /* private flags */ |
@@ -660,6 +664,7 @@ static int __devinit sh_cmt_probe(struct platform_device *pdev) | |||
660 | 664 | ||
661 | if (p) { | 665 | if (p) { |
662 | dev_info(&pdev->dev, "kept as earlytimer\n"); | 666 | dev_info(&pdev->dev, "kept as earlytimer\n"); |
667 | pm_runtime_enable(&pdev->dev); | ||
663 | return 0; | 668 | return 0; |
664 | } | 669 | } |
665 | 670 | ||
@@ -674,6 +679,9 @@ static int __devinit sh_cmt_probe(struct platform_device *pdev) | |||
674 | kfree(p); | 679 | kfree(p); |
675 | platform_set_drvdata(pdev, NULL); | 680 | platform_set_drvdata(pdev, NULL); |
676 | } | 681 | } |
682 | |||
683 | if (!is_early_platform_device(pdev)) | ||
684 | pm_runtime_enable(&pdev->dev); | ||
677 | return ret; | 685 | return ret; |
678 | } | 686 | } |
679 | 687 | ||