diff options
author | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-12-09 22:43:00 -0500 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-12-09 22:43:00 -0500 |
commit | adca48f7c61c53708a1f1ed567e0447ccb2b3b96 (patch) | |
tree | d1860df280202eb86a625bd3400eab02b819100a /drivers/regulator/anatop-regulator.c | |
parent | 9e218670737e01ef37bd1ac400482462049dfeff (diff) | |
parent | e1b0144f9997d3d52c46785143699d82dd525f1d (diff) |
Merge remote-tracking branch 'regulator/topic/min' into regulator-next
Diffstat (limited to 'drivers/regulator/anatop-regulator.c')
-rw-r--r-- | drivers/regulator/anatop-regulator.c | 28 |
1 files changed, 9 insertions, 19 deletions
diff --git a/drivers/regulator/anatop-regulator.c b/drivers/regulator/anatop-regulator.c index 1aa5246c79d9..0199eeea63b1 100644 --- a/drivers/regulator/anatop-regulator.c +++ b/drivers/regulator/anatop-regulator.c | |||
@@ -48,36 +48,21 @@ static int anatop_regmap_set_voltage_sel(struct regulator_dev *reg, | |||
48 | unsigned selector) | 48 | unsigned selector) |
49 | { | 49 | { |
50 | struct anatop_regulator *anatop_reg = rdev_get_drvdata(reg); | 50 | struct anatop_regulator *anatop_reg = rdev_get_drvdata(reg); |
51 | u32 val, mask; | ||
52 | 51 | ||
53 | if (!anatop_reg->control_reg) | 52 | if (!anatop_reg->control_reg) |
54 | return -ENOTSUPP; | 53 | return -ENOTSUPP; |
55 | 54 | ||
56 | val = anatop_reg->min_bit_val + selector; | 55 | return regulator_set_voltage_sel_regmap(reg, selector); |
57 | dev_dbg(®->dev, "%s: calculated val %d\n", __func__, val); | ||
58 | mask = ((1 << anatop_reg->vol_bit_width) - 1) << | ||
59 | anatop_reg->vol_bit_shift; | ||
60 | val <<= anatop_reg->vol_bit_shift; | ||
61 | regmap_update_bits(anatop_reg->anatop, anatop_reg->control_reg, | ||
62 | mask, val); | ||
63 | |||
64 | return 0; | ||
65 | } | 56 | } |
66 | 57 | ||
67 | static int anatop_regmap_get_voltage_sel(struct regulator_dev *reg) | 58 | static int anatop_regmap_get_voltage_sel(struct regulator_dev *reg) |
68 | { | 59 | { |
69 | struct anatop_regulator *anatop_reg = rdev_get_drvdata(reg); | 60 | struct anatop_regulator *anatop_reg = rdev_get_drvdata(reg); |
70 | u32 val, mask; | ||
71 | 61 | ||
72 | if (!anatop_reg->control_reg) | 62 | if (!anatop_reg->control_reg) |
73 | return -ENOTSUPP; | 63 | return -ENOTSUPP; |
74 | 64 | ||
75 | regmap_read(anatop_reg->anatop, anatop_reg->control_reg, &val); | 65 | return regulator_get_voltage_sel_regmap(reg); |
76 | mask = ((1 << anatop_reg->vol_bit_width) - 1) << | ||
77 | anatop_reg->vol_bit_shift; | ||
78 | val = (val & mask) >> anatop_reg->vol_bit_shift; | ||
79 | |||
80 | return val - anatop_reg->min_bit_val; | ||
81 | } | 66 | } |
82 | 67 | ||
83 | static struct regulator_ops anatop_rops = { | 68 | static struct regulator_ops anatop_rops = { |
@@ -158,15 +143,20 @@ static int anatop_regulator_probe(struct platform_device *pdev) | |||
158 | goto anatop_probe_end; | 143 | goto anatop_probe_end; |
159 | } | 144 | } |
160 | 145 | ||
161 | rdesc->n_voltages = (sreg->max_voltage - sreg->min_voltage) | 146 | rdesc->n_voltages = (sreg->max_voltage - sreg->min_voltage) / 25000 + 1 |
162 | / 25000 + 1; | 147 | + sreg->min_bit_val; |
163 | rdesc->min_uV = sreg->min_voltage; | 148 | rdesc->min_uV = sreg->min_voltage; |
164 | rdesc->uV_step = 25000; | 149 | rdesc->uV_step = 25000; |
150 | rdesc->linear_min_sel = sreg->min_bit_val; | ||
151 | rdesc->vsel_reg = sreg->control_reg; | ||
152 | rdesc->vsel_mask = ((1 << sreg->vol_bit_width) - 1) << | ||
153 | sreg->vol_bit_shift; | ||
165 | 154 | ||
166 | config.dev = &pdev->dev; | 155 | config.dev = &pdev->dev; |
167 | config.init_data = initdata; | 156 | config.init_data = initdata; |
168 | config.driver_data = sreg; | 157 | config.driver_data = sreg; |
169 | config.of_node = pdev->dev.of_node; | 158 | config.of_node = pdev->dev.of_node; |
159 | config.regmap = sreg->anatop; | ||
170 | 160 | ||
171 | /* register regulator */ | 161 | /* register regulator */ |
172 | rdev = regulator_register(rdesc, &config); | 162 | rdev = regulator_register(rdesc, &config); |