diff mbox series

[12/17,v1] clocksource/drivers/ixp4xx: Add OF initialization support

Message ID 20190203214205.13594-13-linus.walleij@linaro.org (mailing list archive)
State New, archived
Headers show
Series ARM: ixp4xx: Modernize and DT support | expand

Commit Message

Linus Walleij Feb. 3, 2019, 9:42 p.m. UTC
This adds support for setting up the IXP4xx timer driver from
device tree.

Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
Clocksource/timer maintainers: I am requesting an ACK for
this once you're happy with the driver, as I intend to
merge all of this IXP4xx rework through ARM SoC.
---
 drivers/clocksource/timer-ixp4xx.c | 35 ++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

Comments

Daniel Lezcano Feb. 11, 2019, 11:26 a.m. UTC | #1
On 03/02/2019 22:42, Linus Walleij wrote:
> This adds support for setting up the IXP4xx timer driver from
> device tree.
> 
> Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
> Clocksource/timer maintainers: I am requesting an ACK for
> this once you're happy with the driver, as I intend to
> merge all of this IXP4xx rework through ARM SoC.

Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>

> ---
>  drivers/clocksource/timer-ixp4xx.c | 35 ++++++++++++++++++++++++++++++
>  1 file changed, 35 insertions(+)
> 
> diff --git a/drivers/clocksource/timer-ixp4xx.c b/drivers/clocksource/timer-ixp4xx.c
> index fa78f80792db..404445bc11ea 100644
> --- a/drivers/clocksource/timer-ixp4xx.c
> +++ b/drivers/clocksource/timer-ixp4xx.c
> @@ -16,6 +16,8 @@
>  #include <linux/slab.h>
>  #include <linux/bitops.h>
>  #include <linux/delay.h>
> +#include <linux/of_address.h>
> +#include <linux/of_irq.h>
>  /* Goes away with OF conversion */
>  #include <linux/platform_data/timer-ixp4xx.h>
>  
> @@ -247,3 +249,36 @@ void __init ixp4xx_timer_setup(resource_size_t timerbase,
>  	ixp4xx_timer_register(base, timer_irq, timer_freq);
>  }
>  EXPORT_SYMBOL_GPL(ixp4xx_timer_setup);
> +
> +#ifdef CONFIG_OF
> +static __init int ixp4xx_of_timer_init(struct device_node *np)
> +{
> +	void __iomem *base;
> +	int irq;
> +	int ret;
> +
> +	base = of_iomap(np, 0);
> +	if (!base) {
> +		pr_crit("IXP4xx: can't remap timer\n");
> +		return -ENODEV;
> +	}
> +
> +	irq = irq_of_parse_and_map(np, 0);
> +	if (irq <= 0) {
> +		pr_err("Can't parse IRQ\n");
> +		ret = -EINVAL;
> +		goto out_unmap;
> +	}
> +
> +	/* TODO: get some fixed clocks into the device tree */
> +	ret = ixp4xx_timer_register(base, irq, 66666000);
> +	if (ret)
> +		goto out_unmap;
> +	return 0;
> +
> +out_unmap:
> +	iounmap(base);
> +	return ret;
> +}
> +TIMER_OF_DECLARE(ixp4xx, "intel,ixp4xx-timer", ixp4xx_of_timer_init);
> +#endif
>
diff mbox series

Patch

diff --git a/drivers/clocksource/timer-ixp4xx.c b/drivers/clocksource/timer-ixp4xx.c
index fa78f80792db..404445bc11ea 100644
--- a/drivers/clocksource/timer-ixp4xx.c
+++ b/drivers/clocksource/timer-ixp4xx.c
@@ -16,6 +16,8 @@ 
 #include <linux/slab.h>
 #include <linux/bitops.h>
 #include <linux/delay.h>
+#include <linux/of_address.h>
+#include <linux/of_irq.h>
 /* Goes away with OF conversion */
 #include <linux/platform_data/timer-ixp4xx.h>
 
@@ -247,3 +249,36 @@  void __init ixp4xx_timer_setup(resource_size_t timerbase,
 	ixp4xx_timer_register(base, timer_irq, timer_freq);
 }
 EXPORT_SYMBOL_GPL(ixp4xx_timer_setup);
+
+#ifdef CONFIG_OF
+static __init int ixp4xx_of_timer_init(struct device_node *np)
+{
+	void __iomem *base;
+	int irq;
+	int ret;
+
+	base = of_iomap(np, 0);
+	if (!base) {
+		pr_crit("IXP4xx: can't remap timer\n");
+		return -ENODEV;
+	}
+
+	irq = irq_of_parse_and_map(np, 0);
+	if (irq <= 0) {
+		pr_err("Can't parse IRQ\n");
+		ret = -EINVAL;
+		goto out_unmap;
+	}
+
+	/* TODO: get some fixed clocks into the device tree */
+	ret = ixp4xx_timer_register(base, irq, 66666000);
+	if (ret)
+		goto out_unmap;
+	return 0;
+
+out_unmap:
+	iounmap(base);
+	return ret;
+}
+TIMER_OF_DECLARE(ixp4xx, "intel,ixp4xx-timer", ixp4xx_of_timer_init);
+#endif