ath79: provide label MAC address
authorAdrian Schmutzler <freifunk@adrianschmutzler.de>
Thu, 15 Aug 2019 13:13:33 +0000 (15:13 +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
ath79.

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:
- alfa-network,ap121f
- avm,fritz300e
- ubnt-xm devices

For the following devices, label MAC address is tied to lan or
wan, so no node to link to exists in device tree:
- adtran,bsap1800-v2
- adtran,bsap1840
- dlink,dir-842-c1/-c2/-c3
- engenius,ecb1750
- iodata,etg3-r
- iodata,wn-ac1167dgr
- iodata,wn-ac1600dgr
- iodata,wn-ac1600dgr2
- iodata,wn-ag300dgr
- nec,wg800hp
- nec,wg1200cr
- trendnet,tew-823dru

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
54 files changed:
target/linux/ath79/base-files/etc/board.d/02_network
target/linux/ath79/dts/ar7161_aruba_ap-105.dts
target/linux/ath79/dts/ar7161_netgear_wndr3700.dtsi
target/linux/ath79/dts/ar7240_tplink_tl-wr74xn-v1.dtsi
target/linux/ath79/dts/ar7241_tplink.dtsi
target/linux/ath79/dts/ar7241_tplink_tl-wr842n-v1.dts
target/linux/ath79/dts/ar7241_ubnt_airrouter.dts
target/linux/ath79/dts/ar7241_ubnt_unifi.dts
target/linux/ath79/dts/ar7241_ubnt_xm.dtsi
target/linux/ath79/dts/ar7241_ubnt_xm_outdoor.dtsi
target/linux/ath79/dts/ar7242_avm_fritz300e.dts
target/linux/ath79/dts/ar7242_buffalo_wzr-hp-g450h.dts
target/linux/ath79/dts/ar7242_tplink_tl-wr2543-v1.dts
target/linux/ath79/dts/ar9132_tplink_tl-wa901nd-v2.dts
target/linux/ath79/dts/ar9132_tplink_tl-wr1043nd-v1.dts
target/linux/ath79/dts/ar9132_tplink_tl-wr941-v2.dts
target/linux/ath79/dts/ar9330_glinet_gl-ar150.dts
target/linux/ath79/dts/ar9331_8dev_carambola2.dts
target/linux/ath79/dts/ar9331_pisen_ts-d084.dts
target/linux/ath79/dts/ar9331_tplink_tl-mr3020-v1.dts
target/linux/ath79/dts/ar9331_tplink_tl-mr3040-v2.dts
target/linux/ath79/dts/ar9331_tplink_tl-wr703n_tl-mr10u.dtsi
target/linux/ath79/dts/ar9331_tplink_tl-wr710n-v1.dts
target/linux/ath79/dts/ar9331_tplink_tl-wr741nd-v4.dtsi
target/linux/ath79/dts/ar9341_tplink.dtsi
target/linux/ath79/dts/ar9342_ubnt_xw.dtsi
target/linux/ath79/dts/ar9344_comfast_cf-e120a-v3.dts
target/linux/ath79/dts/ar9344_tplink_cpexxx.dtsi
target/linux/ath79/dts/ar9344_tplink_tl-wdr3500-v1.dts
target/linux/ath79/dts/ar9344_tplink_tl-wdr4300.dtsi
target/linux/ath79/dts/qca9531_comfast_cf-e5.dts
target/linux/ath79/dts/qca9531_glinet_gl-ar300m.dtsi
target/linux/ath79/dts/qca9531_glinet_gl-ar750.dts
target/linux/ath79/dts/qca9531_tplink_archer-d50-v1.dts
target/linux/ath79/dts/qca9533_tplink_cpe210.dtsi
target/linux/ath79/dts/qca9533_tplink_tl-wr841.dtsi
target/linux/ath79/dts/qca9533_tplink_tl-wr842n-v3.dts
target/linux/ath79/dts/qca9533_ubnt_acb-isp.dts
target/linux/ath79/dts/qca953x_tplink_tl-wr810n.dtsi
target/linux/ath79/dts/qca9558_netgear_ex7300.dtsi
target/linux/ath79/dts/qca9558_ocedo_koala.dts
target/linux/ath79/dts/qca9558_tplink_archer-c7.dtsi
target/linux/ath79/dts/qca9558_tplink_rex5x.dtsi
target/linux/ath79/dts/qca9558_tplink_tl-wdr4900-v2.dts
target/linux/ath79/dts/qca9558_tplink_tl-wr1043nd.dtsi
target/linux/ath79/dts/qca9558_tplink_tl-wr941n-v7-cn.dts
target/linux/ath79/dts/qca9561_tplink_archer-c25-v1.dts
target/linux/ath79/dts/qca9561_tplink_archer-c5x.dtsi
target/linux/ath79/dts/qca9563_tplink_archer-c7-v4.dts
target/linux/ath79/dts/qca9563_tplink_archer-x6-v2.dtsi
target/linux/ath79/dts/qca9563_tplink_archer-x7-v5.dtsi
target/linux/ath79/dts/qca9563_tplink_tl-wr1043n.dtsi
target/linux/ath79/dts/qca9563_ubnt_unifiac-lite.dtsi
target/linux/ath79/dts/qca9563_ubnt_unifiac-pro.dtsi

index 5b47af8..2ed4ee0 100755 (executable)
@@ -314,9 +314,19 @@ ath79_setup_macs()
        adtran,bsap1800-v2|\
        adtran,bsap1840)
                lan_mac=$(mtd_get_mac_binary "Board data" 2)
