Skip to contentSkip to conversation

gpio: realtek-otto: add pinctrl support

PATCH Superseded [email protected] 4 participants 6 messages Aug 20 – Aug 27

Subsystems (2)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v3 cover gpio: realtek-otto: add pinctrl support

This series adds pinctrl support for RTL9607C and referes it in documentation.

---
Changes in v3:
- 'gpio-ranges' is optional in dt-bindings
- pinctrl supported for all SoCs (no-op if disabled in configuration)
- Dropped Reviewed-by (patch changed)
- Link to v2: https://patch.msgid.link/[email protected]

Changes in v2:
- Add 'required' property to dt-bindings
- Dropped the ellipsis and added Reviewed-by
- Link to v1: https://patch.msgid.link/amRpvtNAwIQak_9y@gamepc
---
Michael Zavertkin (2):
dt-bindings: gpio: otto-gpio: Add gpio-ranges
gpio: realtek-otto: add pinctrl support

 .../devicetree/bindings/gpio/realtek,otto-gpio.yaml          | 2 ++
 drivers/gpio/gpio-realtek-otto.c                             | 5 +++--
 2 files changed, 5 insertions(+), 2 deletions(-)
Signature · 1 line
2.54.0
#1 lore raw

PATCH v3 1/2 dt-bindings: gpio: otto-gpio: Add gpio-ranges

Add 'gpio-ranges' optional property to reflect driver changes.

---
 Documentation/devicetree/bindings/gpio/realtek,otto-gpio.yaml | 2 ++
 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/gpio/realtek,otto-gpio.yaml +2 -0
index b18f8f0ca0ae..33c25df7b815 100644
@@ -40,6 +40,8 @@ properties:
 
   gpio-controller: true
 
+  gpio-ranges: true
+
   ngpios:
     minimum: 1
     maximum: 32
Signature · 1 line
2.54.0
#3 lore raw

PATCH v3 2/2 gpio: realtek-otto: add pinctrl support

In reply to [email protected]

RTL9607C relies on pinctrl to mux SoC pins. Use pinctrl to request pins for GPIO.
pinctrl driver for other SoCs might be implemented later.

---
 drivers/gpio/gpio-realtek-otto.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/gpio/gpio-realtek-otto.c +3 -2
index 4a606bad5848..01be8baa25c3 100644
@@ -393,13 +393,14 @@ static int realtek_gpio_probe(struct platform_device *pdev)
 
 	raw_spin_lock_init(&ctrl->lock);
 
+	gen_gc_flags = GPIO_GENERIC_PINCTRL_BACKEND;
+
 	if (dev_flags & GPIO_PORTS_REVERSED) {
-		gen_gc_flags = 0;
 		ctrl->bank_read = realtek_gpio_bank_read;
 		ctrl->bank_write = realtek_gpio_bank_write;
 		ctrl->line_imr_pos = realtek_gpio_line_imr_pos;
 	} else {
-		gen_gc_flags = GPIO_GENERIC_BIG_ENDIAN_BYTE_ORDER;
+		gen_gc_flags |= GPIO_GENERIC_BIG_ENDIAN_BYTE_ORDER;
 		ctrl->bank_read = realtek_gpio_bank_read_swapped;
 		ctrl->bank_write = realtek_gpio_bank_write_swapped;
 		ctrl->line_imr_pos = realtek_gpio_line_imr_pos_swapped;
Signature · 1 line
2.54.0
#4 lore raw
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

New issues:
- [Critical] Unconditionally enabling GPIO_GENERIC_PINCTRL_BACKEND breaks GPIO direction configuration on SoCs that do not yet have a pinctrl driver.

Pre-existing issues:
- [High] Silent failure when optional IRQ probe defers. --

--- Patch [2]: [PATCH v3 2/2] gpio: realtek-otto: add pinctrl support --- commit c33b7f5187bd7fe916fbf0c1df13da9be88e7f72
Author: [email protected] <[email protected]>

gpio: realtek-otto: add pinctrl support

This patch adds pinctrl backend support to the Realtek Otto GPIO driver. It utilizes pinctrl to request pins for GPIO on the RTL9607C SoC.

drivers/gpio/gpio-realtek-otto.c static int realtek_gpio_probe(struct platform_device *pdev) · line 398

Quoted 10 lines
drivers/gpio/gpio-realtek-otto.c +2 -0
index 37ef56f453187..b53c2a9a04c76 100644
@@ -394,13 +394,14 @@ static int realtek_gpio_probe(struct platform_device *pdev)
 
 	raw_spin_lock_init(&ctrl->lock);
 
+	gen_gc_flags = GPIO_GENERIC_PINCTRL_BACKEND;
+

[Severity: Critical]
Does setting GPIO_GENERIC_PINCTRL_BACKEND unconditionally break GPIO direction configuration on SoCs lacking a pinctrl driver?

Because pinctrl drivers for other SoCs are not yet implemented, setting this flag forces gpio_mmio_dir_in() and gpio_mmio_dir_out() to route via pinctrl_gpio_direction_*(). Since no pinctrl driver is registered for those devices, won't this fail with -EPROBE_DEFER and completely break GPIO output/input functionality?

drivers/gpio/gpio-realtek-otto.c static int realtek_gpio_probe(struct platform_device *pdev) · line 397

Quoted 2 lines
drivers/gpio/gpio-realtek-otto.c +0 -1
 	if (dev_flags & GPIO_PORTS_REVERSED) {
-		gen_gc_flags = 0;

[ ... ]

[Severity: High]
This is a pre-existing issue, but does the optional irq check silently discard probe deferrals?

drivers/gpio/gpio-realtek-otto.c:realtek_gpio_probe() {
	...
	irq = platform_get_irq_optional(pdev, 0);
	if (!(dev_flags & GPIO_INTERRUPTS_DISABLED) && irq > 0) {
		girq = &ctrl->chip.gc.irq;
	...
}

When platform_get_irq_optional() returns -EPROBE_DEFER because the parent interrupt controller is not yet ready, the irq > 0 check silently discards the error code. This can lead to the device permanently losing GPIO interrupt support depending on boot timing.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
maintainer
#5 lore raw
Quoted 2 lines · On Thu, Aug 20, 2026 at 9:39 AM <[email protected]> wrote:

- [Critical] Unconditionally enabling GPIO_GENERIC_PINCTRL_BACKEND breaks GPIO direction configuration on SoCs that do not yet have a pinctrl driver.

(...)

Quoted 2 lines

Does setting GPIO_GENERIC_PINCTRL_BACKEND unconditionally break GPIO direction configuration on SoCs lacking a pinctrl driver?

I have adressed this with a separate patch:
https://lore.kernel.org/linux-gpio/[email protected]/

Sashiko identified the bug but was completely clueless about the solution, as it seems to just think everything shoulf be fixed in the drivers instead of just fixing it for everyone in the frameworks, sigh roll eyes.

Yours,
Linus Walleij