Skip to contentSkip to conversation

Suspend for gpio-vbus support

PATCH Superseded Dmitry Eremin-Solenikov 2 participants 5 messages Jul 2, 2011 – Jul 3, 2011

Subsystems (4)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover Suspend for gpio-vbus support

Previous version of these patches generated quite a lot of comments. Now I'd like to present an updated version of this patchset.

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   |   32 ++++++++++++++++++++++++++++++++
 include/linux/usb/gpio_vbus.h |    1 +
 3 files changed, 35 insertions(+), 6 deletions(-)
#1 lore raw

PATCH v2 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.

---
 drivers/usb/otg/gpio_vbus.c   |   32 ++++++++++++++++++++++++++++++++
 include/linux/usb/gpio_vbus.h |    1 +
 2 files changed, 33 insertions(+), 0 deletions(-)
drivers/usb/otg/gpio_vbus.c +32 -0
index 52733d9..44527bd 100644
@@ -327,6 +327,34 @@ static int __exit gpio_vbus_remove(struct platform_device *pdev)
 	return 0;
 }
 
+#ifdef CONFIG_PM
+static int gpio_vbus_suspend(struct platform_device *pdev, pm_message_t state)
+{
+	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 platform_device *pdev)
+{
+	struct gpio_vbus_data *gpio_vbus = platform_get_drvdata(pdev);
+
+	if (gpio_vbus->otg.gadget)
+		schedule_work(&gpio_vbus->work);
+
+	return 0;
+}
+#endif
+
 /* NOTE:  the gpio-vbus device may *NOT* be hotplugged */
 
 MODULE_ALIAS("platform:gpio-vbus");
@@ -337,6 +365,10 @@ static struct platform_driver gpio_vbus_driver = {
 		.owner = THIS_MODULE,
 	},
 	.remove  = __exit_p(gpio_vbus_remove),
+#ifdef CONFIG_PM
+	.suspend	= gpio_vbus_suspend,
+	.resume		= gpio_vbus_resume
+#endif
 };
 
 static int __init gpio_vbus_init(void)
include/linux/usb/gpio_vbus.h +1 -0
index d9f03cc..2faa38d 100644
@@ -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
#2 lore raw

PATCH v2 2/2 mioa701: move gpio-pullup functionality to gpio-vbus

In reply to Dmitry Eremin-Solenikov

gpio-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
index bcbd359..2039a53 100644
@@ -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
#3 lore raw

v2 cover Suspend for gpio-vbus support

In reply to Dmitry Eremin-Solenikov

Hello.

Quoted 7 lines · Dmitry Eremin-Solenikov

Previous version of these patches generated quite a lot of comments. Now I'd like to present an updated version of this patchset.

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.

Frankly speaking, I don't see where you have done that...

Quoted 3 lines

Dmitry Eremin-Solenikov (2):
gpio-vbus: support disabling D+ pullup on suspend
mioa701: move gpio-pullup functionality to gpio-vbus

WBR, Sergei

#4 lore raw

v2 cover Suspend for gpio-vbus support

Quoted 7 lines · Sergei Shtylyov

Hello.

Quoted 2 lines · Dmitry Eremin-Solenikov

Previous version of these patches generated quite a lot of comments. Now I'd like to present an updated version of this patchset.

Quoted 6 lines
Quoted 4 lines

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.

Frankly speaking, I don't see where you have done that...

Oops... Sent a previous version of the patchset. Sorry.

Quoted 7 lines
Quoted 4 lines

Dmitry Eremin-Solenikov (2):
gpio-vbus: support disabling D+ pullup on suspend
mioa701: move gpio-pullup functionality to gpio-vbus

WBR, Sergei

Signature · 2 lines
With best wishes
Dmitry