1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Bluetooth supports for Qualcomm Atheros ROME chips
5 * Copyright (c) 2015 The Linux Foundation. All rights reserved.
8 #define EDL_PATCH_CMD_OPCODE (0xFC00)
9 #define EDL_NVM_ACCESS_OPCODE (0xFC0B)
10 #define EDL_WRITE_BD_ADDR_OPCODE (0xFC14)
11 #define EDL_PATCH_CMD_LEN (1)
12 #define EDL_PATCH_VER_REQ_CMD (0x19)
13 #define EDL_PATCH_TLV_REQ_CMD (0x1E)
14 #define EDL_GET_BUILD_INFO_CMD (0x20)
15 #define EDL_NVM_ACCESS_SET_REQ_CMD (0x01)
16 #define MAX_SIZE_PER_TLV_SEGMENT (243)
17 #define QCA_PRE_SHUTDOWN_CMD (0xFC08)
18 #define QCA_DISABLE_LOGGING (0xFC17)
20 #define EDL_CMD_REQ_RES_EVT (0x00)
21 #define EDL_PATCH_VER_RES_EVT (0x19)
22 #define EDL_APP_VER_RES_EVT (0x02)
23 #define EDL_TVL_DNLD_RES_EVT (0x04)
24 #define EDL_CMD_EXE_STATUS_EVT (0x00)
25 #define EDL_SET_BAUDRATE_RSP_EVT (0x92)
26 #define EDL_NVM_ACCESS_CODE_EVT (0x0B)
27 #define QCA_DISABLE_LOGGING_SUB_OP (0x14)
29 #define EDL_TAG_ID_HCI (17)
30 #define EDL_TAG_ID_DEEP_SLEEP (27)
32 #define QCA_WCN3990_POWERON_PULSE 0xFC
33 #define QCA_WCN3990_POWEROFF_PULSE 0xC0
35 #define QCA_HCI_CC_OPCODE 0xFC00
36 #define QCA_HCI_CC_SUCCESS 0x00
38 #define QCA_WCN3991_SOC_ID (0x40014320)
40 /* QCA chipset version can be decided by patch and SoC
41 * version, combination with upper 2 bytes from SoC
42 * and lower 2 bytes from patch will be used.
44 #define get_soc_ver(soc_id, rom_ver) \
45 ((le32_to_cpu(soc_id) << 16) | (le16_to_cpu(rom_ver)))
47 #define QCA_FW_BUILD_VER_LEN 255
51 QCA_BAUDRATE_115200 = 0,
70 QCA_BAUDRATE_AUTO = 0xFE,
74 enum qca_tlv_dnld_mode {
87 struct qca_fw_config {
90 uint8_t user_baud_rate;
91 enum qca_tlv_dnld_mode dnld_mode;
92 enum qca_tlv_dnld_mode dnld_type;
95 struct edl_event_hdr {
101 struct qca_btsoc_version {
108 struct tlv_seg_resp {
112 struct tlv_type_patch {
121 __le16 patch_version;
126 struct tlv_type_nvm {
134 struct tlv_type_hdr {
139 enum qca_btsoc_type {
150 #if IS_ENABLED(CONFIG_BT_QCA)
152 int qca_set_bdaddr_rome(struct hci_dev *hdev, const bdaddr_t *bdaddr);
153 int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate,
154 enum qca_btsoc_type soc_type, struct qca_btsoc_version ver,
155 const char *firmware_name);
156 int qca_read_soc_version(struct hci_dev *hdev, struct qca_btsoc_version *ver,
157 enum qca_btsoc_type);
158 int qca_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr);
159 int qca_send_pre_shutdown_cmd(struct hci_dev *hdev);
160 static inline bool qca_is_wcn399x(enum qca_btsoc_type soc_type)
162 return soc_type == QCA_WCN3990 || soc_type == QCA_WCN3991 ||
163 soc_type == QCA_WCN3998;
165 static inline bool qca_is_wcn6750(enum qca_btsoc_type soc_type)
167 return soc_type == QCA_WCN6750;
172 static inline int qca_set_bdaddr_rome(struct hci_dev *hdev, const bdaddr_t *bdaddr)
177 static inline int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate,
178 enum qca_btsoc_type soc_type,
179 struct qca_btsoc_version ver,
180 const char *firmware_name)
185 static inline int qca_read_soc_version(struct hci_dev *hdev,
186 struct qca_btsoc_version *ver,
192 static inline int qca_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr)
197 static inline bool qca_is_wcn399x(enum qca_btsoc_type soc_type)
202 static inline bool qca_is_wcn6750(enum qca_btsoc_type soc_type)
207 static inline int qca_send_pre_shutdown_cmd(struct hci_dev *hdev)