* [PATCH 1/2] leds: add DT support for LEDs wired to supply and default brightness
@ 2014-02-28 21:25 Russell King
2014-03-27 22:28 ` Bryan Wu
0 siblings, 1 reply; 4+ messages in thread
From: Russell King @ 2014-02-28 21:25 UTC (permalink / raw)
To: linux-arm-kernel, Bryan Wu, Richard Purdie, Thierry Reding
Cc: Shawn Guo, Sascha Hauer, Rob Herring, Pawel Moll, Mark Rutland,
Ian Campbell, Kumar Gala, Rob Landley, devicetree, linux-doc,
linux-leds
Some PWM outputs are wired such that the LED they're controlling is
connected to supply rather than ground. Therefore, the duty cycle
needs to be inverted to make the LED behave as it should do.
We also provide a way to specify the default brightness when a
trigger is not specified.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
---
Documentation/devicetree/bindings/leds/leds-pwm.txt | 3 +++
drivers/leds/leds-pwm.c | 15 +++++++++++----
2 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/Documentation/devicetree/bindings/leds/leds-pwm.txt b/Documentation/devicetree/bindings/leds/leds-pwm.txt
index 7297107cf832..ffcb74ab61fd 100644
--- a/Documentation/devicetree/bindings/leds/leds-pwm.txt
+++ b/Documentation/devicetree/bindings/leds/leds-pwm.txt
@@ -13,6 +13,9 @@ node's name represents the name of the corresponding LED.
For the pwms and pwm-names property please refer to:
Documentation/devicetree/bindings/pwm/pwm.txt
- max-brightness : Maximum brightness possible for the LED
+- default-brightness : (optional) Default brightness for the LED
+- active-low : (optional) For PWMs where the LED is wired to supply
+ rather than ground.
- label : (optional)
see Documentation/devicetree/bindings/leds/common.txt
- linux,default-trigger : (optional)
diff --git a/drivers/leds/leds-pwm.c b/drivers/leds/leds-pwm.c
index 605047428b5a..fe2cd849b593 100644
--- a/drivers/leds/leds-pwm.c
+++ b/drivers/leds/leds-pwm.c
@@ -70,6 +70,10 @@ static void led_pwm_set(struct led_classdev *led_cdev,
duty *= brightness;
do_div(duty, max);
+
+ if (led_dat->active_low)
+ duty = led_dat->period - duty;
+
led_dat->duty = duty;
if (led_dat->can_sleep)
@@ -93,6 +97,10 @@ static int led_pwm_create_of(struct platform_device *pdev,
for_each_child_of_node(pdev->dev.of_node, child) {
struct led_pwm_data *led_dat = &priv->leds[priv->num_leds];
+ led_dat->cdev.brightness_set = led_pwm_set;
+ led_dat->cdev.brightness = LED_OFF;
+ led_dat->cdev.flags |= LED_CORE_SUSPENDRESUME;
+
led_dat->cdev.name = of_get_property(child, "label",
NULL) ? : child->name;
@@ -110,10 +118,9 @@ static int led_pwm_create_of(struct platform_device *pdev,
"linux,default-trigger", NULL);
of_property_read_u32(child, "max-brightness",
&led_dat->cdev.max_brightness);
-
- led_dat->cdev.brightness_set = led_pwm_set;
- led_dat->cdev.brightness = LED_OFF;
- led_dat->cdev.flags |= LED_CORE_SUSPENDRESUME;
+ of_property_read_u32(child, "default-brightness",
+ &led_dat->cdev.brightness);
+ led_dat->active_low = of_property_read_bool(child, "active-low");
led_dat->can_sleep = pwm_can_sleep(led_dat->pwm);
if (led_dat->can_sleep)
--
1.8.3.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] leds: add DT support for LEDs wired to supply and default brightness
2014-02-28 21:25 [PATCH 1/2] leds: add DT support for LEDs wired to supply and default brightness Russell King
@ 2014-03-27 22:28 ` Bryan Wu
2014-03-27 22:57 ` Uwe Kleine-König
0 siblings, 1 reply; 4+ messages in thread
From: Bryan Wu @ 2014-03-27 22:28 UTC (permalink / raw)
To: Russell King
Cc: linux-arm-kernel@lists.infradead.org, Richard Purdie,
Thierry Reding, Shawn Guo, Sascha Hauer, Rob Herring, Pawel Moll,
Mark Rutland, Ian Campbell, Kumar Gala, Rob Landley,
devicetree@vger.kernel.org, linux-doc@vger.kernel.org,
Linux LED Subsystem
On Fri, Feb 28, 2014 at 1:25 PM, Russell King
<rmk+kernel@arm.linux.org.uk> wrote:
> Some PWM outputs are wired such that the LED they're controlling is
> connected to supply rather than ground. Therefore, the duty cycle
> needs to be inverted to make the LED behave as it should do.
>
> We also provide a way to specify the default brightness when a
> trigger is not specified.
>
> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
> ---
> Documentation/devicetree/bindings/leds/leds-pwm.txt | 3 +++
> drivers/leds/leds-pwm.c | 15 +++++++++++----
> 2 files changed, 14 insertions(+), 4 deletions(-)
>
> diff --git a/Documentation/devicetree/bindings/leds/leds-pwm.txt b/Documentation/devicetree/bindings/leds/leds-pwm.txt
> index 7297107cf832..ffcb74ab61fd 100644
> --- a/Documentation/devicetree/bindings/leds/leds-pwm.txt
> +++ b/Documentation/devicetree/bindings/leds/leds-pwm.txt
> @@ -13,6 +13,9 @@ node's name represents the name of the corresponding LED.
> For the pwms and pwm-names property please refer to:
> Documentation/devicetree/bindings/pwm/pwm.txt
> - max-brightness : Maximum brightness possible for the LED
> +- default-brightness : (optional) Default brightness for the LED
> +- active-low : (optional) For PWMs where the LED is wired to supply
> + rather than ground.
> - label : (optional)
> see Documentation/devicetree/bindings/leds/common.txt
> - linux,default-trigger : (optional)
Why remove "max-brightness", "label" and "linux,default-trigger" here?
I believe you're still using them in your second patch like
+ front {
+ active-low;
+ default-brightness = <128>;
+ label = "imx6:red:front";
+ max-brightness = <248>;
+ pwms = <&pwm1 0 50000>;
+ };
Others are good to me.
Thierry, could you please review this patchset?
Thanks,
-Bryan
> diff --git a/drivers/leds/leds-pwm.c b/drivers/leds/leds-pwm.c
> index 605047428b5a..fe2cd849b593 100644
> --- a/drivers/leds/leds-pwm.c
> +++ b/drivers/leds/leds-pwm.c
> @@ -70,6 +70,10 @@ static void led_pwm_set(struct led_classdev *led_cdev,
>
> duty *= brightness;
> do_div(duty, max);
> +
> + if (led_dat->active_low)
> + duty = led_dat->period - duty;
> +
> led_dat->duty = duty;
>
> if (led_dat->can_sleep)
> @@ -93,6 +97,10 @@ static int led_pwm_create_of(struct platform_device *pdev,
> for_each_child_of_node(pdev->dev.of_node, child) {
> struct led_pwm_data *led_dat = &priv->leds[priv->num_leds];
>
> + led_dat->cdev.brightness_set = led_pwm_set;
> + led_dat->cdev.brightness = LED_OFF;
> + led_dat->cdev.flags |= LED_CORE_SUSPENDRESUME;
> +
> led_dat->cdev.name = of_get_property(child, "label",
> NULL) ? : child->name;
>
> @@ -110,10 +118,9 @@ static int led_pwm_create_of(struct platform_device *pdev,
> "linux,default-trigger", NULL);
> of_property_read_u32(child, "max-brightness",
> &led_dat->cdev.max_brightness);
> -
> - led_dat->cdev.brightness_set = led_pwm_set;
> - led_dat->cdev.brightness = LED_OFF;
> - led_dat->cdev.flags |= LED_CORE_SUSPENDRESUME;
> + of_property_read_u32(child, "default-brightness",
> + &led_dat->cdev.brightness);
> + led_dat->active_low = of_property_read_bool(child, "active-low");
>
> led_dat->can_sleep = pwm_can_sleep(led_dat->pwm);
> if (led_dat->can_sleep)
> --
> 1.8.3.1
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] leds: add DT support for LEDs wired to supply and default brightness
2014-03-27 22:28 ` Bryan Wu
@ 2014-03-27 22:57 ` Uwe Kleine-König
2014-03-27 23:36 ` Bryan Wu
0 siblings, 1 reply; 4+ messages in thread
From: Uwe Kleine-König @ 2014-03-27 22:57 UTC (permalink / raw)
To: Bryan Wu
Cc: Russell King, linux-arm-kernel@lists.infradead.org,
Richard Purdie, Thierry Reding, Shawn Guo, Sascha Hauer,
Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala,
Rob Landley, devicetree@vger.kernel.org,
linux-doc@vger.kernel.org, Linux LED Subsystem
On Thu, Mar 27, 2014 at 03:28:32PM -0700, Bryan Wu wrote:
> On Fri, Feb 28, 2014 at 1:25 PM, Russell King
> <rmk+kernel@arm.linux.org.uk> wrote:
> > Some PWM outputs are wired such that the LED they're controlling is
> > connected to supply rather than ground. Therefore, the duty cycle
> > needs to be inverted to make the LED behave as it should do.
> >
> > We also provide a way to specify the default brightness when a
> > trigger is not specified.
> >
> > Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
> > ---
> > Documentation/devicetree/bindings/leds/leds-pwm.txt | 3 +++
> > drivers/leds/leds-pwm.c | 15 +++++++++++----
> > 2 files changed, 14 insertions(+), 4 deletions(-)
> >
> > diff --git a/Documentation/devicetree/bindings/leds/leds-pwm.txt b/Documentation/devicetree/bindings/leds/leds-pwm.txt
> > index 7297107cf832..ffcb74ab61fd 100644
> > --- a/Documentation/devicetree/bindings/leds/leds-pwm.txt
> > +++ b/Documentation/devicetree/bindings/leds/leds-pwm.txt
> > @@ -13,6 +13,9 @@ node's name represents the name of the corresponding LED.
> > For the pwms and pwm-names property please refer to:
> > Documentation/devicetree/bindings/pwm/pwm.txt
> > - max-brightness : Maximum brightness possible for the LED
> > +- default-brightness : (optional) Default brightness for the LED
> > +- active-low : (optional) For PWMs where the LED is wired to supply
> > + rather than ground.
> > - label : (optional)
> > see Documentation/devicetree/bindings/leds/common.txt
> > - linux,default-trigger : (optional)
>
> Why remove "max-brightness", "label" and "linux,default-trigger" here?
They are not removed, they are just unchanged list items after literal
'-'s in the context of the patch.
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | http://www.pengutronix.de/ |
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] leds: add DT support for LEDs wired to supply and default brightness
2014-03-27 22:57 ` Uwe Kleine-König
@ 2014-03-27 23:36 ` Bryan Wu
0 siblings, 0 replies; 4+ messages in thread
From: Bryan Wu @ 2014-03-27 23:36 UTC (permalink / raw)
To: Uwe Kleine-König
Cc: Russell King, linux-arm-kernel@lists.infradead.org,
Richard Purdie, Thierry Reding, Shawn Guo, Sascha Hauer,
Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala,
Rob Landley, devicetree@vger.kernel.org,
linux-doc@vger.kernel.org, Linux LED Subsystem
On Thu, Mar 27, 2014 at 3:57 PM, Uwe Kleine-König
<u.kleine-koenig@pengutronix.de> wrote:
> On Thu, Mar 27, 2014 at 03:28:32PM -0700, Bryan Wu wrote:
>> On Fri, Feb 28, 2014 at 1:25 PM, Russell King
>> <rmk+kernel@arm.linux.org.uk> wrote:
>> > Some PWM outputs are wired such that the LED they're controlling is
>> > connected to supply rather than ground. Therefore, the duty cycle
>> > needs to be inverted to make the LED behave as it should do.
>> >
>> > We also provide a way to specify the default brightness when a
>> > trigger is not specified.
>> >
>> > Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
>> > ---
>> > Documentation/devicetree/bindings/leds/leds-pwm.txt | 3 +++
>> > drivers/leds/leds-pwm.c | 15 +++++++++++----
>> > 2 files changed, 14 insertions(+), 4 deletions(-)
>> >
>> > diff --git a/Documentation/devicetree/bindings/leds/leds-pwm.txt b/Documentation/devicetree/bindings/leds/leds-pwm.txt
>> > index 7297107cf832..ffcb74ab61fd 100644
>> > --- a/Documentation/devicetree/bindings/leds/leds-pwm.txt
>> > +++ b/Documentation/devicetree/bindings/leds/leds-pwm.txt
>> > @@ -13,6 +13,9 @@ node's name represents the name of the corresponding LED.
>> > For the pwms and pwm-names property please refer to:
>> > Documentation/devicetree/bindings/pwm/pwm.txt
>> > - max-brightness : Maximum brightness possible for the LED
>> > +- default-brightness : (optional) Default brightness for the LED
>> > +- active-low : (optional) For PWMs where the LED is wired to supply
>> > + rather than ground.
>> > - label : (optional)
>> > see Documentation/devicetree/bindings/leds/common.txt
>> > - linux,default-trigger : (optional)
>>
>> Why remove "max-brightness", "label" and "linux,default-trigger" here?
> They are not removed, they are just unchanged list items after literal
> '-'s in the context of the patch.
>
Sorry, my bad. please ignore my question then.
Thanks,
-Bryan
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-03-27 23:36 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-28 21:25 [PATCH 1/2] leds: add DT support for LEDs wired to supply and default brightness Russell King
2014-03-27 22:28 ` Bryan Wu
2014-03-27 22:57 ` Uwe Kleine-König
2014-03-27 23:36 ` Bryan Wu
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).