Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3090511rwb; Mon, 15 Aug 2022 17:53:41 -0700 (PDT) X-Google-Smtp-Source: AA6agR7Z0Ot/kMhwMiVbyB4afFyfBbu97K2khaeZ10oUoatwfxQbLdYJdQ6tz/uneFNxVuur8rb4 X-Received: by 2002:a17:907:948f:b0:731:3f2e:8916 with SMTP id dm15-20020a170907948f00b007313f2e8916mr12150795ejc.442.1660611221141; Mon, 15 Aug 2022 17:53:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660611221; cv=none; d=google.com; s=arc-20160816; b=w90X0dr3XgMqYIyIznkHB7JPK/TZUv4N7Shh+CqwXcoznIQsIWI/QkO96x2+Eaob/Q 29yE2G8sX3VxLulz6x9dNu8uWrVqS3R/y8wPBD1iiCi37YRJiv3xRdBbsiK79B/EeFGS FbaDXIRzkftwUVmPPHeUV51e9mG0WNIJmqAfacHbt12u+Jk6hOB0QwHOIzzbn/nRc/74 9ynaiVkVpjvVByMP31vLThxyHbLUGD+8Zv2AiKzmGp1lgN45zvhBdsjosjgjmJzPWnme oDNWO6gBsMVXPphfKbHdYJyu8v1VpFlLrTz9CNUjzaLchzPr+nivUU81+V7+JF/J0+ta tcyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=fV7VlestbcwkMT76G8+VoISwtQl9hH5EYylghmaFEBo=; b=GGDu6G2SbzWc6qMbUnY/dNYHRFVTl8DlhKrst46slmBtT6Mhu66CyA3canU7KUJtCL QXtY31r91WnK81eDf3NFtvbIMlOJl5g00SFSA2IQnWwq5fCUYOR0zx8+3muTbBpNk3QT MHHK785asf00L6gbwrh7TX1zJjPqX8J73hSbWukwE9NNJsIjh218RNFnvCi31CE6tXGc 7ls4V99n+Hrh6Y7iXYkInC/OrBUFCfTW62ilsMa9WiqmuETmW6qcpDd2dwvKGCHp1wVd jfRU06sGYHfmOfd6CihqJLH2SoZlmXihdbzSURGHiChNH3npBXyUTVGI2D8v9QwLJPig pOyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=rFYt1SFs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q7-20020a50aa87000000b0043d44488b74si9415115edc.165.2022.08.15.17.53.15; Mon, 15 Aug 2022 17:53:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=rFYt1SFs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351890AbiHPAS3 (ORCPT + 99 others); Mon, 15 Aug 2022 20:18:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353234AbiHPAKm (ORCPT ); Mon, 15 Aug 2022 20:10:42 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5094DCCE18; Mon, 15 Aug 2022 13:29:29 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 911E4B80EB1; Mon, 15 Aug 2022 20:29:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 92BBEC433D6; Mon, 15 Aug 2022 20:29:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660595365; bh=REkwR5J41q/Hrazw8AkkdOJJpFzFGfPiF5Ij9pcyQ+g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rFYt1SFst0oribzCjK7N9Fn4ZRrsEs3fogVl6jxvwDxIpTO8BFhZzx1mc7U1KfILg HYY2ShnNq8dxuJmRjWNQjjQRGvWUZjJDJmubndPn7iVAN18d+KfxjBHXKThqJJQP1y xn2vudxCub5TQfuBxNzLIl1Uv1MOKNt+gtaXB0A4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Abel Vesa , Michael Turquette , Stephen Boyd , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Peng Fan , Liu Ying , Abel Vesa , Sasha Levin Subject: [PATCH 5.19 0724/1157] clk: imx: clk-fracn-gppll: Return rate in rate table properly in ->recalc_rate() Date: Mon, 15 Aug 2022 20:01:20 +0200 Message-Id: <20220815180508.438042675@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180439.416659447@linuxfoundation.org> References: <20220815180439.416659447@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Liu Ying [ Upstream commit 5ebaf9f7da5bb2dc56d394eabfcbe46dc6b1ea8d ] The PLL parameters in rate table should be directly compared with those read from PLL registers instead of the cooked ones. Fixes: 1b26cb8a77a4 ("clk: imx: support fracn gppll") Cc: Abel Vesa Cc: Michael Turquette Cc: Stephen Boyd Cc: Shawn Guo Cc: Sascha Hauer Cc: Pengutronix Kernel Team Cc: Fabio Estevam Cc: NXP Linux Team Cc: Peng Fan Signed-off-by: Liu Ying Reviewed-by: Peng Fan Reviewed-by: Abel Vesa Link: https://lore.kernel.org/r/20220609132902.3504651-6-peng.fan@oss.nxp.com Signed-off-by: Abel Vesa Signed-off-by: Sasha Levin --- drivers/clk/imx/clk-fracn-gppll.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/drivers/clk/imx/clk-fracn-gppll.c b/drivers/clk/imx/clk-fracn-gppll.c index 36a53c60e71f..cb06b0045e9e 100644 --- a/drivers/clk/imx/clk-fracn-gppll.c +++ b/drivers/clk/imx/clk-fracn-gppll.c @@ -131,18 +131,7 @@ static unsigned long clk_fracn_gppll_recalc_rate(struct clk_hw *hw, unsigned lon mfi = FIELD_GET(PLL_MFI_MASK, pll_div); rdiv = FIELD_GET(PLL_RDIV_MASK, pll_div); - rdiv = rdiv + 1; odiv = FIELD_GET(PLL_ODIV_MASK, pll_div); - switch (odiv) { - case 0: - odiv = 2; - break; - case 1: - odiv = 3; - break; - default: - break; - } /* * Sometimes, the recalculated rate has deviation due to @@ -160,6 +149,19 @@ static unsigned long clk_fracn_gppll_recalc_rate(struct clk_hw *hw, unsigned lon if (rate) return (unsigned long)rate; + rdiv = rdiv + 1; + + switch (odiv) { + case 0: + odiv = 2; + break; + case 1: + odiv = 3; + break; + default: + break; + } + /* Fvco = Fref * (MFI + MFN / MFD) */ fvco = fvco * mfi * mfd + fvco * mfn; do_div(fvco, mfd * rdiv * odiv); -- 2.35.1