aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/regulator')
-rw-r--r--drivers/regulator/tps6507x-regulator.c31
1 files changed, 5 insertions, 26 deletions
diff --git a/drivers/regulator/tps6507x-regulator.c b/drivers/regulator/tps6507x-regulator.c
index e140a152f5f8..832833fe8aad 100644
--- a/drivers/regulator/tps6507x-regulator.c
+++ b/drivers/regulator/tps6507x-regulator.c
@@ -328,12 +328,11 @@ static int tps6507x_pmic_get_voltage(struct regulator_dev *dev)
328 return tps->info[rid]->table[data] * 1000; 328 return tps->info[rid]->table[data] * 1000;
329} 329}
330 330
331static int tps6507x_pmic_set_voltage(struct regulator_dev *dev, 331static int tps6507x_pmic_set_voltage_sel(struct regulator_dev *dev,
332 int min_uV, int max_uV, 332 unsigned selector)
333 unsigned *selector)
334{ 333{
335 struct tps6507x_pmic *tps = rdev_get_drvdata(dev); 334 struct tps6507x_pmic *tps = rdev_get_drvdata(dev);
336 int data, vsel, rid = rdev_get_id(dev); 335 int data, rid = rdev_get_id(dev);
337 u8 reg, mask; 336 u8 reg, mask;
338 337
339 switch (rid) { 338 switch (rid) {
@@ -367,32 +366,12 @@ static int tps6507x_pmic_set_voltage(struct regulator_dev *dev,
367 return -EINVAL; 366 return -EINVAL;
368 } 367 }
369 368
370 if (min_uV < tps->info[rid]->min_uV || min_uV > tps->info[rid]->max_uV)
371 return -EINVAL;
372 if (max_uV < tps->info[rid]->min_uV || max_uV > tps->info[rid]->max_uV)
373 return -EINVAL;
374
375 for (vsel = 0; vsel < tps->info[rid]->table_len; vsel++) {
376 int mV = tps->info[rid]->table[vsel];
377 int uV = mV * 1000;
378
379 /* Break at the first in-range value */
380 if (min_uV <= uV && uV <= max_uV)
381 break;
382 }
383
384 /* write to the register in case we found a match */
385 if (vsel == tps->info[rid]->table_len)
386 return -EINVAL;
387
388 *selector = vsel;
389
390 data = tps6507x_pmic_reg_read(tps, reg); 369 data = tps6507x_pmic_reg_read(tps, reg);
391 if (data < 0) 370 if (data < 0)
392 return data; 371 return data;
393 372
394 data &= ~mask; 373 data &= ~mask;
395 data |= vsel; 374 data |= selector;
396 375
397 return tps6507x_pmic_reg_write(tps, reg, data); 376 return tps6507x_pmic_reg_write(tps, reg, data);
398} 377}
@@ -417,7 +396,7 @@ static struct regulator_ops tps6507x_pmic_ops = {
417 .enable = tps6507x_pmic_enable, 396 .enable = tps6507x_pmic_enable,
418 .disable = tps6507x_pmic_disable, 397 .disable = tps6507x_pmic_disable,
419 .get_voltage = tps6507x_pmic_get_voltage, 398 .get_voltage = tps6507x_pmic_get_voltage,
420 .set_voltage = tps6507x_pmic_set_voltage, 399 .set_voltage_sel = tps6507x_pmic_set_voltage_sel,
421 .list_voltage = tps6507x_pmic_list_voltage, 400 .list_voltage = tps6507x_pmic_list_voltage,
422}; 401};
423 402