Skip to contentSkip to conversation

misc: Add RZG2L OTP support

PATCH In review Mathieu Othacehe 2 participants 4 messages Apr 22 – May 5 6 messages not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 misc: Add RZG2L OTP support

Add OTP support through the fuse command. Fusing is directly performed by U-Boot, which means that the trusted-firmware must allow the non-secure world to perform fusing operations.

---
Changelog
v3: Read the OTP_BASE address from the device-tree.
v2: Depend on CMD_FUSE. Use readl_poll_sleep_timeout and clrbits_le32 functions.

 arch/arm/dts/r9a07g044-u-boot.dtsi         |  15 ++
 arch/arm/dts/r9a07g044l2-smarc-u-boot.dtsi |   6 +
 drivers/misc/Kconfig                       |   7 +
 drivers/misc/Makefile                      |   1 +
 drivers/misc/rzg2l_otp.c                   | 255 +++++++++++++++++++++
 5 files changed, 284 insertions(+)
 create mode 100644 arch/arm/dts/r9a07g044-u-boot.dtsi
 create mode 100644 arch/arm/dts/r9a07g044l2-smarc-u-boot.dtsi
 create mode 100644 drivers/misc/rzg2l_otp.c
arch/arm/dts/r9a07g044-u-boot.dtsi new file +15 -0
new file mode 100644
index 00000000000..a64ef16fa7f
@@ -0,0 +1,15 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (C) 2026 Mathieu Othacehe <[email protected]>
+ */
+
+/ {
+	soc: soc {
+		otp: otp@11860000 {
+			compatible = "renesas,r9a07g044-otp";
+			reg = <0 0x11860000 0 0x20>;
+			status = "okay";
+			bootph-all;
+		};
+	};
+};
arch/arm/dts/r9a07g044l2-smarc-u-boot.dtsi new file +6 -0
new file mode 100644
index 00000000000..5fe2e6c54a2
@@ -0,0 +1,6 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (C) 2026 Mathieu Othacehe <[email protected]>
+ */
+
+#include "r9a07g044-u-boot.dtsi"
drivers/misc/Kconfig +7 -0
index ea785793d18..324a88c9494 100644
@@ -132,6 +132,13 @@ config SPL_ROCKCHIP_IODOMAIN
 	  for the IO-domain setting of the SoC to match the voltage supplied
 	  by the regulators.
 
+config RZG2L_OTP
+	bool "Renesas RZ/G2L OTP support"
+	depends on MISC && CMD_FUSE
+	help
+	  Enable support for the OTP controller on
+	  Renesas RZ/G2L SoCs.
+
 config SIFIVE_OTP
 	bool "SiFive eMemory OTP driver"
 	depends on MISC
drivers/misc/Makefile +1 -0
index e2170212e5a..64b2701b672 100644
@@ -69,6 +69,7 @@ obj-$(CONFIG_QCOM_GENI) += qcom_geni.o
 obj-$(CONFIG_$(PHASE_)ROCKCHIP_EFUSE) += rockchip-efuse.o
 obj-$(CONFIG_$(PHASE_)ROCKCHIP_OTP) += rockchip-otp.o
 obj-$(CONFIG_$(PHASE_)ROCKCHIP_IODOMAIN) += rockchip-io-domain.o
+obj-$(CONFIG_RZG2L_OTP) += rzg2l_otp.o
 obj-$(CONFIG_SANDBOX) += syscon_sandbox.o misc_sandbox.o
 obj-$(CONFIG_SIFIVE_OTP) += sifive-otp.o
 obj-$(CONFIG_SMSC_LPC47M) += smsc_lpc47m.o
drivers/misc/rzg2l_otp.c new file +255 -0

255 lines not on this page · raw message

Signature · 1 line
2.52.0

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): TYCPR01MB11332159D47D6E4ED78598B1A862A2@TYCPR01MB11332.jpnprd01.prod.outlook.com

#3 lore raw

Hello,

Quoted 5 lines

Is there any reason for not using SMCC to access OTP region?

Currently we use SMCC for reading various bits in OTP region. We could add SMCC handler in TF-A for fuse programming rather than exposing OTP region to normal world

My original reasoning was that the only existing way to do the fusing was to go through the OP-TEE fork of Renesas. As, I do not want to use OP-TEE (even more a fork) on my project, it was not suiting my needs.

Now Marek also raised this point, but I wasn't aware of this SMCC interface between U-Boot and the TF-A. On the TF-A side, I can find this handler[1], but nothing on the U-Boot side, even on Renesas fork. Am I missing something?

