aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator/s5m8767.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/regulator/s5m8767.c')
-rw-r--r--drivers/regulator/s5m8767.c46
1 files changed, 29 insertions, 17 deletions
diff --git a/drivers/regulator/s5m8767.c b/drivers/regulator/s5m8767.c
index abe64a32aedf..9f991f2c525a 100644
--- a/drivers/regulator/s5m8767.c
+++ b/drivers/regulator/s5m8767.c
@@ -168,7 +168,7 @@ static unsigned int s5m8767_opmode_reg[][4] = {
168static int s5m8767_get_register(struct regulator_dev *rdev, int *reg, 168static int s5m8767_get_register(struct regulator_dev *rdev, int *reg,
169 int *enable_ctrl) 169 int *enable_ctrl)
170{ 170{
171 int reg_id = rdev_get_id(rdev); 171 int i, reg_id = rdev_get_id(rdev);
172 unsigned int mode; 172 unsigned int mode;
173 struct s5m8767_info *s5m8767 = rdev_get_drvdata(rdev); 173 struct s5m8767_info *s5m8767 = rdev_get_drvdata(rdev);
174 174
@@ -195,8 +195,17 @@ static int s5m8767_get_register(struct regulator_dev *rdev, int *reg,
195 return -EINVAL; 195 return -EINVAL;
196 } 196 }
197 197
198 mode = s5m8767->opmode[reg_id].mode; 198 for (i = 0; i < s5m8767->num_regulators; i++) {
199 *enable_ctrl = s5m8767_opmode_reg[reg_id][mode] << S5M8767_ENCTRL_SHIFT; 199 if (s5m8767->opmode[i].id == reg_id) {
200 mode = s5m8767->opmode[i].mode;
201 break;
202 }
203 }
204
205 if (i < s5m8767->num_regulators)
206 *enable_ctrl =
207 s5m8767_opmode_reg[reg_id][mode] << S5M8767_ENCTRL_SHIFT;
208
200 return 0; 209 return 0;
201} 210}
202 211
@@ -263,17 +272,17 @@ static int s5m8767_get_voltage_register(struct regulator_dev *rdev, int *_reg)
263 reg = S5M8767_REG_BUCK1CTRL2; 272 reg = S5M8767_REG_BUCK1CTRL2;
264 break; 273 break;
265 case S5M8767_BUCK2: 274 case S5M8767_BUCK2:
266 reg = S5M8767_REG_BUCK2DVS2; 275 reg = S5M8767_REG_BUCK2DVS1;
267 if (s5m8767->buck2_gpiodvs) 276 if (s5m8767->buck2_gpiodvs)
268 reg += s5m8767->buck_gpioindex; 277 reg += s5m8767->buck_gpioindex;
269 break; 278 break;
270 case S5M8767_BUCK3: 279 case S5M8767_BUCK3:
271 reg = S5M8767_REG_BUCK3DVS2; 280 reg = S5M8767_REG_BUCK3DVS1;
272 if (s5m8767->buck3_gpiodvs) 281 if (s5m8767->buck3_gpiodvs)
273 reg += s5m8767->buck_gpioindex; 282 reg += s5m8767->buck_gpioindex;
274 break; 283 break;
275 case S5M8767_BUCK4: 284 case S5M8767_BUCK4:
276 reg = S5M8767_REG_BUCK4DVS2; 285 reg = S5M8767_REG_BUCK4DVS1;
277 if (s5m8767->buck4_gpiodvs) 286 if (s5m8767->buck4_gpiodvs)
278 reg += s5m8767->buck_gpioindex; 287 reg += s5m8767->buck_gpioindex;
279 break; 288 break;
@@ -499,7 +508,7 @@ static struct regulator_desc regulators[] = {
499 s5m8767_regulator_desc(BUCK9), 508 s5m8767_regulator_desc(BUCK9),
500}; 509};
501 510
502static __devinit int s5m8767_pmic_probe(struct platform_device *pdev) 511static int s5m8767_pmic_probe(struct platform_device *pdev)
503{ 512{
504 struct sec_pmic_dev *iodev = dev_get_drvdata(pdev->dev.parent); 513 struct sec_pmic_dev *iodev = dev_get_drvdata(pdev->dev.parent);
505 struct sec_platform_data *pdata = dev_get_platdata(iodev->dev); 514 struct sec_platform_data *pdata = dev_get_platdata(iodev->dev);
@@ -547,7 +556,7 @@ static __devinit int s5m8767_pmic_probe(struct platform_device *pdev)
547 rdev = s5m8767->rdev; 556 rdev = s5m8767->rdev;
548 s5m8767->dev = &pdev->dev; 557 s5m8767->dev = &pdev->dev;
549 s5m8767->iodev = iodev; 558 s5m8767->iodev = iodev;
550 s5m8767->num_regulators = S5M8767_REG_MAX - 2; 559 s5m8767->num_regulators = pdata->num_regulators;
551 platform_set_drvdata(pdev, s5m8767); 560 platform_set_drvdata(pdev, s5m8767);
552 561
553 s5m8767->buck_gpioindex = pdata->buck_default_idx; 562 s5m8767->buck_gpioindex = pdata->buck_default_idx;
@@ -617,9 +626,16 @@ static __devinit int s5m8767_pmic_probe(struct platform_device *pdev)
617 } 626 }
618 } 627 }
619 628
620 if (gpio_is_valid(pdata->buck_gpios[0]) && 629 if (pdata->buck2_gpiodvs || pdata->buck3_gpiodvs ||
621 gpio_is_valid(pdata->buck_gpios[1]) && 630 pdata->buck4_gpiodvs) {
622 gpio_is_valid(pdata->buck_gpios[2])) { 631
632 if (!gpio_is_valid(pdata->buck_gpios[0]) ||
633 !gpio_is_valid(pdata->buck_gpios[1]) ||
634 !gpio_is_valid(pdata->buck_gpios[2])) {
635 dev_err(&pdev->dev, "GPIO NOT VALID\n");
636 return -EINVAL;
637 }
638
623 ret = devm_gpio_request(&pdev->dev, pdata->buck_gpios[0], 639 ret = devm_gpio_request(&pdev->dev, pdata->buck_gpios[0],
624 "S5M8767 SET1"); 640 "S5M8767 SET1");
625 if (ret) 641 if (ret)
@@ -644,10 +660,6 @@ static __devinit int s5m8767_pmic_probe(struct platform_device *pdev)
644 /* SET3 GPIO */ 660 /* SET3 GPIO */
645 gpio_direction_output(pdata->buck_gpios[2], 661 gpio_direction_output(pdata->buck_gpios[2],
646 (s5m8767->buck_gpioindex >> 0) & 0x1); 662 (s5m8767->buck_gpioindex >> 0) & 0x1);
647 } else {
648 dev_err(&pdev->dev, "GPIO NOT VALID\n");
649 ret = -EINVAL;
650 return ret;
651 } 663 }
652 664
653 ret = devm_gpio_request(&pdev->dev, pdata->buck_ds[0], "S5M8767 DS2"); 665 ret = devm_gpio_request(&pdev->dev, pdata->buck_ds[0], "S5M8767 DS2");
@@ -773,7 +785,7 @@ err:
773 return ret; 785 return ret;
774} 786}
775 787
776static int __devexit s5m8767_pmic_remove(struct platform_device *pdev) 788static int s5m8767_pmic_remove(struct platform_device *pdev)
777{ 789{
778 struct s5m8767_info *s5m8767 = platform_get_drvdata(pdev); 790 struct s5m8767_info *s5m8767 = platform_get_drvdata(pdev);
779 struct regulator_dev **rdev = s5m8767->rdev; 791 struct regulator_dev **rdev = s5m8767->rdev;
@@ -798,7 +810,7 @@ static struct platform_driver s5m8767_pmic_driver = {
798 .owner = THIS_MODULE, 810 .owner = THIS_MODULE,
799 }, 811 },
800 .probe = s5m8767_pmic_probe, 812 .probe = s5m8767_pmic_probe,
801 .remove = __devexit_p(s5m8767_pmic_remove), 813 .remove = s5m8767_pmic_remove,
802 .id_table = s5m8767_pmic_id, 814 .id_table = s5m8767_pmic_id,
803}; 815};
804 816