Skip to content

Commit fdabc46

Browse files
linuswgregkh
authored andcommitted
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. Cc: Daniel Mack <[email protected]> Cc: Haojian Zhuang <[email protected]> Acked-by: Robert Jarzmik <[email protected]> Acked-by: Felipe Balbi <[email protected]> Acked-by: Sylwester Nawrocki <[email protected]> Acked-by: Philipp Zabel <[email protected]> Signed-off-by: Linus Walleij <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent eb7a3bb commit fdabc46

File tree

17 files changed

+188
-193
lines changed

17 files changed

+188
-193
lines changed

arch/arm/mach-pxa/colibri-pxa320.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
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) {}
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 = {
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

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
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 @@
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)
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)
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)
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)
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)
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)
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 = {
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)
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

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
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)
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

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
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[] = {
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)
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

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
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,19 +505,27 @@ static struct resource gpio_vbus_resource = {
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 = {
515525
.name = "gpio-vbus",
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)
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

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
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 = {
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)
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)
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

0 commit comments

Comments
 (0)