diff options
Diffstat (limited to 'drivers/clocksource')
-rw-r--r-- | drivers/clocksource/dw_apb_timer_of.c | 26 |
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 @@ | |||
27 | static void timer_get_base_and_rate(struct device_node *np, | 28 | static 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 | |||
58 | try_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 | ||
40 | static void add_clockevent(struct device_node *event_timer) | 64 | static void add_clockevent(struct device_node *event_timer) |