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: 3334531 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 A4FEFC0D4B for ; Thu, 12 Dec 2013 21:40:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8237B207B3 for ; Thu, 12 Dec 2013 21:40:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8A841207BE for ; Thu, 12 Dec 2013 21:40:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751773Ab3LLVkI (ORCPT ); Thu, 12 Dec 2013 16:40:08 -0500 Received: from arroyo.ext.ti.com ([192.94.94.40]:59452 "EHLO arroyo.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751886Ab3LLVjo (ORCPT ); Thu, 12 Dec 2013 16:39:44 -0500 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 CC: , Linux ARM Kernel Mailing List , , Linux OMAP Mailing List , , Santosh Shilimkar , Felipe Balbi 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 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 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)