提交 7f52ba77 编写于 作者: A Axel Lin 提交者: Mark Brown

regulator: Add missing n_voltages setting for max8925

The n_voltages are the same for all regulators: (max - min / step) + 1 == 64.
The vol_shift is always 0, and the vol_nbits is always the same as n_voltages
setting. Thus we can remove vol_shitf and vol_nbits fields from struct
max8925_regulator_info.
Signed-off-by: NAxel Lin <axel.lin@gmail.com>
Signed-off-by: NMark Brown <broonie@opensource.wolfsonmicro.com>
上级 42ff9431
...@@ -42,8 +42,6 @@ struct max8925_regulator_info { ...@@ -42,8 +42,6 @@ struct max8925_regulator_info {
int max_uV; int max_uV;
int step_uV; int step_uV;
int vol_reg; int vol_reg;
int vol_shift;
int vol_nbits;
int enable_reg; int enable_reg;
}; };
...@@ -75,8 +73,7 @@ static int max8925_set_voltage(struct regulator_dev *rdev, ...@@ -75,8 +73,7 @@ static int max8925_set_voltage(struct regulator_dev *rdev,
} }
data = DIV_ROUND_UP(min_uV - info->min_uV, info->step_uV); data = DIV_ROUND_UP(min_uV - info->min_uV, info->step_uV);
*selector = data; *selector = data;
data <<= info->vol_shift; mask = rdev->desc->n_voltages - 1;
mask = ((1 << info->vol_nbits) - 1) << info->vol_shift;
return max8925_set_bits(info->i2c, info->vol_reg, mask, data); return max8925_set_bits(info->i2c, info->vol_reg, mask, data);
} }
...@@ -90,8 +87,8 @@ static int max8925_get_voltage(struct regulator_dev *rdev) ...@@ -90,8 +87,8 @@ static int max8925_get_voltage(struct regulator_dev *rdev)
ret = max8925_reg_read(info->i2c, info->vol_reg); ret = max8925_reg_read(info->i2c, info->vol_reg);
if (ret < 0) if (ret < 0)
return ret; return ret;
mask = ((1 << info->vol_nbits) - 1) << info->vol_shift; mask = rdev->desc->n_voltages - 1;
data = (ret & mask) >> info->vol_shift; data = ret & mask;
return max8925_list_voltage(rdev, data); return max8925_list_voltage(rdev, data);
} }
...@@ -191,13 +188,12 @@ static struct regulator_ops max8925_regulator_ldo_ops = { ...@@ -191,13 +188,12 @@ static struct regulator_ops max8925_regulator_ldo_ops = {
.type = REGULATOR_VOLTAGE, \ .type = REGULATOR_VOLTAGE, \
.id = MAX8925_ID_SD##_id, \ .id = MAX8925_ID_SD##_id, \
.owner = THIS_MODULE, \ .owner = THIS_MODULE, \
.n_voltages = 64, \
}, \ }, \
.min_uV = min * 1000, \ .min_uV = min * 1000, \
.max_uV = max * 1000, \ .max_uV = max * 1000, \
.step_uV = step * 1000, \ .step_uV = step * 1000, \
.vol_reg = MAX8925_SDV##_id, \ .vol_reg = MAX8925_SDV##_id, \
.vol_shift = 0, \
.vol_nbits = 6, \
.enable_reg = MAX8925_SDCTL##_id, \ .enable_reg = MAX8925_SDCTL##_id, \
} }
...@@ -209,13 +205,12 @@ static struct regulator_ops max8925_regulator_ldo_ops = { ...@@ -209,13 +205,12 @@ static struct regulator_ops max8925_regulator_ldo_ops = {
.type = REGULATOR_VOLTAGE, \ .type = REGULATOR_VOLTAGE, \
.id = MAX8925_ID_LDO##_id, \ .id = MAX8925_ID_LDO##_id, \
.owner = THIS_MODULE, \ .owner = THIS_MODULE, \
.n_voltages = 64, \
}, \ }, \
.min_uV = min * 1000, \ .min_uV = min * 1000, \
.max_uV = max * 1000, \ .max_uV = max * 1000, \
.step_uV = step * 1000, \ .step_uV = step * 1000, \
.vol_reg = MAX8925_LDOVOUT##_id, \ .vol_reg = MAX8925_LDOVOUT##_id, \
.vol_shift = 0, \
.vol_nbits = 6, \
.enable_reg = MAX8925_LDOCTL##_id, \ .enable_reg = MAX8925_LDOCTL##_id, \
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册