[PATCH 7/8] led: pwm: support active-low property

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxx>
---
 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 419d96eed392..8a358dde88b3 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;
 
-- 
2.25.0


_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux