Skip to contentSkip to conversation

ARM: u300: device tree support for the timer

PATCH In review Linus Walleij 4 participants 4 messages Apr 22, 2013 – Apr 26, 2013

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 3/23 ARM: u300: device tree support for the timer

From: Linus Walleij <[email protected]>

This adds device tree support for the U300 timer, by making the memory base offset and IRQ dynamically assigned, then optionally looking them up from the device tree.

Since the timer needs to be registered before any platform devices are created, we will go into the device tree and look up the "/timer at c0014000" node and read our base address and IRQ from there.

---
 .../bindings/timer/stericsson-u300-apptimer.txt    | 18 ++++
 arch/arm/mach-u300/timer.c                         | 99 ++++++++++++++--------
 2 files changed, 80 insertions(+), 37 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/timer/stericsson-u300-apptimer.txt
Documentation/devicetree/bindings/timer/stericsson-u300-apptimer.txt new file +18 -0
new file mode 100644
index 0000000..9499bc8
@@ -0,0 +1,18 @@
+ST-Ericsson U300 apptimer
+
+Required properties:
+
+- compatible : should be "stericsson,u300-apptimer"
+- reg : Specifies base physical address and size of the registers.
+- interrupts : A list of 4 interrupts; one for each subtimer. These
+  are, in order: OS (operating system), DD (device driver) both
+  adopted for EPOC/Symbian with two specific IRQs for these tasks,
+  then GP1 and GP2, which are general-purpose timers.
+
+Example:
+
+timer {
+	compatible = "stericsson,u300-apptimer";
+	reg = <0xc0014000 0x1000>;
+	interrupts = <24 25 26 27>;
+};
arch/arm/mach-u300/timer.c +62 -37

228 lines not on this page · raw message

Signature · 1 line
1.7.11.3
#1 lore raw

PATCH 3/23 ARM: u300: device tree support for the timer

arch/arm/mach-u300/timer.c void __init u300_timer_init(void) · line 381

Quoted 12 lines · Linus Walleij
arch/arm/mach-u300/timer.c +12 -0
+#ifdef CONFIG_OF
+       struct device_node *timer = NULL;
+
+       timer = of_find_node_by_path("/timer0 at c0014000");
+       if (timer) {
+               struct resource irq_res;
+
+               u300_timer_base = of_iomap(timer, 0);
+               /* Get the IRQ for the GP1 timer */
+               irq = of_irq_to_resource(timer, 2, &irq_res);
+       }
+#endif

Do you need the #ifdef? The functions should be defined in a way that removes this code if CONFIG_OF is not defined.

Arnd

#2 lore raw

PATCH 3/23 ARM: u300: device tree support for the timer

Quoted 16 lines · Arnd Bergmann

arch/arm/mach-u300/timer.c void __init u300_timer_init(void) · line 381

Quoted 12 lines · Linus Walleij
arch/arm/mach-u300/timer.c +12 -0
+#ifdef CONFIG_OF
+       struct device_node *timer = NULL;
+
+       timer = of_find_node_by_path("/timer0 at c0014000");
+       if (timer) {
+               struct resource irq_res;
+
+               u300_timer_base = of_iomap(timer, 0);
+               /* Get the IRQ for the GP1 timer */
+               irq = of_irq_to_resource(timer, 2, &irq_res);
+       }
+#endif

Do you need the #ifdef? The functions should be defined in a way that removes this code if CONFIG_OF is not defined.

Actually not, this happens without CONFIG_OF:

CC arch/arm/mach-u300/timer.o
/home/elinwal/linux-stericsson/arch/arm/mach-u300/timer.c: In function 'u300_timer_init':
/home/elinwal/linux-stericsson/arch/arm/mach-u300/timer.c:371:2:
error: implicit declaration of function 'of_find_node_by_path' [-Werror=implicit-function-declaration] /home/elinwal/linux-stericsson/arch/arm/mach-u300/timer.c:371:8:
warning: assignment makes pointer from integer without a cast [enabled by default] /home/elinwal/linux-stericsson/arch/arm/mach-u300/timer.c:377:3:
error: implicit declaration of function 'of_irq_to_resource' [-Werror=implicit-function-declaration]
cc1: some warnings being treated as errors

make[3]: *** [arch/arm/mach-u300/timer.o] Error 1
make[2]: *** [arch/arm/mach-u300] Error 2
make[2]: *** Waiting for unfinished jobs....

Maybe it's just a bug that these don't have the proper stubs in <linux/of.h>?

Or is there a deeper idea behind this? (CC some OF ppl.)

Yours,
Linus Walleij

#3 lore raw

PATCH 3/23 ARM: u300: device tree support for the timer

Quoted 34 lines · Linus Walleij
Quoted 16 lines · Arnd Bergmann

arch/arm/mach-u300/timer.c void __init u300_timer_init(void) · line 381

Quoted 12 lines · Linus Walleij
arch/arm/mach-u300/timer.c +12 -0
+#ifdef CONFIG_OF
+       struct device_node *timer = NULL;
+
+       timer = of_find_node_by_path("/timer0 at c0014000");
+       if (timer) {
+               struct resource irq_res;
+
+               u300_timer_base = of_iomap(timer, 0);
+               /* Get the IRQ for the GP1 timer */
+               irq = of_irq_to_resource(timer, 2, &irq_res);
+       }
+#endif

Do you need the #ifdef? The functions should be defined in a way that removes this code if CONFIG_OF is not defined.

Actually not, this happens without CONFIG_OF:

CC arch/arm/mach-u300/timer.o
/home/elinwal/linux-stericsson/arch/arm/mach-u300/timer.c: In function 'u300_timer_init':
/home/elinwal/linux-stericsson/arch/arm/mach-u300/timer.c:371:2:
error: implicit declaration of function 'of_find_node_by_path' [-Werror=implicit-function-declaration] /home/elinwal/linux-stericsson/arch/arm/mach-u300/timer.c:371:8:
warning: assignment makes pointer from integer without a cast [enabled by default] /home/elinwal/linux-stericsson/arch/arm/mach-u300/timer.c:377:3:
error: implicit declaration of function 'of_irq_to_resource' [-Werror=implicit-function-declaration]
cc1: some warnings being treated as errors

Quoted 7 lines

make[3]: *** [arch/arm/mach-u300/timer.o] Error 1
make[2]: *** [arch/arm/mach-u300] Error 2
make[2]: *** Waiting for unfinished jobs....

Maybe it's just a bug that these don't have the proper stubs in <linux/of.h>?

Or is there a deeper idea behind this? (CC some OF ppl.)

Yes, you could add empty function, but searching by path is probably not the right thing to do. Why not use clocksource_of_init? That's what all the cool kids are doing now. Is there some special feature of the timer at this address? If so, then add a property to describe that feature and key off of that plus the compatible prop.

Rob

Quoted 8 lines

Yours,
Linus Walleij
_______________________________________________
devicetree-discuss mailing list
devicetree-discuss at lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss