From patchwork Sun Aug 4 12:32:55 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: 13752618 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 B4CD936139; Sun, 4 Aug 2024 12:24:06 +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=1722774248; cv=fail; b=KZ3FjATSfDl38yL8Ys54SjGK+u3QnggxX9c2w6M5ze0yI2wklrADvCqCqCepL2zbOtQt3LfQm+zXNQ/zEXhUIAq0sFmqE+4GzK9Z+TanKIyfO/ZgmUprxSTxOWXVaOLgzA4ULQ6XLUIYZoyo3wCoX+bqQwm9lgiPYV54uIjj0CQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722774248; c=relaxed/simple; bh=jJHtN5cdjpw48j/RwDXB2cYoH8FaDj/mkqJp7Fm5m44=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=ouFRKgzUWAFiGqUQd4BmDQButuTc5S1qFKF6z3GxwhMfj2rCtfhMAENAqqC+d1H7hjoXBd9vsB0GXc77DSdi4R27eNhz75Vrz12qdOnTh7CTCU+rd25idmP9O0+txGj6MCiTiZgoh6vWeN/vYKDDB+uCtM6lIFJY5K8uhPcfhJc= 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=VjyrvMEL; 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="VjyrvMEL" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=TPOrdhHlK2PQSZtoznZ++fU3a6XCavKAMtWeZnWCPJATMGkl1empKo6byOcP9IucmcKRUcT3YDfDMo5nMYiumOqvSv9hJrGEHH+hIV39/sMNN7wlVYRxxEISQydu3eFpYOk5+6K4c90RVciq27zTy8z1hnMd8ljhlNesy3cD2K2yYt2Ei2EqDUkve4EHInfgElhE1dlEmju8DWXKaKYRA17aRkh3IlJcEIuhqmhPturNp53kN6E1LMJPB6eUmB8Io9aRn4aYzYEZJQOK7KVVQge0+2z3jacsjzNgdGttZkee+a1/ZwzaUgLCVeWW9fMCD5r16Hph0sZgfRIaTW9TVw== 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=Inysam4Nwgvdh+lgZZMJHWWZI7brIH8XEIf9gyI9WyY=; b=Nnb9B5JW7rxc4+gExaiHYq/Y4AQsbx8+yFhGguyjt5gSytjgToy4cz0u+26oddl4kj85m9boGs6v89mJPXjFTyL9V7PKl6c04XN7Fx9FrjQ3xuMGEkzayuwGxijabb2qZZdRuRatR0yMuK0el6JVlJldElMCyMGBpQ8Tpvu1pKEsG5IgmHIQBmWon2bFX0xKzWe8g8hZJCEhbkLsKMQDMpF1Cx/qaA0KKO/ljHL5mBTRTZ5lbcD9PTNfu9TGLnAWTdWryClzHQHtKa12Y8FrBqGxHySaMGKebOTpZQoF1/i0qmPLngEOW+Ut1wHOUnoYV9Z015qFFfQr5mTC5zMxIQ== 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=Inysam4Nwgvdh+lgZZMJHWWZI7brIH8XEIf9gyI9WyY=; b=VjyrvMELoZTn2VRN0S6d8il/f1y1mU4CRbNFyt3kyR/LsNuG+oXHLzbpP2GAslsIJblLgD9hFu3XgsxTTQzjqAPgx7a8AsnAffPMLgV/c/q8mVw2qb/3/3MEdwVxdDOIfr2l1jyrsG5z4vOlT+PtgXXQLs5/FulPNDv7n0OrqtonLcH3DcFKtC7WnAjWnKJx/1jxh7mUdzaFGTa+Xk8ddVhh5HPlpMt4DslpssBjI+A6L38TbedCMZiXf5us57X0YIZVZbUcTz5HfYDhEWmpaPm4bmnJ4gghC3tjxhlaMMqMSVWyEltwHGVuIiC3RI4y3s6TARNECgtDOjAWK5IRvg== 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: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; Sun, 4 Aug 2024 12:24:02 +0000 From: "Peng Fan (OSS)" Date: Sun, 04 Aug 2024 20:32:55 +0800 Subject: [PATCH v4 1/2] of: property: add of_property_for_each_u64 Message-Id: <20240804-clk-u64-v4-1-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=2787; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=/uWDVm5pCySyF5BAPfXac+GeAhNij296nWQXpAULzPw=; b=AaLZMkjvJbIRJu9kcvya9BVP2zvCnZC09Wm/5CF4hx7T1aPMA+kl8/CW65aM7EzzUppKlibbq jntreCoxCFPBI1nOQwRZkyUfA6xt8eEfOrjoyRCZLbYHKu0XsnMrS2G 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: fc070f14-d584-4333-8066-08dcb480534f X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA: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PhWgNu0w0csNHwREFfqtD?= =?utf-8?q?hxV5yz0IEoZ4XEIn15DIjQte1beMatt7IT0pYQ7kkalWP2LN0CEfxy19fJ0ZFDLOX?= =?utf-8?q?ivIvuEBeekeHayHf1X++eevTCw9uhZqIYUAKIXI9Sa+Gfxm3XDs9jPTd1f/E2BQwj?= =?utf-8?q?ngUD5I3PbvuS6ffAMwoFqHB4aGTY9zjX1ctWF+bppcBVGxivmiQoQ9EIOcyccUEmu?= =?utf-8?q?PQsW/q2qikWxEO/fLmhDeBeYQHwVuatYD1+utQo75WeX9n4N2okK38MqYTnOvh5uX?= =?utf-8?q?p98o00Ztit7jdRvZWEVV98o9j4NwypJwi88u6e9k9X1cSIWVl8y69iI3Txl51f+Xd?= =?utf-8?q?RmQFYHx+KVwTQJQMphpzdlIEdFxSscTujOn/m6i1K7jTHC599MhUi5MJ8LxD21aRn?= =?utf-8?q?lF7HxXweohe6nJL/zws5FBkqqBWdv89wPM2ibZTnR0OQGa1RIgvJVdLA6f3Ce3rZ8?= =?utf-8?q?/PsTHuOjc9esRff9woS31NfXbcCVyl4Q7MWN+DORyF9Zb96r+zCSIL55KpIAdhUst?= =?utf-8?q?B1Lwzvh/noFDmA5KMM+AOYKzDLIy8Xi0OQ=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?vHT3ynttJkM+/K5KRYFdgx+YUR+O?= =?utf-8?q?EL3Jx24aYI2amg6ji85p4Iu6yqAbt+J78scpe3DLplFZ092eamHSMJFYTJts6Rsbq?= =?utf-8?q?wkt6j5utNar0hW6xkXCAlzAKykAx2EXc8BZG9/IkLwTbZo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/cR2W8sMQg?= =?utf-8?q?RMfg6LlR+C29+8yonKAiPIb7QhqAbuh6tG8AepnmZKX3r51npbP2gSNx2LtHMYYjU?= =?utf-8?q?PSHCuB5ZVzcaGuCjLp0hW6gGB4+x9Y5dIYsRJijSVwdPae/3+U809htN0F6lPQ/2S?= =?utf-8?q?sOvQlXObAdjH4oumVmrju5emYb0nSznLqfs2zGoePF+QVjGCM8Bz9ERXucz3UzYkw?= =?utf-8?q?h5rcWhA3YkV3pFdTNcql+0IeN/JTnMn1II5msWuXftWxhdea1P7VENd4WcgrwJmxL?= =?utf-8?q?i1UfxjcV3JuPFoh5DrFR576dhbB0//0BuYrcxZrrmAv43VC+uDXe+/LhqqOvl/Z/2?= =?utf-8?q?xzno2dIUQKN83jINkyZbybnGzXmK2BuHuC15X706MtDnTGCEOw/ORD/GlBxOJfaFA?= =?utf-8?q?3SUcmguSfwk5akqcwBkzHhRqAurjd51ygkhhXphRfNqkZpFSkWgHvFdpXY7PrCBpN?= =?utf-8?q?k0alBR0PsUIzcyfMriystiR14NIqFuU/ivs7I/nK3vz1s9tNlVOE8eAQKgAShUSzp?= =?utf-8?q?TSaiwYETUAfe?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: fc070f14-d584-4333-8066-08dcb480534f 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:02.7176 (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: NiyutEYalAxiuJXFzv5NI/56CaMPF+3W+veMbWPwzdY7AOOeboSOLELo1mQqlFrTW1FRWSnAA087ngdZbLyWtg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR04MB7413 From: Peng Fan Preparing for assigned-clock-rates-u64 support, add function of_property_for_each_u64 to iterate each u64 value Reviewed-by: Luca Ceresoli Signed-off-by: Peng Fan Reviewed-by: Rob Herring (Arm) --- drivers/of/property.c | 23 +++++++++++++++++++++++ include/linux/of.h | 23 +++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/drivers/of/property.c b/drivers/of/property.c index 164d77cb9445..f70fd8deb9cd 100644 --- a/drivers/of/property.c +++ b/drivers/of/property.c @@ -548,6 +548,29 @@ const __be32 *of_prop_next_u32(struct property *prop, const __be32 *cur, } EXPORT_SYMBOL_GPL(of_prop_next_u32); +const __be64 *of_prop_next_u64(struct property *prop, const __be64 *cur, + u64 *pu) +{ + const void *curv = cur; + + if (!prop) + return NULL; + + if (!cur) { + curv = prop->value; + goto out_val; + } + + curv += sizeof(*cur); + if (curv >= prop->value + prop->length) + return NULL; + +out_val: + *pu = be64_to_cpup(curv); + return curv; +} +EXPORT_SYMBOL_GPL(of_prop_next_u64); + const char *of_prop_next_string(struct property *prop, const char *cur) { const void *curv = cur; diff --git a/include/linux/of.h b/include/linux/of.h index 85b60ac9eec5..de481a4bdad0 100644 --- a/include/linux/of.h +++ b/include/linux/of.h @@ -437,6 +437,16 @@ extern int of_detach_node(struct device_node *); */ const __be32 *of_prop_next_u32(struct property *prop, const __be32 *cur, u32 *pu); + +/* + * u64 u; + * + * of_property_for_each_u64(np, "propname", u) + * printk("U64 value: %llx\n", u); + */ +const __be64 *of_prop_next_u64(struct property *prop, const __be64 *cur, + u64 *pu); + /* * struct property *prop; * const char *s; @@ -832,6 +842,12 @@ static inline const __be32 *of_prop_next_u32(struct property *prop, return NULL; } +static inline const __be64 *of_prop_next_u64(struct property *prop, + const __be64 *cur, u64 *pu) +{ + return NULL; +} + static inline const char *of_prop_next_string(struct property *prop, const char *cur) { @@ -1436,6 +1452,13 @@ static inline int of_property_read_s32(const struct device_node *np, _it.item; \ _it.item = of_prop_next_u32(_it.prop, _it.item, &u)) +#define of_property_for_each_u64(np, propname, u) \ + for (struct {struct property *prop; const __be64 *item; } _it = \ + {of_find_property(np, propname, NULL), \ + of_prop_next_u64(_it.prop, NULL, &u)}; \ + _it.item; \ + _it.item = of_prop_next_u64(_it.prop, _it.item, &u)) + #define of_property_for_each_string(np, propname, prop, s) \ for (prop = of_find_property(np, propname, NULL), \ s = of_prop_next_string(prop, NULL); \ 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|366016|52116014|376014|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?OMZnu8L376s2i1+Zc/8z5O8NR5mQNvN?= =?utf-8?q?T1J0IqS7kSqJrlbs/0IQG5iKb2qGDmWrlSFhA8IvAXnNqvOG54ygvdbAZkrrxCqyo?= =?utf-8?q?NTg0PiwCeGj/gMT3A2WuoBQLKa4hccXq+otoguAyOSK/g9RnN71Nil4TYr8Q/3BaI?= =?utf-8?q?VT+gI1Xvnk32CAwWVmzOpiVHtN4n1LwiQB2rtijMUUGuHvLZQ0YQ5q//1Y3t+MpI3?= =?utf-8?q?lHA+Ie+Y6qUOntR869q+tY4uCUYlk1nBxAANLL2y75wANnJblkhTa25VjNy+h8tIK?= =?utf-8?q?hFg24Xkuax8xsRGmoOu91D81zgQUspY3UIiwWqiT7MJKyZ8kjcTGvz6Bk16rplqw4?= =?utf-8?q?9I0g0g0qMXOAjpiQnVaZC/yl+E62pfzTDsOSXD5+UmSsRBd9xCK/gv4CyaxYmqGpi?= =?utf-8?q?xZe//O0QZdGM5kNtFoDJdkuCOCc6jbC8IKlrcBbwIjmllNGhFMq1uWLgMgQcQXWcP?= =?utf-8?q?wgYNlJbT2THltNZaJWIPv8Qgy/GhtqH0WkYoUUmV6M4pxDPrk6fME6vBCHTy5iThI?= =?utf-8?q?n68pPGcwWmuUil1MtkO0s7RpYbFLgCTq4kRhJzZhy5uIZhYqz2mGegYNR+nIrwXTt?= =?utf-8?q?9rTPKJBw2SHE8MIOwmmIGSWzfy5eDvVA9FcJVYesQF256ibgh2XQFAOAkF/DGfNYH?= =?utf-8?q?tr79YGUMaEyGkwKAQQErSVcfeEMtJwpUka6mklGcnFLWsZE8MmIogzOtIAF0J/MxJ?= =?utf-8?q?iw8U3fxWXwH89IUM2lZZgKcLQTIHmLX06k5ZNq2aV1NHm8r7Ubzo6tW4ALHnkh6ty?= =?utf-8?q?KvYcUgj1BNO1Cyd8G7o3pQwpub1DvB/rAyKwaNrS6wWdOuUcOtx6Fxxx/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;S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ZCQ9PIZIoIoWSFK5TQo0UUloMN?= =?utf-8?q?00bGRWbXd/SnfwlISP74Cb0+KPgZamgPW9+HEP1fdBytcvPcox5gyN9XXazIsAtw8?= =?utf-8?q?wypAmwrduWCvVej43nIbK2Q0v2EVK24xOVP7cYrKBOBHJIc67VV9Hqcov8TpmpxTS?= =?utf-8?q?OIhX7SaOeIpnh9MRdbgNCSwajKy4b9ZSqTTZw2xrNC42c+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; }