diff options
author | Krzysztof Kozlowski <k.kozlowski@samsung.com> | 2014-04-30 04:40:42 -0400 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2014-05-01 13:53:50 -0400 |
commit | de5d05637f7e036a8122757b18ca6cfd1300f233 (patch) | |
tree | b20cfbacd21c5222fd44eaf05011ab8026ee2314 | |
parent | 9b63cfbfd13b609e8d496852b6714ac686e31901 (diff) |
regulator: s2mps11: Allow GPIO 0 to be used as external control on S2MPS14
GPIO 0 is a valid GPIO so allow using it as external control for
S2MPS14 regulators.
Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
-rw-r--r-- | drivers/regulator/s2mps11.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/drivers/regulator/s2mps11.c b/drivers/regulator/s2mps11.c index 6dad0aa74a47..1583d4eaf911 100644 --- a/drivers/regulator/s2mps11.c +++ b/drivers/regulator/s2mps11.c | |||
@@ -412,7 +412,7 @@ static int s2mps14_regulator_enable(struct regulator_dev *rdev) | |||
412 | 412 | ||
413 | if (s2mps11->s2mps14_suspend_state & (1 << rdev_get_id(rdev))) | 413 | if (s2mps11->s2mps14_suspend_state & (1 << rdev_get_id(rdev))) |
414 | val = S2MPS14_ENABLE_SUSPEND; | 414 | val = S2MPS14_ENABLE_SUSPEND; |
415 | else if (s2mps11->ext_control_gpio[rdev_get_id(rdev)]) | 415 | else if (gpio_is_valid(s2mps11->ext_control_gpio[rdev_get_id(rdev)])) |
416 | val = S2MPS14_ENABLE_EXT_CONTROL; | 416 | val = S2MPS14_ENABLE_EXT_CONTROL; |
417 | else | 417 | else |
418 | val = rdev->desc->enable_mask; | 418 | val = rdev->desc->enable_mask; |
@@ -593,9 +593,7 @@ static void s2mps14_pmic_dt_parse_ext_control_gpio(struct platform_device *pdev, | |||
593 | 593 | ||
594 | gpio[reg] = of_get_named_gpio(rdata[reg].of_node, | 594 | gpio[reg] = of_get_named_gpio(rdata[reg].of_node, |
595 | "samsung,ext-control-gpios", 0); | 595 | "samsung,ext-control-gpios", 0); |
596 | if (!gpio_is_valid(gpio[reg])) | 596 | if (gpio_is_valid(gpio[reg])) |
597 | gpio[reg] = 0; | ||
598 | else | ||
599 | dev_dbg(&pdev->dev, "Using GPIO %d for ext-control over %d/%s\n", | 597 | dev_dbg(&pdev->dev, "Using GPIO %d for ext-control over %d/%s\n", |
600 | gpio[reg], reg, rdata[reg].name); | 598 | gpio[reg], reg, rdata[reg].name); |
601 | } | 599 | } |
@@ -658,6 +656,12 @@ static int s2mps11_pmic_probe(struct platform_device *pdev) | |||
658 | GFP_KERNEL); | 656 | GFP_KERNEL); |
659 | if (!s2mps11->ext_control_gpio) | 657 | if (!s2mps11->ext_control_gpio) |
660 | return -ENOMEM; | 658 | return -ENOMEM; |
659 | /* | ||
660 | * 0 is a valid GPIO so initialize all GPIO-s to negative value | ||
661 | * to indicate that external control won't be used for this regulator. | ||
662 | */ | ||
663 | for (i = 0; i < s2mps11->rdev_num; i++) | ||
664 | s2mps11->ext_control_gpio[i] = -EINVAL; | ||
661 | 665 | ||
662 | if (!iodev->dev->of_node) { | 666 | if (!iodev->dev->of_node) { |
663 | if (iodev->pdata) { | 667 | if (iodev->pdata) { |
@@ -687,6 +691,7 @@ common_reg: | |||
687 | config.dev = &pdev->dev; | 691 | config.dev = &pdev->dev; |
688 | config.regmap = iodev->regmap_pmic; | 692 | config.regmap = iodev->regmap_pmic; |
689 | config.driver_data = s2mps11; | 693 | config.driver_data = s2mps11; |
694 | config.ena_gpio_flags = GPIOF_OUT_INIT_HIGH; | ||
690 | for (i = 0; i < s2mps11->rdev_num; i++) { | 695 | for (i = 0; i < s2mps11->rdev_num; i++) { |
691 | struct regulator_dev *regulator; | 696 | struct regulator_dev *regulator; |
692 | 697 | ||
@@ -697,12 +702,7 @@ common_reg: | |||
697 | config.init_data = rdata[i].init_data; | 702 | config.init_data = rdata[i].init_data; |
698 | config.of_node = rdata[i].of_node; | 703 | config.of_node = rdata[i].of_node; |
699 | } | 704 | } |
700 | 705 | config.ena_gpio = s2mps11->ext_control_gpio[i]; | |
701 | if (s2mps11->ext_control_gpio[i]) { | ||
702 | config.ena_gpio = s2mps11->ext_control_gpio[i]; | ||
703 | config.ena_gpio_flags = GPIOF_OUT_INIT_HIGH; | ||
704 | } else | ||
705 | config.ena_gpio = config.ena_gpio_flags = 0; | ||
706 | 706 | ||
707 | regulator = devm_regulator_register(&pdev->dev, | 707 | regulator = devm_regulator_register(&pdev->dev, |
708 | ®ulators[i], &config); | 708 | ®ulators[i], &config); |
@@ -713,7 +713,7 @@ common_reg: | |||
713 | goto out; | 713 | goto out; |
714 | } | 714 | } |
715 | 715 | ||
716 | if (s2mps11->ext_control_gpio[i]) { | 716 | if (gpio_is_valid(s2mps11->ext_control_gpio[i])) { |
717 | ret = s2mps14_pmic_enable_ext_control(s2mps11, | 717 | ret = s2mps14_pmic_enable_ext_control(s2mps11, |
718 | regulator); | 718 | regulator); |
719 | if (ret < 0) { | 719 | if (ret < 0) { |