From patchwork Fri Aug 18 17:55:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 9909691 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 E1DAC600CC for ; Fri, 18 Aug 2017 17:56:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D8F3028CFD for ; Fri, 18 Aug 2017 17:56:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CDFFE28D0C; Fri, 18 Aug 2017 17:56:06 +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=unavailable 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 263E528CEF for ; Fri, 18 Aug 2017 17:56:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751786AbdHRRzw (ORCPT ); Fri, 18 Aug 2017 13:55:52 -0400 Received: from mail-pg0-f48.google.com ([74.125.83.48]:38889 "EHLO mail-pg0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752038AbdHRRzL (ORCPT ); Fri, 18 Aug 2017 13:55:11 -0400 Received: by mail-pg0-f48.google.com with SMTP id t80so41112084pgb.5 for ; Fri, 18 Aug 2017 10:55:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=2ZU07ODgvCEeWb+lW0HUfnrQU2DiuGUHrZ8l/xceBQE=; b=DjtwB0GUCSAXbfEG0U/RICBfAVmQJdkKIHxftf86uiNP88biV6unIW55wi7QDkHrpD IUuXxti+8rBu5zIvLEbF3RjfQhVUbNtxUeCDONMO9S++E6Wd/Rectie1pCahdhsBCYmA OSGO/ZV/hA4xDk2v7nclxjwQvNiJEa1NR1L/4= 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=2ZU07ODgvCEeWb+lW0HUfnrQU2DiuGUHrZ8l/xceBQE=; b=G1pBLAz5GczKicjERwLiJUjgKS14ZRkRxGwcDS4YICidHkEPTECB92/XYBhArfl9jS FxAektRPqpGmlrfFRQ8Mq/BJcsYMJpALqOtNfqYl+shIIeTpgdaJZ3p8CqpjeYEq2qDw 5Za1Zyg5NS0WVzeYdRvvn/ldt+8QwCnD5OEFIxFjURyFTtkfro9nhTiG/uQY+AbAnZ90 VMgmOHLIB/0NgFBFn2qTF005DT3NWZEJdHJO7xWZRbooYfoxrlIqkNXmPPgWUWBZsa2Z BzteGi/Hq2+lOuzfcceGQH3nrlq59mqN+8kLB5pCivpQOYkR8DODhQIJUXIdjMjEdecP iKeA== X-Gm-Message-State: AHYfb5ilNHAlymysXAW19HrZUB/iIIfUrfyjWz0+1oCjCaqY2YmSvTqe q/zYD7aBdsB2RmLg X-Received: by 10.101.86.74 with SMTP id m10mr9143282pgs.79.1503078911060; Fri, 18 Aug 2017 10:55:11 -0700 (PDT) Received: from localhost.localdomain (ip68-111-217-79.sd.sd.cox.net. [68.111.217.79]) by smtp.gmail.com with ESMTPSA id 204sm11132553pga.85.2017.08.18.10.55.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 18 Aug 2017 10:55:10 -0700 (PDT) From: Bjorn Andersson To: Adrian Hunter , Ulf Hansson Cc: linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Venkat Gopalakrishnan , Ritesh Harjani Subject: [PATCH 1/2] mmc: sdhci-msm: Utilize bulk clock API Date: Fri, 18 Aug 2017 10:55:05 -0700 Message-Id: <20170818175506.5035-2-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20170818175506.5035-1-bjorn.andersson@linaro.org> References: <20170818175506.5035-1-bjorn.andersson@linaro.org> Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP By stuffing the runtime controlled clocks into a clk_bulk_data array we can utilize the newly introduced bulk clock operations and clean up the error paths. This allow us to handle additional clocks in subsequent patch, without the added complexity. Cc: Ritesh Harjani Signed-off-by: Bjorn Andersson --- drivers/mmc/host/sdhci-msm.c | 44 ++++++++++++++++---------------------------- 1 file changed, 16 insertions(+), 28 deletions(-) diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c index fc73e56eb1e2..71e01cbc38b6 100644 --- a/drivers/mmc/host/sdhci-msm.c +++ b/drivers/mmc/host/sdhci-msm.c @@ -131,6 +131,7 @@ struct sdhci_msm_host { struct clk *pclk; /* SDHC peripheral bus clock */ struct clk *bus_clk; /* SDHC bus voter clock */ struct clk *xo_clk; /* TCXO clk needed for FLL feature of cm_dll*/ + struct clk_bulk_data bulk_clks[2]; unsigned long clk_rate; struct mmc_host *mmc; bool use_14lpp_dll_reset; @@ -1167,16 +1168,12 @@ static int sdhci_msm_probe(struct platform_device *pdev) goto bus_clk_disable; } - ret = clk_prepare_enable(msm_host->pclk); - if (ret) - goto bus_clk_disable; - /* Setup SDC MMC clock */ msm_host->clk = devm_clk_get(&pdev->dev, "core"); if (IS_ERR(msm_host->clk)) { ret = PTR_ERR(msm_host->clk); dev_err(&pdev->dev, "SDC MMC clk setup failed (%d)\n", ret); - goto pclk_disable; + goto bus_clk_disable; } /* @@ -1194,9 +1191,13 @@ static int sdhci_msm_probe(struct platform_device *pdev) if (ret) dev_warn(&pdev->dev, "core clock boost failed\n"); - ret = clk_prepare_enable(msm_host->clk); + msm_host->bulk_clks[0].clk = msm_host->clk; + msm_host->bulk_clks[1].clk = msm_host->pclk; + + ret = clk_bulk_prepare_enable(ARRAY_SIZE(msm_host->bulk_clks), + msm_host->bulk_clks); if (ret) - goto pclk_disable; + goto bus_clk_disable; core_memres = platform_get_resource(pdev, IORESOURCE_MEM, 1); msm_host->core_mem = devm_ioremap_resource(&pdev->dev, core_memres); @@ -1290,9 +1291,8 @@ static int sdhci_msm_probe(struct platform_device *pdev) pm_runtime_set_suspended(&pdev->dev); pm_runtime_put_noidle(&pdev->dev); clk_disable: - clk_disable_unprepare(msm_host->clk); -pclk_disable: - clk_disable_unprepare(msm_host->pclk); + clk_bulk_disable_unprepare(ARRAY_SIZE(msm_host->bulk_clks), + msm_host->bulk_clks); bus_clk_disable: if (!IS_ERR(msm_host->bus_clk)) clk_disable_unprepare(msm_host->bus_clk); @@ -1315,8 +1315,8 @@ static int sdhci_msm_remove(struct platform_device *pdev) pm_runtime_disable(&pdev->dev); pm_runtime_put_noidle(&pdev->dev); - clk_disable_unprepare(msm_host->clk); - clk_disable_unprepare(msm_host->pclk); + clk_bulk_disable_unprepare(ARRAY_SIZE(msm_host->bulk_clks), + msm_host->bulk_clks); if (!IS_ERR(msm_host->bus_clk)) clk_disable_unprepare(msm_host->bus_clk); sdhci_pltfm_free(pdev); @@ -1330,8 +1330,8 @@ static int sdhci_msm_runtime_suspend(struct device *dev) struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); struct sdhci_msm_host *msm_host = sdhci_pltfm_priv(pltfm_host); - clk_disable_unprepare(msm_host->clk); - clk_disable_unprepare(msm_host->pclk); + clk_bulk_disable_unprepare(ARRAY_SIZE(msm_host->bulk_clks), + msm_host->bulk_clks); return 0; } @@ -1341,21 +1341,9 @@ static int sdhci_msm_runtime_resume(struct device *dev) struct sdhci_host *host = dev_get_drvdata(dev); struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); struct sdhci_msm_host *msm_host = sdhci_pltfm_priv(pltfm_host); - int ret; - ret = clk_prepare_enable(msm_host->clk); - if (ret) { - dev_err(dev, "clk_enable failed for core_clk: %d\n", ret); - return ret; - } - ret = clk_prepare_enable(msm_host->pclk); - if (ret) { - dev_err(dev, "clk_enable failed for iface_clk: %d\n", ret); - clk_disable_unprepare(msm_host->clk); - return ret; - } - - return 0; + return clk_bulk_prepare_enable(ARRAY_SIZE(msm_host->bulk_clks), + msm_host->bulk_clks); } #endif