diff options
Diffstat (limited to 'drivers/regulator/palmas-regulator.c')
-rw-r--r-- | drivers/regulator/palmas-regulator.c | 87 |
1 files changed, 26 insertions, 61 deletions
diff --git a/drivers/regulator/palmas-regulator.c b/drivers/regulator/palmas-regulator.c index 151c0c46ac01..f4142b4c971b 100644 --- a/drivers/regulator/palmas-regulator.c +++ b/drivers/regulator/palmas-regulator.c | |||
@@ -327,42 +327,6 @@ static int palmas_list_voltage_smps(struct regulator_dev *dev, | |||
327 | return (490000 + ((selector - 5) * 10000)) * mult; | 327 | return (490000 + ((selector - 5) * 10000)) * mult; |
328 | } | 328 | } |
329 | 329 | ||
330 | static int palmas_get_voltage_smps_sel(struct regulator_dev *dev) | ||
331 | { | ||
332 | struct palmas_pmic *pmic = rdev_get_drvdata(dev); | ||
333 | int id = rdev_get_id(dev); | ||
334 | int selector; | ||
335 | unsigned int reg; | ||
336 | unsigned int addr; | ||
337 | |||
338 | addr = palmas_regs_info[id].vsel_addr; | ||
339 | |||
340 | palmas_smps_read(pmic->palmas, addr, ®); | ||
341 | |||
342 | selector = reg & PALMAS_SMPS12_VOLTAGE_VSEL_MASK; | ||
343 | |||
344 | return selector; | ||
345 | } | ||
346 | |||
347 | static int palmas_set_voltage_smps_sel(struct regulator_dev *dev, | ||
348 | unsigned selector) | ||
349 | { | ||
350 | struct palmas_pmic *pmic = rdev_get_drvdata(dev); | ||
351 | int id = rdev_get_id(dev); | ||
352 | unsigned int reg, addr; | ||
353 | |||
354 | addr = palmas_regs_info[id].vsel_addr; | ||
355 | reg = selector; | ||
356 | |||
357 | /* Make sure we don't change the value of RANGE */ | ||
358 | if (pmic->range[id]) | ||
359 | reg |= PALMAS_SMPS12_VOLTAGE_RANGE; | ||
360 | |||
361 | palmas_smps_write(pmic->palmas, addr, reg); | ||
362 | |||
363 | return 0; | ||
364 | } | ||
365 | |||
366 | static int palmas_map_voltage_smps(struct regulator_dev *rdev, | 330 | static int palmas_map_voltage_smps(struct regulator_dev *rdev, |
367 | int min_uV, int max_uV) | 331 | int min_uV, int max_uV) |
368 | { | 332 | { |
@@ -397,8 +361,8 @@ static struct regulator_ops palmas_ops_smps = { | |||
397 | .disable = palmas_disable_smps, | 361 | .disable = palmas_disable_smps, |
398 | .set_mode = palmas_set_mode_smps, | 362 | .set_mode = palmas_set_mode_smps, |
399 | .get_mode = palmas_get_mode_smps, | 363 | .get_mode = palmas_get_mode_smps, |
400 | .get_voltage_sel = palmas_get_voltage_smps_sel, | 364 | .get_voltage_sel = regulator_get_voltage_sel_regmap, |
401 | .set_voltage_sel = palmas_set_voltage_smps_sel, | 365 | .set_voltage_sel = regulator_set_voltage_sel_regmap, |
402 | .list_voltage = palmas_list_voltage_smps, | 366 | .list_voltage = palmas_list_voltage_smps, |
403 | .map_voltage = palmas_map_voltage_smps, | 367 | .map_voltage = palmas_map_voltage_smps, |
404 | }; | 368 | }; |
@@ -723,6 +687,14 @@ static __devinit int palmas_probe(struct platform_device *pdev) | |||
723 | continue; | 687 | continue; |
724 | } | 688 | } |
725 | 689 | ||
690 | /* Initialise sleep/init values from platform data */ | ||
691 | if (pdata && pdata->reg_init[id]) { | ||
692 | reg_init = pdata->reg_init[id]; | ||
693 | ret = palmas_smps_init(palmas, id, reg_init); | ||
694 | if (ret) | ||
695 | goto err_unregister_regulator; | ||
696 | } | ||
697 | |||
726 | /* Register the regulators */ | 698 | /* Register the regulators */ |
727 | pmic->desc[id].name = palmas_regs_info[id].name; | 699 | pmic->desc[id].name = palmas_regs_info[id].name; |
728 | pmic->desc[id].id = id; | 700 | pmic->desc[id].id = id; |
@@ -743,29 +715,11 @@ static __devinit int palmas_probe(struct platform_device *pdev) | |||
743 | pmic->desc[id].uV_step = 1250000; | 715 | pmic->desc[id].uV_step = 1250000; |
744 | break; | 716 | break; |
745 | default: | 717 | default: |
746 | pmic->desc[id].ops = &palmas_ops_smps; | 718 | /* |
747 | pmic->desc[id].n_voltages = PALMAS_SMPS_NUM_VOLTAGES; | 719 | * Read and store the RANGE bit for later use |
748 | } | 720 | * This must be done before regulator is probed, |
749 | 721 | * otherwise we error in probe with unsupportable ranges. | |
750 | pmic->desc[id].type = REGULATOR_VOLTAGE; | 722 | */ |
751 | pmic->desc[id].owner = THIS_MODULE; | ||
752 | |||
753 | /* Initialise sleep/init values from platform data */ | ||
754 | if (pdata) { | ||
755 | reg_init = pdata->reg_init[id]; | ||
756 | if (reg_init) { | ||
757 | ret = palmas_smps_init(palmas, id, reg_init); | ||
758 | if (ret) | ||
759 | goto err_unregister_regulator; | ||
760 | } | ||
761 | } | ||
762 | |||
763 | /* | ||
764 | * read and store the RANGE bit for later use | ||
765 | * This must be done before regulator is probed otherwise | ||
766 | * we error in probe with unsuportable ranges. | ||
767 | */ | ||
768 | if (id != PALMAS_REG_SMPS10) { | ||
769 | addr = palmas_regs_info[id].vsel_addr; | 723 | addr = palmas_regs_info[id].vsel_addr; |
770 | 724 | ||
771 | ret = palmas_smps_read(pmic->palmas, addr, ®); | 725 | ret = palmas_smps_read(pmic->palmas, addr, ®); |
@@ -773,8 +727,19 @@ static __devinit int palmas_probe(struct platform_device *pdev) | |||
773 | goto err_unregister_regulator; | 727 | goto err_unregister_regulator; |
774 | if (reg & PALMAS_SMPS12_VOLTAGE_RANGE) | 728 | if (reg & PALMAS_SMPS12_VOLTAGE_RANGE) |
775 | pmic->range[id] = 1; | 729 | pmic->range[id] = 1; |
730 | |||
731 | pmic->desc[id].ops = &palmas_ops_smps; | ||
732 | pmic->desc[id].n_voltages = PALMAS_SMPS_NUM_VOLTAGES; | ||
733 | pmic->desc[id].vsel_reg = | ||
734 | PALMAS_BASE_TO_REG(PALMAS_SMPS_BASE, | ||
735 | palmas_regs_info[id].vsel_addr); | ||
736 | pmic->desc[id].vsel_mask = | ||
737 | PALMAS_SMPS12_VOLTAGE_VSEL_MASK; | ||
776 | } | 738 | } |
777 | 739 | ||
740 | pmic->desc[id].type = REGULATOR_VOLTAGE; | ||
741 | pmic->desc[id].owner = THIS_MODULE; | ||
742 | |||
778 | if (pdata) | 743 | if (pdata) |
779 | config.init_data = pdata->reg_data[id]; | 744 | config.init_data = pdata->reg_data[id]; |
780 | else | 745 | else |