diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2011-05-24 00:24:07 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-05-24 00:24:07 -0400 |
| commit | d762f4383100c2a87b1a3f2d678cd3b5425655b4 (patch) | |
| tree | e2a982fea165e77d3f7098717e887dbb28efc6d1 /drivers/clocksource | |
| parent | 5214638384a968574a5ea3df1d3b3194da32a496 (diff) | |
| parent | 78207ffd0e00d39238f0a8a455a31a12659b30b3 (diff) | |
Merge branch 'sh-latest' of git://git.kernel.org/pub/scm/linux/kernel/git/lethal/sh-2.6
* 'sh-latest' of git://git.kernel.org/pub/scm/linux/kernel/git/lethal/sh-2.6: (23 commits)
sh: Ignore R_SH_NONE module relocations.
SH: SE7751: Fix pcibios_map_platform_irq prototype.
sh: remove warning and warning_symbol from struct stacktrace_ops
sh: wire up sys_sendmmsg.
clocksource: sh_tmu: Runtime PM support
clocksource: sh_tmu: __clocksource_updatefreq_hz() update
clocksource: sh_cmt: Runtime PM support
clocksource: sh_cmt: __clocksource_updatefreq_hz() update
dmaengine: shdma: synchronize RCU before freeing, simplify spinlock
dmaengine: shdma: add runtime- and system-level power management
dmaengine: shdma: fix locking
sh: sh-sci: sh7377 and sh73a0 build fixes
sh: cosmetic improvement: use an existing pointer
serial: sh-sci: suspend/resume wakeup support V2
serial: sh-sci: Runtime PM support
sh: select IRQ_FORCED_THREADING.
sh: intc: Set virtual IRQs as nothread.
sh: fixup fpu.o compile order
i2c: add a module alias to the sh-mobile driver
ALSA: add a module alias to the FSI driver
...
Diffstat (limited to 'drivers/clocksource')
| -rw-r--r-- | drivers/clocksource/sh_cmt.c | 31 | ||||
| -rw-r--r-- | drivers/clocksource/sh_tmu.c | 31 |
2 files changed, 35 insertions, 27 deletions
diff --git a/drivers/clocksource/sh_cmt.c b/drivers/clocksource/sh_cmt.c index f975d24890fa..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 */ |
| @@ -416,11 +420,15 @@ static cycle_t sh_cmt_clocksource_read(struct clocksource *cs) | |||
| 416 | 420 | ||
| 417 | static int sh_cmt_clocksource_enable(struct clocksource *cs) | 421 | static int sh_cmt_clocksource_enable(struct clocksource *cs) |
| 418 | { | 422 | { |
| 423 | int ret; | ||
| 419 | struct sh_cmt_priv *p = cs_to_sh_cmt(cs); | 424 | struct sh_cmt_priv *p = cs_to_sh_cmt(cs); |
| 420 | 425 | ||
| 421 | p->total_cycles = 0; | 426 | p->total_cycles = 0; |
| 422 | 427 | ||
| 423 | return sh_cmt_start(p, FLAG_CLOCKSOURCE); | 428 | ret = sh_cmt_start(p, FLAG_CLOCKSOURCE); |
| 429 | if (!ret) | ||
| 430 | __clocksource_updatefreq_hz(cs, p->rate); | ||
| 431 | return ret; | ||
| 424 | } | 432 | } |
| 425 | 433 | ||
| 426 | static void sh_cmt_clocksource_disable(struct clocksource *cs) | 434 | static void sh_cmt_clocksource_disable(struct clocksource *cs) |
| @@ -448,19 +456,10 @@ static int sh_cmt_register_clocksource(struct sh_cmt_priv *p, | |||
| 448 | cs->mask = CLOCKSOURCE_MASK(sizeof(unsigned long) * 8); | 456 | cs->mask = CLOCKSOURCE_MASK(sizeof(unsigned long) * 8); |
| 449 | cs->flags = CLOCK_SOURCE_IS_CONTINUOUS; | 457 | cs->flags = CLOCK_SOURCE_IS_CONTINUOUS; |
| 450 | 458 | ||
| 451 | /* clk_get_rate() needs an enabled clock */ | ||
| 452 | clk_enable(p->clk); | ||
| 453 | p->rate = clk_get_rate(p->clk) / ((p->width == 16) ? 512 : 8); | ||
| 454 | clk_disable(p->clk); | ||
| 455 | |||
| 456 | /* TODO: calculate good shift from rate and counter bit width */ | ||
| 457 | cs->shift = 0; | ||
| 458 | cs->mult = clocksource_hz2mult(p->rate, cs->shift); | ||
| 459 | |||
| 460 | dev_info(&p->pdev->dev, "used as clock source\n"); | 459 | dev_info(&p->pdev->dev, "used as clock source\n"); |
| 461 | 460 | ||
| 462 | clocksource_register(cs); | 461 | /* Register with dummy 1 Hz value, gets updated in ->enable() */ |
| 463 | 462 | clocksource_register_hz(cs, 1); | |
| 464 | return 0; | 463 | return 0; |
| 465 | } | 464 | } |
| 466 | 465 | ||
| @@ -665,6 +664,7 @@ static int __devinit sh_cmt_probe(struct platform_device *pdev) | |||
| 665 | 664 | ||
| 666 | if (p) { | 665 | if (p) { |
| 667 | dev_info(&pdev->dev, "kept as earlytimer\n"); | 666 | dev_info(&pdev->dev, "kept as earlytimer\n"); |
| 667 | pm_runtime_enable(&pdev->dev); | ||
| 668 | return 0; | 668 | return 0; |
| 669 | } | 669 | } |
| 670 | 670 | ||
| @@ -679,6 +679,9 @@ static int __devinit sh_cmt_probe(struct platform_device *pdev) | |||
| 679 | kfree(p); | 679 | kfree(p); |
| 680 | platform_set_drvdata(pdev, NULL); | 680 | platform_set_drvdata(pdev, NULL); |
| 681 | } | 681 | } |
| 682 | |||
| 683 | if (!is_early_platform_device(pdev)) | ||
| 684 | pm_runtime_enable(&pdev->dev); | ||
| 682 | return ret; | 685 | return ret; |
| 683 | } | 686 | } |
| 684 | 687 | ||
diff --git a/drivers/clocksource/sh_tmu.c b/drivers/clocksource/sh_tmu.c index 36aba9923060..17296288a205 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 | ||
| 148 | static void sh_tmu_set_next(struct sh_tmu_priv *p, unsigned long delta, | 152 | static void sh_tmu_set_next(struct sh_tmu_priv *p, unsigned long delta, |
| @@ -199,8 +203,12 @@ static cycle_t sh_tmu_clocksource_read(struct clocksource *cs) | |||
| 199 | static int sh_tmu_clocksource_enable(struct clocksource *cs) | 203 | static int sh_tmu_clocksource_enable(struct clocksource *cs) |
| 200 | { | 204 | { |
| 201 | struct sh_tmu_priv *p = cs_to_sh_tmu(cs); | 205 | struct sh_tmu_priv *p = cs_to_sh_tmu(cs); |
| 206 | int ret; | ||
| 202 | 207 | ||
| 203 | return sh_tmu_enable(p); | 208 | ret = sh_tmu_enable(p); |
| 209 | if (!ret) | ||
| 210 | __clocksource_updatefreq_hz(cs, p->rate); | ||
| 211 | return ret; | ||
| 204 | } | 212 | } |
| 205 | 213 | ||
| 206 | static void sh_tmu_clocksource_disable(struct clocksource *cs) | 214 | static void sh_tmu_clocksource_disable(struct clocksource *cs) |
| @@ -221,17 +229,10 @@ static int sh_tmu_register_clocksource(struct sh_tmu_priv *p, | |||
| 221 | cs->mask = CLOCKSOURCE_MASK(32); | 229 | cs->mask = CLOCKSOURCE_MASK(32); |
| 222 | cs->flags = CLOCK_SOURCE_IS_CONTINUOUS; | 230 | cs->flags = CLOCK_SOURCE_IS_CONTINUOUS; |
| 223 | 231 | ||
| 224 | /* clk_get_rate() needs an enabled clock */ | ||
| 225 | clk_enable(p->clk); | ||
| 226 | /* channel will be configured at parent clock / 4 */ | ||
| 227 | p->rate = clk_get_rate(p->clk) / 4; | ||
| 228 | clk_disable(p->clk); | ||
| 229 | /* TODO: calculate good shift from rate and counter bit width */ | ||
| 230 | cs->shift = 10; | ||
| 231 | cs->mult = clocksource_hz2mult(p->rate, cs->shift); | ||
