blob: 63d72689481d9bd019e4055e35faba3198e69c78 [file] [log] [blame]
Jes Sorensen26f1fad2015-10-14 20:44:51 -04001/*
2 * Copyright (c) 2014 - 2015 Jes Sorensen <Jes.Sorensen@redhat.com>
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of version 2 of the GNU General Public License as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 * more details.
12 *
13 * Register definitions taken from original Realtek rtl8723au driver
14 */
15
16#include <asm/byteorder.h>
17
18#define RTL8XXXU_DEBUG_REG_WRITE 0x01
19#define RTL8XXXU_DEBUG_REG_READ 0x02
20#define RTL8XXXU_DEBUG_RFREG_WRITE 0x04
21#define RTL8XXXU_DEBUG_RFREG_READ 0x08
22#define RTL8XXXU_DEBUG_CHANNEL 0x10
23#define RTL8XXXU_DEBUG_TX 0x20
24#define RTL8XXXU_DEBUG_TX_DUMP 0x40
25#define RTL8XXXU_DEBUG_RX 0x80
26#define RTL8XXXU_DEBUG_RX_DUMP 0x100
27#define RTL8XXXU_DEBUG_USB 0x200
28#define RTL8XXXU_DEBUG_KEY 0x400
29#define RTL8XXXU_DEBUG_H2C 0x800
30#define RTL8XXXU_DEBUG_ACTION 0x1000
31#define RTL8XXXU_DEBUG_EFUSE 0x2000
32
33#define RTW_USB_CONTROL_MSG_TIMEOUT 500
34#define RTL8XXXU_MAX_REG_POLL 500
35#define USB_INTR_CONTENT_LENGTH 56
36
Jes Sorensen35a741f2016-02-29 17:04:10 -050037#define RTL8XXXU_OUT_ENDPOINTS 4
Jes Sorensen26f1fad2015-10-14 20:44:51 -040038
39#define REALTEK_USB_READ 0xc0
40#define REALTEK_USB_WRITE 0x40
41#define REALTEK_USB_CMD_REQ 0x05
42#define REALTEK_USB_CMD_IDX 0x00
43
44#define TX_TOTAL_PAGE_NUM 0xf8
Jes Sorensen80805aa2016-04-07 14:19:18 -040045#define TX_TOTAL_PAGE_NUM_8192E 0xf3
Jes Sorensen26f1fad2015-10-14 20:44:51 -040046/* (HPQ + LPQ + NPQ + PUBQ) = TX_TOTAL_PAGE_NUM */
47#define TX_PAGE_NUM_PUBQ 0xe7
48#define TX_PAGE_NUM_HI_PQ 0x0c
49#define TX_PAGE_NUM_LO_PQ 0x02
50#define TX_PAGE_NUM_NORM_PQ 0x02
51
52#define RTL_FW_PAGE_SIZE 4096
53#define RTL8XXXU_FIRMWARE_POLL_MAX 1000
54
55#define RTL8723A_CHANNEL_GROUPS 3
56#define RTL8723A_MAX_RF_PATHS 2
Jes Sorensen21db9972016-02-29 17:05:21 -050057#define RTL8723B_CHANNEL_GROUPS 6
Jes Sorensen3be26992016-02-29 17:05:22 -050058#define RTL8723B_TX_COUNT 4
Jes Sorensen4a0d7db2016-02-29 17:05:18 -050059#define RTL8723B_MAX_RF_PATHS 4
Jes Sorensen21db9972016-02-29 17:05:21 -050060#define RTL8XXXU_MAX_CHANNEL_GROUPS 6
Jes Sorensen26f1fad2015-10-14 20:44:51 -040061#define RF6052_MAX_TX_PWR 0x3f
62
Jes Sorensen3307d842016-02-29 17:03:59 -050063#define EFUSE_MAP_LEN 512
64#define EFUSE_MAX_SECTION_8723A 64
Jes Sorensen26f1fad2015-10-14 20:44:51 -040065#define EFUSE_REAL_CONTENT_LEN_8723A 512
66#define EFUSE_BT_MAP_LEN_8723A 1024
67#define EFUSE_MAX_WORD_UNIT 4
68
Jes Sorensenba17d822016-03-31 17:08:39 -040069enum rtl8xxxu_rtl_chip {
70 RTL8192S = 0x81920,
71 RTL8191S = 0x81910,
72 RTL8192C = 0x8192c,
73 RTL8191C = 0x8191c,
74 RTL8188C = 0x8188c,
75 RTL8188R = 0x81889,
76 RTL8192D = 0x8192d,
77 RTL8723A = 0x8723a,
78 RTL8188E = 0x8188e,
79 RTL8812 = 0x88120,
80 RTL8821 = 0x88210,
81 RTL8192E = 0x8192e,
82 RTL8191E = 0x8191e,
83 RTL8723B = 0x8723b,
84 RTL8814A = 0x8814a,
85 RTL8881A = 0x8881a,
86 RTL8821B = 0x8821b,
87 RTL8822B = 0x8822b,
88 RTL8703B = 0x8703b,
89 RTL8195A = 0x8195a,
90 RTL8188F = 0x8188f
91};
92
Jes Sorensenb18cdfd2016-02-29 17:04:47 -050093enum rtl8xxxu_rx_type {
94 RX_TYPE_DATA_PKT = 0,
95 RX_TYPE_C2H = 1,
96 RX_TYPE_ERROR = -1
97};
98
Jes Sorensen26f1fad2015-10-14 20:44:51 -040099struct rtl8xxxu_rx_desc {
100#ifdef __LITTLE_ENDIAN
101 u32 pktlen:14;
102 u32 crc32:1;
103 u32 icverr:1;
104 u32 drvinfo_sz:4;
105 u32 security:3;
106 u32 qos:1;
107 u32 shift:2;
108 u32 phy_stats:1;
109 u32 swdec:1;
110 u32 ls:1;
111 u32 fs:1;
112 u32 eor:1;
113 u32 own:1;
114
115 u32 macid:5;
116 u32 tid:4;
117 u32 hwrsvd:4;
118 u32 amsdu:1;
119 u32 paggr:1;
120 u32 faggr:1;
121 u32 a1fit:4;
122 u32 a2fit:4;
123 u32 pam:1;
124 u32 pwr:1;
125 u32 md:1;
126 u32 mf:1;
127 u32 type:2;
128 u32 mc:1;
129 u32 bc:1;
130
131 u32 seq:12;
132 u32 frag:4;
133 u32 nextpktlen:14;
134 u32 nextind:1;
135 u32 reserved0:1;
136
137 u32 rxmcs:6;
138 u32 rxht:1;
139 u32 gf:1;
140 u32 splcp:1;
141 u32 bw:1;
142 u32 htc:1;
143 u32 eosp:1;
144 u32 bssidfit:2;
145 u32 reserved1:16;
146 u32 unicastwake:1;
147 u32 magicwake:1;
148
149 u32 pattern0match:1;
150 u32 pattern1match:1;
151 u32 pattern2match:1;
152 u32 pattern3match:1;
153 u32 pattern4match:1;
154 u32 pattern5match:1;
155 u32 pattern6match:1;
156 u32 pattern7match:1;
157 u32 pattern8match:1;
158 u32 pattern9match:1;
159 u32 patternamatch:1;
160 u32 patternbmatch:1;
161 u32 patterncmatch:1;
162 u32 reserved2:19;
163#else
164 u32 own:1;
165 u32 eor:1;
166 u32 fs:1;
167 u32 ls:1;
168 u32 swdec:1;
169 u32 phy_stats:1;
170 u32 shift:2;
171 u32 qos:1;
172 u32 security:3;
173 u32 drvinfo_sz:4;
174 u32 icverr:1;
175 u32 crc32:1;
176 u32 pktlen:14;
177
178 u32 bc:1;
179 u32 mc:1;
180 u32 type:2;
181 u32 mf:1;
182 u32 md:1;
183 u32 pwr:1;
184 u32 pam:1;
185 u32 a2fit:4;
186 u32 a1fit:4;
187 u32 faggr:1;
188 u32 paggr:1;
189 u32 amsdu:1;
190 u32 hwrsvd:4;
191 u32 tid:4;
192 u32 macid:5;
193
194 u32 reserved0:1;
195 u32 nextind:1;
196 u32 nextpktlen:14;
197 u32 frag:4;
198 u32 seq:12;
199
200 u32 magicwake:1;
201 u32 unicastwake:1;
202 u32 reserved1:16;
203 u32 bssidfit:2;
204 u32 eosp:1;
205 u32 htc:1;
206 u32 bw:1;
207 u32 splcp:1;
208 u32 gf:1;
209 u32 rxht:1;
210 u32 rxmcs:6;
211
212 u32 reserved2:19;
213 u32 patterncmatch:1;
214 u32 patternbmatch:1;
215 u32 patternamatch:1;
216 u32 pattern9match:1;
217 u32 pattern8match:1;
218 u32 pattern7match:1;
219 u32 pattern6match:1;
220 u32 pattern5match:1;
221 u32 pattern4match:1;
222 u32 pattern3match:1;
223 u32 pattern2match:1;
224 u32 pattern1match:1;
225 u32 pattern0match:1;
226#endif
227 __le32 tsfl;
228#if 0
229 u32 bassn:12;
230 u32 bavld:1;
231 u32 reserved3:19;
232#endif
233};
234
Jes Sorensena6c80d22016-02-29 17:04:46 -0500235struct rtl8723bu_rx_desc {
236#ifdef __LITTLE_ENDIAN
237 u32 pktlen:14;
238 u32 crc32:1;
239 u32 icverr:1;
240 u32 drvinfo_sz:4;
241 u32 security:3;
242 u32 qos:1;
243 u32 shift:2;
244 u32 phy_stats:1;
245 u32 swdec:1;
246 u32 ls:1;
247 u32 fs:1;
248 u32 eor:1;
249 u32 own:1;
250
251 u32 macid:7;
252 u32 dummy1_0:1;
253 u32 tid:4;
254 u32 dummy1_1:1;
255 u32 amsdu:1;
256 u32 rxid_match:1;
257 u32 paggr:1;
258 u32 a1fit:4; /* 16 */
259 u32 chkerr:1;
260 u32 ipver:1;
261 u32 tcpudp:1;
262 u32 chkvld:1;
263 u32 pam:1;
264 u32 pwr:1;
265 u32 more_data:1;
266 u32 more_frag:1;
267 u32 type:2;
268 u32 mc:1;
269 u32 bc:1;
270
271 u32 seq:12;
272 u32 frag:4;
273 u32 rx_is_qos:1; /* 16 */
274 u32 dummy2_0:1;
275 u32 wlanhd_iv_len:6;
276 u32 dummy2_1:4;
277 u32 rpt_sel:1;
278 u32 dummy2_2:3;
279
280 u32 rxmcs:7;
281 u32 dummy3_0:3;
282 u32 htc:1;
283 u32 eosp:1;
284 u32 bssidfit:2;
285 u32 dummy3_1:2;
286 u32 usb_agg_pktnum:8; /* 16 */
287 u32 dummy3_2:5;
288 u32 pattern_match:1;
289 u32 unicast_match:1;
290 u32 magic_match:1;
291
292 u32 splcp:1;
293 u32 ldcp:1;
294 u32 stbc:1;
295 u32 dummy4_0:1;
296 u32 bw:2;
297 u32 dummy4_1:26;
298#else
299 u32 own:1;
300 u32 eor:1;
301 u32 fs:1;
302 u32 ls:1;
303 u32 swdec:1;
304 u32 phy_stats:1;
305 u32 shift:2;
306 u32 qos:1;
307 u32 security:3;
308 u32 drvinfo_sz:4;
309 u32 icverr:1;
310 u32 crc32:1;
311 u32 pktlen:14;
312
313 u32 bc:1;
314 u32 mc:1;
315 u32 type:2;
316 u32 mf:1;
317 u32 md:1;
318 u32 pwr:1;
319 u32 pam:1;
320 u32 a2fit:4;
321 u32 a1fit:4;
322 u32 faggr:1;
323 u32 paggr:1;
324 u32 amsdu:1;
325 u32 hwrsvd:4;
326 u32 tid:4;
327 u32 macid:5;
328
329 u32 dummy2_2:3;
330 u32 rpt_sel:1;
331 u32 dummy2_1:4;
332 u32 wlanhd_iv_len:6;
333 u32 dummy2_0:1;
334 u32 rx_is_qos:1;
335 u32 frag:4; /* 16 */
336 u32 seq:12;
337
338 u32 magic_match:1;
339 u32 unicast_match:1;
340 u32 pattern_match:1;
341 u32 dummy3_2:5;
342 u32 usb_agg_pktnum:8;
343 u32 dummy3_1:2; /* 16 */
344 u32 bssidfit:2;
345 u32 eosp:1;
346 u32 htc:1;
347 u32 dummy3_0:3;
348 u32 rxmcs:7;
349
350 u32 dumm4_1:26;
351 u32 bw:2;
352 u32 dummy4_0:1;
353 u32 stbc:1;
354 u32 ldcp:1;
355 u32 splcp:1;
356#endif
357 __le32 tsfl;
358};
359
Jes Sorensendbb28962016-03-31 17:08:33 -0400360struct rtl8xxxu_txdesc32 {
Jes Sorensen26f1fad2015-10-14 20:44:51 -0400361 __le16 pkt_size;
362 u8 pkt_offset;
363 u8 txdw0;
364 __le32 txdw1;
365 __le32 txdw2;
366 __le32 txdw3;
367 __le32 txdw4;
368 __le32 txdw5;
369 __le32 txdw6;
370 __le16 csum;
371 __le16 txdw7;
372};
373
Jes Sorensendbb28962016-03-31 17:08:33 -0400374struct rtl8xxxu_txdesc40 {
Jes Sorensen80491a12016-02-29 17:05:26 -0500375 __le16 pkt_size;
376 u8 pkt_offset;
377 u8 txdw0;
378 __le32 txdw1;
379 __le32 txdw2;
380 __le32 txdw3;
381 __le32 txdw4;
382 __le32 txdw5;
383 __le32 txdw6;
384 __le16 csum;
385 __le16 txdw7;
386 __le32 txdw8;
387 __le32 txdw9;
388};
389
Jes Sorensen26f1fad2015-10-14 20:44:51 -0400390/* CCK Rates, TxHT = 0 */
391#define DESC_RATE_1M 0x00
392#define DESC_RATE_2M 0x01
393#define DESC_RATE_5_5M 0x02
394#define DESC_RATE_11M 0x03
395
396/* OFDM Rates, TxHT = 0 */
397#define DESC_RATE_6M 0x04
398#define DESC_RATE_9M 0x05
399#define DESC_RATE_12M 0x06
400#define DESC_RATE_18M 0x07
401#define DESC_RATE_24M 0x08
402#define DESC_RATE_36M 0x09
403#define DESC_RATE_48M 0x0a
404#define DESC_RATE_54M 0x0b
405
406/* MCS Rates, TxHT = 1 */
407#define DESC_RATE_MCS0 0x0c
408#define DESC_RATE_MCS1 0x0d
409#define DESC_RATE_MCS2 0x0e
410#define DESC_RATE_MCS3 0x0f
411#define DESC_RATE_MCS4 0x10
412#define DESC_RATE_MCS5 0x11
413#define DESC_RATE_MCS6 0x12
414#define DESC_RATE_MCS7 0x13
415#define DESC_RATE_MCS8 0x14
416#define DESC_RATE_MCS9 0x15
417#define DESC_RATE_MCS10 0x16
418#define DESC_RATE_MCS11 0x17
419#define DESC_RATE_MCS12 0x18
420#define DESC_RATE_MCS13 0x19
421#define DESC_RATE_MCS14 0x1a
422#define DESC_RATE_MCS15 0x1b
423#define DESC_RATE_MCS15_SG 0x1c
424#define DESC_RATE_MCS32 0x20
425
426#define TXDESC_OFFSET_SZ 0
427#define TXDESC_OFFSET_SHT 16
428#if 0
429#define TXDESC_BMC BIT(24)
430#define TXDESC_LSG BIT(26)
431#define TXDESC_FSG BIT(27)
432#define TXDESC_OWN BIT(31)
433#else
434#define TXDESC_BROADMULTICAST BIT(0)
Jes Sorensen02492582016-02-29 17:05:29 -0500435#define TXDESC_HTC BIT(1)
Jes Sorensen26f1fad2015-10-14 20:44:51 -0400436#define TXDESC_LAST_SEGMENT BIT(2)
437#define TXDESC_FIRST_SEGMENT BIT(3)
Jes Sorensen02492582016-02-29 17:05:29 -0500438#define TXDESC_LINIP BIT(4)
439#define TXDESC_NO_ACM BIT(5)
440#define TXDESC_GF BIT(6)
Jes Sorensen26f1fad2015-10-14 20:44:51 -0400441#define TXDESC_OWN BIT(7)
442#endif
443
444/* Word 1 */
Jes Sorensence2d1db2016-02-29 17:05:30 -0500445/*
446 * Bits 0-7 differ dependent on chip generation. For 8723au bits 5/6 are
447 * aggregation enable and break respectively. For 8723bu, bits 0-7 are macid.
448 */
Jes Sorensen26f1fad2015-10-14 20:44:51 -0400449#define TXDESC_PKT_OFFSET_SZ 0
Jes Sorensen33f37242016-03-31 17:08:34 -0400450#define TXDESC32_AGG_ENABLE BIT(5)
451#define TXDESC32_AGG_BREAK BIT(6)
452#define TXDESC40_MACID_SHIFT 0
453#define TXDESC40_MACID_MASK 0x00f0
Jes Sorensen26f1fad2015-10-14 20:44:51 -0400454#define TXDESC_QUEUE_SHIFT 8
455#define TXDESC_QUEUE_MASK 0x1f00
456#define TXDESC_QUEUE_BK 0x2
457#define TXDESC_QUEUE_BE 0x0
458#define TXDESC_QUEUE_VI 0x5
459#define TXDESC_QUEUE_VO 0x7
460#define TXDESC_QUEUE_BEACON 0x10
461#define TXDESC_QUEUE_HIGH 0x11
462#define TXDESC_QUEUE_MGNT 0x12
463#define TXDESC_QUEUE_CMD 0x13
464#define TXDESC_QUEUE_MAX (TXDESC_QUEUE_CMD + 1)
Jes Sorensen33f37242016-03-31 17:08:34 -0400465#define TXDESC40_RDG_NAV_EXT BIT(13)
466#define TXDESC40_LSIG_TXOP_ENABLE BIT(14)
467#define TXDESC40_PIFS BIT(15)
Jes Sorensen26f1fad2015-10-14 20:44:51 -0400468
469#define DESC_RATE_ID_SHIFT 16
470#define DESC_RATE_ID_MASK 0xf
471#define TXDESC_NAVUSEHDR BIT(20)
472#define TXDESC_SEC_RC4 0x00400000
473#define TXDESC_SEC_AES 0x00c00000
474#define TXDESC_PKT_OFFSET_SHIFT 26
475#define TXDESC_AGG_EN BIT(29)
476#define TXDESC_HWPC BIT(31)
477
478/* Word 2 */
Jes Sorensen33f37242016-03-31 17:08:34 -0400479#define TXDESC40_PAID_SHIFT 0
480#define TXDESC40_PAID_MASK 0x1ff
481#define TXDESC40_CCA_RTS_SHIFT 10
482#define TXDESC40_CCA_RTS_MASK 0xc00
483#define TXDESC40_AGG_ENABLE BIT(12)
484#define TXDESC40_RDG_ENABLE BIT(13)
485#define TXDESC40_AGG_BREAK BIT(16)
486#define TXDESC40_MORE_FRAG BIT(17)
487#define TXDESC40_RAW BIT(18)
488#define TXDESC32_ACK_REPORT BIT(19)
489#define TXDESC40_SPE_RPT BIT(19)
Jes Sorensen26f1fad2015-10-14 20:44:51 -0400490#define TXDESC_AMPDU_DENSITY_SHIFT 20
Jes Sorensen33f37242016-03-31 17:08:34 -0400491#define TXDESC40_BT_INT BIT(23)
Jes Sorensen169bc5c2016-03-31 17:08:35 -0400492#define TXDESC40_GID_SHIFT 24
Jes Sorensen26f1fad2015-10-14 20:44:51 -0400493
494/* Word 3 */
Jes Sorensen33f37242016-03-31 17:08:34 -0400495#define TXDESC40_USE_DRIVER_RATE BIT(8)
496#define TXDESC40_CTS_SELF_ENABLE BIT(11)
497#define TXDESC40_RTS_CTS_ENABLE BIT(12)
498#define TXDESC40_HW_RTS_ENABLE BIT(13)
499#define TXDESC32_SEQ_SHIFT 16
500#define TXDESC32_SEQ_MASK 0x0fff0000
Jes Sorensen26f1fad2015-10-14 20:44:51 -0400501
502/* Word 4 */
Jes Sorensen33f37242016-03-31 17:08:34 -0400503#define TXDESC32_RTS_RATE_SHIFT 0
504#define TXDESC32_RTS_RATE_MASK 0x3f
505#define TXDESC32_QOS BIT(6)
506#define TXDESC32_HW_SEQ_ENABLE BIT(7)
507#define TXDESC32_USE_DRIVER_RATE BIT(8)
Jes Sorensen26f1fad2015-10-14 20:44:51 -0400508#define TXDESC_DISABLE_DATA_FB BIT(10)
Jes Sorensen33f37242016-03-31 17:08:34 -0400509#define TXDESC32_CTS_SELF_ENABLE BIT(11)
510#define TXDESC32_RTS_CTS_ENABLE BIT(12)
511#define TXDESC32_HW_RTS_ENABLE BIT(13)
Jes Sorensen26f1fad2015-10-14 20:44:51 -0400512#define TXDESC_PRIME_CH_OFF_LOWER BIT(20)
513#define TXDESC_PRIME_CH_OFF_UPPER BIT(21)
Jes Sorensen33f37242016-03-31 17:08:34 -0400514#define TXDESC32_SHORT_PREAMBLE BIT(24)
Jes Sorensen26f1fad2015-10-14 20:44:51 -0400515#define TXDESC_DATA_BW BIT(25)
516#define TXDESC_RTS_DATA_BW BIT(27)
517#define TXDESC_RTS_PRIME_CH_OFF_LOWER BIT(28)
518#define TXDESC_RTS_PRIME_CH_OFF_UPPER BIT(29)
Jes Sorensen33f37242016-03-31 17:08:34 -0400519#define TXDESC40_DATA_RATE_FB_SHIFT 8
520#define TXDESC40_DATA_RATE_FB_MASK 0x00001f00
521#define TXDESC40_RETRY_LIMIT_ENABLE BIT(17)
522#define TXDESC40_RETRY_LIMIT_SHIFT 18
523#define TXDESC40_RETRY_LIMIT_MASK 0x00fc0000
524#define TXDESC40_RTS_RATE_SHIFT 24
525#define TXDESC40_RTS_RATE_MASK 0x3f000000
Jes Sorensen26f1fad2015-10-14 20:44:51 -0400526
527/* Word 5 */
Jes Sorensen33f37242016-03-31 17:08:34 -0400528#define TXDESC40_SHORT_PREAMBLE BIT(4)
Jes Sorensen1df1de32016-03-31 17:08:36 -0400529#define TXDESC32_SHORT_GI BIT(6)
Jes Sorensen26f1fad2015-10-14 20:44:51 -0400530#define TXDESC_CCX_TAG BIT(7)
Jes Sorensen33f37242016-03-31 17:08:34 -0400531#define TXDESC32_RETRY_LIMIT_ENABLE BIT(17)
532#define TXDESC32_RETRY_LIMIT_SHIFT 18
533#define TXDESC32_RETRY_LIMIT_MASK 0x00fc0000
Jes Sorensen26f1fad2015-10-14 20:44:51 -0400534
535/* Word 6 */
536#define TXDESC_MAX_AGG_SHIFT 11
537
Jes Sorensen2098bfb2016-02-29 17:05:33 -0500538/* Word 8 */
Jes Sorensen33f37242016-03-31 17:08:34 -0400539#define TXDESC40_HW_SEQ_ENABLE BIT(15)
Jes Sorensen2098bfb2016-02-29 17:05:33 -0500540
Jes Sorensencc2646d2016-02-29 17:05:32 -0500541/* Word 9 */
Jes Sorensen33f37242016-03-31 17:08:34 -0400542#define TXDESC40_SEQ_SHIFT 12
543#define TXDESC40_SEQ_MASK 0x00fff000
Jes Sorensencc2646d2016-02-29 17:05:32 -0500544
Jes Sorensen26f1fad2015-10-14 20:44:51 -0400545struct phy_rx_agc_info {
546#ifdef __LITTLE_ENDIAN
547 u8 gain:7, trsw:1;
548#else
549 u8 trsw:1, gain:7;
550#endif
551};
552
553struct rtl8723au_phy_stats {
554 struct phy_rx_agc_info path_agc[RTL8723A_MAX_RF_PATHS];
555 u8 ch_corr[RTL8723A_MAX_RF_PATHS];
556 u8 cck_sig_qual_ofdm_pwdb_all;
557 u8 cck_agc_rpt_ofdm_cfosho_a;
558 u8 cck_rpt_b_ofdm_cfosho_b;
559 u8 reserved_1;
560 u8 noise_power_db_msb;
561 u8 path_cfotail[RTL8723A_MAX_RF_PATHS];
562 u8 pcts_mask[RTL8723A_MAX_RF_PATHS];
563 s8 stream_rxevm[RTL8723A_MAX_RF_PATHS];
564 u8 path_rxsnr[RTL8723A_MAX_RF_PATHS];
565 u8 noise_power_db_lsb;
566 u8 reserved_2[3];
567 u8 stream_csi[RTL8723A_MAX_RF_PATHS];
568 u8 stream_target_csi[RTL8723A_MAX_RF_PATHS];
569 s8 sig_evm;
570 u8 reserved_3;
571
572#ifdef __LITTLE_ENDIAN
573 u8 antsel_rx_keep_2:1; /* ex_intf_flg:1; */
574 u8 sgi_en:1;
575 u8 rxsc:2;
576 u8 idle_long:1;
577 u8 r_ant_train_en:1;
578 u8 antenna_select_b:1;
579 u8 antenna_select:1;
580#else /* _BIG_ENDIAN_ */
581 u8 antenna_select:1;
582 u8 antenna_select_b:1;
583 u8 r_ant_train_en:1;
584 u8 idle_long:1;
585 u8 rxsc:2;
586 u8 sgi_en:1;
587 u8 antsel_rx_keep_2:1; /* ex_intf_flg:1; */
588#endif
589};
590
591/*
592 * Regs to backup
593 */
594#define RTL8XXXU_ADDA_REGS 16
595#define RTL8XXXU_MAC_REGS 4
596#define RTL8XXXU_BB_REGS 9
597
598struct rtl8xxxu_firmware_header {
599 __le16 signature; /* 92C0: test chip; 92C,
600 88C0: test chip;
601 88C1: MP A-cut;
602 92C1: MP A-cut */
603 u8 category; /* AP/NIC and USB/PCI */
604 u8 function;
605
606 __le16 major_version; /* FW Version */
607 u8 minor_version; /* FW Subversion, default 0x00 */
608 u8 reserved1;
609
610 u8 month; /* Release time Month field */
611 u8 date; /* Release time Date field */
612 u8 hour; /* Release time Hour field */
613 u8 minute; /* Release time Minute field */
614
615 __le16 ramcodesize; /* Size of RAM code */
616 u16 reserved2;
617
618 __le32 svn_idx; /* SVN entry index */
619 u32 reserved3;
620
621 u32 reserved4;
622 u32 reserved5;
623
624 u8 data[0];
625};
626
627/*
628 * The 8723au has 3 channel groups: 1-3, 4-9, and 10-14
629 */
630struct rtl8723au_idx {
631#ifdef __LITTLE_ENDIAN
632 int a:4;
633 int b:4;
634#else
635 int b:4;
636 int a:4;
637#endif
638} __attribute__((packed));
639
640struct rtl8723au_efuse {
641 __le16 rtl_id;
642 u8 res0[0xe];
643 u8 cck_tx_power_index_A[3]; /* 0x10 */
644 u8 cck_tx_power_index_B[3];
645 u8 ht40_1s_tx_power_index_A[3]; /* 0x16 */
646 u8 ht40_1s_tx_power_index_B[3];
647 /*
648 * The following entries are half-bytes split as:
649 * bits 0-3: path A, bits 4-7: path B, all values 4 bits signed
650 */
651 struct rtl8723au_idx ht20_tx_power_index_diff[3];
652 struct rtl8723au_idx ofdm_tx_power_index_diff[3];
653 struct rtl8723au_idx ht40_max_power_offset[3];
654 struct rtl8723au_idx ht20_max_power_offset[3];
655 u8 channel_plan; /* 0x28 */
656 u8 tssi_a;
657 u8 thermal_meter;
658 u8 rf_regulatory;
659 u8 rf_option_2;
660 u8 rf_option_3;
661 u8 rf_option_4;
662 u8 res7;
663 u8 version /* 0x30 */;
664 u8 customer_id_major;
665 u8 customer_id_minor;
666 u8 xtal_k;
667 u8 chipset; /* 0x34 */
668 u8 res8[0x82];
669 u8 vid; /* 0xb7 */
670 u8 res9;
671 u8 pid; /* 0xb9 */
672 u8 res10[0x0c];
673 u8 mac_addr[ETH_ALEN]; /* 0xc6 */
674 u8 res11[2];
675 u8 vendor_name[7];
676 u8 res12[2];
677 u8 device_name[0x29]; /* 0xd7 */
678};
679
680struct rtl8192cu_efuse {
681 __le16 rtl_id;
682 __le16 hpon;
683 u8 res0[2];
684 __le16 clk;
685 __le16 testr;
686 __le16 vid;
687 __le16 did;
688 __le16 svid;
689 __le16 smid; /* 0x10 */
690 u8 res1[4];
691 u8 mac_addr[ETH_ALEN]; /* 0x16 */
692 u8 res2[2];
693 u8 vendor_name[7];
694 u8 res3[3];
695 u8 device_name[0x14]; /* 0x28 */
696 u8 res4[0x1e]; /* 0x3c */
697 u8 cck_tx_power_index_A[3]; /* 0x5a */
698 u8 cck_tx_power_index_B[3];
699 u8 ht40_1s_tx_power_index_A[3]; /* 0x60 */
700 u8 ht40_1s_tx_power_index_B[3];
701 /*
702 * The following entries are half-bytes split as:
703 * bits 0-3: path A, bits 4-7: path B, all values 4 bits signed
704 */
705 struct rtl8723au_idx ht40_2s_tx_power_index_diff[3];
706 struct rtl8723au_idx ht20_tx_power_index_diff[3]; /* 0x69 */
707 struct rtl8723au_idx ofdm_tx_power_index_diff[3];
708 struct rtl8723au_idx ht40_max_power_offset[3]; /* 0x6f */
709 struct rtl8723au_idx ht20_max_power_offset[3];
710 u8 channel_plan; /* 0x75 */
711 u8 tssi_a;
712 u8 tssi_b;
713 u8 thermal_meter; /* xtal_k */ /* 0x78 */
714 u8 rf_regulatory;
715 u8 rf_option_2;
716 u8 rf_option_3;
717 u8 rf_option_4;
718 u8 res5[1]; /* 0x7d */
719 u8 version;
720 u8 customer_id;
721};
722
Jes Sorensen3be26992016-02-29 17:05:22 -0500723struct rtl8723bu_pwr_idx {
724#ifdef __LITTLE_ENDIAN
725 int ht20:4;
726 int ht40:4;
727 int ofdm:4;
728 int cck:4;
729#else
730 int cck:4;
731 int ofdm:4;
732 int ht40:4;
733 int ht20:4;
734#endif
735} __attribute__((packed));
736
Jes Sorensen4a0d7db2016-02-29 17:05:18 -0500737struct rtl8723bu_efuse_tx_power {
738 u8 cck_base[6];
739 u8 ht40_base[5];
740 struct rtl8723au_idx ht20_ofdm_1s_diff;
Jes Sorensen3be26992016-02-29 17:05:22 -0500741 struct rtl8723bu_pwr_idx pwr_diff[3];
Jes Sorensen4a0d7db2016-02-29 17:05:18 -0500742 u8 dummy5g[24]; /* max channel group (14) + power diff offset (10) */
743};
744
Jes Sorensen3c836d62016-02-29 17:04:11 -0500745struct rtl8723bu_efuse {
746 __le16 rtl_id;
747 u8 res0[0x0e];
Jes Sorensen4a0d7db2016-02-29 17:05:18 -0500748 struct rtl8723bu_efuse_tx_power tx_power_index_A; /* 0x10 */
749 struct rtl8723bu_efuse_tx_power tx_power_index_B; /* 0x3a */
750 struct rtl8723bu_efuse_tx_power tx_power_index_C; /* 0x64 */
751 struct rtl8723bu_efuse_tx_power tx_power_index_D; /* 0x8e */
Jes Sorensen3c836d62016-02-29 17:04:11 -0500752 u8 channel_plan; /* 0xb8 */
753 u8 xtal_k;
754 u8 thermal_meter;
755 u8 iqk_lck;
756 u8 pa_type; /* 0xbc */
757 u8 lna_type_2g; /* 0xbd */
758 u8 res2[3];
759 u8 rf_board_option;
760 u8 rf_feature_option;
761 u8 rf_bt_setting;
762 u8 eeprom_version;
763 u8 eeprom_customer_id;
764 u8 res3[2];
765 u8 tx_pwr_calibrate_rate;
766 u8 rf_antenna_option; /* 0xc9 */
767 u8 rfe_option;
768 u8 res4[9];
769 u8 usb_optional_function;
770 u8 res5[0x1e];
771 u8 res6[2];
772 u8 serial[0x0b]; /* 0xf5 */
773 u8 vid; /* 0x100 */
774 u8 res7;
775 u8 pid;
776 u8 res8[4];
777 u8 mac_addr[ETH_ALEN]; /* 0x107 */
778 u8 res9[2];
779 u8 vendor_name[0x07];
780 u8 res10[2];
Jes Sorensen22a31d42016-02-29 17:04:15 -0500781 u8 device_name[0x14];
782 u8 res11[0xcf];
783 u8 package_type; /* 0x1fb */
784 u8 res12[0x4];
Jes Sorensen3c836d62016-02-29 17:04:11 -0500785};
786
Jakub Sitnickie6f9a9c2016-02-29 17:04:39 -0500787struct rtl8192eu_efuse_tx_power {
788 u8 cck_base[6];
789 u8 ht40_base[5];
790 struct rtl8723au_idx ht20_ofdm_1s_diff;
791 struct rtl8723au_idx ht40_ht20_2s_diff;
792 struct rtl8723au_idx ofdm_cck_2s_diff; /* not used */
793 struct rtl8723au_idx ht40_ht20_3s_diff;
794 struct rtl8723au_idx ofdm_cck_3s_diff; /* not used */
795 struct rtl8723au_idx ht40_ht20_4s_diff;
796 struct rtl8723au_idx ofdm_cck_4s_diff; /* not used */
797};
798
Jes Sorensen3307d842016-02-29 17:03:59 -0500799struct rtl8192eu_efuse {
800 __le16 rtl_id;
801 u8 res0[0x0e];
Jakub Sitnickie6f9a9c2016-02-29 17:04:39 -0500802 struct rtl8192eu_efuse_tx_power tx_power_index_A; /* 0x10 */
803 struct rtl8192eu_efuse_tx_power tx_power_index_B; /* 0x22 */
804 struct rtl8192eu_efuse_tx_power tx_power_index_C; /* 0x34 */
805 struct rtl8192eu_efuse_tx_power tx_power_index_D; /* 0x46 */
806 u8 res1[0x60];
Jes Sorensen3307d842016-02-29 17:03:59 -0500807 u8 channel_plan; /* 0xb8 */
808 u8 xtal_k;
809 u8 thermal_meter;
810 u8 iqk_lck;
811 u8 pa_type; /* 0xbc */
812 u8 lna_type_2g; /* 0xbd */
813 u8 res2[1];
814 u8 lna_type_5g; /* 0xbf */
815 u8 res13[1];
816 u8 rf_board_option;
817 u8 rf_feature_option;
818 u8 rf_bt_setting;
819 u8 eeprom_version;
820 u8 eeprom_customer_id;
821 u8 res3[3];
822 u8 rf_antenna_option; /* 0xc9 */
823 u8 res4[6];
824 u8 vid; /* 0xd0 */
825 u8 res5[1];
826 u8 pid; /* 0xd2 */
827 u8 res6[1];
828 u8 usb_optional_function;
829 u8 res7[2];
830 u8 mac_addr[ETH_ALEN]; /* 0xd7 */
831 u8 res8[2];
832 u8 vendor_name[7];
833 u8 res9[2];
834 u8 device_name[0x0b]; /* 0xe8 */
835 u8 res10[2];
836 u8 serial[0x0b]; /* 0xf5 */
837 u8 res11[0x30];
838 u8 unknown[0x0d]; /* 0x130 */
839 u8 res12[0xc3];
840};
841
Jes Sorensen26f1fad2015-10-14 20:44:51 -0400842struct rtl8xxxu_reg8val {
843 u16 reg;
844 u8 val;
845};
846
847struct rtl8xxxu_reg32val {
848 u16 reg;
849 u32 val;
850};
851
852struct rtl8xxxu_rfregval {
853 u8 reg;
854 u32 val;
855};
856
857enum rtl8xxxu_rfpath {
858 RF_A = 0,
859 RF_B = 1,
860};
861
862struct rtl8xxxu_rfregs {
863 u16 hssiparm1;
864 u16 hssiparm2;
865 u16 lssiparm;
866 u16 hspiread;
867 u16 lssiread;
868 u16 rf_sw_ctrl;
869};
870
871#define H2C_MAX_MBOX 4
872#define H2C_EXT BIT(7)
Jes Sorensen26f1fad2015-10-14 20:44:51 -0400873#define H2C_JOIN_BSS_DISCONNECT 0
874#define H2C_JOIN_BSS_CONNECT 1
Jes Sorensend940c242016-02-29 17:04:22 -0500875
876/*
877 * H2C (firmware) commands differ between the older generation chips
878 * 8188[cr]u, 819[12]cu, and 8723au, and the more recent chips 8723bu,
879 * 8192[de]u, 8192eu, and 8812.
880 */
881enum h2c_cmd_8723a {
882 H2C_SET_POWER_MODE = 1,
883 H2C_JOIN_BSS_REPORT = 2,
884 H2C_SET_RSSI = 5,
885 H2C_SET_RATE_MASK = (6 | H2C_EXT),
886};
887
888enum h2c_cmd_8723b {
889 /*
890 * Common Class: 000
891 */
892 H2C_8723B_RSVD_PAGE = 0x00,
893 H2C_8723B_MEDIA_STATUS_RPT = 0x01,
894 H2C_8723B_SCAN_ENABLE = 0x02,
895 H2C_8723B_KEEP_ALIVE = 0x03,
896 H2C_8723B_DISCON_DECISION = 0x04,
897 H2C_8723B_PSD_OFFLOAD = 0x05,
898 H2C_8723B_AP_OFFLOAD = 0x08,
899 H2C_8723B_BCN_RSVDPAGE = 0x09,
900 H2C_8723B_PROBERSP_RSVDPAGE = 0x0A,
901 H2C_8723B_FCS_RSVDPAGE = 0x10,
902 H2C_8723B_FCS_INFO = 0x11,
903 H2C_8723B_AP_WOW_GPIO_CTRL = 0x13,
904
905 /*
906 * PoweSave Class: 001
907 */
908 H2C_8723B_SET_PWR_MODE = 0x20,
909 H2C_8723B_PS_TUNING_PARA = 0x21,
910 H2C_8723B_PS_TUNING_PARA2 = 0x22,
911 H2C_8723B_P2P_LPS_PARAM = 0x23,
912 H2C_8723B_P2P_PS_OFFLOAD = 0x24,
913 H2C_8723B_PS_SCAN_ENABLE = 0x25,
914 H2C_8723B_SAP_PS_ = 0x26,
915 H2C_8723B_INACTIVE_PS_ = 0x27,
916 H2C_8723B_FWLPS_IN_IPS_ = 0x28,
917
918 /*
919 * Dynamic Mechanism Class: 010
920 */
Jes Sorensen80b30b22016-02-29 17:05:37 -0500921 H2C_8723B_MACID_CFG_RAID = 0x40,
Jes Sorensend940c242016-02-29 17:04:22 -0500922 H2C_8723B_TXBF = 0x41,
923 H2C_8723B_RSSI_SETTING = 0x42,
924 H2C_8723B_AP_REQ_TXRPT = 0x43,
925 H2C_8723B_INIT_RATE_COLLECT = 0x44,
926
927 /*
928 * BT Class: 011
929 */
930 H2C_8723B_B_TYPE_TDMA = 0x60,
931 H2C_8723B_BT_INFO = 0x61,
932 H2C_8723B_FORCE_BT_TXPWR = 0x62,
933 H2C_8723B_BT_IGNORE_WLANACT = 0x63,
934 H2C_8723B_DAC_SWING_VALUE = 0x64,
935 H2C_8723B_ANT_SEL_RSV = 0x65,
936 H2C_8723B_WL_OPMODE = 0x66,
937 H2C_8723B_BT_MP_OPER = 0x67,
938 H2C_8723B_BT_CONTROL = 0x68,
939 H2C_8723B_BT_WIFI_CTRL = 0x69,
Jes Sorensenf37e9222016-02-29 17:04:41 -0500940 H2C_8723B_BT_FW_PATCH = 0x6a,
941 H2C_8723B_BT_WLAN_CALIBRATION = 0x6d,
942 H2C_8723B_BT_GRANT = 0x6e,
Jes Sorensend940c242016-02-29 17:04:22 -0500943
944 /*
945 * WOWLAN Class: 100
946 */
947 H2C_8723B_WOWLAN = 0x80,
948 H2C_8723B_REMOTE_WAKE_CTRL = 0x81,
949 H2C_8723B_AOAC_GLOBAL_INFO = 0x82,
950 H2C_8723B_AOAC_RSVD_PAGE = 0x83,
951 H2C_8723B_AOAC_RSVD_PAGE2 = 0x84,
952 H2C_8723B_D0_SCAN_OFFLOAD_CTRL = 0x85,
953 H2C_8723B_D0_SCAN_OFFLOAD_INFO = 0x86,
954 H2C_8723B_CHNL_SWITCH_OFFLOAD = 0x87,
955
956 H2C_8723B_RESET_TSF = 0xC0,
957};
958
Jes Sorensen26f1fad2015-10-14 20:44:51 -0400959
960struct h2c_cmd {
961 union {
962 struct {
963 u8 cmd;
Jes Sorensened35d092016-02-29 17:04:19 -0500964 u8 data[7];
Jes Sorensen26f1fad2015-10-14 20:44:51 -0400965 } __packed cmd;
966 struct {
967 __le32 data;
968 __le16 ext;
969 } __packed raw;
970 struct {
Jes Sorensened35d092016-02-29 17:04:19 -0500971 __le32 data;
972 __le32 ext;
973 } __packed raw_wide;
974 struct {
Jes Sorensen26f1fad2015-10-14 20:44:51 -0400975 u8 cmd;
976 u8 data;
Jes Sorensen26f1fad2015-10-14 20:44:51 -0400977 } __packed joinbss;
978 struct {
979 u8 cmd;
980 __le16 mask_hi;
981 u8 arg;
982 __le16 mask_lo;
983 } __packed ramask;
Jes Sorensenc7a5a192016-02-29 17:04:30 -0500984 struct {
985 u8 cmd;
Jes Sorensen7d794ea2016-02-29 17:05:39 -0500986 u8 parm;
987 u8 macid;
988 u8 macid_end;
989 } __packed media_status_rpt;
990 struct {
991 u8 cmd;
Jes Sorensenf653e692016-02-29 17:05:38 -0500992 u8 macid;
993 /*
994 * [0:4] - RAID
995 * [7] - SGI
996 */
Jes Sorensen3ca7b322016-02-29 17:04:43 -0500997 u8 data1;
Jes Sorensenf653e692016-02-29 17:05:38 -0500998 /*
999 * [0:1] - Bandwidth
1000 * [3] - No Update
1001 * [4:5] - VHT enable
1002 * [6] - DISPT
1003 * [7] - DISRA
1004 */
Jes Sorensen3ca7b322016-02-29 17:04:43 -05001005 u8 data2;
Jes Sorensenf653e692016-02-29 17:05:38 -05001006 u8 ramask0;
Jes Sorensen80b30b22016-02-29 17:05:37 -05001007 u8 ramask1;
1008 u8 ramask2;
1009 u8 ramask3;
Jes Sorensen80b30b22016-02-29 17:05:37 -05001010 } __packed b_macid_cfg;
1011 struct {
1012 u8 cmd;
1013 u8 data1;
1014 u8 data2;
Jes Sorensen3ca7b322016-02-29 17:04:43 -05001015 u8 data3;
1016 u8 data4;
1017 u8 data5;
1018 } __packed b_type_dma;
1019 struct {
1020 u8 cmd;
Jes Sorensen6b9eae02016-02-29 17:04:50 -05001021 u8 data;
1022 } __packed bt_info;
1023 struct {
1024 u8 cmd;
Jes Sorensen394f1bd2016-02-29 17:04:49 -05001025 u8 operreq;
1026 u8 opcode;
1027 u8 data;
1028 u8 addr;
1029 } __packed bt_mp_oper;
1030 struct {
1031 u8 cmd;
Jes Sorensenc7a5a192016-02-29 17:04:30 -05001032 u8 data;
1033 } __packed bt_wlan_calibration;
Jes Sorensenf37e9222016-02-29 17:04:41 -05001034 struct {
1035 u8 cmd;
Jes Sorensen7297f492016-02-29 17:04:44 -05001036 u8 data;
1037 } __packed ignore_wlan;
1038 struct {
1039 u8 cmd;
Jes Sorensenf37e9222016-02-29 17:04:41 -05001040 u8 ant_inverse;
1041 u8 int_switch_type;
1042 } __packed ant_sel_rsv;
1043 struct {
1044 u8 cmd;
1045 u8 data;
1046 } __packed bt_grant;
Jes Sorensen26f1fad2015-10-14 20:44:51 -04001047 };
1048};
1049
Jes Sorensenb2b43b72016-02-29 17:04:48 -05001050enum c2h_evt_8723b {
1051 C2H_8723B_DEBUG = 0,
1052 C2H_8723B_TSF = 1,
1053 C2H_8723B_AP_RPT_RSP = 2,
1054 C2H_8723B_CCX_TX_RPT = 3,
1055 C2H_8723B_BT_RSSI = 4,
1056 C2H_8723B_BT_OP_MODE = 5,
1057 C2H_8723B_EXT_RA_RPT = 6,
1058 C2H_8723B_BT_INFO = 9,
Jes Sorensen394f1bd2016-02-29 17:04:49 -05001059 C2H_8723B_HW_INFO_EXCH = 0x0a,
1060 C2H_8723B_BT_MP_INFO = 0x0b,
Jes Sorensen55a18dd2016-02-29 17:05:41 -05001061 C2H_8723B_RA_REPORT = 0x0c,
Jes Sorensenb2b43b72016-02-29 17:04:48 -05001062 C2H_8723B_FW_DEBUG = 0xff,
1063};
1064
1065enum bt_info_src_8723b {
1066 BT_INFO_SRC_8723B_WIFI_FW = 0x0,
1067 BT_INFO_SRC_8723B_BT_RSP = 0x1,
1068 BT_INFO_SRC_8723B_BT_ACTIVE_SEND = 0x2,
1069};
1070
Jes Sorensen394f1bd2016-02-29 17:04:49 -05001071enum bt_mp_oper_opcode_8723b {
1072 BT_MP_OP_GET_BT_VERSION = 0x00,
1073 BT_MP_OP_RESET = 0x01,
1074 BT_MP_OP_TEST_CTRL = 0x02,
1075 BT_MP_OP_SET_BT_MODE = 0x03,
1076 BT_MP_OP_SET_CHNL_TX_GAIN = 0x04,
1077 BT_MP_OP_SET_PKT_TYPE_LEN = 0x05,
1078 BT_MP_OP_SET_PKT_CNT_L_PL_TYPE = 0x06,
1079 BT_MP_OP_SET_PKT_CNT_H_PKT_INTV = 0x07,
1080 BT_MP_OP_SET_PKT_HEADER = 0x08,
1081 BT_MP_OP_SET_WHITENCOEFF = 0x09,
1082 BT_MP_OP_SET_BD_ADDR_L = 0x0a,
1083 BT_MP_OP_SET_BD_ADDR_H = 0x0b,
1084 BT_MP_OP_WRITE_REG_ADDR = 0x0c,
1085 BT_MP_OP_WRITE_REG_VALUE = 0x0d,
1086 BT_MP_OP_GET_BT_STATUS = 0x0e,
1087 BT_MP_OP_GET_BD_ADDR_L = 0x0f,
1088 BT_MP_OP_GET_BD_ADDR_H = 0x10,
1089 BT_MP_OP_READ_REG = 0x11,
1090 BT_MP_OP_SET_TARGET_BD_ADDR_L = 0x12,
1091 BT_MP_OP_SET_TARGET_BD_ADDR_H = 0x13,
1092 BT_MP_OP_SET_TX_POWER_CALIBRATION = 0x14,
1093 BT_MP_OP_GET_RX_PKT_CNT_L = 0x15,
1094 BT_MP_OP_GET_RX_PKT_CNT_H = 0x16,
1095 BT_MP_OP_GET_RX_ERROR_BITS_L = 0x17,
1096 BT_MP_OP_GET_RX_ERROR_BITS_H = 0x18,
1097 BT_MP_OP_GET_RSSI = 0x19,
1098 BT_MP_OP_GET_CFO_HDR_QUALITY_L = 0x1a,
1099 BT_MP_OP_GET_CFO_HDR_QUALITY_H = 0x1b,
1100 BT_MP_OP_GET_TARGET_BD_ADDR_L = 0x1c,
1101 BT_MP_OP_GET_TARGET_BD_ADDR_H = 0x1d,
1102 BT_MP_OP_GET_AFH_MAP_L = 0x1e,
1103 BT_MP_OP_GET_AFH_MAP_M = 0x1f,
1104 BT_MP_OP_GET_AFH_MAP_H = 0x20,
1105 BT_MP_OP_GET_AFH_STATUS = 0x21,
1106 BT_MP_OP_SET_TRACKING_INTERVAL = 0x22,
1107 BT_MP_OP_SET_THERMAL_METER = 0x23,
1108 BT_MP_OP_ENABLE_CFO_TRACKING = 0x24,
1109};
1110
Jes Sorensenb2b43b72016-02-29 17:04:48 -05001111struct rtl8723bu_c2h {
1112 u8 id;
1113 u8 seq;
1114 union {
1115 struct {
1116 u8 payload[0];
1117 } __packed raw;
1118 struct {
Jes Sorensen394f1bd2016-02-29 17:04:49 -05001119 u8 ext_id;
1120 u8 status:4;
1121 u8 retlen:4;
1122 u8 opcode_ver:4;
1123 u8 req_num:4;
1124 u8 payload[2];
1125 } __packed bt_mp_info;
1126 struct {
Jes Sorensenb2b43b72016-02-29 17:04:48 -05001127 u8 response_source:4;
1128 u8 dummy0_0:4;
1129
1130 u8 bt_info;
1131
1132 u8 retry_count:4;
1133 u8 dummy2_0:1;
1134 u8 bt_page:1;
1135 u8 tx_rx_mask:1;
1136 u8 dummy2_2:1;
1137
1138 u8 rssi;
1139
1140 u8 basic_rate:1;
1141 u8 bt_has_reset:1;
1142 u8 dummy4_1:1;;
1143 u8 ignore_wlan:1;
1144 u8 auto_report:1;
1145 u8 dummy4_2:3;
1146
1147 u8 a4;
1148 u8 a5;
1149 } __packed bt_info;
Jes Sorensen55a18dd2016-02-29 17:05:41 -05001150 struct {
1151 u8 rate:7;
1152 u8 dummy0_0:1;
1153 u8 macid;
1154 u8 ldpc:1;
1155 u8 txbf:1;
1156 u8 noisy_state:1;
1157 u8 dummy2_0:5;
1158 u8 dummy3_0;
1159 } __packed ra_report;
Jes Sorensenb2b43b72016-02-29 17:04:48 -05001160 };
1161};
1162
Jes Sorensen26f1fad2015-10-14 20:44:51 -04001163struct rtl8xxxu_fileops;
1164
1165struct rtl8xxxu_priv {
1166 struct ieee80211_hw *hw;
1167 struct usb_device *udev;
1168 struct rtl8xxxu_fileops *fops;
1169
1170 spinlock_t tx_urb_lock;
1171 struct list_head tx_urb_free_list;
1172 int tx_urb_free_count;
1173 bool tx_stopped;
1174
1175 spinlock_t rx_urb_lock;
1176 struct list_head rx_urb_pending_list;
1177 int rx_urb_pending_count;
1178 bool shutdown;
1179 struct work_struct rx_urb_wq;
1180
1181 u8 mac_addr[ETH_ALEN];
1182 char chip_name[8];
Jes Sorensen0e5d4352016-02-29 17:04:00 -05001183 char chip_vendor[8];
Jes Sorensen21db9972016-02-29 17:05:21 -05001184 u8 cck_tx_power_index_A[RTL8XXXU_MAX_CHANNEL_GROUPS];
1185 u8 cck_tx_power_index_B[RTL8XXXU_MAX_CHANNEL_GROUPS];
1186 u8 ht40_1s_tx_power_index_A[RTL8XXXU_MAX_CHANNEL_GROUPS];
1187 u8 ht40_1s_tx_power_index_B[RTL8XXXU_MAX_CHANNEL_GROUPS];
Jes Sorensen26f1fad2015-10-14 20:44:51 -04001188 /*
1189 * The following entries are half-bytes split as:
1190 * bits 0-3: path A, bits 4-7: path B, all values 4 bits signed
1191 */
Jes Sorensen21db9972016-02-29 17:05:21 -05001192 struct rtl8723au_idx ht40_2s_tx_power_index_diff[
Jes Sorensen3be26992016-02-29 17:05:22 -05001193 RTL8723A_CHANNEL_GROUPS];
1194 struct rtl8723au_idx ht20_tx_power_index_diff[RTL8723A_CHANNEL_GROUPS];
1195 struct rtl8723au_idx ofdm_tx_power_index_diff[RTL8723A_CHANNEL_GROUPS];
1196 struct rtl8723au_idx ht40_max_power_offset[RTL8723A_CHANNEL_GROUPS];
1197 struct rtl8723au_idx ht20_max_power_offset[RTL8723A_CHANNEL_GROUPS];
1198 /*
1199 * Newer generation chips only keep power diffs per TX count,
1200 * not per channel group.
1201 */
1202 struct rtl8723au_idx ofdm_tx_power_diff[RTL8723B_TX_COUNT];
1203 struct rtl8723au_idx ht20_tx_power_diff[RTL8723B_TX_COUNT];
1204 struct rtl8723au_idx ht40_tx_power_diff[RTL8723B_TX_COUNT];
Jes Sorensen26f1fad2015-10-14 20:44:51 -04001205 u32 chip_cut:4;
1206 u32 rom_rev:4;
Jakub Sitnicki38451992016-02-03 13:39:49 -05001207 u32 is_multi_func:1;
Jes Sorensen26f1fad2015-10-14 20:44:51 -04001208 u32 has_wifi:1;
1209 u32 has_bluetooth:1;
1210 u32 enable_bluetooth:1;
1211 u32 has_gps:1;
1212 u32 hi_pa:1;
1213 u32 vendor_umc:1;
Jes Sorensen0e5d4352016-02-29 17:04:00 -05001214 u32 vendor_smic:1;
Jes Sorensen26f1fad2015-10-14 20:44:51 -04001215 u32 has_polarity_ctrl:1;
1216 u32 has_eeprom:1;
1217 u32 boot_eeprom:1;
Jes Sorensen0e28b972016-02-29 17:04:13 -05001218 u32 usb_interrupts:1;
Jes Sorensen26f1fad2015-10-14 20:44:51 -04001219 u32 ep_tx_high_queue:1;
1220 u32 ep_tx_normal_queue:1;
1221 u32 ep_tx_low_queue:1;
Jes Sorensen4ef22eb2016-02-29 17:04:55 -05001222 u32 has_xtalk:1;
1223 u8 xtalk;
Jes Sorensen26f1fad2015-10-14 20:44:51 -04001224 unsigned int pipe_interrupt;
1225 unsigned int pipe_in;
1226 unsigned int pipe_out[TXDESC_QUEUE_MAX];
1227 u8 out_ep[RTL8XXXU_OUT_ENDPOINTS];
Jes Sorensen26f1fad2015-10-14 20:44:51 -04001228 u8 ep_tx_count;
1229 u8 rf_paths;
1230 u8 rx_paths;
1231 u8 tx_paths;
1232 u32 rf_mode_ag[2];
1233 u32 rege94;
1234 u32 rege9c;
1235 u32 regeb4;
1236 u32 regebc;
1237 int next_mbox;
1238 int nr_out_eps;
1239
1240 struct mutex h2c_mutex;
1241
1242 struct usb_anchor rx_anchor;
1243 struct usb_anchor tx_anchor;
1244 struct usb_anchor int_anchor;
1245 struct rtl8xxxu_firmware_header *fw_data;
1246 size_t fw_size;
1247 struct mutex usb_buf_mutex;
1248 union {
1249 __le32 val32;
1250 __le16 val16;
1251 u8 val8;
1252 } usb_buf;
1253 union {
Jes Sorensen3307d842016-02-29 17:03:59 -05001254 u8 raw[EFUSE_MAP_LEN];
Jes Sorensen26f1fad2015-10-14 20:44:51 -04001255 struct rtl8723au_efuse efuse8723;
Jes Sorensen3c836d62016-02-29 17:04:11 -05001256 struct rtl8723bu_efuse efuse8723bu;
Jes Sorensen26f1fad2015-10-14 20:44:51 -04001257 struct rtl8192cu_efuse efuse8192;
Jes Sorensen3307d842016-02-29 17:03:59 -05001258 struct rtl8192eu_efuse efuse8192eu;
Jes Sorensen26f1fad2015-10-14 20:44:51 -04001259 } efuse_wifi;
1260 u32 adda_backup[RTL8XXXU_ADDA_REGS];
1261 u32 mac_backup[RTL8XXXU_MAC_REGS];
1262 u32 bb_backup[RTL8XXXU_BB_REGS];
1263 u32 bb_recovery_backup[RTL8XXXU_BB_REGS];
Jes Sorensenba17d822016-03-31 17:08:39 -04001264 enum rtl8xxxu_rtl_chip rtl_chip;
Jes Sorensen26f1fad2015-10-14 20:44:51 -04001265 u8 pi_enabled:1;
Jes Sorensen26f1fad2015-10-14 20:44:51 -04001266 u8 int_buf[USB_INTR_CONTENT_LENGTH];
1267};
1268
1269struct rtl8xxxu_rx_urb {
1270 struct urb urb;
1271 struct ieee80211_hw *hw;
1272 struct list_head list;
1273};
1274
1275struct rtl8xxxu_tx_urb {
1276 struct urb urb;
1277 struct ieee80211_hw *hw;
1278 struct list_head list;
1279};
1280
1281struct rtl8xxxu_fileops {
1282 int (*parse_efuse) (struct rtl8xxxu_priv *priv);
1283 int (*load_firmware) (struct rtl8xxxu_priv *priv);
1284 int (*power_on) (struct rtl8xxxu_priv *priv);
Jes Sorensenfe37d5f2016-02-29 17:05:47 -05001285 void (*power_off) (struct rtl8xxxu_priv *priv);
Jes Sorensen7d4ccb82016-02-29 17:05:50 -05001286 void (*reset_8051) (struct rtl8xxxu_priv *priv);
Jes Sorensen74b99be2016-02-29 17:04:04 -05001287 int (*llt_init) (struct rtl8xxxu_priv *priv, u8 last_tx_page);
Jes Sorensenf0d9f5e2016-02-29 17:04:16 -05001288 void (*phy_init_antenna_selection) (struct rtl8xxxu_priv *priv);
Jes Sorensene1547c52016-02-29 17:04:35 -05001289 void (*phy_iq_calibrate) (struct rtl8xxxu_priv *priv);
Jes Sorensenc3f95062016-02-29 17:04:40 -05001290 void (*config_channel) (struct ieee80211_hw *hw);
Jes Sorensenb18cdfd2016-02-29 17:04:47 -05001291 int (*parse_rx_desc) (struct rtl8xxxu_priv *priv, struct sk_buff *skb,
1292 struct ieee80211_rx_status *rx_status);
Jes Sorensen3e88ca42016-02-29 17:05:08 -05001293 void (*init_aggregation) (struct rtl8xxxu_priv *priv);
Jes Sorensen9c79bf92016-02-29 17:05:10 -05001294 void (*init_statistics) (struct rtl8xxxu_priv *priv);
Jes Sorensendb08de92016-02-29 17:05:17 -05001295 void (*enable_rf) (struct rtl8xxxu_priv *priv);
Jes Sorensenfc89a412016-02-29 17:05:46 -05001296 void (*disable_rf) (struct rtl8xxxu_priv *priv);
Jes Sorensene796dab2016-02-29 17:05:19 -05001297 void (*set_tx_power) (struct rtl8xxxu_priv *priv, int channel,
1298 bool ht40);
Jes Sorensenf653e692016-02-29 17:05:38 -05001299 void (*update_rate_mask) (struct rtl8xxxu_priv *priv,
1300 u32 ramask, int sgi);
Jes Sorensen7d794ea2016-02-29 17:05:39 -05001301 void (*report_connect) (struct rtl8xxxu_priv *priv,
1302 u8 macid, bool connect);
Jes Sorensen26f1fad2015-10-14 20:44:51 -04001303 int writeN_block_size;
Jes Sorensened35d092016-02-29 17:04:19 -05001304 u16 mbox_ext_reg;
1305 char mbox_ext_width;
Jes Sorensen179e1742016-02-29 17:05:27 -05001306 char tx_desc_size;
Jes Sorensen0d698de2016-02-29 17:04:36 -05001307 char has_s0s1;
Jes Sorensen8634af52016-02-29 17:04:33 -05001308 u32 adda_1t_init;
1309 u32 adda_1t_path_on;
1310 u32 adda_2t_path_on_a;
1311 u32 adda_2t_path_on_b;
Jes Sorensenc606e662016-04-07 14:19:16 -04001312 struct rtl8xxxu_reg8val *mactable;
Jes Sorensen26f1fad2015-10-14 20:44:51 -04001313};