Skip to contentSkip to conversation

pinctrl: sunxi: a523: fix GPIO IRQ operation

PATCH Applied Andre Przywara 5 participants 13 messages Mar 27 – Jun 11

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

v2 cover pinctrl: sunxi: a523: fix GPIO IRQ operation

Hi,

this is the minimal fix version for the GPIO IRQ operation on the Allwinner A523/A527/T527 SoCs. SD card detection is broken as a result, which is a major annoyance. Those patches here fix that problem, and should go into v7.0 still, if possible.
I dropped the more involved fixes from v1, the risk for regressions is now very low:
- The quirk flag is just dropped from the A523, not the other SoCs. I confirmed this again with an experiment, for both the primary and secondary pincontroller. This avoids fixing the workaround code for now, which is more involved, but for now unneeded.
- The DT patch just adds the missing interrupt. The IRQ association was always wrong and never worked, so this can't make it possibly worse.
Together those two patches (plus the required binding change) fix the problem, I would appreciate if this could be taken ASAP, into v7.0 still. The generic pinctrl code is now untouched, which makes this also much easier to backport, and drops the dependencies on other v7.0-rc fixes.

Bases on v7.0-rc1, but applies on later revisions as well.

Please have a look and test, especially on A523/A527/T527 boards!

Changelog v1 .. v2:
- drop generic pinctrl fixes (for now)
- drop quirk removal from other SoCs (for now)
- add Chen-Yu's tag

Cheers,
Andre

Andre Przywara (3):
pinctrl: sunxi: a523: Remove unneeded IRQ remuxing flag
dt-bindings: pinctrl: sun55i-a523: increase IRQ banks number
arm64: dts: allwinner: a523: Add missing GPIO interrupt

 .../bindings/pinctrl/allwinner,sun55i-a523-pinctrl.yaml   | 8 ++++----
 arch/arm64/boot/dts/allwinner/sun55i-a523.dtsi            | 3 ++-
 drivers/pinctrl/sunxi/pinctrl-sun55i-a523-r.c             | 1 -
 drivers/pinctrl/sunxi/pinctrl-sun55i-a523.c               | 1 -
 4 files changed, 6 insertions(+), 7 deletions(-)

base-commit: 6de23f81a5e08be8fbf5e8d7e9febc72a5b5f27f

Signature · 1 line
2.43.0
#1 lore raw

PATCH v2 1/3 pinctrl: sunxi: a523: Remove unneeded IRQ remuxing flag

The Allwinner A10 and H3 SoCs cannot read the state of a GPIO line when that line is muxed for IRQ triggering (muxval 6), but only if it's explicitly muxed for GPIO input (muxval 0). Other SoCs do not show this behaviour, so we added a optional workaround, triggered by a quirk bit, which triggers remuxing the pin when it's configured for IRQ, while we need to read its value.

For some reasons this quirk flag was copied over to newer SoCs, even though they don't show this behaviour, and the GPIO data register reflects the true GPIO state even with a pin muxed to IRQ trigger.

Remove the unneeded quirk from the A523 family, where it's definitely not needed (confirmed by experiments), and where it actually breaks, because the workaround is not compatible with the newer generation pinctrl IP used in that chip.

Together with a DT change this fixes GPIO IRQ operation on the A523 family of SoCs, as for instance used for the SD card detection.

Fixes b8a51e95b376 ("pinctrl: sunxi: Add support for the secondary A523 GPIO ports")
---
 drivers/pinctrl/sunxi/pinctrl-sun55i-a523-r.c | 1 -
 drivers/pinctrl/sunxi/pinctrl-sun55i-a523.c   | 1 -
 2 files changed, 2 deletions(-)
