summaryrefslogtreecommitdiffstats
path: root/drivers/regulator
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@linaro.org>2018-05-14 10:06:23 +0200
committerMark Brown <broonie@kernel.org>2018-05-29 16:55:12 +0200
commit37bed97f00734ce329495823d9682181028b51e4 (patch)
treed320f47ce4a7a7c657cc87a79e3953a7928a9869 /drivers/regulator
parentregulator: fixed: Convert to use GPIO descriptor only (diff)
downloadlinux-37bed97f00734ce329495823d9682181028b51e4.tar.xz
linux-37bed97f00734ce329495823d9682181028b51e4.zip
regulator: gpio: Get enable GPIO using GPIO descriptor
We augment the GPIO regulator to get the *enable* regulator GPIO line (not the other lines) using a descriptor rather than a global number. We then pass this into the regulator core which has been prepared to hande enable descriptors in a separate patch. Switch over the two boardfiles using this facility and clean up so we only pass descriptors around. Cc: Philipp Zabel <philipp.zabel@gmail.com> # HX4700/Magician maintainer Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/regulator')
-rw-r--r--drivers/regulator/gpio-regulator.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/drivers/regulator/gpio-regulator.c b/drivers/regulator/gpio-regulator.c
index a86b8997bb54..9d6094c4d71c 100644
--- a/drivers/regulator/gpio-regulator.c
+++ b/drivers/regulator/gpio-regulator.c
@@ -31,6 +31,7 @@
#include <linux/regulator/of_regulator.h>
#include <linux/regulator/gpio-regulator.h>
#include <linux/gpio.h>
+#include <linux/gpio/consumer.h>
#include <linux/slab.h>
#include <linux/of.h>
#include <linux/of_gpio.h>
@@ -161,10 +162,6 @@ of_get_gpio_regulator_config(struct device *dev, struct device_node *np,
of_property_read_u32(np, "startup-delay-us", &config->startup_delay);
- config->enable_gpio = of_get_named_gpio(np, "enable-gpio", 0);
- if (config->enable_gpio < 0 && config->enable_gpio != -ENOENT)
- return ERR_PTR(config->enable_gpio);
-
/* Fetch GPIOs. - optional property*/
ret = of_gpio_count(np);
if ((ret < 0) && (ret != -ENOENT))
@@ -255,6 +252,7 @@ static int gpio_regulator_probe(struct platform_device *pdev)
struct device_node *np = pdev->dev.of_node;
struct gpio_regulator_data *drvdata;
struct regulator_config cfg = { };
+ enum gpiod_flags gflags;
int ptr, ret, state;
drvdata = devm_kzalloc(&pdev->dev, sizeof(struct gpio_regulator_data),
@@ -340,21 +338,22 @@ static int gpio_regulator_probe(struct platform_device *pdev)
cfg.driver_data = drvdata;
cfg.of_node = np;
- if (gpio_is_valid(config->enable_gpio)) {
- cfg.ena_gpio = config->enable_gpio;
- cfg.ena_gpio_initialized = true;
- }
cfg.ena_gpio_invert = !config->enable_high;
if (config->enabled_at_boot) {
if (config->enable_high)
- cfg.ena_gpio_flags |= GPIOF_OUT_INIT_HIGH;
+ gflags = GPIOD_OUT_HIGH;
else
- cfg.ena_gpio_flags |= GPIOF_OUT_INIT_LOW;
+ gflags = GPIOD_OUT_LOW;
} else {
if (config->enable_high)
- cfg.ena_gpio_flags |= GPIOF_OUT_INIT_LOW;
+ gflags = GPIOD_OUT_LOW;
else
- cfg.ena_gpio_flags |= GPIOF_OUT_INIT_HIGH;
+ gflags = GPIOD_OUT_HIGH;
+ }
+ cfg.ena_gpiod = devm_gpiod_get_optional(&pdev->dev, "enable", gflags);
+ if (IS_ERR(cfg.ena_gpiod)) {
+ ret = PTR_ERR(cfg.ena_gpiod);
+ goto err_stategpio;
}
drvdata->dev = regulator_register(&drvdata->desc, &cfg);