linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] Fix RGB status LED and keyboard backlight LEDs on Nokia N900
@ 2021-12-12 22:40 Merlijn Wajer
  2021-12-12 22:40 ` [PATCH 1/2] ARM: dts: omap3-n900: Fix lp5523 for multi color Merlijn Wajer
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Merlijn Wajer @ 2021-12-12 22:40 UTC (permalink / raw)
  To: merlijn
  Cc: Ivaylo Dimitrov, Dev Null, Tony Lindgren, Sebastian Reichel,
	linux-kernel, linux-leds, linux-omap, Dan Murphy, devicetree,
	Doug Zobel, Jacek Anaszewski, Linus Walleij, Pavel Machek,
	Rob Herring, Sicelo A . Mhlongo, Benoît Cousson

The RGB status LED and keyboard backlight LEDs were broken on the Nokia N900
since the conversion to gpiod descriptors and additionally later on with the
addition of multi color support. There was at least one attempt merged to fix
the lp5523 driver since the gpiod conversion, but it doesn't honour the device
tree, which in the case of the Nokia N900 means that the fix doesn't work.

In this series are two patches fix the problems:

* One addresses the gpiod change in the device tree as well as the multi
  color support in the device tree;
* The other patch fixes the previous attempt at fixing the driver to honour
  the device tree;

Please let me know if anything seems off, and I'll be glad to make any
recommended changes, thanks!

Merlijn Wajer (1):
  leds: lp55xx: initialise output direction from dts

Sicelo A. Mhlongo (1):
  ARM: dts: omap3-n900: Fix lp5523 for multi color

 arch/arm/boot/dts/omap3-n900.dts  | 50 ++++++++++++++++++++++++-------
 drivers/leds/leds-lp55xx-common.c |  4 ++-
 2 files changed, 43 insertions(+), 11 deletions(-)

-- 
2.32.0


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/2] ARM: dts: omap3-n900: Fix lp5523 for multi color
  2021-12-12 22:40 [PATCH 0/2] Fix RGB status LED and keyboard backlight LEDs on Nokia N900 Merlijn Wajer
@ 2021-12-12 22:40 ` Merlijn Wajer
  2021-12-15 20:31   ` Pavel Machek
  2021-12-12 22:40 ` [PATCH 2/2] leds: lp55xx: initialise output direction from dts Merlijn Wajer
  2021-12-15 20:32 ` [PATCH 0/2] Fix RGB status LED and keyboard backlight LEDs on Nokia N900 Pavel Machek
  2 siblings, 1 reply; 8+ messages in thread
From: Merlijn Wajer @ 2021-12-12 22:40 UTC (permalink / raw)
  To: merlijn
  Cc: Ivaylo Dimitrov, Dev Null, Tony Lindgren, Sebastian Reichel,
	Sicelo A. Mhlongo, Benoît Cousson, Rob Herring,
	Pavel Machek, Jacek Anaszewski, Dan Murphy, Linus Walleij,
	linux-omap, devicetree, linux-kernel

From: "Sicelo A. Mhlongo" <absicsz@gmail.com>

Since the LED multicolor framework support was added in commit
92a81562e695 ("leds: lp55xx: Add multicolor framework support to lp55xx")
LEDs on this platform stopped working.

Fixes: 92a81562e695 ("leds: lp55xx: Add multicolor framework support to lp55xx")
Fixes: ac219bf3c9bd ("leds: lp55xx: Convert to use GPIO descriptors")
Signed-off-by: Merlijn Wajer <merlijn@wizzup.org>
Signed-off-by: Sicelo A. Mhlongo <absicsz@gmail.com>
---
 arch/arm/boot/dts/omap3-n900.dts | 50 +++++++++++++++++++++++++-------
 1 file changed, 40 insertions(+), 10 deletions(-)

diff --git a/arch/arm/boot/dts/omap3-n900.dts b/arch/arm/boot/dts/omap3-n900.dts
index c89b6c87271f..1746a44e96bc 100644
--- a/arch/arm/boot/dts/omap3-n900.dts
+++ b/arch/arm/boot/dts/omap3-n900.dts
@@ -8,6 +8,7 @@
 
 #include "omap34xx.dtsi"
 #include <dt-bindings/input/input.h>
+#include <dt-bindings/leds/common.h>
 
 /*
  * Default secure signed bootloader (Nokia X-Loader) does not enable L3 firewall
@@ -630,63 +631,92 @@ indicator {
 	};
 
 	lp5523: lp5523@32 {
+		#address-cells = <1>;
+		#size-cells = <0>;
 		compatible = "national,lp5523";
 		reg = <0x32>;
 		clock-mode = /bits/ 8 <0>; /* LP55XX_CLOCK_AUTO */
-		enable-gpio = <&gpio2 9 GPIO_ACTIVE_HIGH>; /* 41 */
+		enable-gpios = <&gpio2 9 GPIO_ACTIVE_HIGH>; /* 41 */
 
-		chan0 {
+		led@0 {
+			reg = <0>;
 			chan-name = "lp5523:kb1";
 			led-cur = /bits/ 8 <50>;
 			max-cur = /bits/ 8 <100>;
+			color = <LED_COLOR_ID_WHITE>;
+			function = LED_FUNCTION_KBD_BACKLIGHT;
 		};
 
-		chan1 {
+		led@1 {
+			reg = <1>;
 			chan-name = "lp5523:kb2";
 			led-cur = /bits/ 8 <50>;
 			max-cur = /bits/ 8 <100>;
+			color = <LED_COLOR_ID_WHITE>;
+			function = LED_FUNCTION_KBD_BACKLIGHT;
 		};
 
-		chan2 {
+		led@2 {
+			reg = <2>;
 			chan-name = "lp5523:kb3";
 			led-cur = /bits/ 8 <50>;
 			max-cur = /bits/ 8 <100>;
+			color = <LED_COLOR_ID_WHITE>;
+			function = LED_FUNCTION_KBD_BACKLIGHT;
 		};
 
-		chan3 {
+		led@3 {
+			reg = <3>;
 			chan-name = "lp5523:kb4";
 			led-cur = /bits/ 8 <50>;
 			max-cur = /bits/ 8 <100>;
+			color = <LED_COLOR_ID_WHITE>;
+			function = LED_FUNCTION_KBD_BACKLIGHT;
 		};
 
-		chan4 {
+		led@4 {
+			reg = <4>;
 			chan-name = "lp5523:b";
 			led-cur = /bits/ 8 <50>;
 			max-cur = /bits/ 8 <100>;
+			color = <LED_COLOR_ID_BLUE>;
+			function = LED_FUNCTION_STATUS;
 		};
 
-		chan5 {
+		led@5 {
+			reg = <5>;
 			chan-name = "lp5523:g";
 			led-cur = /bits/ 8 <50>;
 			max-cur = /bits/ 8 <100>;
+			color = <LED_COLOR_ID_GREEN>;
+			function = LED_FUNCTION_STATUS;
 		};
 
-		chan6 {
+		led@6 {
+			reg = <6>;
 			chan-name = "lp5523:r";
 			led-cur = /bits/ 8 <50>;
 			max-cur = /bits/ 8 <100>;
+			color = <LED_COLOR_ID_RED>;
+			function = LED_FUNCTION_STATUS;
 		};
 
-		chan7 {
+		led@7 {
+			reg = <7>;
 			chan-name = "lp5523:kb5";
 			led-cur = /bits/ 8 <50>;
 			max-cur = /bits/ 8 <100>;
+			color = <LED_COLOR_ID_WHITE>;
+			function = LED_FUNCTION_KBD_BACKLIGHT;
 		};
 
-		chan8 {
+		led@8 {
+			reg = <8>;
 			chan-name = "lp5523:kb6";
 			led-cur = /bits/ 8 <50>;
 			max-cur = /bits/ 8 <100>;
+			color = <LED_COLOR_ID_WHITE>;
+			function = LED_FUNCTION_KBD_BACKLIGHT;
 		};
 	};
 
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/2] leds: lp55xx: initialise output direction from dts
  2021-12-12 22:40 [PATCH 0/2] Fix RGB status LED and keyboard backlight LEDs on Nokia N900 Merlijn Wajer
  2021-12-12 22:40 ` [PATCH 1/2] ARM: dts: omap3-n900: Fix lp5523 for multi color Merlijn Wajer
