Skip to content

Commit

Permalink
Merge pull request #10 from OpenBricks/solidrun-led-patch
Browse files Browse the repository at this point in the history
leds: Fix support for low-active PWM LED
  • Loading branch information
linux4kix committed Sep 1, 2015
2 parents a15c00a + 29e2207 commit 83987a1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Documentation/devicetree/bindings/leds/leds-pwm.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ LED sub-node properties:
see Documentation/devicetree/bindings/leds/common.txt
- linux,default-trigger : (optional)
see Documentation/devicetree/bindings/leds/common.txt
- active-low : (optional)
Inverts the duty cycle to reflect a low-active output pin

Example:

Expand All @@ -38,6 +40,7 @@ pwmleds {
label = "omap4::keypad";
pwms = <&twl_pwm 0 7812500>;
max-brightness = <127>;
active-low;
};

charging {
Expand Down
5 changes: 5 additions & 0 deletions drivers/leds/leds-pwm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -117,6 +121,7 @@ static int led_pwm_create_of(struct platform_device *pdev,

led_dat->cdev.default_trigger = of_get_property(child,
"linux,default-trigger", NULL);
led_dat->active_low = of_property_read_bool(child, "active-low");
of_property_read_u32(child, "max-brightness",
&led_dat->cdev.max_brightness);

Expand Down

0 comments on commit 83987a1

Please sign in to comment.