diff options
author | Kevin Hilman <khilman@deeprootsystems.com> | 2009-04-14 08:06:37 -0400 |
---|---|---|
committer | Kevin Hilman <khilman@deeprootsystems.com> | 2009-04-27 12:49:36 -0400 |
commit | e60990023cac11bc6185e7a7f1007fbbb8d30e4d (patch) | |
tree | 1756b42a1a632908068a1878db5054bf18b9c313 /arch/arm/mach-davinci/time.c | |
parent | f5c122da543ebf98a5ccb3166768e38eea3120dd (diff) |
davinci: timers: use clk_get_rate()
Use clock framework instead of hard-coded CLOCK_TICK_RATE for
determining timer tick frequencies.
Signed-off-by: Kevin Hilman <khilman@deeprootsystems.com>
Diffstat (limited to 'arch/arm/mach-davinci/time.c')
-rw-r--r-- | arch/arm/mach-davinci/time.c | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/arch/arm/mach-davinci/time.c b/arch/arm/mach-davinci/time.c index 88864ae067b8..494e01bff5c3 100644 --- a/arch/arm/mach-davinci/time.c +++ b/arch/arm/mach-davinci/time.c | |||
@@ -31,6 +31,7 @@ | |||
31 | #include "clock.h" | 31 | #include "clock.h" |
32 | 32 | ||
33 | static struct clock_event_device clockevent_davinci; | 33 | static struct clock_event_device clockevent_davinci; |
34 | static unsigned int davinci_clock_tick_rate; | ||
34 | 35 | ||
35 | #define DAVINCI_TIMER0_BASE (IO_PHYS + 0x21400) | 36 | #define DAVINCI_TIMER0_BASE (IO_PHYS + 0x21400) |
36 | #define DAVINCI_TIMER1_BASE (IO_PHYS + 0x21800) | 37 | #define DAVINCI_TIMER1_BASE (IO_PHYS + 0x21800) |
@@ -282,7 +283,7 @@ static void davinci_set_mode(enum clock_event_mode mode, | |||
282 | 283 | ||
283 | switch (mode) { | 284 | switch (mode) { |
284 | case CLOCK_EVT_MODE_PERIODIC: | 285 | case CLOCK_EVT_MODE_PERIODIC: |
285 | t->period = CLOCK_TICK_RATE / (HZ); | 286 | t->period = davinci_clock_tick_rate / (HZ); |
286 | t->opts = TIMER_OPTS_PERIODIC; | 287 | t->opts = TIMER_OPTS_PERIODIC; |
287 | timer32_config(t); | 288 | timer32_config(t); |
288 | break; | 289 | break; |
@@ -309,21 +310,29 @@ static struct clock_event_device clockevent_davinci = { | |||
309 | 310 | ||
310 | static void __init davinci_timer_init(void) | 311 | static void __init davinci_timer_init(void) |
311 | { | 312 | { |
313 | struct clk *timer_clk; | ||
314 | |||
312 | static char err[] __initdata = KERN_ERR | 315 | static char err[] __initdata = KERN_ERR |
313 | "%s: can't register clocksource!\n"; | 316 | "%s: can't register clocksource!\n"; |
314 | 317 | ||
315 | /* init timer hw */ | 318 | /* init timer hw */ |
316 | timer_init(); | 319 | timer_init(); |
317 | 320 | ||
321 | timer_clk = clk_get(NULL, "timer0"); | ||
322 | BUG_ON(IS_ERR(timer_clk)); | ||
323 | clk_enable(timer_clk); | ||
324 | |||
325 | davinci_clock_tick_rate = clk_get_rate(timer_clk); | ||
326 | |||
318 | /* setup clocksource */ | 327 | /* setup clocksource */ |
319 | clocksource_davinci.mult = | 328 | clocksource_davinci.mult = |
320 | clocksource_khz2mult(CLOCK_TICK_RATE/1000, | 329 | clocksource_khz2mult(davinci_clock_tick_rate/1000, |
321 | clocksource_davinci.shift); | 330 | clocksource_davinci.shift); |
322 | if (clocksource_register(&clocksource_davinci)) | 331 | if (clocksource_register(&clocksource_davinci)) |
323 | printk(err, clocksource_davinci.name); | 332 | printk(err, clocksource_davinci.name); |
324 | 333 | ||
325 | /* setup clockevent */ | 334 | /* setup clockevent */ |
326 | clockevent_davinci.mult = div_sc(CLOCK_TICK_RATE, NSEC_PER_SEC, | 335 | clockevent_davinci.mult = div_sc(davinci_clock_tick_rate, NSEC_PER_SEC, |
327 | clockevent_davinci.shift); | 336 | clockevent_davinci.shift); |
328 | clockevent_davinci.max_delta_ns = | 337 | clockevent_davinci.max_delta_ns = |
329 | clockevent_delta2ns(0xfffffffe, &clockevent_davinci); | 338 | clockevent_delta2ns(0xfffffffe, &clockevent_davinci); |
@@ -343,6 +352,15 @@ struct sys_timer davinci_timer = { | |||
343 | void davinci_watchdog_reset(void) { | 352 | void davinci_watchdog_reset(void) { |
344 | u32 tgcr, wdtcr; | 353 | u32 tgcr, wdtcr; |
345 | void __iomem *base = IO_ADDRESS(DAVINCI_WDOG_BASE); | 354 | void __iomem *base = IO_ADDRESS(DAVINCI_WDOG_BASE); |
355 | struct device dev; | ||
356 | struct clk *wd_clk; | ||
357 | char *name = "watchdog"; | ||
358 | |||
359 | dev_set_name(&dev, name); | ||
360 | wd_clk = clk_get(&dev, NULL); | ||
361 | if (WARN_ON(IS_ERR(wd_clk))) | ||
362 | return; | ||
363 | clk_enable(wd_clk); | ||
346 | 364 | ||
347 | /* disable, internal clock source */ | 365 | /* disable, internal clock source */ |
348 | __raw_writel(0, base + TCR); | 366 | __raw_writel(0, base + TCR); |