From patchwork Mon Jul 29 02:30:53 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: 13744191 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2087.outbound.protection.outlook.com [40.107.21.87]) (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 E10D77A15A; Mon, 29 Jul 2024 02:22:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.21.87 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722219727; cv=fail; b=Kx5DGCxLNXcpgTAAbzkQ7Q292Kj7lqupPrPhspvqLiMfdjHFqbEvMWONIXCr7EkrJLz/n6I/CY6JhoAJGRcEWj/PULtT+kEtPfolK+Zpjdj4SQmt+uU1DiN2UD+1xhf9hkQI0Z0bEmKtEj9hq0xIyNf7jLtWfcojrapnBIixylU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722219727; c=relaxed/simple; bh=Fa969aBC9+UYuRQ629gtOlqO5zXOE83b8T81dJ5UB7k=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=Ko2umpxHUgrJt+/PSvXUiS/HiTUNQ62EC7pvgoSfAk5C2UhTHdlDBHxY5LTYGHg1+rAVgTV2eZvomYmliqySdEpBFw1r6UJZDK3DZvjJlDFYEKTLGLSkYHik1UDtakfJYvHjrb2dR5kUAwwlpSPjrxCiaaPqYDdOaODe74Mg9Ms= 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 (2048-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b=ML7Wh8ak; arc=fail smtp.client-ip=40.107.21.87 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 (2048-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="ML7Wh8ak" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=llbw5H7+qLoB+7ZNpSdWyOcXPQz1cY3YdV6WsOvI0keY2AXi19Aw2K/EeC201PwtCy7b0oEzNN+norlrDZv0yr19zc1gq74wozJj6B4pBe4w6NA1g3BrnLUaLx2XSEI4AM9j+WRTEG7rZESh73Fd9r10QZBaS0RtarUy44lGUrrURe6jAgr+8nLjl5qdTqUiRpfyrJDWAtHo/ymZOajhkVZVOAGZy+dK6VSksoyORDnvUpwBeZwss/sT4b2YXZmOLeBoRZ5LQ9TLLEVHxtgLRI+m6rwKWFzc/vdMutxVN3qvyEZwKXX2GxrKraeHyfVkxTcoSson1zMGuTDOiYVzrw== 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=PbAkF85iaFHvFTLjOWB5s5r8w1kYs2rFztU495YBbr0=; b=BQgC13EEbAldOzk/6BG2WOY9hoyReWX4WBdR7DWxr3GLV9yTuu6Hv8cSu54Kr1Ue3U/pqUz/SuxXXFViY/MrPol1gvsN9VxepOEb9ExXvw0XZNhhP0lBC+a+oORtLEX8HK7Qnd5a5yAsJmu5Y46YrJ1LkKQHai9bFGo1TooD03ugFl16beq/poNYptujlFNAqQvTH/gbf4avHBpL9Jl3hA0Xd5PB1Ils/GDqalXdxoMzkgXJRvSG4oA+6Tbkv65tioU8k7kDjtdROo1hOLtS9kSSow+ckFlwZQbNt9NOqRKNvfAB86d1i64gY0mDbe+S1XDmdlI18emfqS+1Cnthhg== 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=PbAkF85iaFHvFTLjOWB5s5r8w1kYs2rFztU495YBbr0=; b=ML7Wh8akQB4tGmoVx6D7Y6a5MtvRfwFX/RNBqAm3bY6rcoDXXnkJgf78nVK4qZWwUUe0l5VJ+dVtxIqddXi55kamIKbe5ZoEIX3C2k2yK9/rzm1An9jfJuvqZNPCfOxn0VBcIPg19Hm1ix7hYa4S156Y+b7rTy3xY3QRKfgmMjx2T6x0TmAc/yYnXN7hvRQBRn9HSlqpJuja6OWMcZ6s2xgpjoCfy6s2dZrJwk95mmzFctiHh6qjxQGX/jt2AIkXlSb8AKtIcrlZNDVFSycgwV/U6I5LompfHWv3LXMeVRM+OzrFwGpJcTuh6Tw2KkHttbMWDQkd8CfVIMZT/C1uqw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from PAXPR04MB8459.eurprd04.prod.outlook.com (2603:10a6:102:1da::15) by DBAPR04MB7368.eurprd04.prod.outlook.com (2603:10a6:10:1ad::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7807.27; Mon, 29 Jul 2024 02:22:02 +0000 Received: from PAXPR04MB8459.eurprd04.prod.outlook.com ([fe80::165a:30a2:5835:9630]) by PAXPR04MB8459.eurprd04.prod.outlook.com ([fe80::165a:30a2:5835:9630%4]) with mapi id 15.20.7784.020; Mon, 29 Jul 2024 02:22:02 +0000 From: "Peng Fan (OSS)" Date: Mon, 29 Jul 2024 10:30:53 +0800 Subject: [PATCH v2 2/2] clk: clk-conf: support assigned-clock-rates-u64 Message-Id: <20240729-clk-u64-v2-2-ffa62ee437e6@nxp.com> References: <20240729-clk-u64-v2-0-ffa62ee437e6@nxp.com> In-Reply-To: <20240729-clk-u64-v2-0-ffa62ee437e6@nxp.com> To: Rob Herring , Saravana Kannan , Michael Turquette , Stephen Boyd , Luca Ceresoli Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, Peng Fan X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1722220263; l=3649; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=K25e/IwCaHk/VnfjjVO7hUUmnIl5zCnqg1J7sgDRSfI=; b=94BPFdDFZ3u2K7BYWoMG/KL+zR/aaEwwqLDU95lJ20oO9PXtUMF8EMBoZHDLiP1dpIzh5YQc3 ZSWeL13eA71Ci+5d0Jcs4twizC0ant0mn+zIXyLY1gdloCklqsT50+K X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SG2PR02CA0001.apcprd02.prod.outlook.com (2603:1096:3:17::13) To PAXPR04MB8459.eurprd04.prod.outlook.com (2603:10a6:102:1da::15) Precedence: bulk X-Mailing-List: linux-clk@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8459:EE_|DBAPR04MB7368:EE_ X-MS-Office365-Filtering-Correlation-Id: 5187f2b9-81fb-48f6-c8c1-08dcaf753b66 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|366016|1800799024|52116014|376014|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?b3CmkZHNRoWZGiPHH5C3+58khzvF3It?= =?utf-8?q?USGhbgN8b7QgDZGy806CCen9LtOjE3D0vANYi6fcS+RDtIvM1Wekxjr1Wj4yRZnif?= =?utf-8?q?H/k0pMW0GVYjoodGq0S+IMUGatl3kyzswpZQ0nsv+CsVfWia6ELox9yNc2DNPkMUc?= =?utf-8?q?T+9ReYVh0O57sQBp6SMYMv0bc7CKjOGMo4TyXmFEp0WpQ/kPizWNlr+U9eSkk0z9/?= =?utf-8?q?80yOsRXs+9KvHk9WMaILLfLI1yhGQ7POZAnKBin5iCxu5KIQ3lMHaH4XP1CyFvm/S?= =?utf-8?q?QpaMzb4cXPE9C/jNJmNWJE6KQXZnXTyY3G+Cec526FJQJ0xRogDzOmW1cw8fNNxOC?= =?utf-8?q?lVkQ9mOZcj8h5ZD4XZZ6kefnwy6Mxwrb4uIvnOL9wiWYvbjLHRVhOODU7CMYAgpxg?= =?utf-8?q?hP1cXGWEE5hTQS6/dl5GQsXFQh42NUixymp00eOyWtVjv9jSxQOfsCOHTx9Pnk55s?= =?utf-8?q?8+145Gz+P3ZM1WuBnPmuO/tbmSrXXV/vTNRqKrvB2TxO1e0jMSgcBXHgGLla8QKN/?= =?utf-8?q?TFLSEQ4GezugCOKUpV3MC9C43K4RQN8CAdTgyh7Y6OODrtrPA7LMpXDnvBzVXfTWV?= =?utf-8?q?Y1j8EXRY3aXhkolgIpE/SgL/OhhrF/QYtQxgWjvbc12oj2C5zKmRSoKH9PqIH9Ptk?= =?utf-8?q?WX7wixCOJxcJW47U4lj5eDlcEL1NFrzCfrWnGd+Y42oIYHBdq8fpp9IybXy8QAQfP?= =?utf-8?q?ULcx5gOT/BhBcMjxjYwjkcy3TQDcBPNe5DcaOAPaUgZRRqSRF7drkd6liiKQS2ijN?= =?utf-8?q?KK0e+A+UOLsp26/yku3WgGDduDQQImfPRLwigNFjOzbjgpHT646+LB912omP3OPxk?= =?utf-8?q?irzb7R9KEUGuTlkMDK75B4vqkMD15PdPhhFMXv0RNcC1D/9VuWUZlTTCS6skV1YCC?= =?utf-8?q?aXxwD6nNX8irtCBY/WX2H9od3UkYbXOedSAoeMu0cBv0D/EvhBRkSMAy6JKEBgUr2?= =?utf-8?q?lr4rqaljP5aw3PGY+gHUwigDDAkXxzdLnUcTS3C8NKOQNaEgyyI1Yft+4U6z63Li0?= =?utf-8?q?r8HfnB7/j+m0/FGezdPC+wGvgsvJiNx/YC7A7j7n58PrC10qhd+LuYLLI85csfQuw?= =?utf-8?q?g9G/5TQe0zIBwSTVZwItEK/G0/+TdT8KvWMSUEekm+1r7wWzcESzpL6rOzR3OeMhG?= =?utf-8?q?bj4ULf5hDJ+fU1WpkFcsBmRqpsX2H/lgUmCKdqGdTv5D4u50RnqIJGUH8rRlGPnDY?= =?utf-8?q?tc6HwgS6P/DA/YeMgw6tsqJvxQzBn0Y7z7Iq0XVVaYnFkywIiL9Qjrz/UT3lmHfrc?= =?utf-8?q?r6wObbp/Czcp4DIm9MzcHcG3oQCLyoYa9JAZIwE2sDBdSUiJbXC4hOiVaqfekIEuE?= =?utf-8?q?u0tzRE1G69FcGRyYA/qlQdLu+dmlYBU+PQ=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB8459.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(52116014)(376014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?GuT/Q6ORH+kDhP6K/oG5BYzwEh7r?= =?utf-8?q?Y9lC/23N3gf+8C9ePjwJZMjZC4WJKToJuV64W4U9WsIBHGmJ2y0Dnw+hVAaGZdRdV?= =?utf-8?q?R7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N8KpwvZyTeDx6Y2uJK+P/pIpVDgQiueLgGybAvXNeal4l3D6CTb3v?= =?utf-8?q?XsCnXapCP32xWytKnReo7DJl3+SY9e8PjyYzotBbMqdUE6ZO/yCtqadFCNwkekYSE?= =?utf-8?q?CGoamkdRdBR2wudTvzkYBYmPKuzS4/ZQJx2zEEEwxG4D+QgeTlPGxNZfnCAmF3rTD?= =?utf-8?q?hx4AChdPkz3Ps7N/nX/0yiyOAc+UYWTIpqkxbfGox13oTAdiQhft5Kh9pISFc9KgX?= =?utf-8?q?gL0zguLWToDSJrzaS2zUGf25Hpr6ZOi/Uq60t7lrQ+qpWk6aKjefWooHKQX0zENep?= =?utf-8?q?ahyHBvFQLp2rIhOu7Wy4xacipUJQalAoeu1tVhwZcvnzV7vSjNH087I/v0vAkEZ0L?= =?utf-8?q?gSDZDg5w5XF423T/NQkRtirk3sQsGIVFnFbcUDTBrbhp2cDTyqZzSZtKl5GxnJFHv?= =?utf-8?q?VZH7h15X8fbVdZnLUrt/HLPDcc1ferLAM/Z6pwpVUzhPDS+fOnJQWHCgerDuR6jIk?= =?utf-8?q?t0x1uDl/nQt0y4wNbE4I1XKWCN9ltfbfwP9DbWeZosiq4GOghrcnZdrtEMslNvI/v?= =?utf-8?q?E76PNFjwO7cv?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5187f2b9-81fb-48f6-c8c1-08dcaf753b66 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8459.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jul 2024 02:22:02.3138 (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: jSXp1aJgniPWNjhSvbNFX0XMQm9CDyObORJs4Q6qoE7GuMNyGxjqg8neX4vxszNRzFYWcUs8owYT4EIenXHpUg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR04MB7368 From: Peng Fan i.MX95 System Management Control Firmware(SCMI) manages the clock function, it exposes PLL VCO which could support up to 5GHz rate that exceeds UINT32_MAX. So add assigned-clock-rates-u64 support to set rate that exceeds UINT32_MAX. Signed-off-by: Peng Fan --- drivers/clk/clk-conf.c | 104 ++++++++++++++++++++++++++++++++++--------------- 1 file changed, 73 insertions(+), 31 deletions(-) diff --git a/drivers/clk/clk-conf.c b/drivers/clk/clk-conf.c index 058420562020..37b72600b296 100644 --- a/drivers/clk/clk-conf.c +++ b/drivers/clk/clk-conf.c @@ -78,47 +78,89 @@ static int __set_clk_parents(struct device_node *node, bool clk_supplier) return rc; } -static int __set_clk_rates(struct device_node *node, bool clk_supplier) +static int __set_clk_rate(struct device_node *node, bool clk_supplier, int index, + unsigned long rate) { struct of_phandle_args clkspec; - int rc, index = 0; struct clk *clk; - u32 rate; + int rc; - of_property_for_each_u32(node, "assigned-clock-rates", rate) { - if (rate) { - rc = of_parse_phandle_with_args(node, "assigned-clocks", + rc = of_parse_phandle_with_args(node, "assigned-clocks", "#clock-cells", index, &clkspec); - if (rc < 0) { - /* skip empty (null) phandles */ - if (rc == -ENOENT) - continue; - else - return rc; - } - if (clkspec.np == node && !clk_supplier) { - of_node_put(clkspec.np); - return 0; - } + if (rc < 0) + return rc; - clk = of_clk_get_from_provider(&clkspec); - of_node_put(clkspec.np); - if (IS_ERR(clk)) { - if (PTR_ERR(clk) != -EPROBE_DEFER) - pr_warn("clk: couldn't get clock %d for %pOF\n", - index, node); - return PTR_ERR(clk); + if (clkspec.np == node && !clk_supplier) { + of_node_put(clkspec.np); + return 1; + } + + clk = of_clk_get_from_provider(&clkspec); + of_node_put(clkspec.np); + if (IS_ERR(clk)) { + if (PTR_ERR(clk) != -EPROBE_DEFER) + pr_warn("clk: couldn't get clock %d for %pOF\n", + index, node); + return PTR_ERR(clk); + } + + rc = clk_set_rate(clk, rate); + if (rc < 0) + pr_err("clk: couldn't set %s clk rate to %lu (%d), current rate: %lu\n", + __clk_get_name(clk), rate, rc, clk_get_rate(clk)); + clk_put(clk); + + return 0; +} + +static int __set_clk_rates(struct device_node *node, bool clk_supplier) +{ + int rc, index = 0; + u64 rate; + u32 rate_32; + bool is_rate_32 = false; + + if (!of_find_property(node, "assigned-clock-rates-u64", NULL)) + is_rate_32 = true; + + if (is_rate_32) { + of_property_for_each_u32(node, "assigned-clock-rates", rate_32) { + if (rate_32) { + rc = __set_clk_rate(node, clk_supplier, index, rate_32); + + if (rc == 1 && !clk_supplier) + return 0; + + if (rc < 0) { + /* skip empty (null) phandles */ + if (rc == -ENOENT) + continue; + else + return rc; + } } + index++; + } + } else { + of_property_for_each_u64(node, "assigned-clock-rates-u64", rate) { + if (rate) { + rc = __set_clk_rate(node, clk_supplier, index, rate); - rc = clk_set_rate(clk, rate); - if (rc < 0) - pr_err("clk: couldn't set %s clk rate to %u (%d), current rate: %lu\n", - __clk_get_name(clk), rate, rc, - clk_get_rate(clk)); - clk_put(clk); + if (rc == 1 && !clk_supplier) + return 0; + + if (rc < 0) { + /* skip empty (null) phandles */ + if (rc == -ENOENT) + continue; + else + return rc; + } + } + index++; } - index++; } + return 0; }