mediatek: filogic: add H3C Magic NX30 Pro support
[openwrt/staging/981213.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 asus,tuf-ax4200)
14 CI_UBIPART="UBI_DEV"
15 addr=$(mtd_get_mac_binary_ubi "Factory" 0x4)
16 # Originally, phy0 is phy1 mac with LA bit set. However, this would conflict
17 # addresses on multiple VIFs with the other radio. Set LA bit and increment
18 # mac-address instead.
19 [ "$PHYNBR" = "0" ] && macaddr_setbit_la $(macaddr_add $addr 1) > /sys${DEVPATH}/macaddress
20 [ "$PHYNBR" = "1" ] && echo "$addr" > /sys${DEVPATH}/macaddress
21 ;;
22 bananapi,bpi-r3)
23 addr=$(macaddr_add $(cat /sys/class/net/eth0/address) 2)
24 [ "$PHYNBR" = "0" ] && macaddr_unsetbit $addr 6 > /sys${DEVPATH}/macaddress
25 [ "$PHYNBR" = "1" ] && macaddr_setbit $addr 6 > /sys${DEVPATH}/macaddress
26 ;;
27 cudy,wr3000-v1)
28 addr=$(mtd_get_mac_binary bdinfo 0xde00)
29 # Originally, phy0 is phy1 mac with LA bit set. However, this would conflict
30 # addresses on multiple VIFs with the other radio. Set LA bit and increment
31 # mac-address instead.
32 [ "$PHYNBR" = "0" ] && echo "$addr" > /sys${DEVPATH}/macaddress
33 [ "$PHYNBR" = "1" ] && macaddr_setbit_la $(macaddr_add $addr 1) > /sys${DEVPATH}/macaddress
34 ;;
35 h3c,magic-nx30-pro)
36 addr=$(mtd_get_mac_ascii pdt_data_1 ethaddr)
37 [ "$PHYNBR" = "0" ] && macaddr_add $addr 2 > /sys${DEVPATH}/macaddress
38 [ "$PHYNBR" = "1" ] && macaddr_add $addr 3 > /sys${DEVPATH}/macaddress
39 ;;
40 mercusys,mr90x-v1)
41 addr=$(get_mac_binary "/tmp/tp_data/default-mac" 0)
42 [ "$PHYNBR" = "0" ] && echo "$addr" > /sys${DEVPATH}/macaddress
43 [ "$PHYNBR" = "1" ] && macaddr_add $addr -1 > /sys${DEVPATH}/macaddress
44 ;;
45 netgear,wax220)
46 hw_mac_addr=$(mtd_get_mac_ascii u-boot-env mac)
47 [ "$PHYNBR" = "0" ] && macaddr_add $hw_mac_addr 2 > /sys${DEVPATH}/macaddress
48 [ "$PHYNBR" = "1" ] && macaddr_add $hw_mac_addr 3 > /sys${DEVPATH}/macaddress
49 ;;
50 qihoo,360t7)
51 addr=$(mtd_get_mac_ascii factory lanMac)
52 [ "$PHYNBR" = "0" ] && macaddr_add $addr 2 > /sys${DEVPATH}/macaddress
53 [ "$PHYNBR" = "1" ] && macaddr_add $addr 3 > /sys${DEVPATH}/macaddress
54 ;;
55 tplink,tl-xdr4288|\
56 tplink,tl-xdr6086|\
57 tplink,tl-xdr6088)
58 [ "$PHYNBR" = "0" ] && get_mac_label > /sys${DEVPATH}/macaddress
59 ;;
60 zyxel,ex5601-t0)
61 addr=$(mtd_get_mac_binary "Factory" 0x4)
62 [ "$PHYNBR" = "1" ] && macaddr_add $addr 1 > /sys${DEVPATH}/macaddress
63 ;;
64 esac