Skip to contentSkip to conversation

dt-bindings: leds: Convert PCA9532 to dtschema

PATCH Superseded Wadim Egorov 4 participants 4 messages Dec 28, 2022 – Dec 29, 2022

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dt-bindings: leds: Convert PCA9532 to dtschema

Convert the PCA9532 LED dimmer to dtschema.
While at it, also update and the the example to match recommended node names and the link to the product datasheet.

---
 .../devicetree/bindings/leds/leds-pca9532.txt | 49 -----------
 .../bindings/leds/leds-pca9532.yaml           | 86 +++++++++++++++++++
 2 files changed, 86 insertions(+), 49 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/leds/leds-pca9532.txt
 create mode 100644 Documentation/devicetree/bindings/leds/leds-pca9532.yaml
Documentation/devicetree/bindings/leds/leds-pca9532.txt deleted +0 -49
deleted file mode 100644
index f769c52e3643..000000000000
@@ -1,49 +0,0 @@
-*NXP - pca9532 PWM LED Driver
-
-The PCA9532 family is SMBus I/O expander optimized for dimming LEDs.
-The PWM support 256 steps.
-
-Required properties:
-	- compatible:
-		"nxp,pca9530"
-		"nxp,pca9531"
-		"nxp,pca9532"
-		"nxp,pca9533"
-	- reg -  I2C slave address
-
-Each led is represented as a sub-node of the nxp,pca9530.
-
-Optional sub-node properties:
-	- label: see Documentation/devicetree/bindings/leds/common.txt
-	- type: Output configuration, see dt-bindings/leds/leds-pca9532.h (default NONE)
-	- linux,default-trigger: see Documentation/devicetree/bindings/leds/common.txt
-	- default-state: see Documentation/devicetree/bindings/leds/common.txt
-	  This property is only valid for sub-nodes of type <PCA9532_TYPE_LED>.
-
-Example:
-  #include <dt-bindings/leds/leds-pca9532.h>
-
-  leds: pca9530@60 {
-    compatible = "nxp,pca9530";
-    reg = <0x60>;
-
-    red-power {
-      label = "pca:red:power";
-      type = <PCA9532_TYPE_LED>;
-    };
-    green-power {
-      label = "pca:green:power";
-      type = <PCA9532_TYPE_LED>;
-    };
-    kernel-booting {
-      type = <PCA9532_TYPE_LED>;
-      default-state = "on";
-    };
-    sys-stat {
-      type = <PCA9532_TYPE_LED>;
-      default-state = "keep"; // don't touch, was set by U-Boot
-    };
-  };
-
-For more product information please see the link below:
-http://nxp.com/documents/data_sheet/PCA9532.pdf
Documentation/devicetree/bindings/leds/leds-pca9532.yaml new file +86 -0

86 lines not on this page · raw message

Signature · 1 line
2.34.1
#1 lore raw

Documentation/devicetree/bindings/leds/leds-pca9532.yaml

Quoted 72 lines · Wadim Egorov

Convert the PCA9532 LED dimmer to dtschema.
While at it, also update and the the example to match recommended node names and the link to the product datasheet.

---
 .../devicetree/bindings/leds/leds-pca9532.txt | 49 -----------
 .../bindings/leds/leds-pca9532.yaml           | 86 +++++++++++++++++++
 2 files changed, 86 insertions(+), 49 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/leds/leds-pca9532.txt
 create mode 100644 Documentation/devicetree/bindings/leds/leds-pca9532.yaml