+               label_mac=$lan_mac
+               ;;
+       alfa-network,ap121f|\
+       ubnt,airrouter|\
+       ubnt,bullet-m|\
+       ubnt,nanostation-m|\
+       ubnt,rocket-m|\
+       ubnt,unifi)
+               label_mac=$(cat /sys/class/ieee80211/phy0/macaddress)
                ;;
        avm,fritz300e)
                lan_mac=$(fritz_tffs -n maca -i $(find_mtd_part "tffs (1)"))
+               label_mac=$(cat /sys/class/ieee80211/phy0/macaddress)
                ;;
        avm,fritz4020)
                lan_mac=$(fritz_tffs -n maca -i $(find_mtd_part "tffs (1)"))
@@ -334,8 +344,13 @@ ath79_setup_macs()
        dlink,dir-842-c1|\
        dlink,dir-842-c2|\
        dlink,dir-842-c3|\
+       nec,wg1200cr)
+               lan_mac=$(mtd_get_mac_ascii devdata "lanmac")
+               wan_mac=$(mtd_get_mac_ascii devdata "wanmac")
+               label_mac=$lan_mac
+               ;;
        dlink,dir-859-a1|\
-       nec,wg1200cr|\
+       qihoo,c301|\
        wd,mynet-n750)
                lan_mac=$(mtd_get_mac_ascii devdata "lanmac")
                wan_mac=$(mtd_get_mac_ascii devdata "wanmac")
@@ -346,12 +361,9 @@ ath79_setup_macs()
                ;;
        engenius,ecb1750)
                lan_mac=$(mtd_get_mac_ascii u-boot-env ethaddr)
+               label_mac=$(mtd_get_mac_ascii u-boot-env athaddr)
                ;;
-       engenius,epg5000|\
-       iodata,wn-ac1167dgr|\
-       iodata,wn-ac1600dgr|\
-       iodata,wn-ac1600dgr2|\
-       iodata,wn-ag300dgr)
+       engenius,epg5000)
                lan_mac=$(mtd_get_mac_ascii u-boot-env ethaddr)
                wan_mac=$(mtd_get_mac_ascii u-boot-env wanaddr)
                ;;
@@ -364,6 +376,15 @@ ath79_setup_macs()
        iodata,etg3-r)
                lan_mac=$(mtd_get_mac_ascii u-boot-env ethaddr)
                wan_mac=$(macaddr_add "$lan_mac" -1)
