ramips: provide label MAC address
authorAdrian Schmutzler <freifunk@adrianschmutzler.de>
Mon, 24 Jun 2019 15:57:15 +0000 (17:57 +0200)
committerPetr Štetiar <ynezz@true.cz>
Thu, 19 Sep 2019 21:43:27 +0000 (23:43 +0200)
This patch adds the label MAC address for several devices in
ramips.

Some devices require setting the MAC address in 02_network:

For the following devices, the netif device can be linked in
device tree, but the MAC address cannot be read:
- cudy,wr1000
- dlink,dir-615-d
- dlink,dir-615-h1
- dlink,dir-860l-b1
- glinet,gl-mt300a
- glinet,gl-mt300n
- glinet,gl-mt750
- vocore,vocore2
- vocore,vocore2-lite
- zbtlink,zbt-we1326
- zbtlink,zbt-wg3526

For the following devices, label MAC address is tied to lan or
wan, so no node to link to exists in device tree:
- dlink,dir-510l
- dlink,dwr-116-a1
- dlink,dwr-118-a1
- dlink,dwr-118-a2
- dlink,dwr-921-c1
- dlink,dwr-922-e2
- all hiwifi devices
- lava,lr-25g001
- xiaomi,mir3p

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
32 files changed:
target/linux/ramips/base-files/etc/board.d/02_network
target/linux/ramips/dts/mt7620a_dlink_dir-810l.dts
target/linux/ramips/dts/mt7620a_glinet_gl-mt300a.dts
target/linux/ramips/dts/mt7620a_glinet_gl-mt300n.dts
target/linux/ramips/dts/mt7620a_glinet_gl-mt750.dts
target/linux/ramips/dts/mt7620a_lenovo_newifi-y1.dts
target/linux/ramips/dts/mt7620a_lenovo_newifi-y1s.dts
target/linux/ramips/dts/mt7620a_xiaomi_miwifi-mini.dts
target/linux/ramips/dts/mt7620n_nexx_wt3020.dtsi
target/linux/ramips/dts/mt7621_adslr_g7.dts
target/linux/ramips/dts/mt7621_d-team_newifi-d2.dts
target/linux/ramips/dts/mt7621_dlink_dir-860l-b1.dts
target/linux/ramips/dts/mt7621_lenovo_newifi-d1.dts
target/linux/ramips/dts/mt7621_mtc_wr1201.dts
target/linux/ramips/dts/mt7621_netgear_r6220.dtsi
target/linux/ramips/dts/mt7621_netgear_r6260_r6350_r6850.dtsi
target/linux/ramips/dts/mt7621_tplink_re650-v1.dts
target/linux/ramips/dts/mt7621_ubiquiti_edgerouterx.dtsi
target/linux/ramips/dts/mt7621_zbtlink_zbt-we1326.dts
target/linux/ramips/dts/mt7621_zbtlink_zbt-wg3526.dtsi
target/linux/ramips/dts/mt7628an_cudy_wr1000.dts
target/linux/ramips/dts/mt7628an_glinet_gl-mt300n-v2.dts
target/linux/ramips/dts/mt7628an_iptime_a604m.dts
target/linux/ramips/dts/mt7628an_netgear_r6120.dts
target/linux/ramips/dts/mt7628an_tplink_8m-split-uboot.dtsi
target/linux/ramips/dts/mt7628an_tplink_8m.dtsi
target/linux/ramips/dts/mt7628an_vocore_vocore2.dtsi
target/linux/ramips/dts/rt3050_dlink_dir-615-d.dts
target/linux/ramips/dts/rt3352_dlink_dir-615-h1.dts
target/linux/ramips/dts/rt5350_unbranded_a5-v11.dts
target/linux/ramips/dts/rt5350_vocore_vocore.dtsi
target/linux/ramips/dts/rt5350_zyxel_keenetic-start.dts

index b4634e09285ebd8fabd9f27ce24fe9e76706b4b6..2aab2edfea0118192b468e7f77e131cf49d563db 100755 (executable)
@@ -511,7 +511,6 @@ ramips_setup_macs()
        8devices,carambola|\
        alfa-network,w502u|\
        arcwireless,freestation5|\
-       cudy,wr1000|\
        lenovo,newifi-y1|\
        lenovo,newifi-y1s|\
        netgear,wnce2001|\
@@ -547,7 +546,6 @@ ramips_setup_macs()
        planex,vr500|\
        samknows,whitebox-v8|\
        youku,yk-l2|\
-       zbtlink,zbt-we1326|\
        zbtlink,zbt-we3526)
                wan_mac=$(mtd_get_mac_binary factory 0xe006)
                ;;
@@ -558,6 +556,7 @@ ramips_setup_macs()
        belkin,f9k1109v1)
                wan_mac=$(mtd_get_mac_ascii uboot-env HW_WAN_MAC)
                lan_mac=$(mtd_get_mac_ascii uboot-env HW_LAN_MAC)
+               label_mac=$wan_mac
                ;;
        buffalo,wcr-1166ds|\
        buffalo,wsr-1166dhp)
@@ -574,6 +573,10 @@ ramips_setup_macs()
        zyxel,keenetic-start)
                # This empty case has to be kept for devices without any MAC address adjustments
                ;;
+       cudy,wr1000)
+               wan_mac=$(mtd_get_mac_binary factory 0x2e)
+               label_mac=$(cat /sys/class/ieee80211/phy0/macaddress)
+               ;;
        dlink,dch-m225|\
        samsung,cy-swr1100)
                lan_mac=$(mtd_get_mac_ascii factory lanmac)
@@ -587,6 +590,17 @@ ramips_setup_macs()
        lava,lr-25g001)
                wan_mac=$(jboot_config_read -m -i $(find_mtd_part "config") -o 0xE000)
                lan_mac=$(macaddr_add "$wan_mac" 1)
+               label_mac=$wan_mac
+               ;;
+       dlink,dir-615-d|\
+       dlink,dir-615-h1|\
+       glinet,gl-mt300a|\
+       glinet,gl-mt300n|\
+       glinet,gl-mt750|\
+       zbtlink,zbt-wg3526-16m|\
+       zbtlink,zbt-wg3526-32m)
+               wan_mac=$(macaddr_add "$(cat /sys/class/net/eth0/address)" 1)
+               label_mac=$(cat /sys/class/ieee80211/phy0/macaddress)
                ;;
        dlink,dir-645)
                lan_mac=$(mtd_get_mac_ascii nvram lanmac)
@@ -595,6 +609,7 @@ ramips_setup_macs()
        dlink,dir-860l-b1)
                lan_mac=$(mtd_get_mac_ascii factory lanmac)
                wan_mac=$(mtd_get_mac_ascii factory wanmac)
+               label_mac=$(cat /sys/class/ieee80211/phy1/macaddress)
                ;;
        dovado,tiny-ac)
                lan_mac=$(mtd_get_mac_ascii u-boot-env LAN_MAC_ADDR)
@@ -616,7 +631,8 @@ ramips_setup_macs()
        hiwifi,hc5861|\
        hiwifi,hc5861b|\
        hiwifi,hc5962)
-               lan_mac=`mtd_get_mac_ascii bdinfo "Vfac_mac "`
+               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)
                ;;
@@ -667,13 +683,24 @@ ramips_setup_macs()
        trendnet,tew-691gr)
                wan_mac=$(macaddr_add "$(mtd_get_mac_binary factory 0x4)" 3)
                ;;
-       xiaomi,mir3g|\
+       vocore,vocore2|\
+       vocore,vocore2-lite)
+               label_mac=$(cat /sys/class/ieee80211/phy0/macaddress)
+               ;;
+       xiaomi,mir3g)
+               lan_mac=$(mtd_get_mac_binary factory 0xe006)
+               ;;
        xiaomi,mir3p)
                lan_mac=$(mtd_get_mac_binary factory 0xe006)
+               label_mac=$lan_mac
                ;;
        xiaomi,miwifi-mini)
                lan_mac=$(macaddr_setbit_la "$(cat /sys/class/net/eth0/address)")
                ;;
+       zbtlink,zbt-we1326)
+               wan_mac=$(mtd_get_mac_binary factory 0xe006)
+               label_mac=$(cat /sys/class/ieee80211/phy0/macaddress)
+               ;;
        *)
                wan_mac=$(macaddr_add "$(cat /sys/class/net/eth0/address)" 1)
                ;;
@@ -681,6 +708,7 @@ ramips_setup_macs()
 
        [ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" $lan_mac
        [ -n "$wan_mac" ] && ucidef_set_interface_macaddr "wan" $wan_mac
+       [ -n "$label_mac" ] && ucidef_set_label_macaddr $label_mac
 }
 
 board_config_update
index f440c035361acf494ef75ec30ffcd850d3ad1563..687d80fa5d86cf9457726248c8fa3409effe5b78 100644 (file)
@@ -14,6 +14,7 @@
                led-failsafe = &led_power_green;
                led-running = &led_power_green;
                led-upgrade = &led_power_green;