drivers/pinctrl/sunxi/pinctrl-sun55i-a523-r.c +0 -1
index 69cd2b4ebd7d..462aa1c4a5fa 100644
@@ -26,7 +26,6 @@ static const u8 a523_r_irq_bank_muxes[SUNXI_PINCTRL_MAX_BANKS] =
 static struct sunxi_pinctrl_desc a523_r_pinctrl_data = {
 	.irq_banks = ARRAY_SIZE(a523_r_irq_bank_map),
 	.irq_bank_map = a523_r_irq_bank_map,
-	.irq_read_needs_mux = true,
 	.io_bias_cfg_variant = BIAS_VOLTAGE_PIO_POW_MODE_SEL,
 	.pin_base = PL_BASE,
 };
drivers/pinctrl/sunxi/pinctrl-sun55i-a523.c +0 -1
index 7d2308c37d29..b6f78f1f30ac 100644
@@ -26,7 +26,6 @@ static const u8 a523_irq_bank_muxes[SUNXI_PINCTRL_MAX_BANKS] =
 static struct sunxi_pinctrl_desc a523_pinctrl_data = {
 	.irq_banks = ARRAY_SIZE(a523_irq_bank_map),
 	.irq_bank_map = a523_irq_bank_map,
-	.irq_read_needs_mux = true,
 	.io_bias_cfg_variant = BIAS_VOLTAGE_PIO_POW_MODE_SEL,
 };
 
Signature · 1 line
2.43.0
maintainer Acked-by on v2 1/3
#2 lore raw

Re: [PATCH v2 1/3] pinctrl: sunxi: a523: Remove unneeded IRQ remuxing flag

Quoted 17 lines · Andre Przywara

The Allwinner A10 and H3 SoCs cannot read the state of a GPIO line when that line is muxed for IRQ triggering (muxval 6), but only if it's explicitly muxed for GPIO input (muxval 0). Other SoCs do not show this behaviour, so we added a optional workaround, triggered by a quirk bit, which triggers remuxing the pin when it's configured for IRQ, while we need to read its value.

For some reasons this quirk flag was copied over to newer SoCs, even though they don't show this behaviour, and the GPIO data register reflects the true GPIO state even with a pin muxed to IRQ trigger.

Remove the unneeded quirk from the A523 family, where it's definitely not needed (confirmed by experiments), and where it actually breaks, because the workaround is not compatible with the newer generation pinctrl IP used in that chip.

Quoted 5 lines

Together with a DT change this fixes GPIO IRQ operation on the A523 family of SoCs, as for instance used for the SD card detection.

Fixes b8a51e95b376 ("pinctrl: sunxi: Add support for the secondary A523 GPIO ports")
Quoted 32 lines
---
 drivers/pinctrl/sunxi/pinctrl-sun55i-a523-r.c | 1 -
 drivers/pinctrl/sunxi/pinctrl-sun55i-a523.c   | 1 -
 2 files changed, 2 deletions(-)
drivers/pinctrl/sunxi/pinctrl-sun55i-a523-r.c +0 -1
index 69cd2b4ebd7d..462aa1c4a5fa 100644
@@ -26,7 +26,6 @@ static const u8 a523_r_irq_bank_muxes[SUNXI_PINCTRL_MAX_BANKS] =
 static struct sunxi_pinctrl_desc a523_r_pinctrl_data = {
        .irq_banks = ARRAY_SIZE(a523_r_irq_bank_map),
        .irq_bank_map = a523_r_irq_bank_map,
-       .irq_read_needs_mux = true,
        .io_bias_cfg_variant = BIAS_VOLTAGE_PIO_POW_MODE_SEL,
        .pin_base = PL_BASE,
 };
drivers/pinctrl/sunxi/pinctrl-sun55i-a523.c +0 -2
index 7d2308c37d29..b6f78f1f30ac 100644
@@ -26,7 +26,6 @@ static const u8 a523_irq_bank_muxes[SUNXI_PINCTRL_MAX_BANKS] =
 static struct sunxi_pinctrl_desc a523_pinctrl_data = {
        .irq_banks = ARRAY_SIZE(a523_irq_bank_map),
        .irq_bank_map = a523_irq_bank_map,
-       .irq_read_needs_mux = true,
        .io_bias_cfg_variant = BIAS_VOLTAGE_PIO_POW_MODE_SEL,
 };
 
