From patchwork Fri Sep 15 23:35:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 112766 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp1168699qgf; Fri, 15 Sep 2017 16:36:02 -0700 (PDT) X-Received: by 10.84.229.143 with SMTP id c15mr30047770plk.311.1505518562169; Fri, 15 Sep 2017 16:36:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505518562; cv=none; d=google.com; s=arc-20160816; b=v5yd9FwS8DXmsyxsA7EO0YDxc7jy/9SBM5JDPBsO6e7q1xzbsvb60Xe1CFbRjJ8U8a IrO/jfLZ9aef1raOZEBxKS31FFzLhZ+kMNX9NdXeP7u2mHuxGm1pDEnCetYeQkvxBa8q r+kUsPzov0/9jf3v622wm8OjOL5HW5cQHsYD+g0bY7wd+ltx1K9iAJySr/wpmQ3UXBXN Y+trAMI9PvvJ1/wN6cRewbYtyjHq4Z0oft+uNuI85rLK7GhqvnM88EtALtloGHLFfLL6 QNAfgV04V4xlGdS6TagHvkGPh3oVi/FZ6io6n81AYQ38pd4ph01D6rr1mlgx222fkuvj jXYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=37JwdqovmW8bWJAINemy8ggQX95iD4dyqckBu+GjOlA=; b=NZ22uzsk1Z8GY+ubHGxRX0H+xWQRyKuERI86CiNfwlABsS8klkr7UpcUGlo664ek6O ZoFvEKzMcWXlcuV8YYGwj1d9s+hUgAXUdE/Q1/vUeqifhzo8X+cRsmHsE9tOeIN3ZCO+ Y/0a7LE4BkgL5W8jpA+qZj8JhvvjkVGgdoBKyYJ4j/UCIcpTyjVcIYyZWSxOnEI1j1WJ w3UzZLdXpEf7p5XEEI4UeIKsdZD9/1li154rSqnT7/QqyS/gOp6wYEYHzckqBdbUURVg jiRIwr6fhb/H01gL+uH9mOyJJjkgSkD3CgBIMhYfORQnwmaIKlOvqN5kafNzut+XyZMR cpbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=B6D99JkF; spf=pass (google.com: best guess record for domain of linux-mmc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-mmc-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e30si1278340pgn.736.2017.09.15.16.36.01; Fri, 15 Sep 2017 16:36:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-mmc-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=@linaro.org header.s=google header.b=B6D99JkF; spf=pass (google.com: best guess record for domain of linux-mmc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-mmc-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751733AbdIOXgA (ORCPT + 6 others); Fri, 15 Sep 2017 19:36:00 -0400 Received: from mail-pg0-f41.google.com ([74.125.83.41]:46574 "EHLO mail-pg0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751197AbdIOXfa (ORCPT ); Fri, 15 Sep 2017 19:35:30 -0400 Received: by mail-pg0-f41.google.com with SMTP id i130so2322068pgc.3 for ; Fri, 15 Sep 2017 16:35:30 -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=5xraOtrtJvxHqgyqh0IDaBMqjbfm7OftNA4fUKDGgfY=; b=B6D99JkFFd64gM+O2zT1kI7BGywfs5VQB3cSVl/i9BZAK6XOJTbYTeTWngdUKgQve2 OYzgiJQcPvJEBfq1FM/ITiHcFwdJhcLqk+l/05E7pWnW+Po6Q/ZDWwTnfAenPQ1MiuBA oHG0dJVDEnmS6DSSXvyLlGKWLpjuzRZRaI9V8= 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=5xraOtrtJvxHqgyqh0IDaBMqjbfm7OftNA4fUKDGgfY=; b=fCS6VG2kXHxe+AE8Uk5fRqEUBxnc792jgX3qHywonFOmvLlMYU9756KI3IdVIWF3TP 7CwGrdh48lAHPt7k11ejTdeezyD/R9uvW7mZELNiBWODbMqTOdDOU8azQl51tYXonrlu YeufZLve7JB1t+sVezdgMNpeYTPlwXuADdOmCre/E5MAxdjTaSAhIGRa1sx2A7iSgXU9 59L81parBB75WYbVig2mWNE3bPkEfM3mv3queAANNdo2Z75+NXMUoleKFDAT6xnmhIve nllX66QS3tfLuMz6wr4dBVsAbPBXLh87gNfuQcKEwU7PpKoabSqc8e9Swf/vBRLc229A WSBQ== X-Gm-Message-State: AHPjjUiGIlTDW4Stga266k2P0lWTVbHbJHobjndo5limh6UDdtsXHPmH CKNS5uvk6AjdEUOU X-Google-Smtp-Source: AOwi7QAzOv01OfrX/ieMnh2rWFsiVCWnwa+yWDPTXQllZbykZ9WwMqfxCm4JU8JkhxLveq1E2crVmw== X-Received: by 10.98.217.220 with SMTP id b89mr1165734pfl.144.1505518530222; Fri, 15 Sep 2017 16:35:30 -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 78sm3924751pfk.70.2017.09.15.16.35.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Sep 2017 16:35:29 -0700 (PDT) From: Bjorn Andersson To: Adrian Hunter , Ulf Hansson Cc: Rob Herring , Mark Rutland , linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Venkat Gopalakrishnan , Ritesh Harjani , devicetree@vger.kernel.org Subject: [PATCH v2 1/2] mmc: sdhci-msm: Utilize bulk clock API Date: Fri, 15 Sep 2017 16:35:23 -0700 Message-Id: <20170915233524.1375-2-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20170915233524.1375-1-bjorn.andersson@linaro.org> References: <20170915233524.1375-1-bjorn.andersson@linaro.org> Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org 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 --- Changes since v1: - Dropped "clk" and "pclk" from sdhci_msm_host drivers/mmc/host/sdhci-msm.c | 80 +++++++++++++++++++------------------------- 1 file changed, 34 insertions(+), 46 deletions(-) -- 2.12.0 -- To unsubscribe from this list: send the line "unsubscribe linux-mmc" 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/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c index 9d601dc0d646..b9ca1b1ef9a8 100644 --- a/drivers/mmc/host/sdhci-msm.c +++ b/drivers/mmc/host/sdhci-msm.c @@ -127,10 +127,9 @@ struct sdhci_msm_host { struct platform_device *pdev; void __iomem *core_mem; /* MSM SDCC mapped address */ int pwr_irq; /* power irq */ - struct clk *clk; /* main SD/MMC bus clock */ - 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]; /* core, iface clocks */ unsigned long clk_rate; struct mmc_host *mmc; bool use_14lpp_dll_reset; @@ -164,10 +163,11 @@ static void msm_set_clock_rate_for_bus_mode(struct sdhci_host *host, struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); struct sdhci_msm_host *msm_host = sdhci_pltfm_priv(pltfm_host); struct mmc_ios curr_ios = host->mmc->ios; + struct clk *core_clk = msm_host->bulk_clks[0].clk; int rc; clock = msm_get_clock_rate_for_bus_mode(host, clock); - rc = clk_set_rate(msm_host->clk, clock); + rc = clk_set_rate(core_clk, clock); if (rc) { pr_err("%s: Failed to set clock at rate %u at timing %d\n", mmc_hostname(host->mmc), clock, @@ -176,7 +176,7 @@ static void msm_set_clock_rate_for_bus_mode(struct sdhci_host *host, } msm_host->clk_rate = clock; pr_debug("%s: Setting clock at rate %lu at timing %d\n", - mmc_hostname(host->mmc), clk_get_rate(msm_host->clk), + mmc_hostname(host->mmc), clk_get_rate(core_clk), curr_ios.timing); } @@ -1032,8 +1032,9 @@ static unsigned int sdhci_msm_get_max_clock(struct sdhci_host *host) { struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); struct sdhci_msm_host *msm_host = sdhci_pltfm_priv(pltfm_host); + struct clk *core_clk = msm_host->bulk_clks[0].clk; - return clk_round_rate(msm_host->clk, ULONG_MAX); + return clk_round_rate(core_clk, ULONG_MAX); } static unsigned int sdhci_msm_get_min_clock(struct sdhci_host *host) @@ -1124,6 +1125,7 @@ static int sdhci_msm_probe(struct platform_device *pdev) struct sdhci_pltfm_host *pltfm_host; struct sdhci_msm_host *msm_host; struct resource *core_memres; + struct clk *clk; int ret; u16 host_version, core_minor; u32 core_version, config; @@ -1159,24 +1161,32 @@ static int sdhci_msm_probe(struct platform_device *pdev) } /* Setup main peripheral bus clock */ - msm_host->pclk = devm_clk_get(&pdev->dev, "iface"); - if (IS_ERR(msm_host->pclk)) { - ret = PTR_ERR(msm_host->pclk); + clk = devm_clk_get(&pdev->dev, "iface"); + if (IS_ERR(clk)) { + ret = PTR_ERR(clk); dev_err(&pdev->dev, "Peripheral clk setup failed (%d)\n", ret); goto bus_clk_disable; } - - ret = clk_prepare_enable(msm_host->pclk); - if (ret) - goto bus_clk_disable; + msm_host->bulk_clks[1].clk = clk; /* 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); + clk = devm_clk_get(&pdev->dev, "core"); + if (IS_ERR(clk)) { + ret = PTR_ERR(clk); dev_err(&pdev->dev, "SDC MMC clk setup failed (%d)\n", ret); - goto pclk_disable; + goto bus_clk_disable; } + msm_host->bulk_clks[0].clk = clk; + + /* Vote for maximum clock rate for maximum performance */ + ret = clk_set_rate(clk, INT_MAX); + if (ret) + dev_warn(&pdev->dev, "core clock boost failed\n"); + + ret = clk_bulk_prepare_enable(ARRAY_SIZE(msm_host->bulk_clks), + msm_host->bulk_clks); + if (ret) + goto bus_clk_disable; /* * xo clock is needed for FLL feature of cm_dll. @@ -1188,15 +1198,6 @@ static int sdhci_msm_probe(struct platform_device *pdev) dev_warn(&pdev->dev, "TCXO clk not present (%d)\n", ret); } - /* Vote for maximum clock rate for maximum performance */ - ret = clk_set_rate(msm_host->clk, INT_MAX); - if (ret) - dev_warn(&pdev->dev, "core clock boost failed\n"); - - ret = clk_prepare_enable(msm_host->clk); - if (ret) - goto pclk_disable; - core_memres = platform_get_resource(pdev, IORESOURCE_MEM, 1); msm_host->core_mem = devm_ioremap_resource(&pdev->dev, core_memres); @@ -1289,9 +1290,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); @@ -1314,8 +1314,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); @@ -1329,8 +1329,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; } @@ -1340,21 +1340,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