OSDN Git Service

ipq40xx: mikrotik: provide BDF-s on demand
[immortalwrt/immortalwrt.git] / target / linux / ipq40xx / base-files / etc / hotplug.d / firmware / 11-ath10k-caldata
1 #!/bin/sh
2
3 [ -e /lib/firmware/$FIRMWARE ] && exit 0
4
5 . /lib/functions/caldata.sh
6
7 board=$(board_name)
8
9 case "$FIRMWARE" in
10 "ath10k/cal-pci-0000:01:00.0.bin")
11         case "$board" in
12         meraki,mr33)
13                 caldata_extract_ubi "ART" 0x9000 0x844
14                 caldata_valid "4408" || caldata_extract "ART" 0x9000 0x844
15                 ath10k_patch_mac $(macaddr_add $(get_mac_binary "/sys/bus/i2c/devices/0-0050/eeprom" 0x66) 1)
16                 ;;
17         esac
18         ;;
19 "ath10k/pre-cal-pci-0000:01:00.0.bin")
20         case "$board" in
21         asus,map-ac2200)
22                 caldata_extract_ubi "Factory" 0x9000 0x2f20
23                 ln -sf /lib/firmware/ath10k/pre-cal-pci-0000\:00\:00.0.bin \
24                         /lib/firmware/ath10k/QCA9888/hw2.0/board.bin
25                 ;;
26         asus,rt-ac42u)
27                 caldata_extract_ubi "Factory" 0x9000 0x2f20
28                 ;;
29         avm,fritzrepeater-3000)
30                 /usr/bin/fritz_cal_extract -i 1 -s 0x3D000 -e 0x212 -l 12064 -o /lib/firmware/$FIRMWARE $(find_mtd_chardev "urlader0") || \
31                 /usr/bin/fritz_cal_extract -i 1 -s 0x3C800 -e 0x212 -l 12064 -o /lib/firmware/$FIRMWARE $(find_mtd_chardev "urlader0") || \
32                 /usr/bin/fritz_cal_extract -i 1 -s 0x3C000 -e 0x212 -l 12064 -o /lib/firmware/$FIRMWARE $(find_mtd_chardev "urlader0") || \
33                 /usr/bin/fritz_cal_extract -i 1 -s 0x3D000 -e 0x212 -l 12064 -o /lib/firmware/$FIRMWARE $(find_mtd_chardev "urlader1") || \
34                 /usr/bin/fritz_cal_extract -i 1 -s 0x3C800 -e 0x212 -l 12064 -o /lib/firmware/$FIRMWARE $(find_mtd_chardev "urlader1") || \
35                 /usr/bin/fritz_cal_extract -i 1 -s 0x3C000 -e 0x212 -l 12064 -o /lib/firmware/$FIRMWARE $(find_mtd_chardev "urlader1")
36                 ;;
37         openmesh,a62 |\
38         plasmacloud,pa2200)
39                 caldata_extract "0:ART" 0x9000 0x2f20
40                 ;;
41         linksys,ea8300 |\
42         linksys,mr8300)
43                 caldata_extract "ART" 0x9000 0x2f20
44                 # OEM assigns 4 sequential MACs
45                 ath10k_patch_mac $(macaddr_setbit_la $(macaddr_add "$(cat /sys/class/net/eth0/address)" 4))
46                 ;;
47         netgear,rbr50|\
48         netgear,rbs50|\
49         netgear,srr60|\
50         netgear,srs60)
51                 caldata_extract_mmc "0:ART" 0x9000 0x2f20
52                 ath10k_patch_mac $(mmc_get_mac_binary ARTMTD 0x12)
53                 ;;
54         esac
55         ;;
56 "ath10k/pre-cal-ahb-a000000.wifi.bin")
57         case "$board" in
58         qcom,ap-dk01.1-c1)
59                 caldata_extract "ART" 0x1000 0x2f20
60                 ;;
61         asus,map-ac2200|\
62         asus,rt-ac42u|\
63         asus,rt-ac58u)
64                 caldata_extract_ubi "Factory" 0x1000 0x2f20
65                 ;;
66         avm,fritzbox-4040)
67                 /usr/bin/fritz_cal_extract -i 1 -s 0x400 -e 0x207 -l 12064 -o /lib/firmware/$FIRMWARE $(find_mtd_chardev "urlader_config")
68                 ;;
69         avm,fritzbox-7530 |\
70         avm,fritzrepeater-1200 |\
71         avm,fritzrepeater-3000)
72                 /usr/bin/fritz_cal_extract -i 1 -s 0x3C000 -e 0x207 -l 12064 -o /lib/firmware/$FIRMWARE $(find_mtd_chardev "urlader0") || \
73                 /usr/bin/fritz_cal_extract -i 1 -s 0x3C800 -e 0x207 -l 12064 -o /lib/firmware/$FIRMWARE $(find_mtd_chardev "urlader0") || \
74                 /usr/bin/fritz_cal_extract -i 1 -s 0x3D000 -e 0x207 -l 12064 -o /lib/firmware/$FIRMWARE $(find_mtd_chardev "urlader0") || \
75                 /usr/bin/fritz_cal_extract -i 1 -s 0x3C000 -e 0x207 -l 12064 -o /lib/firmware/$FIRMWARE $(find_mtd_chardev "urlader1") || \
76                 /usr/bin/fritz_cal_extract -i 1 -s 0x3C800 -e 0x207 -l 12064 -o /lib/firmware/$FIRMWARE $(find_mtd_chardev "urlader1") || \
77                 /usr/bin/fritz_cal_extract -i 1 -s 0x3D000 -e 0x207 -l 12064 -o /lib/firmware/$FIRMWARE $(find_mtd_chardev "urlader1")
78                 ;;
79         cellc,rtl30vw |\
80         openmesh,a42 |\
81         openmesh,a62 |\
82         plasmacloud,pa1200 |\
83         plasmacloud,pa2200)
84                 caldata_extract "0:ART" 0x1000 0x2f20
85                 ;;
86         devolo,magic-2-wifi-next)
87                 caldata_extract "ART" 0x1000 0x2f20
88                 ath10k_patch_mac $(mtd_get_mac_ascii APPSBLENV WiFiMacAddress0)
89                 ;;
90         dlink,dap-2610)
91                 caldata_extract "ART" 0x1000 0x2f20
92                 ath10k_patch_mac $(mtd_get_mac_ascii bdcfg wlanmac)
93                 ;;
94         engenius,emd1)
95                 caldata_extract "0:ART" 0x1000 0x2f20
96                 ath10k_patch_mac $(mtd_get_mac_ascii 0:APPSBLENV wlanaddr)
97                 ;;
98         engenius,emr3500)
99                 caldata_extract "0:ART" 0x1000 0x2f20
100                 ath10k_patch_mac $(mtd_get_mac_ascii 0:APPSBLENV ethaddr)
101                 ;;
102         engenius,ens620ext)
103                 caldata_extract "ART" 0x1000 0x2f20
104                 ath10k_patch_mac $(macaddr_add $(mtd_get_mac_ascii u-boot-env ethaddr) 2)
105                 ;;
106         linksys,ea8300 |\
107         linksys,mr8300)
108                 caldata_extract "ART" 0x1000 0x2f20
109                 ath10k_patch_mac $(macaddr_add "$(cat /sys/class/net/eth0/address)" 2)
110                 ;;
111         meraki,mr33)
112                 caldata_extract_ubi "ART" 0x1000 0x2f20
113                 caldata_valid "202f" || caldata_extract "ART" 0x1000 0x2f20
114                 ath10k_patch_mac $(macaddr_add $(get_mac_binary "/sys/bus/i2c/devices/0-0050/eeprom" 0x66) 2)
115                 ;;
116         mikrotik,cap-ac |\
117         mikrotik,hap-ac2 |\
118         mikrotik,hap-ac3)
119                 wlan_data="/sys/firmware/mikrotik/hard_config/wlan_data"
120                 ( [ -f "$wlan_data" ] && caldata_sysfsload_from_file "$wlan_data" 0x0 0x2f20 ) || \
121                 ( [ -d "$wlan_data" ] && caldata_sysfsload_from_file "$wlan_data/data_0" 0x0 0x2f20 )
122                 ;;
123         netgear,rbr50|\
124         netgear,rbs50|\
125         netgear,srr60|\
126         netgear,srs60)
127                 caldata_extract_mmc "0:ART" 0x1000 0x2f20
128                 ath10k_patch_mac $(mmc_get_mac_binary ARTMTD 0x0)
129                 ;;
130         zyxel,nbg6617 |\
131         zyxel,wre6606)
132                 caldata_extract "ART" 0x1000 0x2f20
133                 ath10k_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) -2)
134                 ;;
135         esac
136         ;;
137 "ath10k/pre-cal-ahb-a800000.wifi.bin")
138         case "$board" in
139         qcom,ap-dk01.1-c1)
140                 caldata_extract "ART" 0x5000 0x2f20
141                 ;;
142         asus,map-ac2200|\
143         asus,rt-ac58u)
144                 caldata_extract_ubi "Factory" 0x5000 0x2f20
145                 ;;
146         avm,fritzbox-4040)
147                 /usr/bin/fritz_cal_extract -i 1 -s 0x400 -e 0x208 -l 12064 -o /lib/firmware/$FIRMWARE $(find_mtd_chardev "urlader_config")
148                 ;;
149         avm,fritzbox-7530 |\
150         avm,fritzrepeater-1200 |\
151         avm,fritzrepeater-3000)
152                 /usr/bin/fritz_cal_extract -i 1 -s 0x3C800 -e 0x208 -l 12064 -o /lib/firmware/$FIRMWARE $(find_mtd_chardev "urlader0") || \
153                 /usr/bin/fritz_cal_extract -i 1 -s 0x3D000 -e 0x208 -l 12064 -o /lib/firmware/$FIRMWARE $(find_mtd_chardev "urlader0") || \
154                 /usr/bin/fritz_cal_extract -i 1 -s 0x3C000 -e 0x208 -l 12064 -o /lib/firmware/$FIRMWARE $(find_mtd_chardev "urlader0") || \
155                 /usr/bin/fritz_cal_extract -i 1 -s 0x3C800 -e 0x208 -l 12064 -o /lib/firmware/$FIRMWARE $(find_mtd_chardev "urlader1") || \
156                 /usr/bin/fritz_cal_extract -i 1 -s 0x3D000 -e 0x208 -l 12064 -o /lib/firmware/$FIRMWARE $(find_mtd_chardev "urlader1") || \
157                 /usr/bin/fritz_cal_extract -i 1 -s 0x3C000 -e 0x208 -l 12064 -o /lib/firmware/$FIRMWARE $(find_mtd_chardev "urlader1")
158                 ;;
159         cellc,rtl30vw |\
160         openmesh,a42 |\
161         openmesh,a62 |\
162         plasmacloud,pa1200 |\
163         plasmacloud,pa2200)
164                 caldata_extract "0:ART" 0x5000 0x2f20
165                 ;;
166         devolo,magic-2-wifi-next)
167                 caldata_extract "ART" 0x5000 0x2f20
168                 ath10k_patch_mac $(mtd_get_mac_ascii APPSBLENV WiFiMacAddress1)
169                 ;;
170         dlink,dap-2610)
171                 caldata_extract "ART" 0x5000 0x2f20
172                 ath10k_patch_mac $(mtd_get_mac_ascii bdcfg wlanmac_a)
173                 ;;
174         engenius,emd1)
175                 caldata_extract "0:ART" 0x5000 0x2f20
176                 ath10k_patch_mac $(macaddr_add $(mtd_get_mac_ascii 0:APPSBLENV wlanaddr) 1)
177                 ;;
178         engenius,emr3500)
179                 caldata_extract "0:ART" 0x5000 0x2f20
180                 ath10k_patch_mac $(macaddr_add $(mtd_get_mac_ascii 0:APPSBLENV ethaddr) 1)
181                 ;;
182         engenius,ens620ext)
183                 caldata_extract "ART" 0x5000 0x2f20
184                 ath10k_patch_mac $(macaddr_add $(mtd_get_mac_ascii u-boot-env ethaddr) 3)
185                 ;;
186         linksys,ea8300 |\
187         linksys,mr8300)
188                 caldata_extract "ART" 0x5000 0x2f20
189                 ath10k_patch_mac $(macaddr_add "$(cat /sys/class/net/eth0/address)" 3)
190                 ;;
191         meraki,mr33)
192                 caldata_extract_ubi "ART" 0x5000 0x2f20
193                 caldata_valid "202f" || caldata_extract "ART" 0x5000 0x2f20
194                 ath10k_patch_mac $(macaddr_add $(get_mac_binary "/sys/bus/i2c/devices/0-0050/eeprom" 0x66) 3)
195                 ;;
196         mikrotik,cap-ac |\
197         mikrotik,hap-ac2 |\
198         mikrotik,hap-ac3 |\
199         mikrotik,sxtsq-5-ac)
200                 wlan_data="/sys/firmware/mikrotik/hard_config/wlan_data"
201                 ( [ -f "$wlan_data" ] && caldata_sysfsload_from_file "$wlan_data" 0x8000 0x2f20 ) || \
202                 ( [ -d "$wlan_data" ] && caldata_sysfsload_from_file "$wlan_data/data_2" 0x0 0x2f20 )
203                 ;;
204         netgear,rbr50|\
205         netgear,rbs50|\
206         netgear,srr60|\
207         netgear,srs60)
208                 caldata_extract_mmc "0:ART" 0x5000 0x2f20
209                 ath10k_patch_mac $(mmc_get_mac_binary ARTMTD 0xc)
210                 ;;
211         zyxel,nbg6617 |\
212         zyxel,wre6606)
213                 caldata_extract "ART" 0x5000 0x2f20
214                 ath10k_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) -1)
215                 ;;
216         esac
217         ;;
218 "ath10k/QCA4019/hw1.0/board-ahb-a000000.wifi.bin")
219         case "$board" in
220         mikrotik,cap-ac |\
221         mikrotik,hap-ac2 |\
222         mikrotik,hap-ac3)
223                 wlan_data="/sys/firmware/mikrotik/hard_config/wlan_data"
224                 ( [ -f "$wlan_data" ] && caldata_sysfsload_from_file "$wlan_data" 0x2f20 0x2f20 ) || \
225                 ( [ -d "$wlan_data" ] && caldata_sysfsload_from_file "$wlan_data/data_0" 0x2f20 0x2f20 )
226                 ;;
227         esac
228         ;;
229 "ath10k/QCA4019/hw1.0/board-ahb-a800000.wifi.bin")
230         case "$board" in
231         mikrotik,cap-ac |\
232         mikrotik,hap-ac2 |\
233         mikrotik,hap-ac3 |\
234         mikrotik,sxtsq-5-ac)
235                 wlan_data="/sys/firmware/mikrotik/hard_config/wlan_data"
236                 ( [ -f "$wlan_data" ] && caldata_sysfsload_from_file "$wlan_data" 0xaf20 0x2f20 ) || \
237                 ( [ -d "$wlan_data" ] && caldata_sysfsload_from_file "$wlan_data/data_2" 0x2f20 0x2f20 )
238                 ;;
239         esac
240         ;;
241 *)
242         exit 1
243         ;;
244 esac