summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@linaro.org>2018-05-14 04:06:22 -0400
committerMark Brown <broonie@kernel.org>2018-05-29 10:53:17 -0400
commit6059577cb28d8b15d2b7dad51eb90d885f1ed9ab (patch)
treef84df9c39410203cb50963369b09a569a19c75d5
parent37fa23dbccbd97663acc085bd79246f427e603a1 (diff)
regulator: fixed: Convert to use GPIO descriptor only
As we augmented the regulator core to accept a GPIO descriptor instead of a GPIO number, we can augment the fixed GPIO regulator to look up and pass that descriptor directly from device tree or board GPIO descriptor look up tables. Some boards just auto-enumerate their fixed regulator platform devices and I have assumed they get names like "fixed-regulator.0" but it's pretty hard to guess this. I need some testing from board maintainers to be sure. Other boards are straight forward, using just plain "fixed-regulator" (ID -1) or "fixed-regulator.1" hammering down the device ID. The OMAP didn't have proper label names on its GPIO chips so I have fixed this with a separate patch to the GPIO tree, see commit 088413bc0bd5f5fb66ca22a19d66a49d7154ba4c "gpio: omap: Give unique labels to each GPIO bank/chip" It seems the da9055 and da9211 has never got around to actually passing any enable gpio into its platform data (not the in-tree code anyway) so we can just decide to simply pass a descriptor instead. The fixed GPIO-controlled regulator in mach-pxa/ezx.c was confusingly named "*_dummy_supply_device" while it is a very real device backed by a GPIO line. There is nothing dummy about it at all, so I renamed it with the infix *_regulator_* as part of this patch set. For the patch hunk hitting arch/blackfin I would say I do not expect testing, review or ACKs anymore so if it works, it works. The hunk hitting the x86 BCM43xx driver is especially tricky as the number comes out of SFI which is a mystery to me. I definately need someone to look at this. (Hi Andy.) Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com> # Check the x86 BCM stuff Cc: Alexander Shiyan <shc_work@mail.ru> # i.MX boards user Cc: Haojian Zhuang <haojian.zhuang@gmail.com> # MMP2 maintainer Cc: Aaro Koskinen <aaro.koskinen@iki.fi> # OMAP1 maintainer Cc: Tony Lindgren <tony@atomide.com> # OMAP1,2,3 maintainer Cc: Mike Rapoport <rppt@linux.vnet.ibm.com> # EM-X270 maintainer Cc: Robert Jarzmik <robert.jarzmik@free.fr> # EZX maintainer Cc: Philipp Zabel <philipp.zabel@gmail.com> # Magician maintainer Cc: Daniel Mack <zonque@gmail.com> # Raumfeld maintainer Cc: Marc Zyngier <marc.zyngier@arm.com> # Zeus maintainer Cc: Geert Uytterhoeven <geert+renesas@glider.be> # SuperH pinctrl/GPIO maintainer Cc: Russell King <rmk+kernel@armlinux.org.uk> # SA1100 Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Acked-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--arch/arm/mach-imx/mach-mx21ads.c13
-rw-r--r--arch/arm/mach-imx/mach-mx27ads.c12
-rw-r--r--arch/arm/mach-mmp/brownstone.c12
-rw-r--r--arch/arm/mach-omap1/board-ams-delta.c14
-rw-r--r--arch/arm/mach-omap2/pdata-quirks.c16
-rw-r--r--arch/arm/mach-pxa/em-x270.c1
-rw-r--r--arch/arm/mach-pxa/ezx.c33
-rw-r--r--arch/arm/mach-pxa/magician.c2
-rw-r--r--arch/arm/mach-pxa/raumfeld.c12
-rw-r--r--arch/arm/mach-pxa/zeus.c23
-rw-r--r--arch/arm/mach-s3c64xx/mach-crag6410.c1
-rw-r--r--arch/arm/mach-s3c64xx/mach-smdk6410.c1
-rw-r--r--arch/arm/mach-sa1100/assabet.c21
-rw-r--r--arch/arm/mach-sa1100/generic.c5
-rw-r--r--arch/arm/mach-sa1100/generic.h3
-rw-r--r--arch/arm/mach-sa1100/shannon.c4
-rw-r--r--arch/sh/boards/mach-ecovec24/setup.c22
-rw-r--r--arch/x86/platform/intel-mid/device_libs/platform_bcm43xx.c17
-rw-r--r--drivers/regulator/fixed-helper.c1
-rw-r--r--drivers/regulator/fixed.c33
-rw-r--r--include/linux/regulator/fixed.h3
21 files changed, 187 insertions, 62 deletions
diff --git a/arch/arm/mach-imx/mach-mx21ads.c b/arch/arm/mach-imx/mach-mx21ads.c
index 5e366824814f..5d3b6b4fe6db 100644
--- a/arch/arm/mach-imx/mach-mx21ads.c
+++ b/arch/arm/mach-imx/mach-mx21ads.c
@@ -18,6 +18,7 @@
18#include <linux/mtd/mtd.h> 18#include <linux/mtd/mtd.h>
19#include <linux/mtd/physmap.h> 19#include <linux/mtd/physmap.h>
20#include <linux/gpio/driver.h> 20#include <linux/gpio/driver.h>
21#include <linux/gpio/machine.h>
21#include <linux/gpio.h> 22#include <linux/gpio.h>
22#include <linux/regulator/fixed.h> 23#include <linux/regulator/fixed.h>
23#include <linux/regulator/machine.h> 24#include <linux/regulator/machine.h>
@@ -175,6 +176,7 @@ static struct resource mx21ads_mmgpio_resource =
175 DEFINE_RES_MEM_NAMED(MX21ADS_IO_REG, SZ_2, "dat"); 176 DEFINE_RES_MEM_NAMED(MX21ADS_IO_REG, SZ_2, "dat");
176 177
177static struct bgpio_pdata mx21ads_mmgpio_pdata = { 178static struct bgpio_pdata mx21ads_mmgpio_pdata = {
179 .label = "mx21ads-mmgpio",
178 .base = MX21ADS_MMGPIO_BASE, 180 .base = MX21ADS_MMGPIO_BASE,
179 .ngpio = 16, 181 .ngpio = 16,
180}; 182};
@@ -203,7 +205,6 @@ static struct regulator_init_data mx21ads_lcd_regulator_init_data = {
203static struct fixed_voltage_config mx21ads_lcd_regulator_pdata = { 205static struct fixed_voltage_config mx21ads_lcd_regulator_pdata = {
204 .supply_name = "LCD", 206 .supply_name = "LCD",
205 .microvolts = 3300000, 207 .microvolts = 3300000,
206 .gpio = MX21ADS_IO_LCDON,
207 .enable_high = 1, 208 .enable_high = 1,
208 .init_data = &mx21ads_lcd_regulator_init_data, 209 .init_data = &mx21ads_lcd_regulator_init_data,
209}; 210};
@@ -216,6 +217,15 @@ static struct platform_device mx21ads_lcd_regulator = {
216 }, 217 },
217}; 218};
218 219
220static struct gpiod_lookup_table mx21ads_lcd_regulator_gpiod_table = {
221 .dev_id = "reg-fixed-voltage.0", /* Let's hope ID 0 is what we get */
222 .table = {
223 GPIO_LOOKUP("mx21ads-mmgpio", 9,
224 "enable", GPIO_ACTIVE_HIGH),
225 { },
226 },
227};
228
219/* 229/*
220 * Connected is a portrait Sharp-QVGA display 230 * Connected is a portrait Sharp-QVGA display
221 * of type: LQ035Q7DB02 231 * of type: LQ035Q7DB02
@@ -311,6 +321,7 @@ static void __init mx21ads_late_init(void)
311{ 321{
312 imx21_add_mxc_mmc(0, &mx21ads_sdhc_pdata); 322 imx21_add_mxc_mmc(0, &mx21ads_sdhc_pdata);
313 323
324 gpiod_add_lookup_table(&mx21ads_lcd_regulator_gpiod_table);
314 platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices)); 325 platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
315 326
316 mx21ads_cs8900_resources[1].start = 327 mx21ads_cs8900_resources[1].start =
diff --git a/arch/arm/mach-imx/mach-mx27ads.c b/arch/arm/mach-imx/mach-mx27ads.c
index a04bb094ded1..0fdb88db0cbd 100644
--- a/arch/arm/mach-imx/mach-mx27ads.c
+++ b/arch/arm/mach-imx/mach-mx27ads.c
@@ -16,6 +16,7 @@
16#include <linux/gpio/driver.h> 16#include <linux/gpio/driver.h>
17/* Needed for gpio_to_irq() */ 17/* Needed for gpio_to_irq() */
18#include <linux/gpio.h> 18#include <linux/gpio.h>
19#include <linux/gpio/machine.h>
19#include <linux/platform_device.h> 20#include <linux/platform_device.h>
20#include <linux/mtd/mtd.h> 21#include <linux/mtd/mtd.h>
21#include <linux/mtd/map.h> 22#include <linux/mtd/map.h>
@@ -230,10 +231,17 @@ static struct regulator_init_data mx27ads_lcd_regulator_init_data = {
230static struct fixed_voltage_config mx27ads_lcd_regulator_pdata = { 231static struct fixed_voltage_config mx27ads_lcd_regulator_pdata = {
231 .supply_name = "LCD", 232 .supply_name = "LCD",
232 .microvolts = 3300000, 233 .microvolts = 3300000,
233 .gpio = MX27ADS_LCD_GPIO,
234 .init_data = &mx27ads_lcd_regulator_init_data, 234 .init_data = &mx27ads_lcd_regulator_init_data,
235}; 235};
236 236
237static struct gpiod_lookup_table mx27ads_lcd_regulator_gpiod_table = {
238 .dev_id = "reg-fixed-voltage.0", /* Let's hope ID 0 is what we get */
239 .table = {
240 GPIO_LOOKUP("LCD", 0, "enable", GPIO_ACTIVE_HIGH),
241 { },
242 },
243};
244
237static void __init mx27ads_regulator_init(void) 245static void __init mx27ads_regulator_init(void)
238{ 246{
239 struct gpio_chip *vchip; 247 struct gpio_chip *vchip;
@@ -247,6 +255,8 @@ static void __init mx27ads_regulator_init(void)
247 vchip->set = vgpio_set; 255 vchip->set = vgpio_set;
248 gpiochip_add_data(vchip, NULL); 256 gpiochip_add_data(vchip, NULL);
249 257
258 gpiod_add_lookup_table(&mx27ads_lcd_regulator_gpiod_table);
259
250 platform_device_register_data(NULL, "reg-fixed-voltage", 260 platform_device_register_data(NULL, "reg-fixed-voltage",
251 PLATFORM_DEVID_AUTO, 261 PLATFORM_DEVID_AUTO,
252 &mx27ads_lcd_regulator_pdata, 262 &mx27ads_lcd_regulator_pdata,
diff --git a/arch/arm/mach-mmp/brownstone.c b/arch/arm/mach-mmp/brownstone.c
index d1613b954926..563b5a278d65 100644
--- a/arch/arm/mach-mmp/brownstone.c
+++ b/arch/arm/mach-mmp/brownstone.c
@@ -15,6 +15,7 @@
15#include <linux/platform_device.h> 15#include <linux/platform_device.h>
16#include <linux/io.h> 16#include <linux/io.h>
17#include <linux/gpio-pxa.h> 17#include <linux/gpio-pxa.h>
18#include <linux/gpio/machine.h>
18#include <linux/regulator/machine.h> 19#include <linux/regulator/machine.h>
19#include <linux/regulator/max8649.h> 20#include <linux/regulator/max8649.h>
20#include <linux/regulator/fixed.h> 21#include <linux/regulator/fixed.h>
@@ -148,7 +149,6 @@ static struct regulator_init_data brownstone_v_5vp_data = {
148static struct fixed_voltage_config brownstone_v_5vp = { 149static struct fixed_voltage_config brownstone_v_5vp = {
149 .supply_name = "v_5vp", 150 .supply_name = "v_5vp",
150 .microvolts = 5000000, 151 .microvolts = 5000000,
151 .gpio = GPIO_5V_ENABLE,
152 .enable_high = 1, 152 .enable_high = 1,
153 .enabled_at_boot = 1, 153 .enabled_at_boot = 1,
154 .init_data = &brownstone_v_5vp_data, 154 .init_data = &brownstone_v_5vp_data,
@@ -162,6 +162,15 @@ static struct platform_device brownstone_v_5vp_device = {
162 }, 162 },
163}; 163};
164 164
165static struct gpiod_lookup_table brownstone_v_5vp_gpiod_table = {
166 .dev_id = "reg-fixed-voltage.1", /* .id set to 1 above */
167 .table = {
168 GPIO_LOOKUP("gpio-pxa", GPIO_5V_ENABLE,
169 "enable", GPIO_ACTIVE_HIGH),
170 { },
171 },
172};
173
165static struct max8925_platform_data brownstone_max8925_info = { 174static struct max8925_platform_data brownstone_max8925_info = {
166 .irq_base = MMP_NR_IRQS, 175 .irq_base = MMP_NR_IRQS,
167}; 176};
@@ -217,6 +226,7 @@ static void __init brownstone_init(void)
217 mmp2_add_isram(&mmp2_isram_platdata); 226 mmp2_add_isram(&mmp2_isram_platdata);
218 227
219 /* enable 5v regulator */ 228 /* enable 5v regulator */
229 gpiod_add_lookup_table(&brownstone_v_5vp_gpiod_table);
220 platform_device_register(&brownstone_v_5vp_device); 230 platform_device_register(&brownstone_v_5vp_device);
221} 231}
222 232
diff --git a/arch/arm/mach-omap1/board-ams-delta.c b/arch/arm/mach-omap1/board-ams-delta.c
index 52e8e53ca154..759fa18f6ab4 100644
--- a/arch/arm/mach-omap1/board-ams-delta.c
+++ b/arch/arm/mach-omap1/board-ams-delta.c
@@ -12,6 +12,7 @@
12 * published by the Free Software Foundation. 12 * published by the Free Software Foundation.
13 */ 13 */
14#include <linux/gpio/driver.h> 14#include <linux/gpio/driver.h>
15#include <linux/gpio/machine.h>
15#include <linux/gpio.h> 16#include <linux/gpio.h>
16#include <linux/kernel.h> 17#include <linux/kernel.h>
17#include <linux/init.h> 18#include <linux/init.h>
@@ -203,6 +204,7 @@ static struct resource latch2_resources[] = {
203}; 204};
204 205
205static struct bgpio_pdata latch2_pdata = { 206static struct bgpio_pdata latch2_pdata = {
207 .label = "ams-delta-latch2",
206 .base = AMS_DELTA_LATCH2_GPIO_BASE, 208 .base = AMS_DELTA_LATCH2_GPIO_BASE,
207 .ngpio = AMS_DELTA_LATCH2_NGPIO, 209 .ngpio = AMS_DELTA_LATCH2_NGPIO,
208}; 210};
@@ -272,7 +274,6 @@ static struct regulator_init_data modem_nreset_data = {
272static struct fixed_voltage_config modem_nreset_config = { 274static struct fixed_voltage_config modem_nreset_config = {
273 .supply_name = "modem_nreset", 275 .supply_name = "modem_nreset",
274 .microvolts = 3300000, 276 .microvolts = 3300000,
275 .gpio = AMS_DELTA_GPIO_PIN_MODEM_NRESET,
276 .startup_delay = 25000, 277 .startup_delay = 25000,
277 .enable_high = 1, 278 .enable_high = 1,
278 .enabled_at_boot = 1, 279 .enabled_at_boot = 1,
@@ -287,6 +288,16 @@ static struct platform_device modem_nreset_device = {
287 }, 288 },
288}; 289};
289 290
291static struct gpiod_lookup_table modem_nreset_gpiod_table = {
292 .dev_id = "reg-fixed-voltage",
293 .table = {
294 /* The AMS_DELTA_GPIO_PIN_MODEM_NRESET is at offset 12 */
295 GPIO_LOOKUP("ams-delta-latch2", 12,
296 "enable", GPIO_ACTIVE_HIGH),
297 { },
298 },
299};
300
290struct modem_private_data { 301struct modem_private_data {
291 struct regulator *regulator; 302 struct regulator *regulator;
292}; 303};
@@ -570,6 +581,7 @@ static int __init late_init(void)
570 581
571 platform_add_devices(late_devices, ARRAY_SIZE(late_devices)); 582 platform_add_devices(late_devices, ARRAY_SIZE(late_devices));
572 583
584 gpiod_add_lookup_table(&modem_nreset_gpiod_table);
573 err = platform_device_register(&modem_nreset_device); 585 err = platform_device_register(&modem_nreset_device);
574 if (err) { 586 if (err) {
575 pr_err("Couldn't register the modem regulator device\n"); 587 pr_err("Couldn't register the modem regulator device\n");
diff --git a/arch/arm/mach-omap2/pdata-quirks.c b/arch/arm/mach-omap2/pdata-quirks.c
index 6459816c2879..7d1447204fb8 100644
--- a/arch/arm/mach-omap2/pdata-quirks.c
+++ b/arch/arm/mach-omap2/pdata-quirks.c
@@ -10,6 +10,7 @@
10#include <linux/clk.h> 10#include <linux/clk.h>
11#include <linux/davinci_emac.h> 11#include <linux/davinci_emac.h>
12#include <linux/gpio.h> 12#include <linux/gpio.h>
13#include <linux/gpio/machine.h>
13#include <linux/init.h> 14#include <linux/init.h>
14#include <linux/kernel.h> 15#include <linux/kernel.h>
15#include <linux/of_platform.h> 16#include <linux/of_platform.h>
@@ -330,7 +331,6 @@ static struct regulator_init_data pandora_vmmc3 = {
330static struct fixed_voltage_config pandora_vwlan = { 331static struct fixed_voltage_config pandora_vwlan = {
331 .supply_name = "vwlan", 332 .supply_name = "vwlan",
332 .microvolts = 1800000, /* 1.8V */ 333 .microvolts = 1800000, /* 1.8V */
333 .gpio = PANDORA_WIFI_NRESET_GPIO,
334 .startup_delay = 50000, /* 50ms */ 334 .startup_delay = 50000, /* 50ms */
335 .enable_high = 1, 335 .enable_high = 1,
336 .init_data = &pandora_vmmc3, 336 .init_data = &pandora_vmmc3,
@@ -344,6 +344,19 @@ static struct platform_device pandora_vwlan_device = {
344 }, 344 },
345}; 345};
346 346
347static struct gpiod_lookup_table pandora_vwlan_gpiod_table = {
348 .dev_id = "reg-fixed-voltage.1",
349 .table = {
350 /*
351 * As this is a low GPIO number it should be at the first
352 * GPIO bank.
353 */
354 GPIO_LOOKUP("gpio-0-31", PANDORA_WIFI_NRESET_GPIO,
355 "enable", GPIO_ACTIVE_HIGH),
356 { },
357 },
358};
359
347static void pandora_wl1251_init_card(struct mmc_card *card) 360static void pandora_wl1251_init_card(struct mmc_card *card)
348{ 361{
349 /* 362 /*
@@ -405,6 +418,7 @@ fail:
405static void __init omap3_pandora_legacy_init(void) 418static void __init omap3_pandora_legacy_init(void)
406{ 419{
407 platform_device_register(&pandora_backlight); 420 platform_device_register(&pandora_backlight);
421 gpiod_add_lookup_table(&pandora_vwlan_gpiod_table);
408 platform_device_register(&pandora_vwlan_device); 422 platform_device_register(&pandora_vwlan_device);
409 omap_hsmmc_init(pandora_mmc3); 423 omap_hsmmc_init(pandora_mmc3);
410 omap_hsmmc_late_init(pandora_mmc3); 424 omap_hsmmc_late_init(pandora_mmc3);
diff --git a/arch/arm/mach-pxa/em-x270.c b/arch/arm/mach-pxa/em-x270.c
index 49022ad338e9..6d7d93981098 100644
--- a/arch/arm/mach-pxa/em-x270.c
+++ b/arch/arm/mach-pxa/em-x270.c
@@ -987,7 +987,6 @@ static struct fixed_voltage_config camera_dummy_config = {
987 .supply_name = "camera_vdd", 987 .supply_name = "camera_vdd",
988 .input_supply = "vcc cam", 988 .input_supply = "vcc cam",
989 .microvolts = 2800000, 989 .microvolts = 2800000,
990 .gpio = -1,
991 .enable_high = 0, 990 .enable_high = 0,
992 .init_data = &camera_dummy_initdata, 991 .init_data = &camera_dummy_initdata,
993}; 992};
diff --git a/arch/arm/mach-pxa/ezx.c b/arch/arm/mach-pxa/ezx.c
index 2c90b58f347d..2b4bd6d94855 100644
--- a/arch/arm/mach-pxa/ezx.c
+++ b/arch/arm/mach-pxa/ezx.c
@@ -21,6 +21,7 @@
21#include <linux/regulator/fixed.h> 21#include <linux/regulator/fixed.h>
22#include <linux/input.h> 22#include <linux/input.h>
23#include <linux/gpio.h> 23#include <linux/gpio.h>
24#include <linux/gpio/machine.h>
24#include <linux/gpio_keys.h> 25#include <linux/gpio_keys.h>
25#include <linux/leds-lp3944.h> 26#include <linux/leds-lp3944.h>
26#include <linux/platform_data/i2c-pxa.h> 27#include <linux/platform_data/i2c-pxa.h>
@@ -698,31 +699,39 @@ static struct pxa27x_keypad_platform_data e2_keypad_platform_data = {
698 699
699#if defined(CONFIG_MACH_EZX_A780) || defined(CONFIG_MACH_EZX_A910) 700#if defined(CONFIG_MACH_EZX_A780) || defined(CONFIG_MACH_EZX_A910)
700/* camera */ 701/* camera */
701static struct regulator_consumer_supply camera_dummy_supplies[] = { 702static struct regulator_consumer_supply camera_regulator_supplies[] = {
702 REGULATOR_SUPPLY("vdd", "0-005d"), 703 REGULATOR_SUPPLY("vdd", "0-005d"),
703}; 704};
704 705
705static struct regulator_init_data camera_dummy_initdata = { 706static struct regulator_init_data camera_regulator_initdata = {
706 .consumer_supplies = camera_dummy_supplies, 707 .consumer_supplies = camera_regulator_supplies,
707 .num_consumer_supplies = ARRAY_SIZE(camera_dummy_supplies), 708 .num_consumer_supplies = ARRAY_SIZE(camera_regulator_supplies),
708 .constraints = { 709 .constraints = {
709 .valid_ops_mask = REGULATOR_CHANGE_STATUS, 710 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
710 }, 711 },
711}; 712};
712 713
713static struct fixed_voltage_config camera_dummy_config = { 714static struct fixed_voltage_config camera_regulator_config = {
714 .supply_name = "camera_vdd", 715 .supply_name = "camera_vdd",
715 .microvolts = 2800000, 716 .microvolts = 2800000,
716 .gpio = GPIO50_nCAM_EN,
717 .enable_high = 0, 717 .enable_high = 0,
718 .init_data = &camera_dummy_initdata, 718 .init_data = &camera_regulator_initdata,
719}; 719};
720 720
721static struct platform_device camera_supply_dummy_device = { 721static struct platform_device camera_supply_regulator_device = {
722 .name = "reg-fixed-voltage", 722 .name = "reg-fixed-voltage",
723 .id = 1, 723 .id = 1,
724 .dev = { 724 .dev = {
725 .platform_data = &camera_dummy_config, 725 .platform_data = &camera_regulator_config,
726 },
727};
728
729static struct gpiod_lookup_table camera_supply_gpiod_table = {
730 .dev_id = "reg-fixed-voltage.1",
731 .table = {
732 GPIO_LOOKUP("gpio-pxa", GPIO50_nCAM_EN,
733 "enable", GPIO_ACTIVE_HIGH),
734 { },
726 }, 735 },
727}; 736};
728#endif 737#endif
@@ -800,7 +809,7 @@ static struct i2c_board_info a780_i2c_board_info[] = {
800 809
801static struct platform_device *a780_devices[] __initdata = { 810static struct platform_device *a780_devices[] __initdata = {
802 &a780_gpio_keys, 811 &a780_gpio_keys,
803 &camera_supply_dummy_device, 812 &camera_supply_regulator_device,
804}; 813};
805 814
806static void __init a780_init(void) 815static void __init a780_init(void)
@@ -823,6 +832,7 @@ static void __init a780_init(void)
823 if (a780_camera_init() == 0) 832 if (a780_camera_init() == 0)
824 pxa_set_camera_info(&a780_pxacamera_platform_data); 833 pxa_set_camera_info(&a780_pxacamera_platform_data);
825 834
835 gpiod_add_lookup_table(&camera_supply_gpiod_table);
826 pwm_add_table(ezx_pwm_lookup, ARRAY_SIZE(ezx_pwm_lookup)); 836 pwm_add_table(ezx_pwm_lookup, ARRAY_SIZE(ezx_pwm_lookup));
827 platform_add_devices(ARRAY_AND_SIZE(ezx_devices)); 837 platform_add_devices(ARRAY_AND_SIZE(ezx_devices));
828 platform_add_devices(ARRAY_AND_SIZE(a780_devices)); 838 platform_add_devices(ARRAY_AND_SIZE(a780_devices));
@@ -892,6 +902,7 @@ static void __init e680_init(void)
892 902
893 pxa_set_keypad_info(&e680_keypad_platform_data); 903 pxa_set_keypad_info(&e680_keypad_platform_data);
894 904
905 gpiod_add_lookup_table(&camera_supply_gpiod_table);
895 pwm_add_table(ezx_pwm_lookup, ARRAY_SIZE(ezx_pwm_lookup)); 906 pwm_add_table(ezx_pwm_lookup, ARRAY_SIZE(ezx_pwm_lookup));
896 platform_add_devices(ARRAY_AND_SIZE(ezx_devices)); 907 platform_add_devices(ARRAY_AND_SIZE(ezx_devices));
897 platform_add_devices(ARRAY_AND_SIZE(e680_devices)); 908 platform_add_devices(ARRAY_AND_SIZE(e680_devices));
@@ -1098,7 +1109,7 @@ static struct i2c_board_info __initdata a910_i2c_board_info[] = {
1098 1109
1099static struct platform_device *a910_devices[] __initdata = { 1110static struct platform_device *a910_devices[] __initdata = {
1100 &a910_gpio_keys, 1111 &a910_gpio_keys,
1101 &camera_supply_dummy_device, 1112 &camera_supply_regulator_device,
1102}; 1113};
1103 1114
1104static void __init a910_init(void) 1115static void __init a910_init(void)
diff --git a/arch/arm/mach-pxa/magician.c b/arch/arm/mach-pxa/magician.c
index c5325d1ae77b..14c0f80bc9e7 100644
--- a/arch/arm/mach-pxa/magician.c
+++ b/arch/arm/mach-pxa/magician.c
@@ -18,6 +18,7 @@
18#include <linux/platform_device.h> 18#include <linux/platform_device.h>
19#include <linux/delay.h> 19#include <linux/delay.h>
20#include <linux/gpio.h> 20#include <linux/gpio.h>
21#include <linux/gpio/machine.h>
21#include <linux/gpio_keys.h> 22#include <linux/gpio_keys.h>
22#include <linux/input.h> 23#include <linux/input.h>
23#include <linux/mfd/htc-pasic3.h> 24#include <linux/mfd/htc-pasic3.h>
@@ -696,7 +697,6 @@ static struct regulator_init_data vads7846_regulator = {
696static struct fixed_voltage_config vads7846 = { 697static struct fixed_voltage_config vads7846 = {
697 .supply_name = "vads7846", 698 .supply_name = "vads7846",
698 .microvolts = 3300000, /* probably */ 699 .microvolts = 3300000, /* probably */
699 .gpio = -EINVAL,
700 .startup_delay = 0, 700 .startup_delay = 0,
701 .init_data = &vads7846_regulator, 701 .init_data = &vads7846_regulator,
702}; 702};
diff --git a/arch/arm/mach-pxa/raumfeld.c b/arch/arm/mach-pxa/raumfeld.c
index 034345546f84..ee766e4ebddc 100644
--- a/arch/arm/mach-pxa/raumfeld.c
+++ b/arch/arm/mach-pxa/raumfeld.c
@@ -886,7 +886,6 @@ static struct regulator_init_data audio_va_initdata = {
886static struct fixed_voltage_config audio_va_config = { 886static struct fixed_voltage_config audio_va_config = {
887 .supply_name = "audio_va", 887 .supply_name = "audio_va",
888 .microvolts = 5000000, 888 .microvolts = 5000000,
889 .gpio = GPIO_AUDIO_VA_ENABLE,
890 .enable_high = 1, 889 .enable_high = 1,
891 .enabled_at_boot = 0, 890 .enabled_at_boot = 0,
892 .init_data = &audio_va_initdata, 891 .init_data = &audio_va_initdata,
@@ -900,6 +899,15 @@ static struct platform_device audio_va_device = {
900 }, 899 },
901}; 900};
902 901
902static struct gpiod_lookup_table audio_va_gpiod_table = {
903 .dev_id = "reg-fixed-voltage.0",
904 .table = {
905 GPIO_LOOKUP("gpio-pxa", GPIO_AUDIO_VA_ENABLE,
906 "enable", GPIO_ACTIVE_HIGH),
907 { },
908 },
909};
910
903/* Dummy supplies for Codec's VD/VLC */ 911/* Dummy supplies for Codec's VD/VLC */
904 912
905static struct regulator_consumer_supply audio_dummy_supplies[] = { 913static struct regulator_consumer_supply audio_dummy_supplies[] = {
@@ -918,7 +926,6 @@ static struct regulator_init_data audio_dummy_initdata = {
918static struct fixed_voltage_config audio_dummy_config = { 926static struct fixed_voltage_config audio_dummy_config = {
919 .supply_name = "audio_vd", 927 .supply_name = "audio_vd",
920 .microvolts = 3300000, 928 .microvolts = 3300000,
921 .gpio = -1,
922 .init_data = &audio_dummy_initdata, 929 .init_data = &audio_dummy_initdata,
923}; 930};
924 931
@@ -1033,6 +1040,7 @@ static void __init raumfeld_audio_init(void)
1033 else 1040 else
1034 gpio_direction_output(GPIO_MCLK_RESET, 1); 1041 gpio_direction_output(GPIO_MCLK_RESET, 1);
1035 1042
1043 gpiod_add_lookup_table(&audio_va_gpiod_table);
1036 platform_add_devices(ARRAY_AND_SIZE(audio_regulator_devices)); 1044 platform_add_devices(ARRAY_AND_SIZE(audio_regulator_devices));
1037} 1045}
1038 1046
diff --git a/arch/arm/mach-pxa/zeus.c b/arch/arm/mach-pxa/zeus.c
index e3851795d6d7..58e05afcece0 100644
--- a/arch/arm/mach-pxa/zeus.c
+++ b/arch/arm/mach-pxa/zeus.c
@@ -17,6 +17,7 @@
17#include <linux/irq.h> 17#include <linux/irq.h>
18#include <linux/pm.h> 18#include <linux/pm.h>
19#include <linux/gpio.h> 19#include <linux/gpio.h>
20#include <linux/gpio/machine.h>
20#include <linux/serial_8250.h> 21#include <linux/serial_8250.h>
21#include <linux/dm9000.h> 22#include <linux/dm9000.h>
22#include <linux/mmc/host.h> 23#include <linux/mmc/host.h>
@@ -410,7 +411,6 @@ static struct regulator_init_data can_regulator_init_data = {
410static struct fixed_voltage_config can_regulator_pdata = { 411static struct fixed_voltage_config can_regulator_pdata = {
411 .supply_name = "CAN_SHDN", 412 .supply_name = "CAN_SHDN",
412 .microvolts = 3300000, 413 .microvolts = 3300000,
413 .gpio = ZEUS_CAN_SHDN_GPIO,
414 .init_data = &can_regulator_init_data, 414 .init_data = &can_regulator_init_data,
415}; 415};
416 416
@@ -422,6 +422,15 @@ static struct platform_device can_regulator_device = {
422 }, 422 },
423}; 423};
424 424
425static struct gpiod_lookup_table can_regulator_gpiod_table = {
426 .dev_id = "reg-fixed-voltage.0",
427 .table = {
428 GPIO_LOOKUP("gpio-pxa", ZEUS_CAN_SHDN_GPIO,
429 "enable", GPIO_ACTIVE_HIGH),
430 { },
431 },
432};
433
425static struct mcp251x_platform_data zeus_mcp2515_pdata = { 434static struct mcp251x_platform_data zeus_mcp2515_pdata = {
426 .oscillator_frequency = 16*1000*1000, 435 .oscillator_frequency = 16*1000*1000,
427}; 436};
@@ -538,7 +547,6 @@ static struct regulator_init_data zeus_ohci_regulator_data = {
538static struct fixed_voltage_config zeus_ohci_regulator_config = { 547static struct fixed_voltage_config zeus_ohci_regulator_config = {
539 .supply_name = "vbus2", 548 .supply_name = "vbus2",
540 .microvolts = 5000000, /* 5.0V */ 549 .microvolts = 5000000, /* 5.0V */
541 .gpio = ZEUS_USB2_PWREN_GPIO,
542 .enable_high = 1, 550 .enable_high = 1,
543 .startup_delay = 0, 551 .startup_delay = 0,
544 .init_data = &zeus_ohci_regulator_data, 552 .init_data = &zeus_ohci_regulator_data,
@@ -552,6 +560,15 @@ static struct platform_device zeus_ohci_regulator_device = {
552 }, 560 },
553}; 561};
554 562
563static struct gpiod_lookup_table zeus_ohci_regulator_gpiod_table = {
564 .dev_id = "reg-fixed-voltage.0",
565 .table = {
566 GPIO_LOOKUP("gpio-pxa", ZEUS_USB2_PWREN_GPIO,
567 "enable", GPIO_ACTIVE_HIGH),
568 { },
569 },
570};
571
555static struct pxaohci_platform_data zeus_ohci_platform_data = { 572static struct pxaohci_platform_data zeus_ohci_platform_data = {
556 .port_mode = PMM_NPS_MODE, 573 .port_mode = PMM_NPS_MODE,
557 /* Clear Power Control Polarity Low and set Power Sense 574 /* Clear Power Control Polarity Low and set Power Sense
@@ -855,6 +872,8 @@ static void __init zeus_init(void)
855 872
856 pxa2xx_mfp_config(ARRAY_AND_SIZE(zeus_pin_config)); 873 pxa2xx_mfp_config(ARRAY_AND_SIZE(zeus_pin_config));
857 874
875 gpiod_add_lookup_table(&can_regulator_gpiod_table);
876 gpiod_add_lookup_table(&zeus_ohci_regulator_gpiod_table);
858 platform_add_devices(zeus_devices, ARRAY_SIZE(zeus_devices)); 877 platform_add_devices(zeus_devices, ARRAY_SIZE(zeus_devices));
859 878
860 zeus_register_ohci(); 879 zeus_register_ohci();
diff --git a/arch/arm/mach-s3c64xx/mach-crag6410.c b/arch/arm/mach-s3c64xx/mach-crag6410.c
index f04650297487..379424d72ae7 100644
--- a/arch/arm/mach-s3c64xx/mach-crag6410.c
+++ b/arch/arm/mach-s3c64xx/mach-crag6410.c
@@ -352,7 +352,6 @@ static struct fixed_voltage_config wallvdd_pdata = {
352 .supply_name = "WALLVDD", 352 .supply_name = "WALLVDD",
353 .microvolts = 5000000, 353 .microvolts = 5000000,
354 .init_data = &wallvdd_data, 354 .init_data = &wallvdd_data,
355 .gpio = -EINVAL,
356}; 355};
357 356
358static struct platform_device wallvdd_device = { 357static struct platform_device wallvdd_device = {
diff --git a/arch/arm/mach-s3c64xx/mach-smdk6410.c b/arch/arm/mach-s3c64xx/mach-smdk6410.c
index c46fa5dfd2e0..908e5aa831c8 100644
--- a/arch/arm/mach-s3c64xx/mach-smdk6410.c
+++ b/arch/arm/mach-s3c64xx/mach-smdk6410.c
@@ -222,7 +222,6 @@ static struct fixed_voltage_config smdk6410_b_pwr_5v_pdata = {
222 .supply_name = "B_PWR_5V", 222 .supply_name = "B_PWR_5V",
223 .microvolts = 5000000, 223 .microvolts = 5000000,
224 .init_data = &smdk6410_b_pwr_5v_data, 224 .init_data = &smdk6410_b_pwr_5v_data,
225 .gpio = -EINVAL,
226}; 225};
227 226
228static struct platform_device smdk6410_b_pwr_5v = { 227static struct platform_device smdk6410_b_pwr_5v = {
diff --git a/arch/arm/mach-sa1100/assabet.c b/arch/arm/mach-sa1100/assabet.c
index 575ec085cffa..dbb53c520165 100644
--- a/arch/arm/mach-sa1100/assabet.c
+++ b/arch/arm/mach-sa1100/assabet.c
@@ -101,7 +101,7 @@ static int __init assabet_init_gpio(void __iomem *reg, u32 def_val)
101 101
102 assabet_bcr_gc = gc; 102 assabet_bcr_gc = gc;
103 103
104 return gc->base; 104 return 0;
105} 105}
106 106
107/* 107/*
@@ -471,6 +471,14 @@ static struct fixed_voltage_config assabet_cf_vcc_pdata __initdata = {
471 .enable_high = 1, 471 .enable_high = 1,
472}; 472};
473 473
474static struct gpiod_lookup_table assabet_cf_vcc_gpio_table = {
475 .dev_id = "reg-fixed-voltage.0",
476 .table = {
477 GPIO_LOOKUP("assabet", 0, "enable", GPIO_ACTIVE_HIGH),
478 { },
479 },
480};
481
474static void __init assabet_init(void) 482static void __init assabet_init(void)
475{ 483{
476 /* 484 /*
@@ -517,9 +525,11 @@ static void __init assabet_init(void)
517 neponset_resources, ARRAY_SIZE(neponset_resources)); 525 neponset_resources, ARRAY_SIZE(neponset_resources));
518#endif 526#endif
519 } else { 527 } else {
528 gpiod_add_lookup_table(&assabet_cf_vcc_gpio_table);
520 sa11x0_register_fixed_regulator(0, &assabet_cf_vcc_pdata, 529 sa11x0_register_fixed_regulator(0, &assabet_cf_vcc_pdata,
521 assabet_cf_vcc_consumers, 530 assabet_cf_vcc_consumers,
522 ARRAY_SIZE(assabet_cf_vcc_consumers)); 531 ARRAY_SIZE(assabet_cf_vcc_consumers),
532 true);
523 533
524 } 534 }
525 535
@@ -802,7 +812,6 @@ fs_initcall(assabet_leds_init);
802 812
803void __init assabet_init_irq(void) 813void __init assabet_init_irq(void)
804{ 814{
805 unsigned int assabet_gpio_base;
806 u32 def_val; 815 u32 def_val;
807 816
808 sa1100_init_irq(); 817 sa1100_init_irq();
@@ -817,9 +826,7 @@ void __init assabet_init_irq(void)
817 * 826 *
818 * This must precede any driver calls to BCR_set() or BCR_clear(). 827 * This must precede any driver calls to BCR_set() or BCR_clear().
819 */ 828 */
820 assabet_gpio_base = assabet_init_gpio((void *)&ASSABET_BCR, def_val); 829 assabet_init_gpio((void *)&ASSABET_BCR, def_val);
821
822 assabet_cf_vcc_pdata.gpio = assabet_gpio_base + 0;
823} 830}
824 831
825MACHINE_START(ASSABET, "Intel-Assabet") 832MACHINE_START(ASSABET, "Intel-Assabet")
diff --git a/arch/arm/mach-sa1100/generic.c b/arch/arm/mach-sa1100/generic.c
index 7167ddf84a0e..800321c6cbd8 100644
--- a/arch/arm/mach-sa1100/generic.c
+++ b/arch/arm/mach-sa1100/generic.c
@@ -348,7 +348,8 @@ void __init sa11x0_init_late(void)
348 348
349int __init sa11x0_register_fixed_regulator(int n, 349int __init sa11x0_register_fixed_regulator(int n,
350 struct fixed_voltage_config *cfg, 350 struct fixed_voltage_config *cfg,
351 struct regulator_consumer_supply *supplies, unsigned num_supplies) 351 struct regulator_consumer_supply *supplies, unsigned num_supplies,
352 bool uses_gpio)
352{ 353{
353 struct regulator_init_data *id; 354 struct regulator_init_data *id;
354 355
@@ -356,7 +357,7 @@ int __init sa11x0_register_fixed_regulator(int n,
356 if (!cfg->init_data) 357 if (!cfg->init_data)
357 return -ENOMEM; 358 return -ENOMEM;
358 359
359 if (cfg->gpio < 0) 360 if (!uses_gpio)
360 id->constraints.always_on = 1; 361 id->constraints.always_on = 1;
361 id->constraints.name = cfg->supply_name; 362 id->constraints.name = cfg->supply_name;
362 id->constraints.min_uV = cfg->microvolts; 363 id->constraints.min_uV = cfg->microvolts;
diff --git a/arch/arm/mach-sa1100/generic.h b/arch/arm/mach-sa1100/generic.h
index 5f3cb52fa6ab..158a4fd5ca24 100644
--- a/arch/arm/mach-sa1100/generic.h
+++ b/arch/arm/mach-sa1100/generic.h
@@ -54,4 +54,5 @@ void sa11x0_register_pcmcia(int socket, struct gpiod_lookup_table *);
54struct fixed_voltage_config; 54struct fixed_voltage_config;
55struct regulator_consumer_supply; 55struct regulator_consumer_supply;
56int sa11x0_register_fixed_regulator(int n, struct fixed_voltage_config *cfg, 56int sa11x0_register_fixed_regulator(int n, struct fixed_voltage_config *cfg,
57 struct regulator_consumer_supply *supplies, unsigned num_supplies); 57 struct regulator_consumer_supply *supplies, unsigned num_supplies,
58 bool uses_gpio);
diff --git a/arch/arm/mach-sa1100/shannon.c b/arch/arm/mach-sa1100/shannon.c
index 22f7fe0b809f..5bc82e2671c6 100644
--- a/arch/arm/mach-sa1100/shannon.c
+++ b/arch/arm/mach-sa1100/shannon.c
@@ -102,14 +102,14 @@ static struct fixed_voltage_config shannon_cf_vcc_pdata __initdata = {
102 .supply_name = "cf-power", 102 .supply_name = "cf-power",
103 .microvolts = 3300000, 103 .microvolts = 3300000,
104 .enabled_at_boot = 1, 104 .enabled_at_boot = 1,
105 .gpio = -EINVAL,
106}; 105};
107 106
108static void __init shannon_init(void) 107static void __init shannon_init(void)
109{ 108{
110 sa11x0_register_fixed_regulator(0, &shannon_cf_vcc_pdata, 109 sa11x0_register_fixed_regulator(0, &shannon_cf_vcc_pdata,
111 shannon_cf_vcc_consumers, 110 shannon_cf_vcc_consumers,
112 ARRAY_SIZE(shannon_cf_vcc_consumers)); 111 ARRAY_SIZE(shannon_cf_vcc_consumers),
112 false);
113 sa11x0_register_pcmcia(0, &shannon_pcmcia0_gpio_table); 113 sa11x0_register_pcmcia(0, &shannon_pcmcia0_gpio_table);
114 sa11x0_register_pcmcia(1, &shannon_pcmcia1_gpio_table); 114 sa11x0_register_pcmcia(1, &shannon_pcmcia1_gpio_table);
115 sa11x0_ppc_configure_mcp(); 115 sa11x0_ppc_configure_mcp();
diff --git a/arch/sh/boards/mach-ecovec24/setup.c b/arch/sh/boards/mach-ecovec24/setup.c
index adc61d14172c..c296b5c399b7 100644
--- a/arch/sh/boards/mach-ecovec24/setup.c
+++ b/arch/sh/boards/mach-ecovec24/setup.c
@@ -633,7 +633,6 @@ static struct regulator_init_data cn12_power_init_data = {
633static struct fixed_voltage_config cn12_power_info = { 633static struct fixed_voltage_config cn12_power_info = {
634 .supply_name = "CN12 SD/MMC Vdd", 634 .supply_name = "CN12 SD/MMC Vdd",
635 .microvolts = 3300000, 635 .microvolts = 3300000,
636 .gpio = GPIO_PTB7,
637 .enable_high = 1, 636 .enable_high = 1,
638 .init_data = &cn12_power_init_data, 637 .init_data = &cn12_power_init_data,
639}; 638};
@@ -646,6 +645,16 @@ static struct platform_device cn12_power = {
646 }, 645 },
647}; 646};
648 647
648static struct gpiod_lookup_table cn12_power_gpiod_table = {
649 .dev_id = "reg-fixed-voltage.0",
650 .table = {
651 /* Offset 7 on port B */
652 GPIO_LOOKUP("sh7724_pfc", GPIO_PTB7,
653 "enable", GPIO_ACTIVE_HIGH),
654 { },
655 },
656};
657
649#if defined(CONFIG_MMC_SDHI) || defined(CONFIG_MMC_SDHI_MODULE) 658#if defined(CONFIG_MMC_SDHI) || defined(CONFIG_MMC_SDHI_MODULE)
650/* SDHI0 */ 659/* SDHI0 */
651static struct regulator_consumer_supply sdhi0_power_consumers[] = 660static struct regulator_consumer_supply sdhi0_power_consumers[] =
@@ -665,7 +674,6 @@ static struct regulator_init_data sdhi0_power_init_data = {
665static struct fixed_voltage_config sdhi0_power_info = { 674static struct fixed_voltage_config sdhi0_power_info = {
666 .supply_name = "CN11 SD/MMC Vdd", 675 .supply_name = "CN11 SD/MMC Vdd",
667 .microvolts = 3300000, 676 .microvolts = 3300000,
668 .gpio = GPIO_PTB6,
669 .enable_high = 1, 677 .enable_high = 1,
670 .init_data = &sdhi0_power_init_data, 678 .init_data = &sdhi0_power_init_data,
671}; 679};
@@ -678,6 +686,16 @@ static struct platform_device sdhi0_power = {
678 }, 686 },
679}; 687};
680 688
689static struct gpiod_lookup_table sdhi0_power_gpiod_table = {
690 .dev_id = "reg-fixed-voltage.1",
691 .table = {
692 /* Offset 6 on port B */
693 GPIO_LOOKUP("sh7724_pfc", GPIO_PTB6,
694 "enable", GPIO_ACTIVE_HIGH),
695 { },
696 },
697};
698
681static struct tmio_mmc_data sdhi0_info = { 699static struct tmio_mmc_data sdhi0_info = {
682 .chan_priv_tx = (void *)SHDMA_SLAVE_SDHI0_TX, 700 .chan_priv_tx = (void *)SHDMA_SLAVE_SDHI0_TX,
683 .chan_priv_rx = (void *)SHDMA_SLAVE_SDHI0_RX, 701 .chan_priv_rx = (void *)SHDMA_SLAVE_SDHI0_RX,
diff --git a/arch/x86/platform/intel-mid/device_libs/platform_bcm43xx.c b/arch/x86/platform/intel-mid/device_libs/platform_bcm43xx.c
index 4392c15ed9e0..fc77d69e51d7 100644
--- a/arch/x86/platform/intel-mid/device_libs/platform_bcm43xx.c
+++ b/arch/x86/platform/intel-mid/device_libs/platform_bcm43xx.c
@@ -10,7 +10,7 @@
10 * of the License. 10 * of the License.
11 */ 11 */
12 12
13#include <linux/gpio.h> 13#include <linux/gpio/machine.h>
14#include <linux/platform_device.h> 14#include <linux/platform_device.h>
15#include <linux/regulator/machine.h> 15#include <linux/regulator/machine.h>
16#include <linux/regulator/fixed.h> 16#include <linux/regulator/fixed.h>
@@ -43,7 +43,6 @@ static struct fixed_voltage_config bcm43xx_vmmc = {
43 * real voltage and signaling are still 1.8V. 43 * real voltage and signaling are still 1.8V.
44 */ 44 */
45 .microvolts = 2000000, /* 1.8V */ 45 .microvolts = 2000000, /* 1.8V */
46 .gpio = -EINVAL,
47 .startup_delay = 250 * 1000, /* 250ms */ 46 .startup_delay = 250 * 1000, /* 250ms */
48 .enable_high = 1, /* active high */ 47 .enable_high = 1, /* active high */
49 .enabled_at_boot = 0, /* disabled at boot */ 48 .enabled_at_boot = 0, /* disabled at boot */
@@ -58,11 +57,23 @@ static struct platform_device bcm43xx_vmmc_regulator = {
58 }, 57 },
59}; 58};
60 59
60static struct gpiod_lookup_table bcm43xx_vmmc_gpio_table = {
61 .dev_id = "reg-fixed-voltage.0",
62 .table = {
63 GPIO_LOOKUP("0000:00:0c.0", -1, "enable", GPIO_ACTIVE_LOW),
64 {}
65 },
66};
67
61static int __init bcm43xx_regulator_register(void) 68static int __init bcm43xx_regulator_register(void)
62{ 69{
70 struct gpiod_lookup_table *table = &bcm43xx_vmmc_gpio_table;
71 struct gpiod_lookup *lookup = table->table;
63 int ret; 72 int ret;
64 73
65 bcm43xx_vmmc.gpio = get_gpio_by_name(WLAN_SFI_GPIO_ENABLE_NAME); 74 lookup[0].chip_hwnum = get_gpio_by_name(WLAN_SFI_GPIO_ENABLE_NAME);
75 gpiod_add_lookup_table(table);
76
66 ret = platform_device_register(&bcm43xx_vmmc_regulator); 77 ret = platform_device_register(&bcm43xx_vmmc_regulator);
67 if (ret) { 78 if (ret) {
68 pr_err("%s: vmmc regulator register failed\n", __func__); 79 pr_err("%s: vmmc regulator register failed\n", __func__);
diff --git a/drivers/regulator/fixed-helper.c b/drivers/regulator/fixed-helper.c
index 777fac6fb4cb..2c6098e6f4bc 100644
--- a/drivers/regulator/fixed-helper.c
+++ b/drivers/regulator/fixed-helper.c
@@ -43,7 +43,6 @@ struct platform_device *regulator_register_always_on(int id, const char *name,
43 } 43 }
44 44
45 data->cfg.microvolts = uv; 45 data->cfg.microvolts = uv;
46 data->cfg.gpio = -EINVAL;
47 data->cfg.enabled_at_boot = 1; 46 data->cfg.enabled_at_boot = 1;
48 data->cfg.init_data = &data->init_data; 47 data->cfg.init_data = &data->init_data;
49 48
diff --git a/drivers/regulator/fixed.c b/drivers/regulator/fixed.c
index 988a7472c2ab..1142f195529b 100644
--- a/drivers/regulator/fixed.c
+++ b/drivers/regulator/fixed.c
@@ -24,10 +24,9 @@
24#include <linux/platform_device.h> 24#include <linux/platform_device.h>
25#include <linux/regulator/driver.h> 25#include <linux/regulator/driver.h>
26#include <linux/regulator/fixed.h> 26#include <linux/regulator/fixed.h>
27#include <linux/gpio.h> 27#include <linux/gpio/consumer.h>
28#include <linux/slab.h> 28#include <linux/slab.h>
29#include <linux/of.h> 29#include <linux/of.h>
30#include <linux/of_gpio.h>
31#include <linux/regulator/of_regulator.h> 30#include <linux/regulator/of_regulator.h>
32#include <linux/regulator/machine.h> 31#include <linux/regulator/machine.h>
33 32
@@ -78,10 +77,6 @@ of_get_fixed_voltage_config(struct device *dev,
78 if (init_data->constraints.boot_on) 77 if (init_data->constraints.boot_on)
79 config->enabled_at_boot = true; 78 config->enabled_at_boot = true;
80 79
81 config->gpio = of_get_named_gpio(np, "gpio", 0);
82 if ((config->gpio < 0) && (config->gpio != -ENOENT))
83 return ERR_PTR(config->gpio);
84
85 of_property_read_u32(np, "startup-delay-us", &config->startup_delay); 80 of_property_read_u32(np, "startup-delay-us", &config->startup_delay);
86 81
87 config->enable_high = of_property_read_bool(np, "enable-active-high"); 82 config->enable_high = of_property_read_bool(np, "enable-active-high");
@@ -102,6 +97,7 @@ static int reg_fixed_voltage_probe(struct platform_device *pdev)
102 struct fixed_voltage_config *config; 97 struct fixed_voltage_config *config;
103 struct fixed_voltage_data *drvdata; 98 struct fixed_voltage_data *drvdata;
104 struct regulator_config cfg = { }; 99 struct regulator_config cfg = { };
100 enum gpiod_flags gflags;
105 int ret; 101 int ret;
106 102
107 drvdata = devm_kzalloc(&pdev->dev, sizeof(struct fixed_voltage_data), 103 drvdata = devm_kzalloc(&pdev->dev, sizeof(struct fixed_voltage_data),
@@ -150,25 +146,28 @@ static int reg_fixed_voltage_probe(struct platform_device *pdev)
150 146
151 drvdata->desc.fixed_uV = config->microvolts; 147 drvdata->desc.fixed_uV = config->microvolts;
152 148
153 if (gpio_is_valid(config->gpio)) {
154 cfg.ena_gpio = config->gpio;
155 if (pdev->dev.of_node)
156 cfg.ena_gpio_initialized = true;
157 }
158 cfg.ena_gpio_invert = !config->enable_high; 149 cfg.ena_gpio_invert = !config->enable_high;
159 if (config->enabled_at_boot) { 150 if (config->enabled_at_boot) {
160 if (config->enable_high) 151 if (config->enable_high)
161 cfg.ena_gpio_flags |= GPIOF_OUT_INIT_HIGH; 152 gflags = GPIOD_OUT_HIGH;
162 else 153 else
163 cfg.ena_gpio_flags |= GPIOF_OUT_INIT_LOW; 154 gflags = GPIOD_OUT_LOW;
164 } else { 155 } else {
165 if (config->enable_high) 156 if (config->enable_high)
166 cfg.ena_gpio_flags |= GPIOF_OUT_INIT_LOW; 157 gflags = GPIOD_OUT_LOW;
167 else 158 else
168 cfg.ena_gpio_flags |= GPIOF_OUT_INIT_HIGH; 159 gflags = GPIOD_OUT_HIGH;
169 } 160 }
170 if (config->gpio_is_open_drain) 161 if (config->gpio_is_open_drain) {
171 cfg.ena_gpio_flags |= GPIOF_OPEN_DRAIN; 162 if (gflags == GPIOD_OUT_HIGH)
163 gflags = GPIOD_OUT_HIGH_OPEN_DRAIN;
164 else
165 gflags = GPIOD_OUT_LOW_OPEN_DRAIN;
166 }
167
168 cfg.ena_gpiod = devm_gpiod_get_optional(&pdev->dev, NULL, gflags);
169 if (IS_ERR(cfg.ena_gpiod))
170 return PTR_ERR(cfg.ena_gpiod);
172 171
173 cfg.dev = &pdev->dev; 172 cfg.dev = &pdev->dev;
174 cfg.init_data = config->init_data; 173 cfg.init_data = config->init_data;
diff --git a/include/linux/regulator/fixed.h b/include/linux/regulator/fixed.h
index 48918be649d4..1a4340ed8e2b 100644
--- a/include/linux/regulator/fixed.h
+++ b/include/linux/regulator/fixed.h
@@ -24,8 +24,6 @@ struct regulator_init_data;
24 * @supply_name: Name of the regulator supply 24 * @supply_name: Name of the regulator supply
25 * @input_supply: Name of the input regulator supply 25 * @input_supply: Name of the input regulator supply
26 * @microvolts: Output voltage of regulator 26 * @microvolts: Output voltage of regulator
27 * @gpio: GPIO to use for enable control
28 * set to -EINVAL if not used
29 * @startup_delay: Start-up time in microseconds 27 * @startup_delay: Start-up time in microseconds
30 * @gpio_is_open_drain: Gpio pin is open drain or normal type. 28 * @gpio_is_open_drain: Gpio pin is open drain or normal type.
31 * If it is open drain type then HIGH will be set 29 * If it is open drain type then HIGH will be set
@@ -49,7 +47,6 @@ struct fixed_voltage_config {
49 const char *supply_name; 47 const char *supply_name;
50 const char *input_supply; 48 const char *input_supply;
51 int microvolts; 49 int microvolts;
52 int gpio;
53 unsigned startup_delay; 50 unsigned startup_delay;
54 unsigned gpio_is_open_drain:1; 51 unsigned gpio_is_open_drain:1;
55 unsigned enable_high:1; 52 unsigned enable_high:1;