@ 2021-12-12 22:40 ` Merlijn Wajer
  2021-12-12 23:59   ` Linus Walleij
  2021-12-15 20:32 ` [PATCH 0/2] Fix RGB status LED and keyboard backlight LEDs on Nokia N900 Pavel Machek
  2 siblings, 1 reply; 8+ messages in thread
From: Merlijn Wajer @ 2021-12-12 22:40 UTC (permalink / raw)
  To: merlijn
  Cc: Ivaylo Dimitrov, Dev Null, Tony Lindgren, Sebastian Reichel,
	Pavel Machek, Doug Zobel, Jacek Anaszewski, Dan Murphy,
	Linus Walleij, linux-leds, linux-kernel

Commit a5d3d1adc95f ("leds: lp55xx: Initialize enable GPIO direction to
output") attempts to fix this, but the fix did not work since at least
for the Nokia N900 the value needs to be set to HIGH, per the device
tree. So rather than hardcoding the value to a potentially invalid value
for some devices, let's set direction in lp55xx_init_device.

Fixes: a5d3d1adc95f ("leds: lp55xx: Initialize enable GPIO direction to output")
Fixes: 92a81562e695 ("leds: lp55xx: Add multicolor framework support to lp55xx")
Fixes: ac219bf3c9bd ("leds: lp55xx: Convert to use GPIO descriptors")
Signed-off-by: Merlijn Wajer <merlijn@wizzup.org>
---
 drivers/leds/leds-lp55xx-common.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/leds/leds-lp55xx-common.c b/drivers/leds/leds-lp55xx-common.c
index d1657c46ee2f..9fdfc1b9a1a0 100644
--- a/drivers/leds/leds-lp55xx-common.c
+++ b/drivers/leds/leds-lp55xx-common.c
@@ -439,6 +439,8 @@ int lp55xx_init_device(struct lp55xx_chip *chip)
 		return -EINVAL;
 
 	if (pdata->enable_gpiod) {
+		gpiod_direction_output(pdata->enable_gpiod, 0);
+
 		gpiod_set_consumer_name(pdata->enable_gpiod, "LP55xx enable");
 		gpiod_set_value(pdata->enable_gpiod, 0);
 		usleep_range(1000, 2000); /* Keep enable down at least 1ms */
@@ -694,7 +696,7 @@ struct lp55xx_platform_data *lp55xx_of_populate_pdata(struct device *dev,
 	of_property_read_u8(np, "clock-mode", &pdata->clock_mode);
 
 	pdata->enable_gpiod = devm_gpiod_get_optional(dev, "enable",
-						      GPIOD_OUT_LOW);
+						      GPIOD_ASIS);
 	if (IS_ERR(pdata->enable_gpiod))
 		return ERR_CAST(pdata->enable_gpiod);
 
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/2] leds: lp55xx: initialise output direction from dts
  2021-12-12 22:40 ` [PATCH 2/2] leds: lp55xx: initialise output direction from dts Merlijn Wajer
