Skip to content

Commit efdfeb0

Browse files
linuswbroonie
authored andcommitted
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. 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. Intel MID portions tested by Andy. Tested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> # Check the x86 BCM stuff Acked-by: Tony Lindgren <tony@atomide.com> # OMAP1,2,3 maintainer Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Reviewed-by: Janusz Krzysztofik <jmkrzyszt@gmail.com> Reviewed-by: Mike Rapoport <rppt@linux.vnet.ibm.com> Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 1efef7c commit efdfeb0

File tree

21 files changed

+188
-63
lines changed

21 files changed

+188
-63
lines changed

arch/arm/mach-imx/mach-mx21ads.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <linux/mtd/mtd.h>
1919
#include <linux/mtd/physmap.h>
2020
#include <linux/gpio/driver.h>
21+
#include <linux/gpio/machine.h>
2122
#include <linux/gpio.h>
2223
#include <linux/regulator/fixed.h>
2324
#include <linux/regulator/machine.h>
@@ -175,6 +176,7 @@ static struct resource mx21ads_mmgpio_resource =
175176
DEFINE_RES_MEM_NAMED(MX21ADS_IO_REG, SZ_2, "dat");
176177

177178
static struct bgpio_pdata mx21ads_mmgpio_pdata = {
179+
.label = "mx21ads-mmgpio",
178180
.base = MX21ADS_MMGPIO_BASE,
179181
.ngpio = 16,
180182
};
@@ -203,7 +205,6 @@ static struct regulator_init_data mx21ads_lcd_regulator_init_data = {
203205
static struct fixed_voltage_config mx21ads_lcd_regulator_pdata = {
204206
.supply_name = "LCD",
205207
.microvolts = 3300000,
206-
.gpio = MX21ADS_IO_LCDON,
207208
.enable_high = 1,
208209
.init_data = &mx21ads_lcd_regulator_init_data,
209210
};
@@ -216,6 +217,14 @@ static struct platform_device mx21ads_lcd_regulator = {
216217
},
217218
};
218219

220+
static 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, NULL, GPIO_ACTIVE_HIGH),
224+
{ },
225+
},
226+
};
227+
219228
/*
220229
* Connected is a portrait Sharp-QVGA display
221230
* of type: LQ035Q7DB02
@@ -311,6 +320,7 @@ static void __init mx21ads_late_init(void)
311320
{
312321
imx21_add_mxc_mmc(0, &mx21ads_sdhc_pdata);
313322

323+
gpiod_add_lookup_table(&mx21ads_lcd_regulator_gpiod_table);
314324
platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
315325

316326
mx21ads_cs8900_resources[1].start =

arch/arm/mach-imx/mach-mx27ads.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <linux/gpio/driver.h>
1717
/* Needed for gpio_to_irq() */
1818
#include <linux/gpio.h>
19+
#include <linux/gpio/machine.h>
1920
#include <linux/platform_device.h>
2021
#include <linux/mtd/mtd.h>
2122
#include <linux/mtd/map.h>
@@ -230,10 +231,17 @@ static struct regulator_init_data mx27ads_lcd_regulator_init_data = {
230231
static struct fixed_voltage_config mx27ads_lcd_regulator_pdata = {
231232
.supply_name = "LCD",
232233
.microvolts = 3300000,
233-
.gpio = MX27ADS_LCD_GPIO,
234234
.init_data = &mx27ads_lcd_regulator_init_data,
235235
};
236236

237+
static 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, NULL, GPIO_ACTIVE_HIGH),
241+
{ },
242+
},
243+
};
244+
237245
static void __init mx27ads_regulator_init(void)
238246
{
239247
struct gpio_chip *vchip;
@@ -247,6 +255,8 @@ static void __init mx27ads_regulator_init(void)
247255
vchip->set = vgpio_set;
248256
gpiochip_add_data(vchip, NULL);
249257

258+
gpiod_add_lookup_table(&mx27ads_lcd_regulator_gpiod_table);
259+
250260
platform_device_register_data(NULL, "reg-fixed-voltage",
251261
PLATFORM_DEVID_AUTO,
252262
&mx27ads_lcd_regulator_pdata,

arch/arm/mach-mmp/brownstone.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <linux/platform_device.h>
1616
#include <linux/io.h>
1717
#include <linux/gpio-pxa.h>
18+
#include <linux/gpio/machine.h>
1819
#include <linux/regulator/machine.h>
1920
#include <linux/regulator/max8649.h>
2021
#include <linux/regulator/fixed.h>
@@ -148,7 +149,6 @@ static struct regulator_init_data brownstone_v_5vp_data = {
148149
static struct fixed_voltage_config brownstone_v_5vp = {
149150
.supply_name = "v_5vp",
150151
.microvolts = 5000000,
151-
.gpio = GPIO_5V_ENABLE,
152152
.enable_high = 1,
153153
.enabled_at_boot = 1,
154154
.init_data = &brownstone_v_5vp_data,
@@ -162,6 +162,15 @@ static struct platform_device brownstone_v_5vp_device = {
162162
},
163163
};
164164

165+
static 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+
NULL, GPIO_ACTIVE_HIGH),
170+
{ },
171+
},
172+
};
173+
165174
static struct max8925_platform_data brownstone_max8925_info = {
166175
.irq_base = MMP_NR_IRQS,
167176
};
@@ -217,6 +226,7 @@ static void __init brownstone_init(void)
217226
mmp2_add_isram(&mmp2_isram_platdata);
218227

