mediatek: convert eeprom/macaddr to nvmem format for cmcc rax3000m

Switch to new nvmem binding.

Also fixes a issue that the MAC address assigned to lan/wan was
reversed on eMMC boards.

Signed-off-by: Tianling Shen <cnsztl@immortalwrt.org>
This commit is contained in:
Tianling Shen 2024-04-02 20:26:45 +08:00 committed by Daniel Golle
parent 02488176b7
commit eb510d2158
5 changed files with 71 additions and 28 deletions

View File

@ -7,6 +7,22 @@
compatible = "cmcc,rax3000m", "mediatek,mt7981";
fragment@0 {
target = <&gmac0>;
__overlay__ {
nvmem-cells = <&macaddr_factory_2a 0>;
nvmem-cell-names = "mac-address";
};
};
fragment@1 {
target = <&gmac1>;
__overlay__ {
nvmem-cells = <&macaddr_factory_24 0>;
nvmem-cell-names = "mac-address";
};
};
fragment@2 {
target = <&mmc0>;
__overlay__ {
bus-width = <8>;
@ -19,10 +35,47 @@
pinctrl-1 = <&mmc0_pins_uhs>;
vmmc-supply = <&reg_3p3v>;
status = "okay";
card@0 {
compatible = "mmc-card";
reg = <0>;
block {
compatible = "block-device";
partitions {
block-partition-factory {
partname = "factory";
nvmem-layout {
compatible = "fixed-layout";
#address-cells = <1>;
#size-cells = <1>;
eeprom_factory_0: eeprom@0 {
reg = <0x0 0x1000>;
};
macaddr_factory_24: macaddr@24 {
compatible = "mac-base";
reg = <0x24 0x6>;
#nvmem-cell-cells = <1>;
};
macaddr_factory_2a: macaddr@2a {
compatible = "mac-base";
reg = <0x2a 0x6>;
#nvmem-cell-cells = <1>;
};
};
};
};
};
};
};
};
fragment@1 {
fragment@3 {
target = <&pio>;
__overlay__ {
mmc0_pins_default: mmc0-pins {
@ -40,4 +93,12 @@
};
};
};
fragment@4 {
target = <&wifi>;
__overlay__ {
nvmem-cells = <&eeprom_factory_0>;
nvmem-cell-names = "eeprom";
};
};
};

View File

@ -79,7 +79,7 @@
reg = <0x100000 0x80000>;
};
factory: partition@180000 {
partition@180000 {
label = "factory";
reg = <0x180000 0x200000>;
read-only;
@ -89,6 +89,10 @@
#address-cells = <1>;
#size-cells = <1>;
eeprom_factory_0: eeprom@0 {
reg = <0x0 0x1000>;
};
macaddr_factory_24: macaddr@24 {
compatible = "mac-base";
reg = <0x24 0x6>;
@ -121,7 +125,8 @@
fragment@4 {
target = <&wifi>;
__overlay__ {
mediatek,mtd-eeprom = <&factory 0x0>;
nvmem-cells = <&eeprom_factory_0>;
nvmem-cell-names = "eeprom";
};
};
};

View File

@ -134,15 +134,6 @@ mediatek_setup_macs()
bananapi,bpi-r4)
wan_mac=$(macaddr_add $(cat /sys/class/net/eth0/address) 1)
;;
cmcc,rax3000m)
case "$(cmdline_get_var root)" in
/dev/mmc*)
wan_mac=$(mmc_get_mac_binary factory 0x2a)
lan_mac=$(mmc_get_mac_binary factory 0x24)
label_mac=$wan_mac
;;
esac
;;
h3c,magic-nx30-pro)
wan_mac=$(mtd_get_mac_ascii pdt_data_1 ethaddr)
lan_mac=$(macaddr_add "$wan_mac" 1)

View File

@ -24,13 +24,6 @@ case "$FIRMWARE" in
;;
"mediatek/mt7981_eeprom_mt7976_dbdc.bin")
case "$board" in
cmcc,rax3000m)
case "$(cmdline_get_var root)" in
/dev/mmc*)
caldata_extract_mmc "factory" 0x0 0x1000
;;
esac
;;
ubnt,unifi-6-plus)
caldata_extract_mmc "factory" 0x0 0x1000
;;

View File

@ -55,15 +55,8 @@ case "$board" in
[ "$PHYNBR" = "1" ] && macaddr_setbit_la $(macaddr_add $addr 2) > /sys${DEVPATH}/macaddress
;;
cmcc,rax3000m)
case "$(cmdline_get_var root)" in
/dev/mmc*)
addr=$(mmc_get_mac_binary factory 0xa)
;;
*)
addr=$(mtd_get_mac_binary factory 0xa)
;;
esac
[ "$PHYNBR" = "1" ] && echo "$addr" > /sys${DEVPATH}/macaddress
addr=$(cat /sys/class/net/eth0/address)
[ "$PHYNBR" = "1" ] && macaddr_add $addr -1 > /sys${DEVPATH}/macaddress
;;
comfast,cf-e393ax)
addr=$(mtd_get_mac_binary "Factory" 0x8000)