[RFC] dt-bindings: gpio: brcm,kona-gpio: convert to YAML

Message ID ZMQU7ap9CxfY5eIu@standask-GA-A55M-S2HP
State New
Headers
Series [RFC] dt-bindings: gpio: brcm,kona-gpio: convert to YAML |

Commit Message

Stanislav Jakubek July 28, 2023, 7:20 p.m. UTC
  Convert Broadcom Kona family GPIO controller bindings to DT schema.

Changes during conversion:
  - add used, but previously undocumented SoC-specific compatibles

Signed-off-by: Stanislav Jakubek <stano.jakubek@gmail.com>
---
RFC since dt_binding_check is giving me these errors/warnings:

Documentation/devicetree/bindings/gpio/brcm,kona-gpio.example.dts:21.23-34.11: Warning (interrupts_property): /example-0/gpio@35003000: Missing interrupt-parent

The old txt bindings and all current DTs do not use interrupt-parent AFAICT,
so I'm not sure what to do about that.

Documentation/devicetree/bindings/gpio/brcm,kona-gpio.example.dtb: gpio@35003000: interrupts: [[0], [106], [4], [0], [115], [4], [0], [114], [4], [0], [113], [4], [0], [112], [4], [0], [111], [4]] is too long

Here I'm not even sure what the issue is.

 .../bindings/gpio/brcm,kona-gpio.txt          | 52 -------------
 .../bindings/gpio/brcm,kona-gpio.yaml         | 77 +++++++++++++++++++
 MAINTAINERS                                   |  2 +-
 3 files changed, 78 insertions(+), 53 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/gpio/brcm,kona-gpio.txt
 create mode 100644 Documentation/devicetree/bindings/gpio/brcm,kona-gpio.yaml
  

Comments

Linus Walleij July 28, 2023, 7:58 p.m. UTC | #1
On Fri, Jul 28, 2023 at 9:20 PM Stanislav Jakubek
<stano.jakubek@gmail.com> wrote:

> Documentation/devicetree/bindings/gpio/brcm,kona-gpio.example.dtb: gpio@35003000: interrupts: [[0], [106], [4], [0], [115], [4], [0], [114], [4], [0], [113], [4], [0], [112], [4], [0], [111], [4]] is too long
>
> Here I'm not even sure what the issue is.

(...)
> +  interrupts:
> +    maxItems: 1

^ There

> +        interrupts = <GIC_SPI 106 IRQ_TYPE_LEVEL_HIGH
> +                      GIC_SPI 115 IRQ_TYPE_LEVEL_HIGH
> +                      GIC_SPI 114 IRQ_TYPE_LEVEL_HIGH
> +                      GIC_SPI 113 IRQ_TYPE_LEVEL_HIGH
> +                      GIC_SPI 112 IRQ_TYPE_LEVEL_HIGH
> +                      GIC_SPI 111 IRQ_TYPE_LEVEL_HIGH>;

This is more than one item.

Yours,
Linus Walleij
  
Rob Herring July 28, 2023, 8:16 p.m. UTC | #2
On Fri, 28 Jul 2023 21:20:13 +0200, Stanislav Jakubek wrote:
> Convert Broadcom Kona family GPIO controller bindings to DT schema.
> 
> Changes during conversion:
>   - add used, but previously undocumented SoC-specific compatibles
> 
> Signed-off-by: Stanislav Jakubek <stano.jakubek@gmail.com>
> ---
> RFC since dt_binding_check is giving me these errors/warnings:
> 
> Documentation/devicetree/bindings/gpio/brcm,kona-gpio.example.dts:21.23-34.11: Warning (interrupts_property): /example-0/gpio@35003000: Missing interrupt-parent
> 
> The old txt bindings and all current DTs do not use interrupt-parent AFAICT,
> so I'm not sure what to do about that.
> 
> Documentation/devicetree/bindings/gpio/brcm,kona-gpio.example.dtb: gpio@35003000: interrupts: [[0], [106], [4], [0], [115], [4], [0], [114], [4], [0], [113], [4], [0], [112], [4], [0], [111], [4]] is too long
> 
> Here I'm not even sure what the issue is.
> 
>  .../bindings/gpio/brcm,kona-gpio.txt          | 52 -------------
>  .../bindings/gpio/brcm,kona-gpio.yaml         | 77 +++++++++++++++++++
>  MAINTAINERS                                   |  2 +-
>  3 files changed, 78 insertions(+), 53 deletions(-)
>  delete mode 100644 Documentation/devicetree/bindings/gpio/brcm,kona-gpio.txt
>  create mode 100644 Documentation/devicetree/bindings/gpio/brcm,kona-gpio.yaml
> 

