Skip to content

Commit d605831

Browse files
andrei-lalaev-APlag-linaro
authored andcommitted
leds: leds-lp55xx: Use correct address for memory programming
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: 31379a5 ("leds: leds-lp55xx: Generalize update_program_memory function") Signed-off-by: Andrei Lalaev <andrei.lalaev@anton-paar.com> Link: https://lore.kernel.org/r/20250820-lp5562-prog-mem-address-v1-1-8569647fa71d@anton-paar.com Signed-off-by: Lee Jones <lee@kernel.org>
1 parent 19c5010 commit d605831

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

drivers/leds/leds-lp55xx-common.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ int lp55xx_update_program_memory(struct lp55xx_chip *chip,
212212
* For LED chip that support page, PAGE is already set in load_engine.
213213
*/
214214
if (!cfg->pages_per_engine)
215-
start_addr += LP55xx_BYTES_PER_PAGE * idx;
215+
start_addr += LP55xx_BYTES_PER_PAGE * (idx - 1);
216216

217217
for (page = 0; page < program_length / LP55xx_BYTES_PER_PAGE; page++) {
218218
/* Write to the next page each 32 bytes (if supported) */

0 commit comments

Comments
 (0)