If there's already a communication channel that can be used, then we would need to add fusing support to the TF-A, and turn my driver into something way more minimal that would just perform SMCC calls to the TF-A. That would feel like a better option overall, as it would not require a TF-A modification to allow fusing in the non-secure world in the first place.

Thanks,

Mathieu
[1]: https://github.com/renesas-rz/rzg_trusted-firmware-a/blob/v2.5/rzg2l/plat/renesas/rz/common/rz_plat_sip_handler.c

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): TYWPR01MB11343A62FB03012A458C1B1DC862A2@TYWPR01MB11343.jpnprd01.prod.outlook.com

A message that is not in the archive (sent off-list or not yet received): TYWPR01MB11343DA55762DB428EA42B211862A2@TYWPR01MB11343.jpnprd01.prod.outlook.com

A message that is not in the archive (sent off-list or not yet received): [email protected]

#8 lore raw

Hello Marek,

Quoted 9 lines

If you do want to expose the fuses via SMC , then the fuse region has to be secure only , so only TFA can access it . TFA can then decide which exact fuse the user can or can not read or program, on a single fuse granularity.

By default, non-secure user should be able to read some select fuses (IDs), program no fuses. User should have the ability to expose some select fuses as programmable, for manufacturing purposes.

Mathieu, which fuses exactly do you plan to program ?

I plan to program all fuses (enable secureboot, ROT hash, user encryption keys) using U-Boot directly or U-Boot + TF-A during manufacturing.

I then see two possibilities:

1. During manufacturing, use a specific TF-A that allows fusing from the non-secure world (with SYS_SLVACCCTL7 register). Fuse directly everything from U-Boot, using the patch under review. Then, flash the regular, default TF-A that does not allow fusing from the non-secure world.

2. During manufacturing, use a specific TF-A that allows, via SMC, fusing everything from the non-secure world. Write a new U-Boot driver that performs fusing through SMC. Use it to fuse everything from U-Boot during manufacturing. Then, flash the regular, default TF-A that only allows specific ID fuse read via SMC.

Both options require a specific TF-A during manufacturing. The only real difference to me is that with option 2, we can allow ID fuse read from U-Boot via SMC during regular use.

What do you think?

Thanks,

Mathieu

#9 lore raw

On 4/27/26 11:15 AM, Mathieu Othacehe wrote:

Hello Mathieu,

Quoted 28 lines
Quoted 9 lines

If you do want to expose the fuses via SMC , then the fuse region has to be secure only , so only TFA can access it . TFA can then decide which exact fuse the user can or can not read or program, on a single fuse granularity.

By default, non-secure user should be able to read some select fuses (IDs), program no fuses. User should have the ability to expose some select fuses as programmable, for manufacturing purposes.

Mathieu, which fuses exactly do you plan to program ?

I plan to program all fuses (enable secureboot, ROT hash, user encryption keys) using U-Boot directly or U-Boot + TF-A during manufacturing.

I then see two possibilities:

1. During manufacturing, use a specific TF-A that allows fusing from the non-secure world (with SYS_SLVACCCTL7 register). Fuse directly everything from U-Boot, using the patch under review. Then, flash the regular, default TF-A that does not allow fusing from the non-secure world.

2. During manufacturing, use a specific TF-A that allows, via SMC, fusing everything from the non-secure world. Write a new U-Boot driver that performs fusing through SMC. Use it to fuse everything from U-Boot during manufacturing. Then, flash the regular, default TF-A that only allows specific ID fuse read via SMC.

Quoted 3 lines

Both options require a specific TF-A during manufacturing. The only real difference to me is that with option 2, we can allow ID fuse read from U-Boot via SMC during regular use.

This difference is in fact a bit more important.

I agree that in both cases, it would be necessary to have a TFA capable of programming the fuses, with one or the other mechanisms.

It is possible to expose the fuse block as read-only to U-Boot/Linux in either case, but this may be undesired. It may be undesired to expose all fuses to U-Boot/Linux, instead, it may be desired to expose only a subset of fuses to U-Boot/Linux and prevent U-Boot/Linux from even reading other fuses.

This is what I see as a benefit of option 2 -- it is possible to limit which fuses can be accessed from U-Boot/Linux with single fuse granularity. This is not possible with option 1.

But please look at prior art if/when implementing option 2 and learn from their mistakes, Linux drivers/nvmem/imx-ocotp-scu.c is for MX8Q SCU which is old and odd so ideally avoid that as an example, drivers/nvmem/stm32-romem.c is I think limited to programming only full 32bit words (?) and does not handle single-fuse granularity. It would also be good to design the SMC ABI in a way that maps easily to Linux NVMEM API and in a way that is generic, so others could reuse it (if possible) and reuse the (generic SMC fuse ABI) driver.