summaryrefslogtreecommitdiff
path: root/drivers/leds/leds-lp8501.c
diff options
context:
space:
mode:
authorChristian Marangi <ansuelsmth@gmail.com>2024-06-26 18:00:11 +0200
committerLee Jones <lee@kernel.org>2024-06-26 17:08:30 +0100
commit409a9dc53682b9f02793584d17721ab3e1b9c86f (patch)
treed94b96a6d40a729ce095ffaf5890543f5370eb3f /drivers/leds/leds-lp8501.c
parent4d310b96f2db602830c40f82a75ede799b243cce (diff)
downloadlwn-409a9dc53682b9f02793584d17721ab3e1b9c86f.tar.gz
lwn-409a9dc53682b9f02793584d17721ab3e1b9c86f.zip
leds: leds-lp55xx: Generalize load_engine_and_select_page function
Generalize load_engine_and_select_page by reworking the implementation and making it part of the generic load_engine function. Add a new option in device_config, pages_per_engine used to define pages assigned to each engine. With this option set, it's assumed LED chip supports pages and load_engine will correctly setup the write page. An equal amount of pages is assigned to each engine and they are assigned from page 0. Update any lp55xx based LED driver to define the option and use the new function. Suggested-by: Lee Jones <lee@kernel.org> Signed-off-by: Christian Marangi <ansuelsmth@gmail.com> Link: https://lore.kernel.org/r/20240626160027.19703-7-ansuelsmth@gmail.com Signed-off-by: Lee Jones <lee@kernel.org>
Diffstat (limited to 'drivers/leds/leds-lp8501.c')
-rw-r--r--drivers/leds/leds-lp8501.c19
1 files changed, 3 insertions, 16 deletions
diff --git a/drivers/leds/leds-lp8501.c b/drivers/leds/leds-lp8501.c
index 04173d6875af..abe2c4b213d7 100644
--- a/drivers/leds/leds-lp8501.c
+++ b/drivers/leds/leds-lp8501.c
@@ -21,6 +21,7 @@
#include "leds-lp55xx-common.h"
#define LP8501_PROGRAM_LENGTH 32
+#define LP8501_PAGES_PER_ENGINE 1
#define LP8501_MAX_LEDS 9
/* Registers */
@@ -116,21 +117,6 @@ static int lp8501_post_init_device(struct lp55xx_chip *chip)
LP8501_PWR_CONFIG_M, chip->pdata->pwr_sel);
}
-static void lp8501_load_engine(struct lp55xx_chip *chip)
-{
- enum lp55xx_engine_index idx = chip->engine_idx;
-
- static const u8 page_sel[] = {
- [LP55XX_ENGINE_1] = LP8501_PAGE_ENG1,
- [LP55XX_ENGINE_2] = LP8501_PAGE_ENG2,
- [LP55XX_ENGINE_3] = LP8501_PAGE_ENG3,
- };
-
- lp55xx_load_engine(chip);
-
- lp55xx_write(chip, LP8501_REG_PROG_PAGE_SEL, page_sel[idx]);
-}
-
static void lp8501_turn_off_channels(struct lp55xx_chip *chip)
{
int i;
@@ -250,7 +236,7 @@ static void lp8501_firmware_loaded(struct lp55xx_chip *chip)
* 2) write firmware data into program memory
*/
- lp8501_load_engine(chip);
+ lp55xx_load_engine(chip);
lp8501_update_program_memory(chip, fw->data, fw->size);
}
@@ -284,6 +270,7 @@ static struct lp55xx_device_config lp8501_cfg = {
.addr = LP8501_REG_ENABLE,
.val = LP8501_ENABLE,
},
+ .pages_per_engine = LP8501_PAGES_PER_ENGINE,
.max_channel = LP8501_MAX_LEDS,
.post_init_device = lp8501_post_init_device,
.brightness_fn = lp8501_led_brightness,