mediatek: use NVMEM framework on all Adtran devices
authorDaniel Golle <daniel@makrotopia.org>
Mon, 7 Oct 2024 14:33:21 +0000 (15:33 +0100)
committerDaniel Golle <daniel@makrotopia.org>
Tue, 15 Oct 2024 16:56:06 +0000 (17:56 +0100)
Use NVMEM framework to assign MAC addresses and WiFi EEPROM data on
all Adtran SmartRG devices.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
target/linux/mediatek/dts/mt7986a-smartrg-bonanza-peak.dtsi
target/linux/mediatek/dts/mt7988a-smartrg-mt-stuart.dtsi
target/linux/mediatek/dts/mt7988d-smartrg-SDG-8733A.dts
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
target/linux/mediatek/filogic/base-files/lib/preinit/10_fix_eth_mac.sh

index 038a76ad73c44f24de78b301223d92cc2954e2ec..deab53dc45f325dc9d75a5e9f5885dc152972abc 100644 (file)
@@ -14,8 +14,7 @@
 / {
        aliases {
                serial0 = &uart0;
-               ethernet0 = &gmac0;
-               ethernet1 = &gmac1;
+               label-mac-device = &gmac1;
                led-boot = &led_status_green;
                led-failsafe = &led_status_red;
                led-running = &led_status_white;
        gmac0: mac@0 {
                compatible = "mediatek,eth-mac";
                reg = <0>;
-
+               nvmem-cells = <&macaddr 1>;
+               nvmem-cell-names = "mac-address";
                phy-mode = "2500base-x";
        };
 
        gmac1: mac@1 {
-               label = "wan";
-
                compatible = "mediatek,eth-mac";
                reg = <1>;
-
+               label = "wan";
+               nvmem-cells = <&macaddr 0>;
+               nvmem-cell-names = "mac-address";
                phy-mode = "2500base-x";
        };
 
        no-sd;
        no-sdio;
        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>;
+                                               };
+
+                                               eeprom_factory_a0000: eeprom@a0000 {
+                                                       reg = <0xa0000 0x1000>;
+                                               };
+                                       };
+                               };
+
+                               block-partition-mfginfo {
+                                       partname = "mfginfo";
+
+                                       nvmem-layout {
+                                               compatible = "adtran,mfginfo";
+
+                                               macaddr: mfg-mac {
+                                                       #nvmem-cell-cells = <1>;
+                                               };
+                                       };
+                               };
+                       };
+               };
+       };
 };
 
 &pcie {
 
                radio0: mt7915@0,0 {
                        reg = <0x0000 0 0 0 0>;
+
+                       nvmem-cells = <&eeprom_factory_a0000>, <&macaddr 4>;
+                       nvmem-cell-names = "eeprom", "mac-address";
                };
        };
 };
 };
 
 &wifi {
-       status = "okay";
+       nvmem-cells = <&eeprom_factory_0>;
+       nvmem-cell-names = "eeprom";
        pinctrl-names = "default";
        pinctrl-0 = <&wf_2g_5g_pins>;
+       #address-cells = <1>;
+       #size-cells = <0>;
+
+       status = "okay";
+
+       band@0 {
+               /* 2.4 GHz */
+               reg = <0>;
+               nvmem-cells = <&macaddr 2>;
+               nvmem-cell-names = "mac-address";
+       };
+
+       band@1 {
+               /* lower 5 GHz */
+               reg = <1>;
+               nvmem-cells = <&macaddr 3>;
+               nvmem-cell-names = "mac-address";
+       };
 };
 
 &pio {
index ccf85fc1108757f1bfa325ae6d232f4b4d66abf3..a3db288d274d393daa10a84530f91a008e6e587f 100644 (file)
@@ -15,8 +15,7 @@
 / {
        aliases {
                serial0 = &uart0;
-               ethernet0 = &gmac0;
-               ethernet1 = &gmac1;
+               label-mac-device = &gmac1;
                led-boot = &led_sys_green;
                led-failsafe = &led_sys_blue;
                led-running = &led_sys_white;
 };
 
 &gmac0 {
+       nvmem-cells = <&macaddr 1>;
+       nvmem-cell-names = "mac-address";
+
        status = "okay";
 };
 
 &gmac1 {
+       nvmem-cells = <&macaddr 0>;
+       nvmem-cell-names = "mac-address";
        label = "wan";
-       status = "okay";
        phy-mode = "usxgmii";
+
+       status = "okay";
 };
 
 &gmac2 {
+       nvmem-cells = <&macaddr 1>;
+       nvmem-cell-names = "mac-address";
        label = "lan1";
-       status = "okay";
        phy-mode = "usxgmii";
        phy-connection-type = "usxgmii";
        phy = <&phy8>;
+
+       status = "okay";
 };
 
 &gsw_phy0 {
                                                };
                                        };
                                };
