summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/arm/mach-pxa/hx4700.c12
-rw-r--r--arch/arm/mach-pxa/magician.c11
-rw-r--r--drivers/regulator/gpio-regulator.c23
-rw-r--r--include/linux/regulator/gpio-regulator.h3
4 files changed, 32 insertions, 17 deletions
diff --git a/arch/arm/mach-pxa/hx4700.c b/arch/arm/mach-pxa/hx4700.c
index e2e7f247a645..6717a10180eb 100644
--- a/arch/arm/mach-pxa/hx4700.c
+++ b/arch/arm/mach-pxa/hx4700.c
@@ -20,6 +20,7 @@
20#include <linux/delay.h> 20#include <linux/delay.h>
21#include <linux/fb.h> 21#include <linux/fb.h>
22#include <linux/gpio.h> 22#include <linux/gpio.h>
23#include <linux/gpio/machine.h>
23#include <linux/gpio_keys.h> 24#include <linux/gpio_keys.h>
24#include <linux/input.h> 25#include <linux/input.h>
25#include <linux/input/navpoint.h> 26#include <linux/input/navpoint.h>
@@ -711,7 +712,6 @@ static struct gpio_regulator_state bq24022_states[] = {
711static struct gpio_regulator_config bq24022_info = { 712static struct gpio_regulator_config bq24022_info = {
712 .supply_name = "bq24022", 713 .supply_name = "bq24022",
713 714
714 .enable_gpio = GPIO72_HX4700_BQ24022_nCHARGE_EN,
715 .enable_high = 0, 715 .enable_high = 0,
716 .enabled_at_boot = 0, 716 .enabled_at_boot = 0,
717 717
@@ -733,6 +733,15 @@ static struct platform_device bq24022 = {
733 }, 733 },
734}; 734};
735 735
736static struct gpiod_lookup_table bq24022_gpiod_table = {
737 .dev_id = "gpio-regulator",
738 .table = {
739 GPIO_LOOKUP("gpio-pxa", GPIO72_HX4700_BQ24022_nCHARGE_EN,
740 "enable", GPIO_ACTIVE_HIGH),
741 { },
742 },
743};
744
736/* 745/*
737 * StrataFlash 746 * StrataFlash
738 */ 747 */
@@ -875,6 +884,7 @@ static void __init hx4700_init(void)
875 pxa_set_btuart_info(NULL); 884 pxa_set_btuart_info(NULL);
876 pxa_set_stuart_info(NULL); 885 pxa_set_stuart_info(NULL);
877 886
887 gpiod_add_lookup_table(&bq24022_gpiod_table);
878 platform_add_devices(devices, ARRAY_SIZE(devices)); 888 platform_add_devices(devices, ARRAY_SIZE(devices));
879 pwm_add_table(hx4700_pwm_lookup, ARRAY_SIZE(hx4700_pwm_lookup)); 889 pwm_add_table(hx4700_pwm_lookup, ARRAY_SIZE(hx4700_pwm_lookup));
880 890
diff --git a/arch/arm/mach-pxa/magician.c b/arch/arm/mach-pxa/magician.c
index 14c0f80bc9e7..9a5bda3ea194 100644
--- a/arch/arm/mach-pxa/magician.c
+++ b/arch/arm/mach-pxa/magician.c
@@ -657,7 +657,6 @@ static struct gpio_regulator_state bq24022_states[] = {
657static struct gpio_regulator_config bq24022_info = { 657static struct gpio_regulator_config bq24022_info = {
658 .supply_name = "bq24022", 658 .supply_name = "bq24022",
659 659
660 .enable_gpio = GPIO30_MAGICIAN_BQ24022_nCHARGE_EN,
661 .enable_high = 0, 660 .enable_high = 0,
662 .enabled_at_boot = 1, 661 .enabled_at_boot = 1,
663 662
@@ -679,6 +678,15 @@ static struct platform_device bq24022 = {
679 }, 678 },
680}; 679};
681 680
681static struct gpiod_lookup_table bq24022_gpiod_table = {
682 .dev_id = "gpio-regulator",
683 .table = {
684 GPIO_LOOKUP("gpio-pxa", GPIO30_MAGICIAN_BQ24022_nCHARGE_EN,
685 "enable", GPIO_ACTIVE_HIGH),
686 { },
687 },
688};
689
682/* 690/*
683 * fixed regulator for ads7846 691 * fixed regulator for ads7846
684 */ 692 */
@@ -1007,6 +1015,7 @@ static void __init magician_init(void)
1007 regulator_register_always_on(0, "power", pwm_backlight_supply, 1015 regulator_register_always_on(0, "power", pwm_backlight_supply,
1008 ARRAY_SIZE(pwm_backlight_supply), 5000000); 1016 ARRAY_SIZE(pwm_backlight_supply), 5000000);
1009 1017
1018 gpiod_add_lookup_table(&bq24022_gpiod_table);
1010 platform_add_devices(ARRAY_AND_SIZE(devices)); 1019 platform_add_devices(ARRAY_AND_SIZE(devices));
1011} 1020}
1012 1021
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 @@
31#include <linux/regulator/of_regulator.h> 31#include <linux/regulator/of_regulator.h>
32#include <linux/regulator/gpio-regulator.h> 32#include <linux/regulator/gpio-regulator.h>
33#include <linux/gpio.h> 33#include <linux/gpio.h>
34#include <linux/gpio/consumer.h>
34#include <linux/slab.h> 35#include <linux/slab.h>
35#include <linux/of.h> 36#include <linux/of.h>
36#include <linux/of_gpio.h> 37#include <linux/of_gpio.h>
@@ -161,10 +162,6 @@ of_get_gpio_regulator_config(struct device *dev, struct device_node *np,
161 162
162 of_property_read_u32(np, "startup-delay-us", &config->startup_delay); 163 of_property_read_u32(np, "startup-delay-us", &config->startup_delay);
163 164
164 config->enable_gpio = of_get_named_gpio(np, "enable-gpio", 0);
165 if (config->enable_gpio < 0 && config->enable_gpio != -ENOENT)
166 return ERR_PTR(config->enable_gpio);
167
168 /* Fetch GPIOs. - optional property*/ 165 /* Fetch GPIOs. - optional property*/
169 ret = of_gpio_count(np); 166 ret = of_gpio_count(np);
170 if ((ret < 0) && (ret != -ENOENT)) 167 if ((ret < 0) && (ret != -ENOENT))
@@ -255,6 +252,7 @@ static int gpio_regulator_probe(struct platform_device *pdev)
255 struct device_node *np = pdev->dev.of_node; 252 struct device_node *np = pdev->dev.of_node;
256 struct gpio_regulator_data *drvdata; 253 struct gpio_regulator_data *drvdata;
257 struct regulator_config cfg = { }; 254 struct regulator_config cfg = { };
255 enum gpiod_flags gflags;
258 int ptr, ret, state; 256 int ptr, ret, state;
259 257
260 drvdata = devm_kzalloc(&pdev->dev, sizeof(struct gpio_regulator_data), 258 drvdata = devm_kzalloc(&pdev->dev, sizeof(struct gpio_regulator_data),
@@ -340,21 +338,22 @@ static int gpio_regulator_probe(struct platform_device *pdev)
340 cfg.driver_data = drvdata; 338 cfg.driver_data = drvdata;
341 cfg.of_node = np; 339 cfg.of_node = np;
342 340
343 if (gpio_is_valid(config->enable_gpio)) {
344 cfg.ena_gpio = config->enable_gpio;
345 cfg.ena_gpio_initialized = true;
346 }
347 cfg.ena_gpio_invert = !config->enable_high; 341 cfg.ena_gpio_invert = !config->enable_high;
348 if (config->enabled_at_boot) { 342 if (config->enabled_at_boot) {
349 if (config->enable_high) 343 if (config->enable_high)
350 cfg.ena_gpio_flags |= GPIOF_OUT_INIT_HIGH; 344 gflags = GPIOD_OUT_HIGH;
351 else 345 else
352 cfg.ena_gpio_flags |= GPIOF_OUT_INIT_LOW; 346 gflags = GPIOD_OUT_LOW;
353 } else { 347 } else {
354 if (config->enable_high) 348 if (config->enable_high)
355 cfg.ena_gpio_flags |= GPIOF_OUT_INIT_LOW; 349 gflags = GPIOD_OUT_LOW;
356 else 350 else
357 cfg.ena_gpio_flags |= GPIOF_OUT_INIT_HIGH; 351 gflags = GPIOD_OUT_HIGH;
352 }
353 cfg.ena_gpiod = devm_gpiod_get_optional(&pdev->dev, "enable", gflags);
354 if (IS_ERR(cfg.ena_gpiod)) {
355 ret = PTR_ERR(cfg.ena_gpiod);
356 goto err_stategpio;
358 } 357 }
359 358
360 drvdata->dev = regulator_register(&drvdata->desc, &cfg); 359 drvdata->dev = regulator_register(&drvdata->desc, &cfg);
diff --git a/include/linux/regulator/gpio-regulator.h b/include/linux/regulator/gpio-regulator.h
index 19fbd267406d..536cab86f2d5 100644
--- a/include/linux/regulator/gpio-regulator.h
+++ b/include/linux/regulator/gpio-regulator.h
@@ -44,8 +44,6 @@ struct gpio_regulator_state {
44/** 44/**
45 * struct gpio_regulator_config - config structure 45 * struct gpio_regulator_config - config structure
46 * @supply_name: Name of the regulator supply 46 * @supply_name: Name of the regulator supply
47 * @enable_gpio: GPIO to use for enable control
48 * set to -EINVAL if not used
49 * @enable_high: Polarity of enable GPIO 47 * @enable_high: Polarity of enable GPIO
50 * 1 = Active high, 0 = Active low 48 * 1 = Active high, 0 = Active low
51 * @enabled_at_boot: Whether regulator has been enabled at 49 * @enabled_at_boot: Whether regulator has been enabled at
@@ -69,7 +67,6 @@ struct gpio_regulator_state {
69struct gpio_regulator_config { 67struct gpio_regulator_config {
70 const char *supply_name; 68 const char *supply_name;
71 69
72 int enable_gpio;
73 unsigned enable_high:1; 70 unsigned enable_high:1;
74 unsigned enabled_at_boot:1; 71 unsigned enabled_at_boot:1;
75 unsigned startup_delay; 72 unsigned startup_delay;