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: 12864136 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A7F24C433F5 for ; Sun, 29 May 2022 07:10:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229529AbiE2HKT (ORCPT ); Sun, 29 May 2022 03:10:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50292 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229557AbiE2HKQ (ORCPT ); Sun, 29 May 2022 03:10:16 -0400 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2047.outbound.protection.outlook.com [40.107.20.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2682193479; Sun, 29 May 2022 00:10:15 -0700 (PDT) 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/k5T293Cw6ijZ9qc4SE9b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mdc09h3BfLaq3IEsy716N9oQYIugFshAPYnPRAjM9iTnfYNgAgMC+MlrkWzQeEjtZSg1mMFrBimaLw9SUEArhI8dEuBOWcFgOvOeF3ks+oJA0aCqIJegBriCopWYpbWA5rE5shSAh97YUTCZBRcHoyzvyq3RLe7AC/zsjylU6iCZAG4PT23bnDmqP1o0oj/N05ZtG+vIrfGeX009q1wAqTsgQxGsmhliCFRgnG8Chdc14NJWIfDUUkuRLH1uK8RkiEl8wcMuqQCyXVMjqkZw8Es7gU1owhB7D/eQ43xJ9wZywb2lfppqzxlmyZvxTWbp5Hl1lKHrqdgcuf43t9RgFnXAjXZkxVF5TdcDQjzNeU00rf8d/bcTW8JZ8BCRX155048hxhJg7pg== X-OriginatorOrg: nxp.com X-MS-Exchange-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 Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.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);