[PATCH v3 8/8] ARM: dts: r9a06g032: Add support for GPIO interrupts

Herve Codina (Schneider Electric) posted 8 patches 1 week, 6 days ago
There is a newer version of this series
[PATCH v3 8/8] ARM: dts: r9a06g032: Add support for GPIO interrupts
Posted by Herve Codina (Schneider Electric) 1 week, 6 days ago
In the RZ/N1 SoC, the GPIO interrupts are multiplexed using the GPIO
Interrupt Multiplexer.

Add the multiplexer node and connect GPIO interrupt lines to the
multiplexer.

The interrupt-map available in the multiplexer node has to be updated in
dts files depending on the GPIO usage. Indeed, the usage of an interrupt
for a GPIO is board dependent.

Up to 8 GPIOs can be used as an interrupt line (one per multiplexer
output interrupt).

Signed-off-by: Herve Codina (Schneider Electric) <herve.codina@bootlin.com>
---
 arch/arm/boot/dts/renesas/r9a06g032.dtsi | 49 ++++++++++++++++++++++++
 1 file changed, 49 insertions(+)

diff --git a/arch/arm/boot/dts/renesas/r9a06g032.dtsi b/arch/arm/boot/dts/renesas/r9a06g032.dtsi
index da977cdd8487..3cd7ac38eb7a 100644
--- a/arch/arm/boot/dts/renesas/r9a06g032.dtsi
+++ b/arch/arm/boot/dts/renesas/r9a06g032.dtsi
@@ -534,6 +534,14 @@ gpio0a: gpio-port@0 {
 				#gpio-cells = <2>;
 				snps,nr-gpios = <32>;
 				reg = <0>;
+
+				interrupt-controller;
+				interrupt-parent = <&gpioirqmux>;
+				interrupts = < 0  1  2  3  4  5  6  7
+					       8  9 10 11 12 13 14 15
+					      16 17 18 19 20 21 22 23
+					      24 25 26 27 28 29 30 31 >;
+				#interrupt-cells = <2>;
 			};
 
 			/* GPIO0b[0..1]   connected to pins GPIO1..2   */
@@ -576,6 +584,14 @@ gpio1a: gpio-port@0 {
 				#gpio-cells = <2>;
 				snps,nr-gpios = <32>;
 				reg = <0>;
+
+				interrupt-controller;
+				interrupt-parent = <&gpioirqmux>;
+				interrupts = < 32 33 34 35 36 37 38 39
+					       40 41 42 43 44 45 46 47
+					       48 49 50 51 52 53 54 55
+					       56 57 58 59 60 61 62 63 >;
+				#interrupt-cells = <2>;
 			};
 
 			/* GPIO1b[0..1]   connected to pins GPIO55..56 */
@@ -608,6 +624,14 @@ gpio2a: gpio-port@0 {
 				#gpio-cells = <2>;
 				snps,nr-gpios = <32>;
 				reg = <0>;
+
+				interrupt-controller;
+				interrupt-parent = <&gpioirqmux>;
+				interrupts = < 64 65 66 67 68 69 70 71
+					       72 73 74 75 76 77 78 79
+					       80 81 82 83 84 85 86 87
+					       88 89 90 91 92 93 94 95 >;
+				#interrupt-cells = <2>;
 			};
 
 			/* GPIO2b[0..9] connected to pins GPIO160..169 */
@@ -620,6 +644,31 @@ gpio2b: gpio-port@1 {
 			};
 		};
 
