[PATCH v3 0/5] nvmem: Derive Rockchip MAC addresses from the OTP CPU ID
From: Alexey Charkov
Date: Mon Nov 23 2026 - 10:35:50 EST
Rockchip SoCs are shipped with a unique CPU ID in their internal OTP
memory, and Rockchip bootloaders use it to give boards which have no
dedicated storage for a MAC address a stable one anyway: they hash the CPU
ID and patch the resulting addresses into the device tree they hand over.
Kernels started without that fixup, e.g. straight from the SPL in Falcon
mode or by any other loader which does not implement Rockchip's derivation,
fall back to random MAC addresses which change on every boot.
Formalize the derivation in the DT binding and implement it in the
Rockchip OTP driver, so that a Linux image can use the same stable
addresses regardless of the boot flow.
v3 is a redesign following the v2 discussion. Instead of a separate
SoC-specific NVMEM layout, which could not coexist with the fixed layouts
already used by RK3528, RK3562 and RK356x, the existing CPU ID cell gets
a "rockchip,cpuid" compatible. Referencing it as a "mac-address" cell
selects the derived address, while any other reference keeps getting the
raw CPU ID. The CPU ID location comes from the cell's reg property, so
no per-SoC data is needed, and other SoCs only need the compatible on
their CPU ID cell plus the GMAC references. This is similar to the
behavior already present upstream in drivers/nvmem/imx-ocotp.c
Plain "mac-base" does not fit here: its argument is an offset added to
the base address, whereas the existing Rockchip derivation used by the
bootloaders XORs the index into the last octet.
Patch 2 lets an NVMEM read post-processor report a shorter output than
the raw cell, which the OTP driver needs to hand out six bytes of MAC
address from the 16-byte CPU ID cell without truncating it for anyone
else.
Patch 4 moves the RK3576 OTP cells from the deprecated direct-child
syntax into a fixed layout, as the former does not allow a compatible on
a cell.
Only RK3576 is wired up here, that being the SoC I can test on.
Cross-checked on an RK3576 board: the addresses fixed up into the FDT by
U-Boot match the ones derived by the driver, and the driver correctly
assigns them to the network interfaces when the kernel is booted without
U-Boot proper at all (via Falcon mode). The raw CPU ID cell remains
readable alongside (e.g. via sysfs).
Signed-off-by: Alexey Charkov <alchark@xxxxxxxxxxx>
---
Changes in v3:
- Dropped the OTP read serialization patch, applied separately
- Replaced the SoC-specific NVMEM layout with a "rockchip,cpuid"
compatible on the existing CPU ID fixed cell, so that it works
alongside other fixed cells (Ricardo) and needs no per-SoC table (Ryan)
- Moved the derivation into the rockchip-otp driver's cell fixup hook,
which also makes the layout module unload issue moot (Sashiko)
- Made #nvmem-cell-cells required for the new compatible (Sashiko)
- Dropped the dead match data and address validity checks (Srinivas)
- Allowed MAC address indices up to 255 rather than just 0 and 1
- Added an NVMEM core change letting post-processing shorten the output
- Moved the RK3576 OTP cells into a fixed layout
- Dropped Miquel's Reviewed-by from the driver patch, as the code moved
- Link to v2: https://patch.msgid.link/20260902-rk3576-otp-cpuid-mac-v2-0-e4b7fe2ab13f@xxxxxxxxxxx
Changes in v2:
- Switched from a scope-based guard to explicit lock/unlock calls in the
OTP driver to avoid mixing styles in a function using goto error
handling (Sashiko)
- Link to v1: https://patch.msgid.link/20260901-rk3576-otp-cpuid-mac-v1-0-ea9135270fc2@xxxxxxxxxxx
---
Alexey Charkov (5):
dt-bindings: nvmem: fixed-cell: Add Rockchip CPU ID
nvmem: core: Let read post-processing return a shorter length
nvmem: rockchip-otp: Derive MAC addresses from the CPU ID
arm64: dts: rockchip: Move RK3576 OTP cells into a fixed layout
arm64: dts: rockchip: Derive GMAC MAC addresses from OTP on RK3576
.../bindings/nvmem/layouts/fixed-cell.yaml | 33 ++++++
.../bindings/nvmem/layouts/fixed-layout.yaml | 6 ++
arch/arm64/boot/dts/rockchip/rk3576.dtsi | 111 +++++++++++----------
drivers/nvmem/Kconfig | 4 +-
drivers/nvmem/core.c | 17 +++-
drivers/nvmem/rockchip-otp.c | 45 +++++++++
include/linux/nvmem-provider.h | 8 +-
7 files changed, 168 insertions(+), 56 deletions(-)
---
base-commit: 909ef7a9a30fa139e69e555e3606680f5cca7726
change-id: 20260901-rk3576-otp-cpuid-mac-3c90243d0884
Best regards,
--
Alexey Charkov <alchark@xxxxxxxxxxx>