Skip to contentSkip to conversation

ARM: Kirkwood: Add interrupt controller support for DT boards

PATCH New Andrew Lunn 5 participants 7 messages Jun 10, 2012 – Jun 14, 2012

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

PATCH 1/9 ARM: Kirkwood: Add interrupt controller support for DT boards

---
 .../devicetree/bindings/arm/mrvl/intc.txt          |   20 ++++++++++++++++++
 arch/arm/boot/dts/kirkwood.dtsi                    |    9 ++++++++
 arch/arm/mach-kirkwood/board-dt.c                  |   22 +++++++++++++++++++-
 3 files changed, 50 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/arm/mrvl/intc.txt +20 -0
index 80b9a94..612536e 100644
@@ -38,3 +38,23 @@ Example:
 		reg-names = "mux status", "mux mask";
 		mrvl,intc-nr-irqs = <2>;
 	};
+
+* Marvell Orion Interrupt controller
+
+Required properties
+- compatible :  Should be "marvell,orion-intc"
+- #interrupt-cells: Specifies the number of cells needed to encode an
+  interrupt source. Supported value is <1>
+- interrupt-controller : So that its clear its an interrupt controller.
+Optional properties
+- reg : Not used yet, but will contain the interrupt mask address
+
+Example:
+
+	intc: interrupt-controller {
+        	compatible = "marvell,orion-intc", "marvell,intc";
+		interrupt-controller;
+		#interrupt-cells = <1>;
+                reg = <0xfed20204 0x04>,
+		      <0xfed20214 0x04>;
+        };
arch/arm/boot/dts/kirkwood.dtsi +9 -0
index 926528b..8eab7c4 100644
@@ -2,6 +2,15 @@
 
 / {
 	compatible = "mrvl,kirkwood";
+	interrupt-parent = <&intc>;
+
+	intc: interrupt-controller {
+        	compatible = "marvell,orion-intc", "marvell,intc";
+		interrupt-controller;
+		#interrupt-cells = <1>;
+                reg = <0xfed20204 0x04>,
+		      <0xfed20214 0x04>;
+        };
 
 	ocp at f1000000 {
 		compatible = "simple-bus";
arch/arm/mach-kirkwood/board-dt.c +21 -1
index edc3f8a..fa51586 100644
@@ -14,6 +14,7 @@
 #include <linux/init.h>
 #include <linux/of.h>
 #include <linux/of_platform.h>
+#include <linux/of_irq.h>
 #include <linux/kexec.h>
 #include <asm/mach/arch.h>
 #include <asm/mach/map.h>
@@ -80,11 +81,30 @@ static const char *kirkwood_dt_board_compat[] = {
 	NULL
 };
 
+static int __init kirkwood_add_irq_domain(struct device_node *np,
+					  struct device_node *interrupt_parent)
+{
+	kirkwood_init_irq();
+	irq_domain_add_legacy(np, 64, 0, 0, &irq_domain_simple_ops, NULL);
+	return 0;
+}
+
+static const struct of_device_id kirkwood_irq_match[] = {
+	{ .compatible = "marvell,orion-intc",
+	  .data = kirkwood_add_irq_domain, },
+	{},
+};
+
+static void __init kirkwood_dt_init_irq(void)
+{
+	of_irq_init(kirkwood_irq_match);
+}
+
 DT_MACHINE_START(KIRKWOOD_DT, "Marvell Kirkwood (Flattened Device Tree)")
 	/* Maintainer: Jason Cooper <[email protected]> */
 	.map_io		= kirkwood_map_io,
 	.init_early	= kirkwood_init_early,
-	.init_irq	= kirkwood_init_irq,
+	.init_irq	= kirkwood_dt_init_irq,
 	.timer		= &kirkwood_timer,
 	.init_machine	= kirkwood_dt_init,
 	.restart	= kirkwood_restart,
Signature · 1 line
1.7.10
#1 lore raw

PATCH 1/9 ARM: Kirkwood: Add interrupt controller support for DT boards

Quoted 13 lines · Andrew Lunn
---
 .../devicetree/bindings/arm/mrvl/intc.txt          |   20 ++++++++++++++++++
 arch/arm/boot/dts/kirkwood.dtsi                    |    9 ++++++++
 arch/arm/mach-kirkwood/board-dt.c                  |   22 +++++++++++++++++++-
 3 files changed, 50 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/arm/mrvl/intc.txt +0 -0
index 80b9a94..612536e 100644
@@ -38,3 +38,23 @@ Example:
 		reg-names = "mux status", "mux mask";

Documentation/devicetree/bindings/arm/mrvl/intc.txt Example: · line 48

Quoted 10 lines
Documentation/devicetree/bindings/arm/mrvl/intc.txt +8 -0
 		mrvl,intc-nr-irqs = <2>;
 	};
+
+* Marvell Orion Interrupt controller
+
+Required properties
+- compatible :  Should be "marvell,orion-intc"
+- #interrupt-cells: Specifies the number of cells needed to encode an
+  interrupt source. Supported value is <1>
+- interrupt-controller : So that its clear its an interrupt controller.

nit. "Declare this node to be an interrupt controller." If you end up doing a v2 for other reasons, go ahead and add this. Otherwise, don't worry about it.

Quoted 79 lines
Documentation/devicetree/bindings/arm/mrvl/intc.txt +12 -0
+Optional properties
+- reg : Not used yet, but will contain the interrupt mask address
+
+Example:
+
+	intc: interrupt-controller {
+        	compatible = "marvell,orion-intc", "marvell,intc";
+		interrupt-controller;
+		#interrupt-cells = <1>;
+                reg = <0xfed20204 0x04>,
+		      <0xfed20214 0x04>;
+        };
arch/arm/boot/dts/kirkwood.dtsi +9 -0
index 926528b..8eab7c4 100644
@@ -2,6 +2,15 @@
 
 / {
 	compatible = "mrvl,kirkwood";
+	interrupt-parent = <&intc>;
+
+	intc: interrupt-controller {
+        	compatible = "marvell,orion-intc", "marvell,intc";
+		interrupt-controller;
+		#interrupt-cells = <1>;
+                reg = <0xfed20204 0x04>,
+		      <0xfed20214 0x04>;
+        };
 
 	ocp at f1000000 {
 		compatible = "simple-bus";
arch/arm/mach-kirkwood/board-dt.c +21 -1
index edc3f8a..fa51586 100644
@@ -14,6 +14,7 @@
 #include <linux/init.h>
 #include <linux/of.h>
 #include <linux/of_platform.h>
+#include <linux/of_irq.h>
 #include <linux/kexec.h>
 #include <asm/mach/arch.h>
 #include <asm/mach/map.h>
@@ -80,11 +81,30 @@ static const char *kirkwood_dt_board_compat[] = {
 	NULL
 };
 
+static int __init kirkwood_add_irq_domain(struct device_node *np,
+					  struct device_node *interrupt_parent)
+{
+	kirkwood_init_irq();
+	irq_domain_add_legacy(np, 64, 0, 0, &irq_domain_simple_ops, NULL);
+	return 0;
+}
+
+static const struct of_device_id kirkwood_irq_match[] = {
+	{ .compatible = "marvell,orion-intc",
+	  .data = kirkwood_add_irq_domain, },
+	{},
+};
+
+static void __init kirkwood_dt_init_irq(void)
+{
+	of_irq_init(kirkwood_irq_match);
+}
+
 DT_MACHINE_START(KIRKWOOD_DT, "Marvell Kirkwood (Flattened Device Tree)")
 	/* Maintainer: Jason Cooper <[email protected]> */
 	.map_io		= kirkwood_map_io,
 	.init_early	= kirkwood_init_early,
-	.init_irq	= kirkwood_init_irq,
+	.init_irq	= kirkwood_dt_init_irq,
 	.timer		= &kirkwood_timer,
 	.init_machine	= kirkwood_dt_init,
 	.restart	= kirkwood_restart,
Signature · 1 line
1.7.10

Looks good.

I'll add Tested-by: once I get a chance.

thx,

Jason.

#2 lore raw

PATCH 1/9 ARM: Kirkwood: Add interrupt controller support for DT boards

In reply to Andrew Lunn

Am Sonntag 10 Juni 2012, 12:31:53 schrieb Andrew Lunn:

Quoted 26 lines
---
 .../devicetree/bindings/arm/mrvl/intc.txt          |   20

++++++++++++++++++ arch/arm/boot/dts/kirkwood.dtsi |
9 ++++++++ arch/arm/mach-kirkwood/board-dt.c | 22
+++++++++++++++++++- 3 files changed, 50 insertions(+), 1 deletion(-)

(quoted diff) +0 -0

b/Documentation/devicetree/bindings/arm/mrvl/intc.txt index 80b9a94..612536e 100644

Documentation/devicetree/bindings/arm/mrvl/intc.txt +10 -0
@@ -38,3 +38,23 @@ Example:
 		reg-names = "mux status", "mux mask";
 		mrvl,intc-nr-irqs = <2>;
 	};
+
+* Marvell Orion Interrupt controller
+
+Required properties
+- compatible :  Should be "marvell,orion-intc"
+- #interrupt-cells: Specifies the number of cells needed to encode an
+  interrupt source. Supported value is <1>
+- interrupt-controller : So that its clear its an interrupt controller.
+Optional properties
+- reg : Not used yet, but will contain the interrupt mask address

Documentation/devicetree/bindings/arm/mrvl/intc.txt Example: · line 60

Quoted 10 lines
Documentation/devicetree/bindings/arm/mrvl/intc.txt +10 -0
+
+Example:
+
+	intc: interrupt-controller {
+        	compatible = "marvell,orion-intc", "marvell,intc";
+		interrupt-controller;
+		#interrupt-cells = <1>;
+                reg = <0xfed20204 0x04>,
+		      <0xfed20214 0x04>;
+        };

please fix whitespaces/tabs

Quoted 7 lines
(quoted diff) +0 -0

b/arch/arm/boot/dts/kirkwood.dtsi index 926528b..8eab7c4 100644

arch/arm/boot/dts/kirkwood.dtsi +0 -0
@@ -2,6 +2,15 @@
 
 / {

arch/arm/boot/dts/kirkwood.dtsi line 13

Quoted 10 lines
arch/arm/boot/dts/kirkwood.dtsi +9 -0
 	compatible = "mrvl,kirkwood";
+	interrupt-parent = <&intc>;
+
+	intc: interrupt-controller {
+        	compatible = "marvell,orion-intc", "marvell,intc";
+		interrupt-controller;
+		#interrupt-cells = <1>;
+                reg = <0xfed20204 0x04>,
+		      <0xfed20214 0x04>;
+        };

ditto

Signature · 1 line
Michael
#3 lore raw

PATCH 1/9 ARM: Kirkwood: Add interrupt controller support for DT boards

In reply to Andrew Lunn
Quoted 68 lines · Andrew Lunn
---
 .../devicetree/bindings/arm/mrvl/intc.txt          |   20 ++++++++++++++++++
 arch/arm/boot/dts/kirkwood.dtsi                    |    9 ++++++++
 arch/arm/mach-kirkwood/board-dt.c                  |   22 +++++++++++++++++++-
 3 files changed, 50 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/arm/mrvl/intc.txt +20 -0
index 80b9a94..612536e 100644
@@ -38,3 +38,23 @@ Example:
 		reg-names = "mux status", "mux mask";
 		mrvl,intc-nr-irqs = <2>;
 	};
+
+* Marvell Orion Interrupt controller
+
+Required properties
+- compatible :  Should be "marvell,orion-intc"
+- #interrupt-cells: Specifies the number of cells needed to encode an
+  interrupt source. Supported value is <1>
+- interrupt-controller : So that its clear its an interrupt controller.
+Optional properties
+- reg : Not used yet, but will contain the interrupt mask address
+
+Example:
+
+	intc: interrupt-controller {
+        	compatible = "marvell,orion-intc", "marvell,intc";
+		interrupt-controller;
+		#interrupt-cells = <1>;
+                reg = <0xfed20204 0x04>,
+		      <0xfed20214 0x04>;
+        };
arch/arm/boot/dts/kirkwood.dtsi +9 -0
index 926528b..8eab7c4 100644
@@ -2,6 +2,15 @@
 
 / {
 	compatible = "mrvl,kirkwood";
+	interrupt-parent = <&intc>;
+
+	intc: interrupt-controller {
+        	compatible = "marvell,orion-intc", "marvell,intc";
+		interrupt-controller;
+		#interrupt-cells = <1>;
+                reg = <0xfed20204 0x04>,
+		      <0xfed20214 0x04>;
+        };
 
 	ocp at f1000000 {
 		compatible = "simple-bus";
arch/arm/mach-kirkwood/board-dt.c +1 -0
index edc3f8a..fa51586 100644
@@ -14,6 +14,7 @@
 #include <linux/init.h>
 #include <linux/of.h>
 #include <linux/of_platform.h>
+#include <linux/of_irq.h>
 #include <linux/kexec.h>
 #include <asm/mach/arch.h>
 #include <asm/mach/map.h>

arch/arm/mach-kirkwood/board-dt.c static const char *kirkwood_dt_board_compat[] = { · line 88

Quoted 8 lines
arch/arm/mach-kirkwood/board-dt.c +5 -0
@@ -80,11 +81,30 @@ static const char *kirkwood_dt_board_compat[] = {
 	NULL
 };
 
+static int __init kirkwood_add_irq_domain(struct device_node *np,
+					  struct device_node *interrupt_parent)
+{
+	kirkwood_init_irq();
+	irq_domain_add_legacy(np, 64, 0, 0, &irq_domain_simple_ops, NULL);

The irqdomain should really be integrated into the interrupt controller itself rather than bolted on top and doesn't need to be DT only. In the process, use irq_data.hwirq rather than fixed Linux virq to hwirq conversion.

Once all interrupts are bound using DT, a linear domain should be used. But that may take some time.

Rob

Quoted 23 lines
arch/arm/mach-kirkwood/board-dt.c +15 -1
+	return 0;
+}rob.herring at calxeda.com
+
+static const struct of_device_id kirkwood_irq_match[] = {
+	{ .compatible = "marvell,orion-intc",
+	  .data = kirkwood_add_irq_domain, },
+	{},
+};
+
+static void __init kirkwood_dt_init_irq(void)
+{
+	of_irq_init(kirkwood_irq_match);
+}
+
 DT_MACHINE_START(KIRKWOOD_DT, "Marvell Kirkwood (Flattened Device Tree)")
 	/* Maintainer: Jason Cooper <[email protected]> */
 	.map_io		= kirkwood_map_io,
 	.init_early	= kirkwood_init_early,
-	.init_irq	= kirkwood_init_irq,
+	.init_irq	= kirkwood_dt_init_irq,
 	.timer		= &kirkwood_timer,
 	.init_machine	= kirkwood_dt_init,
 	.restart	= kirkwood_restart,
#4 lore raw

PATCH 1/9 ARM: Kirkwood: Add interrupt controller support for DT boards

In reply to Andrew Lunn
Quoted 9 lines · Andrew Lunn
arch/arm/mach-kirkwood/board-dt.c +9 -0
+static int __init kirkwood_add_irq_domain(struct device_node *np,
+                                         struct device_node *interrupt_parent)
+{
+       kirkwood_init_irq();
+       irq_domain_add_legacy(np, 64, 0, 0, &irq_domain_simple_ops, NULL);
+       return 0;
+}
+
+static const struct of_device_id kirkwood_irq_match[] = {

arch/arm/mach-kirkwood/board-dt.c static const char *kirkwood_dt_board_compat[] = { · line 102

Quoted 10 lines
arch/arm/mach-kirkwood/board-dt.c +10 -0
+       { .compatible = "marvell,orion-intc",
+         .data = kirkwood_add_irq_domain, },
+       {},
+};
+
+static void __init kirkwood_dt_init_irq(void)
+{
+       of_irq_init(kirkwood_irq_match);
+}
+

I think if you compute the number of interrupts in the domain from the number of registers that are described in the device tree, call orion_irq_init() based on those registers, and use irq domains for the gpio stuff as Rob suggested, this init_irq function can become completely generic to all orion platforms.

That is what I tried to do with an earlier patch, which was flawed for other reasons.

Arnd

#5 lore raw

PATCH 1/9 ARM: Kirkwood: Add interrupt controller support for DT boards

Quoted 17 lines · Arnd Bergmann
Quoted 16 lines · Andrew Lunn
arch/arm/mach-kirkwood/board-dt.c +16 -0
+static int __init kirkwood_add_irq_domain(struct device_node *np,
+                                         struct device_node *interrupt_parent)
+{
+       kirkwood_init_irq();
+       irq_domain_add_legacy(np, 64, 0, 0, &irq_domain_simple_ops, NULL);
+       return 0;
+}
+
+static const struct of_device_id kirkwood_irq_match[] = {
+       { .compatible = "marvell,orion-intc",
+         .data = kirkwood_add_irq_domain, },
+       {},
+};
+
+static void __init kirkwood_dt_init_irq(void)
+{
Quoted 8 lines

arch/arm/mach-kirkwood/board-dt.c static const char *kirkwood_dt_board_compat[] = { · line 102

Quoted 3 lines
arch/arm/mach-kirkwood/board-dt.c +3 -0
+       of_irq_init(kirkwood_irq_match);
+}
+

I think if you compute the number of interrupts in the domain from the number of registers that are described in the device tree, call orion_irq_init() based on those registers, and use irq domains for the gpio stuff as Rob suggested, this init_irq function can become completely generic to all orion platforms.

I'm reworking the GPIO stuff at the moment, moving it to use IRQ domains for its interrupts. That code will be generic to all Orion platforms. I'm modeling the code on the AT91 GPIO handler, since that has a similar structure, one hardware interrupt for a number of GPIO lines, which is in software demultiplexed and triggers secondary level interrupts. The major difference is that AT91 has one hardware interrupt for a GPIO chip with 32 lines, where as Orion has 4 hardware interrupt lines, so maybe four interrupt domains, for one GPIO chip with 32 lines.

Non-GPIO interrupts are more of a problem. Underneath it uses the generic-chip interrupt code. The patchset to add _domain versions of these calls is stalled. So i think for the moment, we need to stay with the domain bolted on top, until generic-chip gets domain support. I would also expect that generic-chip also gets a common DT binding which any SoC can use.

My aim at the moment is to get something which works well enough that we can add DT support to other drivers. Without interrupts, we are not going to get very far. We can later rip it out what i create now and replace it once generic-chip becomes domain and DT aware, and there should be no effect on other drivers.

Andrew

#6 lore raw

PATCH 1/9 ARM: Kirkwood: Add interrupt controller support for DT boards

Quoted 5 lines · Andrew Lunn
Quoted 4 lines

I think if you compute the number of interrupts in the domain from the number of registers that are described in the device tree, call orion_irq_init() based on those registers, and use irq domains for the gpio stuff as Rob suggested, this init_irq function can become completely generic to all orion platforms.

Quoted 9 lines

I'm reworking the GPIO stuff at the moment, moving it to use IRQ domains for its interrupts. That code will be generic to all Orion platforms. I'm modeling the code on the AT91 GPIO handler, since that has a similar structure, one hardware interrupt for a number of GPIO lines, which is in software demultiplexed and triggers secondary level interrupts. The major difference is that AT91 has one hardware interrupt for a GPIO chip with 32 lines, where as Orion has 4 hardware interrupt lines, so maybe four interrupt domains, for one GPIO chip with 32 lines.

My guess is that you're still better off with a single interrupt domain for 32 lines, or even for all the gpio lines, but I'm sure you can find a solution that works best for you.

Quoted 6 lines

Non-GPIO interrupts are more of a problem. Underneath it uses the generic-chip interrupt code. The patchset to add _domain versions of these calls is stalled. So i think for the moment, we need to stay with the domain bolted on top, until generic-chip gets domain support. I would also expect that generic-chip also gets a common DT binding which any SoC can use.

I suggested that before, and the comments I got back then were that we should treat the generic irq chip more like a library and keep the device tree binding at a higher level. If I understood things right, that means we would just have one plat-orion (or mach-mvebu later) irq chip abstraction that handles the DT binding and the irq domains itself but uses the generic irq chip code to implement the actual irq handling.

Quoted 5 lines

My aim at the moment is to get something which works well enough that we can add DT support to other drivers. Without interrupts, we are not going to get very far. We can later rip it out what i create now and replace it once generic-chip becomes domain and DT aware, and there should be no effect on other drivers.

Right. I just want to ensure that we don't need to change the bindings in incompatible ways.

Arnd