@ 2021-12-12 23:59   ` Linus Walleij
  0 siblings, 0 replies; 8+ messages in thread
From: Linus Walleij @ 2021-12-12 23:59 UTC (permalink / raw)
  To: Merlijn Wajer
  Cc: Ivaylo Dimitrov, Dev Null, Tony Lindgren, Sebastian Reichel,
	Pavel Machek, Doug Zobel, Jacek Anaszewski, Dan Murphy,
	linux-leds, linux-kernel

On Sun, Dec 12, 2021 at 11:34 PM Merlijn Wajer <merlijn@wizzup.org> wrote:

> Commit a5d3d1adc95f ("leds: lp55xx: Initialize enable GPIO direction to
> output") attempts to fix this, but the fix did not work since at least
> for the Nokia N900 the value needs to be set to HIGH, per the device
> tree. So rather than hardcoding the value to a potentially invalid value
> for some devices, let's set direction in lp55xx_init_device.
>
> Fixes: a5d3d1adc95f ("leds: lp55xx: Initialize enable GPIO direction to output")
> Fixes: 92a81562e695 ("leds: lp55xx: Add multicolor framework support to lp55xx")
> Fixes: ac219bf3c9bd ("leds: lp55xx: Convert to use GPIO descriptors")
> Signed-off-by: Merlijn Wajer <merlijn@wizzup.org>

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

Thanks for fixing my mistakes!

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/2] ARM: dts: omap3-n900: Fix lp5523 for multi color
  2021-12-12 22:40 ` [PATCH 1/2] ARM: dts: omap3-n900: Fix lp5523 for multi color Merlijn Wajer
