Skip to contentSkip to conversation

Add support for Layerscape external interrupt lines

PATCH In review Kurt Kanzenbach 4 participants 7 messages Sep 23, 2019 – Sep 30, 2019

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

v6 cover Add support for Layerscape external interrupt lines

Hi,

this is a respin of getting the support for the Layerscape's external interrupt lines. The last version from Rasmus Villemoes can be found here:

https://lkml.kernel.org/r/[email protected]/

Rasmus Villemoes ran out of time, so I prepared v6.

Changes since v5:

- Rebase to v5.3.0
- Integrated Thomas Gleixner comments:
- Adjust order of local variables
- Use irq_chip_set_type_parent()
- Cleanup of irq headers
- Integrated Rob Herring comments:
- Add #address-cells and #size-cells to parent
- Use ARCH_LAYERSCAPE, as this feature is not LS1021A specific

It is tested on a Layerscape LS2088A.

Thanks,
Kurt

Rasmus Villemoes (2):
irqchip: Add support for Layerscape external interrupt lines dt/bindings: Add bindings for Layerscape external irqs

 .../interrupt-controller/fsl,ls-extirq.txt    |  47 +++++
 drivers/irqchip/Makefile                      |   1 +
 drivers/irqchip/irq-ls-extirq.c               | 174 ++++++++++++++++++
 3 files changed, 222 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/interrupt-controller/fsl,ls-extirq.txt
 create mode 100644 drivers/irqchip/irq-ls-extirq.c
Signature · 1 line
2.20.1
#1 lore raw

PATCH v6 1/2 irqchip: Add support for Layerscape external interrupt lines

From: Rasmus Villemoes <[email protected]>

The LS1021A allows inverting the polarity of six interrupt lines IRQ[0:5] via the scfg_intpcr register, effectively allowing IRQ_TYPE_LEVEL_LOW and IRQ_TYPE_EDGE_FALLING for those. We just need to check the type, set the relevant bit in INTPCR accordingly, and fixup the type argument before calling the GIC's irq_set_type.

In fact, the power-on-reset value of the INTPCR register on the LS1021A is so that all six lines have their polarity inverted. Hence any hardware connected to those lines is unusable without this: If the line is indeed active low, the generic GIC code will reject an irq spec with IRQ_TYPE_LEVEL_LOW, while if the line is active high, we must obviously disable the polarity inversion (writing 0 to the relevant bit) before unmasking the interrupt.

Some other Layerscape SOCs (LS1043A, LS1046A, LS2088A) reportedly have a similar feature, just with a different number of external interrupt lines (and a different POR value for the INTPCR register). This driver should be prepared for supporting those by properly filling out the device tree node, but I don't have the full reference manual, nor the hardware to be able to test it. I do know, from a tiny clipout from one of the other reference manuals I was shown, that 1U<<n is the right formula to use for setting/clearing the bit corresponding to the external IRQn, but I don't know which interrupts on the GIC those lines represent.

---

Changes since v5:

- Adjust order of local variables
- Cleanup of irq headers
- Use irq_chip_set_type_parent()
- Compile with ARCH_LAYERSCAPE
- Removed last paragraph of changelog, as ARCH_LAYERSCAPE should be used
- Also mention the LS2088A SoC in changelog

drivers/irqchip/Makefile | 1 +

 drivers/irqchip/irq-ls-extirq.c | 174 ++++++++++++++++++++++++++++++++
 2 files changed, 175 insertions(+)
 create mode 100644 drivers/irqchip/irq-ls-extirq.c
drivers/irqchip/Makefile +1 -0
index 8d0fcec6ab23..ce6db511124a 100644
@@ -84,6 +84,7 @@ obj-$(CONFIG_MVEBU_ODMI)		+= irq-mvebu-odmi.o
 obj-$(CONFIG_MVEBU_PIC)			+= irq-mvebu-pic.o
 obj-$(CONFIG_MVEBU_SEI)			+= irq-mvebu-sei.o
 obj-$(CONFIG_LS_SCFG_MSI)		+= irq-ls-scfg-msi.o
