From e536700ef5bf9788af185bf890a52f296d055ed7 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Thu, 7 Jun 2018 14:10:56 +0100 Subject: regulator: gpio: Revert regulator: fixed/gpio: Revert GPIO descriptor changes due to platform breakage Commit 6059577cb28 "regulator: fixed: Convert to use GPIO descriptor only" broke at least the ams-delta platform since the lookup tables added to the board files use the function name "enable" while the driver uses NULL causing the regulator to not acquire and control the enable GPIOs. Revert that and a couple of other commits that are caught up with it to fix the issue: 2b6c00c157c5bf80 "ARM: pxa, regulator: fix building ezx e680" 6059577cb28d8b15 "regulator: fixed: Convert to use GPIO descriptor only" 37bed97f00734ce3 "regulator: gpio: Get enable GPIO using GPIO descriptor" Reported-by: Janusz Krzysztofik Signed-off-by: Mark Brown --- drivers/regulator/fixed-helper.c | 1 + drivers/regulator/fixed.c | 33 +++++++++++++++++---------------- drivers/regulator/gpio-regulator.c | 23 ++++++++++++----------- 3 files changed, 30 insertions(+), 27 deletions(-) (limited to 'drivers/regulator') diff --git a/drivers/regulator/fixed-helper.c b/drivers/regulator/fixed-helper.c index 2c6098e6f4bc..777fac6fb4cb 100644 --- a/drivers/regulator/fixed-helper.c +++ b/drivers/regulator/fixed-helper.c @@ -43,6 +43,7 @@ struct platform_device *regulator_register_always_on(int id, const char *name, } data->cfg.microvolts = uv; + data->cfg.gpio = -EINVAL; data->cfg.enabled_at_boot = 1; data->cfg.init_data = &data->init_data; diff --git a/drivers/regulator/fixed.c b/drivers/regulator/fixed.c index 1142f195529b..988a7472c2ab 100644 --- a/drivers/regulator/fixed.c +++ b/drivers/regulator/fixed.c @@ -24,9 +24,10 @@ #include #include #include -#include +#include #include #include +#include #include #include @@ -77,6 +78,10 @@ of_get_fixed_voltage_config(struct device *dev, if (init_data->constraints.boot_on) config->enabled_at_boot = true; + config->gpio = of_get_named_gpio(np, "gpio", 0); + if ((config->gpio < 0) && (config->gpio != -ENOENT)) + return ERR_PTR(config->gpio); + of_property_read_u32(np, "startup-delay-us", &config->startup_delay); config->enable_high = of_property_read_bool(np, "enable-active-high"); @@ -97,7 +102,6 @@ static int reg_fixed_voltage_probe(struct platform_device *pdev) struct fixed_voltage_config *config; struct fixed_voltage_data *drvdata; struct regulator_config cfg = { }; - enum gpiod_flags gflags; int ret; drvdata = devm_kzalloc(&pdev->dev, sizeof(struct fixed_voltage_data), @@ -146,28 +150,25 @@ static int reg_fixed_voltage_probe(struct platform_device *pdev) drvdata->desc.fixed_uV = config->microvolts; + if (gpio_is_valid(config->gpio)) { + cfg.ena_gpio = config->gpio; + if (pdev->dev.of_node) + cfg.ena_gpio_initialized = true; + } cfg.ena_gpio_invert = !config->enable_high; if (config->enabled_at_boot) { if (config->enable_high) - gflags = GPIOD_OUT_HIGH; + cfg.ena_gpio_flags |= GPIOF_OUT_INIT_HIGH; else - gflags = GPIOD_OUT_LOW; + cfg.ena_gpio_flags |= GPIOF_OUT_INIT_LOW; } else { if (config->enable_high) - gflags = GPIOD_OUT_LOW; + cfg.ena_gpio_flags |= GPIOF_OUT_INIT_LOW; else - gflags = GPIOD_OUT_HIGH; + cfg.ena_gpio_flags |= GPIOF_OUT_INIT_HIGH; } - if (config->gpio_is_open_drain) { - if (gflags == GPIOD_OUT_HIGH) - gflags = GPIOD_OUT_HIGH_OPEN_DRAIN; - else - gflags = GPIOD_OUT_LOW_OPEN_DRAIN; - } - - cfg.ena_gpiod = devm_gpiod_get_optional(&pdev->dev, NULL, gflags); - if (IS_ERR(cfg.ena_gpiod)) - return PTR_ERR(cfg.ena_gpiod); + if (config->gpio_is_open_drain) + cfg.ena_gpio_flags |= GPIOF_OPEN_DRAIN; cfg.dev = &pdev->dev; cfg.init_data = config->init_data; diff --git a/drivers/regulator/gpio-regulator.c b/drivers/regulator/gpio-regulator.c index 9d6094c4d71c..a86b8997bb54 100644 --- a/drivers/regulator/gpio-regulator.c +++ b/drivers/regulator/gpio-regulator.c @@ -31,7 +31,6 @@ #include #include #include -#include #include #include #include @@ -162,6 +161,10 @@ 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)) @@ -252,7 +255,6 @@ 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), @@ -338,22 +340,21 @@ 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) - gflags = GPIOD_OUT_HIGH; + cfg.ena_gpio_flags |= GPIOF_OUT_INIT_HIGH; else - gflags = GPIOD_OUT_LOW; + cfg.ena_gpio_flags |= GPIOF_OUT_INIT_LOW; } else { if (config->enable_high) - gflags = GPIOD_OUT_LOW; + cfg.ena_gpio_flags |= GPIOF_OUT_INIT_LOW; else - 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; + cfg.ena_gpio_flags |= GPIOF_OUT_INIT_HIGH; } drvdata->dev = regulator_register(&drvdata->desc, &cfg); -- cgit