+
+                               block-partition-mfginfo {
+                                       partname = "mfginfo";
+
+                                       nvmem-layout {
+                                               compatible = "adtran,mfginfo";
+
+                                               macaddr: mfg-mac {
+                                                       #nvmem-cell-cells = <1>;
+                                               };
+                                       };
+                               };
                        };
                };
        };
                        nvmem-cells = <&eeprom_factory_0>;
                        nvmem-cell-names = "eeprom";
                        ieee80211-freq-limit = <2400000 2500000>, <5170000 5835000>, <5945000 7125000>;
+
+                       band@0 {
+                               /* 2.4 GHz */
+                               reg = <0>;
+                               nvmem-cells = <&macaddr 4>;
+                               nvmem-cell-names = "mac-address";
+                       };
+
+                       band@1 {
+                               /* 5 GHz */
+                               reg = <1>;
+                               nvmem-cells = <&macaddr 10>;
+                               nvmem-cell-names = "mac-address";
+                       };
+
+                       band@2 {
+                               /* 6 GHz */
+                               reg = <2>;
+                               nvmem-cells = <&macaddr 6>;
+                               nvmem-cell-names = "mac-address";
+                       };
                };
        };
 };
index 54fbbea0ba4253f0a76e3292db4e7419affc30bb..b72ef48bea7fafdc8e7d3c6cffdbdf88c457a748 100644 (file)
@@ -62,6 +62,8 @@
 
 &gmac1 {
        label = "lan";
+       nvmem-cells = <&macaddr 1>;
+       nvmem-cell-names = "mac-address";
        phy-mode = "internal";
        phy-connection-type = "internal";
        phy = <&int_2p5g_phy>;
@@ -69,6 +71,8 @@
 
 &gmac2 {
        label = "wan";
+       nvmem-cells = <&macaddr 0>;
+       nvmem-cell-names = "mac-address";
        phy-mode = "usxgmii";
        phy-connection-type = "usxgmii";
        phy = <&phy8>;
index 74ee571bc028659760f53be405599807da818c1f..d532d75b99ea1e4ed57248cbc5101af545119087 100644 (file)
@@ -162,16 +162,6 @@ mediatek_setup_macs()
                wan_mac=$label_mac
                lan_mac=$(macaddr_add "$label_mac" 1)
                ;;
-       smartrg,sdg-8612|\
-       smartrg,sdg-8614|\
-       smartrg,sdg-8622|\
-       smartrg,sdg-8632|\
-       smartrg,sdg-8733|\
-       smartrg,sdg-8734)
-               label_mac=$(mmc_get_mac_ascii mfginfo MFG_MAC)
-               wan_mac=$label_mac
-               lan_mac=$(macaddr_add "$label_mac" 1)
-               ;;
        xiaomi,mi-router-ax3000t|\
        xiaomi,mi-router-ax3000t-ubootmod|\
        xiaomi,mi-router-wr30u-stock|\
index c6900e6ebd7510baf2049bcee6cb97adcfa86821..d97e5c8354813d4eaad00c6be89bef6387b1a547 100644 (file)
@@ -7,21 +7,6 @@
 board=$(board_name)
 
 case "$FIRMWARE" in
-"mediatek/mt7915_eeprom.bin")
-       case "$board" in
-       smartrg,sdg-8622)
-               caldata_extract_mmc "factory" 0xa0000 0x1000
-               ;;
-       esac
-       ;;
-"mediatek/mt7916_eeprom.bin")
-       case "$board" in
-       acer,predator-w6|\
-       smartrg,sdg-8632)
-               caldata_extract_mmc "factory" 0xa0000 0x1000
-               ;;
-       esac
-       ;;
 "mediatek/mt7981_eeprom_mt7976_dbdc.bin")
        case "$board" in
        ubnt,unifi-6-plus)
