From patchwork Tue Jan 21 15:05:30 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Peng Fan (OSS)" X-Patchwork-Id: 13946397 Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2050.outbound.protection.outlook.com [40.107.105.50]) (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 5C7161F37D2 for ; Tue, 21 Jan 2025 15:06:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.105.50 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737471986; cv=fail; b=XnPVy9+W4vBW+mnVgrlGtISTIWUg6ZUWofI/mTEY/SNAOfQKXaTPl04jdwXMtLX86DNVZXxdLDttm5JgooGtIIWPyEnuUnDm0RZeO9Vh0Yva1QY8N2uGiFkBPH4fOdD2YmL1gmGdafMN6v5VzYaAnQRDLNATAUP+r7KzKsroFXY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737471986; c=relaxed/simple; bh=ILRsm1TCToQDqVHiNju6x7gHUMy0pIE0RDFmJ/s/Nso=; h=From:Subject:Date:Message-Id:Content-Type:To:Cc:MIME-Version; b=AvO6F96nGd6Zq0b8P6BuSIc65+W8Uar5pr+j6xCOjwnGbL6EN7dTjNdr5/z9wy9jIv9BAWzhFheBO5Tp2VtMa75oSXF61i6qLwooM/HdjHjNm80eI0ZmBKku189I1RdYNHttxwKku9gd45tmFLNWbwGtw/nSEHbxDF+62eXMm+g= 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=Vk/qxk+y; arc=fail smtp.client-ip=40.107.105.50 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="Vk/qxk+y" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=JDpZuGZBbFK3OTnYZ+ooK/dHeIGRXJ/9Kd8AVErXX/rkkR5nDACOcuYfSANOoovsD2YtcSF1WHUJwDrYkvcAct1j1vfVBIOKjU0R2YFV4evCrNNXHB1K3S444Z4yMzpmj5quSP+OggWpZqqZzCjbml+4eCqiKowxfw19YBTA4foTWQu5ZJi3FpNQbTjjiSw+ymYWh1SZFt2JpH8j2PeDJ3KaECSaQ0yCjnFi/vT+4sjgfjOIlj7UEJcf4anuCbSa/zpxbxzosGGPx1V61oeH9NUZlxq/TWsxFV0kLWYjisy9aWwWCDvP+vdG5vEQnjdJq3GaObux1hOFBSyvw+56ng== 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=WBHULHP/CvhrPKTc1FyVZQPlVgRDiwLh83NJLrWxGGI=; b=wXoumn6j5exLC0RKAd6vjx71853KIn1zsJFW72Qn3gdtB+yHvmwqcI3AkX6KGpKmR9lT4rEFAp54a1l4yKtlhHVlyHkvPOqBd/V2MxGMLuDARWO7D0Diw/nA0oYJjGG28U8nQg6SVP1VEP6/euo+zFhhKgajfhNuwy/WHvmAcHqRhVsY/oiwcIYBTieaSAkwJU7LrPEiHaPECOkjVqvz8p9qCqKUWqNc4qssuLNVIehv9av3G7PC68Myw2kVqqoO9BVxjkYMMCvCs+O9SP1T/cX56gAjM0BFSx3L050JWWVBPTJaimudc8GmHEQNpnrgeMJdgSQNUy/rqB8X5hlKXg== 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=WBHULHP/CvhrPKTc1FyVZQPlVgRDiwLh83NJLrWxGGI=; b=Vk/qxk+yfEBbk3bzCS8ZsW6as5UrGEvEU2SFkZ8DyAOhZLw6nXchEb/3hcTA8gwb9gKb9rlahxFG6ypsQOFnZKWhAVYPWFRKrukpLrI9HK4VT8w5+wcMANdu6sU+krlBpt4tKOhLDySSbgxDAIrPkzF669RdvIy+/Pi0GeIq1L01w+RCJu0S1Me9wgMvpR8KkJai9NIBffC134G4qf9V7AlomRGiQWQ/FE21yQIb80Oj6+M298zX4DPzUvBH2Ev4b6FjAV+jfDxwKWKKPXTv2ID0L8VAUC04cIRB33X6JoU1rWd33m6sb/uM5Ucf9Zv7hMTXmI/AxcliqwpMrTlVmw== 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 PA4PR04MB9295.eurprd04.prod.outlook.com (2603:10a6:102:2a6::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8356.21; Tue, 21 Jan 2025 15:06:20 +0000 Received: from PAXPR04MB8459.eurprd04.prod.outlook.com ([fe80::165a:30a2:5835:9630]) by PAXPR04MB8459.eurprd04.prod.outlook.com ([fe80::165a:30a2:5835:9630%5]) with mapi id 15.20.8356.020; Tue, 21 Jan 2025 15:06:20 +0000 From: "Peng Fan (OSS)" Subject: [PATCH v6 0/2] Make i.MX9 OCOTP work as accessing controller Date: Tue, 21 Jan 2025 23:05:30 +0800 Message-Id: <20250121-imx-ocotp-v6-0-76dab40e13db@nxp.com> X-B4-Tracking: v=1; b=H4sIALq3j2cC/23OTW7DIBCG4atErEs1M/wYsuo9qi6ADA2LGMuOL FeR714SqSqpuvxGPK+4iYXnwos4Hm5i5rUspY5t2JeDSOcwfrIsp7YFAWkkJFkum6ypXieZImc FGjVkI9r7aeZctkfr/aPtc1mudf56pFe8X/+rrChBoncxQsjOBngbt+k11Yu4N1bq3dA7ak7lE GyKOWuMz071zvdONReJ1IDgHQz47HTnSPVON5cN6ISawOo//zQ/zgCC651pLtiTB0bHkf2v2/f 9GzbKUY2AAQAA X-Change-ID: 20241212-imx-ocotp-cbef304140f5 To: Srinivas Kandagatla , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Alexander Stein Cc: devicetree@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Peng Fan , Frank Li , Conor Dooley X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1737471947; l=3242; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=ILRsm1TCToQDqVHiNju6x7gHUMy0pIE0RDFmJ/s/Nso=; b=txvw6WTPyxwGjvRXAh5OYQw6U8GAF3C0qjJbj2KRXe0FeC/xCUgnL8/tEJon9c8dlyXsXLC1H Zmj0ha8lRw2AlopfPZyrZjC0NpqUoFitoncTJHaiXQdfkj9oCquNm3X X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SG2PR02CA0135.apcprd02.prod.outlook.com (2603:1096:4:188::23) To PAXPR04MB8459.eurprd04.prod.outlook.com (2603:10a6:102:1da::15) Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8459:EE_|PA4PR04MB9295:EE_ X-MS-Office365-Filtering-Correlation-Id: 266e5ead-88c7-4ba0-415e-08dd3a2d2992 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|7416014|376014|52116014|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?nsLK+FjXtxBuz64+1ghh689BdMVo0WG?= =?utf-8?q?QF77EvSDyAViwVEEDOCQpsz3CQoEba1FdGHGLUkO1+iW2AyWqud+kMZJNxiCV9lig?= =?utf-8?q?d3+R4yIuQHNyza2DteZW//uBdLsbHPFNJvpO6ZGR0TfyYpdmb28C+IkJlUpaB+Nga?= =?utf-8?q?/ruoYxO+Zdmrz6CniMUBpjbIBRCCFYD3oyZuB41v2XE5YjXfTD573SOzF/SLVGifC?= =?utf-8?q?cNYF07M2i95vI5aj8zfm8T3Rrj05gldB8xQXnEBlaECMExrAcEiJV2EQDL2e5B0/s?= =?utf-8?q?hcE3iFxX5LbA3SYeM6Zn0SVIYlNrlM7vKQpDrJkXWviE41Xh6XVCB7VqjwMRmIGDE?= =?utf-8?q?sLLMs7hAgkfMFzYYZM1biA+LaJRqHpApYKOlcapDQMY+V8+U7DWGHAk+yt17IC8it?= =?utf-8?q?+wl5f7ZvrpRJajajCq0RECfBbrSqzbLQTFjvNgJD3SzkKmPTIv+gloHGAyNSo5coF?= =?utf-8?q?AD9+mfo6C6bz6tZzwTI499KHYc5zJn4lu5AqI+VfbJFuS+26GfgtljGrJbFQ9mmn8?= =?utf-8?q?Kh6ad7YFK07bMmUJzvIxvcEZS/g+q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PpTA6rA=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)(7416014)(376014)(52116014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?uISfGQHK2mANef9V5J+PJqO6uirZ?= =?utf-8?q?7K6QTZTVFkSvtCxsyZ38YeS7+SOCwZvi6gO7vEzMzOg4bnKim13FClL7HCQIF3jZD?= =?utf-8?q?9nAKlRNbNk3Pfr2FXAQ4I69O2hX6+W6oBiL29ZCUZOZPtzKaoYJbuaI9KkJbS6PGA?= =?utf-8?q?YycNXVVWZESjkCnimlh+LEWs9BC71Zn7BdNu4PO+C1UXQ7Ky5UVpL/2+Rk2ZDpUaj?= =?utf-8?q?h/wllP57/jY54vqM4mnCljgdNouMIokFv1V1ywH91qpJDZI4Tx+e2XlLxRUdhjFq3?= =?utf-8?q?fjoia5uMWMO1QA3/SAvVyiXU06UORo3G0CKgtBubLnDvWb85OlxTBPLMKJE7hVmso?= =?utf-8?q?S/MCg126P5lYphpnF6DPqqVikvZvFG9N+PpXhVE7G/xzzeiL4BLjLsHRavOUBy0JQ?= =?utf-8?q?ymEBqkUzAtMZOJVuR8aC9JwFgRyMVWfkcjbnXaBwYQEjKJnmvnQypR3Enyvz4AmdS?= =?utf-8?q?e/yIPsw3wPppYLsgN3fL89aUCfzeJnhSZEbRlJ3RBvsw6fsaF90cXK7qNUAO/sY1f?= =?utf-8?q?MM+V+Dk1TyoBi1292jrOJ6jtN0tCnrggCDmekOS6GFeeTDDXy6hPpqoy+FIGm8zl+?= =?utf-8?q?YVg1s9qvtQutb6wh0IQ6W/CSQ45jnDBBsTr9vOctFm+K8otbMA+UBICCoh1pw9uvq?= =?utf-8?q?IFl4vzWbof2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orOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 266e5ead-88c7-4ba0-415e-08dd3a2d2992 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8459.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jan 2025 15:06:20.3557 (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: qoTsrmUZXB1iJV8+I0DwL+hrwwjDCKt+41BqV8MBqoNK43QC6CPr9d2rkBYl/stSr7s4w2RI9jqjHkoJzG7xUw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR04MB9295 Previously there was discussion on using "feature-controller" or adding a specific node to group the fuse information for U-Boot to parse and update node. But rejected by DT maintainer(Rob). Since the STM32 engineers added access controller concept and landed the support in Linux Kernel, reuse the concept for i.MX. i.MX OCOTP eFuse has some bits to indicate a specific periphral or function is avaiable for current chip, for example i.MX93 has variants that not have NPU. So introduce '#access-controller-cells' for OCOTP, and add "#access-controllers = <&ocotp [gate_index]>" for periphrals that needs accessing control checking. In OCOTP driver, the nodes under "/" will be iterated, and checked if property "#access-controllers" exsits. If not allow access, detach the node. In the end, cpu nodes should still be handled by bootloader. And I may also update i.MX8M to use same method to support variants if this patchset is good. Signed-off-by: Peng Fan --- Changes in v6: - Rebased to next-2025-1-20 - Update Kconfig per Alexander - Link to v5: https://lore.kernel.org/r/20250108-imx-ocotp-v5-0-a6d90e18ebe9@nxp.com Changes in v5: - Rebased to next-20250107, but seems Srinivas's for-fixes patches not included, so I picked the for-fixes patches and rebase the patchset. - make gates pointer and using ARRAY_SIZE - Use of_parse_phandle_by_args - Read fuse when needed, not cache them in the very beginning - Use %pOF for node name - Check controller node name in imx_ele_ocotp_grant_access - Use dev_info when detach node - Use priv as function parameter to replace pdev. - Link to v4: https://lore.kernel.org/r/20241223-imx-ocotp-v4-0-f504c1420640@nxp.com Changes in v4: - Add missing of_node_put(provider) - Typo fix in commit log - Link to v3: https://lore.kernel.org/r/20241219-imx-ocotp-v3-0-b22371098071@nxp.com Changes in v3: - Add A-b for patch 1 - Use scoped API when iterate nodes and address build warning in patch 2 - I am also thinking that to drop patch 2 to let bootloader to iterate the nodes that have access-controllers property and update the nodes before booting the kernel. Then just need patch 1 for the binding updates. Anyway, comments are welcomed. - Link to v2: https://lore.kernel.org/r/20241217-imx-ocotp-v2-0-3faa6cbff41b@nxp.com Changes in v2: - Add R-b for patch 1 - Use '/' root node instead of '/soc' or '/soc@0' for patch 2 - Link to v1: https://lore.kernel.org/r/20241212-imx-ocotp-v1-0-198bb0af86a0@nxp.com --- Peng Fan (2): dt-bindings: nvmem: imx-ocotp: Introduce #access-controller-cells nvmem: imx-ocotp-ele: Support accessing controller for i.MX9 .../devicetree/bindings/nvmem/imx-ocotp.yaml | 5 + drivers/nvmem/Kconfig | 3 + drivers/nvmem/imx-ocotp-ele.c | 172 ++++++++++++++++++++- include/dt-bindings/nvmem/fsl,imx93-ocotp.h | 24 +++ include/dt-bindings/nvmem/fsl,imx95-ocotp.h | 43 ++++++ 5 files changed, 246 insertions(+), 1 deletion(-) --- base-commit: 8c50c358a94b6f6d7e6185966830b5bc3afa5524 change-id: 20241212-imx-ocotp-cbef304140f5 Best regards,