History

usb: phy: phy-gpio-vbus-usb: Convert to GPIO descriptors

Instead of using the legacy GPIO API and keeping track on polarity inversion semantics in the driver, switch to use GPIO descriptors for this driver and change all consumers in the process. This makes it possible to retire platform data completely: the only remaining platform data member was "wakeup" which was intended to make the vbus interrupt wakeup capable, but was not set by any users and thus remained unused. VBUS was not waking any devices up. Leave a comment about it so later developers using the platform can consider setting it to always enabled so plugging in USB wakes up the platform.

Linus Walleij committed 6 years ago

Commit fdabc461 parent eb7a3bb17 files · +188 −193Browse files

Unified · Split

17 files
  1. arch/arm/mach-pxa/colibri-pxa320.c +9 −7
  2. arch/arm/mach-pxa/eseries.c +25 −15
  3. arch/arm/mach-pxa/gumstix.c +11 −7
  4. arch/arm/mach-pxa/hx4700.c +14 −8
  5. arch/arm/mach-pxa/magician.c +15 −7
  6. arch/arm/mach-pxa/mioa701.c +9 −6
  7. arch/arm/mach-pxa/palm27x.c +17 −17
  8. arch/arm/mach-pxa/palmt5.c +0 −1
  9. arch/arm/mach-pxa/palmtc.c +10 −8
  10. arch/arm/mach-pxa/palmte2.c +10 −8
  11. arch/arm/mach-pxa/palmtx.c +0 −1
  12. arch/arm/mach-pxa/palmz72.c +0 −1
  13. arch/arm/mach-pxa/tosa.c +10 −8
  14. arch/arm/mach-pxa/vpac270.c +8 −7
  15. arch/arm/mach-s3c64xx/mach-smartq.c +7 −6
  16. drivers/usb/phy/phy-gpio-vbus-usb.c +43 −53
  17. include/linux/usb/gpio_vbus.h +0 −33
