Received: by 2002:a05:6a10:6d25:0:0:0:0 with SMTP id gq37csp2044710pxb; Mon, 13 Sep 2021 10:42:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxy92V+kUizmF4bD1DGZRjU8hshkXfRcOp1a4FieTJ+vcwdIXjXR1kpJQWxJXTC0FoJ+iTq X-Received: by 2002:a17:907:9854:: with SMTP id jj20mr14525330ejc.133.1631554943580; Mon, 13 Sep 2021 10:42:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631554943; cv=none; d=google.com; s=arc-20160816; b=z3khnujsMgR9fCqVrUsHPqWIQgZG6adg+Gb7DA+81MhglRQBrIfTKkCvLounl4T08c lBoJj98/pPAzj+S4+VzLhG6MfrSfAYXcqYXwotIJUSwrW8d1gOsrEv2eFK/p9wxjb7nf DDprDfi0pCbgyE1kQfyvANT06RWVG49SaDnaDAKB6SpMQWoZMu9qpPw6ogDApmjmJunF RfSV/P6IvaJerTt3OX6OBJQo4dNqFb8u1VXThqgegwUIu23pw5GAGDNBCuI0fatAy8by sulr3h7hq8nE6xPW2zUvpvNRLbS8PX2XbZomshI/HZmXpT2r+2upFdiA4xicLo9+JbY8 +xyg== 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=X/ApWxLY2Kl0TTgZgPPcp3YrgckAik4O9i9eJa8Nlec=; b=nHEt6jMuFrxqcjGue+L5S9K++Egi+ZyzULo5LVabbmTQW7qEL1jxhzzCfnm6OmykjM QUem3x1D/L23wMVcOUkK6qYJcmNTe6DfWsNXEmeJzckHakqtNESiIiJBWon22cmi4cG5 oZS4+gcuXo4NT0LVXMOxVAO2XISzVqVF3NpWYlOXpVD4vIlD6vX7UKb3OBBL3PtAF9vs SEhCwOIouxZdgr/6wy2MBLzDG0MtOAxVpWe9HpeDaQ8mxfUDlLYxnrX7fP/RtNlmqGBy N319jKKdH5aGRc1trBGoYBO1PhXyUcMbrtGCZE6P5s9OopiVR9UBbTxNUnimTUHGu8bU bwIg== 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 b23si8030181edv.199.2021.09.13.10.41.59; Mon, 13 Sep 2021 10:42:23 -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 S1345371AbhIMRkd (ORCPT + 99 others); Mon, 13 Sep 2021 13:40:33 -0400 Received: from inva020.nxp.com ([92.121.34.13]:43672 "EHLO inva020.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244125AbhIMRjo (ORCPT ); Mon, 13 Sep 2021 13:39:44 -0400 Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id CC4AF1A0396; Mon, 13 Sep 2021 19:38:26 +0200 (CEST) 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 BE23F1A0394; Mon, 13 Sep 2021 19:38:26 +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 EF06520363; Mon, 13 Sep 2021 19:38:25 +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 05/19] devfreq: imx8m-ddrc: Use the opps acquired from EL3 Date: Mon, 13 Sep 2021 20:38:00 +0300 Message-Id: <1631554694-9599-6-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 i.MX8M platforms get their dram OPPs from the EL3. We don't need to duplicate that in the kernel dram dts node. We should just trust the OPPs provided by the EL3. Signed-off-by: Abel Vesa --- drivers/devfreq/imx8m-ddrc.c | 50 +++--------------------------------- 1 file changed, 3 insertions(+), 47 deletions(-) diff --git a/drivers/devfreq/imx8m-ddrc.c b/drivers/devfreq/imx8m-ddrc.c index 583123bf2100..f18a5c3c1c03 100644 --- a/drivers/devfreq/imx8m-ddrc.c +++ b/drivers/devfreq/imx8m-ddrc.c @@ -321,38 +321,9 @@ static int imx8m_ddrc_init_freq_info(struct device *dev) if (freq->dram_core_parent_index == 2 && freq->dram_alt_parent_index == 0) return -ENODEV; - } - - return 0; -} - -static int imx8m_ddrc_check_opps(struct device *dev) -{ - struct imx8m_ddrc *priv = dev_get_drvdata(dev); - struct imx8m_ddrc_freq *freq_info; - struct dev_pm_opp *opp; - unsigned long freq; - int i, opp_count; - - /* Enumerate DT OPPs and disable those not supported by firmware */ - opp_count = dev_pm_opp_get_opp_count(dev); - if (opp_count < 0) - return opp_count; - for (i = 0, freq = 0; i < opp_count; ++i, ++freq) { - opp = dev_pm_opp_find_freq_ceil(dev, &freq); - if (IS_ERR(opp)) { - dev_err(dev, "Failed enumerating OPPs: %ld\n", - PTR_ERR(opp)); - return PTR_ERR(opp); - } - dev_pm_opp_put(opp); - freq_info = imx8m_ddrc_find_freq(priv, freq); - if (!freq_info) { - dev_info(dev, "Disable unsupported OPP %luHz %luMT/s\n", - freq, DIV_ROUND_CLOSEST(freq, 250000)); - dev_pm_opp_disable(dev, freq); - } + if (dev_pm_opp_add(dev, freq->rate * 250000, 0)) + return -ENODEV; } return 0; @@ -360,7 +331,6 @@ static int imx8m_ddrc_check_opps(struct device *dev) static void imx8m_ddrc_exit(struct device *dev) { - dev_pm_opp_of_remove_table(dev); } static int imx8m_ddrc_probe(struct platform_device *pdev) @@ -407,16 +377,7 @@ static int imx8m_ddrc_probe(struct platform_device *pdev) return ret; } - ret = dev_pm_opp_of_add_table(dev); - if (ret < 0) { - dev_err(dev, "failed to get OPP table\n"); - return ret; - } - - ret = imx8m_ddrc_check_opps(dev); - if (ret < 0) - goto err; - + priv->profile.polling_ms = 1000; priv->profile.target = imx8m_ddrc_target; priv->profile.exit = imx8m_ddrc_exit; priv->profile.get_cur_freq = imx8m_ddrc_get_cur_freq; @@ -427,13 +388,8 @@ static int imx8m_ddrc_probe(struct platform_device *pdev) if (IS_ERR(priv->devfreq)) { ret = PTR_ERR(priv->devfreq); dev_err(dev, "failed to add devfreq device: %d\n", ret); - goto err; } - return 0; - -err: - dev_pm_opp_of_remove_table(dev); return ret; } -- 2.31.1