From patchwork Tue Jul 30 08:57:54 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: 13747071 Received: from AM0PR83CU005.outbound.protection.outlook.com (mail-westeuropeazon11010061.outbound.protection.outlook.com [52.101.69.61]) (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 1960A194AD6; Tue, 30 Jul 2024 08:49:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.69.61 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722329354; cv=fail; b=Otv8aiv7ejaR1sQclPWZ/uXeFnxm6Gfn0ywnNyxtxTXzRg7zEvmsQcmmPe90PZUu0wbUV+lybCcudR0M8Jbqn+iTSFlVyzhoe0Jq2sCVQy/6+Xo0MqonWEk5E43loy1uceMeHjzIIj2IzrypqesBB/oDcmMt4BnJk8j08RTWGUo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722329354; c=relaxed/simple; bh=jJHtN5cdjpw48j/RwDXB2cYoH8FaDj/mkqJp7Fm5m44=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=i4zCHH68hVzDxzkUlsQT5Xg0GtYtcvyu7eZpv6KbSukuzM0lEBYHUPhYvU87Uayfsqv/BuzXIYLqWIFBmjUeLkiN/IwxDRnlUhqHNrZg5cxCPoWGsi0X8d7gHo6dF40ZyGfvQhXEQ048br4KanpAw7a9E3bgytrNWL6zT1NOOiY= 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=SSRrAqvo; arc=fail smtp.client-ip=52.101.69.61 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="SSRrAqvo" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=uLdaqUcfLt7fEpX/TUAQ6CMAnSrDfSdC8W/3SSLChgKVvcja/ourLnZqcXCrs9pC0XKgxt9xVJbjVsN3y+l+JD634J2B51vhsHNqCVIFbeWoeIMb27KktNU+3o7bIGk6PEp/2d4LpOs3m5opuh5O94j3E2M7E9mNxF5AQhlRJFJz9AtlKO5t0xLknAsScVuq9TWFZL+6cx8nB+yw2p/uDrnCdOlDB+9WhkdFNM0hK1lvVBg30/hJZVyz6FiqZl+H1wmzFwJuHPhL1v7g6GvQjgMx7KjhCFy9VSLv+DxnQJkOQNIQa9sZVVyHqS8XMhLANnWfgpYaYQl4Kqr4RN7zhw== 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=aCbMP+Kpy0b8AZOm4vvY+WV4eoopEamz1xVTULY2PfAbhgALKnoEKMYlb5g4Css8ZKg8Rk+UXP7MbTBlOSqgMpuckunAAQAkbQ1KR4RfNz/wACTwWh7FkQ0ogm3uFNkEgl2ySfWhCo0xNSk/EZnZNQc48pA8h+4+NnTg3O0ywUn9dbgZygWL0UBa+HuvPr+Bz9fBP4tHa2K9pQj9Q+jQ8sAkfa7FcDYDnSAHkiLRhrQn128siYC8s5jAXXzVm6C1uI151ItsfYfhzoQCD+hkii1X/YuPGtw1H2dWDAOl8NmhJhDH16IQrHbylsZDBTJmNAxWK4p7xQRaAvLC3GdJ8w== 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=SSRrAqvoFZC2nSNwfrhqSBpHSlOkonmEYJ9jHoTomCKRTKfWJkCwfsThE5UsV/ysXI8j00Iz5FKZlgFp1/vE/tUct/+AOl7Q8SDm1d5D8mth7aeK/S1PocuICTkdgqSk4unm6IXRcXwxNbYapqsuKrygZmfTyiVYPc+AR5EOxZc+4c4e1E+aq7iT8EsPZJ3BzVNt3bTc7Rs1KIFJ8rS6VCdvw26phLRvVPdDHXAjerwWXXoO98cUjrD3bxQQL1Zhujal9NTf7HLz51aRcrWA/LQCJbCNFo6GmNWTj/JKu5KhNaTBWFIkizB73v9UTkCbep9p0lYDBl6P/Uwnsj+uLw== 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 PAXPR04MB9021.eurprd04.prod.outlook.com (2603:10a6:102:217::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7784.20; Tue, 30 Jul 2024 08:49:09 +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.7762.020; Tue, 30 Jul 2024 08:49:06 +0000 From: "Peng Fan (OSS)" Date: Tue, 30 Jul 2024 16:57:54 +0800 Subject: [PATCH v3 1/2] of: property: add of_property_for_each_u64 Message-Id: <20240730-clk-u64-v3-1-4d2b19edaa6e@nxp.com> References: <20240730-clk-u64-v3-0-4d2b19edaa6e@nxp.com> In-Reply-To: <20240730-clk-u64-v3-0-4d2b19edaa6e@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=1722329887; l=2787; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=/uWDVm5pCySyF5BAPfXac+GeAhNij296nWQXpAULzPw=; b=bK6nhnpFwq1vkB5JFUMKPuRmRoHYNXYUwqkzCQhqc3Ym8Qk5nbVxHISzmn6Sw2hP6MzcBqTaj fH9xnAKmkbIDSfthoAecvQbGh/y3sAjHWcDdAy5IvSgbfc1RC2Pdr6e X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SI2PR02CA0038.apcprd02.prod.outlook.com (2603:1096:4:196::22) To DB9PR04MB8461.eurprd04.prod.outlook.com (2603:10a6:10:2cf::20) 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: DB9PR04MB8461:EE_|PAXPR04MB9021:EE_ X-MS-Office365-Filtering-Correlation-Id: 15e68d66-e99b-42e0-9c2a-08dcb0747882 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|376014|52116014|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?g9+W0J8u1eb9K5BqqCN2YdWklI/Ncto?= =?utf-8?q?EFa/cATsl+UBpo8B/2Kltw9LrA6urcBpHyolx3K36PsIdco1XrWJrxxAKlUIPotF2?= =?utf-8?q?90BmZJKo6fI9eOIkoEAHGDS4qDhjxZB86aJlat7a0AWiiLVdl5f2uwtf2rzkuZE55?= =?utf-8?q?8FQoX+QLiA3BZAqLhaGDKEcMHYqDf8ydziJuHUYQ8gwHisUGXCo/T66MjhuMKcxpV?= =?utf-8?q?TCp9XPbKSDtW/km4gWvK9t8EbK8l0TMayoYFxgQI9snaeaiZSdlCaLFvK/2XYMnup?= =?utf-8?q?RKBvZH5Z0dSFvQUY50IWsmHvh2Bn3yMhtnpx7AvUZNUjG+3lO88DrDOXOfQJz3WmS?= =?utf-8?q?ma2o7SN3QnjR8xbMQ43VnWK/qiHiofGAaXzzi1DFP5vZfGC6xqwLPH07xyOinBz8q?= =?utf-8?q?Tu64iIuNq1brCGaz57x1jC3KuzER+9Fy34hhKY5+lksMTRLR1RTzhjMvSJmWo2JUK?= =?utf-8?q?4upuGl9T0A28p7OA+zVjVbVcdrumOAJuixTjjubDYpJrPqS0prdHM3EVfONxJFwra?= =?utf-8?q?pVlR1k/gfJrU/DqkBXHKFJsWhvZPGWbYKB9QV6DUhYehO0b19EECqkB7mESxYAmIt?= =?utf-8?q?bn+iij9bjICnwvnVqoR7Is/rw4G+sZrIL0p1725UezA/sBRIp+tXZGZyG+xldNnuc?= =?utf-8?q?TknOI7/VvAoLZtWwTaRMorF6zUe6/ZwsRH5EBfIKkmxG/deP/qNJZ3IrhpwZSbSPn?= =?utf-8?q?VYH4G+/NQqp3xMW1B5BZLAdmhM7FYBRpC9updtvnv3cqqsucN1Eehq4GouYGEUn8R?= =?utf-8?q?yJkWmcyCANtOkky3cPCvsNmmAtlP8ezEQL72vzjQB0DonWD1cA1ZarfPPJcCYIxtu?= =?utf-8?q?XxwEWd5atXig0VXQiYfYqw7G5ikyp1FdsAgomJq5PLvxXXaoSFVkhPBEU+GQuOfSG?= =?utf-8?q?z2vSte7fzNv6CYXfdwSgtXGMEmm656uKKDSaqb6syTu/Pxd1Hsl8+0kMDBmLiOuw2?= =?utf-8?q?E23/Qem7MfP6WKZKiaRCNFnVW5tL9itGpJgyGLmwQQkC84Vn7IvpnXfEaDXzJvDja?= =?utf-8?q?N+XS63rTRmVfWH/7+5sI14IW7OrO5RaPU9fBqwBZqhxDarfmmgmbJvxq9Y3RsVoKW?= =?utf-8?q?SqwmgnsMHPxPZpsiDeooVHFD5CKLDbY06N8WMGZ6m62nd94WMVJ6jjclUAIrQF7mD?= =?utf-8?q?wFsQCNm89m+KVK5g+LPcOpUNh9/ZJgVafh4JojzXxIjIf3CqYEUlGyQ7gVwf41xE9?= =?utf-8?q?8tvPsy2XMyobHQfPKv+uEN2D0zhlYGzOfpnGlYqIVTMo8YFQfQbmIlmmOnGAVb9+p?= =?utf-8?q?3FfiQTdP0bpIJElOARrvTHEpKTMeBwWOE5+7V/nwrpse37ochxhhsZu5bgbPPkFGu?= =?utf-8?q?v0daOtxfXK1ECZA+aXgAJc+T1kiDsby2RQ=3D=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)(366016)(1800799024)(376014)(52116014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?FfUyqprUjygLWogRT91NDZMFawA3?= =?utf-8?q?t17QCIPTeyw1KAsyVmZLDRWj/nvJZKEpLB/ngdLjHWs2fairy7BsaCvLsNSY8qWK7?= =?utf-8?q?FkDJyv4Oidbf2AD+fzaKoy7oRfwK+jWPeKGeVZzSqG8WruD5IVDrjn9sZyTBCxma7?= =?utf-8?q?D9mmX1bkBKhj0yJKCrbiZUQoaek///RtBdKbS133djXT/r7AQsBr+Z7/1Oe2GI01+?= =?utf-8?q?dNo6gzO4733qwLx1MuL4IuHFaMTr1mScqKTAEW9NCFIwVILFb42roUY+u0xtwj06P?= =?utf-8?q?CaIGh5mWiD7UHMaxVlw2hjxmUp4vmzotQkNv/ZXoTAT2reVs6a2OspKo1y89Knmqx?= =?utf-8?q?0RufXEa0ZH/rOm2pr4+CxEPrdsyl3C9QY5HGhC2rh5qqLDqCbLeEv/Y3MTeIW8xnV?= =?utf-8?q?GOx+yb2V++Hcp+pqTTq9zXISmx9YoaJYmjqWEg+kX6YS9gaicQPZzvinj8fuSt/3h?= =?utf-8?q?zugMKeXW2u1UNRn1josjyJnnmKpJ8YSL4n6ZIklD6wmKJUoOZAdhh3KjnU6lc5XUm?= =?utf-8?q?PcTV+BfP5v6HjGgmIPYVCXHNiy4esLBEQ2mP5/0R+6IVqg/jZUt0ARnfKmwrXuBZa?= =?utf-8?q?g0e61gdLikyQf1dNdAcfOuHb9pk9MBvgjZeN7Z9mH0jROr29ynOOR+RaDEcrnb335?= =?utf-8?q?rE2n0b+aUlBSXtlekbxdo7qsvk1OdYrNQ7p3Yhs90mi2ooNF80+NZp40bX9lygIhl?= =?utf-8?q?UJyOuEoSsexTfdbx+e6/A1XImqQj+FHIa9f8MDzgkSqrPbiyw1OnJMNDXI1Ml8Tm+?= =?utf-8?q?ChEyAPFBN9CFwPPvTzrydor641CBlxF5ObemOu/NWeevf7y1euUtICuiZC3XRho+l?= =?utf-8?q?FZCluKeh8M3ksp9FWL3mFWSsuTeH/fbQPohEuzVMDHHmrxODGkjQoehRI/th66OnK?= =?utf-8?q?tczxECa9NIbf0E3feJ24sgftMjtklr7O+5e1va6Ao4koid8sOXeTWcibmsBF+7fXO?= =?utf-8?q?/fc8clXdeH8Uly4KOrtSomNyDbL0V8sVlQNJo98hCSQGHFYymwWIuTYnPaRFK1jjL?= =?utf-8?q?71ZSjb+/jKnDWgMIX2Ii2CjEhRTjsM1cQ1qiHH7sO6TlBy9TdJHCpP8fdLOZQCmlO?= =?utf-8?q?OadNSlR00yM46W/VwXA6lJqeGgVjjy9OVbWrYYG0u2/ML7gbiP4NvQE4W4mG9+ldd?= =?utf-8?q?lgbVpK1sBi+LRU+xx6UJPE3e5gFemt97RpsGyM/YmzjrqoWD91/3XnfxABzgJzbdH?= =?utf-8?q?LlKJj0pDV+cv6ITgE2LwU+thc/ZvVOS/0Iwv4WliyqScGyJp5kMDLIK1zZKZga+3l?= =?utf-8?q?5WPuDFB0pafmEDlWuJZU1YJ15h453DiyH0LLgeHmFIZomWspHEvAis+nXvm0SEVuL?= =?utf-8?q?K5w9e2akoNMiub5XolFjhXuINre1/hublzuNUg0WtXEYRh6VKb5sAfJzvf5kjcwM/?= =?utf-8?q?EexK0/EorZp2doDdE+4/4dsbSQJh6cv3POeUy54IILI80gMduxNEm75SEle7a9U6d?= =?utf-8?q?cERoL/DLRTibQkZdaN8iWtybDGiyBvEMuycikwI26Vuk2roJtIyt2u2/633zs6XsL?= =?utf-8?q?SUkVU50foHt6?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 15e68d66-e99b-42e0-9c2a-08dcb0747882 X-MS-Exchange-CrossTenant-AuthSource: DB9PR04MB8461.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jul 2024 08:49:06.7345 (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: R4UdnlKsFilhFOYoQksr0/d95xFWB7Rjf/SQa/z9R4cGysdNNKwoaqvflv6CTaaf9ZToNRf6+ll5EDg6j8fb3A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB9021 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 --- 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 Tue Jul 30 08:57: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: 13747072 Received: from AM0PR83CU005.outbound.protection.outlook.com (mail-westeuropeazon11010061.outbound.protection.outlook.com [52.101.69.61]) (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 8440F194C64; Tue, 30 Jul 2024 08:49:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.69.61 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722329356; cv=fail; b=lElShC5PcsHUM/0Rq0zk93BzOxIcGnkd77CzS5Zpu+r0fuvhKEJuUaQAhJ9aLVJtAP1US03sgwDTc5RBrznp9bbfRB2tIPZoE6Tq+Dtprk1ouFtDEgogGbRVa3sHMGrvtLPcbvknftMYGeVRZSSQxDMmga5yDlIPt0On4HLuROk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722329356; c=relaxed/simple; bh=5xRTsdrn1Ix/3Mgzo0lry2VgymrmTTFr4xJYfhC4puQ=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=mc4dMzIb1MRIO3WuRAU0O2GeWrC5DJF2jsVYiMFwIcM2B0nQp5rzp3csZyOAyIRwowbcw/VooFBv4c4Q2acONUgcFOsDmIimdjH/2xU3JTHMqEnpwfxxmZwdjlfayjcTv3x1mkcMywHiAiXYyQExKQde/0zyxA0Szqzg+TA5RyA= 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=DxCnGbsg; arc=fail smtp.client-ip=52.101.69.61 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="DxCnGbsg" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=q6g5uvusBkBB7y26xpTv6SaVl7PHiJV4sVvh1QGX7MH+S6KkeJH3lBilXTnnCmbiNB9Juntnm4OnrNpf1JjmU8drjcsHIi4+pnLJt58o34HKqGJpCVn1udkat45E7KnWBNQ3b49Iw6MGxrRX65d4MocjO7B9eQrHvyKcAmnf4G8/Q95VPz4aGeZOIvqdpScuy9h93HhPT1jrFYZbNVIkSEkpwUH6PjAay+p03AchcRnRM5vI0p0t42CEM4/R8b7wnXCJrKMss+dWL8dswZ4tdMbbw+LgEiVkHgC9SOj8iUMTAfB+ySH1MKiWmOOBXJ6HSQK5Bzh+A+YbGEjRBuqWEA== 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=xRwnZNctTZuOkS8PGldxochCXwtjTKzp19U8R/f50d8=; b=PTBmfNYG8Z3j2b0oQLvhsPqDGo7ZIwB5urJlooTgyEj+5DofLzf7EBwe8PGiPQQFA33/Tb5WQyTxhr+yVeu+LeZL+JOAtcjzSOp5ORxX1urgAxZolb3IHHfyiyfOoWYekEw2naBiSbUkWAuP2ijNQnDC3t1FIi85+fSIxLBg94+AiaB/v4jxQNfObOciJsOGQmhZTp+eCDtcLUHq1OYdzyKJibF6V25Ym/kFEUyjGDVyuDfv0+TQ19GmQJm/zxa/nxjzelv/O68VU1sIiYZwYkesyOD10smSIp06eFFGAT/4gXlb18A467c3cZRCzU+h8UXJHGSvkfijcQ3R7LW91w== 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=xRwnZNctTZuOkS8PGldxochCXwtjTKzp19U8R/f50d8=; b=DxCnGbsgjPYfFFSrxfAMifA5Ljl55f/4BbPxDfsblwJwVHwMMBJSueZKQGc35ju77b6uZSnVvgNewuOclqLFRoankUHHqgZrcE1+8W9cDN3bwoRciyBY3qo7dIP0ftUH/I3O5hlaKurGd1aFM+ytCwlwkDzulaV2FxxUzzAKCNKtBVDuseUU3YsjlE4bpaxpQFmqsCPawSiXaeL1pTw6WaJm9HoMc++frLBZx4pSYZbZEbhtgSlnmV4vCSjVSlBPldEklhrT4kHSGssvK9QGHxHTmsqj0TFQgt3Pt6uS6dKdjK4QjxFVRfY2st4qURNsZqKYY3gPnkPY5fThb6fDOg== 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 PAXPR04MB9021.eurprd04.prod.outlook.com (2603:10a6:102:217::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7784.20; Tue, 30 Jul 2024 08:49:10 +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.7762.020; Tue, 30 Jul 2024 08:49:10 +0000 From: "Peng Fan (OSS)" Date: Tue, 30 Jul 2024 16:57:55 +0800 Subject: [PATCH v3 2/2] clk: clk-conf: support assigned-clock-rates-u64 Message-Id: <20240730-clk-u64-v3-2-4d2b19edaa6e@nxp.com> References: <20240730-clk-u64-v3-0-4d2b19edaa6e@nxp.com> In-Reply-To: <20240730-clk-u64-v3-0-4d2b19edaa6e@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=1722329887; l=2412; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=J5oFMdGnIXFx9n/65+BOh2zj6XyKbv53dEmcaGstyuI=; b=UhMJbV25O1exKMZCzyHLn3ZwXPY4PneE5qvA4s5rfAlHmPku0SN4ZeXrFpebYFQ3ELx8DxqKy IoUKGqJqU++DUVH/olwIPLPZmu2JkH5IbyyHxMKiAdZZuiQVV8BvWwx X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SI2PR02CA0038.apcprd02.prod.outlook.com (2603:1096:4:196::22) To DB9PR04MB8461.eurprd04.prod.outlook.com (2603:10a6:10:2cf::20) 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: DB9PR04MB8461:EE_|PAXPR04MB9021:EE_ X-MS-Office365-Filtering-Correlation-Id: 0d28519f-a112-4803-4adb-08dcb0747a86 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|376014|52116014|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?+CDaAo7nib2NmQ5rEroyNBzmQe+X1el?= =?utf-8?q?DVBsov5lFSz5+twOg0nPrlT7rk8ID2q+emb9v4aNBfp0a6m59EL6ZxFcuoBEgjK08?= =?utf-8?q?Jbp7XIhzT2bbYPoJdIBskGQsVDTK0CITL6vY3+5Uw2HVIpy2AYNJVfeTAnO3kgBmJ?= =?utf-8?q?NR5gvDkRgFvdX9ozLjQzeK3RxNPGCrtz5YbvoqmtZRfD7tCY0Wz9p570SzPM6f9Xx?= =?utf-8?q?mZE+Q+4dUt+s3+nNVvsuUUNPe6p4QtmxdgP8BcqM5VvgPUSVk389yCXkL5o9QtEby?= =?utf-8?q?+IMp9qiUEq7sEpRcygtzGaRvKFCiebwLpYlte6ihjgOQIS7W0cVT7/l4UUtDe8JCi?= =?utf-8?q?roPRK8LH3wNDKqoJc4Obtx2G5v0ZxS/QC003J7SYuth1Aqj57FL0tM3w3u4MNOoRu?= =?utf-8?q?uqS8CIpudfNJeaCZ8JepVQFZDDXT7R2ak38uX5NknEC9oWqdzRP6CJXLTQ21b4492?= =?utf-8?q?L/nsF9NldeFCmLv9quznfeY8viG3K1BFyumE9VfYwsX7ngxIEzxaY3dvUo6+iDlF3?= =?utf-8?q?zZugWJEEhm7qu5E63nVQcsThJPlbFPd+bxejXX3eSVUE0W+38pFSvuiWyd12pbqxf?= =?utf-8?q?Gv+5SkJtnMr/ATxxo2U0+Sm1IdSDS2t29nuCqnexGzUzp5YXgqpPsvaCduj62U1Dj?= =?utf-8?q?/msuu7dyNGcDLb13MaSDbHjzWqT1mxu/cAMmeMWkZIhoSxSj+nutL114bj94C8/ML?= =?utf-8?q?FVgi1umD4O2XyhS5FTbC/1d+ly1ZxdspZRg35WhcWw61N8vI96AyZSn4vH+U+yF39?= =?utf-8?q?/Aidd2PyrF7codQfektt+zi+LwS4ycBIqonAi8uMWGsouPVExUm0sksbhcLX62RJr?= =?utf-8?q?kSAV3qmQMRDAg376Cla9zVUYQEg/cwmll0a25Et6WjfKgE03OM7UyO0FijqnXeFTN?= =?utf-8?q?EGJwQur8hhmgkILrMG9SGVwxKC2ZbrImcEVv4PyPA3JXAaVs3eF2EKcw8QaYZkJQN?= =?utf-8?q?F9ikEbE8nteQeUaJR2j1DsR1b5t5tPuKeX2X27Vf9qW+ak662TjDRXxP7DCD2KYci?= =?utf-8?q?VBUVEy92krNwnPkxYX+XtEeH5u6OnzhMXVcKQjX7LC40qNbfPLeg3c7yPUjb1ssBK?= =?utf-8?q?3u3evEA44Fknpky3Vs+UF6Iu0vJBsSW5w1temzZJN9sUKJ+nTQxH8fFMgp8zM/Ab2?= =?utf-8?q?pRs30wsK0ysjtMKbzCqGvxP8L21sw3tXUy8md/E8pJsXzFQ4yGf6YUnIQYYAnGsin?= =?utf-8?q?mvEekBqUn34bvxZldQOtWrrGEx/+15a2ReBY6GfRM8hugdhgMAcre3qAMU+uBVauy?= =?utf-8?q?vVoPjH9ux+emlEslEHntz5YJTTAX5UKlD6IBFmi/2j0jaxMkBTuquh599OvsrJhuf?= =?utf-8?q?sp4EVrGw1S0yunlER+JqpWr8NNw54dOFYg=3D=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)(366016)(1800799024)(376014)(52116014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?SMldHUCgmJVyMKyGyH7iLE6h7hQ0?= =?utf-8?q?KEUG1WHUsZFYzs8icUDOiIWfMBpu5XOtwNp2QqUAJae6tgKI9CIqmNymzRlwdEhKZ?= =?utf-8?q?Y+bDHylYz0jY5f49jsNjdZHj8gLKSr02iWb7CxiasWWLG7nUCJrM4CT60ObZ4XiGv?= =?utf-8?q?K6jEtn/TtrBFEZzGMjrc3nctKqVYmvvzHJSS3op90rVY2VlLgkBnJfdAAoXoVXWgf?= =?utf-8?q?gWoMpe8o8XcaW6pyJ1FwpuiRhTim2lofYFKXBoIYLZCP3SWWZj24HloBt6aSmmO5l?= =?utf-8?q?igz49IuzlTRzxBxWhZ/r0Zr3zYy5UksWiJ3pYRR9VpuxrX4RUJt8dYjVddhWxfPr5?= =?utf-8?q?ELjYT8D1t4uRA9yJbszUlSfXc+SHtfZMvJ/49bSYf7N+i7yy2F/x+Vs+IPQArduUu?= =?utf-8?q?6DhLEs60K+3YcHhe/BCNEhRi4oRodi4azq1SHJCNztbtT/Kd7JNNPUM9fN9H1ZLsE?= =?utf-8?q?NlRbq17qoa1HHcTw+17pf7WNJKQunapDKv12njUIOezkK6KF2d070XS9yvZcH55jC?= =?utf-8?q?U4fZT2hK82XubsYv6ylaxq+iYk3OpbVZVned9f1EFI3etTKYEmZhRy+zH5oXd7cl6?= =?utf-8?q?KNkqd+UWZxNXF7+jVKrfd6Gf+KuzIN4yEHkvKhCpCSSrUx/VEKqhUxT1por0lRCtA?= =?utf-8?q?pZZD7CTMZw/t69bpGg5OnjVHUIicg9hySX0LDymCXM3SoQFEHYNXMgE3aqoUzFb/1?= =?utf-8?q?bta33B9tzEOI9cNK84OTjabliczqegmWcBJt+nZ8TfhOF1rmNOL79hUOnuZcQLs77?= =?utf-8?q?08KWk8pFPozV8iRVGJ8q6zcwPHo2Twvy7czG31SJBLy7cYc/bs+DNuLqVP5fWtJh7?= =?utf-8?q?lhKVllcCIJy3Mh9dtXD18ZvA+qhdVNd6MfiiXbDmC9lF3O/AHYQ3TxgK3KqCIU96r?= =?utf-8?q?LuPNIoaghbLKXhRCmt1Mbne6sfTnyzbF70rwOfQ1CyMc46/2M5+DA/eh/MLlrlaFa?= =?utf-8?q?0ww4VbgYViuHBaHv4DE+G3dePSDm4TtpGAhg8Jf2kMmi+C5F48aD/uARlw/9f55x1?= =?utf-8?q?KTbH468CEuSx83G4gk2lo51w4M+eQj6EjqdPzzIsZ3nEPaCAkQgJiRIpeuH/ynra6?= =?utf-8?q?SlRfushulHXNMDfjf0lXlnWpO+lK+Vty2JBxNwcR/+06lKl+KARbnaGGKZe5feIwc?= =?utf-8?q?O9Qx0KyCm2R3O/mepsbwG4V6HiTD2i4sgOdVuXWIdcKJkrUkisltZYIMjMQCtoiRj?= =?utf-8?q?yekOuQlJzcwrhCCcNjHwG5bk5W6gOsiRa+p0h/u5DRswhDe8C875q4YgcJK++oS/C?= =?utf-8?q?7mSbFFVlRKd81VOlZiIXobdQMS75F7q05mZMFVgAerINJuUR03RaKYxDLDr4C+C4G?= =?utf-8?q?ous12yIEVDqzqBeAIOA5xP+n67dI5uGU5DszOpz3v2JXdeSOY75/DQSzF372c2Y/d?= =?utf-8?q?hRuacysk4WpeC8J0oqsHgV1g8d36UH/3a87dCHpbegADH3SxkPDsq/bMPpf3fgqT9?= =?utf-8?q?1NveahZGAtQ87Bj6uejLBBBEf7If/T3dHps0W+jAP8oiX+Y3w7fHsEknnfUAhw+QP?= =?utf-8?q?o0TG62FY7F5H?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0d28519f-a112-4803-4adb-08dcb0747a86 X-MS-Exchange-CrossTenant-AuthSource: DB9PR04MB8461.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jul 2024 08:49:10.0435 (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: n9EvV2wZNOEYInmB4c/W+ONFQOpm6RLefn4+HVFcM4bJqkSMSwyq46znbaj/6jPEK3izFNYAsX5dy5oKH4h0wg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB9021 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..684e0c0738b3 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, index; struct clk *clk; - u32 rate; + u32 *rates __free(kfree); + bool rate_64 = false; + + count = of_property_count_u64_elems(node, "assigned-clock-rates-u64"); + if (count <= 0) { + count = of_property_count_u32_elems(node, "assigned-clock-rates"); + if (count <= 0) + return 0; + + rates = kcalloc(count, sizeof(u32), GFP_KERNEL); + if (!rates) + return -ENOMEM; + rc = of_property_read_variable_u32_array(node, + "assigned-clock-rates", + rates, + 1, count); + } else { + rates = kcalloc(count, sizeof(u64), GFP_KERNEL); + if (!rates) + return -ENOMEM; + rc = of_property_read_variable_u64_array(node, + "assigned-clock-rates-u64", + (u64 *)rates, + 1, count); + rate_64 = true; + } + + + for (index = 0; index < count; index++) { + unsigned long rate; + + if (rate_64) + rate = ((u64 *)rates)[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; }