Received: by 2002:a05:6a10:6d25:0:0:0:0 with SMTP id gq37csp2044534pxb; Mon, 13 Sep 2021 10:42:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwUd0tJJo5bsXzu2QbrlgIgXdQSw2e26VgopYt/xh5JLzwYe9zDs0bKFg5TnLPg2SafTsaZ X-Received: by 2002:a17:906:d04f:: with SMTP id bo15mr14201555ejb.309.1631554928000; Mon, 13 Sep 2021 10:42:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631554927; cv=none; d=google.com; s=arc-20160816; b=0LPT7I1gpuGDsWgiOQReH6d4cpOaQ20wHQsMUjPYSpqaEGZS+eCgQZbA6+nYY/9aN0 HiZHrEjAxM0Wf1ZkRDZ6Rd+nnZ9IU+tGRfqD/BkGy2zivNUoTUlzcp6DTqRVoLXCGoQ7 wLGoyLsnY/v+Jggt/+RXDb+JioX6NwDUz2arKk4eyRCjnC1GxKD+8x+nnJ3H5x3ZUH7n +KjVd5F9dRWT6OTIsf3sjlDU8SZaSi2a2IvJVnM/OF4XA/6g0hJS1Zp3Ibd/7vgN91jB lRFYqZnDS/QUmt2Eqde6dMYjAXWKZftCQA/nGEzsdgC7266MQuDdhi2nWRh8dbKwUcZK j4nw== 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=dMRcVW/VjwxshFzdUf4jTfqIU8vDciFaBcYG+hcZNjo=; b=yAuLhCdiYGknreqoj8eNN+V2dQ+MxW9TH01EiV5zUdVdVWNbgDqKvQYhyESMAPTfUI ac0w7ih4XxXgrM4DoMU4G+rd9CyJSMwDdKwihdwn9BWaxKIVp2S6G343bqgwcmS7kU2A yziNfUvUKOpkwsuXYdpJ4yAHFS9+TTgcKexDuVot2aaWkgSZIwn7ZMkucl6//ILAp7Cu 5TTNR+NHnLads0uaJkQ20peKjX1KQAIEjAInD7uY5UHzNRjTkkzq7zv59U7Bj4od6Xw7 7RG37/gLOmYs7CJiu0iVKHu+Y1Tme6Rgfih9MWlPbPn6XbEInKDDo+34RXjnsFKYzS4G K/JA== 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 p31si724871edb.554.2021.09.13.10.41.43; Mon, 13 Sep 2021 10:42:07 -0700 (PDT) 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 S243787AbhIMRko (ORCPT + 99 others); Mon, 13 Sep 2021 13:40:44 -0400 Received: from inva021.nxp.com ([92.121.34.21]:59276 "EHLO inva021.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343524AbhIMRjz (ORCPT ); Mon, 13 Sep 2021 13:39:55 -0400 Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 3B02C2005F5; Mon, 13 Sep 2021 19:38:38 +0200 (CEST) Received: from inva024.eu-rdc02.nxp.com (inva024.eu-rdc02.nxp.com [134.27.226.22]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 2DE712005F0; Mon, 13 Sep 2021 19:38:38 +0200 (CEST) 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 6011620363; Mon, 13 Sep 2021 19:38:37 +0200 (CEST) From: Abel Vesa To: Rob Herring , Dong Aisheng , Shawn Guo , Sascha Hauer , Fabio Estevam , "catalin.marinas@arm.com" , Will Deacon , MyungJoo Ham , Kyungmin Park , Chanwoo Choi , Georgi Djakov , Adrian Hunter , Ulf Hansson , Ahmad Fatoum Cc: Pengutronix Kernel Team , linux-serial@vger.kernel.org, NXP Linux Team , Linux Kernel Mailing List , devicetree@vger.kernel.org, linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Abel Vesa Subject: [RFC 18/19] mmc: sdhci-esdhc-imx: Add interconnect support Date: Mon, 13 Sep 2021 20:38:13 +0300 Message-Id: <1631554694-9599-19-git-send-email-abel.vesa@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1631554694-9599-1-git-send-email-abel.vesa@nxp.com> References: <1631554694-9599-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 | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c index f18d169bc8ff..9773a9efaae1 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 @@ -324,6 +325,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 */ @@ -1573,6 +1577,19 @@ 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)) { + err = PTR_ERR(imx_data->bus_path); + goto free_sdhci; + } 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); @@ -1762,14 +1779,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; @@ -1821,6 +1844,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; } @@ -1831,6 +1856,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.31.1