Linux GPIO subsystem development
 help / color / mirror / Atom feed
* [PATCH] gpio: realtek-otto: add pinctrl support
@ 2026-07-25  7:46 Michael Zavertkin
  2026-07-25 14:10 ` Linus Walleij
  0 siblings, 1 reply; 5+ messages in thread
From: Michael Zavertkin @ 2026-07-25  7:46 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, linux-gpio, linux-kernel

RTL9607C relies on pinctrl to mux SoC pins. Use pinctrl to request pins
for GPIO

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

diff --git a/drivers/gpio/gpio-realtek-otto.c b/drivers/gpio/gpio-realtek-otto.c
index 4a606bad5848..4d594db24dd0 100644
--- a/drivers/gpio/gpio-realtek-otto.c
+++ b/drivers/gpio/gpio-realtek-otto.c
@@ -97,6 +97,11 @@ enum realtek_gpio_flags {
 	 * range, where the per-cpu enable masks are located.
 	 */
 	GPIO_INTERRUPTS_PER_CPU = BIT(2),
+	/*
+	 * Request GPIOs from pinctrl using gpiochip_generic_request()
+	 * and gpiochip_generic_free().
+	 */
+	GPIO_PINCTRL = BIT(3),
 };
 
 static struct realtek_gpio_ctrl *irq_data_to_ctrl(struct irq_data *data)
@@ -354,7 +359,7 @@ static const struct of_device_id realtek_gpio_of_match[] = {
 	},
 	{
 		.compatible = "realtek,rtl9607-gpio",
-		.data = (void *)GPIO_PORTS_REVERSED,
+		.data = (void *)(GPIO_PORTS_REVERSED | GPIO_PINCTRL),
 	},
 	{}
 };
@@ -405,6 +410,10 @@ static int realtek_gpio_probe(struct platform_device *pdev)
 		ctrl->line_imr_pos = realtek_gpio_line_imr_pos_swapped;
 	}
 
+	if (dev_flags & GPIO_PINCTRL) {
+		gen_gc_flags |= GPIO_GENERIC_PINCTRL_BACKEND;
+	}
+
 	config = (struct gpio_generic_chip_config) {
 		.dev = dev,
 		.sz = 4,
-- 
2.54.0


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

* Re: [PATCH] gpio: realtek-otto: add pinctrl support
  2026-07-25  7:46 [PATCH] gpio: realtek-otto: add pinctrl support Michael Zavertkin
@ 2026-07-25 14:10 ` Linus Walleij
  2026-07-26 15:21   ` Michael Zavertkin
  0 siblings, 1 reply; 5+ messages in thread
From: Linus Walleij @ 2026-07-25 14:10 UTC (permalink / raw)
  To: Michael Zavertkin; +Cc: Bartosz Golaszewski, linux-gpio, linux-kernel

On Sat, Jul 25, 2026 at 9:46 AM Michael Zavertkin
<misha.zavertkin@mail.ru> wrote:

> RTL9607C relies on pinctrl to mux SoC pins. Use pinctrl to request pins
> for GPIO
>
> Signed-off-by: Michael Zavertkin <misha.zavertkin@mail.ru>

That's neat!

> +       if (dev_flags & GPIO_PINCTRL) {
> +               gen_gc_flags |= GPIO_GENERIC_PINCTRL_BACKEND;
> +       }

Drop the ellipsis {}.

With that fix:
Reviewed-by: Linus Walleij <linusw@kernel.org>

Yours,
Linus Walleij

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

* Re: [PATCH] gpio: realtek-otto: add pinctrl support
  2026-07-25 14:10 ` Linus Walleij
@ 2026-07-26 15:21   ` Michael Zavertkin
  2026-07-26 16:38     ` Linus Walleij
  0 siblings, 1 reply; 5+ messages in thread
From: Michael Zavertkin @ 2026-07-26 15:21 UTC (permalink / raw)
  To: Linus Walleij; +Cc: Bartosz Golaszewski, linux-gpio, linux-kernel

