mediatek: add support for JDCloud RE-CP-03
[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,rt-ax59u)
20 CI_UBIPART="UBI_DEV"
21 addr=$(mtd_get_mac_binary_ubi "Factory" 0x4)
22 # Originally, phy1 is phy0 mac with LA and 28th bits set. However, this would conflict
23 # addresses on multiple VIFs with the other radio when bit 28 is already set.
24 # Set LA and 28 bits and increment mac-address instead.
25 [ "$PHYNBR" = "1" ] && \
26 macaddr_setbit_la $(macaddr_setbit $(macaddr_add $addr 1) 28) > \
27 /sys${DEVPATH}/macaddress
28 ;;
29 asus,tuf-ax4200|\
30 asus,tuf-ax6000)
31 CI_UBIPART="UBI_DEV"
32 addr=$(mtd_get_mac_binary_ubi "Factory" 0x4)
33 # Originally, phy0 is phy1 mac with LA bit set. However, this would conflict
34 # addresses on multiple VIFs with the other radio. Set LA bit and increment
35 # mac-address instead.
36 [ "$PHYNBR" = "0" ] && macaddr_setbit_la $(macaddr_add $addr 1) > /sys${DEVPATH}/macaddress
37 [ "$PHYNBR" = "1" ] && echo "$addr" > /sys${DEVPATH}/macaddress
38 ;;
39 bananapi,bpi-r3)
40 addr=$(cat /sys/class/net/eth0/address)
41 [ "$PHYNBR" = "0" ] && macaddr_add $addr 2 > /sys${DEVPATH}/macaddress
42 [ "$PHYNBR" = "1" ] && macaddr_add $addr 3 > /sys${DEVPATH}/macaddress
43 ;;
44 cetron,ct3003)
45 addr=$(mtd_get_mac_binary "art" 0)
46 [ "$PHYNBR" = "0" ] && macaddr_add $addr 1 > /sys${DEVPATH}/macaddress
47 [ "$PHYNBR" = "1" ] && macaddr_setbit_la $(macaddr_add $addr 2) > /sys${DEVPATH}/macaddress
48 ;;
49 cmcc,rax3000m)
50 case "$(cmdline_get_var root)" in
51 /dev/mmc*)
52 addr=$(mmc_get_mac_binary factory 0xa)
53 ;;
54 *)
55 addr=$(mtd_get_mac_binary factory 0xa)
56 ;;
57 esac
58 [ "$PHYNBR" = "1" ] && echo "$addr" > /sys${DEVPATH}/macaddress
59 ;;
60 cudy,wr3000-v1)
61 addr=$(mtd_get_mac_binary bdinfo 0xde00)
62 # Originally, phy0 is phy1 mac with LA bit set. However, this would conflict
63 # addresses on multiple VIFs with the other radio. Set LA bit and increment
64 # mac-address instead.
65 [ "$PHYNBR" = "0" ] && echo "$addr" > /sys${DEVPATH}/macaddress
66 [ "$PHYNBR" = "1" ] && macaddr_setbit_la $(macaddr_add $addr 1) > /sys${DEVPATH}/macaddress
67 ;;
68 glinet,gl-mt6000)
69 addr=$(mmc_get_mac_binary factory 0x04)
70 [ "$PHYNBR" = "0" ] && echo "$addr" > /sys${DEVPATH}/macaddress
71 [ "$PHYNBR" = "1" ] && macaddr_add $addr 1 > /sys${DEVPATH}/macaddress
72 ;;
73 h3c,magic-nx30-pro)
74 addr=$(mtd_get_mac_ascii pdt_data_1 ethaddr)
75 [ "$PHYNBR" = "0" ] && macaddr_add $addr 2 > /sys${DEVPATH}/macaddress
76 [ "$PHYNBR" = "1" ] && macaddr_add $addr 3 > /sys${DEVPATH}/macaddress
77 ;;
78 jcg,q30-pro)
79 # Originally, phy1 is phy0 mac with LA bit set. However, this would conflict
80 # addresses on multiple VIFs with the other radio. Use label mac to set LA bit.
81 [ "$PHYNBR" = "1" ] && macaddr_setbit_la $(get_mac_label) > /sys${DEVPATH}/macaddress
82 ;;
83 jdcloud,re-cp-03)
84 [ "$PHYNBR" = "1" ] && mmc_get_mac_binary factory 0xa > /sys${DEVPATH}/macaddress
85 ;;
86 mercusys,mr90x-v1)
87 addr=$(get_mac_binary "/tmp/tp_data/default-mac" 0)
88 [ "$PHYNBR" = "0" ] && echo "$addr" > /sys${DEVPATH}/macaddress
89 [ "$PHYNBR" = "1" ] && macaddr_add $addr -1 > /sys${DEVPATH}/macaddress
90 ;;
91 netgear,wax220)
92 hw_mac_addr=$(mtd_get_mac_ascii u-boot-env mac)
93 [ "$PHYNBR" = "0" ] && macaddr_add $hw_mac_addr 2 > /sys${DEVPATH}/macaddress
94 [ "$PHYNBR" = "1" ] && macaddr_add $hw_mac_addr 3 > /sys${DEVPATH}/macaddress
95 ;;
96 qihoo,360t7)
97 addr=$(mtd_get_mac_ascii factory lanMac)
98 [ "$PHYNBR" = "0" ] && macaddr_add $addr 2 > /sys${DEVPATH}/macaddress
99 [ "$PHYNBR" = "1" ] && macaddr_add $addr 3 > /sys${DEVPATH}/macaddress
100 ;;
101 smartrg,sdg-8612|\
102 smartrg,sdg-8614|\
103 smartrg,sdg-8622|\
104 smartrg,sdg-8632)
105 addr=$(mmc_get_mac_ascii mfginfo MFG_MAC)
106 [ "$PHYNBR" = "0" ] && macaddr_add $addr 2 > /sys${DEVPATH}/macaddress
107 [ "$PHYNBR" = "1" ] && macaddr_add $addr 3 > /sys${DEVPATH}/macaddress
108 [ "$PHYNBR" = "2" ] && macaddr_add $addr 4 > /sys${DEVPATH}/macaddress
109 ;;
110 tplink,tl-xdr4288|\
111 tplink,tl-xdr6086|\
112 tplink,tl-xdr6088)
113 [ "$PHYNBR" = "0" ] && get_mac_label > /sys${DEVPATH}/macaddress
114 ;;
115 ubnt,unifi-6-plus)
116 addr=$(mtd_get_mac_binary EEPROM 0x6)
117 [ "$PHYNBR" = "0" ] && echo "$addr" > /sys${DEVPATH}/macaddress
118 [ "$PHYNBR" = "1" ] && macaddr_add $addr 1 > /sys${DEVPATH}/macaddress
119 ;;
120 routerich,ax3000|\
121 zbtlink,zbt-z8102ax|\
122 zbtlink,zbt-z8103ax|\
123 zyxel,ex5601-t0|\
124 zyxel,ex5601-t0-ubootmod)
125 addr=$(mtd_get_mac_binary "Factory" 0x4)
126 [ "$PHYNBR" = "1" ] && macaddr_add $addr 1 > /sys${DEVPATH}/macaddress
127 ;;
128 zyxel,nwa50ax-pro)
129 hw_mac_addr="$(mtd_get_mac_binary mrd 0x1fff8)"
130 [ "$PHYNBR" = "0" ] && macaddr_add $hw_mac_addr 1 > /sys${DEVPATH}/macaddress
131 [ "$PHYNBR" = "1" ] && macaddr_add $hw_mac_addr 2 > /sys${DEVPATH}/macaddress
132 ;;
133 esac