From patchwork Tue Jan 17 14:35:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Bailon X-Patchwork-Id: 91668 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp518499qgi; Tue, 17 Jan 2017 06:35:52 -0800 (PST) X-Received: by 10.84.129.131 with SMTP id b3mr58028435plb.54.1484663752176; Tue, 17 Jan 2017 06:35:52 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 61si19063841pld.335.2017.01.17.06.35.52; Tue, 17 Jan 2017 06:35:52 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@baylibre-com.20150623.gappssmtp.com; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751394AbdAQOfp (ORCPT + 4 others); Tue, 17 Jan 2017 09:35:45 -0500 Received: from mail-wm0-f43.google.com ([74.125.82.43]:35476 "EHLO mail-wm0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751386AbdAQOfm (ORCPT ); Tue, 17 Jan 2017 09:35:42 -0500 Received: by mail-wm0-f43.google.com with SMTP id r126so203358763wmr.0 for ; Tue, 17 Jan 2017 06:35:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=awC65UmPIRgoCgyeY606qntMWyjVQFeLu8xp6PCY1WE=; b=TMQls8kQC3lU8XD40zfM0yFTAB8BTArCK4pkf+e29Qe6D6tKU4j78fCHpxRNjlKq0G fP60aQNPmP4D3eurju1HYNgCGdRoAUzDXtkDoOuJnrWpfXcjVBFdXCdsEyeOnUB9XpAO 20XzZCPwvLjYODTiIGeIyzmVSn09b2761ZkQmZyqxjgoopkY0TueRb9M9O54J475Tic4 tHoBY4Q71wpY8Oc5IYXW43DvzEWIppDPPgVzXdyeeuYKxgkvG6VDDP5a6P+/kvg5jbrw n5ZTuDRnPfuYAkdqbZ6AdMpuspYTPqtmdFWwaAKjKyei6WHPx4wDG3NrudE6lSsvvGvD 9p9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=awC65UmPIRgoCgyeY606qntMWyjVQFeLu8xp6PCY1WE=; b=IJq7Lqf3XAMaAlriUbRreYG878P43pAG1Wc2Ia+c4bMnst4E67LOfbDOyUn2O9rbFp woXyhbKm3WFccAVjXZx4DdgYgP2xtEeWYIkI2mmV/oEeMLpCrhrWcAbHuvv6kmMGMTPC 763aRbNvWmO2/Wh4YRqyA9Rr5ZcteYJU7+Bk9iBRi5cwF77RGEYMRbcMwRyiT2vT5GO2 YNGD248AXImd/ZVVvWawireU2YcQaVthojyTQiVM0opuR8rBXEmwbtFheQYaxmHX2zNM Af5fr0wgiJb/7r6NQiU6ZozKrIew07Sm8VSqRjLlKAX4dkDXAqW5tp6jvJGLn/maX3vM z39Q== X-Gm-Message-State: AIkVDXLLipVClju2J2BwJreaJzc1a1mmfrij2xcSxQjwOq/x63WRhdnn13SL66EyzXxHF/vj X-Received: by 10.223.136.109 with SMTP id e42mr18093074wre.14.1484663740959; Tue, 17 Jan 2017 06:35:40 -0800 (PST) Received: from localhost.localdomain ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id k11sm37394939wmb.18.2017.01.17.06.35.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 17 Jan 2017 06:35:40 -0800 (PST) From: Alexandre Bailon To: b-liu@ti.com Cc: vinod.koul@intel.com, dmaengine@vger.kernel.org, nsekhar@ti.com, khilman@baylibre.com, ptitiano@baylibre.com, tony@atomide.com, linux-omap@vger.kernel.org, sergei.shtylyov@cogentembedded.com, Alexandre Bailon Subject: [PATCH v2 5/5] usb: musb: da8xx: Add a primary support of PM runtime Date: Tue, 17 Jan 2017 15:35:28 +0100 Message-Id: <20170117143528.11404-6-abailon@baylibre.com> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20170117143528.11404-1-abailon@baylibre.com> References: <20170117143528.11404-1-abailon@baylibre.com> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org Currently, DA8xx doesn't support PM runtime. In addition, the glue driver is managing the clock itself. But the CPPI DMA needs to manage this clock too. Add support to PM runtime and use the callback to enable / disable the clock. And because the CPPI 4.1 is a child of Da8xx USB, it will be able to enable / disable the clock by using PM runtime. Signed-off-by: Alexandre Bailon --- drivers/usb/musb/da8xx.c | 41 ++++++++++++++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 7 deletions(-) -- 2.10.2 -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c index 046356f..e67c41d 100644 --- a/drivers/usb/musb/da8xx.c +++ b/drivers/usb/musb/da8xx.c @@ -379,11 +379,7 @@ static int da8xx_musb_init(struct musb *musb) musb->mregs += DA8XX_MENTOR_CORE_OFFSET; - ret = clk_prepare_enable(glue->clk); - if (ret) { - dev_err(glue->dev, "failed to enable clock\n"); - return ret; - } + pm_runtime_get(musb->controller->parent); /* Returns zero if e.g. not clocked */ rev = musb_readl(reg_base, DA8XX_USB_REVISION_REG); @@ -426,7 +422,7 @@ static int da8xx_musb_init(struct musb *musb) err_phy_power_on: phy_exit(glue->phy); fail: - clk_disable_unprepare(glue->clk); + pm_runtime_put(musb->controller->parent); return ret; } @@ -438,7 +434,7 @@ static int da8xx_musb_exit(struct musb *musb) phy_power_off(glue->phy); phy_exit(glue->phy); - clk_disable_unprepare(glue->clk); + pm_runtime_put(musb->controller->parent); usb_put_phy(musb->xceiv); @@ -584,6 +580,8 @@ static int da8xx_probe(struct platform_device *pdev) pinfo.data = pdata; pinfo.size_data = sizeof(*pdata); + pm_runtime_enable(&pdev->dev); + glue->musb = platform_device_register_full(&pinfo); ret = PTR_ERR_OR_ZERO(glue->musb); if (ret) { @@ -614,12 +612,41 @@ static const struct of_device_id da8xx_id_table[] = { MODULE_DEVICE_TABLE(of, da8xx_id_table); #endif +static int da8xx_runtime_suspend(struct device *dev) +{ + struct da8xx_glue *glue = dev_get_drvdata(dev); + + clk_disable_unprepare(glue->clk); + + return 0; +} + +static int da8xx_runtime_resume(struct device *dev) +{ + int ret; + struct da8xx_glue *glue = dev_get_drvdata(dev); + + ret = clk_prepare_enable(glue->clk); + if (ret) { + dev_err(glue->dev, "failed to enable clock\n"); + return ret; + } + + return 0; +} + +static const struct dev_pm_ops da8xx_pm_ops = { + .runtime_suspend = da8xx_runtime_suspend, + .runtime_resume = da8xx_runtime_resume, +}; + static struct platform_driver da8xx_driver = { .probe = da8xx_probe, .remove = da8xx_remove, .driver = { .name = "musb-da8xx", .of_match_table = of_match_ptr(da8xx_id_table), + .pm = &da8xx_pm_ops, }, };