From patchwork Tue Jul 5 13:08:38 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 945122 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 p65DRJCa009099 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 5 Jul 2011 13:27:40 GMT Received: from canuck.infradead.org ([2001:4978:20e::1]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1Qe5aS-00088f-Oh; Tue, 05 Jul 2011 13:22:50 +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 1Qe5Px-0008Hi-5e; Tue, 05 Jul 2011 13:11:57 +0000 Received: from mail-fx0-f43.google.com ([209.85.161.43]) by canuck.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1Qe5No-0007X5-JN for linux-arm-kernel@lists.infradead.org; Tue, 05 Jul 2011 13:09:45 +0000 Received: by mail-fx0-f43.google.com with SMTP id 17so5321658fxg.16 for ; Tue, 05 Jul 2011 06:09:44 -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=L1651jxWBF6pHsh7mp958LGxpV6cyb9qVhk/4h0zlck=; b=cdob9h5bsE33v7UM5R/SBjXjGMa8FdT9FTxAD3KpmFR1jwGicS2fmjiq0ERJ35rScI TfwpijNlQCAhIq4tXr6U+s4uh5PIgnslW06j5kVeS+NLfBzVnmMeOuCBv9UjEny7/F/c 3vOue+u20PdIaTvp8TI7zkaRu7dIysMPVibm8= Received: by 10.223.143.20 with SMTP id s20mr11315225fau.10.1309871384205; Tue, 05 Jul 2011 06:09:44 -0700 (PDT) Received: from doriath.ww600.siemens.net ([91.213.169.4]) by mx.google.com with ESMTPS id n20sm1952263fad.16.2011.07.05.06.09.40 (version=SSLv3 cipher=OTHER); Tue, 05 Jul 2011 06:09:43 -0700 (PDT) From: Dmitry Eremin-Solenikov To: linux-arm-kernel@lists.infradead.org, linux-usb@vger.kernel.org Subject: [PATCH 12/15] gpio-vbus: support disabling D+ pullup on suspend Date: Tue, 5 Jul 2011 17:08:38 +0400 Message-Id: <1309871321-11305-13-git-send-email-dbaryshkov@gmail.com> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1309871321-11305-1-git-send-email-dbaryshkov@gmail.com> References: <1309871321-11305-1-git-send-email-dbaryshkov@gmail.com> X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110705_090944_781702_C6BD4663 X-CRM114-Status: GOOD ( 15.24 ) 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 [209.85.161.43 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (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 T_TO_NO_BRKTS_FREEMAIL To: misformatted and free email service Cc: 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]); Tue, 05 Jul 2011 13:27:40 +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..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; };