Skip to content

Commit 40df14c

Browse files
author
Linus Walleij
committed
clocksource/drivers/ixp4xx: Add OF initialization support
This adds support for setting up the IXP4xx timer driver from device tree. Cc: Thomas Gleixner <tglx@linutronix.de> Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
1 parent 7c23b0e commit 40df14c

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

‎drivers/clocksource/timer-ixp4xx.c‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
#include <linux/slab.h>
1717
#include <linux/bitops.h>
1818
#include <linux/delay.h>
19+
#include <linux/of_address.h>
20+
#include <linux/of_irq.h>
1921
/* Goes away with OF conversion */
2022
#include <linux/platform_data/timer-ixp4xx.h>
2123

@@ -247,3 +249,36 @@ void __init ixp4xx_timer_setup(resource_size_t timerbase,
247249
ixp4xx_timer_register(base, timer_irq, timer_freq);
248250
}
249251
EXPORT_SYMBOL_GPL(ixp4xx_timer_setup);
252+
253+
#ifdef CONFIG_OF
254+
static __init int ixp4xx_of_timer_init(struct device_node *np)
255+
{
256+
void __iomem *base;
257+
int irq;
258+
int ret;
259+
260+
base = of_iomap(np, 0);
261+
if (!base) {
262+
pr_crit("IXP4xx: can't remap timer\n");
263+
return -ENODEV;
264+
}
265+
266+
irq = irq_of_parse_and_map(np, 0);
267+
if (irq <= 0) {
268+
pr_err("Can't parse IRQ\n");
269+
ret = -EINVAL;
270+
goto out_unmap;
271+
}
272+
273+
/* TODO: get some fixed clocks into the device tree */
274+
ret = ixp4xx_timer_register(base, irq, 66666000);
275+
if (ret)
276+
goto out_unmap;
277+
return 0;
278+
279+
out_unmap:
280+
iounmap(base);
281+
return ret;
282+
}
283+
TIMER_OF_DECLARE(ixp4xx, "intel,ixp4xx-timer", ixp4xx_of_timer_init);
284+
#endif

0 commit comments

Comments
 (0)