Documentation/devicetree/bindings/leds/leds-pca9532.txt deleted +0 -49
deleted file mode 100644
index f769c52e3643..000000000000
@@ -1,49 +0,0 @@
-*NXP - pca9532 PWM LED Driver
-
-The PCA9532 family is SMBus I/O expander optimized for dimming LEDs.
-The PWM support 256 steps.
-
-Required properties:
-	- compatible:
-		"nxp,pca9530"
-		"nxp,pca9531"
-		"nxp,pca9532"
-		"nxp,pca9533"
-	- reg -  I2C slave address
-
-Each led is represented as a sub-node of the nxp,pca9530.
-
-Optional sub-node properties:
-	- label: see Documentation/devicetree/bindings/leds/common.txt
-	- type: Output configuration, see dt-bindings/leds/leds-pca9532.h (default NONE)
-	- linux,default-trigger: see Documentation/devicetree/bindings/leds/common.txt
-	- default-state: see Documentation/devicetree/bindings/leds/common.txt
-	  This property is only valid for sub-nodes of type <PCA9532_TYPE_LED>.
-
-Example:
-  #include <dt-bindings/leds/leds-pca9532.h>
-
-  leds: pca9530@60 {
-    compatible = "nxp,pca9530";
-    reg = <0x60>;
-
-    red-power {
-      label = "pca:red:power";
-      type = <PCA9532_TYPE_LED>;
-    };
-    green-power {
-      label = "pca:green:power";
-      type = <PCA9532_TYPE_LED>;
-    };
-    kernel-booting {
-      type = <PCA9532_TYPE_LED>;
-      default-state = "on";
-    };
-    sys-stat {
-      type = <PCA9532_TYPE_LED>;
-      default-state = "keep"; // don't touch, was set by U-Boot
-    };
-  };
-
-For more product information please see the link below:
-http://nxp.com/documents/data_sheet/PCA9532.pdf
Documentation/devicetree/bindings/leds/leds-pca9532.yaml new file +0 -0
new file mode 100644
index 000000000000..e3741b5046b7

Filename matching compatibles, so nxp,pca9530.yaml or nxp,pca953x.yaml

Documentation/devicetree/bindings/leds/leds-pca9532.yaml line 7

Quoted 8 lines
Documentation/devicetree/bindings/leds/leds-pca9532.yaml new file +7 -0
@@ -0,0 +1,86 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/leds/leds-pca9532.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: NXP - pca9532 PWM LED Driver

Is "Driver" for Linux Driver? If yes, then drop.

Also drop dash after company name and make model uppercase.

Documentation/devicetree/bindings/leds/leds-pca9532.yaml line 11

Quoted 4 lines
Documentation/devicetree/bindings/leds/leds-pca9532.yaml new file +4 -0
+
+maintainers:
+  - Jacek Anaszewski <[email protected]>
+  - Pavel Machek <[email protected]>

Same as your other patch - not subsystem maintainers but device maintainers.

Quoted 9 lines
Documentation/devicetree/bindings/leds/leds-pca9532.yaml new file +9 -0
+
+description: |
+  The PCA9532 family is SMBus I/O expander optimized for dimming LEDs.
+  The PWM support 256 steps.
+
+  For more product information please see the link below:
+    https://www.nxp.com/docs/en/data-sheet/PCA9532.pdf
+
+properties:

Documentation/devicetree/bindings/leds/leds-pca9532.yaml line 30

Quoted 10 lines
Documentation/devicetree/bindings/leds/leds-pca9532.yaml new file +10 -0
+  compatible:
+    enum:
+      - nxp,pca9530
+      - nxp,pca9531
+      - nxp,pca9532
+      - nxp,pca9533
+
+  reg:
+    maxItems: 1
+    description: I2C slave address

Drop description

Documentation/devicetree/bindings/leds/leds-pca9532.yaml line 35

Quoted 5 lines
Documentation/devicetree/bindings/leds/leds-pca9532.yaml new file +5 -0
+
+patternProperties:
+  "^led-[0-9a-z]+$":
+    type: object
+    $ref: common.yaml#

unevaluatedProperties: false on this level

Documentation/devicetree/bindings/leds/leds-pca9532.yaml line 39

Quoted 4 lines
Documentation/devicetree/bindings/leds/leds-pca9532.yaml new file +4 -0
+    properties:
+      type:
+        description: |
+          Output configuration, see dt-bindings/leds/leds-pca9532.h

Full path

Documentation/devicetree/bindings/leds/leds-pca9532.yaml line 40

