From patchwork Tue Jan 21 15:05:31 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: 13946406 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 04CDDC02182 for ; Tue, 21 Jan 2025 15:09:22 +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=2FLuY1ABhGylovDLLw+c0IFOe/ 4035JAwpqnL77texkOCOYmJHLsgLRCjcoSUmidkhKoq3Q+/Hpa7fKww9R/d0IqBKevR2+ZyN85ylm ClHwF+nO3IbmqdhwmBsB7GXZg80VmQSCT/88YYB+UlMY850EkQN4F87PLkpF2acfYd3bHVYbd63r8 m6ctRf9cBR7qicV2g/eJbxFGfjFt6XreJzr0AN5CWP7rgan96SFjw1EQk0maEGr9cFhREEqTAkmwO dN8T/lyoMDKmFo8yOlDpcoodySv/mSf8j7Pdqfemh5Xt7CWXZ61JIsua5V97MuD32d3m/VyMsCqEo fWGhR15A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1taFsL-00000008Aq8-3Ek0; Tue, 21 Jan 2025 15:09:09 +0000 Received: from mail-am7eur03on20614.outbound.protection.outlook.com ([2a01:111:f403:260e::614] helo=EUR03-AM7-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1taFpn-000000089ss-077h for linux-arm-kernel@lists.infradead.org; Tue, 21 Jan 2025 15:06:32 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=YuiY0kd/z1m7nqtODwEQE0e/S+JlnZN65s4KyDWpL9k7Lip7oTiItV6eKisYgowG16ETwVItJ2dPQ+1psRf0+oZO137CUsI4O7wBmc0/NQdZkQ+aeVRUWJvrmEQ7xbkPC5MW0Z24YH7l/7cNNaq6KSwWwqvraBus9euJE24k62Hd4LenOP67vtU7PzU5tRJNmkCo1DEsEO2G+Y20EyX/o3WFAVaqKiFJi/tn0nRPzwywQzMXxYUX1YQHSv6m2411UxMefQ1UehMHZe286RJpw14Hp/EdjjfRW+HtHz8Yen7qFNjzK7D9hoeSIFhYQSWh02g1BlYhqMawW3E7NYxOVA== 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=jZt0yThwbJmQiuoGMGmzxVoOm5NRoK4FYEDxzerufMfXByj7HE0umVNHBGyWxqxz2iQ1up8CkPhTaEHrwLrINbTNM0gkUOvG4IEnuAfzzjr0JxO90JerxoPUPftb4ks3+L233klA/9rJsQgY/0D0+lqRksA7rwYK4CIkTRvj5GiF9JsQPBVddYeq0pbSZgjMjJvok0OtxVb006uobIoMApYRftTMvXfWul3PsEkgvJx7mEkvU59PU6nZp3/2aSQZlUrH/lvG5N/NhlF+0y3qpQkbzS7Fhm5pAJ4cN4oCANAz6HcBuxF4PzazUc5876BEdvvC11YtRFjRh2xbF2YLog== 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=exQMF9vXmyNVAC5UvYcI2a0VWcKay8FP6olgOAVLh2Nrj7njSHcikHLs6Bztzm4YEbf9I7rZq23+UkyQi65oDHmyNiMQS20Nmq4ACgsGkY24JYfuvQM+hvkNpCA2spi1Y5w6eHNYmsqBFpxqbuZ0IiIwqvcLXLYnDo4p5Eq9Iqwcf5DjoKyFmtY5IFubPEoogHWtcTRgNy8uE7b2Zum7r7pnbQjV5CIFzLKFPfHF/QSUmbQ1wlWxQ7Lxv7einHLzMAJDYyOBbX4eFRzDTMJi2jSYWY1ntFnKojY+fVvxQn3W4vWqAeWcX/IbVN0ylxIUy19xw3TtvfgvRGJVwHex8Q== 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:25 +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:25 +0000 From: "Peng Fan (OSS)" Date: Tue, 21 Jan 2025 23:05:31 +0800 Subject: [PATCH v6 1/2] dt-bindings: nvmem: imx-ocotp: Introduce #access-controller-cells Message-Id: <20250121-imx-ocotp-v6-1-76dab40e13db@nxp.com> References: <20250121-imx-ocotp-v6-0-76dab40e13db@nxp.com> In-Reply-To: <20250121-imx-ocotp-v6-0-76dab40e13db@nxp.com> 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=4068; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=4MXzYq4oLyYtlA95EQap1UQZ2xOM248M5j3t6NvUUFI=; b=hirbKyc9oP13CRXY8HY82fHLvdWKWL9zBq0DZ6ihd1ndlJr7JRTan9n2fB9wHYjAZjJZnAZgB sFK4SG/khzPBD30f+L2MOjB8dz0NG73FxxbH0lfnNMw/TvGwKHqafg0 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) 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: 16e557e8-d7fc-4328-eb35-08dd3a2d2c7f 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?VP6Er5eOGuqkGhQiW0RdEYhizFAl1oA?= =?utf-8?q?dT7nbbMAjit+G/ZAGoMkYbsR2DIQJAdq4dshKoXziFiThUTPOPu4mIvYkoV8Yseuv?= =?utf-8?q?kOoZPBYBeZ9ierDoQU2GAsp9QIymMLZYJ3B4ly4vhWsUF9zbA+eoRIFvUKHKwywvu?= =?utf-8?q?XmDw0JCGKk22Xk9X7Zr0wY/DevNsXijTf4cEcq9TzBizHWEpg3lCClorz7KnX+Uie?= =?utf-8?q?xv3UiNwy9YJDIh3raJqoKhHSsGLjQb/KgUgWu/tJoFzndWA0Vje+U5NYDrZowSYOs?= =?utf-8?q?tXkAPXzMVONIKO0Dfom39FVH4OAT0SrmTAQg2pMcgwqLMJ6uWU4+xl7uXqmN8vJw/?= =?utf-8?q?/NQQ8jkSS377yNhOS7N1NzWUwncTR8GuOE0cJW2z2Pd0HNiLSM/aJZp5A4aFawARX?= =?utf-8?q?09h1CCUgFAvjzIDiQ/FrDT081UmdQqgD4f3wkJIQJK99ZgB2uG/AGg2oHkfnpqJw5?= =?utf-8?q?0ahpL7FHzqkIowokjPYGTwT7k0nW394oCBLpbx+yJxltuj2JcvC9ZB2Tll7eGnQcO?= =?utf-8?q?mEGfJJmJ/6sKP8WUyaoUq/ZvNnyL0yTR09dRqTvhT+a7MLcU8dDsaIAHnCqPrQEcA?= =?utf-8?q?hmCGxnQMTf/WtgYqK7VlqcIkwbxVUbFWnr5a3NWAmZBOXkLQF4rCnSzFuYhnobKdE?= =?utf-8?q?vXo/xOSRfQ/WdIgnhT652LmmUsKWhut4F8EvUS1S0w8BSVklNsxjvmNzVfZJKuK8v?= =?utf-8?q?dNEJDjkZl6sRNdHV726EjeNl1HC2H/d1VoGtFk/tLwne8yEu8dOyLrgpSHKI0NTfG?= =?utf-8?q?7T8ewB6odwKNm2PweoPMH9cyor3Oxwi7XRXnzEgG7gFujgy2YeSI+HtgHNmXP80oL?= =?utf-8?q?r0gAywulVn6NfttK5oPn2N5lDr38dYhCA9sOQupEnfqaDRzZvCeLWMzmLouUkX1Vj?= =?utf-8?q?HPDlM0oidL+yhyp9TW2ZqUjlF5MHMsB0fgu/fUOSmajfrQLmJzTbcDjfQ6Xn6gvVW?= =?utf-8?q?Nta7985IVmrzXs5y+WTIJU8gawu+w0wJ25PQfKJyS/a7qFpARDh7sl5YJ8tq5BjDu?= =?utf-8?q?gGueIBul+osY1BpDU4Uje5M2uIqjL/VqKMYnibWuhqNnTGW07XpZNIvnAjpK/6bIB?= =?utf-8?q?G+LD6+YK6/hJ+KWDl2EXg/4YF86cFfdvS5wvBCkkXIyDP/7qV6VH1Xj04geBlIQWg?= =?utf-8?q?KgJm8UoIgJRytO5YL85M8g1FBY4GIfxTMyLPT8KY2M9p7x5USjL1n1iQsfgQlMWYm?= =?utf-8?q?MvQaMkT5VXAYdK/ngRR/eIMjhTEdmNdNZ22aiqwtsb2LkKaW0p+jjVvuOkiakGR83?= =?utf-8?q?YxW1pazMvW3IWcAnP2x8oYpvPCeeU1r1ec/afGk1R0sZpOy90OkcbWNEnqtvHS2AO?= =?utf-8?q?8bjCx/IO5T6zdAzQZRqN6m49WtNsbQo+OMBXpyNJ0Z0LBmGQwpsG6xkr+dSMEcJ6/?= =?utf-8?q?njAGJpkcRv6?= 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?4P/otC4GhKUlgRC5Em/cGwb12wwQ?= =?utf-8?q?U+BtH9i5anJ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6ATAXHHO8+ocVYD+/YM452IkUPWOvH/kdNufrSkukVb?= =?utf-8?q?oirR0FOTRGdpJhIuf7SaMVhlhHIuhzzQ7e2tgehTqhhKYkbbmN3qdTiu9yzSVCu1u?= =?utf-8?q?4cVDKEm5T6qsbvlusdDjgCkcEsRK1UWHqlV95W2L19bXdgOVFDTKEqU0xP/K5AXvx?= =?utf-8?q?IZoQglwqilbU6HUnwfV13LSfo8gsyv6tPqtVFAG3c/aKonyNC1C4PWjSAEUv/b2B+?= =?utf-8?q?lQUO0pfb3JlXquSRhGXPxfjKtrJM7MNXhEIJgDbIJxtW6+coaHVGaY/oyrqNlt+DI?= =?utf-8?q?jwIBHYJ9h4ddvAM4f0LkwdaQphUsWQc8b6fqdVj2VqcDwxNCEjV/FdlDKwViw0yw0?= =?utf-8?q?7apN+PkKGLwdGzFZN1jyycP1d2urez899nEiWPPnbKaUmmFJO+E4TlvgoTe69c9xT?= =?utf-8?q?ZLya/gSuf1dtNOMIFTrXOCDI7LNkndXHCjZseGG13F2G8ML997Yi+mfmbu36J3xme?= =?utf-8?q?obwcIHGSBqxPNLkkpP1OMsOOX7csiPhNlg0Zt9DaumJCmIvYpYvX+PSNFKkQM3VRX?= =?utf-8?q?ceHl1BCtiWzoEtzZN5ytDXaHj7oNVDywAFqaxtMeQ09Q8mWqSm6dUbzayM+MJ6gT+?= =?utf-8?q?b735p/zxWxDS?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 16e557e8-d7fc-4328-eb35-08dd3a2d2c7f 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:25.3015 (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: TM70L4F6wJM6FWdoHGf3+R3xctCqx5R2KJDGk3fLvOchchCUOrwFjpEcZCxRmMccYYeQCc7Dq81sAE53+IbBfg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR04MB9295 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250121_070631_075766_7A6C1911 X-CRM114-Status: GOOD ( 11.92 ) 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 Tue Jan 21 15:05:32 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: 13946409 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 4DA90C02182 for ; Tue, 21 Jan 2025 15:10:42 +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=NoQKZLTbR21LXDKQOZkJFS0OxuAVgfiu7By1xR04+6o=; b=GqTQqRZdW5R36UlXX12uTAkOnt TXlxi3EoKvIvuiyt7RGQx6yEOBnSBgaKXA3IuKG4l1e8IWJ12aOrSeT2qk8FHeAOVkItQXf+BqiUX q5EbM4cni4RaI7vg8uY+B/6KaB3hS+r2bt3OojHSPizh1imPVXlecxOjoL1yW3E+xDv5PkSFdLDhg 2AU9p4B6HVI86udK0Bx4aWIjrR2geH9rvDYmZ3NtncDojUCZ7vit8eTa3sx4YNZS9OhKKc0hom5vW MnL+1tJMMzESycstvWvcsXF2gHsJsTnOEa8JdxicFZIltbzNLFbt421y3hcW2yjBcX4UogJF61nCw PSAnIbxQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1taFtb-00000008B89-1g3u; Tue, 21 Jan 2025 15:10:27 +0000 Received: from mail-am7eur03on20614.outbound.protection.outlook.com ([2a01:111:f403:260e::614] helo=EUR03-AM7-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1taFpo-000000089ss-1vn8 for linux-arm-kernel@lists.infradead.org; Tue, 21 Jan 2025 15:06:33 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=b8YbSraPoylov2qfoux3z0HYVwqLSdyC1sxYIkyapiT2jGdroChFCStymc6Ay3rEC+RIvQKDbu++LCzExDIXnTKeBmfuDK50uRBqBgurGKTXUFKwqjCT2FUE+IdWKXwcjLhIVS4P7q8JmTNGmMdgC48U0UFPbkEUTo42vNWjIu9vt0EupK4sUXDajGUxeIiBOiNmbW1Z+S9ryeYeDDo76gaFRovGjpUbw77hy/KTPDC+h6gzseGxwTPHAV9AnfIDYa34sXzNidJUZCRuhoBb5vO+Wwewjq4R1bMDlMa/AcY5mK0zg+CZytEjKV8GnuiQtXJTAsIjVHD1Wyj7ahHUmw== 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=NoQKZLTbR21LXDKQOZkJFS0OxuAVgfiu7By1xR04+6o=; b=ZHS/dktbynqoBHVV5Kpz1gowlduG+8c003D920OdM+0EpB7Plp7/X0pfyprCbn8Y3fQ0mmguRoRppCR8qGOt3rwRn/5Z+6rsAPFqljK4aldyO0MtjDTEV1gIUSlrzFjpNT5cu4wt23Euzj0dsRrrTO9snBa2FjGIpkp8PlQcn2jUObvxXj7YTrnt37Qm3vlW+UusXNlYPx3Sa5CMMVbH5LwqHQrFjIYkLZTUCKl3aUF5NYIfQ2FvHnZmt8451NaCkRTgQ1OeuglHYhNJj34H7qNyT4PzrY3bNTMzArZE4ggbQsYx9zoxlPNJLrbWT7XTgfhyvNpUxXh46cM2gFs4YQ== 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=NoQKZLTbR21LXDKQOZkJFS0OxuAVgfiu7By1xR04+6o=; b=QcXkqu0KH3ZjF1w3jPSxAbszqUeG/wDwlvAC2XhK4W4TwM6xSA3o5hufzI7uEoD6ruFp8xpYjjJoFqhB6GQpeD6VeH8SOqJtpuTLqZ9Vl60InYdQzqRG3CckxWw090wietcO/qWKa0d525QvPvE1qcajaNPsPKKPeaAWh9tliUnzZlMgNMTFrLc7MO0tB1dK1Wu8AMOeh3sggKPDVitw6LSrFjTGmQw+CvrO7Hgw7WPrX8TUd1SDbTxDboievEE2myiQvgwGfqhNqncA04/hGWAhPQv3N/mE9ERlPeIdqWuQZ+t+CBWL4cv9GJOGeNuNaRoZWRiwlDv8OAckwsbeJQ== 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:29 +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:29 +0000 From: "Peng Fan (OSS)" Date: Tue, 21 Jan 2025 23:05:32 +0800 Subject: [PATCH v6 2/2] nvmem: imx-ocotp-ele: Support accessing controller for i.MX9 Message-Id: <20250121-imx-ocotp-v6-2-76dab40e13db@nxp.com> References: <20250121-imx-ocotp-v6-0-76dab40e13db@nxp.com> In-Reply-To: <20250121-imx-ocotp-v6-0-76dab40e13db@nxp.com> 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 X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1737471947; l=9107; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=CivJ/dkdlR5J1G+iH4A3XJvFEDAAqKsxHI1c3/ElmTs=; b=SsBVfTKKOGj176E2OCm+mHDfNvXfve/XjphphhZExNWdiH+oeCH03ZHPwh3jBFJl7hWQpPHe8 XDiMVtfC22UBM/kHrr/b+0l2cKY7aiPQdBc/t9adGS8Cu10KNgwS3YH 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) 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: 59cd4115-63e6-4a70-5200-08dd3a2d2ef9 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?nJz+Oc6j+vTu6J+73mkkx5bPfoZ0gAm?= =?utf-8?q?jf4SYTQS37ga7g9tC+VD+mgARhKiL6gk705GfyJPM1KszB0yAsfnNQoW3VDCjkflv?= =?utf-8?q?XsHTpG28mp21BHs/Z7vw0qa7LyhZ0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BB9VeaoTPaZyT/eMKHyQ5Ww1kQUdS?= =?utf-8?q?hX/ei+86Doq8qF9ZROTje8Nh/HyGbFuguf1uxeu7xVCnzJ20tRAruS7yjfFBah8Dd?= =?utf-8?q?oaAHuhqYd5UAGqsX5VYbK2PsvBlWpWyWxzLiXEDwaDR6cUa6j9dUlzdxzxbEElN+o?= =?utf-8?q?DgAkeRFTPEd+o2vK4ERiF+6wTv1lTxGL3OktOkOqa1PpJwNLzcOKK9EgbpERGfOZo?= =?utf-8?q?dLCcUGCBAOxqXPT5A7A0NhgLfpFxgtIR/bdJEmgdsWdtpcDz3xunN+fsnBGuRR6Yo?= =?utf-8?q?c3YJNgGYOVcx7LE6oOPBTRP+kWB5LQk1KFVpccCU9uiARYbFoXZ4BjLV+JnVzHZer?= =?utf-8?q?QtIsJckqjvac7ni2h3ZEg4CkhexhmdZKQco7/t2FVROEmciGFv+qnxV+PICPB+K3m?= =?utf-8?q?4smLcQZtXtZ?= 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?SZ2/jGqvLas+OyVrzkDt4mPadGi5?= =?utf-8?q?gG31leH31Vo9OQ+Kq5FlCCWmc6EoR/jR2G1rkX9w4ylr3cOsfOwVct7avw/qne5kd?= =?utf-8?q?IX/ZZfAEFXx9Ydh6mqenqzbaWmWiEGqFT/06TsBs7U+JyWGHoczEJ/kp0Yk2O0Z4q?= =?utf-8?q?POuvILvuU3AR8ehdlMbmFir0mgSau4EjjkdpQirYuZ0rURaFAHjdOrzjIS1u/xRrS?= =?utf-8?q?b3XH4HEktyHmkc9MbYSZwU6aFu4KL9vppXVoepNMcBl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vwhpyOuszHAWngdDwY?= =?utf-8?q?9Uc0n3zA+3Uc6Iz77u4/Q9N5xp1LK/4A9T3nu3oDjUsEDaZhaflYF090SLntDQTgs?= =?utf-8?q?ukcp/y+yoJl9wPYcIonyCpcAhDczeX0ONGVe+pOKweyImMel5hXcLeCaXvlE75thp?= =?utf-8?q?hfBX2RCGCBFF3w+QQOjSKOApVfd5JRFuE5Rn0BoAXyg7ly6usYLxj0yGQqZogVPhT?= =?utf-8?q?qWvPS6RbdsOHfygFq9e6x53wmMvyqXkCkOCw6c4lpE2j6kOV+Yygitbj3ypurVtys?= =?utf-8?q?GMxFBfzKiV7w7W9BQErSinoNXl4t52ZtYAkiidE1a/BzjdqE4v/167bpRnTxP7fOR?= =?utf-8?q?AMu+gPLNJj+2I0KeBSr1+MzTNbDHaYkdcS6sR2vKae+6us0oSyr4B9dJDzRihWT/9?= =?utf-8?q?jdB6d54tOIID?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 59cd4115-63e6-4a70-5200-08dd3a2d2ef9 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:29.3714 (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: gdHpAzNAkA9rn+AD8vxykS+w/MfbSczv+WWzhd9BOyjZcAUSBKtBeiMmoGlHpUXulvrg7FKCtkyuvIIE7z7pHw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR04MB9295 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250121_070632_509247_803B8E08 X-CRM114-Status: GOOD ( 20.17 ) 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 all nodes to check accessing permission. If not allowed to be accessed, detach the node Signed-off-by: Peng Fan --- drivers/nvmem/Kconfig | 3 + drivers/nvmem/imx-ocotp-ele.c | 172 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 174 insertions(+), 1 deletion(-) diff --git a/drivers/nvmem/Kconfig b/drivers/nvmem/Kconfig index 8671b7c974b933e147154bb40b5d41b5730518d2..77cc496fd5e0e1afd753534b56fe1f5ef3e3ec55 100644 --- a/drivers/nvmem/Kconfig +++ b/drivers/nvmem/Kconfig @@ -93,6 +93,9 @@ config NVMEM_IMX_OCOTP_ELE This is a driver for the On-Chip OTP Controller (OCOTP) available on i.MX SoCs which has ELE. + If built as modules, any other driver relying on this working + as access controller also needs to be a module as well. + config NVMEM_IMX_OCOTP_SCU tristate "i.MX8 SCU On-Chip OTP Controller support" depends on IMX_SCU diff --git a/drivers/nvmem/imx-ocotp-ele.c b/drivers/nvmem/imx-ocotp-ele.c index ca6dd71d8a2e29888c6e556aaea116c1a967cb5f..5ea6d959ce38760eeed44a989992fb35c462c0b4 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,6 +39,20 @@ struct ocotp_devtype_data { struct ocotp_map_entry entry[]; }; +#define OCOTP_MAX_NUM_GATE_WORDS 4 + +struct access_gate { + u32 word; + u32 mask; +}; + +struct ocotp_access_gates { + u32 num_words; + u32 words[OCOTP_MAX_NUM_GATE_WORDS]; + u32 num_gates; + struct access_gate *gates; +}; + struct imx_ocotp_priv { struct device *dev; void __iomem *base; @@ -131,6 +148,82 @@ 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 imx_ocotp_priv *priv, u32 id) +{ + const struct ocotp_access_gates *access_gates = priv->data->access_gates; + void __iomem *reg = priv->base + priv->data->reg_off; + u32 word, mask, val; + + if (id >= access_gates->num_gates) { + dev_err(priv->config.dev, "Index %d too large\n", id); + return -EACCES; + } + + word = access_gates->gates[id].word; + mask = access_gates->gates[id].mask; + + reg = priv->base + priv->data->reg_off + (word << 2); + val = readl(reg); + + dev_dbg(priv->config.dev, "id:%d word:%d mask:0x%08x\n", id, word, mask); + /* true means not allow access */ + if (val & mask) + return -EACCES; + + return 0; +} + +static int imx_ele_ocotp_grant_access(struct imx_ocotp_priv *priv, struct device_node *parent) +{ + struct device *dev = priv->config.dev; + + for_each_available_child_of_node_scoped(parent, child) { + struct of_phandle_args args; + u32 id, idx = 0; + + while (!of_parse_phandle_with_args(child, "access-controllers", + "#access-controller-cells", + idx++, &args)) { + of_node_put(args.np); + if (args.np != dev->of_node) + continue; + + /* Only support one cell */ + if (args.args_count != 1) { + dev_err(dev, "wrong args count\n"); + continue; + } + + id = args.args[0]; + + dev_dbg(dev, "Checking node: %pOF gate: %d\n", child, id); + + if (imx_ele_ocotp_check_access(priv, id)) { + of_detach_node(child); + dev_info(dev, "%pOF: Not granted, device driver will not be probed\n", + child); + } + } + + imx_ele_ocotp_grant_access(priv, child); + } + + return 0; +} + +static int imx_ele_ocotp_access_control(struct imx_ocotp_priv *priv) +{ + struct device_node *root __free(device_node) = of_find_node_by_path("/"); + + if (!priv->data->access_gates) + return 0; + + /* This should never happen */ + WARN_ON(!root); + + return imx_ele_ocotp_grant_access(priv, root); +} + static int imx_ele_ocotp_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -161,14 +254,45 @@ 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(priv); } +struct access_gate imx93_access_gate[] = { + [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_access_gates imx93_access_gates_info = { + .num_words = 3, + .words = {19, 20, 21}, + .num_gates = ARRAY_SIZE(imx93_access_gate), + .gates = imx93_access_gate, +}; + static const struct ocotp_devtype_data imx93_ocotp_data = { + .access_gates = &imx93_access_gates_info, .reg_off = 0x8000, .reg_read = imx_ocotp_reg_read, .size = 2048, @@ -183,7 +307,53 @@ static const struct ocotp_devtype_data imx93_ocotp_data = { }, }; +struct access_gate imx95_access_gate[] = { + [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_access_gates imx95_access_gates_info = { + .num_words = 3, + .words = {17, 18, 19}, + .num_gates = ARRAY_SIZE(imx95_access_gate), + .gates = imx95_access_gate, +}; + static const struct ocotp_devtype_data imx95_ocotp_data = { + .access_gates = &imx95_access_gates_info, .reg_off = 0x8000, .reg_read = imx_ocotp_reg_read, .size = 2048,