2 * Copyright (c) 2005-2011 Atheros Communications Inc.
3 * Copyright (c) 2011-2017 Qualcomm Atheros, Inc.
4 * Copyright (c) 2018, The Linux Foundation. All rights reserved.
6 * Permission to use, copy, modify, and/or distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 #include <linux/module.h>
20 #include <linux/firmware.h>
22 #include <linux/property.h>
23 #include <linux/dmi.h>
24 #include <linux/ctype.h>
25 #include <asm/byteorder.h>
39 unsigned int ath10k_debug_mask
;
40 static unsigned int ath10k_cryptmode_param
;
41 static bool uart_print
;
45 unsigned long ath10k_coredump_mask
= BIT(ATH10K_FW_CRASH_DUMP_REGISTERS
) |
46 BIT(ATH10K_FW_CRASH_DUMP_CE_DATA
);
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 .bus
= ATH10K_BUS_PCI
,
68 .name
= "qca988x hw2.0",
69 .patch_load_addr
= QCA988X_HW_2_0_PATCH_LOAD_ADDR
,
71 .cc_wraparound_type
= ATH10K_HW_CC_WRAP_SHIFTED_ALL
,
73 .channel_counters_freq_hz
= 88000,
74 .max_probe_resp_desc_thres
= 0,
77 .dir
= QCA988X_HW_2_0_FW_DIR
,
78 .board
= QCA988X_HW_2_0_BOARD_DATA_FILE
,
79 .board_size
= QCA988X_BOARD_DATA_SZ
,
80 .board_ext_size
= QCA988X_BOARD_EXT_DATA_SZ
,
82 .hw_ops
= &qca988x_ops
,
83 .decap_align_bytes
= 4,
84 .spectral_bin_discard
= 0,
85 .spectral_bin_offset
= 0,
86 .vht160_mcs_rx_highest
= 0,
87 .vht160_mcs_tx_highest
= 0,
89 .ast_skid_limit
= 0x10,
90 .num_wds_entries
= 0x20,
91 .target_64bit
= false,
92 .rx_ring_fill_level
= HTT_RX_RING_FILL_LEVEL
,
93 .shadow_reg_support
= false,
95 .hw_filter_reset_required
= true,
96 .fw_diag_ce_download
= false,
99 .id
= QCA988X_HW_2_0_VERSION
,
100 .dev_id
= QCA988X_2_0_DEVICE_ID_UBNT
,
101 .name
= "qca988x hw2.0 ubiquiti",
102 .patch_load_addr
= QCA988X_HW_2_0_PATCH_LOAD_ADDR
,
104 .cc_wraparound_type
= ATH10K_HW_CC_WRAP_SHIFTED_ALL
,
106 .channel_counters_freq_hz
= 88000,
107 .max_probe_resp_desc_thres
= 0,
108 .cal_data_len
= 2116,
110 .dir
= QCA988X_HW_2_0_FW_DIR
,
111 .board
= QCA988X_HW_2_0_BOARD_DATA_FILE
,
112 .board_size
= QCA988X_BOARD_DATA_SZ
,
113 .board_ext_size
= QCA988X_BOARD_EXT_DATA_SZ
,
115 .hw_ops
= &qca988x_ops
,
116 .decap_align_bytes
= 4,
117 .spectral_bin_discard
= 0,
118 .spectral_bin_offset
= 0,
119 .vht160_mcs_rx_highest
= 0,
120 .vht160_mcs_tx_highest
= 0,
121 .n_cipher_suites
= 8,
122 .ast_skid_limit
= 0x10,
123 .num_wds_entries
= 0x20,
124 .target_64bit
= false,
125 .rx_ring_fill_level
= HTT_RX_RING_FILL_LEVEL
,
127 .shadow_reg_support
= false,
129 .hw_filter_reset_required
= true,
130 .fw_diag_ce_download
= false,
133 .id
= QCA9887_HW_1_0_VERSION
,
134 .dev_id
= QCA9887_1_0_DEVICE_ID
,
135 .bus
= ATH10K_BUS_PCI
,
136 .name
= "qca9887 hw1.0",
137 .patch_load_addr
= QCA9887_HW_1_0_PATCH_LOAD_ADDR
,
139 .cc_wraparound_type
= ATH10K_HW_CC_WRAP_SHIFTED_ALL
,
141 .channel_counters_freq_hz
= 88000,
142 .max_probe_resp_desc_thres
= 0,
143 .cal_data_len
= 2116,
145 .dir
= QCA9887_HW_1_0_FW_DIR
,
146 .board
= QCA9887_HW_1_0_BOARD_DATA_FILE
,
147 .board_size
= QCA9887_BOARD_DATA_SZ
,
148 .board_ext_size
= QCA9887_BOARD_EXT_DATA_SZ
,
150 .hw_ops
= &qca988x_ops
,
151 .decap_align_bytes
= 4,
152 .spectral_bin_discard
= 0,
153 .spectral_bin_offset
= 0,
154 .vht160_mcs_rx_highest
= 0,
155 .vht160_mcs_tx_highest
= 0,
156 .n_cipher_suites
= 8,
157 .ast_skid_limit
= 0x10,
158 .num_wds_entries
= 0x20,
159 .target_64bit
= false,
160 .rx_ring_fill_level
= HTT_RX_RING_FILL_LEVEL
,
162 .shadow_reg_support
= false,
164 .hw_filter_reset_required
= true,
165 .fw_diag_ce_download
= false,
168 .id
= QCA6174_HW_2_1_VERSION
,
169 .dev_id
= QCA6164_2_1_DEVICE_ID
,
170 .bus
= ATH10K_BUS_PCI
,
171 .name
= "qca6164 hw2.1",
172 .patch_load_addr
= QCA6174_HW_2_1_PATCH_LOAD_ADDR
,
175 .channel_counters_freq_hz
= 88000,
176 .max_probe_resp_desc_thres
= 0,
177 .cal_data_len
= 8124,
179 .dir
= QCA6174_HW_2_1_FW_DIR
,
180 .board
= QCA6174_HW_2_1_BOARD_DATA_FILE
,
181 .board_size
= QCA6174_BOARD_DATA_SZ
,
182 .board_ext_size
= QCA6174_BOARD_EXT_DATA_SZ
,
184 .hw_ops
= &qca988x_ops
,
185 .decap_align_bytes
= 4,
186 .spectral_bin_discard
= 0,
187 .spectral_bin_offset
= 0,
188 .vht160_mcs_rx_highest
= 0,
189 .vht160_mcs_tx_highest
= 0,
190 .n_cipher_suites
= 8,
191 .ast_skid_limit
= 0x10,
192 .num_wds_entries
= 0x20,
193 .target_64bit
= false,
194 .rx_ring_fill_level
= HTT_RX_RING_FILL_LEVEL
,
196 .shadow_reg_support
= false,
198 .hw_filter_reset_required
= true,
199 .fw_diag_ce_download
= false,
202 .id
= QCA6174_HW_2_1_VERSION
,
203 .dev_id
= QCA6174_2_1_DEVICE_ID
,
204 .bus
= ATH10K_BUS_PCI
,
205 .name
= "qca6174 hw2.1",
206 .patch_load_addr
= QCA6174_HW_2_1_PATCH_LOAD_ADDR
,
209 .channel_counters_freq_hz
= 88000,
210 .max_probe_resp_desc_thres
= 0,
211 .cal_data_len
= 8124,
213 .dir
= QCA6174_HW_2_1_FW_DIR
,
214 .board
= QCA6174_HW_2_1_BOARD_DATA_FILE
,
215 .board_size
= QCA6174_BOARD_DATA_SZ
,
216 .board_ext_size
= QCA6174_BOARD_EXT_DATA_SZ
,
218 .hw_ops
= &qca988x_ops
,
219 .decap_align_bytes
= 4,
220 .spectral_bin_discard
= 0,
221 .spectral_bin_offset
= 0,
222 .vht160_mcs_rx_highest
= 0,
223 .vht160_mcs_tx_highest
= 0,
224 .n_cipher_suites
= 8,
225 .ast_skid_limit
= 0x10,
226 .num_wds_entries
= 0x20,
227 .target_64bit
= false,
228 .rx_ring_fill_level
= HTT_RX_RING_FILL_LEVEL
,
230 .shadow_reg_support
= false,
232 .hw_filter_reset_required
= true,
233 .fw_diag_ce_download
= false,
236 .id
= QCA6174_HW_3_0_VERSION
,
237 .dev_id
= QCA6174_2_1_DEVICE_ID
,
238 .bus
= ATH10K_BUS_PCI
,
239 .name
= "qca6174 hw3.0",
240 .patch_load_addr
= QCA6174_HW_3_0_PATCH_LOAD_ADDR
,
243 .channel_counters_freq_hz
= 88000,
244 .max_probe_resp_desc_thres
= 0,
245 .cal_data_len
= 8124,
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
= &qca988x_ops
,
253 .decap_align_bytes
= 4,
254 .spectral_bin_discard
= 0,
255 .spectral_bin_offset
= 0,
256 .vht160_mcs_rx_highest
= 0,
257 .vht160_mcs_tx_highest
= 0,
258 .n_cipher_suites
= 8,
259 .ast_skid_limit
= 0x10,
260 .num_wds_entries
= 0x20,
261 .target_64bit
= false,
262 .rx_ring_fill_level
= HTT_RX_RING_FILL_LEVEL
,
264 .shadow_reg_support
= false,
266 .hw_filter_reset_required
= true,
267 .fw_diag_ce_download
= false,
270 .id
= QCA6174_HW_3_2_VERSION
,
271 .dev_id
= QCA6174_2_1_DEVICE_ID
,
272 .bus
= ATH10K_BUS_PCI
,
273 .name
= "qca6174 hw3.2",
274 .patch_load_addr
= QCA6174_HW_3_0_PATCH_LOAD_ADDR
,
277 .channel_counters_freq_hz
= 88000,
278 .max_probe_resp_desc_thres
= 0,
279 .cal_data_len
= 8124,
281 /* uses same binaries as hw3.0 */
282 .dir
= QCA6174_HW_3_0_FW_DIR
,
283 .board
= QCA6174_HW_3_0_BOARD_DATA_FILE
,
284 .board_size
= QCA6174_BOARD_DATA_SZ
,
285 .board_ext_size
= QCA6174_BOARD_EXT_DATA_SZ
,
287 .hw_ops
= &qca6174_ops
,
288 .hw_clk
= qca6174_clk
,
289 .target_cpu_freq
= 176000000,
290 .decap_align_bytes
= 4,
291 .spectral_bin_discard
= 0,
292 .spectral_bin_offset
= 0,
293 .vht160_mcs_rx_highest
= 0,
294 .vht160_mcs_tx_highest
= 0,
295 .n_cipher_suites
= 8,
296 .ast_skid_limit
= 0x10,
297 .num_wds_entries
= 0x20,
298 .target_64bit
= false,
299 .rx_ring_fill_level
= HTT_RX_RING_FILL_LEVEL
,
301 .shadow_reg_support
= false,
303 .hw_filter_reset_required
= true,
304 .fw_diag_ce_download
= true,
307 .id
= QCA99X0_HW_2_0_DEV_VERSION
,
308 .dev_id
= QCA99X0_2_0_DEVICE_ID
,
309 .bus
= ATH10K_BUS_PCI
,
310 .name
= "qca99x0 hw2.0",
311 .patch_load_addr
= QCA99X0_HW_2_0_PATCH_LOAD_ADDR
,
313 .otp_exe_param
= 0x00000700,
314 .continuous_frag_desc
= true,
315 .cck_rate_map_rev2
= true,
316 .channel_counters_freq_hz
= 150000,
317 .max_probe_resp_desc_thres
= 24,
318 .tx_chain_mask
= 0xf,
319 .rx_chain_mask
= 0xf,
320 .max_spatial_stream
= 4,
321 .cal_data_len
= 12064,
323 .dir
= QCA99X0_HW_2_0_FW_DIR
,
324 .board
= QCA99X0_HW_2_0_BOARD_DATA_FILE
,
325 .board_size
= QCA99X0_BOARD_DATA_SZ
,
326 .board_ext_size
= QCA99X0_BOARD_EXT_DATA_SZ
,
328 .sw_decrypt_mcast_mgmt
= true,
329 .hw_ops
= &qca99x0_ops
,
330 .decap_align_bytes
= 1,
331 .spectral_bin_discard
= 4,
332 .spectral_bin_offset
= 0,
333 .vht160_mcs_rx_highest
= 0,
334 .vht160_mcs_tx_highest
= 0,
335 .n_cipher_suites
= 11,
336 .ast_skid_limit
= 0x10,
337 .num_wds_entries
= 0x20,
338 .target_64bit
= false,
339 .rx_ring_fill_level
= HTT_RX_RING_FILL_LEVEL
,
341 .shadow_reg_support
= false,
343 .hw_filter_reset_required
= true,
344 .fw_diag_ce_download
= false,
347 .id
= QCA9984_HW_1_0_DEV_VERSION
,
348 .dev_id
= QCA9984_1_0_DEVICE_ID
,
349 .bus
= ATH10K_BUS_PCI
,
350 .name
= "qca9984/qca9994 hw1.0",
351 .patch_load_addr
= QCA9984_HW_1_0_PATCH_LOAD_ADDR
,
353 .cc_wraparound_type
= ATH10K_HW_CC_WRAP_SHIFTED_EACH
,
354 .otp_exe_param
= 0x00000700,
355 .continuous_frag_desc
= true,
356 .cck_rate_map_rev2
= true,
357 .channel_counters_freq_hz
= 150000,
358 .max_probe_resp_desc_thres
= 24,
359 .tx_chain_mask
= 0xf,
360 .rx_chain_mask
= 0xf,
361 .max_spatial_stream
= 4,
362 .cal_data_len
= 12064,
364 .dir
= QCA9984_HW_1_0_FW_DIR
,
365 .board
= QCA9984_HW_1_0_BOARD_DATA_FILE
,
366 .eboard
= QCA9984_HW_1_0_EBOARD_DATA_FILE
,
367 .board_size
= QCA99X0_BOARD_DATA_SZ
,
368 .board_ext_size
= QCA99X0_BOARD_EXT_DATA_SZ
,
369 .ext_board_size
= QCA99X0_EXT_BOARD_DATA_SZ
,
371 .sw_decrypt_mcast_mgmt
= true,
372 .hw_ops
= &qca99x0_ops
,
373 .decap_align_bytes
= 1,
374 .spectral_bin_discard
= 12,
375 .spectral_bin_offset
= 8,
377 /* Can do only 2x2 VHT160 or 80+80. 1560Mbps is 4x4 80Mhz
378 * or 2x2 160Mhz, long-guard-interval.
380 .vht160_mcs_rx_highest
= 1560,
381 .vht160_mcs_tx_highest
= 1560,
382 .n_cipher_suites
= 11,
383 .ast_skid_limit
= 0x10,
384 .num_wds_entries
= 0x20,
385 .target_64bit
= false,
386 .rx_ring_fill_level
= HTT_RX_RING_FILL_LEVEL
,
388 .shadow_reg_support
= false,
390 .hw_filter_reset_required
= true,
391 .fw_diag_ce_download
= false,
394 .id
= QCA9888_HW_2_0_DEV_VERSION
,
395 .dev_id
= QCA9888_2_0_DEVICE_ID
,
396 .bus
= ATH10K_BUS_PCI
,
397 .name
= "qca9888 hw2.0",
398 .patch_load_addr
= QCA9888_HW_2_0_PATCH_LOAD_ADDR
,
400 .cc_wraparound_type
= ATH10K_HW_CC_WRAP_SHIFTED_EACH
,
401 .otp_exe_param
= 0x00000700,
402 .continuous_frag_desc
= true,
403 .channel_counters_freq_hz
= 150000,
404 .max_probe_resp_desc_thres
= 24,
407 .max_spatial_stream
= 2,
408 .cal_data_len
= 12064,
410 .dir
= QCA9888_HW_2_0_FW_DIR
,
411 .board
= QCA9888_HW_2_0_BOARD_DATA_FILE
,
412 .board_size
= QCA99X0_BOARD_DATA_SZ
,
413 .board_ext_size
= QCA99X0_BOARD_EXT_DATA_SZ
,
415 .sw_decrypt_mcast_mgmt
= true,
416 .hw_ops
= &qca99x0_ops
,
417 .decap_align_bytes
= 1,
418 .spectral_bin_discard
= 12,
419 .spectral_bin_offset
= 8,
421 /* Can do only 1x1 VHT160 or 80+80. 780Mbps is 2x2 80Mhz or
422 * 1x1 160Mhz, long-guard-interval.
424 .vht160_mcs_rx_highest
= 780,
425 .vht160_mcs_tx_highest
= 780,
426 .n_cipher_suites
= 11,
427 .ast_skid_limit
= 0x10,
428 .num_wds_entries
= 0x20,
429 .target_64bit
= false,
430 .rx_ring_fill_level
= HTT_RX_RING_FILL_LEVEL
,
432 .shadow_reg_support
= false,
434 .hw_filter_reset_required
= true,
435 .fw_diag_ce_download
= false,
438 .id
= QCA9377_HW_1_0_DEV_VERSION
,
439 .dev_id
= QCA9377_1_0_DEVICE_ID
,
440 .bus
= ATH10K_BUS_PCI
,
441 .name
= "qca9377 hw1.0",
442 .patch_load_addr
= QCA9377_HW_1_0_PATCH_LOAD_ADDR
,
445 .channel_counters_freq_hz
= 88000,
446 .max_probe_resp_desc_thres
= 0,
447 .cal_data_len
= 8124,
449 .dir
= QCA9377_HW_1_0_FW_DIR
,
450 .board
= QCA9377_HW_1_0_BOARD_DATA_FILE
,
451 .board_size
= QCA9377_BOARD_DATA_SZ
,
452 .board_ext_size
= QCA9377_BOARD_EXT_DATA_SZ
,
454 .hw_ops
= &qca988x_ops
,
455 .decap_align_bytes
= 4,
456 .spectral_bin_discard
= 0,
457 .spectral_bin_offset
= 0,
458 .vht160_mcs_rx_highest
= 0,
459 .vht160_mcs_tx_highest
= 0,
460 .n_cipher_suites
= 8,
461 .ast_skid_limit
= 0x10,
462 .num_wds_entries
= 0x20,
463 .target_64bit
= false,
464 .rx_ring_fill_level
= HTT_RX_RING_FILL_LEVEL
,
466 .shadow_reg_support
= false,
468 .hw_filter_reset_required
= true,
469 .fw_diag_ce_download
= false,
472 .id
= QCA9377_HW_1_1_DEV_VERSION
,
473 .dev_id
= QCA9377_1_0_DEVICE_ID
,
474 .bus
= ATH10K_BUS_PCI
,
475 .name
= "qca9377 hw1.1",
476 .patch_load_addr
= QCA9377_HW_1_0_PATCH_LOAD_ADDR
,
479 .channel_counters_freq_hz
= 88000,
480 .max_probe_resp_desc_thres
= 0,
481 .cal_data_len
= 8124,
483 .dir
= QCA9377_HW_1_0_FW_DIR
,
484 .board
= QCA9377_HW_1_0_BOARD_DATA_FILE
,
485 .board_size
= QCA9377_BOARD_DATA_SZ
,
486 .board_ext_size
= QCA9377_BOARD_EXT_DATA_SZ
,
488 .hw_ops
= &qca6174_ops
,
489 .hw_clk
= qca6174_clk
,
490 .target_cpu_freq
= 176000000,
491 .decap_align_bytes
= 4,
492 .spectral_bin_discard
= 0,
493 .spectral_bin_offset
= 0,
494 .vht160_mcs_rx_highest
= 0,
495 .vht160_mcs_tx_highest
= 0,
496 .n_cipher_suites
= 8,
497 .ast_skid_limit
= 0x10,
498 .num_wds_entries
= 0x20,
499 .target_64bit
= false,
500 .rx_ring_fill_level
= HTT_RX_RING_FILL_LEVEL
,
502 .shadow_reg_support
= false,
504 .hw_filter_reset_required
= true,
505 .fw_diag_ce_download
= true,
508 .id
= QCA4019_HW_1_0_DEV_VERSION
,
510 .bus
= ATH10K_BUS_AHB
,
511 .name
= "qca4019 hw1.0",
512 .patch_load_addr
= QCA4019_HW_1_0_PATCH_LOAD_ADDR
,
514 .cc_wraparound_type
= ATH10K_HW_CC_WRAP_SHIFTED_EACH
,
515 .otp_exe_param
= 0x0010000,
516 .continuous_frag_desc
= true,
517 .cck_rate_map_rev2
= true,
518 .channel_counters_freq_hz
= 125000,
519 .max_probe_resp_desc_thres
= 24,
520 .tx_chain_mask
= 0x3,
521 .rx_chain_mask
= 0x3,
522 .max_spatial_stream
= 2,
523 .cal_data_len
= 12064,
525 .dir
= QCA4019_HW_1_0_FW_DIR
,
526 .board
= QCA4019_HW_1_0_BOARD_DATA_FILE
,
527 .board_size
= QCA4019_BOARD_DATA_SZ
,
528 .board_ext_size
= QCA4019_BOARD_EXT_DATA_SZ
,
530 .sw_decrypt_mcast_mgmt
= true,
531 .hw_ops
= &qca99x0_ops
,
532 .decap_align_bytes
= 1,
533 .spectral_bin_discard
= 4,
534 .spectral_bin_offset
= 0,
535 .vht160_mcs_rx_highest
= 0,
536 .vht160_mcs_tx_highest
= 0,
537 .n_cipher_suites
= 11,
538 .ast_skid_limit
= 0x10,
539 .num_wds_entries
= 0x20,
540 .target_64bit
= false,
541 .rx_ring_fill_level
= HTT_RX_RING_FILL_LEVEL
,
543 .shadow_reg_support
= false,
545 .hw_filter_reset_required
= true,
546 .fw_diag_ce_download
= false,
549 .id
= WCN3990_HW_1_0_DEV_VERSION
,
551 .bus
= ATH10K_BUS_PCI
,
552 .name
= "wcn3990 hw1.0",
553 .continuous_frag_desc
= true,
554 .tx_chain_mask
= 0x7,
555 .rx_chain_mask
= 0x7,
556 .max_spatial_stream
= 4,
558 .dir
= WCN3990_HW_1_0_FW_DIR
,
560 .sw_decrypt_mcast_mgmt
= true,
561 .hw_ops
= &wcn3990_ops
,
562 .decap_align_bytes
= 1,
563 .num_peers
= TARGET_HL_10_TLV_NUM_PEERS
,
564 .ast_skid_limit
= TARGET_HL_10_TLV_AST_SKID_LIMIT
,
565 .num_wds_entries
= TARGET_HL_10_TLV_NUM_WDS_ENTRIES
,
566 .target_64bit
= true,
567 .rx_ring_fill_level
= HTT_RX_RING_FILL_LEVEL_DUAL_MAC
,
569 .shadow_reg_support
= true,
571 .hw_filter_reset_required
= false,
572 .fw_diag_ce_download
= false,
576 static const char *const ath10k_core_fw_feature_str
[] = {
577 [ATH10K_FW_FEATURE_EXT_WMI_MGMT_RX
] = "wmi-mgmt-rx",
578 [ATH10K_FW_FEATURE_WMI_10X
] = "wmi-10.x",
579 [ATH10K_FW_FEATURE_HAS_WMI_MGMT_TX
] = "has-wmi-mgmt-tx",
580 [ATH10K_FW_FEATURE_NO_P2P
] = "no-p2p",
581 [ATH10K_FW_FEATURE_WMI_10_2
] = "wmi-10.2",
582 [ATH10K_FW_FEATURE_MULTI_VIF_PS_SUPPORT
] = "multi-vif-ps",
583 [ATH10K_FW_FEATURE_WOWLAN_SUPPORT
] = "wowlan",
584 [ATH10K_FW_FEATURE_IGNORE_OTP_RESULT
] = "ignore-otp",
585 [ATH10K_FW_FEATURE_NO_NWIFI_DECAP_4ADDR_PADDING
] = "no-4addr-pad",
586 [ATH10K_FW_FEATURE_SUPPORTS_SKIP_CLOCK_INIT
] = "skip-clock-init",
587 [ATH10K_FW_FEATURE_RAW_MODE_SUPPORT
] = "raw-mode",
588 [ATH10K_FW_FEATURE_SUPPORTS_ADAPTIVE_CCA
] = "adaptive-cca",
589 [ATH10K_FW_FEATURE_MFP_SUPPORT
] = "mfp",
590 [ATH10K_FW_FEATURE_PEER_FLOW_CONTROL
] = "peer-flow-ctrl",
591 [ATH10K_FW_FEATURE_BTCOEX_PARAM
] = "btcoex-param",
592 [ATH10K_FW_FEATURE_SKIP_NULL_FUNC_WAR
] = "skip-null-func-war",
593 [ATH10K_FW_FEATURE_ALLOWS_MESH_BCAST
] = "allows-mesh-bcast",
594 [ATH10K_FW_FEATURE_NO_PS
] = "no-ps",
595 [ATH10K_FW_FEATURE_MGMT_TX_BY_REF
] = "mgmt-tx-by-reference",
596 [ATH10K_FW_FEATURE_NON_BMI
] = "non-bmi",
599 static unsigned int ath10k_core_get_fw_feature_str(char *buf
,
601 enum ath10k_fw_features feat
)
603 /* make sure that ath10k_core_fw_feature_str[] gets updated */
604 BUILD_BUG_ON(ARRAY_SIZE(ath10k_core_fw_feature_str
) !=
605 ATH10K_FW_FEATURE_COUNT
);
607 if (feat
>= ARRAY_SIZE(ath10k_core_fw_feature_str
) ||
608 WARN_ON(!ath10k_core_fw_feature_str
[feat
])) {
609 return scnprintf(buf
, buf_len
, "bit%d", feat
);
612 return scnprintf(buf
, buf_len
, "%s", ath10k_core_fw_feature_str
[feat
]);
615 void ath10k_core_get_fw_features_str(struct ath10k
*ar
,
622 for (i
= 0; i
< ATH10K_FW_FEATURE_COUNT
; i
++) {
623 if (test_bit(i
, ar
->normal_mode_fw
.fw_file
.fw_features
)) {
625 len
+= scnprintf(buf
+ len
, buf_len
- len
, ",");
627 len
+= ath10k_core_get_fw_feature_str(buf
+ len
,
634 static void ath10k_send_suspend_complete(struct ath10k
*ar
)
636 ath10k_dbg(ar
, ATH10K_DBG_BOOT
, "boot suspend complete\n");
638 complete(&ar
->target_suspend
);
641 static void ath10k_init_sdio(struct ath10k
*ar
)
645 ath10k_bmi_write32(ar
, hi_mbox_io_block_sz
, 256);
646 ath10k_bmi_write32(ar
, hi_mbox_isr_yield_limit
, 99);
647 ath10k_bmi_read32(ar
, hi_acs_flags
, ¶m
);
649 param
|= (HI_ACS_FLAGS_SDIO_SWAP_MAILBOX_SET
|
650 HI_ACS_FLAGS_SDIO_REDUCE_TX_COMPL_SET
|
651 HI_ACS_FLAGS_ALT_DATA_CREDIT_SIZE
);
653 ath10k_bmi_write32(ar
, hi_acs_flags
, param
);
656 static int ath10k_init_configure_target(struct ath10k
*ar
)
661 /* tell target which HTC version it is used*/
662 ret
= ath10k_bmi_write32(ar
, hi_app_host_interest
,
663 HTC_PROTOCOL_VERSION
);
665 ath10k_err(ar
, "settings HTC version failed\n");
669 /* set the firmware mode to STA/IBSS/AP */
670 ret
= ath10k_bmi_read32(ar
, hi_option_flag
, ¶m_host
);
672 ath10k_err(ar
, "setting firmware mode (1/2) failed\n");
676 /* TODO following parameters need to be re-visited. */
678 param_host
|= (1 << HI_OPTION_NUM_DEV_SHIFT
);
680 /* FIXME: Why FW_MODE_AP ??.*/
681 param_host
|= (HI_OPTION_FW_MODE_AP
<< HI_OPTION_FW_MODE_SHIFT
);
682 /* mac_addr_method */
683 param_host
|= (1 << HI_OPTION_MAC_ADDR_METHOD_SHIFT
);
684 /* firmware_bridge */
685 param_host
|= (0 << HI_OPTION_FW_BRIDGE_SHIFT
);
687 param_host
|= (0 << HI_OPTION_FW_SUBMODE_SHIFT
);
689 ret
= ath10k_bmi_write32(ar
, hi_option_flag
, param_host
);
691 ath10k_err(ar
, "setting firmware mode (2/2) failed\n");
695 /* We do all byte-swapping on the host */
696 ret
= ath10k_bmi_write32(ar
, hi_be
, 0);
698 ath10k_err(ar
, "setting host CPU BE mode failed\n");
702 /* FW descriptor/Data swap flags */
703 ret
= ath10k_bmi_write32(ar
, hi_fw_swap
, 0);
706 ath10k_err(ar
, "setting FW data/desc swap flags failed\n");
710 /* Some devices have a special sanity check that verifies the PCI
711 * Device ID is written to this host interest var. It is known to be
712 * required to boot QCA6164.
714 ret
= ath10k_bmi_write32(ar
, hi_hci_uart_pwr_mgmt_params_ext
,
717 ath10k_err(ar
, "failed to set pwr_mgmt_params: %d\n", ret
);
724 static const struct firmware
*ath10k_fetch_fw_file(struct ath10k
*ar
,
729 const struct firmware
*fw
;
733 return ERR_PTR(-ENOENT
);
738 snprintf(filename
, sizeof(filename
), "%s/%s", dir
, file
);
739 ret
= firmware_request_nowarn(&fw
, filename
, ar
->dev
);
740 ath10k_dbg(ar
, ATH10K_DBG_BOOT
, "boot fw request '%s': %d\n",
749 static int ath10k_push_board_ext_data(struct ath10k
*ar
, const void *data
,
752 u32 board_data_size
= ar
->hw_params
.fw
.board_size
;
753 u32 board_ext_data_size
= ar
->hw_params
.fw
.board_ext_size
;
754 u32 board_ext_data_addr
;
757 ret
= ath10k_bmi_read32(ar
, hi_board_ext_data
, &board_ext_data_addr
);
759 ath10k_err(ar
, "could not read board ext data addr (%d)\n",
764 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
765 "boot push board extended data addr 0x%x\n",
766 board_ext_data_addr
);
768 if (board_ext_data_addr
== 0)
771 if (data_len
!= (board_data_size
+ board_ext_data_size
)) {
772 ath10k_err(ar
, "invalid board (ext) data sizes %zu != %d+%d\n",
773 data_len
, board_data_size
, board_ext_data_size
);
777 ret
= ath10k_bmi_write_memory(ar
, board_ext_data_addr
,
778 data
+ board_data_size
,
779 board_ext_data_size
);
781 ath10k_err(ar
, "could not write board ext data (%d)\n", ret
);
785 ret
= ath10k_bmi_write32(ar
, hi_board_ext_data_config
,
786 (board_ext_data_size
<< 16) | 1);
788 ath10k_err(ar
, "could not write board ext data bit (%d)\n",
796 static int ath10k_core_get_board_id_from_otp(struct ath10k
*ar
)
799 u8 board_id
, chip_id
;
800 bool ext_bid_support
;
801 int ret
, bmi_board_id_param
;
803 address
= ar
->hw_params
.patch_load_addr
;
805 if (!ar
->normal_mode_fw
.fw_file
.otp_data
||
806 !ar
->normal_mode_fw
.fw_file
.otp_len
) {
808 "failed to retrieve board id because of invalid otp\n");
812 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
813 "boot upload otp to 0x%x len %zd for board id\n",
814 address
, ar
->normal_mode_fw
.fw_file
.otp_len
);
816 ret
= ath10k_bmi_fast_download(ar
, address
,
817 ar
->normal_mode_fw
.fw_file
.otp_data
,
818 ar
->normal_mode_fw
.fw_file
.otp_len
);
820 ath10k_err(ar
, "could not write otp for board id check: %d\n",
825 if (ar
->cal_mode
== ATH10K_PRE_CAL_MODE_DT
||
826 ar
->cal_mode
== ATH10K_PRE_CAL_MODE_FILE
)
827 bmi_board_id_param
= BMI_PARAM_GET_FLASH_BOARD_ID
;
829 bmi_board_id_param
= BMI_PARAM_GET_EEPROM_BOARD_ID
;
831 ret
= ath10k_bmi_execute(ar
, address
, bmi_board_id_param
, &result
);
833 ath10k_err(ar
, "could not execute otp for board id check: %d\n",
838 board_id
= MS(result
, ATH10K_BMI_BOARD_ID_FROM_OTP
);
839 chip_id
= MS(result
, ATH10K_BMI_CHIP_ID_FROM_OTP
);
840 ext_bid_support
= (result
& ATH10K_BMI_EXT_BOARD_ID_SUPPORT
);
842 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
843 "boot get otp board id result 0x%08x board_id %d chip_id %d ext_bid_support %d\n",
844 result
, board_id
, chip_id
, ext_bid_support
);
846 ar
->id
.ext_bid_supported
= ext_bid_support
;
848 if ((result
& ATH10K_BMI_BOARD_ID_STATUS_MASK
) != 0 ||
850 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
851 "board id does not exist in otp, ignore it\n");
855 ar
->id
.bmi_ids_valid
= true;
856 ar
->id
.bmi_board_id
= board_id
;
857 ar
->id
.bmi_chip_id
= chip_id
;
862 static void ath10k_core_check_bdfext(const struct dmi_header
*hdr
, void *data
)
864 struct ath10k
*ar
= data
;
866 const char *magic
= ATH10K_SMBIOS_BDF_EXT_MAGIC
;
870 if (hdr
->type
!= ATH10K_SMBIOS_BDF_EXT_TYPE
)
873 if (hdr
->length
!= ATH10K_SMBIOS_BDF_EXT_LENGTH
) {
874 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
875 "wrong smbios bdf ext type length (%d).\n",
880 bdf_enabled
= *((u8
*)hdr
+ ATH10K_SMBIOS_BDF_EXT_OFFSET
);
882 ath10k_dbg(ar
, ATH10K_DBG_BOOT
, "bdf variant name not found.\n");
886 /* Only one string exists (per spec) */
887 bdf_ext
= (char *)hdr
+ hdr
->length
;
889 if (memcmp(bdf_ext
, magic
, strlen(magic
)) != 0) {
890 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
891 "bdf variant magic does not match.\n");
895 for (i
= 0; i
< strlen(bdf_ext
); i
++) {
896 if (!isascii(bdf_ext
[i
]) || !isprint(bdf_ext
[i
])) {
897 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
898 "bdf variant name contains non ascii chars.\n");
903 /* Copy extension name without magic suffix */
904 if (strscpy(ar
->id
.bdf_ext
, bdf_ext
+ strlen(magic
),
905 sizeof(ar
->id
.bdf_ext
)) < 0) {
906 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
907 "bdf variant string is longer than the buffer can accommodate (variant: %s)\n",
912 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
913 "found and validated bdf variant smbios_type 0x%x bdf %s\n",
914 ATH10K_SMBIOS_BDF_EXT_TYPE
, bdf_ext
);
917 static int ath10k_core_check_smbios(struct ath10k
*ar
)
919 ar
->id
.bdf_ext
[0] = '\0';
920 dmi_walk(ath10k_core_check_bdfext
, ar
);
922 if (ar
->id
.bdf_ext
[0] == '\0')
928 static int ath10k_core_check_dt(struct ath10k
*ar
)
930 struct device_node
*node
;
931 const char *variant
= NULL
;
933 node
= ar
->dev
->of_node
;
937 of_property_read_string(node
, "qcom,ath10k-calibration-variant",
942 if (strscpy(ar
->id
.bdf_ext
, variant
, sizeof(ar
->id
.bdf_ext
)) < 0)
943 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
944 "bdf variant string is longer than the buffer can accommodate (variant: %s)\n",
950 static int ath10k_download_fw(struct ath10k
*ar
)
952 u32 address
, data_len
;
956 address
= ar
->hw_params
.patch_load_addr
;
958 data
= ar
->running_fw
->fw_file
.firmware_data
;
959 data_len
= ar
->running_fw
->fw_file
.firmware_len
;
961 ret
= ath10k_swap_code_seg_configure(ar
, &ar
->running_fw
->fw_file
);
963 ath10k_err(ar
, "failed to configure fw code swap: %d\n",
968 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
969 "boot uploading firmware image %pK len %d\n",
972 /* Check if device supports to download firmware via
973 * diag copy engine. Downloading firmware via diag CE
974 * greatly reduces the time to download firmware.
976 if (ar
->hw_params
.fw_diag_ce_download
) {
977 ret
= ath10k_hw_diag_fast_download(ar
, address
,
980 /* firmware upload via diag ce was successful */
984 "failed to upload firmware via diag ce, trying BMI: %d",
988 return ath10k_bmi_fast_download(ar
, address
,
992 void ath10k_core_free_board_files(struct ath10k
*ar
)
994 if (!IS_ERR(ar
->normal_mode_fw
.board
))
995 release_firmware(ar
->normal_mode_fw
.board
);
997 if (!IS_ERR(ar
->normal_mode_fw
.ext_board
))
998 release_firmware(ar
->normal_mode_fw
.ext_board
);
1000 ar
->normal_mode_fw
.board
= NULL
;
1001 ar
->normal_mode_fw
.board_data
= NULL
;
1002 ar
->normal_mode_fw
.board_len
= 0;
1003 ar
->normal_mode_fw
.ext_board
= NULL
;
1004 ar
->normal_mode_fw
.ext_board_data
= NULL
;
1005 ar
->normal_mode_fw
.ext_board_len
= 0;
1007 EXPORT_SYMBOL(ath10k_core_free_board_files
);
1009 static void ath10k_core_free_firmware_files(struct ath10k
*ar
)
1011 if (!IS_ERR(ar
->normal_mode_fw
.fw_file
.firmware
))
1012 release_firmware(ar
->normal_mode_fw
.fw_file
.firmware
);
1014 if (!IS_ERR(ar
->cal_file
))
1015 release_firmware(ar
->cal_file
);
1017 if (!IS_ERR(ar
->pre_cal_file
))
1018 release_firmware(ar
->pre_cal_file
);
1020 ath10k_swap_code_seg_release(ar
, &ar
->normal_mode_fw
.fw_file
);
1022 ar
->normal_mode_fw
.fw_file
.otp_data
= NULL
;
1023 ar
->normal_mode_fw
.fw_file
.otp_len
= 0;
1025 ar
->normal_mode_fw
.fw_file
.firmware
= NULL
;
1026 ar
->normal_mode_fw
.fw_file
.firmware_data
= NULL
;
1027 ar
->normal_mode_fw
.fw_file
.firmware_len
= 0;
1029 ar
->cal_file
= NULL
;
1030 ar
->pre_cal_file
= NULL
;
1033 static int ath10k_fetch_cal_file(struct ath10k
*ar
)
1037 /* pre-cal-<bus>-<id>.bin */
1038 scnprintf(filename
, sizeof(filename
), "pre-cal-%s-%s.bin",
1039 ath10k_bus_str(ar
->hif
.bus
), dev_name(ar
->dev
));
1041 ar
->pre_cal_file
= ath10k_fetch_fw_file(ar
, ATH10K_FW_DIR
, filename
);
1042 if (!IS_ERR(ar
->pre_cal_file
))
1045 /* cal-<bus>-<id>.bin */
1046 scnprintf(filename
, sizeof(filename
), "cal-%s-%s.bin",
1047 ath10k_bus_str(ar
->hif
.bus
), dev_name(ar
->dev
));
1049 ar
->cal_file
= ath10k_fetch_fw_file(ar
, ATH10K_FW_DIR
, filename
);
1050 if (IS_ERR(ar
->cal_file
))
1051 /* calibration file is optional, don't print any warnings */
1052 return PTR_ERR(ar
->cal_file
);
1054 ath10k_dbg(ar
, ATH10K_DBG_BOOT
, "found calibration file %s/%s\n",
1055 ATH10K_FW_DIR
, filename
);
1060 static int ath10k_core_fetch_board_data_api_1(struct ath10k
*ar
, int bd_ie_type
)
1062 const struct firmware
*fw
;
1064 if (bd_ie_type
== ATH10K_BD_IE_BOARD
) {
1065 if (!ar
->hw_params
.fw
.board
) {
1066 ath10k_err(ar
, "failed to find board file fw entry\n");
1070 ar
->normal_mode_fw
.board
= ath10k_fetch_fw_file(ar
,
1071 ar
->hw_params
.fw
.dir
,
1072 ar
->hw_params
.fw
.board
);
1073 if (IS_ERR(ar
->normal_mode_fw
.board
))
1074 return PTR_ERR(ar
->normal_mode_fw
.board
);
1076 ar
->normal_mode_fw
.board_data
= ar
->normal_mode_fw
.board
->data
;
1077 ar
->normal_mode_fw
.board_len
= ar
->normal_mode_fw
.board
->size
;
1078 } else if (bd_ie_type
== ATH10K_BD_IE_BOARD_EXT
) {
1079 if (!ar
->hw_params
.fw
.eboard
) {
1080 ath10k_err(ar
, "failed to find eboard file fw entry\n");
1084 fw
= ath10k_fetch_fw_file(ar
, ar
->hw_params
.fw
.dir
,
1085 ar
->hw_params
.fw
.eboard
);
1086 ar
->normal_mode_fw
.ext_board
= fw
;
1087 if (IS_ERR(ar
->normal_mode_fw
.ext_board
))
1088 return PTR_ERR(ar
->normal_mode_fw
.ext_board
);
1090 ar
->normal_mode_fw
.ext_board_data
= ar
->normal_mode_fw
.ext_board
->data
;
1091 ar
->normal_mode_fw
.ext_board_len
= ar
->normal_mode_fw
.ext_board
->size
;
1097 static int ath10k_core_parse_bd_ie_board(struct ath10k
*ar
,
1098 const void *buf
, size_t buf_len
,
1099 const char *boardname
,
1102 const struct ath10k_fw_ie
*hdr
;
1103 bool name_match_found
;
1104 int ret
, board_ie_id
;
1105 size_t board_ie_len
;
1106 const void *board_ie_data
;
1108 name_match_found
= false;
1110 /* go through ATH10K_BD_IE_BOARD_ elements */
1111 while (buf_len
> sizeof(struct ath10k_fw_ie
)) {
1113 board_ie_id
= le32_to_cpu(hdr
->id
);
1114 board_ie_len
= le32_to_cpu(hdr
->len
);
1115 board_ie_data
= hdr
->data
;
1117 buf_len
-= sizeof(*hdr
);
1118 buf
+= sizeof(*hdr
);
1120 if (buf_len
< ALIGN(board_ie_len
, 4)) {
1121 ath10k_err(ar
, "invalid ATH10K_BD_IE_BOARD length: %zu < %zu\n",
1122 buf_len
, ALIGN(board_ie_len
, 4));
1127 switch (board_ie_id
) {
1128 case ATH10K_BD_IE_BOARD_NAME
:
1129 ath10k_dbg_dump(ar
, ATH10K_DBG_BOOT
, "board name", "",
1130 board_ie_data
, board_ie_len
);
1132 if (board_ie_len
!= strlen(boardname
))
1135 ret
= memcmp(board_ie_data
, boardname
, strlen(boardname
));
1139 name_match_found
= true;
1140 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
1141 "boot found match for name '%s'",
1144 case ATH10K_BD_IE_BOARD_DATA
:
1145 if (!name_match_found
)
1146 /* no match found */
1149 if (bd_ie_type
== ATH10K_BD_IE_BOARD
) {
1150 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
1151 "boot found board data for '%s'",
1154 ar
->normal_mode_fw
.board_data
= board_ie_data
;
1155 ar
->normal_mode_fw
.board_len
= board_ie_len
;
1156 } else if (bd_ie_type
== ATH10K_BD_IE_BOARD_EXT
) {
1157 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
1158 "boot found eboard data for '%s'",
1161 ar
->normal_mode_fw
.ext_board_data
= board_ie_data
;
1162 ar
->normal_mode_fw
.ext_board_len
= board_ie_len
;
1168 ath10k_warn(ar
, "unknown ATH10K_BD_IE_BOARD found: %d\n",
1173 /* jump over the padding */
1174 board_ie_len
= ALIGN(board_ie_len
, 4);
1176 buf_len
-= board_ie_len
;
1177 buf
+= board_ie_len
;
1180 /* no match found */
1187 static int ath10k_core_search_bd(struct ath10k
*ar
,
1188 const char *boardname
,
1193 struct ath10k_fw_ie
*hdr
;
1194 int ret
= -ENOENT
, ie_id
;
1196 while (len
> sizeof(struct ath10k_fw_ie
)) {
1197 hdr
= (struct ath10k_fw_ie
*)data
;
1198 ie_id
= le32_to_cpu(hdr
->id
);
1199 ie_len
= le32_to_cpu(hdr
->len
);
1201 len
-= sizeof(*hdr
);
1204 if (len
< ALIGN(ie_len
, 4)) {
1205 ath10k_err(ar
, "invalid length for board ie_id %d ie_len %zu len %zu\n",
1206 ie_id
, ie_len
, len
);
1211 case ATH10K_BD_IE_BOARD
:
1212 ret
= ath10k_core_parse_bd_ie_board(ar
, data
, ie_len
,
1214 ATH10K_BD_IE_BOARD
);
1216 /* no match found, continue */
1219 /* either found or error, so stop searching */
1221 case ATH10K_BD_IE_BOARD_EXT
:
1222 ret
= ath10k_core_parse_bd_ie_board(ar
, data
, ie_len
,
1224 ATH10K_BD_IE_BOARD_EXT
);
1226 /* no match found, continue */
1229 /* either found or error, so stop searching */
1233 /* jump over the padding */
1234 ie_len
= ALIGN(ie_len
, 4);
1241 /* return result of parse_bd_ie_board() or -ENOENT */
1245 static int ath10k_core_fetch_board_data_api_n(struct ath10k
*ar
,
1246 const char *boardname
,
1247 const char *fallback_boardname
,
1248 const char *filename
)
1250 size_t len
, magic_len
;
1254 /* Skip if already fetched during board data download */
1255 if (!ar
->normal_mode_fw
.board
)
1256 ar
->normal_mode_fw
.board
= ath10k_fetch_fw_file(ar
,
1257 ar
->hw_params
.fw
.dir
,
1259 if (IS_ERR(ar
->normal_mode_fw
.board
))
1260 return PTR_ERR(ar
->normal_mode_fw
.board
);
1262 data
= ar
->normal_mode_fw
.board
->data
;
1263 len
= ar
->normal_mode_fw
.board
->size
;
1265 /* magic has extra null byte padded */
1266 magic_len
= strlen(ATH10K_BOARD_MAGIC
) + 1;
1267 if (len
< magic_len
) {
1268 ath10k_err(ar
, "failed to find magic value in %s/%s, file too short: %zu\n",
1269 ar
->hw_params
.fw
.dir
, filename
, len
);
1274 if (memcmp(data
, ATH10K_BOARD_MAGIC
, magic_len
)) {
1275 ath10k_err(ar
, "found invalid board magic\n");
1280 /* magic is padded to 4 bytes */
1281 magic_len
= ALIGN(magic_len
, 4);
1282 if (len
< magic_len
) {
1283 ath10k_err(ar
, "failed: %s/%s too small to contain board data, len: %zu\n",
1284 ar
->hw_params
.fw
.dir
, filename
, len
);
1292 /* attempt to find boardname in the IE list */
1293 ret
= ath10k_core_search_bd(ar
, boardname
, data
, len
);
1295 /* if we didn't find it and have a fallback name, try that */
1296 if (ret
== -ENOENT
&& fallback_boardname
)
1297 ret
= ath10k_core_search_bd(ar
, fallback_boardname
, data
, len
);
1299 if (ret
== -ENOENT
) {
1301 "failed to fetch board data for %s from %s/%s\n",
1302 boardname
, ar
->hw_params
.fw
.dir
, filename
);
1312 ath10k_core_free_board_files(ar
);
1316 static int ath10k_core_create_board_name(struct ath10k
*ar
, char *name
,
1317 size_t name_len
, bool with_variant
)
1319 /* strlen(',variant=') + strlen(ar->id.bdf_ext) */
1320 char variant
[9 + ATH10K_SMBIOS_BDF_EXT_STR_LENGTH
] = { 0 };
1322 if (with_variant
&& ar
->id
.bdf_ext
[0] != '\0')
1323 scnprintf(variant
, sizeof(variant
), ",variant=%s",
1326 if (ar
->id
.bmi_ids_valid
) {
1327 scnprintf(name
, name_len
,
1328 "bus=%s,bmi-chip-id=%d,bmi-board-id=%d%s",
1329 ath10k_bus_str(ar
->hif
.bus
),
1331 ar
->id
.bmi_board_id
, variant
);
1335 if (ar
->id
.qmi_ids_valid
) {
1336 scnprintf(name
, name_len
,
1337 "bus=%s,qmi-board-id=%x",
1338 ath10k_bus_str(ar
->hif
.bus
),
1339 ar
->id
.qmi_board_id
);
1343 scnprintf(name
, name_len
,
1344 "bus=%s,vendor=%04x,device=%04x,subsystem-vendor=%04x,subsystem-device=%04x%s",
1345 ath10k_bus_str(ar
->hif
.bus
),
1346 ar
->id
.vendor
, ar
->id
.device
,
1347 ar
->id
.subsystem_vendor
, ar
->id
.subsystem_device
, variant
);
1349 ath10k_dbg(ar
, ATH10K_DBG_BOOT
, "boot using board name '%s'\n", name
);
1354 static int ath10k_core_create_eboard_name(struct ath10k
*ar
, char *name
,
1357 if (ar
->id
.bmi_ids_valid
) {
1358 scnprintf(name
, name_len
,
1359 "bus=%s,bmi-chip-id=%d,bmi-eboard-id=%d",
1360 ath10k_bus_str(ar
->hif
.bus
),
1362 ar
->id
.bmi_eboard_id
);
1364 ath10k_dbg(ar
, ATH10K_DBG_BOOT
, "boot using eboard name '%s'\n", name
);
1367 /* Fallback if returned board id is zero */
1371 int ath10k_core_fetch_board_file(struct ath10k
*ar
, int bd_ie_type
)
1373 char boardname
[100], fallback_boardname
[100];
1376 if (bd_ie_type
== ATH10K_BD_IE_BOARD
) {
1377 ret
= ath10k_core_create_board_name(ar
, boardname
,
1378 sizeof(boardname
), true);
1380 ath10k_err(ar
, "failed to create board name: %d", ret
);
1384 ret
= ath10k_core_create_board_name(ar
, fallback_boardname
,
1385 sizeof(boardname
), false);
1387 ath10k_err(ar
, "failed to create fallback board name: %d", ret
);
1390 } else if (bd_ie_type
== ATH10K_BD_IE_BOARD_EXT
) {
1391 ret
= ath10k_core_create_eboard_name(ar
, boardname
,
1394 ath10k_err(ar
, "fallback to eboard.bin since board id 0");
1400 ret
= ath10k_core_fetch_board_data_api_n(ar
, boardname
,
1402 ATH10K_BOARD_API2_FILE
);
1408 ret
= ath10k_core_fetch_board_data_api_1(ar
, bd_ie_type
);
1410 ath10k_err(ar
, "failed to fetch board-2.bin or board.bin from %s\n",
1411 ar
->hw_params
.fw
.dir
);
1416 ath10k_dbg(ar
, ATH10K_DBG_BOOT
, "using board api %d\n", ar
->bd_api
);
1419 EXPORT_SYMBOL(ath10k_core_fetch_board_file
);
1421 static int ath10k_core_get_ext_board_id_from_otp(struct ath10k
*ar
)
1423 u32 result
, address
;
1427 address
= ar
->hw_params
.patch_load_addr
;
1429 if (!ar
->normal_mode_fw
.fw_file
.otp_data
||
1430 !ar
->normal_mode_fw
.fw_file
.otp_len
) {
1432 "failed to retrieve extended board id due to otp binary missing\n");
1436 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
1437 "boot upload otp to 0x%x len %zd for ext board id\n",
1438 address
, ar
->normal_mode_fw
.fw_file
.otp_len
);
1440 ret
= ath10k_bmi_fast_download(ar
, address
,
1441 ar
->normal_mode_fw
.fw_file
.otp_data
,
1442 ar
->normal_mode_fw
.fw_file
.otp_len
);
1444 ath10k_err(ar
, "could not write otp for ext board id check: %d\n",
1449 ret
= ath10k_bmi_execute(ar
, address
, BMI_PARAM_GET_EXT_BOARD_ID
, &result
);
1451 ath10k_err(ar
, "could not execute otp for ext board id check: %d\n",
1457 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
1458 "ext board id does not exist in otp, ignore it\n");
1462 ext_board_id
= result
& ATH10K_BMI_EBOARD_ID_STATUS_MASK
;
1464 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
1465 "boot get otp ext board id result 0x%08x ext_board_id %d\n",
1466 result
, ext_board_id
);
1468 ar
->id
.bmi_eboard_id
= ext_board_id
;
1473 static int ath10k_download_board_data(struct ath10k
*ar
, const void *data
,
1476 u32 board_data_size
= ar
->hw_params
.fw
.board_size
;
1477 u32 eboard_data_size
= ar
->hw_params
.fw
.ext_board_size
;
1479 u32 ext_board_address
;
1482 ret
= ath10k_push_board_ext_data(ar
, data
, data_len
);
1484 ath10k_err(ar
, "could not push board ext data (%d)\n", ret
);
1488 ret
= ath10k_bmi_read32(ar
, hi_board_data
, &board_address
);
1490 ath10k_err(ar
, "could not read board data addr (%d)\n", ret
);
1494 ret
= ath10k_bmi_write_memory(ar
, board_address
, data
,
1495 min_t(u32
, board_data_size
,
1498 ath10k_err(ar
, "could not write board data (%d)\n", ret
);
1502 ret
= ath10k_bmi_write32(ar
, hi_board_data_initialized
, 1);
1504 ath10k_err(ar
, "could not write board data bit (%d)\n", ret
);
1508 if (!ar
->id
.ext_bid_supported
)
1511 /* Extended board data download */
1512 ret
= ath10k_core_get_ext_board_id_from_otp(ar
);
1513 if (ret
== -EOPNOTSUPP
) {
1514 /* Not fetching ext_board_data if ext board id is 0 */
1515 ath10k_dbg(ar
, ATH10K_DBG_BOOT
, "otp returned ext board id 0\n");
1518 ath10k_err(ar
, "failed to get extended board id: %d\n", ret
);
1522 ret
= ath10k_core_fetch_board_file(ar
, ATH10K_BD_IE_BOARD_EXT
);
1526 if (ar
->normal_mode_fw
.ext_board_data
) {
1527 ext_board_address
= board_address
+ EXT_BOARD_ADDRESS_OFFSET
;
1528 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
1529 "boot writing ext board data to addr 0x%x",
1531 ret
= ath10k_bmi_write_memory(ar
, ext_board_address
,
1532 ar
->normal_mode_fw
.ext_board_data
,
1533 min_t(u32
, eboard_data_size
, data_len
));
1535 ath10k_err(ar
, "failed to write ext board data: %d\n", ret
);
1542 static int ath10k_download_and_run_otp(struct ath10k
*ar
)
1544 u32 result
, address
= ar
->hw_params
.patch_load_addr
;
1545 u32 bmi_otp_exe_param
= ar
->hw_params
.otp_exe_param
;
1548 ret
= ath10k_download_board_data(ar
,
1549 ar
->running_fw
->board_data
,
1550 ar
->running_fw
->board_len
);
1552 ath10k_err(ar
, "failed to download board data: %d\n", ret
);
1556 /* OTP is optional */
1558 if (!ar
->running_fw
->fw_file
.otp_data
||
1559 !ar
->running_fw
->fw_file
.otp_len
) {
1560 ath10k_warn(ar
, "Not running otp, calibration will be incorrect (otp-data %pK otp_len %zd)!\n",
1561 ar
->running_fw
->fw_file
.otp_data
,
1562 ar
->running_fw
->fw_file
.otp_len
);
1566 ath10k_dbg(ar
, ATH10K_DBG_BOOT
, "boot upload otp to 0x%x len %zd\n",
1567 address
, ar
->running_fw
->fw_file
.otp_len
);
1569 ret
= ath10k_bmi_fast_download(ar
, address
,
1570 ar
->running_fw
->fw_file
.otp_data
,
1571 ar
->running_fw
->fw_file
.otp_len
);
1573 ath10k_err(ar
, "could not write otp (%d)\n", ret
);
1577 /* As of now pre-cal is valid for 10_4 variants */
1578 if (ar
->cal_mode
== ATH10K_PRE_CAL_MODE_DT
||
1579 ar
->cal_mode
== ATH10K_PRE_CAL_MODE_FILE
)
1580 bmi_otp_exe_param
= BMI_PARAM_FLASH_SECTION_ALL
;
1582 ret
= ath10k_bmi_execute(ar
, address
, bmi_otp_exe_param
, &result
);
1584 ath10k_err(ar
, "could not execute otp (%d)\n", ret
);
1588 ath10k_dbg(ar
, ATH10K_DBG_BOOT
, "boot otp execute result %d\n", result
);
1590 if (!(skip_otp
|| test_bit(ATH10K_FW_FEATURE_IGNORE_OTP_RESULT
,
1591 ar
->running_fw
->fw_file
.fw_features
)) &&
1593 ath10k_err(ar
, "otp calibration failed: %d", result
);
1600 static int ath10k_download_cal_file(struct ath10k
*ar
,
1601 const struct firmware
*file
)
1609 return PTR_ERR(file
);
1611 ret
= ath10k_download_board_data(ar
, file
->data
, file
->size
);
1613 ath10k_err(ar
, "failed to download cal_file data: %d\n", ret
);
1617 ath10k_dbg(ar
, ATH10K_DBG_BOOT
, "boot cal file downloaded\n");
1622 static int ath10k_download_cal_dt(struct ath10k
*ar
, const char *dt_name
)
1624 struct device_node
*node
;
1629 node
= ar
->dev
->of_node
;
1631 /* Device Tree is optional, don't print any warnings if
1632 * there's no node for ath10k.
1636 if (!of_get_property(node
, dt_name
, &data_len
)) {
1637 /* The calibration data node is optional */
1641 if (data_len
!= ar
->hw_params
.cal_data_len
) {
1642 ath10k_warn(ar
, "invalid calibration data length in DT: %d\n",
1648 data
= kmalloc(data_len
, GFP_KERNEL
);
1654 ret
= of_property_read_u8_array(node
, dt_name
, data
, data_len
);
1656 ath10k_warn(ar
, "failed to read calibration data from DT: %d\n",
1661 ret
= ath10k_download_board_data(ar
, data
, data_len
);
1663 ath10k_warn(ar
, "failed to download calibration data from Device Tree: %d\n",
1677 static int ath10k_download_cal_eeprom(struct ath10k
*ar
)
1683 ret
= ath10k_hif_fetch_cal_eeprom(ar
, &data
, &data_len
);
1685 if (ret
!= -EOPNOTSUPP
)
1686 ath10k_warn(ar
, "failed to read calibration data from EEPROM: %d\n",
1691 ret
= ath10k_download_board_data(ar
, data
, data_len
);
1693 ath10k_warn(ar
, "failed to download calibration data from EEPROM: %d\n",
1706 int ath10k_core_fetch_firmware_api_n(struct ath10k
*ar
, const char *name
,
1707 struct ath10k_fw_file
*fw_file
)
1709 size_t magic_len
, len
, ie_len
;
1710 int ie_id
, i
, index
, bit
, ret
;
1711 struct ath10k_fw_ie
*hdr
;
1713 __le32
*timestamp
, *version
;
1715 /* first fetch the firmware file (firmware-*.bin) */
1716 fw_file
->firmware
= ath10k_fetch_fw_file(ar
, ar
->hw_params
.fw
.dir
,
1718 if (IS_ERR(fw_file
->firmware
))
1719 return PTR_ERR(fw_file
->firmware
);
1721 data
= fw_file
->firmware
->data
;
1722 len
= fw_file
->firmware
->size
;
1724 /* magic also includes the null byte, check that as well */
1725 magic_len
= strlen(ATH10K_FIRMWARE_MAGIC
) + 1;
1727 if (len
< magic_len
) {
1728 ath10k_err(ar
, "firmware file '%s/%s' too small to contain magic: %zu\n",
1729 ar
->hw_params
.fw
.dir
, name
, len
);
1734 if (memcmp(data
, ATH10K_FIRMWARE_MAGIC
, magic_len
) != 0) {
1735 ath10k_err(ar
, "invalid firmware magic\n");
1740 /* jump over the padding */
1741 magic_len
= ALIGN(magic_len
, 4);
1747 while (len
> sizeof(struct ath10k_fw_ie
)) {
1748 hdr
= (struct ath10k_fw_ie
*)data
;
1750 ie_id
= le32_to_cpu(hdr
->id
);
1751 ie_len
= le32_to_cpu(hdr
->len
);
1753 len
-= sizeof(*hdr
);
1754 data
+= sizeof(*hdr
);
1757 ath10k_err(ar
, "invalid length for FW IE %d (%zu < %zu)\n",
1758 ie_id
, len
, ie_len
);
1764 case ATH10K_FW_IE_FW_VERSION
:
1765 if (ie_len
> sizeof(fw_file
->fw_version
) - 1)
1768 memcpy(fw_file
->fw_version
, data
, ie_len
);
1769 fw_file
->fw_version
[ie_len
] = '\0';
1771 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
1772 "found fw version %s\n",
1773 fw_file
->fw_version
);
1775 case ATH10K_FW_IE_TIMESTAMP
:
1776 if (ie_len
!= sizeof(u32
))
1779 timestamp
= (__le32
*)data
;
1781 ath10k_dbg(ar
, ATH10K_DBG_BOOT
, "found fw timestamp %d\n",
1782 le32_to_cpup(timestamp
));
1784 case ATH10K_FW_IE_FEATURES
:
1785 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
1786 "found firmware features ie (%zd B)\n",
1789 for (i
= 0; i
< ATH10K_FW_FEATURE_COUNT
; i
++) {
1793 if (index
== ie_len
)
1796 if (data
[index
] & (1 << bit
)) {
1797 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
1798 "Enabling feature bit: %i\n",
1800 __set_bit(i
, fw_file
->fw_features
);
1804 ath10k_dbg_dump(ar
, ATH10K_DBG_BOOT
, "features", "",
1805 fw_file
->fw_features
,
1806 sizeof(fw_file
->fw_features
));
1808 case ATH10K_FW_IE_FW_IMAGE
:
1809 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
1810 "found fw image ie (%zd B)\n",
1813 fw_file
->firmware_data
= data
;
1814 fw_file
->firmware_len
= ie_len
;
1817 case ATH10K_FW_IE_OTP_IMAGE
:
1818 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
1819 "found otp image ie (%zd B)\n",
1822 fw_file
->otp_data
= data
;
1823 fw_file
->otp_len
= ie_len
;
1826 case ATH10K_FW_IE_WMI_OP_VERSION
:
1827 if (ie_len
!= sizeof(u32
))
1830 version
= (__le32
*)data
;
1832 fw_file
->wmi_op_version
= le32_to_cpup(version
);
1834 ath10k_dbg(ar
, ATH10K_DBG_BOOT
, "found fw ie wmi op version %d\n",
1835 fw_file
->wmi_op_version
);
1837 case ATH10K_FW_IE_HTT_OP_VERSION
:
1838 if (ie_len
!= sizeof(u32
))
1841 version
= (__le32
*)data
;
1843 fw_file
->htt_op_version
= le32_to_cpup(version
);
1845 ath10k_dbg(ar
, ATH10K_DBG_BOOT
, "found fw ie htt op version %d\n",
1846 fw_file
->htt_op_version
);
1848 case ATH10K_FW_IE_FW_CODE_SWAP_IMAGE
:
1849 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
1850 "found fw code swap image ie (%zd B)\n",
1852 fw_file
->codeswap_data
= data
;
1853 fw_file
->codeswap_len
= ie_len
;
1856 ath10k_warn(ar
, "Unknown FW IE: %u\n",
1857 le32_to_cpu(hdr
->id
));
1861 /* jump over the padding */
1862 ie_len
= ALIGN(ie_len
, 4);
1868 if (!test_bit(ATH10K_FW_FEATURE_NON_BMI
, fw_file
->fw_features
) &&
1869 (!fw_file
->firmware_data
|| !fw_file
->firmware_len
)) {
1870 ath10k_warn(ar
, "No ATH10K_FW_IE_FW_IMAGE found from '%s/%s', skipping\n",
1871 ar
->hw_params
.fw
.dir
, name
);
1879 ath10k_core_free_firmware_files(ar
);
1883 static void ath10k_core_get_fw_name(struct ath10k
*ar
, char *fw_name
,
1884 size_t fw_name_len
, int fw_api
)
1886 switch (ar
->hif
.bus
) {
1887 case ATH10K_BUS_SDIO
:
1888 case ATH10K_BUS_USB
:
1889 scnprintf(fw_name
, fw_name_len
, "%s-%s-%d.bin",
1890 ATH10K_FW_FILE_BASE
, ath10k_bus_str(ar
->hif
.bus
),
1893 case ATH10K_BUS_PCI
:
1894 case ATH10K_BUS_AHB
:
1895 case ATH10K_BUS_SNOC
:
1896 scnprintf(fw_name
, fw_name_len
, "%s-%d.bin",
1897 ATH10K_FW_FILE_BASE
, fw_api
);
1902 static int ath10k_core_fetch_firmware_files(struct ath10k
*ar
)
1907 /* calibration file is optional, don't check for any errors */
1908 ath10k_fetch_cal_file(ar
);
1910 for (i
= ATH10K_FW_API_MAX
; i
>= ATH10K_FW_API_MIN
; i
--) {
1912 ath10k_dbg(ar
, ATH10K_DBG_BOOT
, "trying fw api %d\n",
1915 ath10k_core_get_fw_name(ar
, fw_name
, sizeof(fw_name
), ar
->fw_api
);
1916 ret
= ath10k_core_fetch_firmware_api_n(ar
, fw_name
,
1917 &ar
->normal_mode_fw
.fw_file
);
1922 /* we end up here if we couldn't fetch any firmware */
1924 ath10k_err(ar
, "Failed to find firmware-N.bin (N between %d and %d) from %s: %d",
1925 ATH10K_FW_API_MIN
, ATH10K_FW_API_MAX
, ar
->hw_params
.fw
.dir
,
1931 ath10k_dbg(ar
, ATH10K_DBG_BOOT
, "using fw api %d\n", ar
->fw_api
);
1936 static int ath10k_core_pre_cal_download(struct ath10k
*ar
)
1940 ret
= ath10k_download_cal_file(ar
, ar
->pre_cal_file
);
1942 ar
->cal_mode
= ATH10K_PRE_CAL_MODE_FILE
;
1946 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
1947 "boot did not find a pre calibration file, try DT next: %d\n",
1950 ret
= ath10k_download_cal_dt(ar
, "qcom,ath10k-pre-calibration-data");
1952 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
1953 "unable to load pre cal data from DT: %d\n", ret
);
1956 ar
->cal_mode
= ATH10K_PRE_CAL_MODE_DT
;
1959 ath10k_dbg(ar
, ATH10K_DBG_BOOT
, "boot using calibration mode %s\n",
1960 ath10k_cal_mode_str(ar
->cal_mode
));
1965 static int ath10k_core_pre_cal_config(struct ath10k
*ar
)
1969 ret
= ath10k_core_pre_cal_download(ar
);
1971 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
1972 "failed to load pre cal data: %d\n", ret
);
1976 ret
= ath10k_core_get_board_id_from_otp(ar
);
1978 ath10k_err(ar
, "failed to get board id: %d\n", ret
);
1982 ret
= ath10k_download_and_run_otp(ar
);
1984 ath10k_err(ar
, "failed to run otp: %d\n", ret
);
1988 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
1989 "pre cal configuration done successfully\n");
1994 static int ath10k_download_cal_data(struct ath10k
*ar
)
1998 ret
= ath10k_core_pre_cal_config(ar
);
2002 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
2003 "pre cal download procedure failed, try cal file: %d\n",
2006 ret
= ath10k_download_cal_file(ar
, ar
->cal_file
);
2008 ar
->cal_mode
= ATH10K_CAL_MODE_FILE
;
2012 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
2013 "boot did not find a calibration file, try DT next: %d\n",
2016 ret
= ath10k_download_cal_dt(ar
, "qcom,ath10k-calibration-data");
2018 ar
->cal_mode
= ATH10K_CAL_MODE_DT
;
2022 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
2023 "boot did not find DT entry, try target EEPROM next: %d\n",
2026 ret
= ath10k_download_cal_eeprom(ar
);
2028 ar
->cal_mode
= ATH10K_CAL_MODE_EEPROM
;
2032 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
2033 "boot did not find target EEPROM entry, try OTP next: %d\n",
2036 ret
= ath10k_download_and_run_otp(ar
);
2038 ath10k_err(ar
, "failed to run otp: %d\n", ret
);
2042 ar
->cal_mode
= ATH10K_CAL_MODE_OTP
;
2045 ath10k_dbg(ar
, ATH10K_DBG_BOOT
, "boot using calibration mode %s\n",
2046 ath10k_cal_mode_str(ar
->cal_mode
));
2050 static int ath10k_init_uart(struct ath10k
*ar
)
2055 * Explicitly setting UART prints to zero as target turns it on
2056 * based on scratch registers.
2058 ret
= ath10k_bmi_write32(ar
, hi_serial_enable
, 0);
2060 ath10k_warn(ar
, "could not disable UART prints (%d)\n", ret
);
2067 ret
= ath10k_bmi_write32(ar
, hi_dbg_uart_txpin
, ar
->hw_params
.uart_pin
);
2069 ath10k_warn(ar
, "could not enable UART prints (%d)\n", ret
);
2073 ret
= ath10k_bmi_write32(ar
, hi_serial_enable
, 1);
2075 ath10k_warn(ar
, "could not enable UART prints (%d)\n", ret
);
2079 /* Set the UART baud rate to 19200. */
2080 ret
= ath10k_bmi_write32(ar
, hi_desired_baud_rate
, 19200);
2082 ath10k_warn(ar
, "could not set the baud rate (%d)\n", ret
);
2086 ath10k_info(ar
, "UART prints enabled\n");
2090 static int ath10k_init_hw_params(struct ath10k
*ar
)
2092 const struct ath10k_hw_params
*uninitialized_var(hw_params
);
2095 for (i
= 0; i
< ARRAY_SIZE(ath10k_hw_params_list
); i
++) {
2096 hw_params
= &ath10k_hw_params_list
[i
];
2098 if (hw_params
->bus
== ar
->hif
.bus
&&
2099 hw_params
->id
== ar
->target_version
&&
2100 hw_params
->dev_id
== ar
->dev_id
)
2104 if (i
== ARRAY_SIZE(ath10k_hw_params_list
)) {
2105 ath10k_err(ar
, "Unsupported hardware version: 0x%x\n",
2106 ar
->target_version
);
2110 ar
->hw_params
= *hw_params
;
2112 ath10k_dbg(ar
, ATH10K_DBG_BOOT
, "Hardware name %s version 0x%x\n",
2113 ar
->hw_params
.name
, ar
->target_version
);
2118 static void ath10k_core_restart(struct work_struct
*work
)
2120 struct ath10k
*ar
= container_of(work
, struct ath10k
, restart_work
);
2123 set_bit(ATH10K_FLAG_CRASH_FLUSH
, &ar
->dev_flags
);
2125 /* Place a barrier to make sure the compiler doesn't reorder
2126 * CRASH_FLUSH and calling other functions.
2130 ieee80211_stop_queues(ar
->hw
);
2131 ath10k_drain_tx(ar
);
2132 complete(&ar
->scan
.started
);
2133 complete(&ar
->scan
.completed
);
2134 complete(&ar
->scan
.on_channel
);
2135 complete(&ar
->offchan_tx_completed
);
2136 complete(&ar
->install_key_done
);
2137 complete(&ar
->vdev_setup_done
);
2138 complete(&ar
->thermal
.wmi_sync
);
2139 complete(&ar
->bss_survey_done
);
2140 wake_up(&ar
->htt
.empty_tx_wq
);
2141 wake_up(&ar
->wmi
.tx_credits_wq
);
2142 wake_up(&ar
->peer_mapping_wq
);
2144 /* TODO: We can have one instance of cancelling coverage_class_work by
2145 * moving it to ath10k_halt(), so that both stop() and restart() would
2146 * call that but it takes conf_mutex() and if we call cancel_work_sync()
2147 * with conf_mutex it will deadlock.
2149 cancel_work_sync(&ar
->set_coverage_class_work
);
2151 mutex_lock(&ar
->conf_mutex
);
2153 switch (ar
->state
) {
2154 case ATH10K_STATE_ON
:
2155 ar
->state
= ATH10K_STATE_RESTARTING
;
2157 ath10k_scan_finish(ar
);
2158 ieee80211_restart_hw(ar
->hw
);
2160 case ATH10K_STATE_OFF
:
2161 /* this can happen if driver is being unloaded
2162 * or if the crash happens during FW probing
2164 ath10k_warn(ar
, "cannot restart a device that hasn't been started\n");
2166 case ATH10K_STATE_RESTARTING
:
2167 /* hw restart might be requested from multiple places */
2169 case ATH10K_STATE_RESTARTED
:
2170 ar
->state
= ATH10K_STATE_WEDGED
;
2172 case ATH10K_STATE_WEDGED
:
2173 ath10k_warn(ar
, "device is wedged, will not restart\n");
2175 case ATH10K_STATE_UTF
:
2176 ath10k_warn(ar
, "firmware restart in UTF mode not supported\n");
2180 mutex_unlock(&ar
->conf_mutex
);
2182 ret
= ath10k_coredump_submit(ar
);
2184 ath10k_warn(ar
, "failed to send firmware crash dump via devcoredump: %d",
2188 static void ath10k_core_set_coverage_class_work(struct work_struct
*work
)
2190 struct ath10k
*ar
= container_of(work
, struct ath10k
,
2191 set_coverage_class_work
);
2193 if (ar
->hw_params
.hw_ops
->set_coverage_class
)
2194 ar
->hw_params
.hw_ops
->set_coverage_class(ar
, -1);
2197 static int ath10k_core_init_firmware_features(struct ath10k
*ar
)
2199 struct ath10k_fw_file
*fw_file
= &ar
->normal_mode_fw
.fw_file
;
2202 if (test_bit(ATH10K_FW_FEATURE_WMI_10_2
, fw_file
->fw_features
) &&
2203 !test_bit(ATH10K_FW_FEATURE_WMI_10X
, fw_file
->fw_features
)) {
2204 ath10k_err(ar
, "feature bits corrupted: 10.2 feature requires 10.x feature to be set as well");
2208 if (fw_file
->wmi_op_version
>= ATH10K_FW_WMI_OP_VERSION_MAX
) {
2209 ath10k_err(ar
, "unsupported WMI OP version (max %d): %d\n",
2210 ATH10K_FW_WMI_OP_VERSION_MAX
, fw_file
->wmi_op_version
);
2214 ar
->wmi
.rx_decap_mode
= ATH10K_HW_TXRX_NATIVE_WIFI
;
2215 switch (ath10k_cryptmode_param
) {
2216 case ATH10K_CRYPT_MODE_HW
:
2217 clear_bit(ATH10K_FLAG_RAW_MODE
, &ar
->dev_flags
);
2218 clear_bit(ATH10K_FLAG_HW_CRYPTO_DISABLED
, &ar
->dev_flags
);
2220 case ATH10K_CRYPT_MODE_SW
:
2221 if (!test_bit(ATH10K_FW_FEATURE_RAW_MODE_SUPPORT
,
2222 fw_file
->fw_features
)) {
2223 ath10k_err(ar
, "cryptmode > 0 requires raw mode support from firmware");
2227 set_bit(ATH10K_FLAG_RAW_MODE
, &ar
->dev_flags
);
2228 set_bit(ATH10K_FLAG_HW_CRYPTO_DISABLED
, &ar
->dev_flags
);
2231 ath10k_info(ar
, "invalid cryptmode: %d\n",
2232 ath10k_cryptmode_param
);
2236 ar
->htt
.max_num_amsdu
= ATH10K_HTT_MAX_NUM_AMSDU_DEFAULT
;
2237 ar
->htt
.max_num_ampdu
= ATH10K_HTT_MAX_NUM_AMPDU_DEFAULT
;
2240 if (!test_bit(ATH10K_FW_FEATURE_RAW_MODE_SUPPORT
,
2241 fw_file
->fw_features
)) {
2242 ath10k_err(ar
, "rawmode = 1 requires support from firmware");
2245 set_bit(ATH10K_FLAG_RAW_MODE
, &ar
->dev_flags
);
2248 if (test_bit(ATH10K_FLAG_RAW_MODE
, &ar
->dev_flags
)) {
2249 ar
->wmi
.rx_decap_mode
= ATH10K_HW_TXRX_RAW
;
2253 * Firmware A-MSDU aggregation breaks with RAW Tx encap mode
2254 * and causes enormous performance issues (malformed frames,
2257 * Disabling A-MSDU makes RAW mode stable with heavy traffic
2258 * albeit a bit slower compared to regular operation.
2260 ar
->htt
.max_num_amsdu
= 1;
2263 /* Backwards compatibility for firmwares without
2264 * ATH10K_FW_IE_WMI_OP_VERSION.
2266 if (fw_file
->wmi_op_version
== ATH10K_FW_WMI_OP_VERSION_UNSET
) {
2267 if (test_bit(ATH10K_FW_FEATURE_WMI_10X
, fw_file
->fw_features
)) {
2268 if (test_bit(ATH10K_FW_FEATURE_WMI_10_2
,
2269 fw_file
->fw_features
))
2270 fw_file
->wmi_op_version
= ATH10K_FW_WMI_OP_VERSION_10_2
;
2272 fw_file
->wmi_op_version
= ATH10K_FW_WMI_OP_VERSION_10_1
;
2274 fw_file
->wmi_op_version
= ATH10K_FW_WMI_OP_VERSION_MAIN
;
2278 switch (fw_file
->wmi_op_version
) {
2279 case ATH10K_FW_WMI_OP_VERSION_MAIN
:
2280 max_num_peers
= TARGET_NUM_PEERS
;
2281 ar
->max_num_stations
= TARGET_NUM_STATIONS
;
2282 ar
->max_num_vdevs
= TARGET_NUM_VDEVS
;
2283 ar
->htt
.max_num_pending_tx
= TARGET_NUM_MSDU_DESC
;
2284 ar
->fw_stats_req_mask
= WMI_STAT_PDEV
| WMI_STAT_VDEV
|
2286 ar
->max_spatial_stream
= WMI_MAX_SPATIAL_STREAM
;
2288 case ATH10K_FW_WMI_OP_VERSION_10_1
:
2289 case ATH10K_FW_WMI_OP_VERSION_10_2
:
2290 case ATH10K_FW_WMI_OP_VERSION_10_2_4
:
2291 if (ath10k_peer_stats_enabled(ar
)) {
2292 max_num_peers
= TARGET_10X_TX_STATS_NUM_PEERS
;
2293 ar
->max_num_stations
= TARGET_10X_TX_STATS_NUM_STATIONS
;
2295 max_num_peers
= TARGET_10X_NUM_PEERS
;
2296 ar
->max_num_stations
= TARGET_10X_NUM_STATIONS
;
2298 ar
->max_num_vdevs
= TARGET_10X_NUM_VDEVS
;
2299 ar
->htt
.max_num_pending_tx
= TARGET_10X_NUM_MSDU_DESC
;
2300 ar
->fw_stats_req_mask
= WMI_STAT_PEER
;
2301 ar
->max_spatial_stream
= WMI_MAX_SPATIAL_STREAM
;
2303 case ATH10K_FW_WMI_OP_VERSION_TLV
:
2304 max_num_peers
= TARGET_TLV_NUM_PEERS
;
2305 ar
->max_num_stations
= TARGET_TLV_NUM_STATIONS
;
2306 ar
->max_num_vdevs
= TARGET_TLV_NUM_VDEVS
;
2307 ar
->max_num_tdls_vdevs
= TARGET_TLV_NUM_TDLS_VDEVS
;
2308 ar
->htt
.max_num_pending_tx
= TARGET_TLV_NUM_MSDU_DESC
;
2309 ar
->wow
.max_num_patterns
= TARGET_TLV_NUM_WOW_PATTERNS
;
2310 ar
->fw_stats_req_mask
= WMI_STAT_PDEV
| WMI_STAT_VDEV
|
2312 ar
->max_spatial_stream
= WMI_MAX_SPATIAL_STREAM
;
2313 ar
->wmi
.mgmt_max_num_pending_tx
= TARGET_TLV_MGMT_NUM_MSDU_DESC
;
2315 case ATH10K_FW_WMI_OP_VERSION_10_4
:
2316 max_num_peers
= TARGET_10_4_NUM_PEERS
;
2317 ar
->max_num_stations
= TARGET_10_4_NUM_STATIONS
;
2318 ar
->num_active_peers
= TARGET_10_4_ACTIVE_PEERS
;
2319 ar
->max_num_vdevs
= TARGET_10_4_NUM_VDEVS
;
2320 ar
->num_tids
= TARGET_10_4_TGT_NUM_TIDS
;
2321 ar
->fw_stats_req_mask
= WMI_10_4_STAT_PEER
|
2322 WMI_10_4_STAT_PEER_EXTD
|
2323 WMI_10_4_STAT_VDEV_EXTD
;
2324 ar
->max_spatial_stream
= ar
->hw_params
.max_spatial_stream
;
2325 ar
->max_num_tdls_vdevs
= TARGET_10_4_NUM_TDLS_VDEVS
;
2327 if (test_bit(ATH10K_FW_FEATURE_PEER_FLOW_CONTROL
,
2328 fw_file
->fw_features
))
2329 ar
->htt
.max_num_pending_tx
= TARGET_10_4_NUM_MSDU_DESC_PFC
;
2331 ar
->htt
.max_num_pending_tx
= TARGET_10_4_NUM_MSDU_DESC
;
2333 case ATH10K_FW_WMI_OP_VERSION_UNSET
:
2334 case ATH10K_FW_WMI_OP_VERSION_MAX
:
2340 if (ar
->hw_params
.num_peers
)
2341 ar
->max_num_peers
= ar
->hw_params
.num_peers
;
2343 ar
->max_num_peers
= max_num_peers
;
2345 /* Backwards compatibility for firmwares without
2346 * ATH10K_FW_IE_HTT_OP_VERSION.
2348 if (fw_file
->htt_op_version
== ATH10K_FW_HTT_OP_VERSION_UNSET
) {
2349 switch (fw_file
->wmi_op_version
) {
2350 case ATH10K_FW_WMI_OP_VERSION_MAIN
:
2351 fw_file
->htt_op_version
= ATH10K_FW_HTT_OP_VERSION_MAIN
;
2353 case ATH10K_FW_WMI_OP_VERSION_10_1
:
2354 case ATH10K_FW_WMI_OP_VERSION_10_2
:
2355 case ATH10K_FW_WMI_OP_VERSION_10_2_4
:
2356 fw_file
->htt_op_version
= ATH10K_FW_HTT_OP_VERSION_10_1
;
2358 case ATH10K_FW_WMI_OP_VERSION_TLV
:
2359 fw_file
->htt_op_version
= ATH10K_FW_HTT_OP_VERSION_TLV
;
2361 case ATH10K_FW_WMI_OP_VERSION_10_4
:
2362 case ATH10K_FW_WMI_OP_VERSION_UNSET
:
2363 case ATH10K_FW_WMI_OP_VERSION_MAX
:
2364 ath10k_err(ar
, "htt op version not found from fw meta data");
2372 static int ath10k_core_reset_rx_filter(struct ath10k
*ar
)
2378 const u8
*vdev_addr
;
2381 vdev_type
= WMI_VDEV_TYPE_STA
;
2382 vdev_subtype
= ath10k_wmi_get_vdev_subtype(ar
, WMI_VDEV_SUBTYPE_NONE
);
2383 vdev_addr
= ar
->mac_addr
;
2385 ret
= ath10k_wmi_vdev_create(ar
, vdev_id
, vdev_type
, vdev_subtype
,
2388 ath10k_err(ar
, "failed to create dummy vdev: %d\n", ret
);
2392 ret
= ath10k_wmi_vdev_delete(ar
, vdev_id
);
2394 ath10k_err(ar
, "failed to delete dummy vdev: %d\n", ret
);
2398 /* WMI and HTT may use separate HIF pipes and are not guaranteed to be
2399 * serialized properly implicitly.
2401 * Moreover (most) WMI commands have no explicit acknowledges. It is
2402 * possible to infer it implicitly by poking firmware with echo
2403 * command - getting a reply means all preceding comments have been
2404 * (mostly) processed.
2406 * In case of vdev create/delete this is sufficient.
2408 * Without this it's possible to end up with a race when HTT Rx ring is
2409 * started before vdev create/delete hack is complete allowing a short
2410 * window of opportunity to receive (and Tx ACK) a bunch of frames.
2412 ret
= ath10k_wmi_barrier(ar
);
2414 ath10k_err(ar
, "failed to ping firmware: %d\n", ret
);
2421 int ath10k_core_start(struct ath10k
*ar
, enum ath10k_firmware_mode mode
,
2422 const struct ath10k_fw_components
*fw
)
2427 lockdep_assert_held(&ar
->conf_mutex
);
2429 clear_bit(ATH10K_FLAG_CRASH_FLUSH
, &ar
->dev_flags
);
2431 ar
->running_fw
= fw
;
2433 if (!test_bit(ATH10K_FW_FEATURE_NON_BMI
,
2434 ar
->running_fw
->fw_file
.fw_features
)) {
2435 ath10k_bmi_start(ar
);
2437 if (ath10k_init_configure_target(ar
)) {
2442 status
= ath10k_download_cal_data(ar
);
2446 /* Some of of qca988x solutions are having global reset issue
2447 * during target initialization. Bypassing PLL setting before
2448 * downloading firmware and letting the SoC run on REF_CLK is
2449 * fixing the problem. Corresponding firmware change is also
2450 * needed to set the clock source once the target is
2453 if (test_bit(ATH10K_FW_FEATURE_SUPPORTS_SKIP_CLOCK_INIT
,
2454 ar
->running_fw
->fw_file
.fw_features
)) {
2455 status
= ath10k_bmi_write32(ar
, hi_skip_clock_init
, 1);
2457 ath10k_err(ar
, "could not write to skip_clock_init: %d\n",
2463 status
= ath10k_download_fw(ar
);
2467 status
= ath10k_init_uart(ar
);
2471 if (ar
->hif
.bus
== ATH10K_BUS_SDIO
)
2472 ath10k_init_sdio(ar
);
2475 ar
->htc
.htc_ops
.target_send_suspend_complete
=
2476 ath10k_send_suspend_complete
;
2478 status
= ath10k_htc_init(ar
);
2480 ath10k_err(ar
, "could not init HTC (%d)\n", status
);
2484 if (!test_bit(ATH10K_FW_FEATURE_NON_BMI
,
2485 ar
->running_fw
->fw_file
.fw_features
)) {
2486 status
= ath10k_bmi_done(ar
);
2491 status
= ath10k_wmi_attach(ar
);
2493 ath10k_err(ar
, "WMI attach failed: %d\n", status
);
2497 status
= ath10k_htt_init(ar
);
2499 ath10k_err(ar
, "failed to init htt: %d\n", status
);
2500 goto err_wmi_detach
;
2503 status
= ath10k_htt_tx_start(&ar
->htt
);
2505 ath10k_err(ar
, "failed to alloc htt tx: %d\n", status
);
2506 goto err_wmi_detach
;
2509 /* If firmware indicates Full Rx Reorder support it must be used in a
2510 * slightly different manner. Let HTT code know.
2512 ar
->htt
.rx_ring
.in_ord_rx
= !!(test_bit(WMI_SERVICE_RX_FULL_REORDER
,
2515 status
= ath10k_htt_rx_alloc(&ar
->htt
);
2517 ath10k_err(ar
, "failed to alloc htt rx: %d\n", status
);
2518 goto err_htt_tx_detach
;
2521 status
= ath10k_hif_start(ar
);
2523 ath10k_err(ar
, "could not start HIF: %d\n", status
);
2524 goto err_htt_rx_detach
;
2527 status
= ath10k_htc_wait_target(&ar
->htc
);
2529 ath10k_err(ar
, "failed to connect to HTC: %d\n", status
);
2533 if (mode
== ATH10K_FIRMWARE_MODE_NORMAL
) {
2534 status
= ath10k_htt_connect(&ar
->htt
);
2536 ath10k_err(ar
, "failed to connect htt (%d)\n", status
);
2541 status
= ath10k_wmi_connect(ar
);
2543 ath10k_err(ar
, "could not connect wmi: %d\n", status
);
2547 status
= ath10k_htc_start(&ar
->htc
);
2549 ath10k_err(ar
, "failed to start htc: %d\n", status
);
2553 if (mode
== ATH10K_FIRMWARE_MODE_NORMAL
) {
2554 status
= ath10k_wmi_wait_for_service_ready(ar
);
2556 ath10k_warn(ar
, "wmi service ready event not received");
2561 ath10k_dbg(ar
, ATH10K_DBG_BOOT
, "firmware %s booted\n",
2562 ar
->hw
->wiphy
->fw_version
);
2564 if (test_bit(WMI_SERVICE_EXT_RES_CFG_SUPPORT
, ar
->wmi
.svc_map
) &&
2565 mode
== ATH10K_FIRMWARE_MODE_NORMAL
) {
2567 if (ath10k_peer_stats_enabled(ar
))
2568 val
= WMI_10_4_PEER_STATS
;
2570 /* Enable vdev stats by default */
2571 val
|= WMI_10_4_VDEV_STATS
;
2573 if (test_bit(WMI_SERVICE_BSS_CHANNEL_INFO_64
, ar
->wmi
.svc_map
))
2574 val
|= WMI_10_4_BSS_CHANNEL_INFO_64
;
2576 /* 10.4 firmware supports BT-Coex without reloading firmware
2577 * via pdev param. To support Bluetooth coexistence pdev param,
2578 * WMI_COEX_GPIO_SUPPORT of extended resource config should be
2581 if (test_bit(WMI_SERVICE_COEX_GPIO
, ar
->wmi
.svc_map
) &&
2582 test_bit(ATH10K_FW_FEATURE_BTCOEX_PARAM
,
2583 ar
->running_fw
->fw_file
.fw_features
))
2584 val
|= WMI_10_4_COEX_GPIO_SUPPORT
;
2586 if (test_bit(WMI_SERVICE_TDLS_EXPLICIT_MODE_ONLY
,
2588 val
|= WMI_10_4_TDLS_EXPLICIT_MODE_ONLY
;
2590 if (test_bit(WMI_SERVICE_TDLS_UAPSD_BUFFER_STA
,
2592 val
|= WMI_10_4_TDLS_UAPSD_BUFFER_STA
;
2594 if (test_bit(WMI_SERVICE_TX_DATA_ACK_RSSI
,
2596 val
|= WMI_10_4_TX_DATA_ACK_RSSI
;
2598 status
= ath10k_mac_ext_resource_config(ar
, val
);
2601 "failed to send ext resource cfg command : %d\n",
2607 status
= ath10k_wmi_cmd_init(ar
);
2609 ath10k_err(ar
, "could not send WMI init command (%d)\n",
2614 status
= ath10k_wmi_wait_for_unified_ready(ar
);
2616 ath10k_err(ar
, "wmi unified ready event not received\n");
2620 /* Some firmware revisions do not properly set up hardware rx filter
2623 * A known example from QCA9880 and 10.2.4 is that MAC_PCU_ADDR1_MASK
2624 * is filled with 0s instead of 1s allowing HW to respond with ACKs to
2625 * any frames that matches MAC_PCU_RX_FILTER which is also
2626 * misconfigured to accept anything.
2628 * The ADDR1 is programmed using internal firmware structure field and
2629 * can't be (easily/sanely) reached from the driver explicitly. It is
2630 * possible to implicitly make it correct by creating a dummy vdev and
2633 if (ar
->hw_params
.hw_filter_reset_required
&&
2634 mode
== ATH10K_FIRMWARE_MODE_NORMAL
) {
2635 status
= ath10k_core_reset_rx_filter(ar
);
2638 "failed to reset rx filter: %d\n", status
);
2643 status
= ath10k_htt_rx_ring_refill(ar
);
2645 ath10k_err(ar
, "failed to refill htt rx ring: %d\n", status
);
2649 if (ar
->max_num_vdevs
>= 64)
2650 ar
->free_vdev_map
= 0xFFFFFFFFFFFFFFFFLL
;
2652 ar
->free_vdev_map
= (1LL << ar
->max_num_vdevs
) - 1;
2654 INIT_LIST_HEAD(&ar
->arvifs
);
2656 /* we don't care about HTT in UTF mode */
2657 if (mode
== ATH10K_FIRMWARE_MODE_NORMAL
) {
2658 status
= ath10k_htt_setup(&ar
->htt
);
2660 ath10k_err(ar
, "failed to setup htt: %d\n", status
);
2665 status
= ath10k_debug_start(ar
);
2672 ath10k_hif_stop(ar
);
2674 ath10k_htt_rx_free(&ar
->htt
);
2676 ath10k_htt_tx_free(&ar
->htt
);
2678 ath10k_wmi_detach(ar
);
2682 EXPORT_SYMBOL(ath10k_core_start
);
2684 int ath10k_wait_for_suspend(struct ath10k
*ar
, u32 suspend_opt
)
2687 unsigned long time_left
;
2689 reinit_completion(&ar
->target_suspend
);
2691 ret
= ath10k_wmi_pdev_suspend_target(ar
, suspend_opt
);
2693 ath10k_warn(ar
, "could not suspend target (%d)\n", ret
);
2697 time_left
= wait_for_completion_timeout(&ar
->target_suspend
, 1 * HZ
);
2700 ath10k_warn(ar
, "suspend timed out - target pause event never came\n");
2707 void ath10k_core_stop(struct ath10k
*ar
)
2709 lockdep_assert_held(&ar
->conf_mutex
);
2710 ath10k_debug_stop(ar
);
2712 /* try to suspend target */
2713 if (ar
->state
!= ATH10K_STATE_RESTARTING
&&
2714 ar
->state
!= ATH10K_STATE_UTF
)
2715 ath10k_wait_for_suspend(ar
, WMI_PDEV_SUSPEND_AND_DISABLE_INTR
);
2717 ath10k_hif_stop(ar
);
2718 ath10k_htt_tx_stop(&ar
->htt
);
2719 ath10k_htt_rx_free(&ar
->htt
);
2720 ath10k_wmi_detach(ar
);
2722 EXPORT_SYMBOL(ath10k_core_stop
);
2724 /* mac80211 manages fw/hw initialization through start/stop hooks. However in
2725 * order to know what hw capabilities should be advertised to mac80211 it is
2726 * necessary to load the firmware (and tear it down immediately since start
2727 * hook will try to init it again) before registering
2729 static int ath10k_core_probe_fw(struct ath10k
*ar
)
2731 struct bmi_target_info target_info
;
2734 ret
= ath10k_hif_power_up(ar
);
2736 ath10k_err(ar
, "could not power on hif bus (%d)\n", ret
);
2740 switch (ar
->hif
.bus
) {
2741 case ATH10K_BUS_SDIO
:
2742 memset(&target_info
, 0, sizeof(target_info
));
2743 ret
= ath10k_bmi_get_target_info_sdio(ar
, &target_info
);
2745 ath10k_err(ar
, "could not get target info (%d)\n", ret
);
2746 goto err_power_down
;
2748 ar
->target_version
= target_info
.version
;
2749 ar
->hw
->wiphy
->hw_version
= target_info
.version
;
2751 case ATH10K_BUS_PCI
:
2752 case ATH10K_BUS_AHB
:
2753 case ATH10K_BUS_USB
:
2754 memset(&target_info
, 0, sizeof(target_info
));
2755 ret
= ath10k_bmi_get_target_info(ar
, &target_info
);
2757 ath10k_err(ar
, "could not get target info (%d)\n", ret
);
2758 goto err_power_down
;
2760 ar
->target_version
= target_info
.version
;
2761 ar
->hw
->wiphy
->hw_version
= target_info
.version
;
2763 case ATH10K_BUS_SNOC
:
2764 memset(&target_info
, 0, sizeof(target_info
));
2765 ret
= ath10k_hif_get_target_info(ar
, &target_info
);
2767 ath10k_err(ar
, "could not get target info (%d)\n", ret
);
2768 goto err_power_down
;
2770 ar
->target_version
= target_info
.version
;
2771 ar
->hw
->wiphy
->hw_version
= target_info
.version
;
2774 ath10k_err(ar
, "incorrect hif bus type: %d\n", ar
->hif
.bus
);
2777 ret
= ath10k_init_hw_params(ar
);
2779 ath10k_err(ar
, "could not get hw params (%d)\n", ret
);
2780 goto err_power_down
;
2783 ret
= ath10k_core_fetch_firmware_files(ar
);
2785 ath10k_err(ar
, "could not fetch firmware files (%d)\n", ret
);
2786 goto err_power_down
;
2789 BUILD_BUG_ON(sizeof(ar
->hw
->wiphy
->fw_version
) !=
2790 sizeof(ar
->normal_mode_fw
.fw_file
.fw_version
));
2791 memcpy(ar
->hw
->wiphy
->fw_version
, ar
->normal_mode_fw
.fw_file
.fw_version
,
2792 sizeof(ar
->hw
->wiphy
->fw_version
));
2794 ath10k_debug_print_hwfw_info(ar
);
2796 if (!test_bit(ATH10K_FW_FEATURE_NON_BMI
,
2797 ar
->normal_mode_fw
.fw_file
.fw_features
)) {
2798 ret
= ath10k_core_pre_cal_download(ar
);
2800 /* pre calibration data download is not necessary
2801 * for all the chipsets. Ignore failures and continue.
2803 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
2804 "could not load pre cal data: %d\n", ret
);
2807 ret
= ath10k_core_get_board_id_from_otp(ar
);
2808 if (ret
&& ret
!= -EOPNOTSUPP
) {
2809 ath10k_err(ar
, "failed to get board id from otp: %d\n",
2811 goto err_free_firmware_files
;
2814 ret
= ath10k_core_check_smbios(ar
);
2816 ath10k_dbg(ar
, ATH10K_DBG_BOOT
, "SMBIOS bdf variant name not set.\n");
2818 ret
= ath10k_core_check_dt(ar
);
2820 ath10k_dbg(ar
, ATH10K_DBG_BOOT
, "DT bdf variant name not set.\n");
2822 ret
= ath10k_core_fetch_board_file(ar
, ATH10K_BD_IE_BOARD
);
2824 ath10k_err(ar
, "failed to fetch board file: %d\n", ret
);
2825 goto err_free_firmware_files
;
2828 ath10k_debug_print_board_info(ar
);
2831 device_get_mac_address(ar
->dev
, ar
->mac_addr
, sizeof(ar
->mac_addr
));
2833 ret
= ath10k_core_init_firmware_features(ar
);
2835 ath10k_err(ar
, "fatal problem with firmware features: %d\n",
2837 goto err_free_firmware_files
;
2840 if (!test_bit(ATH10K_FW_FEATURE_NON_BMI
,
2841 ar
->normal_mode_fw
.fw_file
.fw_features
)) {
2842 ret
= ath10k_swap_code_seg_init(ar
,
2843 &ar
->normal_mode_fw
.fw_file
);
2845 ath10k_err(ar
, "failed to initialize code swap segment: %d\n",
2847 goto err_free_firmware_files
;
2851 mutex_lock(&ar
->conf_mutex
);
2853 ret
= ath10k_core_start(ar
, ATH10K_FIRMWARE_MODE_NORMAL
,
2854 &ar
->normal_mode_fw
);
2856 ath10k_err(ar
, "could not init core (%d)\n", ret
);
2860 ath10k_debug_print_boot_info(ar
);
2861 ath10k_core_stop(ar
);
2863 mutex_unlock(&ar
->conf_mutex
);
2865 ath10k_hif_power_down(ar
);
2869 mutex_unlock(&ar
->conf_mutex
);
2871 err_free_firmware_files
:
2872 ath10k_core_free_firmware_files(ar
);
2875 ath10k_hif_power_down(ar
);
2880 static void ath10k_core_register_work(struct work_struct
*work
)
2882 struct ath10k
*ar
= container_of(work
, struct ath10k
, register_work
);
2885 /* peer stats are enabled by default */
2886 set_bit(ATH10K_FLAG_PEER_STATS
, &ar
->dev_flags
);
2888 status
= ath10k_core_probe_fw(ar
);
2890 ath10k_err(ar
, "could not probe fw (%d)\n", status
);
2894 status
= ath10k_mac_register(ar
);
2896 ath10k_err(ar
, "could not register to mac80211 (%d)\n", status
);
2897 goto err_release_fw
;
2900 status
= ath10k_coredump_register(ar
);
2902 ath10k_err(ar
, "unable to register coredump\n");
2903 goto err_unregister_mac
;
2906 status
= ath10k_debug_register(ar
);
2908 ath10k_err(ar
, "unable to initialize debugfs\n");
2909 goto err_unregister_coredump
;
2912 status
= ath10k_spectral_create(ar
);
2914 ath10k_err(ar
, "failed to initialize spectral\n");
2915 goto err_debug_destroy
;
2918 status
= ath10k_thermal_register(ar
);
2920 ath10k_err(ar
, "could not register thermal device: %d\n",
2922 goto err_spectral_destroy
;
2925 set_bit(ATH10K_FLAG_CORE_REGISTERED
, &ar
->dev_flags
);
2928 err_spectral_destroy
:
2929 ath10k_spectral_destroy(ar
);
2931 ath10k_debug_destroy(ar
);
2932 err_unregister_coredump
:
2933 ath10k_coredump_unregister(ar
);
2935 ath10k_mac_unregister(ar
);
2937 ath10k_core_free_firmware_files(ar
);
2939 /* TODO: It's probably a good idea to release device from the driver
2940 * but calling device_release_driver() here will cause a deadlock.
2945 int ath10k_core_register(struct ath10k
*ar
,
2946 const struct ath10k_bus_params
*bus_params
)
2948 ar
->chip_id
= bus_params
->chip_id
;
2949 ar
->dev_type
= bus_params
->dev_type
;
2950 queue_work(ar
->workqueue
, &ar
->register_work
);
2954 EXPORT_SYMBOL(ath10k_core_register
);
2956 void ath10k_core_unregister(struct ath10k
*ar
)
2958 cancel_work_sync(&ar
->register_work
);
2960 if (!test_bit(ATH10K_FLAG_CORE_REGISTERED
, &ar
->dev_flags
))
2963 ath10k_thermal_unregister(ar
);
2964 /* Stop spectral before unregistering from mac80211 to remove the
2965 * relayfs debugfs file cleanly. Otherwise the parent debugfs tree
2966 * would be already be free'd recursively, leading to a double free.
2968 ath10k_spectral_destroy(ar
);
2970 /* We must unregister from mac80211 before we stop HTC and HIF.
2971 * Otherwise we will fail to submit commands to FW and mac80211 will be
2972 * unhappy about callback failures.
2974 ath10k_mac_unregister(ar
);
2976 ath10k_testmode_destroy(ar
);
2978 ath10k_core_free_firmware_files(ar
);
2979 ath10k_core_free_board_files(ar
);
2981 ath10k_debug_unregister(ar
);
2983 EXPORT_SYMBOL(ath10k_core_unregister
);
2985 struct ath10k
*ath10k_core_create(size_t priv_size
, struct device
*dev
,
2986 enum ath10k_bus bus
,
2987 enum ath10k_hw_rev hw_rev
,
2988 const struct ath10k_hif_ops
*hif_ops
)
2993 ar
= ath10k_mac_create(priv_size
);
2997 ar
->ath_common
.priv
= ar
;
2998 ar
->ath_common
.hw
= ar
->hw
;
3000 ar
->hw_rev
= hw_rev
;
3001 ar
->hif
.ops
= hif_ops
;
3005 case ATH10K_HW_QCA988X
:
3006 case ATH10K_HW_QCA9887
:
3007 ar
->regs
= &qca988x_regs
;
3008 ar
->hw_ce_regs
= &qcax_ce_regs
;
3009 ar
->hw_values
= &qca988x_values
;
3011 case ATH10K_HW_QCA6174
:
3012 case ATH10K_HW_QCA9377
:
3013 ar
->regs
= &qca6174_regs
;
3014 ar
->hw_ce_regs
= &qcax_ce_regs
;
3015 ar
->hw_values
= &qca6174_values
;
3017 case ATH10K_HW_QCA99X0
:
3018 case ATH10K_HW_QCA9984
:
3019 ar
->regs
= &qca99x0_regs
;
3020 ar
->hw_ce_regs
= &qcax_ce_regs
;
3021 ar
->hw_values
= &qca99x0_values
;
3023 case ATH10K_HW_QCA9888
:
3024 ar
->regs
= &qca99x0_regs
;
3025 ar
->hw_ce_regs
= &qcax_ce_regs
;
3026 ar
->hw_values
= &qca9888_values
;
3028 case ATH10K_HW_QCA4019
:
3029 ar
->regs
= &qca4019_regs
;
3030 ar
->hw_ce_regs
= &qcax_ce_regs
;
3031 ar
->hw_values
= &qca4019_values
;
3033 case ATH10K_HW_WCN3990
:
3034 ar
->regs
= &wcn3990_regs
;
3035 ar
->hw_ce_regs
= &wcn3990_ce_regs
;
3036 ar
->hw_values
= &wcn3990_values
;
3039 ath10k_err(ar
, "unsupported core hardware revision %d\n",
3045 init_completion(&ar
->scan
.started
);
3046 init_completion(&ar
->scan
.completed
);
3047 init_completion(&ar
->scan
.on_channel
);
3048 init_completion(&ar
->target_suspend
);
3049 init_completion(&ar
->wow
.wakeup_completed
);
3051 init_completion(&ar
->install_key_done
);
3052 init_completion(&ar
->vdev_setup_done
);
3053 init_completion(&ar
->thermal
.wmi_sync
);
3054 init_completion(&ar
->bss_survey_done
);
3056 INIT_DELAYED_WORK(&ar
->scan
.timeout
, ath10k_scan_timeout_work
);
3058 ar
->workqueue
= create_singlethread_workqueue("ath10k_wq");
3062 ar
->workqueue_aux
= create_singlethread_workqueue("ath10k_aux_wq");
3063 if (!ar
->workqueue_aux
)
3066 mutex_init(&ar
->conf_mutex
);
3067 spin_lock_init(&ar
->data_lock
);
3068 spin_lock_init(&ar
->txqs_lock
);
3070 INIT_LIST_HEAD(&ar
->txqs
);
3071 INIT_LIST_HEAD(&ar
->peers
);
3072 init_waitqueue_head(&ar
->peer_mapping_wq
);
3073 init_waitqueue_head(&ar
->htt
.empty_tx_wq
);
3074 init_waitqueue_head(&ar
->wmi
.tx_credits_wq
);
3076 init_completion(&ar
->offchan_tx_completed
);
3077 INIT_WORK(&ar
->offchan_tx_work
, ath10k_offchan_tx_work
);
3078 skb_queue_head_init(&ar
->offchan_tx_queue
);
3080 INIT_WORK(&ar
->wmi_mgmt_tx_work
, ath10k_mgmt_over_wmi_tx_work
);
3081 skb_queue_head_init(&ar
->wmi_mgmt_tx_queue
);
3083 INIT_WORK(&ar
->register_work
, ath10k_core_register_work
);
3084 INIT_WORK(&ar
->restart_work
, ath10k_core_restart
);
3085 INIT_WORK(&ar
->set_coverage_class_work
,
3086 ath10k_core_set_coverage_class_work
);
3088 init_dummy_netdev(&ar
->napi_dev
);
3090 ret
= ath10k_coredump_create(ar
);
3092 goto err_free_aux_wq
;
3094 ret
= ath10k_debug_create(ar
);
3096 goto err_free_coredump
;
3101 ath10k_coredump_destroy(ar
);
3104 destroy_workqueue(ar
->workqueue_aux
);
3106 destroy_workqueue(ar
->workqueue
);
3109 ath10k_mac_destroy(ar
);
3113 EXPORT_SYMBOL(ath10k_core_create
);
3115 void ath10k_core_destroy(struct ath10k
*ar
)
3117 flush_workqueue(ar
->workqueue
);
3118 destroy_workqueue(ar
->workqueue
);
3120 flush_workqueue(ar
->workqueue_aux
);
3121 destroy_workqueue(ar
->workqueue_aux
);
3123 ath10k_debug_destroy(ar
);
3124 ath10k_coredump_destroy(ar
);
3125 ath10k_htt_tx_destroy(&ar
->htt
);
3126 ath10k_wmi_free_host_mem(ar
);
3127 ath10k_mac_destroy(ar
);
3129 EXPORT_SYMBOL(ath10k_core_destroy
);
3131 MODULE_AUTHOR("Qualcomm Atheros");
3132 MODULE_DESCRIPTION("Core module for Qualcomm Atheros 802.11ac wireless LAN cards.");
3133 MODULE_LICENSE("Dual BSD/GPL");