From patchwork Wed May 11 14:04:36 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Munegowda, Keshava" X-Patchwork-Id: 775992 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p4BFcloH023362 for ; Wed, 11 May 2011 15:38:47 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751968Ab1EKPiO (ORCPT ); Wed, 11 May 2011 11:38:14 -0400 Received: from devils.ext.ti.com ([198.47.26.153]:32902 "EHLO devils.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752552Ab1EKPiJ (ORCPT ); Wed, 11 May 2011 11:38:09 -0400 Received: from dbdp20.itg.ti.com ([172.24.170.38]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id p4BE8eRK004414 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 11 May 2011 09:08:42 -0500 Received: from dbde71.ent.ti.com (localhost [127.0.0.1]) by dbdp20.itg.ti.com (8.13.8/8.13.8) with ESMTP id p4BE8asQ009955; Wed, 11 May 2011 19:38:36 +0530 (IST) Received: from dbdp31.itg.ti.com (172.24.170.98) by DBDE71.ent.ti.com (172.24.170.149) with Microsoft SMTP Server id 8.3.106.1; Wed, 11 May 2011 19:38:35 +0530 Received: from localhost.localdomain (a0393220-desktop.india.ti.com [172.24.136.86]) by dbdp31.itg.ti.com (8.13.8/8.13.8) with ESMTP id p4BE8YXk026899; Wed, 11 May 2011 19:38:35 +0530 (IST) From: Keshava Munegowda To: , CC: Keshava Munegowda , , , , Keshava Munegowda Subject: [PATCH 5/5] arm: omap: usb: global Suspend and resume support of ehci and ohci Date: Wed, 11 May 2011 19:34:36 +0530 Message-ID: <1305122676-27236-6-git-send-email-keshava_mgowda@ti.com> X-Mailer: git-send-email 1.6.0.4 In-Reply-To: <1305122676-27236-5-git-send-email-keshava_mgowda@ti.com> References: <1305122676-27236-1-git-send-email-keshava_mgowda@ti.com> <1305122676-27236-2-git-send-email-keshava_mgowda@ti.com> <1305122676-27236-3-git-send-email-keshava_mgowda@ti.com> <1305122676-27236-4-git-send-email-keshava_mgowda@ti.com> <1305122676-27236-5-git-send-email-keshava_mgowda@ti.com> MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Wed, 11 May 2011 15:38:47 +0000 (UTC) From: Keshava Munegowda The global suspend and resume functions for usbhs core driver are implemented.These routine are called when the global suspend and resume occurs. Before calling these functions, the bus suspend and resume of ehci and ohci drivers are called from runtime pm. Signed-off-by: Keshava Munegowda --- drivers/mfd/omap-usb-host.c | 103 +++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 103 insertions(+), 0 deletions(-) diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c index bd63429..e1bc3b5 100644 --- a/drivers/mfd/omap-usb-host.c +++ b/drivers/mfd/omap-usb-host.c @@ -146,6 +146,10 @@ #define is_ehci_hsic_mode(x) (x == OMAP_EHCI_PORT_MODE_HSIC) +/* USBHS state bits */ +#define OMAP_USBHS_INIT 0 +#define OMAP_USBHS_SUSPEND 4 + struct usbhs_hcd_omap { struct clk *xclk60mhsp1_ck; struct clk *xclk60mhsp2_ck; @@ -165,6 +169,7 @@ struct usbhs_hcd_omap { u32 usbhs_rev; spinlock_t lock; int count; + unsigned long state; }; /*-------------------------------------------------------------------------*/ @@ -807,6 +812,8 @@ static int usbhs_enable(struct device *dev) (pdata->ehci_data->reset_gpio_port[1], 1); } + set_bit(OMAP_USBHS_INIT, &omap->state); + end_count: omap->count++; spin_unlock_irqrestore(&omap->lock, flags); @@ -895,6 +902,7 @@ static void usbhs_disable(struct device *dev) } pm_runtime_put_sync(dev); + clear_bit(OMAP_USBHS_INIT, &omap->state); /* The gpio_free migh sleep; so unlock the spinlock */ spin_unlock_irqrestore(&omap->lock, flags); @@ -924,10 +932,105 @@ void omap_usbhs_disable(struct device *dev) } EXPORT_SYMBOL_GPL(omap_usbhs_disable); +#ifdef CONFIG_PM + +static int usbhs_resume(struct device *dev) +{ + struct usbhs_hcd_omap *omap = dev_get_drvdata(dev); + struct usbhs_omap_platform_data *pdata = &omap->platdata; + unsigned long flags = 0; + + dev_dbg(dev, "Resuming TI HSUSB Controller\n"); + + if (!pdata) { + dev_dbg(dev, "missing platform_data\n"); + return -ENODEV; + } + + spin_lock_irqsave(&omap->lock, flags); + + if (!test_bit(OMAP_USBHS_INIT, &omap->state) || + !test_bit(OMAP_USBHS_SUSPEND, &omap->state)) + goto end_resume; + + pm_runtime_get_sync(dev); + + if (is_omap_usbhs_rev2(omap)) { + if (is_ehci_tll_mode(pdata->port_mode[0])) { + clk_enable(omap->usbhost_p1_fck); + clk_enable(omap->usbtll_p1_fck); + } + if (is_ehci_tll_mode(pdata->port_mode[1])) { + clk_enable(omap->usbhost_p2_fck); + clk_enable(omap->usbtll_p2_fck); + } + clk_enable(omap->utmi_p1_fck); + clk_enable(omap->utmi_p2_fck); + } + clear_bit(OMAP_USBHS_SUSPEND, &omap->state); + +end_resume: + spin_unlock_irqrestore(&omap->lock, flags); + return 0; +} + + +static int usbhs_suspend(struct device *dev) +{ + struct usbhs_hcd_omap *omap = dev_get_drvdata(dev); + struct usbhs_omap_platform_data *pdata = &omap->platdata; + unsigned long flags = 0; + + dev_dbg(dev, "Suspending TI HSUSB Controller\n"); + + if (!pdata) { + dev_dbg(dev, "missing platform_data\n"); + return -ENODEV; + } + + spin_lock_irqsave(&omap->lock, flags); + + if (!test_bit(OMAP_USBHS_INIT, &omap->state) || + test_bit(OMAP_USBHS_SUSPEND, &omap->state)) + goto end_suspend; + + if (is_omap_usbhs_rev2(omap)) { + if (is_ehci_tll_mode(pdata->port_mode[0])) { + clk_disable(omap->usbhost_p1_fck); + clk_disable(omap->usbtll_p1_fck); + } + if (is_ehci_tll_mode(pdata->port_mode[1])) { + clk_disable(omap->usbhost_p2_fck); + clk_disable(omap->usbtll_p2_fck); + } + clk_disable(omap->utmi_p2_fck); + clk_disable(omap->utmi_p1_fck); + } + + set_bit(OMAP_USBHS_SUSPEND, &omap->state); + pm_runtime_put_sync(dev); + +end_suspend: + spin_unlock_irqrestore(&omap->lock, flags); + return 0; +} + + +static const struct dev_pm_ops usbhsomap_dev_pm_ops = { + .suspend = usbhs_suspend, + .resume = usbhs_resume, +}; + +#define USBHS_OMAP_DEV_PM_OPS (&usbhsomap_dev_pm_ops) +#else +#define USBHS_OMAP_DEV_PM_OPS NULL +#endif + static struct platform_driver usbhs_omap_driver = { .driver = { .name = (char *)usbhs_driver_name, .owner = THIS_MODULE, + .pm = USBHS_OMAP_DEV_PM_OPS, }, .remove = __exit_p(usbhs_omap_remove), };