Commit 478fc4e6 authored by Paul Mundt's avatar Paul Mundt Committed by Greg Kroah-Hartman

clocksource: sh_cmt: compute mult and shift before registration

commit f4d7c356 upstream.

Based on the sh_tmu change in 66f49121
("clocksource: sh_tmu: compute mult and shift before registration").
The same issues impact the sh_cmt driver, so we take the same approach
here.
Signed-off-by: default avatarPaul Mundt <lethal@linux-sh.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent a2149855
...@@ -413,18 +413,10 @@ static cycle_t sh_cmt_clocksource_read(struct clocksource *cs) ...@@ -413,18 +413,10 @@ static cycle_t sh_cmt_clocksource_read(struct clocksource *cs)
static int sh_cmt_clocksource_enable(struct clocksource *cs) static int sh_cmt_clocksource_enable(struct clocksource *cs)
{ {
struct sh_cmt_priv *p = cs_to_sh_cmt(cs); struct sh_cmt_priv *p = cs_to_sh_cmt(cs);
int ret;
p->total_cycles = 0; p->total_cycles = 0;
ret = sh_cmt_start(p, FLAG_CLOCKSOURCE); return sh_cmt_start(p, FLAG_CLOCKSOURCE);
if (ret)
return ret;
/* TODO: calculate good shift from rate and counter bit width */
cs->shift = 0;
cs->mult = clocksource_hz2mult(p->rate, cs->shift);
return 0;
} }
static void sh_cmt_clocksource_disable(struct clocksource *cs) static void sh_cmt_clocksource_disable(struct clocksource *cs)
...@@ -451,7 +443,18 @@ static int sh_cmt_register_clocksource(struct sh_cmt_priv *p, ...@@ -451,7 +443,18 @@ static int sh_cmt_register_clocksource(struct sh_cmt_priv *p,
cs->resume = sh_cmt_clocksource_resume; cs->resume = sh_cmt_clocksource_resume;
cs->mask = CLOCKSOURCE_MASK(sizeof(unsigned long) * 8); cs->mask = CLOCKSOURCE_MASK(sizeof(unsigned long) * 8);
cs->flags = CLOCK_SOURCE_IS_CONTINUOUS; cs->flags = CLOCK_SOURCE_IS_CONTINUOUS;
/* clk_get_rate() needs an enabled clock */
clk_enable(p->clk);
p->rate = clk_get_rate(p->clk) / (p->width == 16) ? 512 : 8;
clk_disable(p->clk);
/* TODO: calculate good shift from rate and counter bit width */
cs->shift = 10;
cs->mult = clocksource_hz2mult(p->rate, cs->shift);
pr_info("sh_cmt: %s used as clock source\n", cs->name); pr_info("sh_cmt: %s used as clock source\n", cs->name);
clocksource_register(cs); clocksource_register(cs);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment