devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] leds: pwm: Add default-brightness property
@ 2024-11-01 15:48 George Stark
  2024-11-01 15:48 ` [PATCH v2 1/2] dt-bindings: " George Stark
  2024-11-01 15:48 ` [PATCH v2 2/2] leds: pwm: Add optional DT property default-brightness George Stark
  0 siblings, 2 replies; 6+ messages in thread
From: George Stark @ 2024-11-01 15:48 UTC (permalink / raw)
  To: pavel, lee, robh, krzk+dt, conor+dt
  Cc: linux-leds, devicetree, linux-kernel, kernel, George Stark

led-pwm driver supports default-state DT property and if that state is on then
the driver during initialization turns on the LED setting maximum brightness.
Sometimes it's desirable to use lower initial brightness.
This patch series adds support for DT property default-brightness.

Things to discuss:
If such a property is acceptable it could be moved to leds/common.yaml due to
several drivers support multiple brightness levels and could support the property
too.

Changes in v2:
  leds: pwm: Add optional DT property default-brightness
    - refactor patch to make it more accurate
  link to v1: [1]

[1] https://lore.kernel.org/lkml/20241015151410.2158102-3-gnstark@salutedevices.com/T/

George Stark (2):
  dt-bindings: leds: pwm: Add default-brightness property
  leds: pwm: Add optional DT property default-brightness

 .../devicetree/bindings/leds/leds-pwm.yaml      |  6 ++++++
 drivers/leds/leds-pwm.c                         | 17 ++++++++++++++++-
 2 files changed, 22 insertions(+), 1 deletion(-)

--
2.25.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2 1/2] dt-bindings: leds: pwm: Add default-brightness property
  2024-11-01 15:48 [PATCH v2 0/2] leds: pwm: Add default-brightness property George Stark
@ 2024-11-01 15:48 ` George Stark
  2024-11-02 13:06   ` Krzysztof Kozlowski
  2024-11-01 15:48 ` [PATCH v2 2/2] leds: pwm: Add optional DT property default-brightness George Stark
  1 sibling, 1 reply; 6+ messages in thread
From: George Stark @ 2024-11-01 15:48 UTC (permalink / raw)
  To: pavel, lee, robh, krzk+dt, conor+dt
  Cc: linux-leds, devicetree, linux-kernel, kernel, George Stark

Optional default-brightness property specifies brightness value to be
used if default LED state is on.

Signed-off-by: George Stark <gnstark@salutedevices.com>
---
 Documentation/devicetree/bindings/leds/leds-pwm.yaml | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/Documentation/devicetree/bindings/leds/leds-pwm.yaml b/Documentation/devicetree/bindings/leds/leds-pwm.yaml
index 113b7c218303..61b97e8bc36d 100644
--- a/Documentation/devicetree/bindings/leds/leds-pwm.yaml
+++ b/Documentation/devicetree/bindings/leds/leds-pwm.yaml
@@ -34,6 +34,12 @@ patternProperties:
           Maximum brightness possible for the LED
         $ref: /schemas/types.yaml#/definitions/uint32
 
+      default-brightness:
+        description:
+          Brightness to be set if LED's default state is on. Used only during
+          initialization. If the option is not set then max brightness is used.
+        $ref: /schemas/types.yaml#/definitions/uint32
+
     required:
       - pwms
       - max-brightness
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 2/2] leds: pwm: Add optional DT property default-brightness
  2024-11-01 15:48 [PATCH v2 0/2] leds: pwm: Add default-brightness property George Stark
  2024-11-01 15:48 ` [PATCH v2 1/2] dt-bindings: " George Stark
