linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/3] RDA8810PL GPIO fixes
@ 2025-09-27  4:59 Dang Huynh
  2025-09-27  4:59 ` [PATCH v3 1/3] dt-bindings: gpio: rda: Make interrupts optional Dang Huynh
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Dang Huynh @ 2025-09-27  4:59 UTC (permalink / raw)
  To: Manivannan Sadhasivam, Linus Walleij, Bartosz Golaszewski,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley
  Cc: linux-arm-kernel, linux-unisoc, linux-gpio, devicetree,
	linux-kernel, Dang Huynh, Conor Dooley

This patchset fixes two issues with the RDA GPIO driver:
- Makes GPIO IRQ optional for modem-handled GPIO block
- GPIO output direction misbehaviors

This change should not affect any existing users of the RDA Micro
platform.

This patchset is considered to be a v3, as I did not tag the previous
patchset as v2 and is a split from both of my v1/v2 patchset.

Changes in v3:
- Use bidirectional direction register for dirin register which truly
  fixes the previous issue.
- Link to v2: https://lore.kernel.org/all/20250919-rda8810pl-mmc-v1-0-d4f08a05ba4d@mainlining.org/

Changes in v2:
- Update commit message for "gpio: rda: Make direction register unreadable"
- Link to v1: https://lore.kernel.org/all/20250917-rda8810pl-drivers-v1-0-74866def1fe3@mainlining.org/

Signed-off-by: Dang Huynh <dang.huynh@mainlining.org>
---
Dang Huynh (3):
      dt-bindings: gpio: rda: Make interrupts optional
      gpio: rda: Make IRQ optional
      gpio: rda: Use bidirectional GPIO register for direction input

 Documentation/devicetree/bindings/gpio/gpio-rda.yaml | 3 ---
 drivers/gpio/gpio-rda.c                              | 5 ++---
 2 files changed, 2 insertions(+), 6 deletions(-)
---
base-commit: 846bd2225ec3cfa8be046655e02b9457ed41973e
change-id: 20250925-rda8810pl-gpio-fix-db6f7442eae7

Best regards,
-- 
Dang Huynh <dang.huynh@mainlining.org>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v3 1/3] dt-bindings: gpio: rda: Make interrupts optional
  2025-09-27  4:59 [PATCH v3 0/3] RDA8810PL GPIO fixes Dang Huynh
@ 2025-09-27  4:59 ` Dang Huynh
  2025-10-01 11:41   ` Linus Walleij
  2025-09-27  4:59 ` [PATCH v3 2/3] gpio: rda: Make IRQ optional Dang Huynh
  2025-09-27  4:59 ` [PATCH v3 3/3] gpio: rda: Use bidirectional GPIO register for direction input Dang Huynh
  2 siblings, 1 reply; 5+ messages in thread
From: Dang Huynh @ 2025-09-27  4:59 UTC (permalink / raw)
  To: Manivannan Sadhasivam, Linus Walleij, Bartosz Golaszewski,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley
  Cc: linux-arm-kernel, linux-unisoc, linux-gpio, devicetree,
	linux-kernel, Dang Huynh, Conor Dooley

The GPIO controller from the modem does not have an interrupt.

Acked-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Dang Huynh <dang.huynh@mainlining.org>
---
 Documentation/devicetree/bindings/gpio/gpio-rda.yaml | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/Documentation/devicetree/bindings/gpio/gpio-rda.yaml b/Documentation/devicetree/bindings/gpio/gpio-rda.yaml
index 6ece555f074f84b396537917d7149d4061724dcc..dbb73b4d33ed39aa65024376b1af0c4e2fb896db 100644
--- a/Documentation/devicetree/bindings/gpio/gpio-rda.yaml
+++ b/Documentation/devicetree/bindings/gpio/gpio-rda.yaml
@@ -41,9 +41,6 @@ required:
   - gpio-controller
   - "#gpio-cells"
   - ngpios
-  - interrupt-controller
-  - "#interrupt-cells"
-  - interrupts
 
 additionalProperties: false
 

-- 
2.51.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v3 2/3] gpio: rda: Make IRQ optional
  2025-09-27  4:59 [PATCH v3 0/3] RDA8810PL GPIO fixes Dang Huynh
  2025-09-27  4:59 ` [PATCH v3 1/3] dt-bindings: gpio: rda: Make interrupts optional Dang Huynh
@ 2025-09-27  4:59 ` Dang Huynh
  2025-09-27  4:59 ` [PATCH v3 3/3] gpio: rda: Use bidirectional GPIO register for direction input Dang Huynh
  2 siblings, 0 replies; 5+ messages in thread
From: Dang Huynh @ 2025-09-27  4:59 UTC (permalink / raw)
  To: Manivannan Sadhasivam, Linus Walleij, Bartosz Golaszewski,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley
  Cc: linux-arm-kernel, linux-unisoc, linux-gpio, devicetree,
	linux-kernel, Dang Huynh

Not all GPIO have IRQ. When we use this driver with
GPIOC (handled by modem) we get:

rda-gpio 11a08000.gpioc: error -ENXIO: IRQ index 0 not found

Let's mark IRQ as optional so this error doesn't show up.

Signed-off-by: Dang Huynh <dang.huynh@mainlining.org>
---
 drivers/gpio/gpio-rda.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpio/gpio-rda.c b/drivers/gpio/gpio-rda.c