+obj-$(CONFIG_ARCH_LAYERSCAPE)		+= irq-ls-extirq.o
 obj-$(CONFIG_EZNPS_GIC)			+= irq-eznps.o
 obj-$(CONFIG_ARCH_ASPEED)		+= irq-aspeed-vic.o irq-aspeed-i2c-ic.o
 obj-$(CONFIG_STM32_EXTI) 		+= irq-stm32-exti.o
drivers/irqchip/irq-ls-extirq.c new file +174 -0

174 lines not on this page · raw message

Signature · 1 line
2.20.1
#2 lore raw

PATCH v6 2/2 dt/bindings: Add bindings for Layerscape external irqs

In reply to Kurt Kanzenbach

From: Rasmus Villemoes <[email protected]>

This adds Device Tree binding documentation for the external interrupt lines with configurable polarity present on some Layerscape SOCs.

---

Changes since v5:

- Add #address-cells and #size-cells to parent
- Mention LS2088A and the ISC unit

.../interrupt-controller/fsl,ls-extirq.txt | 47 +++++++++++++++++++

 1 file changed, 47 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/interrupt-controller/fsl,ls-extirq.txt
Documentation/devicetree/bindings/interrupt-controller/fsl,ls-extirq.txt new file +47 -0
new file mode 100644
index 000000000000..7b53f9cc8019
@@ -0,0 +1,47 @@
+* Freescale Layerscape external IRQs
+
+Some Layerscape SOCs (LS1021A, LS1043A, LS1046A, LS2088A) support
+inverting the polarity of certain external interrupt lines.
+
+The device node must be a child of the node representing the
+Supplemental Configuration Unit (SCFG) or the Interrupt Sampling
+Control (ISC) Unit.
+
+Required properties:
+- compatible: should be "fsl,<soc-name>-extirq", e.g. "fsl,ls1021a-extirq".
+- interrupt-controller: Identifies the node as an interrupt controller
+- #interrupt-cells: Must be 2. The first element is the index of the
+  external interrupt line. The second element is the trigger type.
+- interrupt-parent: phandle of GIC.
+- reg: Specifies the Interrupt Polarity Control Register (INTPCR) in the SCFG.
+- fsl,extirq-map: Specifies the mapping to interrupt numbers in the parent
+  interrupt controller. Interrupts are mapped one-to-one to parent
+  interrupts.
+
+Optional properties:
+- fsl,bit-reverse: This boolean property should be set on the LS1021A
+  if the SCFGREVCR register has been set to all-ones (which is usually
+  the case), meaning that all reads and writes of SCFG registers are
+  implicitly bit-reversed. Other compatible platforms do not have such
+  a register.
+
+Example:
+	scfg: scfg@1570000 {
+		compatible = "fsl,ls1021a-scfg", "syscon";
+		#address-cells = <1>;
+		#size-cells = <0>;
+		...
+		extirq: interrupt-controller {
+			compatible = "fsl,ls1021a-extirq";
+			#interrupt-cells = <2>;
+			interrupt-controller;
+			interrupt-parent = <&gic>;
+			reg = <0x1ac>;
+			fsl,extirq-map = <163 164 165 167 168 169>;
+			fsl,bit-reverse;
+		};
+	};
+
+
+	interrupts-extended = <&gic GIC_SPI 88 IRQ_TYPE_LEVEL_HIGH>,
+			      <&extirq 1 IRQ_TYPE_LEVEL_LOW>;
Signature · 1 line
2.20.1
maintainer
#3 lore raw

Re: [PATCH v6 2/2] dt/bindings: Add bindings for Layerscape external irqs

Quoted 5 lines · Kurt Kanzenbach

From: Rasmus Villemoes <[email protected]>

This adds Device Tree binding documentation for the external interrupt lines with configurable polarity present on some Layerscape SOCs.

Quoted 8 lines

---

Changes since v5:

- Add #address-cells and #size-cells to parent
- Mention LS2088A and the ISC unit

Repeating some of my lost comments from v2 2 years ago...

Quoted 20 lines

.../interrupt-controller/fsl,ls-extirq.txt | 47 +++++++++++++++++++

 1 file changed, 47 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/interrupt-controller/fsl,ls-extirq.txt
