mediatek: add support for Adtran SmartRG Bonanza Peak series
[openwrt/openwrt.git] / target / linux / mediatek / filogic / base-files / etc / hotplug.d / ieee80211 / 11_fix_wifi_mac
1 [ "$ACTION" == "add" ] || exit 0
2
3 PHYNBR=${DEVPATH##*/phy}
4
5 [ -n $PHYNBR ] || exit 0
6
7 . /lib/functions.sh
8 . /lib/functions/system.sh
9
10 board=$(board_name)
11
12 case "$board" in
13 acer,predator-w6)
14 key_path="/var/qcidata/data"
15 [ "$PHYNBR" = "0" ] && cat $key_path/2gMAC > /sys${DEVPATH}/macaddress
16 [ "$PHYNBR" = "1" ] && cat $key_path/6gMAC > /sys${DEVPATH}/macaddress
17 [ "$PHYNBR" = "2" ] && cat $key_path/5gMAC > /sys${DEVPATH}/macaddress
18 ;;
19 asus,tuf-ax4200|\
20 asus,tuf-ax6000)
21 CI_UBIPART="UBI_DEV"
22 addr=$(mtd_get_mac_binary_ubi "Factory" 0x4)
23 # Originally, phy0 is phy1 mac with LA bit set. However, this would conflict
24 # addresses on multiple VIFs with the other radio. Set LA bit and increment
25 # mac-address instead.
26 [ "$PHYNBR" = "0" ] && macaddr_setbit_la $(macaddr_add $addr 1) > /sys${DEVPATH}/macaddress
27 [ "$PHYNBR" = "1" ] && echo "$addr" > /sys${DEVPATH}/macaddress
28 ;;
29 bananapi,bpi-r3)
30 addr=$(macaddr_add $(cat /sys/class/net/eth0/address) 2)
31 [ "$PHYNBR" = "0" ] && macaddr_unsetbit $addr 6 > /sys${DEVPATH}/macaddress
32 [ "$PHYNBR" = "1" ] && macaddr_setbit $addr 6 > /sys${DEVPATH}/macaddress
33 ;;
34 cetron,ct3003)
35 addr=$(mtd_get_mac_binary "art" 0)
36 [ "$PHYNBR" = "0" ] && macaddr_add $addr 1 > /sys${DEVPATH}/macaddress
37 [ "$PHYNBR" = "1" ] && macaddr_setbit_la $(macaddr_add $addr 2) > /sys${DEVPATH}/macaddress
38 ;;
39 cmcc,rax3000m)
40 case "$(cmdline_get_var root)" in
41 /dev/mmc*)
42 addr=$(mmc_get_mac_binary factory 0xa)
43 ;;
44 *)
45 addr=$(mtd_get_mac_binary factory 0xa)
46 ;;
47 esac
48 [ "$PHYNBR" = "1" ] && echo "$addr" > /sys${DEVPATH}/macaddress
49 ;;
50 cudy,wr3000-v1)
51 addr=$(mtd_get_mac_binary bdinfo 0xde00)
52 # Originally, phy0 is phy1 mac with LA bit set. However, this would conflict
53 # addresses on multiple VIFs with the other radio. Set LA bit and increment
54 # mac-address instead.
55 [ "$PHYNBR" = "0" ] && echo "$addr" > /sys${DEVPATH}/macaddress
56 [ "$PHYNBR" = "1" ] && macaddr_setbit_la $(macaddr_add $addr 1) > /sys${DEVPATH}/macaddress
57 ;;
58 glinet,gl-mt6000)
59 addr=$(mmc_get_mac_binary factory 0x04)
60 [ "$PHYNBR" = "0" ] && echo "$addr" > /sys${DEVPATH}/macaddress
61 [ "$PHYNBR" = "1" ] && macaddr_add $addr 1 > /sys${DEVPATH}/macaddress
62 ;;
63 h3c,magic-nx30-pro)
64 addr=$(mtd_get_mac_ascii pdt_data_1 ethaddr)
65 [ "$PHYNBR" = "0" ] && macaddr_add $addr 2 > /sys${DEVPATH}/macaddress
66 [ "$PHYNBR" = "1" ] && macaddr_add $addr 3 > /sys${DEVPATH}/macaddress
67 ;;
68 jcg,q30-pro)
69 # Originally, phy1 is phy0 mac with LA bit set. However, this would conflict
70 # addresses on multiple VIFs with the other radio. Use label mac to set LA bit.
71 [ "$PHYNBR" = "1" ] && macaddr_setbit_la $(get_mac_label) > /sys${DEVPATH}/macaddress
72 ;;
73 mercusys,mr90x-v1)
74 addr=$(get_mac_binary "/tmp/tp_data/default-mac" 0)
75 [ "$PHYNBR" = "0" ] && echo "$addr" > /sys${DEVPATH}/macaddress
76 [ "$PHYNBR" = "1" ] && macaddr_add $addr -1 > /sys${DEVPATH}/macaddress
77 ;;
78 netgear,wax220)
79 hw_mac_addr=$(mtd_get_mac_ascii u-boot-env mac)
80 [ "$PHYNBR" = "0" ] && macaddr_add $hw_mac_addr 2 > /sys${DEVPATH}/macaddress
81 [ "$PHYNBR" = "1" ] && macaddr_add $hw_mac_addr 3 > /sys${DEVPATH}/macaddress
82 ;;
83 qihoo,360t7)
84 addr=$(mtd_get_mac_ascii factory lanMac)
85 [ "$PHYNBR" = "0" ] && macaddr_add $addr 2 > /sys${DEVPATH}/macaddress
86 [ "$PHYNBR" = "1" ] && macaddr_add $addr 3 > /sys${DEVPATH}/macaddress
87 ;;
88 smartrg,sdg-8612|\
89 smartrg,sdg-8614|\
90 smartrg,sdg-8622|\
91 smartrg,sdg-8632)
92 addr=$(mmc_get_mac_ascii mfginfo MFG_MAC)
93 [ "$PHYNBR" = "0" ] && macaddr_add $addr 2 > /sys${DEVPATH}/macaddress
94 [ "$PHYNBR" = "1" ] && macaddr_add $addr 3 > /sys${DEVPATH}/macaddress
95 [ "$PHYNBR" = "2" ] && macaddr_add $addr 4 > /sys${DEVPATH}/macaddress
96 ;;
97 tplink,tl-xdr4288|\
98 tplink,tl-xdr6086|\
99 tplink,tl-xdr6088)
100 [ "$PHYNBR" = "0" ] && get_mac_label > /sys${DEVPATH}/macaddress
101 ;;
102 ubnt,unifi-6-plus)
103 addr=$(mtd_get_mac_binary EEPROM 0x6)
104 [ "$PHYNBR" = "0" ] && echo "$addr" > /sys${DEVPATH}/macaddress
105 [ "$PHYNBR" = "1" ] && macaddr_add $addr 1 > /sys${DEVPATH}/macaddress
106 ;;
107 zbtlink,zbt-z8102ax|\
108 zyxel,ex5601-t0|\
109 zyxel,ex5601-t0-ubootmod)
110 addr=$(mtd_get_mac_binary "Factory" 0x4)
111 [ "$PHYNBR" = "1" ] && macaddr_add $addr 1 > /sys${DEVPATH}/macaddress
112 ;;
113 zyxel,nwa50ax-pro)
114 hw_mac_addr="$(mtd_get_mac_binary mrd 0x1fff8)"
115 [ "$PHYNBR" = "0" ] && macaddr_add $hw_mac_addr 1 > /sys${DEVPATH}/macaddress
116 [ "$PHYNBR" = "1" ] && macaddr_add $hw_mac_addr 2 > /sys${DEVPATH}/macaddress
117 ;;
118 esac