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>
33 unsigned int ath10k_debug_mask;
34 static unsigned int ath10k_cryptmode_param;
35 static bool uart_print;
38 module_param_named(debug_mask, ath10k_debug_mask, uint, 0644);
39 module_param_named(cryptmode, ath10k_cryptmode_param, uint, 0644);
40 module_param(uart_print, bool, 0644);
41 module_param(skip_otp, bool, 0644);
43 MODULE_PARM_DESC(debug_mask, "Debugging mask");
44 MODULE_PARM_DESC(uart_print, "Uart target debugging");
45 MODULE_PARM_DESC(skip_otp, "Skip otp failure for calibration in testmode");
46 MODULE_PARM_DESC(cryptmode, "Crypto mode: 0-hardware, 1-software");
48 static const struct ath10k_hw_params ath10k_hw_params_list[] = {
50 .id = QCA988X_HW_2_0_VERSION,
51 .name = "qca988x hw2.0",
52 .patch_load_addr = QCA988X_HW_2_0_PATCH_LOAD_ADDR,
54 .has_shifted_cc_wraparound = true,
56 .channel_counters_freq_hz = 88000,
58 .dir = QCA988X_HW_2_0_FW_DIR,
59 .fw = QCA988X_HW_2_0_FW_FILE,
60 .otp = QCA988X_HW_2_0_OTP_FILE,
61 .board = QCA988X_HW_2_0_BOARD_DATA_FILE,
62 .board_size = QCA988X_BOARD_DATA_SZ,
63 .board_ext_size = QCA988X_BOARD_EXT_DATA_SZ,
67 .id = QCA6174_HW_2_1_VERSION,
68 .name = "qca6174 hw2.1",
69 .patch_load_addr = QCA6174_HW_2_1_PATCH_LOAD_ADDR,
72 .channel_counters_freq_hz = 88000,
74 .dir = QCA6174_HW_2_1_FW_DIR,
75 .fw = QCA6174_HW_2_1_FW_FILE,
76 .otp = QCA6174_HW_2_1_OTP_FILE,
77 .board = QCA6174_HW_2_1_BOARD_DATA_FILE,
78 .board_size = QCA6174_BOARD_DATA_SZ,
79 .board_ext_size = QCA6174_BOARD_EXT_DATA_SZ,
83 .id = QCA6174_HW_3_0_VERSION,
84 .name = "qca6174 hw3.0",
85 .patch_load_addr = QCA6174_HW_3_0_PATCH_LOAD_ADDR,
88 .channel_counters_freq_hz = 88000,
90 .dir = QCA6174_HW_3_0_FW_DIR,
91 .fw = QCA6174_HW_3_0_FW_FILE,
92 .otp = QCA6174_HW_3_0_OTP_FILE,
93 .board = QCA6174_HW_3_0_BOARD_DATA_FILE,
94 .board_size = QCA6174_BOARD_DATA_SZ,
95 .board_ext_size = QCA6174_BOARD_EXT_DATA_SZ,
99 .id = QCA6174_HW_3_2_VERSION,
100 .name = "qca6174 hw3.2",
101 .patch_load_addr = QCA6174_HW_3_0_PATCH_LOAD_ADDR,
104 .channel_counters_freq_hz = 88000,
106 /* uses same binaries as hw3.0 */
107 .dir = QCA6174_HW_3_0_FW_DIR,
108 .fw = QCA6174_HW_3_0_FW_FILE,
109 .otp = QCA6174_HW_3_0_OTP_FILE,
110 .board = QCA6174_HW_3_0_BOARD_DATA_FILE,
111 .board_size = QCA6174_BOARD_DATA_SZ,
112 .board_ext_size = QCA6174_BOARD_EXT_DATA_SZ,
116 .id = QCA99X0_HW_2_0_DEV_VERSION,
117 .name = "qca99x0 hw2.0",
118 .patch_load_addr = QCA99X0_HW_2_0_PATCH_LOAD_ADDR,
120 .otp_exe_param = 0x00000700,
121 .continuous_frag_desc = true,
122 .channel_counters_freq_hz = 150000,
124 .dir = QCA99X0_HW_2_0_FW_DIR,
125 .fw = QCA99X0_HW_2_0_FW_FILE,
126 .otp = QCA99X0_HW_2_0_OTP_FILE,
127 .board = QCA99X0_HW_2_0_BOARD_DATA_FILE,
128 .board_size = QCA99X0_BOARD_DATA_SZ,
129 .board_ext_size = QCA99X0_BOARD_EXT_DATA_SZ,
134 static const char *const ath10k_core_fw_feature_str[] = {
135 [ATH10K_FW_FEATURE_EXT_WMI_MGMT_RX] = "wmi-mgmt-rx",
136 [ATH10K_FW_FEATURE_WMI_10X] = "wmi-10.x",
137 [ATH10K_FW_FEATURE_HAS_WMI_MGMT_TX] = "has-wmi-mgmt-tx",
138 [ATH10K_FW_FEATURE_NO_P2P] = "no-p2p",
139 [ATH10K_FW_FEATURE_WMI_10_2] = "wmi-10.2",
140 [ATH10K_FW_FEATURE_MULTI_VIF_PS_SUPPORT] = "multi-vif-ps",
141 [ATH10K_FW_FEATURE_WOWLAN_SUPPORT] = "wowlan",
142 [ATH10K_FW_FEATURE_IGNORE_OTP_RESULT] = "ignore-otp",
143 [ATH10K_FW_FEATURE_NO_NWIFI_DECAP_4ADDR_PADDING] = "no-4addr-pad",
144 [ATH10K_FW_FEATURE_SUPPORTS_SKIP_CLOCK_INIT] = "skip-clock-init",
147 static unsigned int ath10k_core_get_fw_feature_str(char *buf,
149 enum ath10k_fw_features feat)
151 if (feat >= ARRAY_SIZE(ath10k_core_fw_feature_str) ||
152 WARN_ON(!ath10k_core_fw_feature_str[feat])) {
153 return scnprintf(buf, buf_len, "bit%d", feat);
156 return scnprintf(buf, buf_len, "%s", ath10k_core_fw_feature_str[feat]);
159 void ath10k_core_get_fw_features_str(struct ath10k *ar,
163 unsigned int len = 0;
166 for (i = 0; i < ATH10K_FW_FEATURE_COUNT; i++) {
167 if (test_bit(i, ar->fw_features)) {
169 len += scnprintf(buf + len, buf_len - len, ",");
171 len += ath10k_core_get_fw_feature_str(buf + len,
178 static void ath10k_send_suspend_complete(struct ath10k *ar)
180 ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot suspend complete\n");
182 complete(&ar->target_suspend);
185 static int ath10k_init_configure_target(struct ath10k *ar)
190 /* tell target which HTC version it is used*/
191 ret = ath10k_bmi_write32(ar, hi_app_host_interest,
192 HTC_PROTOCOL_VERSION);
194 ath10k_err(ar, "settings HTC version failed\n");
198 /* set the firmware mode to STA/IBSS/AP */
199 ret = ath10k_bmi_read32(ar, hi_option_flag, ¶m_host);
201 ath10k_err(ar, "setting firmware mode (1/2) failed\n");
205 /* TODO following parameters need to be re-visited. */
207 param_host |= (1 << HI_OPTION_NUM_DEV_SHIFT);
209 /* FIXME: Why FW_MODE_AP ??.*/
210 param_host |= (HI_OPTION_FW_MODE_AP << HI_OPTION_FW_MODE_SHIFT);
211 /* mac_addr_method */
212 param_host |= (1 << HI_OPTION_MAC_ADDR_METHOD_SHIFT);
213 /* firmware_bridge */
214 param_host |= (0 << HI_OPTION_FW_BRIDGE_SHIFT);
216 param_host |= (0 << HI_OPTION_FW_SUBMODE_SHIFT);
218 ret = ath10k_bmi_write32(ar, hi_option_flag, param_host);
220 ath10k_err(ar, "setting firmware mode (2/2) failed\n");
224 /* We do all byte-swapping on the host */
225 ret = ath10k_bmi_write32(ar, hi_be, 0);
227 ath10k_err(ar, "setting host CPU BE mode failed\n");
231 /* FW descriptor/Data swap flags */
232 ret = ath10k_bmi_write32(ar, hi_fw_swap, 0);
235 ath10k_err(ar, "setting FW data/desc swap flags failed\n");
239 /* Some devices have a special sanity check that verifies the PCI
240 * Device ID is written to this host interest var. It is known to be
241 * required to boot QCA6164.
243 ret = ath10k_bmi_write32(ar, hi_hci_uart_pwr_mgmt_params_ext,
246 ath10k_err(ar, "failed to set pwr_mgmt_params: %d\n", ret);
253 static const struct firmware *ath10k_fetch_fw_file(struct ath10k *ar,
258 const struct firmware *fw;
262 return ERR_PTR(-ENOENT);
267 snprintf(filename, sizeof(filename), "%s/%s", dir, file);
268 ret = request_firmware(&fw, filename, ar->dev);
275 static int ath10k_push_board_ext_data(struct ath10k *ar, const void *data,
278 u32 board_data_size = ar->hw_params.fw.board_size;
279 u32 board_ext_data_size = ar->hw_params.fw.board_ext_size;
280 u32 board_ext_data_addr;
283 ret = ath10k_bmi_read32(ar, hi_board_ext_data, &board_ext_data_addr);
285 ath10k_err(ar, "could not read board ext data addr (%d)\n",
290 ath10k_dbg(ar, ATH10K_DBG_BOOT,
291 "boot push board extended data addr 0x%x\n",
292 board_ext_data_addr);
294 if (board_ext_data_addr == 0)
297 if (data_len != (board_data_size + board_ext_data_size)) {
298 ath10k_err(ar, "invalid board (ext) data sizes %zu != %d+%d\n",
299 data_len, board_data_size, board_ext_data_size);
303 ret = ath10k_bmi_write_memory(ar, board_ext_data_addr,
304 data + board_data_size,
305 board_ext_data_size);
307 ath10k_err(ar, "could not write board ext data (%d)\n", ret);
311 ret = ath10k_bmi_write32(ar, hi_board_ext_data_config,
312 (board_ext_data_size << 16) | 1);
314 ath10k_err(ar, "could not write board ext data bit (%d)\n",
322 static int ath10k_download_board_data(struct ath10k *ar, const void *data,
325 u32 board_data_size = ar->hw_params.fw.board_size;
329 ret = ath10k_push_board_ext_data(ar, data, data_len);
331 ath10k_err(ar, "could not push board ext data (%d)\n", ret);
335 ret = ath10k_bmi_read32(ar, hi_board_data, &address);
337 ath10k_err(ar, "could not read board data addr (%d)\n", ret);
341 ret = ath10k_bmi_write_memory(ar, address, data,
342 min_t(u32, board_data_size,
345 ath10k_err(ar, "could not write board data (%d)\n", ret);
349 ret = ath10k_bmi_write32(ar, hi_board_data_initialized, 1);
351 ath10k_err(ar, "could not write board data bit (%d)\n", ret);
359 static int ath10k_download_cal_file(struct ath10k *ar)
366 if (IS_ERR(ar->cal_file))
367 return PTR_ERR(ar->cal_file);
369 ret = ath10k_download_board_data(ar, ar->cal_file->data,
372 ath10k_err(ar, "failed to download cal_file data: %d\n", ret);
376 ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot cal file downloaded\n");
381 static int ath10k_download_cal_dt(struct ath10k *ar)
383 struct device_node *node;
388 node = ar->dev->of_node;
390 /* Device Tree is optional, don't print any warnings if
391 * there's no node for ath10k.
395 if (!of_get_property(node, "qcom,ath10k-calibration-data",
397 /* The calibration data node is optional */
401 if (data_len != QCA988X_CAL_DATA_LEN) {
402 ath10k_warn(ar, "invalid calibration data length in DT: %d\n",
408 data = kmalloc(data_len, GFP_KERNEL);
414 ret = of_property_read_u8_array(node, "qcom,ath10k-calibration-data",
417 ath10k_warn(ar, "failed to read calibration data from DT: %d\n",
422 ret = ath10k_download_board_data(ar, data, data_len);
424 ath10k_warn(ar, "failed to download calibration data from Device Tree: %d\n",
438 static int ath10k_download_and_run_otp(struct ath10k *ar)
440 u32 result, address = ar->hw_params.patch_load_addr;
441 u32 bmi_otp_exe_param = ar->hw_params.otp_exe_param;
444 ret = ath10k_download_board_data(ar, ar->board_data, ar->board_len);
446 ath10k_err(ar, "failed to download board data: %d\n", ret);
450 /* OTP is optional */
452 if (!ar->otp_data || !ar->otp_len) {
453 ath10k_warn(ar, "Not running otp, calibration will be incorrect (otp-data %p otp_len %zd)!\n",
454 ar->otp_data, ar->otp_len);
458 ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot upload otp to 0x%x len %zd\n",
459 address, ar->otp_len);
461 ret = ath10k_bmi_fast_download(ar, address, ar->otp_data, ar->otp_len);
463 ath10k_err(ar, "could not write otp (%d)\n", ret);
467 ret = ath10k_bmi_execute(ar, address, bmi_otp_exe_param, &result);
469 ath10k_err(ar, "could not execute otp (%d)\n", ret);
473 ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot otp execute result %d\n", result);
475 if (!(skip_otp || test_bit(ATH10K_FW_FEATURE_IGNORE_OTP_RESULT,
478 ath10k_err(ar, "otp calibration failed: %d", result);
485 static int ath10k_download_fw(struct ath10k *ar, enum ath10k_firmware_mode mode)
487 u32 address, data_len;
488 const char *mode_name;
492 address = ar->hw_params.patch_load_addr;
495 case ATH10K_FIRMWARE_MODE_NORMAL:
496 data = ar->firmware_data;
497 data_len = ar->firmware_len;
498 mode_name = "normal";
499 ret = ath10k_swap_code_seg_configure(ar,
500 ATH10K_SWAP_CODE_SEG_BIN_TYPE_FW);
502 ath10k_err(ar, "failed to configure fw code swap: %d\n",
507 case ATH10K_FIRMWARE_MODE_UTF:
508 data = ar->testmode.utf->data;
509 data_len = ar->testmode.utf->size;
513 ath10k_err(ar, "unknown firmware mode: %d\n", mode);
517 ath10k_dbg(ar, ATH10K_DBG_BOOT,
518 "boot uploading firmware image %p len %d mode %s\n",
519 data, data_len, mode_name);
521 ret = ath10k_bmi_fast_download(ar, address, data, data_len);
523 ath10k_err(ar, "failed to download %s firmware: %d\n",
531 static void ath10k_core_free_firmware_files(struct ath10k *ar)
533 if (!IS_ERR(ar->board))
534 release_firmware(ar->board);
536 if (!IS_ERR(ar->otp))
537 release_firmware(ar->otp);
539 if (!IS_ERR(ar->firmware))
540 release_firmware(ar->firmware);
542 if (!IS_ERR(ar->cal_file))
543 release_firmware(ar->cal_file);
545 ath10k_swap_code_seg_release(ar);
548 ar->board_data = NULL;
556 ar->firmware_data = NULL;
557 ar->firmware_len = 0;
563 static int ath10k_fetch_cal_file(struct ath10k *ar)
567 /* cal-<bus>-<id>.bin */
568 scnprintf(filename, sizeof(filename), "cal-%s-%s.bin",
569 ath10k_bus_str(ar->hif.bus), dev_name(ar->dev));
571 ar->cal_file = ath10k_fetch_fw_file(ar, ATH10K_FW_DIR, filename);
572 if (IS_ERR(ar->cal_file))
573 /* calibration file is optional, don't print any warnings */
574 return PTR_ERR(ar->cal_file);
576 ath10k_dbg(ar, ATH10K_DBG_BOOT, "found calibration file %s/%s\n",
577 ATH10K_FW_DIR, filename);
582 static int ath10k_core_fetch_spec_board_file(struct ath10k *ar)
586 scnprintf(filename, sizeof(filename), "board-%s-%s.bin",
587 ath10k_bus_str(ar->hif.bus), ar->spec_board_id);
589 ar->board = ath10k_fetch_fw_file(ar, ar->hw_params.fw.dir, filename);
590 if (IS_ERR(ar->board))
591 return PTR_ERR(ar->board);
593 ar->board_data = ar->board->data;
594 ar->board_len = ar->board->size;
595 ar->spec_board_loaded = true;
600 static int ath10k_core_fetch_generic_board_file(struct ath10k *ar)
602 if (!ar->hw_params.fw.board) {
603 ath10k_err(ar, "failed to find board file fw entry\n");
607 ar->board = ath10k_fetch_fw_file(ar,
608 ar->hw_params.fw.dir,
609 ar->hw_params.fw.board);
610 if (IS_ERR(ar->board))
611 return PTR_ERR(ar->board);
613 ar->board_data = ar->board->data;
614 ar->board_len = ar->board->size;
615 ar->spec_board_loaded = false;
620 static int ath10k_core_fetch_board_file(struct ath10k *ar)
624 if (strlen(ar->spec_board_id) > 0) {
625 ret = ath10k_core_fetch_spec_board_file(ar);
627 ath10k_info(ar, "failed to load spec board file, falling back to generic: %d\n",
632 ath10k_dbg(ar, ATH10K_DBG_BOOT, "found specific board file for %s\n",
638 ret = ath10k_core_fetch_generic_board_file(ar);
640 ath10k_err(ar, "failed to fetch generic board data: %d\n", ret);
647 static int ath10k_core_fetch_firmware_api_1(struct ath10k *ar)
651 if (ar->hw_params.fw.fw == NULL) {
652 ath10k_err(ar, "firmware file not defined\n");
656 ar->firmware = ath10k_fetch_fw_file(ar,
657 ar->hw_params.fw.dir,
658 ar->hw_params.fw.fw);
659 if (IS_ERR(ar->firmware)) {
660 ret = PTR_ERR(ar->firmware);
661 ath10k_err(ar, "could not fetch firmware (%d)\n", ret);
665 ar->firmware_data = ar->firmware->data;
666 ar->firmware_len = ar->firmware->size;
668 /* OTP may be undefined. If so, don't fetch it at all */
669 if (ar->hw_params.fw.otp == NULL)
672 ar->otp = ath10k_fetch_fw_file(ar,
673 ar->hw_params.fw.dir,
674 ar->hw_params.fw.otp);
675 if (IS_ERR(ar->otp)) {
676 ret = PTR_ERR(ar->otp);
677 ath10k_err(ar, "could not fetch otp (%d)\n", ret);
681 ar->otp_data = ar->otp->data;
682 ar->otp_len = ar->otp->size;
687 ath10k_core_free_firmware_files(ar);
691 static int ath10k_core_fetch_firmware_api_n(struct ath10k *ar, const char *name)
693 size_t magic_len, len, ie_len;
694 int ie_id, i, index, bit, ret;
695 struct ath10k_fw_ie *hdr;
697 __le32 *timestamp, *version;
699 /* first fetch the firmware file (firmware-*.bin) */
700 ar->firmware = ath10k_fetch_fw_file(ar, ar->hw_params.fw.dir, name);
701 if (IS_ERR(ar->firmware)) {
702 ath10k_err(ar, "could not fetch firmware file '%s/%s': %ld\n",
703 ar->hw_params.fw.dir, name, PTR_ERR(ar->firmware));
704 return PTR_ERR(ar->firmware);
707 data = ar->firmware->data;
708 len = ar->firmware->size;
710 /* magic also includes the null byte, check that as well */
711 magic_len = strlen(ATH10K_FIRMWARE_MAGIC) + 1;
713 if (len < magic_len) {
714 ath10k_err(ar, "firmware file '%s/%s' too small to contain magic: %zu\n",
715 ar->hw_params.fw.dir, name, len);
720 if (memcmp(data, ATH10K_FIRMWARE_MAGIC, magic_len) != 0) {
721 ath10k_err(ar, "invalid firmware magic\n");
726 /* jump over the padding */
727 magic_len = ALIGN(magic_len, 4);
733 while (len > sizeof(struct ath10k_fw_ie)) {
734 hdr = (struct ath10k_fw_ie *)data;
736 ie_id = le32_to_cpu(hdr->id);
737 ie_len = le32_to_cpu(hdr->len);
740 data += sizeof(*hdr);
743 ath10k_err(ar, "invalid length for FW IE %d (%zu < %zu)\n",
750 case ATH10K_FW_IE_FW_VERSION:
751 if (ie_len > sizeof(ar->hw->wiphy->fw_version) - 1)
754 memcpy(ar->hw->wiphy->fw_version, data, ie_len);
755 ar->hw->wiphy->fw_version[ie_len] = '\0';
757 ath10k_dbg(ar, ATH10K_DBG_BOOT,
758 "found fw version %s\n",
759 ar->hw->wiphy->fw_version);
761 case ATH10K_FW_IE_TIMESTAMP:
762 if (ie_len != sizeof(u32))
765 timestamp = (__le32 *)data;
767 ath10k_dbg(ar, ATH10K_DBG_BOOT, "found fw timestamp %d\n",
768 le32_to_cpup(timestamp));
770 case ATH10K_FW_IE_FEATURES:
771 ath10k_dbg(ar, ATH10K_DBG_BOOT,
772 "found firmware features ie (%zd B)\n",
775 for (i = 0; i < ATH10K_FW_FEATURE_COUNT; i++) {
782 if (data[index] & (1 << bit)) {
783 ath10k_dbg(ar, ATH10K_DBG_BOOT,
784 "Enabling feature bit: %i\n",
786 __set_bit(i, ar->fw_features);
790 ath10k_dbg_dump(ar, ATH10K_DBG_BOOT, "features", "",
792 sizeof(ar->fw_features));
794 case ATH10K_FW_IE_FW_IMAGE:
795 ath10k_dbg(ar, ATH10K_DBG_BOOT,
796 "found fw image ie (%zd B)\n",
799 ar->firmware_data = data;
800 ar->firmware_len = ie_len;
803 case ATH10K_FW_IE_OTP_IMAGE:
804 ath10k_dbg(ar, ATH10K_DBG_BOOT,
805 "found otp image ie (%zd B)\n",
809 ar->otp_len = ie_len;
812 case ATH10K_FW_IE_WMI_OP_VERSION:
813 if (ie_len != sizeof(u32))
816 version = (__le32 *)data;
818 ar->wmi.op_version = le32_to_cpup(version);
820 ath10k_dbg(ar, ATH10K_DBG_BOOT, "found fw ie wmi op version %d\n",
823 case ATH10K_FW_IE_HTT_OP_VERSION:
824 if (ie_len != sizeof(u32))
827 version = (__le32 *)data;
829 ar->htt.op_version = le32_to_cpup(version);
831 ath10k_dbg(ar, ATH10K_DBG_BOOT, "found fw ie htt op version %d\n",
834 case ATH10K_FW_IE_FW_CODE_SWAP_IMAGE:
835 ath10k_dbg(ar, ATH10K_DBG_BOOT,
836 "found fw code swap image ie (%zd B)\n",
838 ar->swap.firmware_codeswap_data = data;
839 ar->swap.firmware_codeswap_len = ie_len;
842 ath10k_warn(ar, "Unknown FW IE: %u\n",
843 le32_to_cpu(hdr->id));
847 /* jump over the padding */
848 ie_len = ALIGN(ie_len, 4);
854 if (!ar->firmware_data || !ar->firmware_len) {
855 ath10k_warn(ar, "No ATH10K_FW_IE_FW_IMAGE found from '%s/%s', skipping\n",
856 ar->hw_params.fw.dir, name);
864 ath10k_core_free_firmware_files(ar);
868 static int ath10k_core_fetch_firmware_files(struct ath10k *ar)
872 /* calibration file is optional, don't check for any errors */
873 ath10k_fetch_cal_file(ar);
875 ret = ath10k_core_fetch_board_file(ar);
877 ath10k_err(ar, "failed to fetch board file: %d\n", ret);
882 ath10k_dbg(ar, ATH10K_DBG_BOOT, "trying fw api %d\n", ar->fw_api);
884 ret = ath10k_core_fetch_firmware_api_n(ar, ATH10K_FW_API5_FILE);
889 ath10k_dbg(ar, ATH10K_DBG_BOOT, "trying fw api %d\n", ar->fw_api);
891 ret = ath10k_core_fetch_firmware_api_n(ar, ATH10K_FW_API4_FILE);
896 ath10k_dbg(ar, ATH10K_DBG_BOOT, "trying fw api %d\n", ar->fw_api);
898 ret = ath10k_core_fetch_firmware_api_n(ar, ATH10K_FW_API3_FILE);
903 ath10k_dbg(ar, ATH10K_DBG_BOOT, "trying fw api %d\n", ar->fw_api);
905 ret = ath10k_core_fetch_firmware_api_n(ar, ATH10K_FW_API2_FILE);
910 ath10k_dbg(ar, ATH10K_DBG_BOOT, "trying fw api %d\n", ar->fw_api);
912 ret = ath10k_core_fetch_firmware_api_1(ar);
917 ath10k_dbg(ar, ATH10K_DBG_BOOT, "using fw api %d\n", ar->fw_api);
922 static int ath10k_download_cal_data(struct ath10k *ar)
926 ret = ath10k_download_cal_file(ar);
928 ar->cal_mode = ATH10K_CAL_MODE_FILE;
932 ath10k_dbg(ar, ATH10K_DBG_BOOT,
933 "boot did not find a calibration file, try DT next: %d\n",
936 ret = ath10k_download_cal_dt(ar);
938 ar->cal_mode = ATH10K_CAL_MODE_DT;
942 ath10k_dbg(ar, ATH10K_DBG_BOOT,
943 "boot did not find DT entry, try OTP next: %d\n",
946 ret = ath10k_download_and_run_otp(ar);
948 ath10k_err(ar, "failed to run otp: %d\n", ret);
952 ar->cal_mode = ATH10K_CAL_MODE_OTP;
955 ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot using calibration mode %s\n",
956 ath10k_cal_mode_str(ar->cal_mode));
960 static int ath10k_init_uart(struct ath10k *ar)
965 * Explicitly setting UART prints to zero as target turns it on
966 * based on scratch registers.
968 ret = ath10k_bmi_write32(ar, hi_serial_enable, 0);
970 ath10k_warn(ar, "could not disable UART prints (%d)\n", ret);
977 ret = ath10k_bmi_write32(ar, hi_dbg_uart_txpin, ar->hw_params.uart_pin);
979 ath10k_warn(ar, "could not enable UART prints (%d)\n", ret);
983 ret = ath10k_bmi_write32(ar, hi_serial_enable, 1);
985 ath10k_warn(ar, "could not enable UART prints (%d)\n", ret);
989 /* Set the UART baud rate to 19200. */
990 ret = ath10k_bmi_write32(ar, hi_desired_baud_rate, 19200);
992 ath10k_warn(ar, "could not set the baud rate (%d)\n", ret);
996 ath10k_info(ar, "UART prints enabled\n");
1000 static int ath10k_init_hw_params(struct ath10k *ar)
1002 const struct ath10k_hw_params *uninitialized_var(hw_params);
1005 for (i = 0; i < ARRAY_SIZE(ath10k_hw_params_list); i++) {
1006 hw_params = &ath10k_hw_params_list[i];
1008 if (hw_params->id == ar->target_version)
1012 if (i == ARRAY_SIZE(ath10k_hw_params_list)) {
1013 ath10k_err(ar, "Unsupported hardware version: 0x%x\n",
1014 ar->target_version);
1018 ar->hw_params = *hw_params;
1020 ath10k_dbg(ar, ATH10K_DBG_BOOT, "Hardware name %s version 0x%x\n",
1021 ar->hw_params.name, ar->target_version);
1026 static void ath10k_core_restart(struct work_struct *work)
1028 struct ath10k *ar = container_of(work, struct ath10k, restart_work);
1030 set_bit(ATH10K_FLAG_CRASH_FLUSH, &ar->dev_flags);
1032 /* Place a barrier to make sure the compiler doesn't reorder
1033 * CRASH_FLUSH and calling other functions.
1037 ieee80211_stop_queues(ar->hw);
1038 ath10k_drain_tx(ar);
1039 complete_all(&ar->scan.started);
1040 complete_all(&ar->scan.completed);
1041 complete_all(&ar->scan.on_channel);
1042 complete_all(&ar->offchan_tx_completed);
1043 complete_all(&ar->install_key_done);
1044 complete_all(&ar->vdev_setup_done);
1045 complete_all(&ar->thermal.wmi_sync);
1046 wake_up(&ar->htt.empty_tx_wq);
1047 wake_up(&ar->wmi.tx_credits_wq);
1048 wake_up(&ar->peer_mapping_wq);
1050 mutex_lock(&ar->conf_mutex);
1052 switch (ar->state) {
1053 case ATH10K_STATE_ON:
1054 ar->state = ATH10K_STATE_RESTARTING;
1055 ath10k_hif_stop(ar);
1056 ath10k_scan_finish(ar);
1057 ieee80211_restart_hw(ar->hw);
1059 case ATH10K_STATE_OFF:
1060 /* this can happen if driver is being unloaded
1061 * or if the crash happens during FW probing */
1062 ath10k_warn(ar, "cannot restart a device that hasn't been started\n");
1064 case ATH10K_STATE_RESTARTING:
1065 /* hw restart might be requested from multiple places */
1067 case ATH10K_STATE_RESTARTED:
1068 ar->state = ATH10K_STATE_WEDGED;
1070 case ATH10K_STATE_WEDGED:
1071 ath10k_warn(ar, "device is wedged, will not restart\n");
1073 case ATH10K_STATE_UTF:
1074 ath10k_warn(ar, "firmware restart in UTF mode not supported\n");
1078 mutex_unlock(&ar->conf_mutex);
1081 static int ath10k_core_init_firmware_features(struct ath10k *ar)
1083 if (test_bit(ATH10K_FW_FEATURE_WMI_10_2, ar->fw_features) &&
1084 !test_bit(ATH10K_FW_FEATURE_WMI_10X, ar->fw_features)) {
1085 ath10k_err(ar, "feature bits corrupted: 10.2 feature requires 10.x feature to be set as well");
1089 if (ar->wmi.op_version >= ATH10K_FW_WMI_OP_VERSION_MAX) {
1090 ath10k_err(ar, "unsupported WMI OP version (max %d): %d\n",
1091 ATH10K_FW_WMI_OP_VERSION_MAX, ar->wmi.op_version);
1095 ar->wmi.rx_decap_mode = ATH10K_HW_TXRX_NATIVE_WIFI;
1096 switch (ath10k_cryptmode_param) {
1097 case ATH10K_CRYPT_MODE_HW:
1098 clear_bit(ATH10K_FLAG_RAW_MODE, &ar->dev_flags);
1099 clear_bit(ATH10K_FLAG_HW_CRYPTO_DISABLED, &ar->dev_flags);
1101 case ATH10K_CRYPT_MODE_SW:
1102 if (!test_bit(ATH10K_FW_FEATURE_RAW_MODE_SUPPORT,
1104 ath10k_err(ar, "cryptmode > 0 requires raw mode support from firmware");
1108 set_bit(ATH10K_FLAG_RAW_MODE, &ar->dev_flags);
1109 set_bit(ATH10K_FLAG_HW_CRYPTO_DISABLED, &ar->dev_flags);
1112 ath10k_info(ar, "invalid cryptmode: %d\n",
1113 ath10k_cryptmode_param);
1117 ar->htt.max_num_amsdu = ATH10K_HTT_MAX_NUM_AMSDU_DEFAULT;
1118 ar->htt.max_num_ampdu = ATH10K_HTT_MAX_NUM_AMPDU_DEFAULT;
1120 if (test_bit(ATH10K_FLAG_RAW_MODE, &ar->dev_flags)) {
1121 ar->wmi.rx_decap_mode = ATH10K_HW_TXRX_RAW;
1125 * Firmware A-MSDU aggregation breaks with RAW Tx encap mode
1126 * and causes enormous performance issues (malformed frames,
1129 * Disabling A-MSDU makes RAW mode stable with heavy traffic
1130 * albeit a bit slower compared to regular operation.
1132 ar->htt.max_num_amsdu = 1;
1135 /* Backwards compatibility for firmwares without
1136 * ATH10K_FW_IE_WMI_OP_VERSION.
1138 if (ar->wmi.op_version == ATH10K_FW_WMI_OP_VERSION_UNSET) {
1139 if (test_bit(ATH10K_FW_FEATURE_WMI_10X, ar->fw_features)) {
1140 if (test_bit(ATH10K_FW_FEATURE_WMI_10_2,
1142 ar->wmi.op_version = ATH10K_FW_WMI_OP_VERSION_10_2;
1144 ar->wmi.op_version = ATH10K_FW_WMI_OP_VERSION_10_1;
1146 ar->wmi.op_version = ATH10K_FW_WMI_OP_VERSION_MAIN;
1150 switch (ar->wmi.op_version) {
1151 case ATH10K_FW_WMI_OP_VERSION_MAIN:
1152 ar->max_num_peers = TARGET_NUM_PEERS;
1153 ar->max_num_stations = TARGET_NUM_STATIONS;
1154 ar->max_num_vdevs = TARGET_NUM_VDEVS;
1155 ar->htt.max_num_pending_tx = TARGET_NUM_MSDU_DESC;
1156 ar->fw_stats_req_mask = WMI_STAT_PDEV | WMI_STAT_VDEV |
1158 ar->max_spatial_stream = WMI_MAX_SPATIAL_STREAM;
1160 case ATH10K_FW_WMI_OP_VERSION_10_1:
1161 case ATH10K_FW_WMI_OP_VERSION_10_2:
1162 case ATH10K_FW_WMI_OP_VERSION_10_2_4:
1163 ar->max_num_peers = TARGET_10X_NUM_PEERS;
1164 ar->max_num_stations = TARGET_10X_NUM_STATIONS;
1165 ar->max_num_vdevs = TARGET_10X_NUM_VDEVS;
1166 ar->htt.max_num_pending_tx = TARGET_10X_NUM_MSDU_DESC;
1167 ar->fw_stats_req_mask = WMI_STAT_PEER;
1168 ar->max_spatial_stream = WMI_MAX_SPATIAL_STREAM;
1170 case ATH10K_FW_WMI_OP_VERSION_TLV:
1171 ar->max_num_peers = TARGET_TLV_NUM_PEERS;
1172 ar->max_num_stations = TARGET_TLV_NUM_STATIONS;
1173 ar->max_num_vdevs = TARGET_TLV_NUM_VDEVS;
1174 ar->max_num_tdls_vdevs = TARGET_TLV_NUM_TDLS_VDEVS;
1175 ar->htt.max_num_pending_tx = TARGET_TLV_NUM_MSDU_DESC;
1176 ar->wow.max_num_patterns = TARGET_TLV_NUM_WOW_PATTERNS;
1177 ar->fw_stats_req_mask = WMI_STAT_PDEV | WMI_STAT_VDEV |
1179 ar->max_spatial_stream = WMI_MAX_SPATIAL_STREAM;
1181 case ATH10K_FW_WMI_OP_VERSION_10_4:
1182 ar->max_num_peers = TARGET_10_4_NUM_PEERS;
1183 ar->max_num_stations = TARGET_10_4_NUM_STATIONS;
1184 ar->num_active_peers = TARGET_10_4_ACTIVE_PEERS;
1185 ar->max_num_vdevs = TARGET_10_4_NUM_VDEVS;
1186 ar->num_tids = TARGET_10_4_TGT_NUM_TIDS;
1187 ar->htt.max_num_pending_tx = TARGET_10_4_NUM_MSDU_DESC;
1188 ar->fw_stats_req_mask = WMI_STAT_PEER;
1189 ar->max_spatial_stream = WMI_10_4_MAX_SPATIAL_STREAM;
1191 case ATH10K_FW_WMI_OP_VERSION_UNSET:
1192 case ATH10K_FW_WMI_OP_VERSION_MAX:
1197 /* Backwards compatibility for firmwares without
1198 * ATH10K_FW_IE_HTT_OP_VERSION.
1200 if (ar->htt.op_version == ATH10K_FW_HTT_OP_VERSION_UNSET) {
1201 switch (ar->wmi.op_version) {
1202 case ATH10K_FW_WMI_OP_VERSION_MAIN:
1203 ar->htt.op_version = ATH10K_FW_HTT_OP_VERSION_MAIN;
1205 case ATH10K_FW_WMI_OP_VERSION_10_1:
1206 case ATH10K_FW_WMI_OP_VERSION_10_2:
1207 case ATH10K_FW_WMI_OP_VERSION_10_2_4:
1208 ar->htt.op_version = ATH10K_FW_HTT_OP_VERSION_10_1;
1210 case ATH10K_FW_WMI_OP_VERSION_TLV:
1211 ar->htt.op_version = ATH10K_FW_HTT_OP_VERSION_TLV;
1213 case ATH10K_FW_WMI_OP_VERSION_10_4:
1214 case ATH10K_FW_WMI_OP_VERSION_UNSET:
1215 case ATH10K_FW_WMI_OP_VERSION_MAX:
1224 int ath10k_core_start(struct ath10k *ar, enum ath10k_firmware_mode mode)
1228 lockdep_assert_held(&ar->conf_mutex);
1230 clear_bit(ATH10K_FLAG_CRASH_FLUSH, &ar->dev_flags);
1232 ath10k_bmi_start(ar);
1234 if (ath10k_init_configure_target(ar)) {
1239 status = ath10k_download_cal_data(ar);
1243 /* Some of of qca988x solutions are having global reset issue
1244 * during target initialization. Bypassing PLL setting before
1245 * downloading firmware and letting the SoC run on REF_CLK is
1246 * fixing the problem. Corresponding firmware change is also needed
1247 * to set the clock source once the target is initialized.
1249 if (test_bit(ATH10K_FW_FEATURE_SUPPORTS_SKIP_CLOCK_INIT,
1251 status = ath10k_bmi_write32(ar, hi_skip_clock_init, 1);
1253 ath10k_err(ar, "could not write to skip_clock_init: %d\n",
1259 status = ath10k_download_fw(ar, mode);
1263 status = ath10k_init_uart(ar);
1267 ar->htc.htc_ops.target_send_suspend_complete =
1268 ath10k_send_suspend_complete;
1270 status = ath10k_htc_init(ar);
1272 ath10k_err(ar, "could not init HTC (%d)\n", status);
1276 status = ath10k_bmi_done(ar);
1280 status = ath10k_wmi_attach(ar);
1282 ath10k_err(ar, "WMI attach failed: %d\n", status);
1286 status = ath10k_htt_init(ar);
1288 ath10k_err(ar, "failed to init htt: %d\n", status);
1289 goto err_wmi_detach;
1292 status = ath10k_htt_tx_alloc(&ar->htt);
1294 ath10k_err(ar, "failed to alloc htt tx: %d\n", status);
1295 goto err_wmi_detach;
1298 status = ath10k_htt_rx_alloc(&ar->htt);
1300 ath10k_err(ar, "failed to alloc htt rx: %d\n", status);
1301 goto err_htt_tx_detach;
1304 status = ath10k_hif_start(ar);
1306 ath10k_err(ar, "could not start HIF: %d\n", status);
1307 goto err_htt_rx_detach;
1310 status = ath10k_htc_wait_target(&ar->htc);
1312 ath10k_err(ar, "failed to connect to HTC: %d\n", status);
1316 if (mode == ATH10K_FIRMWARE_MODE_NORMAL) {
1317 status = ath10k_htt_connect(&ar->htt);
1319 ath10k_err(ar, "failed to connect htt (%d)\n", status);
1324 status = ath10k_wmi_connect(ar);
1326 ath10k_err(ar, "could not connect wmi: %d\n", status);
1330 status = ath10k_htc_start(&ar->htc);
1332 ath10k_err(ar, "failed to start htc: %d\n", status);
1336 if (mode == ATH10K_FIRMWARE_MODE_NORMAL) {
1337 status = ath10k_wmi_wait_for_service_ready(ar);
1339 ath10k_warn(ar, "wmi service ready event not received");
1344 ath10k_dbg(ar, ATH10K_DBG_BOOT, "firmware %s booted\n",
1345 ar->hw->wiphy->fw_version);
1347 status = ath10k_wmi_cmd_init(ar);
1349 ath10k_err(ar, "could not send WMI init command (%d)\n",
1354 status = ath10k_wmi_wait_for_unified_ready(ar);
1356 ath10k_err(ar, "wmi unified ready event not received\n");
1360 /* If firmware indicates Full Rx Reorder support it must be used in a
1361 * slightly different manner. Let HTT code know.
1363 ar->htt.rx_ring.in_ord_rx = !!(test_bit(WMI_SERVICE_RX_FULL_REORDER,
1366 status = ath10k_htt_rx_ring_refill(ar);
1368 ath10k_err(ar, "failed to refill htt rx ring: %d\n", status);
1372 /* we don't care about HTT in UTF mode */
1373 if (mode == ATH10K_FIRMWARE_MODE_NORMAL) {
1374 status = ath10k_htt_setup(&ar->htt);
1376 ath10k_err(ar, "failed to setup htt: %d\n", status);
1381 status = ath10k_debug_start(ar);
1385 ar->free_vdev_map = (1LL << ar->max_num_vdevs) - 1;
1387 INIT_LIST_HEAD(&ar->arvifs);
1392 ath10k_hif_stop(ar);
1394 ath10k_htt_rx_free(&ar->htt);
1396 ath10k_htt_tx_free(&ar->htt);
1398 ath10k_wmi_detach(ar);
1402 EXPORT_SYMBOL(ath10k_core_start);
1404 int ath10k_wait_for_suspend(struct ath10k *ar, u32 suspend_opt)
1407 unsigned long time_left;
1409 reinit_completion(&ar->target_suspend);
1411 ret = ath10k_wmi_pdev_suspend_target(ar, suspend_opt);
1413 ath10k_warn(ar, "could not suspend target (%d)\n", ret);
1417 time_left = wait_for_completion_timeout(&ar->target_suspend, 1 * HZ);
1420 ath10k_warn(ar, "suspend timed out - target pause event never came\n");
1427 void ath10k_core_stop(struct ath10k *ar)
1429 lockdep_assert_held(&ar->conf_mutex);
1430 ath10k_debug_stop(ar);
1432 /* try to suspend target */
1433 if (ar->state != ATH10K_STATE_RESTARTING &&
1434 ar->state != ATH10K_STATE_UTF)
1435 ath10k_wait_for_suspend(ar, WMI_PDEV_SUSPEND_AND_DISABLE_INTR);
1437 ath10k_hif_stop(ar);
1438 ath10k_htt_tx_free(&ar->htt);
1439 ath10k_htt_rx_free(&ar->htt);
1440 ath10k_wmi_detach(ar);
1442 EXPORT_SYMBOL(ath10k_core_stop);
1444 /* mac80211 manages fw/hw initialization through start/stop hooks. However in
1445 * order to know what hw capabilities should be advertised to mac80211 it is
1446 * necessary to load the firmware (and tear it down immediately since start
1447 * hook will try to init it again) before registering */
1448 static int ath10k_core_probe_fw(struct ath10k *ar)
1450 struct bmi_target_info target_info;
1453 ret = ath10k_hif_power_up(ar);
1455 ath10k_err(ar, "could not start pci hif (%d)\n", ret);
1459 memset(&target_info, 0, sizeof(target_info));
1460 ret = ath10k_bmi_get_target_info(ar, &target_info);
1462 ath10k_err(ar, "could not get target info (%d)\n", ret);
1463 goto err_power_down;
1466 ar->target_version = target_info.version;
1467 ar->hw->wiphy->hw_version = target_info.version;
1469 ret = ath10k_init_hw_params(ar);
1471 ath10k_err(ar, "could not get hw params (%d)\n", ret);
1472 goto err_power_down;
1475 ret = ath10k_core_fetch_firmware_files(ar);
1477 ath10k_err(ar, "could not fetch firmware files (%d)\n", ret);
1478 goto err_power_down;
1481 ret = ath10k_core_init_firmware_features(ar);
1483 ath10k_err(ar, "fatal problem with firmware features: %d\n",
1485 goto err_free_firmware_files;
1488 ret = ath10k_swap_code_seg_init(ar);
1490 ath10k_err(ar, "failed to initialize code swap segment: %d\n",
1492 goto err_free_firmware_files;
1495 mutex_lock(&ar->conf_mutex);
1497 ret = ath10k_core_start(ar, ATH10K_FIRMWARE_MODE_NORMAL);
1499 ath10k_err(ar, "could not init core (%d)\n", ret);
1503 ath10k_print_driver_info(ar);
1504 ath10k_core_stop(ar);
1506 mutex_unlock(&ar->conf_mutex);
1508 ath10k_hif_power_down(ar);
1512 mutex_unlock(&ar->conf_mutex);
1514 err_free_firmware_files:
1515 ath10k_core_free_firmware_files(ar);
1518 ath10k_hif_power_down(ar);
1523 static void ath10k_core_register_work(struct work_struct *work)
1525 struct ath10k *ar = container_of(work, struct ath10k, register_work);
1528 status = ath10k_core_probe_fw(ar);
1530 ath10k_err(ar, "could not probe fw (%d)\n", status);
1534 status = ath10k_mac_register(ar);
1536 ath10k_err(ar, "could not register to mac80211 (%d)\n", status);
1537 goto err_release_fw;
1540 status = ath10k_debug_register(ar);
1542 ath10k_err(ar, "unable to initialize debugfs\n");
1543 goto err_unregister_mac;
1546 status = ath10k_spectral_create(ar);
1548 ath10k_err(ar, "failed to initialize spectral\n");
1549 goto err_debug_destroy;
1552 status = ath10k_thermal_register(ar);
1554 ath10k_err(ar, "could not register thermal device: %d\n",
1556 goto err_spectral_destroy;
1559 set_bit(ATH10K_FLAG_CORE_REGISTERED, &ar->dev_flags);
1562 err_spectral_destroy:
1563 ath10k_spectral_destroy(ar);
1565 ath10k_debug_destroy(ar);
1567 ath10k_mac_unregister(ar);
1569 ath10k_core_free_firmware_files(ar);
1571 /* TODO: It's probably a good idea to release device from the driver
1572 * but calling device_release_driver() here will cause a deadlock.
1577 int ath10k_core_register(struct ath10k *ar, u32 chip_id)
1579 ar->chip_id = chip_id;
1580 queue_work(ar->workqueue, &ar->register_work);
1584 EXPORT_SYMBOL(ath10k_core_register);
1586 void ath10k_core_unregister(struct ath10k *ar)
1588 cancel_work_sync(&ar->register_work);
1590 if (!test_bit(ATH10K_FLAG_CORE_REGISTERED, &ar->dev_flags))
1593 ath10k_thermal_unregister(ar);
1594 /* Stop spectral before unregistering from mac80211 to remove the
1595 * relayfs debugfs file cleanly. Otherwise the parent debugfs tree
1596 * would be already be free'd recursively, leading to a double free.
1598 ath10k_spectral_destroy(ar);
1600 /* We must unregister from mac80211 before we stop HTC and HIF.
1601 * Otherwise we will fail to submit commands to FW and mac80211 will be
1602 * unhappy about callback failures. */
1603 ath10k_mac_unregister(ar);
1605 ath10k_testmode_destroy(ar);
1607 ath10k_core_free_firmware_files(ar);
1609 ath10k_debug_unregister(ar);
1611 EXPORT_SYMBOL(ath10k_core_unregister);
1613 struct ath10k *ath10k_core_create(size_t priv_size, struct device *dev,
1614 enum ath10k_bus bus,
1615 enum ath10k_hw_rev hw_rev,
1616 const struct ath10k_hif_ops *hif_ops)
1621 ar = ath10k_mac_create(priv_size);
1625 ar->ath_common.priv = ar;
1626 ar->ath_common.hw = ar->hw;
1628 ar->hw_rev = hw_rev;
1629 ar->hif.ops = hif_ops;
1633 case ATH10K_HW_QCA988X:
1634 ar->regs = &qca988x_regs;
1635 ar->hw_values = &qca988x_values;
1637 case ATH10K_HW_QCA6174:
1638 ar->regs = &qca6174_regs;
1639 ar->hw_values = &qca6174_values;
1641 case ATH10K_HW_QCA99X0:
1642 ar->regs = &qca99x0_regs;
1643 ar->hw_values = &qca99x0_values;
1646 ath10k_err(ar, "unsupported core hardware revision %d\n",
1652 init_completion(&ar->scan.started);
1653 init_completion(&ar->scan.completed);
1654 init_completion(&ar->scan.on_channel);
1655 init_completion(&ar->target_suspend);
1656 init_completion(&ar->wow.wakeup_completed);
1658 init_completion(&ar->install_key_done);
1659 init_completion(&ar->vdev_setup_done);
1660 init_completion(&ar->thermal.wmi_sync);
1662 INIT_DELAYED_WORK(&ar->scan.timeout, ath10k_scan_timeout_work);
1664 ar->workqueue = create_singlethread_workqueue("ath10k_wq");
1668 ar->workqueue_aux = create_singlethread_workqueue("ath10k_aux_wq");
1669 if (!ar->workqueue_aux)
1672 mutex_init(&ar->conf_mutex);
1673 spin_lock_init(&ar->data_lock);
1675 INIT_LIST_HEAD(&ar->peers);
1676 init_waitqueue_head(&ar->peer_mapping_wq);
1677 init_waitqueue_head(&ar->htt.empty_tx_wq);
1678 init_waitqueue_head(&ar->wmi.tx_credits_wq);
1680 init_completion(&ar->offchan_tx_completed);
1681 INIT_WORK(&ar->offchan_tx_work, ath10k_offchan_tx_work);
1682 skb_queue_head_init(&ar->offchan_tx_queue);
1684 INIT_WORK(&ar->wmi_mgmt_tx_work, ath10k_mgmt_over_wmi_tx_work);
1685 skb_queue_head_init(&ar->wmi_mgmt_tx_queue);
1687 INIT_WORK(&ar->register_work, ath10k_core_register_work);
1688 INIT_WORK(&ar->restart_work, ath10k_core_restart);
1690 ret = ath10k_debug_create(ar);
1692 goto err_free_aux_wq;
1697 destroy_workqueue(ar->workqueue_aux);
1699 destroy_workqueue(ar->workqueue);
1702 ath10k_mac_destroy(ar);
1706 EXPORT_SYMBOL(ath10k_core_create);
1708 void ath10k_core_destroy(struct ath10k *ar)
1710 flush_workqueue(ar->workqueue);
1711 destroy_workqueue(ar->workqueue);
1713 flush_workqueue(ar->workqueue_aux);
1714 destroy_workqueue(ar->workqueue_aux);
1716 ath10k_debug_destroy(ar);
1717 ath10k_mac_destroy(ar);
1719 EXPORT_SYMBOL(ath10k_core_destroy);
1721 MODULE_AUTHOR("Qualcomm Atheros");
1722 MODULE_DESCRIPTION("Core module for QCA988X PCIe devices.");
1723 MODULE_LICENSE("Dual BSD/GPL");