Devicetree
 help / color / mirror / Atom feed
* [PATCH v4 0/2] gpio: realtek-otto: add pinctrl support
@ 2026-08-27 14:29 Michael Zavertkin
  2026-08-27 14:29 ` [PATCH v4 1/2] dt-bindings: gpio: otto-gpio: Add gpio-ranges Michael Zavertkin
  2026-08-27 14:29 ` [PATCH v4 2/2] gpio: realtek-otto: add pinctrl support Michael Zavertkin
  0 siblings, 2 replies; 4+ messages in thread
From: Michael Zavertkin @ 2026-08-27 14:29 UTC (permalink / raw)
  To: linux-gpio
  Cc: Linus Walleij, Bartosz Golaszewski, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Sander Vanheule,
	Bert Vermeulen, devicetree, linux-kernel, Michael Zavertkin

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

Signed-off-by: Michael Zavertkin <misha.zavertkin@mail.ru>
---
Changes in v4:
- Fixed SoB mismatch
- Link to v3: https://patch.msgid.link/cover.1787209558.git.misha.zavertkin@mail.ru

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/cover.1787130560.git.misha.zavertkin@mail.ru

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(-)

-- 
2.54.0


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

* [PATCH v4 1/2] dt-bindings: gpio: otto-gpio: Add gpio-ranges
  2026-08-27 14:29 [PATCH v4 0/2] gpio: realtek-otto: add pinctrl support Michael Zavertkin
@ 2026-08-27 14:29 ` Michael Zavertkin
  2026-08-27 14:29 ` [PATCH v4 2/2] gpio: realtek-otto: add pinctrl support Michael Zavertkin
  1 sibling, 0 replies; 4+ messages in thread
From: Michael Zavertkin @ 2026-08-27 14:29 UTC (permalink / raw)
  To: linux-gpio
  Cc: Linus Walleij, Bartosz Golaszewski, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Sander Vanheule,
	Bert Vermeulen, devicetree, linux-kernel, Michael Zavertkin

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

Signed-off-by: Michael Zavertkin <misha.zavertkin@mail.ru>
---
 Documentation/devicetree/bindings/gpio/realtek,otto-gpio.yaml | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/gpio/realtek,otto-gpio.yaml b/Documentation/devicetree/bindings/gpio/realtek,otto-gpio.yaml
index b18f8f0ca0ae..33c25df7b815 100644
--- a/Documentation/devicetree/bindings/gpio/realtek,otto-gpio.yaml
+++ b/Documentation/devicetree/bindings/gpio/realtek,otto-gpio.yaml
@@ -40,6 +40,8 @@ properties:
 
   gpio-controller: true
 
+  gpio-ranges: true
+
   ngpios:
     minimum: 1
     maximum: 32
-- 
2.54.0


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

* [PATCH v4 2/2] gpio: realtek-otto: add pinctrl support
  2026-08-27 14:29 [PATCH v4 0/2] gpio: realtek-otto: add pinctrl support Michael Zavertkin
  2026-08-27 14:29 ` [PATCH v4 1/2] dt-bindings: gpio: otto-gpio: Add gpio-ranges Michael Zavertkin
@ 2026-08-27 14:29 ` Michael Zavertkin
  2026-08-27 14:54   ` sashiko-bot
  1 sibling, 1 reply; 4+ messages in thread
From: Michael Zavertkin @ 2026-08-27 14:29 UTC (permalink / raw)
  To: linux-gpio
  Cc: Linus Walleij, Bartosz Golaszewski, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Sander Vanheule,
	Bert Vermeulen, devicetree, linux-kernel, Michael Zavertkin

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

Signed-off-by: Michael Zavertkin <misha.zavertkin@mail.ru>
---
 drivers/gpio/gpio-realtek-otto.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/gpio/gpio-realtek-otto.c b/drivers/gpio/gpio-realtek-otto.c
index 4a606bad5848..01be8baa25c3 100644
--- a/drivers/gpio/gpio-realtek-otto.c
+++ b/drivers/gpio/gpio-realtek-otto.c
@@ -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;
-- 
2.54.0


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

* Re: [PATCH v4 2/2] gpio: realtek-otto: add pinctrl support
  2026-08-27 14:29 ` [PATCH v4 2/2] gpio: realtek-otto: add pinctrl support Michael Zavertkin
@ 2026-08-27 14:54   ` sashiko-bot
  0 siblings, 0 replies; 4+ messages in thread
From: sashiko-bot @ 2026-08-27 14:54 UTC (permalink / raw)
  To: Michael Zavertkin; +Cc: devicetree, robh, conor+dt

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Unconditional use of GPIO_GENERIC_PINCTRL_BACKEND breaks GPIO requests and direction configuration on SoCs without a pinctrl driver.
--

commit e286232a1c082edc58e67d8d4c62156ff41a0294
Author: Michael Zavertkin <misha.zavertkin@mail.ru>

gpio: realtek-otto: add pinctrl support

This commit adds pinctrl backend support to the realtek-otto GPIO driver
so that RTL9607C can use pinctrl to request pins.

> diff --git a/drivers/gpio/gpio-realtek-otto.c b/drivers/gpio/gpio-realtek-otto.c
> index 37ef56f453187..b53c2a9a04c76 100644
> --- a/drivers/gpio/gpio-realtek-otto.c
> +++ b/drivers/gpio/gpio-realtek-otto.c
> @@ -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: High]
Does unconditionally setting GPIO_GENERIC_PINCTRL_BACKEND break GPIO
functionality for SoCs that lack a pinctrl driver?

When a GPIO is requested or its direction is set on an SoC without a pinctrl
driver, gpio_generic_chip_init() routes the calls to pinctrl_gpio_request() and
pinctrl_gpio_direction(). 

Because pinctrl_gpio_direction() calls pinctrl_get_device_gpio_range(), it will
return -EPROBE_DEFER when no pinctrl device overlaps with the GPIO chip. This
would cause all GPIO requests and direction configurations to fail indefinitely,
rendering GPIO unusable and breaking dependent devices on hardware like RTL8380
or RTL9300, which the commit message acknowledges might have pinctrl drivers
implemented later.

Should this backend flag only be set conditionally, perhaps by checking for
gpio-ranges in the device tree?

>  	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;

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1787830440.git.misha.zavertkin@mail.ru?part=2

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

end of thread, other threads:[~2026-08-27 14:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-27 14:29 [PATCH v4 0/2] gpio: realtek-otto: add pinctrl support Michael Zavertkin
2026-08-27 14:29 ` [PATCH v4 1/2] dt-bindings: gpio: otto-gpio: Add gpio-ranges Michael Zavertkin
2026-08-27 14:29 ` [PATCH v4 2/2] gpio: realtek-otto: add pinctrl support Michael Zavertkin
2026-08-27 14:54   ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox