Commit 41097afd64108348a935c658c78662bce1ea6355

Authored by Axel Lin
Committed by Mark Brown
1 parent 7f225ba585

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>

Showing 1 changed file with 7 additions and 17 deletions Side-by-side Diff

drivers/regulator/tps62360-regulator.c
... ... @@ -137,35 +137,24 @@
137 137 return vsel;
138 138 }
139 139  
140   -static int tps62360_dcdc_set_voltage(struct regulator_dev *dev,
141   - int min_uV, int max_uV, unsigned *selector)
  140 +static int tps62360_dcdc_set_voltage_sel(struct regulator_dev *dev,
  141 + unsigned selector)
142 142 {
143 143 struct tps62360_chip *tps = rdev_get_drvdata(dev);
144   - int vsel;
145 144 int ret;
146 145 bool found = false;
147 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 149 * If gpios are available to select the VSET register then least
161 150 * recently used register for new configuration.
162 151 */
163 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 155 if (!found) {
167 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 158 if (ret < 0) {
170 159 dev_err(tps->dev,
171 160 "%s(): register %d update failed with err %d\n",
... ... @@ -173,7 +162,7 @@
173 162 return ret;
174 163 }
175 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 168 /* Select proper VSET register vio gpios */
180 169  
... ... @@ -204,8 +193,9 @@
204 193  
205 194 static struct regulator_ops tps62360_dcdc_ops = {
206 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 197 .list_voltage = regulator_list_voltage_linear,
  198 + .map_voltage = regulator_map_voltage_linear,
209 199 .set_voltage_time_sel = tps62360_set_voltage_time_sel,
210 200 };
211 201