aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator/anatop-regulator.c
diff options
context:
space:
mode:
authorAxel Lin <axel.lin@gmail.com>2012-06-03 11:02:34 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-06-11 00:01:41 -0400
commitd01c3a1e1b1e4e417202adf1e9dec0730eb00e2b (patch)
tree0cbc0450154244b2c4df90cedcf3a7c1bf8503fb /drivers/regulator/anatop-regulator.c
parentea7e33045458ffd6d13175031527b6527807633c (diff)
regulator: anatop: Convert to set_voltage_sel and regulator_map_voltage_linear
Signed-off-by: Axel Lin <axel.lin@gmail.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/regulator/anatop-regulator.c')
-rw-r--r--drivers/regulator/anatop-regulator.c29
1 files changed, 6 insertions, 23 deletions
diff --git a/drivers/regulator/anatop-regulator.c b/drivers/regulator/anatop-regulator.c
index d04cf2113245..4324cea01141 100644
--- a/drivers/regulator/anatop-regulator.c
+++ b/drivers/regulator/anatop-regulator.c
@@ -43,33 +43,15 @@ struct anatop_regulator {
43 struct regulator_init_data *initdata; 43 struct regulator_init_data *initdata;
44}; 44};
45 45
46static int anatop_set_voltage(struct regulator_dev *reg, int min_uV, 46static int anatop_set_voltage_sel(struct regulator_dev *reg, unsigned selector)
47 int max_uV, unsigned *selector)
48{ 47{
49 struct anatop_regulator *anatop_reg = rdev_get_drvdata(reg); 48 struct anatop_regulator *anatop_reg = rdev_get_drvdata(reg);
50 u32 val, sel, mask; 49 u32 val, mask;
51 int uv;
52
53 uv = min_uV;
54 dev_dbg(&reg->dev, "%s: uv %d, min %d, max %d\n", __func__,
55 uv, anatop_reg->min_voltage,
56 anatop_reg->max_voltage);
57
58 if (uv < anatop_reg->min_voltage) {
59 if (max_uV > anatop_reg->min_voltage)
60 uv = anatop_reg->min_voltage;
61 else
62 return -EINVAL;
63 }
64 50
65 if (!anatop_reg->control_reg) 51 if (!anatop_reg->control_reg)
66 return -ENOTSUPP; 52 return -ENOTSUPP;
67 53
68 sel = DIV_ROUND_UP(uv - anatop_reg->min_voltage, 25000); 54 val = anatop_reg->min_bit_val + selector;
69 if (sel * 25000 + anatop_reg->min_voltage > anatop_reg->max_voltage)
70 return -EINVAL;
71 val = anatop_reg->min_bit_val + sel;
72 *selector = sel;
73 dev_dbg(&reg->dev, "%s: calculated val %d\n", __func__, val); 55 dev_dbg(&reg->dev, "%s: calculated val %d\n", __func__, val);
74 mask = ((1 << anatop_reg->vol_bit_width) - 1) << 56 mask = ((1 << anatop_reg->vol_bit_width) - 1) <<
75 anatop_reg->vol_bit_shift; 57 anatop_reg->vol_bit_shift;
@@ -95,9 +77,10 @@ static int anatop_get_voltage_sel(struct regulator_dev *reg)
95} 77}
96 78
97static struct regulator_ops anatop_rops = { 79static struct regulator_ops anatop_rops = {
98 .set_voltage = anatop_set_voltage, 80 .set_voltage_sel = anatop_set_voltage_sel,
99 .get_voltage_sel = anatop_get_voltage_sel, 81 .get_voltage_sel = anatop_get_voltage_sel,
100 .list_voltage = regulator_list_voltage_linear, 82 .list_voltage = regulator_list_voltage_linear,
83 .map_voltage = regulator_map_voltage_linear,
101}; 84};
102 85
103static int __devinit anatop_regulator_probe(struct platform_device *pdev) 86static int __devinit anatop_regulator_probe(struct platform_device *pdev)