219228
/* enable 5v regulator */
229+
gpiod_add_lookup_table(&brownstone_v_5vp_gpiod_table);
220230
platform_device_register(&brownstone_v_5vp_device);
221231
}
222232

arch/arm/mach-omap1/board-ams-delta.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,6 @@ static struct regulator_init_data modem_nreset_data = {
300300
static struct fixed_voltage_config modem_nreset_config = {
301301
.supply_name = "modem_nreset",
302302
.microvolts = 3300000,
303-
.gpio = AMS_DELTA_GPIO_PIN_MODEM_NRESET,
304303
.startup_delay = 25000,
305304
.enable_high = 1,
306305
.enabled_at_boot = 1,
@@ -315,6 +314,15 @@ static struct platform_device modem_nreset_device = {
315314
},
316315
};
317316

317+
static struct gpiod_lookup_table ams_delta_nreset_gpiod_table = {
318+
.dev_id = "reg-fixed-voltage",
319+
.table = {
320+
GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_MODEM_NRESET,
321+
NULL, GPIO_ACTIVE_HIGH),
322+
{ },
323+
},
324+
};
325+
318326
struct modem_private_data {
319327
struct regulator *regulator;
320328
};
@@ -568,7 +576,6 @@ static struct regulator_init_data keybrd_pwr_initdata = {
568576
static struct fixed_voltage_config keybrd_pwr_config = {
569577
.supply_name = "keybrd_pwr",
570578
.microvolts = 5000000,
571-
.gpio = AMS_DELTA_GPIO_PIN_KEYBRD_PWR,
572579
.enable_high = 1,
573580
.init_data = &keybrd_pwr_initdata,
574581
};
@@ -602,6 +609,7 @@ static struct platform_device *ams_delta_devices[] __initdata = {
602609
};
603610

604611
static struct gpiod_lookup_table *ams_delta_gpio_tables[] __initdata = {
612+
&ams_delta_nreset_gpiod_table,
605613
&ams_delta_audio_gpio_table,
606614
&keybrd_pwr_gpio_table,
607615
&ams_delta_lcd_gpio_table,

arch/arm/mach-omap2/pdata-quirks.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <linux/clk.h>
1111
#include <linux/davinci_emac.h>
1212
#include <linux/gpio.h>
13+
#include <linux/gpio/machine.h>
1314
#include <linux/init.h>
1415
#include <linux/kernel.h>
1516
#include <linux/of_platform.h>
@@ -328,7 +329,6 @@ static struct regulator_init_data pandora_vmmc3 = {
328329
static struct fixed_voltage_config pandora_vwlan = {
329330
.supply_name = "vwlan",
330331
.microvolts = 1800000, /* 1.8V */
331-
.gpio = PANDORA_WIFI_NRESET_GPIO,
332332
.startup_delay = 50000, /* 50ms */
333333
.enable_high = 1,
334334
.init_data = &pandora_vmmc3,
@@ -342,6 +342,19 @@ static struct platform_device pandora_vwlan_device = {
342342
},
343343
};
344344

345+
static struct gpiod_lookup_table pandora_vwlan_gpiod_table = {
346+
.dev_id = "reg-fixed-voltage.1",
347+
.table = {
348+
/*
349+
* As this is a low GPIO number it should be at the first
350+
* GPIO bank.
351+
*/
352+
GPIO_LOOKUP("gpio-0-31", PANDORA_WIFI_NRESET_GPIO,
353+
NULL, GPIO_ACTIVE_HIGH),
354+
{ },
355+
},
356+
};
357+
345358
static void pandora_wl1251_init_card(struct mmc_card *card)
346359
{
347360
/*
@@ -403,6 +416,7 @@ static void __init pandora_wl1251_init(void)
403416
static void __init omap3_pandora_legacy_init(void)
404417
{
405418
platform_device_register(&pandora_backlight);
419+
gpiod_add_lookup_table(&pandora_vwlan_gpiod_table);
406420
platform_device_register(&pandora_vwlan_device);
407421
omap_hsmmc_init(pandora_mmc3);
408422
omap_hsmmc_late_init(pandora_mmc3);

arch/arm/mach-pxa/em-x270.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -986,7 +986,6 @@ static struct fixed_voltage_config camera_dummy_config = {
986986
.supply_name = "camera_vdd",
987987
.input_supply = "vcc cam",
988988
.microvolts = 2800000,
989-
.gpio = -1,
990989
.enable_high = 0,
991990
.init_data = &camera_dummy_initdata,
992991
};

arch/arm/mach-pxa/ezx.c

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <linux/regulator/fixed.h>
2222
#include <linux/input.h>
2323
#include <linux/gpio.h>
24+
#include <linux/gpio/machine.h>
2425
#include <linux/gpio_keys.h>
2526
#include <linux/leds-lp3944.h>
2627
#include <linux/platform_data/i2c-pxa.h>
@@ -698,31 +699,39 @@ static struct pxa27x_keypad_platform_data e2_keypad_platform_data = {
698699

699700
#if defined(CONFIG_MACH_EZX_A780) || defined(CONFIG_MACH_EZX_A910)
700701
/* camera */
701-
static struct regulator_consumer_supply camera_dummy_supplies[] = {
702+
static struct regulator_consumer_supply camera_regulator_supplies[] = {
702703
REGULATOR_SUPPLY("vdd", "0-005d"),
703704
};
704705

705-
static struct regulator_init_data camera_dummy_initdata = {
706-
.consumer_supplies = camera_dummy_supplies,
707-
.num_consumer_supplies = ARRAY_SIZE(camera_dummy_supplies),
706+
static struct regulator_init_data camera_regulator_initdata = {
707+
.consumer_supplies = camera_regulator_supplies,
708+
.num_consumer_supplies = ARRAY_SIZE(camera_regulator_supplies),
708709
.constraints = {
709710
.valid_ops_mask = REGULATOR_CHANGE_STATUS,
710711
},
711712
};
712713

713-
static struct fixed_voltage_config camera_dummy_config = {
714+
static struct fixed_voltage_config camera_regulator_config = {
714715
.supply_name = "camera_vdd",
715716
.microvolts = 2800000,
716-
.gpio = GPIO50_nCAM_EN,
717717
.enable_high = 0,
718-
.init_data = &camera_dummy_initdata,
718+
.init_data = &camera_regulator_initdata,
719719
};
720720

721-
static struct platform_device camera_supply_dummy_device = {
721+
static struct platform_device camera_supply_regulator_device = {
722722
.name = "reg-fixed-voltage",
723723
.id = 1,
724724
.dev = {
725-
.platform_data = &camera_dummy_config,
725+
.platform_data = &camera_regulator_config,
726+
},
727+
};
728+
729+
static 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+
NULL, GPIO_ACTIVE_HIGH),
734+
{ },
726735
},
727736
};
728737
#endif
@@ -800,7 +809,7 @@ static struct i2c_board_info a780_i2c_board_info[] = {
800809

801810
static struct platform_device *a780_devices[] __initdata = {
802811
&a780_gpio_keys,
803-
&camera_supply_dummy_device,
812+
&camera_supply_regulator_device,
804813
};
805814

806815
static void __init a780_init(void)
@@ -823,6 +832,7 @@ static void __init a780_init(void)
823832
if (a780_camera_init() == 0)
824833
pxa_set_camera_info(&a780_pxacamera_platform_data);
825834

835+
gpiod_add_lookup_table(&camera_supply_gpiod_table);
826836
pwm_add_table(ezx_pwm_lookup, ARRAY_SIZE(ezx_pwm_lookup));
827837
platform_add_devices(ARRAY_AND_SIZE(ezx_devices));
828838
platform_add_devices(ARRAY_AND_SIZE(a780_devices));
@@ -1098,7 +1108,7 @@ static struct i2c_board_info __initdata a910_i2c_board_info[] = {
10981108

10991109
static struct platform_device *a910_devices[] __initdata = {
11001110
&a910_gpio_keys,
1101-
&camera_supply_dummy_device,
1111+
&camera_supply_regulator_device,
11021112
};
11031113

11041114
static void __init a910_init(void)
@@ -1121,6 +1131,7 @@ static void __init a910_init(void)
11211131
if (a910_camera_init() == 0)
11221132
pxa_set_camera_info(&a910_pxacamera_platform_data);
11231133

1134+
gpiod_add_lookup_table(&camera_supply_gpiod_table);
11241135
pwm_add_table(ezx_pwm_lookup, ARRAY_SIZE(ezx_pwm_lookup));
11251136
platform_add_devices(ARRAY_AND_SIZE(ezx_devices));
11261137
platform_add_devices(ARRAY_AND_SIZE(a910_devices));

arch/arm/mach-pxa/magician.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <linux/platform_device.h>
1919
#include <linux/delay.h>
2020
#include <linux/gpio.h>
21+
#include <linux/gpio/machine.h>
2122
#include <linux/gpio_keys.h>
2223
#include <linux/input.h>
2324
#include <linux/mfd/htc-pasic3.h>
@@ -696,7 +697,6 @@ static struct regulator_init_data vads7846_regulator = {
696697
static struct fixed_voltage_config vads7846 = {
697698
.supply_name = "vads7846",
698699
.microvolts = 3300000, /* probably */
699-
.gpio = -EINVAL,
700700
.startup_delay = 0,
701701
.init_data = &vads7846_regulator,
702702
};

arch/arm/mach-pxa/raumfeld.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -886,7 +886,6 @@ static struct regulator_init_data audio_va_initdata = {
886886
static struct fixed_voltage_config audio_va_config = {
887887
.supply_name = "audio_va",
888888
.microvolts = 5000000,
889-
.gpio = GPIO_AUDIO_VA_ENABLE,
890889
.enable_high = 1,
891890
.enabled_at_boot = 0,
892891
.init_data = &audio_va_initdata,
@@ -900,6 +899,15 @@ static struct platform_device audio_va_device = {
900899
},
901900
};
902901

902+
static 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+
NULL, GPIO_ACTIVE_HIGH),
907+
{ },
908+
},
909+
};
910+
903911
/* Dummy supplies for Codec's VD/VLC */
904912

905913
static struct regulator_consumer_supply audio_dummy_supplies[] = {
@@ -918,7 +926,6 @@ static struct regulator_init_data audio_dummy_initdata = {
918926
static struct fixed_voltage_config audio_dummy_config = {
919927
.supply_name = "audio_vd",
920928
.microvolts = 3300000,
921-
.gpio = -1,
922929
.init_data = &audio_dummy_initdata,
923930
};
924931

@@ -1033,6 +1040,7 @@ static void __init raumfeld_audio_init(void)
10331040
else
10341041
gpio_direction_output(GPIO_MCLK_RESET, 1);
10351042

1043+
gpiod_add_lookup_table(&audio_va_gpiod_table);
10361044
platform_add_devices(ARRAY_AND_SIZE(audio_regulator_devices));
10371045
}
10381046

0 commit comments

Comments
 (0)