mediatek: add CMCC RAX3000M support
[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 CI_UBIPART="UBI_DEV"
21 addr=$(mtd_get_mac_binary_ubi "Factory" 0x4)
22 # Originally, phy0 is phy1 mac with LA bit set. However, this would conflict
23 # addresses on multiple VIFs with the other radio. Set LA bit and increment
24 # mac-address instead.
25 [ "$PHYNBR" = "0" ] && macaddr_setbit_la $(macaddr_add $addr 1) > /sys${DEVPATH}/macaddress
26 [ "$PHYNBR" = "1" ] && echo "$addr" > /sys${DEVPATH}/macaddress
27 ;;
28 bananapi,bpi-r3)
29 addr=$(macaddr_add $(cat /sys/class/net/eth0/address) 2)
30 [ "$PHYNBR" = "0" ] && macaddr_unsetbit $addr 6 > /sys${DEVPATH}/macaddress
31 [ "$PHYNBR" = "1" ] && macaddr_setbit $addr 6 > /sys${DEVPATH}/macaddress
32 ;;
33 cetron,ct3003)
34 addr=$(mtd_get_mac_binary "art" 0)
35 [ "$PHYNBR" = "0" ] && macaddr_add $addr 1 > /sys${DEVPATH}/macaddress
36 [ "$PHYNBR" = "1" ] && macaddr_setbit_la $(macaddr_add $addr 2) > /sys${DEVPATH}/macaddress
37 ;;
38 cmcc,rax3000m)
39 case "$(cmdline_get_var root)" in
40 /dev/mmc*)
41 addr=$(mmc_get_mac_binary factory 0xa)
42 ;;
43 *)
44 addr=$(mtd_get_mac_binary factory 0xa)
45 ;;
46 esac
47 [ "$PHYNBR" = "1" ] && echo "$addr" > /sys${DEVPATH}/macaddress
48 ;;
49 cudy,wr3000-v1)
50 addr=$(mtd_get_mac_binary bdinfo 0xde00)
51 # Originally, phy0 is phy1 mac with LA bit set. However, this would conflict
52 # addresses on multiple VIFs with the other radio. Set LA bit and increment
53 # mac-address instead.
54 [ "$PHYNBR" = "0" ] && echo "$addr" > /sys${DEVPATH}/macaddress
55 [ "$PHYNBR" = "1" ] && macaddr_setbit_la $(macaddr_add $addr 1) > /sys${DEVPATH}/macaddress
56 ;;
57 glinet,gl-mt6000)
58 addr=$(mmc_get_mac_binary factory 0x04)
59 [ "$PHYNBR" = "0" ] && echo "$addr" > /sys${DEVPATH}/macaddress
60 [ "$PHYNBR" = "1" ] && macaddr_add $addr 1 > /sys${DEVPATH}/macaddress
61 ;;
62 h3c,magic-nx30-pro)
63 addr=$(mtd_get_mac_ascii pdt_data_1 ethaddr)
64 [ "$PHYNBR" = "0" ] && macaddr_add $addr 2 > /sys${DEVPATH}/macaddress
65 [ "$PHYNBR" = "1" ] && macaddr_add $addr 3 > /sys${DEVPATH}/macaddress
66 ;;
67 mercusys,mr90x-v1)
68 addr=$(get_mac_binary "/tmp/tp_data/default-mac" 0)
69 [ "$PHYNBR" = "0" ] && echo "$addr" > /sys${DEVPATH}/macaddress
70 [ "$PHYNBR" = "1" ] && macaddr_add $addr -1 > /sys${DEVPATH}/macaddress
71 ;;
72 netgear,wax220)
73 hw_mac_addr=$(mtd_get_mac_ascii u-boot-env mac)
74 [ "$PHYNBR" = "0" ] && macaddr_add $hw_mac_addr 2 > /sys${DEVPATH}/macaddress
75 [ "$PHYNBR" = "1" ] && macaddr_add $hw_mac_addr 3 > /sys${DEVPATH}/macaddress
76 ;;
77 ubnt,unifi-6-plus)
78 addr=$(mtd_get_mac_binary EEPROM 0x6)
79 [ "$PHYNBR" = "0" ] && echo "$addr" > /sys${DEVPATH}/macaddress
80 [ "$PHYNBR" = "1" ] && macaddr_add $addr 1 > /sys${DEVPATH}/macaddress
81 ;;
82 qihoo,360t7)
83 addr=$(mtd_get_mac_ascii factory lanMac)
84 [ "$PHYNBR" = "0" ] && macaddr_add $addr 2 > /sys${DEVPATH}/macaddress
85 [ "$PHYNBR" = "1" ] && macaddr_add $addr 3 > /sys${DEVPATH}/macaddress
86 ;;
87 tplink,tl-xdr4288|\
88 tplink,tl-xdr6086|\
89 tplink,tl-xdr6088)
90 [ "$PHYNBR" = "0" ] && get_mac_label > /sys${DEVPATH}/macaddress
91 ;;
92 zyxel,ex5601-t0)
93 addr=$(mtd_get_mac_binary "Factory" 0x4)
94 [ "$PHYNBR" = "1" ] && macaddr_add $addr 1 > /sys${DEVPATH}/macaddress
95 ;;
96 zyxel,nwa50ax-pro)
97 hw_mac_addr="$(mtd_get_mac_binary mrd 0x1fff8)"
98 [ "$PHYNBR" = "0" ] && macaddr_add $hw_mac_addr 1 > /sys${DEVPATH}/macaddress
99 [ "$PHYNBR" = "1" ] && macaddr_add $hw_mac_addr 2 > /sys${DEVPATH}/macaddress
100 ;;
101 esac