+               label_mac=$wan_mac
+               ;;
+       iodata,wn-ac1167dgr|\
+       iodata,wn-ac1600dgr|\
+       iodata,wn-ac1600dgr2|\
+       iodata,wn-ag300dgr)
+               lan_mac=$(mtd_get_mac_ascii u-boot-env ethaddr)
+               wan_mac=$(mtd_get_mac_ascii u-boot-env wanaddr)
+               label_mac=$wan_mac
                ;;
        jjplus,ja76pf2)
                wan_mac=$(fconfig -s -r -d $(find_mtd_part "RedBoot config") -n alias/ethaddr)
@@ -372,6 +393,7 @@ ath79_setup_macs()
        nec,wg800hp)
                lan_mac=$(mtd_get_mac_text board_data 0x280)
                wan_mac=$(mtd_get_mac_text board_data 0x480)
+               label_mac=$wan_mac
                ;;
        netgear,wndr3700|\
        netgear,wndr3700v2|\
@@ -382,10 +404,6 @@ ath79_setup_macs()
                lan_mac=$(k2t_get_mac "lan_mac")
                wan_mac=$(k2t_get_mac "wan_mac")
                ;;
-       qihoo,c301)
-               lan_mac=$(mtd_get_mac_ascii devdata lanmac)
-               wan_mac=$(mtd_get_mac_ascii devdata wanmac)
-               ;;
        rosinson,wr818)
                wan_mac=$(mtd_get_mac_binary factory 0x0)
                lan_mac=$(macaddr_setbit_la "$wan_mac")
@@ -406,6 +424,7 @@ ath79_setup_macs()
        trendnet,tew-823dru)
                lan_mac=$(mtd_get_mac_text mac 0x4)
                wan_mac=$(mtd_get_mac_text mac 0x18)
+               label_mac=$wan_mac
                ;;
        ubnt,routerstation|\
        ubnt,routerstation-pro)
@@ -419,6 +438,7 @@ ath79_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 45d4d03..91f6e1d 100644 (file)
@@ -19,6 +19,7 @@
                led-failsafe = &power_red;
                led-running = &power_green;
                led-upgrade = &power_green;
