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>
20 #include <linux/mmc/sdio_func.h>
27 unsigned int debug_mask;
28 static unsigned int testmode;
30 module_param(debug_mask, uint, 0644);
31 module_param(testmode, uint, 0644);
34 * Include definitions here that can be used to tune the WLAN module
35 * behavior. Different customers can tune the behavior as per their needs,
40 * This configuration item enable/disable keepalive support.
41 * Keepalive support: In the absence of any data traffic to AP, null
42 * frames will be sent to the AP at periodic interval, to keep the association
43 * active. This configuration item defines the periodic interval.
44 * Use value of zero to disable keepalive support
47 #define WLAN_CONFIG_KEEP_ALIVE_INTERVAL 60
50 * This configuration item sets the value of disconnect timeout
51 * Firmware delays sending the disconnec event to the host for this
52 * timeout after is gets disconnected from the current AP.
53 * If the firmware successly roams within the disconnect timeout
54 * it sends a new connect event
56 #define WLAN_CONFIG_DISCONNECT_TIMEOUT 10
58 #define CONFIG_AR600x_DEBUG_UART_TX_PIN 8
60 #define ATH6KL_DATA_OFFSET 64
61 struct sk_buff *ath6kl_buf_alloc(int size)
66 /* Add chacheline space at front and back of buffer */
67 reserved = (2 * L1_CACHE_BYTES) + ATH6KL_DATA_OFFSET +
68 sizeof(struct htc_packet) + ATH6KL_HTC_ALIGN_BYTES;
69 skb = dev_alloc_skb(size + reserved);
72 skb_reserve(skb, reserved - L1_CACHE_BYTES);
76 void ath6kl_init_profile_info(struct ath6kl_vif *vif)
79 memset(vif->ssid, 0, sizeof(vif->ssid));
81 vif->dot11_auth_mode = OPEN_AUTH;
82 vif->auth_mode = NONE_AUTH;
83 vif->prwise_crypto = NONE_CRYPT;
84 vif->prwise_crypto_len = 0;
85 vif->grp_crypto = NONE_CRYPT;
86 vif->grp_crypto_len = 0;
87 memset(vif->wep_key_list, 0, sizeof(vif->wep_key_list));
88 memset(vif->req_bssid, 0, sizeof(vif->req_bssid));
89 memset(vif->bssid, 0, sizeof(vif->bssid));
93 static int ath6kl_set_host_app_area(struct ath6kl *ar)
96 struct host_app_area host_app_area;
98 /* Fetch the address of the host_app_area_s
99 * instance in the host interest area */
100 address = ath6kl_get_hi_item_addr(ar, HI_ITEM(hi_app_host_interest));
101 address = TARG_VTOP(ar->target_type, address);
103 if (ath6kl_diag_read32(ar, address, &data))
106 address = TARG_VTOP(ar->target_type, data);
107 host_app_area.wmi_protocol_ver = cpu_to_le32(WMI_PROTOCOL_VERSION);
108 if (ath6kl_diag_write(ar, address, (u8 *) &host_app_area,
109 sizeof(struct host_app_area)))
115 static inline void set_ac2_ep_map(struct ath6kl *ar,
117 enum htc_endpoint_id ep)
119 ar->ac2ep_map[ac] = ep;
120 ar->ep2ac_map[ep] = ac;
123 /* connect to a service */
124 static int ath6kl_connectservice(struct ath6kl *ar,
125 struct htc_service_connect_req *con_req,
129 struct htc_service_connect_resp response;
131 memset(&response, 0, sizeof(response));
133 status = ath6kl_htc_conn_service(ar->htc_target, con_req, &response);
135 ath6kl_err("failed to connect to %s service status:%d\n",
140 switch (con_req->svc_id) {
141 case WMI_CONTROL_SVC:
142 if (test_bit(WMI_ENABLED, &ar->flag))
143 ath6kl_wmi_set_control_ep(ar->wmi, response.endpoint);
144 ar->ctrl_ep = response.endpoint;
146 case WMI_DATA_BE_SVC:
147 set_ac2_ep_map(ar, WMM_AC_BE, response.endpoint);
149 case WMI_DATA_BK_SVC:
150 set_ac2_ep_map(ar, WMM_AC_BK, response.endpoint);
152 case WMI_DATA_VI_SVC:
153 set_ac2_ep_map(ar, WMM_AC_VI, response.endpoint);
155 case WMI_DATA_VO_SVC:
156 set_ac2_ep_map(ar, WMM_AC_VO, response.endpoint);
159 ath6kl_err("service id is not mapped %d\n", con_req->svc_id);
166 static int ath6kl_init_service_ep(struct ath6kl *ar)
168 struct htc_service_connect_req connect;
170 memset(&connect, 0, sizeof(connect));
172 /* these fields are the same for all service endpoints */
173 connect.ep_cb.rx = ath6kl_rx;
174 connect.ep_cb.rx_refill = ath6kl_rx_refill;
175 connect.ep_cb.tx_full = ath6kl_tx_queue_full;
178 * Set the max queue depth so that our ath6kl_tx_queue_full handler
181 connect.max_txq_depth = MAX_DEFAULT_SEND_QUEUE_DEPTH;
182 connect.ep_cb.rx_refill_thresh = ATH6KL_MAX_RX_BUFFERS / 4;
183 if (!connect.ep_cb.rx_refill_thresh)
184 connect.ep_cb.rx_refill_thresh++;
186 /* connect to control service */
187 connect.svc_id = WMI_CONTROL_SVC;
188 if (ath6kl_connectservice(ar, &connect, "WMI CONTROL"))
191 connect.flags |= HTC_FLGS_TX_BNDL_PAD_EN;
194 * Limit the HTC message size on the send path, although e can
195 * receive A-MSDU frames of 4K, we will only send ethernet-sized
196 * (802.3) frames on the send path.
198 connect.max_rxmsg_sz = WMI_MAX_TX_DATA_FRAME_LENGTH;
201 * To reduce the amount of committed memory for larger A_MSDU
202 * frames, use the recv-alloc threshold mechanism for larger
205 connect.ep_cb.rx_alloc_thresh = ATH6KL_BUFFER_SIZE;
206 connect.ep_cb.rx_allocthresh = ath6kl_alloc_amsdu_rxbuf;
209 * For the remaining data services set the connection flag to
210 * reduce dribbling, if configured to do so.
212 connect.conn_flags |= HTC_CONN_FLGS_REDUCE_CRED_DRIB;
213 connect.conn_flags &= ~HTC_CONN_FLGS_THRESH_MASK;
214 connect.conn_flags |= HTC_CONN_FLGS_THRESH_LVL_HALF;
216 connect.svc_id = WMI_DATA_BE_SVC;
218 if (ath6kl_connectservice(ar, &connect, "WMI DATA BE"))
221 /* connect to back-ground map this to WMI LOW_PRI */
222 connect.svc_id = WMI_DATA_BK_SVC;
223 if (ath6kl_connectservice(ar, &connect, "WMI DATA BK"))
226 /* connect to Video service, map this to to HI PRI */
227 connect.svc_id = WMI_DATA_VI_SVC;
228 if (ath6kl_connectservice(ar, &connect, "WMI DATA VI"))
232 * Connect to VO service, this is currently not mapped to a WMI
233 * priority stream due to historical reasons. WMI originally
234 * defined 3 priorities over 3 mailboxes We can change this when
235 * WMI is reworked so that priorities are not dependent on
238 connect.svc_id = WMI_DATA_VO_SVC;
239 if (ath6kl_connectservice(ar, &connect, "WMI DATA VO"))
245 void ath6kl_init_control_info(struct ath6kl_vif *vif)
247 ath6kl_init_profile_info(vif);
248 vif->def_txkey_index = 0;
249 memset(vif->wep_key_list, 0, sizeof(vif->wep_key_list));
254 * Set HTC/Mbox operational parameters, this can only be called when the
255 * target is in the BMI phase.
257 static int ath6kl_set_htc_params(struct ath6kl *ar, u32 mbox_isr_yield_val,
263 blk_size = ar->mbox_info.block_size;
266 blk_size |= ((u32)htc_ctrl_buf) << 16;
268 /* set the host interest area for the block size */
269 status = ath6kl_bmi_write(ar,
270 ath6kl_get_hi_item_addr(ar,
271 HI_ITEM(hi_mbox_io_block_sz)),
275 ath6kl_err("bmi_write_memory for IO block size failed\n");
279 ath6kl_dbg(ATH6KL_DBG_TRC, "block size set: %d (target addr:0x%X)\n",
281 ath6kl_get_hi_item_addr(ar, HI_ITEM(hi_mbox_io_block_sz)));
283 if (mbox_isr_yield_val) {
284 /* set the host interest area for the mbox ISR yield limit */
285 status = ath6kl_bmi_write(ar,
286 ath6kl_get_hi_item_addr(ar,
287 HI_ITEM(hi_mbox_isr_yield_limit)),
288 (u8 *)&mbox_isr_yield_val,
291 ath6kl_err("bmi_write_memory for yield limit failed\n");
300 #define REG_DUMP_COUNT_AR6003 60
301 #define REGISTER_DUMP_LEN_MAX 60
303 static void ath6kl_dump_target_assert_info(struct ath6kl *ar)
308 u32 regdump_val[REGISTER_DUMP_LEN_MAX];
311 if (ar->target_type != TARGET_TYPE_AR6003)
314 /* the reg dump pointer is copied to the host interest area */
315 address = ath6kl_get_hi_item_addr(ar, HI_ITEM(hi_failure_state));
316 address = TARG_VTOP(ar->target_type, address);
318 /* read RAM location through diagnostic window */
319 status = ath6kl_diag_read32(ar, address, ®dump_loc);
321 if (status || !regdump_loc) {
322 ath6kl_err("failed to get ptr to register dump area\n");
326 ath6kl_dbg(ATH6KL_DBG_TRC, "location of register dump data: 0x%X\n",
328 regdump_loc = TARG_VTOP(ar->target_type, regdump_loc);
330 /* fetch register dump data */
331 status = ath6kl_diag_read(ar, regdump_loc, (u8 *)®dump_val[0],
332 REG_DUMP_COUNT_AR6003 * (sizeof(u32)));
335 ath6kl_err("failed to get register dump\n");
338 ath6kl_dbg(ATH6KL_DBG_TRC, "Register Dump:\n");
340 for (i = 0; i < REG_DUMP_COUNT_AR6003; i++)
341 ath6kl_dbg(ATH6KL_DBG_TRC, " %d : 0x%8.8X\n",
346 void ath6kl_target_failure(struct ath6kl *ar)
348 ath6kl_err("target asserted\n");
350 /* try dumping target assertion information (if any) */
351 ath6kl_dump_target_assert_info(ar);
355 static int ath6kl_target_config_wlan_params(struct ath6kl *ar)
361 * Configure the device for rx dot11 header rules. "0,0" are the
362 * default values. Required if checksum offload is needed. Set
363 * RxMetaVersion to 2.
365 if (ath6kl_wmi_set_rx_frame_format_cmd(ar->wmi,
366 ar->rx_meta_ver, 0, 0)) {
367 ath6kl_err("unable to set the rx frame format\n");
371 if (ar->conf_flags & ATH6KL_CONF_IGNORE_PS_FAIL_EVT_IN_SCAN)
372 if ((ath6kl_wmi_pmparams_cmd(ar->wmi, 0, 1, 0, 0, 1,
373 IGNORE_POWER_SAVE_FAIL_EVENT_DURING_SCAN)) != 0) {
374 ath6kl_err("unable to set power save fail event policy\n");
378 if (!(ar->conf_flags & ATH6KL_CONF_IGNORE_ERP_BARKER))
379 if ((ath6kl_wmi_set_lpreamble_cmd(ar->wmi, 0,
380 WMI_DONOT_IGNORE_BARKER_IN_ERP)) != 0) {
381 ath6kl_err("unable to set barker preamble policy\n");
385 if (ath6kl_wmi_set_keepalive_cmd(ar->wmi,
386 WLAN_CONFIG_KEEP_ALIVE_INTERVAL)) {
387 ath6kl_err("unable to set keep alive interval\n");
391 if (ath6kl_wmi_disctimeout_cmd(ar->wmi,
392 WLAN_CONFIG_DISCONNECT_TIMEOUT)) {
393 ath6kl_err("unable to set disconnect timeout\n");
397 if (!(ar->conf_flags & ATH6KL_CONF_ENABLE_TX_BURST))
398 if (ath6kl_wmi_set_wmm_txop(ar->wmi, WMI_TXOP_DISABLED)) {
399 ath6kl_err("unable to set txop bursting\n");
404 ret = ath6kl_wmi_info_req_cmd(ar->wmi,
405 P2P_FLAG_CAPABILITIES_REQ |
406 P2P_FLAG_MACADDR_REQ |
407 P2P_FLAG_HMODEL_REQ);
409 ath6kl_dbg(ATH6KL_DBG_TRC, "failed to request P2P "
410 "capabilities (%d) - assuming P2P not "
417 /* Enable Probe Request reporting for P2P */
418 ret = ath6kl_wmi_probe_report_req_cmd(ar->wmi, true);
420 ath6kl_dbg(ATH6KL_DBG_TRC, "failed to enable Probe "
421 "Request reporting (%d)\n", ret);
428 int ath6kl_configure_target(struct ath6kl *ar)
430 u32 param, ram_reserved_size;
431 u8 fw_iftype, fw_mode = 0, fw_submode = 0;
435 * Note: Even though the firmware interface type is
436 * chosen as BSS_STA for all three interfaces, can
437 * be configured to IBSS/AP as long as the fw submode
438 * remains normal mode (0 - AP, STA and IBSS). But
439 * due to an target assert in firmware only one interface is
440 * configured for now.
442 fw_iftype = HI_OPTION_FW_MODE_BSS_STA;
444 for (i = 0; i < MAX_NUM_VIF; i++)
445 fw_mode |= fw_iftype << (i * HI_OPTION_FW_MODE_BITS);
448 * By default, submodes :
449 * vif[0] - AP/STA/IBSS
450 * vif[1] - "P2P dev"/"P2P GO"/"P2P Client"
451 * vif[2] - "P2P dev"/"P2P GO"/"P2P Client"
454 for (i = 0; i < ar->max_norm_iface; i++)
455 fw_submode |= HI_OPTION_FW_SUBMODE_NONE <<
456 (i * HI_OPTION_FW_SUBMODE_BITS);
458 for (i = ar->max_norm_iface; i < MAX_NUM_VIF; i++)
459 fw_submode |= HI_OPTION_FW_SUBMODE_P2PDEV <<
460 (i * HI_OPTION_FW_SUBMODE_BITS);
463 * FIXME: This needs to be removed once the multivif
464 * support is enabled.
467 fw_submode = HI_OPTION_FW_SUBMODE_P2PDEV;
469 param = HTC_PROTOCOL_VERSION;
470 if (ath6kl_bmi_write(ar,
471 ath6kl_get_hi_item_addr(ar,
472 HI_ITEM(hi_app_host_interest)),
473 (u8 *)¶m, 4) != 0) {
474 ath6kl_err("bmi_write_memory for htc version failed\n");
478 /* set the firmware mode to STA/IBSS/AP */
481 if (ath6kl_bmi_read(ar,
482 ath6kl_get_hi_item_addr(ar,
483 HI_ITEM(hi_option_flag)),
484 (u8 *)¶m, 4) != 0) {
485 ath6kl_err("bmi_read_memory for setting fwmode failed\n");
489 param |= (MAX_NUM_VIF << HI_OPTION_NUM_DEV_SHIFT);
490 param |= fw_mode << HI_OPTION_FW_MODE_SHIFT;
491 param |= fw_submode << HI_OPTION_FW_SUBMODE_SHIFT;
493 param |= (0 << HI_OPTION_MAC_ADDR_METHOD_SHIFT);
494 param |= (0 << HI_OPTION_FW_BRIDGE_SHIFT);
496 if (ath6kl_bmi_write(ar,
497 ath6kl_get_hi_item_addr(ar,
498 HI_ITEM(hi_option_flag)),
501 ath6kl_err("bmi_write_memory for setting fwmode failed\n");
505 ath6kl_dbg(ATH6KL_DBG_TRC, "firmware mode set\n");
508 * Hardcode the address use for the extended board data
509 * Ideally this should be pre-allocate by the OS at boot time
510 * But since it is a new feature and board data is loaded
511 * at init time, we have to workaround this from host.
512 * It is difficult to patch the firmware boot code,
513 * but possible in theory.
516 param = ar->hw.board_ext_data_addr;
517 ram_reserved_size = ar->hw.reserved_ram_size;
519 if (ath6kl_bmi_write(ar, ath6kl_get_hi_item_addr(ar,
520 HI_ITEM(hi_board_ext_data)),
521 (u8 *)¶m, 4) != 0) {
522 ath6kl_err("bmi_write_memory for hi_board_ext_data failed\n");
526 if (ath6kl_bmi_write(ar, ath6kl_get_hi_item_addr(ar,
527 HI_ITEM(hi_end_ram_reserve_sz)),
528 (u8 *)&ram_reserved_size, 4) != 0) {
529 ath6kl_err("bmi_write_memory for hi_end_ram_reserve_sz failed\n");
533 /* set the block size for the target */
534 if (ath6kl_set_htc_params(ar, MBOX_YIELD_LIMIT, 0))
535 /* use default number of control buffers */
541 void ath6kl_core_free(struct ath6kl *ar)
543 wiphy_free(ar->wiphy);
546 void ath6kl_core_cleanup(struct ath6kl *ar)
548 destroy_workqueue(ar->ath6kl_wq);
551 ath6kl_htc_cleanup(ar->htc_target);
553 ath6kl_cookie_cleanup(ar);
555 ath6kl_cleanup_amsdu_rxbufs(ar);
557 ath6kl_bmi_cleanup(ar);
559 ath6kl_debug_cleanup(ar);
566 ath6kl_deinit_ieee80211_hw(ar);
569 /* firmware upload */
570 static int ath6kl_get_fw(struct ath6kl *ar, const char *filename,
571 u8 **fw, size_t *fw_len)
573 const struct firmware *fw_entry;
576 ret = request_firmware(&fw_entry, filename, ar->dev);
580 *fw_len = fw_entry->size;
581 *fw = kmemdup(fw_entry->data, fw_entry->size, GFP_KERNEL);
586 release_firmware(fw_entry);
592 static const char *get_target_ver_dir(const struct ath6kl *ar)
594 switch (ar->version.target_ver) {
595 case AR6003_REV1_VERSION:
596 return "ath6k/AR6003/hw1.0";
597 case AR6003_REV2_VERSION:
598 return "ath6k/AR6003/hw2.0";
599 case AR6003_REV3_VERSION:
600 return "ath6k/AR6003/hw2.1.1";
602 ath6kl_warn("%s: unsupported target version 0x%x.\n", __func__,
603 ar->version.target_ver);
608 * Check the device tree for a board-id and use it to construct
609 * the pathname to the firmware file. Used (for now) to find a
610 * fallback to the "bdata.bin" file--typically a symlink to the
611 * appropriate board-specific file.
613 static bool check_device_tree(struct ath6kl *ar)
615 static const char *board_id_prop = "atheros,board-id";
616 struct device_node *node;
617 char board_filename[64];
618 const char *board_id;
621 for_each_compatible_node(node, NULL, "atheros,ath6kl") {
622 board_id = of_get_property(node, board_id_prop, NULL);
623 if (board_id == NULL) {
624 ath6kl_warn("No \"%s\" property on %s node.\n",
625 board_id_prop, node->name);
628 snprintf(board_filename, sizeof(board_filename),
629 "%s/bdata.%s.bin", get_target_ver_dir(ar), board_id);
631 ret = ath6kl_get_fw(ar, board_filename, &ar->fw_board,
634 ath6kl_err("Failed to get DT board file %s: %d\n",
635 board_filename, ret);
643 static bool check_device_tree(struct ath6kl *ar)
647 #endif /* CONFIG_OF */
649 static int ath6kl_fetch_board_file(struct ath6kl *ar)
651 const char *filename;
654 if (ar->fw_board != NULL)
657 switch (ar->version.target_ver) {
658 case AR6003_REV2_VERSION:
659 filename = AR6003_REV2_BOARD_DATA_FILE;
661 case AR6004_REV1_VERSION:
662 filename = AR6004_REV1_BOARD_DATA_FILE;
665 filename = AR6003_REV3_BOARD_DATA_FILE;
669 ret = ath6kl_get_fw(ar, filename, &ar->fw_board,
672 /* managed to get proper board file */
676 if (check_device_tree(ar)) {
677 /* got board file from device tree */
681 /* there was no proper board file, try to use default instead */
682 ath6kl_warn("Failed to get board file %s (%d), trying to find default board file.\n",
685 switch (ar->version.target_ver) {
686 case AR6003_REV2_VERSION:
687 filename = AR6003_REV2_DEFAULT_BOARD_DATA_FILE;
689 case AR6004_REV1_VERSION:
690 filename = AR6004_REV1_DEFAULT_BOARD_DATA_FILE;
693 filename = AR6003_REV3_DEFAULT_BOARD_DATA_FILE;
697 ret = ath6kl_get_fw(ar, filename, &ar->fw_board,
700 ath6kl_err("Failed to get default board file %s: %d\n",
705 ath6kl_warn("WARNING! No proper board file was not found, instead using a default board file.\n");
706 ath6kl_warn("Most likely your hardware won't work as specified. Install correct board file!\n");
711 static int ath6kl_fetch_otp_file(struct ath6kl *ar)
713 const char *filename;
716 if (ar->fw_otp != NULL)
719 switch (ar->version.target_ver) {
720 case AR6003_REV2_VERSION:
721 filename = AR6003_REV2_OTP_FILE;
723 case AR6004_REV1_VERSION:
724 ath6kl_dbg(ATH6KL_DBG_TRC, "AR6004 doesn't need OTP file\n");
728 filename = AR6003_REV3_OTP_FILE;
732 ret = ath6kl_get_fw(ar, filename, &ar->fw_otp,
735 ath6kl_err("Failed to get OTP file %s: %d\n",
743 static int ath6kl_fetch_fw_file(struct ath6kl *ar)
745 const char *filename;
752 switch (ar->version.target_ver) {
753 case AR6003_REV2_VERSION:
754 filename = AR6003_REV2_TCMD_FIRMWARE_FILE;
756 case AR6003_REV3_VERSION:
757 filename = AR6003_REV3_TCMD_FIRMWARE_FILE;
759 case AR6004_REV1_VERSION:
760 ath6kl_warn("testmode not supported with ar6004\n");
763 ath6kl_warn("unknown target version: 0x%x\n",
764 ar->version.target_ver);
768 set_bit(TESTMODE, &ar->flag);
773 switch (ar->version.target_ver) {
774 case AR6003_REV2_VERSION:
775 filename = AR6003_REV2_FIRMWARE_FILE;
777 case AR6004_REV1_VERSION:
778 filename = AR6004_REV1_FIRMWARE_FILE;
781 filename = AR6003_REV3_FIRMWARE_FILE;
786 ret = ath6kl_get_fw(ar, filename, &ar->fw, &ar->fw_len);
788 ath6kl_err("Failed to get firmware file %s: %d\n",
796 static int ath6kl_fetch_patch_file(struct ath6kl *ar)
798 const char *filename;
801 switch (ar->version.target_ver) {
802 case AR6003_REV2_VERSION:
803 filename = AR6003_REV2_PATCH_FILE;
805 case AR6004_REV1_VERSION:
806 /* FIXME: implement for AR6004 */
810 filename = AR6003_REV3_PATCH_FILE;
814 if (ar->fw_patch == NULL) {
815 ret = ath6kl_get_fw(ar, filename, &ar->fw_patch,
818 ath6kl_err("Failed to get patch file %s: %d\n",
827 static int ath6kl_fetch_fw_api1(struct ath6kl *ar)
831 ret = ath6kl_fetch_otp_file(ar);
835 ret = ath6kl_fetch_fw_file(ar);
839 ret = ath6kl_fetch_patch_file(ar);
846 static int ath6kl_fetch_fw_api2(struct ath6kl *ar)
848 size_t magic_len, len, ie_len;
849 const struct firmware *fw;
850 struct ath6kl_fw_ie *hdr;
851 const char *filename;
853 int ret, ie_id, i, index, bit;
856 switch (ar->version.target_ver) {
857 case AR6003_REV2_VERSION:
858 filename = AR6003_REV2_FIRMWARE_2_FILE;
860 case AR6003_REV3_VERSION:
861 filename = AR6003_REV3_FIRMWARE_2_FILE;
863 case AR6004_REV1_VERSION:
864 filename = AR6004_REV1_FIRMWARE_2_FILE;
870 ret = request_firmware(&fw, filename, ar->dev);
877 /* magic also includes the null byte, check that as well */
878 magic_len = strlen(ATH6KL_FIRMWARE_MAGIC) + 1;
880 if (len < magic_len) {
885 if (memcmp(data, ATH6KL_FIRMWARE_MAGIC, magic_len) != 0) {
894 while (len > sizeof(struct ath6kl_fw_ie)) {
895 /* hdr is unaligned! */
896 hdr = (struct ath6kl_fw_ie *) data;
898 ie_id = le32_to_cpup(&hdr->id);
899 ie_len = le32_to_cpup(&hdr->len);
902 data += sizeof(*hdr);
910 case ATH6KL_FW_IE_OTP_IMAGE:
911 ath6kl_dbg(ATH6KL_DBG_BOOT, "found otp image ie (%zd B)\n",
914 ar->fw_otp = kmemdup(data, ie_len, GFP_KERNEL);
916 if (ar->fw_otp == NULL) {
921 ar->fw_otp_len = ie_len;
923 case ATH6KL_FW_IE_FW_IMAGE:
924 ath6kl_dbg(ATH6KL_DBG_BOOT, "found fw image ie (%zd B)\n",
927 ar->fw = kmemdup(data, ie_len, GFP_KERNEL);
929 if (ar->fw == NULL) {
936 case ATH6KL_FW_IE_PATCH_IMAGE:
937 ath6kl_dbg(ATH6KL_DBG_BOOT, "found patch image ie (%zd B)\n",
940 ar->fw_patch = kmemdup(data, ie_len, GFP_KERNEL);
942 if (ar->fw_patch == NULL) {
947 ar->fw_patch_len = ie_len;
949 case ATH6KL_FW_IE_RESERVED_RAM_SIZE:
950 val = (__le32 *) data;
951 ar->hw.reserved_ram_size = le32_to_cpup(val);
953 ath6kl_dbg(ATH6KL_DBG_BOOT,
954 "found reserved ram size ie 0x%d\n",
955 ar->hw.reserved_ram_size);
957 case ATH6KL_FW_IE_CAPABILITIES:
958 ath6kl_dbg(ATH6KL_DBG_BOOT,
959 "found firmware capabilities ie (%zd B)\n",
962 for (i = 0; i < ATH6KL_FW_CAPABILITY_MAX; i++) {
963 index = ALIGN(i, 8) / 8;
966 if (data[index] & (1 << bit))
967 __set_bit(i, ar->fw_capabilities);
970 ath6kl_dbg_dump(ATH6KL_DBG_BOOT, "capabilities", "",
972 sizeof(ar->fw_capabilities));
974 case ATH6KL_FW_IE_PATCH_ADDR:
975 if (ie_len != sizeof(*val))
978 val = (__le32 *) data;
979 ar->hw.dataset_patch_addr = le32_to_cpup(val);
981 ath6kl_dbg(ATH6KL_DBG_BOOT,
982 "found patch address ie 0x%d\n",
983 ar->hw.dataset_patch_addr);
986 ath6kl_dbg(ATH6KL_DBG_BOOT, "Unknown fw ie: %u\n",
987 le32_to_cpup(&hdr->id));
997 release_firmware(fw);
1002 static int ath6kl_fetch_firmwares(struct ath6kl *ar)
1006 ret = ath6kl_fetch_board_file(ar);
1010 ret = ath6kl_fetch_fw_api2(ar);
1012 ath6kl_dbg(ATH6KL_DBG_BOOT, "using fw api 2\n");
1016 ret = ath6kl_fetch_fw_api1(ar);
1020 ath6kl_dbg(ATH6KL_DBG_BOOT, "using fw api 1\n");
1025 static int ath6kl_upload_board_file(struct ath6kl *ar)
1027 u32 board_address, board_ext_address, param;
1028 u32 board_data_size, board_ext_data_size;
1031 if (WARN_ON(ar->fw_board == NULL))
1035 * Determine where in Target RAM to write Board Data.
1036 * For AR6004, host determine Target RAM address for
1037 * writing board data.
1039 if (ar->target_type == TARGET_TYPE_AR6004) {
1040 board_address = AR6004_REV1_BOARD_DATA_ADDRESS;
1041 ath6kl_bmi_write(ar,
1042 ath6kl_get_hi_item_addr(ar,
1043 HI_ITEM(hi_board_data)),
1044 (u8 *) &board_address, 4);
1047 ath6kl_get_hi_item_addr(ar,
1048 HI_ITEM(hi_board_data)),
1049 (u8 *) &board_address, 4);
1052 /* determine where in target ram to write extended board data */
1054 ath6kl_get_hi_item_addr(ar,
1055 HI_ITEM(hi_board_ext_data)),
1056 (u8 *) &board_ext_address, 4);
1058 if (board_ext_address == 0) {
1059 ath6kl_err("Failed to get board file target address.\n");
1063 switch (ar->target_type) {
1064 case TARGET_TYPE_AR6003:
1065 board_data_size = AR6003_BOARD_DATA_SZ;
1066 board_ext_data_size = AR6003_BOARD_EXT_DATA_SZ;
1068 case TARGET_TYPE_AR6004:
1069 board_data_size = AR6004_BOARD_DATA_SZ;
1070 board_ext_data_size = AR6004_BOARD_EXT_DATA_SZ;
1078 if (ar->fw_board_len == (board_data_size +
1079 board_ext_data_size)) {
1081 /* write extended board data */
1082 ath6kl_dbg(ATH6KL_DBG_BOOT,
1083 "writing extended board data to 0x%x (%d B)\n",
1084 board_ext_address, board_ext_data_size);
1086 ret = ath6kl_bmi_write(ar, board_ext_address,
1087 ar->fw_board + board_data_size,
1088 board_ext_data_size);
1090 ath6kl_err("Failed to write extended board data: %d\n",
1095 /* record that extended board data is initialized */
1096 param = (board_ext_data_size << 16) | 1;
1098 ath6kl_bmi_write(ar,
1099 ath6kl_get_hi_item_addr(ar,
1100 HI_ITEM(hi_board_ext_data_config)),
1101 (unsigned char *) ¶m, 4);
1104 if (ar->fw_board_len < board_data_size) {
1105 ath6kl_err("Too small board file: %zu\n", ar->fw_board_len);
1110 ath6kl_dbg(ATH6KL_DBG_BOOT, "writing board file to 0x%x (%d B)\n",
1111 board_address, board_data_size);
1113 ret = ath6kl_bmi_write(ar, board_address, ar->fw_board,
1117 ath6kl_err("Board file bmi write failed: %d\n", ret);
1121 /* record the fact that Board Data IS initialized */
1123 ath6kl_bmi_write(ar,
1124 ath6kl_get_hi_item_addr(ar,
1125 HI_ITEM(hi_board_data_initialized)),
1131 static int ath6kl_upload_otp(struct ath6kl *ar)
1134 bool from_hw = false;
1137 if (WARN_ON(ar->fw_otp == NULL))
1140 address = ar->hw.app_load_addr;
1142 ath6kl_dbg(ATH6KL_DBG_BOOT, "writing otp to 0x%x (%zd B)\n", address,
1145 ret = ath6kl_bmi_fast_download(ar, address, ar->fw_otp,
1148 ath6kl_err("Failed to upload OTP file: %d\n", ret);
1152 /* read firmware start address */
1153 ret = ath6kl_bmi_read(ar,
1154 ath6kl_get_hi_item_addr(ar,
1155 HI_ITEM(hi_app_start)),
1156 (u8 *) &address, sizeof(address));
1159 ath6kl_err("Failed to read hi_app_start: %d\n", ret);
1163 if (ar->hw.app_start_override_addr == 0) {
1164 ar->hw.app_start_override_addr = address;
1168 ath6kl_dbg(ATH6KL_DBG_BOOT, "app_start_override_addr%s 0x%x\n",
1169 from_hw ? " (from hw)" : "",
1170 ar->hw.app_start_override_addr);
1172 /* execute the OTP code */
1173 ath6kl_dbg(ATH6KL_DBG_BOOT, "executing OTP at 0x%x\n",
1174 ar->hw.app_start_override_addr);
1176 ath6kl_bmi_execute(ar, ar->hw.app_start_override_addr, ¶m);
1181 static int ath6kl_upload_firmware(struct ath6kl *ar)
1186 if (WARN_ON(ar->fw == NULL))
1189 address = ar->hw.app_load_addr;
1191 ath6kl_dbg(ATH6KL_DBG_BOOT, "writing firmware to 0x%x (%zd B)\n",
1192 address, ar->fw_len);
1194 ret = ath6kl_bmi_fast_download(ar, address, ar->fw, ar->fw_len);
1197 ath6kl_err("Failed to write firmware: %d\n", ret);
1202 * Set starting address for firmware
1203 * Don't need to setup app_start override addr on AR6004
1205 if (ar->target_type != TARGET_TYPE_AR6004) {
1206 address = ar->hw.app_start_override_addr;
1207 ath6kl_bmi_set_app_start(ar, address);
1212 static int ath6kl_upload_patch(struct ath6kl *ar)
1217 if (WARN_ON(ar->fw_patch == NULL))
1220 address = ar->hw.dataset_patch_addr;
1222 ath6kl_dbg(ATH6KL_DBG_BOOT, "writing patch to 0x%x (%zd B)\n",
1223 address, ar->fw_patch_len);
1225 ret = ath6kl_bmi_write(ar, address, ar->fw_patch, ar->fw_patch_len);
1227 ath6kl_err("Failed to write patch file: %d\n", ret);
1232 ath6kl_bmi_write(ar,
1233 ath6kl_get_hi_item_addr(ar,
1234 HI_ITEM(hi_dset_list_head)),
1235 (unsigned char *) ¶m, 4);
1240 static int ath6kl_init_upload(struct ath6kl *ar)
1242 u32 param, options, sleep, address;
1245 if (ar->target_type != TARGET_TYPE_AR6003 &&
1246 ar->target_type != TARGET_TYPE_AR6004)
1249 /* temporarily disable system sleep */
1250 address = MBOX_BASE_ADDRESS + LOCAL_SCRATCH_ADDRESS;
1251 status = ath6kl_bmi_reg_read(ar, address, ¶m);
1257 param |= ATH6KL_OPTION_SLEEP_DISABLE;
1258 status = ath6kl_bmi_reg_write(ar, address, param);
1262 address = RTC_BASE_ADDRESS + SYSTEM_SLEEP_ADDRESS;
1263 status = ath6kl_bmi_reg_read(ar, address, ¶m);
1269 param |= SM(SYSTEM_SLEEP_DISABLE, 1);
1270 status = ath6kl_bmi_reg_write(ar, address, param);
1274 ath6kl_dbg(ATH6KL_DBG_TRC, "old options: %d, old sleep: %d\n",
1277 /* program analog PLL register */
1278 /* no need to control 40/44MHz clock on AR6004 */
1279 if (ar->target_type != TARGET_TYPE_AR6004) {
1280 status = ath6kl_bmi_reg_write(ar, ATH6KL_ANALOG_PLL_REGISTER,
1286 /* Run at 80/88MHz by default */
1287 param = SM(CPU_CLOCK_STANDARD, 1);
1289 address = RTC_BASE_ADDRESS + CPU_CLOCK_ADDRESS;
1290 status = ath6kl_bmi_reg_write(ar, address, param);
1296 address = RTC_BASE_ADDRESS + LPO_CAL_ADDRESS;
1297 param = SM(LPO_CAL_ENABLE, 1);
1298 status = ath6kl_bmi_reg_write(ar, address, param);
1302 /* WAR to avoid SDIO CRC err */
1303 if (ar->version.target_ver == AR6003_REV2_VERSION) {
1304 ath6kl_err("temporary war to avoid sdio crc error\n");
1308 address = GPIO_BASE_ADDRESS + GPIO_PIN10_ADDRESS;
1309 status = ath6kl_bmi_reg_write(ar, address, param);
1313 address = GPIO_BASE_ADDRESS + GPIO_PIN11_ADDRESS;
1314 status = ath6kl_bmi_reg_write(ar, address, param);
1318 address = GPIO_BASE_ADDRESS + GPIO_PIN12_ADDRESS;
1319 status = ath6kl_bmi_reg_write(ar, address, param);
1323 address = GPIO_BASE_ADDRESS + GPIO_PIN13_ADDRESS;
1324 status = ath6kl_bmi_reg_write(ar, address, param);
1329 /* write EEPROM data to Target RAM */
1330 status = ath6kl_upload_board_file(ar);
1334 /* transfer One time Programmable data */
1335 status = ath6kl_upload_otp(ar);
1339 /* Download Target firmware */
1340 status = ath6kl_upload_firmware(ar);
1344 status = ath6kl_upload_patch(ar);
1348 /* Restore system sleep */
1349 address = RTC_BASE_ADDRESS + SYSTEM_SLEEP_ADDRESS;
1350 status = ath6kl_bmi_reg_write(ar, address, sleep);
1354 address = MBOX_BASE_ADDRESS + LOCAL_SCRATCH_ADDRESS;
1355 param = options | 0x20;
1356 status = ath6kl_bmi_reg_write(ar, address, param);
1360 /* Configure GPIO AR6003 UART */
1361 param = CONFIG_AR600x_DEBUG_UART_TX_PIN;
1362 status = ath6kl_bmi_write(ar,
1363 ath6kl_get_hi_item_addr(ar,
1364 HI_ITEM(hi_dbg_uart_txpin)),
1370 static int ath6kl_init_hw_params(struct ath6kl *ar)
1372 switch (ar->version.target_ver) {
1373 case AR6003_REV2_VERSION:
1374 ar->hw.dataset_patch_addr = AR6003_REV2_DATASET_PATCH_ADDRESS;
1375 ar->hw.app_load_addr = AR6003_REV2_APP_LOAD_ADDRESS;
1376 ar->hw.board_ext_data_addr = AR6003_REV2_BOARD_EXT_DATA_ADDRESS;
1377 ar->hw.reserved_ram_size = AR6003_REV2_RAM_RESERVE_SIZE;
1379 /* hw2.0 needs override address hardcoded */
1380 ar->hw.app_start_override_addr = 0x944C00;
1383 case AR6003_REV3_VERSION:
1384 ar->hw.dataset_patch_addr = AR6003_REV3_DATASET_PATCH_ADDRESS;
1385 ar->hw.app_load_addr = 0x1234;
1386 ar->hw.board_ext_data_addr = AR6003_REV3_BOARD_EXT_DATA_ADDRESS;
1387 ar->hw.reserved_ram_size = AR6003_REV3_RAM_RESERVE_SIZE;
1389 case AR6004_REV1_VERSION:
1390 ar->hw.dataset_patch_addr = AR6003_REV2_DATASET_PATCH_ADDRESS;
1391 ar->hw.app_load_addr = AR6003_REV3_APP_LOAD_ADDRESS;
1392 ar->hw.board_ext_data_addr = AR6004_REV1_BOARD_EXT_DATA_ADDRESS;
1393 ar->hw.reserved_ram_size = AR6004_REV1_RAM_RESERVE_SIZE;
1396 ath6kl_err("Unsupported hardware version: 0x%x\n",
1397 ar->version.target_ver);
1401 ath6kl_dbg(ATH6KL_DBG_BOOT,
1402 "target_ver 0x%x target_type 0x%x dataset_patch 0x%x app_load_addr 0x%x\n",
1403 ar->version.target_ver, ar->target_type,
1404 ar->hw.dataset_patch_addr, ar->hw.app_load_addr);
1405 ath6kl_dbg(ATH6KL_DBG_BOOT,
1406 "app_start_override_addr 0x%x board_ext_data_addr 0x%x reserved_ram_size 0x%x",
1407 ar->hw.app_start_override_addr, ar->hw.board_ext_data_addr,
1408 ar->hw.reserved_ram_size);
1413 static int ath6kl_init(struct ath6kl *ar)
1417 struct net_device *ndev;
1423 /* Do we need to finish the BMI phase */
1424 if (ath6kl_bmi_done(ar)) {
1426 goto ath6kl_init_done;
1429 /* Indicate that WMI is enabled (although not ready yet) */
1430 set_bit(WMI_ENABLED, &ar->flag);
1431 ar->wmi = ath6kl_wmi_init(ar);
1433 ath6kl_err("failed to initialize wmi\n");
1435 goto ath6kl_init_done;
1438 ath6kl_dbg(ATH6KL_DBG_TRC, "%s: got wmi @ 0x%p.\n", __func__, ar->wmi);
1440 status = ath6kl_register_ieee80211_hw(ar);
1442 goto err_node_cleanup;
1444 status = ath6kl_debug_init(ar);
1446 wiphy_unregister(ar->wiphy);
1447 goto err_node_cleanup;
1450 for (i = 0; i < MAX_NUM_VIF; i++)
1451 ar->avail_idx_map |= BIT(i);
1455 /* Add an initial station interface */
1456 ndev = ath6kl_interface_add(ar, "wlan%d", NL80211_IFTYPE_STATION, 0,
1462 ath6kl_err("Failed to instantiate a network device\n");
1464 wiphy_unregister(ar->wiphy);
1465 goto err_debug_init;
1469 ath6kl_dbg(ATH6KL_DBG_TRC, "%s: name=%s dev=0x%p, ar=0x%p\n",
1470 __func__, ndev->name, ndev, ar);
1473 * The reason we have to wait for the target here is that the
1474 * driver layer has to init BMI in order to set the host block
1477 if (ath6kl_htc_wait_target(ar->htc_target)) {
1482 if (ath6kl_init_service_ep(ar)) {
1484 goto err_cleanup_scatter;
1487 /* setup access class priority mappings */
1488 ar->ac_stream_pri_map[WMM_AC_BK] = 0; /* lowest */
1489 ar->ac_stream_pri_map[WMM_AC_BE] = 1;
1490 ar->ac_stream_pri_map[WMM_AC_VI] = 2;
1491 ar->ac_stream_pri_map[WMM_AC_VO] = 3; /* highest */
1493 /* give our connected endpoints some buffers */
1494 ath6kl_rx_refill(ar->htc_target, ar->ctrl_ep);
1495 ath6kl_rx_refill(ar->htc_target, ar->ac2ep_map[WMM_AC_BE]);
1497 /* allocate some buffers that handle larger AMSDU frames */
1498 ath6kl_refill_amsdu_rxbufs(ar, ATH6KL_MAX_AMSDU_RX_BUFFERS);
1500 /* setup credit distribution */
1501 ath6k_setup_credit_dist(ar->htc_target, &ar->credit_state_info);
1503 ath6kl_cookie_init(ar);
1506 status = ath6kl_htc_start(ar->htc_target);
1509 ath6kl_cookie_cleanup(ar);
1510 goto err_rxbuf_cleanup;
1513 /* Wait for Wmi event to be ready */
1514 timeleft = wait_event_interruptible_timeout(ar->event_wq,
1519 ath6kl_dbg(ATH6KL_DBG_BOOT, "firmware booted\n");
1521 if (ar->version.abi_ver != ATH6KL_ABI_VERSION) {
1522 ath6kl_err("abi version mismatch: host(0x%x), target(0x%x)\n",
1523 ATH6KL_ABI_VERSION, ar->version.abi_ver);
1528 if (!timeleft || signal_pending(current)) {
1529 ath6kl_err("wmi is not ready or wait was interrupted\n");
1534 ath6kl_dbg(ATH6KL_DBG_TRC, "%s: wmi is ready\n", __func__);
1536 /* communicate the wmi protocol verision to the target */
1537 if ((ath6kl_set_host_app_area(ar)) != 0)
1538 ath6kl_err("unable to set the host app area\n");
1540 ar->conf_flags = ATH6KL_CONF_IGNORE_ERP_BARKER |
1541 ATH6KL_CONF_ENABLE_11N | ATH6KL_CONF_ENABLE_TX_BURST;
1543 ar->wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM |
1544 WIPHY_FLAG_HAVE_AP_SME;
1546 status = ath6kl_target_config_wlan_params(ar);
1551 * Set mac address which is received in ready event
1552 * FIXME: Move to ath6kl_interface_add()
1554 memcpy(ndev->dev_addr, ar->mac_addr, ETH_ALEN);
1559 ath6kl_htc_stop(ar->htc_target);
1561 ath6kl_htc_flush_rx_buf(ar->htc_target);
1562 ath6kl_cleanup_amsdu_rxbufs(ar);
1563 err_cleanup_scatter:
1564 ath6kl_hif_cleanup_scatter(ar);
1567 ath6kl_deinit_if_data(netdev_priv(ndev));
1569 wiphy_unregister(ar->wiphy);
1571 ath6kl_debug_cleanup(ar);
1573 ath6kl_wmi_shutdown(ar->wmi);
1574 clear_bit(WMI_ENABLED, &ar->flag);
1581 int ath6kl_core_init(struct ath6kl *ar)
1584 struct ath6kl_bmi_target_info targ_info;
1586 ar->ath6kl_wq = create_singlethread_workqueue("ath6kl");
1590 ret = ath6kl_bmi_init(ar);
1594 ret = ath6kl_bmi_get_target_info(ar, &targ_info);
1596 goto err_bmi_cleanup;
1598 ar->version.target_ver = le32_to_cpu(targ_info.version);
1599 ar->target_type = le32_to_cpu(targ_info.type);
1600 ar->wiphy->hw_version = le32_to_cpu(targ_info.version);
1602 ret = ath6kl_init_hw_params(ar);
1604 goto err_bmi_cleanup;
1606 ret = ath6kl_configure_target(ar);
1608 goto err_bmi_cleanup;
1610 ar->htc_target = ath6kl_htc_create(ar);
1612 if (!ar->htc_target) {
1614 goto err_bmi_cleanup;
1617 ret = ath6kl_fetch_firmwares(ar);
1619 goto err_htc_cleanup;
1621 ret = ath6kl_init_upload(ar);
1623 goto err_htc_cleanup;
1625 ret = ath6kl_init(ar);
1627 goto err_htc_cleanup;
1632 ath6kl_htc_cleanup(ar->htc_target);
1634 ath6kl_bmi_cleanup(ar);
1636 destroy_workqueue(ar->ath6kl_wq);
1641 void ath6kl_cleanup_vif(struct ath6kl_vif *vif, bool wmi_ready)
1643 static u8 bcast_mac[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
1646 netif_stop_queue(vif->ndev);
1648 clear_bit(WLAN_ENABLED, &vif->flags);
1651 discon_issued = test_bit(CONNECTED, &vif->flags) ||
1652 test_bit(CONNECT_PEND, &vif->flags);
1653 ath6kl_disconnect(vif);
1654 del_timer(&vif->disconnect_timer);
1657 ath6kl_disconnect_event(vif, DISCONNECT_CMD,
1658 (vif->nw_type & AP_NETWORK) ?
1659 bcast_mac : vif->bssid,
1663 if (vif->scan_req) {
1664 cfg80211_scan_done(vif->scan_req, true);
1665 vif->scan_req = NULL;
1669 void ath6kl_stop_txrx(struct ath6kl *ar)
1671 struct ath6kl_vif *vif, *tmp_vif;
1673 set_bit(DESTROY_IN_PROGRESS, &ar->flag);
1675 if (down_interruptible(&ar->sem)) {
1676 ath6kl_err("down_interruptible failed\n");
1680 spin_lock(&ar->list_lock);
1681 list_for_each_entry_safe(vif, tmp_vif, &ar->vif_list, list) {
1682 list_del(&vif->list);
1683 spin_unlock(&ar->list_lock);
1684 ath6kl_cleanup_vif(vif, test_bit(WMI_READY, &ar->flag));
1686 ath6kl_deinit_if_data(vif);
1688 spin_lock(&ar->list_lock);
1690 spin_unlock(&ar->list_lock);
1692 clear_bit(WMI_READY, &ar->flag);
1695 * After wmi_shudown all WMI events will be dropped. We
1696 * need to cleanup the buffers allocated in AP mode and
1697 * give disconnect notification to stack, which usually
1698 * happens in the disconnect_event. Simulate the disconnect
1699 * event by calling the function directly. Sometimes
1700 * disconnect_event will be received when the debug logs
1703 ath6kl_wmi_shutdown(ar->wmi);
1705 clear_bit(WMI_ENABLED, &ar->flag);
1706 if (ar->htc_target) {
1707 ath6kl_dbg(ATH6KL_DBG_TRC, "%s: shut down htc\n", __func__);
1708 ath6kl_htc_stop(ar->htc_target);
1712 * Try to reset the device if we can. The driver may have been
1713 * configure NOT to reset the target during a debug session.
1715 ath6kl_dbg(ATH6KL_DBG_TRC,
1716 "attempting to reset target on instance destroy\n");
1717 ath6kl_reset_device(ar, ar->target_type, true, true);
1719 clear_bit(WLAN_ENABLED, &ar->flag);