My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check'
on your patch (DT_CHECKER_FLAGS is new in v5.13):

yamllint warnings/errors:

dtschema/dtc warnings/errors:
Documentation/devicetree/bindings/gpio/brcm,kona-gpio.example.dts:21.23-34.11: Warning (interrupts_property): /example-0/gpio@35003000: Missing interrupt-parent
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/gpio/brcm,kona-gpio.example.dtb: gpio@35003000: interrupts: [[0], [106], [4], [0], [115], [4], [0], [114], [4], [0], [113], [4], [0], [112], [4], [0], [111], [4]] is too long
	from schema $id: http://devicetree.org/schemas/gpio/brcm,kona-gpio.yaml#

doc reference errors (make refcheckdocs):

See https://patchwork.ozlabs.org/project/devicetree-bindings/patch/ZMQU7ap9CxfY5eIu@standask-GA-A55M-S2HP

The base for the series is generally the latest rc1. A different dependency
should be noted in *this* patch.

If you already ran 'make dt_binding_check' and didn't see the above
error(s), then make sure 'yamllint' is installed and dt-schema is up to
date:

pip3 install dtschema --upgrade

Please check and re-submit after running the above command yourself. Note
that DT_SCHEMA_FILES can be set to your schema file to speed up checking
your schema. However, it must be unset to test all examples with your schema.
  
Krzysztof Kozlowski July 30, 2023, 10:30 a.m. UTC | #3
On 28/07/2023 21:20, Stanislav Jakubek wrote:
> Convert Broadcom Kona family GPIO controller bindings to DT schema.
> 
> Changes during conversion:
>   - add used, but previously undocumented SoC-specific compatibles
> 
> Signed-off-by: Stanislav Jakubek <stano.jakubek@gmail.com>
> ---
> RFC since dt_binding_check is giving me these errors/warnings:
> 
> Documentation/devicetree/bindings/gpio/brcm,kona-gpio.example.dts:21.23-34.11: Warning (interrupts_property): /example-0/gpio@35003000: Missing interrupt-parent
> 
> The old txt bindings and all current DTs do not use interrupt-parent AFAICT,
> so I'm not sure what to do about that.
> 
> Documentation/devicetree/bindings/gpio/brcm,kona-gpio.example.dtb: gpio@35003000: interrupts: [[0], [106], [4], [0], [115], [4], [0], [114], [4], [0], [113], [4], [0], [112], [4], [0], [111], [4]] is too long
> 
> Here I'm not even sure what the issue is.
> 
>  .../bindings/gpio/brcm,kona-gpio.txt          | 52 -------------
>  .../bindings/gpio/brcm,kona-gpio.yaml         | 77 +++++++++++++++++++
>  MAINTAINERS                                   |  2 +-
>  3 files changed, 78 insertions(+), 53 deletions(-)
>  delete mode 100644 Documentation/devicetree/bindings/gpio/brcm,kona-gpio.txt
>  create mode 100644 Documentation/devicetree/bindings/gpio/brcm,kona-gpio.yaml
> 
> diff --git a/Documentation/devicetree/bindings/gpio/brcm,kona-gpio.txt b/Documentation/devicetree/bindings/gpio/brcm,kona-gpio.txt
> deleted file mode 100644
> index 4a63bc96b687..000000000000
> --- a/Documentation/devicetree/bindings/gpio/brcm,kona-gpio.txt
> +++ /dev/null
> @@ -1,52 +0,0 @@
> -Broadcom Kona Family GPIO
> -=========================
> -
> -This GPIO driver is used in the following Broadcom SoCs:
> -  BCM11130, BCM11140, BCM11351, BCM28145, BCM28155
> -
> -The Broadcom GPIO Controller IP can be configured prior to synthesis to
> -support up to 8 banks of 32 GPIOs where each bank has its own IRQ. The
> -GPIO controller only supports edge, not level, triggering of interrupts.
> -
> -Required properties
> --------------------
> -
> -- compatible: "brcm,bcm11351-gpio", "brcm,kona-gpio"
> -- reg: Physical base address and length of the controller's registers.
> -- interrupts: The interrupt outputs from the controller. There is one GPIO
> -  interrupt per GPIO bank. The number of interrupts listed depends on the
> -  number of GPIO banks on the SoC. The interrupts must be ordered by bank,
> -  starting with bank 0. There is always a 1:1 mapping between banks and
> -  IRQs.
> -- #gpio-cells: Should be <2>. The first cell is the pin number, the second
> -  cell is used to specify optional parameters:
> -  - bit 0 specifies polarity (0 for normal, 1 for inverted)
> -  See also "gpio-specifier" in .../devicetree/bindings/gpio/gpio.txt.
> -- #interrupt-cells: Should be <2>. The first cell is the GPIO number. The
> -  second cell is used to specify flags. The following subset of flags is
> -  supported:
> -  - trigger type (bits[1:0]):
> -      1 = low-to-high edge triggered.
> -      2 = high-to-low edge triggered.
> -      3 = low-to-high or high-to-low edge triggered
> -      Valid values are 1, 2, 3
> -  See also .../devicetree/bindings/interrupt-controller/interrupts.txt.
> -- gpio-controller: Marks the device node as a GPIO controller.
> -- interrupt-controller: Marks the device node as an interrupt controller.
> -
> -Example:
> -	gpio: gpio@35003000 {
> -		compatible = "brcm,bcm11351-gpio", "brcm,kona-gpio";
> -		reg = <0x35003000 0x800>;
> -		interrupts =
> -		       <GIC_SPI 106 IRQ_TYPE_LEVEL_HIGH
> -			GIC_SPI 115 IRQ_TYPE_LEVEL_HIGH
> -			GIC_SPI 114 IRQ_TYPE_LEVEL_HIGH
> -			GIC_SPI 113 IRQ_TYPE_LEVEL_HIGH
> -			GIC_SPI 112 IRQ_TYPE_LEVEL_HIGH
> -			GIC_SPI 111 IRQ_TYPE_LEVEL_HIGH>;
> -		#gpio-cells = <2>;
> -		#interrupt-cells = <2>;
> -		gpio-controller;
> -		interrupt-controller;
> -	};
> diff --git a/Documentation/devicetree/bindings/gpio/brcm,kona-gpio.yaml b/Documentation/devicetree/bindings/gpio/brcm,kona-gpio.yaml
> new file mode 100644
> index 000000000000..9d0b0a1af832
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/gpio/brcm,kona-gpio.yaml
> @@ -0,0 +1,77 @@
> +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/gpio/brcm,kona-gpio.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Broadcom Kona family GPIO controller
> +
> +description:
> +  The Broadcom GPIO Controller IP can be configured prior to synthesis to
> +  support up to 8 banks of 32 GPIOs where each bank has its own IRQ. The
> +  GPIO controller only supports edge, not level, triggering of interrupts.
> +
> +maintainers:
> +  - Ray Jui <rjui@broadcom.com>
> +
> +properties:
> +  compatible:
> +    items:
> +      - enum:
> +          - brcm,bcm11351-gpio
> +          - brcm,bcm21664-gpio
> +          - brcm,bcm23550-gpio
> +      - const: brcm,kona-gpio
> +
> +  reg:
> +    maxItems: 1
> +
> +  interrupts:
> +    maxItems: 1

