[PATCH v4 6/7] dt-bindings: gpio: Add bindings for pinctrl based generic gpio driver

Dan Carpenter posted 7 patches 2 weeks, 6 days ago
[PATCH v4 6/7] dt-bindings: gpio: Add bindings for pinctrl based generic gpio driver
Posted by Dan Carpenter 2 weeks, 6 days ago
From: AKASHI Takahiro <takahiro.akashi@linaro.org>

Add a dt binding for the gpio-by-pinctrl driver.  The driver is used
for doing GPIO over the SCMI pinctrl protocol.  There are a few
mandatory properties such as gpio-ranges and ngpios, but it's not
mandatory to specify the pin-mux.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Linus Walleij <linusw@kernel.org>
---
v4: Changed additionalProperties: true to false.

    My concern here was that there might be a lot of gpio properties
    which I wasn't familiar with.  To check I did:
        grep :$ Documentation/devicetree/bindings/gpio/* | \
          cut -d : -f 2- | perl -ne 's/[\       ]*//g; print "$_\n"' | \
          sort | uniq -c
    The only property that I decided to add was gpio-line-names.

    Deleted the extra bonus example.

 .../bindings/gpio/pin-control-gpio.yaml       | 59 +++++++++++++++++++
 1 file changed, 59 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/gpio/pin-control-gpio.yaml

diff --git a/Documentation/devicetree/bindings/gpio/pin-control-gpio.yaml b/Documentation/devicetree/bindings/gpio/pin-control-gpio.yaml
new file mode 100644
index 000000000000..ebc3fdd039fd
--- /dev/null
+++ b/Documentation/devicetree/bindings/gpio/pin-control-gpio.yaml
@@ -0,0 +1,59 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/gpio/pin-control-gpio.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Pin control based generic GPIO controller
+
+description:
+  The pin control-based GPIO will facilitate a pin controller's ability
+  to drive electric lines high/low and other generic properties of a
+  pin controller to perform general-purpose one-bit binary I/O.
+
+maintainers:
+  - Dan Carpenter <dan.carpenter@linaro.og>
+
+properties:
+  compatible:
+    const: scmi-pinctrl-gpio
+
+  gpio-controller: true
+
+  "#gpio-cells":
+    const: 2
+
+  gpio-line-names: true
+
+  gpio-ranges: true
+
+  ngpios: true
+
+patternProperties:
+  "^.+-hog(-[0-9]+)?$":
+    type: object
+
+    required:
+      - gpio-hog
+
+required:
+  - compatible
+  - gpio-controller
+  - "#gpio-cells"
+  - gpio-ranges
+  - ngpios
+
+additionalProperties: false
+
+examples:
+  - |
+    gpio {
+        compatible = "scmi-pinctrl-gpio";
+        gpio-controller;
+        #gpio-cells = <2>;
+        ngpios = <3>;
+        gpio-line-names = "gpio_5_17", "gpio_5_20", "gpio_5_22", "gpio_2_1";
+        gpio-ranges = <&scmi_pinctrl 0 30 4>;
+        pinctrl-names = "default";
+        pinctrl-0 = <&keys_pins>;
+    };
-- 
2.51.0
Re: [PATCH v4 6/7] dt-bindings: gpio: Add bindings for pinctrl based generic gpio driver
Posted by Krzysztof Kozlowski 2 weeks, 5 days ago
On Tue, Mar 17, 2026 at 05:40:57PM +0300, Dan Carpenter wrote:
> From: AKASHI Takahiro <takahiro.akashi@linaro.org>
> 
> Add a dt binding for the gpio-by-pinctrl driver.  The driver is used

Drop all references to the driver. Describe the
device/hardware/firmware/interface, not driver. Same for subject.

> for doing GPIO over the SCMI pinctrl protocol.  There are a few
> mandatory properties such as gpio-ranges and ngpios, but it's not
> mandatory to specify the pin-mux.

There is no such thing there as pin-mux, so I don't understand above
sentence.

Describe the hardware/firmware/interface, not the patch, because we
easily see which properties are mandatory. Schema tells that.

> 
> Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> Reviewed-by: Linus Walleij <linusw@kernel.org>

A nit, subject: drop second/last, redundant "bindings for". The
"dt-bindings" prefix is already stating that these are bindings.
See also:
https://elixir.bootlin.com/linux/v6.17-rc3/source/Documentation/devicetree/bindings/submitting-patches.rst#L18

> ---
> v4: Changed additionalProperties: true to false.
> 
>     My concern here was that there might be a lot of gpio properties
>     which I wasn't familiar with.  To check I did:
>         grep :$ Documentation/devicetree/bindings/gpio/* | \
>           cut -d : -f 2- | perl -ne 's/[\       ]*//g; print "$_\n"' | \
>           sort | uniq -c
>     The only property that I decided to add was gpio-line-names.
> 
>     Deleted the extra bonus example.
> 
>  .../bindings/gpio/pin-control-gpio.yaml       | 59 +++++++++++++++++++
>  1 file changed, 59 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/gpio/pin-control-gpio.yaml
> 
> diff --git a/Documentation/devicetree/bindings/gpio/pin-control-gpio.yaml b/Documentation/devicetree/bindings/gpio/pin-control-gpio.yaml
> new file mode 100644
> index 000000000000..ebc3fdd039fd
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/gpio/pin-control-gpio.yaml
> @@ -0,0 +1,59 @@
> +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/gpio/pin-control-gpio.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Pin control based generic GPIO controller
> +
> +description:
> +  The pin control-based GPIO will facilitate a pin controller's ability
> +  to drive electric lines high/low and other generic properties of a
> +  pin controller to perform general-purpose one-bit binary I/O.
> +
> +maintainers:
> +  - Dan Carpenter <dan.carpenter@linaro.og>
> +
> +properties:
> +  compatible:
> +    const: scmi-pinctrl-gpio
> +
> +  gpio-controller: true
> +
> +  "#gpio-cells":
> +    const: 2
> +
> +  gpio-line-names: true
> +
> +  gpio-ranges: true
> +
> +  ngpios: true
> +
> +patternProperties:
> +  "^.+-hog(-[0-9]+)?$":
> +    type: object
> +
> +    required:
> +      - gpio-hog
> +
> +required:
> +  - compatible
> +  - gpio-controller
> +  - "#gpio-cells"
> +  - gpio-ranges
> +  - ngpios
> +
> +additionalProperties: false
> +
> +examples:
> +  - |
> +    gpio {
> +        compatible = "scmi-pinctrl-gpio";
> +        gpio-controller;
> +        #gpio-cells = <2>;
> +        ngpios = <3>;

Three pins here

> +        gpio-line-names = "gpio_5_17", "gpio_5_20", "gpio_5_22", "gpio_2_1";

... four here

> +        gpio-ranges = <&scmi_pinctrl 0 30 4>;

... and four here, so it feels inconsistent. I guess ngpios = 4?

Best regards,
Krzysztof