From patchwork Thu Dec 19 14:25:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Fan X-Patchwork-Id: 13915127 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E05DAE77184 for ; Thu, 19 Dec 2024 14:29:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:MIME-Version:Cc:To: In-Reply-To:References:Message-Id:Content-Transfer-Encoding:Content-Type: Subject:Date:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=rsEDvNEYhF3R8DXfZgJKKwqLRbmEeD16rDVIKjmLYLA=; b=GwQffU3sxafSoKYw2EsDaaYw26 eWBRbNZJHkHnw7r6Aee3/dPoszfkX1b1e8YaFotAc6FkewdAU9YVS4hz6uJShmk2So0qUN10vDayD XE2LbNFbd2O0z05s5tQ4hu1acEBho1zAvYZAO57peb3vSENwANAEBDGPHskOT7mDWX5rO8P9MUFsp UIJkzNJdgEfezdzzvtXFucHdEODgwW2TgzPpAStdcJ2VcHo99eXOvVYcONvu9aSk2u1rmLjJWm51A h2brU32KOrX53XzTRVmto6WOpmg3pSQowEfatwN0TCfqWIqu+8AHN7oevCgHi3n523mtlN/q1luqG Cc5la85g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tOHWI-000000023yA-0edm; Thu, 19 Dec 2024 14:28:54 +0000 Received: from mail-dbaeur03on20617.outbound.protection.outlook.com ([2a01:111:f403:260d::617] helo=EUR03-DBA-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tOHTS-000000023Qu-3HTZ for linux-arm-kernel@lists.infradead.org; Thu, 19 Dec 2024 14:25:59 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=InDROwyA3vglPME+j4+yw5p2jHdxl0eODRGdEHch9lj94hXSCK+1t/Za2sRIZ+52jLv74QEq0/wrFfJ9E4w+ZB5NPSQTXxJUDi+qaVdU/lSxtaHO0zolpgPuMzaRqvt22Fbww7F4sKm4a18NvpUGC7d4fYulAQqBiDH9hhaubkrrNlTbcw4Q2PVLDjKKtDB9+vP2u7NY7h2tvz8PgC9cFHFXJ/A6YQIQwmqVnpH5lC4lu49o7eWhyZP/V72to2Y3agHfFpVQwRFAprTKMVLoAMm4q5Qb1NT3GxQvhSnABzjwIUvmNKEVcuqk1Z24v5qZNFsi16ku1Of1TgYYkPBYJw== 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=rsEDvNEYhF3R8DXfZgJKKwqLRbmEeD16rDVIKjmLYLA=; b=l8ceU/gFv8UjLDFZ2OQKGL8eUaDKDCYhAi5WuF71lgvq5DpMAXE7bdaFS37USUcd8nDk1UNuO0RwdllCu7Gg4FJUFgVR4ex0RHbx/M8Lu0QM2sAY9gG0jAo6VbFJcfg7L2UfoSeVh0Zhp6/it9Ss2WZl4C4LnsvGV4MeJp6zW85nN0pGc6IaqxVuSMqz/CjiIPvxiEaW6T4CqwZ8ws+mCQgs0MSlHQjkfkRvkJmWmXzzqIPzIlVSnrrVNVIITQkgY6VNcjFy9gyARgS7DX7nYmhNpXlcwYsKXHsVWGKwMySjbzCFuarN9FT46kDzEbkTh6ULMH1VVK6BEzV3O3W3Zg== 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=rsEDvNEYhF3R8DXfZgJKKwqLRbmEeD16rDVIKjmLYLA=; b=V7e4VJou1WX5BJvmi3hshad6Puo60C2DQ+G1pGgWxXhL8QKHY4D2L92YO3RB/BQR3qLk3h9orbHiP9jQqCum7Ym4sdEOiR990cufuCluwW2swMxbyCb/PMXg9yPGohMSIsovkHcOF57ocauSZpA0OXGTPmBZ/2WFpYB9bDcEDDxu4/kzB0S+Swbzxc7dDB5Cgca756KzPFu6iuesmutBiyIF3PXUSc0wLuA6BiGWs7Ap3A+l2HK6Bjo/iy3Yzgk9N4ayDOI411msNk5MjbLDmP/LdkRaMAMqzHiQDTApcGqY++DHGNYRZXDpJ81NXAMB5bdmlPnUNJZhKKm72LksGQ== 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 DU2PR04MB8950.eurprd04.prod.outlook.com (2603:10a6:10:2e1::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8272.14; Thu, 19 Dec 2024 14:25:53 +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.8272.013; Thu, 19 Dec 2024 14:25:53 +0000 From: "Peng Fan (OSS)" Date: Thu, 19 Dec 2024 22:25:17 +0800 Subject: [PATCH v3 1/2] dt-bindings: nvmem: imx-ocotp: Introduce #access-controller-cells Message-Id: <20241219-imx-ocotp-v3-1-b22371098071@nxp.com> References: <20241219-imx-ocotp-v3-0-b22371098071@nxp.com> In-Reply-To: <20241219-imx-ocotp-v3-0-b22371098071@nxp.com> To: Srinivas Kandagatla , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam 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=1734618328; l=4068; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=4MXzYq4oLyYtlA95EQap1UQZ2xOM248M5j3t6NvUUFI=; b=2n8SYklS6e19QSV0YXimnalu4mvhdBKEWo+LWHeSrGAMu7d620ZxT2ZxADDrPexqVKAAd/RtX vPFJyN1cdejCfHuiCbwv+tgRQcKmtar8io57DHImLU/BJCsjxz/sr3b X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SI1PR02CA0054.apcprd02.prod.outlook.com (2603:1096:4:1f5::13) To PAXPR04MB8459.eurprd04.prod.outlook.com (2603:10a6:102:1da::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8459:EE_|DU2PR04MB8950:EE_ X-MS-Office365-Filtering-Correlation-Id: de0963aa-0795-4189-9182-08dd20390ba1 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|52116014|7416014|376014|1800799024|366016|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?sRHW0fPM6FuCr8RP/PFj7Bm4MlNNxwp?= =?utf-8?q?Dr+7Jqk7eU7m/qQuJnNtn6+mSNIcSttwDKwt3aIWjkd6jBXCjNlsFtRLKHMVfMeya?= =?utf-8?q?RcMe2sv6DU3vJJRvh2D/sZfkEQ5D2l4xJipKYiZaZHCaRpLD/azaIp8wX5ooMCczy?= =?utf-8?q?K8wvPwCJuW/BZQK01A9+QVtGorGmxXyI/WioH1A0p5ZnkW/lJ8M2liKeEqIEEb3BL?= =?utf-8?q?XWPgb1lxQqIzrlDPOWWmh8LKwj9wpihql2+itee2K8K7T/QqMRR1P6LfAUs3+CjVn?= =?utf-8?q?IQD4eaeeKDGBQpzC/dWy4zdtl5SqwHJkgJUa5yLohHM254z7pGvKCKONMXrVHNkEA?= =?utf-8?q?wBjhJsRPPYEKVPi0226z2SGXf606CMA9Kc9RO+05DHH5qMcaizPy5t0lLtHv/Bsdn?= =?utf-8?q?IYOHfcuV0tL9IRQNcfKLrlg/mC5vHF6oNPUT8nZa4mwD8mmHXRPVGjpVUi6OikLWQ?= =?utf-8?q?HRNVJELOpAKVrzjPhzPGUGBL1Hj74C0YzXnSE4zWMJTn9Sg+1WIUVv1/3gIcBddt+?= =?utf-8?q?1GE4XALnNFb77VouRe94xGXDpWl1GYGAePAC6wwhV/fW39CP8DOD1+w9UGIDTSpOT?= =?utf-8?q?kQ9q8OHjrZPvfhyhpD6ox64Wh0ZvciAwiEA/BDVnwB5VV6uv3D2aAwmC3wyL3ebZR?= =?utf-8?q?c7eVRjFRDJ1SSGnHhY5VU8payVOgQtXNSse+4sslPJ3LaF+OnOFdKWycg7lMMy1e9?= =?utf-8?q?5I1KrnPK555tLaxHpCCyB5mssnYHDX9OHCPivb/dxJwoLGtQKRnzJWQhTg9msDTnx?= =?utf-8?q?L23qwFlS+POfD55EWoTXeqbUAp54AHmARSqFrm4TSvF0skNybmEzaX6eHpLa//f76?= =?utf-8?q?4myCjsqT1ey8u/PzGp5hpbIEcqQRMTXKY15GyxxGOGs0SRcI99Q5H1e/gFxNZoBEp?= =?utf-8?q?5mtPAqXGVwpsM/fBD4gy7e0AIK8sOT40UhojISJuFiTYpuxF4vU/ymtizZA2wTedW?= =?utf-8?q?rqM/x5dmYzeDmFW59MzEIeQXlDybtLeE1ACuRstJ0DBZR0/PfDI3Ko0YLUG3ll616?= =?utf-8?q?ztjEx7cyFZQoYolnCNWleYstVaQV3wse4PPZfPxZKbzlfqdChNJneUAW0y0OUwXdY?= =?utf-8?q?cax8XXf3pK5SndlOEqcz4C3df+oR6b2B/6vAml9j1LtoajpKB8kTnMdYyPaHh3Ju0?= =?utf-8?q?DmWBDGLmwgFgv5UzwteAUKWySidxkq8zQMAcOEer1CODaaHbAJAXZBuJjU8B2MV1W?= =?utf-8?q?1Y+QvW4k5LwR1wSRcLiIrnsIP48SA1q4AwEW6Ti2MLMOken8MquTwM10SJOcEw2G7?= =?utf-8?q?uf/wXDFc64O4t5kTORTyQrhVArqYyZtYCYPt3UN+NzzWOAwtU6JwDOuoSxQsB9HK8?= =?utf-8?q?nwtqDovkUlm/Nue2j7lBg/3+qYMfJE3eP2cjLulnujAoyv++zAH3nxtNY68witZUp?= =?utf-8?q?2Aa6KCDuGHO?= 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)(52116014)(7416014)(376014)(1800799024)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?prayf+jwK2XXP3XhM8MXrzYrn6hL?= =?utf-8?q?RiomE/sWoP+JvbOL7v7EsKEoX7VDHR+brFBDxJuxzgqUtaaEu2V/fTZOi4A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utf-8?q?BMKmdV6B+COf+bRGmr91kGqGBNFdpNj2ChMrj589OdpRSeUUeNl6GYHpJMdhskyzO?= =?utf-8?q?xZ9gDSEqsJh4rnl0vox+S7i/YS9NSJhQ6HjDazexIRKaaOCp2CIvDXp6RNArpay/s?= =?utf-8?q?mv2TU1ncgTHnRu0eAyXyboFCgW5K1l3b4scLVS9JNx6G0a9dQFzMKR6eaDAIyPAQ8?= =?utf-8?q?e8FVLqUJdxxYLt4+U2VmnGisnhsC709vU077ICiDhUa3ZarB/criCQHe63ePSllB8?= =?utf-8?q?GH/rz9TwDq9N7Jp+/UYoKVvn+alhWRHIm0Tt8p/xTHuLojE9fMPMneO7+JKeJ1dZG?= =?utf-8?q?0ayPyIPW2oLO1oJ06H7pjoA1SXeUNASrCBGHBoUfJIJa8QDOO/K7nbgXGVuLtbGo4?= =?utf-8?q?7xQCc4jWrAadv7fzwSzPWijv/emGKbM46xljlHKQ0O56LkmKQwsC+RLtvaaqhRiNu?= =?utf-8?q?e1yPS3+uTtyjCtq7cqBGurQVs0/g3sKSi1M/Reg6jOfIWpFMILfDkQ0QBKaUOhM4q?= =?utf-8?q?l6tbeNaTqItvkoivQvT512bK5IZBiQ6MakGAhUwsf1B/KeSkKsPZJGxCIRNCsIiOA?= =?utf-8?q?Z2uM8lXucR2V?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: de0963aa-0795-4189-9182-08dd20390ba1 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8459.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Dec 2024 14:25:53.8101 (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: c34K/InTy97fdJFJP78N8RWAhzJ7BD/WcuMmNPlzNxJz3HzXqXiRIP54X3vHgnfjMzy8rUutI+N/lhhTwu5oFw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8950 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241219_062558_828070_8407AC0A X-CRM114-Status: GOOD ( 11.61 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Peng Fan Introduce "#access-controller-cells" to make OCOTP be an accessing controller, because i.MX Family OCOTP supports a specific peripheral or function being fused which means being disabled. Add the i.MX[95,93] OCOTP gate index. Reviewed-by: Frank Li Acked-by: Conor Dooley Signed-off-by: Peng Fan --- .../devicetree/bindings/nvmem/imx-ocotp.yaml | 5 +++ include/dt-bindings/nvmem/fsl,imx93-ocotp.h | 24 ++++++++++++ include/dt-bindings/nvmem/fsl,imx95-ocotp.h | 43 ++++++++++++++++++++++ 3 files changed, 72 insertions(+) diff --git a/Documentation/devicetree/bindings/nvmem/imx-ocotp.yaml b/Documentation/devicetree/bindings/nvmem/imx-ocotp.yaml index b2cb76cf9053a883a158acaf5eaa108895818afc..c78e202ced22f1c278f7be827b71ba434832d2a7 100644 --- a/Documentation/devicetree/bindings/nvmem/imx-ocotp.yaml +++ b/Documentation/devicetree/bindings/nvmem/imx-ocotp.yaml @@ -54,6 +54,11 @@ properties: clocks: maxItems: 1 + "#access-controller-cells": + const: 1 + description: + Contains the gate ID associated to the peripheral. + required: - "#address-cells" - "#size-cells" diff --git a/include/dt-bindings/nvmem/fsl,imx93-ocotp.h b/include/dt-bindings/nvmem/fsl,imx93-ocotp.h new file mode 100644 index 0000000000000000000000000000000000000000..6ef525173845fd4ee0e847cf5a17e53a14f71362 --- /dev/null +++ b/include/dt-bindings/nvmem/fsl,imx93-ocotp.h @@ -0,0 +1,24 @@ +/* SPDX-License-Identifier: GPL-2.0 OR MIT */ + +#ifndef _DT_BINDINGS_NVMEM_IMX93_OTPC_H +#define _DT_BINDINGS_NVMEM_IMX93_OTPC_H + +#define IMX93_OCOTP_NPU_GATE 0 +#define IMX93_OCOTP_A550_GATE 1 +#define IMX93_OCOTP_A551_GATE 2 +#define IMX93_OCOTP_M33_GATE 3 +#define IMX93_OCOTP_CAN1_FD_GATE 4 +#define IMX93_OCOTP_CAN2_FD_GATE 5 +#define IMX93_OCOTP_CAN1_GATE 6 +#define IMX93_OCOTP_CAN2_GATE 7 +#define IMX93_OCOTP_USB1_GATE 8 +#define IMX93_OCOTP_USB2_GATE 9 +#define IMX93_OCOTP_ENET1_GATE 10 +#define IMX93_OCOTP_ENET2_GATE 11 +#define IMX93_OCOTP_PXP_GATE 12 +#define IMX93_OCOTP_MIPI_CSI1_GATE 13 +#define IMX93_OCOTP_MIPI_DSI1_GATE 14 +#define IMX93_OCOTP_LVDS1_GATE 15 +#define IMX93_OCOTP_ADC1_GATE 16 + +#endif diff --git a/include/dt-bindings/nvmem/fsl,imx95-ocotp.h b/include/dt-bindings/nvmem/fsl,imx95-ocotp.h new file mode 100644 index 0000000000000000000000000000000000000000..2d21d1f690974d0215c71352168378a150f489af --- /dev/null +++ b/include/dt-bindings/nvmem/fsl,imx95-ocotp.h @@ -0,0 +1,43 @@ +/* SPDX-License-Identifier: GPL-2.0 OR MIT */ + +#ifndef _DT_BINDINGS_NVMEM_IMX95_OTPC_H +#define _DT_BINDINGS_NVMEM_IMX95_OTPC_H + +#define IMX95_OCOTP_CANFD1_GATE 0 +#define IMX95_OCOTP_CANFD2_GATE 1 +#define IMX95_OCOTP_CANFD3_GATE 2 +#define IMX95_OCOTP_CANFD4_GATE 3 +#define IMX95_OCOTP_CANFD5_GATE 4 +#define IMX95_OCOTP_CAN1_GATE 5 +#define IMX95_OCOTP_CAN2_GATE 6 +#define IMX95_OCOTP_CAN3_GATE 7 +#define IMX95_OCOTP_CAN4_GATE 8 +#define IMX95_OCOTP_CAN5_GATE 9 +#define IMX95_OCOTP_NPU_GATE 10 +#define IMX95_OCOTP_A550_GATE 11 +#define IMX95_OCOTP_A551_GATE 12 +#define IMX95_OCOTP_A552_GATE 13 +#define IMX95_OCOTP_A553_GATE 14 +#define IMX95_OCOTP_A554_GATE 15 +#define IMX95_OCOTP_A555_GATE 16 +#define IMX95_OCOTP_M7_GATE 17 +#define IMX95_OCOTP_DCSS_GATE 18 +#define IMX95_OCOTP_LVDS1_GATE 19 +#define IMX95_OCOTP_ISP_GATE 20 +#define IMX95_OCOTP_USB1_GATE 21 +#define IMX95_OCOTP_USB2_GATE 22 +#define IMX95_OCOTP_NETC_GATE 23 +#define IMX95_OCOTP_PCIE1_GATE 24 +#define IMX95_OCOTP_PCIE2_GATE 25 +#define IMX95_OCOTP_ADC1_GATE 26 +#define IMX95_OCOTP_EARC_RX_GATE 27 +#define IMX95_OCOTP_GPU3D_GATE 28 +#define IMX95_OCOTP_VPU_GATE 29 +#define IMX95_OCOTP_JPEG_ENC_GATE 30 +#define IMX95_OCOTP_JPEG_DEC_GATE 31 +#define IMX95_OCOTP_MIPI_CSI1_GATE 32 +#define IMX95_OCOTP_MIPI_CSI2_GATE 33 +#define IMX95_OCOTP_MIPI_DSI1_GATE 34 +#define IMX95_OCOTP_V2X_GATE 35 + +#endif From patchwork Thu Dec 19 14:25:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Fan X-Patchwork-Id: 13915131 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C7B4EE77184 for ; Thu, 19 Dec 2024 14:30:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:MIME-Version:Cc:To: In-Reply-To:References:Message-Id:Content-Transfer-Encoding:Content-Type: Subject:Date:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=nRakj/Xgdf9SAZMTHvQNk088xoMpLAeaT4jiRGUFlK8=; b=IwvpDZWT0j4vNZSn3eUVTMaUuG bBiWLVD6RZJ0OwJUnJI2KMzVEwNafgC0nJfgT1iglHADGKPAZP1HH+tE2YwzGFRH5lgewjjnrnJNo t+sC+waTEHI5banPEV+5Y6pFxRMhYLJFug8CqGAj8LRYw7wA+AH6/6IvE2CIuBFCGruHj39F7Hfr2 f9oyyaFNwRfF8IJgSjO3rF3A6NV/J/1oOZvRJeUIr7rbY75Y+Lycc25Em9zjTrlXZXLNoUpcct3cw WUnjfronDfVqHhXN1P/nRVYPeVO3k4+WPCgJCTgrr9NYIeIssX7fs9V7dCRYUx7yKQTG0yEhK2xsE UCYq/TzQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tOHXN-000000024B1-3FpR; Thu, 19 Dec 2024 14:30:01 +0000 Received: from mail-dbaeur03on20617.outbound.protection.outlook.com ([2a01:111:f403:260d::617] helo=EUR03-DBA-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tOHTU-000000023Qu-0lT8 for linux-arm-kernel@lists.infradead.org; Thu, 19 Dec 2024 14:26:01 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=XLjR2MufGPpaJ/xUbzZyhXsRsvDEx6Gd2nxF1VFg7VM52wJcbIPSwpKl7V6QhZm3FfkCM4qkVyIzSK7QkQNPf1lXbzd+mVzUoj2cTNCJQ8Z/x9F8yPHLl2xT3QzfX11F7uI3M2Dp4Z0AkOt1AK5TwLgf70GuhKyvd+Ei76vJTcTcsFuDcvFCjmvjoW1fRy+clzGDkg0VRoa59XIWQlwi6h9Z0lOrqe1VP51t/sqWbSB/uxNbIFU26AkxuqNChAw2r3bO3IdOnkD34gDkfwCfFVG4ocypIaSWRRyr/sEthGLoMw446wlkso/VwtamRK7icacLqaQ4tr3f75ugpkPXyA== 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=nRakj/Xgdf9SAZMTHvQNk088xoMpLAeaT4jiRGUFlK8=; b=otdNYp64870gzPAnyArh8/v9rKntodniGqpavziHwZrodWssTxi9m2Mr/NY2BLEbKomnPhEUaJy9Fa7c+plsmzBWKPnbfMlH5/eKqT8vtYQ+R+AlHwJJqzZtO8LHL1+c2ok+eCUQLpRae/JEIXFEuOhYGXPL0Vr+tKfxyEUu2ZW0ff4s1VSOf5Yt0y32g0Er/I55bz2ve+0bl+BSYrbDPnKUeZ3v0zBlGp4q5Fk74WCW+2uR9e0C7YfnGH3wReC66104RqB1ph0SCzInUVTbGx3G9vsSJcleJ+B5k/RvmedMP62SAhYDZEFkY9LW0huOAAhG3oryfIZFkLw5bOlI/A== 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=nRakj/Xgdf9SAZMTHvQNk088xoMpLAeaT4jiRGUFlK8=; b=rDEYnqjhD/ch45QYBCiF66mAqMcn1mjrEu7Jx76B0l7M1td80MhFQcCqLP2yfcY6Ux8SbzeeWY+rFDoPtBEhtO5t+COmU8J3x78EHI4B8raLt3NttFaWBOmyB2Y9/h0C/SGIwX3GM1Vxe4VsYOv1wtuR3a9XMFiWUxeMtMHe5xXW3cPdm3OiyFuKIEBEDJ0RcbEK8hSmoa3zcxSjyqj0CoMtQ8SQa+XKz7DIyNASx6cMlPtO7gt/j5g/GRhdfguDAGBUNPUci1mLa3VUH6spz8ArE+GsaMPAS4nU2Qmxkn+PmuO8zX+FNy6d8eIPccgeTDCFSB2pKUUyZ3MacNwRiQ== 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 DU2PR04MB8950.eurprd04.prod.outlook.com (2603:10a6:10:2e1::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8272.14; Thu, 19 Dec 2024 14:25:58 +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.8272.013; Thu, 19 Dec 2024 14:25:58 +0000 From: "Peng Fan (OSS)" Date: Thu, 19 Dec 2024 22:25:18 +0800 Subject: [PATCH v3 2/2] nvmem: imx-ocotp-ele: Support accessing controller for i.MX9 Message-Id: <20241219-imx-ocotp-v3-2-b22371098071@nxp.com> References: <20241219-imx-ocotp-v3-0-b22371098071@nxp.com> In-Reply-To: <20241219-imx-ocotp-v3-0-b22371098071@nxp.com> To: Srinivas Kandagatla , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam Cc: devicetree@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Peng Fan X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1734618328; l=9105; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=EFPjusyV5OCGOG+g+/w5SCv3f0XaX5a9BcxGOgvkLIA=; b=3NP25a18VA4EHmzCFGnuMDVYJWFUPocUa3sizGRj222JTW0VVsA6XDPZxsvZRKjwLamrYJTyz prv014V2E66BzEDlEbZEfkc4vcYCWvQqluQq/cHEhAh/p23qWI9ZLQF X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SI1PR02CA0054.apcprd02.prod.outlook.com (2603:1096:4:1f5::13) To PAXPR04MB8459.eurprd04.prod.outlook.com (2603:10a6:102:1da::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8459:EE_|DU2PR04MB8950:EE_ X-MS-Office365-Filtering-Correlation-Id: f6c0e95f-7f16-4939-2912-08dd20390e47 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|52116014|7416014|376014|1800799024|366016|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?bj1w/iD2P+2hUsxpHXxuoPAOisbphRB?= =?utf-8?q?KAjQFPWa5j7HL6I/PzGyWs/h+lAhSe5pYs40o4Bq0n3AIV3l63/dypowgsTAg4JZl?= =?utf-8?q?Rrxno7B9wylnL4EskiNs8aWMKwfFiRikOeK7W55gHsy0S2ZZx2twBXZ2x+/wgF+Al?= =?utf-8?q?UrWiV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?q?rBI2RWgAg8aO1j8J3d2s1Lqvcqk+3+tGo897v2QfYoSa5Q3xth/IkFmCncwONM4Z5?= =?utf-8?q?RCqkknympoCICO7xHuZ4k9blXZPIBU/Hn//rjLuEO5OU7D8znOnMHf1RhiFbNldPs?= =?utf-8?q?IsQS8kJxisijdNk6e5F9kFZJxANwrR1wIp+r702SCkR9qWBcwA0ZbBOU2FihTB1WJ?= =?utf-8?q?BhyHOZdnMMACkKNkhCuyVlKW70zSGivZDetmkZEcGgFsMDKUaqQjW3eAubW39C82j?= =?utf-8?q?jLX4x6HIE8sOD5TsbV2hRfqvwzGEhBgHaPCxctTQNqO3SGcagDJEX1cCI1ztvFfGI?= =?utf-8?q?9QprC1moctzkikKN6mMwrSJMixU5Pu3VM1575aINFJMAYvLd5m1XJfkuoYnoY0E2t?= =?utf-8?q?IQZStolI1tm?= 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)(52116014)(7416014)(376014)(1800799024)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?ykfXTGKDQqZ6HSr8O7piqxXYb+T/?= =?utf-8?q?au3ocnAf+RxTRFT0IM+HCtRy9YeUvCKQr51j+iLzw2Gvx5p4azoWWwX00NvG70taI?= =?utf-8?q?mPy0c8QUVRIRUHRGp+R5J5G0UvypJxk+Z+L1Fmqoc+UTLFriP0CIwVhZmtHQ2b0Aj?= =?utf-8?q?C0caeBqFsn/QhytqqS5oZcZwXqij7LrnZUvGhHCPreNLlRxb9qtm9o6dFdz8SG9G/?= =?utf-8?q?xE2QzoJQHuXoq00+VGG0GhRIAE/ZWX/8Wgi31/CjCUrzYnt6GgMaiQY/OCgwOmEkv?= =?utf-8?q?dyRmq4KNPo852KB8vhNNZ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bblizwfOglQNllRD+rAA57phD5MJAaFnAeuZsTfH8t+wj1Cq?= =?utf-8?q?jhJlGJRIY4Lhu0MWTktyX0j6oYCSqkT22s4/SumtDXnGjoFUazG2XLFnnb/Mp78r+?= =?utf-8?q?zN8efQN6qH6mqzczESFQQM/5Zh6b0W+XPFaybdjMlHxkjHaFqO/bykeSkOXa0guVX?= =?utf-8?q?KzLpHFYufmN6kudTtE/tWgAEPguzOYmhTY0QNKGAt4Wta0POmSuFCibFv7+3WJ71O?= =?utf-8?q?kNEGiqs1phnvlVycpYfsOue6icJtzUEEWkZQNyEGJvrun3EByHDlUu8UPo0MHK2Ls?= =?utf-8?q?IqMOjntWgLsKgK9nmM3NCzjmF01+8kBoamtRDYx4JzIm+uGDQ1C4USu/R7TImOO7G?= =?utf-8?q?MeCceXf65y78?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: f6c0e95f-7f16-4939-2912-08dd20390e47 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8459.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Dec 2024 14:25:58.2211 (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: SmcbndP4NUsvLV0xyPzYT2Ibmc4R19T4i0BhjRlUCBT8raGkDq8BkrYHdHN2WCL8qrJBSdCRu2uqC9qB7AFtKA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8950 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241219_062600_231161_6710CB95 X-CRM114-Status: GOOD ( 19.88 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Peng Fan i.MX9 OCOTP supports a specific peripheral or function being fused which means disabled, so - Introduce ocotp_access_gates to be container of efuse gate info - Iterate each node under '/soc' to check accessing permission. If not allowed to be accessed, detach the node Signed-off-by: Peng Fan --- drivers/nvmem/imx-ocotp-ele.c | 183 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 182 insertions(+), 1 deletion(-) diff --git a/drivers/nvmem/imx-ocotp-ele.c b/drivers/nvmem/imx-ocotp-ele.c index ca6dd71d8a2e29888c6e556aaea116c1a967cb5f..173863b1fd7de150576b78f03c256a151b174389 100644 --- a/drivers/nvmem/imx-ocotp-ele.c +++ b/drivers/nvmem/imx-ocotp-ele.c @@ -5,6 +5,8 @@ * Copyright 2023 NXP */ +#include +#include #include #include #include @@ -27,6 +29,7 @@ struct ocotp_map_entry { }; struct ocotp_devtype_data { + const struct ocotp_access_gates *access_gates; u32 reg_off; char *name; u32 size; @@ -36,11 +39,26 @@ struct ocotp_devtype_data { struct ocotp_map_entry entry[]; }; +#define OCOTP_MAX_NUM_GATE_WORDS 4 +#define IMX93_OCOTP_NUM_GATES 17 +#define IMX95_OCOTP_NUM_GATES 36 + +struct ocotp_access_gates { + u32 num_words; + u32 words[OCOTP_MAX_NUM_GATE_WORDS]; + u32 num_gates; + struct access_gate { + u32 word; + u32 mask; + } gates[]; +}; + struct imx_ocotp_priv { struct device *dev; void __iomem *base; struct nvmem_config config; struct mutex lock; + u32 value[OCOTP_MAX_NUM_GATE_WORDS]; const struct ocotp_devtype_data *data; }; @@ -131,6 +149,96 @@ static void imx_ocotp_fixup_dt_cell_info(struct nvmem_device *nvmem, cell->read_post_process = imx_ocotp_cell_pp; } +static int imx_ele_ocotp_check_access(struct platform_device *pdev, u32 id) +{ + struct imx_ocotp_priv *priv = platform_get_drvdata(pdev); + const struct ocotp_access_gates *access_gates = priv->data->access_gates; + u32 word, mask; + + if (id >= access_gates->num_gates) { + dev_err(&pdev->dev, "Index %d too large\n", id); + return -EACCES; + } + + word = access_gates->gates[id].word; + mask = access_gates->gates[id].mask; + + dev_dbg(&pdev->dev, "id:%d word:%d mask:0x%08x\n", id, word, mask); + /* true means not allow access */ + if (priv->value[word] & mask) + return -EACCES; + + return 0; +} + +static int imx_ele_ocotp_grant_access(struct platform_device *pdev, struct device_node *parent) +{ + struct device *dev = &pdev->dev; + + for_each_available_child_of_node_scoped(parent, child) { + struct of_phandle_iterator it; + int err; + u32 id; + + of_for_each_phandle(&it, err, child, "access-controllers", + "#access-controller-cells", 0) { + struct of_phandle_args provider_args; + struct device_node *provider = it.node; + + if (err) { + dev_err(dev, "Unable to get access-controllers property for node %s\n, err: %d", + child->full_name, err); + of_node_put(provider); + return err; + } + + /* Only support one cell */ + if (of_phandle_iterator_args(&it, provider_args.args, 1) != 1) { + dev_err(dev, "wrong args count\n"); + return -EINVAL; + } + + id = provider_args.args[0]; + + dev_dbg(dev, "Checking node: %s gate: %d\n", child->full_name, id); + + if (imx_ele_ocotp_check_access(pdev, id)) { + of_detach_node(child); + dev_err(dev, "%s: Not granted, device driver will not be probed\n", + child->full_name); + } + } + + imx_ele_ocotp_grant_access(pdev, child); + } + + return 0; +} + +static int imx_ele_ocotp_access_control(struct platform_device *pdev) +{ + struct imx_ocotp_priv *priv = platform_get_drvdata(pdev); + struct device_node *root __free(device_node) = of_find_node_by_path("/"); + const struct ocotp_access_gates *access_gates = priv->data->access_gates; + void __iomem *reg = priv->base + priv->data->reg_off; + u32 off; + int i; + + if (!priv->data->access_gates) + return 0; + + /* This should never happen */ + WARN_ON(!root); + + for (i = 0; i < access_gates->num_words; i++) { + off = access_gates->words[i] << 2; + priv->value[i] = readl(reg + off); + dev_dbg(&pdev->dev, "word:%d 0x%08x\n", access_gates->words[i], priv->value[i]); + } + + return imx_ele_ocotp_grant_access(pdev, root); +} + static int imx_ele_ocotp_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -161,14 +269,43 @@ static int imx_ele_ocotp_probe(struct platform_device *pdev) priv->config.fixup_dt_cell_info = imx_ocotp_fixup_dt_cell_info; mutex_init(&priv->lock); + platform_set_drvdata(pdev, priv); + nvmem = devm_nvmem_register(dev, &priv->config); if (IS_ERR(nvmem)) return PTR_ERR(nvmem); - return 0; + + return imx_ele_ocotp_access_control(pdev); } +static const struct ocotp_access_gates imx93_access_gates = { + .num_words = 3, + .words = {19, 20, 21}, + .num_gates = IMX93_OCOTP_NUM_GATES, + .gates = { + [IMX93_OCOTP_NPU_GATE] = { .word = 19, .mask = BIT(13) }, + [IMX93_OCOTP_A550_GATE] = { .word = 19, .mask = BIT(14) }, + [IMX93_OCOTP_A551_GATE] = { .word = 19, .mask = BIT(15) }, + [IMX93_OCOTP_M33_GATE] = { .word = 19, .mask = BIT(24) }, + [IMX93_OCOTP_CAN1_FD_GATE] = { .word = 19, .mask = BIT(28) }, + [IMX93_OCOTP_CAN2_FD_GATE] = { .word = 19, .mask = BIT(29) }, + [IMX93_OCOTP_CAN1_GATE] = { .word = 19, .mask = BIT(30) }, + [IMX93_OCOTP_CAN2_GATE] = { .word = 19, .mask = BIT(31) }, + [IMX93_OCOTP_USB1_GATE] = { .word = 20, .mask = BIT(3) }, + [IMX93_OCOTP_USB2_GATE] = { .word = 20, .mask = BIT(4) }, + [IMX93_OCOTP_ENET1_GATE] = { .word = 20, .mask = BIT(5) }, + [IMX93_OCOTP_ENET2_GATE] = { .word = 20, .mask = BIT(6) }, + [IMX93_OCOTP_PXP_GATE] = { .word = 20, .mask = BIT(10) }, + [IMX93_OCOTP_MIPI_CSI1_GATE] = { .word = 20, .mask = BIT(17) }, + [IMX93_OCOTP_MIPI_DSI1_GATE] = { .word = 20, .mask = BIT(19) }, + [IMX93_OCOTP_LVDS1_GATE] = { .word = 20, .mask = BIT(24) }, + [IMX93_OCOTP_ADC1_GATE] = { .word = 21, .mask = BIT(7) }, + }, +}; + static const struct ocotp_devtype_data imx93_ocotp_data = { + .access_gates = &imx93_access_gates, .reg_off = 0x8000, .reg_read = imx_ocotp_reg_read, .size = 2048, @@ -183,7 +320,51 @@ static const struct ocotp_devtype_data imx93_ocotp_data = { }, }; +static const struct ocotp_access_gates imx95_access_gates = { + .num_words = 3, + .words = {17, 18, 19}, + .num_gates = IMX95_OCOTP_NUM_GATES, + .gates = { + [IMX95_OCOTP_CANFD1_GATE] = { .word = 17, .mask = BIT(20) }, + [IMX95_OCOTP_CANFD2_GATE] = { .word = 17, .mask = BIT(21) }, + [IMX95_OCOTP_CANFD3_GATE] = { .word = 17, .mask = BIT(22) }, + [IMX95_OCOTP_CANFD4_GATE] = { .word = 17, .mask = BIT(23) }, + [IMX95_OCOTP_CANFD5_GATE] = { .word = 17, .mask = BIT(24) }, + [IMX95_OCOTP_CAN1_GATE] = { .word = 17, .mask = BIT(25) }, + [IMX95_OCOTP_CAN2_GATE] = { .word = 17, .mask = BIT(26) }, + [IMX95_OCOTP_CAN3_GATE] = { .word = 17, .mask = BIT(27) }, + [IMX95_OCOTP_CAN4_GATE] = { .word = 17, .mask = BIT(28) }, + [IMX95_OCOTP_CAN5_GATE] = { .word = 17, .mask = BIT(29) }, + [IMX95_OCOTP_NPU_GATE] = { .word = 18, .mask = BIT(0) }, + [IMX95_OCOTP_A550_GATE] = { .word = 18, .mask = BIT(1) }, + [IMX95_OCOTP_A551_GATE] = { .word = 18, .mask = BIT(2) }, + [IMX95_OCOTP_A552_GATE] = { .word = 18, .mask = BIT(3) }, + [IMX95_OCOTP_A553_GATE] = { .word = 18, .mask = BIT(4) }, + [IMX95_OCOTP_A554_GATE] = { .word = 18, .mask = BIT(5) }, + [IMX95_OCOTP_A555_GATE] = { .word = 18, .mask = BIT(6) }, + [IMX95_OCOTP_M7_GATE] = { .word = 18, .mask = BIT(9) }, + [IMX95_OCOTP_DCSS_GATE] = { .word = 18, .mask = BIT(22) }, + [IMX95_OCOTP_LVDS1_GATE] = { .word = 18, .mask = BIT(27) }, + [IMX95_OCOTP_ISP_GATE] = { .word = 18, .mask = BIT(29) }, + [IMX95_OCOTP_USB1_GATE] = { .word = 19, .mask = BIT(2) }, + [IMX95_OCOTP_USB2_GATE] = { .word = 19, .mask = BIT(3) }, + [IMX95_OCOTP_NETC_GATE] = { .word = 19, .mask = BIT(4) }, + [IMX95_OCOTP_PCIE1_GATE] = { .word = 19, .mask = BIT(6) }, + [IMX95_OCOTP_PCIE2_GATE] = { .word = 19, .mask = BIT(7) }, + [IMX95_OCOTP_ADC1_GATE] = { .word = 19, .mask = BIT(8) }, + [IMX95_OCOTP_EARC_RX_GATE] = { .word = 19, .mask = BIT(11) }, + [IMX95_OCOTP_GPU3D_GATE] = { .word = 19, .mask = BIT(16) }, + [IMX95_OCOTP_VPU_GATE] = { .word = 19, .mask = BIT(17) }, + [IMX95_OCOTP_JPEG_ENC_GATE] = { .word = 19, .mask = BIT(18) }, + [IMX95_OCOTP_JPEG_DEC_GATE] = { .word = 19, .mask = BIT(19) }, + [IMX95_OCOTP_MIPI_CSI1_GATE] = { .word = 19, .mask = BIT(21) }, + [IMX95_OCOTP_MIPI_CSI2_GATE] = { .word = 19, .mask = BIT(22) }, + [IMX95_OCOTP_MIPI_DSI1_GATE] = { .word = 19, .mask = BIT(23) }, + } +}; + static const struct ocotp_devtype_data imx95_ocotp_data = { + .access_gates = &imx95_access_gates, .reg_off = 0x8000, .reg_read = imx_ocotp_reg_read, .size = 2048,