xref: /openbmc/linux/drivers/bluetooth/btqca.h (revision b830f94f)
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 
17 #define EDL_CMD_REQ_RES_EVT		(0x00)
18 #define EDL_PATCH_VER_RES_EVT		(0x19)
19 #define EDL_APP_VER_RES_EVT		(0x02)
20 #define EDL_TVL_DNLD_RES_EVT		(0x04)
21 #define EDL_CMD_EXE_STATUS_EVT		(0x00)
22 #define EDL_SET_BAUDRATE_RSP_EVT	(0x92)
23 #define EDL_NVM_ACCESS_CODE_EVT		(0x0B)
24 
25 #define EDL_TAG_ID_HCI			(17)
26 #define EDL_TAG_ID_DEEP_SLEEP		(27)
27 
28 #define QCA_WCN3990_POWERON_PULSE	0xFC
29 #define QCA_WCN3990_POWEROFF_PULSE	0xC0
30 
31 #define QCA_HCI_CC_OPCODE		0xFC00
32 #define QCA_HCI_CC_SUCCESS		0x00
33 
34 enum qca_baudrate {
35 	QCA_BAUDRATE_115200 	= 0,
36 	QCA_BAUDRATE_57600,
37 	QCA_BAUDRATE_38400,
38 	QCA_BAUDRATE_19200,
39 	QCA_BAUDRATE_9600,
40 	QCA_BAUDRATE_230400,
41 	QCA_BAUDRATE_250000,
42 	QCA_BAUDRATE_460800,
43 	QCA_BAUDRATE_500000,
44 	QCA_BAUDRATE_720000,
45 	QCA_BAUDRATE_921600,
46 	QCA_BAUDRATE_1000000,
47 	QCA_BAUDRATE_1250000,
48 	QCA_BAUDRATE_2000000,
49 	QCA_BAUDRATE_3000000,
50 	QCA_BAUDRATE_4000000,
51 	QCA_BAUDRATE_1600000,
52 	QCA_BAUDRATE_3200000,
53 	QCA_BAUDRATE_3500000,
54 	QCA_BAUDRATE_AUTO 	= 0xFE,
55 	QCA_BAUDRATE_RESERVED
56 };
57 
58 enum rome_tlv_dnld_mode {
59 	ROME_SKIP_EVT_NONE,
60 	ROME_SKIP_EVT_VSE,
61 	ROME_SKIP_EVT_CC,
62 	ROME_SKIP_EVT_VSE_CC
63 };
64 
65 enum rome_tlv_type {
66 	TLV_TYPE_PATCH = 1,
67 	TLV_TYPE_NVM
68 };
69 
70 struct rome_config {
71 	u8 type;
72 	char fwname[64];
73 	uint8_t user_baud_rate;
74 	enum rome_tlv_dnld_mode dnld_mode;
75 	enum rome_tlv_dnld_mode dnld_type;
76 };
77 
78 struct edl_event_hdr {
79 	__u8 cresp;
80 	__u8 rtype;
81 	__u8 data[0];
82 } __packed;
83 
84 struct rome_version {
85 	__le32 product_id;
86 	__le16 patch_ver;
87 	__le16 rome_ver;
88 	__le32 soc_id;
89 } __packed;
90 
91 struct tlv_seg_resp {
92 	__u8 result;
93 } __packed;
94 
95 struct tlv_type_patch {
96 	__le32 total_size;
97 	__le32 data_length;
98 	__u8   format_version;
99 	__u8   signature;
100 	__u8   download_mode;
101 	__u8   reserved1;
102 	__le16 product_id;
103 	__le16 rom_build;
104 	__le16 patch_version;
105 	__le16 reserved2;
106 	__le32 entry;
107 } __packed;
108 
109 struct tlv_type_nvm {
110 	__le16 tag_id;
111 	__le16 tag_len;
112 	__le32 reserve1;
113 	__le32 reserve2;
114 	__u8   data[0];
115 } __packed;
116 
117 struct tlv_type_hdr {
118 	__le32 type_len;
119 	__u8   data[0];
120 } __packed;
121 
122 enum qca_btsoc_type {
123 	QCA_INVALID = -1,
124 	QCA_AR3002,
125 	QCA_ROME,
126 	QCA_WCN3990,
127 	QCA_WCN3998,
128 };
129 
130 #if IS_ENABLED(CONFIG_BT_QCA)
131 
132 int qca_set_bdaddr_rome(struct hci_dev *hdev, const bdaddr_t *bdaddr);
133 int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate,
134 		   enum qca_btsoc_type soc_type, u32 soc_ver,
135 		   const char *firmware_name);
136 int qca_read_soc_version(struct hci_dev *hdev, u32 *soc_version);
137 int qca_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr);
138 static inline bool qca_is_wcn399x(enum qca_btsoc_type soc_type)
139 {
140 	return soc_type == QCA_WCN3990 || soc_type == QCA_WCN3998;
141 }
142 #else
143 
144 static inline int qca_set_bdaddr_rome(struct hci_dev *hdev, const bdaddr_t *bdaddr)
145 {
146 	return -EOPNOTSUPP;
147 }
148 
149 static inline int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate,
150 				 enum qca_btsoc_type soc_type, u32 soc_ver,
151 				 const char *firmware_name)
152 {
153 	return -EOPNOTSUPP;
154 }
155 
156 static inline int qca_read_soc_version(struct hci_dev *hdev, u32 *soc_version)
157 {
158 	return -EOPNOTSUPP;
159 }
160 
161 static inline int qca_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr)
162 {
163 	return -EOPNOTSUPP;
164 }
165 
166 static inline bool qca_is_wcn399x(enum qca_btsoc_type soc_type)
167 {
168 	return false;
169 }
170 #endif
171