From patchwork Sun Aug 4 12:32:56 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: 13752619 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2043.outbound.protection.outlook.com [40.107.22.43]) (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 308CA3A8C0; Sun, 4 Aug 2024 12:24:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.22.43 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722774251; cv=fail; b=PnFHa/TWNFduldF9k+sUay3hdUsuyyOBgbw710HoJx1ZsYYYSdS/PoNw+yXZQuOOqi2kCUiMa9FSVtWc52KP5pPruVZLSNw8DPxqbVc7VeLuIgeQ74UeCHNKBKcwBDCZJLo2LL/XCpfatxdPPchTtsSm7QXrHkMZdld7WLDJL1Y= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722774251; c=relaxed/simple; bh=5exL70/tt30kfB6mb7RZ8VICYJtENbMxLVAUET0ul1w=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=pcsRvzME+lVxHXSh0hsguRFihA7fHxD+GZILyw9Yh1VzB0nbC0EHcdiaA03j1ASV6lH30b/obWs7doNTFkXa1aM7IGhSFkF9B2G0xi3a6JhpsjIuESKdrCuqhJdN8711Q5urFVeamVGKJmmSfufglxGBIdoWOQob9MO2wuWglVA= 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=Iec7IqmI; arc=fail smtp.client-ip=40.107.22.43 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="Iec7IqmI" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=a1SfQ5oJdmGAeMAcOYC5fM1ueRE3thsfwNMIIfRqp/frcfQYGgJmEdFQdYWu3yOIqGpl3pdng/VgitKs+wrSn8j5M+BfAj3fkviojyuXVTdQd1vtfhghIFKWoU3pL1w7Pzhuus+AZGNzoPK2tnmexvxDkfSkrGQnJzxwygPy6XGIQQTdG5QHODdKZ0qZdWcx9MkaY4qP9t9fj0P3drPZS8HqrmjyoiULFi6fIvlrLtMMg1lTegGptii+r8XQxz2nE8dc9yS9TPGxLnZjx+RRBbmslkRJTi3Ll256FLCBJ2lX+eWnUOqQYtbHmSK5omaEJ+XF6yYuY9/X6EAx6qCEiQ== 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=bzFf2gUbL6hQAqWlaxlv6WSxMOsq3cWITirJyGx/LUM=; b=VDbXDfNle3Htuu9ovw+u9sAE8FYQqZXWNAOoUu03Sfadsi4XFo9gy6knCv7Y1ICzUrXQbolJemMxdKgTwYaFaM6K6uwKJZpHvX8ws4FBlBXUXe9ihxJCo9NZ0O4Ufot30Nq+rGnPFhhqsSUhUb/O9zc3JfEje4oA+e+Q8qC9sZt0foGi093gSTVyuGTVt2/naFRFjy7Yuo2v35AJiSp7hSb0NnMW1dRalgQn64IK7cfRvXCHV2/I4MksAORCHOSvZ/HYB/uhs65m64ICjc9MRE2pJNvCvPuxO1//diQvEwJODYGJT2P6bijY1PuGgYvPZ97I0DlhAznVtbLyf92+5A== 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=bzFf2gUbL6hQAqWlaxlv6WSxMOsq3cWITirJyGx/LUM=; b=Iec7IqmInshXlvrGwTj6uppXB0rKBvbWP68nI6PpVVQmxUA8yC+q7wdA3ZX4floZvOdCCoVM1gzC657r+9nXnMDMJLnQHaU8qxFwQeF47lOztDD+qx6FBy/Gpg4SwESZYdlIK8VYNd0BeJikEHnreaJTltoUI6oXfG6T0Twm/Hu3EOBdPfDu4kb5USPUOv7WzaM32jZ/rdnaABqDQH473iibw9Piku+OcdyLHklKxGd2zUnMepo7zl0tmCHT6IFl1iaX92pPQWmC55zIloJtyDziTzxzKt3Ns+44K76wAtXrrLQ6r8ENPSRBSTqu0XlIVW6NhBJulWqG76w5P9nU2Q== 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 DBAPR04MB7413.eurprd04.prod.outlook.com (2603:10a6:10:1a6::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.25; Sun, 4 Aug 2024 12:24:05 +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; Sun, 4 Aug 2024 12:24:05 +0000 From: "Peng Fan (OSS)" Date: Sun, 04 Aug 2024 20:32:56 +0800 Subject: [PATCH v4 2/2] clk: clk-conf: support assigned-clock-rates-u64 Message-Id: <20240804-clk-u64-v4-2-8e55569f39a4@nxp.com> References: <20240804-clk-u64-v4-0-8e55569f39a4@nxp.com> In-Reply-To: <20240804-clk-u64-v4-0-8e55569f39a4@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.14.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1722774785; l=2430; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=7TVlq1qnZb1qUyp9XqfulwMtIztiW668BVycfgkxiRE=; b=VV2hfupZcsiddnFcgCrzrancGaCyalRkERTYwf60cn2iUpE205o9ngWwz8hovZe5cmKcnZ0M7 YT0GVHYKyUXAViZAQsSZRnhCwR0q+7lwu1oU26/FpOpqlh5uLCZJOqI X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SI2PR01CA0047.apcprd01.prod.exchangelabs.com (2603:1096:4:193::10) 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_|DBAPR04MB7413:EE_ X-MS-Office365-Filtering-Correlation-Id: 18c2044b-d512-4128-13ff-08dcb48054fd 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|366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fxxx/dSvC84Ja?= =?utf-8?q?BKi6S5zx1blAC3rs31Ql2D/acQqcfk1U1jvtntpxscMx+6rAhiWlJWx6xkIa8hxR1?= =?utf-8?q?KH/gORSKXjSwqMgZpqfuVEYd81CHRZ6JN2llWXxd66irvZp1B4L4pUSBq6bAFPtCq?= =?utf-8?q?QJSCyLT3CWhQPU62xDHK7WAd69Zg8jstzpPHLvmee8fMpnnL3uxefIZSnqAxMMFNP?= =?utf-8?q?z/T1Bf24uwLSeiE6h8JAjmegDmYG1Te1A1zlO9ZYv69m/HCTIX+zc+f5ba/psTFbZ?= =?utf-8?q?ckEUqfKziJeaX8vrU3nF94jAmjA8ZHTOcLZtk7E00fJfAoEU4UCGr4+jl5n7Eiu4Y?= =?utf-8?q?d09EHuK0k7uFHrOkH2pFF417ASkxa2KcH+5rpNGX1Nts+BSFGKA2BwQfX3oSTRO2z?= =?utf-8?q?I/krPsWV95U2CBv2gJ7SzwMDZ2p93DO8B5jQ93W2G0wKq1Ws5wSDP67J1HfbKooC3?= =?utf-8?q?t1B2n00ETSBCtcdyfiOCUWfPNEc/52lZgjFnbqRiaakKaV2vdsDnnSAQBQrj2s1Yb?= =?utf-8?q?cdM3D5OoKsrPl49nlrxK3RXJRs2x6jUUYg=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)(52116014)(376014)(1800799024)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?9pbqr8dt1yfP3OgQsNZ/1z7kOs4d?= =?utf-8?q?qzA9WzKY4xLMfpfW82EUGd5t7Cmnn3lg+7C3ioq+Bp8HFcZ6mYDvwIZ583HbOoKEK?= =?utf-8?q?5nIolJDAMmxFngaNMbp0xamQaLf6XWnmFKx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42c+TrRmzISQTd8AcXnD2gW?= =?utf-8?q?tJsaewCIDYAxO6QzXSy3eW5Go/vkAoTAWav5jg3d2UOEdKiOQ+Yzl4K5HXHwnX0//?= =?utf-8?q?4EwCKy9MZv+KCh2f9lJMq1+YpYnBdfY/AcqHYSxd3+mzgOcTS8HA2y/SWY2h2YgkP?= =?utf-8?q?LhNymhvE7wpsY+ck95oO6P1zQ9s8jUwZhQjQLmj8E76YoM3+z55lwgwVypM7uczfK?= =?utf-8?q?WE+FimDiaAGcNLCeLftsbDcDssRGbJd+5X2wk08zt8RTTyN1kesooJ5wheKs7jBs3?= =?utf-8?q?8is1tiMbc/SXKiD3a8c7DG2i1hQGbP+kweVgcOVzDT3jewNo7e6MwmOyBZg4wQHIc?= =?utf-8?q?Ba2kfqYr8dFrPyRvCMYGecANE5zMB4btM0UVKeAVRHKWuXtAuH2Zvcjma9r/NU0qC?= =?utf-8?q?amGLjqHyv3pLYHr8njv4k7AhZbsm3nMgs8g9BV95a+eGwJeWD3IRY2NrDg732o0wO?= =?utf-8?q?9IOIic4FC0hfe4KPs6mrAHOC+QVCIWbfIFn5kRQB0VyN+YzkqQv6wlC4uRmnqDbe4?= =?utf-8?q?Yh0cH+itOm6d?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 18c2044b-d512-4128-13ff-08dcb48054fd X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8459.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Aug 2024 12:24:05.5233 (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: j22dPgNLCjrV29CDScZRnBA41IRx2vTpiPRWdAAPu133MYCIV1YJazOZquiszLX8yjO7dkMVMoMEgRj7ODVqeA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR04MB7413 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 | 42 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 37 insertions(+), 5 deletions(-) diff --git a/drivers/clk/clk-conf.c b/drivers/clk/clk-conf.c index 058420562020..51f994366d73 100644 --- a/drivers/clk/clk-conf.c +++ b/drivers/clk/clk-conf.c @@ -81,11 +81,44 @@ static int __set_clk_parents(struct device_node *node, bool clk_supplier) static int __set_clk_rates(struct device_node *node, bool clk_supplier) { struct of_phandle_args clkspec; - int rc, index = 0; + int rc, count, count_64, index; struct clk *clk; - u32 rate; + u64 *rates_64 __free(kfree) = NULL; + u32 *rates __free(kfree) = NULL; + + count = of_property_count_u32_elems(node, "assigned-clock-rates"); + count_64 = of_property_count_u64_elems(node, "assigned-clock-rates-u64"); + if (count_64 > 0) { + count = count_64; + rates_64 = kcalloc(count, sizeof(*rates_64), GFP_KERNEL); + if (!rates_64) + return -ENOMEM; + + rc = of_property_read_u64_array(node, + "assigned-clock-rates-u64", + rates_64, count); + } else if (count > 0) { + rates = kcalloc(count, sizeof(*rates), GFP_KERNEL); + if (!rates) + return -ENOMEM; + + rc = of_property_read_u32_array(node, "assigned-clock-rates", + rates, count); + } else { + return 0; + } + + if (rc) + return rc; + + for (index = 0; index < count; index++) { + unsigned long rate; + + if (rates_64) + rate = rates_64[index]; + else + rate = rates[index]; - of_property_for_each_u32(node, "assigned-clock-rates", rate) { if (rate) { rc = of_parse_phandle_with_args(node, "assigned-clocks", "#clock-cells", index, &clkspec); @@ -112,12 +145,11 @@ static int __set_clk_rates(struct device_node *node, bool clk_supplier) 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", + 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); } - index++; } return 0; }