On Sat, Jul 25, 2026 at 04:10:54PM +0200, Linus Walleij wrote:
> On Sat, Jul 25, 2026 at 9:46 AM Michael Zavertkin
> <misha.zavertkin@mail.ru> wrote:
> > +       if (dev_flags & GPIO_PINCTRL) {
> > +               gen_gc_flags |= GPIO_GENERIC_PINCTRL_BACKEND;
> > +       }
> 
> Drop the ellipsis {}.
> 
> With that fix:
> Reviewed-by: Linus Walleij <linusw@kernel.org>
> 
> Yours,
> Linus Walleij
No problem
Should I also add pinctrl property to required in realtek,otto-gpio.yaml
for realtek,rtl9607-gpio?


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

* Re: [PATCH] gpio: realtek-otto: add pinctrl support
  2026-07-26 15:21   ` Michael Zavertkin
@ 2026-07-26 16:38     ` Linus Walleij
  2026-07-26 17:03       ` Michael Zavertkin
  0 siblings, 1 reply; 5+ messages in thread
From: Linus Walleij @ 2026-07-26 16:38 UTC (permalink / raw)
  To: Michael Zavertkin; +Cc: Bartosz Golaszewski, linux-gpio, linux-kernel

On Sun, Jul 26, 2026 at 5:21 PM Michael Zavertkin
<misha.zavertkin@mail.ru> wrote:

> Should I also add pinctrl property to required in realtek,otto-gpio.yaml
> for realtek,rtl9607-gpio?

What do you mean? You should use gpio-ranges so add that if
you don't have it already:

gpio-ranges: true

After adding appropriate gpio-ranges to your DTS the pin controller
will become a back-end for the gpio. But certainly you must have
done that already?

Yours,
Linus Walleij

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

* Re: [PATCH] gpio: realtek-otto: add pinctrl support
  2026-07-26 16:38     ` Linus Walleij
@ 2026-07-26 17:03       ` Michael Zavertkin
  0 siblings, 0 replies; 5+ messages in thread
From: Michael Zavertkin @ 2026-07-26 17:03 UTC (permalink / raw)
  To: Linus Walleij; +Cc: Bartosz Golaszewski, linux-gpio, linux-kernel

On Sun, Jul 26, 2026 at 06:38:00PM +0200, Linus Walleij wrote:
> On Sun, Jul 26, 2026 at 5:21 PM Michael Zavertkin
> <misha.zavertkin@mail.ru> wrote:
> 
> > Should I also add pinctrl property to required in realtek,otto-gpio.yaml
> > for realtek,rtl9607-gpio?
> 
> What do you mean? You should use gpio-ranges so add that if
> you don't have it already:
> 
> gpio-ranges: true
> 
> After adding appropriate gpio-ranges to your DTS the pin controller
> will become a back-end for the gpio. But certainly you must have
> done that already?
> 
> Yours,
> Linus Walleij
Yes, there is gpio-ranges in .dts I tested.
I meant should correspondig 'required' property be added to
realtek,otto-gpio documentation? Just like that:

--- 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: false
+
   ngpios:
     minimum: 1
     maximum: 32
@@ -75,6 +77,18 @@ required:
   - "#gpio-cells"
   - gpio-controller

+allOf:
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: realtek,rtl9607-gpio
+    then:
+      properties:
+        gpio-ranges: true
+      required:
+        - gpio-ranges
+
 additionalProperties: false

 dependencies:

It is required for RTL9607C, otherwise controller won't be connected to
SoC pins and GPIOs won't work.
AFAIK, it should be a separate patch (but same patch series?)
If it's okay, I'll add it to v2

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

end of thread, other threads:[~2026-07-26 17:03 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-25  7:46 [PATCH] gpio: realtek-otto: add pinctrl support Michael Zavertkin
2026-07-25 14:10 ` Linus Walleij
2026-07-26 15:21   ` Michael Zavertkin
2026-07-26 16:38     ` Linus Walleij
2026-07-26 17:03       ` Michael Zavertkin

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