Commit 5def51b0 authored by Linus Walleij's avatar Linus Walleij Committed by Russell King

ARM: 7211/1: smp_twd: get the rate from a clock

This break-out from Colin Cross' cpufreq-aware TWD patch will
optionally retrieve the clock rate of the TWD from an external
clock. A variant of this patch has been proposed by Rob Herring
as well.

The basic idea is to avoid recalibrating the rate of the clock
at boot if the platform already know what rate the clock to the
TWD block has.

ChangeLog v1->v2: added clk_[prepare|unprepare] calls.

[Broke out of larger SMP TWD patch]
Signed-off-by: default avatarColin Cross <ccross@android.com>
Acked-by: default avatarThomas Gleixner <tglx@linutronix.de>
Acked-by: default avatarRob Herring <rob.herring@calxeda.com>
Acked-by: default avatarSantosh Shilimkar <santosh.shilimkar@ti.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Signed-off-by: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
parent 54d15b1d
...@@ -10,8 +10,10 @@ ...@@ -10,8 +10,10 @@
*/ */
#include <linux/init.h> #include <linux/init.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/clk.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/device.h> #include <linux/device.h>
#include <linux/err.h>
#include <linux/smp.h> #include <linux/smp.h>
#include <linux/jiffies.h> #include <linux/jiffies.h>
#include <linux/clockchips.h> #include <linux/clockchips.h>
...@@ -25,6 +27,7 @@ ...@@ -25,6 +27,7 @@
/* set up by the platform code */ /* set up by the platform code */
void __iomem *twd_base; void __iomem *twd_base;
static struct clk *twd_clk;
static unsigned long twd_timer_rate; static unsigned long twd_timer_rate;
static struct clock_event_device __percpu **twd_evt; static struct clock_event_device __percpu **twd_evt;
...@@ -140,6 +143,35 @@ static irqreturn_t twd_handler(int irq, void *dev_id) ...@@ -140,6 +143,35 @@ static irqreturn_t twd_handler(int irq, void *dev_id)
return IRQ_NONE; return IRQ_NONE;
} }
static struct clk *twd_get_clock(void)
{
struct clk *clk;
int err;
clk = clk_get_sys("smp_twd", NULL);
if (IS_ERR(clk)) {
pr_err("smp_twd: clock not found: %d\n", (int)PTR_ERR(clk));
return clk;
}
err = clk_prepare(clk);
if (err) {
pr_err("smp_twd: clock failed to prepare: %d\n", err);
clk_put(clk);
return ERR_PTR(err);
}
err = clk_enable(clk);
if (err) {
pr_err("smp_twd: clock failed to enable: %d\n", err);
clk_unprepare(clk);
clk_put(clk);
return ERR_PTR(err);
}
return clk;
}
/* /*
* Setup the local clock events for a CPU. * Setup the local clock events for a CPU.
*/ */
...@@ -165,6 +197,12 @@ void __cpuinit twd_timer_setup(struct clock_event_device *clk) ...@@ -165,6 +197,12 @@ void __cpuinit twd_timer_setup(struct clock_event_device *clk)
} }
} }
if (!twd_clk)
twd_clk = twd_get_clock();
if (!IS_ERR_OR_NULL(twd_clk))
twd_timer_rate = clk_get_rate(twd_clk);
else
twd_calibrate_rate(); twd_calibrate_rate();
clk->name = "local_timer"; clk->name = "local_timer";
......
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