leds: pwm: Add default-brightness property
Subsystems (2)
v2 cover leds: pwm: Add default-brightness property
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/[email protected]/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
PATCH RESEND v2 1/2 dt-bindings: leds: pwm: Add default-brightness property
Optional default-brightness property specifies brightness value to be used if default LED state is on.
--- Documentation/devicetree/bindings/leds/leds-pwm.yaml | 6 ++++++ 1 file changed, 6 insertions(+)
Documentation/devicetree/bindings/leds/leds-pwm.yaml +6 -0
@@ -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
Signature · 1 line
2.25.1
PATCH RESEND v2 2/2 leds: pwm: Add optional DT property default-brightness
In reply to George StarkWhen probing if default LED state is on then default brightness will be applied instead of max brightness.
--- drivers/leds/leds-pwm.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)
drivers/leds/leds-pwm.c +16 -1
@@ -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 : {
Signature · 1 line
2.25.1
Re: (subset) [RESEND PATCH v2 2/2] leds: pwm: Add optional DT property default-brightness
Quoted 4 lines · George Stark
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 [李琼斯]
Lee Jones
maintainerQuoted 17 lines · 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 toleds/common.yamldue 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]
Quoted 7 lines
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.
Signature · 1 line
Lee Jones [李琼斯]
Quoted 11 lines · 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 toleds/common.yamldue 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 [李琼斯]