--

2.43.0

#3 lore raw

Re: [PATCH v2 1/3] pinctrl: sunxi: a523: Remove unneeded IRQ remuxing flag

On Fri, 27 Mar 2026 19:38:57 +0800
Chen-Yu Tsai <[email protected]> wrote:

Hi Linus,

Quoted 18 lines · Andre Przywara
Quoted 17 lines

The Allwinner A10 and H3 SoCs cannot read the state of a GPIO line when that line is muxed for IRQ triggering (muxval 6), but only if it's explicitly muxed for GPIO input (muxval 0). Other SoCs do not show this behaviour, so we added a optional workaround, triggered by a quirk bit, which triggers remuxing the pin when it's configured for IRQ, while we need to read its value.

For some reasons this quirk flag was copied over to newer SoCs, even though they don't show this behaviour, and the GPIO data register reflects the true GPIO state even with a pin muxed to IRQ trigger.

Remove the unneeded quirk from the A523 family, where it's definitely not needed (confirmed by experiments), and where it actually breaks, because the workaround is not compatible with the newer generation pinctrl IP used in that chip.

Quoted 7 lines
Quoted 5 lines

Together with a DT change this fixes GPIO IRQ operation on the A523 family of SoCs, as for instance used for the SD card detection.

Fixes b8a51e95b376 ("pinctrl: sunxi: Add support for the secondary A523 GPIO ports")

Can you possibly take this patch and maybe the binding (PATCH v2 2/3)? Ideally still for v7.0? IIUC Chen-Yu would take the DT patch, but relies on those two here.

Thanks,
Andre

Quoted 34 lines
Quoted 33 lines
---
 drivers/pinctrl/sunxi/pinctrl-sun55i-a523-r.c | 1 -
 drivers/pinctrl/sunxi/pinctrl-sun55i-a523.c   | 1 -
 2 files changed, 2 deletions(-)
drivers/pinctrl/sunxi/pinctrl-sun55i-a523-r.c +0 -1
index 69cd2b4ebd7d..462aa1c4a5fa 100644
@@ -26,7 +26,6 @@ static const u8 a523_r_irq_bank_muxes[SUNXI_PINCTRL_MAX_BANKS] =
 static struct sunxi_pinctrl_desc a523_r_pinctrl_data = {
        .irq_banks = ARRAY_SIZE(a523_r_irq_bank_map),
        .irq_bank_map = a523_r_irq_bank_map,
-       .irq_read_needs_mux = true,
        .io_bias_cfg_variant = BIAS_VOLTAGE_PIO_POW_MODE_SEL,
        .pin_base = PL_BASE,
 };
drivers/pinctrl/sunxi/pinctrl-sun55i-a523.c +0 -2
index 7d2308c37d29..b6f78f1f30ac 100644
@@ -26,7 +26,6 @@ static const u8 a523_irq_bank_muxes[SUNXI_PINCTRL_MAX_BANKS] =
 static struct sunxi_pinctrl_desc a523_pinctrl_data = {
        .irq_banks = ARRAY_SIZE(a523_irq_bank_map),
        .irq_bank_map = a523_irq_bank_map,
-       .irq_read_needs_mux = true,
        .io_bias_cfg_variant = BIAS_VOLTAGE_PIO_POW_MODE_SEL,
 };
 
--

2.43.0

maintainer Reviewed-by on v2 1/3
#4 lore raw

Re: [PATCH v2 1/3] pinctrl: sunxi: a523: Remove unneeded IRQ remuxing flag

In reply to Andre Przywara

Dne petek, 27. marec 2026 ob 12:30:04 Srednjeevropski standardni čas je Andre Przywara napisal(a):

Quoted 16 lines

