Skip to contentSkip to conversation

dt-bindings: leds: pca955x: Convert text bindings to YAML

PATCH Superseded Delphine CC Chiu 2 participants 3 messages Oct 16, 2024

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dt-bindings: leds: pca955x: Convert text bindings to YAML

From: Ricky CX Wu <[email protected]>

Convert the text bindings of pca955x to YAML so it could be used to validate the DTS.

---
 .../devicetree/bindings/leds/leds-pca955x.txt |  89 ----------
 .../devicetree/bindings/leds/nxp,pca955x.yaml | 161 ++++++++++++++++++
 2 files changed, 161 insertions(+), 89 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/leds/leds-pca955x.txt
 create mode 100644 Documentation/devicetree/bindings/leds/nxp,pca955x.yaml
Documentation/devicetree/bindings/leds/leds-pca955x.txt deleted +0 -89
deleted file mode 100644
index 817f460f3a72..000000000000
@@ -1,89 +0,0 @@
-* NXP - pca955x LED driver
-
-The PCA955x family of chips are I2C LED blinkers whose pins not used
-to control LEDs can be used as general purpose I/Os. The GPIO pins can
-be input or output, and output pins can also be pulse-width controlled.
-
-Required properties:
-- compatible : should be one of :
-	"nxp,pca9550"
-	"nxp,pca9551"
-	"nxp,pca9552"
-	"ibm,pca9552"
-	"nxp,pca9553"
-- #address-cells: must be 1
-- #size-cells: must be 0
-- reg: I2C slave address. depends on the model.
-
-Optional properties:
-- gpio-controller: allows pins to be used as GPIOs.
-- #gpio-cells: must be 2.
-- gpio-line-names: define the names of the GPIO lines
-
-LED sub-node properties:
-- reg : number of LED line.
-		from 0 to  1 for the pca9550
-		from 0 to  7 for the pca9551
-		from 0 to 15 for the pca9552
-		from 0 to  3 for the pca9553
-- type: (optional) either
-	PCA955X_TYPE_NONE
-	PCA955X_TYPE_LED
-	PCA955X_TYPE_GPIO
-	see dt-bindings/leds/leds-pca955x.h (default to LED)
-- label : (optional)
-	see Documentation/devicetree/bindings/leds/common.txt
-- linux,default-trigger : (optional)
-	see Documentation/devicetree/bindings/leds/common.txt
-
-Examples:
-
-pca9552: pca9552@60 {
-	compatible = "nxp,pca9552";
-	#address-cells = <1>;
-        #size-cells = <0>;
-	reg = <0x60>;
-
-	gpio-controller;
-	#gpio-cells = <2>;
-	gpio-line-names = "GPIO12", "GPIO13", "GPIO14", "GPIO15";
-
-	gpio@12 {
-		reg = <12>;
-		type = <PCA955X_TYPE_GPIO>;
-	};
-	gpio@13 {
-		reg = <13>;
-		type = <PCA955X_TYPE_GPIO>;
-	};
-	gpio@14 {
-		reg = <14>;
-		type = <PCA955X_TYPE_GPIO>;
-	};
-	gpio@15 {
-		reg = <15>;
-		type = <PCA955X_TYPE_GPIO>;
-	};
-
-	led@0 {
-		label = "red:power";
-		linux,default-trigger = "default-on";
-		reg = <0>;
-		type = <PCA955X_TYPE_LED>;
-	};
-	led@1 {
-		label = "green:power";
-		reg = <1>;
-		type = <PCA955X_TYPE_LED>;
-	};
-	led@2 {
-		label = "pca9552:yellow";
-		reg = <2>;
-		type = <PCA955X_TYPE_LED>;
-	};
-	led@3 {
-		label = "pca9552:white";
-		reg = <3>;
-		type = <PCA955X_TYPE_LED>;
-	};
-};
Documentation/devicetree/bindings/leds/nxp,pca955x.yaml new file +161 -0

