diff options
-rw-r--r-- | arch/microblaze/kernel/timer.c | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/arch/microblaze/kernel/timer.c b/arch/microblaze/kernel/timer.c index 6cb7f3b1914a..e10e0b8548ab 100644 --- a/arch/microblaze/kernel/timer.c +++ b/arch/microblaze/kernel/timer.c | |||
@@ -22,6 +22,7 @@ | |||
22 | #include <linux/clocksource.h> | 22 | #include <linux/clocksource.h> |
23 | #include <linux/clockchips.h> | 23 | #include <linux/clockchips.h> |
24 | #include <linux/io.h> | 24 | #include <linux/io.h> |
25 | #include <linux/of_address.h> | ||
25 | #include <linux/bug.h> | 26 | #include <linux/bug.h> |
26 | #include <asm/cpuinfo.h> | 27 | #include <asm/cpuinfo.h> |
27 | #include <asm/setup.h> | 28 | #include <asm/setup.h> |
@@ -29,7 +30,7 @@ | |||
29 | #include <asm/irq.h> | 30 | #include <asm/irq.h> |
30 | #include <linux/cnt32_to_63.h> | 31 | #include <linux/cnt32_to_63.h> |
31 | 32 | ||
32 | static unsigned int timer_baseaddr; | 33 | static void __iomem *timer_baseaddr; |
33 | 34 | ||
34 | static unsigned int freq_div_hz; | 35 | static unsigned int freq_div_hz; |
35 | static unsigned int timer_clock_freq; | 36 | static unsigned int timer_clock_freq; |
@@ -242,26 +243,27 @@ static void __init xilinx_timer_init(struct device_node *timer) | |||
242 | { | 243 | { |
243 | u32 irq; | 244 | u32 irq; |
244 | u32 timer_num = 1; | 245 | u32 timer_num = 1; |
245 | const void *prop; | 246 | int ret; |
247 | |||
248 | timer_baseaddr = of_iomap(timer, 0); | ||
249 | if (!timer_baseaddr) { | ||
250 | pr_err("ERROR: invalid timer base address\n"); | ||
251 | BUG(); | ||
252 | } | ||
246 | 253 | ||
247 | timer_baseaddr = be32_to_cpup(of_get_property(timer, "reg", NULL)); | ||
248 | timer_baseaddr = (unsigned long) ioremap(timer_baseaddr, PAGE_SIZE); | ||
249 | irq = irq_of_parse_and_map(timer, 0); | 254 | irq = irq_of_parse_and_map(timer, 0); |
250 | timer_num = be32_to_cpup(of_get_property(timer, | 255 | |
251 | "xlnx,one-timer-only", NULL)); | 256 | of_property_read_u32(timer, "xlnx,one-timer-only", &timer_num); |
252 | if (timer_num) { | 257 | if (timer_num) { |
253 | pr_emerg("Please enable two timers in HW\n"); | 258 | pr_emerg("Please enable two timers in HW\n"); |
254 | BUG(); | 259 | BUG(); |
255 | } | 260 | } |
256 | 261 | ||
257 | pr_info("%s #0 at 0x%08x, irq=%d\n", | 262 | pr_info("%s: irq=%d\n", timer->full_name, irq); |
258 | timer->name, timer_baseaddr, irq); | ||
259 | 263 | ||
260 | /* If there is clock-frequency property than use it */ | 264 | /* If there is clock-frequency property than use it */ |
261 | prop = of_get_property(timer, "clock-frequency", NULL); | 265 | ret = of_property_read_u32(timer, "clock-frequency", &timer_clock_freq); |
262 | if (prop) | 266 | if (ret < 0) |
263 | timer_clock_freq = be32_to_cpup(prop); | ||
264 | else | ||
265 | timer_clock_freq = cpuinfo.cpu_clock_freq; | 267 | timer_clock_freq = cpuinfo.cpu_clock_freq; |
266 | 268 | ||
267 | freq_div_hz = timer_clock_freq / HZ; | 269 | freq_div_hz = timer_clock_freq / HZ; |