ath79: convert ath10k pre-calibration data to NVMEM (ASCII MAC)
[openwrt/openwrt.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,covr-p2500-a1)
21 [ "$PHYNBR" -eq 0 ] && \
22 mtd_get_mac_ascii art "protest_ath1_mac" > /sys${DEVPATH}/macaddress
23 [ "$PHYNBR" -eq 1 ] && \
24 mtd_get_mac_ascii art "protest_ath0_mac" > /sys${DEVPATH}/macaddress
25 ;;
26 dlink,dap-1330-a1|\
27 dlink,dap-1365-a1|\
28 dlink,dch-g020-a1)
29 mtd_get_mac_text "mp" 0x13 > /sys${DEVPATH}/macaddress
30 ;;
31 dlink,dap-2230-a1|\
32 dlink,dap-3320-a1)
33 mtd_get_mac_ascii bdcfg "wlanmac" > /sys${DEVPATH}/macaddress
34 ;;
35 dlink,dap-2660-a1|\
36 dlink,dap-2680-a1|\
37 dlink,dap-2695-a1|\
38 dlink,dap-3662-a1)
39 [ "$PHYNBR" -eq 0 ] && \
40 mtd_get_mac_ascii bdcfg "wlanmac_a" > /sys${DEVPATH}/macaddress
41 [ "$PHYNBR" -eq 1 ] && \
42 mtd_get_mac_ascii bdcfg "wlanmac" > /sys${DEVPATH}/macaddress
43 ;;
44 engenius,epg5000|\
45 engenius,esr1200|\
46 engenius,esr1750|\
47 engenius,esr900)
48 macaddr_add "$(mtd_get_mac_ascii u-boot-env ethaddr)" "$PHYNBR" > /sys${DEVPATH}/macaddress
49 ;;
50 iodata,wn-ac1600dgr)
51 # There is no eeprom data for 5 GHz wlan in "art" partition
52 # which would allow to patch the macaddress
53 [ "$PHYNBR" -eq 0 ] && \
54 macaddr_add "$(mtd_get_mac_ascii u-boot-env ethaddr)" 1 > /sys${DEVPATH}/macaddress
55 ;;
56 iodata,wn-ag300dgr)
57 # There is no eeprom data for 5 GHz wlan in "art" partition
58 # which would allow to patch the macaddress
59 [ "$PHYNBR" -eq 1 ] && \
60 macaddr_add "$(mtd_get_mac_ascii u-boot-env ethaddr)" 1 > /sys${DEVPATH}/macaddress
61 ;;
62 nec,wf1200cr|\
63 nec,wg1200cr)
64 [ "$PHYNBR" -eq 0 ] && \
65 mtd_get_mac_ascii devdata wlan5mac > /sys${DEVPATH}/macaddress
66 ;;
67 phicomm,k2t)
68 [ "$PHYNBR" -eq 0 ] && \
69 k2t_get_mac "5g_mac" > /sys${DEVPATH}/macaddress
70 # The K2T factory firmware does use LAN mac address as the 2.4G wifi mac address
71 [ "$PHYNBR" -eq 1 ] && \
72 k2t_get_mac "lan_mac" > /sys${DEVPATH}/macaddress
73 ;;
74 siemens,ws-ap3610)
75 mtd_get_mac_ascii cfg1 RADIOADDR${PHYNBR} > /sys${DEVPATH}/macaddress
76 ;;
77 tplink,deco-s4-v2)
78 base_mac=$(mtd_get_mac_encrypted_deco $(find_mtd_part config))
79 [ "$PHYNBR" -eq 0 ] && \
80 macaddr_add $base_mac 2 > /sys${DEVPATH}/macaddress
81
82 ;;
83 trendnet,tew-823dru)
84 # set the 2.4G interface mac address to LAN MAC
85 [ "$PHYNBR" -eq 1 ] && \
86 mtd_get_mac_text mac 4 > /sys${DEVPATH}/macaddress
87 # set the 5G interface mac address to WAN MAC + 1
88 [ "$PHYNBR" -eq 0 ] && \
89 macaddr_add "$(mtd_get_mac_text mac 0x18)" 1 > /sys${DEVPATH}/macaddress
90 ;;
91 zyxel,nbg6616)
92 # Set mac address for 2.4g device
93 [ "$PHYNBR" -eq 1 ] && \
94 mtd_get_mac_ascii u-boot-env ethaddr > /sys${DEVPATH}/macaddress
95 ;;
96 zyxel,nwa1123-ac)
97 [ "$PHYNBR" -eq 0 ] && \
98 mtd_get_mac_text mib0 0x66 > /sys${DEVPATH}/macaddress
99 ;;
100 zyxel,nwa1123-ni)
101 [ "$PHYNBR" -eq 1 ] && \
102 mtd_get_mac_text mib0 0x66 > /sys${DEVPATH}/macaddress
103 ;;
104 esac