realtek: use nvmem for mac address for XikeStor SKS8310-8X

Define an nvmem cell in the device tree of XikeStor SKS8310-8X to
reference that as a source for the MAC address of the switch (ports).
This eliminates the need for the userspace script to read and parse the
MAC address.

Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/22211
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
This commit is contained in:
Jonas Jelonek 2026-02-27 22:31:55 +00:00 committed by Hauke Mehrtens
parent 4724649689
commit 05cbbb4037
2 changed files with 22 additions and 6 deletions

View file

@ -65,6 +65,7 @@ realtek_setup_macs()
xikestor,sks8300-8t|\
xikestor,sks8300-12e2t2x|\
xikestor,sks8300-12x-v1|\
xikestor,sks8310-8x|\
zyxel,xgs1210-12-a1|\
zyxel,xgs1210-12-b1)
lan_mac=$(get_mac_label)
@ -100,12 +101,6 @@ realtek_setup_macs()
lan_mac_start=$lan_mac
eth0_mac=$lan_mac
;;
xikestor,sks8310-8x)
lan_mac=$(mtd_get_mac_binary factory 0x80)
label_mac="$lan_mac"
lan_mac_start=$lan_mac
eth0_mac=$lan_mac
;;
allnet,all-sg8208m|\
apresia,aplgs120gtss|\
d-link,dgs-1210-10mp-f|\

View file

@ -10,6 +10,10 @@
compatible = "xikestor,sks8310-8x", "realtek,rtl9303-soc";
model = "XikeStor SKS8310-8X";
aliases {
label-mac-device = &ethernet0;
};
memory@0 {
device_type = "memory";
reg = <0x00000000 0x10000000>, /* first 256 MiB */
@ -217,6 +221,18 @@
label = "factory";
reg = <0x1e0000 0x10000>;
read-only;
nvmem-layout {
compatible = "fixed-layout";
#address-cells = <1>;
#size-cells = <1>;
factory_macaddr: macaddr@80 {
compatible = "mac-base";
reg = <0x80 0x6>;
#nvmem-cell-cells = <1>;
};
};
};
partition@1f0000 {
@ -240,6 +256,11 @@
};
};
&ethernet0 {
nvmem-cells = <&factory_macaddr 0>;
nvmem-cell-names = "mac-address";
};
&switch0 {
ethernet-ports {
#address-cells = <1>;