aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator/s5m8767.c
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2012-12-11 07:44:55 -0500
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-12-11 07:44:55 -0500
commit4ffc45c3604dd8e283884ce006faf0e955cbd9e6 (patch)
treeb646d318e41fb770c18ad066cd3a4c42eda8ffc5 /drivers/regulator/s5m8767.c
parentf3cd19c38c3453d3af766979ccdde91eeb8b4d05 (diff)
parent76c854d1dfdce33354dc2481e5db31f27c6be3e3 (diff)
Merge remote-tracking branch 'regulator/topic/sm8767' into regulator-next
Diffstat (limited to 'drivers/regulator/s5m8767.c')
-rw-r--r--drivers/regulator/s5m8767.c40
1 files changed, 26 insertions, 14 deletions
diff --git a/drivers/regulator/s5m8767.c b/drivers/regulator/s5m8767.c
index 2b822bec3c2d..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;
@@ -547,7 +556,7 @@ static 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 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 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");