From: Emil Renner Berthing <emil.renner.berthing@canonical.com>
To: linux-kernel@vger.kernel.org
Cc: Pavel Machek <pavel@ucw.cz>, Rob Herring <robh+dt@kernel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
Paul Walmsley <paul.walmsley@sifive.com>,
Palmer Dabbelt <palmer@dabbelt.com>,
Vincent Pelletier <plr.vincent@gmail.com>,
Bin Meng <bin.meng@windriver.com>,
Aurelien Jarno <aurelien@aurel32.net>,
Ron Economos <w6rz@comcast.net>,
Qiu Wenbo <qiuwenbo@kylinos.com.cn>,
Geert Uytterhoeven <geert@linux-m68k.org>,
Stephen L Arnold <nerdboy@gentoo.org>,
Jianlong Huang <jianlong.huang@starfivetech.com>,
Mark Kettenis <kettenis@openbsd.org>,
Sven Schwermer <sven.schwermer@disruptive-technologies.com>,
Andy Shevchenko <andy.shevchenko@gmail.com>,
David Abdurachmanov <davidlt@rivosinc.com>,
linux-leds@vger.kernel.org, devicetree@vger.kernel.org,
linux-riscv@lists.infradead.org
Subject: [PATCH v1 3/4] leds: pwm-multicolor: Support active-low LEDs
Date: Tue, 5 Jul 2022 23:01:42 +0200 [thread overview]
Message-ID: <20220705210143.315151-4-emil.renner.berthing@canonical.com> (raw)
In-Reply-To: <20220705210143.315151-1-emil.renner.berthing@canonical.com>
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@canonical.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
next prev parent reply other threads:[~2022-07-05 21:02 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-05 21:01 [PATCH v1 0/4] Add HiFive Unmatched LEDs Emil Renner Berthing
2022-07-05 21:01 ` [PATCH v1 1/4] leds: pwm-multicolor: Don't show -EPROBE_DEFER as errors Emil Renner Berthing
2022-07-06 7:30 ` Geert Uytterhoeven
2022-07-05 21:01 ` [PATCH v1 2/4] dt-bindings: leds: pwm-multicolor: Add active-low property Emil Renner Berthing
2022-07-06 7:33 ` Geert Uytterhoeven
2022-07-06 16:13 ` Rob Herring
2022-07-05 21:01 ` Emil Renner Berthing [this message]
2022-07-06 7:43 ` [PATCH v1 3/4] leds: pwm-multicolor: Support active-low LEDs Geert Uytterhoeven
2022-07-05 21:01 ` [PATCH v1 4/4] riscv: dts: sifive unmatched: Add PWM controlled LEDs Emil Renner Berthing
2022-07-06 7:56 ` Geert Uytterhoeven
2022-07-08 9:21 ` Ron Economos
2022-07-17 10:57 ` Pavel Machek
2022-07-17 14:05 ` Emil Renner Berthing
2022-07-17 11:02 ` [PATCH v1 0/4] Add HiFive Unmatched LEDs Pavel Machek
2022-08-11 21:06 ` Palmer Dabbelt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220705210143.315151-4-emil.renner.berthing@canonical.com \
--to=emil.renner.berthing@canonical.com \
--cc=andy.shevchenko@gmail.com \
--cc=aurelien@aurel32.net \
--cc=bin.meng@windriver.com \
--cc=davidlt@rivosinc.com \
--cc=devicetree@vger.kernel.org \
--cc=geert@linux-m68k.org \
--cc=jianlong.huang@starfivetech.com \
--cc=kettenis@openbsd.org \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=nerdboy@gentoo.org \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.com \
--cc=pavel@ucw.cz \
--cc=plr.vincent@gmail.com \
--cc=qiuwenbo@kylinos.com.cn \
--cc=robh+dt@kernel.org \
--cc=sven.schwermer@disruptive-technologies.com \
--cc=w6rz@comcast.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®