linux-leds.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] leds: pwm: set polarity on non DT platforms
@ 2014-03-17 18:38 Alexandre Belloni
  2014-03-18 23:02 ` Bryan Wu
  0 siblings, 1 reply; 4+ messages in thread
From: Alexandre Belloni @ 2014-03-17 18:38 UTC (permalink / raw)
  To: Bryan Wu; +Cc: Richard Purdie, linux-leds, linux-kernel, Alexandre Belloni

Set inversed polarity when .active_low is set in the platform_data. With device
tree, this is taken care of by of_pwm_xlate_with_flags(), called from
of_pwm_get().

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 drivers/leds/leds-pwm.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/leds/leds-pwm.c b/drivers/leds/leds-pwm.c
index 605047428b5a..09681556a6aa 100644
--- a/drivers/leds/leds-pwm.c
+++ b/drivers/leds/leds-pwm.c
@@ -180,6 +180,11 @@ static int led_pwm_probe(struct platform_device *pdev)
 			led_dat->cdev.max_brightness = cur_led->max_brightness;
 			led_dat->cdev.flags |= LED_CORE_SUSPENDRESUME;
 
+			if (led_dat->active_low)
+				if (pwm_set_polarity(led_dat->pwm,
+						 PWM_POLARITY_INVERSED))
+					dev_err(&pdev->dev, "impossible to change polarity");
+
 			led_dat->can_sleep = pwm_can_sleep(led_dat->pwm);
 			if (led_dat->can_sleep)
 				INIT_WORK(&led_dat->work, led_pwm_work);
-- 
1.8.3.2

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

* Re: [PATCH] leds: pwm: set polarity on non DT platforms
  2014-03-17 18:38 [PATCH] leds: pwm: set polarity on non DT platforms Alexandre Belloni
@ 2014-03-18 23:02 ` Bryan Wu
  2014-03-18 23:09   ` Alexandre Belloni
  0 siblings, 1 reply; 4+ messages in thread
From: Bryan Wu @ 2014-03-18 23:02 UTC (permalink / raw)
  To: Alexandre Belloni, Thierry Reding
  Cc: Richard Purdie, Linux LED Subsystem, lkml

On Mon, Mar 17, 2014 at 11:38 AM, Alexandre Belloni
<alexandre.belloni@free-electrons.com> wrote:
> Set inversed polarity when .active_low is set in the platform_data. With device
> tree, this is taken care of by of_pwm_xlate_with_flags(), called from
> of_pwm_get().
>
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> ---
>  drivers/leds/leds-pwm.c | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/drivers/leds/leds-pwm.c b/drivers/leds/leds-pwm.c
> index 605047428b5a..09681556a6aa 100644
> --- a/drivers/leds/leds-pwm.c
> +++ b/drivers/leds/leds-pwm.c
> @@ -180,6 +180,11 @@ static int led_pwm_probe(struct platform_device *pdev)
>                         led_dat->cdev.max_brightness = cur_led->max_brightness;
>                         led_dat->cdev.flags |= LED_CORE_SUSPENDRESUME;
>
> +                       if (led_dat->active_low)

Why .active_low needs to inverse PWM polarity? In
of_pwm_xlate_with_flags(), it checked with PWM_POLARITY_INVERSED in
args. Moreover in of_pwm_simple_xlate() and pxa_pwm_of_xlate(), we
didn't inverse PWM polarity at all.

Add Thierry to review this.

Thanks,
-Bryan

> +                               if (pwm_set_polarity(led_dat->pwm,
> +                                                PWM_POLARITY_INVERSED))
> +                                       dev_err(&pdev->dev, "impossible to change polarity");
> +
>                         led_dat->can_sleep = pwm_can_sleep(led_dat->pwm);
>                         if (led_dat->can_sleep)
>                                 INIT_WORK(&led_dat->work, led_pwm_work);
> --
> 1.8.3.2
>

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

* Re: [PATCH] leds: pwm: set polarity on non DT platforms
  2014-03-18 23:02 ` Bryan Wu
@ 2014-03-18 23:09   ` Alexandre Belloni
  2014-04-07 11:33     ` Thierry Reding
  0 siblings, 1 reply; 4+ messages in thread
From: Alexandre Belloni @ 2014-03-18 23:09 UTC (permalink / raw)
  To: Bryan Wu; +Cc: Thierry Reding, Richard Purdie, Linux LED Subsystem, lkml

