linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] leds: leds-lp55xx: use correct address for memory programming
@ 2025-08-20  8:47 Andrei Lalaev via B4 Relay
  2025-09-02 12:34 ` (subset) " Lee Jones
  0 siblings, 1 reply; 2+ messages in thread
From: Andrei Lalaev via B4 Relay @ 2025-08-20  8:47 UTC (permalink / raw)
  To: Lee Jones, Pavel Machek, Christian Marangi
  Cc: linux-leds, linux-kernel, Andrei Lalaev

From: Andrei Lalaev <andrei.lalaev@anton-paar.com>

Memory programming doesn't work for devices without page support.
For example, LP5562 has 3 engines but doesn't support pages,
the start address is changed depending on engine number.
According to datasheet [1], the PROG MEM register addresses for each
engine are as follows:

  Engine 1: 0x10
  Engine 2: 0x30
  Engine 3: 0x50

However, the current implementation incorrectly calculates the address
of PROG MEM register using the engine index starting from 1:

  prog_mem_base = 0x10
  LP55xx_BYTES_PER_PAGE = 0x20

  Engine 1: 0x10 + 0x20 * 1 = 0x30
  Engine 2: 0x10 + 0x20 * 2 = 0x50
  Engine 3: 0x10 + 0x20 * 3 = 0x70

This results in writing to the wrong engine memory, causing pattern
programming to fail.

To correct it, the engine index should be decreased:
  Engine 1: 0x10 + 0x20 * 0 = 0x10
  Engine 2: 0x10 + 0x20 * 1 = 0x30
  Engine 3: 0x10 + 0x20 * 2 = 0x50

1 - https://www.ti.com/lit/ds/symlink/lp5562.pdf

Fixes: 31379a57cf2f ("leds: leds-lp55xx: Generalize update_program_memory function")
Signed-off-by: Andrei Lalaev <andrei.lalaev@anton-paar.com>
---
 drivers/leds/leds-lp55xx-common.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/leds/leds-lp55xx-common.c b/drivers/leds/leds-lp55xx-common.c
index e71456a56ab8dae56988f50edd267e8e55090df8..fd447eb7eb15e243f1c470085f7780a8da866286 100644
--- a/drivers/leds/leds-lp55xx-common.c
+++ b/drivers/leds/leds-lp55xx-common.c
@@ -212,7 +212,7 @@ int lp55xx_update_program_memory(struct lp55xx_chip *chip,
 	 * For LED chip that support page, PAGE is already set in load_engine.
 	 */
 	if (!cfg->pages_per_engine)
-		start_addr += LP55xx_BYTES_PER_PAGE * idx;
+		start_addr += LP55xx_BYTES_PER_PAGE * (idx - 1);
 
 	for (page = 0; page < program_length / LP55xx_BYTES_PER_PAGE; page++) {
 		/* Write to the next page each 32 bytes (if supported) */

---
base-commit: b19a97d57c15643494ac8bfaaa35e3ee472d41da
change-id: 20250820-lp5562-prog-mem-address-ff33ac25be24

Best regards,
-- 
Andrei Lalaev <andrei.lalaev@anton-paar.com>



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

* Re: (subset) [PATCH] leds: leds-lp55xx: use correct address for memory programming
  2025-08-20  8:47 [PATCH] leds: leds-lp55xx: use correct address for memory programming Andrei Lalaev via B4 Relay
@ 2025-09-02 12:34 ` Lee Jones
  0 siblings, 0 replies; 2+ messages in thread
From: Lee Jones @ 2025-09-02 12:34 UTC (permalink / raw)
  To: Lee Jones, Pavel Machek, Christian Marangi, Andrei Lalaev
  Cc: linux-leds, linux-kernel

On Wed, 20 Aug 2025 10:47:12 +0200, Andrei Lalaev wrote:
> Memory programming doesn't work for devices without page support.
> For example, LP5562 has 3 engines but doesn't support pages,
> the start address is changed depending on engine number.
> According to datasheet [1], the PROG MEM register addresses for each
> engine are as follows:
> 
>   Engine 1: 0x10
>   Engine 2: 0x30
>   Engine 3: 0x50
> 
> [...]

Applied, thanks!

[1/1] leds: leds-lp55xx: use correct address for memory programming
      commit: d6058316d16ee0d1861c0550051b2492efb54b79

--
Lee Jones [李琼斯]


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

end of thread, other threads:[~2025-09-02 12:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-20  8:47 [PATCH] leds: leds-lp55xx: use correct address for memory programming Andrei Lalaev via B4 Relay
2025-09-02 12:34 ` (subset) " Lee Jones

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).