The Allwinner A10 and H3 SoCs cannot read the state of a GPIO line when that line is muxed for IRQ triggering (muxval 6), but only if it's explicitly muxed for GPIO input (muxval 0). Other SoCs do not show this behaviour, so we added a optional workaround, triggered by a quirk bit, which triggers remuxing the pin when it's configured for IRQ, while we need to read its value.

For some reasons this quirk flag was copied over to newer SoCs, even though they don't show this behaviour, and the GPIO data register reflects the true GPIO state even with a pin muxed to IRQ trigger.

Remove the unneeded quirk from the A523 family, where it's definitely not needed (confirmed by experiments), and where it actually breaks, because the workaround is not compatible with the newer generation pinctrl IP used in that chip.

Quoted 5 lines

Together with a DT change this fixes GPIO IRQ operation on the A523 family of SoCs, as for instance used for the SD card detection.

Fixes b8a51e95b376 ("pinctrl: sunxi: Add support for the secondary A523 GPIO ports")

Best regards,
Jernej

#5 lore raw

PATCH v2 2/3 dt-bindings: pinctrl: sun55i-a523: increase IRQ banks number

In reply to Andre Przywara

The Allwinner A523 SoC implements 10 GPIO banks in the first pinctrl instance, but it skips the first bank (PortA), so their index goes from 1 to 10. The same is actually true for the IRQ banks: there are registers for 11 banks, though the first bank is not implemented (RAZ/WI). In contrast to previous SoCs, the count of the IRQ banks starts with this first unimplemented bank, so we need to provide an interrupt for it. And indeed the A523 user manual lists an interrupt number for PortA, so we need to increase the maximum number of interrupts per pin controller to 11, to be able to assign the correct interrupt number for each bank.

---
 .../bindings/pinctrl/allwinner,sun55i-a523-pinctrl.yaml   | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
Documentation/devicetree/bindings/pinctrl/allwinner,sun55i-a523-pinctrl.yaml +4 -4
index 154e03da8ce9..f87b8274cc37 100644
@@ -34,7 +34,7 @@ properties:
 
   interrupts:
     minItems: 2
-    maxItems: 10
+    maxItems: 11
     description:
       One interrupt per external interrupt bank supported on the
       controller, sorted by bank number ascending order.
@@ -61,7 +61,7 @@ properties:
       bank found in the controller
     $ref: /schemas/types.yaml#/definitions/uint32-array
     minItems: 2
-    maxItems: 10
+    maxItems: 11
 
 patternProperties:
   # It's pretty scary, but the basic idea is that:
@@ -130,8 +130,8 @@ allOf:
     then:
       properties:
         interrupts:
-          minItems: 10
-          maxItems: 10
+          minItems: 11
+          maxItems: 11
 
   - if:
       properties:
Signature · 1 line
2.43.0
maintainer Reviewed-by on v2 2/3
#6 lore raw

Re: [PATCH v2 2/3] dt-bindings: pinctrl: sun55i-a523: increase IRQ banks number

Dne petek, 27. marec 2026 ob 12:30:05 Srednjeevropski standardni čas je Andre Przywara napisal(a):

Quoted 11 lines

The Allwinner A523 SoC implements 10 GPIO banks in the first pinctrl instance, but it skips the first bank (PortA), so their index goes from 1 to 10. The same is actually true for the IRQ banks: there are registers for 11 banks, though the first bank is not implemented (RAZ/WI). In contrast to previous SoCs, the count of the IRQ banks starts with this first unimplemented bank, so we need to provide an interrupt for it. And indeed the A523 user manual lists an interrupt number for PortA, so we need to increase the maximum number of interrupts per pin controller to 11, to be able to assign the correct interrupt number for each bank.

Best regards,
Jernej

maintainer Acked-by on v2 2/3
#7 lore raw

Re: [PATCH v2 2/3] dt-bindings: pinctrl: sun55i-a523: increase IRQ banks number

In reply to Andre Przywara
Quoted 10 lines · Andre Przywara