161 lines not on this page · raw message

Signature · 1 line
2.25.1
#1 lore raw
Quoted 149 lines · Delphine CC Chiu

From: Ricky CX Wu <[email protected]>

Convert the text bindings of pca955x to YAML so it could be used to validate the DTS.

---
 .../devicetree/bindings/leds/leds-pca955x.txt |  89 ----------
 .../devicetree/bindings/leds/nxp,pca955x.yaml | 161 ++++++++++++++++++
 2 files changed, 161 insertions(+), 89 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/leds/leds-pca955x.txt
 create mode 100644 Documentation/devicetree/bindings/leds/nxp,pca955x.yaml
Documentation/devicetree/bindings/leds/leds-pca955x.txt deleted +0 -89
deleted file mode 100644
index 817f460f3a72..000000000000
@@ -1,89 +0,0 @@
-* NXP - pca955x LED driver
-
-The PCA955x family of chips are I2C LED blinkers whose pins not used
-to control LEDs can be used as general purpose I/Os. The GPIO pins can
-be input or output, and output pins can also be pulse-width controlled.
-
-Required properties:
-- compatible : should be one of :
-	"nxp,pca9550"
-	"nxp,pca9551"
-	"nxp,pca9552"
-	"ibm,pca9552"
-	"nxp,pca9553"
-- #address-cells: must be 1
-- #size-cells: must be 0
-- reg: I2C slave address. depends on the model.
-
-Optional properties:
-- gpio-controller: allows pins to be used as GPIOs.
-- #gpio-cells: must be 2.
-- gpio-line-names: define the names of the GPIO lines
-
-LED sub-node properties:
-- reg : number of LED line.
-		from 0 to  1 for the pca9550
-		from 0 to  7 for the pca9551
-		from 0 to 15 for the pca9552
-		from 0 to  3 for the pca9553
-- type: (optional) either
-	PCA955X_TYPE_NONE
-	PCA955X_TYPE_LED
-	PCA955X_TYPE_GPIO
-	see dt-bindings/leds/leds-pca955x.h (default to LED)
-- label : (optional)
-	see Documentation/devicetree/bindings/leds/common.txt
-- linux,default-trigger : (optional)
-	see Documentation/devicetree/bindings/leds/common.txt
-
-Examples:
-
-pca9552: pca9552@60 {
-	compatible = "nxp,pca9552";
-	#address-cells = <1>;
-        #size-cells = <0>;
-	reg = <0x60>;
-
-	gpio-controller;
-	#gpio-cells = <2>;
-	gpio-line-names = "GPIO12", "GPIO13", "GPIO14", "GPIO15";
-
-	gpio@12 {
-		reg = <12>;
-		type = <PCA955X_TYPE_GPIO>;
-	};
-	gpio@13 {
-		reg = <13>;
-		type = <PCA955X_TYPE_GPIO>;
-	};
-	gpio@14 {
-		reg = <14>;
-		type = <PCA955X_TYPE_GPIO>;
-	};
-	gpio@15 {
-		reg = <15>;
-		type = <PCA955X_TYPE_GPIO>;
-	};
-
-	led@0 {
-		label = "red:power";
-		linux,default-trigger = "default-on";
-		reg = <0>;
-		type = <PCA955X_TYPE_LED>;
-	};
-	led@1 {
-		label = "green:power";
-		reg = <1>;
-		type = <PCA955X_TYPE_LED>;
-	};
-	led@2 {
-		label = "pca9552:yellow";
-		reg = <2>;
-		type = <PCA955X_TYPE_LED>;
-	};
-	led@3 {
-		label = "pca9552:white";
-		reg = <3>;
-		type = <PCA955X_TYPE_LED>;
-	};
-};
Documentation/devicetree/bindings/leds/nxp,pca955x.yaml new file +34 -0
new file mode 100644
index 000000000000..70f8c1dfa75a
@@ -0,0 +1,161 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/leds/nxp,pca955x.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: NXP PCA955X LED controllers
+
+maintainers:
+  - Nate Case <[email protected]>
+
+description: |
+  The PCA955x family of chips are I2C LED blinkers whose pins not used
+  to control LEDs can be used as general purpose I/Os. The GPIO pins can
+  be input or output, and output pins can also be pulse-width controlled.
+
+  For more product information please see the link below:
+  - https://www.nxp.com/docs/en/data-sheet/PCA9552.pdf
+
+properties:
+  compatible:
+    enum:
+      - nxp,pca9550
+      - nxp,pca9551
+      - nxp,pca9552
+      - ibm,pca9552
+      - nxp,pca9553
+
+  reg:
+    maxItems: 1
+
+  "#address-cells":
+    const: 1
+

