diff mbox series

[2/2] leds: syscon: Implement support for active-low property

Message ID 20220818172528.23062-2-pali@kernel.org
State New
Headers show
Series [1/2] dt-bindings: leds: register-bit-led: Add active-low property | expand

Commit Message

Pali Rohár Aug. 18, 2022, 5:25 p.m. UTC
This new active-low property specify that LED has inverted logic
(0 - enable LED, 1 - disable LED).

Signed-off-by: Pali Rohár <pali@kernel.org>
---
 drivers/leds/leds-syscon.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

Comments

Linus Walleij Aug. 26, 2022, 8:05 a.m. UTC | #1
On Thu, Aug 18, 2022 at 7:25 PM Pali Rohár <pali@kernel.org> wrote:

> This new active-low property specify that LED has inverted logic
> (0 - enable LED, 1 - disable LED).
>
> Signed-off-by: Pali Rohár <pali@kernel.org>

Acked-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij
Pali Rohár Aug. 31, 2022, 11:49 a.m. UTC | #2
On Friday 26 August 2022 10:05:26 Linus Walleij wrote:
> On Thu, Aug 18, 2022 at 7:25 PM Pali Rohár <pali@kernel.org> wrote:
> 
> > This new active-low property specify that LED has inverted logic
> > (0 - enable LED, 1 - disable LED).
> >
> > Signed-off-by: Pali Rohár <pali@kernel.org>
> 
> Acked-by: Linus Walleij <linus.walleij@linaro.org>
> 
> Yours,
> Linus Walleij

Is something else needed for this patch series?
Pali Rohár Oct. 9, 2022, 11:40 a.m. UTC | #3
On Wednesday 31 August 2022 13:49:36 Pali Rohár wrote:
> On Friday 26 August 2022 10:05:26 Linus Walleij wrote:
> > On Thu, Aug 18, 2022 at 7:25 PM Pali Rohár <pali@kernel.org> wrote:
> > 
> > > This new active-low property specify that LED has inverted logic
> > > (0 - enable LED, 1 - disable LED).
> > >
> > > Signed-off-by: Pali Rohár <pali@kernel.org>
> > 
> > Acked-by: Linus Walleij <linus.walleij@linaro.org>
> > 
> > Yours,
> > Linus Walleij
> 
> Is something else needed for this patch series?

PING?
Pali Rohár Nov. 1, 2022, 10:32 p.m. UTC | #4
On Sunday 09 October 2022 13:40:43 Pali Rohár wrote:
> On Wednesday 31 August 2022 13:49:36 Pali Rohár wrote:
> > On Friday 26 August 2022 10:05:26 Linus Walleij wrote:
> > > On Thu, Aug 18, 2022 at 7:25 PM Pali Rohár <pali@kernel.org> wrote:
> > > 
> > > > This new active-low property specify that LED has inverted logic
> > > > (0 - enable LED, 1 - disable LED).
> > > >
> > > > Signed-off-by: Pali Rohár <pali@kernel.org>
> > > 
> > > Acked-by: Linus Walleij <linus.walleij@linaro.org>
> > > 
> > > Yours,
> > > Linus Walleij
> > 
> > Is something else needed for this patch series?
> 
> PING?

PING?
Linus Walleij Nov. 8, 2022, 12:42 p.m. UTC | #5
On Tue, Nov 1, 2022 at 11:33 PM Pali Rohár <pali@kernel.org> wrote:
> On Sunday 09 October 2022 13:40:43 Pali Rohár wrote:
> > On Wednesday 31 August 2022 13:49:36 Pali Rohár wrote:
> > > On Friday 26 August 2022 10:05:26 Linus Walleij wrote:
> > > > On Thu, Aug 18, 2022 at 7:25 PM Pali Rohár <pali@kernel.org> wrote:
> > > >
> > > > > This new active-low property specify that LED has inverted logic
> > > > > (0 - enable LED, 1 - disable LED).
> > > > >
> > > > > Signed-off-by: Pali Rohár <pali@kernel.org>
> > > >
> > > > Acked-by: Linus Walleij <linus.walleij@linaro.org>
> > > >
> > > > Yours,
> > > > Linus Walleij
> > >
> > > Is something else needed for this patch series?
> >
> > PING?
>
> PING?

If the LED subsystem isn't working consider sending the patch to the
SoC tree with a notice that they apply it instead and why.

Yours,
Linus Walleij
diff mbox series

Patch

diff --git a/drivers/leds/leds-syscon.c b/drivers/leds/leds-syscon.c
index 7eddb8ecb44e..5e605d8438e9 100644
--- a/drivers/leds/leds-syscon.c
+++ b/drivers/leds/leds-syscon.c
@@ -29,6 +29,7 @@  struct syscon_led {
 	struct regmap *map;
 	u32 offset;
 	u32 mask;
+	bool active_low;
 	bool state;
 };
 
@@ -41,10 +42,10 @@  static void syscon_led_set(struct led_classdev *led_cdev,
 	int ret;
 
 	if (value == LED_OFF) {
-		val = 0;
+		val = sled->active_low ? sled->mask : 0;
 		sled->state = false;
 	} else {
-		val = sled->mask;
+		val = sled->active_low ? 0 : sled->mask;
 		sled->state = true;
 	}
 
@@ -85,6 +86,8 @@  static int syscon_led_probe(struct platform_device *pdev)
 		return -EINVAL;
 	if (of_property_read_u32(np, "mask", &sled->mask))
 		return -EINVAL;
+	if (of_find_property(np, "active-low", NULL))
+		sled->active_low = true;
 
 	state = of_get_property(np, "default-state", NULL);
 	if (state) {
@@ -95,17 +98,20 @@  static int syscon_led_probe(struct platform_device *pdev)
 			if (ret < 0)
 				return ret;
 			sled->state = !!(val & sled->mask);
+			if (sled->active_low)
+				sled->state = !sled->state;
 		} else if (!strcmp(state, "on")) {
 			sled->state = true;
 			ret = regmap_update_bits(map, sled->offset,
 						 sled->mask,
-						 sled->mask);
+						 sled->active_low ? 0 : sled->mask);
 			if (ret < 0)
 				return ret;
 		} else {
 			sled->state = false;
 			ret = regmap_update_bits(map, sled->offset,
-						 sled->mask, 0);
+						 sled->mask,
+						 sled->active_low ? sled->mask : 0);
 			if (ret < 0)
 				return ret;
 		}