aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/clocksource/sh_cmt.c
diff options
context:
space:
mode:
authorMagnus Damm <damm@opensource.se>2011-04-25 09:32:11 -0400
committerPaul Mundt <lethal@linux-sh.org>2011-05-23 01:33:59 -0400
commit3593f5fe40a13badf6921ccbc3378b02fbf6a532 (patch)
treef2d8710c0e6abfb0f633935003bd532757a27f66 /drivers/clocksource/sh_cmt.c
parent31705e21f9b5a0628c043f88ff4d20488b47b8ab (diff)
clocksource: sh_cmt: __clocksource_updatefreq_hz() update
This patch updates the clocksource part of the CMT driver to make use of the __clocksource_updatefreq_hz() function. Without this patch the old code uses clocksource_register() together with a hack that assumes a never changing clock rate (see clk_enable(), clk_get_rate() and clk_disable()). The patch uses clocksource_register_hz() with 1 Hz as initial value, then lets the ->enable() callback update the value with __clocksource_updatefreq_hz() once the struct clk has been enabled and the frequency is stable. 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/sh_cmt.c')
-rw-r--r--drivers/clocksource/sh_cmt.c19
1 files changed, 7 insertions, 12 deletions
diff --git a/drivers/clocksource/sh_cmt.c b/drivers/clocksource/sh_cmt.c
index f975d24890fa..dc7c033ef587 100644
--- a/drivers/clocksource/sh_cmt.c
+++ b/drivers/clocksource/sh_cmt.c
@@ -416,11 +416,15 @@ static cycle_t sh_cmt_clocksource_read(struct clocksource *cs)
416 416
417static int sh_cmt_clocksource_enable(struct clocksource *cs) 417static int sh_cmt_clocksource_enable(struct clocksource *cs)
418{ 418{
419 int ret;
419 struct sh_cmt_priv *p = cs_to_sh_cmt(cs); 420 struct sh_cmt_priv *p = cs_to_sh_cmt(cs);
420 421
421 p->total_cycles = 0; 422 p->total_cycles = 0;
422 423
423 return sh_cmt_start(p, FLAG_CLOCKSOURCE); 424 ret = sh_cmt_start(p, FLAG_CLOCKSOURCE);
425 if (!ret)
426 __clocksource_updatefreq_hz(cs, p->rate);
427 return ret;
424} 428}
425 429
426static void sh_cmt_clocksource_disable(struct clocksource *cs) 430static void sh_cmt_clocksource_disable(struct clocksource *cs)
@@ -448,19 +452,10 @@ static int sh_cmt_register_clocksource(struct sh_cmt_priv *p,
448 cs->mask = CLOCKSOURCE_MASK(sizeof(unsigned long) * 8); 452 cs->mask = CLOCKSOURCE_MASK(sizeof(unsigned long) * 8);
449 cs->flags = CLOCK_SOURCE_IS_CONTINUOUS; 453 cs->flags = CLOCK_SOURCE_IS_CONTINUOUS;
450 454
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"); 455 dev_info(&p->pdev->dev, "used as clock source\n");
461 456
462 clocksource_register(cs); 457 /* Register with dummy 1 Hz value, gets updated in ->enable() */
463 458 clocksource_register_hz(cs, 1);
464 return 0; 459 return 0;
465} 460}
466 461