2 * Copyright (c) 2005-2011 Atheros Communications Inc.
3 * Copyright (c) 2011-2017 Qualcomm Atheros, Inc.
5 * Permission to use, copy, modify, and/or distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 #include <linux/module.h>
19 #include <linux/firmware.h>
21 #include <linux/dmi.h>
22 #include <linux/ctype.h>
23 #include <asm/byteorder.h>
37 unsigned int ath10k_debug_mask
;
38 static unsigned int ath10k_cryptmode_param
;
39 static bool uart_print
;
43 /* Enable ATH10K_FW_CRASH_DUMP_REGISTERS and ATH10K_FW_CRASH_DUMP_CE_DATA
46 unsigned long ath10k_coredump_mask
= 0x3;
48 /* FIXME: most of these should be readonly */
49 module_param_named(debug_mask
, ath10k_debug_mask
, uint
, 0644);
50 module_param_named(cryptmode
, ath10k_cryptmode_param
, uint
, 0644);
51 module_param(uart_print
, bool, 0644);
52 module_param(skip_otp
, bool, 0644);
53 module_param(rawmode
, bool, 0644);
54 module_param_named(coredump_mask
, ath10k_coredump_mask
, ulong
, 0444);
56 MODULE_PARM_DESC(debug_mask
, "Debugging mask");
57 MODULE_PARM_DESC(uart_print
, "Uart target debugging");
58 MODULE_PARM_DESC(skip_otp
, "Skip otp failure for calibration in testmode");
59 MODULE_PARM_DESC(cryptmode
, "Crypto mode: 0-hardware, 1-software");
60 MODULE_PARM_DESC(rawmode
, "Use raw 802.11 frame datapath");
61 MODULE_PARM_DESC(coredump_mask
, "Bitfield of what to include in firmware crash file");
63 static const struct ath10k_hw_params ath10k_hw_params_list
[] = {
65 .id
= QCA988X_HW_2_0_VERSION
,
66 .dev_id
= QCA988X_2_0_DEVICE_ID
,
67 .name
= "qca988x hw2.0",
68 .patch_load_addr
= QCA988X_HW_2_0_PATCH_LOAD_ADDR
,
70 .cc_wraparound_type
= ATH10K_HW_CC_WRAP_SHIFTED_ALL
,
72 .channel_counters_freq_hz
= 88000,
73 .max_probe_resp_desc_thres
= 0,
76 .dir
= QCA988X_HW_2_0_FW_DIR
,
77 .board
= QCA988X_HW_2_0_BOARD_DATA_FILE
,
78 .board_size
= QCA988X_BOARD_DATA_SZ
,
79 .board_ext_size
= QCA988X_BOARD_EXT_DATA_SZ
,
81 .hw_ops
= &qca988x_ops
,
82 .decap_align_bytes
= 4,
83 .spectral_bin_discard
= 0,
84 .vht160_mcs_rx_highest
= 0,
85 .vht160_mcs_tx_highest
= 0,
87 .num_peers
= TARGET_TLV_NUM_PEERS
,
88 .ast_skid_limit
= 0x10,
89 .num_wds_entries
= 0x20,
90 .target_64bit
= false,
91 .rx_ring_fill_level
= HTT_RX_RING_FILL_LEVEL
,
94 .id
= QCA988X_HW_2_0_VERSION
,
95 .dev_id
= QCA988X_2_0_DEVICE_ID_UBNT
,
96 .name
= "qca988x hw2.0 ubiquiti",
97 .patch_load_addr
= QCA988X_HW_2_0_PATCH_LOAD_ADDR
,
99 .cc_wraparound_type
= ATH10K_HW_CC_WRAP_SHIFTED_ALL
,
101 .channel_counters_freq_hz
= 88000,
102 .max_probe_resp_desc_thres
= 0,
103 .cal_data_len
= 2116,
105 .dir
= QCA988X_HW_2_0_FW_DIR
,
106 .board
= QCA988X_HW_2_0_BOARD_DATA_FILE
,
107 .board_size
= QCA988X_BOARD_DATA_SZ
,
108 .board_ext_size
= QCA988X_BOARD_EXT_DATA_SZ
,
110 .hw_ops
= &qca988x_ops
,
111 .decap_align_bytes
= 4,
112 .spectral_bin_discard
= 0,
113 .vht160_mcs_rx_highest
= 0,
114 .vht160_mcs_tx_highest
= 0,
115 .n_cipher_suites
= 8,
116 .num_peers
= TARGET_TLV_NUM_PEERS
,
117 .ast_skid_limit
= 0x10,
118 .num_wds_entries
= 0x20,
119 .target_64bit
= false,
120 .rx_ring_fill_level
= HTT_RX_RING_FILL_LEVEL
,
123 .id
= QCA9887_HW_1_0_VERSION
,
124 .dev_id
= QCA9887_1_0_DEVICE_ID
,
125 .name
= "qca9887 hw1.0",
126 .patch_load_addr
= QCA9887_HW_1_0_PATCH_LOAD_ADDR
,
128 .cc_wraparound_type
= ATH10K_HW_CC_WRAP_SHIFTED_ALL
,
130 .channel_counters_freq_hz
= 88000,
131 .max_probe_resp_desc_thres
= 0,
132 .cal_data_len
= 2116,
134 .dir
= QCA9887_HW_1_0_FW_DIR
,
135 .board
= QCA9887_HW_1_0_BOARD_DATA_FILE
,
136 .board_size
= QCA9887_BOARD_DATA_SZ
,
137 .board_ext_size
= QCA9887_BOARD_EXT_DATA_SZ
,
139 .hw_ops
= &qca988x_ops
,
140 .decap_align_bytes
= 4,
141 .spectral_bin_discard
= 0,
142 .vht160_mcs_rx_highest
= 0,
143 .vht160_mcs_tx_highest
= 0,
144 .n_cipher_suites
= 8,
145 .num_peers
= TARGET_TLV_NUM_PEERS
,
146 .ast_skid_limit
= 0x10,
147 .num_wds_entries
= 0x20,
148 .target_64bit
= false,
149 .rx_ring_fill_level
= HTT_RX_RING_FILL_LEVEL
,
152 .id
= QCA6174_HW_2_1_VERSION
,
153 .dev_id
= QCA6164_2_1_DEVICE_ID
,
154 .name
= "qca6164 hw2.1",
155 .patch_load_addr
= QCA6174_HW_2_1_PATCH_LOAD_ADDR
,
158 .channel_counters_freq_hz
= 88000,
159 .max_probe_resp_desc_thres
= 0,
160 .cal_data_len
= 8124,
162 .dir
= QCA6174_HW_2_1_FW_DIR
,
163 .board
= QCA6174_HW_2_1_BOARD_DATA_FILE
,
164 .board_size
= QCA6174_BOARD_DATA_SZ
,
165 .board_ext_size
= QCA6174_BOARD_EXT_DATA_SZ
,
167 .hw_ops
= &qca988x_ops
,
168 .decap_align_bytes
= 4,
169 .spectral_bin_discard
= 0,
170 .vht160_mcs_rx_highest
= 0,
171 .vht160_mcs_tx_highest
= 0,
172 .n_cipher_suites
= 8,
173 .num_peers
= TARGET_TLV_NUM_PEERS
,
174 .ast_skid_limit
= 0x10,
175 .num_wds_entries
= 0x20,
176 .target_64bit
= false,
177 .rx_ring_fill_level
= HTT_RX_RING_FILL_LEVEL
,
180 .id
= QCA6174_HW_2_1_VERSION
,
181 .dev_id
= QCA6174_2_1_DEVICE_ID
,
182 .name
= "qca6174 hw2.1",
183 .patch_load_addr
= QCA6174_HW_2_1_PATCH_LOAD_ADDR
,
186 .channel_counters_freq_hz
= 88000,
187 .max_probe_resp_desc_thres
= 0,
188 .cal_data_len
= 8124,
190 .dir
= QCA6174_HW_2_1_FW_DIR
,
191 .board
= QCA6174_HW_2_1_BOARD_DATA_FILE
,
192 .board_size
= QCA6174_BOARD_DATA_SZ
,
193 .board_ext_size
= QCA6174_BOARD_EXT_DATA_SZ
,
195 .hw_ops
= &qca988x_ops
,
196 .decap_align_bytes
= 4,
197 .spectral_bin_discard
= 0,
198 .vht160_mcs_rx_highest
= 0,
199 .vht160_mcs_tx_highest
= 0,
200 .n_cipher_suites
= 8,
201 .num_peers
= TARGET_TLV_NUM_PEERS
,
202 .ast_skid_limit
= 0x10,
203 .num_wds_entries
= 0x20,
204 .target_64bit
= false,
205 .rx_ring_fill_level
= HTT_RX_RING_FILL_LEVEL
,
208 .id
= QCA6174_HW_3_0_VERSION
,
209 .dev_id
= QCA6174_2_1_DEVICE_ID
,
210 .name
= "qca6174 hw3.0",
211 .patch_load_addr
= QCA6174_HW_3_0_PATCH_LOAD_ADDR
,
214 .channel_counters_freq_hz
= 88000,
215 .max_probe_resp_desc_thres
= 0,
216 .cal_data_len
= 8124,
218 .dir
= QCA6174_HW_3_0_FW_DIR
,
219 .board
= QCA6174_HW_3_0_BOARD_DATA_FILE
,
220 .board_size
= QCA6174_BOARD_DATA_SZ
,
221 .board_ext_size
= QCA6174_BOARD_EXT_DATA_SZ
,
223 .hw_ops
= &qca988x_ops
,
224 .decap_align_bytes
= 4,
225 .spectral_bin_discard
= 0,
226 .vht160_mcs_rx_highest
= 0,
227 .vht160_mcs_tx_highest
= 0,
228 .n_cipher_suites
= 8,
229 .num_peers
= TARGET_TLV_NUM_PEERS
,
230 .ast_skid_limit
= 0x10,
231 .num_wds_entries
= 0x20,
232 .target_64bit
= false,
233 .rx_ring_fill_level
= HTT_RX_RING_FILL_LEVEL
,
236 .id
= QCA6174_HW_3_2_VERSION
,
237 .dev_id
= QCA6174_2_1_DEVICE_ID
,
238 .name
= "qca6174 hw3.2",
239 .patch_load_addr
= QCA6174_HW_3_0_PATCH_LOAD_ADDR
,
242 .channel_counters_freq_hz
= 88000,
243 .max_probe_resp_desc_thres
= 0,
244 .cal_data_len
= 8124,
246 /* uses same binaries as hw3.0 */
247 .dir
= QCA6174_HW_3_0_FW_DIR
,
248 .board
= QCA6174_HW_3_0_BOARD_DATA_FILE
,
249 .board_size
= QCA6174_BOARD_DATA_SZ
,
250 .board_ext_size
= QCA6174_BOARD_EXT_DATA_SZ
,
252 .hw_ops
= &qca6174_ops
,
253 .hw_clk
= qca6174_clk
,
254 .target_cpu_freq
= 176000000,
255 .decap_align_bytes
= 4,
256 .spectral_bin_discard
= 0,
257 .vht160_mcs_rx_highest
= 0,
258 .vht160_mcs_tx_highest
= 0,
259 .n_cipher_suites
= 8,
260 .num_peers
= TARGET_TLV_NUM_PEERS
,
261 .ast_skid_limit
= 0x10,
262 .num_wds_entries
= 0x20,
263 .target_64bit
= false,
264 .rx_ring_fill_level
= HTT_RX_RING_FILL_LEVEL
,
267 .id
= QCA99X0_HW_2_0_DEV_VERSION
,
268 .dev_id
= QCA99X0_2_0_DEVICE_ID
,
269 .name
= "qca99x0 hw2.0",
270 .patch_load_addr
= QCA99X0_HW_2_0_PATCH_LOAD_ADDR
,
272 .otp_exe_param
= 0x00000700,
273 .continuous_frag_desc
= true,
274 .cck_rate_map_rev2
= true,
275 .channel_counters_freq_hz
= 150000,
276 .max_probe_resp_desc_thres
= 24,
277 .tx_chain_mask
= 0xf,
278 .rx_chain_mask
= 0xf,
279 .max_spatial_stream
= 4,
280 .cal_data_len
= 12064,
282 .dir
= QCA99X0_HW_2_0_FW_DIR
,
283 .board
= QCA99X0_HW_2_0_BOARD_DATA_FILE
,
284 .board_size
= QCA99X0_BOARD_DATA_SZ
,
285 .board_ext_size
= QCA99X0_BOARD_EXT_DATA_SZ
,
287 .sw_decrypt_mcast_mgmt
= true,
288 .hw_ops
= &qca99x0_ops
,
289 .decap_align_bytes
= 1,
290 .spectral_bin_discard
= 4,
291 .vht160_mcs_rx_highest
= 0,
292 .vht160_mcs_tx_highest
= 0,
293 .n_cipher_suites
= 11,
294 .num_peers
= TARGET_TLV_NUM_PEERS
,
295 .ast_skid_limit
= 0x10,
296 .num_wds_entries
= 0x20,
297 .target_64bit
= false,
298 .rx_ring_fill_level
= HTT_RX_RING_FILL_LEVEL
,
301 .id
= QCA9984_HW_1_0_DEV_VERSION
,
302 .dev_id
= QCA9984_1_0_DEVICE_ID
,
303 .name
= "qca9984/qca9994 hw1.0",
304 .patch_load_addr
= QCA9984_HW_1_0_PATCH_LOAD_ADDR
,
306 .cc_wraparound_type
= ATH10K_HW_CC_WRAP_SHIFTED_EACH
,
307 .otp_exe_param
= 0x00000700,
308 .continuous_frag_desc
= true,
309 .cck_rate_map_rev2
= true,
310 .channel_counters_freq_hz
= 150000,
311 .max_probe_resp_desc_thres
= 24,
312 .tx_chain_mask
= 0xf,
313 .rx_chain_mask
= 0xf,
314 .max_spatial_stream
= 4,
315 .cal_data_len
= 12064,
317 .dir
= QCA9984_HW_1_0_FW_DIR
,
318 .board
= QCA9984_HW_1_0_BOARD_DATA_FILE
,
319 .board_size
= QCA99X0_BOARD_DATA_SZ
,
320 .board_ext_size
= QCA99X0_BOARD_EXT_DATA_SZ
,
322 .sw_decrypt_mcast_mgmt
= true,
323 .hw_ops
= &qca99x0_ops
,
324 .decap_align_bytes
= 1,
325 .spectral_bin_discard
= 12,
327 /* Can do only 2x2 VHT160 or 80+80. 1560Mbps is 4x4 80Mhz
328 * or 2x2 160Mhz, long-guard-interval.
330 .vht160_mcs_rx_highest
= 1560,
331 .vht160_mcs_tx_highest
= 1560,
332 .n_cipher_suites
= 11,
333 .num_peers
= TARGET_TLV_NUM_PEERS
,
334 .ast_skid_limit
= 0x10,
335 .num_wds_entries
= 0x20,
336 .target_64bit
= false,
337 .rx_ring_fill_level
= HTT_RX_RING_FILL_LEVEL
,
340 .id
= QCA9888_HW_2_0_DEV_VERSION
,
341 .dev_id
= QCA9888_2_0_DEVICE_ID
,
342 .name
= "qca9888 hw2.0",
343 .patch_load_addr
= QCA9888_HW_2_0_PATCH_LOAD_ADDR
,
345 .cc_wraparound_type
= ATH10K_HW_CC_WRAP_SHIFTED_EACH
,
346 .otp_exe_param
= 0x00000700,
347 .continuous_frag_desc
= true,
348 .channel_counters_freq_hz
= 150000,
349 .max_probe_resp_desc_thres
= 24,
352 .max_spatial_stream
= 2,
353 .cal_data_len
= 12064,
355 .dir
= QCA9888_HW_2_0_FW_DIR
,
356 .board
= QCA9888_HW_2_0_BOARD_DATA_FILE
,
357 .board_size
= QCA99X0_BOARD_DATA_SZ
,
358 .board_ext_size
= QCA99X0_BOARD_EXT_DATA_SZ
,
360 .sw_decrypt_mcast_mgmt
= true,
361 .hw_ops
= &qca99x0_ops
,
362 .decap_align_bytes
= 1,
363 .spectral_bin_discard
= 12,
365 /* Can do only 1x1 VHT160 or 80+80. 780Mbps is 2x2 80Mhz or
366 * 1x1 160Mhz, long-guard-interval.
368 .vht160_mcs_rx_highest
= 780,
369 .vht160_mcs_tx_highest
= 780,
370 .n_cipher_suites
= 11,
371 .num_peers
= TARGET_TLV_NUM_PEERS
,
372 .ast_skid_limit
= 0x10,
373 .num_wds_entries
= 0x20,
374 .target_64bit
= false,
375 .rx_ring_fill_level
= HTT_RX_RING_FILL_LEVEL
,
378 .id
= QCA9377_HW_1_0_DEV_VERSION
,
379 .dev_id
= QCA9377_1_0_DEVICE_ID
,
380 .name
= "qca9377 hw1.0",
381 .patch_load_addr
= QCA9377_HW_1_0_PATCH_LOAD_ADDR
,
384 .channel_counters_freq_hz
= 88000,
385 .max_probe_resp_desc_thres
= 0,
386 .cal_data_len
= 8124,
388 .dir
= QCA9377_HW_1_0_FW_DIR
,
389 .board
= QCA9377_HW_1_0_BOARD_DATA_FILE
,
390 .board_size
= QCA9377_BOARD_DATA_SZ
,
391 .board_ext_size
= QCA9377_BOARD_EXT_DATA_SZ
,
393 .hw_ops
= &qca988x_ops
,
394 .decap_align_bytes
= 4,
395 .spectral_bin_discard
= 0,
396 .vht160_mcs_rx_highest
= 0,
397 .vht160_mcs_tx_highest
= 0,
398 .n_cipher_suites
= 8,
399 .num_peers
= TARGET_TLV_NUM_PEERS
,
400 .ast_skid_limit
= 0x10,
401 .num_wds_entries
= 0x20,
402 .target_64bit
= false,
403 .rx_ring_fill_level
= HTT_RX_RING_FILL_LEVEL
,
406 .id
= QCA9377_HW_1_1_DEV_VERSION
,
407 .dev_id
= QCA9377_1_0_DEVICE_ID
,
408 .name
= "qca9377 hw1.1",
409 .patch_load_addr
= QCA9377_HW_1_0_PATCH_LOAD_ADDR
,
412 .channel_counters_freq_hz
= 88000,
413 .max_probe_resp_desc_thres
= 0,
414 .cal_data_len
= 8124,
416 .dir
= QCA9377_HW_1_0_FW_DIR
,
417 .board
= QCA9377_HW_1_0_BOARD_DATA_FILE
,
418 .board_size
= QCA9377_BOARD_DATA_SZ
,
419 .board_ext_size
= QCA9377_BOARD_EXT_DATA_SZ
,
421 .hw_ops
= &qca6174_ops
,
422 .hw_clk
= qca6174_clk
,
423 .target_cpu_freq
= 176000000,
424 .decap_align_bytes
= 4,
425 .spectral_bin_discard
= 0,
426 .vht160_mcs_rx_highest
= 0,
427 .vht160_mcs_tx_highest
= 0,
428 .n_cipher_suites
= 8,
429 .num_peers
= TARGET_TLV_NUM_PEERS
,
430 .ast_skid_limit
= 0x10,
431 .num_wds_entries
= 0x20,
432 .target_64bit
= false,
433 .rx_ring_fill_level
= HTT_RX_RING_FILL_LEVEL
,
436 .id
= QCA4019_HW_1_0_DEV_VERSION
,
438 .name
= "qca4019 hw1.0",
439 .patch_load_addr
= QCA4019_HW_1_0_PATCH_LOAD_ADDR
,
441 .cc_wraparound_type
= ATH10K_HW_CC_WRAP_SHIFTED_EACH
,
442 .otp_exe_param
= 0x0010000,
443 .continuous_frag_desc
= true,
444 .cck_rate_map_rev2
= true,
445 .channel_counters_freq_hz
= 125000,
446 .max_probe_resp_desc_thres
= 24,
447 .tx_chain_mask
= 0x3,
448 .rx_chain_mask
= 0x3,
449 .max_spatial_stream
= 2,
450 .cal_data_len
= 12064,
452 .dir
= QCA4019_HW_1_0_FW_DIR
,
453 .board
= QCA4019_HW_1_0_BOARD_DATA_FILE
,
454 .board_size
= QCA4019_BOARD_DATA_SZ
,
455 .board_ext_size
= QCA4019_BOARD_EXT_DATA_SZ
,
457 .sw_decrypt_mcast_mgmt
= true,
458 .hw_ops
= &qca99x0_ops
,
459 .decap_align_bytes
= 1,
460 .spectral_bin_discard
= 4,
461 .vht160_mcs_rx_highest
= 0,
462 .vht160_mcs_tx_highest
= 0,
463 .n_cipher_suites
= 11,
464 .num_peers
= TARGET_TLV_NUM_PEERS
,
465 .ast_skid_limit
= 0x10,
466 .num_wds_entries
= 0x20,
467 .target_64bit
= false,
468 .rx_ring_fill_level
= HTT_RX_RING_FILL_LEVEL
,
471 .id
= WCN3990_HW_1_0_DEV_VERSION
,
473 .name
= "wcn3990 hw1.0",
474 .continuous_frag_desc
= true,
475 .tx_chain_mask
= 0x7,
476 .rx_chain_mask
= 0x7,
477 .max_spatial_stream
= 4,
479 .dir
= WCN3990_HW_1_0_FW_DIR
,
481 .sw_decrypt_mcast_mgmt
= true,
482 .hw_ops
= &wcn3990_ops
,
483 .decap_align_bytes
= 1,
484 .num_peers
= TARGET_HL_10_TLV_NUM_PEERS
,
485 .ast_skid_limit
= TARGET_HL_10_TLV_AST_SKID_LIMIT
,
486 .num_wds_entries
= TARGET_HL_10_TLV_NUM_WDS_ENTRIES
,
487 .target_64bit
= true,
488 .rx_ring_fill_level
= HTT_RX_RING_FILL_LEVEL_DUAL_MAC
,
492 static const char *const ath10k_core_fw_feature_str
[] = {
493 [ATH10K_FW_FEATURE_EXT_WMI_MGMT_RX
] = "wmi-mgmt-rx",
494 [ATH10K_FW_FEATURE_WMI_10X
] = "wmi-10.x",
495 [ATH10K_FW_FEATURE_HAS_WMI_MGMT_TX
] = "has-wmi-mgmt-tx",
496 [ATH10K_FW_FEATURE_NO_P2P
] = "no-p2p",
497 [ATH10K_FW_FEATURE_WMI_10_2
] = "wmi-10.2",
498 [ATH10K_FW_FEATURE_MULTI_VIF_PS_SUPPORT
] = "multi-vif-ps",
499 [ATH10K_FW_FEATURE_WOWLAN_SUPPORT
] = "wowlan",
500 [ATH10K_FW_FEATURE_IGNORE_OTP_RESULT
] = "ignore-otp",
501 [ATH10K_FW_FEATURE_NO_NWIFI_DECAP_4ADDR_PADDING
] = "no-4addr-pad",
502 [ATH10K_FW_FEATURE_SUPPORTS_SKIP_CLOCK_INIT
] = "skip-clock-init",
503 [ATH10K_FW_FEATURE_RAW_MODE_SUPPORT
] = "raw-mode",
504 [ATH10K_FW_FEATURE_SUPPORTS_ADAPTIVE_CCA
] = "adaptive-cca",
505 [ATH10K_FW_FEATURE_MFP_SUPPORT
] = "mfp",
506 [ATH10K_FW_FEATURE_PEER_FLOW_CONTROL
] = "peer-flow-ctrl",
507 [ATH10K_FW_FEATURE_BTCOEX_PARAM
] = "btcoex-param",
508 [ATH10K_FW_FEATURE_SKIP_NULL_FUNC_WAR
] = "skip-null-func-war",
509 [ATH10K_FW_FEATURE_ALLOWS_MESH_BCAST
] = "allows-mesh-bcast",
510 [ATH10K_FW_FEATURE_NO_PS
] = "no-ps",
511 [ATH10K_FW_FEATURE_MGMT_TX_BY_REF
] = "mgmt-tx-by-reference",
512 [ATH10K_FW_FEATURE_NON_BMI
] = "non-bmi",
515 static unsigned int ath10k_core_get_fw_feature_str(char *buf
,
517 enum ath10k_fw_features feat
)
519 /* make sure that ath10k_core_fw_feature_str[] gets updated */
520 BUILD_BUG_ON(ARRAY_SIZE(ath10k_core_fw_feature_str
) !=
521 ATH10K_FW_FEATURE_COUNT
);
523 if (feat
>= ARRAY_SIZE(ath10k_core_fw_feature_str
) ||
524 WARN_ON(!ath10k_core_fw_feature_str
[feat
])) {
525 return scnprintf(buf
, buf_len
, "bit%d", feat
);
528 return scnprintf(buf
, buf_len
, "%s", ath10k_core_fw_feature_str
[feat
]);
531 void ath10k_core_get_fw_features_str(struct ath10k
*ar
,
538 for (i
= 0; i
< ATH10K_FW_FEATURE_COUNT
; i
++) {
539 if (test_bit(i
, ar
->normal_mode_fw
.fw_file
.fw_features
)) {
541 len
+= scnprintf(buf
+ len
, buf_len
- len
, ",");
543 len
+= ath10k_core_get_fw_feature_str(buf
+ len
,
550 static void ath10k_send_suspend_complete(struct ath10k
*ar
)
552 ath10k_dbg(ar
, ATH10K_DBG_BOOT
, "boot suspend complete\n");
554 complete(&ar
->target_suspend
);
557 static void ath10k_init_sdio(struct ath10k
*ar
)
561 ath10k_bmi_write32(ar
, hi_mbox_io_block_sz
, 256);
562 ath10k_bmi_write32(ar
, hi_mbox_isr_yield_limit
, 99);
563 ath10k_bmi_read32(ar
, hi_acs_flags
, ¶m
);
565 param
|= (HI_ACS_FLAGS_SDIO_SWAP_MAILBOX_SET
|
566 HI_ACS_FLAGS_SDIO_REDUCE_TX_COMPL_SET
|
567 HI_ACS_FLAGS_ALT_DATA_CREDIT_SIZE
);
569 ath10k_bmi_write32(ar
, hi_acs_flags
, param
);
572 static int ath10k_init_configure_target(struct ath10k
*ar
)
577 /* tell target which HTC version it is used*/
578 ret
= ath10k_bmi_write32(ar
, hi_app_host_interest
,
579 HTC_PROTOCOL_VERSION
);
581 ath10k_err(ar
, "settings HTC version failed\n");
585 /* set the firmware mode to STA/IBSS/AP */
586 ret
= ath10k_bmi_read32(ar
, hi_option_flag
, ¶m_host
);
588 ath10k_err(ar
, "setting firmware mode (1/2) failed\n");
592 /* TODO following parameters need to be re-visited. */
594 param_host
|= (1 << HI_OPTION_NUM_DEV_SHIFT
);
596 /* FIXME: Why FW_MODE_AP ??.*/
597 param_host
|= (HI_OPTION_FW_MODE_AP
<< HI_OPTION_FW_MODE_SHIFT
);
598 /* mac_addr_method */
599 param_host
|= (1 << HI_OPTION_MAC_ADDR_METHOD_SHIFT
);
600 /* firmware_bridge */
601 param_host
|= (0 << HI_OPTION_FW_BRIDGE_SHIFT
);
603 param_host
|= (0 << HI_OPTION_FW_SUBMODE_SHIFT
);
605 ret
= ath10k_bmi_write32(ar
, hi_option_flag
, param_host
);
607 ath10k_err(ar
, "setting firmware mode (2/2) failed\n");
611 /* We do all byte-swapping on the host */
612 ret
= ath10k_bmi_write32(ar
, hi_be
, 0);
614 ath10k_err(ar
, "setting host CPU BE mode failed\n");
618 /* FW descriptor/Data swap flags */
619 ret
= ath10k_bmi_write32(ar
, hi_fw_swap
, 0);
622 ath10k_err(ar
, "setting FW data/desc swap flags failed\n");
626 /* Some devices have a special sanity check that verifies the PCI
627 * Device ID is written to this host interest var. It is known to be
628 * required to boot QCA6164.
630 ret
= ath10k_bmi_write32(ar
, hi_hci_uart_pwr_mgmt_params_ext
,
633 ath10k_err(ar
, "failed to set pwr_mgmt_params: %d\n", ret
);
640 static const struct firmware
*ath10k_fetch_fw_file(struct ath10k
*ar
,
645 const struct firmware
*fw
;
649 return ERR_PTR(-ENOENT
);
654 snprintf(filename
, sizeof(filename
), "%s/%s", dir
, file
);
655 ret
= request_firmware(&fw
, filename
, ar
->dev
);
656 ath10k_dbg(ar
, ATH10K_DBG_BOOT
, "boot fw request '%s': %d\n",
665 static int ath10k_push_board_ext_data(struct ath10k
*ar
, const void *data
,
668 u32 board_data_size
= ar
->hw_params
.fw
.board_size
;
669 u32 board_ext_data_size
= ar
->hw_params
.fw
.board_ext_size
;
670 u32 board_ext_data_addr
;
673 ret
= ath10k_bmi_read32(ar
, hi_board_ext_data
, &board_ext_data_addr
);
675 ath10k_err(ar
, "could not read board ext data addr (%d)\n",
680 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
681 "boot push board extended data addr 0x%x\n",
682 board_ext_data_addr
);
684 if (board_ext_data_addr
== 0)
687 if (data_len
!= (board_data_size
+ board_ext_data_size
)) {
688 ath10k_err(ar
, "invalid board (ext) data sizes %zu != %d+%d\n",
689 data_len
, board_data_size
, board_ext_data_size
);
693 ret
= ath10k_bmi_write_memory(ar
, board_ext_data_addr
,
694 data
+ board_data_size
,
695 board_ext_data_size
);
697 ath10k_err(ar
, "could not write board ext data (%d)\n", ret
);
701 ret
= ath10k_bmi_write32(ar
, hi_board_ext_data_config
,
702 (board_ext_data_size
<< 16) | 1);
704 ath10k_err(ar
, "could not write board ext data bit (%d)\n",
712 static int ath10k_download_board_data(struct ath10k
*ar
, const void *data
,
715 u32 board_data_size
= ar
->hw_params
.fw
.board_size
;
719 ret
= ath10k_push_board_ext_data(ar
, data
, data_len
);
721 ath10k_err(ar
, "could not push board ext data (%d)\n", ret
);
725 ret
= ath10k_bmi_read32(ar
, hi_board_data
, &address
);
727 ath10k_err(ar
, "could not read board data addr (%d)\n", ret
);
731 ret
= ath10k_bmi_write_memory(ar
, address
, data
,
732 min_t(u32
, board_data_size
,
735 ath10k_err(ar
, "could not write board data (%d)\n", ret
);
739 ret
= ath10k_bmi_write32(ar
, hi_board_data_initialized
, 1);
741 ath10k_err(ar
, "could not write board data bit (%d)\n", ret
);
749 static int ath10k_download_cal_file(struct ath10k
*ar
,
750 const struct firmware
*file
)
758 return PTR_ERR(file
);
760 ret
= ath10k_download_board_data(ar
, file
->data
, file
->size
);
762 ath10k_err(ar
, "failed to download cal_file data: %d\n", ret
);
766 ath10k_dbg(ar
, ATH10K_DBG_BOOT
, "boot cal file downloaded\n");
771 static int ath10k_download_cal_dt(struct ath10k
*ar
, const char *dt_name
)
773 struct device_node
*node
;
778 node
= ar
->dev
->of_node
;
780 /* Device Tree is optional, don't print any warnings if
781 * there's no node for ath10k.
785 if (!of_get_property(node
, dt_name
, &data_len
)) {
786 /* The calibration data node is optional */
790 if (data_len
!= ar
->hw_params
.cal_data_len
) {
791 ath10k_warn(ar
, "invalid calibration data length in DT: %d\n",
797 data
= kmalloc(data_len
, GFP_KERNEL
);
803 ret
= of_property_read_u8_array(node
, dt_name
, data
, data_len
);
805 ath10k_warn(ar
, "failed to read calibration data from DT: %d\n",
810 ret
= ath10k_download_board_data(ar
, data
, data_len
);
812 ath10k_warn(ar
, "failed to download calibration data from Device Tree: %d\n",
826 static int ath10k_download_cal_eeprom(struct ath10k
*ar
)
832 ret
= ath10k_hif_fetch_cal_eeprom(ar
, &data
, &data_len
);
834 if (ret
!= -EOPNOTSUPP
)
835 ath10k_warn(ar
, "failed to read calibration data from EEPROM: %d\n",
840 ret
= ath10k_download_board_data(ar
, data
, data_len
);
842 ath10k_warn(ar
, "failed to download calibration data from EEPROM: %d\n",
855 static int ath10k_core_get_board_id_from_otp(struct ath10k
*ar
)
858 u8 board_id
, chip_id
;
859 int ret
, bmi_board_id_param
;
861 address
= ar
->hw_params
.patch_load_addr
;
863 if (!ar
->normal_mode_fw
.fw_file
.otp_data
||
864 !ar
->normal_mode_fw
.fw_file
.otp_len
) {
866 "failed to retrieve board id because of invalid otp\n");
870 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
871 "boot upload otp to 0x%x len %zd for board id\n",
872 address
, ar
->normal_mode_fw
.fw_file
.otp_len
);
874 ret
= ath10k_bmi_fast_download(ar
, address
,
875 ar
->normal_mode_fw
.fw_file
.otp_data
,
876 ar
->normal_mode_fw
.fw_file
.otp_len
);
878 ath10k_err(ar
, "could not write otp for board id check: %d\n",
883 if (ar
->cal_mode
== ATH10K_PRE_CAL_MODE_DT
||
884 ar
->cal_mode
== ATH10K_PRE_CAL_MODE_FILE
)
885 bmi_board_id_param
= BMI_PARAM_GET_FLASH_BOARD_ID
;
887 bmi_board_id_param
= BMI_PARAM_GET_EEPROM_BOARD_ID
;
889 ret
= ath10k_bmi_execute(ar
, address
, bmi_board_id_param
, &result
);
891 ath10k_err(ar
, "could not execute otp for board id check: %d\n",
896 board_id
= MS(result
, ATH10K_BMI_BOARD_ID_FROM_OTP
);
897 chip_id
= MS(result
, ATH10K_BMI_CHIP_ID_FROM_OTP
);
899 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
900 "boot get otp board id result 0x%08x board_id %d chip_id %d\n",
901 result
, board_id
, chip_id
);
903 if ((result
& ATH10K_BMI_BOARD_ID_STATUS_MASK
) != 0 ||
905 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
906 "board id does not exist in otp, ignore it\n");
910 ar
->id
.bmi_ids_valid
= true;
911 ar
->id
.bmi_board_id
= board_id
;
912 ar
->id
.bmi_chip_id
= chip_id
;
917 static void ath10k_core_check_bdfext(const struct dmi_header
*hdr
, void *data
)
919 struct ath10k
*ar
= data
;
921 const char *magic
= ATH10K_SMBIOS_BDF_EXT_MAGIC
;
925 if (hdr
->type
!= ATH10K_SMBIOS_BDF_EXT_TYPE
)
928 if (hdr
->length
!= ATH10K_SMBIOS_BDF_EXT_LENGTH
) {
929 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
930 "wrong smbios bdf ext type length (%d).\n",
935 bdf_enabled
= *((u8
*)hdr
+ ATH10K_SMBIOS_BDF_EXT_OFFSET
);
937 ath10k_dbg(ar
, ATH10K_DBG_BOOT
, "bdf variant name not found.\n");
941 /* Only one string exists (per spec) */
942 bdf_ext
= (char *)hdr
+ hdr
->length
;
944 if (memcmp(bdf_ext
, magic
, strlen(magic
)) != 0) {
945 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
946 "bdf variant magic does not match.\n");
950 for (i
= 0; i
< strlen(bdf_ext
); i
++) {
951 if (!isascii(bdf_ext
[i
]) || !isprint(bdf_ext
[i
])) {
952 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
953 "bdf variant name contains non ascii chars.\n");
958 /* Copy extension name without magic suffix */
959 if (strscpy(ar
->id
.bdf_ext
, bdf_ext
+ strlen(magic
),
960 sizeof(ar
->id
.bdf_ext
)) < 0) {
961 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
962 "bdf variant string is longer than the buffer can accommodate (variant: %s)\n",
967 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
968 "found and validated bdf variant smbios_type 0x%x bdf %s\n",
969 ATH10K_SMBIOS_BDF_EXT_TYPE
, bdf_ext
);
972 static int ath10k_core_check_smbios(struct ath10k
*ar
)
974 ar
->id
.bdf_ext
[0] = '\0';
975 dmi_walk(ath10k_core_check_bdfext
, ar
);
977 if (ar
->id
.bdf_ext
[0] == '\0')
983 static int ath10k_core_check_dt(struct ath10k
*ar
)
985 struct device_node
*node
;
986 const char *variant
= NULL
;
988 node
= ar
->dev
->of_node
;
992 of_property_read_string(node
, "qcom,ath10k-calibration-variant",
997 if (strscpy(ar
->id
.bdf_ext
, variant
, sizeof(ar
->id
.bdf_ext
)) < 0)
998 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
999 "bdf variant string is longer than the buffer can accommodate (variant: %s)\n",
1005 static int ath10k_download_and_run_otp(struct ath10k
*ar
)
1007 u32 result
, address
= ar
->hw_params
.patch_load_addr
;
1008 u32 bmi_otp_exe_param
= ar
->hw_params
.otp_exe_param
;
1011 ret
= ath10k_download_board_data(ar
,
1012 ar
->running_fw
->board_data
,
1013 ar
->running_fw
->board_len
);
1015 ath10k_err(ar
, "failed to download board data: %d\n", ret
);
1019 /* OTP is optional */
1021 if (!ar
->running_fw
->fw_file
.otp_data
||
1022 !ar
->running_fw
->fw_file
.otp_len
) {
1023 ath10k_warn(ar
, "Not running otp, calibration will be incorrect (otp-data %pK otp_len %zd)!\n",
1024 ar
->running_fw
->fw_file
.otp_data
,
1025 ar
->running_fw
->fw_file
.otp_len
);
1029 ath10k_dbg(ar
, ATH10K_DBG_BOOT
, "boot upload otp to 0x%x len %zd\n",
1030 address
, ar
->running_fw
->fw_file
.otp_len
);
1032 ret
= ath10k_bmi_fast_download(ar
, address
,
1033 ar
->running_fw
->fw_file
.otp_data
,
1034 ar
->running_fw
->fw_file
.otp_len
);
1036 ath10k_err(ar
, "could not write otp (%d)\n", ret
);
1040 /* As of now pre-cal is valid for 10_4 variants */
1041 if (ar
->cal_mode
== ATH10K_PRE_CAL_MODE_DT
||
1042 ar
->cal_mode
== ATH10K_PRE_CAL_MODE_FILE
)
1043 bmi_otp_exe_param
= BMI_PARAM_FLASH_SECTION_ALL
;
1045 ret
= ath10k_bmi_execute(ar
, address
, bmi_otp_exe_param
, &result
);
1047 ath10k_err(ar
, "could not execute otp (%d)\n", ret
);
1051 ath10k_dbg(ar
, ATH10K_DBG_BOOT
, "boot otp execute result %d\n", result
);
1053 if (!(skip_otp
|| test_bit(ATH10K_FW_FEATURE_IGNORE_OTP_RESULT
,
1054 ar
->running_fw
->fw_file
.fw_features
)) &&
1056 ath10k_err(ar
, "otp calibration failed: %d", result
);
1063 static int ath10k_download_fw(struct ath10k
*ar
)
1065 u32 address
, data_len
;
1069 address
= ar
->hw_params
.patch_load_addr
;
1071 data
= ar
->running_fw
->fw_file
.firmware_data
;
1072 data_len
= ar
->running_fw
->fw_file
.firmware_len
;
1074 ret
= ath10k_swap_code_seg_configure(ar
, &ar
->running_fw
->fw_file
);
1076 ath10k_err(ar
, "failed to configure fw code swap: %d\n",
1081 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
1082 "boot uploading firmware image %pK len %d\n",
1085 ret
= ath10k_bmi_fast_download(ar
, address
, data
, data_len
);
1087 ath10k_err(ar
, "failed to download firmware: %d\n",
1095 static void ath10k_core_free_board_files(struct ath10k
*ar
)
1097 if (!IS_ERR(ar
->normal_mode_fw
.board
))
1098 release_firmware(ar
->normal_mode_fw
.board
);
1100 ar
->normal_mode_fw
.board
= NULL
;
1101 ar
->normal_mode_fw
.board_data
= NULL
;
1102 ar
->normal_mode_fw
.board_len
= 0;
1105 static void ath10k_core_free_firmware_files(struct ath10k
*ar
)
1107 if (!IS_ERR(ar
->normal_mode_fw
.fw_file
.firmware
))
1108 release_firmware(ar
->normal_mode_fw
.fw_file
.firmware
);
1110 if (!IS_ERR(ar
->cal_file
))
1111 release_firmware(ar
->cal_file
);
1113 if (!IS_ERR(ar
->pre_cal_file
))
1114 release_firmware(ar
->pre_cal_file
);
1116 ath10k_swap_code_seg_release(ar
, &ar
->normal_mode_fw
.fw_file
);
1118 ar
->normal_mode_fw
.fw_file
.otp_data
= NULL
;
1119 ar
->normal_mode_fw
.fw_file
.otp_len
= 0;
1121 ar
->normal_mode_fw
.fw_file
.firmware
= NULL
;
1122 ar
->normal_mode_fw
.fw_file
.firmware_data
= NULL
;
1123 ar
->normal_mode_fw
.fw_file
.firmware_len
= 0;
1125 ar
->cal_file
= NULL
;
1126 ar
->pre_cal_file
= NULL
;
1129 static int ath10k_fetch_cal_file(struct ath10k
*ar
)
1133 /* pre-cal-<bus>-<id>.bin */
1134 scnprintf(filename
, sizeof(filename
), "pre-cal-%s-%s.bin",
1135 ath10k_bus_str(ar
->hif
.bus
), dev_name(ar
->dev
));
1137 ar
->pre_cal_file
= ath10k_fetch_fw_file(ar
, ATH10K_FW_DIR
, filename
);
1138 if (!IS_ERR(ar
->pre_cal_file
))
1141 /* cal-<bus>-<id>.bin */
1142 scnprintf(filename
, sizeof(filename
), "cal-%s-%s.bin",
1143 ath10k_bus_str(ar
->hif
.bus
), dev_name(ar
->dev
));
1145 ar
->cal_file
= ath10k_fetch_fw_file(ar
, ATH10K_FW_DIR
, filename
);
1146 if (IS_ERR(ar
->cal_file
))
1147 /* calibration file is optional, don't print any warnings */
1148 return PTR_ERR(ar
->cal_file
);
1150 ath10k_dbg(ar
, ATH10K_DBG_BOOT
, "found calibration file %s/%s\n",
1151 ATH10K_FW_DIR
, filename
);
1156 static int ath10k_core_fetch_board_data_api_1(struct ath10k
*ar
)
1158 if (!ar
->hw_params
.fw
.board
) {
1159 ath10k_err(ar
, "failed to find board file fw entry\n");
1163 ar
->normal_mode_fw
.board
= ath10k_fetch_fw_file(ar
,
1164 ar
->hw_params
.fw
.dir
,
1165 ar
->hw_params
.fw
.board
);
1166 if (IS_ERR(ar
->normal_mode_fw
.board
))
1167 return PTR_ERR(ar
->normal_mode_fw
.board
);
1169 ar
->normal_mode_fw
.board_data
= ar
->normal_mode_fw
.board
->data
;
1170 ar
->normal_mode_fw
.board_len
= ar
->normal_mode_fw
.board
->size
;
1175 static int ath10k_core_parse_bd_ie_board(struct ath10k
*ar
,
1176 const void *buf
, size_t buf_len
,
1177 const char *boardname
)
1179 const struct ath10k_fw_ie
*hdr
;
1180 bool name_match_found
;
1181 int ret
, board_ie_id
;
1182 size_t board_ie_len
;
1183 const void *board_ie_data
;
1185 name_match_found
= false;
1187 /* go through ATH10K_BD_IE_BOARD_ elements */
1188 while (buf_len
> sizeof(struct ath10k_fw_ie
)) {
1190 board_ie_id
= le32_to_cpu(hdr
->id
);
1191 board_ie_len
= le32_to_cpu(hdr
->len
);
1192 board_ie_data
= hdr
->data
;
1194 buf_len
-= sizeof(*hdr
);
1195 buf
+= sizeof(*hdr
);
1197 if (buf_len
< ALIGN(board_ie_len
, 4)) {
1198 ath10k_err(ar
, "invalid ATH10K_BD_IE_BOARD length: %zu < %zu\n",
1199 buf_len
, ALIGN(board_ie_len
, 4));
1204 switch (board_ie_id
) {
1205 case ATH10K_BD_IE_BOARD_NAME
:
1206 ath10k_dbg_dump(ar
, ATH10K_DBG_BOOT
, "board name", "",
1207 board_ie_data
, board_ie_len
);
1209 if (board_ie_len
!= strlen(boardname
))
1212 ret
= memcmp(board_ie_data
, boardname
, strlen(boardname
));
1216 name_match_found
= true;
1217 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
1218 "boot found match for name '%s'",
1221 case ATH10K_BD_IE_BOARD_DATA
:
1222 if (!name_match_found
)
1223 /* no match found */
1226 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
1227 "boot found board data for '%s'",
1230 ar
->normal_mode_fw
.board_data
= board_ie_data
;
1231 ar
->normal_mode_fw
.board_len
= board_ie_len
;
1236 ath10k_warn(ar
, "unknown ATH10K_BD_IE_BOARD found: %d\n",
1241 /* jump over the padding */
1242 board_ie_len
= ALIGN(board_ie_len
, 4);
1244 buf_len
-= board_ie_len
;
1245 buf
+= board_ie_len
;
1248 /* no match found */
1255 static int ath10k_core_fetch_board_data_api_n(struct ath10k
*ar
,
1256 const char *boardname
,
1257 const char *filename
)
1259 size_t len
, magic_len
, ie_len
;
1260 struct ath10k_fw_ie
*hdr
;
1264 ar
->normal_mode_fw
.board
= ath10k_fetch_fw_file(ar
,
1265 ar
->hw_params
.fw
.dir
,
1267 if (IS_ERR(ar
->normal_mode_fw
.board
))
1268 return PTR_ERR(ar
->normal_mode_fw
.board
);
1270 data
= ar
->normal_mode_fw
.board
->data
;
1271 len
= ar
->normal_mode_fw
.board
->size
;
1273 /* magic has extra null byte padded */
1274 magic_len
= strlen(ATH10K_BOARD_MAGIC
) + 1;
1275 if (len
< magic_len
) {
1276 ath10k_err(ar
, "failed to find magic value in %s/%s, file too short: %zu\n",
1277 ar
->hw_params
.fw
.dir
, filename
, len
);
1282 if (memcmp(data
, ATH10K_BOARD_MAGIC
, magic_len
)) {
1283 ath10k_err(ar
, "found invalid board magic\n");
1288 /* magic is padded to 4 bytes */
1289 magic_len
= ALIGN(magic_len
, 4);
1290 if (len
< magic_len
) {
1291 ath10k_err(ar
, "failed: %s/%s too small to contain board data, len: %zu\n",
1292 ar
->hw_params
.fw
.dir
, filename
, len
);
1300 while (len
> sizeof(struct ath10k_fw_ie
)) {
1301 hdr
= (struct ath10k_fw_ie
*)data
;
1302 ie_id
= le32_to_cpu(hdr
->id
);
1303 ie_len
= le32_to_cpu(hdr
->len
);
1305 len
-= sizeof(*hdr
);
1308 if (len
< ALIGN(ie_len
, 4)) {
1309 ath10k_err(ar
, "invalid length for board ie_id %d ie_len %zu len %zu\n",
1310 ie_id
, ie_len
, len
);
1316 case ATH10K_BD_IE_BOARD
:
1317 ret
= ath10k_core_parse_bd_ie_board(ar
, data
, ie_len
,
1319 if (ret
== -ENOENT
&& ar
->id
.bdf_ext
[0] != '\0') {
1320 /* try default bdf if variant was not found */
1321 char *s
, *v
= ",variant=";
1322 char boardname2
[100];
1324 strlcpy(boardname2
, boardname
,
1325 sizeof(boardname2
));
1327 s
= strstr(boardname2
, v
);
1329 *s
= '\0'; /* strip ",variant=%s" */
1331 ret
= ath10k_core_parse_bd_ie_board(ar
, data
,
1337 /* no match found, continue */
1340 /* there was an error, bail out */
1343 /* board data found */
1347 /* jump over the padding */
1348 ie_len
= ALIGN(ie_len
, 4);
1355 if (!ar
->normal_mode_fw
.board_data
|| !ar
->normal_mode_fw
.board_len
) {
1357 "failed to fetch board data for %s from %s/%s\n",
1358 boardname
, ar
->hw_params
.fw
.dir
, filename
);
1366 ath10k_core_free_board_files(ar
);
1370 static int ath10k_core_create_board_name(struct ath10k
*ar
, char *name
,
1373 /* strlen(',variant=') + strlen(ar->id.bdf_ext) */
1374 char variant
[9 + ATH10K_SMBIOS_BDF_EXT_STR_LENGTH
] = { 0 };
1376 if (ar
->id
.bdf_ext
[0] != '\0')
1377 scnprintf(variant
, sizeof(variant
), ",variant=%s",
1380 if (ar
->id
.bmi_ids_valid
) {
1381 scnprintf(name
, name_len
,
1382 "bus=%s,bmi-chip-id=%d,bmi-board-id=%d%s",
1383 ath10k_bus_str(ar
->hif
.bus
),
1385 ar
->id
.bmi_board_id
, variant
);
1389 scnprintf(name
, name_len
,
1390 "bus=%s,vendor=%04x,device=%04x,subsystem-vendor=%04x,subsystem-device=%04x%s",
1391 ath10k_bus_str(ar
->hif
.bus
),
1392 ar
->id
.vendor
, ar
->id
.device
,
1393 ar
->id
.subsystem_vendor
, ar
->id
.subsystem_device
, variant
);
1395 ath10k_dbg(ar
, ATH10K_DBG_BOOT
, "boot using board name '%s'\n", name
);
1400 static int ath10k_core_fetch_board_file(struct ath10k
*ar
)
1402 char boardname
[100];
1405 ret
= ath10k_core_create_board_name(ar
, boardname
, sizeof(boardname
));
1407 ath10k_err(ar
, "failed to create board name: %d", ret
);
1412 ret
= ath10k_core_fetch_board_data_api_n(ar
, boardname
,
1413 ATH10K_BOARD_API2_FILE
);
1418 ret
= ath10k_core_fetch_board_data_api_1(ar
);
1420 ath10k_err(ar
, "failed to fetch board-2.bin or board.bin from %s\n",
1421 ar
->hw_params
.fw
.dir
);
1426 ath10k_dbg(ar
, ATH10K_DBG_BOOT
, "using board api %d\n", ar
->bd_api
);
1430 int ath10k_core_fetch_firmware_api_n(struct ath10k
*ar
, const char *name
,
1431 struct ath10k_fw_file
*fw_file
)
1433 size_t magic_len
, len
, ie_len
;
1434 int ie_id
, i
, index
, bit
, ret
;
1435 struct ath10k_fw_ie
*hdr
;
1437 __le32
*timestamp
, *version
;
1439 /* first fetch the firmware file (firmware-*.bin) */
1440 fw_file
->firmware
= ath10k_fetch_fw_file(ar
, ar
->hw_params
.fw
.dir
,
1442 if (IS_ERR(fw_file
->firmware
))
1443 return PTR_ERR(fw_file
->firmware
);
1445 data
= fw_file
->firmware
->data
;
1446 len
= fw_file
->firmware
->size
;
1448 /* magic also includes the null byte, check that as well */
1449 magic_len
= strlen(ATH10K_FIRMWARE_MAGIC
) + 1;
1451 if (len
< magic_len
) {
1452 ath10k_err(ar
, "firmware file '%s/%s' too small to contain magic: %zu\n",
1453 ar
->hw_params
.fw
.dir
, name
, len
);
1458 if (memcmp(data
, ATH10K_FIRMWARE_MAGIC
, magic_len
) != 0) {
1459 ath10k_err(ar
, "invalid firmware magic\n");
1464 /* jump over the padding */
1465 magic_len
= ALIGN(magic_len
, 4);
1471 while (len
> sizeof(struct ath10k_fw_ie
)) {
1472 hdr
= (struct ath10k_fw_ie
*)data
;
1474 ie_id
= le32_to_cpu(hdr
->id
);
1475 ie_len
= le32_to_cpu(hdr
->len
);
1477 len
-= sizeof(*hdr
);
1478 data
+= sizeof(*hdr
);
1481 ath10k_err(ar
, "invalid length for FW IE %d (%zu < %zu)\n",
1482 ie_id
, len
, ie_len
);
1488 case ATH10K_FW_IE_FW_VERSION
:
1489 if (ie_len
> sizeof(fw_file
->fw_version
) - 1)
1492 memcpy(fw_file
->fw_version
, data
, ie_len
);
1493 fw_file
->fw_version
[ie_len
] = '\0';
1495 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
1496 "found fw version %s\n",
1497 fw_file
->fw_version
);
1499 case ATH10K_FW_IE_TIMESTAMP
:
1500 if (ie_len
!= sizeof(u32
))
1503 timestamp
= (__le32
*)data
;
1505 ath10k_dbg(ar
, ATH10K_DBG_BOOT
, "found fw timestamp %d\n",
1506 le32_to_cpup(timestamp
));
1508 case ATH10K_FW_IE_FEATURES
:
1509 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
1510 "found firmware features ie (%zd B)\n",
1513 for (i
= 0; i
< ATH10K_FW_FEATURE_COUNT
; i
++) {
1517 if (index
== ie_len
)
1520 if (data
[index
] & (1 << bit
)) {
1521 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
1522 "Enabling feature bit: %i\n",
1524 __set_bit(i
, fw_file
->fw_features
);
1528 ath10k_dbg_dump(ar
, ATH10K_DBG_BOOT
, "features", "",
1529 fw_file
->fw_features
,
1530 sizeof(fw_file
->fw_features
));
1532 case ATH10K_FW_IE_FW_IMAGE
:
1533 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
1534 "found fw image ie (%zd B)\n",
1537 fw_file
->firmware_data
= data
;
1538 fw_file
->firmware_len
= ie_len
;
1541 case ATH10K_FW_IE_OTP_IMAGE
:
1542 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
1543 "found otp image ie (%zd B)\n",
1546 fw_file
->otp_data
= data
;
1547 fw_file
->otp_len
= ie_len
;
1550 case ATH10K_FW_IE_WMI_OP_VERSION
:
1551 if (ie_len
!= sizeof(u32
))
1554 version
= (__le32
*)data
;
1556 fw_file
->wmi_op_version
= le32_to_cpup(version
);
1558 ath10k_dbg(ar
, ATH10K_DBG_BOOT
, "found fw ie wmi op version %d\n",
1559 fw_file
->wmi_op_version
);
1561 case ATH10K_FW_IE_HTT_OP_VERSION
:
1562 if (ie_len
!= sizeof(u32
))
1565 version
= (__le32
*)data
;
1567 fw_file
->htt_op_version
= le32_to_cpup(version
);
1569 ath10k_dbg(ar
, ATH10K_DBG_BOOT
, "found fw ie htt op version %d\n",
1570 fw_file
->htt_op_version
);
1572 case ATH10K_FW_IE_FW_CODE_SWAP_IMAGE
:
1573 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
1574 "found fw code swap image ie (%zd B)\n",
1576 fw_file
->codeswap_data
= data
;
1577 fw_file
->codeswap_len
= ie_len
;
1580 ath10k_warn(ar
, "Unknown FW IE: %u\n",
1581 le32_to_cpu(hdr
->id
));
1585 /* jump over the padding */
1586 ie_len
= ALIGN(ie_len
, 4);
1592 if (!test_bit(ATH10K_FW_FEATURE_NON_BMI
, fw_file
->fw_features
) &&
1593 (!fw_file
->firmware_data
|| !fw_file
->firmware_len
)) {
1594 ath10k_warn(ar
, "No ATH10K_FW_IE_FW_IMAGE found from '%s/%s', skipping\n",
1595 ar
->hw_params
.fw
.dir
, name
);
1603 ath10k_core_free_firmware_files(ar
);
1607 static void ath10k_core_get_fw_name(struct ath10k
*ar
, char *fw_name
,
1608 size_t fw_name_len
, int fw_api
)
1610 switch (ar
->hif
.bus
) {
1611 case ATH10K_BUS_SDIO
:
1612 case ATH10K_BUS_USB
:
1613 scnprintf(fw_name
, fw_name_len
, "%s-%s-%d.bin",
1614 ATH10K_FW_FILE_BASE
, ath10k_bus_str(ar
->hif
.bus
),
1617 case ATH10K_BUS_PCI
:
1618 case ATH10K_BUS_AHB
:
1619 case ATH10K_BUS_SNOC
:
1620 scnprintf(fw_name
, fw_name_len
, "%s-%d.bin",
1621 ATH10K_FW_FILE_BASE
, fw_api
);
1626 static int ath10k_core_fetch_firmware_files(struct ath10k
*ar
)
1631 /* calibration file is optional, don't check for any errors */
1632 ath10k_fetch_cal_file(ar
);
1634 for (i
= ATH10K_FW_API_MAX
; i
>= ATH10K_FW_API_MIN
; i
--) {
1636 ath10k_dbg(ar
, ATH10K_DBG_BOOT
, "trying fw api %d\n",
1639 ath10k_core_get_fw_name(ar
, fw_name
, sizeof(fw_name
), ar
->fw_api
);
1640 ret
= ath10k_core_fetch_firmware_api_n(ar
, fw_name
,
1641 &ar
->normal_mode_fw
.fw_file
);
1646 /* we end up here if we couldn't fetch any firmware */
1648 ath10k_err(ar
, "Failed to find firmware-N.bin (N between %d and %d) from %s: %d",
1649 ATH10K_FW_API_MIN
, ATH10K_FW_API_MAX
, ar
->hw_params
.fw
.dir
,
1655 ath10k_dbg(ar
, ATH10K_DBG_BOOT
, "using fw api %d\n", ar
->fw_api
);
1660 static int ath10k_core_pre_cal_download(struct ath10k
*ar
)
1664 ret
= ath10k_download_cal_file(ar
, ar
->pre_cal_file
);
1666 ar
->cal_mode
= ATH10K_PRE_CAL_MODE_FILE
;
1670 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
1671 "boot did not find a pre calibration file, try DT next: %d\n",
1674 ret
= ath10k_download_cal_dt(ar
, "qcom,ath10k-pre-calibration-data");
1676 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
1677 "unable to load pre cal data from DT: %d\n", ret
);
1680 ar
->cal_mode
= ATH10K_PRE_CAL_MODE_DT
;
1683 ath10k_dbg(ar
, ATH10K_DBG_BOOT
, "boot using calibration mode %s\n",
1684 ath10k_cal_mode_str(ar
->cal_mode
));
1689 static int ath10k_core_pre_cal_config(struct ath10k
*ar
)
1693 ret
= ath10k_core_pre_cal_download(ar
);
1695 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
1696 "failed to load pre cal data: %d\n", ret
);
1700 ret
= ath10k_core_get_board_id_from_otp(ar
);
1702 ath10k_err(ar
, "failed to get board id: %d\n", ret
);
1706 ret
= ath10k_download_and_run_otp(ar
);
1708 ath10k_err(ar
, "failed to run otp: %d\n", ret
);
1712 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
1713 "pre cal configuration done successfully\n");
1718 static int ath10k_download_cal_data(struct ath10k
*ar
)
1722 ret
= ath10k_core_pre_cal_config(ar
);
1726 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
1727 "pre cal download procedure failed, try cal file: %d\n",
1730 ret
= ath10k_download_cal_file(ar
, ar
->cal_file
);
1732 ar
->cal_mode
= ATH10K_CAL_MODE_FILE
;
1736 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
1737 "boot did not find a calibration file, try DT next: %d\n",
1740 ret
= ath10k_download_cal_dt(ar
, "qcom,ath10k-calibration-data");
1742 ar
->cal_mode
= ATH10K_CAL_MODE_DT
;
1746 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
1747 "boot did not find DT entry, try target EEPROM next: %d\n",
1750 ret
= ath10k_download_cal_eeprom(ar
);
1752 ar
->cal_mode
= ATH10K_CAL_MODE_EEPROM
;
1756 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
1757 "boot did not find target EEPROM entry, try OTP next: %d\n",
1760 ret
= ath10k_download_and_run_otp(ar
);
1762 ath10k_err(ar
, "failed to run otp: %d\n", ret
);
1766 ar
->cal_mode
= ATH10K_CAL_MODE_OTP
;
1769 ath10k_dbg(ar
, ATH10K_DBG_BOOT
, "boot using calibration mode %s\n",
1770 ath10k_cal_mode_str(ar
->cal_mode
));
1774 static int ath10k_init_uart(struct ath10k
*ar
)
1779 * Explicitly setting UART prints to zero as target turns it on
1780 * based on scratch registers.
1782 ret
= ath10k_bmi_write32(ar
, hi_serial_enable
, 0);
1784 ath10k_warn(ar
, "could not disable UART prints (%d)\n", ret
);
1791 ret
= ath10k_bmi_write32(ar
, hi_dbg_uart_txpin
, ar
->hw_params
.uart_pin
);
1793 ath10k_warn(ar
, "could not enable UART prints (%d)\n", ret
);
1797 ret
= ath10k_bmi_write32(ar
, hi_serial_enable
, 1);
1799 ath10k_warn(ar
, "could not enable UART prints (%d)\n", ret
);
1803 /* Set the UART baud rate to 19200. */
1804 ret
= ath10k_bmi_write32(ar
, hi_desired_baud_rate
, 19200);
1806 ath10k_warn(ar
, "could not set the baud rate (%d)\n", ret
);
1810 ath10k_info(ar
, "UART prints enabled\n");
1814 static int ath10k_init_hw_params(struct ath10k
*ar
)
1816 const struct ath10k_hw_params
*uninitialized_var(hw_params
);
1819 for (i
= 0; i
< ARRAY_SIZE(ath10k_hw_params_list
); i
++) {
1820 hw_params
= &ath10k_hw_params_list
[i
];
1822 if (hw_params
->id
== ar
->target_version
&&
1823 hw_params
->dev_id
== ar
->dev_id
)
1827 if (i
== ARRAY_SIZE(ath10k_hw_params_list
)) {
1828 ath10k_err(ar
, "Unsupported hardware version: 0x%x\n",
1829 ar
->target_version
);
1833 ar
->hw_params
= *hw_params
;
1835 ath10k_dbg(ar
, ATH10K_DBG_BOOT
, "Hardware name %s version 0x%x\n",
1836 ar
->hw_params
.name
, ar
->target_version
);
1841 static void ath10k_core_restart(struct work_struct
*work
)
1843 struct ath10k
*ar
= container_of(work
, struct ath10k
, restart_work
);
1846 set_bit(ATH10K_FLAG_CRASH_FLUSH
, &ar
->dev_flags
);
1848 /* Place a barrier to make sure the compiler doesn't reorder
1849 * CRASH_FLUSH and calling other functions.
1853 ieee80211_stop_queues(ar
->hw
);
1854 ath10k_drain_tx(ar
);
1855 complete(&ar
->scan
.started
);
1856 complete(&ar
->scan
.completed
);
1857 complete(&ar
->scan
.on_channel
);
1858 complete(&ar
->offchan_tx_completed
);
1859 complete(&ar
->install_key_done
);
1860 complete(&ar
->vdev_setup_done
);
1861 complete(&ar
->thermal
.wmi_sync
);
1862 complete(&ar
->bss_survey_done
);
1863 wake_up(&ar
->htt
.empty_tx_wq
);
1864 wake_up(&ar
->wmi
.tx_credits_wq
);
1865 wake_up(&ar
->peer_mapping_wq
);
1867 /* TODO: We can have one instance of cancelling coverage_class_work by
1868 * moving it to ath10k_halt(), so that both stop() and restart() would
1869 * call that but it takes conf_mutex() and if we call cancel_work_sync()
1870 * with conf_mutex it will deadlock.
1872 cancel_work_sync(&ar
->set_coverage_class_work
);
1874 mutex_lock(&ar
->conf_mutex
);
1876 switch (ar
->state
) {
1877 case ATH10K_STATE_ON
:
1878 ar
->state
= ATH10K_STATE_RESTARTING
;
1880 ath10k_scan_finish(ar
);
1881 ieee80211_restart_hw(ar
->hw
);
1883 case ATH10K_STATE_OFF
:
1884 /* this can happen if driver is being unloaded
1885 * or if the crash happens during FW probing
1887 ath10k_warn(ar
, "cannot restart a device that hasn't been started\n");
1889 case ATH10K_STATE_RESTARTING
:
1890 /* hw restart might be requested from multiple places */
1892 case ATH10K_STATE_RESTARTED
:
1893 ar
->state
= ATH10K_STATE_WEDGED
;
1895 case ATH10K_STATE_WEDGED
:
1896 ath10k_warn(ar
, "device is wedged, will not restart\n");
1898 case ATH10K_STATE_UTF
:
1899 ath10k_warn(ar
, "firmware restart in UTF mode not supported\n");
1903 mutex_unlock(&ar
->conf_mutex
);
1905 ret
= ath10k_coredump_submit(ar
);
1907 ath10k_warn(ar
, "failed to send firmware crash dump via devcoredump: %d",
1911 static void ath10k_core_set_coverage_class_work(struct work_struct
*work
)
1913 struct ath10k
*ar
= container_of(work
, struct ath10k
,
1914 set_coverage_class_work
);
1916 if (ar
->hw_params
.hw_ops
->set_coverage_class
)
1917 ar
->hw_params
.hw_ops
->set_coverage_class(ar
, -1);
1920 static int ath10k_core_init_firmware_features(struct ath10k
*ar
)
1922 struct ath10k_fw_file
*fw_file
= &ar
->normal_mode_fw
.fw_file
;
1924 if (test_bit(ATH10K_FW_FEATURE_WMI_10_2
, fw_file
->fw_features
) &&
1925 !test_bit(ATH10K_FW_FEATURE_WMI_10X
, fw_file
->fw_features
)) {
1926 ath10k_err(ar
, "feature bits corrupted: 10.2 feature requires 10.x feature to be set as well");
1930 if (fw_file
->wmi_op_version
>= ATH10K_FW_WMI_OP_VERSION_MAX
) {
1931 ath10k_err(ar
, "unsupported WMI OP version (max %d): %d\n",
1932 ATH10K_FW_WMI_OP_VERSION_MAX
, fw_file
->wmi_op_version
);
1936 ar
->wmi
.rx_decap_mode
= ATH10K_HW_TXRX_NATIVE_WIFI
;
1937 switch (ath10k_cryptmode_param
) {
1938 case ATH10K_CRYPT_MODE_HW
:
1939 clear_bit(ATH10K_FLAG_RAW_MODE
, &ar
->dev_flags
);
1940 clear_bit(ATH10K_FLAG_HW_CRYPTO_DISABLED
, &ar
->dev_flags
);
1942 case ATH10K_CRYPT_MODE_SW
:
1943 if (!test_bit(ATH10K_FW_FEATURE_RAW_MODE_SUPPORT
,
1944 fw_file
->fw_features
)) {
1945 ath10k_err(ar
, "cryptmode > 0 requires raw mode support from firmware");
1949 set_bit(ATH10K_FLAG_RAW_MODE
, &ar
->dev_flags
);
1950 set_bit(ATH10K_FLAG_HW_CRYPTO_DISABLED
, &ar
->dev_flags
);
1953 ath10k_info(ar
, "invalid cryptmode: %d\n",
1954 ath10k_cryptmode_param
);
1958 ar
->htt
.max_num_amsdu
= ATH10K_HTT_MAX_NUM_AMSDU_DEFAULT
;
1959 ar
->htt
.max_num_ampdu
= ATH10K_HTT_MAX_NUM_AMPDU_DEFAULT
;
1962 if (!test_bit(ATH10K_FW_FEATURE_RAW_MODE_SUPPORT
,
1963 fw_file
->fw_features
)) {
1964 ath10k_err(ar
, "rawmode = 1 requires support from firmware");
1967 set_bit(ATH10K_FLAG_RAW_MODE
, &ar
->dev_flags
);
1970 if (test_bit(ATH10K_FLAG_RAW_MODE
, &ar
->dev_flags
)) {
1971 ar
->wmi
.rx_decap_mode
= ATH10K_HW_TXRX_RAW
;
1975 * Firmware A-MSDU aggregation breaks with RAW Tx encap mode
1976 * and causes enormous performance issues (malformed frames,
1979 * Disabling A-MSDU makes RAW mode stable with heavy traffic
1980 * albeit a bit slower compared to regular operation.
1982 ar
->htt
.max_num_amsdu
= 1;
1985 /* Backwards compatibility for firmwares without
1986 * ATH10K_FW_IE_WMI_OP_VERSION.
1988 if (fw_file
->wmi_op_version
== ATH10K_FW_WMI_OP_VERSION_UNSET
) {
1989 if (test_bit(ATH10K_FW_FEATURE_WMI_10X
, fw_file
->fw_features
)) {
1990 if (test_bit(ATH10K_FW_FEATURE_WMI_10_2
,
1991 fw_file
->fw_features
))
1992 fw_file
->wmi_op_version
= ATH10K_FW_WMI_OP_VERSION_10_2
;
1994 fw_file
->wmi_op_version
= ATH10K_FW_WMI_OP_VERSION_10_1
;
1996 fw_file
->wmi_op_version
= ATH10K_FW_WMI_OP_VERSION_MAIN
;
2000 switch (fw_file
->wmi_op_version
) {
2001 case ATH10K_FW_WMI_OP_VERSION_MAIN
:
2002 ar
->max_num_peers
= TARGET_NUM_PEERS
;
2003 ar
->max_num_stations
= TARGET_NUM_STATIONS
;
2004 ar
->max_num_vdevs
= TARGET_NUM_VDEVS
;
2005 ar
->htt
.max_num_pending_tx
= TARGET_NUM_MSDU_DESC
;
2006 ar
->fw_stats_req_mask
= WMI_STAT_PDEV
| WMI_STAT_VDEV
|
2008 ar
->max_spatial_stream
= WMI_MAX_SPATIAL_STREAM
;
2010 case ATH10K_FW_WMI_OP_VERSION_10_1
:
2011 case ATH10K_FW_WMI_OP_VERSION_10_2
:
2012 case ATH10K_FW_WMI_OP_VERSION_10_2_4
:
2013 if (ath10k_peer_stats_enabled(ar
)) {
2014 ar
->max_num_peers
= TARGET_10X_TX_STATS_NUM_PEERS
;
2015 ar
->max_num_stations
= TARGET_10X_TX_STATS_NUM_STATIONS
;
2017 ar
->max_num_peers
= TARGET_10X_NUM_PEERS
;
2018 ar
->max_num_stations
= TARGET_10X_NUM_STATIONS
;
2020 ar
->max_num_vdevs
= TARGET_10X_NUM_VDEVS
;
2021 ar
->htt
.max_num_pending_tx
= TARGET_10X_NUM_MSDU_DESC
;
2022 ar
->fw_stats_req_mask
= WMI_STAT_PEER
;
2023 ar
->max_spatial_stream
= WMI_MAX_SPATIAL_STREAM
;
2025 case ATH10K_FW_WMI_OP_VERSION_TLV
:
2026 ar
->max_num_peers
= TARGET_TLV_NUM_PEERS
;
2027 ar
->max_num_stations
= TARGET_TLV_NUM_STATIONS
;
2028 ar
->max_num_vdevs
= TARGET_TLV_NUM_VDEVS
;
2029 ar
->max_num_tdls_vdevs
= TARGET_TLV_NUM_TDLS_VDEVS
;
2030 ar
->htt
.max_num_pending_tx
= TARGET_TLV_NUM_MSDU_DESC
;
2031 ar
->wow
.max_num_patterns
= TARGET_TLV_NUM_WOW_PATTERNS
;
2032 ar
->fw_stats_req_mask
= WMI_STAT_PDEV
| WMI_STAT_VDEV
|
2034 ar
->max_spatial_stream
= WMI_MAX_SPATIAL_STREAM
;
2036 case ATH10K_FW_WMI_OP_VERSION_10_4
:
2037 ar
->max_num_peers
= TARGET_10_4_NUM_PEERS
;
2038 ar
->max_num_stations
= TARGET_10_4_NUM_STATIONS
;
2039 ar
->num_active_peers
= TARGET_10_4_ACTIVE_PEERS
;
2040 ar
->max_num_vdevs
= TARGET_10_4_NUM_VDEVS
;
2041 ar
->num_tids
= TARGET_10_4_TGT_NUM_TIDS
;
2042 ar
->fw_stats_req_mask
= WMI_10_4_STAT_PEER
|
2043 WMI_10_4_STAT_PEER_EXTD
;
2044 ar
->max_spatial_stream
= ar
->hw_params
.max_spatial_stream
;
2045 ar
->max_num_tdls_vdevs
= TARGET_10_4_NUM_TDLS_VDEVS
;
2047 if (test_bit(ATH10K_FW_FEATURE_PEER_FLOW_CONTROL
,
2048 fw_file
->fw_features
))
2049 ar
->htt
.max_num_pending_tx
= TARGET_10_4_NUM_MSDU_DESC_PFC
;
2051 ar
->htt
.max_num_pending_tx
= TARGET_10_4_NUM_MSDU_DESC
;
2053 case ATH10K_FW_WMI_OP_VERSION_UNSET
:
2054 case ATH10K_FW_WMI_OP_VERSION_MAX
:
2059 /* Backwards compatibility for firmwares without
2060 * ATH10K_FW_IE_HTT_OP_VERSION.
2062 if (fw_file
->htt_op_version
== ATH10K_FW_HTT_OP_VERSION_UNSET
) {
2063 switch (fw_file
->wmi_op_version
) {
2064 case ATH10K_FW_WMI_OP_VERSION_MAIN
:
2065 fw_file
->htt_op_version
= ATH10K_FW_HTT_OP_VERSION_MAIN
;
2067 case ATH10K_FW_WMI_OP_VERSION_10_1
:
2068 case ATH10K_FW_WMI_OP_VERSION_10_2
:
2069 case ATH10K_FW_WMI_OP_VERSION_10_2_4
:
2070 fw_file
->htt_op_version
= ATH10K_FW_HTT_OP_VERSION_10_1
;
2072 case ATH10K_FW_WMI_OP_VERSION_TLV
:
2073 fw_file
->htt_op_version
= ATH10K_FW_HTT_OP_VERSION_TLV
;
2075 case ATH10K_FW_WMI_OP_VERSION_10_4
:
2076 case ATH10K_FW_WMI_OP_VERSION_UNSET
:
2077 case ATH10K_FW_WMI_OP_VERSION_MAX
:
2078 ath10k_err(ar
, "htt op version not found from fw meta data");
2086 static int ath10k_core_reset_rx_filter(struct ath10k
*ar
)
2092 const u8
*vdev_addr
;
2095 vdev_type
= WMI_VDEV_TYPE_STA
;
2096 vdev_subtype
= ath10k_wmi_get_vdev_subtype(ar
, WMI_VDEV_SUBTYPE_NONE
);
2097 vdev_addr
= ar
->mac_addr
;
2099 ret
= ath10k_wmi_vdev_create(ar
, vdev_id
, vdev_type
, vdev_subtype
,
2102 ath10k_err(ar
, "failed to create dummy vdev: %d\n", ret
);
2106 ret
= ath10k_wmi_vdev_delete(ar
, vdev_id
);
2108 ath10k_err(ar
, "failed to delete dummy vdev: %d\n", ret
);
2112 /* WMI and HTT may use separate HIF pipes and are not guaranteed to be
2113 * serialized properly implicitly.
2115 * Moreover (most) WMI commands have no explicit acknowledges. It is
2116 * possible to infer it implicitly by poking firmware with echo
2117 * command - getting a reply means all preceding comments have been
2118 * (mostly) processed.
2120 * In case of vdev create/delete this is sufficient.
2122 * Without this it's possible to end up with a race when HTT Rx ring is
2123 * started before vdev create/delete hack is complete allowing a short
2124 * window of opportunity to receive (and Tx ACK) a bunch of frames.
2126 ret
= ath10k_wmi_barrier(ar
);
2128 ath10k_err(ar
, "failed to ping firmware: %d\n", ret
);
2135 int ath10k_core_start(struct ath10k
*ar
, enum ath10k_firmware_mode mode
,
2136 const struct ath10k_fw_components
*fw
)
2141 lockdep_assert_held(&ar
->conf_mutex
);
2143 clear_bit(ATH10K_FLAG_CRASH_FLUSH
, &ar
->dev_flags
);
2145 ar
->running_fw
= fw
;
2147 if (!test_bit(ATH10K_FW_FEATURE_NON_BMI
,
2148 ar
->running_fw
->fw_file
.fw_features
)) {
2149 ath10k_bmi_start(ar
);
2151 if (ath10k_init_configure_target(ar
)) {
2156 status
= ath10k_download_cal_data(ar
);
2160 /* Some of of qca988x solutions are having global reset issue
2161 * during target initialization. Bypassing PLL setting before
2162 * downloading firmware and letting the SoC run on REF_CLK is
2163 * fixing the problem. Corresponding firmware change is also
2164 * needed to set the clock source once the target is
2167 if (test_bit(ATH10K_FW_FEATURE_SUPPORTS_SKIP_CLOCK_INIT
,
2168 ar
->running_fw
->fw_file
.fw_features
)) {
2169 status
= ath10k_bmi_write32(ar
, hi_skip_clock_init
, 1);
2171 ath10k_err(ar
, "could not write to skip_clock_init: %d\n",
2177 status
= ath10k_download_fw(ar
);
2181 status
= ath10k_init_uart(ar
);
2185 if (ar
->hif
.bus
== ATH10K_BUS_SDIO
)
2186 ath10k_init_sdio(ar
);
2189 ar
->htc
.htc_ops
.target_send_suspend_complete
=
2190 ath10k_send_suspend_complete
;
2192 status
= ath10k_htc_init(ar
);
2194 ath10k_err(ar
, "could not init HTC (%d)\n", status
);
2198 if (!test_bit(ATH10K_FW_FEATURE_NON_BMI
,
2199 ar
->running_fw
->fw_file
.fw_features
)) {
2200 status
= ath10k_bmi_done(ar
);
2205 status
= ath10k_wmi_attach(ar
);
2207 ath10k_err(ar
, "WMI attach failed: %d\n", status
);
2211 status
= ath10k_htt_init(ar
);
2213 ath10k_err(ar
, "failed to init htt: %d\n", status
);
2214 goto err_wmi_detach
;
2217 status
= ath10k_htt_tx_start(&ar
->htt
);
2219 ath10k_err(ar
, "failed to alloc htt tx: %d\n", status
);
2220 goto err_wmi_detach
;
2223 /* If firmware indicates Full Rx Reorder support it must be used in a
2224 * slightly different manner. Let HTT code know.
2226 ar
->htt
.rx_ring
.in_ord_rx
= !!(test_bit(WMI_SERVICE_RX_FULL_REORDER
,
2229 status
= ath10k_htt_rx_alloc(&ar
->htt
);
2231 ath10k_err(ar
, "failed to alloc htt rx: %d\n", status
);
2232 goto err_htt_tx_detach
;
2235 status
= ath10k_hif_start(ar
);
2237 ath10k_err(ar
, "could not start HIF: %d\n", status
);
2238 goto err_htt_rx_detach
;
2241 status
= ath10k_htc_wait_target(&ar
->htc
);
2243 ath10k_err(ar
, "failed to connect to HTC: %d\n", status
);
2247 if (mode
== ATH10K_FIRMWARE_MODE_NORMAL
) {
2248 status
= ath10k_htt_connect(&ar
->htt
);
2250 ath10k_err(ar
, "failed to connect htt (%d)\n", status
);
2255 status
= ath10k_wmi_connect(ar
);
2257 ath10k_err(ar
, "could not connect wmi: %d\n", status
);
2261 status
= ath10k_htc_start(&ar
->htc
);
2263 ath10k_err(ar
, "failed to start htc: %d\n", status
);
2267 if (mode
== ATH10K_FIRMWARE_MODE_NORMAL
) {
2268 status
= ath10k_wmi_wait_for_service_ready(ar
);
2270 ath10k_warn(ar
, "wmi service ready event not received");
2275 ath10k_dbg(ar
, ATH10K_DBG_BOOT
, "firmware %s booted\n",
2276 ar
->hw
->wiphy
->fw_version
);
2278 if (test_bit(WMI_SERVICE_EXT_RES_CFG_SUPPORT
, ar
->wmi
.svc_map
) &&
2279 mode
== ATH10K_FIRMWARE_MODE_NORMAL
) {
2281 if (ath10k_peer_stats_enabled(ar
))
2282 val
= WMI_10_4_PEER_STATS
;
2284 if (test_bit(WMI_SERVICE_BSS_CHANNEL_INFO_64
, ar
->wmi
.svc_map
))
2285 val
|= WMI_10_4_BSS_CHANNEL_INFO_64
;
2287 /* 10.4 firmware supports BT-Coex without reloading firmware
2288 * via pdev param. To support Bluetooth coexistence pdev param,
2289 * WMI_COEX_GPIO_SUPPORT of extended resource config should be
2292 if (test_bit(WMI_SERVICE_COEX_GPIO
, ar
->wmi
.svc_map
) &&
2293 test_bit(ATH10K_FW_FEATURE_BTCOEX_PARAM
,
2294 ar
->running_fw
->fw_file
.fw_features
))
2295 val
|= WMI_10_4_COEX_GPIO_SUPPORT
;
2297 if (test_bit(WMI_SERVICE_TDLS_EXPLICIT_MODE_ONLY
,
2299 val
|= WMI_10_4_TDLS_EXPLICIT_MODE_ONLY
;
2301 if (test_bit(WMI_SERVICE_TDLS_UAPSD_BUFFER_STA
,
2303 val
|= WMI_10_4_TDLS_UAPSD_BUFFER_STA
;
2305 status
= ath10k_mac_ext_resource_config(ar
, val
);
2308 "failed to send ext resource cfg command : %d\n",
2314 status
= ath10k_wmi_cmd_init(ar
);
2316 ath10k_err(ar
, "could not send WMI init command (%d)\n",
2321 status
= ath10k_wmi_wait_for_unified_ready(ar
);
2323 ath10k_err(ar
, "wmi unified ready event not received\n");
2327 /* Some firmware revisions do not properly set up hardware rx filter
2330 * A known example from QCA9880 and 10.2.4 is that MAC_PCU_ADDR1_MASK
2331 * is filled with 0s instead of 1s allowing HW to respond with ACKs to
2332 * any frames that matches MAC_PCU_RX_FILTER which is also
2333 * misconfigured to accept anything.
2335 * The ADDR1 is programmed using internal firmware structure field and
2336 * can't be (easily/sanely) reached from the driver explicitly. It is
2337 * possible to implicitly make it correct by creating a dummy vdev and
2340 if (mode
== ATH10K_FIRMWARE_MODE_NORMAL
) {
2341 status
= ath10k_core_reset_rx_filter(ar
);
2344 "failed to reset rx filter: %d\n", status
);
2349 status
= ath10k_htt_rx_ring_refill(ar
);
2351 ath10k_err(ar
, "failed to refill htt rx ring: %d\n", status
);
2355 if (ar
->max_num_vdevs
>= 64)
2356 ar
->free_vdev_map
= 0xFFFFFFFFFFFFFFFFLL
;
2358 ar
->free_vdev_map
= (1LL << ar
->max_num_vdevs
) - 1;
2360 INIT_LIST_HEAD(&ar
->arvifs
);
2362 /* we don't care about HTT in UTF mode */
2363 if (mode
== ATH10K_FIRMWARE_MODE_NORMAL
) {
2364 status
= ath10k_htt_setup(&ar
->htt
);
2366 ath10k_err(ar
, "failed to setup htt: %d\n", status
);
2371 status
= ath10k_debug_start(ar
);
2378 ath10k_hif_stop(ar
);
2380 ath10k_htt_rx_free(&ar
->htt
);
2382 ath10k_htt_tx_free(&ar
->htt
);
2384 ath10k_wmi_detach(ar
);
2388 EXPORT_SYMBOL(ath10k_core_start
);
2390 int ath10k_wait_for_suspend(struct ath10k
*ar
, u32 suspend_opt
)
2393 unsigned long time_left
;
2395 reinit_completion(&ar
->target_suspend
);
2397 ret
= ath10k_wmi_pdev_suspend_target(ar
, suspend_opt
);
2399 ath10k_warn(ar
, "could not suspend target (%d)\n", ret
);
2403 time_left
= wait_for_completion_timeout(&ar
->target_suspend
, 1 * HZ
);
2406 ath10k_warn(ar
, "suspend timed out - target pause event never came\n");
2413 void ath10k_core_stop(struct ath10k
*ar
)
2415 lockdep_assert_held(&ar
->conf_mutex
);
2416 ath10k_debug_stop(ar
);
2418 /* try to suspend target */
2419 if (ar
->state
!= ATH10K_STATE_RESTARTING
&&
2420 ar
->state
!= ATH10K_STATE_UTF
)
2421 ath10k_wait_for_suspend(ar
, WMI_PDEV_SUSPEND_AND_DISABLE_INTR
);
2423 ath10k_hif_stop(ar
);
2424 ath10k_htt_tx_stop(&ar
->htt
);
2425 ath10k_htt_rx_free(&ar
->htt
);
2426 ath10k_wmi_detach(ar
);
2428 EXPORT_SYMBOL(ath10k_core_stop
);
2430 /* mac80211 manages fw/hw initialization through start/stop hooks. However in
2431 * order to know what hw capabilities should be advertised to mac80211 it is
2432 * necessary to load the firmware (and tear it down immediately since start
2433 * hook will try to init it again) before registering
2435 static int ath10k_core_probe_fw(struct ath10k
*ar
)
2437 struct bmi_target_info target_info
;
2440 ret
= ath10k_hif_power_up(ar
);
2442 ath10k_err(ar
, "could not start pci hif (%d)\n", ret
);
2446 switch (ar
->hif
.bus
) {
2447 case ATH10K_BUS_SDIO
:
2448 memset(&target_info
, 0, sizeof(target_info
));
2449 ret
= ath10k_bmi_get_target_info_sdio(ar
, &target_info
);
2451 ath10k_err(ar
, "could not get target info (%d)\n", ret
);
2452 goto err_power_down
;
2454 ar
->target_version
= target_info
.version
;
2455 ar
->hw
->wiphy
->hw_version
= target_info
.version
;
2457 case ATH10K_BUS_PCI
:
2458 case ATH10K_BUS_AHB
:
2459 case ATH10K_BUS_USB
:
2460 memset(&target_info
, 0, sizeof(target_info
));
2461 ret
= ath10k_bmi_get_target_info(ar
, &target_info
);
2463 ath10k_err(ar
, "could not get target info (%d)\n", ret
);
2464 goto err_power_down
;
2466 ar
->target_version
= target_info
.version
;
2467 ar
->hw
->wiphy
->hw_version
= target_info
.version
;
2469 case ATH10K_BUS_SNOC
:
2472 ath10k_err(ar
, "incorrect hif bus type: %d\n", ar
->hif
.bus
);
2475 ret
= ath10k_init_hw_params(ar
);
2477 ath10k_err(ar
, "could not get hw params (%d)\n", ret
);
2478 goto err_power_down
;
2481 ret
= ath10k_core_fetch_firmware_files(ar
);
2483 ath10k_err(ar
, "could not fetch firmware files (%d)\n", ret
);
2484 goto err_power_down
;
2487 BUILD_BUG_ON(sizeof(ar
->hw
->wiphy
->fw_version
) !=
2488 sizeof(ar
->normal_mode_fw
.fw_file
.fw_version
));
2489 memcpy(ar
->hw
->wiphy
->fw_version
, ar
->normal_mode_fw
.fw_file
.fw_version
,
2490 sizeof(ar
->hw
->wiphy
->fw_version
));
2492 ath10k_debug_print_hwfw_info(ar
);
2494 if (!test_bit(ATH10K_FW_FEATURE_NON_BMI
,
2495 ar
->normal_mode_fw
.fw_file
.fw_features
)) {
2496 ret
= ath10k_core_pre_cal_download(ar
);
2498 /* pre calibration data download is not necessary
2499 * for all the chipsets. Ignore failures and continue.
2501 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
2502 "could not load pre cal data: %d\n", ret
);
2505 ret
= ath10k_core_get_board_id_from_otp(ar
);
2506 if (ret
&& ret
!= -EOPNOTSUPP
) {
2507 ath10k_err(ar
, "failed to get board id from otp: %d\n",
2509 goto err_free_firmware_files
;
2512 ret
= ath10k_core_check_smbios(ar
);
2514 ath10k_dbg(ar
, ATH10K_DBG_BOOT
, "SMBIOS bdf variant name not set.\n");
2516 ret
= ath10k_core_check_dt(ar
);
2518 ath10k_dbg(ar
, ATH10K_DBG_BOOT
, "DT bdf variant name not set.\n");
2520 ret
= ath10k_core_fetch_board_file(ar
);
2522 ath10k_err(ar
, "failed to fetch board file: %d\n", ret
);
2523 goto err_free_firmware_files
;
2526 ath10k_debug_print_board_info(ar
);
2529 ret
= ath10k_core_init_firmware_features(ar
);
2531 ath10k_err(ar
, "fatal problem with firmware features: %d\n",
2533 goto err_free_firmware_files
;
2536 if (!test_bit(ATH10K_FW_FEATURE_NON_BMI
,
2537 ar
->normal_mode_fw
.fw_file
.fw_features
)) {
2538 ret
= ath10k_swap_code_seg_init(ar
,
2539 &ar
->normal_mode_fw
.fw_file
);
2541 ath10k_err(ar
, "failed to initialize code swap segment: %d\n",
2543 goto err_free_firmware_files
;
2547 mutex_lock(&ar
->conf_mutex
);
2549 ret
= ath10k_core_start(ar
, ATH10K_FIRMWARE_MODE_NORMAL
,
2550 &ar
->normal_mode_fw
);
2552 ath10k_err(ar
, "could not init core (%d)\n", ret
);
2556 ath10k_debug_print_boot_info(ar
);
2557 ath10k_core_stop(ar
);
2559 mutex_unlock(&ar
->conf_mutex
);
2561 ath10k_hif_power_down(ar
);
2565 mutex_unlock(&ar
->conf_mutex
);
2567 err_free_firmware_files
:
2568 ath10k_core_free_firmware_files(ar
);
2571 ath10k_hif_power_down(ar
);
2576 static void ath10k_core_register_work(struct work_struct
*work
)
2578 struct ath10k
*ar
= container_of(work
, struct ath10k
, register_work
);
2581 /* peer stats are enabled by default */
2582 set_bit(ATH10K_FLAG_PEER_STATS
, &ar
->dev_flags
);
2584 status
= ath10k_core_probe_fw(ar
);
2586 ath10k_err(ar
, "could not probe fw (%d)\n", status
);
2590 status
= ath10k_mac_register(ar
);
2592 ath10k_err(ar
, "could not register to mac80211 (%d)\n", status
);
2593 goto err_release_fw
;
2596 status
= ath10k_coredump_register(ar
);
2598 ath10k_err(ar
, "unable to register coredump\n");
2599 goto err_unregister_mac
;
2602 status
= ath10k_debug_register(ar
);
2604 ath10k_err(ar
, "unable to initialize debugfs\n");
2605 goto err_unregister_coredump
;
2608 status
= ath10k_spectral_create(ar
);
2610 ath10k_err(ar
, "failed to initialize spectral\n");
2611 goto err_debug_destroy
;
2614 status
= ath10k_thermal_register(ar
);
2616 ath10k_err(ar
, "could not register thermal device: %d\n",
2618 goto err_spectral_destroy
;
2621 set_bit(ATH10K_FLAG_CORE_REGISTERED
, &ar
->dev_flags
);
2624 err_spectral_destroy
:
2625 ath10k_spectral_destroy(ar
);
2627 ath10k_debug_destroy(ar
);
2628 err_unregister_coredump
:
2629 ath10k_coredump_unregister(ar
);
2631 ath10k_mac_unregister(ar
);
2633 ath10k_core_free_firmware_files(ar
);
2635 /* TODO: It's probably a good idea to release device from the driver
2636 * but calling device_release_driver() here will cause a deadlock.
2641 int ath10k_core_register(struct ath10k
*ar
, u32 chip_id
)
2643 ar
->chip_id
= chip_id
;
2644 queue_work(ar
->workqueue
, &ar
->register_work
);
2648 EXPORT_SYMBOL(ath10k_core_register
);
2650 void ath10k_core_unregister(struct ath10k
*ar
)
2652 cancel_work_sync(&ar
->register_work
);
2654 if (!test_bit(ATH10K_FLAG_CORE_REGISTERED
, &ar
->dev_flags
))
2657 ath10k_thermal_unregister(ar
);
2658 /* Stop spectral before unregistering from mac80211 to remove the
2659 * relayfs debugfs file cleanly. Otherwise the parent debugfs tree
2660 * would be already be free'd recursively, leading to a double free.
2662 ath10k_spectral_destroy(ar
);
2664 /* We must unregister from mac80211 before we stop HTC and HIF.
2665 * Otherwise we will fail to submit commands to FW and mac80211 will be
2666 * unhappy about callback failures.
2668 ath10k_mac_unregister(ar
);
2670 ath10k_testmode_destroy(ar
);
2672 ath10k_core_free_firmware_files(ar
);
2673 ath10k_core_free_board_files(ar
);
2675 ath10k_debug_unregister(ar
);
2677 EXPORT_SYMBOL(ath10k_core_unregister
);
2679 struct ath10k
*ath10k_core_create(size_t priv_size
, struct device
*dev
,
2680 enum ath10k_bus bus
,
2681 enum ath10k_hw_rev hw_rev
,
2682 const struct ath10k_hif_ops
*hif_ops
)
2687 ar
= ath10k_mac_create(priv_size
);
2691 ar
->ath_common
.priv
= ar
;
2692 ar
->ath_common
.hw
= ar
->hw
;
2694 ar
->hw_rev
= hw_rev
;
2695 ar
->hif
.ops
= hif_ops
;
2699 case ATH10K_HW_QCA988X
:
2700 case ATH10K_HW_QCA9887
:
2701 ar
->regs
= &qca988x_regs
;
2702 ar
->hw_ce_regs
= &qcax_ce_regs
;
2703 ar
->hw_values
= &qca988x_values
;
2705 case ATH10K_HW_QCA6174
:
2706 case ATH10K_HW_QCA9377
:
2707 ar
->regs
= &qca6174_regs
;
2708 ar
->hw_ce_regs
= &qcax_ce_regs
;
2709 ar
->hw_values
= &qca6174_values
;
2711 case ATH10K_HW_QCA99X0
:
2712 case ATH10K_HW_QCA9984
:
2713 ar
->regs
= &qca99x0_regs
;
2714 ar
->hw_ce_regs
= &qcax_ce_regs
;
2715 ar
->hw_values
= &qca99x0_values
;
2717 case ATH10K_HW_QCA9888
:
2718 ar
->regs
= &qca99x0_regs
;
2719 ar
->hw_ce_regs
= &qcax_ce_regs
;
2720 ar
->hw_values
= &qca9888_values
;
2722 case ATH10K_HW_QCA4019
:
2723 ar
->regs
= &qca4019_regs
;
2724 ar
->hw_ce_regs
= &qcax_ce_regs
;
2725 ar
->hw_values
= &qca4019_values
;
2727 case ATH10K_HW_WCN3990
:
2728 ar
->regs
= &wcn3990_regs
;
2729 ar
->hw_ce_regs
= &wcn3990_ce_regs
;
2730 ar
->hw_values
= &wcn3990_values
;
2733 ath10k_err(ar
, "unsupported core hardware revision %d\n",
2739 init_completion(&ar
->scan
.started
);
2740 init_completion(&ar
->scan
.completed
);
2741 init_completion(&ar
->scan
.on_channel
);
2742 init_completion(&ar
->target_suspend
);
2743 init_completion(&ar
->wow
.wakeup_completed
);
2745 init_completion(&ar
->install_key_done
);
2746 init_completion(&ar
->vdev_setup_done
);
2747 init_completion(&ar
->thermal
.wmi_sync
);
2748 init_completion(&ar
->bss_survey_done
);
2750 INIT_DELAYED_WORK(&ar
->scan
.timeout
, ath10k_scan_timeout_work
);
2752 ar
->workqueue
= create_singlethread_workqueue("ath10k_wq");
2756 ar
->workqueue_aux
= create_singlethread_workqueue("ath10k_aux_wq");
2757 if (!ar
->workqueue_aux
)
2760 mutex_init(&ar
->conf_mutex
);
2761 spin_lock_init(&ar
->data_lock
);
2762 spin_lock_init(&ar
->txqs_lock
);
2764 INIT_LIST_HEAD(&ar
->txqs
);
2765 INIT_LIST_HEAD(&ar
->peers
);
2766 init_waitqueue_head(&ar
->peer_mapping_wq
);
2767 init_waitqueue_head(&ar
->htt
.empty_tx_wq
);
2768 init_waitqueue_head(&ar
->wmi
.tx_credits_wq
);
2770 init_completion(&ar
->offchan_tx_completed
);
2771 INIT_WORK(&ar
->offchan_tx_work
, ath10k_offchan_tx_work
);
2772 skb_queue_head_init(&ar
->offchan_tx_queue
);
2774 INIT_WORK(&ar
->wmi_mgmt_tx_work
, ath10k_mgmt_over_wmi_tx_work
);
2775 skb_queue_head_init(&ar
->wmi_mgmt_tx_queue
);
2777 INIT_WORK(&ar
->register_work
, ath10k_core_register_work
);
2778 INIT_WORK(&ar
->restart_work
, ath10k_core_restart
);
2779 INIT_WORK(&ar
->set_coverage_class_work
,
2780 ath10k_core_set_coverage_class_work
);
2782 init_dummy_netdev(&ar
->napi_dev
);
2784 ret
= ath10k_coredump_create(ar
);
2786 goto err_free_aux_wq
;
2788 ret
= ath10k_debug_create(ar
);
2790 goto err_free_coredump
;
2795 ath10k_coredump_destroy(ar
);
2798 destroy_workqueue(ar
->workqueue_aux
);
2800 destroy_workqueue(ar
->workqueue
);
2803 ath10k_mac_destroy(ar
);
2807 EXPORT_SYMBOL(ath10k_core_create
);
2809 void ath10k_core_destroy(struct ath10k
*ar
)
2811 flush_workqueue(ar
->workqueue
);
2812 destroy_workqueue(ar
->workqueue
);
2814 flush_workqueue(ar
->workqueue_aux
);
2815 destroy_workqueue(ar
->workqueue_aux
);
2817 ath10k_debug_destroy(ar
);
2818 ath10k_coredump_destroy(ar
);
2819 ath10k_htt_tx_destroy(&ar
->htt
);
2820 ath10k_wmi_free_host_mem(ar
);
2821 ath10k_mac_destroy(ar
);
2823 EXPORT_SYMBOL(ath10k_core_destroy
);
2825 MODULE_AUTHOR("Qualcomm Atheros");
2826 MODULE_DESCRIPTION("Core module for Qualcomm Atheros 802.11ac wireless LAN cards.");
2827 MODULE_LICENSE("Dual BSD/GPL");