The Allwinner A523 SoC implements 10 GPIO banks in the first pinctrl instance, but it skips the first bank (PortA), so their index goes from 1 to 10. The same is actually true for the IRQ banks: there are registers for 11 banks, though the first bank is not implemented (RAZ/WI). In contrast to previous SoCs, the count of the IRQ banks starts with this first unimplemented bank, so we need to provide an interrupt for it. And indeed the A523 user manual lists an interrupt number for PortA, so we need to increase the maximum number of interrupts per pin controller to 11, to be able to assign the correct interrupt number for each bank.

Quoted 5 lines
---
 .../bindings/pinctrl/allwinner,sun55i-a523-pinctrl.yaml   | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
#8 lore raw

PATCH v2 3/3 arm64: dts: allwinner: a523: Add missing GPIO interrupt

In reply to Andre Przywara

Even though the Allwinner A523 SoC implements 10 GPIO banks, it has actually registers for 11 IRQ banks, and even an interrupt assigned to the first, non-implemented IRQ bank.
Add that first interrupt to the list of GPIO interrupts, to correct the association between IRQs and GPIO banks.

This fixes GPIO IRQ operation on boards with A523 SoCs, as seen by broken SD card detect functionality, for instance.

Fixes 35ac96f79664 ("arm64: dts: allwinner: Add Allwinner A523 .dtsi file")
---
 arch/arm64/boot/dts/allwinner/sun55i-a523.dtsi | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/arm64/boot/dts/allwinner/sun55i-a523.dtsi +2 -1
