1 // SPDX-License-Identifier: ISC
3 * Copyright (c) 2005-2011 Atheros Communications Inc.
4 * Copyright (c) 2011-2017 Qualcomm Atheros, Inc.
5 * Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
6 * Copyright (c) 2021-2024 Qualcomm Innovation Center, Inc. All rights reserved.
9 #include <linux/module.h>
10 #include <linux/firmware.h>
12 #include <linux/property.h>
13 #include <linux/dmi.h>
14 #include <linux/ctype.h>
15 #include <linux/pm_qos.h>
16 #include <linux/nvmem-consumer.h>
17 #include <asm/byteorder.h>
32 unsigned int ath10k_debug_mask
;
33 EXPORT_SYMBOL(ath10k_debug_mask
);
35 static unsigned int ath10k_cryptmode_param
;
36 static bool uart_print
;
38 static bool fw_diag_log
;
40 /* frame mode values are mapped as per enum ath10k_hw_txrx_mode */
41 unsigned int ath10k_frame_mode
= ATH10K_HW_TXRX_NATIVE_WIFI
;
43 unsigned long ath10k_coredump_mask
= BIT(ATH10K_FW_CRASH_DUMP_REGISTERS
) |
44 BIT(ATH10K_FW_CRASH_DUMP_CE_DATA
);
46 /* FIXME: most of these should be readonly */
47 module_param_named(debug_mask
, ath10k_debug_mask
, uint
, 0644);
48 module_param_named(cryptmode
, ath10k_cryptmode_param
, uint
, 0644);
49 module_param(uart_print
, bool, 0644);
50 module_param(skip_otp
, bool, 0644);
51 module_param(fw_diag_log
, bool, 0644);
52 module_param_named(frame_mode
, ath10k_frame_mode
, uint
, 0644);
53 module_param_named(coredump_mask
, ath10k_coredump_mask
, ulong
, 0444);
55 MODULE_PARM_DESC(debug_mask
, "Debugging mask");
56 MODULE_PARM_DESC(uart_print
, "Uart target debugging");
57 MODULE_PARM_DESC(skip_otp
, "Skip otp failure for calibration in testmode");
58 MODULE_PARM_DESC(cryptmode
, "Crypto mode: 0-hardware, 1-software");
59 MODULE_PARM_DESC(frame_mode
,
60 "Datapath frame mode (0: raw, 1: native wifi (default), 2: ethernet)");
61 MODULE_PARM_DESC(coredump_mask
, "Bitfield of what to include in firmware crash file");
62 MODULE_PARM_DESC(fw_diag_log
, "Diag based fw log debugging");
64 static const struct ath10k_hw_params ath10k_hw_params_list
[] = {
66 .id
= QCA988X_HW_2_0_VERSION
,
67 .dev_id
= QCA988X_2_0_DEVICE_ID
,
68 .bus
= ATH10K_BUS_PCI
,
69 .name
= "qca988x hw2.0",
70 .patch_load_addr
= QCA988X_HW_2_0_PATCH_LOAD_ADDR
,
73 .cc_wraparound_type
= ATH10K_HW_CC_WRAP_SHIFTED_ALL
,
75 .channel_counters_freq_hz
= 88000,
76 .max_probe_resp_desc_thres
= 0,
79 .dir
= QCA988X_HW_2_0_FW_DIR
,
80 .board_size
= QCA988X_BOARD_DATA_SZ
,
81 .board_ext_size
= QCA988X_BOARD_EXT_DATA_SZ
,
83 .rx_desc_ops
= &qca988x_rx_desc_ops
,
84 .hw_ops
= &qca988x_ops
,
85 .decap_align_bytes
= 4,
86 .spectral_bin_discard
= 0,
87 .spectral_bin_offset
= 0,
88 .vht160_mcs_rx_highest
= 0,
89 .vht160_mcs_tx_highest
= 0,
91 .ast_skid_limit
= 0x10,
92 .num_wds_entries
= 0x20,
93 .target_64bit
= false,
94 .rx_ring_fill_level
= HTT_RX_RING_FILL_LEVEL
,
95 .shadow_reg_support
= false,
97 .hw_filter_reset_required
= true,
98 .fw_diag_ce_download
= false,
99 .credit_size_workaround
= false,
100 .tx_stats_over_pktlog
= true,
101 .dynamic_sar_support
= false,
102 .hw_restart_disconnect
= false,
103 .use_fw_tx_credits
= true,
104 .delay_unmap_buffer
= false,
105 .mcast_frame_registration
= false,
108 .id
= QCA988X_HW_2_0_VERSION
,
109 .dev_id
= QCA988X_2_0_DEVICE_ID_UBNT
,
110 .name
= "qca988x hw2.0 ubiquiti",
111 .patch_load_addr
= QCA988X_HW_2_0_PATCH_LOAD_ADDR
,
114 .cc_wraparound_type
= ATH10K_HW_CC_WRAP_SHIFTED_ALL
,
116 .channel_counters_freq_hz
= 88000,
117 .max_probe_resp_desc_thres
= 0,
118 .cal_data_len
= 2116,
120 .dir
= QCA988X_HW_2_0_FW_DIR
,
121 .board_size
= QCA988X_BOARD_DATA_SZ
,
122 .board_ext_size
= QCA988X_BOARD_EXT_DATA_SZ
,
124 .rx_desc_ops
= &qca988x_rx_desc_ops
,
125 .hw_ops
= &qca988x_ops
,
126 .decap_align_bytes
= 4,
127 .spectral_bin_discard
= 0,
128 .spectral_bin_offset
= 0,
129 .vht160_mcs_rx_highest
= 0,
130 .vht160_mcs_tx_highest
= 0,
131 .n_cipher_suites
= 8,
132 .ast_skid_limit
= 0x10,
133 .num_wds_entries
= 0x20,
134 .target_64bit
= false,
135 .rx_ring_fill_level
= HTT_RX_RING_FILL_LEVEL
,
136 .shadow_reg_support
= false,
138 .hw_filter_reset_required
= true,
139 .fw_diag_ce_download
= false,
140 .credit_size_workaround
= false,
141 .tx_stats_over_pktlog
= true,
142 .dynamic_sar_support
= false,
143 .hw_restart_disconnect
= false,
144 .use_fw_tx_credits
= true,
145 .delay_unmap_buffer
= false,
146 .mcast_frame_registration
= false,
149 .id
= QCA9887_HW_1_0_VERSION
,
150 .dev_id
= QCA9887_1_0_DEVICE_ID
,
151 .bus
= ATH10K_BUS_PCI
,
152 .name
= "qca9887 hw1.0",
153 .patch_load_addr
= QCA9887_HW_1_0_PATCH_LOAD_ADDR
,
156 .cc_wraparound_type
= ATH10K_HW_CC_WRAP_SHIFTED_ALL
,
158 .channel_counters_freq_hz
= 88000,
159 .max_probe_resp_desc_thres
= 0,
160 .cal_data_len
= 2116,
162 .dir
= QCA9887_HW_1_0_FW_DIR
,
163 .board_size
= QCA9887_BOARD_DATA_SZ
,
164 .board_ext_size
= QCA9887_BOARD_EXT_DATA_SZ
,
166 .rx_desc_ops
= &qca988x_rx_desc_ops
,
167 .hw_ops
= &qca988x_ops
,
168 .decap_align_bytes
= 4,
169 .spectral_bin_discard
= 0,
170 .spectral_bin_offset
= 0,
171 .vht160_mcs_rx_highest
= 0,
172 .vht160_mcs_tx_highest
= 0,
173 .n_cipher_suites
= 8,
174 .ast_skid_limit
= 0x10,
175 .num_wds_entries
= 0x20,
176 .target_64bit
= false,
177 .rx_ring_fill_level
= HTT_RX_RING_FILL_LEVEL
,
178 .shadow_reg_support
= false,
180 .hw_filter_reset_required
= true,
181 .fw_diag_ce_download
= false,
182 .credit_size_workaround
= false,
183 .tx_stats_over_pktlog
= false,
184 .dynamic_sar_support
= false,
185 .hw_restart_disconnect
= false,
186 .use_fw_tx_credits
= true,
187 .delay_unmap_buffer
= false,
188 .mcast_frame_registration
= false,
191 .id
= QCA6174_HW_3_2_VERSION
,
192 .dev_id
= QCA6174_3_2_DEVICE_ID
,
193 .bus
= ATH10K_BUS_SDIO
,
194 .name
= "qca6174 hw3.2 sdio",
195 .patch_load_addr
= QCA6174_HW_3_0_PATCH_LOAD_ADDR
,
199 .channel_counters_freq_hz
= 88000,
200 .max_probe_resp_desc_thres
= 0,
203 .dir
= QCA6174_HW_3_0_FW_DIR
,
204 .board_size
= QCA6174_BOARD_DATA_SZ
,
205 .board_ext_size
= QCA6174_BOARD_EXT_DATA_SZ
,
207 .rx_desc_ops
= &qca988x_rx_desc_ops
,
208 .hw_ops
= &qca6174_sdio_ops
,
209 .hw_clk
= qca6174_clk
,
210 .target_cpu_freq
= 176000000,
211 .decap_align_bytes
= 4,
212 .n_cipher_suites
= 8,
214 .ast_skid_limit
= 0x10,
215 .num_wds_entries
= 0x20,
216 .uart_pin_workaround
= true,
217 .tx_stats_over_pktlog
= false,
218 .credit_size_workaround
= false,
219 .bmi_large_size_download
= true,
220 .supports_peer_stats_info
= true,
221 .dynamic_sar_support
= true,
222 .hw_restart_disconnect
= false,
223 .use_fw_tx_credits
= true,
224 .delay_unmap_buffer
= false,
225 .mcast_frame_registration
= false,
228 .id
= QCA6174_HW_2_1_VERSION
,
229 .dev_id
= QCA6164_2_1_DEVICE_ID
,
230 .bus
= ATH10K_BUS_PCI
,
231 .name
= "qca6164 hw2.1",
232 .patch_load_addr
= QCA6174_HW_2_1_PATCH_LOAD_ADDR
,
236 .channel_counters_freq_hz
= 88000,
237 .max_probe_resp_desc_thres
= 0,
238 .cal_data_len
= 8124,
240 .dir
= QCA6174_HW_2_1_FW_DIR
,
241 .board_size
= QCA6174_BOARD_DATA_SZ
,
242 .board_ext_size
= QCA6174_BOARD_EXT_DATA_SZ
,
244 .rx_desc_ops
= &qca988x_rx_desc_ops
,
245 .hw_ops
= &qca988x_ops
,
246 .decap_align_bytes
= 4,
247 .spectral_bin_discard
= 0,
248 .spectral_bin_offset
= 0,
249 .vht160_mcs_rx_highest
= 0,
250 .vht160_mcs_tx_highest
= 0,
251 .n_cipher_suites
= 8,
252 .ast_skid_limit
= 0x10,
253 .num_wds_entries
= 0x20,
254 .target_64bit
= false,
255 .rx_ring_fill_level
= HTT_RX_RING_FILL_LEVEL
,
256 .shadow_reg_support
= false,
258 .hw_filter_reset_required
= true,
259 .fw_diag_ce_download
= false,
260 .credit_size_workaround
= false,
261 .tx_stats_over_pktlog
= false,
262 .dynamic_sar_support
= false,
263 .hw_restart_disconnect
= false,
264 .use_fw_tx_credits
= true,
265 .delay_unmap_buffer
= false,
266 .mcast_frame_registration
= false,
269 .id
= QCA6174_HW_2_1_VERSION
,
270 .dev_id
= QCA6174_2_1_DEVICE_ID
,
271 .bus
= ATH10K_BUS_PCI
,
272 .name
= "qca6174 hw2.1",
273 .patch_load_addr
= QCA6174_HW_2_1_PATCH_LOAD_ADDR
,
277 .channel_counters_freq_hz
= 88000,
278 .max_probe_resp_desc_thres
= 0,
279 .cal_data_len
= 8124,
281 .dir
= QCA6174_HW_2_1_FW_DIR
,
282 .board_size
= QCA6174_BOARD_DATA_SZ
,
283 .board_ext_size
= QCA6174_BOARD_EXT_DATA_SZ
,
285 .rx_desc_ops
= &qca988x_rx_desc_ops
,
286 .hw_ops
= &qca988x_ops
,
287 .decap_align_bytes
= 4,
288 .spectral_bin_discard
= 0,
289 .spectral_bin_offset
= 0,
290 .vht160_mcs_rx_highest
= 0,
291 .vht160_mcs_tx_highest
= 0,
292 .n_cipher_suites
= 8,
293 .ast_skid_limit
= 0x10,
294 .num_wds_entries
= 0x20,
295 .target_64bit
= false,
296 .rx_ring_fill_level
= HTT_RX_RING_FILL_LEVEL
,
297 .shadow_reg_support
= false,
299 .hw_filter_reset_required
= true,
300 .fw_diag_ce_download
= false,
301 .credit_size_workaround
= false,
302 .tx_stats_over_pktlog
= false,
303 .dynamic_sar_support
= false,
304 .hw_restart_disconnect
= false,
305 .use_fw_tx_credits
= true,
306 .delay_unmap_buffer
= false,
307 .mcast_frame_registration
= false,
310 .id
= QCA6174_HW_3_0_VERSION
,
311 .dev_id
= QCA6174_2_1_DEVICE_ID
,
312 .bus
= ATH10K_BUS_PCI
,
313 .name
= "qca6174 hw3.0",
314 .patch_load_addr
= QCA6174_HW_3_0_PATCH_LOAD_ADDR
,
318 .channel_counters_freq_hz
= 88000,
319 .max_probe_resp_desc_thres
= 0,
320 .cal_data_len
= 8124,
322 .dir
= QCA6174_HW_3_0_FW_DIR
,
323 .board_size
= QCA6174_BOARD_DATA_SZ
,
324 .board_ext_size
= QCA6174_BOARD_EXT_DATA_SZ
,
326 .rx_desc_ops
= &qca988x_rx_desc_ops
,
327 .hw_ops
= &qca988x_ops
,
328 .decap_align_bytes
= 4,
329 .spectral_bin_discard
= 0,
330 .spectral_bin_offset
= 0,
331 .vht160_mcs_rx_highest
= 0,
332 .vht160_mcs_tx_highest
= 0,
333 .n_cipher_suites
= 8,
334 .ast_skid_limit
= 0x10,
335 .num_wds_entries
= 0x20,
336 .target_64bit
= false,
337 .rx_ring_fill_level
= HTT_RX_RING_FILL_LEVEL
,
338 .shadow_reg_support
= false,
340 .hw_filter_reset_required
= true,
341 .fw_diag_ce_download
= false,
342 .credit_size_workaround
= false,
343 .tx_stats_over_pktlog
= false,
344 .dynamic_sar_support
= false,
345 .hw_restart_disconnect
= false,
346 .use_fw_tx_credits
= true,
347 .delay_unmap_buffer
= false,
348 .mcast_frame_registration
= false,
351 .id
= QCA6174_HW_3_2_VERSION
,
352 .dev_id
= QCA6174_2_1_DEVICE_ID
,
353 .bus
= ATH10K_BUS_PCI
,
354 .name
= "qca6174 hw3.2",
355 .patch_load_addr
= QCA6174_HW_3_0_PATCH_LOAD_ADDR
,
359 .channel_counters_freq_hz
= 88000,
360 .max_probe_resp_desc_thres
= 0,
361 .cal_data_len
= 8124,
363 /* uses same binaries as hw3.0 */
364 .dir
= QCA6174_HW_3_0_FW_DIR
,
365 .board_size
= QCA6174_BOARD_DATA_SZ
,
366 .board_ext_size
= QCA6174_BOARD_EXT_DATA_SZ
,
368 .rx_desc_ops
= &qca988x_rx_desc_ops
,
369 .hw_ops
= &qca6174_ops
,
370 .hw_clk
= qca6174_clk
,
371 .target_cpu_freq
= 176000000,
372 .decap_align_bytes
= 4,
373 .spectral_bin_discard
= 0,
374 .spectral_bin_offset
= 0,
375 .vht160_mcs_rx_highest
= 0,
376 .vht160_mcs_tx_highest
= 0,
377 .n_cipher_suites
= 8,
378 .ast_skid_limit
= 0x10,
379 .num_wds_entries
= 0x20,
380 .target_64bit
= false,
381 .rx_ring_fill_level
= HTT_RX_RING_FILL_LEVEL
,
382 .shadow_reg_support
= false,
384 .hw_filter_reset_required
= true,
385 .fw_diag_ce_download
= true,
386 .credit_size_workaround
= false,
387 .tx_stats_over_pktlog
= false,
388 .supports_peer_stats_info
= true,
389 .dynamic_sar_support
= true,
390 .hw_restart_disconnect
= false,
391 .use_fw_tx_credits
= true,
392 .delay_unmap_buffer
= false,
393 .mcast_frame_registration
= true,
396 .id
= QCA99X0_HW_2_0_DEV_VERSION
,
397 .dev_id
= QCA99X0_2_0_DEVICE_ID
,
398 .bus
= ATH10K_BUS_PCI
,
399 .name
= "qca99x0 hw2.0",
400 .patch_load_addr
= QCA99X0_HW_2_0_PATCH_LOAD_ADDR
,
403 .otp_exe_param
= 0x00000700,
404 .continuous_frag_desc
= true,
405 .cck_rate_map_rev2
= true,
406 .channel_counters_freq_hz
= 150000,
407 .max_probe_resp_desc_thres
= 24,
408 .tx_chain_mask
= 0xf,
409 .rx_chain_mask
= 0xf,
410 .max_spatial_stream
= 4,
411 .cal_data_len
= 12064,
413 .dir
= QCA99X0_HW_2_0_FW_DIR
,
414 .board_size
= QCA99X0_BOARD_DATA_SZ
,
415 .board_ext_size
= QCA99X0_BOARD_EXT_DATA_SZ
,
417 .sw_decrypt_mcast_mgmt
= true,
418 .rx_desc_ops
= &qca99x0_rx_desc_ops
,
419 .hw_ops
= &qca99x0_ops
,
420 .decap_align_bytes
= 1,
421 .spectral_bin_discard
= 4,
422 .spectral_bin_offset
= 0,
423 .vht160_mcs_rx_highest
= 0,
424 .vht160_mcs_tx_highest
= 0,
425 .n_cipher_suites
= 11,
426 .ast_skid_limit
= 0x10,
427 .num_wds_entries
= 0x20,
428 .target_64bit
= false,
429 .rx_ring_fill_level
= HTT_RX_RING_FILL_LEVEL
,
430 .shadow_reg_support
= false,
432 .hw_filter_reset_required
= true,
433 .fw_diag_ce_download
= false,
434 .credit_size_workaround
= false,
435 .tx_stats_over_pktlog
= false,
436 .dynamic_sar_support
= false,
437 .hw_restart_disconnect
= false,
438 .use_fw_tx_credits
= true,
439 .delay_unmap_buffer
= false,
440 .mcast_frame_registration
= false,
443 .id
= QCA9984_HW_1_0_DEV_VERSION
,
444 .dev_id
= QCA9984_1_0_DEVICE_ID
,
445 .bus
= ATH10K_BUS_PCI
,
446 .name
= "qca9984/qca9994 hw1.0",
447 .patch_load_addr
= QCA9984_HW_1_0_PATCH_LOAD_ADDR
,
450 .cc_wraparound_type
= ATH10K_HW_CC_WRAP_SHIFTED_EACH
,
451 .otp_exe_param
= 0x00000700,
452 .continuous_frag_desc
= true,
453 .cck_rate_map_rev2
= true,
454 .channel_counters_freq_hz
= 150000,
455 .max_probe_resp_desc_thres
= 24,
456 .tx_chain_mask
= 0xf,
457 .rx_chain_mask
= 0xf,
458 .max_spatial_stream
= 4,
459 .cal_data_len
= 12064,
461 .dir
= QCA9984_HW_1_0_FW_DIR
,
462 .board_size
= QCA99X0_BOARD_DATA_SZ
,
463 .board_ext_size
= QCA99X0_BOARD_EXT_DATA_SZ
,
464 .ext_board_size
= QCA99X0_EXT_BOARD_DATA_SZ
,
466 .sw_decrypt_mcast_mgmt
= true,
467 .rx_desc_ops
= &qca99x0_rx_desc_ops
,
468 .hw_ops
= &qca99x0_ops
,
469 .decap_align_bytes
= 1,
470 .spectral_bin_discard
= 12,
471 .spectral_bin_offset
= 8,
473 /* Can do only 2x2 VHT160 or 80+80. 1560Mbps is 4x4 80Mhz
474 * or 2x2 160Mhz, long-guard-interval.
476 .vht160_mcs_rx_highest
= 1560,
477 .vht160_mcs_tx_highest
= 1560,
478 .n_cipher_suites
= 11,
479 .ast_skid_limit
= 0x10,
480 .num_wds_entries
= 0x20,
481 .target_64bit
= false,
482 .rx_ring_fill_level
= HTT_RX_RING_FILL_LEVEL
,
483 .shadow_reg_support
= false,
485 .hw_filter_reset_required
= true,
486 .fw_diag_ce_download
= false,
487 .credit_size_workaround
= false,
488 .tx_stats_over_pktlog
= false,
489 .dynamic_sar_support
= false,
490 .hw_restart_disconnect
= false,
491 .use_fw_tx_credits
= true,
492 .delay_unmap_buffer
= false,
493 .mcast_frame_registration
= false,
496 .id
= QCA9888_HW_2_0_DEV_VERSION
,
497 .dev_id
= QCA9888_2_0_DEVICE_ID
,
498 .bus
= ATH10K_BUS_PCI
,
499 .name
= "qca9888 hw2.0",
500 .patch_load_addr
= QCA9888_HW_2_0_PATCH_LOAD_ADDR
,
503 .cc_wraparound_type
= ATH10K_HW_CC_WRAP_SHIFTED_EACH
,
504 .otp_exe_param
= 0x00000700,
505 .continuous_frag_desc
= true,
506 .channel_counters_freq_hz
= 150000,
507 .max_probe_resp_desc_thres
= 24,
510 .max_spatial_stream
= 2,
511 .cal_data_len
= 12064,
513 .dir
= QCA9888_HW_2_0_FW_DIR
,
514 .board_size
= QCA99X0_BOARD_DATA_SZ
,
515 .board_ext_size
= QCA99X0_BOARD_EXT_DATA_SZ
,
517 .sw_decrypt_mcast_mgmt
= true,
518 .rx_desc_ops
= &qca99x0_rx_desc_ops
,
519 .hw_ops
= &qca99x0_ops
,
520 .decap_align_bytes
= 1,
521 .spectral_bin_discard
= 12,
522 .spectral_bin_offset
= 8,
524 /* Can do only 1x1 VHT160 or 80+80. 780Mbps is 2x2 80Mhz or
525 * 1x1 160Mhz, long-guard-interval.
527 .vht160_mcs_rx_highest
= 780,
528 .vht160_mcs_tx_highest
= 780,
529 .n_cipher_suites
= 11,
530 .ast_skid_limit
= 0x10,
531 .num_wds_entries
= 0x20,
532 .target_64bit
= false,
533 .rx_ring_fill_level
= HTT_RX_RING_FILL_LEVEL
,
534 .shadow_reg_support
= false,
536 .hw_filter_reset_required
= true,
537 .fw_diag_ce_download
= false,
538 .credit_size_workaround
= false,
539 .tx_stats_over_pktlog
= false,
540 .dynamic_sar_support
= false,
541 .hw_restart_disconnect
= false,
542 .use_fw_tx_credits
= true,
543 .delay_unmap_buffer
= false,
544 .mcast_frame_registration
= false,
547 .id
= QCA9377_HW_1_0_DEV_VERSION
,
548 .dev_id
= QCA9377_1_0_DEVICE_ID
,
549 .bus
= ATH10K_BUS_PCI
,
550 .name
= "qca9377 hw1.0",
551 .patch_load_addr
= QCA9377_HW_1_0_PATCH_LOAD_ADDR
,
555 .channel_counters_freq_hz
= 88000,
556 .max_probe_resp_desc_thres
= 0,
557 .cal_data_len
= 8124,
559 .dir
= QCA9377_HW_1_0_FW_DIR
,
560 .board_size
= QCA9377_BOARD_DATA_SZ
,
561 .board_ext_size
= QCA9377_BOARD_EXT_DATA_SZ
,
563 .rx_desc_ops
= &qca988x_rx_desc_ops
,
564 .hw_ops
= &qca988x_ops
,
565 .decap_align_bytes
= 4,
566 .spectral_bin_discard
= 0,
567 .spectral_bin_offset
= 0,
568 .vht160_mcs_rx_highest
= 0,
569 .vht160_mcs_tx_highest
= 0,
570 .n_cipher_suites
= 8,
571 .ast_skid_limit
= 0x10,
572 .num_wds_entries
= 0x20,
573 .target_64bit
= false,
574 .rx_ring_fill_level
= HTT_RX_RING_FILL_LEVEL
,
575 .shadow_reg_support
= false,
577 .hw_filter_reset_required
= true,
578 .fw_diag_ce_download
= false,
579 .credit_size_workaround
= false,
580 .tx_stats_over_pktlog
= false,
581 .dynamic_sar_support
= false,
582 .hw_restart_disconnect
= false,
583 .use_fw_tx_credits
= true,
584 .delay_unmap_buffer
= false,
585 .mcast_frame_registration
= false,
588 .id
= QCA9377_HW_1_1_DEV_VERSION
,
589 .dev_id
= QCA9377_1_0_DEVICE_ID
,
590 .bus
= ATH10K_BUS_PCI
,
591 .name
= "qca9377 hw1.1",
592 .patch_load_addr
= QCA9377_HW_1_0_PATCH_LOAD_ADDR
,
596 .channel_counters_freq_hz
= 88000,
597 .max_probe_resp_desc_thres
= 0,
598 .cal_data_len
= 8124,
600 .dir
= QCA9377_HW_1_0_FW_DIR
,
601 .board_size
= QCA9377_BOARD_DATA_SZ
,
602 .board_ext_size
= QCA9377_BOARD_EXT_DATA_SZ
,
604 .rx_desc_ops
= &qca988x_rx_desc_ops
,
605 .hw_ops
= &qca6174_ops
,
606 .hw_clk
= qca6174_clk
,
607 .target_cpu_freq
= 176000000,
608 .decap_align_bytes
= 4,
609 .spectral_bin_discard
= 0,
610 .spectral_bin_offset
= 0,
611 .vht160_mcs_rx_highest
= 0,
612 .vht160_mcs_tx_highest
= 0,
613 .n_cipher_suites
= 8,
614 .ast_skid_limit
= 0x10,
615 .num_wds_entries
= 0x20,
616 .target_64bit
= false,
617 .rx_ring_fill_level
= HTT_RX_RING_FILL_LEVEL
,
618 .shadow_reg_support
= false,
620 .hw_filter_reset_required
= true,
621 .fw_diag_ce_download
= true,
622 .credit_size_workaround
= false,
623 .tx_stats_over_pktlog
= false,
624 .dynamic_sar_support
= false,
625 .hw_restart_disconnect
= false,
626 .use_fw_tx_credits
= true,
627 .delay_unmap_buffer
= false,
628 .mcast_frame_registration
= false,
631 .id
= QCA9377_HW_1_1_DEV_VERSION
,
632 .dev_id
= QCA9377_1_0_DEVICE_ID
,
633 .bus
= ATH10K_BUS_SDIO
,
634 .name
= "qca9377 hw1.1 sdio",
635 .patch_load_addr
= QCA9377_HW_1_0_PATCH_LOAD_ADDR
,
639 .channel_counters_freq_hz
= 88000,
640 .max_probe_resp_desc_thres
= 0,
641 .cal_data_len
= 8124,
643 .dir
= QCA9377_HW_1_0_FW_DIR
,
644 .board_size
= QCA9377_BOARD_DATA_SZ
,
645 .board_ext_size
= QCA9377_BOARD_EXT_DATA_SZ
,
647 .rx_desc_ops
= &qca988x_rx_desc_ops
,
648 .hw_ops
= &qca6174_ops
,
649 .hw_clk
= qca6174_clk
,
650 .target_cpu_freq
= 176000000,
651 .decap_align_bytes
= 4,
652 .n_cipher_suites
= 8,
653 .num_peers
= TARGET_QCA9377_HL_NUM_PEERS
,
654 .ast_skid_limit
= 0x10,
655 .num_wds_entries
= 0x20,
656 .uart_pin_workaround
= true,
657 .credit_size_workaround
= true,
658 .dynamic_sar_support
= false,
659 .hw_restart_disconnect
= false,
660 .use_fw_tx_credits
= true,
661 .delay_unmap_buffer
= false,
662 .mcast_frame_registration
= false,
665 .id
= QCA4019_HW_1_0_DEV_VERSION
,
667 .bus
= ATH10K_BUS_AHB
,
668 .name
= "qca4019 hw1.0",
669 .patch_load_addr
= QCA4019_HW_1_0_PATCH_LOAD_ADDR
,
672 .cc_wraparound_type
= ATH10K_HW_CC_WRAP_SHIFTED_EACH
,
673 .otp_exe_param
= 0x0010000,
674 .continuous_frag_desc
= true,
675 .cck_rate_map_rev2
= true,
676 .channel_counters_freq_hz
= 125000,
677 .max_probe_resp_desc_thres
= 24,
678 .tx_chain_mask
= 0x3,
679 .rx_chain_mask
= 0x3,
680 .max_spatial_stream
= 2,
681 .cal_data_len
= 12064,
683 .dir
= QCA4019_HW_1_0_FW_DIR
,
684 .board_size
= QCA4019_BOARD_DATA_SZ
,
685 .board_ext_size
= QCA4019_BOARD_EXT_DATA_SZ
,
687 .sw_decrypt_mcast_mgmt
= true,
688 .rx_desc_ops
= &qca99x0_rx_desc_ops
,
689 .hw_ops
= &qca99x0_ops
,
690 .decap_align_bytes
= 1,
691 .spectral_bin_discard
= 4,
692 .spectral_bin_offset
= 0,
693 .vht160_mcs_rx_highest
= 0,
694 .vht160_mcs_tx_highest
= 0,
695 .n_cipher_suites
= 11,
696 .ast_skid_limit
= 0x10,
697 .num_wds_entries
= 0x20,
698 .target_64bit
= false,
699 .rx_ring_fill_level
= HTT_RX_RING_FILL_LEVEL
,
700 .shadow_reg_support
= false,
702 .hw_filter_reset_required
= true,
703 .fw_diag_ce_download
= false,
704 .credit_size_workaround
= false,
705 .tx_stats_over_pktlog
= false,
706 .dynamic_sar_support
= false,
707 .hw_restart_disconnect
= false,
708 .use_fw_tx_credits
= true,
709 .delay_unmap_buffer
= false,
710 .mcast_frame_registration
= false,
713 .id
= WCN3990_HW_1_0_DEV_VERSION
,
715 .bus
= ATH10K_BUS_SNOC
,
716 .name
= "wcn3990 hw1.0",
718 .continuous_frag_desc
= true,
719 .tx_chain_mask
= 0x7,
720 .rx_chain_mask
= 0x7,
721 .max_spatial_stream
= 4,
723 .dir
= WCN3990_HW_1_0_FW_DIR
,
724 .board_size
= WCN3990_BOARD_DATA_SZ
,
725 .board_ext_size
= WCN3990_BOARD_EXT_DATA_SZ
,
727 .sw_decrypt_mcast_mgmt
= true,
728 .rx_desc_ops
= &wcn3990_rx_desc_ops
,
729 .hw_ops
= &wcn3990_ops
,
730 .decap_align_bytes
= 1,
731 .num_peers
= TARGET_HL_TLV_NUM_PEERS
,
732 .n_cipher_suites
= 11,
733 .ast_skid_limit
= TARGET_HL_TLV_AST_SKID_LIMIT
,
734 .num_wds_entries
= TARGET_HL_TLV_NUM_WDS_ENTRIES
,
735 .target_64bit
= true,
736 .rx_ring_fill_level
= HTT_RX_RING_FILL_LEVEL_DUAL_MAC
,
737 .shadow_reg_support
= true,
739 .hw_filter_reset_required
= false,
740 .fw_diag_ce_download
= false,
741 .credit_size_workaround
= false,
742 .tx_stats_over_pktlog
= false,
743 .dynamic_sar_support
= true,
744 .hw_restart_disconnect
= true,
745 .use_fw_tx_credits
= false,
746 .delay_unmap_buffer
= true,
747 .mcast_frame_registration
= false,
751 static const char *const ath10k_core_fw_feature_str
[] = {
752 [ATH10K_FW_FEATURE_EXT_WMI_MGMT_RX
] = "wmi-mgmt-rx",
753 [ATH10K_FW_FEATURE_WMI_10X
] = "wmi-10.x",
754 [ATH10K_FW_FEATURE_HAS_WMI_MGMT_TX
] = "has-wmi-mgmt-tx",
755 [ATH10K_FW_FEATURE_NO_P2P
] = "no-p2p",
756 [ATH10K_FW_FEATURE_WMI_10_2
] = "wmi-10.2",
757 [ATH10K_FW_FEATURE_MULTI_VIF_PS_SUPPORT
] = "multi-vif-ps",
758 [ATH10K_FW_FEATURE_WOWLAN_SUPPORT
] = "wowlan",
759 [ATH10K_FW_FEATURE_IGNORE_OTP_RESULT
] = "ignore-otp",
760 [ATH10K_FW_FEATURE_NO_NWIFI_DECAP_4ADDR_PADDING
] = "no-4addr-pad",
761 [ATH10K_FW_FEATURE_SUPPORTS_SKIP_CLOCK_INIT
] = "skip-clock-init",
762 [ATH10K_FW_FEATURE_RAW_MODE_SUPPORT
] = "raw-mode",
763 [ATH10K_FW_FEATURE_SUPPORTS_ADAPTIVE_CCA
] = "adaptive-cca",
764 [ATH10K_FW_FEATURE_MFP_SUPPORT
] = "mfp",
765 [ATH10K_FW_FEATURE_PEER_FLOW_CONTROL
] = "peer-flow-ctrl",
766 [ATH10K_FW_FEATURE_BTCOEX_PARAM
] = "btcoex-param",
767 [ATH10K_FW_FEATURE_SKIP_NULL_FUNC_WAR
] = "skip-null-func-war",
768 [ATH10K_FW_FEATURE_ALLOWS_MESH_BCAST
] = "allows-mesh-bcast",
769 [ATH10K_FW_FEATURE_NO_PS
] = "no-ps",
770 [ATH10K_FW_FEATURE_MGMT_TX_BY_REF
] = "mgmt-tx-by-reference",
771 [ATH10K_FW_FEATURE_NON_BMI
] = "non-bmi",
772 [ATH10K_FW_FEATURE_SINGLE_CHAN_INFO_PER_CHANNEL
] = "single-chan-info-per-channel",
773 [ATH10K_FW_FEATURE_PEER_FIXED_RATE
] = "peer-fixed-rate",
774 [ATH10K_FW_FEATURE_IRAM_RECOVERY
] = "iram-recovery",
777 static unsigned int ath10k_core_get_fw_feature_str(char *buf
,
779 enum ath10k_fw_features feat
)
781 /* make sure that ath10k_core_fw_feature_str[] gets updated */
782 BUILD_BUG_ON(ARRAY_SIZE(ath10k_core_fw_feature_str
) !=
783 ATH10K_FW_FEATURE_COUNT
);
785 if (feat
>= ARRAY_SIZE(ath10k_core_fw_feature_str
) ||
786 WARN_ON(!ath10k_core_fw_feature_str
[feat
])) {
787 return scnprintf(buf
, buf_len
, "bit%d", feat
);
790 return scnprintf(buf
, buf_len
, "%s", ath10k_core_fw_feature_str
[feat
]);
793 void ath10k_core_get_fw_features_str(struct ath10k
*ar
,
800 for (i
= 0; i
< ATH10K_FW_FEATURE_COUNT
; i
++) {
801 if (test_bit(i
, ar
->normal_mode_fw
.fw_file
.fw_features
)) {
803 len
+= scnprintf(buf
+ len
, buf_len
- len
, ",");
805 len
+= ath10k_core_get_fw_feature_str(buf
+ len
,
812 static void ath10k_send_suspend_complete(struct ath10k
*ar
)
814 ath10k_dbg(ar
, ATH10K_DBG_BOOT
, "boot suspend complete\n");
816 complete(&ar
->target_suspend
);
819 static int ath10k_init_sdio(struct ath10k
*ar
, enum ath10k_firmware_mode mode
)
821 bool mtu_workaround
= ar
->hw_params
.credit_size_workaround
;
825 ret
= ath10k_bmi_write32(ar
, hi_mbox_io_block_sz
, 256);
829 ret
= ath10k_bmi_write32(ar
, hi_mbox_isr_yield_limit
, 99);
833 ret
= ath10k_bmi_read32(ar
, hi_acs_flags
, ¶m
);
837 param
|= HI_ACS_FLAGS_SDIO_REDUCE_TX_COMPL_SET
;
839 if (mode
== ATH10K_FIRMWARE_MODE_NORMAL
&& !mtu_workaround
)
840 param
|= HI_ACS_FLAGS_ALT_DATA_CREDIT_SIZE
;
842 param
&= ~HI_ACS_FLAGS_ALT_DATA_CREDIT_SIZE
;
844 if (mode
== ATH10K_FIRMWARE_MODE_UTF
)
845 param
&= ~HI_ACS_FLAGS_SDIO_SWAP_MAILBOX_SET
;
847 param
|= HI_ACS_FLAGS_SDIO_SWAP_MAILBOX_SET
;
849 ret
= ath10k_bmi_write32(ar
, hi_acs_flags
, param
);
853 ret
= ath10k_bmi_read32(ar
, hi_option_flag2
, ¶m
);
857 param
|= HI_OPTION_SDIO_CRASH_DUMP_ENHANCEMENT_HOST
;
859 ret
= ath10k_bmi_write32(ar
, hi_option_flag2
, param
);
866 static int ath10k_init_configure_target(struct ath10k
*ar
)
871 /* tell target which HTC version it is used*/
872 ret
= ath10k_bmi_write32(ar
, hi_app_host_interest
,
873 HTC_PROTOCOL_VERSION
);
875 ath10k_err(ar
, "settings HTC version failed\n");
879 /* set the firmware mode to STA/IBSS/AP */
880 ret
= ath10k_bmi_read32(ar
, hi_option_flag
, ¶m_host
);
882 ath10k_err(ar
, "setting firmware mode (1/2) failed\n");
886 /* TODO following parameters need to be re-visited. */
888 param_host
|= (1 << HI_OPTION_NUM_DEV_SHIFT
);
890 /* FIXME: Why FW_MODE_AP ??.*/
891 param_host
|= (HI_OPTION_FW_MODE_AP
<< HI_OPTION_FW_MODE_SHIFT
);
892 /* mac_addr_method */
893 param_host
|= (1 << HI_OPTION_MAC_ADDR_METHOD_SHIFT
);
894 /* firmware_bridge */
895 param_host
|= (0 << HI_OPTION_FW_BRIDGE_SHIFT
);
897 param_host
|= (0 << HI_OPTION_FW_SUBMODE_SHIFT
);
899 ret
= ath10k_bmi_write32(ar
, hi_option_flag
, param_host
);
901 ath10k_err(ar
, "setting firmware mode (2/2) failed\n");
905 /* We do all byte-swapping on the host */
906 ret
= ath10k_bmi_write32(ar
, hi_be
, 0);
908 ath10k_err(ar
, "setting host CPU BE mode failed\n");
912 /* FW descriptor/Data swap flags */
913 ret
= ath10k_bmi_write32(ar
, hi_fw_swap
, 0);
916 ath10k_err(ar
, "setting FW data/desc swap flags failed\n");
920 /* Some devices have a special sanity check that verifies the PCI
921 * Device ID is written to this host interest var. It is known to be
922 * required to boot QCA6164.
924 ret
= ath10k_bmi_write32(ar
, hi_hci_uart_pwr_mgmt_params_ext
,
927 ath10k_err(ar
, "failed to set pwr_mgmt_params: %d\n", ret
);
934 static const struct firmware
*ath10k_fetch_fw_file(struct ath10k
*ar
,
939 const struct firmware
*fw
;
943 return ERR_PTR(-ENOENT
);
948 if (ar
->board_name
) {
949 snprintf(filename
, sizeof(filename
), "%s/%s/%s",
950 dir
, ar
->board_name
, file
);
951 ret
= firmware_request_nowarn(&fw
, filename
, ar
->dev
);
952 ath10k_dbg(ar
, ATH10K_DBG_BOOT
, "boot fw request '%s': %d\n",
958 snprintf(filename
, sizeof(filename
), "%s/%s", dir
, file
);
959 ret
= firmware_request_nowarn(&fw
, filename
, ar
->dev
);
960 ath10k_dbg(ar
, ATH10K_DBG_BOOT
, "boot fw request '%s': %d\n",
968 static int ath10k_push_board_ext_data(struct ath10k
*ar
, const void *data
,
971 u32 board_data_size
= ar
->hw_params
.fw
.board_size
;
972 u32 board_ext_data_size
= ar
->hw_params
.fw
.board_ext_size
;
973 u32 board_ext_data_addr
;
976 ret
= ath10k_bmi_read32(ar
, hi_board_ext_data
, &board_ext_data_addr
);
978 ath10k_err(ar
, "could not read board ext data addr (%d)\n",
983 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
984 "boot push board extended data addr 0x%x\n",
985 board_ext_data_addr
);
987 if (board_ext_data_addr
== 0)
990 if (data_len
!= (board_data_size
+ board_ext_data_size
)) {
991 ath10k_err(ar
, "invalid board (ext) data sizes %zu != %d+%d\n",
992 data_len
, board_data_size
, board_ext_data_size
);
996 ret
= ath10k_bmi_write_memory(ar
, board_ext_data_addr
,
997 data
+ board_data_size
,
998 board_ext_data_size
);
1000 ath10k_err(ar
, "could not write board ext data (%d)\n", ret
);
1004 ret
= ath10k_bmi_write32(ar
, hi_board_ext_data_config
,
1005 (board_ext_data_size
<< 16) | 1);
1007 ath10k_err(ar
, "could not write board ext data bit (%d)\n",
1015 static int ath10k_core_get_board_id_from_otp(struct ath10k
*ar
)
1017 u32 result
, address
;
1018 u8 board_id
, chip_id
;
1019 bool ext_bid_support
;
1020 int ret
, bmi_board_id_param
;
1022 address
= ar
->hw_params
.patch_load_addr
;
1024 if (!ar
->normal_mode_fw
.fw_file
.otp_data
||
1025 !ar
->normal_mode_fw
.fw_file
.otp_len
) {
1027 "failed to retrieve board id because of invalid otp\n");
1031 if (ar
->id
.bmi_ids_valid
) {
1032 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
1033 "boot already acquired valid otp board id,skip download, board_id %d chip_id %d\n",
1034 ar
->id
.bmi_board_id
, ar
->id
.bmi_chip_id
);
1035 goto skip_otp_download
;
1038 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
1039 "boot upload otp to 0x%x len %zd for board id\n",
1040 address
, ar
->normal_mode_fw
.fw_file
.otp_len
);
1042 ret
= ath10k_bmi_fast_download(ar
, address
,
1043 ar
->normal_mode_fw
.fw_file
.otp_data
,
1044 ar
->normal_mode_fw
.fw_file
.otp_len
);
1046 ath10k_err(ar
, "could not write otp for board id check: %d\n",
1051 if (ar
->cal_mode
== ATH10K_PRE_CAL_MODE_DT
||
1052 ar
->cal_mode
== ATH10K_PRE_CAL_MODE_FILE
||
1053 ar
->cal_mode
== ATH10K_PRE_CAL_MODE_NVMEM
)
1054 bmi_board_id_param
= BMI_PARAM_GET_FLASH_BOARD_ID
;
1056 bmi_board_id_param
= BMI_PARAM_GET_EEPROM_BOARD_ID
;
1058 ret
= ath10k_bmi_execute(ar
, address
, bmi_board_id_param
, &result
);
1060 ath10k_err(ar
, "could not execute otp for board id check: %d\n",
1065 board_id
= MS(result
, ATH10K_BMI_BOARD_ID_FROM_OTP
);
1066 chip_id
= MS(result
, ATH10K_BMI_CHIP_ID_FROM_OTP
);
1067 ext_bid_support
= (result
& ATH10K_BMI_EXT_BOARD_ID_SUPPORT
);
1069 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
1070 "boot get otp board id result 0x%08x board_id %d chip_id %d ext_bid_support %d\n",
1071 result
, board_id
, chip_id
, ext_bid_support
);
1073 ar
->id
.ext_bid_supported
= ext_bid_support
;
1075 if ((result
& ATH10K_BMI_BOARD_ID_STATUS_MASK
) != 0 ||
1077 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
1078 "board id does not exist in otp, ignore it\n");
1082 ar
->id
.bmi_ids_valid
= true;
1083 ar
->id
.bmi_board_id
= board_id
;
1084 ar
->id
.bmi_chip_id
= chip_id
;
1091 static void ath10k_core_check_bdfext(const struct dmi_header
*hdr
, void *data
)
1093 struct ath10k
*ar
= data
;
1094 const char *bdf_ext
;
1095 const char *magic
= ATH10K_SMBIOS_BDF_EXT_MAGIC
;
1099 if (hdr
->type
!= ATH10K_SMBIOS_BDF_EXT_TYPE
)
1102 if (hdr
->length
!= ATH10K_SMBIOS_BDF_EXT_LENGTH
) {
1103 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
1104 "wrong smbios bdf ext type length (%d).\n",
1109 bdf_enabled
= *((u8
*)hdr
+ ATH10K_SMBIOS_BDF_EXT_OFFSET
);
1111 ath10k_dbg(ar
, ATH10K_DBG_BOOT
, "bdf variant name not found.\n");
1115 /* Only one string exists (per spec) */
1116 bdf_ext
= (char *)hdr
+ hdr
->length
;
1118 if (memcmp(bdf_ext
, magic
, strlen(magic
)) != 0) {
1119 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
1120 "bdf variant magic does not match.\n");
1124 for (i
= 0; i
< strlen(bdf_ext
); i
++) {
1125 if (!isascii(bdf_ext
[i
]) || !isprint(bdf_ext
[i
])) {
1126 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
1127 "bdf variant name contains non ascii chars.\n");
1132 /* Copy extension name without magic suffix */
1133 if (strscpy(ar
->id
.bdf_ext
, bdf_ext
+ strlen(magic
),
1134 sizeof(ar
->id
.bdf_ext
)) < 0) {
1135 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
1136 "bdf variant string is longer than the buffer can accommodate (variant: %s)\n",
1141 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
1142 "found and validated bdf variant smbios_type 0x%x bdf %s\n",
1143 ATH10K_SMBIOS_BDF_EXT_TYPE
, bdf_ext
);
1146 static int ath10k_core_check_smbios(struct ath10k
*ar
)
1148 ar
->id
.bdf_ext
[0] = '\0';
1149 dmi_walk(ath10k_core_check_bdfext
, ar
);
1151 if (ar
->id
.bdf_ext
[0] == '\0')
1157 int ath10k_core_check_dt(struct ath10k
*ar
)
1159 struct device_node
*node
;
1160 const char *variant
= NULL
;
1162 node
= ar
->dev
->of_node
;
1166 of_property_read_string(node
, "qcom,ath10k-calibration-variant",
1171 if (strscpy(ar
->id
.bdf_ext
, variant
, sizeof(ar
->id
.bdf_ext
)) < 0)
1172 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
1173 "bdf variant string is longer than the buffer can accommodate (variant: %s)\n",
1178 EXPORT_SYMBOL(ath10k_core_check_dt
);
1180 static int ath10k_download_fw(struct ath10k
*ar
)
1182 u32 address
, data_len
;
1185 struct pm_qos_request latency_qos
;
1187 address
= ar
->hw_params
.patch_load_addr
;
1189 data
= ar
->running_fw
->fw_file
.firmware_data
;
1190 data_len
= ar
->running_fw
->fw_file
.firmware_len
;
1192 ret
= ath10k_swap_code_seg_configure(ar
, &ar
->running_fw
->fw_file
);
1194 ath10k_err(ar
, "failed to configure fw code swap: %d\n",
1199 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
1200 "boot uploading firmware image %pK len %d\n",
1203 /* Check if device supports to download firmware via
1204 * diag copy engine. Downloading firmware via diag CE
1205 * greatly reduces the time to download firmware.
1207 if (ar
->hw_params
.fw_diag_ce_download
) {
1208 ret
= ath10k_hw_diag_fast_download(ar
, address
,
1211 /* firmware upload via diag ce was successful */
1215 "failed to upload firmware via diag ce, trying BMI: %d",
1219 memset(&latency_qos
, 0, sizeof(latency_qos
));
1220 cpu_latency_qos_add_request(&latency_qos
, 0);
1222 ret
= ath10k_bmi_fast_download(ar
, address
, data
, data_len
);
1224 cpu_latency_qos_remove_request(&latency_qos
);
1229 void ath10k_core_free_board_files(struct ath10k
*ar
)
1231 if (!IS_ERR(ar
->normal_mode_fw
.board
))
1232 release_firmware(ar
->normal_mode_fw
.board
);
1234 if (!IS_ERR(ar
->normal_mode_fw
.ext_board
))
1235 release_firmware(ar
->normal_mode_fw
.ext_board
);
1237 ar
->normal_mode_fw
.board
= NULL
;
1238 ar
->normal_mode_fw
.board_data
= NULL
;
1239 ar
->normal_mode_fw
.board_len
= 0;
1240 ar
->normal_mode_fw
.ext_board
= NULL
;
1241 ar
->normal_mode_fw
.ext_board_data
= NULL
;
1242 ar
->normal_mode_fw
.ext_board_len
= 0;
1244 EXPORT_SYMBOL(ath10k_core_free_board_files
);
1246 static void ath10k_core_free_firmware_files(struct ath10k
*ar
)
1248 if (!IS_ERR(ar
->normal_mode_fw
.fw_file
.firmware
))
1249 release_firmware(ar
->normal_mode_fw
.fw_file
.firmware
);
1251 if (!IS_ERR(ar
->cal_file
))
1252 release_firmware(ar
->cal_file
);
1254 if (!IS_ERR(ar
->pre_cal_file
))
1255 release_firmware(ar
->pre_cal_file
);
1257 ath10k_swap_code_seg_release(ar
, &ar
->normal_mode_fw
.fw_file
);
1259 ar
->normal_mode_fw
.fw_file
.otp_data
= NULL
;
1260 ar
->normal_mode_fw
.fw_file
.otp_len
= 0;
1262 ar
->normal_mode_fw
.fw_file
.firmware
= NULL
;
1263 ar
->normal_mode_fw
.fw_file
.firmware_data
= NULL
;
1264 ar
->normal_mode_fw
.fw_file
.firmware_len
= 0;
1266 ar
->cal_file
= NULL
;
1267 ar
->pre_cal_file
= NULL
;
1270 static int ath10k_fetch_cal_file(struct ath10k
*ar
)
1274 /* pre-cal-<bus>-<id>.bin */
1275 scnprintf(filename
, sizeof(filename
), "pre-cal-%s-%s.bin",
1276 ath10k_bus_str(ar
->hif
.bus
), dev_name(ar
->dev
));
1278 ar
->pre_cal_file
= ath10k_fetch_fw_file(ar
, ATH10K_FW_DIR
, filename
);
1279 if (!IS_ERR(ar
->pre_cal_file
))
1282 /* cal-<bus>-<id>.bin */
1283 scnprintf(filename
, sizeof(filename
), "cal-%s-%s.bin",
1284 ath10k_bus_str(ar
->hif
.bus
), dev_name(ar
->dev
));
1286 ar
->cal_file
= ath10k_fetch_fw_file(ar
, ATH10K_FW_DIR
, filename
);
1287 if (IS_ERR(ar
->cal_file
))
1288 /* calibration file is optional, don't print any warnings */
1289 return PTR_ERR(ar
->cal_file
);
1291 ath10k_dbg(ar
, ATH10K_DBG_BOOT
, "found calibration file %s/%s\n",
1292 ATH10K_FW_DIR
, filename
);
1297 static int ath10k_core_fetch_board_data_api_1(struct ath10k
*ar
, int bd_ie_type
)
1299 const struct firmware
*fw
;
1300 char boardname
[100];
1302 if (bd_ie_type
== ATH10K_BD_IE_BOARD
) {
1303 scnprintf(boardname
, sizeof(boardname
), "board-%s-%s.bin",
1304 ath10k_bus_str(ar
->hif
.bus
), dev_name(ar
->dev
));
1306 ar
->normal_mode_fw
.board
= ath10k_fetch_fw_file(ar
,
1307 ar
->hw_params
.fw
.dir
,
1309 if (IS_ERR(ar
->normal_mode_fw
.board
)) {
1310 fw
= ath10k_fetch_fw_file(ar
,
1311 ar
->hw_params
.fw
.dir
,
1312 ATH10K_BOARD_DATA_FILE
);
1313 ar
->normal_mode_fw
.board
= fw
;
1316 if (IS_ERR(ar
->normal_mode_fw
.board
))
1317 return PTR_ERR(ar
->normal_mode_fw
.board
);
1319 ar
->normal_mode_fw
.board_data
= ar
->normal_mode_fw
.board
->data
;
1320 ar
->normal_mode_fw
.board_len
= ar
->normal_mode_fw
.board
->size
;
1321 } else if (bd_ie_type
== ATH10K_BD_IE_BOARD_EXT
) {
1322 fw
= ath10k_fetch_fw_file(ar
, ar
->hw_params
.fw
.dir
,
1323 ATH10K_EBOARD_DATA_FILE
);
1324 ar
->normal_mode_fw
.ext_board
= fw
;
1325 if (IS_ERR(ar
->normal_mode_fw
.ext_board
))
1326 return PTR_ERR(ar
->normal_mode_fw
.ext_board
);
1328 ar
->normal_mode_fw
.ext_board_data
= ar
->normal_mode_fw
.ext_board
->data
;
1329 ar
->normal_mode_fw
.ext_board_len
= ar
->normal_mode_fw
.ext_board
->size
;
1335 static int ath10k_core_parse_bd_ie_board(struct ath10k
*ar
,
1336 const void *buf
, size_t buf_len
,
1337 const char *boardname
,
1340 const struct ath10k_fw_ie
*hdr
;
1341 bool name_match_found
;
1342 int ret
, board_ie_id
;
1343 size_t board_ie_len
;
1344 const void *board_ie_data
;
1346 name_match_found
= false;
1348 /* go through ATH10K_BD_IE_BOARD_ elements */
1349 while (buf_len
> sizeof(struct ath10k_fw_ie
)) {
1351 board_ie_id
= le32_to_cpu(hdr
->id
);
1352 board_ie_len
= le32_to_cpu(hdr
->len
);
1353 board_ie_data
= hdr
->data
;
1355 buf_len
-= sizeof(*hdr
);
1356 buf
+= sizeof(*hdr
);
1358 if (buf_len
< ALIGN(board_ie_len
, 4)) {
1359 ath10k_err(ar
, "invalid ATH10K_BD_IE_BOARD length: %zu < %zu\n",
1360 buf_len
, ALIGN(board_ie_len
, 4));
1365 switch (board_ie_id
) {
1366 case ATH10K_BD_IE_BOARD_NAME
:
1367 ath10k_dbg_dump(ar
, ATH10K_DBG_BOOT
, "board name", "",
1368 board_ie_data
, board_ie_len
);
1370 if (board_ie_len
!= strlen(boardname
))
1373 ret
= memcmp(board_ie_data
, boardname
, strlen(boardname
));
1377 name_match_found
= true;
1378 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
1379 "boot found match for name '%s'",
1382 case ATH10K_BD_IE_BOARD_DATA
:
1383 if (!name_match_found
)
1384 /* no match found */
1387 if (bd_ie_type
== ATH10K_BD_IE_BOARD
) {
1388 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
1389 "boot found board data for '%s'",
1392 ar
->normal_mode_fw
.board_data
= board_ie_data
;
1393 ar
->normal_mode_fw
.board_len
= board_ie_len
;
1394 } else if (bd_ie_type
== ATH10K_BD_IE_BOARD_EXT
) {
1395 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
1396 "boot found eboard data for '%s'",
1399 ar
->normal_mode_fw
.ext_board_data
= board_ie_data
;
1400 ar
->normal_mode_fw
.ext_board_len
= board_ie_len
;
1406 ath10k_warn(ar
, "unknown ATH10K_BD_IE_BOARD found: %d\n",
1411 /* jump over the padding */
1412 board_ie_len
= ALIGN(board_ie_len
, 4);
1414 buf_len
-= board_ie_len
;
1415 buf
+= board_ie_len
;
1418 /* no match found */
1425 static int ath10k_core_search_bd(struct ath10k
*ar
,
1426 const char *boardname
,
1431 struct ath10k_fw_ie
*hdr
;
1432 int ret
= -ENOENT
, ie_id
;
1434 while (len
> sizeof(struct ath10k_fw_ie
)) {
1435 hdr
= (struct ath10k_fw_ie
*)data
;
1436 ie_id
= le32_to_cpu(hdr
->id
);
1437 ie_len
= le32_to_cpu(hdr
->len
);
1439 len
-= sizeof(*hdr
);
1442 if (len
< ALIGN(ie_len
, 4)) {
1443 ath10k_err(ar
, "invalid length for board ie_id %d ie_len %zu len %zu\n",
1444 ie_id
, ie_len
, len
);
1449 case ATH10K_BD_IE_BOARD
:
1450 ret
= ath10k_core_parse_bd_ie_board(ar
, data
, ie_len
,
1452 ATH10K_BD_IE_BOARD
);
1454 /* no match found, continue */
1457 /* either found or error, so stop searching */
1459 case ATH10K_BD_IE_BOARD_EXT
:
1460 ret
= ath10k_core_parse_bd_ie_board(ar
, data
, ie_len
,
1462 ATH10K_BD_IE_BOARD_EXT
);
1464 /* no match found, continue */
1467 /* either found or error, so stop searching */
1471 /* jump over the padding */
1472 ie_len
= ALIGN(ie_len
, 4);
1479 /* return result of parse_bd_ie_board() or -ENOENT */
1483 static int ath10k_core_fetch_board_data_api_n(struct ath10k
*ar
,
1484 const char *boardname
,
1485 const char *fallback_boardname1
,
1486 const char *fallback_boardname2
,
1487 const char *filename
)
1489 size_t len
, magic_len
;
1493 /* Skip if already fetched during board data download */
1494 if (!ar
->normal_mode_fw
.board
)
1495 ar
->normal_mode_fw
.board
= ath10k_fetch_fw_file(ar
,
1496 ar
->hw_params
.fw
.dir
,
1498 if (IS_ERR(ar
->normal_mode_fw
.board
))
1499 return PTR_ERR(ar
->normal_mode_fw
.board
);
1501 data
= ar
->normal_mode_fw
.board
->data
;
1502 len
= ar
->normal_mode_fw
.board
->size
;
1504 /* magic has extra null byte padded */
1505 magic_len
= strlen(ATH10K_BOARD_MAGIC
) + 1;
1506 if (len
< magic_len
) {
1507 ath10k_err(ar
, "failed to find magic value in %s/%s, file too short: %zu\n",
1508 ar
->hw_params
.fw
.dir
, filename
, len
);
1513 if (memcmp(data
, ATH10K_BOARD_MAGIC
, magic_len
)) {
1514 ath10k_err(ar
, "found invalid board magic\n");
1519 /* magic is padded to 4 bytes */
1520 magic_len
= ALIGN(magic_len
, 4);
1521 if (len
< magic_len
) {
1522 ath10k_err(ar
, "failed: %s/%s too small to contain board data, len: %zu\n",
1523 ar
->hw_params
.fw
.dir
, filename
, len
);
1531 /* attempt to find boardname in the IE list */
1532 ret
= ath10k_core_search_bd(ar
, boardname
, data
, len
);
1534 /* if we didn't find it and have a fallback name, try that */
1535 if (ret
== -ENOENT
&& fallback_boardname1
)
1536 ret
= ath10k_core_search_bd(ar
, fallback_boardname1
, data
, len
);
1538 if (ret
== -ENOENT
&& fallback_boardname2
)
1539 ret
= ath10k_core_search_bd(ar
, fallback_boardname2
, data
, len
);
1541 if (ret
== -ENOENT
) {
1543 "failed to fetch board data for %s from %s/%s\n",
1544 boardname
, ar
->hw_params
.fw
.dir
, filename
);
1554 ath10k_core_free_board_files(ar
);
1558 static int ath10k_core_create_board_name(struct ath10k
*ar
, char *name
,
1559 size_t name_len
, bool with_variant
,
1562 /* strlen(',variant=') + strlen(ar->id.bdf_ext) */
1563 char variant
[9 + ATH10K_SMBIOS_BDF_EXT_STR_LENGTH
] = { 0 };
1565 if (with_variant
&& ar
->id
.bdf_ext
[0] != '\0')
1566 scnprintf(variant
, sizeof(variant
), ",variant=%s",
1569 if (ar
->id
.bmi_ids_valid
) {
1570 scnprintf(name
, name_len
,
1571 "bus=%s,bmi-chip-id=%d,bmi-board-id=%d%s",
1572 ath10k_bus_str(ar
->hif
.bus
),
1574 ar
->id
.bmi_board_id
, variant
);
1578 if (ar
->id
.qmi_ids_valid
) {
1580 scnprintf(name
, name_len
,
1581 "bus=%s,qmi-board-id=%x,qmi-chip-id=%x%s",
1582 ath10k_bus_str(ar
->hif
.bus
),
1583 ar
->id
.qmi_board_id
, ar
->id
.qmi_chip_id
,
1586 scnprintf(name
, name_len
,
1587 "bus=%s,qmi-board-id=%x",
1588 ath10k_bus_str(ar
->hif
.bus
),
1589 ar
->id
.qmi_board_id
);
1593 scnprintf(name
, name_len
,
1594 "bus=%s,vendor=%04x,device=%04x,subsystem-vendor=%04x,subsystem-device=%04x%s",
1595 ath10k_bus_str(ar
->hif
.bus
),
1596 ar
->id
.vendor
, ar
->id
.device
,
1597 ar
->id
.subsystem_vendor
, ar
->id
.subsystem_device
, variant
);
1599 ath10k_dbg(ar
, ATH10K_DBG_BOOT
, "boot using board name '%s'\n", name
);
1604 static int ath10k_core_create_eboard_name(struct ath10k
*ar
, char *name
,
1607 if (ar
->id
.bmi_ids_valid
) {
1608 scnprintf(name
, name_len
,
1609 "bus=%s,bmi-chip-id=%d,bmi-eboard-id=%d",
1610 ath10k_bus_str(ar
->hif
.bus
),
1612 ar
->id
.bmi_eboard_id
);
1614 ath10k_dbg(ar
, ATH10K_DBG_BOOT
, "boot using eboard name '%s'\n", name
);
1617 /* Fallback if returned board id is zero */
1621 int ath10k_core_fetch_board_file(struct ath10k
*ar
, int bd_ie_type
)
1623 char boardname
[100], fallback_boardname1
[100], fallback_boardname2
[100];
1626 if (bd_ie_type
== ATH10K_BD_IE_BOARD
) {
1627 /* With variant and chip id */
1628 ret
= ath10k_core_create_board_name(ar
, boardname
,
1629 sizeof(boardname
), true,
1632 ath10k_err(ar
, "failed to create board name: %d", ret
);
1636 /* Without variant and only chip-id */
1637 ret
= ath10k_core_create_board_name(ar
, fallback_boardname1
,
1638 sizeof(boardname
), false,
1641 ath10k_err(ar
, "failed to create 1st fallback board name: %d",
1646 /* Without variant and without chip-id */
1647 ret
= ath10k_core_create_board_name(ar
, fallback_boardname2
,
1648 sizeof(boardname
), false,
1651 ath10k_err(ar
, "failed to create 2nd fallback board name: %d",
1655 } else if (bd_ie_type
== ATH10K_BD_IE_BOARD_EXT
) {
1656 ret
= ath10k_core_create_eboard_name(ar
, boardname
,
1659 ath10k_err(ar
, "fallback to eboard.bin since board id 0");
1665 ret
= ath10k_core_fetch_board_data_api_n(ar
, boardname
,
1666 fallback_boardname1
,
1667 fallback_boardname2
,
1668 ATH10K_BOARD_API2_FILE
);
1674 ret
= ath10k_core_fetch_board_data_api_1(ar
, bd_ie_type
);
1676 ath10k_err(ar
, "failed to fetch board-2.bin or board.bin from %s\n",
1677 ar
->hw_params
.fw
.dir
);
1682 ath10k_dbg(ar
, ATH10K_DBG_BOOT
, "using board api %d\n", ar
->bd_api
);
1685 EXPORT_SYMBOL(ath10k_core_fetch_board_file
);
1687 static int ath10k_core_get_ext_board_id_from_otp(struct ath10k
*ar
)
1689 u32 result
, address
;
1693 address
= ar
->hw_params
.patch_load_addr
;
1695 if (!ar
->normal_mode_fw
.fw_file
.otp_data
||
1696 !ar
->normal_mode_fw
.fw_file
.otp_len
) {
1698 "failed to retrieve extended board id due to otp binary missing\n");
1702 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
1703 "boot upload otp to 0x%x len %zd for ext board id\n",
1704 address
, ar
->normal_mode_fw
.fw_file
.otp_len
);
1706 ret
= ath10k_bmi_fast_download(ar
, address
,
1707 ar
->normal_mode_fw
.fw_file
.otp_data
,
1708 ar
->normal_mode_fw
.fw_file
.otp_len
);
1710 ath10k_err(ar
, "could not write otp for ext board id check: %d\n",
1715 ret
= ath10k_bmi_execute(ar
, address
, BMI_PARAM_GET_EXT_BOARD_ID
, &result
);
1717 ath10k_err(ar
, "could not execute otp for ext board id check: %d\n",
1723 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
1724 "ext board id does not exist in otp, ignore it\n");
1728 ext_board_id
= result
& ATH10K_BMI_EBOARD_ID_STATUS_MASK
;
1730 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
1731 "boot get otp ext board id result 0x%08x ext_board_id %d\n",
1732 result
, ext_board_id
);
1734 ar
->id
.bmi_eboard_id
= ext_board_id
;
1739 static int ath10k_download_board_data(struct ath10k
*ar
, const void *data
,
1742 u32 board_data_size
= ar
->hw_params
.fw
.board_size
;
1743 u32 eboard_data_size
= ar
->hw_params
.fw
.ext_board_size
;
1745 u32 ext_board_address
;
1748 ret
= ath10k_push_board_ext_data(ar
, data
, data_len
);
1750 ath10k_err(ar
, "could not push board ext data (%d)\n", ret
);
1754 ret
= ath10k_bmi_read32(ar
, hi_board_data
, &board_address
);
1756 ath10k_err(ar
, "could not read board data addr (%d)\n", ret
);
1760 ret
= ath10k_bmi_write_memory(ar
, board_address
, data
,
1761 min_t(u32
, board_data_size
,
1764 ath10k_err(ar
, "could not write board data (%d)\n", ret
);
1768 ret
= ath10k_bmi_write32(ar
, hi_board_data_initialized
, 1);
1770 ath10k_err(ar
, "could not write board data bit (%d)\n", ret
);
1774 if (!ar
->id
.ext_bid_supported
)
1777 /* Extended board data download */
1778 ret
= ath10k_core_get_ext_board_id_from_otp(ar
);
1779 if (ret
== -EOPNOTSUPP
) {
1780 /* Not fetching ext_board_data if ext board id is 0 */
1781 ath10k_dbg(ar
, ATH10K_DBG_BOOT
, "otp returned ext board id 0\n");
1784 ath10k_err(ar
, "failed to get extended board id: %d\n", ret
);
1788 ret
= ath10k_core_fetch_board_file(ar
, ATH10K_BD_IE_BOARD_EXT
);
1792 if (ar
->normal_mode_fw
.ext_board_data
) {
1793 ext_board_address
= board_address
+ EXT_BOARD_ADDRESS_OFFSET
;
1794 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
1795 "boot writing ext board data to addr 0x%x",
1797 ret
= ath10k_bmi_write_memory(ar
, ext_board_address
,
1798 ar
->normal_mode_fw
.ext_board_data
,
1799 min_t(u32
, eboard_data_size
, data_len
));
1801 ath10k_err(ar
, "failed to write ext board data: %d\n", ret
);
1808 static int ath10k_download_and_run_otp(struct ath10k
*ar
)
1810 u32 result
, address
= ar
->hw_params
.patch_load_addr
;
1811 u32 bmi_otp_exe_param
= ar
->hw_params
.otp_exe_param
;
1814 ret
= ath10k_download_board_data(ar
,
1815 ar
->running_fw
->board_data
,
1816 ar
->running_fw
->board_len
);
1818 ath10k_err(ar
, "failed to download board data: %d\n", ret
);
1822 /* OTP is optional */
1824 if (!ar
->running_fw
->fw_file
.otp_data
||
1825 !ar
->running_fw
->fw_file
.otp_len
) {
1826 ath10k_warn(ar
, "Not running otp, calibration will be incorrect (otp-data %pK otp_len %zd)!\n",
1827 ar
->running_fw
->fw_file
.otp_data
,
1828 ar
->running_fw
->fw_file
.otp_len
);
1832 ath10k_dbg(ar
, ATH10K_DBG_BOOT
, "boot upload otp to 0x%x len %zd\n",
1833 address
, ar
->running_fw
->fw_file
.otp_len
);
1835 ret
= ath10k_bmi_fast_download(ar
, address
,
1836 ar
->running_fw
->fw_file
.otp_data
,
1837 ar
->running_fw
->fw_file
.otp_len
);
1839 ath10k_err(ar
, "could not write otp (%d)\n", ret
);
1843 /* As of now pre-cal is valid for 10_4 variants */
1844 if (ar
->cal_mode
== ATH10K_PRE_CAL_MODE_DT
||
1845 ar
->cal_mode
== ATH10K_PRE_CAL_MODE_FILE
||
1846 ar
->cal_mode
== ATH10K_PRE_CAL_MODE_NVMEM
)
1847 bmi_otp_exe_param
= BMI_PARAM_FLASH_SECTION_ALL
;
1849 ret
= ath10k_bmi_execute(ar
, address
, bmi_otp_exe_param
, &result
);
1851 ath10k_err(ar
, "could not execute otp (%d)\n", ret
);
1855 ath10k_dbg(ar
, ATH10K_DBG_BOOT
, "boot otp execute result %d\n", result
);
1857 if (!(skip_otp
|| test_bit(ATH10K_FW_FEATURE_IGNORE_OTP_RESULT
,
1858 ar
->running_fw
->fw_file
.fw_features
)) &&
1860 ath10k_err(ar
, "otp calibration failed: %d", result
);
1867 static int ath10k_download_cal_file(struct ath10k
*ar
,
1868 const struct firmware
*file
)
1876 return PTR_ERR(file
);
1878 ret
= ath10k_download_board_data(ar
, file
->data
, file
->size
);
1880 ath10k_err(ar
, "failed to download cal_file data: %d\n", ret
);
1884 ath10k_dbg(ar
, ATH10K_DBG_BOOT
, "boot cal file downloaded\n");
1889 static int ath10k_download_cal_dt(struct ath10k
*ar
, const char *dt_name
)
1891 struct device_node
*node
;
1896 node
= ar
->dev
->of_node
;
1898 /* Device Tree is optional, don't print any warnings if
1899 * there's no node for ath10k.
1903 if (!of_get_property(node
, dt_name
, &data_len
)) {
1904 /* The calibration data node is optional */
1908 if (data_len
!= ar
->hw_params
.cal_data_len
) {
1909 ath10k_warn(ar
, "invalid calibration data length in DT: %d\n",
1915 data
= kmalloc(data_len
, GFP_KERNEL
);
1921 ret
= of_property_read_u8_array(node
, dt_name
, data
, data_len
);
1923 ath10k_warn(ar
, "failed to read calibration data from DT: %d\n",
1928 ret
= ath10k_download_board_data(ar
, data
, data_len
);
1930 ath10k_warn(ar
, "failed to download calibration data from Device Tree: %d\n",
1944 static int ath10k_download_cal_eeprom(struct ath10k
*ar
)
1950 ret
= ath10k_hif_fetch_cal_eeprom(ar
, &data
, &data_len
);
1952 if (ret
!= -EOPNOTSUPP
)
1953 ath10k_warn(ar
, "failed to read calibration data from EEPROM: %d\n",
1958 ret
= ath10k_download_board_data(ar
, data
, data_len
);
1960 ath10k_warn(ar
, "failed to download calibration data from EEPROM: %d\n",
1973 static int ath10k_download_cal_nvmem(struct ath10k
*ar
, const char *cell_name
)
1975 struct nvmem_cell
*cell
;
1980 cell
= devm_nvmem_cell_get(ar
->dev
, cell_name
);
1982 ret
= PTR_ERR(cell
);
1986 buf
= nvmem_cell_read(cell
, &len
);
1988 return PTR_ERR(buf
);
1990 if (ar
->hw_params
.cal_data_len
!= len
) {
1992 ath10k_warn(ar
, "invalid calibration data length in nvmem-cell '%s': %zu != %u\n",
1993 cell_name
, len
, ar
->hw_params
.cal_data_len
);
1997 ret
= ath10k_download_board_data(ar
, buf
, len
);
2000 ath10k_warn(ar
, "failed to download calibration data from nvmem-cell '%s': %d\n",
2006 int ath10k_core_fetch_firmware_api_n(struct ath10k
*ar
, const char *name
,
2007 struct ath10k_fw_file
*fw_file
)
2009 size_t magic_len
, len
, ie_len
;
2010 int ie_id
, i
, index
, bit
, ret
;
2011 struct ath10k_fw_ie
*hdr
;
2013 __le32
*timestamp
, *version
;
2015 /* first fetch the firmware file (firmware-*.bin) */
2016 fw_file
->firmware
= ath10k_fetch_fw_file(ar
, ar
->hw_params
.fw
.dir
,
2018 if (IS_ERR(fw_file
->firmware
))
2019 return PTR_ERR(fw_file
->firmware
);
2021 data
= fw_file
->firmware
->data
;
2022 len
= fw_file
->firmware
->size
;
2024 /* magic also includes the null byte, check that as well */
2025 magic_len
= strlen(ATH10K_FIRMWARE_MAGIC
) + 1;
2027 if (len
< magic_len
) {
2028 ath10k_err(ar
, "firmware file '%s/%s' too small to contain magic: %zu\n",
2029 ar
->hw_params
.fw
.dir
, name
, len
);
2034 if (memcmp(data
, ATH10K_FIRMWARE_MAGIC
, magic_len
) != 0) {
2035 ath10k_err(ar
, "invalid firmware magic\n");
2040 /* jump over the padding */
2041 magic_len
= ALIGN(magic_len
, 4);
2047 while (len
> sizeof(struct ath10k_fw_ie
)) {
2048 hdr
= (struct ath10k_fw_ie
*)data
;
2050 ie_id
= le32_to_cpu(hdr
->id
);
2051 ie_len
= le32_to_cpu(hdr
->len
);
2053 len
-= sizeof(*hdr
);
2054 data
+= sizeof(*hdr
);
2057 ath10k_err(ar
, "invalid length for FW IE %d (%zu < %zu)\n",
2058 ie_id
, len
, ie_len
);
2064 case ATH10K_FW_IE_FW_VERSION
:
2065 if (ie_len
> sizeof(fw_file
->fw_version
) - 1)
2068 memcpy(fw_file
->fw_version
, data
, ie_len
);
2069 fw_file
->fw_version
[ie_len
] = '\0';
2071 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
2072 "found fw version %s\n",
2073 fw_file
->fw_version
);
2075 case ATH10K_FW_IE_TIMESTAMP
:
2076 if (ie_len
!= sizeof(u32
))
2079 timestamp
= (__le32
*)data
;
2081 ath10k_dbg(ar
, ATH10K_DBG_BOOT
, "found fw timestamp %d\n",
2082 le32_to_cpup(timestamp
));
2084 case ATH10K_FW_IE_FEATURES
:
2085 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
2086 "found firmware features ie (%zd B)\n",
2089 for (i
= 0; i
< ATH10K_FW_FEATURE_COUNT
; i
++) {
2093 if (index
== ie_len
)
2096 if (data
[index
] & (1 << bit
)) {
2097 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
2098 "Enabling feature bit: %i\n",
2100 __set_bit(i
, fw_file
->fw_features
);
2104 ath10k_dbg_dump(ar
, ATH10K_DBG_BOOT
, "features", "",
2105 fw_file
->fw_features
,
2106 sizeof(fw_file
->fw_features
));
2108 case ATH10K_FW_IE_FW_IMAGE
:
2109 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
2110 "found fw image ie (%zd B)\n",
2113 fw_file
->firmware_data
= data
;
2114 fw_file
->firmware_len
= ie_len
;
2117 case ATH10K_FW_IE_OTP_IMAGE
:
2118 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
2119 "found otp image ie (%zd B)\n",
2122 fw_file
->otp_data
= data
;
2123 fw_file
->otp_len
= ie_len
;
2126 case ATH10K_FW_IE_WMI_OP_VERSION
:
2127 if (ie_len
!= sizeof(u32
))
2130 version
= (__le32
*)data
;
2132 fw_file
->wmi_op_version
= le32_to_cpup(version
);
2134 ath10k_dbg(ar
, ATH10K_DBG_BOOT
, "found fw ie wmi op version %d\n",
2135 fw_file
->wmi_op_version
);
2137 case ATH10K_FW_IE_HTT_OP_VERSION
:
2138 if (ie_len
!= sizeof(u32
))
2141 version
= (__le32
*)data
;
2143 fw_file
->htt_op_version
= le32_to_cpup(version
);
2145 ath10k_dbg(ar
, ATH10K_DBG_BOOT
, "found fw ie htt op version %d\n",
2146 fw_file
->htt_op_version
);
2148 case ATH10K_FW_IE_FW_CODE_SWAP_IMAGE
:
2149 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
2150 "found fw code swap image ie (%zd B)\n",
2152 fw_file
->codeswap_data
= data
;
2153 fw_file
->codeswap_len
= ie_len
;
2156 ath10k_warn(ar
, "Unknown FW IE: %u\n",
2157 le32_to_cpu(hdr
->id
));
2161 /* jump over the padding */
2162 ie_len
= ALIGN(ie_len
, 4);
2168 if (!test_bit(ATH10K_FW_FEATURE_NON_BMI
, fw_file
->fw_features
) &&
2169 (!fw_file
->firmware_data
|| !fw_file
->firmware_len
)) {
2170 ath10k_warn(ar
, "No ATH10K_FW_IE_FW_IMAGE found from '%s/%s', skipping\n",
2171 ar
->hw_params
.fw
.dir
, name
);
2179 ath10k_core_free_firmware_files(ar
);
2183 static void ath10k_core_get_fw_name(struct ath10k
*ar
, char *fw_name
,
2184 size_t fw_name_len
, int fw_api
)
2186 switch (ar
->hif
.bus
) {
2187 case ATH10K_BUS_SDIO
:
2188 case ATH10K_BUS_USB
:
2189 scnprintf(fw_name
, fw_name_len
, "%s-%s-%d.bin",
2190 ATH10K_FW_FILE_BASE
, ath10k_bus_str(ar
->hif
.bus
),
2193 case ATH10K_BUS_PCI
:
2194 case ATH10K_BUS_AHB
:
2195 case ATH10K_BUS_SNOC
:
2196 scnprintf(fw_name
, fw_name_len
, "%s-%d.bin",
2197 ATH10K_FW_FILE_BASE
, fw_api
);
2202 static int ath10k_core_fetch_firmware_files(struct ath10k
*ar
)
2207 /* calibration file is optional, don't check for any errors */
2208 ath10k_fetch_cal_file(ar
);
2210 for (i
= ATH10K_FW_API_MAX
; i
>= ATH10K_FW_API_MIN
; i
--) {
2212 ath10k_dbg(ar
, ATH10K_DBG_BOOT
, "trying fw api %d\n",
2215 ath10k_core_get_fw_name(ar
, fw_name
, sizeof(fw_name
), ar
->fw_api
);
2216 ret
= ath10k_core_fetch_firmware_api_n(ar
, fw_name
,
2217 &ar
->normal_mode_fw
.fw_file
);
2222 /* we end up here if we couldn't fetch any firmware */
2224 ath10k_err(ar
, "Failed to find firmware-N.bin (N between %d and %d) from %s: %d",
2225 ATH10K_FW_API_MIN
, ATH10K_FW_API_MAX
, ar
->hw_params
.fw
.dir
,
2231 ath10k_dbg(ar
, ATH10K_DBG_BOOT
, "using fw api %d\n", ar
->fw_api
);
2236 static int ath10k_core_pre_cal_download(struct ath10k
*ar
)
2240 ret
= ath10k_download_cal_nvmem(ar
, "pre-calibration");
2242 ar
->cal_mode
= ATH10K_PRE_CAL_MODE_NVMEM
;
2244 } else if (ret
== -EPROBE_DEFER
) {
2248 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
2249 "boot did not find a pre-calibration nvmem-cell, try file next: %d\n",
2252 ret
= ath10k_download_cal_file(ar
, ar
->pre_cal_file
);
2254 ar
->cal_mode
= ATH10K_PRE_CAL_MODE_FILE
;
2258 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
2259 "boot did not find a pre calibration file, try DT next: %d\n",
2262 ret
= ath10k_download_cal_dt(ar
, "qcom,ath10k-pre-calibration-data");
2264 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
2265 "unable to load pre cal data from DT: %d\n", ret
);
2268 ar
->cal_mode
= ATH10K_PRE_CAL_MODE_DT
;
2271 ath10k_dbg(ar
, ATH10K_DBG_BOOT
, "boot using calibration mode %s\n",
2272 ath10k_cal_mode_str(ar
->cal_mode
));
2277 static int ath10k_core_pre_cal_config(struct ath10k
*ar
)
2281 ret
= ath10k_core_pre_cal_download(ar
);
2283 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
2284 "failed to load pre cal data: %d\n", ret
);
2288 ret
= ath10k_core_get_board_id_from_otp(ar
);
2290 ath10k_err(ar
, "failed to get board id: %d\n", ret
);
2294 ret
= ath10k_download_and_run_otp(ar
);
2296 ath10k_err(ar
, "failed to run otp: %d\n", ret
);
2300 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
2301 "pre cal configuration done successfully\n");
2306 static int ath10k_download_cal_data(struct ath10k
*ar
)
2310 ret
= ath10k_core_pre_cal_config(ar
);
2314 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
2315 "pre cal download procedure failed, try cal file: %d\n",
2318 ret
= ath10k_download_cal_nvmem(ar
, "calibration");
2320 ar
->cal_mode
= ATH10K_CAL_MODE_NVMEM
;
2322 } else if (ret
== -EPROBE_DEFER
) {
2326 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
2327 "boot did not find a calibration nvmem-cell, try file next: %d\n",
2330 ret
= ath10k_download_cal_file(ar
, ar
->cal_file
);
2332 ar
->cal_mode
= ATH10K_CAL_MODE_FILE
;
2336 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
2337 "boot did not find a calibration file, try DT next: %d\n",
2340 ret
= ath10k_download_cal_dt(ar
, "qcom,ath10k-calibration-data");
2342 ar
->cal_mode
= ATH10K_CAL_MODE_DT
;
2346 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
2347 "boot did not find DT entry, try target EEPROM next: %d\n",
2350 ret
= ath10k_download_cal_eeprom(ar
);
2352 ar
->cal_mode
= ATH10K_CAL_MODE_EEPROM
;
2356 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
2357 "boot did not find target EEPROM entry, try OTP next: %d\n",
2360 ret
= ath10k_download_and_run_otp(ar
);
2362 ath10k_err(ar
, "failed to run otp: %d\n", ret
);
2366 ar
->cal_mode
= ATH10K_CAL_MODE_OTP
;
2369 ath10k_dbg(ar
, ATH10K_DBG_BOOT
, "boot using calibration mode %s\n",
2370 ath10k_cal_mode_str(ar
->cal_mode
));
2374 static void ath10k_core_fetch_btcoex_dt(struct ath10k
*ar
)
2376 struct device_node
*node
;
2377 u8 coex_support
= 0;
2380 node
= ar
->dev
->of_node
;
2384 ret
= of_property_read_u8(node
, "qcom,coexist-support", &coex_support
);
2386 ar
->coex_support
= true;
2391 ar
->coex_support
= true;
2393 ar
->coex_support
= false;
2394 ar
->coex_gpio_pin
= -1;
2398 ret
= of_property_read_u32(node
, "qcom,coexist-gpio-pin",
2399 &ar
->coex_gpio_pin
);
2401 ar
->coex_gpio_pin
= -1;
2404 ath10k_dbg(ar
, ATH10K_DBG_BOOT
, "boot coex_support %d coex_gpio_pin %d\n",
2405 ar
->coex_support
, ar
->coex_gpio_pin
);
2408 static int ath10k_init_uart(struct ath10k
*ar
)
2413 * Explicitly setting UART prints to zero as target turns it on
2414 * based on scratch registers.
2416 ret
= ath10k_bmi_write32(ar
, hi_serial_enable
, 0);
2418 ath10k_warn(ar
, "could not disable UART prints (%d)\n", ret
);
2423 if (ar
->hw_params
.uart_pin_workaround
) {
2424 ret
= ath10k_bmi_write32(ar
, hi_dbg_uart_txpin
,
2425 ar
->hw_params
.uart_pin
);
2427 ath10k_warn(ar
, "failed to set UART TX pin: %d",
2436 ret
= ath10k_bmi_write32(ar
, hi_dbg_uart_txpin
, ar
->hw_params
.uart_pin
);
2438 ath10k_warn(ar
, "could not enable UART prints (%d)\n", ret
);
2442 ret
= ath10k_bmi_write32(ar
, hi_serial_enable
, 1);
2444 ath10k_warn(ar
, "could not enable UART prints (%d)\n", ret
);
2448 /* Set the UART baud rate to 19200. */
2449 ret
= ath10k_bmi_write32(ar
, hi_desired_baud_rate
, 19200);
2451 ath10k_warn(ar
, "could not set the baud rate (%d)\n", ret
);
2455 ath10k_info(ar
, "UART prints enabled\n");
2459 static int ath10k_init_hw_params(struct ath10k
*ar
)
2461 const struct ath10k_hw_params
*hw_params
;
2464 for (i
= 0; i
< ARRAY_SIZE(ath10k_hw_params_list
); i
++) {
2465 hw_params
= &ath10k_hw_params_list
[i
];
2467 if (hw_params
->bus
== ar
->hif
.bus
&&
2468 hw_params
->id
== ar
->target_version
&&
2469 hw_params
->dev_id
== ar
->dev_id
)
2473 if (i
== ARRAY_SIZE(ath10k_hw_params_list
)) {
2474 ath10k_err(ar
, "Unsupported hardware version: 0x%x\n",
2475 ar
->target_version
);
2479 ar
->hw_params
= *hw_params
;
2481 ath10k_dbg(ar
, ATH10K_DBG_BOOT
, "Hardware name %s version 0x%x\n",
2482 ar
->hw_params
.name
, ar
->target_version
);
2487 void ath10k_core_start_recovery(struct ath10k
*ar
)
2489 if (test_and_set_bit(ATH10K_FLAG_RESTARTING
, &ar
->dev_flags
)) {
2490 ath10k_warn(ar
, "already restarting\n");
2494 queue_work(ar
->workqueue
, &ar
->restart_work
);
2496 EXPORT_SYMBOL(ath10k_core_start_recovery
);
2498 void ath10k_core_napi_enable(struct ath10k
*ar
)
2500 lockdep_assert_held(&ar
->conf_mutex
);
2502 if (test_bit(ATH10K_FLAG_NAPI_ENABLED
, &ar
->dev_flags
))
2505 napi_enable(&ar
->napi
);
2506 set_bit(ATH10K_FLAG_NAPI_ENABLED
, &ar
->dev_flags
);
2508 EXPORT_SYMBOL(ath10k_core_napi_enable
);
2510 void ath10k_core_napi_sync_disable(struct ath10k
*ar
)
2512 lockdep_assert_held(&ar
->conf_mutex
);
2514 if (!test_bit(ATH10K_FLAG_NAPI_ENABLED
, &ar
->dev_flags
))
2517 napi_synchronize(&ar
->napi
);
2518 napi_disable(&ar
->napi
);
2519 clear_bit(ATH10K_FLAG_NAPI_ENABLED
, &ar
->dev_flags
);
2521 EXPORT_SYMBOL(ath10k_core_napi_sync_disable
);
2523 static void ath10k_core_restart(struct work_struct
*work
)
2525 struct ath10k
*ar
= container_of(work
, struct ath10k
, restart_work
);
2528 set_bit(ATH10K_FLAG_CRASH_FLUSH
, &ar
->dev_flags
);
2530 /* Place a barrier to make sure the compiler doesn't reorder
2531 * CRASH_FLUSH and calling other functions.
2535 ieee80211_stop_queues(ar
->hw
);
2536 ath10k_drain_tx(ar
);
2537 complete(&ar
->scan
.started
);
2538 complete(&ar
->scan
.completed
);
2539 complete(&ar
->scan
.on_channel
);
2540 complete(&ar
->offchan_tx_completed
);
2541 complete(&ar
->install_key_done
);
2542 complete(&ar
->vdev_setup_done
);
2543 complete(&ar
->vdev_delete_done
);
2544 complete(&ar
->thermal
.wmi_sync
);
2545 complete(&ar
->bss_survey_done
);
2546 wake_up(&ar
->htt
.empty_tx_wq
);
2547 wake_up(&ar
->wmi
.tx_credits_wq
);
2548 wake_up(&ar
->peer_mapping_wq
);
2550 /* TODO: We can have one instance of cancelling coverage_class_work by
2551 * moving it to ath10k_halt(), so that both stop() and restart() would
2552 * call that but it takes conf_mutex() and if we call cancel_work_sync()
2553 * with conf_mutex it will deadlock.
2555 cancel_work_sync(&ar
->set_coverage_class_work
);
2557 mutex_lock(&ar
->conf_mutex
);
2559 switch (ar
->state
) {
2560 case ATH10K_STATE_ON
:
2561 ar
->state
= ATH10K_STATE_RESTARTING
;
2563 ath10k_scan_finish(ar
);
2564 ieee80211_restart_hw(ar
->hw
);
2566 case ATH10K_STATE_OFF
:
2567 /* this can happen if driver is being unloaded
2568 * or if the crash happens during FW probing
2570 ath10k_warn(ar
, "cannot restart a device that hasn't been started\n");
2572 case ATH10K_STATE_RESTARTING
:
2573 /* hw restart might be requested from multiple places */
2575 case ATH10K_STATE_RESTARTED
:
2576 ar
->state
= ATH10K_STATE_WEDGED
;
2578 case ATH10K_STATE_WEDGED
:
2579 ath10k_warn(ar
, "device is wedged, will not restart\n");
2581 case ATH10K_STATE_UTF
:
2582 ath10k_warn(ar
, "firmware restart in UTF mode not supported\n");
2586 mutex_unlock(&ar
->conf_mutex
);
2588 ret
= ath10k_coredump_submit(ar
);
2590 ath10k_warn(ar
, "failed to send firmware crash dump via devcoredump: %d",
2593 complete(&ar
->driver_recovery
);
2596 static void ath10k_core_set_coverage_class_work(struct work_struct
*work
)
2598 struct ath10k
*ar
= container_of(work
, struct ath10k
,
2599 set_coverage_class_work
);
2601 if (ar
->hw_params
.hw_ops
->set_coverage_class
)
2602 ar
->hw_params
.hw_ops
->set_coverage_class(ar
, -1);
2605 static int ath10k_core_init_firmware_features(struct ath10k
*ar
)
2607 struct ath10k_fw_file
*fw_file
= &ar
->normal_mode_fw
.fw_file
;
2610 if (test_bit(ATH10K_FW_FEATURE_WMI_10_2
, fw_file
->fw_features
) &&
2611 !test_bit(ATH10K_FW_FEATURE_WMI_10X
, fw_file
->fw_features
)) {
2612 ath10k_err(ar
, "feature bits corrupted: 10.2 feature requires 10.x feature to be set as well");
2616 if (fw_file
->wmi_op_version
>= ATH10K_FW_WMI_OP_VERSION_MAX
) {
2617 ath10k_err(ar
, "unsupported WMI OP version (max %d): %d\n",
2618 ATH10K_FW_WMI_OP_VERSION_MAX
, fw_file
->wmi_op_version
);
2622 ar
->wmi
.rx_decap_mode
= ATH10K_HW_TXRX_NATIVE_WIFI
;
2623 switch (ath10k_cryptmode_param
) {
2624 case ATH10K_CRYPT_MODE_HW
:
2625 clear_bit(ATH10K_FLAG_RAW_MODE
, &ar
->dev_flags
);
2626 clear_bit(ATH10K_FLAG_HW_CRYPTO_DISABLED
, &ar
->dev_flags
);
2628 case ATH10K_CRYPT_MODE_SW
:
2629 if (!test_bit(ATH10K_FW_FEATURE_RAW_MODE_SUPPORT
,
2630 fw_file
->fw_features
)) {
2631 ath10k_err(ar
, "cryptmode > 0 requires raw mode support from firmware");
2635 set_bit(ATH10K_FLAG_RAW_MODE
, &ar
->dev_flags
);
2636 set_bit(ATH10K_FLAG_HW_CRYPTO_DISABLED
, &ar
->dev_flags
);
2639 ath10k_info(ar
, "invalid cryptmode: %d\n",
2640 ath10k_cryptmode_param
);
2644 ar
->htt
.max_num_amsdu
= ATH10K_HTT_MAX_NUM_AMSDU_DEFAULT
;
2645 ar
->htt
.max_num_ampdu
= ATH10K_HTT_MAX_NUM_AMPDU_DEFAULT
;
2647 if (ath10k_frame_mode
== ATH10K_HW_TXRX_RAW
) {
2648 if (!test_bit(ATH10K_FW_FEATURE_RAW_MODE_SUPPORT
,
2649 fw_file
->fw_features
)) {
2650 ath10k_err(ar
, "rawmode = 1 requires support from firmware");
2653 set_bit(ATH10K_FLAG_RAW_MODE
, &ar
->dev_flags
);
2656 if (test_bit(ATH10K_FLAG_RAW_MODE
, &ar
->dev_flags
)) {
2657 ar
->wmi
.rx_decap_mode
= ATH10K_HW_TXRX_RAW
;
2661 * Firmware A-MSDU aggregation breaks with RAW Tx encap mode
2662 * and causes enormous performance issues (malformed frames,
2665 * Disabling A-MSDU makes RAW mode stable with heavy traffic
2666 * albeit a bit slower compared to regular operation.
2668 ar
->htt
.max_num_amsdu
= 1;
2671 /* Backwards compatibility for firmwares without
2672 * ATH10K_FW_IE_WMI_OP_VERSION.
2674 if (fw_file
->wmi_op_version
== ATH10K_FW_WMI_OP_VERSION_UNSET
) {
2675 if (test_bit(ATH10K_FW_FEATURE_WMI_10X
, fw_file
->fw_features
)) {
2676 if (test_bit(ATH10K_FW_FEATURE_WMI_10_2
,
2677 fw_file
->fw_features
))
2678 fw_file
->wmi_op_version
= ATH10K_FW_WMI_OP_VERSION_10_2
;
2680 fw_file
->wmi_op_version
= ATH10K_FW_WMI_OP_VERSION_10_1
;
2682 fw_file
->wmi_op_version
= ATH10K_FW_WMI_OP_VERSION_MAIN
;
2686 switch (fw_file
->wmi_op_version
) {
2687 case ATH10K_FW_WMI_OP_VERSION_MAIN
:
2688 max_num_peers
= TARGET_NUM_PEERS
;
2689 ar
->max_num_stations
= TARGET_NUM_STATIONS
;
2690 ar
->max_num_vdevs
= TARGET_NUM_VDEVS
;
2691 ar
->htt
.max_num_pending_tx
= TARGET_NUM_MSDU_DESC
;
2692 ar
->fw_stats_req_mask
= WMI_STAT_PDEV
| WMI_STAT_VDEV
|
2694 ar
->max_spatial_stream
= WMI_MAX_SPATIAL_STREAM
;
2696 case ATH10K_FW_WMI_OP_VERSION_10_1
:
2697 case ATH10K_FW_WMI_OP_VERSION_10_2
:
2698 case ATH10K_FW_WMI_OP_VERSION_10_2_4
:
2699 if (ath10k_peer_stats_enabled(ar
)) {
2700 max_num_peers
= TARGET_10X_TX_STATS_NUM_PEERS
;
2701 ar
->max_num_stations
= TARGET_10X_TX_STATS_NUM_STATIONS
;
2703 max_num_peers
= TARGET_10X_NUM_PEERS
;
2704 ar
->max_num_stations
= TARGET_10X_NUM_STATIONS
;
2706 ar
->max_num_vdevs
= TARGET_10X_NUM_VDEVS
;
2707 ar
->htt
.max_num_pending_tx
= TARGET_10X_NUM_MSDU_DESC
;
2708 ar
->fw_stats_req_mask
= WMI_STAT_PEER
;
2709 ar
->max_spatial_stream
= WMI_MAX_SPATIAL_STREAM
;
2711 case ATH10K_FW_WMI_OP_VERSION_TLV
:
2712 max_num_peers
= TARGET_TLV_NUM_PEERS
;
2713 ar
->max_num_stations
= TARGET_TLV_NUM_STATIONS
;
2714 ar
->max_num_vdevs
= TARGET_TLV_NUM_VDEVS
;
2715 ar
->max_num_tdls_vdevs
= TARGET_TLV_NUM_TDLS_VDEVS
;
2716 if (ar
->hif
.bus
== ATH10K_BUS_SDIO
)
2717 ar
->htt
.max_num_pending_tx
=
2718 TARGET_TLV_NUM_MSDU_DESC_HL
;
2720 ar
->htt
.max_num_pending_tx
= TARGET_TLV_NUM_MSDU_DESC
;
2721 ar
->wow
.max_num_patterns
= TARGET_TLV_NUM_WOW_PATTERNS
;
2722 ar
->fw_stats_req_mask
= WMI_TLV_STAT_PDEV
| WMI_TLV_STAT_VDEV
|
2723 WMI_TLV_STAT_PEER
| WMI_TLV_STAT_PEER_EXTD
;
2724 ar
->max_spatial_stream
= WMI_MAX_SPATIAL_STREAM
;
2725 ar
->wmi
.mgmt_max_num_pending_tx
= TARGET_TLV_MGMT_NUM_MSDU_DESC
;
2727 case ATH10K_FW_WMI_OP_VERSION_10_4
:
2728 max_num_peers
= TARGET_10_4_NUM_PEERS
;
2729 ar
->max_num_stations
= TARGET_10_4_NUM_STATIONS
;
2730 ar
->num_active_peers
= TARGET_10_4_ACTIVE_PEERS
;
2731 ar
->max_num_vdevs
= TARGET_10_4_NUM_VDEVS
;
2732 ar
->num_tids
= TARGET_10_4_TGT_NUM_TIDS
;
2733 ar
->fw_stats_req_mask
= WMI_10_4_STAT_PEER
|
2734 WMI_10_4_STAT_PEER_EXTD
|
2735 WMI_10_4_STAT_VDEV_EXTD
;
2736 ar
->max_spatial_stream
= ar
->hw_params
.max_spatial_stream
;
2737 ar
->max_num_tdls_vdevs
= TARGET_10_4_NUM_TDLS_VDEVS
;
2739 if (test_bit(ATH10K_FW_FEATURE_PEER_FLOW_CONTROL
,
2740 fw_file
->fw_features
))
2741 ar
->htt
.max_num_pending_tx
= TARGET_10_4_NUM_MSDU_DESC_PFC
;
2743 ar
->htt
.max_num_pending_tx
= TARGET_10_4_NUM_MSDU_DESC
;
2745 case ATH10K_FW_WMI_OP_VERSION_UNSET
:
2746 case ATH10K_FW_WMI_OP_VERSION_MAX
:
2752 if (ar
->hw_params
.num_peers
)
2753 ar
->max_num_peers
= ar
->hw_params
.num_peers
;
2755 ar
->max_num_peers
= max_num_peers
;
2757 /* Backwards compatibility for firmwares without
2758 * ATH10K_FW_IE_HTT_OP_VERSION.
2760 if (fw_file
->htt_op_version
== ATH10K_FW_HTT_OP_VERSION_UNSET
) {
2761 switch (fw_file
->wmi_op_version
) {
2762 case ATH10K_FW_WMI_OP_VERSION_MAIN
:
2763 fw_file
->htt_op_version
= ATH10K_FW_HTT_OP_VERSION_MAIN
;
2765 case ATH10K_FW_WMI_OP_VERSION_10_1
:
2766 case ATH10K_FW_WMI_OP_VERSION_10_2
:
2767 case ATH10K_FW_WMI_OP_VERSION_10_2_4
:
2768 fw_file
->htt_op_version
= ATH10K_FW_HTT_OP_VERSION_10_1
;
2770 case ATH10K_FW_WMI_OP_VERSION_TLV
:
2771 fw_file
->htt_op_version
= ATH10K_FW_HTT_OP_VERSION_TLV
;
2773 case ATH10K_FW_WMI_OP_VERSION_10_4
:
2774 case ATH10K_FW_WMI_OP_VERSION_UNSET
:
2775 case ATH10K_FW_WMI_OP_VERSION_MAX
:
2776 ath10k_err(ar
, "htt op version not found from fw meta data");
2784 static int ath10k_core_reset_rx_filter(struct ath10k
*ar
)
2790 const u8
*vdev_addr
;
2793 vdev_type
= WMI_VDEV_TYPE_STA
;
2794 vdev_subtype
= ath10k_wmi_get_vdev_subtype(ar
, WMI_VDEV_SUBTYPE_NONE
);
2795 vdev_addr
= ar
->mac_addr
;
2797 ret
= ath10k_wmi_vdev_create(ar
, vdev_id
, vdev_type
, vdev_subtype
,
2800 ath10k_err(ar
, "failed to create dummy vdev: %d\n", ret
);
2804 ret
= ath10k_wmi_vdev_delete(ar
, vdev_id
);
2806 ath10k_err(ar
, "failed to delete dummy vdev: %d\n", ret
);
2810 /* WMI and HTT may use separate HIF pipes and are not guaranteed to be
2811 * serialized properly implicitly.
2813 * Moreover (most) WMI commands have no explicit acknowledges. It is
2814 * possible to infer it implicitly by poking firmware with echo
2815 * command - getting a reply means all preceding comments have been
2816 * (mostly) processed.
2818 * In case of vdev create/delete this is sufficient.
2820 * Without this it's possible to end up with a race when HTT Rx ring is
2821 * started before vdev create/delete hack is complete allowing a short
2822 * window of opportunity to receive (and Tx ACK) a bunch of frames.
2824 ret
= ath10k_wmi_barrier(ar
);
2826 ath10k_err(ar
, "failed to ping firmware: %d\n", ret
);
2833 static int ath10k_core_compat_services(struct ath10k
*ar
)
2835 struct ath10k_fw_file
*fw_file
= &ar
->normal_mode_fw
.fw_file
;
2837 /* all 10.x firmware versions support thermal throttling but don't
2838 * advertise the support via service flags so we have to hardcode
2841 switch (fw_file
->wmi_op_version
) {
2842 case ATH10K_FW_WMI_OP_VERSION_10_1
:
2843 case ATH10K_FW_WMI_OP_VERSION_10_2
:
2844 case ATH10K_FW_WMI_OP_VERSION_10_2_4
:
2845 case ATH10K_FW_WMI_OP_VERSION_10_4
:
2846 set_bit(WMI_SERVICE_THERM_THROT
, ar
->wmi
.svc_map
);
2855 #define TGT_IRAM_READ_PER_ITR (8 * 1024)
2857 static int ath10k_core_copy_target_iram(struct ath10k
*ar
)
2859 const struct ath10k_hw_mem_layout
*hw_mem
;
2860 const struct ath10k_mem_region
*tmp
, *mem_region
= NULL
;
2865 u32 len
, remaining_len
;
2867 /* copy target iram feature must work also when
2868 * ATH10K_FW_CRASH_DUMP_RAM_DATA is disabled, so
2869 * _ath10k_coredump_get_mem_layout() to accomplist that
2871 hw_mem
= _ath10k_coredump_get_mem_layout(ar
);
2873 /* if CONFIG_DEV_COREDUMP is disabled we get NULL, then
2874 * just silently disable the feature by doing nothing
2878 for (i
= 0; i
< hw_mem
->region_table
.size
; i
++) {
2879 tmp
= &hw_mem
->region_table
.regions
[i
];
2880 if (tmp
->type
== ATH10K_MEM_REGION_TYPE_REG
) {
2889 for (i
= 0; i
< ar
->wmi
.num_mem_chunks
; i
++) {
2890 if (ar
->wmi
.mem_chunks
[i
].req_id
==
2891 WMI_IRAM_RECOVERY_HOST_MEM_REQ_ID
) {
2892 vaddr
= ar
->wmi
.mem_chunks
[i
].vaddr
;
2893 len
= ar
->wmi
.mem_chunks
[i
].len
;
2898 if (!vaddr
|| !len
) {
2899 ath10k_warn(ar
, "No allocated memory for IRAM back up");
2903 len
= (len
< mem_region
->len
) ? len
: mem_region
->len
;
2904 paddr
= mem_region
->start
;
2905 num_read_itr
= len
/ TGT_IRAM_READ_PER_ITR
;
2906 remaining_len
= len
% TGT_IRAM_READ_PER_ITR
;
2907 for (i
= 0; i
< num_read_itr
; i
++) {
2908 ret
= ath10k_hif_diag_read(ar
, paddr
, vaddr
,
2909 TGT_IRAM_READ_PER_ITR
);
2911 ath10k_warn(ar
, "failed to copy firmware IRAM contents: %d",
2916 paddr
+= TGT_IRAM_READ_PER_ITR
;
2917 vaddr
+= TGT_IRAM_READ_PER_ITR
;
2920 if (remaining_len
) {
2921 ret
= ath10k_hif_diag_read(ar
, paddr
, vaddr
, remaining_len
);
2923 ath10k_warn(ar
, "failed to copy firmware IRAM contents: %d",
2929 ath10k_dbg(ar
, ATH10K_DBG_BOOT
, "target IRAM back up completed\n");
2934 int ath10k_core_start(struct ath10k
*ar
, enum ath10k_firmware_mode mode
,
2935 const struct ath10k_fw_components
*fw
)
2940 lockdep_assert_held(&ar
->conf_mutex
);
2942 clear_bit(ATH10K_FLAG_CRASH_FLUSH
, &ar
->dev_flags
);
2944 ar
->running_fw
= fw
;
2946 if (!test_bit(ATH10K_FW_FEATURE_NON_BMI
,
2947 ar
->running_fw
->fw_file
.fw_features
)) {
2948 ath10k_bmi_start(ar
);
2950 /* Enable hardware clock to speed up firmware download */
2951 if (ar
->hw_params
.hw_ops
->enable_pll_clk
) {
2952 status
= ar
->hw_params
.hw_ops
->enable_pll_clk(ar
);
2953 ath10k_dbg(ar
, ATH10K_DBG_BOOT
, "boot enable pll ret %d\n",
2957 if (ath10k_init_configure_target(ar
)) {
2962 status
= ath10k_download_cal_data(ar
);
2966 /* Some of qca988x solutions are having global reset issue
2967 * during target initialization. Bypassing PLL setting before
2968 * downloading firmware and letting the SoC run on REF_CLK is
2969 * fixing the problem. Corresponding firmware change is also
2970 * needed to set the clock source once the target is
2973 if (test_bit(ATH10K_FW_FEATURE_SUPPORTS_SKIP_CLOCK_INIT
,
2974 ar
->running_fw
->fw_file
.fw_features
)) {
2975 status
= ath10k_bmi_write32(ar
, hi_skip_clock_init
, 1);
2977 ath10k_err(ar
, "could not write to skip_clock_init: %d\n",
2983 status
= ath10k_download_fw(ar
);
2987 status
= ath10k_init_uart(ar
);
2991 if (ar
->hif
.bus
== ATH10K_BUS_SDIO
) {
2992 status
= ath10k_init_sdio(ar
, mode
);
2994 ath10k_err(ar
, "failed to init SDIO: %d\n", status
);
3000 ar
->htc
.htc_ops
.target_send_suspend_complete
=
3001 ath10k_send_suspend_complete
;
3003 status
= ath10k_htc_init(ar
);
3005 ath10k_err(ar
, "could not init HTC (%d)\n", status
);
3009 if (!test_bit(ATH10K_FW_FEATURE_NON_BMI
,
3010 ar
->running_fw
->fw_file
.fw_features
)) {
3011 status
= ath10k_bmi_done(ar
);
3016 status
= ath10k_wmi_attach(ar
);
3018 ath10k_err(ar
, "WMI attach failed: %d\n", status
);
3022 status
= ath10k_htt_init(ar
);
3024 ath10k_err(ar
, "failed to init htt: %d\n", status
);
3025 goto err_wmi_detach
;
3028 status
= ath10k_htt_tx_start(&ar
->htt
);
3030 ath10k_err(ar
, "failed to alloc htt tx: %d\n", status
);
3031 goto err_wmi_detach
;
3034 /* If firmware indicates Full Rx Reorder support it must be used in a
3035 * slightly different manner. Let HTT code know.
3037 ar
->htt
.rx_ring
.in_ord_rx
= !!(test_bit(WMI_SERVICE_RX_FULL_REORDER
,
3040 status
= ath10k_htt_rx_alloc(&ar
->htt
);
3042 ath10k_err(ar
, "failed to alloc htt rx: %d\n", status
);
3043 goto err_htt_tx_detach
;
3046 status
= ath10k_hif_start(ar
);
3048 ath10k_err(ar
, "could not start HIF: %d\n", status
);
3049 goto err_htt_rx_detach
;
3052 status
= ath10k_htc_wait_target(&ar
->htc
);
3054 ath10k_err(ar
, "failed to connect to HTC: %d\n", status
);
3058 status
= ath10k_hif_start_post(ar
);
3060 ath10k_err(ar
, "failed to swap mailbox: %d\n", status
);
3064 if (mode
== ATH10K_FIRMWARE_MODE_NORMAL
) {
3065 status
= ath10k_htt_connect(&ar
->htt
);
3067 ath10k_err(ar
, "failed to connect htt (%d)\n", status
);
3072 status
= ath10k_wmi_connect(ar
);
3074 ath10k_err(ar
, "could not connect wmi: %d\n", status
);
3078 status
= ath10k_htc_start(&ar
->htc
);
3080 ath10k_err(ar
, "failed to start htc: %d\n", status
);
3084 if (mode
== ATH10K_FIRMWARE_MODE_NORMAL
) {
3085 status
= ath10k_wmi_wait_for_service_ready(ar
);
3087 ath10k_warn(ar
, "wmi service ready event not received");
3092 ath10k_dbg(ar
, ATH10K_DBG_BOOT
, "firmware %s booted\n",
3093 ar
->hw
->wiphy
->fw_version
);
3095 if (test_bit(ATH10K_FW_FEATURE_IRAM_RECOVERY
,
3096 ar
->running_fw
->fw_file
.fw_features
)) {
3097 status
= ath10k_core_copy_target_iram(ar
);
3099 ath10k_warn(ar
, "failed to copy target iram contents: %d",
3105 if (test_bit(WMI_SERVICE_EXT_RES_CFG_SUPPORT
, ar
->wmi
.svc_map
) &&
3106 mode
== ATH10K_FIRMWARE_MODE_NORMAL
) {
3108 if (ath10k_peer_stats_enabled(ar
))
3109 val
= WMI_10_4_PEER_STATS
;
3111 /* Enable vdev stats by default */
3112 val
|= WMI_10_4_VDEV_STATS
;
3114 if (test_bit(WMI_SERVICE_BSS_CHANNEL_INFO_64
, ar
->wmi
.svc_map
))
3115 val
|= WMI_10_4_BSS_CHANNEL_INFO_64
;
3117 ath10k_core_fetch_btcoex_dt(ar
);
3119 /* 10.4 firmware supports BT-Coex without reloading firmware
3120 * via pdev param. To support Bluetooth coexistence pdev param,
3121 * WMI_COEX_GPIO_SUPPORT of extended resource config should be
3124 * We can still enable BTCOEX if firmware has the support
3125 * even though btceox_support value is
3126 * ATH10K_DT_BTCOEX_NOT_FOUND
3129 if (test_bit(WMI_SERVICE_COEX_GPIO
, ar
->wmi
.svc_map
) &&
3130 test_bit(ATH10K_FW_FEATURE_BTCOEX_PARAM
,
3131 ar
->running_fw
->fw_file
.fw_features
) &&
3133 val
|= WMI_10_4_COEX_GPIO_SUPPORT
;
3135 if (test_bit(WMI_SERVICE_TDLS_EXPLICIT_MODE_ONLY
,
3137 val
|= WMI_10_4_TDLS_EXPLICIT_MODE_ONLY
;
3139 if (test_bit(WMI_SERVICE_TDLS_UAPSD_BUFFER_STA
,
3141 val
|= WMI_10_4_TDLS_UAPSD_BUFFER_STA
;
3143 if (test_bit(WMI_SERVICE_TX_DATA_ACK_RSSI
,
3145 val
|= WMI_10_4_TX_DATA_ACK_RSSI
;
3147 if (test_bit(WMI_SERVICE_REPORT_AIRTIME
, ar
->wmi
.svc_map
))
3148 val
|= WMI_10_4_REPORT_AIRTIME
;
3150 if (test_bit(WMI_SERVICE_EXT_PEER_TID_CONFIGS_SUPPORT
,
3152 val
|= WMI_10_4_EXT_PEER_TID_CONFIGS_SUPPORT
;
3154 status
= ath10k_mac_ext_resource_config(ar
, val
);
3157 "failed to send ext resource cfg command : %d\n",
3163 status
= ath10k_wmi_cmd_init(ar
);
3165 ath10k_err(ar
, "could not send WMI init command (%d)\n",
3170 status
= ath10k_wmi_wait_for_unified_ready(ar
);
3172 ath10k_err(ar
, "wmi unified ready event not received\n");
3176 status
= ath10k_core_compat_services(ar
);
3178 ath10k_err(ar
, "compat services failed: %d\n", status
);
3182 status
= ath10k_wmi_pdev_set_base_macaddr(ar
, ar
->mac_addr
);
3183 if (status
&& status
!= -EOPNOTSUPP
) {
3185 "failed to set base mac address: %d\n", status
);
3189 /* Some firmware revisions do not properly set up hardware rx filter
3192 * A known example from QCA9880 and 10.2.4 is that MAC_PCU_ADDR1_MASK
3193 * is filled with 0s instead of 1s allowing HW to respond with ACKs to
3194 * any frames that matches MAC_PCU_RX_FILTER which is also
3195 * misconfigured to accept anything.
3197 * The ADDR1 is programmed using internal firmware structure field and
3198 * can't be (easily/sanely) reached from the driver explicitly. It is
3199 * possible to implicitly make it correct by creating a dummy vdev and
3202 if (ar
->hw_params
.hw_filter_reset_required
&&
3203 mode
== ATH10K_FIRMWARE_MODE_NORMAL
) {
3204 status
= ath10k_core_reset_rx_filter(ar
);
3207 "failed to reset rx filter: %d\n", status
);
3212 status
= ath10k_htt_rx_ring_refill(ar
);
3214 ath10k_err(ar
, "failed to refill htt rx ring: %d\n", status
);
3218 if (ar
->max_num_vdevs
>= 64)
3219 ar
->free_vdev_map
= 0xFFFFFFFFFFFFFFFFLL
;
3221 ar
->free_vdev_map
= (1LL << ar
->max_num_vdevs
) - 1;
3223 INIT_LIST_HEAD(&ar
->arvifs
);
3225 /* we don't care about HTT in UTF mode */
3226 if (mode
== ATH10K_FIRMWARE_MODE_NORMAL
) {
3227 status
= ath10k_htt_setup(&ar
->htt
);
3229 ath10k_err(ar
, "failed to setup htt: %d\n", status
);
3234 status
= ath10k_debug_start(ar
);
3238 status
= ath10k_hif_set_target_log_mode(ar
, fw_diag_log
);
3239 if (status
&& status
!= -EOPNOTSUPP
) {
3240 ath10k_warn(ar
, "set target log mode failed: %d\n", status
);
3244 status
= ath10k_leds_start(ar
);
3251 ath10k_hif_stop(ar
);
3253 ath10k_htt_rx_free(&ar
->htt
);
3255 ath10k_htt_tx_free(&ar
->htt
);
3257 ath10k_wmi_detach(ar
);
3261 EXPORT_SYMBOL(ath10k_core_start
);
3263 int ath10k_wait_for_suspend(struct ath10k
*ar
, u32 suspend_opt
)
3266 unsigned long time_left
;
3268 reinit_completion(&ar
->target_suspend
);
3270 ret
= ath10k_wmi_pdev_suspend_target(ar
, suspend_opt
);
3272 ath10k_warn(ar
, "could not suspend target (%d)\n", ret
);
3276 time_left
= wait_for_completion_timeout(&ar
->target_suspend
, 1 * HZ
);
3279 ath10k_warn(ar
, "suspend timed out - target pause event never came\n");
3286 void ath10k_core_stop(struct ath10k
*ar
)
3288 lockdep_assert_held(&ar
->conf_mutex
);
3289 ath10k_debug_stop(ar
);
3291 /* try to suspend target */
3292 if (ar
->state
!= ATH10K_STATE_RESTARTING
&&
3293 ar
->state
!= ATH10K_STATE_UTF
)
3294 ath10k_wait_for_suspend(ar
, WMI_PDEV_SUSPEND_AND_DISABLE_INTR
);
3296 ath10k_hif_stop(ar
);
3297 ath10k_htt_tx_stop(&ar
->htt
);
3298 ath10k_htt_rx_free(&ar
->htt
);
3299 ath10k_wmi_detach(ar
);
3301 ar
->id
.bmi_ids_valid
= false;
3303 EXPORT_SYMBOL(ath10k_core_stop
);
3305 /* mac80211 manages fw/hw initialization through start/stop hooks. However in
3306 * order to know what hw capabilities should be advertised to mac80211 it is
3307 * necessary to load the firmware (and tear it down immediately since start
3308 * hook will try to init it again) before registering
3310 static int ath10k_core_probe_fw(struct ath10k
*ar
)
3312 struct bmi_target_info target_info
;
3315 ret
= ath10k_hif_power_up(ar
, ATH10K_FIRMWARE_MODE_NORMAL
);
3317 ath10k_err(ar
, "could not power on hif bus (%d)\n", ret
);
3321 switch (ar
->hif
.bus
) {
3322 case ATH10K_BUS_SDIO
:
3323 memset(&target_info
, 0, sizeof(target_info
));
3324 ret
= ath10k_bmi_get_target_info_sdio(ar
, &target_info
);
3326 ath10k_err(ar
, "could not get target info (%d)\n", ret
);
3327 goto err_power_down
;
3329 ar
->target_version
= target_info
.version
;
3330 ar
->hw
->wiphy
->hw_version
= target_info
.version
;
3332 case ATH10K_BUS_PCI
:
3333 case ATH10K_BUS_AHB
:
3334 case ATH10K_BUS_USB
:
3335 memset(&target_info
, 0, sizeof(target_info
));
3336 ret
= ath10k_bmi_get_target_info(ar
, &target_info
);
3338 ath10k_err(ar
, "could not get target info (%d)\n", ret
);
3339 goto err_power_down
;
3341 ar
->target_version
= target_info
.version
;
3342 ar
->hw
->wiphy
->hw_version
= target_info
.version
;
3344 case ATH10K_BUS_SNOC
:
3345 memset(&target_info
, 0, sizeof(target_info
));
3346 ret
= ath10k_hif_get_target_info(ar
, &target_info
);
3348 ath10k_err(ar
, "could not get target info (%d)\n", ret
);
3349 goto err_power_down
;
3351 ar
->target_version
= target_info
.version
;
3352 ar
->hw
->wiphy
->hw_version
= target_info
.version
;
3355 ath10k_err(ar
, "incorrect hif bus type: %d\n", ar
->hif
.bus
);
3358 ret
= ath10k_init_hw_params(ar
);
3360 ath10k_err(ar
, "could not get hw params (%d)\n", ret
);
3361 goto err_power_down
;
3364 ret
= ath10k_core_fetch_firmware_files(ar
);
3366 ath10k_err(ar
, "could not fetch firmware files (%d)\n", ret
);
3367 goto err_power_down
;
3370 BUILD_BUG_ON(sizeof(ar
->hw
->wiphy
->fw_version
) !=
3371 sizeof(ar
->normal_mode_fw
.fw_file
.fw_version
));
3372 memcpy(ar
->hw
->wiphy
->fw_version
, ar
->normal_mode_fw
.fw_file
.fw_version
,
3373 sizeof(ar
->hw
->wiphy
->fw_version
));
3375 ath10k_debug_print_hwfw_info(ar
);
3377 if (!test_bit(ATH10K_FW_FEATURE_NON_BMI
,
3378 ar
->normal_mode_fw
.fw_file
.fw_features
)) {
3379 ret
= ath10k_core_pre_cal_download(ar
);
3381 /* pre calibration data download is not necessary
3382 * for all the chipsets. Ignore failures and continue.
3384 ath10k_dbg(ar
, ATH10K_DBG_BOOT
,
3385 "could not load pre cal data: %d\n", ret
);
3388 ret
= ath10k_core_get_board_id_from_otp(ar
);
3389 if (ret
&& ret
!= -EOPNOTSUPP
) {
3390 ath10k_err(ar
, "failed to get board id from otp: %d\n",
3392 goto err_free_firmware_files
;
3395 ret
= ath10k_core_check_smbios(ar
);
3397 ath10k_dbg(ar
, ATH10K_DBG_BOOT
, "SMBIOS bdf variant name not set.\n");
3399 ret
= ath10k_core_check_dt(ar
);
3401 ath10k_dbg(ar
, ATH10K_DBG_BOOT
, "DT bdf variant name not set.\n");
3403 ret
= ath10k_core_fetch_board_file(ar
, ATH10K_BD_IE_BOARD
);
3405 ath10k_err(ar
, "failed to fetch board file: %d\n", ret
);
3406 goto err_free_firmware_files
;
3409 ath10k_debug_print_board_info(ar
);
3412 device_get_mac_address(ar
->dev
, ar
->mac_addr
);
3414 ret
= ath10k_core_init_firmware_features(ar
);
3416 ath10k_err(ar
, "fatal problem with firmware features: %d\n",
3418 goto err_free_firmware_files
;
3421 if (!test_bit(ATH10K_FW_FEATURE_NON_BMI
,
3422 ar
->normal_mode_fw
.fw_file
.fw_features
)) {
3423 ret
= ath10k_swap_code_seg_init(ar
,
3424 &ar
->normal_mode_fw
.fw_file
);
3426 ath10k_err(ar
, "failed to initialize code swap segment: %d\n",
3428 goto err_free_firmware_files
;
3432 mutex_lock(&ar
->conf_mutex
);
3434 ret
= ath10k_core_start(ar
, ATH10K_FIRMWARE_MODE_NORMAL
,
3435 &ar
->normal_mode_fw
);
3437 ath10k_err(ar
, "could not init core (%d)\n", ret
);
3441 ath10k_debug_print_boot_info(ar
);
3442 ath10k_core_stop(ar
);
3444 mutex_unlock(&ar
->conf_mutex
);
3446 ath10k_hif_power_down(ar
);
3450 mutex_unlock(&ar
->conf_mutex
);
3452 err_free_firmware_files
:
3453 ath10k_core_free_firmware_files(ar
);
3456 ath10k_hif_power_down(ar
);
3461 static void ath10k_core_register_work(struct work_struct
*work
)
3463 struct ath10k
*ar
= container_of(work
, struct ath10k
, register_work
);
3466 /* peer stats are enabled by default */
3467 set_bit(ATH10K_FLAG_PEER_STATS
, &ar
->dev_flags
);
3469 status
= ath10k_core_probe_fw(ar
);
3471 ath10k_err(ar
, "could not probe fw (%d)\n", status
);
3475 status
= ath10k_mac_register(ar
);
3477 ath10k_err(ar
, "could not register to mac80211 (%d)\n", status
);
3478 goto err_release_fw
;
3481 status
= ath10k_coredump_register(ar
);
3483 ath10k_err(ar
, "unable to register coredump\n");
3484 goto err_unregister_mac
;
3487 status
= ath10k_debug_register(ar
);
3489 ath10k_err(ar
, "unable to initialize debugfs\n");
3490 goto err_unregister_coredump
;
3493 status
= ath10k_spectral_create(ar
);
3495 ath10k_err(ar
, "failed to initialize spectral\n");
3496 goto err_debug_destroy
;
3499 status
= ath10k_thermal_register(ar
);
3501 ath10k_err(ar
, "could not register thermal device: %d\n",
3503 goto err_spectral_destroy
;
3506 status
= ath10k_leds_register(ar
);
3508 ath10k_err(ar
, "could not register leds: %d\n",
3510 goto err_thermal_unregister
;
3513 set_bit(ATH10K_FLAG_CORE_REGISTERED
, &ar
->dev_flags
);
3516 err_thermal_unregister
:
3517 ath10k_thermal_unregister(ar
);
3518 err_spectral_destroy
:
3519 ath10k_spectral_destroy(ar
);
3521 ath10k_debug_destroy(ar
);
3522 err_unregister_coredump
:
3523 ath10k_coredump_unregister(ar
);
3525 ath10k_mac_unregister(ar
);
3527 ath10k_core_free_firmware_files(ar
);
3529 /* TODO: It's probably a good idea to release device from the driver
3530 * but calling device_release_driver() here will cause a deadlock.
3535 int ath10k_core_register(struct ath10k
*ar
,
3536 const struct ath10k_bus_params
*bus_params
)
3538 ar
->bus_param
= *bus_params
;
3540 queue_work(ar
->workqueue
, &ar
->register_work
);
3544 EXPORT_SYMBOL(ath10k_core_register
);
3546 void ath10k_core_unregister(struct ath10k
*ar
)
3548 cancel_work_sync(&ar
->register_work
);
3550 if (!test_bit(ATH10K_FLAG_CORE_REGISTERED
, &ar
->dev_flags
))
3553 ath10k_leds_unregister(ar
);
3555 ath10k_thermal_unregister(ar
);
3556 /* Stop spectral before unregistering from mac80211 to remove the
3557 * relayfs debugfs file cleanly. Otherwise the parent debugfs tree
3558 * would be already be free'd recursively, leading to a double free.
3560 ath10k_spectral_destroy(ar
);
3562 /* We must unregister from mac80211 before we stop HTC and HIF.
3563 * Otherwise we will fail to submit commands to FW and mac80211 will be
3564 * unhappy about callback failures.
3566 ath10k_mac_unregister(ar
);
3568 ath10k_testmode_destroy(ar
);
3570 ath10k_core_free_firmware_files(ar
);
3571 ath10k_core_free_board_files(ar
);
3573 ath10k_debug_unregister(ar
);
3575 EXPORT_SYMBOL(ath10k_core_unregister
);
3577 struct ath10k
*ath10k_core_create(size_t priv_size
, struct device
*dev
,
3578 enum ath10k_bus bus
,
3579 enum ath10k_hw_rev hw_rev
,
3580 const struct ath10k_hif_ops
*hif_ops
)
3585 ar
= ath10k_mac_create(priv_size
);
3589 ar
->ath_common
.priv
= ar
;
3590 ar
->ath_common
.hw
= ar
->hw
;
3592 ar
->hw_rev
= hw_rev
;
3593 ar
->hif
.ops
= hif_ops
;
3597 case ATH10K_HW_QCA988X
:
3598 case ATH10K_HW_QCA9887
:
3599 ar
->regs
= &qca988x_regs
;
3600 ar
->hw_ce_regs
= &qcax_ce_regs
;
3601 ar
->hw_values
= &qca988x_values
;
3603 case ATH10K_HW_QCA6174
:
3604 case ATH10K_HW_QCA9377
:
3605 ar
->regs
= &qca6174_regs
;
3606 ar
->hw_ce_regs
= &qcax_ce_regs
;
3607 ar
->hw_values
= &qca6174_values
;
3609 case ATH10K_HW_QCA99X0
:
3610 case ATH10K_HW_QCA9984
:
3611 ar
->regs
= &qca99x0_regs
;
3612 ar
->hw_ce_regs
= &qcax_ce_regs
;
3613 ar
->hw_values
= &qca99x0_values
;
3615 case ATH10K_HW_QCA9888
:
3616 ar
->regs
= &qca99x0_regs
;
3617 ar
->hw_ce_regs
= &qcax_ce_regs
;
3618 ar
->hw_values
= &qca9888_values
;
3620 case ATH10K_HW_QCA4019
:
3621 ar
->regs
= &qca4019_regs
;
3622 ar
->hw_ce_regs
= &qcax_ce_regs
;
3623 ar
->hw_values
= &qca4019_values
;
3625 case ATH10K_HW_WCN3990
:
3626 ar
->regs
= &wcn3990_regs
;
3627 ar
->hw_ce_regs
= &wcn3990_ce_regs
;
3628 ar
->hw_values
= &wcn3990_values
;
3631 ath10k_err(ar
, "unsupported core hardware revision %d\n",
3637 init_completion(&ar
->scan
.started
);
3638 init_completion(&ar
->scan
.completed
);
3639 init_completion(&ar
->scan
.on_channel
);
3640 init_completion(&ar
->target_suspend
);
3641 init_completion(&ar
->driver_recovery
);
3642 init_completion(&ar
->wow
.wakeup_completed
);
3644 init_completion(&ar
->install_key_done
);
3645 init_completion(&ar
->vdev_setup_done
);
3646 init_completion(&ar
->vdev_delete_done
);
3647 init_completion(&ar
->thermal
.wmi_sync
);
3648 init_completion(&ar
->bss_survey_done
);
3649 init_completion(&ar
->peer_delete_done
);
3650 init_completion(&ar
->peer_stats_info_complete
);
3652 INIT_DELAYED_WORK(&ar
->scan
.timeout
, ath10k_scan_timeout_work
);
3654 ar
->workqueue
= create_singlethread_workqueue("ath10k_wq");
3658 ar
->workqueue_aux
= create_singlethread_workqueue("ath10k_aux_wq");
3659 if (!ar
->workqueue_aux
)
3662 ar
->workqueue_tx_complete
=
3663 create_singlethread_workqueue("ath10k_tx_complete_wq");
3664 if (!ar
->workqueue_tx_complete
)
3665 goto err_free_aux_wq
;
3667 mutex_init(&ar
->conf_mutex
);
3668 mutex_init(&ar
->dump_mutex
);
3669 spin_lock_init(&ar
->data_lock
);
3671 for (int ac
= 0; ac
< IEEE80211_NUM_ACS
; ac
++)
3672 spin_lock_init(&ar
->queue_lock
[ac
]);
3674 INIT_LIST_HEAD(&ar
->peers
);
3675 init_waitqueue_head(&ar
->peer_mapping_wq
);
3676 init_waitqueue_head(&ar
->htt
.empty_tx_wq
);
3677 init_waitqueue_head(&ar
->wmi
.tx_credits_wq
);
3679 skb_queue_head_init(&ar
->htt
.rx_indication_head
);
3681 init_completion(&ar
->offchan_tx_completed
);
3682 INIT_WORK(&ar
->offchan_tx_work
, ath10k_offchan_tx_work
);
3683 skb_queue_head_init(&ar
->offchan_tx_queue
);
3685 INIT_WORK(&ar
->wmi_mgmt_tx_work
, ath10k_mgmt_over_wmi_tx_work
);
3686 skb_queue_head_init(&ar
->wmi_mgmt_tx_queue
);
3688 INIT_WORK(&ar
->register_work
, ath10k_core_register_work
);
3689 INIT_WORK(&ar
->restart_work
, ath10k_core_restart
);
3690 INIT_WORK(&ar
->set_coverage_class_work
,
3691 ath10k_core_set_coverage_class_work
);
3693 ar
->napi_dev
= alloc_netdev_dummy(0);
3695 goto err_free_tx_complete
;
3697 ret
= ath10k_coredump_create(ar
);
3699 goto err_free_netdev
;
3701 ret
= ath10k_debug_create(ar
);
3703 goto err_free_coredump
;
3708 ath10k_coredump_destroy(ar
);
3710 free_netdev(ar
->napi_dev
);
3711 err_free_tx_complete
:
3712 destroy_workqueue(ar
->workqueue_tx_complete
);
3714 destroy_workqueue(ar
->workqueue_aux
);
3716 destroy_workqueue(ar
->workqueue
);
3718 ath10k_mac_destroy(ar
);
3722 EXPORT_SYMBOL(ath10k_core_create
);
3724 void ath10k_core_destroy(struct ath10k
*ar
)
3726 destroy_workqueue(ar
->workqueue
);
3728 destroy_workqueue(ar
->workqueue_aux
);
3730 destroy_workqueue(ar
->workqueue_tx_complete
);
3732 free_netdev(ar
->napi_dev
);
3733 ath10k_debug_destroy(ar
);
3734 ath10k_coredump_destroy(ar
);
3735 ath10k_htt_tx_destroy(&ar
->htt
);
3736 ath10k_wmi_free_host_mem(ar
);
3737 ath10k_mac_destroy(ar
);
3739 EXPORT_SYMBOL(ath10k_core_destroy
);
3741 MODULE_AUTHOR("Qualcomm Atheros");
3742 MODULE_DESCRIPTION("Core module for Qualcomm Atheros 802.11ac wireless LAN cards.");
3743 MODULE_LICENSE("Dual BSD/GPL");