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;
30 static bool suspend_cutpower;
32 module_param(debug_mask, uint, 0644);
33 module_param(testmode, uint, 0644);
34 module_param(suspend_cutpower, bool, 0444);
37 * Include definitions here that can be used to tune the WLAN module
38 * behavior. Different customers can tune the behavior as per their needs,
43 * This configuration item enable/disable keepalive support.
44 * Keepalive support: In the absence of any data traffic to AP, null
45 * frames will be sent to the AP at periodic interval, to keep the association
46 * active. This configuration item defines the periodic interval.
47 * Use value of zero to disable keepalive support
50 #define WLAN_CONFIG_KEEP_ALIVE_INTERVAL 60
53 * This configuration item sets the value of disconnect timeout
54 * Firmware delays sending the disconnec event to the host for this
55 * timeout after is gets disconnected from the current AP.
56 * If the firmware successly roams within the disconnect timeout
57 * it sends a new connect event
59 #define WLAN_CONFIG_DISCONNECT_TIMEOUT 10
61 #define CONFIG_AR600x_DEBUG_UART_TX_PIN 8
63 #define ATH6KL_DATA_OFFSET 64
64 struct sk_buff *ath6kl_buf_alloc(int size)
69 /* Add chacheline space at front and back of buffer */
70 reserved = (2 * L1_CACHE_BYTES) + ATH6KL_DATA_OFFSET +
71 sizeof(struct htc_packet) + ATH6KL_HTC_ALIGN_BYTES;
72 skb = dev_alloc_skb(size + reserved);
75 skb_reserve(skb, reserved - L1_CACHE_BYTES);
79 void ath6kl_init_profile_info(struct ath6kl_vif *vif)
82 memset(vif->ssid, 0, sizeof(vif->ssid));
84 vif->dot11_auth_mode = OPEN_AUTH;
85 vif->auth_mode = NONE_AUTH;
86 vif->prwise_crypto = NONE_CRYPT;
87 vif->prwise_crypto_len = 0;
88 vif->grp_crypto = NONE_CRYPT;
89 vif->grp_crypto_len = 0;
90 memset(vif->wep_key_list, 0, sizeof(vif->wep_key_list));
91 memset(vif->req_bssid, 0, sizeof(vif->req_bssid));
92 memset(vif->bssid, 0, sizeof(vif->bssid));
96 static int ath6kl_set_host_app_area(struct ath6kl *ar)
99 struct host_app_area host_app_area;
101 /* Fetch the address of the host_app_area_s
102 * instance in the host interest area */
103 address = ath6kl_get_hi_item_addr(ar, HI_ITEM(hi_app_host_interest));
104 address = TARG_VTOP(ar->target_type, address);
106 if (ath6kl_diag_read32(ar, address, &data))
109 address = TARG_VTOP(ar->target_type, data);
110 host_app_area.wmi_protocol_ver = cpu_to_le32(WMI_PROTOCOL_VERSION);
111 if (ath6kl_diag_write(ar, address, (u8 *) &host_app_area,
112 sizeof(struct host_app_area)))
118 static inline void set_ac2_ep_map(struct ath6kl *ar,
120 enum htc_endpoint_id ep)
122 ar->ac2ep_map[ac] = ep;
123 ar->ep2ac_map[ep] = ac;
126 /* connect to a service */
127 static int ath6kl_connectservice(struct ath6kl *ar,
128 struct htc_service_connect_req *con_req,
132 struct htc_service_connect_resp response;
134 memset(&response, 0, sizeof(response));
136 status = ath6kl_htc_conn_service(ar->htc_target, con_req, &response);
138 ath6kl_err("failed to connect to %s service status:%d\n",
143 switch (con_req->svc_id) {
144 case WMI_CONTROL_SVC:
145 if (test_bit(WMI_ENABLED, &ar->flag))
146 ath6kl_wmi_set_control_ep(ar->wmi, response.endpoint);
147 ar->ctrl_ep = response.endpoint;
149 case WMI_DATA_BE_SVC:
150 set_ac2_ep_map(ar, WMM_AC_BE, response.endpoint);
152 case WMI_DATA_BK_SVC:
153 set_ac2_ep_map(ar, WMM_AC_BK, response.endpoint);
155 case WMI_DATA_VI_SVC:
156 set_ac2_ep_map(ar, WMM_AC_VI, response.endpoint);
158 case WMI_DATA_VO_SVC:
159 set_ac2_ep_map(ar, WMM_AC_VO, response.endpoint);
162 ath6kl_err("service id is not mapped %d\n", con_req->svc_id);
169 static int ath6kl_init_service_ep(struct ath6kl *ar)
171 struct htc_service_connect_req connect;
173 memset(&connect, 0, sizeof(connect));
175 /* these fields are the same for all service endpoints */
176 connect.ep_cb.rx = ath6kl_rx;
177 connect.ep_cb.rx_refill = ath6kl_rx_refill;
178 connect.ep_cb.tx_full = ath6kl_tx_queue_full;
181 * Set the max queue depth so that our ath6kl_tx_queue_full handler
184 connect.max_txq_depth = MAX_DEFAULT_SEND_QUEUE_DEPTH;
185 connect.ep_cb.rx_refill_thresh = ATH6KL_MAX_RX_BUFFERS / 4;
186 if (!connect.ep_cb.rx_refill_thresh)
187 connect.ep_cb.rx_refill_thresh++;
189 /* connect to control service */
190 connect.svc_id = WMI_CONTROL_SVC;
191 if (ath6kl_connectservice(ar, &connect, "WMI CONTROL"))
194 connect.flags |= HTC_FLGS_TX_BNDL_PAD_EN;
197 * Limit the HTC message size on the send path, although e can
198 * receive A-MSDU frames of 4K, we will only send ethernet-sized
199 * (802.3) frames on the send path.
201 connect.max_rxmsg_sz = WMI_MAX_TX_DATA_FRAME_LENGTH;
204 * To reduce the amount of committed memory for larger A_MSDU
205 * frames, use the recv-alloc threshold mechanism for larger
208 connect.ep_cb.rx_alloc_thresh = ATH6KL_BUFFER_SIZE;
209 connect.ep_cb.rx_allocthresh = ath6kl_alloc_amsdu_rxbuf;
212 * For the remaining data services set the connection flag to
213 * reduce dribbling, if configured to do so.
215 connect.conn_flags |= HTC_CONN_FLGS_REDUCE_CRED_DRIB;
216 connect.conn_flags &= ~HTC_CONN_FLGS_THRESH_MASK;
217 connect.conn_flags |= HTC_CONN_FLGS_THRESH_LVL_HALF;
219 connect.svc_id = WMI_DATA_BE_SVC;
221 if (ath6kl_connectservice(ar, &connect, "WMI DATA BE"))
224 /* connect to back-ground map this to WMI LOW_PRI */
225 connect.svc_id = WMI_DATA_BK_SVC;
226 if (ath6kl_connectservice(ar, &connect, "WMI DATA BK"))
229 /* connect to Video service, map this to to HI PRI */
230 connect.svc_id = WMI_DATA_VI_SVC;
231 if (ath6kl_connectservice(ar, &connect, "WMI DATA VI"))
235 * Connect to VO service, this is currently not mapped to a WMI
236 * priority stream due to historical reasons. WMI originally
237 * defined 3 priorities over 3 mailboxes We can change this when
238 * WMI is reworked so that priorities are not dependent on
241 connect.svc_id = WMI_DATA_VO_SVC;
242 if (ath6kl_connectservice(ar, &connect, "WMI DATA VO"))
248 void ath6kl_init_control_info(struct ath6kl_vif *vif)
250 ath6kl_init_profile_info(vif);
251 vif->def_txkey_index = 0;
252 memset(vif->wep_key_list, 0, sizeof(vif->wep_key_list));
257 * Set HTC/Mbox operational parameters, this can only be called when the
258 * target is in the BMI phase.
260 static int ath6kl_set_htc_params(struct ath6kl *ar, u32 mbox_isr_yield_val,
266 blk_size = ar->mbox_info.block_size;
269 blk_size |= ((u32)htc_ctrl_buf) << 16;
271 /* set the host interest area for the block size */
272 status = ath6kl_bmi_write(ar,
273 ath6kl_get_hi_item_addr(ar,
274 HI_ITEM(hi_mbox_io_block_sz)),
278 ath6kl_err("bmi_write_memory for IO block size failed\n");
282 ath6kl_dbg(ATH6KL_DBG_TRC, "block size set: %d (target addr:0x%X)\n",
284 ath6kl_get_hi_item_addr(ar, HI_ITEM(hi_mbox_io_block_sz)));
286 if (mbox_isr_yield_val) {
287 /* set the host interest area for the mbox ISR yield limit */
288 status = ath6kl_bmi_write(ar,
289 ath6kl_get_hi_item_addr(ar,
290 HI_ITEM(hi_mbox_isr_yield_limit)),
291 (u8 *)&mbox_isr_yield_val,
294 ath6kl_err("bmi_write_memory for yield limit failed\n");
303 static int ath6kl_target_config_wlan_params(struct ath6kl *ar, int idx)
309 * Configure the device for rx dot11 header rules. "0,0" are the
310 * default values. Required if checksum offload is needed. Set
311 * RxMetaVersion to 2.
313 if (ath6kl_wmi_set_rx_frame_format_cmd(ar->wmi, idx,
314 ar->rx_meta_ver, 0, 0)) {
315 ath6kl_err("unable to set the rx frame format\n");
319 if (ar->conf_flags & ATH6KL_CONF_IGNORE_PS_FAIL_EVT_IN_SCAN)
320 if ((ath6kl_wmi_pmparams_cmd(ar->wmi, idx, 0, 1, 0, 0, 1,
321 IGNORE_POWER_SAVE_FAIL_EVENT_DURING_SCAN)) != 0) {
322 ath6kl_err("unable to set power save fail event policy\n");
326 if (!(ar->conf_flags & ATH6KL_CONF_IGNORE_ERP_BARKER))
327 if ((ath6kl_wmi_set_lpreamble_cmd(ar->wmi, idx, 0,
328 WMI_DONOT_IGNORE_BARKER_IN_ERP)) != 0) {
329 ath6kl_err("unable to set barker preamble policy\n");
333 if (ath6kl_wmi_set_keepalive_cmd(ar->wmi, idx,
334 WLAN_CONFIG_KEEP_ALIVE_INTERVAL)) {
335 ath6kl_err("unable to set keep alive interval\n");
339 if (ath6kl_wmi_disctimeout_cmd(ar->wmi, idx,
340 WLAN_CONFIG_DISCONNECT_TIMEOUT)) {
341 ath6kl_err("unable to set disconnect timeout\n");
345 if (!(ar->conf_flags & ATH6KL_CONF_ENABLE_TX_BURST))
346 if (ath6kl_wmi_set_wmm_txop(ar->wmi, idx, WMI_TXOP_DISABLED)) {
347 ath6kl_err("unable to set txop bursting\n");
352 * FIXME: Make sure p2p configurations are not applied to
353 * non-p2p capable interfaces when multivif support is enabled.
356 ret = ath6kl_wmi_info_req_cmd(ar->wmi, idx,
357 P2P_FLAG_CAPABILITIES_REQ |
358 P2P_FLAG_MACADDR_REQ |
359 P2P_FLAG_HMODEL_REQ);
361 ath6kl_dbg(ATH6KL_DBG_TRC, "failed to request P2P "
362 "capabilities (%d) - assuming P2P not "
369 * FIXME: Make sure p2p configurations are not applied to
370 * non-p2p capable interfaces when multivif support is enabled.
373 /* Enable Probe Request reporting for P2P */
374 ret = ath6kl_wmi_probe_report_req_cmd(ar->wmi, idx, true);
376 ath6kl_dbg(ATH6KL_DBG_TRC, "failed to enable Probe "
377 "Request reporting (%d)\n", ret);
384 int ath6kl_configure_target(struct ath6kl *ar)
386 u32 param, ram_reserved_size;
387 u8 fw_iftype, fw_mode = 0, fw_submode = 0;
391 * Note: Even though the firmware interface type is
392 * chosen as BSS_STA for all three interfaces, can
393 * be configured to IBSS/AP as long as the fw submode
394 * remains normal mode (0 - AP, STA and IBSS). But
395 * due to an target assert in firmware only one interface is
396 * configured for now.
398 fw_iftype = HI_OPTION_FW_MODE_BSS_STA;
400 for (i = 0; i < MAX_NUM_VIF; i++)
401 fw_mode |= fw_iftype << (i * HI_OPTION_FW_MODE_BITS);
404 * By default, submodes :
405 * vif[0] - AP/STA/IBSS
406 * vif[1] - "P2P dev"/"P2P GO"/"P2P Client"
407 * vif[2] - "P2P dev"/"P2P GO"/"P2P Client"
410 for (i = 0; i < ar->max_norm_iface; i++)
411 fw_submode |= HI_OPTION_FW_SUBMODE_NONE <<
412 (i * HI_OPTION_FW_SUBMODE_BITS);
414 for (i = ar->max_norm_iface; i < MAX_NUM_VIF; i++)
415 fw_submode |= HI_OPTION_FW_SUBMODE_P2PDEV <<
416 (i * HI_OPTION_FW_SUBMODE_BITS);
419 * FIXME: This needs to be removed once the multivif
420 * support is enabled.
423 fw_submode = HI_OPTION_FW_SUBMODE_P2PDEV;
425 param = HTC_PROTOCOL_VERSION;
426 if (ath6kl_bmi_write(ar,
427 ath6kl_get_hi_item_addr(ar,
428 HI_ITEM(hi_app_host_interest)),
429 (u8 *)¶m, 4) != 0) {
430 ath6kl_err("bmi_write_memory for htc version failed\n");
434 /* set the firmware mode to STA/IBSS/AP */
437 if (ath6kl_bmi_read(ar,
438 ath6kl_get_hi_item_addr(ar,
439 HI_ITEM(hi_option_flag)),
440 (u8 *)¶m, 4) != 0) {
441 ath6kl_err("bmi_read_memory for setting fwmode failed\n");
445 param |= (MAX_NUM_VIF << HI_OPTION_NUM_DEV_SHIFT);
446 param |= fw_mode << HI_OPTION_FW_MODE_SHIFT;
447 param |= fw_submode << HI_OPTION_FW_SUBMODE_SHIFT;
449 param |= (0 << HI_OPTION_MAC_ADDR_METHOD_SHIFT);
450 param |= (0 << HI_OPTION_FW_BRIDGE_SHIFT);
452 if (ath6kl_bmi_write(ar,
453 ath6kl_get_hi_item_addr(ar,
454 HI_ITEM(hi_option_flag)),
457 ath6kl_err("bmi_write_memory for setting fwmode failed\n");
461 ath6kl_dbg(ATH6KL_DBG_TRC, "firmware mode set\n");
464 * Hardcode the address use for the extended board data
465 * Ideally this should be pre-allocate by the OS at boot time
466 * But since it is a new feature and board data is loaded
467 * at init time, we have to workaround this from host.
468 * It is difficult to patch the firmware boot code,
469 * but possible in theory.
472 param = ar->hw.board_ext_data_addr;
473 ram_reserved_size = ar->hw.reserved_ram_size;
475 if (ath6kl_bmi_write(ar, ath6kl_get_hi_item_addr(ar,
476 HI_ITEM(hi_board_ext_data)),
477 (u8 *)¶m, 4) != 0) {
478 ath6kl_err("bmi_write_memory for hi_board_ext_data failed\n");
482 if (ath6kl_bmi_write(ar, ath6kl_get_hi_item_addr(ar,
483 HI_ITEM(hi_end_ram_reserve_sz)),
484 (u8 *)&ram_reserved_size, 4) != 0) {
485 ath6kl_err("bmi_write_memory for hi_end_ram_reserve_sz failed\n");
489 /* set the block size for the target */
490 if (ath6kl_set_htc_params(ar, MBOX_YIELD_LIMIT, 0))
491 /* use default number of control buffers */
497 void ath6kl_core_free(struct ath6kl *ar)
499 wiphy_free(ar->wiphy);
502 void ath6kl_core_cleanup(struct ath6kl *ar)
504 ath6kl_hif_power_off(ar);
506 destroy_workqueue(ar->ath6kl_wq);
509 ath6kl_htc_cleanup(ar->htc_target);
511 ath6kl_cookie_cleanup(ar);
513 ath6kl_cleanup_amsdu_rxbufs(ar);
515 ath6kl_bmi_cleanup(ar);
517 ath6kl_debug_cleanup(ar);
524 ath6kl_deinit_ieee80211_hw(ar);
527 /* firmware upload */
528 static int ath6kl_get_fw(struct ath6kl *ar, const char *filename,
529 u8 **fw, size_t *fw_len)
531 const struct firmware *fw_entry;
534 ret = request_firmware(&fw_entry, filename, ar->dev);
538 *fw_len = fw_entry->size;
539 *fw = kmemdup(fw_entry->data, fw_entry->size, GFP_KERNEL);
544 release_firmware(fw_entry);
550 static const char *get_target_ver_dir(const struct ath6kl *ar)
552 switch (ar->version.target_ver) {
553 case AR6003_REV1_VERSION:
554 return "ath6k/AR6003/hw1.0";
555 case AR6003_REV2_VERSION:
556 return "ath6k/AR6003/hw2.0";
557 case AR6003_REV3_VERSION:
558 return "ath6k/AR6003/hw2.1.1";
560 ath6kl_warn("%s: unsupported target version 0x%x.\n", __func__,
561 ar->version.target_ver);
566 * Check the device tree for a board-id and use it to construct
567 * the pathname to the firmware file. Used (for now) to find a
568 * fallback to the "bdata.bin" file--typically a symlink to the
569 * appropriate board-specific file.
571 static bool check_device_tree(struct ath6kl *ar)
573 static const char *board_id_prop = "atheros,board-id";
574 struct device_node *node;
575 char board_filename[64];
576 const char *board_id;
579 for_each_compatible_node(node, NULL, "atheros,ath6kl") {
580 board_id = of_get_property(node, board_id_prop, NULL);
581 if (board_id == NULL) {
582 ath6kl_warn("No \"%s\" property on %s node.\n",
583 board_id_prop, node->name);
586 snprintf(board_filename, sizeof(board_filename),
587 "%s/bdata.%s.bin", get_target_ver_dir(ar), board_id);
589 ret = ath6kl_get_fw(ar, board_filename, &ar->fw_board,
592 ath6kl_err("Failed to get DT board file %s: %d\n",
593 board_filename, ret);
601 static bool check_device_tree(struct ath6kl *ar)
605 #endif /* CONFIG_OF */
607 static int ath6kl_fetch_board_file(struct ath6kl *ar)
609 const char *filename;
612 if (ar->fw_board != NULL)
615 switch (ar->version.target_ver) {
616 case AR6003_REV2_VERSION:
617 filename = AR6003_REV2_BOARD_DATA_FILE;
619 case AR6004_REV1_VERSION:
620 filename = AR6004_REV1_BOARD_DATA_FILE;
623 filename = AR6003_REV3_BOARD_DATA_FILE;
627 ret = ath6kl_get_fw(ar, filename, &ar->fw_board,
630 /* managed to get proper board file */
634 if (check_device_tree(ar)) {
635 /* got board file from device tree */
639 /* there was no proper board file, try to use default instead */
640 ath6kl_warn("Failed to get board file %s (%d), trying to find default board file.\n",
643 switch (ar->version.target_ver) {
644 case AR6003_REV2_VERSION:
645 filename = AR6003_REV2_DEFAULT_BOARD_DATA_FILE;
647 case AR6004_REV1_VERSION:
648 filename = AR6004_REV1_DEFAULT_BOARD_DATA_FILE;
651 filename = AR6003_REV3_DEFAULT_BOARD_DATA_FILE;
655 ret = ath6kl_get_fw(ar, filename, &ar->fw_board,
658 ath6kl_err("Failed to get default board file %s: %d\n",
663 ath6kl_warn("WARNING! No proper board file was not found, instead using a default board file.\n");
664 ath6kl_warn("Most likely your hardware won't work as specified. Install correct board file!\n");
669 static int ath6kl_fetch_otp_file(struct ath6kl *ar)
671 const char *filename;
674 if (ar->fw_otp != NULL)
677 switch (ar->version.target_ver) {
678 case AR6003_REV2_VERSION:
679 filename = AR6003_REV2_OTP_FILE;
681 case AR6004_REV1_VERSION:
682 ath6kl_dbg(ATH6KL_DBG_TRC, "AR6004 doesn't need OTP file\n");
686 filename = AR6003_REV3_OTP_FILE;
690 ret = ath6kl_get_fw(ar, filename, &ar->fw_otp,
693 ath6kl_err("Failed to get OTP file %s: %d\n",
701 static int ath6kl_fetch_fw_file(struct ath6kl *ar)
703 const char *filename;
710 switch (ar->version.target_ver) {
711 case AR6003_REV2_VERSION:
712 filename = AR6003_REV2_TCMD_FIRMWARE_FILE;
714 case AR6003_REV3_VERSION:
715 filename = AR6003_REV3_TCMD_FIRMWARE_FILE;
717 case AR6004_REV1_VERSION:
718 ath6kl_warn("testmode not supported with ar6004\n");
721 ath6kl_warn("unknown target version: 0x%x\n",
722 ar->version.target_ver);
726 set_bit(TESTMODE, &ar->flag);
731 switch (ar->version.target_ver) {
732 case AR6003_REV2_VERSION:
733 filename = AR6003_REV2_FIRMWARE_FILE;
735 case AR6004_REV1_VERSION:
736 filename = AR6004_REV1_FIRMWARE_FILE;
739 filename = AR6003_REV3_FIRMWARE_FILE;
744 ret = ath6kl_get_fw(ar, filename, &ar->fw, &ar->fw_len);
746 ath6kl_err("Failed to get firmware file %s: %d\n",
754 static int ath6kl_fetch_patch_file(struct ath6kl *ar)
756 const char *filename;
759 switch (ar->version.target_ver) {
760 case AR6003_REV2_VERSION:
761 filename = AR6003_REV2_PATCH_FILE;
763 case AR6004_REV1_VERSION:
764 /* FIXME: implement for AR6004 */
768 filename = AR6003_REV3_PATCH_FILE;
772 if (ar->fw_patch == NULL) {
773 ret = ath6kl_get_fw(ar, filename, &ar->fw_patch,
776 ath6kl_err("Failed to get patch file %s: %d\n",
785 static int ath6kl_fetch_fw_api1(struct ath6kl *ar)
789 ret = ath6kl_fetch_otp_file(ar);
793 ret = ath6kl_fetch_fw_file(ar);
797 ret = ath6kl_fetch_patch_file(ar);
804 static int ath6kl_fetch_fw_api2(struct ath6kl *ar)
806 size_t magic_len, len, ie_len;
807 const struct firmware *fw;
808 struct ath6kl_fw_ie *hdr;
809 const char *filename;
811 int ret, ie_id, i, index, bit;
814 switch (ar->version.target_ver) {
815 case AR6003_REV2_VERSION:
816 filename = AR6003_REV2_FIRMWARE_2_FILE;
818 case AR6003_REV3_VERSION:
819 filename = AR6003_REV3_FIRMWARE_2_FILE;
821 case AR6004_REV1_VERSION:
822 filename = AR6004_REV1_FIRMWARE_2_FILE;
828 ret = request_firmware(&fw, filename, ar->dev);
835 /* magic also includes the null byte, check that as well */
836 magic_len = strlen(ATH6KL_FIRMWARE_MAGIC) + 1;
838 if (len < magic_len) {
843 if (memcmp(data, ATH6KL_FIRMWARE_MAGIC, magic_len) != 0) {
852 while (len > sizeof(struct ath6kl_fw_ie)) {
853 /* hdr is unaligned! */
854 hdr = (struct ath6kl_fw_ie *) data;
856 ie_id = le32_to_cpup(&hdr->id);
857 ie_len = le32_to_cpup(&hdr->len);
860 data += sizeof(*hdr);
868 case ATH6KL_FW_IE_OTP_IMAGE:
869 ath6kl_dbg(ATH6KL_DBG_BOOT, "found otp image ie (%zd B)\n",
872 ar->fw_otp = kmemdup(data, ie_len, GFP_KERNEL);
874 if (ar->fw_otp == NULL) {
879 ar->fw_otp_len = ie_len;
881 case ATH6KL_FW_IE_FW_IMAGE:
882 ath6kl_dbg(ATH6KL_DBG_BOOT, "found fw image ie (%zd B)\n",
885 ar->fw = kmemdup(data, ie_len, GFP_KERNEL);
887 if (ar->fw == NULL) {
894 case ATH6KL_FW_IE_PATCH_IMAGE:
895 ath6kl_dbg(ATH6KL_DBG_BOOT, "found patch image ie (%zd B)\n",
898 ar->fw_patch = kmemdup(data, ie_len, GFP_KERNEL);
900 if (ar->fw_patch == NULL) {
905 ar->fw_patch_len = ie_len;
907 case ATH6KL_FW_IE_RESERVED_RAM_SIZE:
908 val = (__le32 *) data;
909 ar->hw.reserved_ram_size = le32_to_cpup(val);
911 ath6kl_dbg(ATH6KL_DBG_BOOT,
912 "found reserved ram size ie 0x%d\n",
913 ar->hw.reserved_ram_size);
915 case ATH6KL_FW_IE_CAPABILITIES:
916 ath6kl_dbg(ATH6KL_DBG_BOOT,
917 "found firmware capabilities ie (%zd B)\n",
920 for (i = 0; i < ATH6KL_FW_CAPABILITY_MAX; i++) {
921 index = ALIGN(i, 8) / 8;
924 if (data[index] & (1 << bit))
925 __set_bit(i, ar->fw_capabilities);
928 ath6kl_dbg_dump(ATH6KL_DBG_BOOT, "capabilities", "",
930 sizeof(ar->fw_capabilities));
932 case ATH6KL_FW_IE_PATCH_ADDR:
933 if (ie_len != sizeof(*val))
936 val = (__le32 *) data;
937 ar->hw.dataset_patch_addr = le32_to_cpup(val);
939 ath6kl_dbg(ATH6KL_DBG_BOOT,
940 "found patch address ie 0x%d\n",
941 ar->hw.dataset_patch_addr);
944 ath6kl_dbg(ATH6KL_DBG_BOOT, "Unknown fw ie: %u\n",
945 le32_to_cpup(&hdr->id));
955 release_firmware(fw);
960 static int ath6kl_fetch_firmwares(struct ath6kl *ar)
964 ret = ath6kl_fetch_board_file(ar);
968 ret = ath6kl_fetch_fw_api2(ar);
970 ath6kl_dbg(ATH6KL_DBG_BOOT, "using fw api 2\n");
974 ret = ath6kl_fetch_fw_api1(ar);
978 ath6kl_dbg(ATH6KL_DBG_BOOT, "using fw api 1\n");
983 static int ath6kl_upload_board_file(struct ath6kl *ar)
985 u32 board_address, board_ext_address, param;
986 u32 board_data_size, board_ext_data_size;
989 if (WARN_ON(ar->fw_board == NULL))
993 * Determine where in Target RAM to write Board Data.
994 * For AR6004, host determine Target RAM address for
995 * writing board data.
997 if (ar->target_type == TARGET_TYPE_AR6004) {
998 board_address = AR6004_REV1_BOARD_DATA_ADDRESS;
1000 ath6kl_get_hi_item_addr(ar,
1001 HI_ITEM(hi_board_data)),
1002 (u8 *) &board_address, 4);
1005 ath6kl_get_hi_item_addr(ar,
1006 HI_ITEM(hi_board_data)),
1007 (u8 *) &board_address, 4);
1010 /* determine where in target ram to write extended board data */
1012 ath6kl_get_hi_item_addr(ar,
1013 HI_ITEM(hi_board_ext_data)),
1014 (u8 *) &board_ext_address, 4);
1016 if (board_ext_address == 0) {
1017 ath6kl_err("Failed to get board file target address.\n");
1021 switch (ar->target_type) {
1022 case TARGET_TYPE_AR6003:
1023 board_data_size = AR6003_BOARD_DATA_SZ;
1024 board_ext_data_size = AR6003_BOARD_EXT_DATA_SZ;
1026 case TARGET_TYPE_AR6004:
1027 board_data_size = AR6004_BOARD_DATA_SZ;
1028 board_ext_data_size = AR6004_BOARD_EXT_DATA_SZ;
1036 if (ar->fw_board_len == (board_data_size +
1037 board_ext_data_size)) {
1039 /* write extended board data */
1040 ath6kl_dbg(ATH6KL_DBG_BOOT,
1041 "writing extended board data to 0x%x (%d B)\n",
1042 board_ext_address, board_ext_data_size);
1044 ret = ath6kl_bmi_write(ar, board_ext_address,
1045 ar->fw_board + board_data_size,
1046 board_ext_data_size);
1048 ath6kl_err("Failed to write extended board data: %d\n",
1053 /* record that extended board data is initialized */
1054 param = (board_ext_data_size << 16) | 1;
1056 ath6kl_bmi_write(ar,
1057 ath6kl_get_hi_item_addr(ar,
1058 HI_ITEM(hi_board_ext_data_config)),
1059 (unsigned char *) ¶m, 4);
1062 if (ar->fw_board_len < board_data_size) {
1063 ath6kl_err("Too small board file: %zu\n", ar->fw_board_len);
1068 ath6kl_dbg(ATH6KL_DBG_BOOT, "writing board file to 0x%x (%d B)\n",
1069 board_address, board_data_size);
1071 ret = ath6kl_bmi_write(ar, board_address, ar->fw_board,
1075 ath6kl_err("Board file bmi write failed: %d\n", ret);
1079 /* record the fact that Board Data IS initialized */
1081 ath6kl_bmi_write(ar,
1082 ath6kl_get_hi_item_addr(ar,
1083 HI_ITEM(hi_board_data_initialized)),
1089 static int ath6kl_upload_otp(struct ath6kl *ar)
1092 bool from_hw = false;
1095 if (WARN_ON(ar->fw_otp == NULL))
1098 address = ar->hw.app_load_addr;
1100 ath6kl_dbg(ATH6KL_DBG_BOOT, "writing otp to 0x%x (%zd B)\n", address,
1103 ret = ath6kl_bmi_fast_download(ar, address, ar->fw_otp,
1106 ath6kl_err("Failed to upload OTP file: %d\n", ret);
1110 /* read firmware start address */
1111 ret = ath6kl_bmi_read(ar,
1112 ath6kl_get_hi_item_addr(ar,
1113 HI_ITEM(hi_app_start)),
1114 (u8 *) &address, sizeof(address));
1117 ath6kl_err("Failed to read hi_app_start: %d\n", ret);
1121 if (ar->hw.app_start_override_addr == 0) {
1122 ar->hw.app_start_override_addr = address;
1126 ath6kl_dbg(ATH6KL_DBG_BOOT, "app_start_override_addr%s 0x%x\n",
1127 from_hw ? " (from hw)" : "",
1128 ar->hw.app_start_override_addr);
1130 /* execute the OTP code */
1131 ath6kl_dbg(ATH6KL_DBG_BOOT, "executing OTP at 0x%x\n",
1132 ar->hw.app_start_override_addr);
1134 ath6kl_bmi_execute(ar, ar->hw.app_start_override_addr, ¶m);
1139 static int ath6kl_upload_firmware(struct ath6kl *ar)
1144 if (WARN_ON(ar->fw == NULL))
1147 address = ar->hw.app_load_addr;
1149 ath6kl_dbg(ATH6KL_DBG_BOOT, "writing firmware to 0x%x (%zd B)\n",
1150 address, ar->fw_len);
1152 ret = ath6kl_bmi_fast_download(ar, address, ar->fw, ar->fw_len);
1155 ath6kl_err("Failed to write firmware: %d\n", ret);
1160 * Set starting address for firmware
1161 * Don't need to setup app_start override addr on AR6004
1163 if (ar->target_type != TARGET_TYPE_AR6004) {
1164 address = ar->hw.app_start_override_addr;
1165 ath6kl_bmi_set_app_start(ar, address);
1170 static int ath6kl_upload_patch(struct ath6kl *ar)
1175 if (WARN_ON(ar->fw_patch == NULL))
1178 address = ar->hw.dataset_patch_addr;
1180 ath6kl_dbg(ATH6KL_DBG_BOOT, "writing patch to 0x%x (%zd B)\n",
1181 address, ar->fw_patch_len);
1183 ret = ath6kl_bmi_write(ar, address, ar->fw_patch, ar->fw_patch_len);
1185 ath6kl_err("Failed to write patch file: %d\n", ret);
1190 ath6kl_bmi_write(ar,
1191 ath6kl_get_hi_item_addr(ar,
1192 HI_ITEM(hi_dset_list_head)),
1193 (unsigned char *) ¶m, 4);
1198 static int ath6kl_init_upload(struct ath6kl *ar)
1200 u32 param, options, sleep, address;
1203 if (ar->target_type != TARGET_TYPE_AR6003 &&
1204 ar->target_type != TARGET_TYPE_AR6004)
1207 /* temporarily disable system sleep */
1208 address = MBOX_BASE_ADDRESS + LOCAL_SCRATCH_ADDRESS;
1209 status = ath6kl_bmi_reg_read(ar, address, ¶m);
1215 param |= ATH6KL_OPTION_SLEEP_DISABLE;
1216 status = ath6kl_bmi_reg_write(ar, address, param);
1220 address = RTC_BASE_ADDRESS + SYSTEM_SLEEP_ADDRESS;
1221 status = ath6kl_bmi_reg_read(ar, address, ¶m);
1227 param |= SM(SYSTEM_SLEEP_DISABLE, 1);
1228 status = ath6kl_bmi_reg_write(ar, address, param);
1232 ath6kl_dbg(ATH6KL_DBG_TRC, "old options: %d, old sleep: %d\n",
1235 /* program analog PLL register */
1236 /* no need to control 40/44MHz clock on AR6004 */
1237 if (ar->target_type != TARGET_TYPE_AR6004) {
1238 status = ath6kl_bmi_reg_write(ar, ATH6KL_ANALOG_PLL_REGISTER,
1244 /* Run at 80/88MHz by default */
1245 param = SM(CPU_CLOCK_STANDARD, 1);
1247 address = RTC_BASE_ADDRESS + CPU_CLOCK_ADDRESS;
1248 status = ath6kl_bmi_reg_write(ar, address, param);
1254 address = RTC_BASE_ADDRESS + LPO_CAL_ADDRESS;
1255 param = SM(LPO_CAL_ENABLE, 1);
1256 status = ath6kl_bmi_reg_write(ar, address, param);
1260 /* WAR to avoid SDIO CRC err */
1261 if (ar->version.target_ver == AR6003_REV2_VERSION) {
1262 ath6kl_err("temporary war to avoid sdio crc error\n");
1266 address = GPIO_BASE_ADDRESS + GPIO_PIN10_ADDRESS;
1267 status = ath6kl_bmi_reg_write(ar, address, param);
1271 address = GPIO_BASE_ADDRESS + GPIO_PIN11_ADDRESS;
1272 status = ath6kl_bmi_reg_write(ar, address, param);
1276 address = GPIO_BASE_ADDRESS + GPIO_PIN12_ADDRESS;
1277 status = ath6kl_bmi_reg_write(ar, address, param);
1281 address = GPIO_BASE_ADDRESS + GPIO_PIN13_ADDRESS;
1282 status = ath6kl_bmi_reg_write(ar, address, param);
1287 /* write EEPROM data to Target RAM */
1288 status = ath6kl_upload_board_file(ar);
1292 /* transfer One time Programmable data */
1293 status = ath6kl_upload_otp(ar);
1297 /* Download Target firmware */
1298 status = ath6kl_upload_firmware(ar);
1302 status = ath6kl_upload_patch(ar);
1306 /* Restore system sleep */
1307 address = RTC_BASE_ADDRESS + SYSTEM_SLEEP_ADDRESS;
1308 status = ath6kl_bmi_reg_write(ar, address, sleep);
1312 address = MBOX_BASE_ADDRESS + LOCAL_SCRATCH_ADDRESS;
1313 param = options | 0x20;
1314 status = ath6kl_bmi_reg_write(ar, address, param);
1318 /* Configure GPIO AR6003 UART */
1319 param = CONFIG_AR600x_DEBUG_UART_TX_PIN;
1320 status = ath6kl_bmi_write(ar,
1321 ath6kl_get_hi_item_addr(ar,
1322 HI_ITEM(hi_dbg_uart_txpin)),
1328 static int ath6kl_init_hw_params(struct ath6kl *ar)
1330 switch (ar->version.target_ver) {
1331 case AR6003_REV2_VERSION:
1332 ar->hw.dataset_patch_addr = AR6003_REV2_DATASET_PATCH_ADDRESS;
1333 ar->hw.app_load_addr = AR6003_REV2_APP_LOAD_ADDRESS;
1334 ar->hw.board_ext_data_addr = AR6003_REV2_BOARD_EXT_DATA_ADDRESS;
1335 ar->hw.reserved_ram_size = AR6003_REV2_RAM_RESERVE_SIZE;
1337 /* hw2.0 needs override address hardcoded */
1338 ar->hw.app_start_override_addr = 0x944C00;
1341 case AR6003_REV3_VERSION:
1342 ar->hw.dataset_patch_addr = AR6003_REV3_DATASET_PATCH_ADDRESS;
1343 ar->hw.app_load_addr = 0x1234;
1344 ar->hw.board_ext_data_addr = AR6003_REV3_BOARD_EXT_DATA_ADDRESS;
1345 ar->hw.reserved_ram_size = AR6003_REV3_RAM_RESERVE_SIZE;
1347 case AR6004_REV1_VERSION:
1348 ar->hw.dataset_patch_addr = AR6003_REV2_DATASET_PATCH_ADDRESS;
1349 ar->hw.app_load_addr = AR6003_REV3_APP_LOAD_ADDRESS;
1350 ar->hw.board_ext_data_addr = AR6004_REV1_BOARD_EXT_DATA_ADDRESS;
1351 ar->hw.reserved_ram_size = AR6004_REV1_RAM_RESERVE_SIZE;
1354 ath6kl_err("Unsupported hardware version: 0x%x\n",
1355 ar->version.target_ver);
1359 ath6kl_dbg(ATH6KL_DBG_BOOT,
1360 "target_ver 0x%x target_type 0x%x dataset_patch 0x%x app_load_addr 0x%x\n",
1361 ar->version.target_ver, ar->target_type,
1362 ar->hw.dataset_patch_addr, ar->hw.app_load_addr);
1363 ath6kl_dbg(ATH6KL_DBG_BOOT,
1364 "app_start_override_addr 0x%x board_ext_data_addr 0x%x reserved_ram_size 0x%x",
1365 ar->hw.app_start_override_addr, ar->hw.board_ext_data_addr,
1366 ar->hw.reserved_ram_size);
1371 int ath6kl_init_hw_start(struct ath6kl *ar)
1376 ath6kl_dbg(ATH6KL_DBG_BOOT, "hw start\n");
1378 ret = ath6kl_hif_power_on(ar);
1382 ret = ath6kl_configure_target(ar);
1386 ret = ath6kl_init_upload(ar);
1390 /* Do we need to finish the BMI phase */
1391 /* FIXME: return error from ath6kl_bmi_done() */
1392 if (ath6kl_bmi_done(ar)) {
1398 * The reason we have to wait for the target here is that the
1399 * driver layer has to init BMI in order to set the host block
1402 if (ath6kl_htc_wait_target(ar->htc_target)) {
1407 if (ath6kl_init_service_ep(ar)) {
1409 goto err_cleanup_scatter;
1412 /* setup credit distribution */
1413 ath6kl_credit_setup(ar->htc_target, &ar->credit_state_info);
1416 ret = ath6kl_htc_start(ar->htc_target);
1418 /* FIXME: call this */
1419 ath6kl_cookie_cleanup(ar);
1420 goto err_cleanup_scatter;
1423 /* Wait for Wmi event to be ready */
1424 timeleft = wait_event_interruptible_timeout(ar->event_wq,
1429 ath6kl_dbg(ATH6KL_DBG_BOOT, "firmware booted\n");
1431 if (ar->version.abi_ver != ATH6KL_ABI_VERSION) {
1432 ath6kl_err("abi version mismatch: host(0x%x), target(0x%x)\n",
1433 ATH6KL_ABI_VERSION, ar->version.abi_ver);
1438 if (!timeleft || signal_pending(current)) {
1439 ath6kl_err("wmi is not ready or wait was interrupted\n");
1444 ath6kl_dbg(ATH6KL_DBG_TRC, "%s: wmi is ready\n", __func__);
1446 /* communicate the wmi protocol verision to the target */
1447 /* FIXME: return error */
1448 if ((ath6kl_set_host_app_area(ar)) != 0)
1449 ath6kl_err("unable to set the host app area\n");
1451 for (i = 0; i < MAX_NUM_VIF; i++) {
1452 ret = ath6kl_target_config_wlan_params(ar, i);
1457 ar->state = ATH6KL_STATE_ON;
1462 ath6kl_htc_stop(ar->htc_target);
1463 err_cleanup_scatter:
1464 ath6kl_hif_cleanup_scatter(ar);
1466 ath6kl_hif_power_off(ar);
1471 int ath6kl_init_hw_stop(struct ath6kl *ar)
1475 ath6kl_dbg(ATH6KL_DBG_BOOT, "hw stop\n");
1477 ath6kl_htc_stop(ar->htc_target);
1479 ath6kl_hif_stop(ar);
1481 ath6kl_bmi_reset(ar);
1483 ret = ath6kl_hif_power_off(ar);
1485 ath6kl_warn("failed to power off hif: %d\n", ret);
1487 ar->state = ATH6KL_STATE_OFF;
1492 int ath6kl_core_init(struct ath6kl *ar)
1494 struct ath6kl_bmi_target_info targ_info;
1495 struct net_device *ndev;
1498 ar->ath6kl_wq = create_singlethread_workqueue("ath6kl");
1502 ret = ath6kl_bmi_init(ar);
1507 * Turn on power to get hardware (target) version and leave power
1508 * on delibrately as we will boot the hardware anyway within few
1511 ret = ath6kl_hif_power_on(ar);
1513 goto err_bmi_cleanup;
1515 ret = ath6kl_bmi_get_target_info(ar, &targ_info);
1519 ar->version.target_ver = le32_to_cpu(targ_info.version);
1520 ar->target_type = le32_to_cpu(targ_info.type);
1521 ar->wiphy->hw_version = le32_to_cpu(targ_info.version);
1523 ret = ath6kl_init_hw_params(ar);
1527 ar->htc_target = ath6kl_htc_create(ar);
1529 if (!ar->htc_target) {
1534 ret = ath6kl_fetch_firmwares(ar);
1536 goto err_htc_cleanup;
1538 /* FIXME: we should free all firmwares in the error cases below */
1540 /* Indicate that WMI is enabled (although not ready yet) */
1541 set_bit(WMI_ENABLED, &ar->flag);
1542 ar->wmi = ath6kl_wmi_init(ar);
1544 ath6kl_err("failed to initialize wmi\n");
1546 goto err_htc_cleanup;
1549 ath6kl_dbg(ATH6KL_DBG_TRC, "%s: got wmi @ 0x%p.\n", __func__, ar->wmi);
1551 ret = ath6kl_register_ieee80211_hw(ar);
1553 goto err_node_cleanup;
1555 ret = ath6kl_debug_init(ar);
1557 wiphy_unregister(ar->wiphy);
1558 goto err_node_cleanup;
1561 for (i = 0; i < MAX_NUM_VIF; i++)
1562 ar->avail_idx_map |= BIT(i);
1566 /* Add an initial station interface */
1567 ndev = ath6kl_interface_add(ar, "wlan%d", NL80211_IFTYPE_STATION, 0,
1573 ath6kl_err("Failed to instantiate a network device\n");
1575 wiphy_unregister(ar->wiphy);
1576 goto err_debug_init;
1580 ath6kl_dbg(ATH6KL_DBG_TRC, "%s: name=%s dev=0x%p, ar=0x%p\n",
1581 __func__, ndev->name, ndev, ar);
1583 /* setup access class priority mappings */
1584 ar->ac_stream_pri_map[WMM_AC_BK] = 0; /* lowest */
1585 ar->ac_stream_pri_map[WMM_AC_BE] = 1;
1586 ar->ac_stream_pri_map[WMM_AC_VI] = 2;
1587 ar->ac_stream_pri_map[WMM_AC_VO] = 3; /* highest */
1589 /* give our connected endpoints some buffers */
1590 ath6kl_rx_refill(ar->htc_target, ar->ctrl_ep);
1591 ath6kl_rx_refill(ar->htc_target, ar->ac2ep_map[WMM_AC_BE]);
1593 /* allocate some buffers that handle larger AMSDU frames */
1594 ath6kl_refill_amsdu_rxbufs(ar, ATH6KL_MAX_AMSDU_RX_BUFFERS);
1596 ath6kl_cookie_init(ar);
1598 ar->conf_flags = ATH6KL_CONF_IGNORE_ERP_BARKER |
1599 ATH6KL_CONF_ENABLE_11N | ATH6KL_CONF_ENABLE_TX_BURST;
1601 if (suspend_cutpower)
1602 ar->conf_flags |= ATH6KL_CONF_SUSPEND_CUTPOWER;
1604 ar->wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM |
1605 WIPHY_FLAG_HAVE_AP_SME |
1606 WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL;
1608 set_bit(FIRST_BOOT, &ar->flag);
1610 ret = ath6kl_init_hw_start(ar);
1612 ath6kl_err("Failed to start hardware: %d\n", ret);
1613 goto err_rxbuf_cleanup;
1617 * Set mac address which is received in ready event
1618 * FIXME: Move to ath6kl_interface_add()
1620 memcpy(ndev->dev_addr, ar->mac_addr, ETH_ALEN);
1625 ath6kl_htc_flush_rx_buf(ar->htc_target);
1626 ath6kl_cleanup_amsdu_rxbufs(ar);
1628 ath6kl_deinit_if_data(netdev_priv(ndev));
1630 wiphy_unregister(ar->wiphy);
1632 ath6kl_debug_cleanup(ar);
1634 ath6kl_wmi_shutdown(ar->wmi);
1635 clear_bit(WMI_ENABLED, &ar->flag);
1638 ath6kl_htc_cleanup(ar->htc_target);
1640 ath6kl_hif_power_off(ar);
1642 ath6kl_bmi_cleanup(ar);
1644 destroy_workqueue(ar->ath6kl_wq);
1649 void ath6kl_cleanup_vif(struct ath6kl_vif *vif, bool wmi_ready)
1651 static u8 bcast_mac[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
1654 netif_stop_queue(vif->ndev);
1656 clear_bit(WLAN_ENABLED, &vif->flags);
1659 discon_issued = test_bit(CONNECTED, &vif->flags) ||
1660 test_bit(CONNECT_PEND, &vif->flags);
1661 ath6kl_disconnect(vif);
1662 del_timer(&vif->disconnect_timer);
1665 ath6kl_disconnect_event(vif, DISCONNECT_CMD,
1666 (vif->nw_type & AP_NETWORK) ?
1667 bcast_mac : vif->bssid,
1671 if (vif->scan_req) {
1672 cfg80211_scan_done(vif->scan_req, true);
1673 vif->scan_req = NULL;
1677 void ath6kl_stop_txrx(struct ath6kl *ar)
1679 struct ath6kl_vif *vif, *tmp_vif;
1681 set_bit(DESTROY_IN_PROGRESS, &ar->flag);
1683 if (down_interruptible(&ar->sem)) {
1684 ath6kl_err("down_interruptible failed\n");
1688 spin_lock_bh(&ar->list_lock);
1689 list_for_each_entry_safe(vif, tmp_vif, &ar->vif_list, list) {
1690 list_del(&vif->list);
1691 spin_unlock_bh(&ar->list_lock);
1692 ath6kl_cleanup_vif(vif, test_bit(WMI_READY, &ar->flag));
1694 ath6kl_deinit_if_data(vif);
1696 spin_lock_bh(&ar->list_lock);
1698 spin_unlock_bh(&ar->list_lock);
1700 clear_bit(WMI_READY, &ar->flag);
1703 * After wmi_shudown all WMI events will be dropped. We
1704 * need to cleanup the buffers allocated in AP mode and
1705 * give disconnect notification to stack, which usually
1706 * happens in the disconnect_event. Simulate the disconnect
1707 * event by calling the function directly. Sometimes
1708 * disconnect_event will be received when the debug logs
1711 ath6kl_wmi_shutdown(ar->wmi);
1713 clear_bit(WMI_ENABLED, &ar->flag);
1714 if (ar->htc_target) {
1715 ath6kl_dbg(ATH6KL_DBG_TRC, "%s: shut down htc\n", __func__);
1716 ath6kl_htc_stop(ar->htc_target);
1720 * Try to reset the device if we can. The driver may have been
1721 * configure NOT to reset the target during a debug session.
1723 ath6kl_dbg(ATH6KL_DBG_TRC,
1724 "attempting to reset target on instance destroy\n");
1725 ath6kl_reset_device(ar, ar->target_type, true, true);
1727 clear_bit(WLAN_ENABLED, &ar->flag);