3 * Copyright (c) 2011 Atheros Communications 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/moduleparam.h>
19 #include <linux/errno.h>
21 #include <linux/mmc/sdio_func.h>
28 unsigned int debug_mask;
29 static unsigned int testmode;
31 module_param(debug_mask, uint, 0644);
32 module_param(testmode, uint, 0644);
35 * Include definitions here that can be used to tune the WLAN module
36 * behavior. Different customers can tune the behavior as per their needs,
41 * This configuration item enable/disable keepalive support.
42 * Keepalive support: In the absence of any data traffic to AP, null
43 * frames will be sent to the AP at periodic interval, to keep the association
44 * active. This configuration item defines the periodic interval.
45 * Use value of zero to disable keepalive support
48 #define WLAN_CONFIG_KEEP_ALIVE_INTERVAL 60
51 * This configuration item sets the value of disconnect timeout
52 * Firmware delays sending the disconnec event to the host for this
53 * timeout after is gets disconnected from the current AP.
54 * If the firmware successly roams within the disconnect timeout
55 * it sends a new connect event
57 #define WLAN_CONFIG_DISCONNECT_TIMEOUT 10
59 #define CONFIG_AR600x_DEBUG_UART_TX_PIN 8
61 #define ATH6KL_DATA_OFFSET 64
62 struct sk_buff *ath6kl_buf_alloc(int size)
67 /* Add chacheline space at front and back of buffer */
68 reserved = (2 * L1_CACHE_BYTES) + ATH6KL_DATA_OFFSET +
69 sizeof(struct htc_packet) + ATH6KL_HTC_ALIGN_BYTES;
70 skb = dev_alloc_skb(size + reserved);
73 skb_reserve(skb, reserved - L1_CACHE_BYTES);
77 void ath6kl_init_profile_info(struct ath6kl_vif *vif)
80 memset(vif->ssid, 0, sizeof(vif->ssid));
82 vif->dot11_auth_mode = OPEN_AUTH;
83 vif->auth_mode = NONE_AUTH;
84 vif->prwise_crypto = NONE_CRYPT;
85 vif->prwise_crypto_len = 0;
86 vif->grp_crypto = NONE_CRYPT;
87 vif->grp_crypto_len = 0;
88 memset(vif->wep_key_list, 0, sizeof(vif->wep_key_list));
89 memset(vif->req_bssid, 0, sizeof(vif->req_bssid));
90 memset(vif->bssid, 0, sizeof(vif->bssid));
94 static int ath6kl_set_host_app_area(struct ath6kl *ar)
97 struct host_app_area host_app_area;
99 /* Fetch the address of the host_app_area_s
100 * instance in the host interest area */
101 address = ath6kl_get_hi_item_addr(ar, HI_ITEM(hi_app_host_interest));
102 address = TARG_VTOP(ar->target_type, address);
104 if (ath6kl_diag_read32(ar, address, &data))
107 address = TARG_VTOP(ar->target_type, data);
108 host_app_area.wmi_protocol_ver = cpu_to_le32(WMI_PROTOCOL_VERSION);
109 if (ath6kl_diag_write(ar, address, (u8 *) &host_app_area,
110 sizeof(struct host_app_area)))
116 static inline void set_ac2_ep_map(struct ath6kl *ar,
118 enum htc_endpoint_id ep)
120 ar->ac2ep_map[ac] = ep;
121 ar->ep2ac_map[ep] = ac;
124 /* connect to a service */
125 static int ath6kl_connectservice(struct ath6kl *ar,
126 struct htc_service_connect_req *con_req,
130 struct htc_service_connect_resp response;
132 memset(&response, 0, sizeof(response));
134 status = ath6kl_htc_conn_service(ar->htc_target, con_req, &response);
136 ath6kl_err("failed to connect to %s service status:%d\n",
141 switch (con_req->svc_id) {
142 case WMI_CONTROL_SVC:
143 if (test_bit(WMI_ENABLED, &ar->flag))
144 ath6kl_wmi_set_control_ep(ar->wmi, response.endpoint);
145 ar->ctrl_ep = response.endpoint;
147 case WMI_DATA_BE_SVC:
148 set_ac2_ep_map(ar, WMM_AC_BE, response.endpoint);
150 case WMI_DATA_BK_SVC:
151 set_ac2_ep_map(ar, WMM_AC_BK, response.endpoint);
153 case WMI_DATA_VI_SVC:
154 set_ac2_ep_map(ar, WMM_AC_VI, response.endpoint);
156 case WMI_DATA_VO_SVC:
157 set_ac2_ep_map(ar, WMM_AC_VO, response.endpoint);
160 ath6kl_err("service id is not mapped %d\n", con_req->svc_id);
167 static int ath6kl_init_service_ep(struct ath6kl *ar)
169 struct htc_service_connect_req connect;
171 memset(&connect, 0, sizeof(connect));
173 /* these fields are the same for all service endpoints */
174 connect.ep_cb.rx = ath6kl_rx;
175 connect.ep_cb.rx_refill = ath6kl_rx_refill;
176 connect.ep_cb.tx_full = ath6kl_tx_queue_full;
179 * Set the max queue depth so that our ath6kl_tx_queue_full handler
182 connect.max_txq_depth = MAX_DEFAULT_SEND_QUEUE_DEPTH;
183 connect.ep_cb.rx_refill_thresh = ATH6KL_MAX_RX_BUFFERS / 4;
184 if (!connect.ep_cb.rx_refill_thresh)
185 connect.ep_cb.rx_refill_thresh++;
187 /* connect to control service */
188 connect.svc_id = WMI_CONTROL_SVC;
189 if (ath6kl_connectservice(ar, &connect, "WMI CONTROL"))
192 connect.flags |= HTC_FLGS_TX_BNDL_PAD_EN;
195 * Limit the HTC message size on the send path, although e can
196 * receive A-MSDU frames of 4K, we will only send ethernet-sized
197 * (802.3) frames on the send path.
199 connect.max_rxmsg_sz = WMI_MAX_TX_DATA_FRAME_LENGTH;
202 * To reduce the amount of committed memory for larger A_MSDU
203 * frames, use the recv-alloc threshold mechanism for larger
206 connect.ep_cb.rx_alloc_thresh = ATH6KL_BUFFER_SIZE;
207 connect.ep_cb.rx_allocthresh = ath6kl_alloc_amsdu_rxbuf;
210 * For the remaining data services set the connection flag to
211 * reduce dribbling, if configured to do so.
213 connect.conn_flags |= HTC_CONN_FLGS_REDUCE_CRED_DRIB;
214 connect.conn_flags &= ~HTC_CONN_FLGS_THRESH_MASK;
215 connect.conn_flags |= HTC_CONN_FLGS_THRESH_LVL_HALF;
217 connect.svc_id = WMI_DATA_BE_SVC;
219 if (ath6kl_connectservice(ar, &connect, "WMI DATA BE"))
222 /* connect to back-ground map this to WMI LOW_PRI */
223 connect.svc_id = WMI_DATA_BK_SVC;
224 if (ath6kl_connectservice(ar, &connect, "WMI DATA BK"))
227 /* connect to Video service, map this to to HI PRI */
228 connect.svc_id = WMI_DATA_VI_SVC;
229 if (ath6kl_connectservice(ar, &connect, "WMI DATA VI"))
233 * Connect to VO service, this is currently not mapped to a WMI
234 * priority stream due to historical reasons. WMI originally
235 * defined 3 priorities over 3 mailboxes We can change this when
236 * WMI is reworked so that priorities are not dependent on
239 connect.svc_id = WMI_DATA_VO_SVC;
240 if (ath6kl_connectservice(ar, &connect, "WMI DATA VO"))
246 void ath6kl_init_control_info(struct ath6kl_vif *vif)
248 ath6kl_init_profile_info(vif);
249 vif->def_txkey_index = 0;
250 memset(vif->wep_key_list, 0, sizeof(vif->wep_key_list));
255 * Set HTC/Mbox operational parameters, this can only be called when the
256 * target is in the BMI phase.
258 static int ath6kl_set_htc_params(struct ath6kl *ar, u32 mbox_isr_yield_val,
264 blk_size = ar->mbox_info.block_size;
267 blk_size |= ((u32)htc_ctrl_buf) << 16;
269 /* set the host interest area for the block size */
270 status = ath6kl_bmi_write(ar,
271 ath6kl_get_hi_item_addr(ar,
272 HI_ITEM(hi_mbox_io_block_sz)),
276 ath6kl_err("bmi_write_memory for IO block size failed\n");
280 ath6kl_dbg(ATH6KL_DBG_TRC, "block size set: %d (target addr:0x%X)\n",
282 ath6kl_get_hi_item_addr(ar, HI_ITEM(hi_mbox_io_block_sz)));
284 if (mbox_isr_yield_val) {
285 /* set the host interest area for the mbox ISR yield limit */
286 status = ath6kl_bmi_write(ar,
287 ath6kl_get_hi_item_addr(ar,
288 HI_ITEM(hi_mbox_isr_yield_limit)),
289 (u8 *)&mbox_isr_yield_val,
292 ath6kl_err("bmi_write_memory for yield limit failed\n");
301 #define REG_DUMP_COUNT_AR6003 60
302 #define REGISTER_DUMP_LEN_MAX 60
304 static void ath6kl_dump_target_assert_info(struct ath6kl *ar)
309 u32 regdump_val[REGISTER_DUMP_LEN_MAX];
312 if (ar->target_type != TARGET_TYPE_AR6003)
315 /* the reg dump pointer is copied to the host interest area */
316 address = ath6kl_get_hi_item_addr(ar, HI_ITEM(hi_failure_state));
317 address = TARG_VTOP(ar->target_type, address);
319 /* read RAM location through diagnostic window */
320 status = ath6kl_diag_read32(ar, address, ®dump_loc);
322 if (status || !regdump_loc) {
323 ath6kl_err("failed to get ptr to register dump area\n");
327 ath6kl_dbg(ATH6KL_DBG_TRC, "location of register dump data: 0x%X\n",
329 regdump_loc = TARG_VTOP(ar->target_type, regdump_loc);
331 /* fetch register dump data */
332 status = ath6kl_diag_read(ar, regdump_loc, (u8 *)®dump_val[0],
333 REG_DUMP_COUNT_AR6003 * (sizeof(u32)));
336 ath6kl_err("failed to get register dump\n");
339 ath6kl_dbg(ATH6KL_DBG_TRC, "Register Dump:\n");
341 for (i = 0; i < REG_DUMP_COUNT_AR6003; i++)
342 ath6kl_dbg(ATH6KL_DBG_TRC, " %d : 0x%8.8X\n",
347 void ath6kl_target_failure(struct ath6kl *ar)
349 ath6kl_err("target asserted\n");
351 /* try dumping target assertion information (if any) */
352 ath6kl_dump_target_assert_info(ar);
356 static int ath6kl_target_config_wlan_params(struct ath6kl *ar, int idx)
362 * Configure the device for rx dot11 header rules. "0,0" are the
363 * default values. Required if checksum offload is needed. Set
364 * RxMetaVersion to 2.
366 if (ath6kl_wmi_set_rx_frame_format_cmd(ar->wmi, idx,
367 ar->rx_meta_ver, 0, 0)) {
368 ath6kl_err("unable to set the rx frame format\n");
372 if (ar->conf_flags & ATH6KL_CONF_IGNORE_PS_FAIL_EVT_IN_SCAN)
373 if ((ath6kl_wmi_pmparams_cmd(ar->wmi, idx, 0, 1, 0, 0, 1,
374 IGNORE_POWER_SAVE_FAIL_EVENT_DURING_SCAN)) != 0) {
375 ath6kl_err("unable to set power save fail event policy\n");
379 if (!(ar->conf_flags & ATH6KL_CONF_IGNORE_ERP_BARKER))
380 if ((ath6kl_wmi_set_lpreamble_cmd(ar->wmi, idx, 0,
381 WMI_DONOT_IGNORE_BARKER_IN_ERP)) != 0) {
382 ath6kl_err("unable to set barker preamble policy\n");
386 if (ath6kl_wmi_set_keepalive_cmd(ar->wmi, idx,
387 WLAN_CONFIG_KEEP_ALIVE_INTERVAL)) {
388 ath6kl_err("unable to set keep alive interval\n");
392 if (ath6kl_wmi_disctimeout_cmd(ar->wmi, idx,
393 WLAN_CONFIG_DISCONNECT_TIMEOUT)) {
394 ath6kl_err("unable to set disconnect timeout\n");
398 if (!(ar->conf_flags & ATH6KL_CONF_ENABLE_TX_BURST))
399 if (ath6kl_wmi_set_wmm_txop(ar->wmi, idx, WMI_TXOP_DISABLED)) {
400 ath6kl_err("unable to set txop bursting\n");
405 * FIXME: Make sure p2p configurations are not applied to
406 * non-p2p capable interfaces when multivif support is enabled.
409 ret = ath6kl_wmi_info_req_cmd(ar->wmi, idx,
410 P2P_FLAG_CAPABILITIES_REQ |
411 P2P_FLAG_MACADDR_REQ |
412 P2P_FLAG_HMODEL_REQ);
414 ath6kl_dbg(ATH6KL_DBG_TRC, "failed to request P2P "
415 "capabilities (%d) - assuming P2P not "
422 * FIXME: Make sure p2p configurations are not applied to
423 * non-p2p capable interfaces when multivif support is enabled.
426 /* Enable Probe Request reporting for P2P */
427 ret = ath6kl_wmi_probe_report_req_cmd(ar->wmi, idx, true);
429 ath6kl_dbg(ATH6KL_DBG_TRC, "failed to enable Probe "
430 "Request reporting (%d)\n", ret);
437 int ath6kl_configure_target(struct ath6kl *ar)
439 u32 param, ram_reserved_size;
440 u8 fw_iftype, fw_mode = 0, fw_submode = 0;
444 * Note: Even though the firmware interface type is
445 * chosen as BSS_STA for all three interfaces, can
446 * be configured to IBSS/AP as long as the fw submode
447 * remains normal mode (0 - AP, STA and IBSS). But
448 * due to an target assert in firmware only one interface is
449 * configured for now.
451 fw_iftype = HI_OPTION_FW_MODE_BSS_STA;
453 for (i = 0; i < MAX_NUM_VIF; i++)
454 fw_mode |= fw_iftype << (i * HI_OPTION_FW_MODE_BITS);
457 * By default, submodes :
458 * vif[0] - AP/STA/IBSS
459 * vif[1] - "P2P dev"/"P2P GO"/"P2P Client"
460 * vif[2] - "P2P dev"/"P2P GO"/"P2P Client"
463 for (i = 0; i < ar->max_norm_iface; i++)
464 fw_submode |= HI_OPTION_FW_SUBMODE_NONE <<
465 (i * HI_OPTION_FW_SUBMODE_BITS);
467 for (i = ar->max_norm_iface; i < MAX_NUM_VIF; i++)
468 fw_submode |= HI_OPTION_FW_SUBMODE_P2PDEV <<
469 (i * HI_OPTION_FW_SUBMODE_BITS);
472 * FIXME: This needs to be removed once the multivif
473 * support is enabled.
476 fw_submode = HI_OPTION_FW_SUBMODE_P2PDEV;
478 param = HTC_PROTOCOL_VERSION;
479 if (ath6kl_bmi_write(ar,
480 ath6kl_get_hi_item_addr(ar,
481 HI_ITEM(hi_app_host_interest)),
482 (u8 *)¶m, 4) != 0) {
483 ath6kl_err("bmi_write_memory for htc version failed\n");
487 /* set the firmware mode to STA/IBSS/AP */
490 if (ath6kl_bmi_read(ar,
491 ath6kl_get_hi_item_addr(ar,
492 HI_ITEM(hi_option_flag)),
493 (u8 *)¶m, 4) != 0) {
494 ath6kl_err("bmi_read_memory for setting fwmode failed\n");
498 param |= (MAX_NUM_VIF << HI_OPTION_NUM_DEV_SHIFT);
499 param |= fw_mode << HI_OPTION_FW_MODE_SHIFT;
500 param |= fw_submode << HI_OPTION_FW_SUBMODE_SHIFT;
502 param |= (0 << HI_OPTION_MAC_ADDR_METHOD_SHIFT);
503 param |= (0 << HI_OPTION_FW_BRIDGE_SHIFT);
505 if (ath6kl_bmi_write(ar,
506 ath6kl_get_hi_item_addr(ar,
507 HI_ITEM(hi_option_flag)),
510 ath6kl_err("bmi_write_memory for setting fwmode failed\n");
514 ath6kl_dbg(ATH6KL_DBG_TRC, "firmware mode set\n");
517 * Hardcode the address use for the extended board data
518 * Ideally this should be pre-allocate by the OS at boot time
519 * But since it is a new feature and board data is loaded
520 * at init time, we have to workaround this from host.
521 * It is difficult to patch the firmware boot code,
522 * but possible in theory.
525 param = ar->hw.board_ext_data_addr;
526 ram_reserved_size = ar->hw.reserved_ram_size;
528 if (ath6kl_bmi_write(ar, ath6kl_get_hi_item_addr(ar,
529 HI_ITEM(hi_board_ext_data)),
530 (u8 *)¶m, 4) != 0) {
531 ath6kl_err("bmi_write_memory for hi_board_ext_data failed\n");
535 if (ath6kl_bmi_write(ar, ath6kl_get_hi_item_addr(ar,
536 HI_ITEM(hi_end_ram_reserve_sz)),
537 (u8 *)&ram_reserved_size, 4) != 0) {
538 ath6kl_err("bmi_write_memory for hi_end_ram_reserve_sz failed\n");
542 /* set the block size for the target */
543 if (ath6kl_set_htc_params(ar, MBOX_YIELD_LIMIT, 0))
544 /* use default number of control buffers */
550 void ath6kl_core_free(struct ath6kl *ar)
552 wiphy_free(ar->wiphy);
555 void ath6kl_core_cleanup(struct ath6kl *ar)
557 destroy_workqueue(ar->ath6kl_wq);
560 ath6kl_htc_cleanup(ar->htc_target);
562 ath6kl_cookie_cleanup(ar);
564 ath6kl_cleanup_amsdu_rxbufs(ar);
566 ath6kl_bmi_cleanup(ar);
568 ath6kl_debug_cleanup(ar);
575 ath6kl_deinit_ieee80211_hw(ar);
578 /* firmware upload */
579 static int ath6kl_get_fw(struct ath6kl *ar, const char *filename,
580 u8 **fw, size_t *fw_len)
582 const struct firmware *fw_entry;
585 ret = request_firmware(&fw_entry, filename, ar->dev);
589 *fw_len = fw_entry->size;
590 *fw = kmemdup(fw_entry->data, fw_entry->size, GFP_KERNEL);
595 release_firmware(fw_entry);
601 static const char *get_target_ver_dir(const struct ath6kl *ar)
603 switch (ar->version.target_ver) {
604 case AR6003_REV1_VERSION:
605 return "ath6k/AR6003/hw1.0";
606 case AR6003_REV2_VERSION:
607 return "ath6k/AR6003/hw2.0";
608 case AR6003_REV3_VERSION:
609 return "ath6k/AR6003/hw2.1.1";
611 ath6kl_warn("%s: unsupported target version 0x%x.\n", __func__,
612 ar->version.target_ver);
617 * Check the device tree for a board-id and use it to construct
618 * the pathname to the firmware file. Used (for now) to find a
619 * fallback to the "bdata.bin" file--typically a symlink to the
620 * appropriate board-specific file.
622 static bool check_device_tree(struct ath6kl *ar)
624 static const char *board_id_prop = "atheros,board-id";
625 struct device_node *node;
626 char board_filename[64];
627 const char *board_id;
630 for_each_compatible_node(node, NULL, "atheros,ath6kl") {
631 board_id = of_get_property(node, board_id_prop, NULL);
632 if (board_id == NULL) {
633 ath6kl_warn("No \"%s\" property on %s node.\n",
634 board_id_prop, node->name);
637 snprintf(board_filename, sizeof(board_filename),
638 "%s/bdata.%s.bin", get_target_ver_dir(ar), board_id);
640 ret = ath6kl_get_fw(ar, board_filename, &ar->fw_board,
643 ath6kl_err("Failed to get DT board file %s: %d\n",
644 board_filename, ret);
652 static bool check_device_tree(struct ath6kl *ar)
656 #endif /* CONFIG_OF */
658 static int ath6kl_fetch_board_file(struct ath6kl *ar)
660 const char *filename;
663 if (ar->fw_board != NULL)
666 switch (ar->version.target_ver) {
667 case AR6003_REV2_VERSION:
668 filename = AR6003_REV2_BOARD_DATA_FILE;
670 case AR6004_REV1_VERSION:
671 filename = AR6004_REV1_BOARD_DATA_FILE;
674 filename = AR6003_REV3_BOARD_DATA_FILE;
678 ret = ath6kl_get_fw(ar, filename, &ar->fw_board,
681 /* managed to get proper board file */
685 if (check_device_tree(ar)) {
686 /* got board file from device tree */
690 /* there was no proper board file, try to use default instead */
691 ath6kl_warn("Failed to get board file %s (%d), trying to find default board file.\n",
694 switch (ar->version.target_ver) {
695 case AR6003_REV2_VERSION:
696 filename = AR6003_REV2_DEFAULT_BOARD_DATA_FILE;
698 case AR6004_REV1_VERSION:
699 filename = AR6004_REV1_DEFAULT_BOARD_DATA_FILE;
702 filename = AR6003_REV3_DEFAULT_BOARD_DATA_FILE;
706 ret = ath6kl_get_fw(ar, filename, &ar->fw_board,
709 ath6kl_err("Failed to get default board file %s: %d\n",
714 ath6kl_warn("WARNING! No proper board file was not found, instead using a default board file.\n");
715 ath6kl_warn("Most likely your hardware won't work as specified. Install correct board file!\n");
720 static int ath6kl_fetch_otp_file(struct ath6kl *ar)
722 const char *filename;
725 if (ar->fw_otp != NULL)
728 switch (ar->version.target_ver) {
729 case AR6003_REV2_VERSION:
730 filename = AR6003_REV2_OTP_FILE;
732 case AR6004_REV1_VERSION:
733 ath6kl_dbg(ATH6KL_DBG_TRC, "AR6004 doesn't need OTP file\n");
737 filename = AR6003_REV3_OTP_FILE;
741 ret = ath6kl_get_fw(ar, filename, &ar->fw_otp,
744 ath6kl_err("Failed to get OTP file %s: %d\n",
752 static int ath6kl_fetch_fw_file(struct ath6kl *ar)
754 const char *filename;
761 switch (ar->version.target_ver) {
762 case AR6003_REV2_VERSION:
763 filename = AR6003_REV2_TCMD_FIRMWARE_FILE;
765 case AR6003_REV3_VERSION:
766 filename = AR6003_REV3_TCMD_FIRMWARE_FILE;
768 case AR6004_REV1_VERSION:
769 ath6kl_warn("testmode not supported with ar6004\n");
772 ath6kl_warn("unknown target version: 0x%x\n",
773 ar->version.target_ver);
777 set_bit(TESTMODE, &ar->flag);
782 switch (ar->version.target_ver) {
783 case AR6003_REV2_VERSION:
784 filename = AR6003_REV2_FIRMWARE_FILE;
786 case AR6004_REV1_VERSION:
787 filename = AR6004_REV1_FIRMWARE_FILE;
790 filename = AR6003_REV3_FIRMWARE_FILE;
795 ret = ath6kl_get_fw(ar, filename, &ar->fw, &ar->fw_len);
797 ath6kl_err("Failed to get firmware file %s: %d\n",
805 static int ath6kl_fetch_patch_file(struct ath6kl *ar)
807 const char *filename;
810 switch (ar->version.target_ver) {
811 case AR6003_REV2_VERSION:
812 filename = AR6003_REV2_PATCH_FILE;
814 case AR6004_REV1_VERSION:
815 /* FIXME: implement for AR6004 */
819 filename = AR6003_REV3_PATCH_FILE;
823 if (ar->fw_patch == NULL) {
824 ret = ath6kl_get_fw(ar, filename, &ar->fw_patch,
827 ath6kl_err("Failed to get patch file %s: %d\n",
836 static int ath6kl_fetch_fw_api1(struct ath6kl *ar)
840 ret = ath6kl_fetch_otp_file(ar);
844 ret = ath6kl_fetch_fw_file(ar);
848 ret = ath6kl_fetch_patch_file(ar);
855 static int ath6kl_fetch_fw_api2(struct ath6kl *ar)
857 size_t magic_len, len, ie_len;
858 const struct firmware *fw;
859 struct ath6kl_fw_ie *hdr;
860 const char *filename;
862 int ret, ie_id, i, index, bit;
865 switch (ar->version.target_ver) {
866 case AR6003_REV2_VERSION:
867 filename = AR6003_REV2_FIRMWARE_2_FILE;
869 case AR6003_REV3_VERSION:
870 filename = AR6003_REV3_FIRMWARE_2_FILE;
872 case AR6004_REV1_VERSION:
873 filename = AR6004_REV1_FIRMWARE_2_FILE;
879 ret = request_firmware(&fw, filename, ar->dev);
886 /* magic also includes the null byte, check that as well */
887 magic_len = strlen(ATH6KL_FIRMWARE_MAGIC) + 1;
889 if (len < magic_len) {
894 if (memcmp(data, ATH6KL_FIRMWARE_MAGIC, magic_len) != 0) {
903 while (len > sizeof(struct ath6kl_fw_ie)) {
904 /* hdr is unaligned! */
905 hdr = (struct ath6kl_fw_ie *) data;
907 ie_id = le32_to_cpup(&hdr->id);
908 ie_len = le32_to_cpup(&hdr->len);
911 data += sizeof(*hdr);
919 case ATH6KL_FW_IE_OTP_IMAGE:
920 ath6kl_dbg(ATH6KL_DBG_BOOT, "found otp image ie (%zd B)\n",
923 ar->fw_otp = kmemdup(data, ie_len, GFP_KERNEL);
925 if (ar->fw_otp == NULL) {
930 ar->fw_otp_len = ie_len;
932 case ATH6KL_FW_IE_FW_IMAGE:
933 ath6kl_dbg(ATH6KL_DBG_BOOT, "found fw image ie (%zd B)\n",
936 ar->fw = kmemdup(data, ie_len, GFP_KERNEL);
938 if (ar->fw == NULL) {
945 case ATH6KL_FW_IE_PATCH_IMAGE:
946 ath6kl_dbg(ATH6KL_DBG_BOOT, "found patch image ie (%zd B)\n",
949 ar->fw_patch = kmemdup(data, ie_len, GFP_KERNEL);
951 if (ar->fw_patch == NULL) {
956 ar->fw_patch_len = ie_len;
958 case ATH6KL_FW_IE_RESERVED_RAM_SIZE:
959 val = (__le32 *) data;
960 ar->hw.reserved_ram_size = le32_to_cpup(val);
962 ath6kl_dbg(ATH6KL_DBG_BOOT,
963 "found reserved ram size ie 0x%d\n",
964 ar->hw.reserved_ram_size);
966 case ATH6KL_FW_IE_CAPABILITIES:
967 ath6kl_dbg(ATH6KL_DBG_BOOT,
968 "found firmware capabilities ie (%zd B)\n",
971 for (i = 0; i < ATH6KL_FW_CAPABILITY_MAX; i++) {
972 index = ALIGN(i, 8) / 8;
975 if (data[index] & (1 << bit))
976 __set_bit(i, ar->fw_capabilities);
979 ath6kl_dbg_dump(ATH6KL_DBG_BOOT, "capabilities", "",
981 sizeof(ar->fw_capabilities));
983 case ATH6KL_FW_IE_PATCH_ADDR:
984 if (ie_len != sizeof(*val))
987 val = (__le32 *) data;
988 ar->hw.dataset_patch_addr = le32_to_cpup(val);
990 ath6kl_dbg(ATH6KL_DBG_BOOT,
991 "found patch address ie 0x%d\n",
992 ar->hw.dataset_patch_addr);
995 ath6kl_dbg(ATH6KL_DBG_BOOT, "Unknown fw ie: %u\n",
996 le32_to_cpup(&hdr->id));
1006 release_firmware(fw);
1011 static int ath6kl_fetch_firmwares(struct ath6kl *ar)
1015 ret = ath6kl_fetch_board_file(ar);
1019 ret = ath6kl_fetch_fw_api2(ar);
1021 ath6kl_dbg(ATH6KL_DBG_BOOT, "using fw api 2\n");
1025 ret = ath6kl_fetch_fw_api1(ar);
1029 ath6kl_dbg(ATH6KL_DBG_BOOT, "using fw api 1\n");
1034 static int ath6kl_upload_board_file(struct ath6kl *ar)
1036 u32 board_address, board_ext_address, param;
1037 u32 board_data_size, board_ext_data_size;
1040 if (WARN_ON(ar->fw_board == NULL))
1044 * Determine where in Target RAM to write Board Data.
1045 * For AR6004, host determine Target RAM address for
1046 * writing board data.
1048 if (ar->target_type == TARGET_TYPE_AR6004) {
1049 board_address = AR6004_REV1_BOARD_DATA_ADDRESS;
1050 ath6kl_bmi_write(ar,
1051 ath6kl_get_hi_item_addr(ar,
1052 HI_ITEM(hi_board_data)),
1053 (u8 *) &board_address, 4);
1056 ath6kl_get_hi_item_addr(ar,
1057 HI_ITEM(hi_board_data)),
1058 (u8 *) &board_address, 4);
1061 /* determine where in target ram to write extended board data */
1063 ath6kl_get_hi_item_addr(ar,
1064 HI_ITEM(hi_board_ext_data)),
1065 (u8 *) &board_ext_address, 4);
1067 if (board_ext_address == 0) {
1068 ath6kl_err("Failed to get board file target address.\n");
1072 switch (ar->target_type) {
1073 case TARGET_TYPE_AR6003:
1074 board_data_size = AR6003_BOARD_DATA_SZ;
1075 board_ext_data_size = AR6003_BOARD_EXT_DATA_SZ;
1077 case TARGET_TYPE_AR6004:
1078 board_data_size = AR6004_BOARD_DATA_SZ;
1079 board_ext_data_size = AR6004_BOARD_EXT_DATA_SZ;
1087 if (ar->fw_board_len == (board_data_size +
1088 board_ext_data_size)) {
1090 /* write extended board data */
1091 ath6kl_dbg(ATH6KL_DBG_BOOT,
1092 "writing extended board data to 0x%x (%d B)\n",
1093 board_ext_address, board_ext_data_size);
1095 ret = ath6kl_bmi_write(ar, board_ext_address,
1096 ar->fw_board + board_data_size,
1097 board_ext_data_size);
1099 ath6kl_err("Failed to write extended board data: %d\n",
1104 /* record that extended board data is initialized */
1105 param = (board_ext_data_size << 16) | 1;
1107 ath6kl_bmi_write(ar,
1108 ath6kl_get_hi_item_addr(ar,
1109 HI_ITEM(hi_board_ext_data_config)),
1110 (unsigned char *) ¶m, 4);
1113 if (ar->fw_board_len < board_data_size) {
1114 ath6kl_err("Too small board file: %zu\n", ar->fw_board_len);
1119 ath6kl_dbg(ATH6KL_DBG_BOOT, "writing board file to 0x%x (%d B)\n",
1120 board_address, board_data_size);
1122 ret = ath6kl_bmi_write(ar, board_address, ar->fw_board,
1126 ath6kl_err("Board file bmi write failed: %d\n", ret);
1130 /* record the fact that Board Data IS initialized */
1132 ath6kl_bmi_write(ar,
1133 ath6kl_get_hi_item_addr(ar,
1134 HI_ITEM(hi_board_data_initialized)),
1140 static int ath6kl_upload_otp(struct ath6kl *ar)
1143 bool from_hw = false;
1146 if (WARN_ON(ar->fw_otp == NULL))
1149 address = ar->hw.app_load_addr;
1151 ath6kl_dbg(ATH6KL_DBG_BOOT, "writing otp to 0x%x (%zd B)\n", address,
1154 ret = ath6kl_bmi_fast_download(ar, address, ar->fw_otp,
1157 ath6kl_err("Failed to upload OTP file: %d\n", ret);
1161 /* read firmware start address */
1162 ret = ath6kl_bmi_read(ar,
1163 ath6kl_get_hi_item_addr(ar,
1164 HI_ITEM(hi_app_start)),
1165 (u8 *) &address, sizeof(address));
1168 ath6kl_err("Failed to read hi_app_start: %d\n", ret);
1172 if (ar->hw.app_start_override_addr == 0) {
1173 ar->hw.app_start_override_addr = address;
1177 ath6kl_dbg(ATH6KL_DBG_BOOT, "app_start_override_addr%s 0x%x\n",
1178 from_hw ? " (from hw)" : "",
1179 ar->hw.app_start_override_addr);
1181 /* execute the OTP code */
1182 ath6kl_dbg(ATH6KL_DBG_BOOT, "executing OTP at 0x%x\n",
1183 ar->hw.app_start_override_addr);
1185 ath6kl_bmi_execute(ar, ar->hw.app_start_override_addr, ¶m);
1190 static int ath6kl_upload_firmware(struct ath6kl *ar)
1195 if (WARN_ON(ar->fw == NULL))
1198 address = ar->hw.app_load_addr;
1200 ath6kl_dbg(ATH6KL_DBG_BOOT, "writing firmware to 0x%x (%zd B)\n",
1201 address, ar->fw_len);
1203 ret = ath6kl_bmi_fast_download(ar, address, ar->fw, ar->fw_len);
1206 ath6kl_err("Failed to write firmware: %d\n", ret);
1211 * Set starting address for firmware
1212 * Don't need to setup app_start override addr on AR6004
1214 if (ar->target_type != TARGET_TYPE_AR6004) {
1215 address = ar->hw.app_start_override_addr;
1216 ath6kl_bmi_set_app_start(ar, address);
1221 static int ath6kl_upload_patch(struct ath6kl *ar)
1226 if (WARN_ON(ar->fw_patch == NULL))
1229 address = ar->hw.dataset_patch_addr;
1231 ath6kl_dbg(ATH6KL_DBG_BOOT, "writing patch to 0x%x (%zd B)\n",
1232 address, ar->fw_patch_len);
1234 ret = ath6kl_bmi_write(ar, address, ar->fw_patch, ar->fw_patch_len);
1236 ath6kl_err("Failed to write patch file: %d\n", ret);
1241 ath6kl_bmi_write(ar,
1242 ath6kl_get_hi_item_addr(ar,
1243 HI_ITEM(hi_dset_list_head)),
1244 (unsigned char *) ¶m, 4);
1249 static int ath6kl_init_upload(struct ath6kl *ar)
1251 u32 param, options, sleep, address;
1254 if (ar->target_type != TARGET_TYPE_AR6003 &&
1255 ar->target_type != TARGET_TYPE_AR6004)
1258 /* temporarily disable system sleep */
1259 address = MBOX_BASE_ADDRESS + LOCAL_SCRATCH_ADDRESS;
1260 status = ath6kl_bmi_reg_read(ar, address, ¶m);
1266 param |= ATH6KL_OPTION_SLEEP_DISABLE;
1267 status = ath6kl_bmi_reg_write(ar, address, param);
1271 address = RTC_BASE_ADDRESS + SYSTEM_SLEEP_ADDRESS;
1272 status = ath6kl_bmi_reg_read(ar, address, ¶m);
1278 param |= SM(SYSTEM_SLEEP_DISABLE, 1);
1279 status = ath6kl_bmi_reg_write(ar, address, param);
1283 ath6kl_dbg(ATH6KL_DBG_TRC, "old options: %d, old sleep: %d\n",
1286 /* program analog PLL register */
1287 /* no need to control 40/44MHz clock on AR6004 */
1288 if (ar->target_type != TARGET_TYPE_AR6004) {
1289 status = ath6kl_bmi_reg_write(ar, ATH6KL_ANALOG_PLL_REGISTER,
1295 /* Run at 80/88MHz by default */
1296 param = SM(CPU_CLOCK_STANDARD, 1);
1298 address = RTC_BASE_ADDRESS + CPU_CLOCK_ADDRESS;
1299 status = ath6kl_bmi_reg_write(ar, address, param);
1305 address = RTC_BASE_ADDRESS + LPO_CAL_ADDRESS;
1306 param = SM(LPO_CAL_ENABLE, 1);
1307 status = ath6kl_bmi_reg_write(ar, address, param);
1311 /* WAR to avoid SDIO CRC err */
1312 if (ar->version.target_ver == AR6003_REV2_VERSION) {
1313 ath6kl_err("temporary war to avoid sdio crc error\n");
1317 address = GPIO_BASE_ADDRESS + GPIO_PIN10_ADDRESS;
1318 status = ath6kl_bmi_reg_write(ar, address, param);
1322 address = GPIO_BASE_ADDRESS + GPIO_PIN11_ADDRESS;
1323 status = ath6kl_bmi_reg_write(ar, address, param);
1327 address = GPIO_BASE_ADDRESS + GPIO_PIN12_ADDRESS;
1328 status = ath6kl_bmi_reg_write(ar, address, param);
1332 address = GPIO_BASE_ADDRESS + GPIO_PIN13_ADDRESS;
1333 status = ath6kl_bmi_reg_write(ar, address, param);
1338 /* write EEPROM data to Target RAM */
1339 status = ath6kl_upload_board_file(ar);
1343 /* transfer One time Programmable data */
1344 status = ath6kl_upload_otp(ar);
1348 /* Download Target firmware */
1349 status = ath6kl_upload_firmware(ar);
1353 status = ath6kl_upload_patch(ar);
1357 /* Restore system sleep */
1358 address = RTC_BASE_ADDRESS + SYSTEM_SLEEP_ADDRESS;
1359 status = ath6kl_bmi_reg_write(ar, address, sleep);
1363 address = MBOX_BASE_ADDRESS + LOCAL_SCRATCH_ADDRESS;
1364 param = options | 0x20;
1365 status = ath6kl_bmi_reg_write(ar, address, param);
1369 /* Configure GPIO AR6003 UART */
1370 param = CONFIG_AR600x_DEBUG_UART_TX_PIN;
1371 status = ath6kl_bmi_write(ar,
1372 ath6kl_get_hi_item_addr(ar,
1373 HI_ITEM(hi_dbg_uart_txpin)),
1379 static int ath6kl_init_hw_params(struct ath6kl *ar)
1381 switch (ar->version.target_ver) {
1382 case AR6003_REV2_VERSION:
1383 ar->hw.dataset_patch_addr = AR6003_REV2_DATASET_PATCH_ADDRESS;
1384 ar->hw.app_load_addr = AR6003_REV2_APP_LOAD_ADDRESS;
1385 ar->hw.board_ext_data_addr = AR6003_REV2_BOARD_EXT_DATA_ADDRESS;
1386 ar->hw.reserved_ram_size = AR6003_REV2_RAM_RESERVE_SIZE;
1388 /* hw2.0 needs override address hardcoded */
1389 ar->hw.app_start_override_addr = 0x944C00;
1392 case AR6003_REV3_VERSION:
1393 ar->hw.dataset_patch_addr = AR6003_REV3_DATASET_PATCH_ADDRESS;
1394 ar->hw.app_load_addr = 0x1234;
1395 ar->hw.board_ext_data_addr = AR6003_REV3_BOARD_EXT_DATA_ADDRESS;
1396 ar->hw.reserved_ram_size = AR6003_REV3_RAM_RESERVE_SIZE;
1398 case AR6004_REV1_VERSION:
1399 ar->hw.dataset_patch_addr = AR6003_REV2_DATASET_PATCH_ADDRESS;
1400 ar->hw.app_load_addr = AR6003_REV3_APP_LOAD_ADDRESS;
1401 ar->hw.board_ext_data_addr = AR6004_REV1_BOARD_EXT_DATA_ADDRESS;
1402 ar->hw.reserved_ram_size = AR6004_REV1_RAM_RESERVE_SIZE;
1405 ath6kl_err("Unsupported hardware version: 0x%x\n",
1406 ar->version.target_ver);
1410 ath6kl_dbg(ATH6KL_DBG_BOOT,
1411 "target_ver 0x%x target_type 0x%x dataset_patch 0x%x app_load_addr 0x%x\n",
1412 ar->version.target_ver, ar->target_type,
1413 ar->hw.dataset_patch_addr, ar->hw.app_load_addr);
1414 ath6kl_dbg(ATH6KL_DBG_BOOT,
1415 "app_start_override_addr 0x%x board_ext_data_addr 0x%x reserved_ram_size 0x%x",
1416 ar->hw.app_start_override_addr, ar->hw.board_ext_data_addr,
1417 ar->hw.reserved_ram_size);
1422 static int ath6kl_init(struct ath6kl *ar)
1426 struct net_device *ndev;
1432 /* Do we need to finish the BMI phase */
1433 if (ath6kl_bmi_done(ar)) {
1435 goto ath6kl_init_done;
1438 /* Indicate that WMI is enabled (although not ready yet) */
1439 set_bit(WMI_ENABLED, &ar->flag);
1440 ar->wmi = ath6kl_wmi_init(ar);
1442 ath6kl_err("failed to initialize wmi\n");
1444 goto ath6kl_init_done;
1447 ath6kl_dbg(ATH6KL_DBG_TRC, "%s: got wmi @ 0x%p.\n", __func__, ar->wmi);
1449 status = ath6kl_register_ieee80211_hw(ar);
1451 goto err_node_cleanup;
1453 status = ath6kl_debug_init(ar);
1455 wiphy_unregister(ar->wiphy);
1456 goto err_node_cleanup;
1459 for (i = 0; i < MAX_NUM_VIF; i++)
1460 ar->avail_idx_map |= BIT(i);
1464 /* Add an initial station interface */
1465 ndev = ath6kl_interface_add(ar, "wlan%d", NL80211_IFTYPE_STATION, 0,
1471 ath6kl_err("Failed to instantiate a network device\n");
1473 wiphy_unregister(ar->wiphy);
1474 goto err_debug_init;
1478 ath6kl_dbg(ATH6KL_DBG_TRC, "%s: name=%s dev=0x%p, ar=0x%p\n",
1479 __func__, ndev->name, ndev, ar);
1482 * The reason we have to wait for the target here is that the
1483 * driver layer has to init BMI in order to set the host block
1486 if (ath6kl_htc_wait_target(ar->htc_target)) {
1491 if (ath6kl_init_service_ep(ar)) {
1493 goto err_cleanup_scatter;
1496 /* setup access class priority mappings */
1497 ar->ac_stream_pri_map[WMM_AC_BK] = 0; /* lowest */
1498 ar->ac_stream_pri_map[WMM_AC_BE] = 1;
1499 ar->ac_stream_pri_map[WMM_AC_VI] = 2;
1500 ar->ac_stream_pri_map[WMM_AC_VO] = 3; /* highest */
1502 /* give our connected endpoints some buffers */
1503 ath6kl_rx_refill(ar->htc_target, ar->ctrl_ep);
1504 ath6kl_rx_refill(ar->htc_target, ar->ac2ep_map[WMM_AC_BE]);
1506 /* allocate some buffers that handle larger AMSDU frames */
1507 ath6kl_refill_amsdu_rxbufs(ar, ATH6KL_MAX_AMSDU_RX_BUFFERS);
1509 /* setup credit distribution */
1510 ath6kl_credit_setup(ar->htc_target, &ar->credit_state_info);
1512 ath6kl_cookie_init(ar);
1515 status = ath6kl_htc_start(ar->htc_target);
1518 ath6kl_cookie_cleanup(ar);
1519 goto err_rxbuf_cleanup;
1522 /* Wait for Wmi event to be ready */
1523 timeleft = wait_event_interruptible_timeout(ar->event_wq,
1528 ath6kl_dbg(ATH6KL_DBG_BOOT, "firmware booted\n");
1530 if (ar->version.abi_ver != ATH6KL_ABI_VERSION) {
1531 ath6kl_err("abi version mismatch: host(0x%x), target(0x%x)\n",
1532 ATH6KL_ABI_VERSION, ar->version.abi_ver);
1537 if (!timeleft || signal_pending(current)) {
1538 ath6kl_err("wmi is not ready or wait was interrupted\n");
1543 ath6kl_dbg(ATH6KL_DBG_TRC, "%s: wmi is ready\n", __func__);
1545 /* communicate the wmi protocol verision to the target */
1546 if ((ath6kl_set_host_app_area(ar)) != 0)
1547 ath6kl_err("unable to set the host app area\n");
1549 ar->conf_flags = ATH6KL_CONF_IGNORE_ERP_BARKER |
1550 ATH6KL_CONF_ENABLE_11N | ATH6KL_CONF_ENABLE_TX_BURST;
1552 ar->wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM |
1553 WIPHY_FLAG_HAVE_AP_SME;
1555 for (i = 0; i < MAX_NUM_VIF; i++) {
1556 status = ath6kl_target_config_wlan_params(ar, i);
1562 * Set mac address which is received in ready event
1563 * FIXME: Move to ath6kl_interface_add()
1565 memcpy(ndev->dev_addr, ar->mac_addr, ETH_ALEN);
1570 ath6kl_htc_stop(ar->htc_target);
1572 ath6kl_htc_flush_rx_buf(ar->htc_target);
1573 ath6kl_cleanup_amsdu_rxbufs(ar);
1574 err_cleanup_scatter:
1575 ath6kl_hif_cleanup_scatter(ar);
1578 ath6kl_deinit_if_data(netdev_priv(ndev));
1580 wiphy_unregister(ar->wiphy);
1582 ath6kl_debug_cleanup(ar);
1584 ath6kl_wmi_shutdown(ar->wmi);
1585 clear_bit(WMI_ENABLED, &ar->flag);
1592 int ath6kl_core_init(struct ath6kl *ar)
1595 struct ath6kl_bmi_target_info targ_info;
1597 ar->ath6kl_wq = create_singlethread_workqueue("ath6kl");
1601 ret = ath6kl_bmi_init(ar);
1605 ret = ath6kl_bmi_get_target_info(ar, &targ_info);
1607 goto err_bmi_cleanup;
1609 ar->version.target_ver = le32_to_cpu(targ_info.version);
1610 ar->target_type = le32_to_cpu(targ_info.type);
1611 ar->wiphy->hw_version = le32_to_cpu(targ_info.version);
1613 ret = ath6kl_init_hw_params(ar);
1615 goto err_bmi_cleanup;
1617 ret = ath6kl_configure_target(ar);
1619 goto err_bmi_cleanup;
1621 ar->htc_target = ath6kl_htc_create(ar);
1623 if (!ar->htc_target) {
1625 goto err_bmi_cleanup;
1628 ret = ath6kl_fetch_firmwares(ar);
1630 goto err_htc_cleanup;
1632 ret = ath6kl_init_upload(ar);
1634 goto err_htc_cleanup;
1636 ret = ath6kl_init(ar);
1638 goto err_htc_cleanup;
1643 ath6kl_htc_cleanup(ar->htc_target);
1645 ath6kl_bmi_cleanup(ar);
1647 destroy_workqueue(ar->ath6kl_wq);
1652 void ath6kl_cleanup_vif(struct ath6kl_vif *vif, bool wmi_ready)
1654 static u8 bcast_mac[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
1657 netif_stop_queue(vif->ndev);
1659 clear_bit(WLAN_ENABLED, &vif->flags);
1662 discon_issued = test_bit(CONNECTED, &vif->flags) ||
1663 test_bit(CONNECT_PEND, &vif->flags);
1664 ath6kl_disconnect(vif);
1665 del_timer(&vif->disconnect_timer);
1668 ath6kl_disconnect_event(vif, DISCONNECT_CMD,
1669 (vif->nw_type & AP_NETWORK) ?
1670 bcast_mac : vif->bssid,
1674 if (vif->scan_req) {
1675 cfg80211_scan_done(vif->scan_req, true);
1676 vif->scan_req = NULL;
1680 void ath6kl_stop_txrx(struct ath6kl *ar)
1682 struct ath6kl_vif *vif, *tmp_vif;
1684 set_bit(DESTROY_IN_PROGRESS, &ar->flag);
1686 if (down_interruptible(&ar->sem)) {
1687 ath6kl_err("down_interruptible failed\n");
1691 spin_lock(&ar->list_lock);
1692 list_for_each_entry_safe(vif, tmp_vif, &ar->vif_list, list) {
1693 list_del(&vif->list);
1694 spin_unlock(&ar->list_lock);
1695 ath6kl_cleanup_vif(vif, test_bit(WMI_READY, &ar->flag));
1697 ath6kl_deinit_if_data(vif);
1699 spin_lock(&ar->list_lock);
1701 spin_unlock(&ar->list_lock);
1703 clear_bit(WMI_READY, &ar->flag);
1706 * After wmi_shudown all WMI events will be dropped. We
1707 * need to cleanup the buffers allocated in AP mode and
1708 * give disconnect notification to stack, which usually
1709 * happens in the disconnect_event. Simulate the disconnect
1710 * event by calling the function directly. Sometimes
1711 * disconnect_event will be received when the debug logs
1714 ath6kl_wmi_shutdown(ar->wmi);
1716 clear_bit(WMI_ENABLED, &ar->flag);
1717 if (ar->htc_target) {
1718 ath6kl_dbg(ATH6KL_DBG_TRC, "%s: shut down htc\n", __func__);
1719 ath6kl_htc_stop(ar->htc_target);
1723 * Try to reset the device if we can. The driver may have been
1724 * configure NOT to reset the target during a debug session.
1726 ath6kl_dbg(ATH6KL_DBG_TRC,
1727 "attempting to reset target on instance destroy\n");
1728 ath6kl_reset_device(ar, ar->target_type, true, true);
1730 clear_bit(WLAN_ENABLED, &ar->flag);