Skip to content

Commit cfd4eae

Browse files
author
Michal Simek
committed
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>
1 parent 4bcd943 commit cfd4eae

1 file changed

Lines changed: 15 additions & 13 deletions

File tree

‎arch/microblaze/kernel/timer.c‎

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,15 @@
2222
#include <linux/clocksource.h>
2323
#include <linux/clockchips.h>
2424
#include <linux/io.h>
25+
#include <linux/of_address.h>
2526
#include <linux/bug.h>
2627
#include <asm/cpuinfo.h>
2728
#include <asm/setup.h>
2829
#include <asm/prom.h>
2930
#include <asm/irq.h>
3031
#include <linux/cnt32_to_63.h>
3132

32-
static unsigned int timer_baseaddr;
33+
static void __iomem *timer_baseaddr;
3334

3435
static unsigned int freq_div_hz;
3536
static unsigned int timer_clock_freq;
@@ -242,26 +243,27 @@ static void __init xilinx_timer_init(struct device_node *timer)
242243
{
243244
u32 irq;
244245
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+
}
246253

247-
timer_baseaddr = be32_to_cpup(of_get_property(timer, "reg", NULL));
248-
timer_baseaddr = (unsigned long) ioremap(timer_baseaddr, PAGE_SIZE);
249254
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);
252257
if (timer_num) {
253-
pr_emerg("Please enable two timers in HW\n");
258+
pr_emerg("Please enable two timers in HW\n");
254259
BUG();
255260
}
256261

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);
259263

260264
/* 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)
265267
timer_clock_freq = cpuinfo.cpu_clock_freq;
266268

267269
freq_div_hz = timer_clock_freq / HZ;

0 commit comments

Comments
 (0)