As Linus pointed out, you do not have one interrupt. Put here the widest
constraints (min/maxItems) and narrow it per each variant in
allOf:if:then:. Also fix the syntax in example. Each interrupt is in its
own <>.


Best regards,
Krzysztof
  

Patch

diff --git a/Documentation/devicetree/bindings/gpio/brcm,kona-gpio.txt b/Documentation/devicetree/bindings/gpio/brcm,kona-gpio.txt
deleted file mode 100644
index 4a63bc96b687..000000000000
--- a/Documentation/devicetree/bindings/gpio/brcm,kona-gpio.txt
+++ /dev/null
@@ -1,52 +0,0 @@ 
-Broadcom Kona Family GPIO
-=========================
-
-This GPIO driver is used in the following Broadcom SoCs:
-  BCM11130, BCM11140, BCM11351, BCM28145, BCM28155
-
-The Broadcom GPIO Controller IP can be configured prior to synthesis to
-support up to 8 banks of 32 GPIOs where each bank has its own IRQ. The
-GPIO controller only supports edge, not level, triggering of interrupts.
-
-Required properties
--------------------
-
-- compatible: "brcm,bcm11351-gpio", "brcm,kona-gpio"
-- reg: Physical base address and length of the controller's registers.
-- interrupts: The interrupt outputs from the controller. There is one GPIO
-  interrupt per GPIO bank. The number of interrupts listed depends on the
-  number of GPIO banks on the SoC. The interrupts must be ordered by bank,
-  starting with bank 0. There is always a 1:1 mapping between banks and
-  IRQs.
-- #gpio-cells: Should be <2>. The first cell is the pin number, the second
-  cell is used to specify optional parameters:
-  - bit 0 specifies polarity (0 for normal, 1 for inverted)
-  See also "gpio-specifier" in .../devicetree/bindings/gpio/gpio.txt.
-- #interrupt-cells: Should be <2>. The first cell is the GPIO number. The
-  second cell is used to specify flags. The following subset of flags is
-  supported:
-  - trigger type (bits[1:0]):
-      1 = low-to-high edge triggered.
-      2 = high-to-low edge triggered.
-      3 = low-to-high or high-to-low edge triggered
-      Valid values are 1, 2, 3
-  See also .../devicetree/bindings/interrupt-controller/interrupts.txt.
-- gpio-controller: Marks the device node as a GPIO controller.
-- interrupt-controller: Marks the device node as an interrupt controller.
-
-Example:
-	gpio: gpio@35003000 {
-		compatible = "brcm,bcm11351-gpio", "brcm,kona-gpio";
-		reg = <0x35003000 0x800>;
-		interrupts =
-		       <GIC_SPI 106 IRQ_TYPE_LEVEL_HIGH
-			GIC_SPI 115 IRQ_TYPE_LEVEL_HIGH
-			GIC_SPI 114 IRQ_TYPE_LEVEL_HIGH
-			GIC_SPI 113 IRQ_TYPE_LEVEL_HIGH
-			GIC_SPI 112 IRQ_TYPE_LEVEL_HIGH
-			GIC_SPI 111 IRQ_TYPE_LEVEL_HIGH>;
-		#gpio-cells = <2>;
-		#interrupt-cells = <2>;
-		gpio-controller;
-		interrupt-controller;
-	};
diff --git a/Documentation/devicetree/bindings/gpio/brcm,kona-gpio.yaml b/Documentation/devicetree/bindings/gpio/brcm,kona-gpio.yaml
new file mode 100644
index 000000000000..9d0b0a1af832
--- /dev/null
+++ b/Documentation/devicetree/bindings/gpio/brcm,kona-gpio.yaml
@@ -0,0 +1,77 @@ 
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/gpio/brcm,kona-gpio.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Broadcom Kona family GPIO controller
+
+description:
+  The Broadcom GPIO Controller IP can be configured prior to synthesis to
+  support up to 8 banks of 32 GPIOs where each bank has its own IRQ. The
+  GPIO controller only supports edge, not level, triggering of interrupts.
+
+maintainers:
+  - Ray Jui <rjui@broadcom.com>
+
+properties:
+  compatible:
+    items:
+      - enum:
+          - brcm,bcm11351-gpio
+          - brcm,bcm21664-gpio
+          - brcm,bcm23550-gpio
+      - const: brcm,kona-gpio
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+    description:
+      The interrupt outputs from the controller. There is one GPIO interrupt
+      per GPIO bank. The number of interrupts listed depends on the number of
+      GPIO banks on the SoC. The interrupts must be ordered by bank, starting
+      with bank 0. There is always a 1:1 mapping between banks and IRQs.
+
+  '#gpio-cells':
+    const: 2
+
+  '#interrupt-cells':
+    const: 2
+
+  gpio-controller: true
+
+  interrupt-controller: true
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - '#gpio-cells'
+  - '#interrupt-cells'
+  - gpio-controller
+  - interrupt-controller
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+    #include <dt-bindings/interrupt-controller/irq.h>
+
+    gpio@35003000 {
+        compatible = "brcm,bcm11351-gpio", "brcm,kona-gpio";
+        reg = <0x35003000 0x800>;
+        interrupts = <GIC_SPI 106 IRQ_TYPE_LEVEL_HIGH
+                      GIC_SPI 115 IRQ_TYPE_LEVEL_HIGH
+                      GIC_SPI 114 IRQ_TYPE_LEVEL_HIGH
+                      GIC_SPI 113 IRQ_TYPE_LEVEL_HIGH
+                      GIC_SPI 112 IRQ_TYPE_LEVEL_HIGH
+                      GIC_SPI 111 IRQ_TYPE_LEVEL_HIGH>;
+        #gpio-cells = <2>;
+        #interrupt-cells = <2>;
+        gpio-controller;
+        interrupt-controller;
+    };
+...
diff --git a/MAINTAINERS b/MAINTAINERS
index 733bcfa0209a..368fee1ef5b0 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -4221,7 +4221,7 @@  BROADCOM KONA GPIO DRIVER
 M:	Ray Jui <rjui@broadcom.com>
 R:	Broadcom internal kernel review list <bcm-kernel-feedback-list@broadcom.com>
 S:	Supported
-F:	Documentation/devicetree/bindings/gpio/brcm,kona-gpio.txt
+F:	Documentation/devicetree/bindings/gpio/brcm,kona-gpio.yaml
 F:	drivers/gpio/gpio-bcm-kona.c
 
 BROADCOM MPI3 STORAGE CONTROLLER DRIVER