aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2013-01-14 23:20:03 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2013-01-14 23:20:03 -0500
commit2ac1e664a963fb1047baabe1c04f3869a153889b (patch)
treef59d89914b3234cef03cbb4a8b78d062ab7f6e9c
parent3152ba0f86428cebe8a9f8462d5be0a9aefa6289 (diff)
parente3d5b2f5707b623c9bb5dbff1a02c8b0d48a44b4 (diff)
Merge tag 'regulator-3.8-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator
Pull regulator fixes from Mark Brown: "A few fixes for the regulator subsystems, a few driver specific things plus a fix for the interaction between regultor_can_change_voltage() and continuous voltage ranges both of which were added for this release." * tag 'regulator-3.8-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator: regulator: max8998: Ensure enough delay time for max8998_set_voltage_buck_time_sel regulator: max8998: Use uV in voltage_map_desc regulator: max8997: Use uV in voltage_map_desc regulator: core: Fix comment for regulator_register() regulator: core: Fix continuous_voltage_range case in regulator_can_change_voltage regulator: s5m8767: Fix probe failure due to stack corruption
-rw-r--r--drivers/regulator/core.c15
-rw-r--r--drivers/regulator/max8997.c36
-rw-r--r--drivers/regulator/max8998.c44
-rw-r--r--drivers/regulator/s5m8767.c4
4 files changed, 52 insertions, 47 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 0f65b246cc0..278584302f2 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1885,9 +1885,15 @@ int regulator_can_change_voltage(struct regulator *regulator)
1885 struct regulator_dev *rdev = regulator->rdev; 1885 struct regulator_dev *rdev = regulator->rdev;
1886 1886
1887 if (rdev->constraints && 1887 if (rdev->constraints &&
1888 rdev->constraints->valid_ops_mask & REGULATOR_CHANGE_VOLTAGE && 1888 (rdev->constraints->valid_ops_mask & REGULATOR_CHANGE_VOLTAGE)) {
1889 (rdev->desc->n_voltages - rdev->desc->linear_min_sel) > 1) 1889 if (rdev->desc->n_voltages - rdev->desc->linear_min_sel > 1)
1890 return 1; 1890 return 1;
1891
1892 if (rdev->desc->continuous_voltage_range &&
1893 rdev->constraints->min_uV && rdev->constraints->max_uV &&
1894 rdev->constraints->min_uV != rdev->constraints->max_uV)
1895 return 1;
1896 }
1891 1897
1892 return 0; 1898 return 0;
1893} 1899}
@@ -3315,7 +3321,8 @@ static void rdev_init_debugfs(struct regulator_dev *rdev)
3315 * @config: runtime configuration for regulator 3321 * @config: runtime configuration for regulator
3316 * 3322 *
3317 * Called by regulator drivers to register a regulator. 3323 * Called by regulator drivers to register a regulator.
3318 * Returns 0 on success. 3324 * Returns a valid pointer to struct regulator_dev on success
3325 * or an ERR_PTR() on error.
3319 */ 3326 */
3320struct regulator_dev * 3327struct regulator_dev *
3321regulator_register(const struct regulator_desc *regulator_desc, 3328regulator_register(const struct regulator_desc *regulator_desc,
diff --git a/drivers/regulator/max8997.c b/drivers/regulator/max8997.c
index df0eafb0dc7..02be7fcae32 100644
--- a/drivers/regulator/max8997.c
+++ b/drivers/regulator/max8997.c
@@ -71,26 +71,26 @@ struct voltage_map_desc {
71 int step; 71 int step;
72}; 72};
73 73
74/* Voltage maps in mV */ 74/* Voltage maps in uV */
75static const struct voltage_map_desc ldo_voltage_map_desc = { 75static const struct voltage_map_desc ldo_voltage_map_desc = {
76 .min = 800, .max = 3950, .step = 50, 76 .min = 800000, .max = 3950000, .step = 50000,
77}; /* LDO1 ~ 18, 21 all */ 77}; /* LDO1 ~ 18, 21 all */
78 78
79static const struct voltage_map_desc buck1245_voltage_map_desc = { 79static const struct voltage_map_desc buck1245_voltage_map_desc = {
80 .min = 650, .max = 2225, .step = 25, 80 .min = 650000, .max = 2225000, .step = 25000,
81}; /* Buck1, 2, 4, 5 */ 81}; /* Buck1, 2, 4, 5 */
82 82
83static const struct voltage_map_desc buck37_voltage_map_desc = { 83static const struct voltage_map_desc buck37_voltage_map_desc = {
84 .min = 750, .max = 3900, .step = 50, 84 .min = 750000, .max = 3900000, .step = 50000,
85}; /* Buck3, 7 */ 85}; /* Buck3, 7 */
86 86
87/* current map in mA */ 87/* current map in uA */
88static const struct voltage_map_desc charger_current_map_desc = { 88static const struct voltage_map_desc charger_current_map_desc = {
89 .min = 200, .max = 950, .step = 50, 89 .min = 200000, .max = 950000, .step = 50000,
90}; 90};
91 91
92static const struct voltage_map_desc topoff_current_map_desc = { 92static const struct voltage_map_desc topoff_current_map_desc = {
93 .min = 50, .max = 200, .step = 10, 93 .min = 50000, .max = 200000, .step = 10000,
94}; 94};
95 95
96static const struct voltage_map_desc *reg_voltage_map[] = { 96static const struct voltage_map_desc *reg_voltage_map[] = {
@@ -194,7 +194,7 @@ static int max8997_list_voltage(struct regulator_dev *rdev,
194 if (val > desc->max) 194 if (val > desc->max)
195 return -EINVAL; 195 return -EINVAL;
196 196
197 return val * 1000; 197 return val;
198} 198}
199 199
200static int max8997_get_enable_register(struct regulator_dev *rdev, 200static int max8997_get_enable_register(struct regulator_dev *rdev,
@@ -485,7 +485,6 @@ static int max8997_set_voltage_ldobuck(struct regulator_dev *rdev,
485{ 485{
486 struct max8997_data *max8997 = rdev_get_drvdata(rdev); 486 struct max8997_data *max8997 = rdev_get_drvdata(rdev);
487 struct i2c_client *i2c = max8997->iodev->i2c; 487 struct i2c_client *i2c = max8997->iodev->i2c;
488 int min_vol = min_uV / 1000, max_vol = max_uV / 1000;
489 const struct voltage_map_desc *desc; 488 const struct voltage_map_desc *desc;
490 int rid = rdev_get_id(rdev); 489 int rid = rdev_get_id(rdev);
491 int i, reg, shift, mask, ret; 490 int i, reg, shift, mask, ret;
@@ -509,7 +508,7 @@ static int max8997_set_voltage_ldobuck(struct regulator_dev *rdev,
509 508
510 desc = reg_voltage_map[rid]; 509 desc = reg_voltage_map[rid];
511 510
512 i = max8997_get_voltage_proper_val(desc, min_vol, max_vol); 511 i = max8997_get_voltage_proper_val(desc, min_uV, max_uV);
513 if (i < 0) 512 if (i < 0)
514 return i; 513 return i;
515 514
@@ -557,7 +556,7 @@ static int max8997_set_voltage_ldobuck_time_sel(struct regulator_dev *rdev,
557 case MAX8997_BUCK4: 556 case MAX8997_BUCK4:
558 case MAX8997_BUCK5: 557 case MAX8997_BUCK5:
559 return DIV_ROUND_UP(desc->step * (new_selector - old_selector), 558 return DIV_ROUND_UP(desc->step * (new_selector - old_selector),
560 max8997->ramp_delay); 559 max8997->ramp_delay * 1000);
561 } 560 }
562 561
563 return 0; 562 return 0;
@@ -656,7 +655,6 @@ static int max8997_set_voltage_buck(struct regulator_dev *rdev,
656 const struct voltage_map_desc *desc; 655 const struct voltage_map_desc *desc;
657 int new_val, new_idx, damage, tmp_val, tmp_idx, tmp_dmg; 656 int new_val, new_idx, damage, tmp_val, tmp_idx, tmp_dmg;
658 bool gpio_dvs_mode = false; 657 bool gpio_dvs_mode = false;
659 int min_vol = min_uV / 1000, max_vol = max_uV / 1000;
660 658
661 if (rid < MAX8997_BUCK1 || rid > MAX8997_BUCK7) 659 if (rid < MAX8997_BUCK1 || rid > MAX8997_BUCK7)
662 return -EINVAL; 660 return -EINVAL;
@@ -681,7 +679,7 @@ static int max8997_set_voltage_buck(struct regulator_dev *rdev,
681 selector); 679 selector);
682 680
683 desc = reg_voltage_map[rid]; 681 desc = reg_voltage_map[rid];
684 new_val = max8997_get_voltage_proper_val(desc, min_vol, max_vol); 682 new_val = max8997_get_voltage_proper_val(desc, min_uV, max_uV);
685 if (new_val < 0) 683 if (new_val < 0)
686 return new_val; 684 return new_val;
687 685
@@ -1123,8 +1121,8 @@ static int max8997_pmic_probe(struct platform_device *pdev)
1123 max8997->buck1_vol[i] = ret = 1121 max8997->buck1_vol[i] = ret =
1124 max8997_get_voltage_proper_val( 1122 max8997_get_voltage_proper_val(
1125 &buck1245_voltage_map_desc, 1123 &buck1245_voltage_map_desc,
1126 pdata->buck1_voltage[i] / 1000, 1124 pdata->buck1_voltage[i],
1127 pdata->buck1_voltage[i] / 1000 + 1125 pdata->buck1_voltage[i] +
1128 buck1245_voltage_map_desc.step); 1126 buck1245_voltage_map_desc.step);
1129 if (ret < 0) 1127 if (ret < 0)
1130 goto err_out; 1128 goto err_out;
@@ -1132,8 +1130,8 @@ static int max8997_pmic_probe(struct platform_device *pdev)
1132 max8997->buck2_vol[i] = ret = 1130 max8997->buck2_vol[i] = ret =
1133 max8997_get_voltage_proper_val( 1131 max8997_get_voltage_proper_val(
1134 &buck1245_voltage_map_desc, 1132 &buck1245_voltage_map_desc,
1135 pdata->buck2_voltage[i] / 1000, 1133 pdata->buck2_voltage[i],
1136 pdata->buck2_voltage[i] / 1000 + 1134 pdata->buck2_voltage[i] +
1137 buck1245_voltage_map_desc.step); 1135 buck1245_voltage_map_desc.step);
1138 if (ret < 0) 1136 if (ret < 0)
1139 goto err_out; 1137 goto err_out;
@@ -1141,8 +1139,8 @@ static int max8997_pmic_probe(struct platform_device *pdev)
1141 max8997->buck5_vol[i] = ret = 1139 max8997->buck5_vol[i] = ret =
1142 max8997_get_voltage_proper_val( 1140 max8997_get_voltage_proper_val(
1143 &buck1245_voltage_map_desc, 1141 &buck1245_voltage_map_desc,
1144 pdata->buck5_voltage[i] / 1000, 1142 pdata->buck5_voltage[i],
1145 pdata->buck5_voltage[i] / 1000 + 1143 pdata->buck5_voltage[i] +
1146 buck1245_voltage_map_desc.step); 1144 buck1245_voltage_map_desc.step);
1147 if (ret < 0) 1145 if (ret < 0)
1148 goto err_out; 1146 goto err_out;
diff --git a/drivers/regulator/max8998.c b/drivers/regulator/max8998.c
index b821d08eb64..1f0df4046b8 100644
--- a/drivers/regulator/max8998.c
+++ b/drivers/regulator/max8998.c
@@ -51,39 +51,39 @@ struct voltage_map_desc {
51 int step; 51 int step;
52}; 52};
53 53
54/* Voltage maps */ 54/* Voltage maps in uV*/
55static const struct voltage_map_desc ldo23_voltage_map_desc = { 55static const struct voltage_map_desc ldo23_voltage_map_desc = {
56 .min = 800, .step = 50, .max = 1300, 56 .min = 800000, .step = 50000, .max = 1300000,
57}; 57};
58static const struct voltage_map_desc ldo456711_voltage_map_desc = { 58static const struct voltage_map_desc ldo456711_voltage_map_desc = {
59 .min = 1600, .step = 100, .max = 3600, 59 .min = 1600000, .step = 100000, .max = 3600000,
60}; 60};
61static const struct voltage_map_desc ldo8_voltage_map_desc = { 61static const struct voltage_map_desc ldo8_voltage_map_desc = {
62 .min = 3000, .step = 100, .max = 3600, 62 .min = 3000000, .step = 100000, .max = 3600000,
63}; 63};
64static const struct voltage_map_desc ldo9_voltage_map_desc = { 64static const struct voltage_map_desc ldo9_voltage_map_desc = {
65 .min = 2800, .step = 100, .max = 3100, 65 .min = 2800000, .step = 100000, .max = 3100000,
66}; 66};
67static const struct voltage_map_desc ldo10_voltage_map_desc = { 67static const struct voltage_map_desc ldo10_voltage_map_desc = {
68 .min = 950, .step = 50, .max = 1300, 68 .min = 95000, .step = 50000, .max = 1300000,
69}; 69};
70static const struct voltage_map_desc ldo1213_voltage_map_desc = { 70static const struct voltage_map_desc ldo1213_voltage_map_desc = {
71 .min = 800, .step = 100, .max = 3300, 71 .min = 800000, .step = 100000, .max = 3300000,
72}; 72};
73static const struct voltage_map_desc ldo1415_voltage_map_desc = { 73static const struct voltage_map_desc ldo1415_voltage_map_desc = {
74 .min = 1200, .step = 100, .max = 3300, 74 .min = 1200000, .step = 100000, .max = 3300000,
75}; 75};
76static const struct voltage_map_desc ldo1617_voltage_map_desc = { 76static const struct voltage_map_desc ldo1617_voltage_map_desc = {
77 .min = 1600, .step = 100, .max = 3600, 77 .min = 1600000, .step = 100000, .max = 3600000,
78}; 78};
79static const struct voltage_map_desc buck12_voltage_map_desc = { 79static const struct voltage_map_desc buck12_voltage_map_desc = {
80 .min = 750, .step = 25, .max = 1525, 80 .min = 750000, .step = 25000, .max = 1525000,
81}; 81};
82static const struct voltage_map_desc buck3_voltage_map_desc = { 82static const struct voltage_map_desc buck3_voltage_map_desc = {
83 .min = 1600, .step = 100, .max = 3600, 83 .min = 1600000, .step = 100000, .max = 3600000,
84}; 84};
85static const struct voltage_map_desc buck4_voltage_map_desc = { 85static const struct voltage_map_desc buck4_voltage_map_desc = {
86 .min = 800, .step = 100, .max = 2300, 86 .min = 800000, .step = 100000, .max = 2300000,
87}; 87};
88 88
89static const struct voltage_map_desc *ldo_voltage_map[] = { 89static const struct voltage_map_desc *ldo_voltage_map[] = {
@@ -445,9 +445,9 @@ static int max8998_set_voltage_buck_time_sel(struct regulator_dev *rdev,
445 if (max8998->iodev->type == TYPE_MAX8998 && !(val & MAX8998_ENRAMP)) 445 if (max8998->iodev->type == TYPE_MAX8998 && !(val & MAX8998_ENRAMP))
446 return 0; 446 return 0;
447 447
448 difference = (new_selector - old_selector) * desc->step; 448 difference = (new_selector - old_selector) * desc->step / 1000;
449 if (difference > 0) 449 if (difference > 0)
450 return difference / ((val & 0x0f) + 1); 450 return DIV_ROUND_UP(difference, (val & 0x0f) + 1);
451 451
452 return 0; 452 return 0;
453} 453}
@@ -702,7 +702,7 @@ static int max8998_pmic_probe(struct platform_device *pdev)
702 i = 0; 702 i = 0;
703 while (buck12_voltage_map_desc.min + 703 while (buck12_voltage_map_desc.min +
704 buck12_voltage_map_desc.step*i 704 buck12_voltage_map_desc.step*i
705 < (pdata->buck1_voltage1 / 1000)) 705 < pdata->buck1_voltage1)
706 i++; 706 i++;
707 max8998->buck1_vol[0] = i; 707 max8998->buck1_vol[0] = i;
708 ret = max8998_write_reg(i2c, MAX8998_REG_BUCK1_VOLTAGE1, i); 708 ret = max8998_write_reg(i2c, MAX8998_REG_BUCK1_VOLTAGE1, i);
@@ -713,7 +713,7 @@ static int max8998_pmic_probe(struct platform_device *pdev)
713 i = 0; 713 i = 0;
714 while (buck12_voltage_map_desc.min + 714 while (buck12_voltage_map_desc.min +
715 buck12_voltage_map_desc.step*i 715 buck12_voltage_map_desc.step*i
716 < (pdata->buck1_voltage2 / 1000)) 716 < pdata->buck1_voltage2)
717 i++; 717 i++;
718 718
719 max8998->buck1_vol[1] = i; 719 max8998->buck1_vol[1] = i;
@@ -725,7 +725,7 @@ static int max8998_pmic_probe(struct platform_device *pdev)
725 i = 0; 725 i = 0;
726 while (buck12_voltage_map_desc.min + 726 while (buck12_voltage_map_desc.min +
727 buck12_voltage_map_desc.step*i 727 buck12_voltage_map_desc.step*i
728 < (pdata->buck1_voltage3 / 1000)) 728 < pdata->buck1_voltage3)
729 i++; 729 i++;
730 730
731 max8998->buck1_vol[2] = i; 731 max8998->buck1_vol[2] = i;
@@ -737,7 +737,7 @@ static int max8998_pmic_probe(struct platform_device *pdev)
737 i = 0; 737 i = 0;
738 while (buck12_voltage_map_desc.min + 738 while (buck12_voltage_map_desc.min +
739 buck12_voltage_map_desc.step*i 739 buck12_voltage_map_desc.step*i
740 < (pdata->buck1_voltage4 / 1000)) 740 < pdata->buck1_voltage4)
741 i++; 741 i++;
742 742
743 max8998->buck1_vol[3] = i; 743 max8998->buck1_vol[3] = i;
@@ -763,7 +763,7 @@ static int max8998_pmic_probe(struct platform_device *pdev)
763 i = 0; 763 i = 0;
764 while (buck12_voltage_map_desc.min + 764 while (buck12_voltage_map_desc.min +
765 buck12_voltage_map_desc.step*i 765 buck12_voltage_map_desc.step*i
766 < (pdata->buck2_voltage1 / 1000)) 766 < pdata->buck2_voltage1)
767 i++; 767 i++;
768 max8998->buck2_vol[0] = i; 768 max8998->buck2_vol[0] = i;
769 ret = max8998_write_reg(i2c, MAX8998_REG_BUCK2_VOLTAGE1, i); 769 ret = max8998_write_reg(i2c, MAX8998_REG_BUCK2_VOLTAGE1, i);
@@ -774,7 +774,7 @@ static int max8998_pmic_probe(struct platform_device *pdev)
774 i = 0; 774 i = 0;
775 while (buck12_voltage_map_desc.min + 775 while (buck12_voltage_map_desc.min +
776 buck12_voltage_map_desc.step*i 776 buck12_voltage_map_desc.step*i
777 < (pdata->buck2_voltage2 / 1000)) 777 < pdata->buck2_voltage2)
778 i++; 778 i++;
779 max8998->buck2_vol[1] = i; 779 max8998->buck2_vol[1] = i;
780 ret = max8998_write_reg(i2c, MAX8998_REG_BUCK2_VOLTAGE2, i); 780 ret = max8998_write_reg(i2c, MAX8998_REG_BUCK2_VOLTAGE2, i);
@@ -792,8 +792,8 @@ static int max8998_pmic_probe(struct platform_device *pdev)
792 int count = (desc->max - desc->min) / desc->step + 1; 792 int count = (desc->max - desc->min) / desc->step + 1;
793 793
794 regulators[index].n_voltages = count; 794 regulators[index].n_voltages = count;
795 regulators[index].min_uV = desc->min * 1000; 795 regulators[index].min_uV = desc->min;
796 regulators[index].uV_step = desc->step * 1000; 796 regulators[index].uV_step = desc->step;
797 } 797 }
798 798
799 config.dev = max8998->dev; 799 config.dev = max8998->dev;
diff --git a/drivers/regulator/s5m8767.c b/drivers/regulator/s5m8767.c
index 9f991f2c525..33b65c9ad5d 100644
--- a/drivers/regulator/s5m8767.c
+++ b/drivers/regulator/s5m8767.c
@@ -214,7 +214,7 @@ static int s5m8767_reg_is_enabled(struct regulator_dev *rdev)
214 struct s5m8767_info *s5m8767 = rdev_get_drvdata(rdev); 214 struct s5m8767_info *s5m8767 = rdev_get_drvdata(rdev);
215 int ret, reg; 215 int ret, reg;
216 int mask = 0xc0, enable_ctrl; 216 int mask = 0xc0, enable_ctrl;
217 u8 val; 217 unsigned int val;
218 218
219 ret = s5m8767_get_register(rdev, &reg, &enable_ctrl); 219 ret = s5m8767_get_register(rdev, &reg, &enable_ctrl);
220 if (ret == -EINVAL) 220 if (ret == -EINVAL)
@@ -306,7 +306,7 @@ static int s5m8767_get_voltage_sel(struct regulator_dev *rdev)
306 struct s5m8767_info *s5m8767 = rdev_get_drvdata(rdev); 306 struct s5m8767_info *s5m8767 = rdev_get_drvdata(rdev);
307 int reg, mask, ret; 307 int reg, mask, ret;
308 int reg_id = rdev_get_id(rdev); 308 int reg_id = rdev_get_id(rdev);
309 u8 val; 309 unsigned int val;
310 310
311 ret = s5m8767_get_voltage_register(rdev, &reg); 311 ret = s5m8767_get_voltage_register(rdev, &reg);
312 if (ret) 312 if (ret)