From patchwork Tue Oct 16 09:45:36 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vikas C Sajjan X-Patchwork-Id: 1599631 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 45F4BDFFED for ; Tue, 16 Oct 2012 09:42:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752619Ab2JPJmQ (ORCPT ); Tue, 16 Oct 2012 05:42:16 -0400 Received: from mailout1.samsung.com ([203.254.224.24]:16529 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750918Ab2JPJmP (ORCPT ); Tue, 16 Oct 2012 05:42:15 -0400 Received: from epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MBZ00JBXCADQIT0@mailout1.samsung.com>; Tue, 16 Oct 2012 18:42:13 +0900 (KST) X-AuditID: cbfee61a-b7f976d000001eb9-40-507d2bf47d07 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 84.DE.07865.4FB2D705; Tue, 16 Oct 2012 18:42:13 +0900 (KST) Received: from vivekkumarg-linuxpc.sisodomain.com ([107.108.73.134]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MBZ001PUC6SONI0@mmp2.samsung.com>; Tue, 16 Oct 2012 18:42:12 +0900 (KST) From: Vikas Sajjan To: linux-usb@vger.kernel.org Cc: linux-omap@vger.kernel.org, gregkh@linuxfoundation.org, sarah.a.sharp@linux.intel.com, balbi@ti.com, joshi@samsung.com, kishon@ti.com, Abhilash Kesavan , Vikas C Sajjan , Doug Anderson Subject: [PATCH v3 1/3] usb: dwc3: Add the suspend/resume functionality Date: Tue, 16 Oct 2012 15:15:36 +0530 Message-id: <1350380738-32473-2-git-send-email-vikas.sajjan@linaro.org> X-Mailer: git-send-email 1.7.6.5 In-reply-to: <1350380738-32473-1-git-send-email-vikas.sajjan@linaro.org> References: <1350380738-32473-1-git-send-email-vikas.sajjan@linaro.org> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrOJMWRmVeSWpSXmKPExsVy+t9jQd2v2rUBBjvns1rMXtLPYrFoWSuz A5PH501yAYxRXDYpqTmZZalF+nYJXBktLxezFLzgq/i++zpzA+NUni5GTg4JAROJvTtWMUPY YhIX7q1n62Lk4hASmM4osXvCExYIZzKTxOG911hAqtgEdCS2L5rKCGKLCMhKHL7ymxmkiFmg i0micU8rK0hCWMBdYvbHqWANLAKqEtd/HgAay8HBCxR/sNYMYpuCxJvbz8A2cwp4SJw8/hds phBQyYK+ZSwTGHkXMDKsYhRNLUguKE5KzzXUK07MLS7NS9dLzs/dxAj2/jOpHYwrGywOMQpw MCrx8GY41wQIsSaWFVfmHmKU4GBWEuFlVqoNEOJNSaysSi3Kjy8qzUktPsQozcGiJM7b7JES ICSQnliSmp2aWpBaBJNl4uCUamCcmRSkaN2e8iPkjeLTZHXZPXe3359lsaJtSZH4J5aNjFsN Kl7nrNrRdeb+r+JezpjC9483bVosoBGs1uRxI/7Yr2QnoSMqFTdcFBXNEl12NbQzf03edXBl rmGlTXW8yOcnGRu7+Y+9vVn78FjN51MXVU+fEZEOmJGS27qYaUOBl4YP7+xJh8WUWIozEg21 mIuKEwETJo0v+gEAAA== Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org Adds suspend and resume callbacks as part of the power management support to DWC3 controller Driver. This patch facilitates transition of DWC3 controller between D0 and D3 power states during suspend/resume cycles. Signed-off-by: Abhilash Kesavan Signed-off-by: Vikas C Sajjan CC: Doug Anderson --- drivers/usb/dwc3/core.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 44 insertions(+), 0 deletions(-) diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 5db4c76..9f35cf8 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -621,11 +621,55 @@ static int __devexit dwc3_remove(struct platform_device *pdev) return 0; } +#ifdef CONFIG_PM_SLEEP +static int dwc3_resume(struct device *dev) +{ + struct dwc3 *dwc = dev_get_drvdata(dev); + int ret; + + ret = dwc3_core_init(dwc); + if (ret < 0) + return ret; + + switch (dwc->mode) { + case DWC3_MODE_DEVICE: + dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_DEVICE); + break; + case DWC3_MODE_HOST: + dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_HOST); + break; + case DWC3_MODE_DRD: + dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_OTG); + } + + /* runtime set active to reflect active state. */ + pm_runtime_disable(dev); + pm_runtime_set_active(dev); + pm_runtime_enable(dev); + + return 0; +} + +static int dwc3_suspend(struct device *dev) +{ + struct dwc3 *dwc = dev_get_drvdata(dev); + + dwc3_core_exit(dwc); + + return 0; +} +#endif /* CONFIG_PM_SLEEP */ + +static const struct dev_pm_ops dwc3_pm_ops = { + SET_SYSTEM_SLEEP_PM_OPS(dwc3_suspend, dwc3_resume) +}; + static struct platform_driver dwc3_driver = { .probe = dwc3_probe, .remove = __devexit_p(dwc3_remove), .driver = { .name = "dwc3", + .pm = &dwc3_pm_ops, }, };