index 9335977751e2..cea5b166c00f 100644
@@ -128,7 +128,8 @@ gpu: gpu@1800000 {
 		pio: pinctrl@2000000 {
 			compatible = "allwinner,sun55i-a523-pinctrl";
 			reg = <0x2000000 0x800>;
-			interrupts = <GIC_SPI 69 IRQ_TYPE_LEVEL_HIGH>,
+			interrupts = <GIC_SPI 67 IRQ_TYPE_LEVEL_HIGH>,
+				     <GIC_SPI 69 IRQ_TYPE_LEVEL_HIGH>,
 				     <GIC_SPI 71 IRQ_TYPE_LEVEL_HIGH>,
 				     <GIC_SPI 73 IRQ_TYPE_LEVEL_HIGH>,
 				     <GIC_SPI 75 IRQ_TYPE_LEVEL_HIGH>,
Signature · 1 line
2.43.0
maintainer Reviewed-by on v2 3/3
#9 lore raw

Re: [PATCH v2 3/3] arm64: dts: allwinner: a523: Add missing GPIO interrupt

Dne petek, 27. marec 2026 ob 12:30:06 Srednjeevropski standardni čas je Andre Przywara napisal(a):

Quoted 6 lines

Even though the Allwinner A523 SoC implements 10 GPIO banks, it has actually registers for 11 IRQ banks, and even an interrupt assigned to the first, non-implemented IRQ bank.
Add that first interrupt to the list of GPIO interrupts, to correct the association between IRQs and GPIO banks.

Quoted 6 lines

This fixes GPIO IRQ operation on boards with A523 SoCs, as seen by broken SD card detect functionality, for instance.

Fixes 35ac96f79664 ("arm64: dts: allwinner: Add Allwinner A523 .dtsi file")

Best regards,
Jernej

#10 lore raw
In reply to Andre Przywara

On Fri, 27 Mar 2026 11:30:03 +0000
Andre Przywara <[email protected]> wrote:

Hi,

Quoted 4 lines

this is the minimal fix version for the GPIO IRQ operation on the Allwinner A523/A527/T527 SoCs. SD card detection is broken as a result, which is a major annoyance. Those patches here fix that problem, and should go into v7.0 still, if possible.

what is the status of this series, please? We missed v7.0 back then, but please can we take this now, for v7.1? There are review tags for every patch, and this fixes SD card operation on all A523/A527/T572 boards. The series still applies cleanly on current master, if I should resend anyway, please let me know.

Cheers,
Andre

Quoted 37 lines

I dropped the more involved fixes from v1, the risk for regressions is now very low:
- The quirk flag is just dropped from the A523, not the other SoCs. I confirmed this again with an experiment, for both the primary and secondary pincontroller. This avoids fixing the workaround code for now, which is more involved, but for now unneeded.
- The DT patch just adds the missing interrupt. The IRQ association was always wrong and never worked, so this can't make it possibly worse.
Together those two patches (plus the required binding change) fix the problem, I would appreciate if this could be taken ASAP, into v7.0 still. The generic pinctrl code is now untouched, which makes this also much easier to backport, and drops the dependencies on other v7.0-rc fixes.

Bases on v7.0-rc1, but applies on later revisions as well.

Please have a look and test, especially on A523/A527/T527 boards!

Changelog v1 .. v2:
- drop generic pinctrl fixes (for now)
- drop quirk removal from other SoCs (for now)
- add Chen-Yu's tag

Cheers,
Andre

Andre Przywara (3):
pinctrl: sunxi: a523: Remove unneeded IRQ remuxing flag
dt-bindings: pinctrl: sun55i-a523: increase IRQ banks number
arm64: dts: allwinner: a523: Add missing GPIO interrupt

 .../bindings/pinctrl/allwinner,sun55i-a523-pinctrl.yaml   | 8 ++++----
 arch/arm64/boot/dts/allwinner/sun55i-a523.dtsi            | 3 ++-
 drivers/pinctrl/sunxi/pinctrl-sun55i-a523-r.c             | 1 -
 drivers/pinctrl/sunxi/pinctrl-sun55i-a523.c               | 1 -
 4 files changed, 6 insertions(+), 7 deletions(-)

base-commit: 6de23f81a5e08be8fbf5e8d7e9febc72a5b5f27f

maintainer
#11 lore raw
In reply to Andre Przywara
Quoted 4 lines · Andre Przywara

this is the minimal fix version for the GPIO IRQ operation on the Allwinner A523/A527/T527 SoCs. SD card detection is broken as a result, which is a major annoyance. Those patches here fix that problem, and should go into v7.0 still, if possible.

Patches 1 & 2 applied to the pinctrl tree, please send patch 3 to the SoC tree.

Sorry for missing this, dunno what happened. Probably it got lost by me trying to use korgalore and screwing up.

Yours,
Linus Walleij

maintainer Applied
#12 lore raw

Re: (subset) [PATCH v2 0/3] pinctrl: sunxi: a523: fix GPIO IRQ operation

In reply to Andre Przywara
Quoted 17 lines · Andre Przywara

this is the minimal fix version for the GPIO IRQ operation on the Allwinner A523/A527/T527 SoCs. SD card detection is broken as a result, which is a major annoyance. Those patches here fix that problem, and should go into v7.0 still, if possible.
I dropped the more involved fixes from v1, the risk for regressions is now very low:
- The quirk flag is just dropped from the A523, not the other SoCs. I confirmed this again with an experiment, for both the primary and secondary pincontroller. This avoids fixing the workaround code for now, which is more involved, but for now unneeded.
- The DT patch just adds the missing interrupt. The IRQ association was always wrong and never worked, so this can't make it possibly worse.
Together those two patches (plus the required binding change) fix the problem, I would appreciate if this could be taken ASAP, into v7.0 still. The generic pinctrl code is now untouched, which makes this also much easier to backport, and drops the dependencies on other v7.0-rc fixes.

Quoted 1 line

[...]

Applied to sunxi/dt-for-7.2 in sunxi, thanks!

[3/3] arm64: dts: allwinner: a523: Add missing GPIO interrupt

      https://git.kernel.org/sunxi/linux/c/6b81aa0c8a4f

Best regards,

Signature · 1 line
Chen-Yu Tsai <[email protected]>