+               label-mac-device = &ethernet;
        };
 
        keys {
index 2cea9d9beb69b1b42023467cdeee23e6d6f6b9f3..ba446a4c8dce3e51de6264cc85842d6a0ca8ad20 100644 (file)
@@ -9,6 +9,10 @@
        compatible = "glinet,gl-mt300a", "ralink,mt7620a-soc";
        model = "GL-MT300A";
 
+       aliases {
+               label-mac-device = &wmac;
+       };
+
        chosen {
                bootargs = "console=ttyS0,115200";
        };
index a30792cacea90d28f59f5e2aed7f7e290ae8df3f..444ffb04404d55b3e3d0e5a2ab58bcc4da6aa62b 100644 (file)
@@ -9,6 +9,10 @@
        compatible = "glinet,gl-mt300n", "ralink,mt7620a-soc";
        model = "GL-MT300N";
 
+       aliases {
+               label-mac-device = &wmac;
+       };
+
        chosen {
                bootargs = "console=ttyS0,115200";
        };
index 11133a126a2f833b89087c5fe629483792439237..8fc0df2a330630e9aac7f589e0ae0aed48f90f1a 100644 (file)
@@ -9,6 +9,10 @@
        compatible = "glinet,gl-mt750", "ralink,mt7620a-soc";
        model = "GL-MT750";
 
+       aliases {
+               label-mac-device = &wmac;
+       };
+
        chosen {
                bootargs = "console=ttyS0,115200";
        };
index b8c0ec8a836979d22c8b998153ce138d593e6d77..2b98d6c55f14647c2b70d1bb7f8f45a8a1db2cfd 100644 (file)
@@ -11,6 +11,7 @@
                led-failsafe = &led_power;
                led-running = &led_power;
                led-upgrade = &led_power;
+               label-mac-device = &ethernet;
        };
 
        leds {
index bf51329114c4103870c8ad2feaeeef5f5d487270..de01b480e5e56666f24c80a37e0f6e3a05c87e28 100644 (file)
@@ -11,6 +11,7 @@
                led-failsafe = &led_power_blue;
                led-running = &led_power_blue;
                led-upgrade = &led_power_blue;
+               label-mac-device = &ethernet;
        };
 
        gpio_export {
index e8ff02f2abc99dec0c0ad7a761b7448fd5ac19fd..15493e978335dbf0dc41c53036a6d0209bd1856e 100644 (file)
@@ -14,6 +14,7 @@
                led-failsafe = &led_blue;
                led-running = &led_blue;
                led-upgrade = &led_blue;
+               label-mac-device = &ethernet;
        };
 
        chosen {
index 59558a2e963153f5c44d321a32f2aafaf207a406..701701c1de892f7a64515e7c30e90d50ab50be6a 100644 (file)
@@ -11,6 +11,7 @@
                led-failsafe = &led_power;
                led-running = &led_power;
                led-upgrade = &led_power;
+               label-mac-device = &ethernet;
        };
 
        keys {
index 9c92d77102e1e75d0afc1dd1ac4cf7084c3dff3a..c086b16f7dae998f2c1eeb04de78cfd4c51837f2 100644 (file)
@@ -15,6 +15,7 @@
                led-failsafe = &led_sys;
                led-running = &led_sys;
                led-upgrade = &led_sys;
+               label-mac-device = &ethernet;
        };
 
        chosen {
index d51eb29600141cd9413d4b3f32fd251aa091e15b..39c16a569ff50598d3c8f0676da3ab6cf01eccda 100644 (file)
@@ -14,6 +14,7 @@
                led-failsafe = &led_power_blue;
                led-running = &led_power_blue;
                led-upgrade = &led_power_blue;
+               label-mac-device = &ethernet;
        };
 
        chosen {
index 5ddb6302cb0553fad140784f978ade145b89fbdd..13b1dc0519c2c5fd267a6e0befc1c7009412d25c 100644 (file)
@@ -14,6 +14,7 @@
                led-failsafe = &led_power_green;
                led-running = &led_power_green;
                led-upgrade = &led_power_green;
+               label-mac-device = &wifi1;
        };
 
        chosen {
 };
 
 &pcie0 {
-       mt76@0,0 {
+       wifi0: mt76@0,0 {
                reg = <0x0000 0 0 0 0>;
                mediatek,mtd-eeprom = <&radio 0x2000>;
                ieee80211-freq-limit = <5000000 6000000>;
 };
 
 &pcie1 {
-       mt76@0,0 {
+       wifi1: mt76@0,0 {
                reg = <0x0000 0 0 0 0>;
                mediatek,mtd-eeprom = <&radio 0>;
                ieee80211-freq-limit = <2400000 2500000>;
index e681e1a0c9040a1e9c8fb1061db505b4a51c5387..1ab3390093d6df30e1cec0cc18d2694d011a1665 100644 (file)
@@ -14,6 +14,7 @@
                led-failsafe = &led_blue;
                led-running = &led_blue;
                led-upgrade = &led_blue;
+               label-mac-device = &ethernet;
        };
 
        chosen {
index 6f46818800b837c497744d7f01d6cf1ea3106307..885f6dcc8d6307b7af7ec810f55ec6a74741ad99 100644 (file)
@@ -14,6 +14,7 @@
                led-failsafe = &led_power;
                led-running = &led_power;
                led-upgrade = &led_power;
+               label-mac-device = &ethernet;
        };
 
        chosen {
index a25a677d3b668421985d1f140f66db12d0bfc46c..44dec9ef85ac1d418400230d6f619085700fc4f7 100644 (file)
@@ -14,6 +14,7 @@
                led-failsafe = &led_power;
                led-running = &led_power;
                led-upgrade = &led_power;
+               label-mac-device = &ethernet;
        };
 
        chosen {
index 2fe4d241ccfcc78d43fbd7f17acf0245b338c41a..c09fb947c1d1457b6cfa66f1f19247fcd9c213e3 100644 (file)
@@ -14,6 +14,7 @@
                led-failsafe = &led_power;
                led-running = &led_power;
                led-upgrade = &led_power;
+               label-mac-device = &ethernet;
        };
 
        chosen {
index 5c1d308ed8ca33e9f127db3261a58ffd0dfe10a3..23b559daa80e1f5a68fb769e9151e1ae2a52382e 100644 (file)
@@ -15,6 +15,7 @@
                led-failsafe = &led_power;
                led-running = &led_power;
                led-upgrade = &led_power;
+               label-mac-device = &ethernet;
        };
 
        chosen {
index 2aaca832610f4b2e103b7109ef7189b94f045c69..b8de4113e267589f35cb43d4517d3bded12217ce 100644 (file)
@@ -6,6 +6,10 @@
 / {
        compatible = "ubiquiti,edgerouterx", "mediatek,mt7621-soc";
 
+       aliases {
+               label-mac-device = &ethernet;
+       };
+
        chosen {
                bootargs = "console=ttyS0,57600";
        };
index 2f6f94f3ffd917fcad07ca142789b74382a8dff1..819c851c733544ea7a848be1d31376d7775c3646 100644 (file)
@@ -9,6 +9,10 @@
        compatible = "zbtlink,zbt-we1326", "mediatek,mt7621-soc";
        model = "ZBT-WE1326";
 
+       aliases {
+               label-mac-device = &wifi1;
+       };
+
        chosen {
                bootargs = "console=ttyS0,115200";
        };
@@ -83,7 +87,7 @@
 };
 
 &pcie0 {
-       mt76@0,0 {
+       wifi0: mt76@0,0 {
                reg = <0x0000 0 0 0 0>;
                mediatek,mtd-eeprom = <&factory 0x8000>;
                ieee80211-freq-limit = <5000000 6000000>;
@@ -91,7 +95,7 @@
 };
 
 &pcie1 {
-       mt76@0,0 {
+       wifi1: mt76@0,0 {
                reg = <0x0000 0 0 0 0>;
                mediatek,mtd-eeprom = <&factory 0x0000>;
                ieee80211-freq-limit = <2400000 2500000>;
index 87999b1e46e0246a5934b1dc95c03f893cea707b..a2ab252b7e5d1fb73ab61fd8ed7e55abd6579ed0 100644 (file)
@@ -11,6 +11,7 @@
                led-failsafe = &led_status;
                led-running = &led_status;
                led-upgrade = &led_status;
+               label-mac-device = &wifi0;
        };
 
        chosen {
@@ -92,7 +93,7 @@
 };
 
 &pcie0 {
-       wifi@0,0 {
+       wifi0: wifi@0,0 {
                compatible = "pci14c3,7603";
                reg = <0x0000 0 0 0 0>;
                mediatek,mtd-eeprom = <&factory 0x0000>;
 };
 
 &pcie1 {
-       wifi@0,0 {
+       wifi1: wifi@0,0 {
                compatible = "pci14c3,7662";
                reg = <0x0000 0 0 0 0>;
                mediatek,mtd-eeprom = <&factory 0x8000>;
index ad81e8303dd86f8db13bc922067ade55d45127a3..074a5ab1ae8cdf774cb4afed184afa5a3db8c930 100644 (file)
@@ -14,6 +14,7 @@
                led-boot = &led_wps;
                led-failsafe = &led_wps;
                led-upgrade = &led_wps;
+               label-mac-device = &wmac;
        };
 
        keys {
index 6222cfe345e48e3fd881df8fa85dcfbcfda49ba6..785088b633ae1b66888bd0835a53d90e036f72e0 100644 (file)
@@ -14,6 +14,7 @@
                led-failsafe = &led_power;
                led-running = &led_power;
                led-upgrade = &led_power;
+               label-mac-device = &ethernet;
        };
 
        chosen {
index d21f4f69746aaa32bf2e2dd91cb3393bf6d5518d..8ccc649a82bef6435bdd081779cf607e7f11ae61 100644 (file)
@@ -15,6 +15,7 @@
                led-failsafe = &led_cpu;
                led-running = &led_cpu;
                led-upgrade = &led_cpu;
+               label-mac-device = &ethernet;
        };
 
        leds {
index e6d8ea478bf72715c2be2abef8db23c01952e092..9f1ea1d68ab8b9425495ea2bebe7474bc981a4bd 100644 (file)
@@ -14,6 +14,7 @@
                led-failsafe = &led_power;
                led-running = &led_power;
                led-upgrade = &led_power;
+               label-mac-device = &ethernet;
        };
 
        keys {
index 04c6062e1607c2045726def1af611274502ece50..6d7fb01c56a0e297a67c09f43a3e41064f723c4c 100644 (file)
@@ -5,6 +5,10 @@
        chosen {
                bootargs = "console=ttyS0,115200";
        };
+
+       aliases {
+               label-mac-device = &ethernet;
+       };
 };
 
 &spi0 {
index 9e3db9971a0ce84fc2edb4dd2d866783d125ac6e..ba3350ed024835a9a07fe1155195d8ec73432ddd 100644 (file)
@@ -4,6 +4,10 @@
        chosen {
                bootargs = "console=ttyS0,115200";
        };
+
+       aliases {
+               label-mac-device = &ethernet;
+       };
 };
 
 &spi0 {
index f7aec8e1f57334da71d7d9847c538e6c07c78fbc..0f7e63dfe3478330d369db9dadadcdf3c18d7875 100644 (file)
@@ -3,6 +3,10 @@
 / {
        compatible = "vocore,vocore2", "mediatek,mt7628an-soc";
 
+       aliases {
+               label-mac-device = &wmac;
+       };
+
        chosen {
                bootargs = "console=ttyS2,115200";
        };
index 69cc5e252a964f9991f27b4c2a1a408c29c7301d..16018ff1f0815c494c02d4a35a831d457522842b 100644 (file)
@@ -14,6 +14,7 @@
                led-failsafe = &led_status_green;
                led-running = &led_status_green;
                led-upgrade = &led_status_green;
+               label-mac-device = &wmac;
        };
 
        cfi@1f000000 {
index 79d4717f57bda766ac418776fd53c322c1af4b33..a87fc1e9a267da45336f76da8d25cfce61a29ef8 100644 (file)
@@ -14,6 +14,7 @@
                led-failsafe = &led_status_green;
                led-running = &led_status_green;
                led-upgrade = &led_status_green;
+               label-mac-device = &wmac;
        };
 
        leds {
index 707963d691351f17419542570cd04b88a9a2058e..f4e4d17b02fb521a7eccaae917a3852beb5b78d2 100644 (file)
@@ -14,6 +14,7 @@
                led-failsafe = &led_power;
                led-running = &led_power;
                led-upgrade = &led_power;
+               label-mac-device = &ethernet;
        };
 
        leds {
index c5c26e77c803b968756810ef5564a7abdd5006a1..cce444c00729174a1cad4e029db41bb851d5a2a6 100644 (file)
@@ -10,6 +10,7 @@
                led-failsafe = &led_status;
                led-running = &led_status;
                led-upgrade = &led_status;
+               label-mac-device = &ethernet;
        };
 
        gpio-export {
index 16ab9567c0d6a6431af62fa2597b2ce52cbb6645..6f1f6097ccfbb38a31e45b73bd634e28b22cefb7 100644 (file)
@@ -15,6 +15,7 @@
                led-failsafe = &led_status;
                led-running = &led_status;
                led-upgrade = &led_status;
+               label-mac-device = &ethernet;
        };
 
        leds {