curr);
}
-static int lp5521_configure(struct i2c_client *client)
+static int lp5521_post_init_device(struct lp55xx_chip *chip)
{
- struct lp5521_chip *chip = i2c_get_clientdata(client);
int ret;
- u8 cfg;
u8 val;
/*
* otherwise further access to the R G B channels in the
* LP5521_REG_ENABLE register will not have any effect - strange!
*/
- ret = lp5521_read(client, LP5521_REG_R_CURRENT, &val);
+ ret = lp55xx_read(chip, LP5521_REG_R_CURRENT, &val);
if (ret) {
- dev_err(&client->dev, "error in resetting chip\n");
+ dev_err(&chip->cl->dev, "error in resetting chip\n");
return ret;
}
if (val != LP5521_REG_R_CURR_DEFAULT) {
- dev_err(&client->dev,
+ dev_err(&chip->cl->dev,
"unexpected data in register (expected 0x%x got 0x%x)\n",
LP5521_REG_R_CURR_DEFAULT, val);
ret = -EINVAL;
usleep_range(10000, 20000);
/* Set all PWMs to direct control mode */
- ret = lp5521_write(client, LP5521_REG_OP_MODE, LP5521_CMD_DIRECT);
+ ret = lp55xx_write(chip, LP5521_REG_OP_MODE, LP5521_CMD_DIRECT);
- cfg = chip->pdata->update_config ?
+ val = chip->pdata->update_config ?
: (LP5521_PWRSAVE_EN | LP5521_CP_MODE_AUTO | LP5521_R_TO_BATT);
- ret = lp5521_write(client, LP5521_REG_CONFIG, cfg);
+ ret = lp55xx_write(chip, LP5521_REG_CONFIG, val);
if (ret)
return ret;
/* Initialize all channels PWM to zero -> leds off */
- lp5521_write(client, LP5521_REG_R_PWM, 0);
- lp5521_write(client, LP5521_REG_G_PWM, 0);
- lp5521_write(client, LP5521_REG_B_PWM, 0);
+ lp55xx_write(chip, LP5521_REG_R_PWM, 0);
+ lp55xx_write(chip, LP5521_REG_G_PWM, 0);
+ lp55xx_write(chip, LP5521_REG_B_PWM, 0);
/* Set engines are set to run state when OP_MODE enables engines */
- ret = lp5521_write(client, LP5521_REG_ENABLE,
- LP5521_ENABLE_RUN_PROGRAM);
+ ret = lp55xx_write(chip, LP5521_REG_ENABLE, LP5521_ENABLE_RUN_PROGRAM);
if (ret)
return ret;
static int lp5521_init_device(struct lp5521_chip *chip)
{
struct i2c_client *client = chip->client;
+ struct lp55xx_chip *temp;
int ret;
- ret = lp5521_configure(client);
+ ret = lp5521_post_init_device(temp);
if (ret < 0) {
dev_err(&client->dev, "error configuring chip\n");
goto err_config;
.addr = LP5521_REG_ENABLE,
.val = LP5521_ENABLE_DEFAULT,
},
+ .post_init_device = lp5521_post_init_device,
};
static int lp5521_probe(struct i2c_client *client,
return 0;
}
-static int lp5523_configure(struct i2c_client *client)
+static int lp5523_post_init_device(struct lp55xx_chip *chip)
{
- int ret = 0;
+ int ret;
- ret = lp5523_write(client, LP5523_REG_ENABLE, LP5523_ENABLE);
+ ret = lp55xx_write(chip, LP5523_REG_ENABLE, LP5523_ENABLE);
if (ret)
return ret;
/* Chip startup time is 500 us, 1 - 2 ms gives some margin */
usleep_range(1000, 2000);
- ret = lp5523_write(client, LP5523_REG_CONFIG,
+ ret = lp55xx_write(chip, LP5523_REG_CONFIG,
LP5523_AUTO_INC | LP5523_PWR_SAVE |
LP5523_CP_AUTO | LP5523_AUTO_CLK |
LP5523_PWM_PWR_SAVE);
return ret;
/* turn on all leds */
- ret = lp5523_write(client, LP5523_REG_ENABLE_LEDS_MSB, 0x01);
+ ret = lp55xx_write(chip, LP5523_REG_ENABLE_LEDS_MSB, 0x01);
if (ret)
return ret;
- return lp5523_write(client, LP5523_REG_ENABLE_LEDS_LSB, 0xff);
+ return lp55xx_write(chip, LP5523_REG_ENABLE_LEDS_LSB, 0xff);
}
static int lp5523_set_engine_mode(struct lp5523_engine *engine, u8 mode)
static int lp5523_init_device(struct lp5523_chip *chip)
{
struct i2c_client *client = chip->client;
+ struct lp55xx_chip *temp;
int ret;
- ret = lp5523_configure(client);
+ ret = lp5523_post_init_device(temp);
if (ret < 0) {
dev_err(&client->dev, "error configuring chip\n");
goto err_config;
.addr = LP5523_REG_ENABLE,
.val = LP5523_ENABLE,
},
+ .post_init_device = lp5523_post_init_device,
};
static int lp5523_probe(struct i2c_client *client,