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: 3334461 Return-Path: X-Original-To: patchwork-linux-omap@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 709DAC0D4A for ; Thu, 12 Dec 2013 21:40:03 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4A502207B3 for ; Thu, 12 Dec 2013 21:40:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 379B8207B0 for ; Thu, 12 Dec 2013 21:40:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751959Ab3LLVkA (ORCPT ); Thu, 12 Dec 2013 16:40:00 -0500 Received: from bear.ext.ti.com ([192.94.94.41]:50155 "EHLO bear.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751773Ab3LLVju (ORCPT ); Thu, 12 Dec 2013 16:39:50 -0500 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 CC: , Linux ARM Kernel Mailing List , , Linux OMAP Mailing List , , Santosh Shilimkar , Felipe Balbi 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 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 = {