Documentation/devicetree/bindings/leds/nxp,pca955x.yaml line 44

Quoted 10 lines
Documentation/devicetree/bindings/leds/nxp,pca955x.yaml new file +10 -0
+  "#size-cells":
+    const: 0
+
+  gpio-controller: true
+
+  gpio-line-names:
+    minItems: 1
+    maxItems: 16
+
+  '#gpio-cells':

Keep consistent quotes: " or '

Documentation/devicetree/bindings/leds/nxp,pca955x.yaml line 48

Quoted 4 lines
Documentation/devicetree/bindings/leds/nxp,pca955x.yaml new file +4 -0
+    const: 2
+
+patternProperties:
+  "^led@[0-9a-f]+$":

max is 15 leds, so f, thus '+' is not needed. Same in other places.

Documentation/devicetree/bindings/leds/nxp,pca955x.yaml line 55

Quoted 7 lines
Documentation/devicetree/bindings/leds/nxp,pca955x.yaml new file +7 -0
+    type: object
+    $ref: common.yaml#
+    unevaluatedProperties: false
+
+    properties:
+      reg:
+        minimum: 0

drop minimum, but instead maxItems: 1

Documentation/devicetree/bindings/leds/nxp,pca955x.yaml line 62

Quoted 7 lines
Documentation/devicetree/bindings/leds/nxp,pca955x.yaml new file +7 -0
+      type:
+        description: |
+          Output configuration, see include/dt-bindings/leds/leds-pca955x.h
+        $ref: /schemas/types.yaml#/definitions/uint32
+        default: 0
+        minimum: 0
+        maximum: 4

I see defines up to 2, not 4. Any changes in binding should be explained in commit msg.

Quoted 36 lines
Documentation/devicetree/bindings/leds/nxp,pca955x.yaml new file +36 -0
+
+    required:
+      - reg
+
+allOf:
+  - if:
+      properties:
+        compatible:
+          contains:
+            enum:
+              - nxp,pca9550
+    then:
+      patternProperties:
+        "^led@[0-9a-f]+$":
+          properties:
+            reg:
+              maximum: 1
+    else:
+      if:
+        properties:
+          compatible:
+            contains:
+              enum:
+                - nxp,pca9551
+      then:
+        patternProperties:
+          "^led@[0-9a-f]+$":
+            properties:
+              reg:
+                maximum: 7
+      else:
+        if:
+          properties:
+            compatible:
+              contains:
+                enum:

Documentation/devicetree/bindings/leds/nxp,pca955x.yaml line 108

Quoted 10 lines
Documentation/devicetree/bindings/leds/nxp,pca955x.yaml new file +10 -0
+                  - nxp,pca9552
+                  - ibm,pca9552
+        then:
+          patternProperties:
+            "^led@[0-9a-f]+$":
+              properties:
+                reg:
+                  maximum: 15
+        else:
+          if:

Do not nest else:if. It's not manageable. See other bindings...

Documentation/devicetree/bindings/leds/nxp,pca955x.yaml line 121