On 18/03/2014 at 16:02:51 -0700, Bryan Wu wrote :
> On Mon, Mar 17, 2014 at 11:38 AM, Alexandre Belloni
> <alexandre.belloni@free-electrons.com> wrote:
> > Set inversed polarity when .active_low is set in the platform_data. With device
> > tree, this is taken care of by of_pwm_xlate_with_flags(), called from
> > of_pwm_get().
> >
> > Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> > ---
> >  drivers/leds/leds-pwm.c | 5 +++++
> >  1 file changed, 5 insertions(+)
> >
> > diff --git a/drivers/leds/leds-pwm.c b/drivers/leds/leds-pwm.c
> > index 605047428b5a..09681556a6aa 100644
> > --- a/drivers/leds/leds-pwm.c
> > +++ b/drivers/leds/leds-pwm.c
> > @@ -180,6 +180,11 @@ static int led_pwm_probe(struct platform_device *pdev)
> >                         led_dat->cdev.max_brightness = cur_led->max_brightness;
> >                         led_dat->cdev.flags |= LED_CORE_SUSPENDRESUME;
> >
> > +                       if (led_dat->active_low)
> 
> Why .active_low needs to inverse PWM polarity? In
> of_pwm_xlate_with_flags(), it checked with PWM_POLARITY_INVERSED in
> args. Moreover in of_pwm_simple_xlate() and pxa_pwm_of_xlate(), we
> didn't inverse PWM polarity at all.
> 

Yeah, exactly, there is no issue when using device tree. What I'm trying
to fix here is th non-DT case where of_pwm_xlate_with_flags() is not
called.

> Add Thierry to review this.
> 

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

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

* Re: [PATCH] leds: pwm: set polarity on non DT platforms
  2014-03-18 23:09   ` Alexandre Belloni
@ 2014-04-07 11:33     ` Thierry Reding
  0 siblings, 0 replies; 4+ messages in thread
From: Thierry Reding @ 2014-04-07 11:33 UTC (permalink / raw)
  To: Alexandre Belloni; +Cc: Bryan Wu, Richard Purdie, Linux LED Subsystem, lkml

[-- Attachment #1: Type: text/plain, Size: 1842 bytes --]

On Wed, Mar 19, 2014 at 12:09:46AM +0100, Alexandre Belloni wrote:
> On 18/03/2014 at 16:02:51 -0700, Bryan Wu wrote :
> > On Mon, Mar 17, 2014 at 11:38 AM, Alexandre Belloni
> > <alexandre.belloni@free-electrons.com> wrote:
> > > Set inversed polarity when .active_low is set in the platform_data. With device
> > > tree, this is taken care of by of_pwm_xlate_with_flags(), called from
> > > of_pwm_get().
> > >
> > > Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> > > ---
> > >  drivers/leds/leds-pwm.c | 5 +++++
> > >  1 file changed, 5 insertions(+)
> > >
> > > diff --git a/drivers/leds/leds-pwm.c b/drivers/leds/leds-pwm.c
> > > index 605047428b5a..09681556a6aa 100644
> > > --- a/drivers/leds/leds-pwm.c
> > > +++ b/drivers/leds/leds-pwm.c
> > > @@ -180,6 +180,11 @@ static int led_pwm_probe(struct platform_device *pdev)
> > >                         led_dat->cdev.max_brightness = cur_led->max_brightness;
> > >                         led_dat->cdev.flags |= LED_CORE_SUSPENDRESUME;
> > >
> > > +                       if (led_dat->active_low)
> > 
> > Why .active_low needs to inverse PWM polarity? In
> > of_pwm_xlate_with_flags(), it checked with PWM_POLARITY_INVERSED in
> > args. Moreover in of_pwm_simple_xlate() and pxa_pwm_of_xlate(), we
> > didn't inverse PWM polarity at all.
> > 
> 
> Yeah, exactly, there is no issue when using device tree. What I'm trying
> to fix here is th non-DT case where of_pwm_xlate_with_flags() is not
> called.

The goal here would be to move to a common interface, irrespective of
whether DT or platform code was used to instantiate a device. So like I
mentioned in a reply to another patch of yours, I think a better
approach would be to provide a mechanism to specify the PWMs polarity
within the PWM lookup table.

Thierry

[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]

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

end of thread, other threads:[~2014-04-07 11:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-17 18:38 [PATCH] leds: pwm: set polarity on non DT platforms Alexandre Belloni
2014-03-18 23:02 ` Bryan Wu
2014-03-18 23:09   ` Alexandre Belloni
2014-04-07 11:33     ` Thierry Reding

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).