Commit 15b397d7 authored by Axel Lin's avatar Axel Lin Committed by Mark Brown

regulator: rc5t583: Use regulator_get_voltage_sel_regmap()

Signed-off-by: default avatarAxel Lin <axel.lin@gmail.com>
Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
parent 09812bc4
...@@ -39,8 +39,6 @@ struct rc5t583_regulator_info { ...@@ -39,8 +39,6 @@ struct rc5t583_regulator_info {
/* Regulator register address.*/ /* Regulator register address.*/
uint8_t reg_disc_reg; uint8_t reg_disc_reg;
uint8_t disc_bit; uint8_t disc_bit;
uint8_t vout_reg;
uint8_t vout_mask;
uint8_t deepsleep_reg; uint8_t deepsleep_reg;
/* Chip constraints on regulator behavior */ /* Chip constraints on regulator behavior */
...@@ -91,33 +89,20 @@ static int rc5t583_set_voltage(struct regulator_dev *rdev, ...@@ -91,33 +89,20 @@ static int rc5t583_set_voltage(struct regulator_dev *rdev,
*selector = sel; *selector = sel;
ret = rc5t583_update(reg->mfd->dev, ri->vout_reg, sel, ri->vout_mask); ret = rc5t583_update(reg->mfd->dev, rdev->desc->vsel_reg, sel,
rdev->desc->vsel_mask);
if (ret < 0) if (ret < 0)
dev_err(&rdev->dev, dev_err(&rdev->dev, "Error in update voltage register 0x%02x\n",
"Error in update voltage register 0x%02x\n", ri->vout_reg); rdev->desc->vsel_reg);
return ret; return ret;
} }
static int rc5t583_get_voltage_sel(struct regulator_dev *rdev)
{
struct rc5t583_regulator *reg = rdev_get_drvdata(rdev);
struct rc5t583_regulator_info *ri = reg->reg_info;
uint8_t vsel;
int ret;
ret = rc5t583_read(reg->mfd->dev, ri->vout_reg, &vsel);
if (ret < 0) {
dev_err(&rdev->dev,
"Error in reading voltage register 0x%02x\n", ri->vout_reg);
return ret;
}
return vsel & ri->vout_mask;
}
static int rc5t583_regulator_enable_time(struct regulator_dev *rdev) static int rc5t583_regulator_enable_time(struct regulator_dev *rdev)
{ {
struct rc5t583_regulator *reg = rdev_get_drvdata(rdev); struct rc5t583_regulator *reg = rdev_get_drvdata(rdev);
int vsel = rc5t583_get_voltage_sel(rdev); int vsel = regulator_get_voltage_sel_regmap(rdev);
int curr_uV = rc5t583_list_voltage(rdev, vsel); int curr_uV = rc5t583_list_voltage(rdev, vsel);
return DIV_ROUND_UP(curr_uV, reg->reg_info->enable_uv_per_us); return DIV_ROUND_UP(curr_uV, reg->reg_info->enable_uv_per_us);
} }
...@@ -145,7 +130,7 @@ static struct regulator_ops rc5t583_ops = { ...@@ -145,7 +130,7 @@ static struct regulator_ops rc5t583_ops = {
.enable = regulator_enable_regmap, .enable = regulator_enable_regmap,
.disable = regulator_disable_regmap, .disable = regulator_disable_regmap,
.enable_time = rc5t583_regulator_enable_time, .enable_time = rc5t583_regulator_enable_time,
.get_voltage_sel = rc5t583_get_voltage_sel, .get_voltage_sel = regulator_get_voltage_sel_regmap,
.set_voltage = rc5t583_set_voltage, .set_voltage = rc5t583_set_voltage,
.list_voltage = rc5t583_list_voltage, .list_voltage = rc5t583_list_voltage,
.set_voltage_time_sel = rc5t583_set_voltage_time_sel, .set_voltage_time_sel = rc5t583_set_voltage_time_sel,
...@@ -156,8 +141,6 @@ static struct regulator_ops rc5t583_ops = { ...@@ -156,8 +141,6 @@ static struct regulator_ops rc5t583_ops = {
{ \ { \
.reg_disc_reg = RC5T583_REG_##_disc_reg, \ .reg_disc_reg = RC5T583_REG_##_disc_reg, \
.disc_bit = _disc_bit, \ .disc_bit = _disc_bit, \
.vout_reg = RC5T583_REG_##_id##DAC, \
.vout_mask = _vout_mask, \
.deepsleep_reg = RC5T583_REG_##_id##DAC_DS, \ .deepsleep_reg = RC5T583_REG_##_id##DAC_DS, \
.min_uV = _min_mv * 1000, \ .min_uV = _min_mv * 1000, \
.max_uV = _max_mv * 1000, \ .max_uV = _max_mv * 1000, \
...@@ -172,6 +155,8 @@ static struct regulator_ops rc5t583_ops = { ...@@ -172,6 +155,8 @@ static struct regulator_ops rc5t583_ops = {
.ops = &rc5t583_ops, \ .ops = &rc5t583_ops, \
.type = REGULATOR_VOLTAGE, \ .type = REGULATOR_VOLTAGE, \
.owner = THIS_MODULE, \ .owner = THIS_MODULE, \
.vsel_reg = RC5T583_REG_##_id##DAC, \
.vsel_mask = _vout_mask, \
.enable_reg = RC5T583_REG_##_en_reg, \ .enable_reg = RC5T583_REG_##_en_reg, \
.enable_mask = BIT(_en_bit), \ .enable_mask = BIT(_en_bit), \
}, \ }, \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment