From patchwork Wed Jun 22 12:20:16 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 904802 Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p5MCLfK2007097 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 22 Jun 2011 12:22:02 GMT Received: from canuck.infradead.org ([2001:4978:20e::1]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QZMQT-0005g0-G1; Wed, 22 Jun 2011 12:20:58 +0000 Received: from localhost ([127.0.0.1] helo=canuck.infradead.org) by canuck.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1QZMQS-0007Rx-VV; Wed, 22 Jun 2011 12:20:56 +0000 Received: from mail-wy0-f177.google.com ([74.125.82.177]) by canuck.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QZMQ4-0007KH-FR for linux-arm-kernel@lists.infradead.org; Wed, 22 Jun 2011 12:20:33 +0000 Received: by wyf23 with SMTP id 23so649569wyf.36 for ; Wed, 22 Jun 2011 05:20:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:cc:subject:date:message-id:x-mailer; bh=h4gBufxHDaQqbDDyONMfKzXvqPxo1710EEHZoc1cSas=; b=XjLyvECPA2EJXpXYYnLRUgEvLAH8UvTg2n9U1rQMquOmnDE4uQLAz3o8Ff5v9QAHIf x5u1sZTrJcYroGSaxoICAVIqAZgQb7VZIGH1G8qmdqrMi3oYOTKzPtu9g9LCDgMSW5ua YofMW/8qVZnrQ+qYnBf8ayE1XyXc63EMmgaoc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=SYXqlc4rnGBiBMO6XVoM/JUrcjJ5iNdPr+pIiMXjPPkV3eyYFHNfaNul2t+oFTrHKl +0lpvRS1Eo+K8Lr69O0LMJmnZf54eP80W79Sl/koDpl+aStmAD/C7ukEt7SAAwYmc4Oi xT52eywSX7LiS0HcDDesYNdlzIjoB2ohoh+Ks= Received: by 10.227.200.206 with SMTP id ex14mr692817wbb.12.1308745226766; Wed, 22 Jun 2011 05:20:26 -0700 (PDT) Received: from doriath.ww600.siemens.net ([91.213.169.4]) by mx.google.com with ESMTPS id ex2sm401398wbb.14.2011.06.22.05.20.22 (version=SSLv3 cipher=OTHER); Wed, 22 Jun 2011 05:20:25 -0700 (PDT) From: Dmitry Eremin-Solenikov To: linux-arm-kernel@lists.infradead.org, linux-usb@vger.kernel.org Subject: [PATCH 1/2] gpio-vbus: support disabling D+ pullup on suspend Date: Wed, 22 Jun 2011 16:20:16 +0400 Message-Id: <1308745217-10883-1-git-send-email-dbaryshkov@gmail.com> X-Mailer: git-send-email 1.7.5.3 X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110622_082032_801515_2707370C X-CRM114-Status: GOOD ( 17.32 ) X-Spam-Score: -0.8 (/) X-Spam-Report: SpamAssassin version 3.3.1 on canuck.infradead.org summary: Content analysis details: (-0.8 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [74.125.82.177 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is freemail (dbaryshkov[at]gmail.com) -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.0 RFC_ABUSE_POST Both abuse and postmaster missing on sender domain 0.0 T_TO_NO_BRKTS_FREEMAIL T_TO_NO_BRKTS_FREEMAIL Cc: Eric Miao , Robert Jarzmik , Greg Kroah-Hartman , Russell King , Felipe Balbi X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Wed, 22 Jun 2011 12:22:03 +0000 (UTC) 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. Signed-off-by: Dmitry Eremin-Solenikov --- drivers/usb/otg/gpio_vbus.c | 32 ++++++++++++++++++++++++++++++++ include/linux/usb/gpio_vbus.h | 1 + 2 files changed, 33 insertions(+), 0 deletions(-) diff --git a/drivers/usb/otg/gpio_vbus.c b/drivers/usb/otg/gpio_vbus.c index 52733d9..44527bd 100644 --- a/drivers/usb/otg/gpio_vbus.c +++ b/drivers/usb/otg/gpio_vbus.c @@ -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) 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; };