diff --git a/target/linux/ramips/dts/mt7620a_hiwifi_hc5661.dts b/target/linux/ramips/dts/mt7620a_hiwifi_hc5661.dts index 90ce3c92d78..3d1c1697658 100644 --- a/target/linux/ramips/dts/mt7620a_hiwifi_hc5661.dts +++ b/target/linux/ramips/dts/mt7620a_hiwifi_hc5661.dts @@ -5,6 +5,7 @@ model = "HiWiFi HC5661"; aliases { + label-mac-device = ðernet; led-boot = &led_system; led-failsafe = &led_system; led-running = &led_system; diff --git a/target/linux/ramips/dts/mt7620a_hiwifi_hc5761.dts b/target/linux/ramips/dts/mt7620a_hiwifi_hc5761.dts index f37b663973d..7b5cd0675bb 100644 --- a/target/linux/ramips/dts/mt7620a_hiwifi_hc5761.dts +++ b/target/linux/ramips/dts/mt7620a_hiwifi_hc5761.dts @@ -5,6 +5,7 @@ model = "HiWiFi HC5761"; aliases { + label-mac-device = ðernet; led-boot = &led_system; led-failsafe = &led_system; led-running = &led_system; @@ -63,8 +64,8 @@ &pcie0 { mt76@0,0 { reg = <0x0000 0 0 0 0>; - nvmem-cells = <&eeprom_factory_8000>; - nvmem-cell-names = "eeprom"; + nvmem-cells = <&eeprom_factory_8000>, <&macaddr_bdinfo_18a 0>; + nvmem-cell-names = "eeprom", "mac-address"; ieee80211-freq-limit = <5000000 6000000>; }; }; diff --git a/target/linux/ramips/dts/mt7620a_hiwifi_hc5861.dts b/target/linux/ramips/dts/mt7620a_hiwifi_hc5861.dts index fcd40402921..8b99655cdd7 100644 --- a/target/linux/ramips/dts/mt7620a_hiwifi_hc5861.dts +++ b/target/linux/ramips/dts/mt7620a_hiwifi_hc5861.dts @@ -5,6 +5,7 @@ model = "HiWiFi HC5861"; aliases { + label-mac-device = ðernet; led-boot = &led_system; led-failsafe = &led_system; led-running = &led_system; @@ -95,8 +96,8 @@ wifi@0,0 { compatible = "pci14c3,7662"; reg = <0x0000 0 0 0 0>; - nvmem-cells = <&eeprom_factory_8000>; - nvmem-cell-names = "eeprom"; + nvmem-cells = <&eeprom_factory_8000>, <&macaddr_bdinfo_18a 0>; + nvmem-cell-names = "eeprom", "mac-address"; ieee80211-freq-limit = <5000000 6000000>; }; }; diff --git a/target/linux/ramips/dts/mt7620a_hiwifi_hc5x61.dtsi b/target/linux/ramips/dts/mt7620a_hiwifi_hc5x61.dtsi index 6a602b84116..34412cd7f41 100644 --- a/target/linux/ramips/dts/mt7620a_hiwifi_hc5x61.dtsi +++ b/target/linux/ramips/dts/mt7620a_hiwifi_hc5x61.dtsi @@ -68,10 +68,6 @@ eeprom_factory_8000: eeprom@8000 { reg = <0x8000 0x200>; }; - - macaddr_factory_4: macaddr@4 { - reg = <0x4 0x6>; - }; }; }; @@ -91,6 +87,18 @@ label = "bdinfo"; reg = <0xfe0000 0x10000>; read-only; + + nvmem-layout { + compatible = "fixed-layout"; + #address-cells = <1>; + #size-cells = <1>; + + macaddr_bdinfo_18a: macaddr@18a { + compatible = "mac-base"; + reg = <0x18a 0x11>; + #nvmem-cell-cells = <1>; + }; + }; }; partition@ff0000 { @@ -103,10 +111,10 @@ }; ðernet { - nvmem-cells = <&macaddr_factory_4>; - nvmem-cell-names = "mac-address"; - mediatek,portmap = "wllll"; + + nvmem-cells = <&macaddr_bdinfo_18a 0>; + nvmem-cell-names = "mac-address"; }; &sdhci { @@ -114,8 +122,8 @@ }; &wmac { - nvmem-cells = <&eeprom_factory_0>; - nvmem-cell-names = "eeprom"; + nvmem-cells = <&eeprom_factory_0>, <&macaddr_bdinfo_18a 0>; + nvmem-cell-names = "eeprom", "mac-address"; }; &state_default { diff --git a/target/linux/ramips/dts/mt7621_hiwifi_hc5962.dts b/target/linux/ramips/dts/mt7621_hiwifi_hc5962.dts index 5a8f32d7236..ade82efa393 100644 --- a/target/linux/ramips/dts/mt7621_hiwifi_hc5962.dts +++ b/target/linux/ramips/dts/mt7621_hiwifi_hc5962.dts @@ -9,6 +9,7 @@ model = "HiWiFi HC5962"; aliases { + label-mac-device = &gmac0; led-boot = &led_system; led-failsafe = &led_system; led-running = &led_status; @@ -116,6 +117,18 @@ label = "bdinfo"; reg = <0x21c0000 0x80000>; read-only; + + nvmem-layout { + compatible = "fixed-layout"; + #address-cells = <1>; + #size-cells = <1>; + + macaddr_bdinfo_18a: macaddr@18a { + compatible = "mac-base"; + reg = <0x18a 0x11>; + #nvmem-cell-cells = <1>; + }; + }; }; ubiconcat1: partition@2240000 { @@ -132,8 +145,8 @@ &pcie0 { mt76@0,0 { reg = <0x0000 0 0 0 0>; - nvmem-cells = <&eeprom_factory_0>; - nvmem-cell-names = "eeprom"; + nvmem-cells = <&eeprom_factory_0>, <&macaddr_bdinfo_18a 0>; + nvmem-cell-names = "eeprom", "mac-address"; ieee80211-freq-limit = <2400000 2500000>; }; }; @@ -141,16 +154,24 @@ &pcie1 { mt76@0,0 { reg = <0x0000 0 0 0 0>; - nvmem-cells = <&eeprom_factory_8000>; - nvmem-cell-names = "eeprom"; + nvmem-cells = <&eeprom_factory_8000>, <&macaddr_bdinfo_18a 0>; + nvmem-cell-names = "eeprom", "mac-address"; ieee80211-freq-limit = <5000000 6000000>; }; }; +&gmac0 { + nvmem-cells = <&macaddr_bdinfo_18a 0>; + nvmem-cell-names = "mac-address"; +}; + &gmac1 { status = "okay"; label = "wan"; phy-handle = <ðphy4>; + + nvmem-cells = <&macaddr_bdinfo_18a 1>; + nvmem-cell-names = "mac-address"; }; ðphy4 { diff --git a/target/linux/ramips/dts/mt7628an_hiwifi_hc5761a.dts b/target/linux/ramips/dts/mt7628an_hiwifi_hc5761a.dts index eedf5340177..44086698c57 100644 --- a/target/linux/ramips/dts/mt7628an_hiwifi_hc5761a.dts +++ b/target/linux/ramips/dts/mt7628an_hiwifi_hc5761a.dts @@ -73,8 +73,8 @@ &pcie0 { wifi@0,0 { reg = <0x0000 0 0 0 0>; - nvmem-cells = <&eeprom_factory_8000>; - nvmem-cell-names = "eeprom"; + nvmem-cells = <&eeprom_factory_8000>, <&macaddr_bdinfo_18a 0>; + nvmem-cell-names = "eeprom", "mac-address"; ieee80211-freq-limit = <5000000 6000000>; }; }; diff --git a/target/linux/ramips/dts/mt7628an_hiwifi_hc5861b.dts b/target/linux/ramips/dts/mt7628an_hiwifi_hc5861b.dts index 44ebef2ad5c..7db5a6bc433 100644 --- a/target/linux/ramips/dts/mt7628an_hiwifi_hc5861b.dts +++ b/target/linux/ramips/dts/mt7628an_hiwifi_hc5861b.dts @@ -43,7 +43,7 @@ wifi@0,0 { reg = <0x0000 0 0 0 0>; ieee80211-freq-limit = <5000000 6000000>; - nvmem-cells = <&eeprom_factory_8000>, <&macaddr_factory_2e>; + nvmem-cells = <&eeprom_factory_8000>, <&macaddr_bdinfo_18a 0>; nvmem-cell-names = "eeprom", "mac-address"; led { diff --git a/target/linux/ramips/dts/mt7628an_hiwifi_hc5x61a.dtsi b/target/linux/ramips/dts/mt7628an_hiwifi_hc5x61a.dtsi index 4b114c94145..99fc46d351a 100644 --- a/target/linux/ramips/dts/mt7628an_hiwifi_hc5x61a.dtsi +++ b/target/linux/ramips/dts/mt7628an_hiwifi_hc5x61a.dtsi @@ -9,6 +9,7 @@ compatible = "hiwifi,hc5x61a", "mediatek,mt7628an-soc"; aliases { + label-mac-device = ðernet; led-boot = &led_system; led-failsafe = &led_system; led-running = &led_system; @@ -73,14 +74,6 @@ eeprom_factory_8000: eeprom@8000 { reg = <0x8000 0x200>; }; - - macaddr_factory_4: macaddr@4 { - reg = <0x4 0x6>; - }; - - macaddr_factory_2e: macaddr@2e { - reg = <0x2e 0x6>; - }; }; }; @@ -100,6 +93,18 @@ label = "bdinfo"; reg = <0xfe0000 0x10000>; read-only; + + nvmem-layout { + compatible = "fixed-layout"; + #address-cells = <1>; + #size-cells = <1>; + + macaddr_bdinfo_18a: macaddr@18a { + compatible = "mac-base"; + reg = <0x18a 0x11>; + #nvmem-cell-cells = <1>; + }; + }; }; partition@ff0000 { @@ -112,13 +117,13 @@ }; ðernet { - nvmem-cells = <&macaddr_factory_4>; + nvmem-cells = <&macaddr_bdinfo_18a 0>; nvmem-cell-names = "mac-address"; }; &wmac { status = "okay"; - nvmem-cells = <&eeprom_factory_0>; - nvmem-cell-names = "eeprom"; + nvmem-cells = <&eeprom_factory_0>, <&macaddr_bdinfo_18a 0>; + nvmem-cell-names = "eeprom", "mac-address"; }; diff --git a/target/linux/ramips/mt7620/base-files/etc/board.d/02_network b/target/linux/ramips/mt7620/base-files/etc/board.d/02_network index 9f436a2e8fe..208cb647d3d 100644 --- a/target/linux/ramips/mt7620/base-files/etc/board.d/02_network +++ b/target/linux/ramips/mt7620/base-files/etc/board.d/02_network @@ -382,10 +382,7 @@ ramips_setup_macs() hiwifi,hc5661|\ hiwifi,hc5761|\ hiwifi,hc5861) - lan_mac=$(mtd_get_mac_ascii bdinfo "Vfac_mac ") - label_mac=$lan_mac - [ -n "$lan_mac" ] || lan_mac=$(cat /sys/class/net/eth0/address) - wan_mac=$(macaddr_add "$lan_mac" 1) + wan_mac=$(macaddr_add "$(cat /sys/class/net/eth0/address)" 1) ;; iodata,wn-ac1167gr|\ iodata,wn-ac733gr3) diff --git a/target/linux/ramips/mt7620/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac b/target/linux/ramips/mt7620/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac index aa0ad991582..4c6c7cedba8 100644 --- a/target/linux/ramips/mt7620/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac +++ b/target/linux/ramips/mt7620/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac @@ -10,17 +10,9 @@ PHYNBR=${DEVPATH##*/phy} board=$(board_name) case "$board" in - hiwifi,hc5661) - label_mac=$(mtd_get_mac_ascii bdinfo "Vfac_mac ") - [ "$PHYNBR" = "0" ] && [ -n "$label_mac" ] && \ - echo -n "$label_mac" > /sys${DEVPATH}/macaddress - ;; hiwifi,hc5761|\ hiwifi,hc5861) - label_mac=$(mtd_get_mac_ascii bdinfo "Vfac_mac ") - [ "$PHYNBR" = "1" ] && [ -n "$label_mac" ] && \ - echo -n "$label_mac" > /sys${DEVPATH}/macaddress - [ "$PHYNBR" = "0" ] && [ -n "$label_mac" ] && \ - macaddr_unsetbit "$label_mac" 6 > /sys${DEVPATH}/macaddress + [ "$PHYNBR" = "0" ] && \ + macaddr_unsetbit "$(cat /sys${DEVPATH}/macaddress)" 6 > /sys${DEVPATH}/macaddress ;; esac diff --git a/target/linux/ramips/mt7621/base-files/etc/board.d/02_network b/target/linux/ramips/mt7621/base-files/etc/board.d/02_network index a274dd0d994..31c3f143a0b 100644 --- a/target/linux/ramips/mt7621/base-files/etc/board.d/02_network +++ b/target/linux/ramips/mt7621/base-files/etc/board.d/02_network @@ -272,12 +272,6 @@ ramips_setup_macs() lan_mac=$(macaddr_add "$label_mac" 1) wan_mac=$label_mac ;; - hiwifi,hc5962) - lan_mac=$(mtd_get_mac_ascii bdinfo "Vfac_mac") - label_mac=$lan_mac - [ -n "$lan_mac" ] || lan_mac=$(cat /sys/class/net/eth0/address) - wan_mac=$(macaddr_add "$lan_mac" 1) - ;; iodata,wnpr2600g) wan_mac=$(mtd_get_mac_ascii u-boot-env wanaddr) label_mac=$wan_mac diff --git a/target/linux/ramips/mt7621/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac b/target/linux/ramips/mt7621/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac index c1c6ec749bc..d2da8a227b8 100644 --- a/target/linux/ramips/mt7621/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac +++ b/target/linux/ramips/mt7621/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac @@ -110,11 +110,8 @@ case "$board" in macaddr_setbit_la "$(mtd_get_mac_binary factory 0x4)" > /sys${DEVPATH}/macaddress ;; hiwifi,hc5962) - label_mac=$(mtd_get_mac_ascii bdinfo "Vfac_mac") - [ "$PHYNBR" = "0" ] && [ -n "$label_mac" ] && \ - echo -n "$label_mac" > /sys${DEVPATH}/macaddress - [ "$PHYNBR" = "1" ] && [ -n "$label_mac" ] && \ - macaddr_unsetbit "$label_mac" 6 > /sys${DEVPATH}/macaddress + [ "$PHYNBR" = "1" ] && \ + macaddr_unsetbit "$(cat /sys${DEVPATH}/macaddress)" 6 > /sys${DEVPATH}/macaddress ;; iptime,a3002mesh|\ iptime,a3004t) diff --git a/target/linux/ramips/mt76x8/base-files/etc/board.d/02_network b/target/linux/ramips/mt76x8/base-files/etc/board.d/02_network index cd9199a7d13..ef29d9b3289 100644 --- a/target/linux/ramips/mt76x8/base-files/etc/board.d/02_network +++ b/target/linux/ramips/mt76x8/base-files/etc/board.d/02_network @@ -290,10 +290,7 @@ ramips_setup_macs() hiwifi,hc5661a|\ hiwifi,hc5761a|\ hiwifi,hc5861b) - lan_mac=$(mtd_get_mac_ascii bdinfo "Vfac_mac ") - label_mac=$lan_mac - [ -n "$lan_mac" ] || lan_mac=$(cat /sys/class/net/eth0/address) - wan_mac=$(macaddr_add "$lan_mac" 1) + wan_mac=$(macaddr_add "$(cat /sys/class/net/eth0/address)" 1) ;; iptime,a3|\ iptime,a604m|\ diff --git a/target/linux/ramips/mt76x8/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac b/target/linux/ramips/mt76x8/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac index c9e205a0fc1..57518445fc4 100644 --- a/target/linux/ramips/mt76x8/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac +++ b/target/linux/ramips/mt76x8/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac @@ -10,14 +10,9 @@ PHYNBR=${DEVPATH##*/phy} board=$(board_name) case "$board" in - hiwifi,hc5611|\ - hiwifi,hc5661a|\ hiwifi,hc5761a|\ hiwifi,hc5861b) - label_mac=$(mtd_get_mac_ascii bdinfo "Vfac_mac ") - [ "$PHYNBR" = "0" ] && [ -n "$label_mac" ] && \ - echo -n "$label_mac" > /sys${DEVPATH}/macaddress - [ "$PHYNBR" = "1" ] && [ -n "$label_mac" ] && \ - macaddr_unsetbit "$label_mac" 6 > /sys${DEVPATH}/macaddress + [ "$PHYNBR" = "1" ] && \ + macaddr_unsetbit "$(cat /sys${DEVPATH}/macaddress)" 6 > /sys${DEVPATH}/macaddress ;; esac