Documentation/devicetree/bindings/interrupt-controller/fsl,ls-extirq.txt new file +9 -0
new file mode 100644
index 000000000000..7b53f9cc8019
@@ -0,0 +1,47 @@
+* Freescale Layerscape external IRQs
+
+Some Layerscape SOCs (LS1021A, LS1043A, LS1046A, LS2088A) support
+inverting the polarity of certain external interrupt lines.
+
+The device node must be a child of the node representing the
+Supplemental Configuration Unit (SCFG) or the Interrupt Sampling
+Control (ISC) Unit.
+

Documentation/devicetree/bindings/interrupt-controller/fsl,ls-extirq.txt line 19

Quoted 10 lines
Documentation/devicetree/bindings/interrupt-controller/fsl,ls-extirq.txt new file +10 -0
+Required properties:
+- compatible: should be "fsl,<soc-name>-extirq", e.g. "fsl,ls1021a-extirq".
+- interrupt-controller: Identifies the node as an interrupt controller
+- #interrupt-cells: Must be 2. The first element is the index of the
+  external interrupt line. The second element is the trigger type.
+- interrupt-parent: phandle of GIC.
+- reg: Specifies the Interrupt Polarity Control Register (INTPCR) in the SCFG.
+- fsl,extirq-map: Specifies the mapping to interrupt numbers in the parent
+  interrupt controller. Interrupts are mapped one-to-one to parent
+  interrupts.

This should be an 'interrupt-map' instead.

Documentation/devicetree/bindings/interrupt-controller/fsl,ls-extirq.txt line 26

Quoted 7 lines
Documentation/devicetree/bindings/interrupt-controller/fsl,ls-extirq.txt new file +7 -0
+
+Optional properties:
+- fsl,bit-reverse: This boolean property should be set on the LS1021A
+  if the SCFGREVCR register has been set to all-ones (which is usually
+  the case), meaning that all reads and writes of SCFG registers are
+  implicitly bit-reversed. Other compatible platforms do not have such
+  a register.

Couldn't you just read that register and tell?

Does this apply to only the extirq register or all of scfg?

Documentation/devicetree/bindings/interrupt-controller/fsl,ls-extirq.txt line 32

Quoted 6 lines
Documentation/devicetree/bindings/interrupt-controller/fsl,ls-extirq.txt new file +6 -0
+
+Example:
+	scfg: scfg@1570000 {
+		compatible = "fsl,ls1021a-scfg", "syscon";
+		#address-cells = <1>;
+		#size-cells = <0>;

As the child node(s) are memory mapped, this should not be 0. And you need 'ranges'.

Quoted 18 lines
Documentation/devicetree/bindings/interrupt-controller/fsl,ls-extirq.txt new file +15 -0
+		...
+		extirq: interrupt-controller {
+			compatible = "fsl,ls1021a-extirq";
+			#interrupt-cells = <2>;
+			interrupt-controller;
+			interrupt-parent = <&gic>;
+			reg = <0x1ac>;
+			fsl,extirq-map = <163 164 165 167 168 169>;
+			fsl,bit-reverse;
+		};
+	};
+
+
+	interrupts-extended = <&gic GIC_SPI 88 IRQ_TYPE_LEVEL_HIGH>,
+			      <&extirq 1 IRQ_TYPE_LEVEL_LOW>;
Signature · 1 line
2.20.1
#4 lore raw

Re: [PATCH v6 2/2] dt/bindings: Add bindings for Layerscape external irqs

Quoted 23 lines · Rob Herring
Quoted 22 lines · Kurt Kanzenbach

From: Rasmus Villemoes <[email protected]>

This adds Device Tree binding documentation for the external interrupt lines with configurable polarity present on some Layerscape SOCs.

---

Documentation/devicetree/bindings/interrupt-controller/fsl,ls-extirq.txt new file +13 -0
+* Freescale Layerscape external IRQs
+
+Some Layerscape SOCs (LS1021A, LS1043A, LS1046A, LS2088A) support
+inverting the polarity of certain external interrupt lines.
+
+The device node must be a child of the node representing the
+Supplemental Configuration Unit (SCFG) or the Interrupt Sampling
+Control (ISC) Unit.
+
+Required properties:
+- compatible: should be "fsl,<soc-name>-extirq", e.g. "fsl,ls1021a-extirq".
+- interrupt-controller: Identifies the node as an interrupt controller
+- #interrupt-cells: Must be 2. The first element is the index of the
Quoted 8 lines

