From patchwork Thu Feb 27 19:49:51 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Balbi X-Patchwork-Id: 25474 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f199.google.com (mail-ob0-f199.google.com [209.85.214.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 440D620543 for ; Thu, 27 Feb 2014 19:51:44 +0000 (UTC) Received: by mail-ob0-f199.google.com with SMTP id wo20sf2034812obc.6 for ; Thu, 27 Feb 2014 11:51:43 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe:content-type; bh=CI8pJSa2cxgeHchYea5VUa+ZSgsYh1NsXAiHgYOAS7A=; b=jmNs53UBEDR1Xz0AoXu4O5nIdKx5v7DNpINfgtmQgcGuoyUo+iTyXm/XHAVm3hrlZ4 x21XYh/2OEvYUWpMJLB+rHF0MGNeXPH0LC2Kr1h44/rp7F2dkgKIDBJh9ihSPCqOm8d0 Gox6uvpH3AYVmwImE9OkE8MmliJD3b931dxQKm0kg+tJLofCskOKmq61KIfCmTDCud4Q mG7tPVcAGLNanTHVS5k9dUaOdwKVDiC9fOR5OUnMxx796z/XVBeTCM2/waJzHp2QlrI8 oH1zWL/VzI9DpgaN9CU2stx25btOE+2ApDlVeKKTrQpHI+RbUmDd/ThIefKCeORc1pJ2 BKVw== X-Gm-Message-State: ALoCoQmx17LSCvkN3jtxAye6IVysS0ZHww0HbV8YERK0v3sC7tlHeBncVI5P/HTy8cF8ViCk66+/ X-Received: by 10.182.129.129 with SMTP id nw1mr4918800obb.34.1393530703874; Thu, 27 Feb 2014 11:51:43 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.89.136 with SMTP id v8ls836772qgd.17.gmail; Thu, 27 Feb 2014 11:51:43 -0800 (PST) X-Received: by 10.52.157.8 with SMTP id wi8mr1743094vdb.46.1393530703625; Thu, 27 Feb 2014 11:51:43 -0800 (PST) Received: from mail-ve0-f175.google.com (mail-ve0-f175.google.com [209.85.128.175]) by mx.google.com with ESMTPS id dq2si1556642veb.69.2014.02.27.11.51.43 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 27 Feb 2014 11:51:43 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.175 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.175; Received: by mail-ve0-f175.google.com with SMTP id oy12so4317559veb.6 for ; Thu, 27 Feb 2014 11:51:43 -0800 (PST) X-Received: by 10.220.147.16 with SMTP id j16mr2824797vcv.28.1393530703520; Thu, 27 Feb 2014 11:51:43 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.130.193 with SMTP id u1csp1521vcs; Thu, 27 Feb 2014 11:51:43 -0800 (PST) X-Received: by 10.66.164.70 with SMTP id yo6mr17205304pab.85.1393530702583; Thu, 27 Feb 2014 11:51:42 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id yo5si352357pab.34.2014.02.27.11.51.42; Thu, 27 Feb 2014 11:51:42 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752512AbaB0Tv3 (ORCPT + 3 others); Thu, 27 Feb 2014 14:51:29 -0500 Received: from bear.ext.ti.com ([192.94.94.41]:57338 "EHLO bear.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752435AbaB0Tv0 (ORCPT ); Thu, 27 Feb 2014 14:51:26 -0500 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id s1RJpPdc025393 for ; Thu, 27 Feb 2014 13:51:25 -0600 Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id s1RJpPHD026850 for ; Thu, 27 Feb 2014 13:51:25 -0600 Received: from dlep32.itg.ti.com (157.170.170.100) by DFLE72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.3.174.1; Thu, 27 Feb 2014 13:51:25 -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 s1RJpOxB016638; Thu, 27 Feb 2014 13:51:25 -0600 From: Felipe Balbi To: Linux USB Mailing List CC: Felipe Balbi Subject: [PATCH 2/8] usb: dwc3: omap: add basic pm_runtime support Date: Thu, 27 Feb 2014 13:49:51 -0600 Message-ID: <1393530597-12259-2-git-send-email-balbi@ti.com> X-Mailer: git-send-email 1.9.0 In-Reply-To: <1393530597-12259-1-git-send-email-balbi@ti.com> References: <1393530597-12259-1-git-send-email-balbi@ti.com> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: balbi@ti.com X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.175 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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. While at that, also fix ifdeferry up. Signed-off-by: Felipe Balbi --- drivers/usb/dwc3/dwc3-omap.c | 56 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 46 insertions(+), 10 deletions(-) diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c index b269dbd..558e1b5 100644 --- a/drivers/usb/dwc3/dwc3-omap.c +++ b/drivers/usb/dwc3/dwc3-omap.c @@ -600,7 +600,7 @@ static const struct of_device_id of_dwc3_match[] = { }; MODULE_DEVICE_TABLE(of, of_dwc3_match); -#ifdef CONFIG_PM_SLEEP +#ifdef CONFIG_PM static int dwc3_omap_prepare(struct device *dev) { struct dwc3_omap *omap = dev_get_drvdata(dev); @@ -617,20 +617,39 @@ static void dwc3_omap_complete(struct device *dev) dwc3_omap_enable_irqs(omap); } +static int __dwc3_omap_suspend(struct dwc3_omap *omap) +{ + 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; +} + +#ifdef CONFIG_PM_SLEEP static int dwc3_omap_suspend(struct device *dev) { struct dwc3_omap *omap = dev_get_drvdata(dev); - omap->utmi_otg_status = dwc3_omap_read_utmi_status(omap); + if (pm_runtime_suspended(dev)) + return 0; - return 0; + 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); @@ -638,26 +657,43 @@ static int dwc3_omap_resume(struct device *dev) return 0; } +#endif /* CONFIG_PM_SLEEP */ + +#ifdef CONFIG_PM_RUNTIME +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); +} +#endif /* CONFIG_PM_RUNTIME */ +#endif /* CONFIG_PM */ static const struct dev_pm_ops dwc3_omap_dev_pm_ops = { +#ifdef CONFIG_PM .prepare = dwc3_omap_prepare, .complete = dwc3_omap_complete, +#endif 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) -#else -#define DEV_PM_OPS NULL -#endif /* CONFIG_PM_SLEEP */ - static struct platform_driver dwc3_omap_driver = { .probe = dwc3_omap_probe, .remove = dwc3_omap_remove, .driver = { .name = "omap-dwc3", .of_match_table = of_dwc3_match, - .pm = DEV_PM_OPS, + .pm = &dwc3_omap_dev_pm_ops, }, };