From 769eb5e7bbb21199611cec2519a47447375cc57a Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Thu, 6 Feb 2020 12:23:33 +0100 Subject: 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 Signed-off-by: Sascha Hauer --- drivers/led/led-pwm.c | 4 ++++ 1 file changed, 4 insertions(+) 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; -- cgit v1.2.3