From patchwork Thu Dec 12 21:38:40 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Balbi X-Patchwork-Id: 3334581 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 298E89F2A9 for ; Thu, 12 Dec 2013 21:42:38 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 52CE7207B0 for ; Thu, 12 Dec 2013 21:42:37 +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 64CB02058C for ; Thu, 12 Dec 2013 21:42:36 +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 1VrE08-0000uX-3d; Thu, 12 Dec 2013 21:40:56 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VrDzg-000330-3P; Thu, 12 Dec 2013 21:40:28 +0000 Received: from arroyo.ext.ti.com ([192.94.94.40]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VrDyu-0002vr-GG for linux-arm-kernel@lists.infradead.org; Thu, 12 Dec 2013 21:39:42 +0000 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id rBCLdH00016539; Thu, 12 Dec 2013 15:39:17 -0600 Received: from DLEE70.ent.ti.com (dlemailx.itg.ti.com [157.170.170.113]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id rBCLdG4Z025937; Thu, 12 Dec 2013 15:39:16 -0600 Received: from dflp32.itg.ti.com (10.64.6.15) by DLEE70.ent.ti.com (157.170.170.113) with Microsoft SMTP Server id 14.2.342.3; Thu, 12 Dec 2013 15:39:16 -0600 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id rBCLdG60006591; Thu, 12 Dec 2013 15:39:16 -0600 From: Felipe Balbi To: Linux USB Mailing List Subject: [PATCH 2/7] usb: dwc3: omap: add basic pm_runtime support Date: Thu, 12 Dec 2013 15:38:40 -0600 Message-ID: <1386884325-11440-3-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_163940_753555_491BB6C4 X-CRM114-Status: GOOD ( 11.17 ) 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 If we want to suspend/runtime in runtime, we can do so, in OMAP's case at least, with the same implementation we use for system pm. This patch adds basic pm_runtime support with that in mind. Signed-off-by: Felipe Balbi --- drivers/usb/dwc3/dwc3-omap.c | 39 +++++++++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c index b269dbd..aea305d 100644 --- a/drivers/usb/dwc3/dwc3-omap.c +++ b/drivers/usb/dwc3/dwc3-omap.c @@ -617,20 +617,35 @@ static void dwc3_omap_complete(struct device *dev) dwc3_omap_enable_irqs(omap); } -static int dwc3_omap_suspend(struct device *dev) +static int __dwc3_omap_suspend(struct dwc3_omap *omap) { - struct dwc3_omap *omap = dev_get_drvdata(dev); - omap->utmi_otg_status = dwc3_omap_read_utmi_status(omap); return 0; } +static int __dwc3_omap_resume(struct dwc3_omap *omap) +{ + dwc3_omap_write_utmi_status(omap, omap->utmi_otg_status); + + return 0; +} + +static int dwc3_omap_suspend(struct device *dev) +{ + struct dwc3_omap *omap = dev_get_drvdata(dev); + + return __dwc3_omap_suspend(omap); +} + static int dwc3_omap_resume(struct device *dev) { struct dwc3_omap *omap = dev_get_drvdata(dev); + int ret; - dwc3_omap_write_utmi_status(omap, omap->utmi_otg_status); + ret = __dwc3_omap_resume(omap); + if (ret) + return ret; pm_runtime_disable(dev); pm_runtime_set_active(dev); @@ -639,11 +654,27 @@ static int dwc3_omap_resume(struct device *dev) return 0; } +static int dwc3_omap_runtime_suspend(struct device *dev) +{ + struct dwc3_omap *omap = dev_get_drvdata(dev); + + return __dwc3_omap_suspend(omap); +} + +static int dwc3_omap_runtime_resume(struct device *dev) +{ + struct dwc3_omap *omap = dev_get_drvdata(dev); + + return __dwc3_omap_resume(omap); +} + static const struct dev_pm_ops dwc3_omap_dev_pm_ops = { .prepare = dwc3_omap_prepare, .complete = dwc3_omap_complete, SET_SYSTEM_SLEEP_PM_OPS(dwc3_omap_suspend, dwc3_omap_resume) + SET_RUNTIME_PM_OPS(dwc3_omap_runtime_suspend, dwc3_omap_runtime_resume, + NULL) }; #define DEV_PM_OPS (&dwc3_omap_dev_pm_ops)