Suspend for gpio-vbus
Subsystems (4)
v3 cover Suspend for gpio-vbus
V1 version of these patches generated quite a lot of comments. Now I'd like to present an updated version of this patchset.
Changes since V2:
* Really include all promised features. Blaming git format-patch :(
Changes since V1:
* Switch to using dev_pm_ops instead of platform_driver hooks
* Move suspend/resume to _noirq (LATE) to be sure that otg transceiver suspends after the main UDC driver.
Dmitry Eremin-Solenikov (2):
gpio-vbus: support disabling D+ pullup on suspend
mioa701: move gpio-pullup functionality to gpio-vbus
arch/arm/mach-pxa/mioa701.c | 8 +----- drivers/usb/otg/gpio_vbus.c | 42 +++++++++++++++++++++++++++++++++++++++++ include/linux/usb/gpio_vbus.h | 1 + 3 files changed, 45 insertions(+), 6 deletions(-)
PATCH v3 1/2 gpio-vbus: support disabling D+ pullup on suspend
Some platforms would like to disable D+ pullup on suspend, to drain as low power, as possible. E.g. this was requested by mioa701 board maintainers.
Suspend/resume is done in _noirq path, to force handling of pullup after the main UDC driver suspend/before resume.
--- drivers/usb/otg/gpio_vbus.c | 42 +++++++++++++++++++++++++++++++++++++++++ include/linux/usb/gpio_vbus.h | 1 + 2 files changed, 43 insertions(+), 0 deletions(-)
drivers/usb/otg/gpio_vbus.c +42 -0
@@ -327,6 +327,47 @@ static int __exit gpio_vbus_remove(struct platform_device *pdev)return 0 ; } +#ifdef CONFIG_PM +static int gpio_vbus_suspend (struct device *dev) +{ +struct platform_device *pdev =to_platform_device (dev); +struct gpio_vbus_data *gpio_vbus =platform_get_drvdata (pdev); +struct gpio_vbus_mach_info *pdata = gpio_vbus->dev->platform_data; + +if (gpio_vbus->otg.gadget && pdata->disconnect_on_suspend) { +/* optionally disable D+ pullup */ +if (gpio_is_valid (pdata->gpio_pullup)) +gpio_set_value (pdata->gpio_pullup, + pdata->gpio_pullup_inverted); + +set_vbus_draw (gpio_vbus,0 ); + } +return 0 ; +} + +static int gpio_vbus_resume (struct device *dev) +{ +struct platform_device *pdev =to_platform_device (dev); +struct gpio_vbus_data *gpio_vbus =platform_get_drvdata (pdev); + +if (gpio_vbus->otg.gadget) +schedule_work (&gpio_vbus->work); + +return 0 ; +} +static const struct dev_pm_ops gpio_vbus_pm_ops = { + .suspend_noirq = gpio_vbus_suspend, + .resume_noirq = gpio_vbus_resume, + .freeze_noirq = gpio_vbus_suspend, + .thaw_noirq = gpio_vbus_resume, + .poweroff_noirq = gpio_vbus_suspend, + .restore_noirq = gpio_vbus_resume, +}; +#define GPIO_VBUS_PM_OPS &gpio_vbus_pm_ops +#else +#define GPIO_VBUS_PM_OPS NULL +#endif +/* NOTE: the gpio-vbus device may *NOT* be hotplugged */ MODULE_ALIAS ("platform:gpio-vbus" );
@@ -335,6 +376,7 @@ static struct platform_driver gpio_vbus_driver = { .driver = { .name = "gpio-vbus", .owner = THIS_MODULE, + .pm = GPIO_VBUS_PM_OPS, }, .remove = __exit_p(gpio_vbus_remove), };
include/linux/usb/gpio_vbus.h +1 -0
@@ -27,4 +27,5 @@ struct gpio_vbus_mach_info {int gpio_pullup;bool gpio_vbus_inverted;bool gpio_pullup_inverted; +bool disconnect_on_suspend; };
Signature · 1 line
1.7.5.4
PATCH v3 2/2 mioa701: move gpio-pullup functionality to gpio-vbus
In reply to Dmitry Eremin-Solenikovgpio-vbus can (and should?) handle D+ pullup gpio for us. Move gpio-pullup handling to gpio-vbus and stop providing udc_info as it's empty now. Also tell gpio-vbus that it should disable D+ pullup on suspend, as did pxa27x_udc driver.
--- arch/arm/mach-pxa/mioa701.c | 8 ++------ 1 files changed, 2 insertions(+), 6 deletions(-)
arch/arm/mach-pxa/mioa701.c +2 -6
@@ -402,14 +402,11 @@ static void gsm_exit(void)/* * USB UDC */ -static struct pxa2xx_udc_mach_info mioa701_udc_info = { - .gpio_pullup =GPIO22_USB_ENABLE , -}; -struct gpio_vbus_mach_info gpio_vbus_data = { .gpio_vbus = GPIO13_nUSB_DETECT, .gpio_vbus_inverted =1 , - .gpio_pullup =-1 , + .gpio_pullup =GPIO22_USB_ENABLE , + .disconnect_on_suspend =1 , };/*
@@ -770,7 +767,6 @@ static void __init mioa701_machine_init(void)pxa_set_fb_info (NULL , &mioa701_pxafb_info);pxa_set_mci_info (&mioa701_mci_info);pxa_set_keypad_info (&mioa701_keypad_info); -pxa_set_udc_info (&mioa701_udc_info);pxa_set_ac97_info (&mioa701_ac97_info); pm_power_off = mioa701_poweroff; arm_pm_restart = mioa701_restart;
Signature · 1 line
1.7.5.4