From patchwork Sun Jul 3 22:45:24 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 941222 Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p6400afU011025 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Mon, 4 Jul 2011 00:00:58 GMT Received: from canuck.infradead.org ([2001:4978:20e::1]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QdWaL-0005Qo-9C; Mon, 04 Jul 2011 00:00: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 1QdWaK-0005X9-Sp; Mon, 04 Jul 2011 00:00:20 +0000 Received: from casper.infradead.org ([2001:770:15f::2]) by canuck.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QdWaI-0005X4-Cf for linux-arm-kernel@canuck.infradead.org; Mon, 04 Jul 2011 00:00:18 +0000 Received: from mail-ww0-f49.google.com ([74.125.82.49]) by casper.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QdVQk-0003xu-NM for linux-arm-kernel@lists.infradead.org; Sun, 03 Jul 2011 22:46:23 +0000 Received: by wwf22 with SMTP id 22so3370428wwf.18 for ; Sun, 03 Jul 2011 15:45:32 -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=HkQodefCr8Ni6mLlhQh2bBWHopEfXYrcnPlz5WoR6Cg=; b=it9RCr+OfyJcPXWt8coCwKrtSDERkMZxT0CiJkP061h66u4iw1hpKnP2Gr86IP4JSf AQ4MKk5iIUsBTGoRE2y2ieCzE0jOzNd+3oaZmytAYEjLjFtU56IjJJq7YreTFXgPMJ/X wm+UoEmP+TtRcTqMiHzQ9ix1/xlixNFYKyRrg= Received: by 10.227.57.130 with SMTP id c2mr4695084wbh.68.1309733132399; Sun, 03 Jul 2011 15:45:32 -0700 (PDT) Received: from doriath.ww600.siemens.net ([91.213.169.4]) by mx.google.com with ESMTPS id gb1sm4004978wbb.54.2011.07.03.15.45.30 (version=SSLv3 cipher=OTHER); Sun, 03 Jul 2011 15:45:31 -0700 (PDT) From: Dmitry Eremin-Solenikov To: linux-arm-kernel@lists.infradead.org, linux-usb@vger.kernel.org Subject: [PATCH V3 1/2] gpio-vbus: support disabling D+ pullup on suspend Date: Mon, 4 Jul 2011 02:45:24 +0400 Message-Id: <1309733125-10869-2-git-send-email-dbaryshkov@gmail.com> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1309733125-10869-1-git-send-email-dbaryshkov@gmail.com> References: <1309733125-10869-1-git-send-email-dbaryshkov@gmail.com> X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110703_234622_966834_E2758539 X-CRM114-Status: GOOD ( 16.81 ) X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.3.2-r929478 on casper.infradead.org summary: Content analysis details: (-2.7 points, 5.0 required) 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.49 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -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 (demeter1.kernel.org [140.211.167.41]); Mon, 04 Jul 2011 00:00:58 +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. 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 --- 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..0754445 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; };