Skip to contentSkip to conversation

Add device tree based initialisation for VIC

PATCH New Jamie Iles 2 participants 10 messages Jul 25, 2011 – Jul 31, 2011

Subsystems (5)
lore
Share & tools
lore

Jamie Iles

author
#0 lore raw

cover Add device tree based initialisation for VIC

This series aims to allow VIC devices to be probed from the device tree. Currently the only in-tree device tree enabled user of the VIC is versatile, but I'll shortly submit patches for picoxcell on device tree that uses 2 VIC's.

I've split this into 3 patches for bisectability, but this could be fairly squashed into 2.

Jamie Iles (3):
vic: add device tree bindings
versatile dt: set the irq-start property for the vic
versatile: convert to common VIC DT probing

 Documentation/devicetree/bindings/arm/vic.txt |   21 +++++++++++++++
 arch/arm/boot/dts/versatile-ab.dts            |    1 +
 arch/arm/common/vic.c                         |   35 +++++++++++++++++++++++++
 arch/arm/include/asm/hardware/vic.h           |    5 +++
 arch/arm/mach-versatile/core.c                |    9 +-----
 5 files changed, 63 insertions(+), 8 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/arm/vic.txt
Signature · 1 line
1.7.4.1
author
#1 lore raw

PATCH 1/3 vic: add device tree bindings

Allow the VIC to be used from device tree. This adds vic_of_init() that finds all compatible controllers in the device tree creating irq domains and initialising the VIC.

We use of_iomap() for the IO mapping, but allow the entry functions in arch/arm/include/asm/entry-macro-vic2.S to be used, this requires that a static mapping is configured on the platform.

Cc Russell King <[email protected]>
Cc devicetree-discuss at lists.ozlabs.org
---
 Documentation/devicetree/bindings/arm/vic.txt |   21 +++++++++++++++
 arch/arm/common/vic.c                         |   35 +++++++++++++++++++++++++
 arch/arm/include/asm/hardware/vic.h           |    5 +++
 3 files changed, 61 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/arm/vic.txt
Documentation/devicetree/bindings/arm/vic.txt new file +21 -0
new file mode 100644
index 0000000..be5abc9
@@ -0,0 +1,21 @@
+ARM Vectored Interrupt Controller
+
+Some ARM cores may contain a vectored interrupt controller (VIC).  This
+controller is represented in the device tree with:
+
+Required properties:
+  - #interrupt-cells : <1> (32 interrupt sources supported)
+  - compatible : "arm,pl190-vic", "arm,pl192-vic", "arm-vic"
+  - reg : Offset and length of the register set for this device
+  - interrupt-controller
+  - irq-start : The first interrupt number that the VIC services
+
+Example ARM VIC node:
+
+vic0 at 60000 {
+	compatible = "arm,pl192-vic";
+	interrupt-controller;
+	reg = <0x60000 0x1000>;
+	irq-start = <32>;
+	#interrupt-cells = <1>;
+};
arch/arm/common/vic.c +35 -0
index 7aa4262..5838b9f 100644
@@ -25,6 +25,9 @@
 #include <linux/syscore_ops.h>
 #include <linux/device.h>
 #include <linux/amba/bus.h>
+#include <linux/of.h>
+#include <linux/of_address.h>
+#include <linux/of_irq.h>
 
 #include <asm/mach/irq.h>
 #include <asm/hardware/vic.h>
@@ -377,3 +380,35 @@ void __init vic_init(void __iomem *base, unsigned int irq_start,
 
 	vic_pm_register(base, irq_start, resume_sources);
 }
