Hi,
This series adds support for GPIO and GPIO IRQ mux available in the
RZ/N1 SoCs.
The first patches in this series are related to a new helper introduced
to parse an interrupt-map property.
- patch 1: Introduce the helper (for_each_of_imap_item)
- patch 2: Add a unittest for the new helper
- patch 3 and 4: convert existing drivers to use this new helper
Patch 4 will conflicts with commit 40c26230a1bf ("irqchip: Use int type
to store negative error codes") available in linux-next.
Patch 5 adds support for GPIO (device-tree description)
The last patches (6, 7 and 8) of the series are related to GPIO
interrupts and GPIO IRQ multiplexer.
In the RZ/N1 SoCs, GPIO interrupts are wired to a GPIO IRQ multiplexer.
This multiplexer does nothing but select 8 GPIO IRQ lines out of the 96
available to wire them to the GIC input lines.
One upstreaming attempt have been done previously by Phil Edworthy [1]
but the series has never been applied.
Based on my understanding, I have fully reworked the driver proposed by
Phil and removed the IRQ domain. Indeed, the device doesn't handle
interrupts. It just routes signals.
Also, as an interrupt-map property is used, the driver cannot be
involved as an interrupt controller itself. It is a nexus node.
With that in mind,
- Patch 6 is related to the irq-mux binding.
- Patch 7 introduces the irq-mux driver.
This driver uses the 'for_each_of_imap_item' helper introduced
previously. Indeed, the lines routing is defined by the
interrupt-map property and the driver needs to set registers to
apply this routing.
- Patch 8 is the RZ/N1 device-tree description update to have the
support for the GPIO interrupts.
[1] https://lore.kernel.org/all/20190219155511.28507-1-phil.edworthy@renesas.com/
Best regards,
Hervé
Changes v3 -> v4
v3: https://lore.kernel.org/lkml/20250918104009.94754-1-herve.codina@bootlin.com/
Patch 1:
- Add 'Tested-by: Wolfram Sang'
Patch 2..5:
- No changes
Patch 6:
- Add minItems and maxItems
- Update the 'interrup-map' description
Patch 7:
- Use rzn1_irqmux prefix instead of irqmux.
- Introduce rzn1_irqmux_output_lines[] to give the mapping between
the interrupt output line index and the GIC controller interrupt
number.
- Remove of_irq_count() call and related checks
Patch 8:
- Describe the irq mux node using a reduced (one item) interrupt-map
property.
Changes v2 -> v3
v2: https://lore.kernel.org/lkml/20250909120041.154459-1-herve.codina@bootlin.com/
Reordered patches as suggested by Thomas Gleixner.
Patch 1: (3 in v2)
- Replace a wrong 'extern' by 'static inline' in of_irq.h (detected
by test robots)
Patch 2: (4 in v2)
Patch 3: (5 in v2)
Patch 4: (6 in v2)
- No changes
Patch 5: (1 in v2)
- Add 'Reviewed-by: Wolfram Sang'
- Add 'Tested-by: Wolfram Sang'
Patch 6: (2 in v2)
- Add '#address-cells = <0>;' in the interrupt-controller node
present in the example.
Patch 7:
Patch 8:
- No changes
Changes v1 -> v2
v1: https://lore.kernel.org/lkml/20250725152618.32886-1-herve.codina@bootlin.com/
Rebase on top of v6.17-rc5
Patch 1 in v1
- Removed in v2 (no need for RZ/N1 compatible strings).
Patch 1 (2 in v1)
- Fix node names (issue reported by Rob's bot)
- Fix compatible RZ/N1 compatible strings
- Removed undocumented and unused 'bank-name' properties
Patch 2 (3 in v1)
- Remove 'interrupts' property
- Update 'interrupt-map' description
Patch 3 (4 in v1)
- Rework of_irq_foreach_imap() to provide the for_each_of_imap_item
iterator (similar to for_each_of_range)
Patch 4 (new in v2)
- Add a unittest for for_each_of_imap_item
Patch 5 (new in v2)
- Convert irqchip/ls-extirq to use for_each_of_imap_item
Patch 6 (new in v2)
- Convert irqchip/renesas-rza1 to use for_each_of_imap_item
Patch 7 (5 in v1)
- Use for_each_of_imap_item
- Remove 'interrupts' property usage
Patch 8 (6 in v1)
- Remove 'interrupts' property
Herve Codina (Schneider Electric) (8):
of/irq: Introduce for_each_of_imap_item
of: unittest: Add a test case for for_each_of_imap_item iterator
irqchip/ls-extirq: Use for_each_of_imap_item iterator
irqchip/renesas-rza1: Use for_each_of_imap_item iterator
ARM: dts: r9a06g032: Add GPIO controllers
dt-bindings: soc: renesas: Add the Renesas RZ/N1 GPIO Interrupt
Multiplexer
soc: renesas: Add support for Renesas RZ/N1 GPIO Interrupt Multiplexer
ARM: dts: r9a06g032: Add support for GPIO interrupts
.../soc/renesas/renesas,rzn1-gpioirqmux.yaml | 87 ++++++++++
arch/arm/boot/dts/renesas/r9a06g032.dtsi | 164 ++++++++++++++++++
drivers/irqchip/irq-ls-extirq.c | 47 ++---
drivers/irqchip/irq-renesas-rza1.c | 43 ++---
drivers/of/irq.c | 70 ++++++++
.../of/unittest-data/tests-interrupts.dtsi | 9 +
drivers/of/unittest.c | 116 +++++++++++++
drivers/soc/renesas/Kconfig | 4 +
drivers/soc/renesas/Makefile | 1 +
drivers/soc/renesas/rzn1_irqmux.c | 136 +++++++++++++++
include/linux/of_irq.h | 41 ++++-
11 files changed, 660 insertions(+), 58 deletions(-)
create mode 100644 Documentation/devicetree/bindings/soc/renesas/renesas,rzn1-gpioirqmux.yaml
create mode 100644 drivers/soc/renesas/rzn1_irqmux.c
--
2.51.0
for_each_of_imap_item is an iterator designed to help a driver to parse
an interrupt-map property.
Indeed some drivers need to know details about the interrupt mapping
described in the device-tree in order to set internal registers
accordingly.
Signed-off-by: Herve Codina (Schneider Electric) <herve.codina@bootlin.com>
Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
drivers/of/irq.c | 70 ++++++++++++++++++++++++++++++++++++++++++
include/linux/of_irq.h | 41 ++++++++++++++++++++++++-
2 files changed, 110 insertions(+), 1 deletion(-)
@@ -157,6 +157,76 @@ const __be32 *of_irq_parse_imap_parent(const __be32 *imap, int len, struct of_phreturnimap;}+intof_imap_parser_init(structof_imap_parser*parser,structdevice_node*node,+structof_imap_item*item)+{+intimaplen;+u32tmp;+intret;++/*+*parent_offsetistheoffsetwheretheparentpartisstarting.+*Inotherwords,theoffsetwheretheparentinterruptcontroller+*phandleispresent.+*+*Computethisoffset(child#interrupt-cells+child#address-cells)+*/+parser->parent_offset=of_bus_n_addr_cells(node);++ret=of_property_read_u32(node,"#interrupt-cells",&tmp);+if(ret)+returnret;++parser->parent_offset+=tmp;++if(WARN(parser->parent_offset>ARRAY_SIZE(item->child_imap),+"child part size = %u, cannot fit in array of %zu items",+parser->parent_offset,ARRAY_SIZE(item->child_imap)))+return-EINVAL;++parser->imap=of_get_property(node,"interrupt-map",&imaplen);+if(!parser->imap)+return-ENOENT;++imaplen/=sizeof(*parser->imap);+parser->imap_end=parser->imap+imaplen;++memset(item,0,sizeof(*item));+item->child_imap_count=parser->parent_offset;++return0;+}+EXPORT_SYMBOL_GPL(of_imap_parser_init);++structof_imap_item*of_imap_parser_one(structof_imap_parser*parser,+structof_imap_item*item)+{+const__be32*imap_parent,*imap_next;+inti;++/* Release previously get parent node */+of_node_put(item->parent_args.np);++if(parser->imap+parser->parent_offset+1>=parser->imap_end)+returnNULL;++imap_parent=parser->imap+parser->parent_offset;++imap_next=of_irq_parse_imap_parent(imap_parent,+parser->imap_end-imap_parent,+&item->parent_args);+if(!imap_next)+returnNULL;++for(i=0;i<parser->parent_offset;i++)+item->child_imap[i]=be32_to_cpu(*(parser->imap+i));++parser->imap=imap_next;++returnitem;+}+EXPORT_SYMBOL_GPL(of_imap_parser_one);+/***of_irq_parse_raw-Lowlevelinterrupttreeparsing*@addr:addressspecifier(startof"reg"propertyofthedevice)inbe32format
Recently for_each_of_imap_item iterator has been introduce to help
drivers in parsing the interrupt-map property.
Add a test case for this iterator.
Signed-off-by: Herve Codina (Schneider Electric) <herve.codina@bootlin.com>
---
.../of/unittest-data/tests-interrupts.dtsi | 9 ++
drivers/of/unittest.c | 116 ++++++++++++++++++
2 files changed, 125 insertions(+)
The ls-extirq driver parses the interrupt-map property. It does it using
open code.
Recently for_each_of_imap_item iterator has been introduce to help
drivers in this parsing.
Convert the ls-extirq driver to use the for_each_of_imap_item
iterator instead of open code.
Signed-off-by: Herve Codina (Schneider Electric) <herve.codina@bootlin.com>
---
drivers/irqchip/irq-ls-extirq.c | 47 ++++++++++++---------------------
1 file changed, 17 insertions(+), 30 deletions(-)
The renesas-rza1 driver parses the interrupt-map property. It does it
using open code.
Recently for_each_of_imap_item iterator has been introduce to help
drivers in this parsing.
Convert the renesas-rza1 driver to use the for_each_of_imap_item
iterator instead of open code.
Signed-off-by: Herve Codina (Schneider Electric) <herve.codina@bootlin.com>
---
drivers/irqchip/irq-renesas-rza1.c | 43 +++++++++++-------------------
1 file changed, 16 insertions(+), 27 deletions(-)
On the Renesas RZ/N1 SoC, GPIOs can generate interruptions. Those
interruption lines are multiplexed by the GPIO Interrupt Multiplexer in
order to map 32 * 3 GPIO interrupt lines to 8 GIC interrupt lines.
The GPIO interrupt multiplexer IP does nothing but select 8 GPIO
IRQ lines out of the 96 available to wire them to the GIC input lines.
Signed-off-by: Herve Codina (Schneider Electric) <herve.codina@bootlin.com>
---
.../soc/renesas/renesas,rzn1-gpioirqmux.yaml | 87 +++++++++++++++++++
1 file changed, 87 insertions(+)
create mode 100644 Documentation/devicetree/bindings/soc/renesas/renesas,rzn1-gpioirqmux.yaml
@@ -0,0 +1,87 @@+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)+%YAML1.2+---+$id:http://devicetree.org/schemas/soc/renesas/renesas,rzn1-gpioirqmux.yaml#+$schema:http://devicetree.org/meta-schemas/core.yaml#++title:Renesas RZ/N1 SoCs GPIO Interrupt Multiplexer++description:|+The Renesas RZ/N1 GPIO Interrupt Multiplexer multiplexes GPIO interrupt+lines to the interrupt controller available in the SoC.++It selects up to 8 of the 96 GPIO interrupt lines available and connect them+to 8 output interrupt lines.++maintainers:+-Herve Codina <herve.codina@bootlin.com>++properties:+compatible:+items:+-enum:+-renesas,r9a06g032-gpioirqmux+-const:renesas,rzn1-gpioirqmux++reg:+maxItems:1++"#address-cells":+const:0++"#interrupt-cells":+const:1++interrupt-map-mask:+items:+-const:0x7f++interrupt-map:+description:|+Specifies the mapping from external GPIO interrupt lines to the output+interrupts. The array has up to 8 items defining the mapping related to+the output line 0 (GIC 103) up to the output line 7 (GIC 110).++The child interrupt number set in arrays items is computed using the+following formula:+gpio_bank * 32 + gpio_number+with:+-gpio_bank:The GPIO bank number+-0 for GPIO0A,+-1 for GPIO1A,+-2 for GPIO2A+-gpio_number:Number of the gpio in the bank (0..31)+minItems:1+maxItems:8++required:+-compatible+-reg+-"#address-cells"+-"#interrupt-cells"+-interrupt-map-mask+-interrupt-map++additionalProperties:false++examples:+-|+#include <dt-bindings/interrupt-controller/arm-gic.h>++gic:interrupt-controller {+interrupt-controller;+#address-cells = <0>;+#interrupt-cells = <3>;+};++interrupt-controller@51000480 {+compatible = "renesas,r9a06g032-gpioirqmux", "renesas,rzn1-gpioirqmux";+reg = <0x51000480 0x20>;+#address-cells = <0>;+#interrupt-cells = <1>;+interrupt-map-mask = <0x7f>;+interrupt-map =+<32 &gic GIC_SPI 103 IRQ_TYPE_LEVEL_HIGH>, /* line 0, GPIO1A.0 */+<89 &gic GIC_SPI 104 IRQ_TYPE_LEVEL_HIGH>, /* line 1, GPIO2A.25 */+<9 &gic GIC_SPI 106 IRQ_TYPE_LEVEL_HIGH>; /* line 3, GPIO0A.9 */+};
On the Renesas RZ/N1 SoC, GPIOs can generate interruptions. Those
interruption lines are multiplexed by the GPIO Interrupt Multiplexer in
order to map 32 * 3 GPIO interrupt lines to 8 GIC interrupt lines.
The GPIO interrupt multiplexer IP does nothing but select 8 GPIO
IRQ lines out of the 96 available to wire them to the GIC input lines.
Signed-off-by: Herve Codina (Schneider Electric) <herve.codina@bootlin.com>
---
drivers/soc/renesas/Kconfig | 4 +
drivers/soc/renesas/Makefile | 1 +
drivers/soc/renesas/rzn1_irqmux.c | 136 ++++++++++++++++++++++++++++++
3 files changed, 141 insertions(+)
create mode 100644 drivers/soc/renesas/rzn1_irqmux.c
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 | 43 ++++++++++++++++++++++++
1 file changed, 43 insertions(+)
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>
---
From: Wolfram Sang <wsa+renesas@sang-engineering.com> Date: 2025-09-23 06:56:20
On Mon, Sep 22, 2025 at 05:26:35PM +0200, Herve Codina (Schneider Electric) wrote:
The renesas-rza1 driver parses the interrupt-map property. It does it
using open code.
Recently for_each_of_imap_item iterator has been introduce to help
drivers in this parsing.
Convert the renesas-rza1 driver to use the for_each_of_imap_item
iterator instead of open code.
Signed-off-by: Herve Codina (Schneider Electric) <herve.codina@bootlin.com>
SW6 on my Genmai board still delivers irqs via rza1-irqc, so:
Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
From: Wolfram Sang <wsa+renesas@sang-engineering.com> Date: 2025-09-24 08:08:02
On Mon, Sep 22, 2025 at 05:26:37PM +0200, Herve Codina (Schneider Electric) wrote:
On the Renesas RZ/N1 SoC, GPIOs can generate interruptions. Those
interruption lines are multiplexed by the GPIO Interrupt Multiplexer in
order to map 32 * 3 GPIO interrupt lines to 8 GIC interrupt lines.
The GPIO interrupt multiplexer IP does nothing but select 8 GPIO
IRQ lines out of the 96 available to wire them to the GIC input lines.
Signed-off-by: Herve Codina (Schneider Electric) <herve.codina@bootlin.com>
Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Looks good from the technical side. No comment on the syntax because my
DT check invocation fails again after some update, sigh...
From: Wolfram Sang <wsa+renesas@sang-engineering.com> Date: 2025-09-24 18:41:29
Hi Herve,
On Mon, Sep 22, 2025 at 05:26:38PM +0200, Herve Codina (Schneider Electric) wrote:
On the Renesas RZ/N1 SoC, GPIOs can generate interruptions. Those
interruption lines are multiplexed by the GPIO Interrupt Multiplexer in
order to map 32 * 3 GPIO interrupt lines to 8 GIC interrupt lines.
The GPIO interrupt multiplexer IP does nothing but select 8 GPIO
IRQ lines out of the 96 available to wire them to the GIC input lines.
Signed-off-by: Herve Codina (Schneider Electric) <herve.codina@bootlin.com>
Thanks for improving the driver and removing the requirement of a fixed
ordering!
+static u32 rzn1_irqmux_output_lines[] = {
const?
+ 103, 104, 105, 106, 107, 108, 109, 110
+};
...
+ for (i = 0; i < ARRAY_SIZE(rzn1_irqmux_output_lines); i++) {
+ if (parent_args->args[1] == rzn1_irqmux_output_lines[i])
+ return i;
+ }
Do we want a check here if the index has already been used in cases of
an improper 'interrupt-map'? I'd think it would be nice to have but I
would also not really require it.
...
+ ret = rzn1_irqmux_setup(dev, np, regs);
+ if (ret)
+ return dev_err_probe(dev, ret, "failed to setup mux\n");
+
+ return 0;
Maybe just
return rzn1_irqmux_setup(dev, np, regs);
The driver core will report a failed probe already.
It still works, so:
Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Happy hacking,
Wolfram
From: Wolfram Sang <wsa+renesas@sang-engineering.com> Date: 2025-09-24 21:48:43
+ /*
+ * 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 one GIC interrupt line among 103 to 110.
+ */
+ interrupt-map = <0 &gic GIC_SPI 103 IRQ_TYPE_LEVEL_HIGH>;
Okay, so my main concern here was that we setup some "random" default
mapping for each board. Which is not true because this node is disabled
by default. So, maybe we could rephrase the paragraph like
/*
* Example mapping entry. Board DTs need to overwrite 'interrupt-map'
* with their specific mapping. Check the irqmux binding documentation
* for details.
*/
? I will see if I can provide a useful board addition for the DB400
boards...
Hi Herve,
thanks for your patch!
On Mon, Sep 22, 2025 at 5:27 PM Herve Codina (Schneider Electric)
[off-list ref] wrote:
On the Renesas RZ/N1 SoC, GPIOs can generate interruptions. Those
interruption lines are multiplexed by the GPIO Interrupt Multiplexer in
order to map 32 * 3 GPIO interrupt lines to 8 GIC interrupt lines.
The GPIO interrupt multiplexer IP does nothing but select 8 GPIO
IRQ lines out of the 96 available to wire them to the GIC input lines.
Signed-off-by: Herve Codina (Schneider Electric) <herve.codina@bootlin.com>
This looks like some complicated code to reimplement hierarchical
irq domains.
Can't you just select IRQ_DOMAIN_HIERARCHY and let
the existing infrastructure in GPIOLIB_IRQCHIP handle
this?
This kind of remapping and handling is exactly what the
.child_to_parent_hwirq() callback in struct gpio_irq_chip
is for. This function can fail if you run out if IRQ lines.
Inspect drivers/gpio/Kconfig driver that select
IRQ_DOMAIN_HIERARCHY for examples of how to
do this.
Even if your GPIO driver is not using GPIOLIB_IRQCHIP (in that
case: why not?) I think you still need to use IRQ_DOMAIN_HIERARCHY
for this.
Yours,
Linus Walleij
Hi Linus,
On Wed, 1 Oct 2025 13:08:57 +0200
Linus Walleij [off-list ref] wrote:
Hi Herve,
thanks for your patch!
On Mon, Sep 22, 2025 at 5:27 PM Herve Codina (Schneider Electric)
[off-list ref] wrote:
quoted
On the Renesas RZ/N1 SoC, GPIOs can generate interruptions. Those
interruption lines are multiplexed by the GPIO Interrupt Multiplexer in
order to map 32 * 3 GPIO interrupt lines to 8 GIC interrupt lines.
The GPIO interrupt multiplexer IP does nothing but select 8 GPIO
IRQ lines out of the 96 available to wire them to the GIC input lines.
Signed-off-by: Herve Codina (Schneider Electric) <herve.codina@bootlin.com>
This looks like some complicated code to reimplement hierarchical
irq domains.
Can't you just select IRQ_DOMAIN_HIERARCHY and let
the existing infrastructure in GPIOLIB_IRQCHIP handle
this?
This kind of remapping and handling is exactly what the
.child_to_parent_hwirq() callback in struct gpio_irq_chip
is for. This function can fail if you run out if IRQ lines.
Inspect drivers/gpio/Kconfig driver that select
IRQ_DOMAIN_HIERARCHY for examples of how to
do this.
Even if your GPIO driver is not using GPIOLIB_IRQCHIP (in that
case: why not?) I think you still need to use IRQ_DOMAIN_HIERARCHY
for this.
I don't see how IRQ_DOMAIN_HIERARCHY would help.
The irq-mux only muxes irq signal without performing any operations usually
done by an interrupt controller.
That's why I used interrupt-map in the irq-mux.
The only information needed by the irq-mux is the interrupt line muxing that
needs to be applied. This information is available in the interrupt-map.
If we introduce IRQ_DOMAIN_HIERARCHY, either it is done at gpio controller
level to route gpio interrupts to GIC interrupts and, in that case, the
irq-mux is skipped and cannot apply the muxing.
Or it is introduced at irq-mux level and irq-mux need to be an interrupt
controller but is component is not an interrupt controller.
Maybe I missed some points or I misunderstood the purpose of
IRQ_DOMAIN_HIERARCHY.
Can you give me some details on how IRQ_DOMAIN_HIERARCHY should be
used in my case?
Best regards,
Hervé
On Wed, Oct 1, 2025 at 5:42 PM Herve Codina [off-list ref] wrote:
On Wed, 1 Oct 2025 13:08:57 +0200
Linus Walleij [off-list ref] wrote:
I don't see how IRQ_DOMAIN_HIERARCHY would help.
The irq-mux only muxes irq signal without performing any operations usually
done by an interrupt controller.
That's why I used interrupt-map in the irq-mux.
The only information needed by the irq-mux is the interrupt line muxing that
needs to be applied. This information is available in the interrupt-map.
If we introduce IRQ_DOMAIN_HIERARCHY, either it is done at gpio controller
level to route gpio interrupts to GIC interrupts and, in that case, the
irq-mux is skipped and cannot apply the muxing.
I meant to introduce the muxing code directly into the
GPIO driver instead of using a separate muxing driver,
using the struct gpio_irq_chip supplanted by IRQ_DOMAIN_HIERARCHY.
Are these IRQ lines ever muxed for anything else than
GPIO? In that case go ahead with this solution, I guess.
But the title of your patch seems to suggest it is
only used by GPIO.
If it is only used for GPIO, why make it a separate
driver instead of just putting the muxing into the
GPIO driver?
Or it is introduced at irq-mux level and irq-mux need to be an interrupt
controller but is component is not an interrupt controller.
It is a hierarchy, as all interrupts are routed through
it. Just becaus you don't have to ACK every IRQ in the
hierarchy doesn't mean it's not a hierarchy.
Maybe I missed some points or I misunderstood the purpose of
IRQ_DOMAIN_HIERARCHY.
Can you give me some details on how IRQ_DOMAIN_HIERARCHY should be
used in my case?
The gpio_irq_chip ->child_to_parent_hwirq() is called
as part of the translation of each IRQ and in this callback
you can set up your mux. You can return
negative if you run out of muxable GPIO lines.
This means the irqdomain hierarchy fits as abstraction
for this usecase.
Yours,
Linus Walleij
From: Wolfram Sang <wsa+renesas@sang-engineering.com> Date: 2025-10-14 14:30:44
Hi Linus,
giving some details about the HW until Herve can return to this topic.
Are these IRQ lines ever muxed for anything else than
GPIO? In that case go ahead with this solution, I guess.
But the title of your patch seems to suggest it is
only used by GPIO.
True, it only muxes 96 GPIOs to the 8 available irqs.
If it is only used for GPIO, why make it a separate
driver instead of just putting the muxing into the
GPIO driver?
Because the HW design kind of suggests it, I'd think. The GPIO
controller is a standard Synopsis one ("snps,dw-apb-gpio") without any
extras. The GPIOMUX (which is extra) is according to the docs part of
the system controller with a dedicated set of registers. Luckily,
self-contained and not mangled with other functionality.
I am just stating where this comes from. I haven't looked into the
details of your suggestion. It may or may not make sense to add this to
the Synopsis driver with a dedicated compatible for RZ/N1D. I'll leave
this for Herve, though.
Happy hacking,
Wolfram
On Tue, Oct 14, 2025 at 4:30 PM Wolfram Sang
[off-list ref] wrote:
Because the HW design kind of suggests it, I'd think. The GPIO
controller is a standard Synopsis one ("snps,dw-apb-gpio") without any
extras. The GPIOMUX (which is extra) is according to the docs part of
the system controller with a dedicated set of registers. Luckily,
self-contained and not mangled with other functionality.
Aha I see. If this is so tightly coupled with the Synopsis
designware GPIO then it should be mentioned in the commit
I guess. Also:
config RZN1_IRQMUX
bool "Renesas RZ/N1 GPIO IRQ multiplexer support" if COMPILE_TEST
+ depends on GPIO_DWAPB || COMPILE_TEST
?
I understand that it is convenient to make this a separate driver.
I'm not sure it is the right thing to do, but it's no a hill I want to
die on so if everyone else thinks I'm wrong, I can just shut up
about it, it's not like this driver is a big obstacle or anything.
Yours,
Linus Walleij
Hi Linus, Wolfram,
On Tue, 14 Oct 2025 22:13:50 +0200
Linus Walleij [off-list ref] wrote:
On Tue, Oct 14, 2025 at 4:30 PM Wolfram Sang
[off-list ref] wrote:
quoted
Because the HW design kind of suggests it, I'd think. The GPIO
controller is a standard Synopsis one ("snps,dw-apb-gpio") without any
extras. The GPIOMUX (which is extra) is according to the docs part of
the system controller with a dedicated set of registers. Luckily,
self-contained and not mangled with other functionality.
Aha I see. If this is so tightly coupled with the Synopsis
designware GPIO then it should be mentioned in the commit
I guess. Also:
config RZN1_IRQMUX
bool "Renesas RZ/N1 GPIO IRQ multiplexer support" if COMPILE_TEST
+ depends on GPIO_DWAPB || COMPILE_TEST
?
I understand that it is convenient to make this a separate driver.
I'm not sure it is the right thing to do, but it's no a hill I want to
die on so if everyone else thinks I'm wrong, I can just shut up
about it, it's not like this driver is a big obstacle or anything.
Yours,
Linus Walleij
I don't think the mux should depends on GPIO_DWAPB (the gpio controller).
Also, several gpio controller instances are connected to the mux.
The 96 GPIOs connected to the mux come from 3 GPIO controller instances (32
gpios per instance). I don't think it makes sense to have the mux handled by
the gpio driver itself. It could have make sense if 3 muxes were available,
one per gpio controller but this is not the case.
As Wolfram said, the mux is an hardware component really outside of the
GPIO controller IPs.
Best regards,
Hervé
Hi Wolfram,
On Wed, 24 Sep 2025 23:48:40 +0200
Wolfram Sang [off-list ref] wrote:
quoted
+ /*
+ * 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 one GIC interrupt line among 103 to 110.
+ */
+ interrupt-map = <0 &gic GIC_SPI 103 IRQ_TYPE_LEVEL_HIGH>;
Okay, so my main concern here was that we setup some "random" default
mapping for each board. Which is not true because this node is disabled
by default. So, maybe we could rephrase the paragraph like
/*
* Example mapping entry. Board DTs need to overwrite 'interrupt-map'
* with their specific mapping. Check the irqmux binding documentation
* for details.
*/
Will be updated in next iteration.
? I will see if I can provide a useful board addition for the DB400
boards...
Hi Wolfram,
On Wed, 24 Sep 2025 20:41:20 +0200
Wolfram Sang [off-list ref] wrote:
Hi Herve,
On Mon, Sep 22, 2025 at 05:26:38PM +0200, Herve Codina (Schneider Electric) wrote:
quoted
On the Renesas RZ/N1 SoC, GPIOs can generate interruptions. Those
interruption lines are multiplexed by the GPIO Interrupt Multiplexer in
order to map 32 * 3 GPIO interrupt lines to 8 GIC interrupt lines.
The GPIO interrupt multiplexer IP does nothing but select 8 GPIO
IRQ lines out of the 96 available to wire them to the GIC input lines.
Signed-off-by: Herve Codina (Schneider Electric) <herve.codina@bootlin.com>
Thanks for improving the driver and removing the requirement of a fixed
ordering!
quoted
+static u32 rzn1_irqmux_output_lines[] = {
const?
Yes, will be added in the next iteration.
quoted
+ 103, 104, 105, 106, 107, 108, 109, 110
+};
...
quoted
+ for (i = 0; i < ARRAY_SIZE(rzn1_irqmux_output_lines); i++) {
+ if (parent_args->args[1] == rzn1_irqmux_output_lines[i])
+ return i;
+ }
Do we want a check here if the index has already been used in cases of
an improper 'interrupt-map'? I'd think it would be nice to have but I
would also not really require it.
Agree, it will be a good improvement.
I will add this check in the next iteration.
...
quoted
+ ret = rzn1_irqmux_setup(dev, np, regs);
+ if (ret)
+ return dev_err_probe(dev, ret, "failed to setup mux\n");
+
+ return 0;
Maybe just
return rzn1_irqmux_setup(dev, np, regs);
The driver core will report a failed probe already.
Yes
It still works, so:
Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
With update planned (new check for already been used indexes), a
re-test will be probably needed.
Best regards,
Hervé