+               label-mac-device = &eth0;
        };
 
        extosc: ref {
index 89e9b2f..070f450 100644 (file)
@@ -12,6 +12,7 @@
                led-failsafe = &power_orange;
                led-running = &power_green;
                led-upgrade = &power_orange;
+               label-mac-device = &eth0;
        };
 
        chosen {
index b7db74d..89c1176 100644 (file)
@@ -11,6 +11,7 @@
                led-failsafe = &led_system;
                led-running = &led_system;
                led-upgrade = &led_system;
+               label-mac-device = &ath9k;
        };
 
        keys {
index fa6ba71..827c51b 100644 (file)
@@ -11,6 +11,7 @@
                led-failsafe = &led_system;
                led-running = &led_system;
                led-upgrade = &led_system;
+               label-mac-device = &ath9k;
        };
 
        keys {
index 282446b..15cb22b 100644 (file)
@@ -15,6 +15,7 @@
                led-failsafe = &led_system;
                led-running = &led_system;
                led-upgrade = &led_system;
+               label-mac-device = &ath9k;
        };
 
        keys {
index 774a45f..f12d434 100644 (file)
@@ -12,6 +12,7 @@
                led-failsafe = &globe;
                led-running = &globe;
                led-upgrade = &globe;
+               label-mac-device = &wifi;
        };
 
        airrouter-leds {
index 27aec88..44a5fdd 100644 (file)
@@ -15,6 +15,7 @@
                led-failsafe = &dome_green;
                led-running = &dome_green;
                led-upgrade = &dome_green;
+               label-mac-device = &wifi;
        };
 
        extosc: ref {
 &pcie {
        status = "okay";
 
-       wifi@0,0 {
+       wifi: wifi@0,0 {
                reg = <0x0000 0 0 0 0>;
                qca,no-eeprom;
        };
index 5466575..d330a56 100644 (file)
@@ -89,7 +89,7 @@
 &pcie {
        status = "okay";
 
-       wifi@0,0 {
+       wifi: wifi@0,0 {
                reg = <0x0000 0 0 0 0>;
                qca,no-eeprom;
        };
index c773f1a..787a017 100644 (file)
@@ -9,6 +9,7 @@
        aliases {
                led-boot = &link4;
                led-failsafe = &link4;
+               label-mac-device = &wifi;
        };
 
        leds {
index 3621714..a7fdc97 100644 (file)
@@ -15,6 +15,7 @@
                led-failsafe = &power;
                led-running = &power;
                led-upgrade = &power;
+               label-mac-device = &ath9k;
        };
 
        keys {
index e76f677..37c9860 100644 (file)
        compatible = "buffalo,wzr-hp-g450h", "qca,ar7242";
        model = "Buffalo WZR-HP-G450H/WZR-450HP";
 
+       aliases {
+               label-mac-device = &eth0;
+       };
+
        ath9k-leds {
                compatible = "gpio-leds";
 
index c42207e..08f82a8 100644 (file)
@@ -15,6 +15,7 @@
                led-failsafe = &system;
                led-running = &system;
                led-upgrade = &system;
+               label-mac-device = &eth0;
        };
 
        chosen {
index 6551d0a..2fff081 100644 (file)
@@ -15,6 +15,7 @@
                led-failsafe = &system;
                led-running = &system;
                led-upgrade = &system;
+               label-mac-device = &eth0;
        };
 
        extosc: ref {
index f617d89..88b9d36 100644 (file)
@@ -15,6 +15,7 @@
                led-failsafe = &system;
                led-running = &system;
                led-upgrade = &system;
+               label-mac-device = &eth0;
        };
 
        extosc: ref {
index 93b99be..80677fa 100644 (file)
@@ -15,6 +15,7 @@
                led-failsafe = &led_system;
                led-running = &led_system;
                led-upgrade = &led_system;
+               label-mac-device = &eth0;
        };
 
        keys {
index 76f6e80..e4ea4c9 100644 (file)
@@ -15,6 +15,7 @@
                led-boot = &wlan;
                led-failsafe = &wlan;
                led-upgrade = &wlan;
+               label-mac-device = &eth0;
        };
 
        leds {
index eb8ea3b..8af378e 100644 (file)
@@ -12,6 +12,7 @@
 
        aliases {
                serial0 = &uart;
+               label-mac-device = &wmac;
        };
 
        leds {
index 1dc659b..8b8e304 100644 (file)
@@ -16,6 +16,7 @@
                led-failsafe = &led_system;
                led-running = &led_system;
                led-upgrade = &led_system;
+               label-mac-device = &wmac;
        };
 
        keys {
index 9182374..728463b 100644 (file)
@@ -16,6 +16,7 @@
                led-failsafe = &system;
                led-running = &system;
                led-upgrade = &system;
+               label-mac-device = &eth0;
        };
 
        leds {
index ebf4d44..1644799 100644 (file)
@@ -13,6 +13,7 @@
        aliases {
                led-boot = &led_lan;
                led-failsafe = &led_lan;
+               label-mac-device = &eth0;
        };
 
        leds {
index ffd3d71..a0f5485 100644 (file)
@@ -13,6 +13,7 @@
                led-failsafe = &system;
                led-running = &system;
                led-upgrade = &system;
+               label-mac-device = &eth0;
        };
 
        keys {
index 056e9fa..0254b40 100644 (file)
@@ -16,6 +16,7 @@
                led-failsafe = &led_system;
                led-running = &led_system;
                led-upgrade = &led_system;
+               label-mac-device = &eth0;
        };
 
        keys {
index e4b59f1..9fef023 100644 (file)
@@ -16,6 +16,7 @@
                led-failsafe = &system;
                led-running = &system;
                led-upgrade = &system;
+               label-mac-device = &wmac;
        };
 
        keys {
index e472481..5dbcac3 100644 (file)
@@ -13,6 +13,7 @@
                led-failsafe = &system;
                led-running = &system;
                led-upgrade = &system;
+               label-mac-device = &wmac;
        };
 
        keys: keys {
index 84fc222..76c5c5e 100644 (file)
@@ -14,6 +14,7 @@
                led-running = &system;
                led-upgrade = &system;
                led-failsafe = &system;
+               label-mac-device = &wmac;
        };
 
        leds {
index b0fdce7..8fe45f6 100644 (file)
@@ -15,6 +15,7 @@
                led-boot = &wan;
                led-failsafe = &wan;
                led-upgrade = &wan;
+               label-mac-device = &eth0;
        };
 
        leds {
index 15b4fc8..dc7313b 100644 (file)
@@ -7,6 +7,10 @@
 #include "ar9344.dtsi"
 
 / {
+       aliases {
+               label-mac-device = &wmac;
+       };
+
        keys {
                compatible = "gpio-keys";
 
index fbe1075..e709e6b 100644 (file)
@@ -6,6 +6,10 @@
 / {
        model = "TP-Link TL-WDR3500 v1";
        compatible = "tplink,tl-wdr3500-v1", "qca,ar9344";
+
+       aliases {
+               label-mac-device = &wmac;
+       };
 };
 
 &leds {
index edf60df..9ca96cc 100644 (file)
@@ -2,6 +2,12 @@
 
 #include "ar9344_tplink_tl-wdrxxxx.dtsi"
 
+/ {
+       aliases {
+               label-mac-device = &ath9k;
+       };
+};
+
 &leds {
        usb1 {
                label = "tp-link:green:usb1";
index c181b32..3851f77 100644 (file)
        compatible = "comfast,cf-e5", "qca,qca9531";
        model = "COMFAST CF-E5/E7";
 
+       aliases {
+               label-mac-device = &eth0;
+       };
+
        keys {
                compatible = "gpio-keys-polled";
                poll-interval = <20>;
index 8b127ed..5d0dd74 100644 (file)
@@ -11,6 +11,7 @@
                led-failsafe = &led_status;
                led-running = &led_status;
                led-upgrade = &led_status;
+               label-mac-device = &eth0;
        };
 
        keys {
index 54aad32..1ce0d91 100644 (file)
        compatible = "glinet,gl-ar750", "qca,qca9531";
        model = "GL.iNet GL-AR750";
 
+       aliases {
+               label-mac-device = &eth0;
+       };
+
        keys {
                compatible = "gpio-keys";
 
index 25c1d05..430a8f9 100644 (file)
        compatible = "tplink,archer-d50-v1", "qca,qca9531";
        model = "TP-Link Archer D50 v1";
 
+       aliases {
+               label-mac-device = &wmac;
+       };
+
        chosen {
                bootargs = "console=ttyS0,115200n8";
        };
index f86ff30..f61b05d 100644 (file)
@@ -16,6 +16,7 @@
                led-failsafe = &system;
                led-running = &system;
                led-upgrade = &system;
+               label-mac-device = &eth0;
        };
 
        leds {
index 34f242a..6177702 100644 (file)
                bootargs = "console=ttyS0,115200n8";
        };
 
+       aliases {
+               label-mac-device = &wmac;
+       };
+
        gpio_leds: leds {
                compatible = "gpio-leds";
 
index 22d70af..8a6667e 100644 (file)
@@ -15,6 +15,7 @@
                led-failsafe = &power_led;
                led-running = &power_led;
                led-upgrade = &power_led;
+               label-mac-device = &eth1;
        };
 
        gpio_leds: leds {
index 3bdaa8b..590ec44 100644 (file)
        compatible = "ubnt,acb-isp", "qca,qca9533";
        model = "Ubiquiti airCube ISP";
 
+       aliases {
+               label-mac-device = &wmac;
+       };
+
        keys {
                compatible = "gpio-keys";
 
index d4faee7..649e538 100644 (file)
@@ -16,6 +16,7 @@
                led-failsafe = &led_system;
                led-running = &led_system;
                led-upgrade = &led_system;
+               label-mac-device = &eth1;
        };
 
        gpio_leds: leds {
index 3e94eda..2d91ba1 100644 (file)
@@ -16,6 +16,7 @@
                led-failsafe = &power_amber;
                led-running = &power_green;
                led-upgrade = &power_amber;
+               label-mac-device = &eth0;
        };
 
        led_spi {
index a80155b..5b55541 100644 (file)
@@ -19,6 +19,7 @@
                led-failsafe = &system;
                led-running = &system;
                led-upgrade = &system;
+               label-mac-device = &eth0;
        };
 
        leds {
index 343d318..c1bd795 100644 (file)
@@ -16,6 +16,7 @@
                led-failsafe = &system;
                led-running = &system;
                led-upgrade = &system;
+               label-mac-device = &eth1;
        };
 
        gpio_leds: leds {
index c593cc4..2bc0f38 100644 (file)
@@ -17,6 +17,7 @@
                led-running = &led_power;
                led-upgrade = &led_power;
                mdio-gpio0 = &mdio2;
+               label-mac-device = &eth0;
        };
 
        leds {
index 3cc2d79..77166b8 100644 (file)
@@ -19,6 +19,7 @@
                led-failsafe = &led_system;
                led-running = &led_system;
                led-upgrade = &led_system;
+               label-mac-device = &eth1;
        };
 
        gpio_leds: leds {
index 61d4aec..1092250 100644 (file)
@@ -16,6 +16,7 @@
                led-failsafe = &system;
                led-running = &system;
                led-upgrade = &system;
+               label-mac-device = &wmac;
        };
 
        leds {
index c33fe74..13dacc2 100644 (file)
@@ -19,6 +19,7 @@
                led-failsafe = &led_system;
                led-running = &led_system;
                led-upgrade = &led_system;
+               label-mac-device = &eth0;
        };
 
        leds {
index 881e3a1..794ac24 100644 (file)
@@ -55,6 +55,7 @@
                led-failsafe = &power;
                led-running = &power;
                led-upgrade = &power;
+               label-mac-device = &eth0;
        };
 
        leds {
index 141baa6..80d8e70 100644 (file)
@@ -13,6 +13,7 @@
                led-failsafe = &power;
                led-running = &power;
                led-upgrade = &power;
+               label-mac-device = &eth1;
        };
 
        chosen {
index f4add2f..9c8e00c 100644 (file)
@@ -19,6 +19,7 @@
                led-failsafe = &system;
                led-running = &system;
                led-upgrade = &system;
+               label-mac-device = &eth0;
        };
 
        led_spi {
index ac10d91..2ed5e0c 100644 (file)
@@ -16,6 +16,7 @@
                led-failsafe = &power;
                led-running = &power;
                led-upgrade = &power;
+               label-mac-device = &eth0;
        };
 
        leds {
index 324d831..2e66e0f 100644 (file)
@@ -16,6 +16,7 @@
                led-failsafe = &system;
                led-running = &system;
                led-upgrade = &system;
+               label-mac-device = &eth0;
        };
 
        gpio_leds: leds {
index 42b4b6b..d21bee6 100644 (file)
@@ -16,6 +16,7 @@
                led-failsafe = &system;
                led-running = &system;
                led-upgrade = &system;
+               label-mac-device = &wmac;
        };
 
        gpio_leds: leds {
index 6fe4345..4f77661 100644 (file)
@@ -2,6 +2,12 @@
 
 #include "qca9563_ubnt_unifiac.dtsi"
 
+/ {
+       aliases {
+               label-mac-device = &eth0;
+       };
+};
+
 &mdio0 {
        status = "okay";
 
index f218143..3a6c0cd 100644 (file)
@@ -2,6 +2,12 @@
 
 #include "qca9563_ubnt_unifiac.dtsi"
 
+/ {
+       aliases {
+               label-mac-device = &eth0;
+       };
+};
+
 &mdio0 {
        status = "okay";
        phy-mask = <0>;