diff options
author | Axel Lin <axel.lin@gmail.com> | 2012-05-13 23:27:25 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-05-14 04:12:00 -0400 |
commit | 41097afd64108348a935c658c78662bce1ea6355 (patch) | |
tree | 2a24cc7c2bb22d6d1578f1cef772243a3f041f79 /drivers/regulator/tps62360-regulator.c | |
parent | 7f225ba5850886b9834f3473c6e584a94c5fc53b (diff) |
regulator: tps62360: Convert to set_voltage_sel and regulator_map_voltage_linear
Signed-off-by: Axel Lin <axel.lin@gmail.com>
Acked-by: Laxman Dewangan <ldewangan@nvidia.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/regulator/tps62360-regulator.c')
-rw-r--r-- | drivers/regulator/tps62360-regulator.c | 24 |
1 files changed, 7 insertions, 17 deletions
diff --git a/drivers/regulator/tps62360-regulator.c b/drivers/regulator/tps62360-regulator.c index dae08a8c6c79..926c0e89a55a 100644 --- a/drivers/regulator/tps62360-regulator.c +++ b/drivers/regulator/tps62360-regulator.c | |||
@@ -137,35 +137,24 @@ static int tps62360_dcdc_get_voltage_sel(struct regulator_dev *dev) | |||
137 | return vsel; | 137 | return vsel; |
138 | } | 138 | } |
139 | 139 | ||
140 | static int tps62360_dcdc_set_voltage(struct regulator_dev *dev, | 140 | static int tps62360_dcdc_set_voltage_sel(struct regulator_dev *dev, |
141 | int min_uV, int max_uV, unsigned *selector) | 141 | unsigned selector) |
142 | { | 142 | { |
143 | struct tps62360_chip *tps = rdev_get_drvdata(dev); | 143 | struct tps62360_chip *tps = rdev_get_drvdata(dev); |
144 | int vsel; | ||
145 | int ret; | 144 | int ret; |
146 | bool found = false; | 145 | bool found = false; |
147 | int new_vset_id = tps->curr_vset_id; | 146 | int new_vset_id = tps->curr_vset_id; |
148 | 147 | ||
149 | if ((max_uV < min_uV) || (max_uV < tps->voltage_base)) | ||
150 | return -EINVAL; | ||
151 | |||
152 | if (min_uV > (tps->voltage_base + (tps->desc.n_voltages - 1) * 10000)) | ||
153 | return -EINVAL; | ||
154 | |||
155 | vsel = DIV_ROUND_UP(min_uV - tps->voltage_base, 10000); | ||
156 | if (selector) | ||
157 | *selector = (vsel & tps->voltage_reg_mask); | ||
158 | |||
159 | /* | 148 | /* |
160 | * If gpios are available to select the VSET register then least | 149 | * If gpios are available to select the VSET register then least |
161 | * recently used register for new configuration. | 150 | * recently used register for new configuration. |
162 | */ | 151 | */ |
163 | if (tps->valid_gpios) | 152 | if (tps->valid_gpios) |
164 | found = find_voltage_set_register(tps, vsel, &new_vset_id); | 153 | found = find_voltage_set_register(tps, selector, &new_vset_id); |
165 | 154 | ||
166 | if (!found) { | 155 | if (!found) { |
167 | ret = regmap_update_bits(tps->regmap, REG_VSET0 + new_vset_id, | 156 | ret = regmap_update_bits(tps->regmap, REG_VSET0 + new_vset_id, |
168 | tps->voltage_reg_mask, vsel); | 157 | tps->voltage_reg_mask, selector); |
169 | if (ret < 0) { | 158 | if (ret < 0) { |
170 | dev_err(tps->dev, | 159 | dev_err(tps->dev, |
171 | "%s(): register %d update failed with err %d\n", | 160 | "%s(): register %d update failed with err %d\n", |
@@ -173,7 +162,7 @@ static int tps62360_dcdc_set_voltage(struct regulator_dev *dev, | |||
173 | return ret; | 162 | return ret; |
174 | } | 163 | } |
175 | tps->curr_vset_id = new_vset_id; | 164 | tps->curr_vset_id = new_vset_id; |
176 | tps->curr_vset_vsel[new_vset_id] = vsel; | 165 | tps->curr_vset_vsel[new_vset_id] = selector; |
177 | } | 166 | } |
178 | 167 | ||
179 | /* Select proper VSET register vio gpios */ | 168 | /* Select proper VSET register vio gpios */ |
@@ -204,8 +193,9 @@ static int tps62360_set_voltage_time_sel(struct regulator_dev *rdev, | |||
204 | 193 | ||
205 | static struct regulator_ops tps62360_dcdc_ops = { | 194 | static struct regulator_ops tps62360_dcdc_ops = { |
206 | .get_voltage_sel = tps62360_dcdc_get_voltage_sel, | 195 | .get_voltage_sel = tps62360_dcdc_get_voltage_sel, |
207 | .set_voltage = tps62360_dcdc_set_voltage, | 196 | .set_voltage_sel = tps62360_dcdc_set_voltage_sel, |
208 | .list_voltage = regulator_list_voltage_linear, | 197 | .list_voltage = regulator_list_voltage_linear, |
198 | .map_voltage = regulator_map_voltage_linear, | ||
209 | .set_voltage_time_sel = tps62360_set_voltage_time_sel, | 199 | .set_voltage_time_sel = tps62360_set_voltage_time_sel, |
210 | }; | 200 | }; |
211 | 201 | ||