Quoted 13 lines
Documentation/devicetree/bindings/leds/nxp,pca955x.yaml new file +13 -0
+            properties:
+              compatible:
+                contains:
+                  enum:
+                    - nxp,pca9553
+          then:
+            patternProperties:
+              "^led@[0-9a-f]+$":
+                properties:
+                  reg:
+                    maximum: 3
+
+additionalProperties: false

Best regards,
Krzysztof

#2 lore raw
Quoted 191 lines

-----Original Message-----
From: Krzysztof Kozlowski <[email protected]>
Sent: Wednesday, October 16, 2024 3:31 PM
To: Delphine_CC_Chiu/WYHQ/Wiwynn <[email protected]>
Cc: [email protected]; Pavel Machek <[email protected]>; Lee Jones <[email protected]>; Rob Herring <[email protected]>; Krzysztof Kozlowski <[email protected]>; Conor Dooley <[email protected]>; Nate Case <[email protected]>; Ricky CX Wu <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v1] dt-bindings: leds: pca955x: Convert text bindings to YAML

[External Sender]

[External Sender]

Quoted 119 lines · Delphine CC Chiu

From: Ricky CX Wu <[email protected]>

Convert the text bindings of pca955x to YAML so it could be used to validate the DTS.

---
 .../devicetree/bindings/leds/leds-pca955x.txt |  89 ----------
.../devicetree/bindings/leds/nxp,pca955x.yaml | 161 ++++++++++++++++++
 2 files changed, 161 insertions(+), 89 deletions(-)  delete mode
100644 Documentation/devicetree/bindings/leds/leds-pca955x.txt
 create mode 100644

Documentation/devicetree/bindings/leds/nxp,pca955x.yaml

Documentation/devicetree/bindings/leds/leds-pca955x.txt deleted +0 -4
deleted file mode 100644
index 817f460f3a72..000000000000
@@ -1,89 +0,0 @@
-* NXP - pca955x LED driver
-
-The PCA955x family of chips are I2C LED blinkers whose pins not used
-to control LEDs can be used as general purpose I/Os. The GPIO pins

can -be input or output, and output pins can also be pulse-width controlled.

Documentation/devicetree/bindings/leds/leds-pca955x.txt deleted +0 -84
-
-Required properties:
-- compatible : should be one of :
-     "nxp,pca9550"
-     "nxp,pca9551"
-     "nxp,pca9552"
-     "ibm,pca9552"
-     "nxp,pca9553"
-- #address-cells: must be 1
-- #size-cells: must be 0
-- reg: I2C slave address. depends on the model.
-
-Optional properties:
-- gpio-controller: allows pins to be used as GPIOs.
-- #gpio-cells: must be 2.
-- gpio-line-names: define the names of the GPIO lines
-
-LED sub-node properties:
-- reg : number of LED line.
-             from 0 to  1 for the pca9550
-             from 0 to  7 for the pca9551
-             from 0 to 15 for the pca9552
-             from 0 to  3 for the pca9553
-- type: (optional) either
-     PCA955X_TYPE_NONE
-     PCA955X_TYPE_LED
-     PCA955X_TYPE_GPIO
-     see dt-bindings/leds/leds-pca955x.h (default to LED)
-- label : (optional)
-     see Documentation/devicetree/bindings/leds/common.txt
-- linux,default-trigger : (optional)
-     see Documentation/devicetree/bindings/leds/common.txt
-
-Examples:
-
-pca9552: pca9552@60 {
-     compatible = "nxp,pca9552";
-     #address-cells = <1>;
-        #size-cells = <0>;
-     reg = <0x60>;
-
-     gpio-controller;
-     #gpio-cells = <2>;
-     gpio-line-names = "GPIO12", "GPIO13", "GPIO14", "GPIO15";
-
-     gpio@12 {
-             reg = <12>;
-             type = <PCA955X_TYPE_GPIO>;
-     };
-     gpio@13 {
-             reg = <13>;
-             type = <PCA955X_TYPE_GPIO>;
-     };
-     gpio@14 {
-             reg = <14>;
-             type = <PCA955X_TYPE_GPIO>;
-     };
-     gpio@15 {
-             reg = <15>;
-             type = <PCA955X_TYPE_GPIO>;
-     };
-
-     led@0 {
-             label = "red:power";
-             linux,default-trigger = "default-on";
-             reg = <0>;
-             type = <PCA955X_TYPE_LED>;
-     };
-     led@1 {
-             label = "green:power";
-             reg = <1>;
-             type = <PCA955X_TYPE_LED>;
-     };
-     led@2 {
-             label = "pca9552:yellow";
-             reg = <2>;
-             type = <PCA955X_TYPE_LED>;
-     };
-     led@3 {
-             label = "pca9552:white";
-             reg = <3>;
-             type = <PCA955X_TYPE_LED>;
-     };
-};
Documentation/devicetree/bindings/leds/nxp,pca955x.yaml new file +0 -0
new file mode 100644
index 000000000000..70f8c1dfa75a

