[PATCH 1/3] leds: lp55xx: Add program and mux base pages to the device config
From: Arthur Crepin Leblond
Date: Mon Oct 26 2026 - 09:57:19 EST
Add program and mux base page to struct lp55xx_device_config to
set the first page of the engine programs and of the LED mapping table.
Until now the mapping tables were placed at the end of the programs.
On the LP5569 this puts them in the upper half of the SRAM, while the
map_* instructions can only address words 0-127.
This change allows placing the mapping tables before the programs instead.
All the chips set the values matching their current layout, so their
behavior is unchanged:
- LP5523 has the 3 engine programs on the first 3 pages and their
LED mapping tables on the next 3 pages.
- LP5569 has the 3 engine programs of 4 pages each, followed by the
LED mapping tables.
- LP8501 stores its program at address 0.
Signed-off-by: Arthur Crepin Leblond <arthur@xxxxxxxxxxxxx>
---
drivers/leds/leds-lp5523.c | 4 ++++
drivers/leds/leds-lp5569.c | 4 ++++
drivers/leds/leds-lp55xx-common.c | 14 ++++++++------
drivers/leds/leds-lp55xx-common.h | 6 ++++++
drivers/leds/leds-lp8501.c | 2 ++
5 files changed, 24 insertions(+), 6 deletions(-)
diff --git a/drivers/leds/leds-lp5523.c b/drivers/leds/leds-lp5523.c
index 39cb26d343c1..3ec9f3f31708 100644
--- a/drivers/leds/leds-lp5523.c
+++ b/drivers/leds/leds-lp5523.c
@@ -31,6 +31,8 @@
* 0x50 engine 3 muxing info
*/
#define LP5523_PAGES_PER_ENGINE 1
+#define LP5523_PROG_PAGE_BASE 0
+#define LP5523_MUX_PAGE_BASE 3
#define LP5523_MAX_LEDS 9
/* Registers */
@@ -335,6 +337,8 @@ static struct lp55xx_device_config lp5523_cfg = {
.addr = LP5523_REG_LED_CTRL_BASE,
},
.pages_per_engine = LP5523_PAGES_PER_ENGINE,
+ .prog_page_base = LP5523_PROG_PAGE_BASE,
+ .mux_page_base = LP5523_MUX_PAGE_BASE,
.max_channel = LP5523_MAX_LEDS,
.post_init_device = lp5523_post_init_device,
.brightness_fn = lp55xx_led_brightness,
diff --git a/drivers/leds/leds-lp5569.c b/drivers/leds/leds-lp5569.c
index 199db3efca65..15beac7b34ea 100644
--- a/drivers/leds/leds-lp5569.c
+++ b/drivers/leds/leds-lp5569.c
@@ -30,6 +30,8 @@
* 0xe0 engine 3 muxing info (1 page)
*/
#define LP5569_PAGES_PER_ENGINE 4
+#define LP5569_PROG_PAGE_BASE 0
+#define LP5569_MUX_PAGE_BASE 12
#define LP5569_REG_ENABLE 0x00
#define LP5569_ENABLE BIT(6)
@@ -503,6 +505,8 @@ static struct lp55xx_device_config lp5569_cfg = {
.addr = LP5569_REG_LED_CTRL_BASE,
},
.pages_per_engine = LP5569_PAGES_PER_ENGINE,
+ .prog_page_base = LP5569_PROG_PAGE_BASE,
+ .mux_page_base = LP5569_MUX_PAGE_BASE,
.max_channel = LP5569_MAX_LEDS,
.post_init_device = lp5569_post_init_device,
.brightness_fn = lp55xx_led_brightness,
diff --git a/drivers/leds/leds-lp55xx-common.c b/drivers/leds/leds-lp55xx-common.c
index ea131177de96..e2c55ce5d92b 100644
--- a/drivers/leds/leds-lp55xx-common.c
+++ b/drivers/leds/leds-lp55xx-common.c
@@ -61,8 +61,8 @@
/* Memory Page Selection */
#define LP55xx_REG_PROG_PAGE_SEL 0x4f
-/* If supported, each ENGINE have an equal amount of pages offset from page 0 */
-#define LP55xx_PAGE_OFFSET(n, pages) (((n) - 1) * (pages))
+/* If supported, each ENGINE have an equal amount of pages offset from base */
+#define LP55xx_PAGE_OFFSET(n, pages, base) ((base) + ((n) - 1) * (pages))
#define LED_ACTIVE(mux, led) (!!((mux) & (0x0001 << (led))))
@@ -131,7 +131,8 @@ void lp55xx_load_engine(struct lp55xx_chip *chip)
/* Setup PAGE if supported (pages_per_engine not 0)*/
if (cfg->pages_per_engine)
lp55xx_write(chip, LP55xx_REG_PROG_PAGE_SEL,
- LP55xx_PAGE_OFFSET(idx, cfg->pages_per_engine));
+ LP55xx_PAGE_OFFSET(idx, cfg->pages_per_engine,
+ cfg->prog_page_base));
}
EXPORT_SYMBOL_GPL(lp55xx_load_engine);
@@ -176,6 +177,8 @@ int lp55xx_update_program_memory(struct lp55xx_chip *chip,
const struct lp55xx_device_config *cfg = chip->cfg;
u8 pattern[LP55xx_MAX_PROGRAM_LENGTH] = { };
u8 start_addr = cfg->prog_mem_base.addr;
+ int first_page = LP55xx_PAGE_OFFSET(idx, cfg->pages_per_engine,
+ cfg->prog_page_base);
int page, i = 0, offset = 0;
int program_length, ret;
@@ -218,7 +221,7 @@ int lp55xx_update_program_memory(struct lp55xx_chip *chip,
/* Write to the next page each 32 bytes (if supported) */
if (cfg->pages_per_engine)
lp55xx_write(chip, LP55xx_REG_PROG_PAGE_SEL,
- LP55xx_PAGE_OFFSET(idx, cfg->pages_per_engine) + page);
+ first_page + page);
for (i = 0; i < LP55xx_BYTES_PER_PAGE; i++) {
ret = lp55xx_write(chip, start_addr + i,
@@ -769,8 +772,7 @@ static int lp55xx_load_mux(struct lp55xx_chip *chip, u16 mux, int nr)
lp55xx_load_engine(chip);
- /* Derive the MUX page offset by starting at the end of the ENGINE pages */
- mux_page = cfg->pages_per_engine * LP55XX_ENGINE_MAX + (nr - 1);
+ mux_page = cfg->mux_page_base + (nr - 1);
ret = lp55xx_write(chip, LP55xx_REG_PROG_PAGE_SEL, mux_page);
if (ret)
return ret;
diff --git a/drivers/leds/leds-lp55xx-common.h b/drivers/leds/leds-lp55xx-common.h
index 8fd64ec40919..7ef657047933 100644
--- a/drivers/leds/leds-lp55xx-common.h
+++ b/drivers/leds/leds-lp55xx-common.h
@@ -125,6 +125,10 @@ struct lp55xx_reg {
* @reg_led_ctrl_base : Chip specific base reg address for LED ctrl base
* @pages_per_engine : Assigned pages for each engine
* (if not set chip doesn't support pages)
+ * @prog_page_base : First page of the engine 1 program, the programs of
+ * the other engines follow one after another
+ * @mux_page_base : First page of the engine 1 LED mapping row, the rows
+ * of the other engines are in the next pages
* @max_channel : Maximum number of channels
* @post_init_device : Chip specific initialization code
* @brightness_fn : Brightness function
@@ -146,6 +150,8 @@ struct lp55xx_device_config {
const struct lp55xx_reg reg_master_fader_base;
const struct lp55xx_reg reg_led_ctrl_base;
const int pages_per_engine;
+ const u8 prog_page_base;
+ const u8 mux_page_base;
const int max_channel;
/* define if the device has specific initialization process */
diff --git a/drivers/leds/leds-lp8501.c b/drivers/leds/leds-lp8501.c
index 8009689db7b4..1c05839cd4c2 100644
--- a/drivers/leds/leds-lp8501.c
+++ b/drivers/leds/leds-lp8501.c
@@ -21,6 +21,7 @@
#include "leds-lp55xx-common.h"
#define LP8501_PAGES_PER_ENGINE 1
+#define LP8501_PROG_PAGE_BASE 0
#define LP8501_MAX_LEDS 9
/* Registers */
@@ -121,6 +122,7 @@ static struct lp55xx_device_config lp8501_cfg = {
.addr = LP8501_REG_LED_CURRENT_BASE,
},
.pages_per_engine = LP8501_PAGES_PER_ENGINE,
+ .prog_page_base = LP8501_PROG_PAGE_BASE,
.max_channel = LP8501_MAX_LEDS,
.post_init_device = lp8501_post_init_device,
.brightness_fn = lp55xx_led_brightness,
--
2.56.0