From patchwork Wed Jun 19 14:05:49 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 2749781 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 1F6F09F8E1 for ; Wed, 19 Jun 2013 14:08:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 56F022035E for ; Wed, 19 Jun 2013 14:08:07 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id ED39320322 for ; Wed, 19 Jun 2013 14:08:05 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UpJ2M-0004ye-MG; Wed, 19 Jun 2013 14:07:03 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UpJ25-0004Du-8O; Wed, 19 Jun 2013 14:06:45 +0000 Received: from devils.ext.ti.com ([198.47.26.153]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UpJ1l-0004A2-Qk for linux-arm-kernel@lists.infradead.org; Wed, 19 Jun 2013 14:06:27 +0000 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id r5JE63sb028231; Wed, 19 Jun 2013 09:06:03 -0500 Received: from DLEE71.ent.ti.com (dlee71.ent.ti.com [157.170.170.114]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id r5JE63EX020976; Wed, 19 Jun 2013 09:06:03 -0500 Received: from dlelxv22.itg.ti.com (172.17.1.197) by DLEE71.ent.ti.com (157.170.170.114) with Microsoft SMTP Server id 14.2.342.3; Wed, 19 Jun 2013 09:06:03 -0500 Received: from localhost.localdomain (h56-73.vpn.ti.com [172.24.56.73]) by dlelxv22.itg.ti.com (8.13.8/8.13.8) with ESMTP id r5JE5t2G021315; Wed, 19 Jun 2013 09:06:01 -0500 From: Roger Quadros To: , Subject: [RFC PATCH 2/6] mfd: omap-usb-host: Put pins in IDLE state on suspend Date: Wed, 19 Jun 2013 17:05:49 +0300 Message-ID: <1371650753-11452-3-git-send-email-rogerq@ti.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1371650753-11452-1-git-send-email-rogerq@ti.com> References: <1371650753-11452-1-git-send-email-rogerq@ti.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130619_100625_988840_F150DB70 X-CRM114-Status: GOOD ( 12.18 ) X-Spam-Score: -8.2 (--------) Cc: linux-usb@vger.kernel.org, Samuel Ortiz , ruslan.bilovol@ti.com, linux-kernel@vger.kernel.org, balbi@ti.com, linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Roger Quadros X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In order to support wake up from suspend use the pinctrl framework to put the USB host pins in IDLE state during suspend. CC: Samuel Ortiz Signed-off-by: Roger Quadros --- drivers/mfd/omap-usb-host.c | 46 +++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 46 insertions(+), 0 deletions(-) diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c index 6601a49..171cc3b 100644 --- a/drivers/mfd/omap-usb-host.c +++ b/drivers/mfd/omap-usb-host.c @@ -31,6 +31,7 @@ #include #include #include +#include #include "omap-usb.h" @@ -111,6 +112,10 @@ struct usbhs_hcd_omap { struct usbhs_omap_platform_data *pdata; u32 usbhs_rev; + + struct pinctrl *pinctrl; + struct pinctrl_state *pins_default; + struct pinctrl_state *pins_idle; }; /*-------------------------------------------------------------------------*/ @@ -325,6 +330,10 @@ static int usbhs_runtime_resume(struct device *dev) dev_dbg(dev, "usbhs_runtime_resume\n"); + if (!IS_ERR(omap->pins_default)) + if (pinctrl_select_state(omap->pinctrl, omap->pins_default)) + dev_err(dev, "Could not select DEFAULT pin state\n"); + omap_tll_enable(pdata); if (!IS_ERR(omap->ehci_logic_fck)) @@ -402,6 +411,10 @@ static int usbhs_runtime_suspend(struct device *dev) omap_tll_disable(pdata); + if (!IS_ERR(omap->pins_idle)) + if (pinctrl_select_state(omap->pinctrl, omap->pins_idle)) + dev_err(dev, "Could not select IDLE pin state\n"); + return 0; } @@ -608,6 +621,30 @@ static int usbhs_omap_probe(struct platform_device *pdev) return -ENOMEM; } + omap->pinctrl = devm_pinctrl_get(dev); + if (!IS_ERR(omap->pinctrl)) { + omap->pins_default = pinctrl_lookup_state(omap->pinctrl, + PINCTRL_STATE_DEFAULT); + if (IS_ERR(omap->pins_default)) + dev_err(dev, "Could not get DEFAULT state pins\n"); + + omap->pins_idle = pinctrl_lookup_state(omap->pinctrl, + PINCTRL_STATE_IDLE); + if (IS_ERR(omap->pins_idle)) + dev_err(dev, "Could not get IDLE state pins\n"); + + } else { + dev_info(dev, "pinctrl_get error\n"); + if (PTR_ERR(omap->pinctrl) == -EPROBE_DEFER) { + dev_info(dev, "defer\n"); + return -EPROBE_DEFER; + } + + omap->pins_default = omap->pins_idle = ERR_PTR(-EINVAL); + dev_dbg(dev, "Proceeding without pinctrl: %ld\n", + PTR_ERR(omap->pinctrl)); + } + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); omap->uhh_base = devm_ioremap_resource(dev, res); if (IS_ERR(omap->uhh_base)) @@ -796,6 +833,10 @@ static int usbhs_omap_probe(struct platform_device *pdev) } } + if (!IS_ERR(omap->pins_default)) + if (pinctrl_select_state(omap->pinctrl, omap->pins_default)) + dev_err(dev, "Could not select DEFAULT pin state\n"); + return 0; err_alloc: @@ -872,6 +913,11 @@ static int usbhs_omap_remove(struct platform_device *pdev) /* remove children */ device_for_each_child(&pdev->dev, NULL, usbhs_omap_remove_child); + + if (!IS_ERR(omap->pins_idle)) + if (pinctrl_select_state(omap->pinctrl, omap->pins_idle)) + dev_err(&pdev->dev, "Could not select IDLE pin state\n"); + return 0; }