1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 /* 3 * Bluetooth supports for Qualcomm Atheros ROME chips 4 * 5 * Copyright (c) 2015 The Linux Foundation. All rights reserved. 6 */ 7 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_NVM_ACCESS_SET_REQ_CMD (0x01) 15 #define MAX_SIZE_PER_TLV_SEGMENT (243) 16 #define QCA_PRE_SHUTDOWN_CMD (0xFC08) 17 #define QCA_DISABLE_LOGGING (0xFC17) 18 19 #define EDL_CMD_REQ_RES_EVT (0x00) 20 #define EDL_PATCH_VER_RES_EVT (0x19) 21 #define EDL_APP_VER_RES_EVT (0x02) 22 #define EDL_TVL_DNLD_RES_EVT (0x04) 23 #define EDL_CMD_EXE_STATUS_EVT (0x00) 24 #define EDL_SET_BAUDRATE_RSP_EVT (0x92) 25 #define EDL_NVM_ACCESS_CODE_EVT (0x0B) 26 #define QCA_DISABLE_LOGGING_SUB_OP (0x14) 27 28 #define EDL_TAG_ID_HCI (17) 29 #define EDL_TAG_ID_DEEP_SLEEP (27) 30 31 #define QCA_WCN3990_POWERON_PULSE 0xFC 32 #define QCA_WCN3990_POWEROFF_PULSE 0xC0 33 34 #define QCA_HCI_CC_OPCODE 0xFC00 35 #define QCA_HCI_CC_SUCCESS 0x00 36 37 enum qca_baudrate { 38 QCA_BAUDRATE_115200 = 0, 39 QCA_BAUDRATE_57600, 40 QCA_BAUDRATE_38400, 41 QCA_BAUDRATE_19200, 42 QCA_BAUDRATE_9600, 43 QCA_BAUDRATE_230400, 44 QCA_BAUDRATE_250000, 45 QCA_BAUDRATE_460800, 46 QCA_BAUDRATE_500000, 47 QCA_BAUDRATE_720000, 48 QCA_BAUDRATE_921600, 49 QCA_BAUDRATE_1000000, 50 QCA_BAUDRATE_1250000, 51 QCA_BAUDRATE_2000000, 52 QCA_BAUDRATE_3000000, 53 QCA_BAUDRATE_4000000, 54 QCA_BAUDRATE_1600000, 55 QCA_BAUDRATE_3200000, 56 QCA_BAUDRATE_3500000, 57 QCA_BAUDRATE_AUTO = 0xFE, 58 QCA_BAUDRATE_RESERVED 59 }; 60 61 enum qca_tlv_dnld_mode { 62 QCA_SKIP_EVT_NONE, 63 QCA_SKIP_EVT_VSE, 64 QCA_SKIP_EVT_CC, 65 QCA_SKIP_EVT_VSE_CC 66 }; 67 68 enum qca_tlv_type { 69 TLV_TYPE_PATCH = 1, 70 TLV_TYPE_NVM 71 }; 72 73 struct qca_fw_config { 74 u8 type; 75 char fwname[64]; 76 uint8_t user_baud_rate; 77 enum qca_tlv_dnld_mode dnld_mode; 78 enum qca_tlv_dnld_mode dnld_type; 79 }; 80 81 struct edl_event_hdr { 82 __u8 cresp; 83 __u8 rtype; 84 __u8 data[]; 85 } __packed; 86 87 struct qca_btsoc_version { 88 __le32 product_id; 89 __le16 patch_ver; 90 __le16 rom_ver; 91 __le32 soc_id; 92 } __packed; 93 94 struct tlv_seg_resp { 95 __u8 result; 96 } __packed; 97 98 struct tlv_type_patch { 99 __le32 total_size; 100 __le32 data_length; 101 __u8 format_version; 102 __u8 signature; 103 __u8 download_mode; 104 __u8 reserved1; 105 __le16 product_id; 106 __le16 rom_build; 107 __le16 patch_version; 108 __le16 reserved2; 109 __le32 entry; 110 } __packed; 111 112 struct tlv_type_nvm { 113 __le16 tag_id; 114 __le16 tag_len; 115 __le32 reserve1; 116 __le32 reserve2; 117 __u8 data[]; 118 } __packed; 119 120 struct tlv_type_hdr { 121 __le32 type_len; 122 __u8 data[]; 123 } __packed; 124 125 enum qca_btsoc_type { 126 QCA_INVALID = -1, 127 QCA_AR3002, 128 QCA_ROME, 129 QCA_WCN3990, 130 QCA_WCN3998, 131 QCA_WCN3991, 132 QCA_QCA6390, 133 }; 134 135 #if IS_ENABLED(CONFIG_BT_QCA) 136 137 int qca_set_bdaddr_rome(struct hci_dev *hdev, const bdaddr_t *bdaddr); 138 int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate, 139 enum qca_btsoc_type soc_type, u32 soc_ver, 140 const char *firmware_name); 141 int qca_read_soc_version(struct hci_dev *hdev, u32 *soc_version, 142 enum qca_btsoc_type); 143 int qca_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr); 144 int qca_send_pre_shutdown_cmd(struct hci_dev *hdev); 145 static inline bool qca_is_wcn399x(enum qca_btsoc_type soc_type) 146 { 147 return soc_type == QCA_WCN3990 || soc_type == QCA_WCN3991 || 148 soc_type == QCA_WCN3998; 149 } 150 #else 151 152 static inline int qca_set_bdaddr_rome(struct hci_dev *hdev, const bdaddr_t *bdaddr) 153 { 154 return -EOPNOTSUPP; 155 } 156 157 static inline int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate, 158 enum qca_btsoc_type soc_type, u32 soc_ver, 159 const char *firmware_name) 160 { 161 return -EOPNOTSUPP; 162 } 163 164 static inline int qca_read_soc_version(struct hci_dev *hdev, u32 *soc_version, 165 enum qca_btsoc_type) 166 { 167 return -EOPNOTSUPP; 168 } 169 170 static inline int qca_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr) 171 { 172 return -EOPNOTSUPP; 173 } 174 175 static inline bool qca_is_wcn399x(enum qca_btsoc_type soc_type) 176 { 177 return false; 178 } 179 180 static inline int qca_send_pre_shutdown_cmd(struct hci_dev *hdev) 181 { 182 return -EOPNOTSUPP; 183 } 184 #endif 185