* Initial multicolor LED intensities @ 2022-05-02 14:09 Sven Schwermer 2022-05-02 20:46 ` Pavel Machek 0 siblings, 1 reply; 16+ messages in thread From: Sven Schwermer @ 2022-05-02 14:09 UTC (permalink / raw) To: linux-leds Hi, Is there a way to assign initial (non-zero) intensities to the individual colors of a multicolor LED via the device tree? In my use case, I'd like to assign a default trigger to a multicolor LED (e.g. linux,default-trigger="heartbeat"). However, since the color intensities are zero upon boot, I don't get a heartbeat on the multicolor LED. Best regards, Sven ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Initial multicolor LED intensities 2022-05-02 14:09 Initial multicolor LED intensities Sven Schwermer @ 2022-05-02 20:46 ` Pavel Machek 2022-05-03 11:04 ` [PATCH v1 1/2] dt-bindings: leds: Add multi-color default-intensities property Sven Schwermer ` (2 more replies) 0 siblings, 3 replies; 16+ messages in thread From: Pavel Machek @ 2022-05-02 20:46 UTC (permalink / raw) To: Sven Schwermer; +Cc: linux-leds Hi! > Is there a way to assign initial (non-zero) intensities to the individual > colors of a multicolor LED via the device tree? I don't believe we have such functionality. Patch would be welcome. > In my use case, I'd like to assign a default trigger to a multicolor LED > (e.g. linux,default-trigger="heartbeat"). However, since the color > intensities are zero upon boot, I don't get a heartbeat on the multicolor > LED. Hmm. Defaulting to zero does not really make much sense. I guess we should default to full on all channels? Best regards, Pavel ^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH v1 1/2] dt-bindings: leds: Add multi-color default-intensities property 2022-05-02 20:46 ` Pavel Machek @ 2022-05-03 11:04 ` Sven Schwermer 2022-05-03 11:04 ` [PATCH v1 2/2] leds: multicolor: Read " Sven Schwermer 2022-05-03 11:27 ` [PATCH v2 1/2] dt-bindings: leds: Add multi-color " Sven Schwermer 2022-05-05 9:50 ` [PATCH v3 " Sven Schwermer 2 siblings, 1 reply; 16+ messages in thread From: Sven Schwermer @ 2022-05-03 11:04 UTC (permalink / raw) To: linux-leds, linux-kernel, pavel, robh+dt, krzysztof.kozlowski+dt, dmurphy, devicetree Cc: Sven Schwermer From: Sven Schwermer <sven.schwermer@disruptive-technologies.com> This allows to assign intensity values to the indivisual 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@disruptive-technologies.com> --- .../devicetree/bindings/leds/leds-class-multicolor.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Documentation/devicetree/bindings/leds/leds-class-multicolor.yaml b/Documentation/devicetree/bindings/leds/leds-class-multicolor.yaml index 37445c68cdef..c483967a847c 100644 --- a/Documentation/devicetree/bindings/leds/leds-class-multicolor.yaml +++ b/Documentation/devicetree/bindings/leds/leds-class-multicolor.yaml @@ -31,6 +31,13 @@ patternProperties: include/linux/leds/common.h. enum: [ 8, 9 ] + default-intensities: + description: | + This parameter, if present, sets the initial intensities of the + individual colors. This array must have the same length as the + multi-color LED has sub LEDs (colors). + $ref: /schemas/types.yaml#/definitions/uint32-array + $ref: "common.yaml#" required: -- 2.36.0 ^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v1 2/2] leds: multicolor: Read default-intensities property 2022-05-03 11:04 ` [PATCH v1 1/2] dt-bindings: leds: Add multi-color default-intensities property Sven Schwermer @ 2022-05-03 11:04 ` Sven Schwermer 0 siblings, 0 replies; 16+ messages in thread From: Sven Schwermer @ 2022-05-03 11:04 UTC (permalink / raw) To: linux-leds, linux-kernel, pavel, robh+dt, krzysztof.kozlowski+dt, dmurphy, devicetree Cc: Sven Schwermer From: Sven Schwermer <sven.schwermer@disruptive-technologies.com> This allows to assign intensity values taken from the firmware interface (if available) to the indivisual sub LEDs (colors) at driver probe time, i.e. most commonly at kernel boot time. This is crucial for setting a specific color and early in the boot process. While it would be possible to set a static color in the bootloader, this mechanism allows setting a pattern (e.g. blinking) at a specific color. Signed-off-by: Sven Schwermer <sven.schwermer@disruptive-technologies.com> --- drivers/leds/led-class-multicolor.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/drivers/leds/led-class-multicolor.c b/drivers/leds/led-class-multicolor.c index e317408583df..eb7f11345ec1 100644 --- a/drivers/leds/led-class-multicolor.c +++ b/drivers/leds/led-class-multicolor.c @@ -9,6 +9,7 @@ #include <linux/module.h> #include <linux/slab.h> #include <linux/uaccess.h> +#include <linux/property.h> #include "leds.h" @@ -116,6 +117,23 @@ static struct attribute *led_multicolor_attrs[] = { }; ATTRIBUTE_GROUPS(led_multicolor); +static void multi_load_default_intensities(struct device *parent, + struct led_classdev_mc *mcled_cdev, + struct fwnode_handle *fwnode) +{ + u32 intensities[LED_COLOR_ID_MAX]; + int ret; + int i; + + ret = fwnode_property_read_u32_array(fwnode, "default-intensities", + intensities, mcled_cdev->num_colors); + if (ret < 0 && ret != -ENODATA) + dev_warn(parent, "failed to read default-intensities property: %d", ret); + + for (i = 0; i < ret; i++) + mcled_cdev->subled_info[i].intensity = intensities[i]; +} + int led_classdev_multicolor_register_ext(struct device *parent, struct led_classdev_mc *mcled_cdev, struct led_init_data *init_data) @@ -134,6 +152,9 @@ int led_classdev_multicolor_register_ext(struct device *parent, led_cdev = &mcled_cdev->led_cdev; mcled_cdev->led_cdev.groups = led_multicolor_groups; + if (init_data && init_data->fwnode) + multi_load_default_intensities(parent, mcled_cdev, init_data->fwnode); + return led_classdev_register_ext(parent, led_cdev, init_data); } EXPORT_SYMBOL_GPL(led_classdev_multicolor_register_ext); -- 2.36.0 ^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v2 1/2] dt-bindings: leds: Add multi-color default-intensities property 2022-05-02 20:46 ` Pavel Machek 2022-05-03 11:04 ` [PATCH v1 1/2] dt-bindings: leds: Add multi-color default-intensities property Sven Schwermer @ 2022-05-03 11:27 ` Sven Schwermer 2022-05-03 11:27 ` [PATCH v2 2/2] leds: multicolor: Read " Sven Schwermer 2022-05-03 13:50 ` AW: [PATCH v2 1/2] dt-bindings: leds: Add multi-color " Sven Schuchmann 2022-05-05 9:50 ` [PATCH v3 " Sven Schwermer 2 siblings, 2 replies; 16+ messages in thread From: Sven Schwermer @ 2022-05-03 11:27 UTC (permalink / raw) To: linux-leds, linux-kernel, pavel, robh+dt, krzysztof.kozlowski+dt, dmurphy, devicetree Cc: Sven Schwermer From: Sven Schwermer <sven.schwermer@disruptive-technologies.com> This allows to assign intensity values to the indivisual 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@disruptive-technologies.com> --- Notes: V1->V2: no changes .../devicetree/bindings/leds/leds-class-multicolor.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Documentation/devicetree/bindings/leds/leds-class-multicolor.yaml b/Documentation/devicetree/bindings/leds/leds-class-multicolor.yaml index 37445c68cdef..c483967a847c 100644 --- a/Documentation/devicetree/bindings/leds/leds-class-multicolor.yaml +++ b/Documentation/devicetree/bindings/leds/leds-class-multicolor.yaml @@ -31,6 +31,13 @@ patternProperties: include/linux/leds/common.h. enum: [ 8, 9 ] + default-intensities: + description: | + This parameter, if present, sets the initial intensities of the + individual colors. This array must have the same length as the + multi-color LED has sub LEDs (colors). + $ref: /schemas/types.yaml#/definitions/uint32-array + $ref: "common.yaml#" required: -- 2.36.0 ^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v2 2/2] leds: multicolor: Read default-intensities property 2022-05-03 11:27 ` [PATCH v2 1/2] dt-bindings: leds: Add multi-color " Sven Schwermer @ 2022-05-03 11:27 ` Sven Schwermer 2022-05-03 13:50 ` AW: [PATCH v2 1/2] dt-bindings: leds: Add multi-color " Sven Schuchmann 1 sibling, 0 replies; 16+ messages in thread From: Sven Schwermer @ 2022-05-03 11:27 UTC (permalink / raw) To: linux-leds, linux-kernel, pavel, robh+dt, krzysztof.kozlowski+dt, dmurphy, devicetree Cc: Sven Schwermer From: Sven Schwermer <sven.schwermer@disruptive-technologies.com> This allows to assign intensity values taken from the firmware interface (if available) to the indivisual sub LEDs (colors) at driver probe time, i.e. most commonly at kernel boot time. This is crucial for setting a specific color and early in the boot process. While it would be possible to set a static color in the bootloader, this mechanism allows setting a pattern (e.g. blinking) at a specific color. Signed-off-by: Sven Schwermer <sven.schwermer@disruptive-technologies.com> --- Notes: V1->V2: Fix mixup drivers/leds/led-class-multicolor.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/leds/led-class-multicolor.c b/drivers/leds/led-class-multicolor.c index e317408583df..84f237784246 100644 --- a/drivers/leds/led-class-multicolor.c +++ b/drivers/leds/led-class-multicolor.c @@ -9,6 +9,7 @@ #include <linux/module.h> #include <linux/slab.h> #include <linux/uaccess.h> +#include <linux/property.h> #include "leds.h" @@ -116,6 +117,26 @@ static struct attribute *led_multicolor_attrs[] = { }; ATTRIBUTE_GROUPS(led_multicolor); +static void multi_load_default_intensities(struct device *parent, + struct led_classdev_mc *mcled_cdev, + struct fwnode_handle *fwnode) +{ + u32 intensities[LED_COLOR_ID_MAX]; + unsigned int i; + int ret; + + ret = fwnode_property_read_u32_array(fwnode, "default-intensities", + intensities, mcled_cdev->num_colors); + if (ret < 0) { + if (ret != -ENODATA) + dev_warn(parent, "failed to read default-intensities property: %d", ret); + return; + } + + for (i = 0; i < mcled_cdev->num_colors; i++) + mcled_cdev->subled_info[i].intensity = intensities[i]; +} + int led_classdev_multicolor_register_ext(struct device *parent, struct led_classdev_mc *mcled_cdev, struct led_init_data *init_data) @@ -134,6 +155,9 @@ int led_classdev_multicolor_register_ext(struct device *parent, led_cdev = &mcled_cdev->led_cdev; mcled_cdev->led_cdev.groups = led_multicolor_groups; + if (init_data && init_data->fwnode) + multi_load_default_intensities(parent, mcled_cdev, init_data->fwnode); + return led_classdev_register_ext(parent, led_cdev, init_data); } EXPORT_SYMBOL_GPL(led_classdev_multicolor_register_ext); -- 2.36.0 ^ permalink raw reply related [flat|nested] 16+ messages in thread
* AW: [PATCH v2 1/2] dt-bindings: leds: Add multi-color default-intensities property 2022-05-03 11:27 ` [PATCH v2 1/2] dt-bindings: leds: Add multi-color " Sven Schwermer 2022-05-03 11:27 ` [PATCH v2 2/2] leds: multicolor: Read " Sven Schwermer @ 2022-05-03 13:50 ` Sven Schuchmann 2022-05-03 18:58 ` Sven Schwermer 1 sibling, 1 reply; 16+ messages in thread From: Sven Schuchmann @ 2022-05-03 13:50 UTC (permalink / raw) To: Sven Schwermer, linux-leds, linux-kernel, pavel, robh+dt, krzysztof.kozlowski+dt, dmurphy, devicetree Cc: Sven Schwermer Hello Sven, tried this some time ago for the LP50XX https://lore.kernel.org/all/20210204143726.27977-1-schuchmann@schleissheimer.de/ Your solution looks much better. Could you give an example of how to use it? My Configuration at this time looks like this: multi-led@0 { #address-cells = <1>; #size-cells = <0>; reg = <0x0>; color = <LED_COLOR_ID_RGB>; function = "eee-led-status"; led-0 { color = <LED_COLOR_ID_RED>; }; led-1 { color = <LED_COLOR_ID_GREEN>; }; led-2 { color = <LED_COLOR_ID_BLUE>; }; }; Where do I put the "default-intensities"? Regards, Sven > -----Ursprüngliche Nachricht----- > Von: Sven Schwermer <sven@svenschwermer.de> > Gesendet: Dienstag, 3. Mai 2022 13:27 > An: linux-leds@vger.kernel.org; linux-kernel@vger.kernel.org; pavel@ucw.cz; > robh+dt@kernel.org; krzysztof.kozlowski+dt@linaro.org; dmurphy@ti.com; > devicetree@vger.kernel.org > Cc: Sven Schwermer <sven.schwermer@disruptive-technologies.com> > Betreff: [PATCH v2 1/2] dt-bindings: leds: Add multi-color default-intensities property > > From: Sven Schwermer <sven.schwermer@disruptive-technologies.com> > > This allows to assign intensity values to the indivisual 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@disruptive-technologies.com> > --- > > Notes: > V1->V2: no changes > > .../devicetree/bindings/leds/leds-class-multicolor.yaml | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/Documentation/devicetree/bindings/leds/leds-class-multicolor.yaml > b/Documentation/devicetree/bindings/leds/leds-class-multicolor.yaml > index 37445c68cdef..c483967a847c 100644 > --- a/Documentation/devicetree/bindings/leds/leds-class-multicolor.yaml > +++ b/Documentation/devicetree/bindings/leds/leds-class-multicolor.yaml > @@ -31,6 +31,13 @@ patternProperties: > include/linux/leds/common.h. > enum: [ 8, 9 ] > > + default-intensities: > + description: | > + This parameter, if present, sets the initial intensities of the > + individual colors. This array must have the same length as the > + multi-color LED has sub LEDs (colors). > + $ref: /schemas/types.yaml#/definitions/uint32-array > + > $ref: "common.yaml#" > > required: > -- > 2.36.0 ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: AW: [PATCH v2 1/2] dt-bindings: leds: Add multi-color default-intensities property 2022-05-03 13:50 ` AW: [PATCH v2 1/2] dt-bindings: leds: Add multi-color " Sven Schuchmann @ 2022-05-03 18:58 ` Sven Schwermer 2022-05-04 7:17 ` AW: " Sven Schuchmann 0 siblings, 1 reply; 16+ messages in thread From: Sven Schwermer @ 2022-05-03 18:58 UTC (permalink / raw) To: Sven Schuchmann, linux-leds; +Cc: Jacek Anaszewski, pavel Hi Sven, Thanks for making me aware of your patch series. My series would work similar to yours, i.e. the default-intensities property would be on the same level as color = <LED_COLOR_ID_RGB>. However, the concern voiced by Jacek is relevant for my patch as well, see https://lore.kernel.org/all/d5631e35-cd62-106f-2ec4-de3163367bc0@gmail.com/ However, I do not know how to resolve the issue. Perhaps somebody from the list has ideas? Best regards, Sven On 5/3/22 15:50, Sven Schuchmann wrote: > Hello Sven, > > tried this some time ago for the LP50XX > https://lore.kernel.org/all/20210204143726.27977-1-schuchmann@schleissheimer.de/ > > Your solution looks much better. > Could you give an example of how to use it? > > My Configuration at this time looks like this: > > multi-led@0 { > #address-cells = <1>; > #size-cells = <0>; > reg = <0x0>; > color = <LED_COLOR_ID_RGB>; > function = "eee-led-status"; > > led-0 { > color = <LED_COLOR_ID_RED>; > }; > > led-1 { > color = <LED_COLOR_ID_GREEN>; > }; > > led-2 { > color = <LED_COLOR_ID_BLUE>; > }; > }; > > > Where do I put the "default-intensities"? > > Regards, > > Sven > >> -----Ursprüngliche Nachricht----- >> Von: Sven Schwermer <sven@svenschwermer.de> >> Gesendet: Dienstag, 3. Mai 2022 13:27 >> An: linux-leds@vger.kernel.org; linux-kernel@vger.kernel.org; pavel@ucw.cz; >> robh+dt@kernel.org; krzysztof.kozlowski+dt@linaro.org; dmurphy@ti.com; >> devicetree@vger.kernel.org >> Cc: Sven Schwermer <sven.schwermer@disruptive-technologies.com> >> Betreff: [PATCH v2 1/2] dt-bindings: leds: Add multi-color default-intensities property >> >> From: Sven Schwermer <sven.schwermer@disruptive-technologies.com> >> >> This allows to assign intensity values to the indivisual 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@disruptive-technologies.com> >> --- >> >> Notes: >> V1->V2: no changes >> >> .../devicetree/bindings/leds/leds-class-multicolor.yaml | 7 +++++++ >> 1 file changed, 7 insertions(+) >> >> diff --git a/Documentation/devicetree/bindings/leds/leds-class-multicolor.yaml >> b/Documentation/devicetree/bindings/leds/leds-class-multicolor.yaml >> index 37445c68cdef..c483967a847c 100644 >> --- a/Documentation/devicetree/bindings/leds/leds-class-multicolor.yaml >> +++ b/Documentation/devicetree/bindings/leds/leds-class-multicolor.yaml >> @@ -31,6 +31,13 @@ patternProperties: >> include/linux/leds/common.h. >> enum: [ 8, 9 ] >> >> + default-intensities: >> + description: | >> + This parameter, if present, sets the initial intensities of the >> + individual colors. This array must have the same length as the >> + multi-color LED has sub LEDs (colors). >> + $ref: /schemas/types.yaml#/definitions/uint32-array >> + >> $ref: "common.yaml#" >> >> required: >> -- >> 2.36.0 > ^ permalink raw reply [flat|nested] 16+ messages in thread
* AW: AW: [PATCH v2 1/2] dt-bindings: leds: Add multi-color default-intensities property 2022-05-03 18:58 ` Sven Schwermer @ 2022-05-04 7:17 ` Sven Schuchmann 2022-05-04 9:24 ` Sven Schwermer 0 siblings, 1 reply; 16+ messages in thread From: Sven Schuchmann @ 2022-05-04 7:17 UTC (permalink / raw) To: Sven Schwermer, linux-leds; +Cc: Jacek Anaszewski, pavel Hello Sven, > -----Ursprüngliche Nachricht----- > Von: Sven Schwermer <sven@svenschwermer.de> > Gesendet: Dienstag, 3. Mai 2022 20:59 > An: Sven Schuchmann <schuchmann@schleissheimer.de>; linux-leds@vger.kernel.org > Cc: Jacek Anaszewski <jacek.anaszewski@gmail.com>; pavel@ucw.cz > Betreff: Re: AW: [PATCH v2 1/2] dt-bindings: leds: Add multi-color default-intensities > property > > Hi Sven, > > Thanks for making me aware of your patch series. My series would work > similar to yours, i.e. the default-intensities property would be on the > same level as color = <LED_COLOR_ID_RGB>. > > However, the concern voiced by Jacek is relevant for my patch as well, > see > https://lore.kernel.org/all/d5631e35-cd62-106f-2ec4-de3163367bc0@gmail.com/ > However, I do not know how to resolve the issue. Perhaps somebody from > the list has ideas? I also do not have an idea. But maybe we can talk about how the definition should look like in DT. As far as I understood with your patch I would have define the LED as follows: multi-led@0 { #address-cells = <1>; #size-cells = <0>; reg = <0x0>; color = <LED_COLOR_ID_RGB>; default-intensities = <100 0 0> <---- function = "eee-led-status"; led-0 { color = <LED_COLOR_ID_RED>; }; led-1 { color = <LED_COLOR_ID_GREEN>; }; led-2 { color = <LED_COLOR_ID_BLUE>; }; }; Maybe it is better to define per Color like this: multi-led@0 { #address-cells = <1>; #size-cells = <0>; reg = <0x0>; color = <LED_COLOR_ID_RGB>; function = "eee-led-status"; led-0 { color = <LED_COLOR_ID_RED>; default-intensity = 100 }; led-1 { color = <LED_COLOR_ID_GREEN>; default-intensity = 0 }; led-2 { color = <LED_COLOR_ID_BLUE>; default-intensity = 0 }; }; I think this could then be handled by RGBW LEDs also. Best Regards, Sven > > Best regards, > Sven > > On 5/3/22 15:50, Sven Schuchmann wrote: > > Hello Sven, > > > > tried this some time ago for the LP50XX > > https://lore.kernel.org/all/20210204143726.27977-1-schuchmann@schleissheimer.de/ > > > > Your solution looks much better. > > Could you give an example of how to use it? > > > > My Configuration at this time looks like this: > > > > multi-led@0 { > > #address-cells = <1>; > > #size-cells = <0>; > > reg = <0x0>; > > color = <LED_COLOR_ID_RGB>; > > function = "eee-led-status"; > > > > led-0 { > > color = <LED_COLOR_ID_RED>; > > }; > > > > led-1 { > > color = <LED_COLOR_ID_GREEN>; > > }; > > > > led-2 { > > color = <LED_COLOR_ID_BLUE>; > > }; > > }; > > > > > > Where do I put the "default-intensities"? > > > > Regards, > > > > Sven > > > >> -----Ursprüngliche Nachricht----- > >> Von: Sven Schwermer <sven@svenschwermer.de> > >> Gesendet: Dienstag, 3. Mai 2022 13:27 > >> An: linux-leds@vger.kernel.org; linux-kernel@vger.kernel.org; pavel@ucw.cz; > >> robh+dt@kernel.org; krzysztof.kozlowski+dt@linaro.org; dmurphy@ti.com; > >> devicetree@vger.kernel.org > >> Cc: Sven Schwermer <sven.schwermer@disruptive-technologies.com> > >> Betreff: [PATCH v2 1/2] dt-bindings: leds: Add multi-color default-intensities property > >> > >> From: Sven Schwermer <sven.schwermer@disruptive-technologies.com> > >> > >> This allows to assign intensity values to the indivisual 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@disruptive-technologies.com> > >> --- > >> > >> Notes: > >> V1->V2: no changes > >> > >> .../devicetree/bindings/leds/leds-class-multicolor.yaml | 7 +++++++ > >> 1 file changed, 7 insertions(+) > >> > >> diff --git a/Documentation/devicetree/bindings/leds/leds-class-multicolor.yaml > >> b/Documentation/devicetree/bindings/leds/leds-class-multicolor.yaml > >> index 37445c68cdef..c483967a847c 100644 > >> --- a/Documentation/devicetree/bindings/leds/leds-class-multicolor.yaml > >> +++ b/Documentation/devicetree/bindings/leds/leds-class-multicolor.yaml > >> @@ -31,6 +31,13 @@ patternProperties: > >> include/linux/leds/common.h. > >> enum: [ 8, 9 ] > >> > >> + default-intensities: > >> + description: | > >> + This parameter, if present, sets the initial intensities of the > >> + individual colors. This array must have the same length as the > >> + multi-color LED has sub LEDs (colors). > >> + $ref: /schemas/types.yaml#/definitions/uint32-array > >> + > >> $ref: "common.yaml#" > >> > >> required: > >> -- > >> 2.36.0 > > ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: AW: AW: [PATCH v2 1/2] dt-bindings: leds: Add multi-color default-intensities property 2022-05-04 7:17 ` AW: " Sven Schuchmann @ 2022-05-04 9:24 ` Sven Schwermer 2022-05-08 19:55 ` Jacek Anaszewski 0 siblings, 1 reply; 16+ messages in thread From: Sven Schwermer @ 2022-05-04 9:24 UTC (permalink / raw) To: Sven Schuchmann, linux-leds; +Cc: Jacek Anaszewski, pavel Hi Sven, I did consider placing the property into the multicolor's sub nodes. However, multicolor LEDs are not required to have firmware sub nodes. At least the multicolor class API does not make any assumptions about this. One possible solution that I came up with is to do something like this: multi-led { color = <LED_COLOR_ID_RGB>; default-intensities = < LED_COLOR_ID_RED 100 LED_COLOR_ID_GREEN 0 LED_COLOR_ID_BLUE 0 >; led-0 { color = <LED_COLOR_ID_RED>; }; led-1 { color = <LED_COLOR_ID_GREEN>; }; led-2 { color = <LED_COLOR_ID_BLUE>; }; }; This requires the array to be twice as long as the number of colors (sub LEDs). Each color identifier would be paired with the initial intensity. This would limit number of LEDs per color to 1. However, I believe, this limitation is already there today. Thoughts? Best regards, Sven On 5/4/22 09:17, Sven Schuchmann wrote: > Hello Sven, > > >> -----Ursprüngliche Nachricht----- >> Von: Sven Schwermer <sven@svenschwermer.de> >> Gesendet: Dienstag, 3. Mai 2022 20:59 >> An: Sven Schuchmann <schuchmann@schleissheimer.de>; linux-leds@vger.kernel.org >> Cc: Jacek Anaszewski <jacek.anaszewski@gmail.com>; pavel@ucw.cz >> Betreff: Re: AW: [PATCH v2 1/2] dt-bindings: leds: Add multi-color default-intensities >> property >> >> Hi Sven, >> >> Thanks for making me aware of your patch series. My series would work >> similar to yours, i.e. the default-intensities property would be on the >> same level as color = <LED_COLOR_ID_RGB>. >> >> However, the concern voiced by Jacek is relevant for my patch as well, >> see >> https://lore.kernel.org/all/d5631e35-cd62-106f-2ec4-de3163367bc0@gmail.com/ >> However, I do not know how to resolve the issue. Perhaps somebody from >> the list has ideas? > > I also do not have an idea. But maybe we can talk about how the definition > should look like in DT. As far as I understood with your patch I would > have define the LED as follows: > > multi-led@0 { > #address-cells = <1>; > #size-cells = <0>; > reg = <0x0>; > color = <LED_COLOR_ID_RGB>; > default-intensities = <100 0 0> <---- > function = "eee-led-status"; > led-0 { > color = <LED_COLOR_ID_RED>; > }; > led-1 { > color = <LED_COLOR_ID_GREEN>; > }; > led-2 { > color = <LED_COLOR_ID_BLUE>; > }; > }; > > > Maybe it is better to define per Color like this: > > multi-led@0 { > #address-cells = <1>; > #size-cells = <0>; > reg = <0x0>; > color = <LED_COLOR_ID_RGB>; > function = "eee-led-status"; > led-0 { > color = <LED_COLOR_ID_RED>; > default-intensity = 100 > }; > led-1 { > color = <LED_COLOR_ID_GREEN>; > default-intensity = 0 > }; > led-2 { > color = <LED_COLOR_ID_BLUE>; > default-intensity = 0 > }; > }; > > > I think this could then be handled by RGBW LEDs also. > > Best Regards, > > Sven > > > >> >> Best regards, >> Sven >> >> On 5/3/22 15:50, Sven Schuchmann wrote: >>> Hello Sven, >>> >>> tried this some time ago for the LP50XX >>> https://lore.kernel.org/all/20210204143726.27977-1-schuchmann@schleissheimer.de/ >>> >>> Your solution looks much better. >>> Could you give an example of how to use it? >>> >>> My Configuration at this time looks like this: >>> >>> multi-led@0 { >>> #address-cells = <1>; >>> #size-cells = <0>; >>> reg = <0x0>; >>> color = <LED_COLOR_ID_RGB>; >>> function = "eee-led-status"; >>> >>> led-0 { >>> color = <LED_COLOR_ID_RED>; >>> }; >>> >>> led-1 { >>> color = <LED_COLOR_ID_GREEN>; >>> }; >>> >>> led-2 { >>> color = <LED_COLOR_ID_BLUE>; >>> }; >>> }; >>> >>> >>> Where do I put the "default-intensities"? >>> >>> Regards, >>> >>> Sven >>> >>>> -----Ursprüngliche Nachricht----- >>>> Von: Sven Schwermer <sven@svenschwermer.de> >>>> Gesendet: Dienstag, 3. Mai 2022 13:27 >>>> An: linux-leds@vger.kernel.org; linux-kernel@vger.kernel.org; pavel@ucw.cz; >>>> robh+dt@kernel.org; krzysztof.kozlowski+dt@linaro.org; dmurphy@ti.com; >>>> devicetree@vger.kernel.org >>>> Cc: Sven Schwermer <sven.schwermer@disruptive-technologies.com> >>>> Betreff: [PATCH v2 1/2] dt-bindings: leds: Add multi-color default-intensities property >>>> >>>> From: Sven Schwermer <sven.schwermer@disruptive-technologies.com> >>>> >>>> This allows to assign intensity values to the indivisual 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@disruptive-technologies.com> >>>> --- >>>> >>>> Notes: >>>> V1->V2: no changes >>>> >>>> .../devicetree/bindings/leds/leds-class-multicolor.yaml | 7 +++++++ >>>> 1 file changed, 7 insertions(+) >>>> >>>> diff --git a/Documentation/devicetree/bindings/leds/leds-class-multicolor.yaml >>>> b/Documentation/devicetree/bindings/leds/leds-class-multicolor.yaml >>>> index 37445c68cdef..c483967a847c 100644 >>>> --- a/Documentation/devicetree/bindings/leds/leds-class-multicolor.yaml >>>> +++ b/Documentation/devicetree/bindings/leds/leds-class-multicolor.yaml >>>> @@ -31,6 +31,13 @@ patternProperties: >>>> include/linux/leds/common.h. >>>> enum: [ 8, 9 ] >>>> >>>> + default-intensities: >>>> + description: | >>>> + This parameter, if present, sets the initial intensities of the >>>> + individual colors. This array must have the same length as the >>>> + multi-color LED has sub LEDs (colors). >>>> + $ref: /schemas/types.yaml#/definitions/uint32-array >>>> + >>>> $ref: "common.yaml#" >>>> >>>> required: >>>> -- >>>> 2.36.0 >>> ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: AW: AW: [PATCH v2 1/2] dt-bindings: leds: Add multi-color default-intensities property 2022-05-04 9:24 ` Sven Schwermer @ 2022-05-08 19:55 ` Jacek Anaszewski 2022-05-10 18:31 ` Sven Schwermer 0 siblings, 1 reply; 16+ messages in thread From: Jacek Anaszewski @ 2022-05-08 19:55 UTC (permalink / raw) To: Sven Schwermer, Sven Schuchmann, linux-leds; +Cc: pavel Hi Sven and Sven, On 5/4/22 11:24, Sven Schwermer wrote: > Hi Sven, > > I did consider placing the property into the multicolor's sub nodes. > However, multicolor LEDs are not required to have firmware sub nodes. At > least the multicolor class API does not make any assumptions about this. So this is something to be clarified. The whole idea relies on having sub-nodes in the multi-led node. > One possible solution that I came up with is to do something like this: > > multi-led { > color = <LED_COLOR_ID_RGB>; > default-intensities = < > LED_COLOR_ID_RED 100 > LED_COLOR_ID_GREEN 0 > LED_COLOR_ID_BLUE 0 > >; > led-0 { > color = <LED_COLOR_ID_RED>; > }; > led-1 { > color = <LED_COLOR_ID_GREEN>; > }; > led-2 { > color = <LED_COLOR_ID_BLUE>; > }; > }; > [...] >> >> >> Maybe it is better to define per Color like this: >> >> multi-led@0 { >> #address-cells = <1>; >> #size-cells = <0>; >> reg = <0x0>; >> color = <LED_COLOR_ID_RGB>; >> function = "eee-led-status"; >> led-0 { >> color = <LED_COLOR_ID_RED>; >> default-intensity = 100 >> }; >> led-1 { >> color = <LED_COLOR_ID_GREEN>; >> default-intensity = 0 >> }; >> led-2 { >> color = <LED_COLOR_ID_BLUE>; >> default-intensity = 0 >> }; >> }; I would go for this. Seems to be the most straightforward solution. -- Best regards, Jacek Anaszewski ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: AW: AW: [PATCH v2 1/2] dt-bindings: leds: Add multi-color default-intensities property 2022-05-08 19:55 ` Jacek Anaszewski @ 2022-05-10 18:31 ` Sven Schwermer 2022-05-10 22:00 ` Jacek Anaszewski 0 siblings, 1 reply; 16+ messages in thread From: Sven Schwermer @ 2022-05-10 18:31 UTC (permalink / raw) To: Jacek Anaszewski, Sven Schuchmann, linux-leds; +Cc: pavel Hi Jacek, On 5/8/22 21:55, Jacek Anaszewski wrote: > Hi Sven and Sven, > > On 5/4/22 11:24, Sven Schwermer wrote: >> Hi Sven, >> >> I did consider placing the property into the multicolor's sub nodes. >> However, multicolor LEDs are not required to have firmware sub nodes. >> At least the multicolor class API does not make any assumptions about >> this. > > So this is something to be clarified. The whole idea relies on having > sub-nodes in the multi-led node. As far as I understand, multi-color LEDs don't require actual OF sub-nodes. The Turris Omnia LED driver doesn't have sub-nodes, see Documentation/devicetree/bindings/leds/cznic,turris-omnia-leds.yaml >>> Maybe it is better to define per Color like this: >>> >>> multi-led@0 { >>> #address-cells = <1>; >>> #size-cells = <0>; >>> reg = <0x0>; >>> color = <LED_COLOR_ID_RGB>; >>> function = "eee-led-status"; >>> led-0 { >>> color = <LED_COLOR_ID_RED>; >>> default-intensity = 100 >>> }; >>> led-1 { >>> color = <LED_COLOR_ID_GREEN>; >>> default-intensity = 0 >>> }; >>> led-2 { >>> color = <LED_COLOR_ID_BLUE>; >>> default-intensity = 0 >>> }; >>> }; > > I would go for this. Seems to be the most straightforward solution. I agree, that this would be the best option. However, as noted above, this wouldn't be compatible with all existing multi-color drivers. Best regards, Sven ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: AW: AW: [PATCH v2 1/2] dt-bindings: leds: Add multi-color default-intensities property 2022-05-10 18:31 ` Sven Schwermer @ 2022-05-10 22:00 ` Jacek Anaszewski 0 siblings, 0 replies; 16+ messages in thread From: Jacek Anaszewski @ 2022-05-10 22:00 UTC (permalink / raw) To: Sven Schwermer, Sven Schuchmann, linux-leds; +Cc: pavel On 5/10/22 20:31, Sven Schwermer wrote: > Hi Jacek, > > On 5/8/22 21:55, Jacek Anaszewski wrote: >> Hi Sven and Sven, >> >> On 5/4/22 11:24, Sven Schwermer wrote: >>> Hi Sven, >>> >>> I did consider placing the property into the multicolor's sub nodes. >>> However, multicolor LEDs are not required to have firmware sub nodes. >>> At least the multicolor class API does not make any assumptions about >>> this. >> >> So this is something to be clarified. The whole idea relies on having >> sub-nodes in the multi-led node. > > As far as I understand, multi-color LEDs don't require actual OF > sub-nodes. The Turris Omnia LED driver doesn't have sub-nodes, see > Documentation/devicetree/bindings/leds/cznic,turris-omnia-leds.yaml Ah, I forgot about that one and the related discussion. In this case, yes, global array will do. -- Best regards, Jacek Anaszewski ^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH v3 1/2] dt-bindings: leds: Add multi-color default-intensities property 2022-05-02 20:46 ` Pavel Machek 2022-05-03 11:04 ` [PATCH v1 1/2] dt-bindings: leds: Add multi-color default-intensities property Sven Schwermer 2022-05-03 11:27 ` [PATCH v2 1/2] dt-bindings: leds: Add multi-color " Sven Schwermer @ 2022-05-05 9:50 ` Sven Schwermer 2022-05-05 9:50 ` [PATCH v3 2/2] leds: multicolor: Read " Sven Schwermer 2022-05-17 0:08 ` [PATCH v3 1/2] dt-bindings: leds: Add multi-color " Rob Herring 2 siblings, 2 replies; 16+ messages in thread From: Sven Schwermer @ 2022-05-05 9:50 UTC (permalink / raw) To: linux-leds, linux-kernel, pavel, robh+dt, krzysztof.kozlowski+dt, devicetree Cc: Sven Schwermer, schuchmann From: Sven Schwermer <sven.schwermer@disruptive-technologies.com> 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@disruptive-technologies.com> --- 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 ^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v3 2/2] leds: multicolor: Read default-intensities property 2022-05-05 9:50 ` [PATCH v3 " Sven Schwermer @ 2022-05-05 9:50 ` Sven Schwermer 2022-05-17 0:08 ` [PATCH v3 1/2] dt-bindings: leds: Add multi-color " Rob Herring 1 sibling, 0 replies; 16+ messages in thread From: Sven Schwermer @ 2022-05-05 9:50 UTC (permalink / raw) To: linux-leds, linux-kernel, pavel, robh+dt, krzysztof.kozlowski+dt, devicetree Cc: Sven Schwermer, schuchmann From: Sven Schwermer <sven.schwermer@disruptive-technologies.com> This allows to assign intensity values taken from the firmware interface (if available) to the indivisual sub LEDs (colors) at driver probe time, i.e. most commonly at kernel boot time. This is crucial for setting a specific color and early in the boot process. While it would be possible to set a static color in the bootloader, this mechanism allows setting a pattern (e.g. blinking) at a specific color. Signed-off-by: Sven Schwermer <sven.schwermer@disruptive-technologies.com> --- Notes: V1->V2: Fix mixup V2->V3: Use color-intensity mapping instead of simple intensity array drivers/leds/led-class-multicolor.c | 48 +++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/drivers/leds/led-class-multicolor.c b/drivers/leds/led-class-multicolor.c index e317408583df..2900dd02fe41 100644 --- a/drivers/leds/led-class-multicolor.c +++ b/drivers/leds/led-class-multicolor.c @@ -9,6 +9,7 @@ #include <linux/module.h> #include <linux/slab.h> #include <linux/uaccess.h> +#include <linux/property.h> #include "leds.h" @@ -116,6 +117,50 @@ static struct attribute *led_multicolor_attrs[] = { }; ATTRIBUTE_GROUPS(led_multicolor); +static void multi_load_default_intensities(struct device *parent, + struct led_classdev_mc *mcled_cdev, + struct fwnode_handle *fwnode) +{ + u32 intensities[2 * LED_COLOR_ID_MAX]; + unsigned int j; + int len; + int ret; + int i; + + len = fwnode_property_read_u32_array(fwnode, "default-intensities", + NULL, 0); + if (len < 0) { + if (len != -ENODATA) + dev_warn(parent, + "failed to read default-intensities property length: %d", ret); + return; + } + if (len % 2 != 0) { + dev_warn(parent, "default-intensities property has uneven number of values"); + return; + } + if (len > ARRAY_SIZE(intensities)) { + dev_warn(parent, "default-intensities property has too many values"); + return; + } + + ret = fwnode_property_read_u32_array(fwnode, "default-intensities", + intensities, len); + if (ret < 0) { + dev_warn(parent, "failed to read default-intensities property values: %d", ret); + return; + } + + for (i = 0; i < len; i += 2) { + for (j = 0; j < mcled_cdev->num_colors; j++) { + if (intensities[i] == mcled_cdev->subled_info[j].color_index) { + mcled_cdev->subled_info[j].intensity = intensities[i + 1]; + break; + } + } + } +} + int led_classdev_multicolor_register_ext(struct device *parent, struct led_classdev_mc *mcled_cdev, struct led_init_data *init_data) @@ -134,6 +179,9 @@ int led_classdev_multicolor_register_ext(struct device *parent, led_cdev = &mcled_cdev->led_cdev; mcled_cdev->led_cdev.groups = led_multicolor_groups; + if (init_data && init_data->fwnode) + multi_load_default_intensities(parent, mcled_cdev, init_data->fwnode); + return led_classdev_register_ext(parent, led_cdev, init_data); } EXPORT_SYMBOL_GPL(led_classdev_multicolor_register_ext); -- 2.36.0 ^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH v3 1/2] dt-bindings: leds: Add multi-color default-intensities property 2022-05-05 9:50 ` [PATCH v3 " Sven Schwermer 2022-05-05 9:50 ` [PATCH v3 2/2] leds: multicolor: Read " Sven Schwermer @ 2022-05-17 0:08 ` Rob Herring 1 sibling, 0 replies; 16+ messages in thread From: Rob Herring @ 2022-05-17 0:08 UTC (permalink / raw) To: Sven Schwermer Cc: pavel, schuchmann, linux-leds, devicetree, robh+dt, linux-kernel, krzysztof.kozlowski+dt, Sven Schwermer On Thu, 05 May 2022 11:50:08 +0200, Sven Schwermer wrote: > From: Sven Schwermer <sven.schwermer@disruptive-technologies.com> > > 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@disruptive-technologies.com> > --- > > 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(+) > Acked-by: Rob Herring <robh@kernel.org> ^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2022-05-17 0:08 UTC | newest] Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2022-05-02 14:09 Initial multicolor LED intensities Sven Schwermer 2022-05-02 20:46 ` Pavel Machek 2022-05-03 11:04 ` [PATCH v1 1/2] dt-bindings: leds: Add multi-color default-intensities property Sven Schwermer 2022-05-03 11:04 ` [PATCH v1 2/2] leds: multicolor: Read " Sven Schwermer 2022-05-03 11:27 ` [PATCH v2 1/2] dt-bindings: leds: Add multi-color " Sven Schwermer 2022-05-03 11:27 ` [PATCH v2 2/2] leds: multicolor: Read " Sven Schwermer 2022-05-03 13:50 ` AW: [PATCH v2 1/2] dt-bindings: leds: Add multi-color " Sven Schuchmann 2022-05-03 18:58 ` Sven Schwermer 2022-05-04 7:17 ` AW: " Sven Schuchmann 2022-05-04 9:24 ` Sven Schwermer 2022-05-08 19:55 ` Jacek Anaszewski 2022-05-10 18:31 ` Sven Schwermer 2022-05-10 22:00 ` Jacek Anaszewski 2022-05-05 9:50 ` [PATCH v3 " Sven Schwermer 2022-05-05 9:50 ` [PATCH v3 2/2] leds: multicolor: Read " Sven Schwermer 2022-05-17 0:08 ` [PATCH v3 1/2] dt-bindings: leds: Add multi-color " Rob Herring
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.