blob: c72c56ea74808b1e850e9e15759925bae72c0760 [file] [log] [blame]
Ben Young Tae Kim83e81962015-08-10 14:24:12 -07001/*
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)
Balakrishna Godavarthi5c0a10012019-01-16 18:01:15 +053023#define EDL_WRITE_BD_ADDR_OPCODE (0xFC14)
Ben Young Tae Kim83e81962015-08-10 14:24:12 -070024#define EDL_PATCH_CMD_LEN (1)
25#define EDL_PATCH_VER_REQ_CMD (0x19)
26#define EDL_PATCH_TLV_REQ_CMD (0x1E)
27#define EDL_NVM_ACCESS_SET_REQ_CMD (0x01)
28#define MAX_SIZE_PER_TLV_SEGMENT (243)
29
30#define EDL_CMD_REQ_RES_EVT (0x00)
31#define EDL_PATCH_VER_RES_EVT (0x19)
32#define EDL_APP_VER_RES_EVT (0x02)
33#define EDL_TVL_DNLD_RES_EVT (0x04)
34#define EDL_CMD_EXE_STATUS_EVT (0x00)
35#define EDL_SET_BAUDRATE_RSP_EVT (0x92)
36#define EDL_NVM_ACCESS_CODE_EVT (0x0B)
37
38#define EDL_TAG_ID_HCI (17)
39#define EDL_TAG_ID_DEEP_SLEEP (27)
40
Balakrishna Godavarthifa9ad872018-08-03 17:46:32 +053041#define QCA_WCN3990_POWERON_PULSE 0xFC
42#define QCA_WCN3990_POWEROFF_PULSE 0xC0
43
Ben Young Tae Kim83e81962015-08-10 14:24:12 -070044enum qca_bardrate {
45 QCA_BAUDRATE_115200 = 0,
46 QCA_BAUDRATE_57600,
47 QCA_BAUDRATE_38400,
48 QCA_BAUDRATE_19200,
49 QCA_BAUDRATE_9600,
50 QCA_BAUDRATE_230400,
51 QCA_BAUDRATE_250000,
52 QCA_BAUDRATE_460800,
53 QCA_BAUDRATE_500000,
54 QCA_BAUDRATE_720000,
55 QCA_BAUDRATE_921600,
56 QCA_BAUDRATE_1000000,
57 QCA_BAUDRATE_1250000,
58 QCA_BAUDRATE_2000000,
59 QCA_BAUDRATE_3000000,
60 QCA_BAUDRATE_4000000,
61 QCA_BAUDRATE_1600000,
62 QCA_BAUDRATE_3200000,
63 QCA_BAUDRATE_3500000,
64 QCA_BAUDRATE_AUTO = 0xFE,
65 QCA_BAUDRATE_RESERVED
66};
67
Loic Poulain6e031262018-04-26 13:13:27 +020068enum rome_tlv_dnld_mode {
69 ROME_SKIP_EVT_NONE,
70 ROME_SKIP_EVT_VSE,
71 ROME_SKIP_EVT_CC,
72 ROME_SKIP_EVT_VSE_CC
73};
74
Ben Young Tae Kim83e81962015-08-10 14:24:12 -070075enum rome_tlv_type {
76 TLV_TYPE_PATCH = 1,
77 TLV_TYPE_NVM
78};
79
80struct rome_config {
81 u8 type;
82 char fwname[64];
83 uint8_t user_baud_rate;
Loic Poulain6e031262018-04-26 13:13:27 +020084 enum rome_tlv_dnld_mode dnld_mode;
Ben Young Tae Kim83e81962015-08-10 14:24:12 -070085};
86
87struct edl_event_hdr {
88 __u8 cresp;
89 __u8 rtype;
90 __u8 data[0];
91} __packed;
92
93struct rome_version {
94 __le32 product_id;
95 __le16 patch_ver;
96 __le16 rome_ver;
97 __le32 soc_id;
98} __packed;
99
100struct tlv_seg_resp {
101 __u8 result;
102} __packed;
103
104struct tlv_type_patch {
105 __le32 total_size;
106 __le32 data_length;
107 __u8 format_version;
108 __u8 signature;
Loic Poulain6e031262018-04-26 13:13:27 +0200109 __u8 download_mode;
110 __u8 reserved1;
Ben Young Tae Kim83e81962015-08-10 14:24:12 -0700111 __le16 product_id;
112 __le16 rom_build;
113 __le16 patch_version;
114 __le16 reserved2;
115 __le32 entry;
116} __packed;
117
118struct tlv_type_nvm {
119 __le16 tag_id;
120 __le16 tag_len;
121 __le32 reserve1;
122 __le32 reserve2;
123 __u8 data[0];
124} __packed;
125
126struct tlv_type_hdr {
127 __le32 type_len;
128 __u8 data[0];
129} __packed;
130
Balakrishna Godavarthiaadebac2018-08-03 17:46:28 +0530131enum qca_btsoc_type {
132 QCA_INVALID = -1,
133 QCA_AR3002,
134 QCA_ROME,
135 QCA_WCN3990
136};
137
Ben Young Tae Kim83e81962015-08-10 14:24:12 -0700138#if IS_ENABLED(CONFIG_BT_QCA)
139
140int qca_set_bdaddr_rome(struct hci_dev *hdev, const bdaddr_t *bdaddr);
Balakrishna Godavarthiaadebac2018-08-03 17:46:28 +0530141int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate,
142 enum qca_btsoc_type soc_type, u32 soc_ver);
Balakrishna Godavarthiba493d42018-08-03 17:46:27 +0530143int qca_read_soc_version(struct hci_dev *hdev, u32 *soc_version);
Balakrishna Godavarthi5c0a10012019-01-16 18:01:15 +0530144int qca_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr);
Ben Young Tae Kim83e81962015-08-10 14:24:12 -0700145#else
146
147static inline int qca_set_bdaddr_rome(struct hci_dev *hdev, const bdaddr_t *bdaddr)
148{
149 return -EOPNOTSUPP;
150}
151
Balakrishna Godavarthiaadebac2018-08-03 17:46:28 +0530152static inline int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate,
153 enum qca_btsoc_type soc_type, u32 soc_ver)
Balakrishna Godavarthiba493d42018-08-03 17:46:27 +0530154{
155 return -EOPNOTSUPP;
156}
157
158static inline int qca_read_soc_version(struct hci_dev *hdev, u32 *soc_version)
Ben Young Tae Kim83e81962015-08-10 14:24:12 -0700159{
160 return -EOPNOTSUPP;
161}
162
Balakrishna Godavarthi5c0a10012019-01-16 18:01:15 +0530163static inline int qca_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr)
164{
165 return -EOPNOTSUPP;
166}
167
Ben Young Tae Kim83e81962015-08-10 14:24:12 -0700168#endif