[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220705210143.315151-4-emil.renner.berthing@canonical.com>
Date: Tue, 5 Jul 2022 23:01:42 +0200
From: Emil Renner Berthing <emil.renner.berthing@...onical.com>
To: linux-kernel@...r.kernel.org
Cc: Pavel Machek <pavel@....cz>, Rob Herring <robh+dt@...nel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@...aro.org>,
Paul Walmsley <paul.walmsley@...ive.com>,
Palmer Dabbelt <palmer@...belt.com>,
Vincent Pelletier <plr.vincent@...il.com>,
Bin Meng <bin.meng@...driver.com>,
Aurelien Jarno <aurelien@...el32.net>,
Ron Economos <w6rz@...cast.net>,
Qiu Wenbo <qiuwenbo@...inos.com.cn>,
Geert Uytterhoeven <geert@...ux-m68k.org>,
Stephen L Arnold <nerdboy@...too.org>,
Jianlong Huang <jianlong.huang@...rfivetech.com>,
Mark Kettenis <kettenis@...nbsd.org>,
Sven Schwermer <sven.schwermer@...ruptive-technologies.com>,
Andy Shevchenko <andy.shevchenko@...il.com>,
David Abdurachmanov <davidlt@...osinc.com>,
linux-leds@...r.kernel.org, devicetree@...r.kernel.org,
linux-riscv@...ts.infradead.org
Subject: [PATCH v1 3/4] leds: pwm-multicolor: Support active-low LEDs
Add support for LEDs wired up to light when the PWM output is low, just
like the regular PWM LEDs.
Signed-off-by: Emil Renner Berthing <emil.renner.berthing@...onical.com>
---
drivers/leds/rgb/leds-pwm-multicolor.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/leds/rgb/leds-pwm-multicolor.c b/drivers/leds/rgb/leds-pwm-multicolor.c
index eb67b89d28e9..da9d2218ae18 100644
--- a/drivers/leds/rgb/leds-pwm-multicolor.c
+++ b/drivers/leds/rgb/leds-pwm-multicolor.c
@@ -19,6 +19,7 @@
struct pwm_led {
struct pwm_device *pwm;
struct pwm_state state;
+ bool active_low;
};
struct pwm_mc_led {
@@ -45,6 +46,9 @@ static int led_pwm_mc_set(struct led_classdev *cdev,
duty *= mc_cdev->subled_info[i].brightness;
do_div(duty, cdev->max_brightness);
+ if (priv->leds[i].active_low)
+ duty = priv->leds[i].state.period - duty;
+
priv->leds[i].state.duty_cycle = duty;
priv->leds[i].state.enabled = duty > 0;
ret = pwm_apply_state(priv->leds[i].pwm,
@@ -76,6 +80,7 @@ static int iterate_subleds(struct device *dev, struct pwm_mc_led *priv,
goto release_fwnode;
}
pwm_init_state(pwmled->pwm, &pwmled->state);
+ pwmled->active_low = fwnode_property_read_bool(fwnode, "active-low");
ret = fwnode_property_read_u32(fwnode, "color", &color);
if (ret) {
--
2.37.0
Powered by blists - more mailing lists