Quoted 1 line
Documentation/devicetree/bindings/leds/leds-pca9532.yaml new file +1 -0
+          Default is 0, PCA9532_TYPE_NONE.

Instead:
default: 0

Don't repeat constraints in free form text.

Quoted 7 lines
Documentation/devicetree/bindings/leds/leds-pca9532.yaml new file +7 -0
+        $ref: /schemas/types.yaml#/definitions/uint32
+        minimum: 0
+        maximum: 4
+
+required:
+  - compatible
+  - reg

Documentation/devicetree/bindings/leds/leds-pca9532.yaml line 57

Quoted 10 lines
Documentation/devicetree/bindings/leds/leds-pca9532.yaml new file +10 -0
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/leds/leds-pca9532.h>
+
+    i2c {
+        led-controller@62 {
+                compatible = "nxp,pca9533";

Messed indentation. Use 4 spaces for example indentation.

Documentation/devicetree/bindings/leds/leds-pca9532.yaml line 58

Quoted 1 line
Documentation/devicetree/bindings/leds/leds-pca9532.yaml new file +1 -0
+                reg = <0x62>;

Best regards,
Krzysztof

maintainer
#2 lore raw
In reply to Wadim Egorov
Quoted 4 lines · Wadim Egorov

Convert the PCA9532 LED dimmer to dtschema.
While at it, also update and the the example to match recommended node names and the link to the product datasheet.

Quoted 8 lines
---
 .../devicetree/bindings/leds/leds-pca9532.txt | 49 -----------
 .../bindings/leds/leds-pca9532.yaml           | 86 +++++++++++++++++++
 2 files changed, 86 insertions(+), 49 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/leds/leds-pca9532.txt
 create mode 100644 Documentation/devicetree/bindings/leds/leds-pca9532.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:
Error: Documentation/devicetree/bindings/leds/leds-pca9532.example.dts:28.38-39 syntax error FATAL ERROR: Unable to parse input tree
make[1]: *** [scripts/Makefile.lib:434: Documentation/devicetree/bindings/leds/leds-pca9532.example.dtb] Error 1 make[1]: *** Waiting for unfinished jobs....
make: *** [Makefile:1508: dt_binding_check] Error 2

doc reference errors (make refcheckdocs):

See https://patchwork.ozlabs.org/project/devicetree-bindings/patch/[email protected]

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.

#3 lore raw
In reply to Wadim Egorov

Hi Wadim,

Quoted 73 lines · Wadim Egorov

Convert the PCA9532 LED dimmer to dtschema.
While at it, also update and the the example to match recommended node names and the link to the product datasheet.

---
  .../devicetree/bindings/leds/leds-pca9532.txt | 49 -----------
  .../bindings/leds/leds-pca9532.yaml           | 86 +++++++++++++++++++
  2 files changed, 86 insertions(+), 49 deletions(-)

delete mode 100644 Documentation/devicetree/bindings/leds/leds-pca9532.txt create mode 100644 Documentation/devicetree/bindings/leds/leds-pca9532.yaml

Documentation/devicetree/bindings/leds/leds-pca9532.txt deleted +0 -49
deleted file mode 100644
index f769c52e3643..000000000000
@@ -1,49 +0,0 @@
-*NXP - pca9532 PWM LED Driver
-
-The PCA9532 family is SMBus I/O expander optimized for dimming LEDs.
-The PWM support 256 steps.
-
-Required properties:
-	- compatible:
-		"nxp,pca9530"
-		"nxp,pca9531"
-		"nxp,pca9532"
-		"nxp,pca9533"
-	- reg -  I2C slave address
-
-Each led is represented as a sub-node of the nxp,pca9530.
-
-Optional sub-node properties:
-	- label: see Documentation/devicetree/bindings/leds/common.txt
-	- type: Output configuration, see dt-bindings/leds/leds-pca9532.h (default NONE)
-	- linux,default-trigger: see Documentation/devicetree/bindings/leds/common.txt
-	- default-state: see Documentation/devicetree/bindings/leds/common.txt
-	  This property is only valid for sub-nodes of type <PCA9532_TYPE_LED>.
-
-Example:
-  #include <dt-bindings/leds/leds-pca9532.h>
-
-  leds: pca9530@60 {
-    compatible = "nxp,pca9530";
-    reg = <0x60>;
-
-    red-power {
-      label = "pca:red:power";
-      type = <PCA9532_TYPE_LED>;
-    };
-    green-power {
-      label = "pca:green:power";
-      type = <PCA9532_TYPE_LED>;
-    };
-    kernel-booting {
-      type = <PCA9532_TYPE_LED>;
-      default-state = "on";
-    };
-    sys-stat {
-      type = <PCA9532_TYPE_LED>;
-      default-state = "keep"; // don't touch, was set by U-Boot
-    };
-  };
-
-For more product information please see the link below:
-http://nxp.com/documents/data_sheet/PCA9532.pdf
Documentation/devicetree/bindings/leds/leds-pca9532.yaml new file +0 -0
new file mode 100644
index 000000000000..e3741b5046b7

Documentation/devicetree/bindings/leds/leds-pca9532.yaml line 10

Quoted 10 lines
Documentation/devicetree/bindings/leds/leds-pca9532.yaml new file +10 -0
@@ -0,0 +1,86 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/leds/leds-pca9532.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: NXP - pca9532 PWM LED Driver
+
+maintainers:
+  - Jacek Anaszewski <[email protected]>

Please remove myself, since I am not longer an LED subsystem maintainer.

Quoted 41 lines
Documentation/devicetree/bindings/leds/leds-pca9532.yaml new file +41 -0
+  - Pavel Machek <[email protected]>
+
+description: |
+  The PCA9532 family is SMBus I/O expander optimized for dimming LEDs.
+  The PWM support 256 steps.
+
+  For more product information please see the link below:
+    https://www.nxp.com/docs/en/data-sheet/PCA9532.pdf
+
+properties:
+  compatible:
+    enum:
+      - nxp,pca9530
+      - nxp,pca9531
+      - nxp,pca9532
+      - nxp,pca9533
+
+  reg:
+    maxItems: 1
+    description: I2C slave address
+
+patternProperties:
+  "^led-[0-9a-z]+$":
+    type: object
+    $ref: common.yaml#
+    properties:
+      type:
+        description: |
+          Output configuration, see dt-bindings/leds/leds-pca9532.h
+          Default is 0, PCA9532_TYPE_NONE.
+        $ref: /schemas/types.yaml#/definitions/uint32
+        minimum: 0
+        maximum: 4
+
+required:
+  - compatible
+  - reg
+
+additionalProperties: false
+
+examples:

Documentation/devicetree/bindings/leds/leds-pca9532.yaml line 61

Quoted 10 lines
Documentation/devicetree/bindings/leds/leds-pca9532.yaml new file +10 -0
+  - |
+    #include <dt-bindings/leds/leds-pca9532.h>
+
+    i2c {
+        led-controller@62 {
+                compatible = "nxp,pca9533";
+                reg = <0x62>;
+
+                led-1 {
+                        label = "user1";

You should leave label unchanged, since this patch claims that it only converts the file format. And anyway, the driver does not use led_classdev_register_ext(), so it won't parse 'color' property automatically.

Quoted 25 lines
Documentation/devicetree/bindings/leds/leds-pca9532.yaml new file +25 -0
+                        type = <PCA9532_TYPE_LED>;
+                        color = <LED_COLOR_ID_RED>;
+                };
+
+                led-2 {
+                        label = "user2";
+                        type = <PCA9532_TYPE_LED>;
+                        color = <LED_COLOR_ID_GREEN>;
+                };
+
+                led-3 {
+                        label = "user3";
+                        type = <PCA9532_TYPE_LED>;
+                        color = <LED_COLOR_ID_BLUE>;
+                };
+
+                led-4 {
+                        label = "user4";
+                        type = <PCA9532_TYPE_LED>;
+                        color = <LED_COLOR_ID_RED>;
+                };
+        };
+    };
+
+...
Signature · 2 lines
Best regards,
Jacek Anaszewski