Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3027068rwb; Mon, 15 Aug 2022 16:25:20 -0700 (PDT) X-Google-Smtp-Source: AA6agR7o7ClDyanz/HVy2lkOKbTy8Nw5/ba11zJUQ5JRrR6UZ6+iEe5OdGYyT0vfkVDTDiXM3n+K X-Received: by 2002:a05:6402:2683:b0:43e:76fc:f9db with SMTP id w3-20020a056402268300b0043e76fcf9dbmr16093800edd.390.1660605836486; Mon, 15 Aug 2022 16:23:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660605836; cv=none; d=google.com; s=arc-20160816; b=ODFn4BqFexLXML1gK95N9ebahP/pwUPiGHYOph4ohXbXIJqVMzsyb3UKiBhvSQ5CYQ +aTYm+rYuyyzcAJaGkQtgGeIyn3Xq3A6SmESx59lXhQcYipuBBBbUU18F7NrYizoFSHb KUV9tOoQ8hSej2nr2tEcylUysZrUATCeJnKx0SCy8s66Z+Ca4MeJs8Ys8wG+zxU9tgu6 4h5Fcq/Am2YKEIbkuPCk2H+BDxo8H+6wPeruNsX1blTqOg+Zzdl3J8qgAwMDpCVSOKW/ rk49qP7aKz8bCN1nmGxDA+7RHg2WkJvRXAk3elH3C2anCvv0yUJ0xNIYyopoRFuRzsSJ Bi6A== 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=vznI/sjVz+m5f9Qotp5iKDC6Xr0+1AmhePAoKpJEcexMbnkvRTkBb7yGMi/lZC1I4/ +X+s3wu2ZOIwbWhl9Scg2sTpowB7W/fsQqSOUpXc3WycshptlEg1SywAOQym6BoELKt4 bYUAF/XQckHaogcoGXI6usVV5eNNrDaaonOQvP/SsIZkKke7KhQqgoWAMW6sMUk49nAv tg3Mpk2mo9vW102tB9UqtzdUZ9yL+Cr/KK5Vos0u9UW/HwpAy2UG5vd6emnFJ6x3IME1 XCoSIVztrIIZiwuOYQUY5LzwG5IRq+1kHaDJvXY7Rk22jovPDAuLHzaKsvC1DHHim3Xv 33hA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=rEpJYOZM; 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 dr17-20020a170907721100b00731646a574esi8912587ejc.839.2022.08.15.16.23.31; Mon, 15 Aug 2022 16:23:56 -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=rEpJYOZM; 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 S1349209AbiHOVrs (ORCPT + 99 others); Mon, 15 Aug 2022 17:47:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349079AbiHOVmU (ORCPT ); Mon, 15 Aug 2022 17:42:20 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 573E1C5788; Mon, 15 Aug 2022 12:29:37 -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 DC241B8112C; Mon, 15 Aug 2022 19:29:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EF0B5C433C1; Mon, 15 Aug 2022 19:29:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660591774; bh=REkwR5J41q/Hrazw8AkkdOJJpFzFGfPiF5Ij9pcyQ+g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rEpJYOZMLOuT+J+7KSuW9VDkVX2q+TcXIIRePOMbEt3lQb69gvvjwh1NXkhI+z7Yq byUCjOvdsgdx1cWFs03l9brvqJ32bpbMMbrOkw+7id9PQ74QyMHH3NdbrAMzGi9Axs s41sW49BZf5o0E/sxmV5JBuqWlqeZaJGvttpVa3Q= 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.18 0679/1095] clk: imx: clk-fracn-gppll: Return rate in rate table properly in ->recalc_rate() Date: Mon, 15 Aug 2022 20:01:18 +0200 Message-Id: <20220815180457.458166104@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180429.240518113@linuxfoundation.org> References: <20220815180429.240518113@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