Thread (12 messages) 12 messages, 3 authors, 2025-01-16

RE: [PATCH v5 2/2] nvmem: imx-ocotp-ele: Support accessing controller for i.MX9

From: Peng Fan <peng.fan@nxp.com>
Date: 2025-01-11 12:42:00
Also in: imx, linux-arm-kernel, lkml

Subject: Re: [PATCH v5 2/2] nvmem: imx-ocotp-ele: Support accessing
controller for i.MX9

Hi,

Am Donnerstag, 9. Januar 2025, 04:34:18 CET schrieb Peng Fan:
quoted
On Wed, Jan 08, 2025 at 11:15:40AM +0100, Alexander Stein wrote:
quoted
Hi Peng,

Am Mittwoch, 8. Januar 2025, 08:00:18 CET schrieb Peng Fan (OSS):
quoted
From: Peng Fan <peng.fan@nxp.com>

i.MX9 OCOTP supports a specific peripheral or function being
fused
quoted
quoted
quoted
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 <peng.fan@nxp.com>
---
 drivers/nvmem/imx-ocotp-ele.c | 172
+++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 171 insertions(+), 1 deletion(-)
[....]
quoted
quoted
+
+	return imx_ele_ocotp_access_control(priv);
In [1] you mentioned devlink should solve the probe order. How
does
quoted
quoted
this play when the driver is compiled in (e.g. ethernet for NFS boot)
but this OCOTP driver is just a module?
OCOTP needs to built in for using devlink. Or the users needs to be
built as module.
I don't like this kind of assumption. Would it make more sense to make
CONFIG_NVMEM_IMX_OCOTP_ELE as bool instead of tristate?
No. Users could setup their own system with this driver build in
or built related drivers as modules.

At least for Android GKI, this driver needs to be as module.

Thanks,
Peng.
quoted
quoted
I'm not well versed with devlink, but is
quoted
access-controllers = <&ocotp IMX93_OCOTP_ENET1_GATE>;
already enough to create that link?
Yes, the drivers/of/property.c has this
"DEFINE_SIMPLE_PROP(access_controllers, "access-controllers",
"#access-controller-cells")"
quoted
The fw_devlink driver will create consumer/supplier to make sure
proper order.
Okay, thanks for confirming.

Best regards,
Alexander
quoted
Regards,
Peng
quoted
Best regards,
Alexander
quoted
 }

+struct access_gate imx93_access_gate[] = {
+		[IMX93_OCOTP_NPU_GATE]		= { .word =
19, .mask = BIT(13) },
quoted
quoted
quoted
+		[IMX93_OCOTP_A550_GATE]		= { .word =
19, .mask = BIT(14) },
quoted
quoted
quoted
+		[IMX93_OCOTP_A551_GATE]		= { .word =
19, .mask = BIT(15) },
quoted
quoted
quoted
+		[IMX93_OCOTP_M33_GATE]		= { .word =
19, .mask = BIT(24) },
quoted
quoted
quoted
+		[IMX93_OCOTP_CAN1_FD_GATE]	= { .word =
19, .mask = BIT(28) },
quoted
quoted
quoted
+		[IMX93_OCOTP_CAN2_FD_GATE]	= { .word =
19, .mask = BIT(29) },
quoted
quoted
quoted
+		[IMX93_OCOTP_CAN1_GATE]		= { .word =
19, .mask = BIT(30) },
quoted
quoted
quoted
+		[IMX93_OCOTP_CAN2_GATE]		= { .word =
19, .mask = BIT(31) },
quoted
quoted
quoted
+		[IMX93_OCOTP_USB1_GATE]		= { .word =
20, .mask = BIT(3) },
quoted
quoted
quoted
+		[IMX93_OCOTP_USB2_GATE]		= { .word =
20, .mask = BIT(4) },
quoted
quoted
quoted
+		[IMX93_OCOTP_ENET1_GATE]	= { .word =
20, .mask = BIT(5) },
quoted
quoted
quoted
+		[IMX93_OCOTP_ENET2_GATE]	= { .word =
20, .mask = BIT(6) },
quoted
quoted
quoted
+		[IMX93_OCOTP_PXP_GATE]		= { .word =
20, .mask = BIT(10) },
quoted
quoted
quoted
+		[IMX93_OCOTP_MIPI_CSI1_GATE]	= { .word =
20, .mask = BIT(17) },
quoted
quoted
quoted
+		[IMX93_OCOTP_MIPI_DSI1_GATE]	= { .word =
20, .mask = BIT(19) },
quoted
quoted
quoted
+		[IMX93_OCOTP_LVDS1_GATE]	= { .word =
20, .mask = BIT(24) },
quoted
quoted
quoted
+		[IMX93_OCOTP_ADC1_GATE]		= { .word =
21, .mask = BIT(7) },
quoted
quoted
quoted
+};
+
+static const struct ocotp_access_gates imx93_access_gates_info =
{
quoted
quoted
quoted
+	.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 = {
quoted
quoted
quoted
 	},
 };

+struct access_gate imx95_access_gate[] = {
+		[IMX95_OCOTP_CANFD1_GATE]	= { .word =
17, .mask = BIT(20) },
quoted
quoted
quoted
+		[IMX95_OCOTP_CANFD2_GATE]	= { .word =
17, .mask = BIT(21) },
quoted
quoted
quoted
+		[IMX95_OCOTP_CANFD3_GATE]	= { .word =
17, .mask = BIT(22) },
quoted
quoted
quoted
+		[IMX95_OCOTP_CANFD4_GATE]	= { .word =
17, .mask = BIT(23) },
quoted
quoted
quoted
+		[IMX95_OCOTP_CANFD5_GATE]	= { .word =
17, .mask = BIT(24) },
quoted
quoted
quoted
+		[IMX95_OCOTP_CAN1_GATE]		= { .word =
17, .mask = BIT(25) },
quoted
quoted
quoted
+		[IMX95_OCOTP_CAN2_GATE]		= { .word =
17, .mask = BIT(26) },
quoted
quoted
quoted
+		[IMX95_OCOTP_CAN3_GATE]		= { .word =
17, .mask = BIT(27) },
quoted
quoted
quoted
+		[IMX95_OCOTP_CAN4_GATE]		= { .word =
17, .mask = BIT(28) },
quoted
quoted
quoted
+		[IMX95_OCOTP_CAN5_GATE]		= { .word =
17, .mask = BIT(29) },
quoted
quoted
quoted
+		[IMX95_OCOTP_NPU_GATE]		= { .word =
18, .mask = BIT(0) },
quoted
quoted
quoted
+		[IMX95_OCOTP_A550_GATE]		= { .word =
18, .mask = BIT(1) },
quoted
quoted
quoted
+		[IMX95_OCOTP_A551_GATE]		= { .word =
18, .mask = BIT(2) },
quoted
quoted
quoted
+		[IMX95_OCOTP_A552_GATE]		= { .word =
18, .mask = BIT(3) },
quoted
quoted
quoted
+		[IMX95_OCOTP_A553_GATE]		= { .word =
18, .mask = BIT(4) },
quoted
quoted
quoted
+		[IMX95_OCOTP_A554_GATE]		= { .word =
18, .mask = BIT(5) },
quoted
quoted
quoted
+		[IMX95_OCOTP_A555_GATE]		= { .word =
18, .mask = BIT(6) },
quoted
quoted
quoted
+		[IMX95_OCOTP_M7_GATE]		= { .word =
18, .mask = BIT(9) },
quoted
quoted
quoted
+		[IMX95_OCOTP_DCSS_GATE]		= { .word =
18, .mask = BIT(22) },
quoted
quoted
quoted
+		[IMX95_OCOTP_LVDS1_GATE]	= { .word =
18, .mask = BIT(27) },
quoted
quoted
quoted
+		[IMX95_OCOTP_ISP_GATE]		= { .word =
18, .mask = BIT(29) },
quoted
quoted
quoted
+		[IMX95_OCOTP_USB1_GATE]		= { .word =
19, .mask = BIT(2) },
quoted
quoted
quoted
+		[IMX95_OCOTP_USB2_GATE]		= { .word =
19, .mask = BIT(3) },
quoted
quoted
quoted
+		[IMX95_OCOTP_NETC_GATE]		= { .word =
19, .mask = BIT(4) },
quoted
quoted
quoted
+		[IMX95_OCOTP_PCIE1_GATE]	= { .word =
19, .mask = BIT(6) },
quoted
quoted
quoted
+		[IMX95_OCOTP_PCIE2_GATE]	= { .word =
19, .mask = BIT(7) },
quoted
quoted
quoted
+		[IMX95_OCOTP_ADC1_GATE]		= { .word =
19, .mask = BIT(8) },
quoted
quoted
quoted
+		[IMX95_OCOTP_EARC_RX_GATE]	= { .word =
19, .mask = BIT(11) },
quoted
quoted
quoted
+		[IMX95_OCOTP_GPU3D_GATE]	= { .word =
19, .mask = BIT(16) },
quoted
quoted
quoted
+		[IMX95_OCOTP_VPU_GATE]		= { .word =
19, .mask = BIT(17) },
quoted
quoted
quoted
+		[IMX95_OCOTP_JPEG_ENC_GATE]	= { .word =
19, .mask = BIT(18) },
quoted
quoted
quoted
+		[IMX95_OCOTP_JPEG_DEC_GATE]	= { .word =
19, .mask = BIT(19) },
quoted
quoted
quoted
+		[IMX95_OCOTP_MIPI_CSI1_GATE]	= { .word =
19, .mask = BIT(21) },
quoted
quoted
quoted
+		[IMX95_OCOTP_MIPI_CSI2_GATE]	= { .word =
19, .mask = BIT(22) },
quoted
quoted
quoted
+		[IMX95_OCOTP_MIPI_DSI1_GATE]	= { .word =
19, .mask = BIT(23) },
quoted
quoted
quoted
+};
+
+static const struct ocotp_access_gates imx95_access_gates_info =
{
quoted
quoted
quoted
+	.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,

--
TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld,
Germany Amtsgericht München, HRB 105018
Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider
https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2F
www.tq-
group.com%2F&data=05%7C02%7Cpeng.fan%40nxp.com%7C55d61ee
fd50749808d4a08dd3099320d%7C686ea1d3bc2b4c6fa92cd99c5c301
635%7C0%7C0%7C638720156723988367%7CUnknown%7CTWFpbGZ
sb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW
4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=
%2BCsoNoGLNpZiltu%2BMD%2BUCMAwHcmXCL0LKVq9olfSIoU%3D&r
eserved=0
  
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help