Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 279797
b: refs/heads/master
c: 5def51b
h: refs/heads/master
i:
  279795: 431f590
v: v3
  • Loading branch information
Linus Walleij authored and Russell King committed Dec 23, 2011
1 parent 773c3a9 commit d79b14d
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 54d15b1d7ac550ecd8ab6b04309c2def614f8c80
refs/heads/master: 5def51b0f827931bb559e6195060d774894fc9f9
40 changes: 39 additions & 1 deletion trunk/arch/arm/kernel/smp_twd.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
*/
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/clk.h>
#include <linux/delay.h>
#include <linux/device.h>
#include <linux/err.h>
#include <linux/smp.h>
#include <linux/jiffies.h>
#include <linux/clockchips.h>
Expand All @@ -25,6 +27,7 @@
/* set up by the platform code */
void __iomem *twd_base;

static struct clk *twd_clk;
static unsigned long twd_timer_rate;

static struct clock_event_device __percpu **twd_evt;
Expand Down Expand Up @@ -140,6 +143,35 @@ static irqreturn_t twd_handler(int irq, void *dev_id)
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.
*/
Expand All @@ -165,7 +197,13 @@ void __cpuinit twd_timer_setup(struct clock_event_device *clk)
}
}

twd_calibrate_rate();
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();

clk->name = "local_timer";
clk->features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT |
Expand Down

0 comments on commit d79b14d

Please sign in to comment.