Commit 0d9298ea authored by Russell King's avatar Russell King Committed by Daniel Lezcano

clocksource/drivers/orion: Read clock rate once

Rather than reading the clock rate three times, read it once - we are
about to add a fourth usage.
Signed-off-by: default avatarRussell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: default avatarDaniel Lezcano <daniel.lezcano@linaro.org>
parent 5fc63f95
...@@ -106,6 +106,7 @@ static struct irqaction orion_clkevt_irq = { ...@@ -106,6 +106,7 @@ static struct irqaction orion_clkevt_irq = {
static int __init orion_timer_init(struct device_node *np) static int __init orion_timer_init(struct device_node *np)
{ {
unsigned long rate;
struct clk *clk; struct clk *clk;
int irq, ret; int irq, ret;
...@@ -135,6 +136,8 @@ static int __init orion_timer_init(struct device_node *np) ...@@ -135,6 +136,8 @@ static int __init orion_timer_init(struct device_node *np)
return -EINVAL; return -EINVAL;
} }
rate = clk_get_rate(clk);
/* setup timer0 as free-running clocksource */ /* setup timer0 as free-running clocksource */
writel(~0, timer_base + TIMER0_VAL); writel(~0, timer_base + TIMER0_VAL);
writel(~0, timer_base + TIMER0_RELOAD); writel(~0, timer_base + TIMER0_RELOAD);
...@@ -142,15 +145,15 @@ static int __init orion_timer_init(struct device_node *np) ...@@ -142,15 +145,15 @@ static int __init orion_timer_init(struct device_node *np)
TIMER0_RELOAD_EN | TIMER0_EN, TIMER0_RELOAD_EN | TIMER0_EN,
TIMER0_RELOAD_EN | TIMER0_EN); TIMER0_RELOAD_EN | TIMER0_EN);
ret = clocksource_mmio_init(timer_base + TIMER0_VAL, "orion_clocksource", ret = clocksource_mmio_init(timer_base + TIMER0_VAL,
clk_get_rate(clk), 300, 32, "orion_clocksource", rate, 300, 32,
clocksource_mmio_readl_down); clocksource_mmio_readl_down);
if (ret) { if (ret) {
pr_err("Failed to initialize mmio timer"); pr_err("Failed to initialize mmio timer");
return ret; return ret;
} }
sched_clock_register(orion_read_sched_clock, 32, clk_get_rate(clk)); sched_clock_register(orion_read_sched_clock, 32, rate);
/* setup timer1 as clockevent timer */ /* setup timer1 as clockevent timer */
ret = setup_irq(irq, &orion_clkevt_irq); ret = setup_irq(irq, &orion_clkevt_irq);
...@@ -162,7 +165,7 @@ static int __init orion_timer_init(struct device_node *np) ...@@ -162,7 +165,7 @@ static int __init orion_timer_init(struct device_node *np)
ticks_per_jiffy = (clk_get_rate(clk) + HZ/2) / HZ; ticks_per_jiffy = (clk_get_rate(clk) + HZ/2) / HZ;
orion_clkevt.cpumask = cpumask_of(0); orion_clkevt.cpumask = cpumask_of(0);
orion_clkevt.irq = irq; orion_clkevt.irq = irq;
clockevents_config_and_register(&orion_clkevt, clk_get_rate(clk), clockevents_config_and_register(&orion_clkevt, rate,
ORION_ONESHOT_MIN, ORION_ONESHOT_MAX); ORION_ONESHOT_MIN, ORION_ONESHOT_MAX);
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