Skip to contentSkip to conversation

gpio: realtek-otto: add pinctrl support

PATCH Superseded Michael Zavertkin 2 participants 5 messages Jul 25 – Jul 26

Subsystems (2)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gpio: realtek-otto: add pinctrl support

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

---
 drivers/gpio/gpio-realtek-otto.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/gpio/gpio-realtek-otto.c +10 -1
index 4a606bad5848..4d594db24dd0 100644
@@ -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,
Signature · 1 line
2.54.0
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · Michael Zavertkin

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

That's neat!

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

Quoted 3 lines
drivers/gpio/gpio-realtek-otto.c +3 -0
+       if (dev_flags & GPIO_PINCTRL) {
+               gen_gc_flags |= GPIO_GENERIC_PINCTRL_BACKEND;
+       }

Drop the ellipsis {}.

With that fix:

Yours,
Linus Walleij

#2 lore raw
Quoted 6 lines · Linus Walleij

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

Quoted 3 lines · Michael Zavertkin
drivers/gpio/gpio-realtek-otto.c +3 -0
+       if (dev_flags & GPIO_PINCTRL) {
+               gen_gc_flags |= GPIO_GENERIC_PINCTRL_BACKEND;
+       }
Quoted 7 lines

Drop the ellipsis {}.

With that fix:

Yours,
Linus Walleij

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

maintainer
#3 lore raw
Quoted 2 lines · Michael Zavertkin

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

#4 lore raw
Quoted 9 lines · Linus Walleij
Quoted 2 lines · Michael Zavertkin

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:

Quoted 8 lines

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:

Documentation/devicetree/bindings/gpio/realtek,otto-gpio.yaml +14 -0
@@ -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