+
+#ifdef CONFIG_OF
+static const struct of_device_id arm_vic_ids[] __initconst = {
+	{ .compatible = "arm,pl190-vic" },
+	{ .compatible = "arm,pl192-vic" },
+	{ .compatible = "arm,vic" },
+	{},
+};
+
+void __init vic_of_init(void)
+{
+	struct device_node *np;
+
+	for_each_matching_node(np, arm_vic_ids) {
+		void __iomem *iobase;
+		u32 base_irq;
+
+		iobase = of_iomap(np, 0);
+
+		if (!iobase)
+			panic("Unable to map VIC");
+
+		if (of_property_read_u32(np, "irq-start", &base_irq))
+			panic("No irq-start property defined");
+
+		of_node_put(np);
+
+		vic_init(iobase, base_irq, ~0, 0);
+		irq_domain_add_simple(np, base_irq);
+	}
+}
+#endif /* CONFIG_OF */
arch/arm/include/asm/hardware/vic.h +5 -0
index 5d72550..dbda2d1 100644
@@ -42,6 +42,11 @@
 
 #ifndef __ASSEMBLY__
 void vic_init(void __iomem *base, unsigned int irq_start, u32 vic_sources, u32 resume_sources);
+#ifdef CONFIG_OF
+void vic_of_init(void);
+#else /* CONFIG_OF */
+static inline void vic_of_init(void) {}
+#endif /* CONFIG_OF */
 #endif
 
 #endif
Signature · 1 line
1.7.4.1
#2 lore raw

PATCH 1/3 vic: add device tree bindings

Quoted 8 lines · Jamie Iles

Allow the VIC to be used from device tree. This adds vic_of_init() that finds all compatible controllers in the device tree creating irq domains and initialising the VIC.

We use of_iomap() for the IO mapping, but allow the entry functions in arch/arm/include/asm/entry-macro-vic2.S to be used, this requires that a static mapping is configured on the platform.

Quoted 5 lines
Cc Russell King <[email protected]>
Cc devicetree-discuss at lists.ozlabs.org
---
 Documentation/devicetree/bindings/arm/vic.txt |   21 +++++++++++++++

Yay! Thanks for documenting!

Quoted 11 lines
 arch/arm/common/vic.c                         |   35 +++++++++++++++++++++++++
 arch/arm/include/asm/hardware/vic.h           |    5 +++
 3 files changed, 61 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/arm/vic.txt
Documentation/devicetree/bindings/arm/vic.txt new file +0 -0
new file mode 100644
index 0000000..be5abc9

Documentation/devicetree/bindings/arm/vic.txt line 7

Quoted 7 lines
Documentation/devicetree/bindings/arm/vic.txt new file +7 -0
@@ -0,0 +1,21 @@
+ARM Vectored Interrupt Controller
+
+Some ARM cores may contain a vectored interrupt controller (VIC).  This
+controller is represented in the device tree with:
+
+Required properties:
+  - #interrupt-cells : <1> (32 interrupt sources supported)

Does the vic have any configuration for level/edge or polarity?

Documentation/devicetree/bindings/arm/vic.txt line 8

Quoted 1 line
Documentation/devicetree/bindings/arm/vic.txt new file +1 -0
+  - compatible : "arm,pl190-vic", "arm,pl192-vic", "arm-vic"

drop "arm-vic". Compatible values should always be specific to an implementation, preferably to a specific version of hardware, although I'm also okay with an IP core name if the version if the core is provided.

Documentation/devicetree/bindings/arm/vic.txt line 11

Quoted 3 lines
Documentation/devicetree/bindings/arm/vic.txt new file +3 -0
+  - reg : Offset and length of the register set for this device
+  - interrupt-controller
+  - irq-start : The first interrupt number that the VIC services

Drop irq-start, it should not be needed. The interrupt controller should allocate its own range of irq numbers when it is set up.

Quoted 39 lines
Documentation/devicetree/bindings/arm/vic.txt new file +10 -0
+
+Example ARM VIC node:
+
+vic0 at 60000 {
+	compatible = "arm,pl192-vic";
+	interrupt-controller;
+	reg = <0x60000 0x1000>;
+	irq-start = <32>;
+	#interrupt-cells = <1>;
+};
arch/arm/common/vic.c +14 -0
index 7aa4262..5838b9f 100644
@@ -25,6 +25,9 @@
 #include <linux/syscore_ops.h>
 #include <linux/device.h>
 #include <linux/amba/bus.h>
