mediatek: convert eeprom/macaddr to nvmem format for cmcc rax3000m
authorTianling Shen <cnsztl@immortalwrt.org>
Tue, 2 Apr 2024 12:26:45 +0000 (20:26 +0800)
committerDaniel Golle <daniel@makrotopia.org>
Thu, 18 Jul 2024 12:20:58 +0000 (13:20 +0100)
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>
target/linux/mediatek/dts/mt7981b-cmcc-rax3000m-emmc.dtso
target/linux/mediatek/dts/mt7981b-cmcc-rax3000m-nand.dtso
target/linux/mediatek/filogic/base-files/etc/board.d/02_network
target/linux/mediatek/filogic/base-files/etc/hotplug.d/firmware/11-mt76-caldata
target/linux/mediatek/filogic/base-files/etc/hotplug.d/ieee80211/11_fix_wifi_mac

index c1c9c75c271ae318b067c9ef97d319cfbbf13488..bfccc923a4961893f1fdd82b9ea0ed3cfafcac0f 100644 (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>;
                        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 {
                        };
                };
        };
+
+       fragment@4 {
+               target = <&wifi>;
+               __overlay__ {
+                       nvmem-cells = <&eeprom_factory_0>;
+                       nvmem-cell-names = "eeprom";
+               };
+       };
 };
index 4d2b01cb63e90ea14d0643e2212c7da587fcef30..3f401b53d342f6ac671cc4ed9b550fa00d117927 100644 (file)
@@ -79,7 +79,7 @@
                                                reg = <0x100000 0x80000>;
                                        };
 
-                                       factory: partition@180000 {
+                                       partition@180000 {
                                                label = "factory";
                                                reg = <0x180000 0x200000>;
                                                read-only;
                                                        #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>;
        fragment@4 {
                target = <&wifi>;
                __overlay__ {
-                       mediatek,mtd-eeprom = <&factory 0x0>;
+                       nvmem-cells = <&eeprom_factory_0>;
+                       nvmem-cell-names = "eeprom";
                };
        };
 };
index 1a210810bcdda584eeb27ea3d3fa287b9dffb24b..c9c8a87f54b882bfd709a07126870384828572f3 100644 (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)
index 920a16d05dd0fcd0820cb9883fc4fbf56170a754..c6900e6ebd7510baf2049bcee6cb97adcfa86821 100644 (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
                ;;
index 942facee87c063188f8430f3e590fc20169a95f1..98b1023e3ee8cb2eff40fb6ced9139f4e161dce5 100644 (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)