Skip to content

Commit

Permalink
leds: leds-pwm: implement PWM inversion
Browse files Browse the repository at this point in the history
Some PWM outputs are wired such that the LED they're controlling is
connected to supply rather than ground.  These PWMs may not support
output inversion, or when they do, disabling the PWM may set the
PWM output low, causing a "brightness" value of zero to turn the LED
fully on.

The platform data for this driver already indicates that this was
thought about, and we have the "active_low" property there already.
However, the implementation for this is missing.

Add the trivial implementation for this feature.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Acked-by: Thierry Reding <thierry.reding@gmail.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
  • Loading branch information
Russell King authored and Bryan Wu committed May 8, 2014
1 parent b795e6d commit d19a8a7
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions drivers/leds/leds-pwm.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,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)
Expand Down

0 comments on commit d19a8a7

Please sign in to comment.