All of lore.kernel.org
 help / color / mirror / Atom feed
From: dbaryshkov@gmail.com (Dmitry Eremin-Solenikov)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 12/15] gpio-vbus: support disabling D+ pullup on suspend
Date: Tue,  5 Jul 2011 17:08:38 +0400	[thread overview]
Message-ID: <1309871321-11305-13-git-send-email-dbaryshkov@gmail.com> (raw)
In-Reply-To: <1309871321-11305-1-git-send-email-dbaryshkov@gmail.com>

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.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
 drivers/usb/otg/gpio_vbus.c   |   42 +++++++++++++++++++++++++++++++++++++++++
 include/linux/usb/gpio_vbus.h |    1 +
 2 files changed, 43 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/otg/gpio_vbus.c b/drivers/usb/otg/gpio_vbus.c
index 52733d9..3b27b1f 100644
--- a/drivers/usb/otg/gpio_vbus.c
+++ b/drivers/usb/otg/gpio_vbus.c
@@ -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),
 };
diff --git a/include/linux/usb/gpio_vbus.h b/include/linux/usb/gpio_vbus.h
index d9f03cc..2faa38d 100644
--- a/include/linux/usb/gpio_vbus.h
+++ b/include/linux/usb/gpio_vbus.h
@@ -27,4 +27,5 @@ struct gpio_vbus_mach_info {
 	int gpio_pullup;
 	bool gpio_vbus_inverted;
 	bool gpio_pullup_inverted;
+	bool disconnect_on_suspend;
 };
-- 
1.7.5.4

  parent reply	other threads:[~2011-07-05 13:08 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-05 13:08 [PATCH 00/15] Big pxa2[57]x_udc cleanup Dmitry Eremin-Solenikov
2011-07-05 13:08 ` [PATCH 01/15] ARM: pxa/balloon3: drop udc_is_connected Dmitry Eremin-Solenikov
2011-07-05 13:08 ` [PATCH 02/15] ARM: pxa/mioa701: " Dmitry Eremin-Solenikov
2011-07-05 13:08 ` [PATCH 03/15] ARM: pxa/stargate2: " Dmitry Eremin-Solenikov
2011-07-05 13:08 ` [PATCH 04/15] ARM: pxa25x_udc: separate lubbock handling to lubbock-usb transceiver Dmitry Eremin-Solenikov
2011-07-05 13:47   ` Felipe Balbi
2011-07-05 13:08 ` [PATCH 05/15] ARM: pxa/lubbock: switch to using lubbock_usb_xceiv transceiver Dmitry Eremin-Solenikov
2011-07-05 14:47   ` Sergei Shtylyov
2011-07-05 13:08 ` [PATCH 06/15] pxa: drop handling of udc_is_connected Dmitry Eremin-Solenikov
2011-07-05 13:08 ` [PATCH 07/15] pxa25x_udc: drop support for udc_command Dmitry Eremin-Solenikov
2011-07-05 13:46   ` Felipe Balbi
2011-07-08 21:34     ` Greg KH
2011-07-08 21:54       ` Felipe Balbi
2011-07-08 22:02         ` Greg KH
2011-07-08 22:14           ` Felipe Balbi
2011-07-12 13:41           ` Dmitry Eremin-Solenikov
2011-07-14  2:52             ` Eric Miao
2011-07-14 18:24               ` Robert Jarzmik
2011-07-14 19:01                 ` Robert Jarzmik
2011-07-15 10:40                 ` Eric Miao
2011-07-18  8:38               ` Felipe Balbi
2011-07-09  8:50       ` Dmitry Eremin-Solenikov
2011-07-05 13:08 ` [PATCH 08/15] otg: add gpio_pullup OTG transceiver for devices with no VBUS sensing Dmitry Eremin-Solenikov
2011-07-05 13:08 ` [PATCH 09/15] corgi: convert to use gpio-pullup Dmitry Eremin-Solenikov
2011-07-05 13:08 ` [PATCH 10/15] poodle: " Dmitry Eremin-Solenikov
2011-07-05 13:08 ` [PATCH 11/15] h5000: " Dmitry Eremin-Solenikov
2011-07-05 13:08 ` Dmitry Eremin-Solenikov [this message]
2011-07-05 13:08 ` [PATCH 13/15] mioa701: move gpio-pullup functionality to gpio-vbus Dmitry Eremin-Solenikov
2011-07-05 13:08 ` [PATCH 14/15] gpio-pullup: support disabling D+ pullup on suspend Dmitry Eremin-Solenikov
2011-07-05 13:08 ` [PATCH 15/15] pxa2[57]x_udc: drop gpio_pullup handling Dmitry Eremin-Solenikov
2011-07-05 13:49   ` Felipe Balbi
2011-07-05 20:42   ` Robert Jarzmik
2011-07-05 20:58     ` Dmitry Eremin-Solenikov
2011-07-06  7:20       ` Felipe Balbi
2011-07-06  7:30         ` Dmitry Eremin-Solenikov
2011-07-06  7:34           ` Felipe Balbi
2011-07-05 13:45 ` [PATCH 00/15] Big pxa2[57]x_udc cleanup Eric Miao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1309871321-11305-13-git-send-email-dbaryshkov@gmail.com \
    --to=dbaryshkov@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.