diff options
Diffstat (limited to 'drivers/clocksource')
-rw-r--r-- | drivers/clocksource/sh_cmt.c | 22 | ||||
-rw-r--r-- | drivers/clocksource/sh_tmu.c | 20 |
2 files changed, 24 insertions, 18 deletions
diff --git a/drivers/clocksource/sh_cmt.c b/drivers/clocksource/sh_cmt.c index f6677cb19789..f3d3898898ed 100644 --- a/drivers/clocksource/sh_cmt.c +++ b/drivers/clocksource/sh_cmt.c | |||
@@ -412,18 +412,10 @@ static cycle_t sh_cmt_clocksource_read(struct clocksource *cs) | |||
412 | static int sh_cmt_clocksource_enable(struct clocksource *cs) | 412 | static int sh_cmt_clocksource_enable(struct clocksource *cs) |
413 | { | 413 | { |
414 | struct sh_cmt_priv *p = cs_to_sh_cmt(cs); | 414 | struct sh_cmt_priv *p = cs_to_sh_cmt(cs); |
415 | int ret; | ||
416 | 415 | ||
417 | p->total_cycles = 0; | 416 | p->total_cycles = 0; |
418 | 417 | ||
419 | ret = sh_cmt_start(p, FLAG_CLOCKSOURCE); | 418 | return sh_cmt_start(p, FLAG_CLOCKSOURCE); |
420 | if (ret) | ||
421 | return ret; | ||
422 | |||
423 | /* TODO: calculate good shift from rate and counter bit width */ | ||
424 | cs->shift = 0; | ||
425 | cs->mult = clocksource_hz2mult(p->rate, cs->shift); | ||
426 | return 0; | ||
427 | } | 419 | } |
428 | 420 | ||
429 | static void sh_cmt_clocksource_disable(struct clocksource *cs) | 421 | static void sh_cmt_clocksource_disable(struct clocksource *cs) |
@@ -450,8 +442,20 @@ static int sh_cmt_register_clocksource(struct sh_cmt_priv *p, | |||
450 | cs->resume = sh_cmt_clocksource_resume; | 442 | cs->resume = sh_cmt_clocksource_resume; |
451 | cs->mask = CLOCKSOURCE_MASK(sizeof(unsigned long) * 8); | 443 | cs->mask = CLOCKSOURCE_MASK(sizeof(unsigned long) * 8); |
452 | cs->flags = CLOCK_SOURCE_IS_CONTINUOUS; | 444 | cs->flags = CLOCK_SOURCE_IS_CONTINUOUS; |
445 | |||
446 | /* clk_get_rate() needs an enabled clock */ | ||
447 | clk_enable(p->clk); | ||
448 | p->rate = clk_get_rate(p->clk) / (p->width == 16) ? 512 : 8; | ||
449 | clk_disable(p->clk); | ||
450 | |||
451 | /* TODO: calculate good shift from rate and counter bit width */ | ||
452 | cs->shift = 10; | ||
453 | cs->mult = clocksource_hz2mult(p->rate, cs->shift); | ||
454 | |||
453 | dev_info(&p->pdev->dev, "used as clock source\n"); | 455 | dev_info(&p->pdev->dev, "used as clock source\n"); |
456 | |||
454 | clocksource_register(cs); | 457 | clocksource_register(cs); |
458 | |||
455 | return 0; | 459 | return 0; |
456 | } | 460 | } |
457 | 461 | ||
diff --git a/drivers/clocksource/sh_tmu.c b/drivers/clocksource/sh_tmu.c index 8e44e14ec4c2..de715901b82a 100644 --- a/drivers/clocksource/sh_tmu.c +++ b/drivers/clocksource/sh_tmu.c | |||
@@ -199,16 +199,8 @@ static cycle_t sh_tmu_clocksource_read(struct clocksource *cs) | |||
199 | static int sh_tmu_clocksource_enable(struct clocksource *cs) | 199 | static int sh_tmu_clocksource_enable(struct clocksource *cs) |
200 | { | 200 | { |
201 | struct sh_tmu_priv *p = cs_to_sh_tmu(cs); | 201 | struct sh_tmu_priv *p = cs_to_sh_tmu(cs); |
202 | int ret; | ||
203 | |||
204 | ret = sh_tmu_enable(p); | ||
205 | if (ret) | ||
206 | return ret; | ||
207 | 202 | ||
208 | /* TODO: calculate good shift from rate and counter bit width */ | 203 | return sh_tmu_enable(p); |
209 | cs->shift = 10; | ||
210 | cs->mult = clocksource_hz2mult(p->rate, cs->shift); | ||
211 | return 0; | ||
212 | } | 204 | } |
213 | 205 | ||
214 | static void sh_tmu_clocksource_disable(struct clocksource *cs) | 206 | static void sh_tmu_clocksource_disable(struct clocksource *cs) |
@@ -228,6 +220,16 @@ static int sh_tmu_register_clocksource(struct sh_tmu_priv *p, | |||
228 | cs->disable = sh_tmu_clocksource_disable; | 220 | cs->disable = sh_tmu_clocksource_disable; |
229 | cs->mask = CLOCKSOURCE_MASK(32); | 221 | cs->mask = CLOCKSOURCE_MASK(32); |
230 | cs->flags = CLOCK_SOURCE_IS_CONTINUOUS; | 222 | cs->flags = CLOCK_SOURCE_IS_CONTINUOUS; |
223 | |||
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); | ||
232 | |||
231 | dev_info(&p->pdev->dev, "used as clock source\n"); | 233 | dev_info(&p->pdev->dev, "used as clock source\n"); |
232 | clocksource_register(cs); | 234 | clocksource_register(cs); |
233 | return 0; | 235 | return 0; |