From patchwork Fri Feb 19 16:00:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abel Vesa X-Patchwork-Id: 12095811 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5F3AAC433DB for ; Fri, 19 Feb 2021 16:06:59 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 250B964E22 for ; Fri, 19 Feb 2021 16:06:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 250B964E22 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=nxp.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To:Message-Id:Date:Subject:To: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Q+0uGdlpKJCs1Scerytw94PfTbVShcGAHVNOiKpK0PQ=; b=IzX1MZD52vA6hlxZO8JOE2Ii7r CFFHiIvPY1Xzn7yTPtQtBC5frSUpGvRONObBJ62YDZWvuzis2155dkeK49YAuwu6cwbJb0b4gsEg7 n+voVGnBbnz8plJ0l5GjrghWROTiWchI5DP9isr5li7p7fnHFa4ijFve+GhtN5LdTiKsfsUzvlNCD Ab0ZWaUkcXak5S2tNqXlr3xSRPiDOgbXIwzzPejp3Ol9KhA/3VV/ASERkOPnMhc5vqyz+g30Zc8pr aF7i1bGg50sv6feT1VozdG6qkwKveiV6DeluZ3DN/lV24bGuYBmy62bO4Pzc4CAlxNaKMvv8I+oGf bb7/MCRA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1lD8Hc-0001fL-PI; Fri, 19 Feb 2021 16:05:32 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1lD8HQ-0001aQ-I3 for linux-arm-kernel@merlin.infradead.org; Fri, 19 Feb 2021 16:05:20 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description; bh=Gr0G7E01FmFIqlw5g7aVEuckhWCGHb9E/DMFwTWGkpo=; b=sNI7Ac0fB2RwtQm9zkcwoBDIVk cXd1n9avTxApLqFx5MZVtwBQLdoywbLbYtqOaPGDibjOqh6RxFBgmCc8X+anO0BR5DJx5kvQAkRUj 5o63oJZZmef8++nO2MYR5jv/yalwHDzM3rfhjU4cHLmJbjHMrSN3uzORYYDXx7T6w7bTN3bx79Sqs 1Y5vAS7WdBv5d2M+svW1mntK9FvwuaVSXc5i7zofhtwPUCV0jFZLNVAl8Og8Ytk21ECv6cJIBTwlY ZX676t/p99GzdTqnwOiG3ltJVuk59yQlEYO/iXKa4dv21V3GAyarr3U6YxAv5qE7bIuGSSEHoctMh 64+qtMZA==; Received: from inva020.nxp.com ([92.121.34.13]) by casper.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lD8E7-0032gK-Aw for linux-arm-kernel@lists.infradead.org; Fri, 19 Feb 2021 16:03:47 +0000 Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 6FAE11A026F; Fri, 19 Feb 2021 17:01:10 +0100 (CET) Received: from inva024.eu-rdc02.nxp.com (inva024.eu-rdc02.nxp.com [134.27.226.22]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 614431A00BD; Fri, 19 Feb 2021 17:01:10 +0100 (CET) Received: from fsr-ub1664-175.ea.freescale.net (fsr-ub1664-175.ea.freescale.net [10.171.82.40]) by inva024.eu-rdc02.nxp.com (Postfix) with ESMTP id BB2122042F; Fri, 19 Feb 2021 17:01:09 +0100 (CET) From: Abel Vesa To: Rob Herring , Shawn Guo , Sascha Hauer , Lucas Stach , Fabio Estevam , Chanwoo Choi , Georgi Djakov , Dong Aisheng , Peng Fan , Martin Kepplinger , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-clk@vger.kernel.org, Linux Kernel Mailing List Subject: [RFC 19/19] mmc: sdhci-esdhc-imx: Add interconnect support Date: Fri, 19 Feb 2021 18:00:16 +0200 Message-Id: <1613750416-11901-20-git-send-email-abel.vesa@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1613750416-11901-1-git-send-email-abel.vesa@nxp.com> References: <1613750416-11901-1-git-send-email-abel.vesa@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210219_160340_221693_663C7A97 X-CRM114-Status: GOOD ( 16.49 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: NXP Linux Team , Abel Vesa MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On probe, if the dts node contains a valid icc path, then look for the fsl,icc-rate property and get the rate. Also set the icc bandwidth for that path to the nominal rate needed for sdhc to function right. Then enable and disable the path every time the sdhc is used or not. This will result in reducing the clock speeds along the icc path for each pl301 and NoC, but still meet the requirements for all the other icc consumers. Signed-off-by: Abel Vesa --- drivers/mmc/host/sdhci-esdhc-imx.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c index a20459744d21..65c5caf82e0c 100644 --- a/drivers/mmc/host/sdhci-esdhc-imx.c +++ b/drivers/mmc/host/sdhci-esdhc-imx.c @@ -9,6 +9,7 @@ */ #include +#include #include #include #include @@ -287,6 +288,9 @@ struct pltfm_imx_data { struct clk *clk_ahb; struct clk *clk_per; unsigned int actual_clock; + struct icc_path *bus_path; + unsigned int bus_rate; + enum { NO_CMD_PENDING, /* no multiblock command pending */ MULTIBLK_IN_PROCESS, /* exact multiblock cmd in process */ @@ -1539,6 +1543,18 @@ static int sdhci_esdhc_imx_probe(struct platform_device *pdev) if (imx_data->socdata->flags & ESDHC_FLAG_PMQOS) cpu_latency_qos_add_request(&imx_data->pm_qos_req, 0); + imx_data->bus_path = devm_of_icc_get(&pdev->dev, "path"); + if (IS_ERR(imx_data->bus_path)) { + return PTR_ERR(imx_data->bus_path); + } else if (imx_data->bus_path) { + if (of_property_read_u32(pdev->dev.of_node, "fsl,icc-rate", &imx_data->bus_rate)) { + dev_err(&pdev->dev, "icc-rate missing\n"); + return -EINVAL; + } + + err = icc_set_bw(imx_data->bus_path, 0, imx_data->bus_rate); + } + imx_data->clk_ipg = devm_clk_get(&pdev->dev, "ipg"); if (IS_ERR(imx_data->clk_ipg)) { err = PTR_ERR(imx_data->clk_ipg); @@ -1720,14 +1736,20 @@ static int sdhci_esdhc_suspend(struct device *dev) ret = mmc_gpio_set_cd_wake(host->mmc, true); + icc_disable(imx_data->bus_path); + return ret; } static int sdhci_esdhc_resume(struct device *dev) { struct sdhci_host *host = dev_get_drvdata(dev); + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); + struct pltfm_imx_data *imx_data = sdhci_pltfm_priv(pltfm_host); int ret; + icc_enable(imx_data->bus_path); + ret = pinctrl_pm_select_default_state(dev); if (ret) return ret; @@ -1779,6 +1801,8 @@ static int sdhci_esdhc_runtime_suspend(struct device *dev) if (imx_data->socdata->flags & ESDHC_FLAG_PMQOS) cpu_latency_qos_remove_request(&imx_data->pm_qos_req); + icc_disable(imx_data->bus_path); + return ret; } @@ -1789,6 +1813,8 @@ static int sdhci_esdhc_runtime_resume(struct device *dev) struct pltfm_imx_data *imx_data = sdhci_pltfm_priv(pltfm_host); int err; + icc_enable(imx_data->bus_path); + if (imx_data->socdata->flags & ESDHC_FLAG_PMQOS) cpu_latency_qos_add_request(&imx_data->pm_qos_req, 0);