@ 2021-12-15 20:31   ` Pavel Machek
  2021-12-16 11:50     ` Merlijn Wajer
  0 siblings, 1 reply; 8+ messages in thread
From: Pavel Machek @ 2021-12-15 20:31 UTC (permalink / raw)
  To: Merlijn Wajer
  Cc: Ivaylo Dimitrov, Dev Null, Tony Lindgren, Sebastian Reichel,
	Sicelo A. Mhlongo, Benoît Cousson, Rob Herring,
	Jacek Anaszewski, Dan Murphy, Linus Walleij, linux-omap,
	devicetree, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 369 bytes --]

Hi!

> From: "Sicelo A. Mhlongo" <absicsz@gmail.com>
> 
> Since the LED multicolor framework support was added in commit
> 92a81562e695 ("leds: lp55xx: Add multicolor framework support to lp55xx")
> LEDs on this platform stopped working.

Does this change names is /sys/class/leds?

Best regards,
								Pavel
-- 
http://www.livejournal.com/~pavelmachek

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 0/2] Fix RGB status LED and keyboard backlight LEDs on Nokia N900
  2021-12-12 22:40 [PATCH 0/2] Fix RGB status LED and keyboard backlight LEDs on Nokia N900 Merlijn Wajer
  2021-12-12 22:40 ` [PATCH 1/2] ARM: dts: omap3-n900: Fix lp5523 for multi color Merlijn Wajer
  2021-12-12 22:40 ` [PATCH 2/2] leds: lp55xx: initialise output direction from dts Merlijn Wajer
@ 2021-12-15 20:32 ` Pavel Machek
  2021-12-16 11:51   ` Merlijn Wajer
  2 siblings, 1 reply; 8+ messages in thread
From: Pavel Machek @ 2021-12-15 20:32 UTC (permalink / raw)
  To: Merlijn Wajer
  Cc: Ivaylo Dimitrov, Dev Null, Tony Lindgren, Sebastian Reichel,
	linux-kernel, linux-leds, linux-omap, Dan Murphy, devicetree,
	Doug Zobel, Jacek Anaszewski, Linus Walleij, Rob Herring,
	Sicelo A . Mhlongo, Benoît Cousson

[-- Attachment #1: Type: text/plain, Size: 985 bytes --]

Hi!

> The RGB status LED and keyboard backlight LEDs were broken on the Nokia N900
> since the conversion to gpiod descriptors and additionally later on with the
> addition of multi color support. There was at least one attempt merged to fix
> the lp5523 driver since the gpiod conversion, but it doesn't honour the device
> tree, which in the case of the Nokia N900 means that the fix doesn't work.
> 
> In this series are two patches fix the problems:
> 
> * One addresses the gpiod change in the device tree as well as the multi
>   color support in the device tree;
> * The other patch fixes the previous attempt at fixing the driver to honour
>   the device tree;
> 
> Please let me know if anything seems off, and I'll be glad to make any
> recommended changes, thanks!

Thank you, I took the series. But if it changes the names in
/sys/class/leds, we want to do something else.

Best regards,
									Pavel
-- 
http://www.livejournal.com/~pavelmachek

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/2] ARM: dts: omap3-n900: Fix lp5523 for multi color
  2021-12-15 20:31   ` Pavel Machek
@ 2021-12-16 11:50     ` Merlijn Wajer
  0 siblings, 0 replies; 8+ messages in thread
From: Merlijn Wajer @ 2021-12-16 11:50 UTC (permalink / raw)
  To: Pavel Machek
  Cc: Ivaylo Dimitrov, Dev Null, Tony Lindgren, Sebastian Reichel,
	Sicelo A. Mhlongo, Benoît Cousson, Rob Herring,
	Jacek Anaszewski, Dan Murphy, Linus Walleij, linux-omap,
	devicetree, linux-kernel

Hi Pavel,

