Message ID | 20230630092248.4146169-2-astrid.rost@axis.com |
---|---|
State | Superseded |
Headers | show |
Series | [v2,1/2] led: led-class: Read max-brightness from devicetree | expand |
On Fri, Jun 30, 2023 at 11:22:46AM +0200, Astrid Rost wrote: > Add max-brightness in order to reduce the current on the connected LEDs. > Normally, the maximum brightness is determined by the hardware, and this > property is not required. This property is used to set a software limit. > It could happen that an LED is made so bright that it gets damaged or > causes damage due to restrictions in a specific system, such as mounting > conditions. Note that led-max-microamp should be preferably used, if it > is supported by the controller. LGTM, Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Maybe you can also add to the cover letter that there are already users in the kernel that may be simplified after this change lands the upstream. > Signed-off-by: Astrid Rost <astrid.rost@axis.com> > --- > drivers/leds/led-class.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c > index 9255bc11f99d..ce652abf9336 100644 > --- a/drivers/leds/led-class.c > +++ b/drivers/leds/led-class.c > @@ -457,6 +457,10 @@ int led_classdev_register_ext(struct device *parent, > if (fwnode_property_present(init_data->fwnode, > "retain-state-shutdown")) > led_cdev->flags |= LED_RETAIN_AT_SHUTDOWN; > + > + fwnode_property_read_u32(init_data->fwnode, > + "max-brightness", > + &led_cdev->max_brightness); > } > } else { > proposed_name = led_cdev->name; > -- > 2.30.2 >
Hi Astrid, On 6/30/23 11:22, Astrid Rost wrote: > Add max-brightness in order to reduce the current on the connected LEDs. > Normally, the maximum brightness is determined by the hardware, and this > property is not required. This property is used to set a software limit. > It could happen that an LED is made so bright that it gets damaged or > causes damage due to restrictions in a specific system, such as mounting > conditions. Note that led-max-microamp should be preferably used, if it > is supported by the controller. > > Signed-off-by: Astrid Rost <astrid.rost@axis.com> > --- > drivers/leds/led-class.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c > index 9255bc11f99d..ce652abf9336 100644 > --- a/drivers/leds/led-class.c > +++ b/drivers/leds/led-class.c > @@ -457,6 +457,10 @@ int led_classdev_register_ext(struct device *parent, > if (fwnode_property_present(init_data->fwnode, > "retain-state-shutdown")) > led_cdev->flags |= LED_RETAIN_AT_SHUTDOWN; > + > + fwnode_property_read_u32(init_data->fwnode, > + "max-brightness", > + &led_cdev->max_brightness); > } > } else { > proposed_name = led_cdev->name; We have led-max-microamp for that and every LED class driver is supposed to calculate its max brightness level basing on it.
Hello Jacek, I am having problems with the PWM controller LP5024. https://www.ti.com/product/LP5024 There is no such a calculation in the data-sheet like: max_brightness = max_current / constant. I also assume it is depending on the type of LEDs and circuit, which are connected. It supports two current modes: 25,5 mA and and 35 mA, both is to high for the LEDs I have. For max_brightness seems to be everything inside the kernel, but reading the value from devicetree. I first thought I could add it in the lp50xx driver, but Andy and Rob thought that I better put it into the general parts. And of course drivers having led-max-microamp should better use it. Please, let me know if you have a better suggestion. Astrid On 7/1/23 13:09, Jacek Anaszewski wrote: > Hi Astrid, > > On 6/30/23 11:22, Astrid Rost wrote: >> Add max-brightness in order to reduce the current on the connected LEDs. >> Normally, the maximum brightness is determined by the hardware, and this >> property is not required. This property is used to set a software limit. >> It could happen that an LED is made so bright that it gets damaged or >> causes damage due to restrictions in a specific system, such as mounting >> conditions. Note that led-max-microamp should be preferably used, if it >> is supported by the controller. >> >> Signed-off-by: Astrid Rost <astrid.rost@axis.com> >> --- >> drivers/leds/led-class.c | 4 ++++ >> 1 file changed, 4 insertions(+) >> >> diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c >> index 9255bc11f99d..ce652abf9336 100644 >> --- a/drivers/leds/led-class.c >> +++ b/drivers/leds/led-class.c >> @@ -457,6 +457,10 @@ int led_classdev_register_ext(struct device *parent, >> if (fwnode_property_present(init_data->fwnode, >> "retain-state-shutdown")) >> led_cdev->flags |= LED_RETAIN_AT_SHUTDOWN; >> + >> + fwnode_property_read_u32(init_data->fwnode, >> + "max-brightness", >> + &led_cdev->max_brightness); >> } >> } else { >> proposed_name = led_cdev->name; > > We have led-max-microamp for that and every LED class driver is supposed > to calculate its max brightness level basing on it. >
Hi Astrid, On 7/3/23 09:53, Astrid Rost wrote: > Hello Jacek, > > I am having problems with the PWM controller LP5024. > > https://www.ti.com/product/LP5024 > > There is no such a calculation in the data-sheet like: > max_brightness = max_current / constant. > > I also assume it is depending on the type of LEDs and circuit, which are > connected. > > It supports two current modes: 25,5 mA and and 35 mA, both is to high > for the LEDs I have. > > For max_brightness seems to be everything inside the kernel, but reading > the value from devicetree. I first thought I could add it in the lp50xx > driver, but Andy and Rob thought that I better put it into the general > parts. And of course drivers having led-max-microamp should better use it. > > Please, let me know if you have a better suggestion. OK, since this LED controller is PWM-driven then there is no current per brightness level granulation. Bindings of leds-pwm driver also use max-brightness DT property. So, yeah, let's make it a common property, but state clearly that it is mainly for drivers like PWM ones, where it is not possible to map brightness level to the amount of current.
diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c index 9255bc11f99d..ce652abf9336 100644 --- a/drivers/leds/led-class.c +++ b/drivers/leds/led-class.c @@ -457,6 +457,10 @@ int led_classdev_register_ext(struct device *parent, if (fwnode_property_present(init_data->fwnode, "retain-state-shutdown")) led_cdev->flags |= LED_RETAIN_AT_SHUTDOWN; + + fwnode_property_read_u32(init_data->fwnode, + "max-brightness", + &led_cdev->max_brightness); } } else { proposed_name = led_cdev->name;
Add max-brightness in order to reduce the current on the connected LEDs. Normally, the maximum brightness is determined by the hardware, and this property is not required. This property is used to set a software limit. It could happen that an LED is made so bright that it gets damaged or causes damage due to restrictions in a specific system, such as mounting conditions. Note that led-max-microamp should be preferably used, if it is supported by the controller. Signed-off-by: Astrid Rost <astrid.rost@axis.com> --- drivers/leds/led-class.c | 4 ++++ 1 file changed, 4 insertions(+)