@@ -213,65 +213,56 @@ static int tps65217_pmic_get_voltage_sel(struct regulator_dev *dev)
213213 return selector ;
214214}
215215
216- static int tps65217_pmic_ldo1_set_voltage_sel (struct regulator_dev * dev ,
217- unsigned selector )
216+ static int tps65217_pmic_set_voltage_sel (struct regulator_dev * dev ,
217+ unsigned selector )
218218{
219+ int ret ;
219220 struct tps65217 * tps = rdev_get_drvdata (dev );
220- int ldo = rdev_get_id (dev );
221+ unsigned int rid = rdev_get_id (dev );
221222
222- if (ldo != TPS65217_LDO_1 )
223- return - EINVAL ;
223+ /* Set the voltage based on vsel value and write protect level is 2 */
224+ ret = tps65217_set_bits (tps , tps -> info [rid ]-> set_vout_reg ,
225+ tps -> info [rid ]-> set_vout_mask ,
226+ selector , TPS65217_PROTECT_L2 );
224227
225- if (selector >= tps -> info [ldo ]-> table_len )
226- return - EINVAL ;
228+ /* Set GO bit for DCDCx to initiate voltage transistion */
229+ switch (rid ) {
230+ case TPS65217_DCDC_1 ... TPS65217_DCDC_3 :
231+ ret = tps65217_set_bits (tps , TPS65217_REG_DEFSLEW ,
232+ TPS65217_DEFSLEW_GO , TPS65217_DEFSLEW_GO ,
233+ TPS65217_PROTECT_L2 );
234+ break ;
235+ }
227236
228- /* Set the voltage based on vsel value and write protect level is 2 */
229- return tps65217_set_bits (tps , tps -> info [ldo ]-> set_vout_reg ,
230- tps -> info [ldo ]-> set_vout_mask ,
231- selector , TPS65217_PROTECT_L2 );
237+ return ret ;
232238}
233239
234- static int tps65217_pmic_set_voltage (struct regulator_dev * dev ,
235- int min_uV , int max_uV , unsigned * selector )
240+ static int tps65217_pmic_map_voltage (struct regulator_dev * dev ,
241+ int min_uV , int max_uV )
236242{
237- int ret ;
243+
238244 struct tps65217 * tps = rdev_get_drvdata (dev );
239- unsigned int rid = rdev_get_id (dev );
245+ unsigned int sel , rid = rdev_get_id (dev );
246+ int ret ;
240247
241- /* LDO1 implements set_voltage_sel callback */
248+ /* LDO1 uses regulator_map_voltage_iterate() */
242249 if (rid == TPS65217_LDO_1 )
243250 return - EINVAL ;
244251
245252 if (rid < TPS65217_DCDC_1 || rid > TPS65217_LDO_4 )
246253 return - EINVAL ;
247254
248- if (min_uV < tps -> info [rid ]-> min_uV
249- || min_uV > tps -> info [rid ]-> max_uV )
255+ if (min_uV < tps -> info [rid ]-> min_uV || min_uV > tps -> info [rid ]-> max_uV )
250256 return - EINVAL ;
251257
252- if (max_uV < tps -> info [rid ]-> min_uV
253- || max_uV > tps -> info [rid ]-> max_uV )
258+ if (max_uV < tps -> info [rid ]-> min_uV || max_uV > tps -> info [rid ]-> max_uV )
254259 return - EINVAL ;
255260
256- ret = tps -> info [rid ]-> uv_to_vsel (min_uV , selector );
261+ ret = tps -> info [rid ]-> uv_to_vsel (min_uV , & sel );
257262 if (ret )
258263 return ret ;
259264
260- /* Set the voltage based on vsel value and write protect level is 2 */
261- ret = tps65217_set_bits (tps , tps -> info [rid ]-> set_vout_reg ,
262- tps -> info [rid ]-> set_vout_mask ,
263- * selector , TPS65217_PROTECT_L2 );
264-
265- /* Set GO bit for DCDCx to initiate voltage transistion */
266- switch (rid ) {
267- case TPS65217_DCDC_1 ... TPS65217_DCDC_3 :
268- ret = tps65217_set_bits (tps , TPS65217_REG_DEFSLEW ,
269- TPS65217_DEFSLEW_GO , TPS65217_DEFSLEW_GO ,
270- TPS65217_PROTECT_L2 );
271- break ;
272- }
273-
274- return ret ;
265+ return sel ;
275266}
276267
277268static int tps65217_pmic_list_voltage (struct regulator_dev * dev ,
@@ -298,8 +289,9 @@ static struct regulator_ops tps65217_pmic_ops = {
298289 .enable = tps65217_pmic_enable ,
299290 .disable = tps65217_pmic_disable ,
300291 .get_voltage_sel = tps65217_pmic_get_voltage_sel ,
301- .set_voltage = tps65217_pmic_set_voltage ,
292+ .set_voltage_sel = tps65217_pmic_set_voltage_sel ,
302293 .list_voltage = tps65217_pmic_list_voltage ,
294+ .map_voltage = tps65217_pmic_map_voltage ,
303295};
304296
305297/* Operations permitted on LDO1 */
@@ -308,7 +300,7 @@ static struct regulator_ops tps65217_pmic_ldo1_ops = {
308300 .enable = tps65217_pmic_enable ,
309301 .disable = tps65217_pmic_disable ,
310302 .get_voltage_sel = tps65217_pmic_get_voltage_sel ,
311- .set_voltage_sel = tps65217_pmic_ldo1_set_voltage_sel ,
303+ .set_voltage_sel = tps65217_pmic_set_voltage_sel ,
312304 .list_voltage = tps65217_pmic_list_voltage ,
313305};
314306
0 commit comments