[PATCH v3 1/2] dt-bindings: leds: Add multi-color default-intensities property

From: Sven Schwermer
Date: Thu May 05 2022 - 05:50:59 EST


From: Sven Schwermer <sven.schwermer@xxxxxxxxxxxxxxxxxxxxxxxxxxx>

This allows to assign intensity values to the individual sub LEDs
(colors) at driver probe time, i.e. most commonly at kernel boot time.
This is crucial for setting a specific color early in the boot process.

Signed-off-by: Sven Schwermer <sven.schwermer@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
---

Notes:
V1->V2: no changes
V2->V3:
- Use color-intensity mapping instead of simple intensity array
- Add example DTS snippet

.../bindings/leds/leds-class-multicolor.yaml | 37 +++++++++++++++++++
1 file changed, 37 insertions(+)

diff --git a/Documentation/devicetree/bindings/leds/leds-class-multicolor.yaml b/Documentation/devicetree/bindings/leds/leds-class-multicolor.yaml
index f41d021ed677..41050de496f6 100644
--- a/Documentation/devicetree/bindings/leds/leds-class-multicolor.yaml
+++ b/Documentation/devicetree/bindings/leds/leds-class-multicolor.yaml
@@ -31,6 +31,19 @@ patternProperties:
include/linux/leds/common.h.
enum: [ 8, 9 ]

+ default-intensities:
+ description: |
+ This parameter, if present, sets the initial intensities of the
+ individual colors. The format is a list of pairs, mapping an intensity
+ value to a sub LED identified by its color.
+ $ref: /schemas/types.yaml#/definitions/uint32-matrix
+ items:
+ minItems: 2
+ maxItems: 2
+ items:
+ - description: color identifier (LED_COLOR_ID_*)
+ - description: intensity value
+
$ref: "common.yaml#"

required:
@@ -38,4 +51,28 @@ patternProperties:

additionalProperties: true

+examples:
+ - |
+ #include <dt-bindings/leds/common.h>
+
+ multi-led {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ color = <LED_COLOR_ID_RGB>;
+ default-intensities = <LED_COLOR_ID_RED 64>,
+ <LED_COLOR_ID_BLUE 0>;
+ led@0 {
+ reg = <0>;
+ color = <LED_COLOR_ID_RED>;
+ };
+ led@1 {
+ reg = <1>;
+ color = <LED_COLOR_ID_GREEN>;
+ };
+ led@2 {
+ reg = <2>;
+ color = <LED_COLOR_ID_BLUE>;
+ };
+ };
...
--
2.36.0