dt-bindings: nvmem: fixed-cell: add compatible for MAC cells
Subsystems (5)
PATCH v4 1/1 dt-bindings: nvmem: fixed-cell: add compatible for MAC cells
From: Rafał Miłecki <[email protected]>
A lot of home routers have NVMEM fixed cells containing MAC address that need some further processing. In ~99% cases MAC needs to be:
1. Optionally parsed from ASCII format
2. Increased by a vendor-picked value
There was already an attempt to design a binding for that at NVMEM device level in the past. It wasn't accepted though as it didn't really fit NVMEM device layer.
The introduction of NVMEM fixed-cells layout seems to be an opportunity to provide a relevant binding in a clean way.
This commit adds a *generic* compatible string: "mac-base". As always it needs to be carefully reviewed.
OpenWrt project currently supports ~300 home routers that have NVMEM cell with binary-stored base MAC.T hose devices are manufactured by multiple vendors. There are TP-Link devices (76 of them), Netgear (19), D-Link (11), OpenMesh (9), EnGenius (8), GL.iNet (8), ZTE (7), Xiaomi (5), Ubiquiti (6) and more. Those devices don't share an architecture or SoC.
Another 200 devices have base MAC stored in an ASCII format (not all those devices have been converted to DT though).
It would be impractical to provide unique "compatible" strings for NVMEM layouts of all those devices. It seems like a valid case for allowing a generic binding instead. Even if this binding will not be sufficient for some further devices it seems to be useful enough as it is.
---
V2: Drop "mac-ascii" as length can be checked instead
Fix "allOf" by adding required: [ compatible ]
V3: Fix cell length in "description" (thank you Rob!)
V4: Fix cell length (12 → 6) in fixed-layout.yaml example as well
--- .../bindings/nvmem/layouts/fixed-cell.yaml | 26 +++++++++++++++++++ .../bindings/nvmem/layouts/fixed-layout.yaml | 12 +++++++++ .../devicetree/bindings/nvmem/nvmem.yaml | 5 +++- 3 files changed, 42 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/nvmem/layouts/fixed-cell.yaml +26 -0
@@ -11,6 +11,15 @@ maintainers: - Srinivas Kandagatla <[email protected]> properties: + compatible: + oneOf: + - const: mac-base + description: > + Cell with base MAC address to be used for calculating extra relative + 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). + reg: maxItems: 1
@@ -25,6 +34,23 @@ properties: description: Size in bit within the address range specified by reg. +allOf: + - if: + required: [ compatible ] + then: + if: + properties: + compatible: + contains: + const: mac-base + then: + properties: + "#nvmem-cell-cells": + description: The first argument is a MAC address offset. + const: 1 + required: + - "#nvmem-cell-cells" + required: - reg
Documentation/devicetree/bindings/nvmem/layouts/fixed-layout.yaml +12 -0
@@ -44,6 +44,18 @@ examples: #address-cells = <1>; #size-cells = <1>; + mac@100 { + compatible = "mac-base"; + reg = <0x100 0x6>; + #nvmem-cell-cells = <1>; + }; + + mac@110 { + compatible = "mac-base"; + reg = <0x110 0x11>; + #nvmem-cell-cells = <1>; + }; + calibration@4000 { reg = <0x4000 0x100>; };
Documentation/devicetree/bindings/nvmem/nvmem.yaml +4 -1
@@ -49,7 +49,10 @@ properties: patternProperties: "@[0-9a-f]+(,[0-7])?$": type: object - $ref: layouts/fixed-cell.yaml + allOf: + - $ref: layouts/fixed-cell.yaml + - properties: + compatible: false deprecated: true additionalProperties: true
Signature · 1 line
2.35.3
Quoted 38 lines · Rafał Miłecki
From: Rafał Miłecki <[email protected]>
A lot of home routers have NVMEM fixed cells containing MAC address that need some further processing. In ~99% cases MAC needs to be:
1. Optionally parsed from ASCII format
2. Increased by a vendor-picked valueThere was already an attempt to design a binding for that at NVMEM device level in the past. It wasn't accepted though as it didn't really fit NVMEM device layer.
The introduction of NVMEM fixed-cells layout seems to be an opportunity to provide a relevant binding in a clean way.
This commit adds a *generic* compatible string: "mac-base". As always it needs to be carefully reviewed.
OpenWrt project currently supports ~300 home routers that have NVMEM cell with binary-stored base MAC.T hose devices are manufactured by multiple vendors. There are TP-Link devices (76 of them), Netgear (19), D-Link (11), OpenMesh (9), EnGenius (8), GL.iNet (8), ZTE (7), Xiaomi (5), Ubiquiti (6) and more. Those devices don't share an architecture or SoC.
Another 200 devices have base MAC stored in an ASCII format (not all those devices have been converted to DT though).
It would be impractical to provide unique "compatible" strings for NVMEM layouts of all those devices. It seems like a valid case for allowing a generic binding instead. Even if this binding will not be sufficient for some further devices it seems to be useful enough as it is.
Signed-off-by Rafał Miłecki <[email protected]>---
V2: Drop "mac-ascii" as length can be checked instead
Fix "allOf" by adding required: [ compatible ]
V3: Fix cell length in "description" (thank you Rob!)
V4: Fix cell length (12 → 6) infixed-layout.yamlexample as well
Quoted 6 lines
--- .../bindings/nvmem/layouts/fixed-cell.yaml | 26 +++++++++++++++++++ .../bindings/nvmem/layouts/fixed-layout.yaml | 12 +++++++++ .../devicetree/bindings/nvmem/nvmem.yaml | 5 +++- 3 files changed, 42 insertions(+), 1 deletion(-)
Srinivas Kandagatla
AppliedQuoted 10 lines · Rafał Miłecki
A lot of home routers have NVMEM fixed cells containing MAC address that need some further processing. In ~99% cases MAC needs to be:
1. Optionally parsed from ASCII format
2. Increased by a vendor-picked valueThere was already an attempt to design a binding for that at NVMEM device level in the past. It wasn't accepted though as it didn't really fit NVMEM device layer.
[...]
Applied, thanks!
[1/1] dt-bindings: nvmem: fixed-cell: add compatible for MAC cells
commit: b7495ea1b534fa4d73e5132f05ecc79f5068aa22
Best regards,
Signature · 6 lines
Srinivas Kandagatla <[email protected]> ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/