Skip to content

Commit d63a422

Browse files
Rafał Miłeckigregkh
authored andcommitted
dt-bindings: nvmem: fixed-cell: add compatible for MAC cells
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. Signed-off-by: Rafał Miłecki <rafal@milecki.pl> Reviewed-by: Rob Herring <robh@kernel.org> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> Link: https://lore.kernel.org/r/20230823132744.350618-2-srinivas.kandagatla@linaro.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent e4711d1 commit d63a422

3 files changed

Lines changed: 42 additions & 1 deletion

File tree

Documentation/devicetree/bindings/nvmem/layouts/fixed-cell.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,15 @@ maintainers:
1111
- Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
1212

1313
properties:
14+
compatible:
15+
oneOf:
16+
- const: mac-base
17+
description: >
18+
Cell with base MAC address to be used for calculating extra relative
19+
addresses.
20+
It can be stored in a plain binary format (cell length 6) or as an
21+
ASCII text like "00:11:22:33:44:55" (cell length 17).
22+
1423
reg:
1524
maxItems: 1
1625

@@ -25,6 +34,23 @@ properties:
2534
description:
2635
Size in bit within the address range specified by reg.
2736

37+
allOf:
38+
- if:
39+
required: [ compatible ]
40+
then:
41+
if:
42+
properties:
43+
compatible:
44+
contains:
45+
const: mac-base
46+
then:
47+
properties:
48+
"#nvmem-cell-cells":
49+
description: The first argument is a MAC address offset.
50+
const: 1
51+
required:
52+
- "#nvmem-cell-cells"
53+
2854
required:
2955
- reg
3056

Documentation/devicetree/bindings/nvmem/layouts/fixed-layout.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,18 @@ examples:
4444
#address-cells = <1>;
4545
#size-cells = <1>;
4646
47+
mac@100 {
48+
compatible = "mac-base";
49+
reg = <0x100 0x6>;
50+
#nvmem-cell-cells = <1>;
51+
};
52+
53+
mac@110 {
54+
compatible = "mac-base";
55+
reg = <0x110 0x11>;
56+
#nvmem-cell-cells = <1>;
57+
};
58+
4759
calibration@4000 {
4860
reg = <0x4000 0x100>;
4961
};

Documentation/devicetree/bindings/nvmem/nvmem.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@ properties:
4949
patternProperties:
5050
"@[0-9a-f]+(,[0-7])?$":
5151
type: object
52-
$ref: layouts/fixed-cell.yaml
52+
allOf:
53+
- $ref: layouts/fixed-cell.yaml
54+
- properties:
55+
compatible: false
5356
deprecated: true
5457

5558
additionalProperties: true

0 commit comments

Comments
 (0)