2 * Copyright (c) 2005-2011 Atheros Communications Inc.
3 * Copyright (c) 2011-2013 Qualcomm Atheros, Inc.
5 * Permission to use, copy, modify, and/or distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 #include <linux/module.h>
19 #include <linux/firmware.h>
21 #include <asm/byteorder.h>
34 unsigned int ath10k_debug_mask;
35 static unsigned int ath10k_cryptmode_param;
36 static bool uart_print;
40 module_param_named(debug_mask, ath10k_debug_mask, uint, 0644);
41 module_param_named(cryptmode, ath10k_cryptmode_param, uint, 0644);
42 module_param(uart_print, bool, 0644);
43 module_param(skip_otp, bool, 0644);
44 module_param(rawmode, bool, 0644);
46 MODULE_PARM_DESC(debug_mask, "Debugging mask");
47 MODULE_PARM_DESC(uart_print, "Uart target debugging");
48 MODULE_PARM_DESC(skip_otp, "Skip otp failure for calibration in testmode");
49 MODULE_PARM_DESC(cryptmode, "Crypto mode: 0-hardware, 1-software");
50 MODULE_PARM_DESC(rawmode, "Use raw 802.11 frame datapath");
52 static const struct ath10k_hw_params ath10k_hw_params_list[] = {
54 .id = QCA988X_HW_2_0_VERSION,
55 .dev_id = QCA988X_2_0_DEVICE_ID,
56 .name = "qca988x hw2.0",
57 .patch_load_addr = QCA988X_HW_2_0_PATCH_LOAD_ADDR,
59 .cc_wraparound_type = ATH10K_HW_CC_WRAP_SHIFTED_ALL,
61 .channel_counters_freq_hz = 88000,
62 .max_probe_resp_desc_thres = 0,
65 .dir = QCA988X_HW_2_0_FW_DIR,
66 .board = QCA988X_HW_2_0_BOARD_DATA_FILE,
67 .board_size = QCA988X_BOARD_DATA_SZ,
68 .board_ext_size = QCA988X_BOARD_EXT_DATA_SZ,
70 .hw_ops = &qca988x_ops,
73 .id = QCA9887_HW_1_0_VERSION,
74 .dev_id = QCA9887_1_0_DEVICE_ID,
75 .name = "qca9887 hw1.0",
76 .patch_load_addr = QCA9887_HW_1_0_PATCH_LOAD_ADDR,
78 .cc_wraparound_type = ATH10K_HW_CC_WRAP_SHIFTED_ALL,
80 .channel_counters_freq_hz = 88000,
81 .max_probe_resp_desc_thres = 0,
84 .dir = QCA9887_HW_1_0_FW_DIR,
85 .board = QCA9887_HW_1_0_BOARD_DATA_FILE,
86 .board_size = QCA9887_BOARD_DATA_SZ,
87 .board_ext_size = QCA9887_BOARD_EXT_DATA_SZ,
89 .hw_ops = &qca988x_ops,
92 .id = QCA6174_HW_2_1_VERSION,
93 .dev_id = QCA6164_2_1_DEVICE_ID,
94 .name = "qca6164 hw2.1",
95 .patch_load_addr = QCA6174_HW_2_1_PATCH_LOAD_ADDR,
98 .channel_counters_freq_hz = 88000,
99 .max_probe_resp_desc_thres = 0,
100 .cal_data_len = 8124,
102 .dir = QCA6174_HW_2_1_FW_DIR,
103 .board = QCA6174_HW_2_1_BOARD_DATA_FILE,
104 .board_size = QCA6174_BOARD_DATA_SZ,
105 .board_ext_size = QCA6174_BOARD_EXT_DATA_SZ,
107 .hw_ops = &qca988x_ops,
110 .id = QCA6174_HW_2_1_VERSION,
111 .dev_id = QCA6174_2_1_DEVICE_ID,
112 .name = "qca6174 hw2.1",
113 .patch_load_addr = QCA6174_HW_2_1_PATCH_LOAD_ADDR,
116 .channel_counters_freq_hz = 88000,
117 .max_probe_resp_desc_thres = 0,
118 .cal_data_len = 8124,
120 .dir = QCA6174_HW_2_1_FW_DIR,
121 .board = QCA6174_HW_2_1_BOARD_DATA_FILE,
122 .board_size = QCA6174_BOARD_DATA_SZ,
123 .board_ext_size = QCA6174_BOARD_EXT_DATA_SZ,
125 .hw_ops = &qca988x_ops,
128 .id = QCA6174_HW_3_0_VERSION,
129 .dev_id = QCA6174_2_1_DEVICE_ID,
130 .name = "qca6174 hw3.0",
131 .patch_load_addr = QCA6174_HW_3_0_PATCH_LOAD_ADDR,
134 .channel_counters_freq_hz = 88000,
135 .max_probe_resp_desc_thres = 0,
136 .cal_data_len = 8124,
138 .dir = QCA6174_HW_3_0_FW_DIR,
139 .board = QCA6174_HW_3_0_BOARD_DATA_FILE,
140 .board_size = QCA6174_BOARD_DATA_SZ,
141 .board_ext_size = QCA6174_BOARD_EXT_DATA_SZ,
143 .hw_ops = &qca988x_ops,
146 .id = QCA6174_HW_3_2_VERSION,
147 .dev_id = QCA6174_2_1_DEVICE_ID,
148 .name = "qca6174 hw3.2",
149 .patch_load_addr = QCA6174_HW_3_0_PATCH_LOAD_ADDR,
152 .channel_counters_freq_hz = 88000,
153 .max_probe_resp_desc_thres = 0,
154 .cal_data_len = 8124,
156 /* uses same binaries as hw3.0 */
157 .dir = QCA6174_HW_3_0_FW_DIR,
158 .board = QCA6174_HW_3_0_BOARD_DATA_FILE,
159 .board_size = QCA6174_BOARD_DATA_SZ,
160 .board_ext_size = QCA6174_BOARD_EXT_DATA_SZ,
162 .hw_ops = &qca988x_ops,
165 .id = QCA99X0_HW_2_0_DEV_VERSION,
166 .dev_id = QCA99X0_2_0_DEVICE_ID,
167 .name = "qca99x0 hw2.0",
168 .patch_load_addr = QCA99X0_HW_2_0_PATCH_LOAD_ADDR,
170 .otp_exe_param = 0x00000700,
171 .continuous_frag_desc = true,
172 .cck_rate_map_rev2 = true,
173 .channel_counters_freq_hz = 150000,
174 .max_probe_resp_desc_thres = 24,
175 .tx_chain_mask = 0xf,
176 .rx_chain_mask = 0xf,
177 .max_spatial_stream = 4,
178 .cal_data_len = 12064,
180 .dir = QCA99X0_HW_2_0_FW_DIR,
181 .board = QCA99X0_HW_2_0_BOARD_DATA_FILE,
182 .board_size = QCA99X0_BOARD_DATA_SZ,
183 .board_ext_size = QCA99X0_BOARD_EXT_DATA_SZ,
185 .sw_decrypt_mcast_mgmt = true,
186 .hw_ops = &qca99x0_ops,
189 .id = QCA9984_HW_1_0_DEV_VERSION,
190 .dev_id = QCA9984_1_0_DEVICE_ID,
191 .name = "qca9984/qca9994 hw1.0",
192 .patch_load_addr = QCA9984_HW_1_0_PATCH_LOAD_ADDR,
194 .otp_exe_param = 0x00000700,
195 .continuous_frag_desc = true,
196 .cck_rate_map_rev2 = true,
197 .channel_counters_freq_hz = 150000,
198 .max_probe_resp_desc_thres = 24,
199 .tx_chain_mask = 0xf,
200 .rx_chain_mask = 0xf,
201 .max_spatial_stream = 4,
202 .cal_data_len = 12064,
204 .dir = QCA9984_HW_1_0_FW_DIR,
205 .board = QCA9984_HW_1_0_BOARD_DATA_FILE,
206 .board_size = QCA99X0_BOARD_DATA_SZ,
207 .board_ext_size = QCA99X0_BOARD_EXT_DATA_SZ,
209 .sw_decrypt_mcast_mgmt = true,
210 .hw_ops = &qca99x0_ops,
213 .id = QCA9888_HW_2_0_DEV_VERSION,
214 .dev_id = QCA9888_2_0_DEVICE_ID,
215 .name = "qca9888 hw2.0",
216 .patch_load_addr = QCA9888_HW_2_0_PATCH_LOAD_ADDR,
218 .otp_exe_param = 0x00000700,
219 .continuous_frag_desc = true,
220 .channel_counters_freq_hz = 150000,
221 .max_probe_resp_desc_thres = 24,
224 .max_spatial_stream = 2,
225 .cal_data_len = 12064,
227 .dir = QCA9888_HW_2_0_FW_DIR,
228 .board = QCA9888_HW_2_0_BOARD_DATA_FILE,
229 .board_size = QCA99X0_BOARD_DATA_SZ,
230 .board_ext_size = QCA99X0_BOARD_EXT_DATA_SZ,
232 .sw_decrypt_mcast_mgmt = true,
233 .hw_ops = &qca99x0_ops,
236 .id = QCA9377_HW_1_0_DEV_VERSION,
237 .dev_id = QCA9377_1_0_DEVICE_ID,
238 .name = "qca9377 hw1.0",
239 .patch_load_addr = QCA9377_HW_1_0_PATCH_LOAD_ADDR,
242 .channel_counters_freq_hz = 88000,
243 .max_probe_resp_desc_thres = 0,
244 .cal_data_len = 8124,
246 .dir = QCA9377_HW_1_0_FW_DIR,
247 .board = QCA9377_HW_1_0_BOARD_DATA_FILE,
248 .board_size = QCA9377_BOARD_DATA_SZ,
249 .board_ext_size = QCA9377_BOARD_EXT_DATA_SZ,
251 .hw_ops = &qca988x_ops,
254 .id = QCA9377_HW_1_1_DEV_VERSION,
255 .dev_id = QCA9377_1_0_DEVICE_ID,
256 .name = "qca9377 hw1.1",
257 .patch_load_addr = QCA9377_HW_1_0_PATCH_LOAD_ADDR,
260 .channel_counters_freq_hz = 88000,
261 .max_probe_resp_desc_thres = 0,
262 .cal_data_len = 8124,
264 .dir = QCA9377_HW_1_0_FW_DIR,
265 .board = QCA9377_HW_1_0_BOARD_DATA_FILE,
266 .board_size = QCA9377_BOARD_DATA_SZ,
267 .board_ext_size = QCA9377_BOARD_EXT_DATA_SZ,
269 .hw_ops = &qca988x_ops,
272 .id = QCA4019_HW_1_0_DEV_VERSION,
274 .name = "qca4019 hw1.0",
275 .patch_load_addr = QCA4019_HW_1_0_PATCH_LOAD_ADDR,
277 .cc_wraparound_type = ATH10K_HW_CC_WRAP_SHIFTED_EACH,
278 .otp_exe_param = 0x0010000,
279 .continuous_frag_desc = true,
280 .cck_rate_map_rev2 = true,
281 .channel_counters_freq_hz = 125000,
282 .max_probe_resp_desc_thres = 24,
283 .tx_chain_mask = 0x3,
284 .rx_chain_mask = 0x3,
285 .max_spatial_stream = 2,
286 .cal_data_len = 12064,
288 .dir = QCA4019_HW_1_0_FW_DIR,
289 .board = QCA4019_HW_1_0_BOARD_DATA_FILE,
290 .board_size = QCA4019_BOARD_DATA_SZ,
291 .board_ext_size = QCA4019_BOARD_EXT_DATA_SZ,
293 .sw_decrypt_mcast_mgmt = true,
294 .hw_ops = &qca99x0_ops,
298 static const char *const ath10k_core_fw_feature_str[] = {
299 [ATH10K_FW_FEATURE_EXT_WMI_MGMT_RX] = "wmi-mgmt-rx",
300 [ATH10K_FW_FEATURE_WMI_10X] = "wmi-10.x",
301 [ATH10K_FW_FEATURE_HAS_WMI_MGMT_TX] = "has-wmi-mgmt-tx",
302 [ATH10K_FW_FEATURE_NO_P2P] = "no-p2p",
303 [ATH10K_FW_FEATURE_WMI_10_2] = "wmi-10.2",
304 [ATH10K_FW_FEATURE_MULTI_VIF_PS_SUPPORT] = "multi-vif-ps",
305 [ATH10K_FW_FEATURE_WOWLAN_SUPPORT] = "wowlan",
306 [ATH10K_FW_FEATURE_IGNORE_OTP_RESULT] = "ignore-otp",
307 [ATH10K_FW_FEATURE_NO_NWIFI_DECAP_4ADDR_PADDING] = "no-4addr-pad",
308 [ATH10K_FW_FEATURE_SUPPORTS_SKIP_CLOCK_INIT] = "skip-clock-init",
309 [ATH10K_FW_FEATURE_RAW_MODE_SUPPORT] = "raw-mode",
310 [ATH10K_FW_FEATURE_SUPPORTS_ADAPTIVE_CCA] = "adaptive-cca",
311 [ATH10K_FW_FEATURE_MFP_SUPPORT] = "mfp",
312 [ATH10K_FW_FEATURE_PEER_FLOW_CONTROL] = "peer-flow-ctrl",
313 [ATH10K_FW_FEATURE_BTCOEX_PARAM] = "btcoex-param",
314 [ATH10K_FW_FEATURE_SKIP_NULL_FUNC_WAR] = "skip-null-func-war",
317 static unsigned int ath10k_core_get_fw_feature_str(char *buf,
319 enum ath10k_fw_features feat)
321 /* make sure that ath10k_core_fw_feature_str[] gets updated */
322 BUILD_BUG_ON(ARRAY_SIZE(ath10k_core_fw_feature_str) !=
323 ATH10K_FW_FEATURE_COUNT);
325 if (feat >= ARRAY_SIZE(ath10k_core_fw_feature_str) ||
326 WARN_ON(!ath10k_core_fw_feature_str[feat])) {
327 return scnprintf(buf, buf_len, "bit%d", feat);
330 return scnprintf(buf, buf_len, "%s", ath10k_core_fw_feature_str[feat]);
333 void ath10k_core_get_fw_features_str(struct ath10k *ar,
337 unsigned int len = 0;
340 for (i = 0; i < ATH10K_FW_FEATURE_COUNT; i++) {
341 if (test_bit(i, ar->normal_mode_fw.fw_file.fw_features)) {
343 len += scnprintf(buf + len, buf_len - len, ",");
345 len += ath10k_core_get_fw_feature_str(buf + len,
352 static void ath10k_send_suspend_complete(struct ath10k *ar)
354 ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot suspend complete\n");
356 complete(&ar->target_suspend);
359 static int ath10k_init_configure_target(struct ath10k *ar)
364 /* tell target which HTC version it is used*/
365 ret = ath10k_bmi_write32(ar, hi_app_host_interest,
366 HTC_PROTOCOL_VERSION);
368 ath10k_err(ar, "settings HTC version failed\n");
372 /* set the firmware mode to STA/IBSS/AP */
373 ret = ath10k_bmi_read32(ar, hi_option_flag, ¶m_host);
375 ath10k_err(ar, "setting firmware mode (1/2) failed\n");
379 /* TODO following parameters need to be re-visited. */
381 param_host |= (1 << HI_OPTION_NUM_DEV_SHIFT);
383 /* FIXME: Why FW_MODE_AP ??.*/
384 param_host |= (HI_OPTION_FW_MODE_AP << HI_OPTION_FW_MODE_SHIFT);
385 /* mac_addr_method */
386 param_host |= (1 << HI_OPTION_MAC_ADDR_METHOD_SHIFT);
387 /* firmware_bridge */
388 param_host |= (0 << HI_OPTION_FW_BRIDGE_SHIFT);
390 param_host |= (0 << HI_OPTION_FW_SUBMODE_SHIFT);
392 ret = ath10k_bmi_write32(ar, hi_option_flag, param_host);
394 ath10k_err(ar, "setting firmware mode (2/2) failed\n");
398 /* We do all byte-swapping on the host */
399 ret = ath10k_bmi_write32(ar, hi_be, 0);
401 ath10k_err(ar, "setting host CPU BE mode failed\n");
405 /* FW descriptor/Data swap flags */
406 ret = ath10k_bmi_write32(ar, hi_fw_swap, 0);
409 ath10k_err(ar, "setting FW data/desc swap flags failed\n");
413 /* Some devices have a special sanity check that verifies the PCI
414 * Device ID is written to this host interest var. It is known to be
415 * required to boot QCA6164.
417 ret = ath10k_bmi_write32(ar, hi_hci_uart_pwr_mgmt_params_ext,
420 ath10k_err(ar, "failed to set pwr_mgmt_params: %d\n", ret);
427 static const struct firmware *ath10k_fetch_fw_file(struct ath10k *ar,
432 const struct firmware *fw;
436 return ERR_PTR(-ENOENT);
441 snprintf(filename, sizeof(filename), "%s/%s", dir, file);
442 ret = request_firmware(&fw, filename, ar->dev);
449 static int ath10k_push_board_ext_data(struct ath10k *ar, const void *data,
452 u32 board_data_size = ar->hw_params.fw.board_size;
453 u32 board_ext_data_size = ar->hw_params.fw.board_ext_size;
454 u32 board_ext_data_addr;
457 ret = ath10k_bmi_read32(ar, hi_board_ext_data, &board_ext_data_addr);
459 ath10k_err(ar, "could not read board ext data addr (%d)\n",
464 ath10k_dbg(ar, ATH10K_DBG_BOOT,
465 "boot push board extended data addr 0x%x\n",
466 board_ext_data_addr);
468 if (board_ext_data_addr == 0)
471 if (data_len != (board_data_size + board_ext_data_size)) {
472 ath10k_err(ar, "invalid board (ext) data sizes %zu != %d+%d\n",
473 data_len, board_data_size, board_ext_data_size);
477 ret = ath10k_bmi_write_memory(ar, board_ext_data_addr,
478 data + board_data_size,
479 board_ext_data_size);
481 ath10k_err(ar, "could not write board ext data (%d)\n", ret);
485 ret = ath10k_bmi_write32(ar, hi_board_ext_data_config,
486 (board_ext_data_size << 16) | 1);
488 ath10k_err(ar, "could not write board ext data bit (%d)\n",
496 static int ath10k_download_board_data(struct ath10k *ar, const void *data,
499 u32 board_data_size = ar->hw_params.fw.board_size;
503 ret = ath10k_push_board_ext_data(ar, data, data_len);
505 ath10k_err(ar, "could not push board ext data (%d)\n", ret);
509 ret = ath10k_bmi_read32(ar, hi_board_data, &address);
511 ath10k_err(ar, "could not read board data addr (%d)\n", ret);
515 ret = ath10k_bmi_write_memory(ar, address, data,
516 min_t(u32, board_data_size,
519 ath10k_err(ar, "could not write board data (%d)\n", ret);
523 ret = ath10k_bmi_write32(ar, hi_board_data_initialized, 1);
525 ath10k_err(ar, "could not write board data bit (%d)\n", ret);
533 static int ath10k_download_cal_file(struct ath10k *ar,
534 const struct firmware *file)
542 return PTR_ERR(file);
544 ret = ath10k_download_board_data(ar, file->data, file->size);
546 ath10k_err(ar, "failed to download cal_file data: %d\n", ret);
550 ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot cal file downloaded\n");
555 static int ath10k_download_cal_dt(struct ath10k *ar, const char *dt_name)
557 struct device_node *node;
562 node = ar->dev->of_node;
564 /* Device Tree is optional, don't print any warnings if
565 * there's no node for ath10k.
569 if (!of_get_property(node, dt_name, &data_len)) {
570 /* The calibration data node is optional */
574 if (data_len != ar->hw_params.cal_data_len) {
575 ath10k_warn(ar, "invalid calibration data length in DT: %d\n",
581 data = kmalloc(data_len, GFP_KERNEL);
587 ret = of_property_read_u8_array(node, dt_name, data, data_len);
589 ath10k_warn(ar, "failed to read calibration data from DT: %d\n",
594 ret = ath10k_download_board_data(ar, data, data_len);
596 ath10k_warn(ar, "failed to download calibration data from Device Tree: %d\n",
610 static int ath10k_download_cal_eeprom(struct ath10k *ar)
616 ret = ath10k_hif_fetch_cal_eeprom(ar, &data, &data_len);
618 if (ret != -EOPNOTSUPP)
619 ath10k_warn(ar, "failed to read calibration data from EEPROM: %d\n",
624 ret = ath10k_download_board_data(ar, data, data_len);
626 ath10k_warn(ar, "failed to download calibration data from EEPROM: %d\n",
639 static int ath10k_core_get_board_id_from_otp(struct ath10k *ar)
642 u8 board_id, chip_id;
645 address = ar->hw_params.patch_load_addr;
647 if (!ar->normal_mode_fw.fw_file.otp_data ||
648 !ar->normal_mode_fw.fw_file.otp_len) {
650 "failed to retrieve board id because of invalid otp\n");
654 ath10k_dbg(ar, ATH10K_DBG_BOOT,
655 "boot upload otp to 0x%x len %zd for board id\n",
656 address, ar->normal_mode_fw.fw_file.otp_len);
658 ret = ath10k_bmi_fast_download(ar, address,
659 ar->normal_mode_fw.fw_file.otp_data,
660 ar->normal_mode_fw.fw_file.otp_len);
662 ath10k_err(ar, "could not write otp for board id check: %d\n",
667 ret = ath10k_bmi_execute(ar, address, BMI_PARAM_GET_EEPROM_BOARD_ID,
670 ath10k_err(ar, "could not execute otp for board id check: %d\n",
675 board_id = MS(result, ATH10K_BMI_BOARD_ID_FROM_OTP);
676 chip_id = MS(result, ATH10K_BMI_CHIP_ID_FROM_OTP);
678 ath10k_dbg(ar, ATH10K_DBG_BOOT,
679 "boot get otp board id result 0x%08x board_id %d chip_id %d\n",
680 result, board_id, chip_id);
682 if ((result & ATH10K_BMI_BOARD_ID_STATUS_MASK) != 0)
685 ar->id.bmi_ids_valid = true;
686 ar->id.bmi_board_id = board_id;
687 ar->id.bmi_chip_id = chip_id;
692 static int ath10k_download_and_run_otp(struct ath10k *ar)
694 u32 result, address = ar->hw_params.patch_load_addr;
695 u32 bmi_otp_exe_param = ar->hw_params.otp_exe_param;
698 ret = ath10k_download_board_data(ar,
699 ar->running_fw->board_data,
700 ar->running_fw->board_len);
702 ath10k_err(ar, "failed to download board data: %d\n", ret);
706 /* OTP is optional */
708 if (!ar->running_fw->fw_file.otp_data ||
709 !ar->running_fw->fw_file.otp_len) {
710 ath10k_warn(ar, "Not running otp, calibration will be incorrect (otp-data %pK otp_len %zd)!\n",
711 ar->running_fw->fw_file.otp_data,
712 ar->running_fw->fw_file.otp_len);
716 ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot upload otp to 0x%x len %zd\n",
717 address, ar->running_fw->fw_file.otp_len);
719 ret = ath10k_bmi_fast_download(ar, address,
720 ar->running_fw->fw_file.otp_data,
721 ar->running_fw->fw_file.otp_len);
723 ath10k_err(ar, "could not write otp (%d)\n", ret);
727 ret = ath10k_bmi_execute(ar, address, bmi_otp_exe_param, &result);
729 ath10k_err(ar, "could not execute otp (%d)\n", ret);
733 ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot otp execute result %d\n", result);
735 if (!(skip_otp || test_bit(ATH10K_FW_FEATURE_IGNORE_OTP_RESULT,
736 ar->running_fw->fw_file.fw_features)) &&
738 ath10k_err(ar, "otp calibration failed: %d", result);
745 static int ath10k_download_fw(struct ath10k *ar)
747 u32 address, data_len;
751 address = ar->hw_params.patch_load_addr;
753 data = ar->running_fw->fw_file.firmware_data;
754 data_len = ar->running_fw->fw_file.firmware_len;
756 ret = ath10k_swap_code_seg_configure(ar, &ar->running_fw->fw_file);
758 ath10k_err(ar, "failed to configure fw code swap: %d\n",
763 ath10k_dbg(ar, ATH10K_DBG_BOOT,
764 "boot uploading firmware image %pK len %d\n",
767 ret = ath10k_bmi_fast_download(ar, address, data, data_len);
769 ath10k_err(ar, "failed to download firmware: %d\n",
777 static void ath10k_core_free_board_files(struct ath10k *ar)
779 if (!IS_ERR(ar->normal_mode_fw.board))
780 release_firmware(ar->normal_mode_fw.board);
782 ar->normal_mode_fw.board = NULL;
783 ar->normal_mode_fw.board_data = NULL;
784 ar->normal_mode_fw.board_len = 0;
787 static void ath10k_core_free_firmware_files(struct ath10k *ar)
789 if (!IS_ERR(ar->normal_mode_fw.fw_file.firmware))
790 release_firmware(ar->normal_mode_fw.fw_file.firmware);
792 if (!IS_ERR(ar->cal_file))
793 release_firmware(ar->cal_file);
795 if (!IS_ERR(ar->pre_cal_file))
796 release_firmware(ar->pre_cal_file);
798 ath10k_swap_code_seg_release(ar, &ar->normal_mode_fw.fw_file);
800 ar->normal_mode_fw.fw_file.otp_data = NULL;
801 ar->normal_mode_fw.fw_file.otp_len = 0;
803 ar->normal_mode_fw.fw_file.firmware = NULL;
804 ar->normal_mode_fw.fw_file.firmware_data = NULL;
805 ar->normal_mode_fw.fw_file.firmware_len = 0;
808 ar->pre_cal_file = NULL;
811 static int ath10k_fetch_cal_file(struct ath10k *ar)
815 /* pre-cal-<bus>-<id>.bin */
816 scnprintf(filename, sizeof(filename), "pre-cal-%s-%s.bin",
817 ath10k_bus_str(ar->hif.bus), dev_name(ar->dev));
819 ar->pre_cal_file = ath10k_fetch_fw_file(ar, ATH10K_FW_DIR, filename);
820 if (!IS_ERR(ar->pre_cal_file))
823 /* cal-<bus>-<id>.bin */
824 scnprintf(filename, sizeof(filename), "cal-%s-%s.bin",
825 ath10k_bus_str(ar->hif.bus), dev_name(ar->dev));
827 ar->cal_file = ath10k_fetch_fw_file(ar, ATH10K_FW_DIR, filename);
828 if (IS_ERR(ar->cal_file))
829 /* calibration file is optional, don't print any warnings */
830 return PTR_ERR(ar->cal_file);
832 ath10k_dbg(ar, ATH10K_DBG_BOOT, "found calibration file %s/%s\n",
833 ATH10K_FW_DIR, filename);
838 static int ath10k_core_fetch_board_data_api_1(struct ath10k *ar)
840 if (!ar->hw_params.fw.board) {
841 ath10k_err(ar, "failed to find board file fw entry\n");
845 ar->normal_mode_fw.board = ath10k_fetch_fw_file(ar,
846 ar->hw_params.fw.dir,
847 ar->hw_params.fw.board);
848 if (IS_ERR(ar->normal_mode_fw.board))
849 return PTR_ERR(ar->normal_mode_fw.board);
851 ar->normal_mode_fw.board_data = ar->normal_mode_fw.board->data;
852 ar->normal_mode_fw.board_len = ar->normal_mode_fw.board->size;
857 static int ath10k_core_parse_bd_ie_board(struct ath10k *ar,
858 const void *buf, size_t buf_len,
859 const char *boardname)
861 const struct ath10k_fw_ie *hdr;
862 bool name_match_found;
863 int ret, board_ie_id;
865 const void *board_ie_data;
867 name_match_found = false;
869 /* go through ATH10K_BD_IE_BOARD_ elements */
870 while (buf_len > sizeof(struct ath10k_fw_ie)) {
872 board_ie_id = le32_to_cpu(hdr->id);
873 board_ie_len = le32_to_cpu(hdr->len);
874 board_ie_data = hdr->data;
876 buf_len -= sizeof(*hdr);
879 if (buf_len < ALIGN(board_ie_len, 4)) {
880 ath10k_err(ar, "invalid ATH10K_BD_IE_BOARD length: %zu < %zu\n",
881 buf_len, ALIGN(board_ie_len, 4));
886 switch (board_ie_id) {
887 case ATH10K_BD_IE_BOARD_NAME:
888 ath10k_dbg_dump(ar, ATH10K_DBG_BOOT, "board name", "",
889 board_ie_data, board_ie_len);
891 if (board_ie_len != strlen(boardname))
894 ret = memcmp(board_ie_data, boardname, strlen(boardname));
898 name_match_found = true;
899 ath10k_dbg(ar, ATH10K_DBG_BOOT,
900 "boot found match for name '%s'",
903 case ATH10K_BD_IE_BOARD_DATA:
904 if (!name_match_found)
908 ath10k_dbg(ar, ATH10K_DBG_BOOT,
909 "boot found board data for '%s'",
912 ar->normal_mode_fw.board_data = board_ie_data;
913 ar->normal_mode_fw.board_len = board_ie_len;
918 ath10k_warn(ar, "unknown ATH10K_BD_IE_BOARD found: %d\n",
923 /* jump over the padding */
924 board_ie_len = ALIGN(board_ie_len, 4);
926 buf_len -= board_ie_len;
937 static int ath10k_core_fetch_board_data_api_n(struct ath10k *ar,
938 const char *boardname,
939 const char *filename)
941 size_t len, magic_len, ie_len;
942 struct ath10k_fw_ie *hdr;
946 ar->normal_mode_fw.board = ath10k_fetch_fw_file(ar,
947 ar->hw_params.fw.dir,
949 if (IS_ERR(ar->normal_mode_fw.board))
950 return PTR_ERR(ar->normal_mode_fw.board);
952 data = ar->normal_mode_fw.board->data;
953 len = ar->normal_mode_fw.board->size;
955 /* magic has extra null byte padded */
956 magic_len = strlen(ATH10K_BOARD_MAGIC) + 1;
957 if (len < magic_len) {
958 ath10k_err(ar, "failed to find magic value in %s/%s, file too short: %zu\n",
959 ar->hw_params.fw.dir, filename, len);
964 if (memcmp(data, ATH10K_BOARD_MAGIC, magic_len)) {
965 ath10k_err(ar, "found invalid board magic\n");
970 /* magic is padded to 4 bytes */
971 magic_len = ALIGN(magic_len, 4);
972 if (len < magic_len) {
973 ath10k_err(ar, "failed: %s/%s too small to contain board data, len: %zu\n",
974 ar->hw_params.fw.dir, filename, len);
982 while (len > sizeof(struct ath10k_fw_ie)) {
983 hdr = (struct ath10k_fw_ie *)data;
984 ie_id = le32_to_cpu(hdr->id);
985 ie_len = le32_to_cpu(hdr->len);
990 if (len < ALIGN(ie_len, 4)) {
991 ath10k_err(ar, "invalid length for board ie_id %d ie_len %zu len %zu\n",
998 case ATH10K_BD_IE_BOARD:
999 ret = ath10k_core_parse_bd_ie_board(ar, data, ie_len,
1002 /* no match found, continue */
1005 /* there was an error, bail out */
1008 /* board data found */
1012 /* jump over the padding */
1013 ie_len = ALIGN(ie_len, 4);
1020 if (!ar->normal_mode_fw.board_data || !ar->normal_mode_fw.board_len) {
1022 "failed to fetch board data for %s from %s/%s\n",
1023 boardname, ar->hw_params.fw.dir, filename);
1031 ath10k_core_free_board_files(ar);
1035 static int ath10k_core_create_board_name(struct ath10k *ar, char *name,
1038 if (ar->id.bmi_ids_valid) {
1039 scnprintf(name, name_len,
1040 "bus=%s,bmi-chip-id=%d,bmi-board-id=%d",
1041 ath10k_bus_str(ar->hif.bus),
1043 ar->id.bmi_board_id);
1047 scnprintf(name, name_len,
1048 "bus=%s,vendor=%04x,device=%04x,subsystem-vendor=%04x,subsystem-device=%04x",
1049 ath10k_bus_str(ar->hif.bus),
1050 ar->id.vendor, ar->id.device,
1051 ar->id.subsystem_vendor, ar->id.subsystem_device);
1054 ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot using board name '%s'\n", name);
1059 static int ath10k_core_fetch_board_file(struct ath10k *ar)
1061 char boardname[100];
1064 ret = ath10k_core_create_board_name(ar, boardname, sizeof(boardname));
1066 ath10k_err(ar, "failed to create board name: %d", ret);
1071 ret = ath10k_core_fetch_board_data_api_n(ar, boardname,
1072 ATH10K_BOARD_API2_FILE);
1077 ret = ath10k_core_fetch_board_data_api_1(ar);
1079 ath10k_err(ar, "failed to fetch board data\n");
1084 ath10k_dbg(ar, ATH10K_DBG_BOOT, "using board api %d\n", ar->bd_api);
1088 int ath10k_core_fetch_firmware_api_n(struct ath10k *ar, const char *name,
1089 struct ath10k_fw_file *fw_file)
1091 size_t magic_len, len, ie_len;
1092 int ie_id, i, index, bit, ret;
1093 struct ath10k_fw_ie *hdr;
1095 __le32 *timestamp, *version;
1097 /* first fetch the firmware file (firmware-*.bin) */
1098 fw_file->firmware = ath10k_fetch_fw_file(ar, ar->hw_params.fw.dir,
1100 if (IS_ERR(fw_file->firmware)) {
1101 ath10k_err(ar, "could not fetch firmware file '%s/%s': %ld\n",
1102 ar->hw_params.fw.dir, name,
1103 PTR_ERR(fw_file->firmware));
1104 return PTR_ERR(fw_file->firmware);
1107 data = fw_file->firmware->data;
1108 len = fw_file->firmware->size;
1110 /* magic also includes the null byte, check that as well */
1111 magic_len = strlen(ATH10K_FIRMWARE_MAGIC) + 1;
1113 if (len < magic_len) {
1114 ath10k_err(ar, "firmware file '%s/%s' too small to contain magic: %zu\n",
1115 ar->hw_params.fw.dir, name, len);
1120 if (memcmp(data, ATH10K_FIRMWARE_MAGIC, magic_len) != 0) {
1121 ath10k_err(ar, "invalid firmware magic\n");
1126 /* jump over the padding */
1127 magic_len = ALIGN(magic_len, 4);
1133 while (len > sizeof(struct ath10k_fw_ie)) {
1134 hdr = (struct ath10k_fw_ie *)data;
1136 ie_id = le32_to_cpu(hdr->id);
1137 ie_len = le32_to_cpu(hdr->len);
1139 len -= sizeof(*hdr);
1140 data += sizeof(*hdr);
1143 ath10k_err(ar, "invalid length for FW IE %d (%zu < %zu)\n",
1144 ie_id, len, ie_len);
1150 case ATH10K_FW_IE_FW_VERSION:
1151 if (ie_len > sizeof(fw_file->fw_version) - 1)
1154 memcpy(fw_file->fw_version, data, ie_len);
1155 fw_file->fw_version[ie_len] = '\0';
1157 ath10k_dbg(ar, ATH10K_DBG_BOOT,
1158 "found fw version %s\n",
1159 fw_file->fw_version);
1161 case ATH10K_FW_IE_TIMESTAMP:
1162 if (ie_len != sizeof(u32))
1165 timestamp = (__le32 *)data;
1167 ath10k_dbg(ar, ATH10K_DBG_BOOT, "found fw timestamp %d\n",
1168 le32_to_cpup(timestamp));
1170 case ATH10K_FW_IE_FEATURES:
1171 ath10k_dbg(ar, ATH10K_DBG_BOOT,
1172 "found firmware features ie (%zd B)\n",
1175 for (i = 0; i < ATH10K_FW_FEATURE_COUNT; i++) {
1179 if (index == ie_len)
1182 if (data[index] & (1 << bit)) {
1183 ath10k_dbg(ar, ATH10K_DBG_BOOT,
1184 "Enabling feature bit: %i\n",
1186 __set_bit(i, fw_file->fw_features);
1190 ath10k_dbg_dump(ar, ATH10K_DBG_BOOT, "features", "",
1191 fw_file->fw_features,
1192 sizeof(fw_file->fw_features));
1194 case ATH10K_FW_IE_FW_IMAGE:
1195 ath10k_dbg(ar, ATH10K_DBG_BOOT,
1196 "found fw image ie (%zd B)\n",
1199 fw_file->firmware_data = data;
1200 fw_file->firmware_len = ie_len;
1203 case ATH10K_FW_IE_OTP_IMAGE:
1204 ath10k_dbg(ar, ATH10K_DBG_BOOT,
1205 "found otp image ie (%zd B)\n",
1208 fw_file->otp_data = data;
1209 fw_file->otp_len = ie_len;
1212 case ATH10K_FW_IE_WMI_OP_VERSION:
1213 if (ie_len != sizeof(u32))
1216 version = (__le32 *)data;
1218 fw_file->wmi_op_version = le32_to_cpup(version);
1220 ath10k_dbg(ar, ATH10K_DBG_BOOT, "found fw ie wmi op version %d\n",
1221 fw_file->wmi_op_version);
1223 case ATH10K_FW_IE_HTT_OP_VERSION:
1224 if (ie_len != sizeof(u32))
1227 version = (__le32 *)data;
1229 fw_file->htt_op_version = le32_to_cpup(version);
1231 ath10k_dbg(ar, ATH10K_DBG_BOOT, "found fw ie htt op version %d\n",
1232 fw_file->htt_op_version);
1234 case ATH10K_FW_IE_FW_CODE_SWAP_IMAGE:
1235 ath10k_dbg(ar, ATH10K_DBG_BOOT,
1236 "found fw code swap image ie (%zd B)\n",
1238 fw_file->codeswap_data = data;
1239 fw_file->codeswap_len = ie_len;
1242 ath10k_warn(ar, "Unknown FW IE: %u\n",
1243 le32_to_cpu(hdr->id));
1247 /* jump over the padding */
1248 ie_len = ALIGN(ie_len, 4);
1254 if (!fw_file->firmware_data ||
1255 !fw_file->firmware_len) {
1256 ath10k_warn(ar, "No ATH10K_FW_IE_FW_IMAGE found from '%s/%s', skipping\n",
1257 ar->hw_params.fw.dir, name);
1265 ath10k_core_free_firmware_files(ar);
1269 static int ath10k_core_fetch_firmware_files(struct ath10k *ar)
1273 /* calibration file is optional, don't check for any errors */
1274 ath10k_fetch_cal_file(ar);
1277 ath10k_dbg(ar, ATH10K_DBG_BOOT, "trying fw api %d\n", ar->fw_api);
1279 ret = ath10k_core_fetch_firmware_api_n(ar, ATH10K_FW_API5_FILE,
1280 &ar->normal_mode_fw.fw_file);
1285 ath10k_dbg(ar, ATH10K_DBG_BOOT, "trying fw api %d\n", ar->fw_api);
1287 ret = ath10k_core_fetch_firmware_api_n(ar, ATH10K_FW_API4_FILE,
1288 &ar->normal_mode_fw.fw_file);
1293 ath10k_dbg(ar, ATH10K_DBG_BOOT, "trying fw api %d\n", ar->fw_api);
1295 ret = ath10k_core_fetch_firmware_api_n(ar, ATH10K_FW_API3_FILE,
1296 &ar->normal_mode_fw.fw_file);
1301 ath10k_dbg(ar, ATH10K_DBG_BOOT, "trying fw api %d\n", ar->fw_api);
1303 ret = ath10k_core_fetch_firmware_api_n(ar, ATH10K_FW_API2_FILE,
1304 &ar->normal_mode_fw.fw_file);
1309 ath10k_dbg(ar, ATH10K_DBG_BOOT, "using fw api %d\n", ar->fw_api);
1314 static int ath10k_core_pre_cal_download(struct ath10k *ar)
1318 ret = ath10k_download_cal_file(ar, ar->pre_cal_file);
1320 ar->cal_mode = ATH10K_PRE_CAL_MODE_FILE;
1324 ath10k_dbg(ar, ATH10K_DBG_BOOT,
1325 "boot did not find a pre calibration file, try DT next: %d\n",
1328 ret = ath10k_download_cal_dt(ar, "qcom,ath10k-pre-calibration-data");
1330 ath10k_dbg(ar, ATH10K_DBG_BOOT,
1331 "unable to load pre cal data from DT: %d\n", ret);
1334 ar->cal_mode = ATH10K_PRE_CAL_MODE_DT;
1337 ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot using calibration mode %s\n",
1338 ath10k_cal_mode_str(ar->cal_mode));
1343 static int ath10k_core_pre_cal_config(struct ath10k *ar)
1347 ret = ath10k_core_pre_cal_download(ar);
1349 ath10k_dbg(ar, ATH10K_DBG_BOOT,
1350 "failed to load pre cal data: %d\n", ret);
1354 ret = ath10k_core_get_board_id_from_otp(ar);
1356 ath10k_err(ar, "failed to get board id: %d\n", ret);
1360 ret = ath10k_download_and_run_otp(ar);
1362 ath10k_err(ar, "failed to run otp: %d\n", ret);
1366 ath10k_dbg(ar, ATH10K_DBG_BOOT,
1367 "pre cal configuration done successfully\n");
1372 static int ath10k_download_cal_data(struct ath10k *ar)
1376 ret = ath10k_core_pre_cal_config(ar);
1380 ath10k_dbg(ar, ATH10K_DBG_BOOT,
1381 "pre cal download procedure failed, try cal file: %d\n",
1384 ret = ath10k_download_cal_file(ar, ar->cal_file);
1386 ar->cal_mode = ATH10K_CAL_MODE_FILE;
1390 ath10k_dbg(ar, ATH10K_DBG_BOOT,
1391 "boot did not find a calibration file, try DT next: %d\n",
1394 ret = ath10k_download_cal_dt(ar, "qcom,ath10k-calibration-data");
1396 ar->cal_mode = ATH10K_CAL_MODE_DT;
1400 ath10k_dbg(ar, ATH10K_DBG_BOOT,
1401 "boot did not find DT entry, try target EEPROM next: %d\n",
1404 ret = ath10k_download_cal_eeprom(ar);
1406 ar->cal_mode = ATH10K_CAL_MODE_EEPROM;
1410 ath10k_dbg(ar, ATH10K_DBG_BOOT,
1411 "boot did not find target EEPROM entry, try OTP next: %d\n",
1414 ret = ath10k_download_and_run_otp(ar);
1416 ath10k_err(ar, "failed to run otp: %d\n", ret);
1420 ar->cal_mode = ATH10K_CAL_MODE_OTP;
1423 ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot using calibration mode %s\n",
1424 ath10k_cal_mode_str(ar->cal_mode));
1428 static int ath10k_init_uart(struct ath10k *ar)
1433 * Explicitly setting UART prints to zero as target turns it on
1434 * based on scratch registers.
1436 ret = ath10k_bmi_write32(ar, hi_serial_enable, 0);
1438 ath10k_warn(ar, "could not disable UART prints (%d)\n", ret);
1445 ret = ath10k_bmi_write32(ar, hi_dbg_uart_txpin, ar->hw_params.uart_pin);
1447 ath10k_warn(ar, "could not enable UART prints (%d)\n", ret);
1451 ret = ath10k_bmi_write32(ar, hi_serial_enable, 1);
1453 ath10k_warn(ar, "could not enable UART prints (%d)\n", ret);
1457 /* Set the UART baud rate to 19200. */
1458 ret = ath10k_bmi_write32(ar, hi_desired_baud_rate, 19200);
1460 ath10k_warn(ar, "could not set the baud rate (%d)\n", ret);
1464 ath10k_info(ar, "UART prints enabled\n");
1468 static int ath10k_init_hw_params(struct ath10k *ar)
1470 const struct ath10k_hw_params *uninitialized_var(hw_params);
1473 for (i = 0; i < ARRAY_SIZE(ath10k_hw_params_list); i++) {
1474 hw_params = &ath10k_hw_params_list[i];
1476 if (hw_params->id == ar->target_version &&
1477 hw_params->dev_id == ar->dev_id)
1481 if (i == ARRAY_SIZE(ath10k_hw_params_list)) {
1482 ath10k_err(ar, "Unsupported hardware version: 0x%x\n",
1483 ar->target_version);
1487 ar->hw_params = *hw_params;
1489 ath10k_dbg(ar, ATH10K_DBG_BOOT, "Hardware name %s version 0x%x\n",
1490 ar->hw_params.name, ar->target_version);
1495 static void ath10k_core_restart(struct work_struct *work)
1497 struct ath10k *ar = container_of(work, struct ath10k, restart_work);
1499 set_bit(ATH10K_FLAG_CRASH_FLUSH, &ar->dev_flags);
1501 /* Place a barrier to make sure the compiler doesn't reorder
1502 * CRASH_FLUSH and calling other functions.
1506 ieee80211_stop_queues(ar->hw);
1507 ath10k_drain_tx(ar);
1508 complete(&ar->scan.started);
1509 complete(&ar->scan.completed);
1510 complete(&ar->scan.on_channel);
1511 complete(&ar->offchan_tx_completed);
1512 complete(&ar->install_key_done);
1513 complete(&ar->vdev_setup_done);
1514 complete(&ar->thermal.wmi_sync);
1515 complete(&ar->bss_survey_done);
1516 wake_up(&ar->htt.empty_tx_wq);
1517 wake_up(&ar->wmi.tx_credits_wq);
1518 wake_up(&ar->peer_mapping_wq);
1520 mutex_lock(&ar->conf_mutex);
1522 switch (ar->state) {
1523 case ATH10K_STATE_ON:
1524 ar->state = ATH10K_STATE_RESTARTING;
1525 ath10k_hif_stop(ar);
1526 ath10k_scan_finish(ar);
1527 ieee80211_restart_hw(ar->hw);
1529 case ATH10K_STATE_OFF:
1530 /* this can happen if driver is being unloaded
1531 * or if the crash happens during FW probing */
1532 ath10k_warn(ar, "cannot restart a device that hasn't been started\n");
1534 case ATH10K_STATE_RESTARTING:
1535 /* hw restart might be requested from multiple places */
1537 case ATH10K_STATE_RESTARTED:
1538 ar->state = ATH10K_STATE_WEDGED;
1540 case ATH10K_STATE_WEDGED:
1541 ath10k_warn(ar, "device is wedged, will not restart\n");
1543 case ATH10K_STATE_UTF:
1544 ath10k_warn(ar, "firmware restart in UTF mode not supported\n");
1548 mutex_unlock(&ar->conf_mutex);
1551 static int ath10k_core_init_firmware_features(struct ath10k *ar)
1553 struct ath10k_fw_file *fw_file = &ar->normal_mode_fw.fw_file;
1555 if (test_bit(ATH10K_FW_FEATURE_WMI_10_2, fw_file->fw_features) &&
1556 !test_bit(ATH10K_FW_FEATURE_WMI_10X, fw_file->fw_features)) {
1557 ath10k_err(ar, "feature bits corrupted: 10.2 feature requires 10.x feature to be set as well");
1561 if (fw_file->wmi_op_version >= ATH10K_FW_WMI_OP_VERSION_MAX) {
1562 ath10k_err(ar, "unsupported WMI OP version (max %d): %d\n",
1563 ATH10K_FW_WMI_OP_VERSION_MAX, fw_file->wmi_op_version);
1567 ar->wmi.rx_decap_mode = ATH10K_HW_TXRX_NATIVE_WIFI;
1568 switch (ath10k_cryptmode_param) {
1569 case ATH10K_CRYPT_MODE_HW:
1570 clear_bit(ATH10K_FLAG_RAW_MODE, &ar->dev_flags);
1571 clear_bit(ATH10K_FLAG_HW_CRYPTO_DISABLED, &ar->dev_flags);
1573 case ATH10K_CRYPT_MODE_SW:
1574 if (!test_bit(ATH10K_FW_FEATURE_RAW_MODE_SUPPORT,
1575 fw_file->fw_features)) {
1576 ath10k_err(ar, "cryptmode > 0 requires raw mode support from firmware");
1580 set_bit(ATH10K_FLAG_RAW_MODE, &ar->dev_flags);
1581 set_bit(ATH10K_FLAG_HW_CRYPTO_DISABLED, &ar->dev_flags);
1584 ath10k_info(ar, "invalid cryptmode: %d\n",
1585 ath10k_cryptmode_param);
1589 ar->htt.max_num_amsdu = ATH10K_HTT_MAX_NUM_AMSDU_DEFAULT;
1590 ar->htt.max_num_ampdu = ATH10K_HTT_MAX_NUM_AMPDU_DEFAULT;
1593 if (!test_bit(ATH10K_FW_FEATURE_RAW_MODE_SUPPORT,
1594 fw_file->fw_features)) {
1595 ath10k_err(ar, "rawmode = 1 requires support from firmware");
1598 set_bit(ATH10K_FLAG_RAW_MODE, &ar->dev_flags);
1601 if (test_bit(ATH10K_FLAG_RAW_MODE, &ar->dev_flags)) {
1602 ar->wmi.rx_decap_mode = ATH10K_HW_TXRX_RAW;
1606 * Firmware A-MSDU aggregation breaks with RAW Tx encap mode
1607 * and causes enormous performance issues (malformed frames,
1610 * Disabling A-MSDU makes RAW mode stable with heavy traffic
1611 * albeit a bit slower compared to regular operation.
1613 ar->htt.max_num_amsdu = 1;
1616 /* Backwards compatibility for firmwares without
1617 * ATH10K_FW_IE_WMI_OP_VERSION.
1619 if (fw_file->wmi_op_version == ATH10K_FW_WMI_OP_VERSION_UNSET) {
1620 if (test_bit(ATH10K_FW_FEATURE_WMI_10X, fw_file->fw_features)) {
1621 if (test_bit(ATH10K_FW_FEATURE_WMI_10_2,
1622 fw_file->fw_features))
1623 fw_file->wmi_op_version = ATH10K_FW_WMI_OP_VERSION_10_2;
1625 fw_file->wmi_op_version = ATH10K_FW_WMI_OP_VERSION_10_1;
1627 fw_file->wmi_op_version = ATH10K_FW_WMI_OP_VERSION_MAIN;
1631 switch (fw_file->wmi_op_version) {
1632 case ATH10K_FW_WMI_OP_VERSION_MAIN:
1633 ar->max_num_peers = TARGET_NUM_PEERS;
1634 ar->max_num_stations = TARGET_NUM_STATIONS;
1635 ar->max_num_vdevs = TARGET_NUM_VDEVS;
1636 ar->htt.max_num_pending_tx = TARGET_NUM_MSDU_DESC;
1637 ar->fw_stats_req_mask = WMI_STAT_PDEV | WMI_STAT_VDEV |
1639 ar->max_spatial_stream = WMI_MAX_SPATIAL_STREAM;
1641 case ATH10K_FW_WMI_OP_VERSION_10_1:
1642 case ATH10K_FW_WMI_OP_VERSION_10_2:
1643 case ATH10K_FW_WMI_OP_VERSION_10_2_4:
1644 if (ath10k_peer_stats_enabled(ar)) {
1645 ar->max_num_peers = TARGET_10X_TX_STATS_NUM_PEERS;
1646 ar->max_num_stations = TARGET_10X_TX_STATS_NUM_STATIONS;
1648 ar->max_num_peers = TARGET_10X_NUM_PEERS;
1649 ar->max_num_stations = TARGET_10X_NUM_STATIONS;
1651 ar->max_num_vdevs = TARGET_10X_NUM_VDEVS;
1652 ar->htt.max_num_pending_tx = TARGET_10X_NUM_MSDU_DESC;
1653 ar->fw_stats_req_mask = WMI_STAT_PEER;
1654 ar->max_spatial_stream = WMI_MAX_SPATIAL_STREAM;
1656 case ATH10K_FW_WMI_OP_VERSION_TLV:
1657 ar->max_num_peers = TARGET_TLV_NUM_PEERS;
1658 ar->max_num_stations = TARGET_TLV_NUM_STATIONS;
1659 ar->max_num_vdevs = TARGET_TLV_NUM_VDEVS;
1660 ar->max_num_tdls_vdevs = TARGET_TLV_NUM_TDLS_VDEVS;
1661 ar->htt.max_num_pending_tx = TARGET_TLV_NUM_MSDU_DESC;
1662 ar->wow.max_num_patterns = TARGET_TLV_NUM_WOW_PATTERNS;
1663 ar->fw_stats_req_mask = WMI_STAT_PDEV | WMI_STAT_VDEV |
1665 ar->max_spatial_stream = WMI_MAX_SPATIAL_STREAM;
1667 case ATH10K_FW_WMI_OP_VERSION_10_4:
1668 ar->max_num_peers = TARGET_10_4_NUM_PEERS;
1669 ar->max_num_stations = TARGET_10_4_NUM_STATIONS;
1670 ar->num_active_peers = TARGET_10_4_ACTIVE_PEERS;
1671 ar->max_num_vdevs = TARGET_10_4_NUM_VDEVS;
1672 ar->num_tids = TARGET_10_4_TGT_NUM_TIDS;
1673 ar->fw_stats_req_mask = WMI_10_4_STAT_PEER |
1674 WMI_10_4_STAT_PEER_EXTD;
1675 ar->max_spatial_stream = ar->hw_params.max_spatial_stream;
1677 if (test_bit(ATH10K_FW_FEATURE_PEER_FLOW_CONTROL,
1678 fw_file->fw_features))
1679 ar->htt.max_num_pending_tx = TARGET_10_4_NUM_MSDU_DESC_PFC;
1681 ar->htt.max_num_pending_tx = TARGET_10_4_NUM_MSDU_DESC;
1683 case ATH10K_FW_WMI_OP_VERSION_UNSET:
1684 case ATH10K_FW_WMI_OP_VERSION_MAX:
1689 /* Backwards compatibility for firmwares without
1690 * ATH10K_FW_IE_HTT_OP_VERSION.
1692 if (fw_file->htt_op_version == ATH10K_FW_HTT_OP_VERSION_UNSET) {
1693 switch (fw_file->wmi_op_version) {
1694 case ATH10K_FW_WMI_OP_VERSION_MAIN:
1695 fw_file->htt_op_version = ATH10K_FW_HTT_OP_VERSION_MAIN;
1697 case ATH10K_FW_WMI_OP_VERSION_10_1:
1698 case ATH10K_FW_WMI_OP_VERSION_10_2:
1699 case ATH10K_FW_WMI_OP_VERSION_10_2_4:
1700 fw_file->htt_op_version = ATH10K_FW_HTT_OP_VERSION_10_1;
1702 case ATH10K_FW_WMI_OP_VERSION_TLV:
1703 fw_file->htt_op_version = ATH10K_FW_HTT_OP_VERSION_TLV;
1705 case ATH10K_FW_WMI_OP_VERSION_10_4:
1706 case ATH10K_FW_WMI_OP_VERSION_UNSET:
1707 case ATH10K_FW_WMI_OP_VERSION_MAX:
1708 ath10k_err(ar, "htt op version not found from fw meta data");
1716 static int ath10k_core_reset_rx_filter(struct ath10k *ar)
1722 const u8 *vdev_addr;
1725 vdev_type = WMI_VDEV_TYPE_STA;
1726 vdev_subtype = ath10k_wmi_get_vdev_subtype(ar, WMI_VDEV_SUBTYPE_NONE);
1727 vdev_addr = ar->mac_addr;
1729 ret = ath10k_wmi_vdev_create(ar, vdev_id, vdev_type, vdev_subtype,
1732 ath10k_err(ar, "failed to create dummy vdev: %d\n", ret);
1736 ret = ath10k_wmi_vdev_delete(ar, vdev_id);
1738 ath10k_err(ar, "failed to delete dummy vdev: %d\n", ret);
1742 /* WMI and HTT may use separate HIF pipes and are not guaranteed to be
1743 * serialized properly implicitly.
1745 * Moreover (most) WMI commands have no explicit acknowledges. It is
1746 * possible to infer it implicitly by poking firmware with echo
1747 * command - getting a reply means all preceding comments have been
1748 * (mostly) processed.
1750 * In case of vdev create/delete this is sufficient.
1752 * Without this it's possible to end up with a race when HTT Rx ring is
1753 * started before vdev create/delete hack is complete allowing a short
1754 * window of opportunity to receive (and Tx ACK) a bunch of frames.
1756 ret = ath10k_wmi_barrier(ar);
1758 ath10k_err(ar, "failed to ping firmware: %d\n", ret);
1765 int ath10k_core_start(struct ath10k *ar, enum ath10k_firmware_mode mode,
1766 const struct ath10k_fw_components *fw)
1771 lockdep_assert_held(&ar->conf_mutex);
1773 clear_bit(ATH10K_FLAG_CRASH_FLUSH, &ar->dev_flags);
1775 ar->running_fw = fw;
1777 ath10k_bmi_start(ar);
1779 if (ath10k_init_configure_target(ar)) {
1784 status = ath10k_download_cal_data(ar);
1788 /* Some of of qca988x solutions are having global reset issue
1789 * during target initialization. Bypassing PLL setting before
1790 * downloading firmware and letting the SoC run on REF_CLK is
1791 * fixing the problem. Corresponding firmware change is also needed
1792 * to set the clock source once the target is initialized.
1794 if (test_bit(ATH10K_FW_FEATURE_SUPPORTS_SKIP_CLOCK_INIT,
1795 ar->running_fw->fw_file.fw_features)) {
1796 status = ath10k_bmi_write32(ar, hi_skip_clock_init, 1);
1798 ath10k_err(ar, "could not write to skip_clock_init: %d\n",
1804 status = ath10k_download_fw(ar);
1808 status = ath10k_init_uart(ar);
1812 ar->htc.htc_ops.target_send_suspend_complete =
1813 ath10k_send_suspend_complete;
1815 status = ath10k_htc_init(ar);
1817 ath10k_err(ar, "could not init HTC (%d)\n", status);
1821 status = ath10k_bmi_done(ar);
1825 status = ath10k_wmi_attach(ar);
1827 ath10k_err(ar, "WMI attach failed: %d\n", status);
1831 status = ath10k_htt_init(ar);
1833 ath10k_err(ar, "failed to init htt: %d\n", status);
1834 goto err_wmi_detach;
1837 status = ath10k_htt_tx_alloc(&ar->htt);
1839 ath10k_err(ar, "failed to alloc htt tx: %d\n", status);
1840 goto err_wmi_detach;
1843 status = ath10k_htt_rx_alloc(&ar->htt);
1845 ath10k_err(ar, "failed to alloc htt rx: %d\n", status);
1846 goto err_htt_tx_detach;
1849 status = ath10k_hif_start(ar);
1851 ath10k_err(ar, "could not start HIF: %d\n", status);
1852 goto err_htt_rx_detach;
1855 status = ath10k_htc_wait_target(&ar->htc);
1857 ath10k_err(ar, "failed to connect to HTC: %d\n", status);
1861 if (mode == ATH10K_FIRMWARE_MODE_NORMAL) {
1862 status = ath10k_htt_connect(&ar->htt);
1864 ath10k_err(ar, "failed to connect htt (%d)\n", status);
1869 status = ath10k_wmi_connect(ar);
1871 ath10k_err(ar, "could not connect wmi: %d\n", status);
1875 status = ath10k_htc_start(&ar->htc);
1877 ath10k_err(ar, "failed to start htc: %d\n", status);
1881 if (mode == ATH10K_FIRMWARE_MODE_NORMAL) {
1882 status = ath10k_wmi_wait_for_service_ready(ar);
1884 ath10k_warn(ar, "wmi service ready event not received");
1889 ath10k_dbg(ar, ATH10K_DBG_BOOT, "firmware %s booted\n",
1890 ar->hw->wiphy->fw_version);
1892 if (test_bit(WMI_SERVICE_EXT_RES_CFG_SUPPORT, ar->wmi.svc_map)) {
1894 if (ath10k_peer_stats_enabled(ar))
1895 val = WMI_10_4_PEER_STATS;
1897 if (test_bit(WMI_SERVICE_BSS_CHANNEL_INFO_64, ar->wmi.svc_map))
1898 val |= WMI_10_4_BSS_CHANNEL_INFO_64;
1900 /* 10.4 firmware supports BT-Coex without reloading firmware
1901 * via pdev param. To support Bluetooth coexistence pdev param,
1902 * WMI_COEX_GPIO_SUPPORT of extended resource config should be
1905 if (test_bit(WMI_SERVICE_COEX_GPIO, ar->wmi.svc_map) &&
1906 test_bit(ATH10K_FW_FEATURE_BTCOEX_PARAM,
1907 ar->running_fw->fw_file.fw_features))
1908 val |= WMI_10_4_COEX_GPIO_SUPPORT;
1910 status = ath10k_mac_ext_resource_config(ar, val);
1913 "failed to send ext resource cfg command : %d\n",
1919 status = ath10k_wmi_cmd_init(ar);
1921 ath10k_err(ar, "could not send WMI init command (%d)\n",
1926 status = ath10k_wmi_wait_for_unified_ready(ar);
1928 ath10k_err(ar, "wmi unified ready event not received\n");
1932 /* Some firmware revisions do not properly set up hardware rx filter
1935 * A known example from QCA9880 and 10.2.4 is that MAC_PCU_ADDR1_MASK
1936 * is filled with 0s instead of 1s allowing HW to respond with ACKs to
1937 * any frames that matches MAC_PCU_RX_FILTER which is also
1938 * misconfigured to accept anything.
1940 * The ADDR1 is programmed using internal firmware structure field and
1941 * can't be (easily/sanely) reached from the driver explicitly. It is
1942 * possible to implicitly make it correct by creating a dummy vdev and
1945 status = ath10k_core_reset_rx_filter(ar);
1947 ath10k_err(ar, "failed to reset rx filter: %d\n", status);
1951 /* If firmware indicates Full Rx Reorder support it must be used in a
1952 * slightly different manner. Let HTT code know.
1954 ar->htt.rx_ring.in_ord_rx = !!(test_bit(WMI_SERVICE_RX_FULL_REORDER,
1957 status = ath10k_htt_rx_ring_refill(ar);
1959 ath10k_err(ar, "failed to refill htt rx ring: %d\n", status);
1963 ar->free_vdev_map = (1LL << ar->max_num_vdevs) - 1;
1965 INIT_LIST_HEAD(&ar->arvifs);
1967 /* we don't care about HTT in UTF mode */
1968 if (mode == ATH10K_FIRMWARE_MODE_NORMAL) {
1969 status = ath10k_htt_setup(&ar->htt);
1971 ath10k_err(ar, "failed to setup htt: %d\n", status);
1976 status = ath10k_debug_start(ar);
1983 ath10k_hif_stop(ar);
1985 ath10k_htt_rx_free(&ar->htt);
1987 ath10k_htt_tx_free(&ar->htt);
1989 ath10k_wmi_detach(ar);
1993 EXPORT_SYMBOL(ath10k_core_start);
1995 int ath10k_wait_for_suspend(struct ath10k *ar, u32 suspend_opt)
1998 unsigned long time_left;
2000 reinit_completion(&ar->target_suspend);
2002 ret = ath10k_wmi_pdev_suspend_target(ar, suspend_opt);
2004 ath10k_warn(ar, "could not suspend target (%d)\n", ret);
2008 time_left = wait_for_completion_timeout(&ar->target_suspend, 1 * HZ);
2011 ath10k_warn(ar, "suspend timed out - target pause event never came\n");
2018 void ath10k_core_stop(struct ath10k *ar)
2020 lockdep_assert_held(&ar->conf_mutex);
2021 ath10k_debug_stop(ar);
2023 /* try to suspend target */
2024 if (ar->state != ATH10K_STATE_RESTARTING &&
2025 ar->state != ATH10K_STATE_UTF)
2026 ath10k_wait_for_suspend(ar, WMI_PDEV_SUSPEND_AND_DISABLE_INTR);
2028 ath10k_hif_stop(ar);
2029 ath10k_htt_tx_free(&ar->htt);
2030 ath10k_htt_rx_free(&ar->htt);
2031 ath10k_wmi_detach(ar);
2033 EXPORT_SYMBOL(ath10k_core_stop);
2035 /* mac80211 manages fw/hw initialization through start/stop hooks. However in
2036 * order to know what hw capabilities should be advertised to mac80211 it is
2037 * necessary to load the firmware (and tear it down immediately since start
2038 * hook will try to init it again) before registering */
2039 static int ath10k_core_probe_fw(struct ath10k *ar)
2041 struct bmi_target_info target_info;
2044 ret = ath10k_hif_power_up(ar);
2046 ath10k_err(ar, "could not start pci hif (%d)\n", ret);
2050 memset(&target_info, 0, sizeof(target_info));
2051 ret = ath10k_bmi_get_target_info(ar, &target_info);
2053 ath10k_err(ar, "could not get target info (%d)\n", ret);
2054 goto err_power_down;
2057 ar->target_version = target_info.version;
2058 ar->hw->wiphy->hw_version = target_info.version;
2060 ret = ath10k_init_hw_params(ar);
2062 ath10k_err(ar, "could not get hw params (%d)\n", ret);
2063 goto err_power_down;
2066 ret = ath10k_core_fetch_firmware_files(ar);
2068 ath10k_err(ar, "could not fetch firmware files (%d)\n", ret);
2069 goto err_power_down;
2072 BUILD_BUG_ON(sizeof(ar->hw->wiphy->fw_version) !=
2073 sizeof(ar->normal_mode_fw.fw_file.fw_version));
2074 memcpy(ar->hw->wiphy->fw_version, ar->normal_mode_fw.fw_file.fw_version,
2075 sizeof(ar->hw->wiphy->fw_version));
2077 ath10k_debug_print_hwfw_info(ar);
2079 ret = ath10k_core_pre_cal_download(ar);
2081 /* pre calibration data download is not necessary
2082 * for all the chipsets. Ignore failures and continue.
2084 ath10k_dbg(ar, ATH10K_DBG_BOOT,
2085 "could not load pre cal data: %d\n", ret);
2088 ret = ath10k_core_get_board_id_from_otp(ar);
2089 if (ret && ret != -EOPNOTSUPP) {
2090 ath10k_err(ar, "failed to get board id from otp: %d\n",
2092 goto err_free_firmware_files;
2095 ret = ath10k_core_fetch_board_file(ar);
2097 ath10k_err(ar, "failed to fetch board file: %d\n", ret);
2098 goto err_free_firmware_files;
2101 ath10k_debug_print_board_info(ar);
2103 ret = ath10k_core_init_firmware_features(ar);
2105 ath10k_err(ar, "fatal problem with firmware features: %d\n",
2107 goto err_free_firmware_files;
2110 ret = ath10k_swap_code_seg_init(ar, &ar->normal_mode_fw.fw_file);
2112 ath10k_err(ar, "failed to initialize code swap segment: %d\n",
2114 goto err_free_firmware_files;
2117 mutex_lock(&ar->conf_mutex);
2119 ret = ath10k_core_start(ar, ATH10K_FIRMWARE_MODE_NORMAL,
2120 &ar->normal_mode_fw);
2122 ath10k_err(ar, "could not init core (%d)\n", ret);
2126 ath10k_debug_print_boot_info(ar);
2127 ath10k_core_stop(ar);
2129 mutex_unlock(&ar->conf_mutex);
2131 ath10k_hif_power_down(ar);
2135 mutex_unlock(&ar->conf_mutex);
2137 err_free_firmware_files:
2138 ath10k_core_free_firmware_files(ar);
2141 ath10k_hif_power_down(ar);
2146 static void ath10k_core_register_work(struct work_struct *work)
2148 struct ath10k *ar = container_of(work, struct ath10k, register_work);
2151 /* peer stats are enabled by default */
2152 set_bit(ATH10K_FLAG_PEER_STATS, &ar->dev_flags);
2154 status = ath10k_core_probe_fw(ar);
2156 ath10k_err(ar, "could not probe fw (%d)\n", status);
2160 status = ath10k_mac_register(ar);
2162 ath10k_err(ar, "could not register to mac80211 (%d)\n", status);
2163 goto err_release_fw;
2166 status = ath10k_debug_register(ar);
2168 ath10k_err(ar, "unable to initialize debugfs\n");
2169 goto err_unregister_mac;
2172 status = ath10k_spectral_create(ar);
2174 ath10k_err(ar, "failed to initialize spectral\n");
2175 goto err_debug_destroy;
2178 status = ath10k_thermal_register(ar);
2180 ath10k_err(ar, "could not register thermal device: %d\n",
2182 goto err_spectral_destroy;
2185 set_bit(ATH10K_FLAG_CORE_REGISTERED, &ar->dev_flags);
2188 err_spectral_destroy:
2189 ath10k_spectral_destroy(ar);
2191 ath10k_debug_destroy(ar);
2193 ath10k_mac_unregister(ar);
2195 ath10k_core_free_firmware_files(ar);
2197 /* TODO: It's probably a good idea to release device from the driver
2198 * but calling device_release_driver() here will cause a deadlock.
2203 int ath10k_core_register(struct ath10k *ar, u32 chip_id)
2205 ar->chip_id = chip_id;
2206 queue_work(ar->workqueue, &ar->register_work);
2210 EXPORT_SYMBOL(ath10k_core_register);
2212 void ath10k_core_unregister(struct ath10k *ar)
2214 cancel_work_sync(&ar->register_work);
2216 if (!test_bit(ATH10K_FLAG_CORE_REGISTERED, &ar->dev_flags))
2219 ath10k_thermal_unregister(ar);
2220 /* Stop spectral before unregistering from mac80211 to remove the
2221 * relayfs debugfs file cleanly. Otherwise the parent debugfs tree
2222 * would be already be free'd recursively, leading to a double free.
2224 ath10k_spectral_destroy(ar);
2226 /* We must unregister from mac80211 before we stop HTC and HIF.
2227 * Otherwise we will fail to submit commands to FW and mac80211 will be
2228 * unhappy about callback failures. */
2229 ath10k_mac_unregister(ar);
2231 ath10k_testmode_destroy(ar);
2233 ath10k_core_free_firmware_files(ar);
2234 ath10k_core_free_board_files(ar);
2236 ath10k_debug_unregister(ar);
2238 EXPORT_SYMBOL(ath10k_core_unregister);
2240 struct ath10k *ath10k_core_create(size_t priv_size, struct device *dev,
2241 enum ath10k_bus bus,
2242 enum ath10k_hw_rev hw_rev,
2243 const struct ath10k_hif_ops *hif_ops)
2248 ar = ath10k_mac_create(priv_size);
2252 ar->ath_common.priv = ar;
2253 ar->ath_common.hw = ar->hw;
2255 ar->hw_rev = hw_rev;
2256 ar->hif.ops = hif_ops;
2260 case ATH10K_HW_QCA988X:
2261 case ATH10K_HW_QCA9887:
2262 ar->regs = &qca988x_regs;
2263 ar->hw_values = &qca988x_values;
2265 case ATH10K_HW_QCA6174:
2266 case ATH10K_HW_QCA9377:
2267 ar->regs = &qca6174_regs;
2268 ar->hw_values = &qca6174_values;
2270 case ATH10K_HW_QCA99X0:
2271 case ATH10K_HW_QCA9984:
2272 ar->regs = &qca99x0_regs;
2273 ar->hw_values = &qca99x0_values;
2275 case ATH10K_HW_QCA9888:
2276 ar->regs = &qca99x0_regs;
2277 ar->hw_values = &qca9888_values;
2279 case ATH10K_HW_QCA4019:
2280 ar->regs = &qca4019_regs;
2281 ar->hw_values = &qca4019_values;
2284 ath10k_err(ar, "unsupported core hardware revision %d\n",
2290 init_completion(&ar->scan.started);
2291 init_completion(&ar->scan.completed);
2292 init_completion(&ar->scan.on_channel);
2293 init_completion(&ar->target_suspend);
2294 init_completion(&ar->wow.wakeup_completed);
2296 init_completion(&ar->install_key_done);
2297 init_completion(&ar->vdev_setup_done);
2298 init_completion(&ar->thermal.wmi_sync);
2299 init_completion(&ar->bss_survey_done);
2301 INIT_DELAYED_WORK(&ar->scan.timeout, ath10k_scan_timeout_work);
2303 ar->workqueue = create_singlethread_workqueue("ath10k_wq");
2307 ar->workqueue_aux = create_singlethread_workqueue("ath10k_aux_wq");
2308 if (!ar->workqueue_aux)
2311 mutex_init(&ar->conf_mutex);
2312 spin_lock_init(&ar->data_lock);
2313 spin_lock_init(&ar->txqs_lock);
2315 INIT_LIST_HEAD(&ar->txqs);
2316 INIT_LIST_HEAD(&ar->peers);
2317 init_waitqueue_head(&ar->peer_mapping_wq);
2318 init_waitqueue_head(&ar->htt.empty_tx_wq);
2319 init_waitqueue_head(&ar->wmi.tx_credits_wq);
2321 init_completion(&ar->offchan_tx_completed);
2322 INIT_WORK(&ar->offchan_tx_work, ath10k_offchan_tx_work);
2323 skb_queue_head_init(&ar->offchan_tx_queue);
2325 INIT_WORK(&ar->wmi_mgmt_tx_work, ath10k_mgmt_over_wmi_tx_work);
2326 skb_queue_head_init(&ar->wmi_mgmt_tx_queue);
2328 INIT_WORK(&ar->register_work, ath10k_core_register_work);
2329 INIT_WORK(&ar->restart_work, ath10k_core_restart);
2331 init_dummy_netdev(&ar->napi_dev);
2333 ret = ath10k_debug_create(ar);
2335 goto err_free_aux_wq;
2340 destroy_workqueue(ar->workqueue_aux);
2342 destroy_workqueue(ar->workqueue);
2345 ath10k_mac_destroy(ar);
2349 EXPORT_SYMBOL(ath10k_core_create);
2351 void ath10k_core_destroy(struct ath10k *ar)
2353 flush_workqueue(ar->workqueue);
2354 destroy_workqueue(ar->workqueue);
2356 flush_workqueue(ar->workqueue_aux);
2357 destroy_workqueue(ar->workqueue_aux);
2359 ath10k_debug_destroy(ar);
2360 ath10k_wmi_free_host_mem(ar);
2361 ath10k_mac_destroy(ar);
2363 EXPORT_SYMBOL(ath10k_core_destroy);
2365 MODULE_AUTHOR("Qualcomm Atheros");
2366 MODULE_DESCRIPTION("Core module for Qualcomm Atheros 802.11ac wireless LAN cards.");
2367 MODULE_LICENSE("Dual BSD/GPL");