2021-12-12 22:34:42

by Merlijn Wajer

[permalink] [raw]
Subject: [PATCH 0/2] Fix RGB status LED and keyboard backlight LEDs on Nokia N900

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



2021-12-12 22:34:45

by Merlijn Wajer

[permalink] [raw]
Subject: [PATCH 1/2] ARM: dts: omap3-n900: Fix lp5523 for multi color

From: "Sicelo A. Mhlongo" <[email protected]>

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 <[email protected]>
Signed-off-by: Sicelo A. Mhlongo <[email protected]>
---
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


2021-12-12 22:34:48

by Merlijn Wajer

[permalink] [raw]
Subject: [PATCH 2/2] leds: lp55xx: initialise output direction from dts

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 <[email protected]>
---
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


2021-12-12 23:59:33

by Linus Walleij

[permalink] [raw]
Subject: Re: [PATCH 2/2] leds: lp55xx: initialise output direction from dts

On Sun, Dec 12, 2021 at 11:34 PM Merlijn Wajer <[email protected]> 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 <[email protected]>

Reviewed-by: Linus Walleij <[email protected]>

Thanks for fixing my mistakes!

Yours,
Linus Walleij

2021-12-15 20:31:21

by Pavel Machek

[permalink] [raw]
Subject: Re: [PATCH 1/2] ARM: dts: omap3-n900: Fix lp5523 for multi color

Hi!

> From: "Sicelo A. Mhlongo" <[email protected]>
>
> 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


Attachments:
(No filename) (355.00 B)
signature.asc (195.00 B)
Download all attachments

2021-12-15 20:33:06

by Pavel Machek

[permalink] [raw]
Subject: Re: [PATCH 0/2] Fix RGB status LED and keyboard backlight LEDs on Nokia N900

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


Attachments:
(No filename) (960.00 B)
signature.asc (195.00 B)
Download all attachments

2021-12-16 11:45:05

by Merlijn Wajer

[permalink] [raw]
Subject: Re: [PATCH 1/2] ARM: dts: omap3-n900: Fix lp5523 for multi color

Hi Pavel,

On 15/12/2021 21:31, Pavel Machek wrote:
> Hi!
>
>> From: "Sicelo A. Mhlongo" <[email protected]>
>>
>> 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

2021-12-16 11:45:50

by Merlijn Wajer

[permalink] [raw]
Subject: Re: [PATCH 0/2] Fix RGB status LED and keyboard backlight LEDs on Nokia N900

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