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: 9521201 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5463F6043D for ; Tue, 17 Jan 2017 14:35:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4BE2327F80 for ; Tue, 17 Jan 2017 14:35:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 40C2E2857F; Tue, 17 Jan 2017 14:35:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CAD6228574 for ; Tue, 17 Jan 2017 14:35:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751386AbdAQOfp (ORCPT ); Tue, 17 Jan 2017 09:35:45 -0500 Received: from mail-wm0-f49.google.com ([74.125.82.49]:36656 "EHLO mail-wm0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751393AbdAQOfm (ORCPT ); Tue, 17 Jan 2017 09:35:42 -0500 Received: by mail-wm0-f49.google.com with SMTP id c85so202603139wmi.1 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=LGPFIyW3UJrvW07Z0BrfZnZlhEb5KwoP9Sik0JUXSWQlXGQ02nQ3/Cjbq+V0dKI6cn IEKvdlUtaa8/67Pa2Fu5bjL2zM/skN20QUSEAdzja79Anizbj3BppaqfRE2UuiGKCPn1 QSvySs83CbcHedLJpzUnQwBQaxjW5cU5CTDjmb7/9JU/AkJ2kHugIE4JAjSxRVYdyrwA If13DqJsO2urZu3GFSdalwe8WY1klckpxicWDkGPUt4uXGIu9z7WMK6aLEugOU74dIc7 UE7jCpcvd48sGVEx+Q+psgIr6XVl536UL+yFTobZNsucwsRWlZMbLKPxTlz0lbHeJTO6 e5FA== X-Gm-Message-State: AIkVDXIIRow6LWryIbD375ceDnOA8ShGiDROOQNB2mLHUSmQhYa79LFEF61wRtjlW7M5A2Vg 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: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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(-) 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, }, };