+#include <linux/of.h>
+#include <linux/of_address.h>
+#include <linux/of_irq.h>
 
 #include <asm/mach/irq.h>
 #include <asm/hardware/vic.h>
@@ -377,3 +380,35 @@ void __init vic_init(void __iomem *base, unsigned int irq_start,
 
 	vic_pm_register(base, irq_start, resume_sources);
 }
+
+#ifdef CONFIG_OF
+static const struct of_device_id arm_vic_ids[] __initconst = {
+	{ .compatible = "arm,pl190-vic" },
+	{ .compatible = "arm,pl192-vic" },
+	{ .compatible = "arm,vic" },
+	{},
+};
+
+void __init vic_of_init(void)
+{

arch/arm/common/vic.c void __init vic_init(void __iomem *base, unsigned int irq_start, · line 403

Quoted 10 lines
arch/arm/common/vic.c +10 -0
+	struct device_node *np;
+
+	for_each_matching_node(np, arm_vic_ids) {
+		void __iomem *iobase;
+		u32 base_irq;
+
+		iobase = of_iomap(np, 0);
+
+		if (!iobase)
+			panic("Unable to map VIC");

If you WARN here instead, then there is a much greater chance of actually getting output to the user.

arch/arm/common/vic.c void __init vic_init(void __iomem *base, unsigned int irq_start, · line 411

Quoted 8 lines
arch/arm/common/vic.c +8 -0
+
+		if (of_property_read_u32(np, "irq-start", &base_irq))
+			panic("No irq-start property defined");
+
+		of_node_put(np);
+
+		vic_init(iobase, base_irq, ~0, 0);
+		irq_domain_add_simple(np, base_irq);

irq_domain_add_simple() is a stop-gap shortcut for interrupt controllers that don't use irq_domain directly. I'm okay with doing this in the short term, but I imagine it will want to change in the near future to take advantage of hw->linux irq translation provided by irq_domain when it matures.

arch/arm/common/vic.c void __init vic_init(void __iomem *base, unsigned int irq_start, · line 412

Quoted 1 line
arch/arm/common/vic.c +1 -0
+	}

I think that rather than writing a interrupt-controller-specific parse route like this one, it would be much better to have a generic helper that finds and sorts all the interrupt controllers before calling a setup callback for each one.

Quoted 25 lines
arch/arm/common/vic.c +2 -0
+}
+#endif /* CONFIG_OF */
arch/arm/include/asm/hardware/vic.h +5 -0
index 5d72550..dbda2d1 100644
@@ -42,6 +42,11 @@
 
 #ifndef __ASSEMBLY__
 void vic_init(void __iomem *base, unsigned int irq_start, u32 vic_sources, u32 resume_sources);
+#ifdef CONFIG_OF
+void vic_of_init(void);
+#else /* CONFIG_OF */
+static inline void vic_of_init(void) {}
+#endif /* CONFIG_OF */
 #endif
 
 #endif
Signature · 6 lines
1.7.4.1

_______________________________________________
devicetree-discuss mailing list
devicetree-discuss at lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss
author
#3 lore raw

PATCH 1/3 vic: add device tree bindings

Hi Grant,

Quoted 1 line · Grant Likely

On Mon, Jul 25, 2011 at 05:09:58PM +0100, Jamie Iles wrote:

[...]

Quoted 5 lines
Quoted 5 lines
 arch/arm/common/vic.c                         |   35 +++++++++++++++++++++++++
 arch/arm/include/asm/hardware/vic.h           |    5 +++
 3 files changed, 61 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/arm/vic.txt
Quoted 15 lines

Documentation/devicetree/bindings/arm/vic.txt line 7

Quoted 13 lines
Documentation/devicetree/bindings/arm/vic.txt new file +7 -0
new file mode 100644
index 0000000..be5abc9
@@ -0,0 +1,21 @@
+ARM Vectored Interrupt Controller
+
+Some ARM cores may contain a vectored interrupt controller (VIC).  This
+controller is represented in the device tree with:
+
+Required properties:
+  - #interrupt-cells : <1> (32 interrupt sources supported)

Does the vic have any configuration for level/edge or polarity?

No, there's no configuration of this type.

Quoted 6 lines

Documentation/devicetree/bindings/arm/vic.txt line 8

Quoted 1 line
Documentation/devicetree/bindings/arm/vic.txt new file +1 -0
+  - compatible : "arm,pl190-vic", "arm,pl192-vic", "arm-vic"

drop "arm-vic". Compatible values should always be specific to an implementation, preferably to a specific version of hardware, although I'm also okay with an IP core name if the version if the core is provided.

OK, fair point. Versatile currently uses arm-vic but I'm not sure what part it actually is as I don't have access to that platform.

Quoted 6 lines

Documentation/devicetree/bindings/arm/vic.txt line 11

Quoted 3 lines
Documentation/devicetree/bindings/arm/vic.txt new file +3 -0
+  - reg : Offset and length of the register set for this device
+  - interrupt-controller
+  - irq-start : The first interrupt number that the VIC services

Drop irq-start, it should not be needed. The interrupt controller should allocate its own range of irq numbers when it is set up.

So the reason I have this is in our system (and I believe others too including some samsung parts), the vic's aren't cascaded so I'm not sure how the entry macros would resolve the outputs from each vic correctly. Perhaps I'm missing something here though.

Quoted 44 lines
Quoted 44 lines
Documentation/devicetree/bindings/arm/vic.txt new file +10 -0
+
+Example ARM VIC node:
+
+vic0 at 60000 {
+	compatible = "arm,pl192-vic";
+	interrupt-controller;
+	reg = <0x60000 0x1000>;
+	irq-start = <32>;
+	#interrupt-cells = <1>;
+};
arch/arm/common/vic.c +19 -0
index 7aa4262..5838b9f 100644
@@ -25,6 +25,9 @@
 #include <linux/syscore_ops.h>
 #include <linux/device.h>
 #include <linux/amba/bus.h>
+#include <linux/of.h>
+#include <linux/of_address.h>
+#include <linux/of_irq.h>
 
 #include <asm/mach/irq.h>
 #include <asm/hardware/vic.h>
@@ -377,3 +380,35 @@ void __init vic_init(void __iomem *base, unsigned int irq_start,
 
 	vic_pm_register(base, irq_start, resume_sources);
 }
+
+#ifdef CONFIG_OF
+static const struct of_device_id arm_vic_ids[] __initconst = {
+	{ .compatible = "arm,pl190-vic" },
+	{ .compatible = "arm,pl192-vic" },
+	{ .compatible = "arm,vic" },
+	{},
+};
+
+void __init vic_of_init(void)
+{
+	struct device_node *np;
+
+	for_each_matching_node(np, arm_vic_ids) {
+		void __iomem *iobase;
+		u32 base_irq;
Quoted 8 lines

arch/arm/common/vic.c void __init vic_init(void __iomem *base, unsigned int irq_start, · line 403

Quoted 5 lines
arch/arm/common/vic.c +5 -0
+
+		iobase = of_iomap(np, 0);
+
+		if (!iobase)
+			panic("Unable to map VIC");

If you WARN here instead, then there is a much greater chance of actually getting output to the user.

OK, I'll change this.

Quoted 6 lines
Quoted 6 lines
arch/arm/common/vic.c +6 -0
+
+		if (of_property_read_u32(np, "irq-start", &base_irq))
+			panic("No irq-start property defined");
+
+		of_node_put(np);
+
Quoted 8 lines

arch/arm/common/vic.c void __init vic_init(void __iomem *base, unsigned int irq_start, · line 411

Quoted 2 lines
arch/arm/common/vic.c +2 -0
+		vic_init(iobase, base_irq, ~0, 0);
+		irq_domain_add_simple(np, base_irq);

irq_domain_add_simple() is a stop-gap shortcut for interrupt controllers that don't use irq_domain directly. I'm okay with doing this in the short term, but I imagine it will want to change in the near future to take advantage of hw->linux irq translation provided by irq_domain when it matures.

I have to admit to taking this from other controllers without fully understanding it. Is there any documentation on how this should be done correctly in the longer term?

Quoted 6 lines

arch/arm/common/vic.c void __init vic_init(void __iomem *base, unsigned int irq_start, · line 412

Quoted 1 line
arch/arm/common/vic.c +1 -0
+	}

I think that rather than writing a interrupt-controller-specific parse route like this one, it would be much better to have a generic helper that finds and sorts all the interrupt controllers before calling a setup callback for each one.

Hmm, not sure I follow this. I can see that many controllers would have some common properties so there will be some common code - are you suggesting having something do all the parsing then callbacks for each controller type that takes some kind of template or am I way off the mark?

Thanks,

Jamie

#4 lore raw

PATCH 1/3 vic: add device tree bindings

Quoted 9 lines · Jamie Iles

Hi Grant,

Quoted 5 lines · Grant Likely

irq_domain_add_simple() is a stop-gap shortcut for interrupt controllers that don't use irq_domain directly. I'm okay with doing this in the short term, but I imagine it will want to change in the near future to take advantage of hw->linux irq translation provided by irq_domain when it matures.

Quoted 3 lines

I have to admit to taking this from other controllers without fully understanding it. Is there any documentation on how this should be done correctly in the longer term?

Documentation? Ummmm... no, not yet. :-/ There will be though.

Quoted 8 lines
Quoted 7 lines

Review

Quoted 2 lines
(quoted diff) +1 -0
+	}

I think that rather than writing a interrupt-controller-specific parse route like this one, it would be much better to have a generic helper that finds and sorts all the interrupt controllers before calling a setup callback for each one.

Quoted 5 lines

Hmm, not sure I follow this. I can see that many controllers would have some common properties so there will be some common code - are you suggesting having something do all the parsing then callbacks for each controller type that takes some kind of template or am I way off the mark?

No, I'm more talking about having a routine that finds all the interrupt controllers and figures out the cascading order, and then calls each irq controller setup routine in order.

g.

author
#5 lore raw

PATCH 1/3 vic: add device tree bindings

Quoted 15 lines · Grant Likely
Quoted 8 lines · Jamie Iles
Quoted 7 lines

Review

Quoted 2 lines
(quoted diff) +1 -0
+	}

I think that rather than writing a interrupt-controller-specific parse route like this one, it would be much better to have a generic helper that finds and sorts all the interrupt controllers before calling a setup callback for each one.

Quoted 5 lines

Hmm, not sure I follow this. I can see that many controllers would have some common properties so there will be some common code - are you suggesting having something do all the parsing then callbacks for each controller type that takes some kind of template or am I way off the mark?

Quoted 3 lines

No, I'm more talking about having a routine that finds all the interrupt controllers and figures out the cascading order, and then calls each irq controller setup routine in order.

OK, that makes sense. I'm not sure how best to implement that but I'll give it some thought.

Regarding the irq-start property - on picoxcell we have 2 VIC's and they aren't cascaded - the outputs are just OR'd together so I can't work out how to fit in the IRQ decoding with get_irqnr_and_base without having this property. Is there another way that I could implement that?

Jamie

author
#6 lore raw

PATCH 2/3 versatile dt: set the irq-start property for the vic

In reply to Jamie Iles

Set an irq-start property for the vic in versatile's dt so that we can convert the versatile platform to use common vic probing.

Cc devicetree-discuss at lists.ozlabs.org
Cc Russell King <[email protected]>
---
 arch/arm/boot/dts/versatile-ab.dts |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
arch/arm/boot/dts/versatile-ab.dts +1 -0
index 2723804..1c6a1e3 100644
@@ -79,6 +79,7 @@
 			interrupt-controller;
 			#interrupt-cells = <1>;
 			reg = <0x10140000 0x1000>;
+			irq-start = <0>;
 		};
 
 		sic: intc at 10003000 {
Signature · 1 line
1.7.4.1
author
#7 lore raw

PATCH 3/3 versatile: convert to common VIC DT probing

In reply to Jamie Iles

Use the common VIC probing code in the VIC driver to instantiate the VIC from the DT.

Cc devicetree-discuss at lists.ozlabs.org
Cc Russell King <[email protected]>
---
 arch/arm/mach-versatile/core.c |    9 +--------
 1 files changed, 1 insertions(+), 8 deletions(-)
arch/arm/mach-versatile/core.c +1 -8
index 15c0091..3f29c01 100644
@@ -85,12 +85,6 @@ static struct fpga_irq_data sic_irq = {
 #define PIC_MASK	0
 #endif
 
-/* Lookup table for finding a DT node that represents the vic instance */
-static const struct of_device_id vic_of_match[] __initconst = {
-	{ .compatible = "arm,vic", },
-	{}
-};
-
 static const struct of_device_id sic_of_match[] __initconst = {
 	{ .compatible = "arm,sic", },
 	{}
@@ -98,8 +92,7 @@ static const struct of_device_id sic_of_match[] __initconst = {
 
 void __init versatile_init_irq(void)
 {
-	vic_init(VA_VIC_BASE, IRQ_VIC_START, ~0, 0);
-	irq_domain_generate_simple(vic_of_match, VERSATILE_VIC_BASE, IRQ_VIC_START);
+	vic_of_init();
 
 	writel(~0, VA_SIC_BASE + SIC_IRQ_ENABLE_CLEAR);
 
Signature · 1 line
1.7.4.1
#8 lore raw

cover Add device tree based initialisation for VIC

In reply to Jamie Iles
Quoted 7 lines · Jamie Iles

This series aims to allow VIC devices to be probed from the device tree. Currently the only in-tree device tree enabled user of the VIC is versatile, but I'll shortly submit patches for picoxcell on device tree that uses 2 VIC's.

I've split this into 3 patches for bisectability, but this could be fairly squashed into 2.

I always prefer fewer patches. Which 2 patches would you squash together? :-)

Quoted 22 lines

Jamie Iles (3):
vic: add device tree bindings
versatile dt: set the irq-start property for the vic
versatile: convert to common VIC DT probing

 Documentation/devicetree/bindings/arm/vic.txt |   21 +++++++++++++++
 arch/arm/boot/dts/versatile-ab.dts            |    1 +
 arch/arm/common/vic.c                         |   35 +++++++++++++++++++++++++
 arch/arm/include/asm/hardware/vic.h           |    5 +++
 arch/arm/mach-versatile/core.c                |    9 +-----
 5 files changed, 63 insertions(+), 8 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/arm/vic.txt
Signature · 7 lines
1.7.4.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
author
#9 lore raw

cover Add device tree based initialisation for VIC

Quoted 11 lines · Grant Likely
Quoted 7 lines · Jamie Iles

This series aims to allow VIC devices to be probed from the device tree. Currently the only in-tree device tree enabled user of the VIC is versatile, but I'll shortly submit patches for picoxcell on device tree that uses 2 VIC's.

I've split this into 3 patches for bisectability, but this could be fairly squashed into 2.

I always prefer fewer patches. Which 2 patches would you squash together? :-)

The conversion for versatile could go into one patch, but I'm not sure it would bisect as easily (I guess that's more important though).

Jamie