[PATCH v4 0/5] nvmem: Derive Rockchip MAC addresses from the OTP CPU ID
From: Alexey Charkov
Date: Tue Nov 24 2026 - 07:04:54 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 the generic NVMEM MAC address helpers accept a cell longer
than six bytes and use its first six. NVMEM cells have a fixed size, so
the OTP driver writes the derived address into the start of the 16-byte
CPU ID cell for MAC address consumers, while the cell keeps its full
size for everyone 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 v4:
- Dropped the NVMEM core change letting post-processing shorten the
output, as cells have a fixed size (Srinivas)
- Added a net change letting the NVMEM MAC address helpers take the
first six bytes of a longer cell instead
- Made the OTP post-processor write the address into the first six
bytes of the CPU ID cell, keeping its size
- Link to v3: https://patch.msgid.link/20261123-rk3576-otp-cpuid-mac-v3-0-40c756dcf36f@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
net: Accept MAC addresses from longer NVMEM cells
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/rockchip-otp.c | 48 +++++++++
net/core/of_net.c | 4 +-
net/ethernet/eth.c | 5 +-
7 files changed, 155 insertions(+), 56 deletions(-)
---
base-commit: 3191063649dbf7c0d0b768e1f3655e4c5fc6edb5
change-id: 20260901-rk3576-otp-cpuid-mac-3c90243d0884
Best regards,
--
Alexey Charkov <alchark@xxxxxxxxxxx>