Documentation/devicetree/bindings/leds/nxp,pca955x.yaml line 4

Quoted 4 lines
Documentation/devicetree/bindings/leds/nxp,pca955x.yaml new file +4 -0
@@ -0,0 +1,161 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause %YAML 1.2
+---
+$id:
+https://urldefense.com/v3/__http://devicetree.org/schemas/leds/nxp,pc

+a955x.yaml*__;Iw!!J63qqgXj!PIbrsq8E67aNk4sJHGvfkCqhXd5PNeLXGzE4uXNe V5

Documentation/devicetree/bindings/leds/nxp,pca955x.yaml line 7

Quoted 4 lines
Documentation/devicetree/bindings/leds/nxp,pca955x.yaml new file +3 -0
+8pCETmSSk3Dxy1prR7fHmTRgTTAKMXAxas54MARw$
+$schema:
+https://urldefense.com/v3/__http://devicetree.org/meta-schemas/core.y

+aml*__;Iw!!J63qqgXj!PIbrsq8E67aNk4sJHGvfkCqhXd5PNeLXGzE4uXNeV58pCE TmS

Quoted 8 lines
Documentation/devicetree/bindings/leds/nxp,pca955x.yaml new file +8 -0
+Sk3Dxy1prR7fHmTRgTTAKMXAxagMegPKw$
+
+title: NXP PCA955X LED controllers
+
+maintainers:
+  - Nate Case <[email protected]>
+
+description: |

Documentation/devicetree/bindings/leds/nxp,pca955x.yaml line 19

Quoted 10 lines
Documentation/devicetree/bindings/leds/nxp,pca955x.yaml new file +10 -0
+  The PCA955x family of chips are I2C LED blinkers whose pins not
+used
+  to control LEDs can be used as general purpose I/Os. The GPIO pins
+can
+  be input or output, and output pins can also be pulse-width controlled.
+
+  For more product information please see the link below:
+  -
+ https://urldefense.com/v3/__https://www.nxp.com/docs/en/data-sheet/P
+

CA9552.pdf__;!!J63qqgXj!PIbrsq8E67aNk4sJHGvfkCqhXd5PNeLXGzE4uXNeV58p

Quoted 21 lines
Documentation/devicetree/bindings/leds/nxp,pca955x.yaml new file +21 -0
+ CETmSSk3Dxy1prR7fHmTRgTTAKMXAxbzCK6mRw$
+
+properties:
+  compatible:
+    enum:
+      - nxp,pca9550
+      - nxp,pca9551
+      - nxp,pca9552
+      - ibm,pca9552
+      - nxp,pca9553
+
+  reg:
+    maxItems: 1
+
+  "#address-cells":
+    const: 1
+
+  "#size-cells":
+    const: 0
+
+  gpio-controller: true
Quoted 9 lines