On 15/12/2021 21:31, Pavel Machek wrote:
> Hi!
> 
>> From: "Sicelo A. Mhlongo" <absicsz@gmail.com>
>>
>> Since the LED multicolor framework support was added in commit
>> 92a81562e695 ("leds: lp55xx: Add multicolor framework support to lp55xx")
>> LEDs on this platform stopped working.
> 
> Does this change names is /sys/class/leds?

I booted my 5.15 with this series (and some other patches) added and
these are the led names:

> root@devuan-n900:~# uname -a
> Linux devuan-n900 5.15.2-00596-g94bfc7de5522-dirty #58 SMP PREEMPT Thu Dec 16 11:53:53 CET 2021 armv7l GNU/Linux
> root@devuan-n900:~# ls /sys/class/leds
> debug::sleep  lp5523:g    lp5523:kb2  lp5523:kb4  lp5523:kb6
> lp5523:b      lp5523:kb1  lp5523:kb3  lp5523:kb5  lp5523:r

On 5.1 (my previous 'stable') kernel, these are the led names:

> root@devuan-n900:~# uname -a
> Linux devuan-n900 5.1.21 #1 Mon Jul 19 16:32:44 UTC 2021 armv7l GNU/Linux
> root@devuan-n900:~# ls /sys/class/leds
> debug::sleep  lp5523:g    lp5523:kb2  lp5523:kb4  lp5523:kb6
> lp5523:b      lp5523:kb1  lp5523:kb3  lp5523:kb5  lp5523:r

So I don't think the names are changed.

Regards,
Merlijn

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 0/2] Fix RGB status LED and keyboard backlight LEDs on Nokia N900
  2021-12-15 20:32 ` [PATCH 0/2] Fix RGB status LED and keyboard backlight LEDs on Nokia N900 Pavel Machek
@ 2021-12-16 11:51   ` Merlijn Wajer
  0 siblings, 0 replies; 8+ messages in thread
From: Merlijn Wajer @ 2021-12-16 11:51 UTC (permalink / raw)
  To: Pavel Machek
  Cc: Ivaylo Dimitrov, Dev Null, Tony Lindgren, Sebastian Reichel,
	linux-kernel, linux-leds, linux-omap, Dan Murphy, devicetree,
	Doug Zobel, Jacek Anaszewski, Linus Walleij, Rob Herring,
	Sicelo A . Mhlongo, Benoît Cousson

Hi Pavel,

On 15/12/2021 21:32, Pavel Machek wrote:
> Hi!
> 
>> The RGB status LED and keyboard backlight LEDs were broken on the Nokia N900
>> since the conversion to gpiod descriptors and additionally later on with the
>> addition of multi color support. There was at least one attempt merged to fix
>> the lp5523 driver since the gpiod conversion, but it doesn't honour the device
>> tree, which in the case of the Nokia N900 means that the fix doesn't work.
>>
>> In this series are two patches fix the problems:
>>
>> * One addresses the gpiod change in the device tree as well as the multi
>>   color support in the device tree;
>> * The other patch fixes the previous attempt at fixing the driver to honour
>>   the device tree;
>>
>> Please let me know if anything seems off, and I'll be glad to make any
>> recommended changes, thanks!
> 
> Thank you, I took the series. But if it changes the names in
> /sys/class/leds, we want to do something else.

Thanks -- just for the record (I already replied to the other email) -
the names do not change based on my testing.

Regards,
Merlijn

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-12-16 11:45 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-12 22:40 [PATCH 0/2] Fix RGB status LED and keyboard backlight LEDs on Nokia N900 Merlijn Wajer
2021-12-12 22:40 ` [PATCH 1/2] ARM: dts: omap3-n900: Fix lp5523 for multi color Merlijn Wajer
2021-12-15 20:31   ` Pavel Machek
2021-12-16 11:50     ` Merlijn Wajer
2021-12-12 22:40 ` [PATCH 2/2] leds: lp55xx: initialise output direction from dts Merlijn Wajer
2021-12-12 23:59   ` Linus Walleij
2021-12-15 20:32 ` [PATCH 0/2] Fix RGB status LED and keyboard backlight LEDs on Nokia N900 Pavel Machek
2021-12-16 11:51   ` Merlijn Wajer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).