@@ -36,12 +21,6 @@ case "$FIRMWARE" in
                ln -sf /tmp/tp_data/MT7986_EEPROM.bin \
                        /lib/firmware/$FIRMWARE
                ;;
-       smartrg,sdg-8612|\
-       smartrg,sdg-8614|\
-       smartrg,sdg-8622|\
-       smartrg,sdg-8632)
-               caldata_extract_mmc "factory" 0x0 0x1000
-               ;;
        esac
        ;;
 "mediatek/mt7986_eeprom_mt7976.bin")
index 3600e323409a37abffc3591742d2196bbc76df6c..3042858353a7cfd90a5295c9f2c1ce49bb61f0d9 100644 (file)
@@ -139,23 +139,6 @@ case "$board" in
                [ "$PHYNBR" = "0" ] && macaddr_add $addr 2 > /sys${DEVPATH}/macaddress
                [ "$PHYNBR" = "1" ] && macaddr_add $addr 3 > /sys${DEVPATH}/macaddress
                ;;
-       smartrg,sdg-8612|\
-       smartrg,sdg-8614|\
-       smartrg,sdg-8622|\
-       smartrg,sdg-8632)
-               addr=$(mmc_get_mac_ascii mfginfo MFG_MAC)
-               [ "$PHYNBR" = "0" ] && macaddr_add $addr 2 > /sys${DEVPATH}/macaddress
-               [ "$PHYNBR" = "1" ] && macaddr_add $addr 3 > /sys${DEVPATH}/macaddress
-               [ "$PHYNBR" = "2" ] && macaddr_add $addr 4 > /sys${DEVPATH}/macaddress
-               ;;
-       smartrg,sdg-8733|\
-       smartrg,sdg-8733a|\
-       smartrg,sdg-8734)
-               addr=$(mmc_get_mac_ascii mfginfo MFG_MAC)
-               [ "$PHYNBR" = "0" ] && macaddr_add $addr 4 > /sys${DEVPATH}/macaddress
-               [ "$PHYNBR" = "1" ] && macaddr_add $addr a > /sys${DEVPATH}/macaddress
-               [ "$PHYNBR" = "2" ] && macaddr_add $addr 6 > /sys${DEVPATH}/macaddress
-               ;;
        tplink,tl-xdr4288|\
        tplink,tl-xdr6086|\
        tplink,tl-xdr6088)
index 65bd5178242c1b264757c45aef385209599b1a02..0497d7dfa2474ff1dbed6a91d763f603eff38d17 100644 (file)
@@ -22,26 +22,6 @@ preinit_set_mac_address() {
                addr=$(get_mac_binary "/tmp/tp_data/default-mac" 0)
                ip link set dev eth1 address "$(macaddr_add $addr 1)"
                ;;
-       smartrg,sdg-8612|\
-       smartrg,sdg-8614|\
-       smartrg,sdg-8733|\
-       smartrg,sdg-8734)
-               addr=$(mmc_get_mac_ascii mfginfo MFG_MAC)
-               lan_addr=$(macaddr_add $addr 1)
-               ip link set dev wan address "$addr"
-               ip link set dev eth0 address "$lan_addr"
-               ip link set dev lan1 address "$lan_addr"
-               ip link set dev lan2 address "$lan_addr"
-               ip link set dev lan3 address "$lan_addr"
-               ip link set dev lan4 address "$lan_addr"
-               ;;
-       smartrg,sdg-8622|\
-       smartrg,sdg-8632|\
-       smartrg,sdg-8733a)
-               addr=$(mmc_get_mac_ascii mfginfo MFG_MAC)
-               ip link set dev wan address "$addr"
-               ip link set dev lan address "$(macaddr_add $addr 1)"
-               ;;
        *)
                ;;
        esac