From patchwork Sun Oct 27 12:00:09 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: 13852511 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 10F43D10C1B for ; Sun, 27 Oct 2024 12:08:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:MIME-Version:Cc:To: In-Reply-To:References:Message-Id:Content-Transfer-Encoding:Content-Type: Subject:Date:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=B+kcPrphzLGA7BGzbN1UZPB/S9IXEYPjoakvnz0Egv0=; b=04KHrADVT1zgqmgieq0gjwQUE5 pQ8ValUBmKOwyACVQ4Q1MPSFBUDYklcx0fY2NAlgm2Il0rmBmc6L1RprUp6fbEgRk2w4JMqhptZkd Qh4U+ZbScJh58AMGhJZT+I8RnQTQwilzGhi/iAtYtxPzLiSfS5V0VUlcALpklvAtyugdcPvY14vjB QLTUjSQiWGTOnpslkEgYDKrgLnyGnDqNEvYmrl1UEROUWFPOA77URtGYQ0YCMJ23rsX/CuzP/YCho IJQxMVk6nNvRZx2JPhYgTMciU1UcQKUFe6X66Cf25FO8tPkJVyd5o4Bbi9rQvDQ2hNuYIe91f7TIL JtSYV1hQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t523h-00000008Bjx-2Pdd; Sun, 27 Oct 2024 12:07:49 +0000 Received: from mail-vi1eur02on2061a.outbound.protection.outlook.com ([2a01:111:f403:2607::61a] helo=EUR02-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t5226-00000008BXc-45Lx for linux-arm-kernel@lists.infradead.org; Sun, 27 Oct 2024 12:06:12 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=hCGutQkIS7sgX13CToNa41S5UBPbHjz3p83yOscqv2uyDLcFPxqFY1/VOG8NofFXovK508AUwvaIuACU7ReZoc0nNouxiRPFDVpVCOS85EINpoMB/y4mP/vYCI+UT0SqHAflHIDLOI1LdnLUyZeGV5AbEzX+oddHOJy2Xfyn/5At+47No6zLxE3feIZxU3c7c0yGTSpS+5cOb5jIi/iGLCJ0IYmSO7m6DCXU7nEPJLGeJnwzBzTYoHYRlCVGhpGLVmskaXIrQqxM/uAd9CUjzW/Q6A1cCgwkqGHncXd/3gmn3COmMUcBs7Cn3m2FuSwbqz6o7EF0hulU0NrA4m4YiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=B+kcPrphzLGA7BGzbN1UZPB/S9IXEYPjoakvnz0Egv0=; b=IXI3+6wKnBlY0hj9yy9OW0go5RrkcT0XNmGKiCFFngKyYlBtcoROdXOinwV/dqk+ytAlbCmoDQhhZrlNOL1WtyhYvMTLdB64YPAujJxiqxZ77/sdEXu5AOrEuur0UKW/inyzFxds5IsUB80Z17eWSgoiLkBrbYoV1kYA9bOQ9uzZc6uEMpLO7gmlCAV4ivlwdvViNJnTWCO84blAnX+J6zJAfnmZoiMmVuol34TtLrUzMa8ek1D9rTS31rBi6bGqzcljcZxCuWWTa32rTrYMD4KzqOIeTC2/8kx0YlZ62jJf0e2+n9azD+JzUSnBksXlshkfB6+0Bq01jkhDzQf5Bg== 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=selector1-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=B+kcPrphzLGA7BGzbN1UZPB/S9IXEYPjoakvnz0Egv0=; b=g7akjn5BIaGonBhgXjsnT4UXvvHr5yYqvUsPPny1BzL7e8LryCqfdAxtBJyQRZxWQC5ME/pF7CrEd67fAbboUv5uFTyc6M9v6QwKfP4KVBOn1P978dhM7SYBmif34GqwgzlyQug8+YscLEH8VqDWIpYqCbgdwjwl9fx4qRgF1lOOWG+2Rk1vZ+e5kt3JTG41vTZxjvm8mfgbhy61U5PbXrAtHzUaznTeEDt+Ns7mBzHK4mcttMFVHBmodF0p+Z1+LQ7TA6X9FBnOMd9hlBlkAOjQrJZzUn8xyz63hYjvZtWP1G2qLeQKTAPgUwVIjQt7WYJ0yFiZsf4mm98PXgaUXQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from DB9PR04MB8461.eurprd04.prod.outlook.com (2603:10a6:10:2cf::20) by AS8PR04MB8689.eurprd04.prod.outlook.com (2603:10a6:20b:428::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.24; Sun, 27 Oct 2024 11:50:11 +0000 Received: from DB9PR04MB8461.eurprd04.prod.outlook.com ([fe80::b1b9:faa9:901b:c197]) by DB9PR04MB8461.eurprd04.prod.outlook.com ([fe80::b1b9:faa9:901b:c197%5]) with mapi id 15.20.8069.016; Sun, 27 Oct 2024 11:50:11 +0000 From: "Peng Fan (OSS)" Date: Sun, 27 Oct 2024 20:00:09 +0800 Subject: [PATCH v3 3/5] clk: imx: fracn-gppll: fix pll power up Message-Id: <20241027-imx-clk-v1-v3-3-89152574d1d7@nxp.com> References: <20241027-imx-clk-v1-v3-0-89152574d1d7@nxp.com> In-Reply-To: <20241027-imx-clk-v1-v3-0-89152574d1d7@nxp.com> To: Abel Vesa , Michael Turquette , Stephen Boyd , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Aisheng Dong 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 , Jacky Bai X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1730030419; l=3036; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=84M7E9SFxBK3SAqAyey+G62IZbKKHtL8RhiilZogEI0=; b=1dp4lIBmYsrpsEeHK/aDU9oJ0s/10g4Ap6rgDp309cycMXdhfpczYI2Qo9LNwe/TMNS53+dZV THPz6oe0exlBhtyz1KVCFihhhDnLgOeF7Q1BRNtePTL94Cv/6eEyRhI X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SG2P153CA0011.APCP153.PROD.OUTLOOK.COM (2603:1096::21) To DB9PR04MB8461.eurprd04.prod.outlook.com (2603:10a6:10:2cf::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB9PR04MB8461:EE_|AS8PR04MB8689:EE_ X-MS-Office365-Filtering-Correlation-Id: 4feeefce-3023-4681-d159-08dcf67d831a X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|7416014|1800799024|366016|376014|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?B2XFNGDFC/ZeZ32lDt6i/gzBBAe6YsG?= =?utf-8?q?tI00Uf5xh0+AW7XPWj2N7CejovlyOOSKF4ZYeQCi6mhUYZhi+BT2RQiUpHZ+m0rZy?= =?utf-8?q?cM1bYOAbEwdiUkLipUZwejFyCH6bvBk+gZ5LyQ81y6FJ5vzXx0pgCqabc2zYV5M9O?= =?utf-8?q?BKQwxJvwUNBoynDOUfhiwoodpKxQpV0tc5fH3y3AGAf/Cj5KdcsThMxEtmNMydQW/?= =?utf-8?q?N5m6iJ/CrreY7eIBGGNNCA0j10JShqqPstc6Rl4DOBQ82HpFuHPgdhixIgYs2MhWw?= =?utf-8?q?lUjlDneRGCnJLdCWSSItxzG3U3eaNhMwdXtRANMeq4Nj8Me7dC4MPyh+TKiLiEvvl?= =?utf-8?q?5+e+fnYUsrxznUqBNuCG9dWWx5E4DioOn6BqxE20ZBqJJWiLqKILINImfP8VTHNBC?= =?utf-8?q?6dzS+SenqdePADbQ2MA9qagCfnmbQRwoHBpc6Ft/4kCU5EOynLrP+fJHX5wRZz87f?= =?utf-8?q?mHNjd+u/Uv01+mAy78yXCyXPv0hcGrSWpUMH7qyqzdZ9OXSSN5Pe5RDzzXFX9Nl25?= =?utf-8?q?C5aLL/Nhhh3tjo6olmK/gzL+ygA7fbb4FfkmL5+oV6tHSYI9wY792KxfI867lgClq?= =?utf-8?q?caxctMKnGEA7hWAJ/Xt1oz03HUE61DkagIWC10SzSxKop7/hczqTuNRM8oKPYfbHj?= =?utf-8?q?HdxyfJDuEtt8LxWpKkliNFct2sL7to6WOR1O14hLsSQe1Rpf4BrE+GSSf66k+RVuK?= =?utf-8?q?F/Va5L/ojAmQ3VWwfmJW5C4Z+abaQ3WklewaVYyJAQgHnKixWPt5yVaLpjN9GmfaZ?= =?utf-8?q?9LJ+P/upVUVJW58CEjXIXMPcDP6rVvhItQIbDkB2xmxRqrR7JnFEsZDDs2kS8/ny/?= =?utf-8?q?6HrIWpY2FpTOJ6raDiewd1gWQfOxOVJEXiQPd+b3GCSCysPTp7NshKGOpC9vjAke/?= =?utf-8?q?C8H6zqjVk9hZicX8qmsNmnk/WoR0K2ZhGHIWfv2qnBhboumdajAV5vnJvJ/T22iXN?= =?utf-8?q?dqVElsbMDnP8kc0cTRUjEge1HHAAWnnTEYkJLQffq2cDknvbQnGOoXclRgmhZwXJE?= =?utf-8?q?jSLAxRl1QuFtD+5qdeLKYVTXkCwpPluoZphPqglhGJwJpY/Uv0LhQ9zUmyqQ8ve1d?= =?utf-8?q?Z5VlnZRooPd4AORUBz+nUel7ODzzI2p87DMCBr7ZRhlHlpH9nh5WHdvy2k0oODLc0?= =?utf-8?q?oHML8c9thj5q4ln9vIied/8RnyDFsfcgy6gjDe7WjMzg8v8o1/nYk1OIF4rij+Dvh?= =?utf-8?q?nPXqmDY0/9by+ACbAJ2S4oUHHG/fkhxU6bSoFKlA/AWNR9qYkWMLPDXItpilG3VqS?= =?utf-8?q?vxPpLe2V7lv5b6c+PfNyb/V/AYOcDyOrxvvU/7GLufJsXzra+ovauz0A=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB9PR04MB8461.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(52116014)(7416014)(1800799024)(366016)(376014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?YiAmYmAG4u/1JCXmY9mnJmhF7cdH?= =?utf-8?q?roJYQ/YRb0eUJEXni1T8CQCcRXBkGV4fYOZVuMvTI477Jr52nXF15Zhu1YXVuah3Y?= =?utf-8?q?0gq4623I07QvbLS7KzmsM5oBnTASLCnwlm8Tyye+rl1DIkV8de3fzMkGwFhn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= =?utf-8?q?NCjo9baOURXC5P+5AHCasKK0xnqDikiEyZS0P7CzF1xKseCmhmi0gD9lAm6O6VUDL?= =?utf-8?q?oqgDnhfwDYJiHDpJVhMxTvKp4GL70qoaEA42AZU1hx16qbJfFkM3eb7kRErK/Z3EK?= =?utf-8?q?c03eHtN0w6Rib63WZkwoYPVYPwZIJvnrovNrA5dhNOP7px0q4fvzf35NiIjB/itX7?= =?utf-8?q?t70vlSQjDIB+hCUN9FIDFjjHLO5gt+cN2MNUB6fyzPUxbD1R3Vwlmwg7VwP51rPyX?= =?utf-8?q?G223HzMM5SnyaGIDO9wHouq4WejrxsV09Ij6VQ2RyjwdcUudjwGaKe05un/nbEnUd?= =?utf-8?q?Ez5FrRqhBKKWZn8olrr1tOoADtF4XkgW2rvR4h6cObLfdvRfweQcA8LHsas9NMTNc?= =?utf-8?q?8pXziS8GuB0vk3liMngeNYSYQlRbmjWYkyhzWPGJW9HZA1nHfxy7G4cAUCwG2pcpR?= =?utf-8?q?3zV0kk1aFXdVjU70/1psnoVksYskHABrMRfreh9BKm3GnTXB4vkgMEFB1ktK/7HoC?= =?utf-8?q?26jrjeHoaEZL?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4feeefce-3023-4681-d159-08dcf67d831a X-MS-Exchange-CrossTenant-AuthSource: DB9PR04MB8461.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Oct 2024 11:50:11.1615 (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: G2ru4uWvSfJqeZ9D5TFrtqKkBAa+Cf/qeaA5+z9OXvmlodrQlt7p+j0mS5L/6lq006hG2H4pbqwT7r/UXgHW3Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8689 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241027_050611_023712_158E1CC8 X-CRM114-Status: GOOD ( 15.99 ) 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 From: Peng Fan To i.MX93 which features dual Cortex-A55 cores and DSU, when using writel_relaxed to write value to PLL registers, the value might be buffered. To make sure the value has been written into the hardware, using readl to read back the register could achieve the goal. current PLL power up flow can be simplified as below: 1. writel_relaxed to set the PLL POWERUP bit; 2. readl_poll_timeout to check the PLL lock bit: a). timeout = ktime_add_us(ktime_get(), timeout_us); b). readl the pll the lock reg; c). check if the pll lock bit ready d). check if timeout But in some corner cases, both the write in step 1 and read in step 2 will be blocked by other bus transaction in the SoC for a long time, saying the value into real hardware is just before step b). That means the timeout counting has begins for quite sometime since step a), but value still not written into real hardware until bus released just at a point before step b). Then there maybe chances that the pll lock bit is not ready when readl done but the timeout happens. readl_poll_timeout will err return due to timeout. To avoid such unexpected failure, read back the reg to make sure the write has been done in HW reg. So use readl after writel_relaxed to fix the issue. Since we are here, to avoid udelay to run before writel_relaxed, use readl before udelay. Fixes: 1b26cb8a77a4 ("clk: imx: support fracn gppll") Co-developed-by: Jacky Bai Signed-off-by: Jacky Bai Signed-off-by: Peng Fan Reviewed-by: Abel Vesa --- drivers/clk/imx/clk-fracn-gppll.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/clk/imx/clk-fracn-gppll.c b/drivers/clk/imx/clk-fracn-gppll.c index 4749c3e0b7051cf53876664808aa28742f6861f7..85771afd4698ae6a0d8a7e82193301e187049255 100644 --- a/drivers/clk/imx/clk-fracn-gppll.c +++ b/drivers/clk/imx/clk-fracn-gppll.c @@ -254,9 +254,11 @@ static int clk_fracn_gppll_set_rate(struct clk_hw *hw, unsigned long drate, pll_div = FIELD_PREP(PLL_RDIV_MASK, rate->rdiv) | rate->odiv | FIELD_PREP(PLL_MFI_MASK, rate->mfi); writel_relaxed(pll_div, pll->base + PLL_DIV); + readl(pll->base + PLL_DIV); if (pll->flags & CLK_FRACN_GPPLL_FRACN) { writel_relaxed(rate->mfd, pll->base + PLL_DENOMINATOR); writel_relaxed(FIELD_PREP(PLL_MFN_MASK, rate->mfn), pll->base + PLL_NUMERATOR); + readl(pll->base + PLL_NUMERATOR); } /* Wait for 5us according to fracn mode pll doc */ @@ -265,6 +267,7 @@ static int clk_fracn_gppll_set_rate(struct clk_hw *hw, unsigned long drate, /* Enable Powerup */ tmp |= POWERUP_MASK; writel_relaxed(tmp, pll->base + PLL_CTRL); + readl(pll->base + PLL_CTRL); /* Wait Lock */ ret = clk_fracn_gppll_wait_lock(pll); @@ -302,6 +305,7 @@ static int clk_fracn_gppll_prepare(struct clk_hw *hw) val |= POWERUP_MASK; writel_relaxed(val, pll->base + PLL_CTRL); + readl(pll->base + PLL_CTRL); ret = clk_fracn_gppll_wait_lock(pll); if (ret)