Documentation/devicetree/bindings/leds/nxp,pca955x.yaml line 44

Quoted 6 lines
Documentation/devicetree/bindings/leds/nxp,pca955x.yaml new file +6 -0
+
+  gpio-line-names:
+    minItems: 1
+    maxItems: 16
+
+  '#gpio-cells':

Keep consistent quotes: " or '

Updated in v2.

Quoted 7 lines

Documentation/devicetree/bindings/leds/nxp,pca955x.yaml line 48

Quoted 4 lines
Documentation/devicetree/bindings/leds/nxp,pca955x.yaml new file +4 -0
+    const: 2
+
+patternProperties:
+  "^led@[0-9a-f]+$":

max is 15 leds, so f, thus '+' is not needed. Same in other places.

Updated in v2.

Quoted 10 lines

Documentation/devicetree/bindings/leds/nxp,pca955x.yaml line 55

Quoted 7 lines
Documentation/devicetree/bindings/leds/nxp,pca955x.yaml new file +7 -0
+    type: object
+    $ref: common.yaml#
+    unevaluatedProperties: false
+
+    properties:
+      reg:
+        minimum: 0

drop minimum, but instead maxItems: 1

Updated in v2.

Quoted 4 lines

Documentation/devicetree/bindings/leds/nxp,pca955x.yaml

Quoted 4 lines
Documentation/devicetree/bindings/leds/nxp,pca955x.yaml new file +3 -0
+      type:
+        description: |
+          Output configuration, see
Quoted 8 lines

include/dt-bindings/leds/leds-pca955x.h

Documentation/devicetree/bindings/leds/nxp,pca955x.yaml line 62

Quoted 4 lines
Documentation/devicetree/bindings/leds/nxp,pca955x.yaml new file +4 -0
+        $ref: /schemas/types.yaml#/definitions/uint32
+        default: 0
+        minimum: 0
+        maximum: 4

I see defines up to 2, not 4. Any changes in binding should be explained in commit msg.

Checked the leds-pca955x.h and set it to 2 in v2.

Quoted 42 lines
Quoted 42 lines
Documentation/devicetree/bindings/leds/nxp,pca955x.yaml new file +40 -0
+
+    required:
+      - reg
+
+allOf:
+  - if:
+      properties:
+        compatible:
+          contains:
+            enum:
+              - nxp,pca9550
+    then:
+      patternProperties:
+        "^led@[0-9a-f]+$":
+          properties:
+            reg:
+              maximum: 1
+    else:
+      if:
+        properties:
+          compatible:
+            contains:
+              enum:
+                - nxp,pca9551
+      then:
+        patternProperties:
+          "^led@[0-9a-f]+$":
+            properties:
+              reg:
+                maximum: 7
+      else:
+        if:
+          properties:
+            compatible:
+              contains:
+                enum:
+                  - nxp,pca9552
+                  - ibm,pca9552
+        then:
+          patternProperties:
Quoted 9 lines

Documentation/devicetree/bindings/leds/nxp,pca955x.yaml line 108

Quoted 6 lines
Documentation/devicetree/bindings/leds/nxp,pca955x.yaml new file +6 -0
+            "^led@[0-9a-f]+$":
+              properties:
+                reg:
+                  maximum: 15
+        else:
+          if:

Do not nest else:if. It's not manageable. See other bindings...

Updated in v2, Thanks.

Quoted 16 lines

Documentation/devicetree/bindings/leds/nxp,pca955x.yaml line 121

Quoted 13 lines
Documentation/devicetree/bindings/leds/nxp,pca955x.yaml new file +13 -0
+            properties:
+              compatible:
+                contains:
+                  enum:
+                    - nxp,pca9553
+          then:
+            patternProperties:
+              "^led@[0-9a-f]+$":
+                properties:
+                  reg:
+                    maximum: 3
+
+additionalProperties: false

Best regards,
Krzysztof