ath79: add support for Trendnet TEW-823DRU
[openwrt/openwrt.git] / target / linux / ath79 / base-files / etc / hotplug.d / ieee80211 / 10_fix_wifi_mac
index bb55b1c11c8a0343a4df287d6a553fb64ec42565..d9c3fe7440a0902d0a613cf46e54591c1e4ea487 100644 (file)
@@ -1,6 +1,6 @@
 #!/bin/ash
 
-[ "$ACTION" == "add" ] || exit 0
+[ "$ACTION" = "add" ] || exit 0
 
 PHYNBR=${DEVPATH##*/phy}
 
@@ -13,21 +13,35 @@ PHYNBR=${DEVPATH##*/phy}
 board=$(board_name)
 
 case "$board" in
+       adtran,bsap1800-v2|\
+       adtran,bsap1840)
+               macaddr_add "$(mtd_get_mac_binary 'Board data' 2)" $(($PHYNBR * 8 + 1)) > /sys${DEVPATH}/macaddress
+               ;;
        iodata,wn-ag300dgr)
                # There is no eeprom data for 5 GHz wlan in "art" partition
                # which would allow to patch the macaddress
                [ "$PHYNBR" -eq 1 ] && \
-                       echo $(macaddr_add "$(mtd_get_mac_ascii u-boot-env ethaddr)" 1) > /sys${DEVPATH}/macaddress
+                       macaddr_add "$(mtd_get_mac_ascii u-boot-env ethaddr)" 1 > /sys${DEVPATH}/macaddress
+               ;;
+       iodata,wn-ac1600dgr)
+               # There is no eeprom data for 5 GHz wlan in "art" partition
+               # which would allow to patch the macaddress
+               [ "$PHYNBR" -eq 0 ] && \
+                       macaddr_add "$(mtd_get_mac_ascii u-boot-env ethaddr)" 1 > /sys${DEVPATH}/macaddress
                ;;
        phicomm,k2t)
                # The K2T factory firmware does use LAN mac address as the 2.4G wifi mac address
                [ "$PHYNBR" -eq 1 ] && \
-                       echo $(k2t_get_mac "lan_mac") > /sys${DEVPATH}/macaddress
-               ;;
-       tplink,archer-c58-v1|\
-       tplink,archer-c59-v1)
-               echo $(macaddr_add $(mtd_get_mac_binary mac 8)  $(($PHYNBR - 1)) ) > /sys${DEVPATH}/macaddress
+                       k2t_get_mac "lan_mac" > /sys${DEVPATH}/macaddress
                ;;
+       trendnet,tew-823dru)
+               # set the 2.4G interface mac address to LAN MAC
+               [ "$PHYNBR" -eq 1 ] && \
+                       mtd_get_mac_text mac 4 > /sys${DEVPATH}/macaddress
+               # set the 5G interface mac address to WAN MAC + 1
+               [ "$PHYNBR" -eq 0 ] && \
+                       macaddr_add "$(mtd_get_mac_text mac 24)" 1 > /sys${DEVPATH}/macaddress
+                ;;
        *)
                ;;
 esac