Skip to content

Commit

Permalink
leds-lp5521: update "Enable Register" if needed when going into run mode
Browse files Browse the repository at this point in the history
lp5521 can set EXEC bits in Enable Register to 00b (Hold), so make sure
that EXEC bits are set to 10b (Run) for desired channel when going into
run mode.

Signed-off-by: Filip Matijević <[email protected]>
  • Loading branch information
filippz committed Dec 23, 2014
1 parent 1fb5693 commit 2310e3b
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions drivers/leds/leds-lp5521.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ static int lp5521_set_engine_mode(struct lp5521_engine *engine, u8 mode)
struct i2c_client *client = chip->client;
int ret;
u8 engine_state;
u8 enable;

/* Only transition between RUN and DIRECT mode are handled here */
if (mode == LP5521_CMD_LOAD)
Expand All @@ -172,6 +173,20 @@ static int lp5521_set_engine_mode(struct lp5521_engine *engine, u8 mode)
if (mode == LP5521_CMD_DISABLED)
mode = LP5521_CMD_DIRECT;

if (mode == LP5521_CMD_RUN) {
/* Refresh EXEC status for current engine */
ret = lp5521_read(client, LP5521_REG_ENABLE, &enable);
if (ret < 0)
return ret;

enable &= ~(engine->engine_mask);
enable |= LP5521_EXEC_RUN & engine->engine_mask;

ret = lp5521_write(client, LP5521_REG_ENABLE, enable);
/* Consecutive writes to ENABLE requires 500us margin */
usleep_range(1000, 2000);
}

ret = lp5521_read(client, LP5521_REG_OP_MODE, &engine_state);
if (ret < 0)
return ret;
Expand Down

0 comments on commit 2310e3b

Please sign in to comment.