summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2020-02-06 12:23:33 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2020-02-10 09:16:15 +0100
commit769eb5e7bbb21199611cec2519a47447375cc57a (patch)
tree17e7bdc1bfa0ecde2c03e1c1bd6d0fb00e9db7ce /drivers
parentf2fae1be3aa51e9665b4b947f7f0f4f723e264d6 (diff)
downloadbarebox-769eb5e7bbb21199611cec2519a47447375cc57a.tar.gz
barebox-769eb5e7bbb21199611cec2519a47447375cc57a.tar.xz
led: pwm: support active-low property
active-low is an optional property to describe PWMs where the LED is wired to supply rather than ground. Add barebox support for it. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/led/led-pwm.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/led/led-pwm.c b/drivers/led/led-pwm.c
index 419d96eed3..8a358dde88 100644
--- a/drivers/led/led-pwm.c
+++ b/drivers/led/led-pwm.c
@@ -41,6 +41,9 @@ static void led_pwm_set(struct led *led, unsigned int brightness)
duty *= brightness;
do_div(duty, max);
+ if (pwmled->active_low)
+ duty = pwmled->period - duty;
+
pwm_config(pwmled->pwm, duty, pwmled->period);
}
@@ -66,6 +69,7 @@ static int led_pwm_of_probe(struct device_d *dev)
return ret;
pwmled->period = pwm_get_period(pwmled->pwm);
+ pwmled->active_low = of_property_read_bool(child, "active-low");
pwmled->led.set = led_pwm_set;