1 // SPDX-License-Identifier: GPL-2.0-only
3 * Bluetooth supports for Qualcomm Atheros chips
5 * Copyright (c) 2015 The Linux Foundation. All rights reserved.
7 #include <linux/module.h>
8 #include <linux/firmware.h>
9 #include <linux/vmalloc.h>
11 #include <net/bluetooth/bluetooth.h>
12 #include <net/bluetooth/hci_core.h>
16 int qca_read_soc_version(struct hci_dev
*hdev
, struct qca_btsoc_version
*ver
,
17 enum qca_btsoc_type soc_type
)
20 struct edl_event_hdr
*edl
;
23 u8 event_type
= HCI_EV_VENDOR
;
24 u8 rlen
= sizeof(*edl
) + sizeof(*ver
);
25 u8 rtype
= EDL_APP_VER_RES_EVT
;
27 bt_dev_dbg(hdev
, "QCA Version Request");
29 /* Unlike other SoC's sending version command response as payload to
30 * VSE event. WCN3991 sends version command response as a payload to
31 * command complete event.
33 if (soc_type
>= QCA_WCN3991
) {
36 rtype
= EDL_PATCH_VER_REQ_CMD
;
39 cmd
= EDL_PATCH_VER_REQ_CMD
;
40 skb
= __hci_cmd_sync_ev(hdev
, EDL_PATCH_CMD_OPCODE
, EDL_PATCH_CMD_LEN
,
41 &cmd
, event_type
, HCI_INIT_TIMEOUT
);
44 bt_dev_err(hdev
, "Reading QCA version information failed (%d)",
49 if (skb
->len
!= rlen
) {
50 bt_dev_err(hdev
, "QCA Version size mismatch len %d", skb
->len
);
55 edl
= (struct edl_event_hdr
*)(skb
->data
);
57 if (edl
->cresp
!= EDL_CMD_REQ_RES_EVT
||
58 edl
->rtype
!= rtype
) {
59 bt_dev_err(hdev
, "QCA Wrong packet received %d %d", edl
->cresp
,
65 if (soc_type
>= QCA_WCN3991
)
66 memcpy(ver
, edl
->data
+ 1, sizeof(*ver
));
68 memcpy(ver
, &edl
->data
, sizeof(*ver
));
70 bt_dev_info(hdev
, "QCA Product ID :0x%08x",
71 le32_to_cpu(ver
->product_id
));
72 bt_dev_info(hdev
, "QCA SOC Version :0x%08x",
73 le32_to_cpu(ver
->soc_id
));
74 bt_dev_info(hdev
, "QCA ROM Version :0x%08x",
75 le16_to_cpu(ver
->rom_ver
));
76 bt_dev_info(hdev
, "QCA Patch Version:0x%08x",
77 le16_to_cpu(ver
->patch_ver
));
79 if (ver
->soc_id
== 0 || ver
->rom_ver
== 0)
85 bt_dev_err(hdev
, "QCA Failed to get version (%d)", err
);
89 EXPORT_SYMBOL_GPL(qca_read_soc_version
);
91 static int qca_read_fw_build_info(struct hci_dev
*hdev
)
94 struct edl_event_hdr
*edl
;
97 int build_lbl_len
, err
= 0;
99 bt_dev_dbg(hdev
, "QCA read fw build info");
101 cmd
= EDL_GET_BUILD_INFO_CMD
;
102 skb
= __hci_cmd_sync_ev(hdev
, EDL_PATCH_CMD_OPCODE
, EDL_PATCH_CMD_LEN
,
103 &cmd
, 0, HCI_INIT_TIMEOUT
);
106 bt_dev_err(hdev
, "Reading QCA fw build info failed (%d)",
111 if (skb
->len
< sizeof(*edl
)) {
116 edl
= (struct edl_event_hdr
*)(skb
->data
);
118 if (edl
->cresp
!= EDL_CMD_REQ_RES_EVT
||
119 edl
->rtype
!= EDL_GET_BUILD_INFO_CMD
) {
120 bt_dev_err(hdev
, "QCA Wrong packet received %d %d", edl
->cresp
,
126 if (skb
->len
< sizeof(*edl
) + 1) {
131 build_lbl_len
= edl
->data
[0];
133 if (skb
->len
< sizeof(*edl
) + 1 + build_lbl_len
) {
138 build_label
= kstrndup(&edl
->data
[1], build_lbl_len
, GFP_KERNEL
);
144 hci_set_fw_info(hdev
, "%s", build_label
);
152 static int qca_send_patch_config_cmd(struct hci_dev
*hdev
)
154 const u8 cmd
[] = { EDL_PATCH_CONFIG_CMD
, 0x01, 0, 0, 0 };
156 struct edl_event_hdr
*edl
;
159 bt_dev_dbg(hdev
, "QCA Patch config");
161 skb
= __hci_cmd_sync_ev(hdev
, EDL_PATCH_CMD_OPCODE
, sizeof(cmd
),
162 cmd
, 0, HCI_INIT_TIMEOUT
);
165 bt_dev_err(hdev
, "Sending QCA Patch config failed (%d)", err
);
170 bt_dev_err(hdev
, "QCA Patch config cmd size mismatch len %d", skb
->len
);
175 edl
= (struct edl_event_hdr
*)(skb
->data
);
177 if (edl
->cresp
!= EDL_PATCH_CONFIG_RES_EVT
|| edl
->rtype
!= EDL_PATCH_CONFIG_CMD
) {
178 bt_dev_err(hdev
, "QCA Wrong packet received %d %d", edl
->cresp
,
191 static int qca_send_reset(struct hci_dev
*hdev
)
196 bt_dev_dbg(hdev
, "QCA HCI_RESET");
198 skb
= __hci_cmd_sync(hdev
, HCI_OP_RESET
, 0, NULL
, HCI_INIT_TIMEOUT
);
201 bt_dev_err(hdev
, "QCA Reset failed (%d)", err
);
210 static int qca_read_fw_board_id(struct hci_dev
*hdev
, u16
*bid
)
214 struct edl_event_hdr
*edl
;
217 cmd
= EDL_GET_BID_REQ_CMD
;
218 skb
= __hci_cmd_sync_ev(hdev
, EDL_PATCH_CMD_OPCODE
, EDL_PATCH_CMD_LEN
,
219 &cmd
, 0, HCI_INIT_TIMEOUT
);
222 bt_dev_err(hdev
, "Reading QCA board ID failed (%d)", err
);
226 edl
= skb_pull_data(skb
, sizeof(*edl
));
228 bt_dev_err(hdev
, "QCA read board ID with no header");
233 if (edl
->cresp
!= EDL_CMD_REQ_RES_EVT
||
234 edl
->rtype
!= EDL_GET_BID_REQ_CMD
) {
235 bt_dev_err(hdev
, "QCA Wrong packet: %d %d", edl
->cresp
, edl
->rtype
);
245 *bid
= (edl
->data
[1] << 8) + edl
->data
[2];
246 bt_dev_dbg(hdev
, "%s: bid = %x", __func__
, *bid
);
253 int qca_send_pre_shutdown_cmd(struct hci_dev
*hdev
)
258 bt_dev_dbg(hdev
, "QCA pre shutdown cmd");
260 skb
= __hci_cmd_sync_ev(hdev
, QCA_PRE_SHUTDOWN_CMD
, 0,
261 NULL
, HCI_EV_CMD_COMPLETE
, HCI_INIT_TIMEOUT
);
265 bt_dev_err(hdev
, "QCA preshutdown_cmd failed (%d)", err
);
273 EXPORT_SYMBOL_GPL(qca_send_pre_shutdown_cmd
);
275 static int qca_tlv_check_data(struct hci_dev
*hdev
,
276 struct qca_fw_config
*config
,
277 u8
*fw_data
, size_t fw_size
,
278 enum qca_btsoc_type soc_type
)
284 struct tlv_type_hdr
*tlv
;
285 struct tlv_type_patch
*tlv_patch
;
286 struct tlv_type_nvm
*tlv_nvm
;
287 uint8_t nvm_baud_rate
= config
->user_baud_rate
;
290 config
->dnld_mode
= QCA_SKIP_EVT_NONE
;
291 config
->dnld_type
= QCA_SKIP_EVT_NONE
;
293 switch (config
->type
) {
298 config
->dnld_mode
= QCA_SKIP_EVT_VSE_CC
;
299 config
->dnld_type
= QCA_SKIP_EVT_VSE_CC
;
301 bt_dev_dbg(hdev
, "File Class : 0x%x", fw_data
[4]);
302 bt_dev_dbg(hdev
, "Data Encoding : 0x%x", fw_data
[5]);
303 bt_dev_dbg(hdev
, "File version : 0x%x", fw_data
[6]);
306 if (fw_size
< sizeof(struct tlv_type_hdr
) + sizeof(struct tlv_type_patch
))
309 tlv
= (struct tlv_type_hdr
*)fw_data
;
310 type_len
= le32_to_cpu(tlv
->type_len
);
311 tlv_patch
= (struct tlv_type_patch
*)tlv
->data
;
313 /* For Rome version 1.1 to 3.1, all segment commands
314 * are acked by a vendor specific event (VSE).
315 * For Rome >= 3.2, the download mode field indicates
316 * if VSE is skipped by the controller.
317 * In case VSE is skipped, only the last segment is acked.
319 config
->dnld_mode
= tlv_patch
->download_mode
;
320 config
->dnld_type
= config
->dnld_mode
;
322 BT_DBG("TLV Type\t\t : 0x%x", type_len
& 0x000000ff);
323 BT_DBG("Total Length : %d bytes",
324 le32_to_cpu(tlv_patch
->total_size
));
325 BT_DBG("Patch Data Length : %d bytes",
326 le32_to_cpu(tlv_patch
->data_length
));
327 BT_DBG("Signing Format Version : 0x%x",
328 tlv_patch
->format_version
);
329 BT_DBG("Signature Algorithm : 0x%x",
330 tlv_patch
->signature
);
331 BT_DBG("Download mode : 0x%x",
332 tlv_patch
->download_mode
);
333 BT_DBG("Reserved : 0x%x",
334 tlv_patch
->reserved1
);
335 BT_DBG("Product ID : 0x%04x",
336 le16_to_cpu(tlv_patch
->product_id
));
337 BT_DBG("Rom Build Version : 0x%04x",
338 le16_to_cpu(tlv_patch
->rom_build
));
339 BT_DBG("Patch Version : 0x%04x",
340 le16_to_cpu(tlv_patch
->patch_version
));
341 BT_DBG("Reserved : 0x%x",
342 le16_to_cpu(tlv_patch
->reserved2
));
343 BT_DBG("Patch Entry Address : 0x%x",
344 le32_to_cpu(tlv_patch
->entry
));
348 if (fw_size
< sizeof(struct tlv_type_hdr
))
351 tlv
= (struct tlv_type_hdr
*)fw_data
;
353 type_len
= le32_to_cpu(tlv
->type_len
);
354 length
= type_len
>> 8;
355 type
= type_len
& 0xff;
357 /* Some NVM files have more than one set of tags, only parse
358 * the first set when it has type 2 for now. When there is
359 * more than one set there is an enclosing header of type 4.
362 if (fw_size
< 2 * sizeof(struct tlv_type_hdr
))
367 type_len
= le32_to_cpu(tlv
->type_len
);
368 length
= type_len
>> 8;
369 type
= type_len
& 0xff;
372 BT_DBG("TLV Type\t\t : 0x%x", type
);
373 BT_DBG("Length\t\t : %d bytes", length
);
378 if (fw_size
< length
+ (tlv
->data
- fw_data
))
383 while (idx
< length
- sizeof(struct tlv_type_nvm
)) {
384 tlv_nvm
= (struct tlv_type_nvm
*)(data
+ idx
);
386 tag_id
= le16_to_cpu(tlv_nvm
->tag_id
);
387 tag_len
= le16_to_cpu(tlv_nvm
->tag_len
);
389 if (length
< idx
+ sizeof(struct tlv_type_nvm
) + tag_len
)
392 /* Update NVM tags as needed */
394 case EDL_TAG_ID_BD_ADDR
:
395 if (tag_len
!= sizeof(bdaddr_t
))
398 memcpy(&config
->bdaddr
, tlv_nvm
->data
, sizeof(bdaddr_t
));
406 /* HCI transport layer parameters
407 * enabling software inband sleep
408 * onto controller side.
410 tlv_nvm
->data
[0] |= 0x80;
413 if (soc_type
>= QCA_WCN3991
)
414 tlv_nvm
->data
[1] = nvm_baud_rate
;
416 tlv_nvm
->data
[2] = nvm_baud_rate
;
420 case EDL_TAG_ID_DEEP_SLEEP
:
425 * enabling deep sleep feature on controller.
427 tlv_nvm
->data
[0] |= 0x01;
432 idx
+= sizeof(struct tlv_type_nvm
) + tag_len
;
437 BT_ERR("Unknown TLV type %d", config
->type
);
444 static int qca_tlv_send_segment(struct hci_dev
*hdev
, int seg_size
,
445 const u8
*data
, enum qca_tlv_dnld_mode mode
,
446 enum qca_btsoc_type soc_type
)
449 struct edl_event_hdr
*edl
;
450 struct tlv_seg_resp
*tlv_resp
;
451 u8 cmd
[MAX_SIZE_PER_TLV_SEGMENT
+ 2];
453 u8 event_type
= HCI_EV_VENDOR
;
454 u8 rlen
= (sizeof(*edl
) + sizeof(*tlv_resp
));
455 u8 rtype
= EDL_TVL_DNLD_RES_EVT
;
457 cmd
[0] = EDL_PATCH_TLV_REQ_CMD
;
459 memcpy(cmd
+ 2, data
, seg_size
);
461 if (mode
== QCA_SKIP_EVT_VSE_CC
|| mode
== QCA_SKIP_EVT_VSE
)
462 return __hci_cmd_send(hdev
, EDL_PATCH_CMD_OPCODE
, seg_size
+ 2,
465 /* Unlike other SoC's sending version command response as payload to
466 * VSE event. WCN3991 sends version command response as a payload to
467 * command complete event.
469 if (soc_type
>= QCA_WCN3991
) {
472 rtype
= EDL_PATCH_TLV_REQ_CMD
;
475 skb
= __hci_cmd_sync_ev(hdev
, EDL_PATCH_CMD_OPCODE
, seg_size
+ 2, cmd
,
476 event_type
, HCI_INIT_TIMEOUT
);
479 bt_dev_err(hdev
, "QCA Failed to send TLV segment (%d)", err
);
483 if (skb
->len
!= rlen
) {
484 bt_dev_err(hdev
, "QCA TLV response size mismatch");
489 edl
= (struct edl_event_hdr
*)(skb
->data
);
491 if (edl
->cresp
!= EDL_CMD_REQ_RES_EVT
|| edl
->rtype
!= rtype
) {
492 bt_dev_err(hdev
, "QCA TLV with error stat 0x%x rtype 0x%x",
493 edl
->cresp
, edl
->rtype
);
497 if (soc_type
>= QCA_WCN3991
)
500 tlv_resp
= (struct tlv_seg_resp
*)(edl
->data
);
501 if (tlv_resp
->result
) {
502 bt_dev_err(hdev
, "QCA TLV with error stat 0x%x rtype 0x%x (0x%x)",
503 edl
->cresp
, edl
->rtype
, tlv_resp
->result
);
512 static int qca_inject_cmd_complete_event(struct hci_dev
*hdev
)
514 struct hci_event_hdr
*hdr
;
515 struct hci_ev_cmd_complete
*evt
;
518 skb
= bt_skb_alloc(sizeof(*hdr
) + sizeof(*evt
) + 1, GFP_KERNEL
);
522 hdr
= skb_put(skb
, sizeof(*hdr
));
523 hdr
->evt
= HCI_EV_CMD_COMPLETE
;
524 hdr
->plen
= sizeof(*evt
) + 1;
526 evt
= skb_put(skb
, sizeof(*evt
));
528 evt
->opcode
= cpu_to_le16(QCA_HCI_CC_OPCODE
);
530 skb_put_u8(skb
, QCA_HCI_CC_SUCCESS
);
532 hci_skb_pkt_type(skb
) = HCI_EVENT_PKT
;
534 return hci_recv_frame(hdev
, skb
);
537 static int qca_download_firmware(struct hci_dev
*hdev
,
538 struct qca_fw_config
*config
,
539 enum qca_btsoc_type soc_type
,
542 const struct firmware
*fw
;
545 int ret
, size
, remain
, i
= 0;
547 bt_dev_info(hdev
, "QCA Downloading %s", config
->fwname
);
549 ret
= request_firmware(&fw
, config
->fwname
, &hdev
->dev
);
551 /* For WCN6750, if mbn file is not present then check for
554 if (soc_type
== QCA_WCN6750
&& config
->type
== ELF_TYPE_PATCH
) {
555 bt_dev_dbg(hdev
, "QCA Failed to request file: %s (%d)",
556 config
->fwname
, ret
);
557 config
->type
= TLV_TYPE_PATCH
;
558 snprintf(config
->fwname
, sizeof(config
->fwname
),
559 "qca/msbtfw%02x.tlv", rom_ver
);
560 bt_dev_info(hdev
, "QCA Downloading %s", config
->fwname
);
561 ret
= request_firmware(&fw
, config
->fwname
, &hdev
->dev
);
563 bt_dev_err(hdev
, "QCA Failed to request file: %s (%d)",
564 config
->fwname
, ret
);
568 bt_dev_err(hdev
, "QCA Failed to request file: %s (%d)",
569 config
->fwname
, ret
);
575 data
= vmalloc(fw
->size
);
577 bt_dev_err(hdev
, "QCA Failed to allocate memory for file: %s",
579 release_firmware(fw
);
583 memcpy(data
, fw
->data
, size
);
584 release_firmware(fw
);
586 ret
= qca_tlv_check_data(hdev
, config
, data
, size
, soc_type
);
593 int segsize
= min(MAX_SIZE_PER_TLV_SEGMENT
, remain
);
595 bt_dev_dbg(hdev
, "Send segment %d, size %d", i
++, segsize
);
598 /* The last segment is always acked regardless download mode */
599 if (!remain
|| segsize
< MAX_SIZE_PER_TLV_SEGMENT
)
600 config
->dnld_mode
= QCA_SKIP_EVT_NONE
;
602 ret
= qca_tlv_send_segment(hdev
, segsize
, segment
,
603 config
->dnld_mode
, soc_type
);
610 /* Latest qualcomm chipsets are not sending a command complete event
611 * for every fw packet sent. They only respond with a vendor specific
612 * event for the last packet. This optimization in the chip will
613 * decrease the BT in initialization time. Here we will inject a command
614 * complete event to avoid a command timeout error message.
616 if (config
->dnld_type
== QCA_SKIP_EVT_VSE_CC
||
617 config
->dnld_type
== QCA_SKIP_EVT_VSE
)
618 ret
= qca_inject_cmd_complete_event(hdev
);
626 static int qca_disable_soc_logging(struct hci_dev
*hdev
)
632 cmd
[0] = QCA_DISABLE_LOGGING_SUB_OP
;
634 skb
= __hci_cmd_sync_ev(hdev
, QCA_DISABLE_LOGGING
, sizeof(cmd
), cmd
,
635 HCI_EV_CMD_COMPLETE
, HCI_INIT_TIMEOUT
);
638 bt_dev_err(hdev
, "QCA Failed to disable soc logging(%d)", err
);
647 int qca_set_bdaddr_rome(struct hci_dev
*hdev
, const bdaddr_t
*bdaddr
)
653 cmd
[0] = EDL_NVM_ACCESS_SET_REQ_CMD
;
654 cmd
[1] = 0x02; /* TAG ID */
655 cmd
[2] = sizeof(bdaddr_t
); /* size */
656 memcpy(cmd
+ 3, bdaddr
, sizeof(bdaddr_t
));
657 skb
= __hci_cmd_sync_ev(hdev
, EDL_NVM_ACCESS_OPCODE
, sizeof(cmd
), cmd
,
658 HCI_EV_VENDOR
, HCI_INIT_TIMEOUT
);
661 bt_dev_err(hdev
, "QCA Change address command failed (%d)", err
);
669 EXPORT_SYMBOL_GPL(qca_set_bdaddr_rome
);
671 static int qca_check_bdaddr(struct hci_dev
*hdev
, const struct qca_fw_config
*config
)
673 struct hci_rp_read_bd_addr
*bda
;
677 if (bacmp(&hdev
->public_addr
, BDADDR_ANY
))
680 skb
= __hci_cmd_sync(hdev
, HCI_OP_READ_BD_ADDR
, 0, NULL
,
684 bt_dev_err(hdev
, "Failed to read device address (%d)", err
);
688 if (skb
->len
!= sizeof(*bda
)) {
689 bt_dev_err(hdev
, "Device address length mismatch");
694 bda
= (struct hci_rp_read_bd_addr
*)skb
->data
;
695 if (!bacmp(&bda
->bdaddr
, &config
->bdaddr
))
696 set_bit(HCI_QUIRK_USE_BDADDR_PROPERTY
, &hdev
->quirks
);
703 static void qca_generate_hsp_nvm_name(char *fwname
, size_t max_size
,
704 struct qca_btsoc_version ver
, u8 rom_ver
, u16 bid
)
709 if ((le32_to_cpu(ver
.soc_id
) & QCA_HSP_GF_SOC_MASK
) == QCA_HSP_GF_SOC_ID
)
715 snprintf(fwname
, max_size
, "qca/hpnv%02x%s.bin", rom_ver
, variant
);
717 snprintf(fwname
, max_size
, "qca/hpnv%02x%s.%x", rom_ver
, variant
, bid
);
720 static inline void qca_get_nvm_name_generic(struct qca_fw_config
*cfg
,
721 const char *stem
, u8 rom_ver
, u16 bid
)
724 snprintf(cfg
->fwname
, sizeof(cfg
->fwname
), "qca/%snv%02x.bin", stem
, rom_ver
);
725 else if (bid
& 0xff00)
726 snprintf(cfg
->fwname
, sizeof(cfg
->fwname
),
727 "qca/%snv%02x.b%x", stem
, rom_ver
, bid
);
729 snprintf(cfg
->fwname
, sizeof(cfg
->fwname
),
730 "qca/%snv%02x.b%02x", stem
, rom_ver
, bid
);
733 int qca_uart_setup(struct hci_dev
*hdev
, uint8_t baudrate
,
734 enum qca_btsoc_type soc_type
, struct qca_btsoc_version ver
,
735 const char *firmware_name
)
737 struct qca_fw_config config
= {};
743 bt_dev_dbg(hdev
, "QCA setup on UART");
745 soc_ver
= get_soc_ver(ver
.soc_id
, ver
.rom_ver
);
747 bt_dev_info(hdev
, "QCA controller version 0x%08x", soc_ver
);
749 config
.user_baud_rate
= baudrate
;
751 /* Firmware files to download are based on ROM version.
752 * ROM version is derived from last two bytes of soc_ver.
754 if (soc_type
== QCA_WCN3988
)
755 rom_ver
= ((soc_ver
& 0x00000f00) >> 0x05) | (soc_ver
& 0x0000000f);
757 rom_ver
= ((soc_ver
& 0x00000f00) >> 0x04) | (soc_ver
& 0x0000000f);
759 if (soc_type
== QCA_WCN6750
)
760 qca_send_patch_config_cmd(hdev
);
762 /* Download rampatch file */
763 config
.type
= TLV_TYPE_PATCH
;
768 snprintf(config
.fwname
, sizeof(config
.fwname
),
769 "qca/crbtfw%02x.tlv", rom_ver
);
772 snprintf(config
.fwname
, sizeof(config
.fwname
),
773 "qca/apbtfw%02x.tlv", rom_ver
);
776 snprintf(config
.fwname
, sizeof(config
.fwname
),
777 "qca/hpbtfw%02x.tlv", rom_ver
);
780 snprintf(config
.fwname
, sizeof(config
.fwname
),
781 "qca/htbtfw%02x.tlv", rom_ver
);
784 /* Choose mbn file by default.If mbn file is not found
785 * then choose tlv file
787 config
.type
= ELF_TYPE_PATCH
;
788 snprintf(config
.fwname
, sizeof(config
.fwname
),
789 "qca/msbtfw%02x.mbn", rom_ver
);
792 snprintf(config
.fwname
, sizeof(config
.fwname
),
793 "qca/hpbtfw%02x.tlv", rom_ver
);
796 snprintf(config
.fwname
, sizeof(config
.fwname
),
797 "qca/hmtbtfw%02x.tlv", rom_ver
);
800 snprintf(config
.fwname
, sizeof(config
.fwname
),
801 "qca/rampatch_%08x.bin", soc_ver
);
804 err
= qca_download_firmware(hdev
, &config
, soc_type
, rom_ver
);
806 bt_dev_err(hdev
, "QCA Failed to download patch (%d)", err
);
810 /* Give the controller some time to get ready to receive the NVM */
813 if (soc_type
== QCA_QCA2066
|| soc_type
== QCA_WCN7850
)
814 qca_read_fw_board_id(hdev
, &boardid
);
816 /* Download NVM configuration */
817 config
.type
= TLV_TYPE_NVM
;
819 snprintf(config
.fwname
, sizeof(config
.fwname
),
820 "qca/%s", firmware_name
);
826 if (le32_to_cpu(ver
.soc_id
) == QCA_WCN3991_SOC_ID
) {
827 snprintf(config
.fwname
, sizeof(config
.fwname
),
828 "qca/crnv%02xu.bin", rom_ver
);
830 snprintf(config
.fwname
, sizeof(config
.fwname
),
831 "qca/crnv%02x.bin", rom_ver
);
835 snprintf(config
.fwname
, sizeof(config
.fwname
),
836 "qca/apnv%02x.bin", rom_ver
);
839 qca_generate_hsp_nvm_name(config
.fwname
,
840 sizeof(config
.fwname
), ver
, rom_ver
, boardid
);
843 snprintf(config
.fwname
, sizeof(config
.fwname
),
844 "qca/htnv%02x.bin", rom_ver
);
847 snprintf(config
.fwname
, sizeof(config
.fwname
),
848 "qca/msnv%02x.bin", rom_ver
);
851 snprintf(config
.fwname
, sizeof(config
.fwname
),
852 "qca/hpnv%02x.bin", rom_ver
);
855 qca_get_nvm_name_generic(&config
, "hmt", rom_ver
, boardid
);
859 snprintf(config
.fwname
, sizeof(config
.fwname
),
860 "qca/nvm_%08x.bin", soc_ver
);
864 err
= qca_download_firmware(hdev
, &config
, soc_type
, rom_ver
);
866 bt_dev_err(hdev
, "QCA Failed to download NVM (%d)", err
);
877 err
= qca_disable_soc_logging(hdev
);
885 /* WCN399x and WCN6750 supports the Microsoft vendor extension with 0xFD70 as the
894 hci_set_msft_opcode(hdev
, 0xFD70);
900 /* Perform HCI reset */
901 err
= qca_send_reset(hdev
);
903 bt_dev_err(hdev
, "QCA Failed to run HCI_RESET (%d)", err
);
912 /* get fw build info */
913 err
= qca_read_fw_build_info(hdev
);
921 err
= qca_check_bdaddr(hdev
, &config
);
925 bt_dev_info(hdev
, "QCA setup on UART is completed");
929 EXPORT_SYMBOL_GPL(qca_uart_setup
);
931 int qca_set_bdaddr(struct hci_dev
*hdev
, const bdaddr_t
*bdaddr
)
933 bdaddr_t bdaddr_swapped
;
937 baswap(&bdaddr_swapped
, bdaddr
);
939 skb
= __hci_cmd_sync_ev(hdev
, EDL_WRITE_BD_ADDR_OPCODE
, 6,
940 &bdaddr_swapped
, HCI_EV_VENDOR
,
944 bt_dev_err(hdev
, "QCA Change address cmd failed (%d)", err
);
952 EXPORT_SYMBOL_GPL(qca_set_bdaddr
);
955 MODULE_AUTHOR("Ben Young Tae Kim <ytkim@qca.qualcomm.com>");
956 MODULE_DESCRIPTION("Bluetooth support for Qualcomm Atheros family");
957 MODULE_LICENSE("GPL");