2023-11-24 09:34:00

by Yuxi (Yuxi) Wang

[permalink] [raw]
Subject: [PATCH 1/2] dt-bindings: leds: add mps mp3326 LED

Document mps mp3326 LED driver devicetree bindings.

Signed-off-by: Yuxi Wang <[email protected]>
---
.../devicetree/bindings/leds/mps,mp3326.yaml | 143 ++++++++++++++++++
1 file changed, 143 insertions(+)
create mode 100644 Documentation/devicetree/bindings/leds/mps,mp3326.yaml

diff --git a/Documentation/devicetree/bindings/leds/mps,mp3326.yaml b/Documentation/devicetree/bindings/leds/mps,mp3326.yaml
new file mode 100644
index 000000000000..5f6bde46ccc8
--- /dev/null
+++ b/Documentation/devicetree/bindings/leds/mps,mp3326.yaml
@@ -0,0 +1,143 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/leds/mps,mp3326.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: MPS MP3326 RGB/White LED Driver
+
+maintainers:
+ - Yuxi Wang <[email protected]>
+
+description: |
+ The MP3326 is a RGB/White LED driver with I2C interface.
+
+ For more product information please see the link below:
+ https://www.monolithicpower.com/en/products/mp3326.html
+
+properties:
+ compatible:
+ const: mps,mp3326
+
+ "#address-cells":
+ const: 1
+
+ "#size-cells":
+ const: 0
+
+ reg:
+ maxItems: 1
+
+ multi-led:
+ type: object
+ unevaluatedProperties: false
+
+ properties:
+ "#address-cells":
+ const: 1
+
+ "#size-cells":
+ const: 0
+
+ color:
+ description: RGB module
+
+ patternProperties:
+ "^led@[0-3]$":
+ type: object
+ $ref: common.yaml#
+ unevaluatedProperties: false
+
+ properties:
+ reg:
+ description: Index of the LED.
+ minimum: 1
+ maximum: 16
+
+ required:
+ - reg
+ - color
+
+ required:
+ - "#address-cells"
+ - "#size-cells"
+ - color
+
+patternProperties:
+ "^led@[0-9]$":
+ type: object
+ $ref: common.yaml#
+ unevaluatedProperties: false
+
+ properties:
+ reg:
+ description: Index of the LED.
+ minimum: 1
+ maximum: 16
+
+ required:
+ - reg
+
+required:
+ - compatible
+ - reg
+ - "#address-cells"
+ - "#size-cells"
+
+additionalProperties: false
+
+examples:
+ - |
+ #include <dt-bindings/leds/common.h>
+
+ i2c {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ led-controller@30 {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ compatible = "mps,mp3326";
+ reg = <0x30>;
+ multi-led {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ color = <LED_COLOR_ID_RGB>;
+
+ led@0 {
+ reg = <1>;
+ color = <LED_COLOR_ID_RED>;
+ };
+
+ led@1 {
+ reg = <2>;
+ color = <LED_COLOR_ID_GREEN>;
+ };
+
+ led@2 {
+ reg = <3>;
+ color = <LED_COLOR_ID_BLUE>;
+ };
+ };
+ };
+ };
+
+ - |
+ #include <dt-bindings/leds/common.h>
+
+ i2c {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ led-controller@30 {
+ compatible = "mps,mp3326";
+ reg = <0x30>;
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ led@0 {
+ reg= <5>;
+ color = <LED_COLOR_ID_WHITE>;
+ };
+ };
+ };
+...
--
2.25.1


2023-11-25 10:44:55

by Krzysztof Kozlowski

[permalink] [raw]
Subject: Re: [PATCH 1/2] dt-bindings: leds: add mps mp3326 LED

On 24/11/2023 10:30, Yuxi Wang wrote:
> Document mps mp3326 LED driver devicetree bindings.
>
> Signed-off-by: Yuxi Wang <[email protected]>
> ---
> .../devicetree/bindings/leds/mps,mp3326.yaml | 143 ++++++++++++++++++
> 1 file changed, 143 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/leds/mps,mp3326.yaml
>
> diff --git a/Documentation/devicetree/bindings/leds/mps,mp3326.yaml b/Documentation/devicetree/bindings/leds/mps,mp3326.yaml
> new file mode 100644
> index 000000000000..5f6bde46ccc8
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/leds/mps,mp3326.yaml
> @@ -0,0 +1,143 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/leds/mps,mp3326.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: MPS MP3326 RGB/White LED Driver
> +
> +maintainers:
> + - Yuxi Wang <[email protected]>
> +
> +description: |
> + The MP3326 is a RGB/White LED driver with I2C interface.
> +
> + For more product information please see the link below:
> + https://www.monolithicpower.com/en/products/mp3326.html
> +
> +properties:
> + compatible:
> + const: mps,mp3326
> +
> + "#address-cells":
> + const: 1
> +
> + "#size-cells":
> + const: 0
> +
> + reg:
> + maxItems: 1
> +
> + multi-led:
> + type: object

Missing ref to multi-led class. Please open existing bindings with such
node and take a look how it is done there.

> + unevaluatedProperties: false
> +
> + properties:
> + "#address-cells":
> + const: 1
> +
> + "#size-cells":
> + const: 0
> +
> + color:
> + description: RGB module

Drop property

> +
> + patternProperties:
> + "^led@[0-3]$":

This says 4...

> + type: object
> + $ref: common.yaml#
> + unevaluatedProperties: false
> +
> + properties:
> + reg:
> + description: Index of the LED.
> + minimum: 1
> + maximum: 16

But this says 16.

Also reg does not match unit address. Minimum reg is 1, but unit address
is 0.

> +
> + required:
> + - reg
> + - color
> +
> + required:
> + - "#address-cells"
> + - "#size-cells"
> + - color

Drop color, it is coming with class-multicolor


> +
> +patternProperties:
> + "^led@[0-9]$":

It's even weirded. Here you have 10 leds with indices 0-9

> + type: object
> + $ref: common.yaml#
> + unevaluatedProperties: false
> +
> + properties:
> + reg:
> + description: Index of the LED.
> + minimum: 1
> + maximum: 16

bu there 16! With indices 1-16.

It's a mess.


> + required:
> + - reg
> +
> +required:
> + - compatible
> + - reg
> + - "#address-cells"
> + - "#size-cells"
> +
> +additionalProperties: false
> +
> +examples:
> + - |
> + #include <dt-bindings/leds/common.h>
> +
> + i2c {
> + #address-cells = <1>;
> + #size-cells = <0>;
> +
> + led-controller@30 {
> + #address-cells = <1>;
> + #size-cells = <0>;
> + compatible = "mps,mp3326";
> + reg = <0x30>;
> + multi-led {
> + #address-cells = <1>;
> + #size-cells = <0>;
> + color = <LED_COLOR_ID_RGB>;
> +
> + led@0 {
> + reg = <1>;

OK, you did not test it. Test your DTS before sending.

Also, messed indentation. Use 4 spaces.

Best regards,
Krzysztof