From patchwork Sat May 4 00:48:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Peng Fan (OSS)" X-Patchwork-Id: 13653707 Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2074.outbound.protection.outlook.com [40.107.105.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 96698171C2 for ; Sat, 4 May 2024 00:41:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.105.74 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714783294; cv=fail; b=pdkE9bvxlR10svp+yp3Z48islK+ZbKkHx3RG0LjIEccCS4nrErbds160bYMPLeYLzr67bd6oXbnTeoXnocskEhJeB3lGdrYnpHVJuAWl/SioefV+KoeS0+vuzuPpEsZE9h37pz1OqnkiCqh4+vz80Pykk9vnlRvlWqdGFJOrxds= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714783294; c=relaxed/simple; bh=5mmWyK9WwIfkcE/cYuEGrNrZK8Et8RVYnJ0d/vH/OxM=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=cEDHSmYYfzuFaInOHI+eGmrKpdefGcHRP3lzlPe7imr0O/hMsnpCmH2H7Mtt2kJnS7lpL1a8YKTdDBu7Q5K7zVvATAb1OtmadAul2O2+kcpekiOXkVIKhlq3TiWHX/0xCuAzx92jKKENkhVXWM4+dpRvrTIcjdGp9D08Rwtg1vI= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.nxp.com; spf=pass smtp.mailfrom=oss.nxp.com; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b=C+jtar6q; arc=fail smtp.client-ip=40.107.105.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="C+jtar6q" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XXc0MPEo1GlatILkQMzFmcxH2wsulOZzbgZIktIK3A80IrvJZQAdkXv5BmtkxR6GMm2LzruthW//JB8egDg3sMcRQztlA8JwIy/m8dkt2azj4pZEj/Jx7hSPTIJ6L/vzEpPchN82ceXkxUTbj00Km2s0giuDbNlMPHHMCRVV4dxCMUwbM32hgW0NSIg9KeS680RtEAnDkywlIlwUIsIGi7rgX4L6ElZhAgEGy95BjcrLt/QcrFIh+yPFVcOx07ZKFL0hdrXyTILxhhPg7EBdB+6lP/VKVOIfxJF9zoiiL7qa4jUNup2fSq1pN9ObIe4Ao48ZlErIH0R0kQyRWkbx9A== 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=3G9L/mbRTXzjXiBgvg8oD625HrvNI8EifS6jYATL6qs=; b=fMiusojq02QHxJr0Qms23ZFUTEuH/rdaIUSDrkskx1rWQTfT1EFiqTA4ssb6gnr5wD/fFvmx1EPhNdpCEMq350wxA0//hG2fpb3lFVAccFIqiX6wf5yAeBVkgVdpz5eLxhxlsLXrMlkGx1WzBaslYyAumsdZwxeu3YS9W9QqHfv1M5FEh56FtlsFl0IvzePyWtO6MnG6Js5jIhJYVjz2BkWAYT+TRPMSCbsZZw0yPPCcBpNfYfuRx1uAeSCOP34VE5Buvk3fepxyZzjQsRxk3scAwth4nifiYWnkRuTgGRhOXVeoMkUok1hCnCcEEfFdQ7BQZrvNZOHaahx5LfRgMA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3G9L/mbRTXzjXiBgvg8oD625HrvNI8EifS6jYATL6qs=; b=C+jtar6q7FDBOKyvaaz/McxXt65Axk4CGgloDQqPbFyUI2MRY9ZGDJnUL0e1+D1QKb/6Byi1DZSE9pX74jJyGT3fpfafYqU3/bKBjNyMqT0JxOtiGiKrULjt6JZ+hO5k8UttBh8Q/y3lTbd5NfU/4wpgBNaqC/tsNEs9e5+cu+o= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) by PA4PR04MB7726.eurprd04.prod.outlook.com (2603:10a6:102:ea::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.29; Sat, 4 May 2024 00:41:30 +0000 Received: from DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::d30b:44e7:e78e:662d]) by DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::d30b:44e7:e78e:662d%4]) with mapi id 15.20.7544.029; Sat, 4 May 2024 00:41:29 +0000 From: "Peng Fan (OSS)" Date: Sat, 04 May 2024 08:48:58 +0800 Subject: [PATCH 05/18] clk: imx: pll14xx: Add constraint for fvco frequency Message-Id: <20240504-imx-clk-v1-5-f7915489d58d@nxp.com> References: <20240504-imx-clk-v1-0-f7915489d58d@nxp.com> In-Reply-To: <20240504-imx-clk-v1-0-f7915489d58d@nxp.com> To: Abel Vesa , Michael Turquette , Stephen Boyd , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Jacky Bai , Ye Li , Dong Aisheng Cc: linux-clk@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Abel Vesa , Peng Fan , Shengjiu Wang , Chancel Liu X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1714783747; l=1882; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=ITpMc0XDxQEnK8rIvUINBCDmIwwvJJ8hnlCjcXFS7+o=; b=rGfviR7PwPWCE1ffyTS7CSGZZAyaa2MX3+Z/5EYDswUDqc7NyMEAczXa7jMKLts7+f3tMQP4g Vs9u3C18IJbDfIXG3mTPY5TRU46Ad4NbsPqn8Wl1hkyz+bmWlNnV2Xe X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SI1PR02CA0055.apcprd02.prod.outlook.com (2603:1096:4:1f5::16) To DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU0PR04MB9417:EE_|PA4PR04MB7726:EE_ X-MS-Office365-Filtering-Correlation-Id: 87501d15-1bf4-4500-ed93-08dc6bd2f04a X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|7416005|52116005|366007|1800799015|376005|921011|38350700005; X-Microsoft-Antispam-Message-Info: =?utf-8?q?1abXW5ypNVRWJFZgSkg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Ck7SAaKNMfLDeVUxv?= =?utf-8?q?KcbnRTpaNGaVaJODJsm0wqxkUOyvYNh+FD/hs6/TkgLAsEeTst84V1RfQstQelH72?= =?utf-8?q?q+8MUA8BfrJy8vlHzwHcKUOGz6s4+8vVpkXPgkENyEkuia/brh/hfS9c6OvZIeLV7?= =?utf-8?q?UaZP86R1rox2JbvJATynPtxQI1SJStinFDn+PNsfesvExvLboDgQZPZe9frVnU1J9?= =?utf-8?q?LTIHHuyb0xLEbLXmPVUqIDsrhgjauuqKkiH3VSZFu8wshLP9xzP45KMCvSxUznJmK?= =?utf-8?q?RB7tuPsO28eivfJNXr8+JhXNLxW9NpSbZknJq+1di3zQ/tE3D5OCOGprtj4lMxfOD?= =?utf-8?q?bPGhtBa3ObBMKbDHvyzUR+NBCUK8icbtU7CGTZ5CfpW0ColpQOFzQueTqI4UkVPI3?= =?utf-8?q?hqAMC2mLSwXhrdeU3xvPoqZUxKd5mKetB9hfjZQ3vazvgSxWV+NXZwNk=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DU0PR04MB9417.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(7416005)(52116005)(366007)(1800799015)(376005)(921011)(38350700005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?Cb6LoAxVox8bmB4HkXRKyeLzqmLy?= =?utf-8?q?z9c26Y+o2WTEY9sedEKUTWlqDWX3SbWhZyzaN3JiO587nJLIszVC39wztU2+v4Txn?= =?utf-8?q?sSmAn5gwp3xDW7ZlfOqnB+M51zVanXH1RhKFfDt7rvOh389K3AuCfxPOgv52JKk19?= =?utf-8?q?tg1VOE3pdowRCF/zOJKo1RBt8gbWcLxFS2EdbXQc/8ES1Pm+8kPI1g9eA8StUxIFd?= =?utf-8?q?PDmua0B5ok6OuHayBuzY5AEjus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UxKuT1mh1Ig0F0KAlJ+/mLUo8kwVOoWL6VfxmMB?= =?utf-8?q?z815EKNA1LAkl/isWiIHcuEhNloHVZ7yYMi6VoScmyKtH/c0Z66W7mHgH8Ok2wTbO?= =?utf-8?q?+/Vf16WKPepCtNZvJzRK9o7tTz4UM5NF5HYtzPvpqeTD3vdvoMyHxfIFMlHH4DEuQ?= =?utf-8?q?G+5R1/HK/uPVYUKf+98E3ygidxAI5PgLCeY7UhIszvit+IEzbpTmPtPk/x46WE/XH?= =?utf-8?q?sV1X9ZjuGSgpWokXGHKWroF+nX0kkC1TmyNjoKhgW4zHkCo32ErhKn8ty8OqIZg6M?= =?utf-8?q?UElqTuno3GFZjjK/p41h0Ka/FW4/CslGP11IQpMjr7uxm6vMwG1VbUKLkZjpifPTm?= =?utf-8?q?8RrMzIFde2OfWT/EWnodlhjTzt0PFYpFZ/kXZQMuiuqran/NxLMcJsc7H6gNKRNT2?= =?utf-8?q?hZjMJVcwpdMD?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 87501d15-1bf4-4500-ed93-08dc6bd2f04a X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9417.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 May 2024 00:41:29.9255 (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: hRuuFfV898wL1reGTV7VQ84Kzk3A6ODTPbEA18bVNDxl1poeBeKhNWVcEs26PtBv05KccImSDPik022ZjftuiQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR04MB7726 From: Shengjiu Wang The fvco frequency range is between 1600MHz and 3200MHz, without this constraint the fvco may out of range, the real output frequency is no accurate. Aslo correct the name for fvco and fout clock. Fixes: b09c68dc57c9 ("clk: imx: pll14xx: Support dynamic rates") Signed-off-by: Shengjiu Wang Acked-by: Jacky Bai Tested-by: Chancel Liu Signed-off-by: Peng Fan --- drivers/clk/imx/clk-pll14xx.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/clk/imx/clk-pll14xx.c b/drivers/clk/imx/clk-pll14xx.c index d63564dbb12c..55812bfb9ec2 100644 --- a/drivers/clk/imx/clk-pll14xx.c +++ b/drivers/clk/imx/clk-pll14xx.c @@ -131,7 +131,7 @@ static void imx_pll14xx_calc_settings(struct clk_pll14xx *pll, unsigned long rat { u32 pll_div_ctl0, pll_div_ctl1; int mdiv, pdiv, sdiv, kdiv; - long fout, rate_min, rate_max, dist, best = LONG_MAX; + long fvco, fout, rate_min, rate_max, dist, best = LONG_MAX; const struct imx_pll14xx_rate_table *tt; /* @@ -144,6 +144,8 @@ static void imx_pll14xx_calc_settings(struct clk_pll14xx *pll, unsigned long rat * * fvco = (m * 65536 + k) * prate / (p * 65536) * fout = (m * 65536 + k) * prate / (p * 65536) / (1 << sdiv) + * + * e) 1600MHz <= fvco <= 3200MHz */ /* First try if we can get the desired rate from one of the static entries */ @@ -193,6 +195,10 @@ static void imx_pll14xx_calc_settings(struct clk_pll14xx *pll, unsigned long rat kdiv = pll1443x_calc_kdiv(mdiv, pdiv, sdiv, rate, prate); fout = pll14xx_calc_rate(pll, mdiv, pdiv, sdiv, kdiv, prate); + fvco = fout << sdiv; + + if (fvco < 1600000000 || fvco > 3200000000) + continue; /* best match */ dist = abs((long)rate - (long)fout); if (dist < best) {