Commit fdabc466 authored by Linus Walleij's avatar Linus Walleij Committed by Greg Kroah-Hartman
Browse files

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 <daniel@zonque.org>
Cc: Haojian Zhuang <haojian.zhuang@gmail.com>
Acked-by: default avatarRobert Jarzmik <robert.jarzmik@free.fr>
Acked-by: default avatarFelipe Balbi <balbi@kernel.org>
Acked-by: default avatarSylwester Nawrocki <snawrocki@kernel.org>
Acked-by: default avatarPhilipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20200123155013.93249-1-linus.walleij@linaro.org


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent eb7a3bb8
Loading
Loading
Loading
Loading
+9 −7
Original line number Diff line number Diff line
@@ -11,9 +11,9 @@
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/platform_device.h>
#include <linux/gpio/machine.h>
#include <linux/gpio.h>
#include <linux/interrupt.h>
#include <linux/usb/gpio_vbus.h>

#include <asm/mach-types.h>
#include <linux/sizes.h>
@@ -144,17 +144,18 @@ static inline void __init colibri_pxa320_init_eth(void) {}
#endif /* CONFIG_AX88796 */

#if defined(CONFIG_USB_PXA27X)||defined(CONFIG_USB_PXA27X_MODULE)
static struct gpio_vbus_mach_info colibri_pxa320_gpio_vbus_info = {
	.gpio_vbus		= mfp_to_gpio(MFP_PIN_GPIO96),
	.gpio_pullup		= -1,
static struct gpiod_lookup_table gpio_vbus_gpiod_table = {
	.dev_id = "gpio-vbus",
	.table = {
		GPIO_LOOKUP("gpio-pxa", MFP_PIN_GPIO96,
			    "vbus", GPIO_ACTIVE_HIGH),
		{ },
	},
};

static struct platform_device colibri_pxa320_gpio_vbus = {
	.name	= "gpio-vbus",
	.id	= -1,
	.dev	= {
		.platform_data	= &colibri_pxa320_gpio_vbus_info,
	},
};

static void colibri_pxa320_udc_command(int cmd)
@@ -173,6 +174,7 @@ static struct pxa2xx_udc_mach_info colibri_pxa320_udc_info __initdata = {
static void __init colibri_pxa320_init_udc(void)
{
	pxa_set_udc_info(&colibri_pxa320_udc_info);
	gpiod_add_lookup_table(&gpio_vbus_gpiod_table);
	platform_device_register(&colibri_pxa320_gpio_vbus);
}
#else
+25 −15
Original line number Diff line number Diff line
@@ -14,6 +14,7 @@
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/clk-provider.h>
#include <linux/gpio/machine.h>
#include <linux/gpio.h>
#include <linux/delay.h>
#include <linux/platform_device.h>
@@ -22,7 +23,6 @@
#include <linux/mfd/t7l66xb.h>
#include <linux/mtd/rawnand.h>
#include <linux/mtd/partitions.h>
#include <linux/usb/gpio_vbus.h>
#include <linux/memblock.h>

#include <video/w100fb.h>
@@ -51,18 +51,20 @@ void __init eseries_fixup(struct tag *tags, char **cmdline)
		memblock_add(0xa0000000, SZ_64M);
}

struct gpio_vbus_mach_info e7xx_udc_info = {
	.gpio_vbus   = GPIO_E7XX_USB_DISC,
	.gpio_pullup = GPIO_E7XX_USB_PULLUP,
	.gpio_pullup_inverted = 1
static struct gpiod_lookup_table e7xx_gpio_vbus_gpiod_table __maybe_unused = {
	.dev_id = "gpio-vbus",
	.table = {
		GPIO_LOOKUP("gpio-pxa", GPIO_E7XX_USB_DISC,
			    "vbus", GPIO_ACTIVE_HIGH),
		GPIO_LOOKUP("gpio-pxa", GPIO_E7XX_USB_PULLUP,
			    "pullup", GPIO_ACTIVE_LOW),
		{ },
	},
};

static struct platform_device e7xx_gpio_vbus __maybe_unused = {
	.name	= "gpio-vbus",
	.id	= -1,
	.dev	= {
		.platform_data	= &e7xx_udc_info,
	},
};

struct pxaficp_platform_data e7xx_ficp_platform_data = {
@@ -165,6 +167,7 @@ static void __init e330_init(void)
	pxa_set_stuart_info(NULL);
	eseries_register_clks();
	eseries_get_tmio_gpios();
	gpiod_add_lookup_table(&e7xx_gpio_vbus_gpiod_table);
	platform_add_devices(ARRAY_AND_SIZE(e330_devices));
}

@@ -216,6 +219,7 @@ static void __init e350_init(void)
	pxa_set_stuart_info(NULL);
	eseries_register_clks();
	eseries_get_tmio_gpios();
	gpiod_add_lookup_table(&e7xx_gpio_vbus_gpiod_table);
	platform_add_devices(ARRAY_AND_SIZE(e350_devices));
}

@@ -340,6 +344,7 @@ static void __init e400_init(void)
	eseries_register_clks();
	eseries_get_tmio_gpios();
	pxa_set_fb_info(NULL, &e400_pxafb_mach_info);
	gpiod_add_lookup_table(&e7xx_gpio_vbus_gpiod_table);
	platform_add_devices(ARRAY_AND_SIZE(e400_devices));
}

