From patchwork Sun May 29 07:11:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Ying X-Patchwork-Id: 12864135 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E9C48C433F5 for ; Sun, 29 May 2022 07:11:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=KlXiDuIzBSvhtlhi+tA+fjVdQvYY6E+1XeX+DnnjpjY=; b=C90BbL3KCRO4v9 xa2bY6V3RxrWzP75NG0AWzd4LU/l2EbwEmzmuSzACrYhScpg4mXKe6eW5OnhHw0XDvCEjs7CgWnHA aFwwu5EXAVCiKXj7KRQB87BLXCiJAaaoafz/DRc8r099nEUNm4OOMdGoHELLPcGSdHQ11dHKDGWcw MSlztj5mh/KUUacjpYK6EcnfZi1VkPk+vxIjD+kftCKwg2hQQYQQpOydBbLsfjOxqLfRAoABoSd0Q FUEE5x/Sab62tAnTE+VaxCOLfcCUj1l1SyjQtTLIJRo8/0p6t6yAPNj9rXi4wLAhWo9Fo9VZSkdfb RnA6yuqWcAgfdRKAD6gQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nvD4B-003R43-14; Sun, 29 May 2022 07:10:23 +0000 Received: from mail-am5eur02on061d.outbound.protection.outlook.com ([2a01:111:f400:fe07::61d] helo=EUR02-AM5-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nvD47-003R2a-BP for linux-arm-kernel@lists.infradead.org; Sun, 29 May 2022 07:10:20 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=i9tSyszyNGK9SyL77HpBu1eVGusCCyW/j23DH6AtSjiflsqZ1WVtahwU+5UA9dfhgnSxo9WLlvd40olEV0DZIDytbqcKyLWUY5oYvFEFa2m1/gwaFyv8Wp4MprXYlpkZ+mHUNA1xgX1Wd0jjKcppXJTGmGM9FUgP4kpayiE0fQAI13Nh/rJiylolpk9OJN2vZmk3h/xhjaxhEKinOjTJHBcycUOUkfcnJc70j4ytMZ9QcB+U5MIdb7vjHbCO90zeyfQAlIBzOmwGEtsrShvfL4ME9r1GOAVl1bKjqiexvdpbbG1j+uDNl9fG3D3SjaMmrjk2QWaqtsy2n4EArLRczA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=jy+tvKxf9qczXyI89nRzX3G19xsC2ED6/mP8+L/2ssU=; b=dFKH64GhFuyN7XyBsYK7JnIjXvZCnEekDoAu/4/jbIkbWxyYeQEelvq2ISRdh2QopLfKFgCr87BFkOwLDKfG97YClnIWsPci3wsaVajZlbLfPmPE+rEF7YR3sDyILCkWcrC0x1N0GR3eHFDch1tboy1epmFrwub9pLuSv8+bCRxk/baKwNQCRdcH65e+MhwLBjfpaiwvnaXC6frQOG28aUxXteUeCiT25qtbpK/ymHgWopJaVVSrgzeKWnceqe26JH/+0P6u2PJ8uX/HYzvb2fZnIF431QNixhE+8tdP6d5rgAlfQO7Q51hsgaZoMDmOsrL4masTei4In8pHWzv/zA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jy+tvKxf9qczXyI89nRzX3G19xsC2ED6/mP8+L/2ssU=; b=TXJV5OZc9qjHwUrzFylvPzk/RnPMLRmgNRRBypdNwI3eE2gB+2KjS2OOJKFlK7X6O41dYrTt4JFiSrqGTFKDLXZCrvncOtqzwZmSAo8iRL9uoprVW0/7gRaPajuFcqrwyhW6pwiAj/WgqKqR4S2KuynWKeKmAMkjpSvpjDwjJXU= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM7PR04MB7046.eurprd04.prod.outlook.com (2603:10a6:20b:113::22) by AS8PR04MB8007.eurprd04.prod.outlook.com (2603:10a6:20b:2aa::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5293.18; Sun, 29 May 2022 07:10:12 +0000 Received: from AM7PR04MB7046.eurprd04.prod.outlook.com ([fe80::3c82:f63b:711a:502]) by AM7PR04MB7046.eurprd04.prod.outlook.com ([fe80::3c82:f63b:711a:502%6]) with mapi id 15.20.5293.018; Sun, 29 May 2022 07:10:12 +0000 From: Liu Ying To: linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Abel Vesa , Michael Turquette , Stephen Boyd , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Peng Fan Subject: [PATCH] clk: imx: clk-fracn-gppll: Return rate in rate table properly in ->recalc_rate() Date: Sun, 29 May 2022 15:11:56 +0800 Message-Id: <20220529071156.2511568-1-victor.liu@nxp.com> X-Mailer: git-send-email 2.25.1 X-ClientProxiedBy: SGBP274CA0023.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b0::35) To AM7PR04MB7046.eurprd04.prod.outlook.com (2603:10a6:20b:113::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3c57ebe8-7d26-4c31-621d-08da41424619 X-MS-TrafficTypeDiagnostic: AS8PR04MB8007:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2jff0eAJGBQf+RhIFb8XbIgbztpFmELI/c5PNbogIlPVbkN87t24JnJm6B9AL0Mv9HAn6neN37QsvI4kI7ZfZM2bTQ7Ib92XlJObc1MhtxasKlgeffY3kJpyrCUCjGSbSvLwl68pFzc3zmIANhUXQZLIzlBBURzaipzMZ1mNa5UhpiDJ/FCjvJXSmhcDkzvf80KZfEZjd3578q10tvI1I7+MF3OoUgFZBcEsblHqtK6XsrKqbpPCufyyWG/Lbl7F1Zt6Ri+njr+orio2WYO/1Fw33XV82CWyKIzqkeEvDdlRlCEuOzMcCYTyYhBsrxgkCYE0tZh2p/0y5WBvuF9PqsHWeVgPwX6vOV0z2wiPfCQDqrSiTYehf0AduXDtvK71Pn+/jgyVudqbLHuSNNQbZWmDXKI6F29wxoAvmikOkNKo77r7LlnPm6OXxmGCZUd8BoE+p4bMkJ3Gt3gUItFIqaY1pQzeShPvdVJ1pVyMxPE4Z7kICD3lb2zLZwye/SiCqab0rda9w188tcf0jsEAeG/d77Y9aSvxMJJ6fG+ez4KTbUeSqLqzqD/cUY1U4XQYCpbZx+czuN2p11+8jSFsIvNXrtHkroNhCWxcNisdxN7NGFR0RabmzqIYOvxBiaGL2teCSPkLWBHo7Yw3C1fnXdPsgH4sY7Wd8JRngo8qm4swVDIKpg1lWrVmYBYatUyMzy6ccCJbmVa6ZSIAE9/pTQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM7PR04MB7046.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(66476007)(66556008)(8936002)(1076003)(36756003)(6506007)(54906003)(186003)(38100700002)(2906002)(66946007)(26005)(508600001)(4326008)(8676002)(316002)(38350700002)(6512007)(6486002)(83380400001)(5660300002)(6666004)(2616005)(86362001)(52116002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: f7wS9IHuBW/qZ4mousPz/8mEyQtmA0tjIguRO70FdQSrZRp9HgVAZ/HPt98tc8qcJGvVTj0GbkK9Q7MhdWrxb7+HmHZzS5RyIVLEc3hJxGpc0uIHayAG794lwOiz07uo/ZQO8CxnEywNil/ajpOCzxA7Fl1usishnVoz7XiDfr2alA+sGm7rPkgNxT7TaFqAH3pDHab4BnEdZTTfM0mr2WI1VVZgaRj34sIG65T/CVlRgRaVxTMqqO/fI/k5T293Cw6ijZ9qc4SE9bGLBE3EBgKH8dmyDJubylJfJwvQJBtjd+n85G3peTxEsz0DGIy9i0ktItvJ2ZlfswZ1PbDKG37F9v9r/YZRoiNQeIfI0Hih1HemMiaUCMXzN1SEZ0Atjmv/my3M/terwrZsjiwCIputFYlQRAcf5iZu+uXJzBbqsBvz3aWL2lADoro5+ATo+bhpCMuAbkhEiFHVJpiVh4Yrx4JZ2FjFV3Bp5U3aQmPwnij7KLE1L5F3v8L7emC2UC+tfxtMjm5QGPAvW50A7RWmOGCrV4UuaAiZM3dlnyXiikranbl6N7hiiFBqwj+DbYYvTwmBIofr167ScOXHiEr3CkR5ys11xx9QuiNBtxdqYNgvYVihetInpJXIWTUfuE/0lECzR/Xc7FPnIYNWDhovxGJFzw/bAsBvRfqL/hYIUdxbG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-CrossTenant-Network-Message-Id: 3c57ebe8-7d26-4c31-621d-08da41424619 X-MS-Exchange-CrossTenant-AuthSource: AM7PR04MB7046.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 May 2022 07:10:12.8561 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 3ZZJp1r/UcmOh9okxtlRa60VCJTMBqSVSircsAH488t2vS9ePSAIH32zKQ/HpGe7thP1RoSVWFzzLoVAb2WItw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8007 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220529_001019_593040_6B44E8D2 X-CRM114-Status: GOOD ( 12.17 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 --- 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 71c102d950ab..762b07dd5a6d 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);