[PATCH v4 1/5] dt-bindings: nvmem: fixed-cell: Add Rockchip CPU ID

From: Alexey Charkov

Date: Tue Nov 24 2026 - 07:05:02 EST


Rockchip SoCs ship with a unique CPU ID programmed into their OTP memory,
and compatible bootloaders derive Ethernet MAC addresses from it, so that
boards with no dedicated storage for one still get a stable address.
Whether a board ends up with those addresses then depends on the
bootloader patching them into the device tree.

Describe the CPU ID cell with a compatible which also defines that
derivation, so that the addresses are available to anything which reads
the device tree, whatever the boot flow. Referencing the cell as a
"mac-address" selects the derived address, keeping the raw CPU ID
available to any other consumer from the same cell. Keep the compatible
vendor-wide, as only the location of the CPU ID differs between SoCs,
and that is given by the reg property already.

Plain "mac-base" does not fit: the CPU ID is not a MAC address in either
of the formats it allows, and its offset argument is added to the base,
whereas the bootloaders XOR the index into the last octet.

Signed-off-by: Alexey Charkov <alchark@xxxxxxxxxxx>
---
.../bindings/nvmem/layouts/fixed-cell.yaml | 33 ++++++++++++++++++++++
.../bindings/nvmem/layouts/fixed-layout.yaml | 6 ++++
2 files changed, 39 insertions(+)

diff --git a/Documentation/devicetree/bindings/nvmem/layouts/fixed-cell.yaml b/Documentation/devicetree/bindings/nvmem/layouts/fixed-cell.yaml
index 38e3ad50ff4f..ad38954cfb59 100644
--- a/Documentation/devicetree/bindings/nvmem/layouts/fixed-cell.yaml
+++ b/Documentation/devicetree/bindings/nvmem/layouts/fixed-cell.yaml
@@ -19,6 +19,18 @@ properties:
addresses.
It can be stored in a plain binary format (cell length 6) or as an
ASCII text like "00:11:22:33:44:55" (cell length 17).
+ - const: rockchip,cpuid
+ description: >
+ Cell with the unique CPU ID of a Rockchip SoC (cell length 16).
+ A consumer referencing it as its "mac-address" NVMEM cell, as
+ Ethernet controllers do, refers to a stable MAC address derived from
+ the CPU ID rather than to the CPU ID itself. The base of such
+ addresses consists of the first six octets of the SHA-256 digest of
+ the 32-character string of lowercase hexadecimal digits representing
+ the 16 CPU ID bytes in stored order, without separators or a
+ terminator. In the first octet, the multicast bit (bit 0) is then
+ cleared and the locally administered bit (bit 1) set. Any other
+ reference to the cell refers to the CPU ID as stored.

reg:
maxItems: 1
@@ -48,6 +60,27 @@ allOf:
const: 1
required:
- "#nvmem-cell-cells"
+ - if:
+ properties:
+ compatible:
+ contains:
+ const: rockchip,cpuid
+ required: [ compatible ]
+ then:
+ properties:
+ reg:
+ items:
+ - items:
+ - description: Offset of the CPU ID
+ - const: 16
+ "#nvmem-cell-cells":
+ description:
+ For a "mac-address" reference, the first argument is the index of
+ the MAC address, which is XORed into the last octet of the base
+ address. It is ignored for any other reference.
+ const: 1
+ required:
+ - "#nvmem-cell-cells"

required:
- reg
diff --git a/Documentation/devicetree/bindings/nvmem/layouts/fixed-layout.yaml b/Documentation/devicetree/bindings/nvmem/layouts/fixed-layout.yaml
index b01567f99284..f30166109a7f 100644
--- a/Documentation/devicetree/bindings/nvmem/layouts/fixed-layout.yaml
+++ b/Documentation/devicetree/bindings/nvmem/layouts/fixed-layout.yaml
@@ -56,6 +56,12 @@ examples:
#nvmem-cell-cells = <1>;
};

+ id@200 {
+ compatible = "rockchip,cpuid";
+ reg = <0x200 0x10>;
+ #nvmem-cell-cells = <1>;
+ };
+
calibration@4000 {
reg = <0x4000 0x100>;
};

--
2.56.0