f4df2c4edbe3054fdbb46be4c936bd0438a2310b
[openwrt/staging/aparcar.git] / target / linux / ath79 / generic / base-files / etc / hotplug.d / ieee80211 / 10_fix_wifi_mac
1 #!/bin/ash
2
3 [ "$ACTION" = "add" ] || exit 0
4
5 PHYNBR=${DEVPATH##*/phy}
6
7 [ -n $PHYNBR ] || exit 0
8
9 . /lib/functions.sh
10 . /lib/functions/system.sh
11 . /lib/functions/k2t.sh
12
13 board=$(board_name)
14
15 case "$board" in
16 adtran,bsap1800-v2|\
17 adtran,bsap1840)
18 macaddr_add "$(mtd_get_mac_binary 'Board data' 2)" $(($PHYNBR * 8 + 1)) > /sys${DEVPATH}/macaddress
19 ;;
20 dlink,dap-1330-a1|\
21 dlink,dap-1365-a1|\
22 dlink,dch-g020-a1)
23 mtd_get_mac_text "mp" 0x13 > /sys${DEVPATH}/macaddress
24 ;;
25 dlink,dap-2230-a1|\
26 dlink,dap-3320-a1)
27 mtd_get_mac_ascii bdcfg "wlanmac" > /sys${DEVPATH}/macaddress
28 ;;
29 dlink,dap-2660-a1|\
30 dlink,dap-2680-a1|\
31 dlink,dap-2695-a1|\
32 dlink,dap-3662-a1)
33 [ "$PHYNBR" -eq 0 ] && \
34 mtd_get_mac_ascii bdcfg "wlanmac_a" > /sys${DEVPATH}/macaddress
35 [ "$PHYNBR" -eq 1 ] && \
36 mtd_get_mac_ascii bdcfg "wlanmac" > /sys${DEVPATH}/macaddress
37 ;;
38 engenius,esr1200|\
39 engenius,esr1750|\
40 engenius,esr900)
41 macaddr_add "$(mtd_get_mac_ascii u-boot-env ethaddr)" "$PHYNBR" > /sys${DEVPATH}/macaddress
42 ;;
43 fortinet,fap-221-b)
44 macaddr_add "$(mtd_get_mac_text u-boot 0x3ff80 12)" $((PHYNBR*7+1)) > /sys${DEVPATH}/macaddress
45 ;;
46 iodata,wn-ac1600dgr)
47 # There is no eeprom data for 5 GHz wlan in "art" partition
48 # which would allow to patch the macaddress
49 [ "$PHYNBR" -eq 0 ] && \
50 macaddr_add "$(mtd_get_mac_ascii u-boot-env ethaddr)" 1 > /sys${DEVPATH}/macaddress
51 ;;
52 iodata,wn-ag300dgr)
53 # There is no eeprom data for 5 GHz wlan in "art" partition
54 # which would allow to patch the macaddress
55 [ "$PHYNBR" -eq 1 ] && \
56 macaddr_add "$(mtd_get_mac_ascii u-boot-env ethaddr)" 1 > /sys${DEVPATH}/macaddress
57 ;;
58 phicomm,k2t)
59 # The K2T factory firmware does use LAN mac address as the 2.4G wifi mac address
60 [ "$PHYNBR" -eq 1 ] && \
61 k2t_get_mac "lan_mac" > /sys${DEVPATH}/macaddress
62 ;;
63 siemens,ws-ap3610)
64 mtd_get_mac_ascii cfg1 RADIOADDR${PHYNBR} > /sys${DEVPATH}/macaddress
65 ;;
66 trendnet,tew-823dru)
67 # set the 2.4G interface mac address to LAN MAC
68 [ "$PHYNBR" -eq 1 ] && \
69 mtd_get_mac_text mac 4 > /sys${DEVPATH}/macaddress
70 # set the 5G interface mac address to WAN MAC + 1
71 [ "$PHYNBR" -eq 0 ] && \
72 macaddr_add "$(mtd_get_mac_text mac 0x18)" 1 > /sys${DEVPATH}/macaddress
73 ;;
74 zyxel,nbg6616)
75 # Set mac address for 2.4g device
76 [ "$PHYNBR" -eq 1 ] && \
77 mtd_get_mac_ascii u-boot-env ethaddr > /sys${DEVPATH}/macaddress
78 ;;
79 zyxel,nwa1123-ac)
80 [ "$PHYNBR" -eq 0 ] && \
81 mtd_get_mac_text mib0 0x66 > /sys${DEVPATH}/macaddress
82 ;;
83 zyxel,nwa1123-ni)
84 [ "$PHYNBR" -eq 1 ] && \
85 mtd_get_mac_text mib0 0x66 > /sys${DEVPATH}/macaddress
86 ;;
87 esac