@ 2024-11-01 15:48 ` George Stark
  1 sibling, 0 replies; 6+ messages in thread
From: George Stark @ 2024-11-01 15:48 UTC (permalink / raw)
  To: pavel, lee, robh, krzk+dt, conor+dt
  Cc: linux-leds, devicetree, linux-kernel, kernel, George Stark

When probing if default LED state is on then default brightness will be
applied instead of max brightness.

Signed-off-by: George Stark <gnstark@salutedevices.com>
---
 drivers/leds/leds-pwm.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/drivers/leds/leds-pwm.c b/drivers/leds/leds-pwm.c
index 7961dca0db2f..7636ee178c39 100644
--- a/drivers/leds/leds-pwm.c
+++ b/drivers/leds/leds-pwm.c
@@ -63,6 +63,20 @@ static int led_pwm_set(struct led_classdev *led_cdev,
 	return pwm_apply_might_sleep(led_dat->pwm, &led_dat->pwmstate);
 }
 
+static int led_pwm_default_brightness_get(struct fwnode_handle *fwnode,
+					  int max_brightness)
+{
+	unsigned int default_brightness;
+	int ret;
+
+	ret = fwnode_property_read_u32(fwnode, "default-brightness",
+				       &default_brightness);
+	if (ret < 0 || default_brightness > max_brightness)
+		default_brightness = max_brightness;
+
+	return default_brightness;
+}
+
 __attribute__((nonnull))
 static int led_pwm_add(struct device *dev, struct led_pwm_priv *priv,
 		       struct led_pwm *led, struct fwnode_handle *fwnode)
@@ -104,7 +118,8 @@ static int led_pwm_add(struct device *dev, struct led_pwm_priv *priv,
 	/* set brightness */
 	switch (led->default_state) {
 	case LEDS_DEFSTATE_ON:
-		led_data->cdev.brightness = led->max_brightness;
+		led_data->cdev.brightness =
+			led_pwm_default_brightness_get(fwnode, led->max_brightness);
 		break;
 	case LEDS_DEFSTATE_KEEP:
 		{
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 1/2] dt-bindings: leds: pwm: Add default-brightness property
  2024-11-01 15:48 ` [PATCH v2 1/2] dt-bindings: " George Stark
@ 2024-11-02 13:06   ` Krzysztof Kozlowski
  2024-11-02 23:15     ` George Stark
  0 siblings, 1 reply; 6+ messages in thread
From: Krzysztof Kozlowski @ 2024-11-02 13:06 UTC (permalink / raw)
  To: George Stark
  Cc: pavel, lee, robh, krzk+dt, conor+dt, linux-leds, devicetree,
	linux-kernel, kernel

On Fri, Nov 01, 2024 at 06:48:43PM +0300, George Stark wrote:
> Optional default-brightness property specifies brightness value to be
> used if default LED state is on.
> 
> Signed-off-by: George Stark <gnstark@salutedevices.com>
> ---
>  Documentation/devicetree/bindings/leds/leds-pwm.yaml | 6 ++++++
>  1 file changed, 6 insertions(+)
>

<form letter>
This is a friendly reminder during the review process.

It looks like you received a tag and forgot to add it.

If you do not know the process, here is a short explanation: Please add
Acked-by/Reviewed-by/Tested-by tags when posting new versions, under
or above your Signed-off-by tag. Tag is "received", when provided
in a message replied to you on the mailing list. Tools like b4 can help
here. However, there's no need to repost patches *only* to add the tags.
The upstream maintainer will do that for tags received on the version
they apply.

https://elixir.bootlin.com/linux/v6.5-rc3/source/Documentation/process/submitting-patches.rst#L577

If a tag was not added on purpose, please state why and what changed.
</form letter>