+		gpioirqmux: interrupt-controller@51000480 {
+			compatible = "renesas,r9a06g032-gpioirqmux", "renesas,rzn1-gpioirqmux";
+			reg = <0x51000480 0x20>;
+			#interrupt-cells = <1>;
+			#address-cells = <0>;
+			interrupt-map-mask = <0x7f>;
+
+			/*
+			 * interrupt-map has to be updated according to GPIO
+			 * usage. The order has to be kept. Only the src irq
+			 * (0 field) has to be updated with the needed GPIO
+			 * interrupt number.
+			 */
+			interrupt-map = <0 &gic GIC_SPI 103 IRQ_TYPE_LEVEL_HIGH>,
+					<0 &gic GIC_SPI 104 IRQ_TYPE_LEVEL_HIGH>,
+					<0 &gic GIC_SPI 105 IRQ_TYPE_LEVEL_HIGH>,
+					<0 &gic GIC_SPI 106 IRQ_TYPE_LEVEL_HIGH>,
+					<0 &gic GIC_SPI 107 IRQ_TYPE_LEVEL_HIGH>,
+					<0 &gic GIC_SPI 108 IRQ_TYPE_LEVEL_HIGH>,
+					<0 &gic GIC_SPI 109 IRQ_TYPE_LEVEL_HIGH>,
+					<0 &gic GIC_SPI 110 IRQ_TYPE_LEVEL_HIGH>;
+
+			status = "disabled";
+		};
+
 		can0: can@52104000 {
 			compatible = "renesas,r9a06g032-sja1000", "renesas,rzn1-sja1000";
 			reg = <0x52104000 0x800>;
-- 
2.51.0
Re: [PATCH v3 8/8] ARM: dts: r9a06g032: Add support for GPIO interrupts
Posted by Wolfram Sang 1 week, 5 days ago
> +			/*
> +			 * interrupt-map has to be updated according to GPIO
> +			 * usage. The order has to be kept. Only the src irq
> +			 * (0 field) has to be updated with the needed GPIO
> +			 * interrupt number.
> +			 */
> +			interrupt-map = <0 &gic GIC_SPI 103 IRQ_TYPE_LEVEL_HIGH>,
> +					<0 &gic GIC_SPI 104 IRQ_TYPE_LEVEL_HIGH>,
> +					<0 &gic GIC_SPI 105 IRQ_TYPE_LEVEL_HIGH>,
> +					<0 &gic GIC_SPI 106 IRQ_TYPE_LEVEL_HIGH>,
> +					<0 &gic GIC_SPI 107 IRQ_TYPE_LEVEL_HIGH>,
> +					<0 &gic GIC_SPI 108 IRQ_TYPE_LEVEL_HIGH>,
> +					<0 &gic GIC_SPI 109 IRQ_TYPE_LEVEL_HIGH>,
> +					<0 &gic GIC_SPI 110 IRQ_TYPE_LEVEL_HIGH>;

I'd think this should be dropped from the include and added in the board
file instead. I did this with my board and it works fine.

Re: [PATCH v3 8/8] ARM: dts: r9a06g032: Add support for GPIO interrupts
Posted by Herve Codina 1 week, 5 days ago
On Fri, 19 Sep 2025 11:42:46 +0200
Wolfram Sang <wsa+renesas@sang-engineering.com> wrote:

> > +			/*
> > +			 * interrupt-map has to be updated according to GPIO
> > +			 * usage. The order has to be kept. Only the src irq
> > +			 * (0 field) has to be updated with the needed GPIO
> > +			 * interrupt number.
> > +			 */
> > +			interrupt-map = <0 &gic GIC_SPI 103 IRQ_TYPE_LEVEL_HIGH>,
> > +					<0 &gic GIC_SPI 104 IRQ_TYPE_LEVEL_HIGH>,
> > +					<0 &gic GIC_SPI 105 IRQ_TYPE_LEVEL_HIGH>,
> > +					<0 &gic GIC_SPI 106 IRQ_TYPE_LEVEL_HIGH>,
> > +					<0 &gic GIC_SPI 107 IRQ_TYPE_LEVEL_HIGH>,
> > +					<0 &gic GIC_SPI 108 IRQ_TYPE_LEVEL_HIGH>,
> > +					<0 &gic GIC_SPI 109 IRQ_TYPE_LEVEL_HIGH>,
> > +					<0 &gic GIC_SPI 110 IRQ_TYPE_LEVEL_HIGH>;  
> 
> I'd think this should be dropped from the include and added in the board
> file instead. I did this with my board and it works fine.
> 

I can only reduce the table but I need to keep the interrupt-map property.

'interrupt-map' is a required property. If the board doesn't use any interrupt
GPIO, its dts has no reason to set the interrupt-map.

In that case, if I fully remove 'interrupt-map' in the dtsi, dtbs_check
will not be happy. Indeed, a required property is missing.

Also, having the full table containing the 8 items with the correct GIC
interrupt number and the correct order could help a user to route the
GPIO line to one of those 8 items.

The '0' field use as interrupt source matches the registers reset value
of the irq-mux controller.

With that in mind, do you still think that I should reduce this table?

Best regards,
Hervé
Re: [PATCH v3 8/8] ARM: dts: r9a06g032: Add support for GPIO interrupts
Posted by Wolfram Sang 1 week, 5 days ago
> 'interrupt-map' is a required property. If the board doesn't use any interrupt
> GPIO, its dts has no reason to set the interrupt-map.

Why is 'interrupt-map' then a required property? Can we drop it from the
requirements?

Re: [PATCH v3 8/8] ARM: dts: r9a06g032: Add support for GPIO interrupts
Posted by Herve Codina 1 week, 5 days ago
On Fri, 19 Sep 2025 16:41:05 +0200
Wolfram Sang <wsa+renesas@sang-engineering.com> wrote:

> > 'interrupt-map' is a required property. If the board doesn't use any interrupt
> > GPIO, its dts has no reason to set the interrupt-map.  
> 
> Why is 'interrupt-map' then a required property? Can we drop it from the
> requirements?
> 

I need to check in details but 'interrupt-map' should be kept required.
Indeed, irq-mux needs this property to work. It is not an optional one.

I need to look at the 'make CHECK_DTBS=y' behavior when required property is
missing in a not enabled node (node with status = "disabled").

Also, got some:
   Warning (interrupts_property): /soc/interrupt-controller@51000480: Missing interrupt-controller or interrupt-map property

This could be due to the presence of #interrupt-cells or the node name (not
sure). As I need to rename the node (Conor's comment), I will see if the
warning disappear. If the warning is due to #interrupt-cells, I don't think
that removing #interrupt-cells is the right solution to avoid the warning.

That's said, I need to perform some local tries. I will keep you informed.

Best regards
Hervé 
Re: [PATCH v3 8/8] ARM: dts: r9a06g032: Add support for GPIO interrupts
Posted by Herve Codina 1 week, 2 days ago
Hi Wolfram,

On Fri, 19 Sep 2025 19:12:11 +0200
Herve Codina <herve.codina@bootlin.com> wrote:

> On Fri, 19 Sep 2025 16:41:05 +0200
> Wolfram Sang <wsa+renesas@sang-engineering.com> wrote:
> 
> > > 'interrupt-map' is a required property. If the board doesn't use any interrupt
> > > GPIO, its dts has no reason to set the interrupt-map.    
> > 
> > Why is 'interrupt-map' then a required property? Can we drop it from the
> > requirements?
> >   
> 
> I need to check in details but 'interrupt-map' should be kept required.
> Indeed, irq-mux needs this property to work. It is not an optional one.
> 
> I need to look at the 'make CHECK_DTBS=y' behavior when required property is
> missing in a not enabled node (node with status = "disabled").
> 
> Also, got some:
>    Warning (interrupts_property): /soc/interrupt-controller@51000480: Missing interrupt-controller or interrupt-map property
> 
> This could be due to the presence of #interrupt-cells or the node name (not
> sure). As I need to rename the node (Conor's comment), I will see if the
> warning disappear. If the warning is due to #interrupt-cells, I don't think
> that removing #interrupt-cells is the right solution to avoid the warning.
> 
> That's said, I need to perform some local tries. I will keep you informed.
> 

If I remove the 'interrupt-map', I still have warnings from DTC:
  r9a06g032.dtsi:647.45-664.5: Warning (interrupts_property): /soc/interrupt-controller@51000480: Missing interrupt-controller or interrupt-map property
  r9a06g032.dtsi:647.45-664.5: Warning (interrupts_property): /soc/interrupt-controller@51000480: Missing interrupt-controller or interrupt-map property
  r9a06g032.dtsi:647.45-664.5: Warning (interrupts_property): /soc/interrupt-controller@51000480: Missing interrupt-controller or interrupt-map property
  r9a06g032.dtsi:647.45-664.5: Warning (interrupt_provider): /soc/interrupt-controller@51000480: '#interrupt-cells' found, but node is not an interrupt provider
  r9a06g032-rzn1d400-eb.dtb: Warning (interrupt_map): Failed prerequisite 'interrupt_provider'

Indeed, the irq-mux node is referenced (interrupt-parent) in the gpio nodes.
DTC checks that in that case irq-mux is correctly set. It has to be either
an interrupt controller ('interrupt-controller' property) or a interrupt
nexus node ('interrupt-map' property).

If I remove, the 'interrupt-map' property, DTC is not happy.

Also in that case, my node has '#interrupt-cells' set without being an
interrupt controller of a interrupt nexus node and this leads to a warning too.

The only way to avoid warnings is to fully remove the irq-mux node and related
references available in gpio nodes.

IHMO, I think we can leave with a reduce 'interrupt-map' array set in the irq-mux
node in r9a06g032.dtsi file such as follow.
--- 8< ---
	interrupt-controller@51000480 {
		compatible = "renesas,r9a06g032-gpioirqmux", "renesas,rzn1-gpioirqmux";
		reg = <0x51000480 0x20>;
		#interrupt-cells = <1>;
		#address-cells = <0>;
		interrupt-map-mask = <0x7f>;

		/*
		 * interrupt-map has to be updated according to GPIO
		 * usage. The src irq (0 field) has to be updated with
		 * the needed GPIO interrupt number.
		 * More items can be added (up to 8). Those items must
		 * define a GIC SPI interrupt in the range 103 to 110.
		 */
		interrupt-map = <0 &gic GIC_SPI 103 IRQ_TYPE_LEVEL_HIGH>;

		status = "disabled";
	};
--- 8< ---

Could this modification be ok on your side?

Best regards,
Hervé
Re: [PATCH v3 8/8] ARM: dts: r9a06g032: Add support for GPIO interrupts
Posted by Wolfram Sang 1 week, 2 days ago
Hi Hervé,

> 		/*
> 		 * interrupt-map has to be updated according to GPIO
> 		 * usage. The src irq (0 field) has to be updated with
> 		 * the needed GPIO interrupt number.
> 		 * More items can be added (up to 8). Those items must
> 		 * define a GIC SPI interrupt in the range 103 to 110.
> 		 */
> 		interrupt-map = <0 &gic GIC_SPI 103 IRQ_TYPE_LEVEL_HIGH>;

Thanks for digging into this. Gievn your results, I can live with a
minimal interrupt-map, but ideally it should do nothing instead of
mapping GPIO0? Will think about it...

All the best,

   Wolfram