diff options
author | Michal Simek <michal.simek@xilinx.com> | 2013-08-27 11:52:32 +0200 |
---|---|---|
committer | Michal Simek <michal.simek@xilinx.com> | 2013-09-03 11:27:30 +0200 |
commit | cfd4eaefd0a8d4a7f464f43a11f1be26664385b7 (patch) | |
tree | 9533a1988841cc213c438a77cda65f943378a963 /arch/microblaze/kernel/timer.c | |
parent | 4bcd943ec81052db47465762bef6787b30b81978 (diff) |
microblaze: timer: Clear driver init function
- Use of_iomap
- Use of_property_read_u32
- Fix printk
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Diffstat (limited to 'arch/microblaze/kernel/timer.c')
-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 @@ #include <linux/clocksource.h> #include <linux/clockchips.h> #include <linux/io.h> +#include <linux/of_address.h> #include <linux/bug.h> #include <asm/cpuinfo.h> #include <asm/setup.h> @@ -29,7 +30,7 @@ #include <asm/irq.h> #include <linux/cnt32_to_63.h> -static unsigned int timer_baseaddr; +static void __iomem *timer_baseaddr; static unsigned int freq_div_hz; static unsigned int timer_clock_freq; @@ -242,26 +243,27 @@ static void __init xilinx_timer_init(struct device_node *timer) { u32 irq; u32 timer_num = 1; - const void *prop; + int ret; + + timer_baseaddr = of_iomap(timer, 0); + if (!timer_baseaddr) { + pr_err("ERROR: invalid timer base address\n"); + BUG(); + } - timer_baseaddr = be32_to_cpup(of_get_property(timer, "reg", NULL)); - timer_baseaddr = (unsigned long) ioremap(timer_baseaddr, PAGE_SIZE); irq = irq_of_parse_and_map(timer, 0); - timer_num = be32_to_cpup(of_get_property(timer, - "xlnx,one-timer-only", NULL)); + + of_property_read_u32(timer, "xlnx,one-timer-only", &timer_num); if (timer_num) { - pr_emerg("Please enable two timers in HW\n"); + pr_emerg("Please enable two timers in HW\n"); BUG(); } - pr_info("%s #0 at 0x%08x, irq=%d\n", - timer->name, timer_baseaddr, irq); + pr_info("%s: irq=%d\n", timer->full_name, irq); /* If there is clock-frequency property than use it */ - prop = of_get_property(timer, "clock-frequency", NULL); - if (prop) - timer_clock_freq = be32_to_cpup(prop); - else + ret = of_property_read_u32(timer, "clock-frequency", &timer_clock_freq); + if (ret < 0) timer_clock_freq = cpuinfo.cpu_clock_freq; freq_div_hz = timer_clock_freq / HZ; |