Best regards,
Krzysztof


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 1/2] dt-bindings: leds: pwm: Add default-brightness property
  2024-11-02 13:06   ` Krzysztof Kozlowski
@ 2024-11-02 23:15     ` George Stark
  2024-11-05 15:57       ` Lee Jones
  0 siblings, 1 reply; 6+ messages in thread
From: George Stark @ 2024-11-02 23:15 UTC (permalink / raw)
  To: Krzysztof Kozlowski, robh
  Cc: pavel, lee, krzk+dt, conor+dt, linux-leds, devicetree,
	linux-kernel, kernel

Hello Krzysztof, Rob

Thanks for noticing it, missed the tag not by purpose, sorry about it.
Sure I'll add the tag to v3 if v3 happens.

On 11/2/24 16:06, Krzysztof Kozlowski wrote:
> On Fri, Nov 01, 2024 at 06:48:43PM +0300, George Stark wrote:
>> Optional default-brightness property specifies brightness value to be
>> used if default LED state is on.
>>
>> Signed-off-by: George Stark <gnstark@salutedevices.com>
>> ---
>>   Documentation/devicetree/bindings/leds/leds-pwm.yaml | 6 ++++++
>>   1 file changed, 6 insertions(+)
>>
> 
> <form letter>
> This is a friendly reminder during the review process.
> 
> It looks like you received a tag and forgot to add it.
> 
> If you do not know the process, here is a short explanation: Please add
> Acked-by/Reviewed-by/Tested-by tags when posting new versions, under
> or above your Signed-off-by tag. Tag is "received", when provided
> in a message replied to you on the mailing list. Tools like b4 can help
> here. However, there's no need to repost patches *only* to add the tags.
> The upstream maintainer will do that for tags received on the version
> they apply.
> 
> https://elixir.bootlin.com/linux/v6.5-rc3/source/Documentation/process/submitting-patches.rst#L577
> 
> If a tag was not added on purpose, please state why and what changed.
> </form letter>
> 
> Best regards,
> Krzysztof
> 

-- 
Best regards
George

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 1/2] dt-bindings: leds: pwm: Add default-brightness property
  2024-11-02 23:15     ` George Stark
@ 2024-11-05 15:57       ` Lee Jones
  0 siblings, 0 replies; 6+ messages in thread
From: Lee Jones @ 2024-11-05 15:57 UTC (permalink / raw)
  To: George Stark
  Cc: Krzysztof Kozlowski, robh, pavel, krzk+dt, conor+dt, linux-leds,
	devicetree, linux-kernel, kernel

On Sun, 03 Nov 2024, George Stark wrote:

> Hello Krzysztof, Rob
> 
> Thanks for noticing it, missed the tag not by purpose, sorry about it.
> Sure I'll add the tag to v3 if v3 happens.

Please reply directly under the text you're referring to.  Top-posting
is not allowed.

Please submit a v2 [RESEND] complete with the missing tags.

> On 11/2/24 16:06, Krzysztof Kozlowski wrote:
> > On Fri, Nov 01, 2024 at 06:48:43PM +0300, George Stark wrote:
> > > Optional default-brightness property specifies brightness value to be
> > > used if default LED state is on.
> > > 
> > > Signed-off-by: George Stark <gnstark@salutedevices.com>
> > > ---
> > >   Documentation/devicetree/bindings/leds/leds-pwm.yaml | 6 ++++++
> > >   1 file changed, 6 insertions(+)
> > > 
> > 
> > <form letter>
> > This is a friendly reminder during the review process.
> > 
> > It looks like you received a tag and forgot to add it.
> > 
> > If you do not know the process, here is a short explanation: Please add
> > Acked-by/Reviewed-by/Tested-by tags when posting new versions, under
> > or above your Signed-off-by tag. Tag is "received", when provided
> > in a message replied to you on the mailing list. Tools like b4 can help
> > here. However, there's no need to repost patches *only* to add the tags.
> > The upstream maintainer will do that for tags received on the version
> > they apply.
> > 
> > https://elixir.bootlin.com/linux/v6.5-rc3/source/Documentation/process/submitting-patches.rst#L577
> > 
> > If a tag was not added on purpose, please state why and what changed.
> > </form letter>
> > 
> > Best regards,
> > Krzysztof
> > 
> 
> -- 
> Best regards
> George

-- 
Lee Jones [李琼斯]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-11-05 15:57 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-01 15:48 [PATCH v2 0/2] leds: pwm: Add default-brightness property George Stark
2024-11-01 15:48 ` [PATCH v2 1/2] dt-bindings: " George Stark
2024-11-02 13:06   ` Krzysztof Kozlowski
2024-11-02 23:15     ` George Stark
2024-11-05 15:57       ` Lee Jones
2024-11-01 15:48 ` [PATCH v2 2/2] leds: pwm: Add optional DT property default-brightness George Stark

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).