diff options
Diffstat (limited to 'drivers/regulator/palmas-regulator.c')
-rw-r--r-- | drivers/regulator/palmas-regulator.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/drivers/regulator/palmas-regulator.c b/drivers/regulator/palmas-regulator.c index 7540c95321ce..17d19fbbc490 100644 --- a/drivers/regulator/palmas-regulator.c +++ b/drivers/regulator/palmas-regulator.c | |||
@@ -373,11 +373,22 @@ static int palmas_set_voltage_smps_sel(struct regulator_dev *dev, | |||
373 | static int palmas_map_voltage_smps(struct regulator_dev *rdev, | 373 | static int palmas_map_voltage_smps(struct regulator_dev *rdev, |
374 | int min_uV, int max_uV) | 374 | int min_uV, int max_uV) |
375 | { | 375 | { |
376 | struct palmas_pmic *pmic = rdev_get_drvdata(rdev); | ||
377 | int id = rdev_get_id(rdev); | ||
376 | int ret, voltage; | 378 | int ret, voltage; |
377 | 379 | ||
378 | ret = ((min_uV - 500000) / 10000) + 1; | 380 | if (min_uV == 0) |
379 | if (ret < 0) | 381 | return 0; |
380 | return ret; | 382 | |
383 | if (pmic->range[id]) { /* RANGE is x2 */ | ||
384 | if (min_uV < 1000000) | ||
385 | min_uV = 1000000; | ||
386 | ret = DIV_ROUND_UP(min_uV - 1000000, 20000) + 1; | ||
387 | } else { /* RANGE is x1 */ | ||
388 | if (min_uV < 500000) | ||
389 | min_uV = 500000; | ||
390 | ret = DIV_ROUND_UP(min_uV - 500000, 10000) + 1; | ||
391 | } | ||
381 | 392 | ||
382 | /* Map back into a voltage to verify we're still in bounds */ | 393 | /* Map back into a voltage to verify we're still in bounds */ |
383 | voltage = palmas_list_voltage_smps(rdev, ret); | 394 | voltage = palmas_list_voltage_smps(rdev, ret); |