index fb479d13eb01a49218ad4229e7d4f70f096f5a2e..7d20dbbb6ec41149a1dbf4d9ef9ac86449773c35 100644
--- a/drivers/gpio/gpio-rda.c
+++ b/drivers/gpio/gpio-rda.c
@@ -229,7 +229,7 @@ static int rda_gpio_probe(struct platform_device *pdev)
 	 * RDA8810PL, GPIOC doesn't support interrupt. So we must handle
 	 * those also.
 	 */
-	rda_gpio->irq = platform_get_irq(pdev, 0);
+	rda_gpio->irq = platform_get_irq_optional(pdev, 0);
 
 	rda_gpio->base = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(rda_gpio->base))

-- 
2.51.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v3 3/3] gpio: rda: Use bidirectional GPIO register for direction input
  2025-09-27  4:59 [PATCH v3 0/3] RDA8810PL GPIO fixes Dang Huynh
  2025-09-27  4:59 ` [PATCH v3 1/3] dt-bindings: gpio: rda: Make interrupts optional Dang Huynh
  2025-09-27  4:59 ` [PATCH v3 2/3] gpio: rda: Make IRQ optional Dang Huynh
@ 2025-09-27  4:59 ` Dang Huynh
  2 siblings, 0 replies; 5+ messages in thread
From: Dang Huynh @ 2025-09-27  4:59 UTC (permalink / raw)
  To: Manivannan Sadhasivam, Linus Walleij, Bartosz Golaszewski,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley
  Cc: linux-arm-kernel, linux-unisoc, linux-gpio, devicetree,
	linux-kernel, Dang Huynh

The current implementation uses both DIRIN and DIROUT registers, but
the bgpio library expects 1 to be output direction, which on this IP
is reversed (0 = output, 1 = input).

To fix this, use GPIO_OEN_VAL for input direction register which
expects 1 = input, 0 = output.

This change should not affect any mainline users as none of them have
any peripherals hooked up to a GPIO.

Signed-off-by: Dang Huynh <dang.huynh@mainlining.org>
---
 drivers/gpio/gpio-rda.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpio/gpio-rda.c b/drivers/gpio/gpio-rda.c
index 7d20dbbb6ec41149a1dbf4d9ef9ac86449773c35..145b61fc83fb6eee2415e979a144616d81595736 100644
--- a/drivers/gpio/gpio-rda.c
+++ b/drivers/gpio/gpio-rda.c
@@ -243,8 +243,7 @@ static int rda_gpio_probe(struct platform_device *pdev)
 		.dat = rda_gpio->base + RDA_GPIO_VAL,
 		.set = rda_gpio->base + RDA_GPIO_SET,
 		.clr = rda_gpio->base + RDA_GPIO_CLR,
-		.dirout = rda_gpio->base + RDA_GPIO_OEN_SET_OUT,
-		.dirin = rda_gpio->base + RDA_GPIO_OEN_SET_IN,
+		.dirin = rda_gpio->base + RDA_GPIO_OEN_VAL,
 		.flags = BGPIOF_READ_OUTPUT_REG_SET,
 	};
 

-- 
2.51.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v3 1/3] dt-bindings: gpio: rda: Make interrupts optional
  2025-09-27  4:59 ` [PATCH v3 1/3] dt-bindings: gpio: rda: Make interrupts optional Dang Huynh
@ 2025-10-01 11:41   ` Linus Walleij
  0 siblings, 0 replies; 5+ messages in thread
From: Linus Walleij @ 2025-10-01 11:41 UTC (permalink / raw)
  To: Dang Huynh
  Cc: Manivannan Sadhasivam, Bartosz Golaszewski, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, linux-arm-kernel, linux-unisoc,
	linux-gpio, devicetree, linux-kernel, Conor Dooley

Hi Dang,

thanks for your patch!

On Sat, Sep 27, 2025 at 7:02 AM Dang Huynh <dang.huynh@mainlining.org> wrote:

> The GPIO controller from the modem does not have an interrupt.
>
> Acked-by: Conor Dooley <conor.dooley@microchip.com>
> Signed-off-by: Dang Huynh <dang.huynh@mainlining.org>

If the GPIO controllers are so different, should they not have different
compatible strings?

Maybe add rda,8810pl-modem-gpio compatible for the modem
GPIO then?

 +++ b/Documentation/devicetree/bindings/gpio/gpio-rda.yaml
> @@ -41,9 +41,6 @@ required:
>    - gpio-controller
>    - "#gpio-cells"
>    - ngpios
> -  - interrupt-controller
> -  - "#interrupt-cells"
> -  - interrupts

Then this can be conditional using an if:-statement such that
it is only mandatory for rda,8810pl-gpio and not for
rda,8810pl-modem-gpio.

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-10-01 11:41 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-27  4:59 [PATCH v3 0/3] RDA8810PL GPIO fixes Dang Huynh
2025-09-27  4:59 ` [PATCH v3 1/3] dt-bindings: gpio: rda: Make interrupts optional Dang Huynh
2025-10-01 11:41   ` Linus Walleij
2025-09-27  4:59 ` [PATCH v3 2/3] gpio: rda: Make IRQ optional Dang Huynh
2025-09-27  4:59 ` [PATCH v3 3/3] gpio: rda: Use bidirectional GPIO register for direction input Dang Huynh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).