* [RESEND PATCH v2 0/2] leds: pwm: Add default-brightness property
@ 2024-11-05 18:50 George Stark
2024-11-05 18:50 ` [RESEND PATCH v2 1/2] dt-bindings: " George Stark
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: George Stark @ 2024-11-05 18:50 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
* [RESEND PATCH v2 1/2] dt-bindings: leds: pwm: Add default-brightness property
2024-11-05 18:50 [RESEND PATCH v2 0/2] leds: pwm: Add default-brightness property George Stark
@ 2024-11-05 18:50 ` George Stark
2024-11-05 18:50 ` [RESEND PATCH v2 2/2] leds: pwm: Add optional DT property default-brightness George Stark
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: George Stark @ 2024-11-05 18:50 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>
Acked-by: Rob Herring (Arm) <robh@kernel.org>
---
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
* [RESEND PATCH v2 2/2] leds: pwm: Add optional DT property default-brightness
2024-11-05 18:50 [RESEND PATCH v2 0/2] leds: pwm: Add default-brightness property George Stark
2024-11-05 18:50 ` [RESEND PATCH v2 1/2] dt-bindings: " George Stark
@ 2024-11-05 18:50 ` George Stark
2024-11-12 12:14 ` (subset) " Lee Jones
2024-11-06 10:54 ` [RESEND PATCH v2 0/2] leds: pwm: Add default-brightness property Lee Jones
2024-11-12 12:14 ` Lee Jones
3 siblings, 1 reply; 6+ messages in thread
From: George Stark @ 2024-11-05 18:50 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 e1b414b40353..a591cc399704 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: [RESEND PATCH v2 0/2] leds: pwm: Add default-brightness property
2024-11-05 18:50 [RESEND PATCH v2 0/2] leds: pwm: Add default-brightness property George Stark
2024-11-05 18:50 ` [RESEND PATCH v2 1/2] dt-bindings: " George Stark
2024-11-05 18:50 ` [RESEND PATCH v2 2/2] leds: pwm: Add optional DT property default-brightness George Stark
@ 2024-11-06 10:54 ` Lee Jones
2024-11-12 12:14 ` Lee Jones
3 siblings, 0 replies; 6+ messages in thread
From: Lee Jones @ 2024-11-06 10:54 UTC (permalink / raw)
To: George Stark
Cc: pavel, robh, krzk+dt, conor+dt, linux-leds, devicetree,
linux-kernel, kernel
On Tue, 05 Nov 2024, George Stark wrote:
> 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(-)
The set doesn't apply. Please rebase it.
--
Lee Jones [李琼斯]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: (subset) [RESEND PATCH v2 2/2] leds: pwm: Add optional DT property default-brightness
2024-11-05 18:50 ` [RESEND PATCH v2 2/2] leds: pwm: Add optional DT property default-brightness George Stark
@ 2024-11-12 12:14 ` Lee Jones
0 siblings, 0 replies; 6+ messages in thread
From: Lee Jones @ 2024-11-12 12:14 UTC (permalink / raw)
To: pavel, lee, robh, krzk+dt, conor+dt, George Stark
Cc: linux-leds, devicetree, linux-kernel, kernel
On Tue, 05 Nov 2024 21:50:06 +0300, George Stark wrote:
> When probing if default LED state is on then default brightness will be
> applied instead of max brightness.
>
>
Applied, thanks!
[2/2] leds: pwm: Add optional DT property default-brightness
commit: 8cb08101835d98fd69cfa2a2b06146eddc057df6
--
Lee Jones [李琼斯]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [RESEND PATCH v2 0/2] leds: pwm: Add default-brightness property
2024-11-05 18:50 [RESEND PATCH v2 0/2] leds: pwm: Add default-brightness property George Stark
` (2 preceding siblings ...)
2024-11-06 10:54 ` [RESEND PATCH v2 0/2] leds: pwm: Add default-brightness property Lee Jones
@ 2024-11-12 12:14 ` Lee Jones
3 siblings, 0 replies; 6+ messages in thread
From: Lee Jones @ 2024-11-12 12:14 UTC (permalink / raw)
To: pavel, lee, robh, krzk+dt, conor+dt, George Stark
Cc: linux-leds, devicetree, linux-kernel, kernel
On Tue, 05 Nov 2024 21:50:04 +0300, George Stark wrote:
> 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.
>
> [...]
Applied, thanks!
[1/2] dt-bindings: leds: pwm: Add default-brightness property
commit: 44e04fb8d69fa7fa4ec9a20762834eab1e7945af
[2/2] leds: pwm: Add optional DT property default-brightness
commit: 8cb08101835d98fd69cfa2a2b06146eddc057df6
--
Lee Jones [李琼斯]
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-11-12 12:14 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-05 18:50 [RESEND PATCH v2 0/2] leds: pwm: Add default-brightness property George Stark
2024-11-05 18:50 ` [RESEND PATCH v2 1/2] dt-bindings: " George Stark
2024-11-05 18:50 ` [RESEND PATCH v2 2/2] leds: pwm: Add optional DT property default-brightness George Stark
2024-11-12 12:14 ` (subset) " Lee Jones
2024-11-06 10:54 ` [RESEND PATCH v2 0/2] leds: pwm: Add default-brightness property Lee Jones
2024-11-12 12:14 ` Lee Jones
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).