arch/arm/mach-pxa/colibri-pxa320.c+9−7
@@ -11,9 +11,9 @@ · 10 unmodified lines
1111 #include <linux/init.h>
1212 #include <linux/kernel.h>
1313 #include <linux/platform_device.h>
14+#include <linux/gpio/machine.h>
1415 #include <linux/gpio.h>
1516 #include <linux/interrupt.h>
16−#include <linux/usb/gpio_vbus.h>
1717
1818 #include <asm/mach-types.h>
1919 #include <linux/sizes.h>
@@ -144,17 +144,18 @@ static inline void __init colibri_pxa320_init_eth(void) {} · 124 unmodified lines
144144 #endif /* CONFIG_AX88796 */
145145
146146 #if defined(CONFIG_USB_PXA27X)||defined(CONFIG_USB_PXA27X_MODULE)
147−static struct gpio_vbus_mach_info colibri_pxa320_gpio_vbus_info = {
148− .gpio_vbus = mfp_to_gpio(MFP_PIN_GPIO96),
149− .gpio_pullup = -1,
147+static struct gpiod_lookup_table gpio_vbus_gpiod_table = {
148+ .dev_id = "gpio-vbus",
149+ .table = {
150+ GPIO_LOOKUP("gpio-pxa", MFP_PIN_GPIO96,
151+ "vbus", GPIO_ACTIVE_HIGH),
152+ { },
153+ },
150154 };
151155
152156 static struct platform_device colibri_pxa320_gpio_vbus = {
153157 .name = "gpio-vbus",
154158 .id = -1,
155− .dev = {
156− .platform_data = &colibri_pxa320_gpio_vbus_info,
157− },
158159 };
159160
160161 static void colibri_pxa320_udc_command(int cmd)
@@ -173,6 +174,7 @@ static struct pxa2xx_udc_mach_info colibri_pxa320_udc_info __initdata = { · 12 unmodified lines
173174 static void __init colibri_pxa320_init_udc(void)
174175 {
175176 pxa_set_udc_info(&colibri_pxa320_udc_info);
177+ gpiod_add_lookup_table(&gpio_vbus_gpiod_table);
176178 platform_device_register(&colibri_pxa320_gpio_vbus);
177179 }
178180 #else
arch/arm/mach-pxa/eseries.c+25−15
@@ -14,6 +14,7 @@ · 13 unmodified lines
1414 #include <linux/kernel.h>
1515 #include <linux/init.h>
1616 #include <linux/clk-provider.h>
17+#include <linux/gpio/machine.h>
1718 #include <linux/gpio.h>
1819 #include <linux/delay.h>
1920 #include <linux/platform_device.h>
@@ -22,7 +23,6 @@ · 2 unmodified lines
2223 #include <linux/mfd/t7l66xb.h>
2324 #include <linux/mtd/rawnand.h>
2425 #include <linux/mtd/partitions.h>
25−#include <linux/usb/gpio_vbus.h>
2626 #include <linux/memblock.h>
2727
2828 #include <video/w100fb.h>
@@ -51,18 +51,20 @@ void __init eseries_fixup(struct tag *tags, char **cmdline) · 22 unmodified lines
5151 memblock_add(0xa0000000, SZ_64M);
5252 }
5353
54−struct gpio_vbus_mach_info e7xx_udc_info = {
55− .gpio_vbus = GPIO_E7XX_USB_DISC,
56− .gpio_pullup = GPIO_E7XX_USB_PULLUP,
57− .gpio_pullup_inverted = 1
54+static struct gpiod_lookup_table e7xx_gpio_vbus_gpiod_table __maybe_unused = {
55+ .dev_id = "gpio-vbus",
56+ .table = {
57+ GPIO_LOOKUP("gpio-pxa", GPIO_E7XX_USB_DISC,
58+ "vbus", GPIO_ACTIVE_HIGH),
59+ GPIO_LOOKUP("gpio-pxa", GPIO_E7XX_USB_PULLUP,
60+ "pullup", GPIO_ACTIVE_LOW),
61+ { },
62+ },
5863 };
5964
6065 static struct platform_device e7xx_gpio_vbus __maybe_unused = {
6166 .name = "gpio-vbus",
6267 .id = -1,
63− .dev = {
64− .platform_data = &e7xx_udc_info,
65− },
6668 };
6769
6870 struct pxaficp_platform_data e7xx_ficp_platform_data = {
@@ -165,6 +167,7 @@ static void __init e330_init(void) · 96 unmodified lines
165167 pxa_set_stuart_info(NULL);
166168 eseries_register_clks();
167169 eseries_get_tmio_gpios();
170+ gpiod_add_lookup_table(&e7xx_gpio_vbus_gpiod_table);
168171 platform_add_devices(ARRAY_AND_SIZE(e330_devices));
169172 }
170173
@@ -216,6 +219,7 @@ static void __init e350_init(void) · 45 unmodified lines
216219 pxa_set_stuart_info(NULL);
217220 eseries_register_clks();
218221 eseries_get_tmio_gpios();
222+ gpiod_add_lookup_table(&e7xx_gpio_vbus_gpiod_table);
219223 platform_add_devices(ARRAY_AND_SIZE(e350_devices));
220224 }
221225
@@ -340,6 +344,7 @@ static void __init e400_init(void) · 118 unmodified lines
340344 eseries_register_clks();
341345 eseries_get_tmio_gpios();
342346 pxa_set_fb_info(NULL, &e400_pxafb_mach_info);
347+ gpiod_add_lookup_table(&e7xx_gpio_vbus_gpiod_table);
343348 platform_add_devices(ARRAY_AND_SIZE(e400_devices));
344349 }
345350
@@ -534,6 +539,7 @@ static void __init e740_init(void) · 188 unmodified lines
534539 clk_add_alias("CLK_CK48M", e740_t7l66xb_device.name,
535540 "UDCCLK", &pxa25x_device_udc.dev),
536541 eseries_get_tmio_gpios();
542+ gpiod_add_lookup_table(&e7xx_gpio_vbus_gpiod_table);
537543 platform_add_devices(ARRAY_AND_SIZE(e740_devices));
538544 pxa_set_ac97_info(NULL);
539545 pxa_set_ficp_info(&e7xx_ficp_platform_data);
@@ -733,6 +739,7 @@ static void __init e750_init(void) · 193 unmodified lines
733739 clk_add_alias("CLK_CK3P6MI", e750_tc6393xb_device.name,
734740 "GPIO11_CLK", NULL),
735741 eseries_get_tmio_gpios();
742+ gpiod_add_lookup_table(&e7xx_gpio_vbus_gpiod_table);
736743 platform_add_devices(ARRAY_AND_SIZE(e750_devices));
737744 pxa_set_ac97_info(NULL);
738745 pxa_set_ficp_info(&e7xx_ficp_platform_data);
@@ -888,18 +895,20 @@ static struct platform_device e800_fb_device = { · 149 unmodified lines
888895
889896 /* --------------------------- UDC definitions --------------------------- */
890897
891−static struct gpio_vbus_mach_info e800_udc_info = {
892− .gpio_vbus = GPIO_E800_USB_DISC,
893− .gpio_pullup = GPIO_E800_USB_PULLUP,
894− .gpio_pullup_inverted = 1
898+static struct gpiod_lookup_table e800_gpio_vbus_gpiod_table = {
899+ .dev_id = "gpio-vbus",
900+ .table = {
901+ GPIO_LOOKUP("gpio-pxa", GPIO_E800_USB_DISC,
902+ "vbus", GPIO_ACTIVE_HIGH),
903+ GPIO_LOOKUP("gpio-pxa", GPIO_E800_USB_PULLUP,
904+ "pullup", GPIO_ACTIVE_LOW),
905+ { },
906+ },
895907 };
896908
897909 static struct platform_device e800_gpio_vbus = {
898910 .name = "gpio-vbus",
899911 .id = -1,
900− .dev = {
901− .platform_data = &e800_udc_info,
902− },
903912 };
904913
905914
@@ -949,6 +958,7 @@ static void __init e800_init(void) · 43 unmodified lines
949958 clk_add_alias("CLK_CK3P6MI", e800_tc6393xb_device.name,
950959 "GPIO11_CLK", NULL),
951960 eseries_get_tmio_gpios();
961+ gpiod_add_lookup_table(&e800_gpio_vbus_gpiod_table);
952962 platform_add_devices(ARRAY_AND_SIZE(e800_devices));
953963 pxa_set_ac97_info(NULL);
954964 }
arch/arm/mach-pxa/gumstix.c+11−7
@@ -20,10 +20,10 @@ · 19 unmodified lines
2020 #include <linux/delay.h>
2121 #include <linux/mtd/mtd.h>
2222 #include <linux/mtd/partitions.h>
23+#include <linux/gpio/machine.h>
2324 #include <linux/gpio.h>
2425 #include <linux/err.h>
2526 #include <linux/clk.h>
26−#include <linux/usb/gpio_vbus.h>
2727
2828 #include <asm/setup.h>
2929 #include <asm/memory.h>
@@ -101,21 +101,25 @@ static void __init gumstix_mmc_init(void) · 71 unmodified lines
101101 #endif
102102
103103 #ifdef CONFIG_USB_PXA25X
104−static struct gpio_vbus_mach_info gumstix_udc_info = {
105− .gpio_vbus = GPIO_GUMSTIX_USB_GPIOn,
106− .gpio_pullup = GPIO_GUMSTIX_USB_GPIOx,
104+static struct gpiod_lookup_table gumstix_gpio_vbus_gpiod_table = {
105+ .dev_id = "gpio-vbus",
106+ .table = {
107+ GPIO_LOOKUP("gpio-pxa", GPIO_GUMSTIX_USB_GPIOn,
108+ "vbus", GPIO_ACTIVE_HIGH),
109+ GPIO_LOOKUP("gpio-pxa", GPIO_GUMSTIX_USB_GPIOx,
110+ "pullup", GPIO_ACTIVE_HIGH),
111+ { },
112+ },
107113 };
108114
109115 static struct platform_device gumstix_gpio_vbus = {
110116 .name = "gpio-vbus",
111117 .id = -1,
112− .dev = {
113− .platform_data = &gumstix_udc_info,
114− },
115118 };
116119
117120 static void __init gumstix_udc_init(void)
118121 {
122+ gpiod_add_lookup_table(&gumstix_gpio_vbus_gpiod_table);
119123 platform_device_register(&gumstix_gpio_vbus);
120124 }
121125 #else
arch/arm/mach-pxa/hx4700.c+14−8
@@ -34,7 +34,6 @@ · 33 unmodified lines
3434 #include <linux/spi/ads7846.h>
3535 #include <linux/spi/spi.h>
3636 #include <linux/spi/pxa2xx_spi.h>
37−#include <linux/usb/gpio_vbus.h>
3837 #include <linux/platform_data/i2c-pxa.h>
3938
4039 #include <mach/hardware.h>
@@ -578,18 +577,24 @@ static struct pwm_lookup hx4700_pwm_lookup[] = { · 537 unmodified lines
578577 * USB "Transceiver"
579578 */
580579
581−static struct gpio_vbus_mach_info gpio_vbus_info = {
582− .gpio_pullup = GPIO76_HX4700_USBC_PUEN,
583− .gpio_vbus = GPIOD14_nUSBC_DETECT,
584− .gpio_vbus_inverted = 1,
580+static struct gpiod_lookup_table gpio_vbus_gpiod_table = {
581+ .dev_id = "gpio-vbus",
582+ .table = {
583+ /* This GPIO is on ASIC3 */
584+ GPIO_LOOKUP("asic3",
585+ /* Convert to a local offset on the ASIC3 */
586+ GPIOD14_nUSBC_DETECT - HX4700_ASIC3_GPIO_BASE,
587+ "vbus", GPIO_ACTIVE_LOW),
588+ /* This one is on the primary SOC GPIO */
589+ GPIO_LOOKUP("gpio-pxa", GPIO76_HX4700_USBC_PUEN,
590+ "pullup", GPIO_ACTIVE_HIGH),
591+ { },
592+ },
585593 };
586594
587595 static struct platform_device gpio_vbus = {
588596 .name = "gpio-vbus",
589597 .id = -1,
590− .dev = {
591− .platform_data = &gpio_vbus_info,
592− },
593598 };
594599
595600 static struct pxa2xx_udc_mach_info hx4700_udc_info;
@@ -883,6 +888,7 @@ static void __init hx4700_init(void) · 287 unmodified lines
883888 pxa_set_stuart_info(NULL);
884889
885890 gpiod_add_lookup_table(&bq24022_gpiod_table);
891+ gpiod_add_lookup_table(&gpio_vbus_gpiod_table);
886892 platform_add_devices(devices, ARRAY_SIZE(devices));
887893 pwm_add_table(hx4700_pwm_lookup, ARRAY_SIZE(hx4700_pwm_lookup));
888894
arch/arm/mach-pxa/magician.c+15−7
@@ -27,7 +27,6 @@ · 26 unmodified lines
2727 #include <linux/regulator/fixed.h>
2828 #include <linux/regulator/gpio-regulator.h>
2929 #include <linux/regulator/machine.h>
30−#include <linux/usb/gpio_vbus.h>
3130 #include <linux/platform_data/i2c-pxa.h>
3231
3332 #include <mach/hardware.h>
@@ -506,9 +505,20 @@ static struct resource gpio_vbus_resource = { · 472 unmodified lines
506505 .end = IRQ_MAGICIAN_VBUS,
507506 };
508507
509−static struct gpio_vbus_mach_info gpio_vbus_info = {
510− .gpio_pullup = GPIO27_MAGICIAN_USBC_PUEN,
511− .gpio_vbus = EGPIO_MAGICIAN_CABLE_VBUS,
508+static struct gpiod_lookup_table gpio_vbus_gpiod_table = {
509+ .dev_id = "gpio-vbus",
510+ .table = {
511+ /*
512+ * EGPIO on register 4 index 1, the second EGPIO chip
513+ * starts at register 4 so this will be at index 1 on that
514+ * chip.
515+ */
516+ GPIO_LOOKUP("htc-egpio-1", 1,
517+ "vbus", GPIO_ACTIVE_HIGH),
518+ GPIO_LOOKUP("gpio-pxa", GPIO27_MAGICIAN_USBC_PUEN,
519+ "pullup", GPIO_ACTIVE_HIGH),
520+ { },
521+ },
512522 };
513523
514524 static struct platform_device gpio_vbus = {
@@ -516,9 +526,6 @@ static struct platform_device gpio_vbus = { · 1 unmodified line
516526 .id = -1,
517527 .num_resources = 1,
518528 .resource = &gpio_vbus_resource,
519− .dev = {
520− .platform_data = &gpio_vbus_info,
521− },
522529 };
523530
524531 /*
@@ -1032,6 +1039,7 @@ static void __init magician_init(void) · 507 unmodified lines
10321039 ARRAY_SIZE(pwm_backlight_supply), 5000000);
10331040
10341041 gpiod_add_lookup_table(&bq24022_gpiod_table);
1042+ gpiod_add_lookup_table(&gpio_vbus_gpiod_table);
10351043 platform_add_devices(ARRAY_AND_SIZE(devices));
10361044 }
10371045
arch/arm/mach-pxa/mioa701.c+9−6
@@ -24,7 +24,6 @@ · 23 unmodified lines
2424 #include <linux/power_supply.h>
2525 #include <linux/wm97xx.h>
2626 #include <linux/mtd/physmap.h>
27−#include <linux/usb/gpio_vbus.h>
2827 #include <linux/reboot.h>
2928 #include <linux/regulator/fixed.h>
3029 #include <linux/regulator/max1586.h>
@@ -368,10 +367,13 @@ static struct pxa2xx_udc_mach_info mioa701_udc_info = { · 337 unmodified lines
368367 .gpio_pullup = GPIO22_USB_ENABLE,
369368 };
370369
371−struct gpio_vbus_mach_info gpio_vbus_data = {
372− .gpio_vbus = GPIO13_nUSB_DETECT,
373− .gpio_vbus_inverted = 1,
374− .gpio_pullup = -1,
370+static struct gpiod_lookup_table gpio_vbus_gpiod_table = {
371+ .dev_id = "gpio-vbus",
372+ .table = {
373+ GPIO_LOOKUP("gpio-pxa", GPIO13_nUSB_DETECT,
374+ "vbus", GPIO_ACTIVE_LOW),
375+ { },
376+ },
375377 };
376378
377379 /*
@@ -677,7 +679,7 @@ MIO_SIMPLE_DEV(mioa701_led, "leds-gpio", &gpio_led_info) · 299 unmodified lines
677679 MIO_SIMPLE_DEV(pxa2xx_pcm, "pxa2xx-pcm", NULL)
678680 MIO_SIMPLE_DEV(mioa701_sound, "mioa701-wm9713", NULL)
679681 MIO_SIMPLE_DEV(mioa701_board, "mioa701-board", NULL)
680−MIO_SIMPLE_DEV(gpio_vbus, "gpio-vbus", &gpio_vbus_data);
682+MIO_SIMPLE_DEV(gpio_vbus, "gpio-vbus", NULL);
681683
682684 static struct platform_device *devices[] __initdata = {
683685 &mioa701_gpio_keys,
@@ -750,6 +752,7 @@ static void __init mioa701_machine_init(void) · 66 unmodified lines
750752 pxa_set_ac97_info(&mioa701_ac97_info);
751753 pm_power_off = mioa701_poweroff;
752754 pwm_add_table(mioa701_pwm_lookup, ARRAY_SIZE(mioa701_pwm_lookup));
755+ gpiod_add_lookup_table(&gpio_vbus_gpiod_table);
753756 platform_add_devices(devices, ARRAY_SIZE(devices));
754757 gsm_init();
755758
arch/arm/mach-pxa/palm27x.c+17−17
@@ -13,10 +13,10 @@ · 12 unmodified lines
1313 #include <linux/pda_power.h>
1414 #include <linux/pwm.h>
1515 #include <linux/pwm_backlight.h>
16+#include <linux/gpio/machine.h>
1617 #include <linux/gpio.h>
1718 #include <linux/wm97xx.h>
1819 #include <linux/power_supply.h>
19−#include <linux/usb/gpio_vbus.h>
2020 #include <linux/regulator/max1586.h>
2121 #include <linux/platform_data/i2c-pxa.h>
2222
@@ -159,32 +159,32 @@ void __init palm27x_lcd_init(int power, struct pxafb_mode_info *mode) · 136 unmodified lines
159159 ******************************************************************************/
160160 #if defined(CONFIG_USB_PXA27X) || \
161161 defined(CONFIG_USB_PXA27X_MODULE)
162−static struct gpio_vbus_mach_info palm27x_udc_info = {
163− .gpio_vbus_inverted = 1,
162+
163+/* The actual GPIO offsets get filled in in the palm27x_udc_init() call */
164+static struct gpiod_lookup_table palm27x_udc_gpiod_table = {
165+ .dev_id = "gpio-vbus",
166+ .table = {
167+ GPIO_LOOKUP("gpio-pxa", 0,
168+ "vbus", GPIO_ACTIVE_HIGH),
169+ GPIO_LOOKUP("gpio-pxa", 0,
170+ "pullup", GPIO_ACTIVE_HIGH),
171+ { },
172+ },
164173 };
165174
166175 static struct platform_device palm27x_gpio_vbus = {
167176 .name = "gpio-vbus",
168177 .id = -1,
169− .dev = {
170− .platform_data = &palm27x_udc_info,
171− },
172178 };
173179
174180 void __init palm27x_udc_init(int vbus, int pullup, int vbus_inverted)
175181 {
176− palm27x_udc_info.gpio_vbus = vbus;
177− palm27x_udc_info.gpio_pullup = pullup;
178−
179− palm27x_udc_info.gpio_vbus_inverted = vbus_inverted;
180−
181− if (!gpio_request(pullup, "USB Pullup")) {
182− gpio_direction_output(pullup,
183− palm27x_udc_info.gpio_vbus_inverted);
184− gpio_free(pullup);
185− } else
186− return;
182+ palm27x_udc_gpiod_table.table[0].chip_hwnum = vbus;
183+ palm27x_udc_gpiod_table.table[1].chip_hwnum = pullup;
184+ if (vbus_inverted)
185+ palm27x_udc_gpiod_table.table[0].flags = GPIO_ACTIVE_LOW;
187186
187+ gpiod_add_lookup_table(&palm27x_udc_gpiod_table);
188188 platform_device_register(&palm27x_gpio_vbus);
189189 }
190190 #endif
arch/arm/mach-pxa/palmt5.c+0−1
@@ -23,7 +23,6 @@ · 22 unmodified lines
2323 #include <linux/gpio.h>
2424 #include <linux/wm97xx.h>
2525 #include <linux/power_supply.h>
26−#include <linux/usb/gpio_vbus.h>
2726
2827 #include <asm/mach-types.h>
2928 #include <asm/mach/arch.h>
arch/arm/mach-pxa/palmtc.c+10−8
@@ -23,7 +23,6 @@ · 22 unmodified lines
2323 #include <linux/power_supply.h>
2424 #include <linux/gpio_keys.h>
2525 #include <linux/mtd/physmap.h>
26−#include <linux/usb/gpio_vbus.h>
2726
2827 #include <asm/mach-types.h>
2928 #include <asm/mach/arch.h>
@@ -319,22 +318,25 @@ static inline void palmtc_mkp_init(void) {} · 289 unmodified lines
319318 * UDC
320319 ******************************************************************************/
321320 #if defined(CONFIG_USB_PXA25X)||defined(CONFIG_USB_PXA25X_MODULE)
322−static struct gpio_vbus_mach_info palmtc_udc_info = {
323− .gpio_vbus = GPIO_NR_PALMTC_USB_DETECT_N,
324− .gpio_vbus_inverted = 1,
325− .gpio_pullup = GPIO_NR_PALMTC_USB_POWER,
321+static struct gpiod_lookup_table palmtc_udc_gpiod_table = {
322+ .dev_id = "gpio-vbus",
323+ .table = {
324+ GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMTC_USB_DETECT_N,
325+ "vbus", GPIO_ACTIVE_LOW),
326+ GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMTC_USB_POWER,
327+ "pullup", GPIO_ACTIVE_HIGH),
328+ { },
329+ },
326330 };
327331
328332 static struct platform_device palmtc_gpio_vbus = {
329333 .name = "gpio-vbus",
330334 .id = -1,
331− .dev = {
332− .platform_data = &palmtc_udc_info,
333− },
334335 };
335336
336337 static void __init palmtc_udc_init(void)
337338 {
339+ gpiod_add_lookup_table(&palmtc_udc_gpiod_table);
338340 platform_device_register(&palmtc_gpio_vbus);
339341 };
340342 #else
arch/arm/mach-pxa/palmte2.c+10−8
@@ -23,7 +23,6 @@ · 22 unmodified lines
2323 #include <linux/gpio.h>
2424 #include <linux/wm97xx.h>
2525 #include <linux/power_supply.h>
26−#include <linux/usb/gpio_vbus.h>
2726
2827 #include <asm/mach-types.h>
2928 #include <asm/mach/arch.h>
@@ -201,18 +200,20 @@ static struct pxaficp_platform_data palmte2_ficp_platform_data = { · 171 unmodified lines
201200 /******************************************************************************
202201 * UDC
203202 ******************************************************************************/
204−static struct gpio_vbus_mach_info palmte2_udc_info = {
205− .gpio_vbus = GPIO_NR_PALMTE2_USB_DETECT_N,
206− .gpio_vbus_inverted = 1,
207− .gpio_pullup = GPIO_NR_PALMTE2_USB_PULLUP,
203+static struct gpiod_lookup_table palmte2_udc_gpiod_table = {
204+ .dev_id = "gpio-vbus",
205+ .table = {
206+ GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMTE2_USB_DETECT_N,
207+ "vbus", GPIO_ACTIVE_LOW),
208+ GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMTE2_USB_PULLUP,
209+ "pullup", GPIO_ACTIVE_HIGH),
210+ { },
211+ },
208212 };
209213
210214 static struct platform_device palmte2_gpio_vbus = {
211215 .name = "gpio-vbus",
212216 .id = -1,
213− .dev = {
214− .platform_data = &palmte2_udc_info,
215− },
216217 };
217218
218219 /******************************************************************************
@@ -368,6 +369,7 @@ static void __init palmte2_init(void) · 149 unmodified lines
368369 pxa_set_ficp_info(&palmte2_ficp_platform_data);
369370
370371 pwm_add_table(palmte2_pwm_lookup, ARRAY_SIZE(palmte2_pwm_lookup));
372+ gpiod_add_lookup_table(&palmte2_udc_gpiod_table);
371373 platform_add_devices(devices, ARRAY_SIZE(devices));
372374 }
373375
arch/arm/mach-pxa/palmtx.c+0−1
@@ -23,7 +23,6 @@ · 22 unmodified lines
2323 #include <linux/gpio.h>
2424 #include <linux/wm97xx.h>
2525 #include <linux/power_supply.h>
26−#include <linux/usb/gpio_vbus.h>
2726 #include <linux/mtd/platnand.h>
2827 #include <linux/mtd/mtd.h>
2928 #include <linux/mtd/physmap.h>
arch/arm/mach-pxa/palmz72.c+0−1
@@ -25,7 +25,6 @@ · 24 unmodified lines
2525 #include <linux/gpio.h>
2626 #include <linux/wm97xx.h>
2727 #include <linux/power_supply.h>
28−#include <linux/usb/gpio_vbus.h>
2928 #include <linux/platform_data/i2c-gpio.h>
3029 #include <linux/gpio/machine.h>
3130
arch/arm/mach-pxa/tosa.c+10−8
@@ -33,7 +33,6 @@ · 32 unmodified lines
3333 #include <linux/spi/pxa2xx_spi.h>
3434 #include <linux/input/matrix_keypad.h>
3535 #include <linux/platform_data/i2c-pxa.h>
36−#include <linux/usb/gpio_vbus.h>
3736 #include <linux/reboot.h>
3837 #include <linux/memblock.h>
3938
@@ -240,18 +239,20 @@ static struct scoop_pcmcia_config tosa_pcmcia_config = { · 200 unmodified lines
240239 /*
241240 * USB Device Controller
242241 */
243−static struct gpio_vbus_mach_info tosa_udc_info = {
244− .gpio_pullup = TOSA_GPIO_USB_PULLUP,
245− .gpio_vbus = TOSA_GPIO_USB_IN,
246− .gpio_vbus_inverted = 1,
242+static struct gpiod_lookup_table tosa_udc_gpiod_table = {
243+ .dev_id = "gpio-vbus",
244+ .table = {
245+ GPIO_LOOKUP("gpio-pxa", TOSA_GPIO_USB_IN,
246+ "vbus", GPIO_ACTIVE_LOW),
247+ GPIO_LOOKUP("gpio-pxa", TOSA_GPIO_USB_PULLUP,
248+ "pullup", GPIO_ACTIVE_HIGH),
249+ { },
250+ },
247251 };
248252
249253 static struct platform_device tosa_gpio_vbus = {
250254 .name = "gpio-vbus",
251255 .id = -1,
252− .dev = {
253− .platform_data = &tosa_udc_info,
254− },
255256 };
256257
257258 /*
@@ -949,6 +950,7 @@ static void __init tosa_init(void) · 691 unmodified lines
949950
950951 clk_add_alias("CLK_CK3P6MI", tc6393xb_device.name, "GPIO11_CLK", NULL);
951952
953+ gpiod_add_lookup_table(&tosa_udc_gpiod_table);
952954 platform_add_devices(devices, ARRAY_SIZE(devices));
953955 }
954956
arch/arm/mach-pxa/vpac270.c+8−7
@@ -14,7 +14,6 @@ · 13 unmodified lines
1414 #include <linux/leds.h>
1515 #include <linux/gpio.h>
1616 #include <linux/gpio/machine.h>
17−#include <linux/usb/gpio_vbus.h>
1817 #include <linux/mtd/mtd.h>
1918 #include <linux/mtd/partitions.h>
2019 #include <linux/mtd/physmap.h>
@@ -352,17 +351,18 @@ static inline void vpac270_uhc_init(void) {} · 331 unmodified lines
352351 * USB Gadget
353352 ******************************************************************************/
354353 #if defined(CONFIG_USB_PXA27X)||defined(CONFIG_USB_PXA27X_MODULE)
355−static struct gpio_vbus_mach_info vpac270_gpio_vbus_info = {
356− .gpio_vbus = GPIO41_VPAC270_UDC_DETECT,
357− .gpio_pullup = -1,
354+static struct gpiod_lookup_table vpac270_gpio_vbus_gpiod_table = {
355+ .dev_id = "gpio-vbus",
356+ .table = {
357+ GPIO_LOOKUP("gpio-pxa", GPIO41_VPAC270_UDC_DETECT,
358+ "vbus", GPIO_ACTIVE_HIGH),
359+ { },
360+ },
358361 };
359362
360363 static struct platform_device vpac270_gpio_vbus = {
361364 .name = "gpio-vbus",
362365 .id = -1,
363− .dev = {
364− .platform_data = &vpac270_gpio_vbus_info,
365− },
366366 };
367367
368368 static void vpac270_udc_command(int cmd)
@@ -381,6 +381,7 @@ static struct pxa2xx_udc_mach_info vpac270_udc_info __initdata = { · 12 unmodified lines
381381 static void __init vpac270_udc_init(void)
382382 {
383383 pxa_set_udc_info(&vpac270_udc_info);
384+ gpiod_add_lookup_table(&vpac270_gpio_vbus_gpiod_table);
384385 platform_device_register(&vpac270_gpio_vbus);
385386 }
386387 #else
arch/arm/mach-s3c64xx/mach-smartq.c+7−6
@@ -13,7 +13,6 @@ · 12 unmodified lines
1313 #include <linux/serial_core.h>
1414 #include <linux/serial_s3c.h>
1515 #include <linux/spi/spi_gpio.h>
16−#include <linux/usb/gpio_vbus.h>
1716 #include <linux/platform_data/s3c-hsotg.h>
1817
1918 #include <asm/mach-types.h>
@@ -124,15 +123,16 @@ static struct s3c2410_hcd_info smartq_usb_host_info = { · 104 unmodified lines
124123 .enable_oc = smartq_usb_host_enableoc,
125124 };
126125
127−static struct gpio_vbus_mach_info smartq_usb_otg_vbus_pdata = {
128− .gpio_vbus = S3C64XX_GPL(9),
129− .gpio_pullup = -1,
130− .gpio_vbus_inverted = true,
126+static struct gpiod_lookup_table smartq_usb_otg_vbus_gpiod_table = {
127+ .dev_id = "gpio-vbus",
128+ .table = {
129+ GPIO_LOOKUP("GPL", 9, "vbus", GPIO_ACTIVE_LOW),
130+ { },
131+ },
131132 };
132133
133134 static struct platform_device smartq_usb_otg_vbus_dev = {
134135 .name = "gpio-vbus",
135− .dev.platform_data = &smartq_usb_otg_vbus_pdata,
136136 };
137137
138138 static struct pwm_lookup smartq_pwm_lookup[] = {
@@ -418,6 +418,7 @@ void __init smartq_machine_init(void) · 279 unmodified lines
418418
419419 pwm_add_table(smartq_pwm_lookup, ARRAY_SIZE(smartq_pwm_lookup));
420420 gpiod_add_lookup_table(&smartq_lcd_control_gpiod_table);
421+ gpiod_add_lookup_table(&smartq_usb_otg_vbus_gpiod_table);
421422 platform_add_devices(smartq_devices, ARRAY_SIZE(smartq_devices));
422423
423424 gpiod_add_lookup_table(&smartq_audio_gpios);
drivers/usb/phy/phy-gpio-vbus-usb.c+43−53
@@ -7,7 +7,7 @@ · 6 unmodified lines
77
88 #include <linux/kernel.h>
99 #include <linux/platform_device.h>
10−#include <linux/gpio.h>
10+#include <linux/gpio/consumer.h>
1111 #include <linux/module.h>
1212 #include <linux/slab.h>
1313 #include <linux/interrupt.h>
@@ -17,7 +17,6 @@ · 3 unmodified lines
1717 #include <linux/regulator/consumer.h>
1818
1919 #include <linux/usb/gadget.h>
20−#include <linux/usb/gpio_vbus.h>
2120 #include <linux/usb/otg.h>
2221
2322
@@ -29,6 +28,8 @@ · 5 unmodified lines
2928 * Needs to be loaded before the UDC driver that will use it.
3029 */
3130 struct gpio_vbus_data {
31+ struct gpio_desc *vbus_gpiod;
32+ struct gpio_desc *pullup_gpiod;
3233 struct usb_phy phy;
3334 struct device *dev;
3435 struct regulator *vbus_draw;
@@ -83,38 +84,30 @@ static void set_vbus_draw(struct gpio_vbus_data *gpio_vbus, unsigned mA) · 48 unmodified lines
8384 gpio_vbus->mA = mA;
8485 }
8586
86−static int is_vbus_powered(struct gpio_vbus_mach_info *pdata)
87+static int is_vbus_powered(struct gpio_vbus_data *gpio_vbus)
8788 {
88− int vbus;
89−
90− vbus = gpio_get_value(pdata->gpio_vbus);
91− if (pdata->gpio_vbus_inverted)
92− vbus = !vbus;
93−
94− return vbus;
89+ return gpiod_get_value(gpio_vbus->vbus_gpiod);
9590 }
9691
9792 static void gpio_vbus_work(struct work_struct *work)
9893 {
9994 struct gpio_vbus_data *gpio_vbus =
10095 container_of(work, struct gpio_vbus_data, work.work);
101− struct gpio_vbus_mach_info *pdata = dev_get_platdata(gpio_vbus->dev);
102− int gpio, status, vbus;
96+ int status, vbus;
10397
10498 if (!gpio_vbus->phy.otg->gadget)
10599 return;
106100
107− vbus = is_vbus_powered(pdata);
101+ vbus = is_vbus_powered(gpio_vbus);
108102 if ((vbus ^ gpio_vbus->vbus) == 0)
109103 return;
110104 gpio_vbus->vbus = vbus;
111105
112106 /* Peripheral controllers which manage the pullup themselves won't have
113− * gpio_pullup configured here. If it's configured here, we'll do what
114− * isp1301_omap::b_peripheral() does and enable the pullup here... although
115− * that may complicate usb_gadget_{,dis}connect() support.
107+ * a pullup GPIO configured here. If it's configured here, we'll do
108+ * what isp1301_omap::b_peripheral() does and enable the pullup here...
109+ * although that may complicate usb_gadget_{,dis}connect() support.
116110 */
117− gpio = pdata->gpio_pullup;
118111
119112 if (vbus) {
120113 status = USB_EVENT_VBUS;
@@ -126,16 +119,16 @@ static void gpio_vbus_work(struct work_struct *work) · 5 unmodified lines
126119 set_vbus_draw(gpio_vbus, 100);
127120
128121 /* optionally enable D+ pullup */
129− if (gpio_is_valid(gpio))
130− gpio_set_value(gpio, !pdata->gpio_pullup_inverted);
122+ if (gpio_vbus->pullup_gpiod)
123+ gpiod_set_value(gpio_vbus->pullup_gpiod, 1);
131124
132125 atomic_notifier_call_chain(&gpio_vbus->phy.notifier,
133126 status, gpio_vbus->phy.otg->gadget);
134127 usb_phy_set_event(&gpio_vbus->phy, USB_EVENT_ENUMERATED);
135128 } else {
136129 /* optionally disable D+ pullup */
137− if (gpio_is_valid(gpio))
138− gpio_set_value(gpio, pdata->gpio_pullup_inverted);
130+ if (gpio_vbus->pullup_gpiod)
131+ gpiod_set_value(gpio_vbus->pullup_gpiod, 0);
139132
140133 set_vbus_draw(gpio_vbus, 0);
141134
@@ -154,12 +147,11 @@ static void gpio_vbus_work(struct work_struct *work) · 12 unmodified lines
154147 static irqreturn_t gpio_vbus_irq(int irq, void *data)
155148 {
156149 struct platform_device *pdev = data;
157− struct gpio_vbus_mach_info *pdata = dev_get_platdata(&pdev->dev);
158150 struct gpio_vbus_data *gpio_vbus = platform_get_drvdata(pdev);
159151 struct usb_otg *otg = gpio_vbus->phy.otg;
160152
161153 dev_dbg(&pdev->dev, "VBUS %s (gadget: %s)\n",
162− is_vbus_powered(pdata) ? "supplied" : "inactive",
154+ is_vbus_powered(gpio_vbus) ? "supplied" : "inactive",
163155 otg->gadget ? otg->gadget->name : "none");
164156
165157 if (otg->gadget)
@@ -175,22 +167,18 @@ static int gpio_vbus_set_peripheral(struct usb_otg *otg, · 9 unmodified lines
175167 struct usb_gadget *gadget)
176168 {
177169 struct gpio_vbus_data *gpio_vbus;
178− struct gpio_vbus_mach_info *pdata;
179170 struct platform_device *pdev;
180− int gpio;
181171
182172 gpio_vbus = container_of(otg->usb_phy, struct gpio_vbus_data, phy);
183173 pdev = to_platform_device(gpio_vbus->dev);
184− pdata = dev_get_platdata(gpio_vbus->dev);
185− gpio = pdata->gpio_pullup;
186174
187175 if (!gadget) {
188176 dev_dbg(&pdev->dev, "unregistering gadget '%s'\n",
189177 otg->gadget->name);
190178
191179 /* optionally disable D+ pullup */
192− if (gpio_is_valid(gpio))
193− gpio_set_value(gpio, pdata->gpio_pullup_inverted);
180+ if (gpio_vbus->pullup_gpiod)
181+ gpiod_set_value(gpio_vbus->pullup_gpiod, 0);
194182
195183 set_vbus_draw(gpio_vbus, 0);
196184
@@ -242,16 +230,12 @@ static int gpio_vbus_set_suspend(struct usb_phy *phy, int suspend) · 45 unmodified lines
242230
243231 static int gpio_vbus_probe(struct platform_device *pdev)
244232 {
245− struct gpio_vbus_mach_info *pdata = dev_get_platdata(&pdev->dev);
246233 struct gpio_vbus_data *gpio_vbus;
247234 struct resource *res;
248− int err, gpio, irq;
235+ struct device *dev = &pdev->dev;
236+ int err, irq;
249237 unsigned long irqflags;
250238
251− if (!pdata || !gpio_is_valid(pdata->gpio_vbus))
252− return -EINVAL;
253− gpio = pdata->gpio_vbus;
254−
255239 gpio_vbus = devm_kzalloc(&pdev->dev, sizeof(struct gpio_vbus_data),
256240 GFP_KERNEL);
257241 if (!gpio_vbus)
@@ -273,37 +257,43 @@ static int gpio_vbus_probe(struct platform_device *pdev) · 15 unmodified lines
273257 gpio_vbus->phy.otg->usb_phy = &gpio_vbus->phy;
274258 gpio_vbus->phy.otg->set_peripheral = gpio_vbus_set_peripheral;
275259
276− err = devm_gpio_request(&pdev->dev, gpio, "vbus_detect");
277− if (err) {
278− dev_err(&pdev->dev, "can't request vbus gpio %d, err: %d\n",
279− gpio, err);
260+ /* Look up the VBUS sensing GPIO */
261+ gpio_vbus->vbus_gpiod = devm_gpiod_get(dev, "vbus", GPIOD_IN);
262+ if (IS_ERR(gpio_vbus->vbus_gpiod)) {
263+ err = PTR_ERR(gpio_vbus->vbus_gpiod);
264+ dev_err(&pdev->dev, "can't request vbus gpio, err: %d\n", err);
280265 return err;
281266 }
282− gpio_direction_input(gpio);
267+ gpiod_set_consumer_name(gpio_vbus->vbus_gpiod, "vbus_detect");
283268
284269 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
285270 if (res) {
286271 irq = res->start;
287272 irqflags = (res->flags & IRQF_TRIGGER_MASK) | IRQF_SHARED;
288273 } else {
289− irq = gpio_to_irq(gpio);
274+ irq = gpiod_to_irq(gpio_vbus->vbus_gpiod);
290275 irqflags = VBUS_IRQ_FLAGS;
291276 }
292277
293278 gpio_vbus->irq = irq;
294279
295− /* if data line pullup is in use, initialize it to "not pulling up" */
296− gpio = pdata->gpio_pullup;
297− if (gpio_is_valid(gpio)) {
298− err = devm_gpio_request(&pdev->dev, gpio, "udc_pullup");
299− if (err) {
300− dev_err(&pdev->dev,
301− "can't request pullup gpio %d, err: %d\n",
302− gpio, err);
303− return err;
304− }
305− gpio_direction_output(gpio, pdata->gpio_pullup_inverted);
280+ /*
281+ * The VBUS sensing GPIO should have a pulldown, which will normally be
282+ * part of a resistor ladder turning a 4.0V-5.25V level on VBUS into a
283+ * value the GPIO detects as active. Some systems will use comparators.
284+ * Get the optional D+ or D- pullup GPIO. If the data line pullup is
285+ * in use, initialize it to "not pulling up"
286+ */
287+ gpio_vbus->pullup_gpiod = devm_gpiod_get_optional(dev, "pullup",
288+ GPIOD_OUT_LOW);
289+ if (IS_ERR(gpio_vbus->pullup_gpiod)) {
290+ err = PTR_ERR(gpio_vbus->pullup_gpiod);
291+ dev_err(&pdev->dev, "can't request pullup gpio, err: %d\n",
292+ err);
293+ return err;
306294 }
295+ if (gpio_vbus->pullup_gpiod)
296+ gpiod_set_consumer_name(gpio_vbus->pullup_gpiod, "udc_pullup");
307297
308298 err = devm_request_irq(&pdev->dev, irq, gpio_vbus_irq, irqflags,
309299 "vbus_detect", pdev);
@@ -330,7 +320,7 @@ static int gpio_vbus_probe(struct platform_device *pdev) · 20 unmodified lines
330320 return err;
331321 }
332322
333− device_init_wakeup(&pdev->dev, pdata->wakeup);
323+ /* TODO: wakeup could be enabled here with device_init_wakeup(dev, 1) */
334324
335325 return 0;
336326 }
include/linux/usb/gpio_vbus.h+0−33
@@ -1,33 +0,0 @@
1−// SPDX-License-Identifier: GPL-2.0
2−/*
3− * A simple GPIO VBUS sensing driver for B peripheral only devices
4− * with internal transceivers.
5− * Optionally D+ pullup can be controlled by a second GPIO.
6− *
7− * Copyright (c) 2008 Philipp Zabel <philipp.zabel@gmail.com>
8− *
9− * This program is free software; you can redistribute it and/or modify
10− * it under the terms of the GNU General Public License version 2 as
11− * published by the Free Software Foundation.
12− *
13− */
14−
15−/**
16− * struct gpio_vbus_mach_info - configuration for gpio_vbus
17− * @gpio_vbus: VBUS sensing GPIO
18− * @gpio_pullup: optional D+ or D- pullup GPIO (else negative/invalid)
19− * @gpio_vbus_inverted: true if gpio_vbus is active low
20− * @gpio_pullup_inverted: true if gpio_pullup is active low
21− * @wakeup: configure gpio_vbus as a wake-up source
22− *
23− * The VBUS sensing GPIO should have a pulldown, which will normally be
24− * part of a resistor ladder turning a 4.0V-5.25V level on VBUS into a
25− * value the GPIO detects as active. Some systems will use comparators.
26− */
27−struct gpio_vbus_mach_info {
28− int gpio_vbus;
29− int gpio_pullup;
30− bool gpio_vbus_inverted;
31− bool gpio_pullup_inverted;
32− bool wakeup;
33−};