@@ -534,6 +539,7 @@ static void __init e740_init(void)
	clk_add_alias("CLK_CK48M", e740_t7l66xb_device.name,
			"UDCCLK", &pxa25x_device_udc.dev),
	eseries_get_tmio_gpios();
	gpiod_add_lookup_table(&e7xx_gpio_vbus_gpiod_table);
	platform_add_devices(ARRAY_AND_SIZE(e740_devices));
	pxa_set_ac97_info(NULL);
	pxa_set_ficp_info(&e7xx_ficp_platform_data);
@@ -733,6 +739,7 @@ static void __init e750_init(void)
	clk_add_alias("CLK_CK3P6MI", e750_tc6393xb_device.name,
			"GPIO11_CLK", NULL),
	eseries_get_tmio_gpios();
	gpiod_add_lookup_table(&e7xx_gpio_vbus_gpiod_table);
	platform_add_devices(ARRAY_AND_SIZE(e750_devices));
	pxa_set_ac97_info(NULL);
	pxa_set_ficp_info(&e7xx_ficp_platform_data);
@@ -888,18 +895,20 @@ static struct platform_device e800_fb_device = {

/* --------------------------- UDC definitions --------------------------- */

static struct gpio_vbus_mach_info e800_udc_info = {
	.gpio_vbus   = GPIO_E800_USB_DISC,
	.gpio_pullup = GPIO_E800_USB_PULLUP,
	.gpio_pullup_inverted = 1
static struct gpiod_lookup_table e800_gpio_vbus_gpiod_table = {
	.dev_id = "gpio-vbus",
	.table = {
		GPIO_LOOKUP("gpio-pxa", GPIO_E800_USB_DISC,
			    "vbus", GPIO_ACTIVE_HIGH),
		GPIO_LOOKUP("gpio-pxa", GPIO_E800_USB_PULLUP,
			    "pullup", GPIO_ACTIVE_LOW),
		{ },
	},
};

static struct platform_device e800_gpio_vbus = {
	.name	= "gpio-vbus",
	.id	= -1,
	.dev	= {
		.platform_data	= &e800_udc_info,
	},
};


@@ -949,6 +958,7 @@ static void __init e800_init(void)
	clk_add_alias("CLK_CK3P6MI", e800_tc6393xb_device.name,
			"GPIO11_CLK", NULL),
	eseries_get_tmio_gpios();
	gpiod_add_lookup_table(&e800_gpio_vbus_gpiod_table);
	platform_add_devices(ARRAY_AND_SIZE(e800_devices));
	pxa_set_ac97_info(NULL);
}
+11 −7
Original line number Diff line number Diff line
@@ -20,10 +20,10 @@
#include <linux/delay.h>
#include <linux/mtd/mtd.h>
#include <linux/mtd/partitions.h>
#include <linux/gpio/machine.h>
#include <linux/gpio.h>
#include <linux/err.h>
#include <linux/clk.h>
#include <linux/usb/gpio_vbus.h>

#include <asm/setup.h>
#include <asm/memory.h>
@@ -101,21 +101,25 @@ static void __init gumstix_mmc_init(void)
#endif

#ifdef CONFIG_USB_PXA25X
static struct gpio_vbus_mach_info gumstix_udc_info = {
	.gpio_vbus		= GPIO_GUMSTIX_USB_GPIOn,
	.gpio_pullup		= GPIO_GUMSTIX_USB_GPIOx,
static struct gpiod_lookup_table gumstix_gpio_vbus_gpiod_table = {
	.dev_id = "gpio-vbus",
	.table = {
		GPIO_LOOKUP("gpio-pxa", GPIO_GUMSTIX_USB_GPIOn,
			    "vbus", GPIO_ACTIVE_HIGH),
		GPIO_LOOKUP("gpio-pxa", GPIO_GUMSTIX_USB_GPIOx,
			    "pullup", GPIO_ACTIVE_HIGH),
		{ },
	},
};

static struct platform_device gumstix_gpio_vbus = {
	.name	= "gpio-vbus",
	.id	= -1,
	.dev	= {
		.platform_data	= &gumstix_udc_info,
	},
};

static void __init gumstix_udc_init(void)
{
	gpiod_add_lookup_table(&gumstix_gpio_vbus_gpiod_table);
	platform_device_register(&gumstix_gpio_vbus);
}
#else
+14 −8
Original line number Diff line number Diff line
@@ -34,7 +34,6 @@
#include <linux/spi/ads7846.h>
#include <linux/spi/spi.h>
#include <linux/spi/pxa2xx_spi.h>
#include <linux/usb/gpio_vbus.h>
#include <linux/platform_data/i2c-pxa.h>

#include <mach/hardware.h>
@@ -578,18 +577,24 @@ static struct pwm_lookup hx4700_pwm_lookup[] = {
 * USB "Transceiver"
 */

static struct gpio_vbus_mach_info gpio_vbus_info = {
	.gpio_pullup        = GPIO76_HX4700_USBC_PUEN,
	.gpio_vbus          = GPIOD14_nUSBC_DETECT,
	.gpio_vbus_inverted = 1,
static struct gpiod_lookup_table gpio_vbus_gpiod_table = {
	.dev_id = "gpio-vbus",
	.table = {
		/* This GPIO is on ASIC3 */
		GPIO_LOOKUP("asic3",
			    /* Convert to a local offset on the ASIC3 */
			    GPIOD14_nUSBC_DETECT - HX4700_ASIC3_GPIO_BASE,
			    "vbus", GPIO_ACTIVE_LOW),
		/* This one is on the primary SOC GPIO */
		GPIO_LOOKUP("gpio-pxa", GPIO76_HX4700_USBC_PUEN,
			    "pullup", GPIO_ACTIVE_HIGH),
		{ },
	},
};

static struct platform_device gpio_vbus = {
	.name          = "gpio-vbus",
	.id            = -1,
	.dev = {
		.platform_data = &gpio_vbus_info,
	},
};

static struct pxa2xx_udc_mach_info hx4700_udc_info;
@@ -883,6 +888,7 @@ static void __init hx4700_init(void)
	pxa_set_stuart_info(NULL);

	gpiod_add_lookup_table(&bq24022_gpiod_table);
	gpiod_add_lookup_table(&gpio_vbus_gpiod_table);
	platform_add_devices(devices, ARRAY_SIZE(devices));
	pwm_add_table(hx4700_pwm_lookup, ARRAY_SIZE(hx4700_pwm_lookup));

+15 −7
Original line number Diff line number Diff line
@@ -27,7 +27,6 @@
#include <linux/regulator/fixed.h>
#include <linux/regulator/gpio-regulator.h>
#include <linux/regulator/machine.h>
#include <linux/usb/gpio_vbus.h>
#include <linux/platform_data/i2c-pxa.h>

#include <mach/hardware.h>
@@ -506,9 +505,20 @@ static struct resource gpio_vbus_resource = {
	.end	= IRQ_MAGICIAN_VBUS,
};

static struct gpio_vbus_mach_info gpio_vbus_info = {
	.gpio_pullup	= GPIO27_MAGICIAN_USBC_PUEN,
	.gpio_vbus	= EGPIO_MAGICIAN_CABLE_VBUS,
static struct gpiod_lookup_table gpio_vbus_gpiod_table = {
	.dev_id = "gpio-vbus",
	.table = {
		/*
		 * EGPIO on register 4 index 1, the second EGPIO chip
		 * starts at register 4 so this will be at index 1 on that
		 * chip.
		 */
		GPIO_LOOKUP("htc-egpio-1", 1,
			    "vbus", GPIO_ACTIVE_HIGH),
		GPIO_LOOKUP("gpio-pxa", GPIO27_MAGICIAN_USBC_PUEN,
			    "pullup", GPIO_ACTIVE_HIGH),
		{ },
	},
};

static struct platform_device gpio_vbus = {
@@ -516,9 +526,6 @@ static struct platform_device gpio_vbus = {
	.id		= -1,
	.num_resources	= 1,
	.resource	= &gpio_vbus_resource,
	.dev = {
		.platform_data = &gpio_vbus_info,
	},
};

/*
@@ -1032,6 +1039,7 @@ static void __init magician_init(void)
		ARRAY_SIZE(pwm_backlight_supply), 5000000);

	gpiod_add_lookup_table(&bq24022_gpiod_table);
	gpiod_add_lookup_table(&gpio_vbus_gpiod_table);
	platform_add_devices(ARRAY_AND_SIZE(devices));
}

Loading