xref: /openbmc/linux/drivers/bluetooth/btqca.h (revision 6a551c11)
1 /*
2  *  Bluetooth supports for Qualcomm Atheros ROME chips
3  *
4  *  Copyright (c) 2015 The Linux Foundation. All rights reserved.
5  *
6  *  This program is free software; you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License version 2
8  *  as published by the Free Software Foundation
9  *
10  *  This program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with this program; if not, write to the Free Software
17  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18  *
19  */
20 
21 #define EDL_PATCH_CMD_OPCODE		(0xFC00)
22 #define EDL_NVM_ACCESS_OPCODE		(0xFC0B)
23 #define EDL_PATCH_CMD_LEN		(1)
24 #define EDL_PATCH_VER_REQ_CMD		(0x19)
25 #define EDL_PATCH_TLV_REQ_CMD		(0x1E)
26 #define EDL_NVM_ACCESS_SET_REQ_CMD	(0x01)
27 #define MAX_SIZE_PER_TLV_SEGMENT	(243)
28 
29 #define EDL_CMD_REQ_RES_EVT		(0x00)
30 #define EDL_PATCH_VER_RES_EVT		(0x19)
31 #define EDL_APP_VER_RES_EVT		(0x02)
32 #define EDL_TVL_DNLD_RES_EVT		(0x04)
33 #define EDL_CMD_EXE_STATUS_EVT		(0x00)
34 #define EDL_SET_BAUDRATE_RSP_EVT	(0x92)
35 #define EDL_NVM_ACCESS_CODE_EVT		(0x0B)
36 
37 #define EDL_TAG_ID_HCI			(17)
38 #define EDL_TAG_ID_DEEP_SLEEP		(27)
39 
40 enum qca_bardrate {
41 	QCA_BAUDRATE_115200 	= 0,
42 	QCA_BAUDRATE_57600,
43 	QCA_BAUDRATE_38400,
44 	QCA_BAUDRATE_19200,
45 	QCA_BAUDRATE_9600,
46 	QCA_BAUDRATE_230400,
47 	QCA_BAUDRATE_250000,
48 	QCA_BAUDRATE_460800,
49 	QCA_BAUDRATE_500000,
50 	QCA_BAUDRATE_720000,
51 	QCA_BAUDRATE_921600,
52 	QCA_BAUDRATE_1000000,
53 	QCA_BAUDRATE_1250000,
54 	QCA_BAUDRATE_2000000,
55 	QCA_BAUDRATE_3000000,
56 	QCA_BAUDRATE_4000000,
57 	QCA_BAUDRATE_1600000,
58 	QCA_BAUDRATE_3200000,
59 	QCA_BAUDRATE_3500000,
60 	QCA_BAUDRATE_AUTO 	= 0xFE,
61 	QCA_BAUDRATE_RESERVED
62 };
63 
64 enum rome_tlv_type {
65 	TLV_TYPE_PATCH = 1,
66 	TLV_TYPE_NVM
67 };
68 
69 struct rome_config {
70 	u8 type;
71 	char fwname[64];
72 	uint8_t user_baud_rate;
73 };
74 
75 struct edl_event_hdr {
76 	__u8 cresp;
77 	__u8 rtype;
78 	__u8 data[0];
79 } __packed;
80 
81 struct rome_version {
82 	__le32 product_id;
83 	__le16 patch_ver;
84 	__le16 rome_ver;
85 	__le32 soc_id;
86 } __packed;
87 
88 struct tlv_seg_resp {
89 	__u8 result;
90 } __packed;
91 
92 struct tlv_type_patch {
93 	__le32 total_size;
94 	__le32 data_length;
95 	__u8   format_version;
96 	__u8   signature;
97 	__le16 reserved1;
98 	__le16 product_id;
99 	__le16 rom_build;
100 	__le16 patch_version;
101 	__le16 reserved2;
102 	__le32 entry;
103 } __packed;
104 
105 struct tlv_type_nvm {
106 	__le16 tag_id;
107 	__le16 tag_len;
108 	__le32 reserve1;
109 	__le32 reserve2;
110 	__u8   data[0];
111 } __packed;
112 
113 struct tlv_type_hdr {
114 	__le32 type_len;
115 	__u8   data[0];
116 } __packed;
117 
118 #if IS_ENABLED(CONFIG_BT_QCA)
119 
120 int qca_set_bdaddr_rome(struct hci_dev *hdev, const bdaddr_t *bdaddr);
121 int qca_uart_setup_rome(struct hci_dev *hdev, uint8_t baudrate);
122 
123 #else
124 
125 static inline int qca_set_bdaddr_rome(struct hci_dev *hdev, const bdaddr_t *bdaddr)
126 {
127 	return -EOPNOTSUPP;
128 }
129 
130 static inline int qca_uart_setup_rome(struct hci_dev *hdev, int speed)
131 {
132 	return -EOPNOTSUPP;
133 }
134 
135 #endif
136