Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp8133375pxb; Fri, 19 Feb 2021 08:11:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJwN7r8GOu6MIV5VrleFfwP3PeSO4esulA6lVrTRfdcIL7XYuD3UBse/4kWD1YY+RkDHSXGn X-Received: by 2002:a50:d302:: with SMTP id g2mr9924594edh.75.1613751065379; Fri, 19 Feb 2021 08:11:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613751065; cv=none; d=google.com; s=arc-20160816; b=q+7ymROdrt4UZBIiF2iGxkwOxgJi3VndloMJYgILG/fqDpVfxNemgHNzlVuHWE6CzJ YSz3puzGHxD/T2IKi+02DnyieH5+f92uVCceI/uH8eTQCLjNQ4fwvwdsHYeMU8GnAZRm Yr1JJR0wJ8L/9AQsR7DpIWGzJlwF/uJY1O5hpVQ5ArApmElqDhfl/NZUT62CKw8dQh4G Pb8Q6GgYMp336PcIENTnrQhEcp+gqZtj0zNLa35iannYuqIJZjYAUZ36IepcXBW9Bmf4 Lyfqmw+4bdfImK92Sc3joT8yM+EoQM+EAh0eTjPY2+EQhayW+YxWSvoilkoRKodJaUhp VMAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=Gr0G7E01FmFIqlw5g7aVEuckhWCGHb9E/DMFwTWGkpo=; b=VJ3cOwkSHpuCW5jVKQZY/zF67LU4q1pxMHl4KP3YzBdM1Pm0msO5dkx/TZYQIZLUW8 I+L/XNUGgqBi+PSyQDKPiZ3SWiwfgmgIS5pRGy/CBM6+/RiGaDtWX/lB7/rF2fwuvlqQ blLIT6FRNqxgxC5+AUDZrDYtdA1k5MJnBtVLFuPpDSg5Go9gJbtkGciol7izsSCLASwW qajxddJ7gC8cYTPothlPYcjWo9uN0xdkJpHsunTMujDiawe4m1APpqYRPhHf335YHNjM 76z6TZT9M0nQhZteOOMjS4P9hI39wIKOLvWw5H0niJlrkXTw0MmjdcOQJ0bO+zzoHMoy l4Mw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t16si7180555edi.293.2021.02.19.08.10.24; Fri, 19 Feb 2021 08:11:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229979AbhBSQHR (ORCPT + 99 others); Fri, 19 Feb 2021 11:07:17 -0500 Received: from inva020.nxp.com ([92.121.34.13]:36974 "EHLO inva020.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230010AbhBSQCi (ORCPT ); Fri, 19 Feb 2021 11:02:38 -0500 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 Cc: NXP Linux Team , Abel Vesa 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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); -- 2.29.2