|
22 | 22 | #include <linux/clocksource.h> |
23 | 23 | #include <linux/clockchips.h> |
24 | 24 | #include <linux/io.h> |
| 25 | +#include <linux/of_address.h> |
25 | 26 | #include <linux/bug.h> |
26 | 27 | #include <asm/cpuinfo.h> |
27 | 28 | #include <asm/setup.h> |
28 | 29 | #include <asm/prom.h> |
29 | 30 | #include <asm/irq.h> |
30 | 31 | #include <linux/cnt32_to_63.h> |
31 | 32 |
|
32 | | -static unsigned int timer_baseaddr; |
| 33 | +static void __iomem *timer_baseaddr; |
33 | 34 |
|
34 | 35 | static unsigned int freq_div_hz; |
35 | 36 | static unsigned int timer_clock_freq; |
@@ -242,26 +243,27 @@ static void __init xilinx_timer_init(struct device_node *timer) |
242 | 243 | { |
243 | 244 | u32 irq; |
244 | 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 | 254 | irq = irq_of_parse_and_map(timer, 0); |
250 | | - timer_num = be32_to_cpup(of_get_property(timer, |
251 | | - "xlnx,one-timer-only", NULL)); |
| 255 | + |
| 256 | + of_property_read_u32(timer, "xlnx,one-timer-only", &timer_num); |
252 | 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 | 259 | BUG(); |
255 | 260 | } |
256 | 261 |
|
257 | | - pr_info("%s #0 at 0x%08x, irq=%d\n", |
258 | | - timer->name, timer_baseaddr, irq); |
| 262 | + pr_info("%s: irq=%d\n", timer->full_name, irq); |
259 | 263 |
|
260 | 264 | /* If there is clock-frequency property than use it */ |
261 | | - prop = of_get_property(timer, "clock-frequency", NULL); |
262 | | - if (prop) |
263 | | - timer_clock_freq = be32_to_cpup(prop); |
264 | | - else |
| 265 | + ret = of_property_read_u32(timer, "clock-frequency", &timer_clock_freq); |
| 266 | + if (ret < 0) |
265 | 267 | timer_clock_freq = cpuinfo.cpu_clock_freq; |
266 | 268 |
|
267 | 269 | freq_div_hz = timer_clock_freq / HZ; |
|
0 commit comments