summaryrefslogtreecommitdiff
path: root/drivers/leds/leds-lp5523.c
diff options
context:
space:
mode:
authorChristian Marangi <ansuelsmth@gmail.com>2024-06-26 18:00:12 +0200
committerLee Jones <lee@kernel.org>2024-06-26 17:08:30 +0100
commit42a9eaac9784e9b3df56f1947526d7d4d0ed9b26 (patch)
tree696bb7d5d2e0ebff33543e879208ea86f04050d2 /drivers/leds/leds-lp5523.c
parent409a9dc53682b9f02793584d17721ab3e1b9c86f (diff)
leds: leds-lp55xx: Generalize run_engine function
Generalize run_engine function for lp55xx based LED driver. The logic is similar to every LED driver, rework it with more macro magic and account for LED model that might have OP MODE and EXEC at base offset in the reg. Update any lp55xx based LED driver to use this generalized function and declare required bits. Suggested-by: Lee Jones <lee@kernel.org> Signed-off-by: Christian Marangi <ansuelsmth@gmail.com> Link: https://lore.kernel.org/r/20240626160027.19703-8-ansuelsmth@gmail.com Signed-off-by: Lee Jones <lee@kernel.org>
Diffstat (limited to 'drivers/leds/leds-lp5523.c')
-rw-r--r--drivers/leds/leds-lp5523.c41
1 files changed, 4 insertions, 37 deletions
diff --git a/drivers/leds/leds-lp5523.c b/drivers/leds/leds-lp5523.c
index 8dabd5814110..b28955b72189 100644
--- a/drivers/leds/leds-lp5523.c
+++ b/drivers/leds/leds-lp5523.c
@@ -184,10 +184,6 @@ static void lp5523_turn_off_channels(struct lp55xx_chip *chip)
static void lp5523_run_engine(struct lp55xx_chip *chip, bool start)
{
- int ret;
- u8 mode;
- u8 exec;
-
/* stop engine */
if (!start) {
lp5523_stop_engine(chip);
@@ -195,39 +191,7 @@ static void lp5523_run_engine(struct lp55xx_chip *chip, bool start)
return;
}
- /*
- * To run the engine,
- * operation mode and enable register should updated at the same time
- */
-
- ret = lp55xx_read(chip, LP5523_REG_OP_MODE, &mode);
- if (ret)
- return;
-
- ret = lp55xx_read(chip, LP5523_REG_ENABLE, &exec);
- if (ret)
- return;
-
- /* change operation mode to RUN only when each engine is loading */
- if (LP5523_ENG1_IS_LOADING(mode)) {
- mode = (mode & ~LP5523_MODE_ENG1_M) | LP5523_RUN_ENG1;
- exec = (exec & ~LP5523_EXEC_ENG1_M) | LP5523_RUN_ENG1;
- }
-
- if (LP5523_ENG2_IS_LOADING(mode)) {
- mode = (mode & ~LP5523_MODE_ENG2_M) | LP5523_RUN_ENG2;
- exec = (exec & ~LP5523_EXEC_ENG2_M) | LP5523_RUN_ENG2;
- }
-
- if (LP5523_ENG3_IS_LOADING(mode)) {
- mode = (mode & ~LP5523_MODE_ENG3_M) | LP5523_RUN_ENG3;
- exec = (exec & ~LP5523_EXEC_ENG3_M) | LP5523_RUN_ENG3;
- }
-
- lp55xx_write(chip, LP5523_REG_OP_MODE, mode);
- lp5523_wait_opmode_done();
-
- lp55xx_update_bits(chip, LP5523_REG_ENABLE, LP5523_EXEC_M, exec);
+ lp55xx_run_engine_common(chip);
}
static int lp5523_init_program_engine(struct lp55xx_chip *chip)
@@ -840,6 +804,9 @@ static struct lp55xx_device_config lp5523_cfg = {
.reg_op_mode = {
.addr = LP5523_REG_OP_MODE,
},
+ .reg_exec = {
+ .addr = LP5523_REG_ENABLE,
+ },
.engine_busy = {
.addr = LP5523_REG_STATUS,
.mask = LP5523_ENGINE_BUSY,