From patchwork Mon Sep 13 17:38:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abel Vesa X-Patchwork-Id: 510091 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.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham 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 6DE7CC43217 for ; Mon, 13 Sep 2021 17:38:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6668E6113E for ; Mon, 13 Sep 2021 17:38:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345355AbhIMRkE (ORCPT ); Mon, 13 Sep 2021 13:40:04 -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-pm@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; }