From patchwork Sat Jul 2 14:02:23 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 940402 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 p62E3Zl3018990 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Sat, 2 Jul 2011 14:03:56 GMT Received: from canuck.infradead.org ([2001:4978:20e::1]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1Qd0n3-0008PH-2g; Sat, 02 Jul 2011 14:03:21 +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 1Qd0n2-0006JX-FL; Sat, 02 Jul 2011 14:03:20 +0000 Received: from mail-ww0-f41.google.com ([74.125.82.41]) by canuck.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1Qd0mT-0006Cy-QN for linux-arm-kernel@lists.infradead.org; Sat, 02 Jul 2011 14:02:48 +0000 Received: by wwi14 with SMTP id 14so556368wwi.0 for ; Sat, 02 Jul 2011 07:02:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=dGEaD7uY4SsvyBnbykC2Jkh235s5WcYsApG83yym/FE=; b=uLR5nxvlW1p+3DHd3A2rlCaMT5NA0p4ROw4992uMucOKbTvYyKKmxbMBrOGkr+EMFX 8fBfvOg3mYchO1M+gFSkBiDtguf6JnEnX41QfYp8JtrZk4EIRHdWn7IVe7eOqY/Ks9J2 kuqdgAaJ+Fd9t6Fy8dwUVTlB0Zw+1ixNQkJc0= Received: by 10.216.233.211 with SMTP id p61mr3589213weq.107.1309615359383; Sat, 02 Jul 2011 07:02:39 -0700 (PDT) Received: from doriath.ww600.siemens.net ([91.213.169.4]) by mx.google.com with ESMTPS id t79sm2070519weq.5.2011.07.02.07.02.37 (version=SSLv3 cipher=OTHER); Sat, 02 Jul 2011 07:02:38 -0700 (PDT) From: Dmitry Eremin-Solenikov To: linux-arm-kernel@lists.infradead.org, linux-usb@vger.kernel.org Subject: [PATCH V2 1/2] gpio-vbus: support disabling D+ pullup on suspend Date: Sat, 2 Jul 2011 18:02:23 +0400 Message-Id: <1309615344-12714-2-git-send-email-dbaryshkov@gmail.com> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1309615344-12714-1-git-send-email-dbaryshkov@gmail.com> References: <1309615344-12714-1-git-send-email-dbaryshkov@gmail.com> X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110702_100245_997276_8F89270F X-CRM114-Status: GOOD ( 13.97 ) 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.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (dbaryshkov[at]gmail.com) -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [74.125.82.41 listed in list.dnswl.org] -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 T_TO_NO_BRKTS_FREEMAIL To: misformatted and free email service Cc: Robert Jarzmik , Greg Kroah-Hartman , Eric Miao , 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]); Sat, 02 Jul 2011 14:03:56 +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; };