From patchwork Mon Jul 29 02:30:52 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: 13744190 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 452A6770F1; Mon, 29 Jul 2024 02:22:02 +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=1722219724; cv=fail; b=C7qTMDRIsrke8WWnA4i/IwWfTooyFyuRMAFmzZ0xPMqcgAo6l+KsShgZkCe4KRDtiEVMPnqWVKntq9wA1o2wBaA/DeqddKohGEWL0AbMnSRkhfugNg6FUgAd5ZHkPaNMAzSin9ewsSmCU45vItAhLywiaCeG7RUAUFALKTAX7e0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722219724; c=relaxed/simple; bh=ECAcC70VNkmHhGoOuWrQrqiUNXqEeLqwVMObpF/upJ8=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=eeoD5kqU8rhcpWFfVdA4E9JvNXoxvK9XJfcEsRPXk+059nnBVYxGnQyP0btp9a7Dw+dtkg8M0T6gnPZzNxALkh768pduUC5Q+ormS6Pjr89c+XE1BPc3nRPt4FEKju9uOg5B+IhorqKy2GAJxmDNGxkuOwIvSf1w3ZzAIGF+Mzc= 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=rWl50BHY; 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="rWl50BHY" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=aHsO2OzhVcTMZCgbSka1ItDfVrYITXki0qdFZIZTCj8ZObgN0gdp0py9sHMT/ZfV5QiFva7xDEIf5Z7gkKfHWasWlQdnUhyy4e+XeBbRZby90Vt0Tmi13XoN7p3Hxfa9i+grbdJ4oecvT3zjcrLj9Tb5bScwYAjl8m2iaF3RaMAjEeAZCj6cU6FJkLoKDGs2b5lehzidN6pQhwYZDYK4P4VebAikaIYFPiRkubglH5wSlA80ay6LDzLkJKnBmWfzUMJ66yZIMUCT7ZmzHLC33KAF0TZellYZlKxF2tigg4ZL7+mskig5WO9o/+y1hG5hPo3LiJm3e/26pjbPRsz1mQ== 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=UZckXn/OMalNyPvz/0j6CIflrCeicJiMPhPygtPLPC4=; b=cGmO46IwmrsH9JRjt1w1dIHSoJGJv0wAsVeqzD7//o4CfxFUFCFcO47IYTTpqoyAqrKOpzrV2xx/OdwoM+q/MlziAo5OXdgK7yjyvLteYmdX/MOaUx4AeTYOFdY+81StgPar4xSFsOG8IvIUPtfIIGKaRZSIGYhlLh1PGvrVpKfKRMmt2ltWc8e+2eodkIMmCnrlAyutny6ZCmqvKA2HpunBnNNfLRNuuyjQr48WUEiXJozgFLZjD5pp7wM2xZea5Bw3EzLIWsUjGVkj+IckuS8CPZcovU0AG8FGWmn+l53tHi0P/XWaGDht0SKLBaeoVUUkovjCbQnHPgOaDatg+g== 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=UZckXn/OMalNyPvz/0j6CIflrCeicJiMPhPygtPLPC4=; b=rWl50BHY+6r71TevAx5LRQRa37ZklND9CFVM3TDgLF9jfxTxtDPOhVszTl8PY5qFYKeIVMP77a3K0kKh0LvinQVf9v5g5VJ+RFWF+FIpsS5CIisNsWW570+R/SVlRbpcHkZB/jFIyn3yTMemIO6P9+uUbJB/PIVK0Nk4PDOW47+2ZdZekKwex1DXVsHSUgWOZsizn7LYSceRPtBTSUXmnGuUxvFFOpaZMMXQQ6lx6YTOEOAZqfK9vHSBxeYlQzT9CvQXf8jYkL5gI39bFkcTTa2e33DGr/tM8pBj7GOoPR1p9OS7E9OyEKXK0rmSGqizR2nYeSHgb6Oo3ZKecLWBCQ== 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:21:59 +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:21:59 +0000 From: "Peng Fan (OSS)" Date: Mon, 29 Jul 2024 10:30:52 +0800 Subject: [PATCH v2 1/2] of: property: add of_property_for_each_u64 Message-Id: <20240729-clk-u64-v2-1-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=2731; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=8CQ/HRjnMclVYkf+T04PTSQpcqAJ1N+X/qi6aupHpMY=; b=ER6Oi5XWGKIOZIG6FLrcTDSS9XH+HxBXFXXv9M/Iv6UoWQt7arfyc+Nt2lywzQLAsG8o++gLm 3BFzlhuzaJRC6OTqc+dJIqU1VcIKj/ggwDbuFDVinLEe0feHd8UrxwO 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: 48e40a8d-86a4-457c-98bc-08dcaf7539ae 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?+Eo0MYtX9asNOh1l1vzNLZuFruwRL+3?= =?utf-8?q?paNAuQ+TU4aZDzziQaMKgo2F2+jSnEz88HQv6T5fZjCqItejt7r2uEVFB//ME1E/p?= =?utf-8?q?ggRoj5D+VNBWCIJ8T1t6z0zCl0mu1SX5rEVxUnQhwA4b95Un74Cnsluu8T1WZ4B6l?= =?utf-8?q?tSXt9bpX1y3XkkDhlzoFe3dBnPYf/m4OJed+VLLF+eVQBZDg/nLkoSWHUjCk8DOdu?= =?utf-8?q?Ly5nYDznunJXEgmF+ESVuGGmFKq1hN4yQSwn+VgDYQTlayirOsXq5mXrwFVJxjV3F?= =?utf-8?q?cbw62fq6Rm8C46fyDKf77ye9HPfA7BSRKEXK0EDo23hCYnHd6qQtFN/RI9yMhfnnH?= =?utf-8?q?L6wiVdJFiX9W6d5fN61eZ/YinQFG/2lRrWJfjktb1RKP2oUBmtHIdCAoUcd1h4djC?= =?utf-8?q?Kq8AXYXHp9wu/ojB08r6Nu9zTEgwIk4B72fsuLseEf/N2h/4S+MK86uPZS2dEnvUM?= =?utf-8?q?KtsBq/LI9bFmxoLNea9b87bqIMBQVM1vEWRi1n9cVnErr8aaOvz/lbVcTipfQUgDH?= =?utf-8?q?8xJeDdK2EZUT48j8uWtwxQP+2hKxYFf0YR6ijqR6mZriROE+98415HcT2kpfVM8Yy?= =?utf-8?q?iifNpCHsA/KMQUT71SK67PbeEqKqlqiWOovT40b/kQvKBW6xNR2BEdCXKjz+KQM3o?= =?utf-8?q?d9W8qkOaBYyA+EHsBD+MV5WI8Sul3kT17gE56lbASG5lw+TmcoVN4WYDwYJvNztef?= =?utf-8?q?G1xG0zvLs0Wl9BvGxJMkn7wQEsA4O94jeqZxmPUhSP8LxU6UvE2wOp97sfXoyWxsg?= =?utf-8?q?QdLgAMiWxvlxsNd459RwBGiXezKvas/s1yIzD7RZto4RQ7xLFa7bp33Sw8P7oqTVb?= =?utf-8?q?u9dYYPXFH3BLsXBL8ehNELss8lv4Tbsq3juWPve5WwjvJ90yo09CKroQngc30k0Vj?= =?utf-8?q?F95xNOXsVChL3mlImkKYyDVjVXDOKfdMKSmHRFjftv9HyafRjjkneGkc/MushCjAS?= =?utf-8?q?IC60cHqSJ1CYSL1cm6yQquPAUsNPZCRpHnBm54I+r+mnhAlitX1s79b8hG+iPIMST?= =?utf-8?q?R4YhY0mnfAtl+d6eLOFougghjzTHonk12RHWz1WxurfQfo59bKJ9BmBCYxOy/K8vm?= =?utf-8?q?7uvw4DHVo7wVysLpPjwyHBwluduQ6fOivGQCN14cDXdntt3NIL93LZQlRweKmDsWp?= =?utf-8?q?rZ8ENkTAOoVvpU2zILXpPsHAMZlXcQycZDn+9qhnuxfM2j3v3nGfUS6LzsFELObPZ?= =?utf-8?q?s6WeOrJ4W1YpfUYVVOLcw/p6UhLD/xzJveM8VQjPPodMSgsg+Ui+5i6aZrVkfuay1?= =?utf-8?q?stu/cnPyLu+Itz+m7g90ebb91VCrRbFCp6wl1531zm1aODisc++Mq6CvXOYSEFd9J?= =?utf-8?q?Ua8GVjnX7s4ZofpgdWymzfHEOAAnCjHRgQ=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?VZtVr6NEeQH72IrVZto4C6SHnEsA?= =?utf-8?q?Lrzumlbe3nleaJwCbKmJpAiwpt+1ZLmEHME3ff65R2V2e/ukMeF9bIpP1KUjOxbO5?= =?utf-8?q?8/Vsn6IDwa9LoqcFcn8Y79nhbamKIQpPS/eNs1r3fTunMX/0bYMXUuixhh8HbSahY?= =?utf-8?q?cHPJzUa9igTUFKclJ9QjJkqpitAHrwcPCM2D61CuU/rwzFslgFDr5X3esJKmKATv3?= =?utf-8?q?Fk4pX6jgoiqMh+/g0UdXisX73TkVnrdgfIKjhm8fxN92xd0omMzL6N0SBJn1xdjea?= =?utf-8?q?RdSzgh0iFWQblYNVAcPfY6i2GetyweLplnfz3wYqoO96xnH1pjQ4aH7dEQzPHstmP?= =?utf-8?q?qa/AenNu7zfoLNKKER3EVXpPrHlQqZbOF8q+QeakrwPUCbNHx2SMJwQL1mWbcFDJd?= =?utf-8?q?Qqa8k0GB+nQgT8lynaOpFN2NjD7iMDLaoAVxJA9AqGecAMUIgW0mGqSqq3qj2IR08?= =?utf-8?q?inpv5dX0b+OA8NpFXyvrFwWSurgTjM/9xHUmJZ+4g1P8Nu8QMW8K22CcGYv1yZIkL?= =?utf-8?q?TBK5KyrU1EW3vAtqVnK4+wHU1OKg0PgYGTPOkmLmegpstowc+io/DnEDrqxl3v9sD?= =?utf-8?q?iIngl4YBXX7KUQJ+hH6ttl0YKkdzpkb9wKq6wPVZAQjSM30ivYhsfO/fB4kzX4Ks4?= =?utf-8?q?T9or11rnR75uZIH26elnOEE2L3+FOc926E2uGgV7MPd+fAPUNe0A0jjnYneuB+NXZ?= =?utf-8?q?NF546mNuF1qqkx3DMjHTHeCyCgzGMyMA6ZQ5/8c3h1kP6ZsF8TJFKeAyzgiR3PaT+?= =?utf-8?q?UUmPVxjWhn6XAD9C6v23IWrTq00t7wjf6wadM3Yz/A23fg2ZqstLGu++u1iTn2NiV?= =?utf-8?q?W/6z6IxSNrau3Q4+zA21zYfvG2h5knDTyU06N1CzTgoyrtiQCSNlpDAP16mZLMuyd?= =?utf-8?q?j1em2KntyKL5e1P6NE7iNbEtqqCF8ODyBOarqhJzjUrAC5r4EAO0iKk6v7fqwcd7h?= =?utf-8?q?la/CsLzUbI9e6ZfINLcQ3IUwrAlaOKbeu4u8Jb+pwAA65I1LP2CevdXyQTrcn7L6M?= =?utf-8?q?j03aF5reZkIwQao2Cs8Wf2er2FflEG64pQ6Ne5Bp0vcOPVPaQEkioceCSXM6G/ZXk?= =?utf-8?q?nnGwzChk3X6ks0b4LVWaY/HCeWcIOFKfL3OuszcgFogVHZpwep4XsSKL8WrWEmTsG?= =?utf-8?q?jgZOUR9Onyp3HgiSPY1kLJJ03m4XCkgkXvhNhmbCWDui9VHdyTPMCF50Tb5UFAI62?= =?utf-8?q?bfU2y4J2pALcxI+utU0nKz4APH1+/rUaaTIp1uUrZQ1jNBrTIFtgaAciSn82FqbCu?= =?utf-8?q?/iEl0uunQ4A0h+xO6iPSNBFAsF1lpabcgDmQ1IDKZeKEi4d8lHEN95usdQgSosSop?= =?utf-8?q?eriLuh5kroAa1YR/intV1hhh7R7fVgkuTWlDVUf2jK7Cafyzu6enh/nPt49uz13J/?= =?utf-8?q?f0jW5dhcc3TDQxenzUtLtwd85nr47e6E+sWuDqZkHholH60MSh6gFGQgNUvKAxXnA?= =?utf-8?q?shi17UpdAqiKaMzpiCcHminH9h3fwOeUbJVO2DyZFgXfz1UM0lbN20zB3MW0eTNOH?= =?utf-8?q?clqzPHw3GoG4?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 48e40a8d-86a4-457c-98bc-08dcaf7539ae 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:21:59.4427 (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: AA/RYE1wY95DCDX1Ue1XbsaK/m0GJz7dsto8ll9bRNsfbH7EaI6SXDcGr6OQZ3wT+N6GVNbFgXl3h/lf/QgQqQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR04MB7368 From: Peng Fan Preparing for assigned-clock-rates-u64 support, add function of_property_for_each_u64 to iterate each u64 value Signed-off-by: Peng Fan Reviewed-by: Luca Ceresoli --- 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 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?R7GCBj51nfOLlaenyzrsQ7FojLXLXj48zKlzyyS0U5Uoi14/iGagqt1a/K+6+M47Z?= =?utf-8?q?ZeXztKDMbvwIbZSHi2dXKkH6bMxvHdtMhtmeY1ejQJawOdGBJ8f76gyVD715W10nM?= =?utf-8?q?YM1gpbQbzC+Wmgbqhovnyr6Qqo9tmXG38PoPmT7Gv5xJgk7Rq9EDM4XCQYS5g/JSR?= =?utf-8?q?d186c+XhtaWbK+QFBX4AKbtgCJ0NetbHr93+LVtxrScUr1Gq1jE0BSIVkg1Q/Mhjl?= =?utf-8?q?fiF1xHndUUhMizEPLEX6++B3vA76I90xFfoe5YMr92dhDP39GaEcDB0LnbtYYovrd?= =?utf-8?q?J+8GCHyMTV0f70d+KgQM25kkDWWAr97onCfCleRo7D+dJaWjRMiBxJknbHibG4u5Q?= =?utf-8?q?QamdD3hDpgIzIl0WDdD0AiD01wetYLZ5o4dF2i1+KanyfXiDpbT3p0c1G6XiRZD2S?= =?utf-8?q?Dk8cxwVUwIZcWg5suxxk1xN5KGgLsd0k5ebA78IC84ahBnAmk6mYYtQYFAdG1Bair?= =?utf-8?q?GogVq9mPin0okytBxkU6zo4HfthwVdPlTvy0/2M4b/hQowJ0hArWgqjI2z8HwZYKd?= =?utf-8?q?XE6xo6b0UDKsur9iJuwRIfxi3+2PrYCHbRVsn/L04+gqLG1YtmA69fiiQUzH7uXTn?= =?utf-8?q?ep+F9ReyUDyj0joQh0zOWWs14t2HwG80sZw5DTbQIso+L0Zi/+HafVOgWDK7RRAmG?= =?utf-8?q?EH8IGiCPn2BPK1pUrNCux4BKy6KrkAMzHzxSuClU/aBM/UupTK8nPG+rhFYDmH+Tg?= =?utf-8?q?HQFCntLoj2WLuNa1QxDTz0uH7KzFtr+R/TJaXFqsfFMcCiMD8IAF+biroXytJFjw0?= =?utf-8?q?Idq+elfeQQ6W6lyGEW42Wi38hwFPwDXTfJOGKIr8+m1S+yFUq/0GZS7huIoRWDIrb?= =?utf-8?q?y9G54lOPowuMN8KpwvZyTeDx6Y2uJK+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; }