Documentation/devicetree/bindings/interrupt-controller/fsl,ls-extirq.txt line 19

Quoted 6 lines
Documentation/devicetree/bindings/interrupt-controller/fsl,ls-extirq.txt new file +6 -0
+  external interrupt line. The second element is the trigger type.
+- interrupt-parent: phandle of GIC.
+- reg: Specifies the Interrupt Polarity Control Register (INTPCR) in the SCFG.
+- fsl,extirq-map: Specifies the mapping to interrupt numbers in the parent
+  interrupt controller. Interrupts are mapped one-to-one to parent
+  interrupts.

This should be an 'interrupt-map' instead.

Rob, thanks for your review comments. I know you said the same thing at v5, and it might seem like they are ignored. However, I asked a couple of followup questions
(https://lore.kernel.org/lkml/[email protected]/).
I'd really appreciate it if you could (a) point to some documentation on how to write that interrupt-map and (b) explain how this is different from the Qualcomm PDC case I tried to copy and which had your Reviewed-By.

Quoted 9 lines

Documentation/devicetree/bindings/interrupt-controller/fsl,ls-extirq.txt line 26

Quoted 7 lines
Documentation/devicetree/bindings/interrupt-controller/fsl,ls-extirq.txt new file +7 -0
+
+Optional properties:
+- fsl,bit-reverse: This boolean property should be set on the LS1021A
+  if the SCFGREVCR register has been set to all-ones (which is usually
+  the case), meaning that all reads and writes of SCFG registers are
+  implicitly bit-reversed. Other compatible platforms do not have such
+  a register.

Couldn't you just read that register and tell?

In theory, yes, but as far as I understand (and as I wrote) it's specific to the ls1021a. Of course one can decide whether it's necessary/possible to read it based on the compatible string, but one would also need an extra reg property to have its address - but that register is not really part of the extirq "device" we're trying to describe. So would it need to be represented as its own subnode of scfg?

If it is set at all, it's done within the first few instructions after reset (before control is even handed to the bootloader), so I see it as a kind of quirk of the hardware. The data sheet says "SCFG bit reverse (SCFG_SCFGREVCR) must be written 0xFFFF_FFFF as a part of initialization sequence before writing to any other SCFG register." which, taken literally, means we don't need the property at all and can just assume it for the ls1021a (i.e., do it based on compatible string alone) - but I think it should be read as "if you're going to write this register, it must be done first thing".

Quoted 1 line

Does this apply to only the extirq register or all of scfg?

All of scfg. It really seems like some accident/bad joke coming out of a discussion between a hardware and software engineer on the enumeration of bits, with the hardware guy ending up saying "alright, have it whichever way you want it", causing even more pain :(

Quoted 9 lines

Documentation/devicetree/bindings/interrupt-controller/fsl,ls-extirq.txt line 32

Quoted 6 lines
Documentation/devicetree/bindings/interrupt-controller/fsl,ls-extirq.txt new file +6 -0
+
+Example:
+	scfg: scfg@1570000 {
+		compatible = "fsl,ls1021a-scfg", "syscon";
+		#address-cells = <1>;
+		#size-cells = <0>;

As the child node(s) are memory mapped, this should not be 0. And you need 'ranges'.

Indeed - I think I understand this a little better now than I did back then.

Thanks,
Rasmus

#5 lore raw

Re: [PATCH v6 2/2] dt/bindings: Add bindings for Layerscape external irqs

Quoted 13 lines · Rasmus Villemoes
Quoted 12 lines · Rob Herring
Quoted 10 lines · Kurt Kanzenbach
Documentation/devicetree/bindings/interrupt-controller/fsl,ls-extirq.txt new file +10 -0
+Required properties:
+- compatible: should be "fsl,<soc-name>-extirq", e.g. "fsl,ls1021a-extirq".
+- interrupt-controller: Identifies the node as an interrupt controller
+- #interrupt-cells: Must be 2. The first element is the index of the
+  external interrupt line. The second element is the trigger type.
+- interrupt-parent: phandle of GIC.
+- reg: Specifies the Interrupt Polarity Control Register (INTPCR) in the SCFG.
+- fsl,extirq-map: Specifies the mapping to interrupt numbers in the parent
+  interrupt controller. Interrupts are mapped one-to-one to parent
+  interrupts.
Quoted 4 lines
Quoted 1 line

This should be an 'interrupt-map' instead.

Rob, thanks for your review comments. I know you said the same thing at v5, and it might seem like they are ignored.

Well, I didn't ignore them. It just wasn't clear to me from the previous discussions which way you want to go.

Quoted 6 lines

However, I asked a couple of followup questions
(https://lore.kernel.org/lkml/[email protected]/).
I'd really appreciate it if you could (a) point to some documentation on how to write that interrupt-map and (b) explain how this is different from the Qualcomm PDC case I tried to copy and which had your Reviewed-By.

I guess, we can have a look at other interrupt controllers and how they handle the interrupt-map property. For example:

https://www.kernel.org/doc/Documentation/devicetree/bindings/interrupt-controller/renesas,rza1-irqc.txt

I need to send a v7 anyway, because I forgot to include the SOC_LS1021A in the build process.

Quoted 11 lines
Quoted 10 lines

Documentation/devicetree/bindings/interrupt-controller/fsl,ls-extirq.txt line 26

Quoted 8 lines
Documentation/devicetree/bindings/interrupt-controller/fsl,ls-extirq.txt new file +7 -0
+
+Optional properties:
+- fsl,bit-reverse: This boolean property should be set on the LS1021A
+  if the SCFGREVCR register has been set to all-ones (which is usually
+  the case), meaning that all reads and writes of SCFG registers are
+  implicitly bit-reversed. Other compatible platforms do not have such
+  a register.

Couldn't you just read that register and tell?

Quoted 6 lines

In theory, yes, but as far as I understand (and as I wrote) it's specific to the ls1021a. Of course one can decide whether it's necessary/possible to read it based on the compatible string, but one would also need an extra reg property to have its address - but that register is not really part of the extirq "device" we're trying to describe. So would it need to be represented as its own subnode of scfg?

Keep in mind, that not all Layerscapes have that feature and the corresponding register. As you said that may be handled via compatible string. However, the bit-reverse property looks like the simplest solution to me.

Quoted 28 lines

If it is set at all, it's done within the first few instructions after reset (before control is even handed to the bootloader), so I see it as a kind of quirk of the hardware. The data sheet says "SCFG bit reverse (SCFG_SCFGREVCR) must be written 0xFFFF_FFFF as a part of initialization sequence before writing to any other SCFG register." which, taken literally, means we don't need the property at all and can just assume it for the ls1021a (i.e., do it based on compatible string alone) - but I think it should be read as "if you're going to write this register, it must be done first thing".

Quoted 1 line

Does this apply to only the extirq register or all of scfg?

All of scfg. It really seems like some accident/bad joke coming out of a discussion between a hardware and software engineer on the enumeration of bits, with the hardware guy ending up saying "alright, have it whichever way you want it", causing even more pain :(

Quoted 9 lines

Documentation/devicetree/bindings/interrupt-controller/fsl,ls-extirq.txt line 32

Quoted 6 lines
Documentation/devicetree/bindings/interrupt-controller/fsl,ls-extirq.txt new file +6 -0
+
+Example:
+	scfg: scfg@1570000 {
+		compatible = "fsl,ls1021a-scfg", "syscon";
+		#address-cells = <1>;
+		#size-cells = <0>;

As the child node(s) are memory mapped, this should not be 0. And you need 'ranges'.

Quoted 2 lines

Indeed - I think I understand this a little better now than I did back then.

Okay.

Quoted 2 lines

Thanks,
Rasmus

Thanks,
Kurt

maintainer
#6 lore raw

Re: [PATCH v6 2/2] dt/bindings: Add bindings for Layerscape external irqs

In reply to Rasmus Villemoes
Quoted 34 lines · Rasmus Villemoes
Quoted 23 lines · Rob Herring
Quoted 22 lines · Kurt Kanzenbach

From: Rasmus Villemoes <[email protected]>

This adds Device Tree binding documentation for the external interrupt lines with configurable polarity present on some Layerscape SOCs.

---

Documentation/devicetree/bindings/interrupt-controller/fsl,ls-extirq.txt new file +13 -0
+* Freescale Layerscape external IRQs
+
+Some Layerscape SOCs (LS1021A, LS1043A, LS1046A, LS2088A) support
+inverting the polarity of certain external interrupt lines.
+
+The device node must be a child of the node representing the
+Supplemental Configuration Unit (SCFG) or the Interrupt Sampling
+Control (ISC) Unit.
+
+Required properties:
+- compatible: should be "fsl,<soc-name>-extirq", e.g. "fsl,ls1021a-extirq".
+- interrupt-controller: Identifies the node as an interrupt controller
+- #interrupt-cells: Must be 2. The first element is the index of the
Quoted 8 lines

Documentation/devicetree/bindings/interrupt-controller/fsl,ls-extirq.txt line 19

Quoted 6 lines
Documentation/devicetree/bindings/interrupt-controller/fsl,ls-extirq.txt new file +6 -0
+  external interrupt line. The second element is the trigger type.
+- interrupt-parent: phandle of GIC.
+- reg: Specifies the Interrupt Polarity Control Register (INTPCR) in the SCFG.
+- fsl,extirq-map: Specifies the mapping to interrupt numbers in the parent
+  interrupt controller. Interrupts are mapped one-to-one to parent
+  interrupts.

This should be an 'interrupt-map' instead.

Quoted 7 lines

Rob, thanks for your review comments. I know you said the same thing at v5, and it might seem like they are ignored. However, I asked a couple of followup questions
(https://lore.kernel.org/lkml/[email protected]/).
I'd really appreciate it if you could (a) point to some documentation on how to write that interrupt-map and (b) explain how this is different from the Qualcomm PDC case I tried to copy and which had your Reviewed-By.

https://www.devicetree.org/specifications/
https://elinux.org/Device_Tree_Usage#Advanced_Interrupt_Mapping

For QC PDC, it could be a large number of interrupts to remap which interrupt-map doesn't scale to very well. Also, I think it sits in parallel to the GIC rather than downstream. The interrupt binding doesn't really have a way to express that.

Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Documentation/devicetree/bindings/interrupt-controller/fsl,ls-extirq.txt new file +6 -0
+Optional properties:
+- fsl,bit-reverse: This boolean property should be set on the LS1021A
+  if the SCFGREVCR register has been set to all-ones (which is usually
+  the case), meaning that all reads and writes of SCFG registers are
+  implicitly bit-reversed. Other compatible platforms do not have such
+  a register.
Quoted 8 lines
Quoted 1 line

Couldn't you just read that register and tell?

In theory, yes, but as far as I understand (and as I wrote) it's specific to the ls1021a. Of course one can decide whether it's necessary/possible to read it based on the compatible string, but one would also need an extra reg property to have its address - but that register is not really part of the extirq "device" we're trying to describe. So would it need to be represented as its own subnode of scfg?

Why? You should know where the register is because you know what chip you are on (from the compatible).

Quoted 11 lines

If it is set at all, it's done within the first few instructions after reset (before control is even handed to the bootloader), so I see it as a kind of quirk of the hardware. The data sheet says "SCFG bit reverse (SCFG_SCFGREVCR) must be written 0xFFFF_FFFF as a part of initialization sequence before writing to any other SCFG register." which, taken literally, means we don't need the property at all and can just assume it for the ls1021a (i.e., do it based on compatible string alone) - but I think it should be read as "if you're going to write this register, it must be done first thing".

Quoted 6 lines
Quoted 1 line

Does this apply to only the extirq register or all of scfg?

All of scfg. It really seems like some accident/bad joke coming out of a discussion between a hardware and software engineer on the enumeration of bits, with the hardware guy ending up saying "alright, have it whichever way you want it", causing even more pain :(

If all of the scfg bits change, then if you have this property, it should be in the scfg node. But I prefer you use the compatible instead if that works.

Rob