aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2011-07-09 02:26:28 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-07-09 02:26:28 -0400
commitb56045d4019a80935ead337e5c3f8e211fa9b471 (patch)
tree996f7c724a2d6d11054325b0ed1b7c1f26366052 /drivers
parent1acc9309eb2674533944f48dbaaa53e7750e3947 (diff)
parent6ff325a2d85481cbe31dfbb74b4fd2d94c115300 (diff)
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/lrg/voltage-2.6
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/lrg/voltage-2.6: regulator: max8997: Fix setting inappropriate value for ramp_delay variable regulator: db8500-prcmu: small fixes regulator: max8997: remove dependency on platform_data pointer regulator: MAX8997: Fix for divide by zero error regulator: max8952 - fix wrong gpio valid check
Diffstat (limited to 'drivers')
-rw-r--r--drivers/regulator/db8500-prcmu.c14
-rw-r--r--drivers/regulator/max8952.c2
-rw-r--r--drivers/regulator/max8997.c55
3 files changed, 33 insertions, 38 deletions
diff --git a/drivers/regulator/db8500-prcmu.c b/drivers/regulator/db8500-prcmu.c
index e5f7b8fe51f4..2bb8f451cc06 100644
--- a/drivers/regulator/db8500-prcmu.c
+++ b/drivers/regulator/db8500-prcmu.c
@@ -266,7 +266,7 @@ static struct regulator_ops db8500_regulator_switch_ops = {
266 * Regulator information 266 * Regulator information
267 */ 267 */
268static struct db8500_regulator_info 268static struct db8500_regulator_info
269 db8500_regulator_info[DB8500_NUM_REGULATORS] = { 269db8500_regulator_info[DB8500_NUM_REGULATORS] = {
270 [DB8500_REGULATOR_VAPE] = { 270 [DB8500_REGULATOR_VAPE] = {
271 .desc = { 271 .desc = {
272 .name = "db8500-vape", 272 .name = "db8500-vape",
@@ -492,11 +492,9 @@ static int __devinit db8500_regulator_probe(struct platform_device *pdev)
492 info->desc.name, err); 492 info->desc.name, err);
493 493
494 /* if failing, unregister all earlier regulators */ 494 /* if failing, unregister all earlier regulators */
495 i--; 495 while (--i >= 0) {
496 while (i >= 0) {
497 info = &db8500_regulator_info[i]; 496 info = &db8500_regulator_info[i];
498 regulator_unregister(info->rdev); 497 regulator_unregister(info->rdev);
499 i--;
500 } 498 }
501 return err; 499 return err;
502 } 500 }
@@ -536,13 +534,7 @@ static struct platform_driver db8500_regulator_driver = {
536 534
537static int __init db8500_regulator_init(void) 535static int __init db8500_regulator_init(void)
538{ 536{
539 int ret; 537 return platform_driver_register(&db8500_regulator_driver);
540
541 ret = platform_driver_register(&db8500_regulator_driver);
542 if (ret < 0)
543 return -ENODEV;
544
545 return 0;
546} 538}
547 539
548static void __exit db8500_regulator_exit(void) 540static void __exit db8500_regulator_exit(void)
diff --git a/drivers/regulator/max8952.c b/drivers/regulator/max8952.c
index daff7fd0e95c..486ed8141fcd 100644
--- a/drivers/regulator/max8952.c
+++ b/drivers/regulator/max8952.c
@@ -139,7 +139,7 @@ static int max8952_set_voltage(struct regulator_dev *rdev,
139 s8 vid = -1, i; 139 s8 vid = -1, i;
140 140
141 if (!gpio_is_valid(max8952->pdata->gpio_vid0) || 141 if (!gpio_is_valid(max8952->pdata->gpio_vid0) ||
142 !gpio_is_valid(max8952->pdata->gpio_vid0)) { 142 !gpio_is_valid(max8952->pdata->gpio_vid1)) {
143 /* DVS not supported */ 143 /* DVS not supported */
144 return -EPERM; 144 return -EPERM;
145 } 145 }
diff --git a/drivers/regulator/max8997.c b/drivers/regulator/max8997.c
index 10d5a1d9768e..ad6628ca94f4 100644
--- a/drivers/regulator/max8997.c
+++ b/drivers/regulator/max8997.c
@@ -39,25 +39,28 @@ struct max8997_data {
39 struct regulator_dev **rdev; 39 struct regulator_dev **rdev;
40 int ramp_delay; /* in mV/us */ 40 int ramp_delay; /* in mV/us */
41 41
42 bool buck1_gpiodvs;
43 bool buck2_gpiodvs;
44 bool buck5_gpiodvs;
42 u8 buck1_vol[8]; 45 u8 buck1_vol[8];
43 u8 buck2_vol[8]; 46 u8 buck2_vol[8];
44 u8 buck5_vol[8]; 47 u8 buck5_vol[8];
48 int buck125_gpios[3];
45 int buck125_gpioindex; 49 int buck125_gpioindex;
50 bool ignore_gpiodvs_side_effect;
46 51
47 u8 saved_states[MAX8997_REG_MAX]; 52 u8 saved_states[MAX8997_REG_MAX];
48}; 53};
49 54
50static inline void max8997_set_gpio(struct max8997_data *max8997) 55static inline void max8997_set_gpio(struct max8997_data *max8997)
51{ 56{
52 struct max8997_platform_data *pdata =
53 dev_get_platdata(max8997->iodev->dev);
54 int set3 = (max8997->buck125_gpioindex) & 0x1; 57 int set3 = (max8997->buck125_gpioindex) & 0x1;
55 int set2 = ((max8997->buck125_gpioindex) >> 1) & 0x1; 58 int set2 = ((max8997->buck125_gpioindex) >> 1) & 0x1;
56 int set1 = ((max8997->buck125_gpioindex) >> 2) & 0x1; 59 int set1 = ((max8997->buck125_gpioindex) >> 2) & 0x1;
57 60
58 gpio_set_value(pdata->buck125_gpios[0], set1); 61 gpio_set_value(max8997->buck125_gpios[0], set1);
59 gpio_set_value(pdata->buck125_gpios[1], set2); 62 gpio_set_value(max8997->buck125_gpios[1], set2);
60 gpio_set_value(pdata->buck125_gpios[2], set3); 63 gpio_set_value(max8997->buck125_gpios[2], set3);
61} 64}
62 65
63struct voltage_map_desc { 66struct voltage_map_desc {
@@ -380,8 +383,6 @@ static int max8997_get_voltage_register(struct regulator_dev *rdev,
380static int max8997_get_voltage(struct regulator_dev *rdev) 383static int max8997_get_voltage(struct regulator_dev *rdev)
381{ 384{
382 struct max8997_data *max8997 = rdev_get_drvdata(rdev); 385 struct max8997_data *max8997 = rdev_get_drvdata(rdev);
383 struct max8997_platform_data *pdata =
384 dev_get_platdata(max8997->iodev->dev);
385 struct i2c_client *i2c = max8997->iodev->i2c; 386 struct i2c_client *i2c = max8997->iodev->i2c;
386 int reg, shift, mask, ret; 387 int reg, shift, mask, ret;
387 int rid = max8997_get_rid(rdev); 388 int rid = max8997_get_rid(rdev);
@@ -391,9 +392,9 @@ static int max8997_get_voltage(struct regulator_dev *rdev)
391 if (ret) 392 if (ret)
392 return ret; 393 return ret;
393 394
394 if ((rid == MAX8997_BUCK1 && pdata->buck1_gpiodvs) || 395 if ((rid == MAX8997_BUCK1 && max8997->buck1_gpiodvs) ||
395 (rid == MAX8997_BUCK2 && pdata->buck2_gpiodvs) || 396 (rid == MAX8997_BUCK2 && max8997->buck2_gpiodvs) ||
396 (rid == MAX8997_BUCK5 && pdata->buck5_gpiodvs)) 397 (rid == MAX8997_BUCK5 && max8997->buck5_gpiodvs))
397 reg += max8997->buck125_gpioindex; 398 reg += max8997->buck125_gpioindex;
398 399
399 ret = max8997_read_reg(i2c, reg, &val); 400 ret = max8997_read_reg(i2c, reg, &val);
@@ -543,7 +544,8 @@ static int max8997_set_voltage_ldobuck(struct regulator_dev *rdev,
543 rid == MAX8997_BUCK4 || rid == MAX8997_BUCK5) { 544 rid == MAX8997_BUCK4 || rid == MAX8997_BUCK5) {
544 /* If the voltage is increasing */ 545 /* If the voltage is increasing */
545 if (org < i) 546 if (org < i)
546 udelay(desc->step * (i - org) / max8997->ramp_delay); 547 udelay(DIV_ROUND_UP(desc->step * (i - org),
548 max8997->ramp_delay));
547 } 549 }
548 550
549 return ret; 551 return ret;
@@ -561,8 +563,6 @@ static int max8997_assess_side_effect(struct regulator_dev *rdev,
561 u8 new_val, int *best) 563 u8 new_val, int *best)
562{ 564{
563 struct max8997_data *max8997 = rdev_get_drvdata(rdev); 565 struct max8997_data *max8997 = rdev_get_drvdata(rdev);
564 struct max8997_platform_data *pdata =
565 dev_get_platdata(max8997->iodev->dev);
566 int rid = max8997_get_rid(rdev); 566 int rid = max8997_get_rid(rdev);
567 u8 *buckx_val[3]; 567 u8 *buckx_val[3];
568 bool buckx_gpiodvs[3]; 568 bool buckx_gpiodvs[3];
@@ -589,9 +589,9 @@ static int max8997_assess_side_effect(struct regulator_dev *rdev,
589 buckx_val[0] = max8997->buck1_vol; 589 buckx_val[0] = max8997->buck1_vol;
590 buckx_val[1] = max8997->buck2_vol; 590 buckx_val[1] = max8997->buck2_vol;
591 buckx_val[2] = max8997->buck5_vol; 591 buckx_val[2] = max8997->buck5_vol;
592 buckx_gpiodvs[0] = pdata->buck1_gpiodvs; 592 buckx_gpiodvs[0] = max8997->buck1_gpiodvs;
593 buckx_gpiodvs[1] = pdata->buck2_gpiodvs; 593 buckx_gpiodvs[1] = max8997->buck2_gpiodvs;
594 buckx_gpiodvs[2] = pdata->buck5_gpiodvs; 594 buckx_gpiodvs[2] = max8997->buck5_gpiodvs;
595 595
596 for (i = 0; i < 8; i++) { 596 for (i = 0; i < 8; i++) {
597 int others; 597 int others;
@@ -640,8 +640,6 @@ static int max8997_set_voltage_buck(struct regulator_dev *rdev,
640 int min_uV, int max_uV, unsigned *selector) 640 int min_uV, int max_uV, unsigned *selector)
641{ 641{
642 struct max8997_data *max8997 = rdev_get_drvdata(rdev); 642 struct max8997_data *max8997 = rdev_get_drvdata(rdev);
643 struct max8997_platform_data *pdata =
644 dev_get_platdata(max8997->iodev->dev);
645 int rid = max8997_get_rid(rdev); 643 int rid = max8997_get_rid(rdev);
646 const struct voltage_map_desc *desc; 644 const struct voltage_map_desc *desc;
647 int new_val, new_idx, damage, tmp_val, tmp_idx, tmp_dmg; 645 int new_val, new_idx, damage, tmp_val, tmp_idx, tmp_dmg;
@@ -653,15 +651,15 @@ static int max8997_set_voltage_buck(struct regulator_dev *rdev,
653 651
654 switch (rid) { 652 switch (rid) {
655 case MAX8997_BUCK1: 653 case MAX8997_BUCK1:
656 if (pdata->buck1_gpiodvs) 654 if (max8997->buck1_gpiodvs)
657 gpio_dvs_mode = true; 655 gpio_dvs_mode = true;
658 break; 656 break;
659 case MAX8997_BUCK2: 657 case MAX8997_BUCK2:
660 if (pdata->buck2_gpiodvs) 658 if (max8997->buck2_gpiodvs)
661 gpio_dvs_mode = true; 659 gpio_dvs_mode = true;
662 break; 660 break;
663 case MAX8997_BUCK5: 661 case MAX8997_BUCK5:
664 if (pdata->buck5_gpiodvs) 662 if (max8997->buck5_gpiodvs)
665 gpio_dvs_mode = true; 663 gpio_dvs_mode = true;
666 break; 664 break;
667 } 665 }
@@ -695,7 +693,7 @@ static int max8997_set_voltage_buck(struct regulator_dev *rdev,
695 new_idx = tmp_idx; 693 new_idx = tmp_idx;
696 new_val = tmp_val; 694 new_val = tmp_val;
697 695
698 if (pdata->ignore_gpiodvs_side_effect == false) 696 if (max8997->ignore_gpiodvs_side_effect == false)
699 return -EINVAL; 697 return -EINVAL;
700 698
701 dev_warn(&rdev->dev, "MAX8997 GPIO-DVS Side Effect Warning: GPIO SET:" 699 dev_warn(&rdev->dev, "MAX8997 GPIO-DVS Side Effect Warning: GPIO SET:"
@@ -993,6 +991,11 @@ static __devinit int max8997_pmic_probe(struct platform_device *pdev)
993 i2c = max8997->iodev->i2c; 991 i2c = max8997->iodev->i2c;
994 992
995 max8997->buck125_gpioindex = pdata->buck125_default_idx; 993 max8997->buck125_gpioindex = pdata->buck125_default_idx;
994 max8997->buck1_gpiodvs = pdata->buck1_gpiodvs;
995 max8997->buck2_gpiodvs = pdata->buck2_gpiodvs;
996 max8997->buck5_gpiodvs = pdata->buck5_gpiodvs;
997 memcpy(max8997->buck125_gpios, pdata->buck125_gpios, sizeof(int) * 3);
998 max8997->ignore_gpiodvs_side_effect = pdata->ignore_gpiodvs_side_effect;
996 999
997 for (i = 0; i < 8; i++) { 1000 for (i = 0; i < 8; i++) {
998 max8997->buck1_vol[i] = ret = 1001 max8997->buck1_vol[i] = ret =
@@ -1124,6 +1127,10 @@ static __devinit int max8997_pmic_probe(struct platform_device *pdev)
1124 0x3f); 1127 0x3f);
1125 } 1128 }
1126 1129
1130 /* Misc Settings */
1131 max8997->ramp_delay = 10; /* set 10mV/us, which is the default */
1132 max8997_write_reg(i2c, MAX8997_REG_BUCKRAMP, (0xf << 4) | 0x9);
1133
1127 for (i = 0; i < pdata->num_regulators; i++) { 1134 for (i = 0; i < pdata->num_regulators; i++) {
1128 const struct voltage_map_desc *desc; 1135 const struct voltage_map_desc *desc;
1129 int id = pdata->regulators[i].id; 1136 int id = pdata->regulators[i].id;
@@ -1148,10 +1155,6 @@ static __devinit int max8997_pmic_probe(struct platform_device *pdev)
1148 } 1155 }
1149 } 1156 }
1150 1157
1151 /* Misc Settings */
1152 max8997->ramp_delay = 10; /* set 10mV/us, which is the default */
1153 max8997_write_reg(i2c, MAX8997_REG_BUCKRAMP, (0xf << 4) | 0x9);
1154
1155 return 0; 1158 return 0;
1156err: 1159err:
1157 for (i = 0; i < max8997->num_regulators; i++) 1160 for (i = 0; i < max8997->num_regulators; i++)