Commit d01c3a1e authored by Axel Lin's avatar Axel Lin Committed by Mark Brown

regulator: anatop: Convert to set_voltage_sel and regulator_map_voltage_linear

Signed-off-by: default avatarAxel Lin <axel.lin@gmail.com>
Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
parent ea7e3304
...@@ -43,33 +43,15 @@ struct anatop_regulator { ...@@ -43,33 +43,15 @@ struct anatop_regulator {
struct regulator_init_data *initdata; struct regulator_init_data *initdata;
}; };
static int anatop_set_voltage(struct regulator_dev *reg, int min_uV, static int anatop_set_voltage_sel(struct regulator_dev *reg, unsigned selector)
int max_uV, unsigned *selector)
{ {
struct anatop_regulator *anatop_reg = rdev_get_drvdata(reg); struct anatop_regulator *anatop_reg = rdev_get_drvdata(reg);
u32 val, sel, mask; u32 val, mask;
int uv;
uv = min_uV;
dev_dbg(&reg->dev, "%s: uv %d, min %d, max %d\n", __func__,
uv, anatop_reg->min_voltage,
anatop_reg->max_voltage);
if (uv < anatop_reg->min_voltage) {
if (max_uV > anatop_reg->min_voltage)
uv = anatop_reg->min_voltage;
else
return -EINVAL;
}
if (!anatop_reg->control_reg) if (!anatop_reg->control_reg)
return -ENOTSUPP; return -ENOTSUPP;
sel = DIV_ROUND_UP(uv - anatop_reg->min_voltage, 25000); val = anatop_reg->min_bit_val + selector;
if (sel * 25000 + anatop_reg->min_voltage > anatop_reg->max_voltage)
return -EINVAL;
val = anatop_reg->min_bit_val + sel;
*selector = sel;
dev_dbg(&reg->dev, "%s: calculated val %d\n", __func__, val); dev_dbg(&reg->dev, "%s: calculated val %d\n", __func__, val);
mask = ((1 << anatop_reg->vol_bit_width) - 1) << mask = ((1 << anatop_reg->vol_bit_width) - 1) <<
anatop_reg->vol_bit_shift; anatop_reg->vol_bit_shift;
...@@ -95,9 +77,10 @@ static int anatop_get_voltage_sel(struct regulator_dev *reg) ...@@ -95,9 +77,10 @@ static int anatop_get_voltage_sel(struct regulator_dev *reg)
} }
static struct regulator_ops anatop_rops = { static struct regulator_ops anatop_rops = {
.set_voltage = anatop_set_voltage, .set_voltage_sel = anatop_set_voltage_sel,
.get_voltage_sel = anatop_get_voltage_sel, .get_voltage_sel = anatop_get_voltage_sel,
.list_voltage = regulator_list_voltage_linear, .list_voltage = regulator_list_voltage_linear,
.map_voltage = regulator_map_voltage_linear,
}; };
static int __devinit anatop_regulator_probe(struct platform_device *pdev) static int __devinit anatop_regulator_probe(struct platform_device *pdev)
......
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