aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorHeiko Stuebner <heiko@sntech.de>2013-06-04 05:37:36 -0400
committerHeiko Stuebner <heiko@sntech.de>2013-06-12 07:47:22 -0400
commita8b447f2bbbba737ff4478f498d7f83c75a9461b (patch)
treeb68792f27524250d1a9d3267ef3cf80f7a3cc946 /drivers
parenta1198f83407ae3421f3f58355a0f296d5ea6249c (diff)
clocksource: dw_apb_timer_of: add clock-handling
Add the possibility to get the clock-frequency from a timer clock instead of specifying it as dt property. Additionally also add the possibility to also define a controlling periphal clock for the timer block. The clock-frequency property is kept to act as fallback if no clocks are specified. Signed-off-by: Heiko Stuebner <heiko@sntech.de> Acked-by: Jamie Iles <jamie@jamieiles.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/clocksource/dw_apb_timer_of.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/drivers/clocksource/dw_apb_timer_of.c b/drivers/clocksource/dw_apb_timer_of.c
index d6c0fda76a7e..1964f8716966 100644
--- a/drivers/clocksource/dw_apb_timer_of.c
+++ b/drivers/clocksource/dw_apb_timer_of.c
@@ -20,6 +20,7 @@
20#include <linux/of.h> 20#include <linux/of.h>
21#include <linux/of_address.h> 21#include <linux/of_address.h>
22#include <linux/of_irq.h> 22#include <linux/of_irq.h>
23#include <linux/clk.h>
23 24
24#include <asm/mach/time.h> 25#include <asm/mach/time.h>
25#include <asm/sched_clock.h> 26#include <asm/sched_clock.h>
@@ -27,14 +28,37 @@
27static void timer_get_base_and_rate(struct device_node *np, 28static void timer_get_base_and_rate(struct device_node *np,
28 void __iomem **base, u32 *rate) 29 void __iomem **base, u32 *rate)
29{ 30{
31 struct clk *timer_clk;
32 struct clk *pclk;
33
30 *base = of_iomap(np, 0); 34 *base = of_iomap(np, 0);
31 35
32 if (!*base) 36 if (!*base)
33 panic("Unable to map regs for %s", np->name); 37 panic("Unable to map regs for %s", np->name);
34 38
39 /*
40 * Not all implementations use a periphal clock, so don't panic
41 * if it's not present
42 */
43 pclk = of_clk_get_by_name(np, "pclk");
44 if (!IS_ERR(pclk))
45 if (clk_prepare_enable(pclk))
46 pr_warn("pclk for %s is present, but could not be activated\n",
47 np->name);
48
49 timer_clk = of_clk_get_by_name(np, "timer");
50 if (IS_ERR(timer_clk))
51 goto try_clock_freq;
52
53 if (!clk_prepare_enable(timer_clk)) {
54 *rate = clk_get_rate(timer_clk);
55 return;
56 }
57
58try_clock_freq:
35 if (of_property_read_u32(np, "clock-freq", rate) && 59 if (of_property_read_u32(np, "clock-freq", rate) &&
36 of_property_read_u32(np, "clock-frequency", rate)) 60 of_property_read_u32(np, "clock-frequency", rate))
37 panic("No clock-frequency property for %s", np->name); 61 panic("No clock nor clock-frequency property for %s", np->name);
38} 62}
39 63
40static void add_clockevent(struct device_node *event_timer) 64static void add_clockevent(struct device_node *event_timer)