From patchwork Thu Dec 12 21:38:41 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Balbi X-Patchwork-Id: 3334601 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 58532C0D4A for ; Thu, 12 Dec 2013 21:43:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7E9B3207B0 for ; Thu, 12 Dec 2013 21:43:27 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 75D912058C for ; Thu, 12 Dec 2013 21:43:26 +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 1VrE0e-0001BT-KW; Thu, 12 Dec 2013 21:41:30 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VrDzy-00034D-Nl; Thu, 12 Dec 2013 21:40:46 +0000 Received: from bear.ext.ti.com ([192.94.94.41]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VrDyv-0002vu-1a for linux-arm-kernel@lists.infradead.org; Thu, 12 Dec 2013 21:39:47 +0000 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id rBCLdHJ6004739; Thu, 12 Dec 2013 15:39:17 -0600 Received: from DLEE70.ent.ti.com (dlee70.ent.ti.com [157.170.170.113]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id rBCLdHK1020319; Thu, 12 Dec 2013 15:39:17 -0600 Received: from dlep32.itg.ti.com (157.170.170.100) by DLEE70.ent.ti.com (157.170.170.113) with Microsoft SMTP Server id 14.2.342.3; Thu, 12 Dec 2013 15:39:17 -0600 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep32.itg.ti.com (8.14.3/8.13.8) with ESMTP id rBCLdGYB003270; Thu, 12 Dec 2013 15:39:17 -0600 From: Felipe Balbi To: Linux USB Mailing List Subject: [PATCH 3/7] usb: dwc3: pci: add pm_runtime support Date: Thu, 12 Dec 2013 15:38:41 -0600 Message-ID: <1386884325-11440-4-git-send-email-balbi@ti.com> X-Mailer: git-send-email 1.8.4.GIT In-Reply-To: <1386884325-11440-1-git-send-email-balbi@ti.com> References: <1386884325-11440-1-git-send-email-balbi@ti.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20131212_163941_366564_CDC2BB3F X-CRM114-Status: GOOD ( 14.40 ) X-Spam-Score: -6.9 (------) Cc: linux-samsung-soc@vger.kernel.org, w-kwok2@ti.com, Felipe Balbi , kgene.kim@samsung.com, Santosh Shilimkar , Linux OMAP Mailing List , Linux ARM Kernel Mailing List 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=-4.2 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 teach the PCI glue about pm_runtime so that it's easier to teach dwc3 core about it later. No functional changes otherwise. Signed-off-by: Felipe Balbi Acked-by: David Cohen --- drivers/usb/dwc3/dwc3-pci.c | 66 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 51 insertions(+), 15 deletions(-) diff --git a/drivers/usb/dwc3/dwc3-pci.c b/drivers/usb/dwc3/dwc3-pci.c index 665686e..78cd0b0 100644 --- a/drivers/usb/dwc3/dwc3-pci.c +++ b/drivers/usb/dwc3/dwc3-pci.c @@ -109,18 +109,17 @@ static int dwc3_pci_probe(struct pci_dev *pci, glue->dev = dev; - ret = pci_enable_device(pci); + pm_runtime_enable(dev); + ret = pm_runtime_get_sync(dev); if (ret) { dev_err(dev, "failed to enable pci device\n"); return -ENODEV; } - pci_set_master(pci); - ret = dwc3_pci_register_phys(glue); if (ret) { dev_err(dev, "couldn't register PHYs\n"); - return ret; + goto err1; } dwc3 = platform_device_alloc("dwc3", PLATFORM_DEVID_AUTO); @@ -167,7 +166,8 @@ static int dwc3_pci_probe(struct pci_dev *pci, err3: platform_device_put(dwc3); err1: - pci_disable_device(pci); + pm_runtime_put_sync(dev); + pm_runtime_disable(dev); return ret; } @@ -175,11 +175,13 @@ err1: static void dwc3_pci_remove(struct pci_dev *pci) { struct dwc3_pci *glue = pci_get_drvdata(pci); + struct device *dev = &pci->dev; platform_device_unregister(glue->dwc3); platform_device_unregister(glue->usb2_phy); platform_device_unregister(glue->usb3_phy); - pci_disable_device(pci); + pm_runtime_put_sync(dev); + pm_runtime_disable(dev); } static const struct pci_device_id dwc3_pci_id_table[] = { @@ -193,24 +195,20 @@ static const struct pci_device_id dwc3_pci_id_table[] = { }; MODULE_DEVICE_TABLE(pci, dwc3_pci_id_table); -#ifdef CONFIG_PM_SLEEP -static int dwc3_pci_suspend(struct device *dev) +static int __dwc3_pci_suspend(struct pci_dev *pci) { - struct pci_dev *pci = to_pci_dev(dev); - pci_disable_device(pci); return 0; } -static int dwc3_pci_resume(struct device *dev) +static int __dwc3_pci_resume(struct pci_dev *pci) { - struct pci_dev *pci = to_pci_dev(dev); - int ret; + int ret; ret = pci_enable_device(pci); if (ret) { - dev_err(dev, "can't re-enable device --> %d\n", ret); + dev_err(&pci->dev, "can't re-enable device --> %d\n", ret); return ret; } @@ -218,10 +216,48 @@ static int dwc3_pci_resume(struct device *dev) return 0; } -#endif /* CONFIG_PM_SLEEP */ + +static int dwc3_pci_suspend(struct device *dev) +{ + struct pci_dev *pci = to_pci_dev(dev); + + return __dwc3_pci_suspend(pci); +} + +static int dwc3_pci_resume(struct device *dev) +{ + struct pci_dev *pci = to_pci_dev(dev); + int ret; + + ret = __dwc3_pci_resume(pci); + if (ret) + return ret; + + pm_runtime_disable(dev); + pm_runtime_set_active(dev); + pm_runtime_disable(dev); + + return 0; +} + +static int dwc3_pci_runtime_suspend(struct device *dev) +{ + struct pci_dev *pci = to_pci_dev(dev); + + return __dwc3_pci_suspend(pci); +} + +static int dwc3_pci_runtime_resume(struct device *dev) +{ + struct pci_dev *pci = to_pci_dev(dev); + + return __dwc3_pci_resume(pci); +} static const struct dev_pm_ops dwc3_pci_dev_pm_ops = { SET_SYSTEM_SLEEP_PM_OPS(dwc3_pci_suspend, dwc3_pci_resume) + SET_RUNTIME_PM_OPS(dwc3_pci_runtime_suspend, dwc3_pci_runtime_resume, + NULL) }; static struct pci_driver dwc3_pci_driver = {