From patchwork Thu Dec 12 21:38:45 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Balbi X-Patchwork-Id: 3334431 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 CA35B9F2A9 for ; Thu, 12 Dec 2013 21:39:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E86F1207EF for ; Thu, 12 Dec 2013 21:39:51 +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 EE6E4207B3 for ; Thu, 12 Dec 2013 21:39:50 +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 1VrDz0-0000KL-En; Thu, 12 Dec 2013 21:39:46 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VrDyx-0002xy-Mi; Thu, 12 Dec 2013 21:39:43 +0000 Received: from comal.ext.ti.com ([198.47.26.152]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VrDyt-0002vw-Gy for linux-arm-kernel@lists.infradead.org; Thu, 12 Dec 2013 21:39:40 +0000 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id rBCLdIH3014165; Thu, 12 Dec 2013 15:39:18 -0600 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 rBCLdI8i020335; Thu, 12 Dec 2013 15:39:18 -0600 Received: from dlep32.itg.ti.com (157.170.170.100) by DLEE71.ent.ti.com (157.170.170.114) 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 rBCLdHTT003283; Thu, 12 Dec 2013 15:39:17 -0600 From: Felipe Balbi To: Linux USB Mailing List Subject: [PATCH 7/7] usb: dwc3: exynos: add pm_runtime support Date: Thu, 12 Dec 2013 15:38:45 -0600 Message-ID: <1386884325-11440-8-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_163939_642591_B8084DF8 X-CRM114-Status: GOOD ( 12.12 ) 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 Exynos 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 --- drivers/usb/dwc3/dwc3-exynos.c | 65 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 56 insertions(+), 9 deletions(-) diff --git a/drivers/usb/dwc3/dwc3-exynos.c b/drivers/usb/dwc3/dwc3-exynos.c index 6ccfc64..c93919a 100644 --- a/drivers/usb/dwc3/dwc3-exynos.c +++ b/drivers/usb/dwc3/dwc3-exynos.c @@ -141,24 +141,40 @@ static int dwc3_exynos_probe(struct platform_device *pdev) exynos->dev = dev; exynos->clk = clk; - clk_prepare_enable(exynos->clk); + ret = clk_prepare(exynos->clk); + if (ret) { + dev_err(dev, "failed to prepare clock\n"); + goto err2; + } + + pm_runtime_enable(dev); + ret = pm_runtime_get_sync(dev); + if (ret) { + dev_err(dev, "failed to enable dwc3 device\n"); + goto err3; + } if (node) { ret = of_platform_populate(node, NULL, NULL, dev); if (ret) { dev_err(dev, "failed to add dwc3 core\n"); - goto err2; + goto err3; } } else { dev_err(dev, "no device node, failed to add dwc3 core\n"); ret = -ENODEV; - goto err2; + goto err3; } return 0; +err3: + pm_runtime_put_sync(dev); + pm_runtime_disable(dev); + err2: - clk_disable_unprepare(clk); + clk_unprepare(clk); + err1: return ret; } @@ -171,7 +187,9 @@ static int dwc3_exynos_remove(struct platform_device *pdev) platform_device_unregister(exynos->usb2_phy); platform_device_unregister(exynos->usb3_phy); - clk_disable_unprepare(exynos->clk); + pm_runtime_put_sync(exynos->dev); + pm_runtime_disable(exynos->dev); + clk_unprepare(exynos->clk); return 0; } @@ -184,20 +202,33 @@ static const struct of_device_id exynos_dwc3_match[] = { MODULE_DEVICE_TABLE(of, exynos_dwc3_match); #endif -static int dwc3_exynos_suspend(struct device *dev) +static int __dwc3_exynos_suspend(struct dwc3_exynos *exynos) { - struct dwc3_exynos *exynos = dev_get_drvdata(dev); - clk_disable(exynos->clk); return 0; } +static int __dwc3_exynos_resume(struct dwc3_exynos *exynos) +{ + return clk_enable(exynos->clk); +} + +static int dwc3_exynos_suspend(struct device *dev) +{ + struct dwc3_exynos *exynos = dev_get_drvdata(dev); + + return __dwc3_exynos_suspend(exynos); +} + static int dwc3_exynos_resume(struct device *dev) { struct dwc3_exynos *exynos = dev_get_drvdata(dev); + int ret; - clk_enable(exynos->clk); + ret = __dwc3_exynos_resume(exynos); + if (ret) + return ret; /* runtime set active to reflect active state. */ pm_runtime_disable(dev); @@ -207,8 +238,24 @@ static int dwc3_exynos_resume(struct device *dev) return 0; } +static int dwc3_exynos_runtime_suspend(struct device *dev) +{ + struct dwc3_exynos *exynos = dev_get_drvdata(dev); + + return __dwc3_exynos_suspend(exynos); +} + +static int dwc3_exynos_runtime_resume(struct device *dev) +{ + struct dwc3_exynos *exynos = dev_get_drvdata(dev); + + return __dwc3_exynos_resume(exynos); +} + static const struct dev_pm_ops dwc3_exynos_dev_pm_ops = { SET_SYSTEM_SLEEP_PM_OPS(dwc3_exynos_suspend, dwc3_exynos_resume) + SET_RUNTIME_PM_OPS(dwc3_exynos_runtime_suspend, + dwc3_exynos_runtime_resume, NULL) }; static struct platform_driver dwc3_exynos_driver = {