blob: bf424db90901a2b1303e3ea55f992e0599add743 [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
45/* (HPQ + LPQ + NPQ + PUBQ) = TX_TOTAL_PAGE_NUM */
46#define TX_PAGE_NUM_PUBQ 0xe7
47#define TX_PAGE_NUM_HI_PQ 0x0c
48#define TX_PAGE_NUM_LO_PQ 0x02
49#define TX_PAGE_NUM_NORM_PQ 0x02
50
51#define RTL_FW_PAGE_SIZE 4096
52#define RTL8XXXU_FIRMWARE_POLL_MAX 1000
53
54#define RTL8723A_CHANNEL_GROUPS 3
55#define RTL8723A_MAX_RF_PATHS 2
56#define RF6052_MAX_TX_PWR 0x3f
57
Jes Sorensen3307d842016-02-29 17:03:59 -050058#define EFUSE_MAP_LEN 512
59#define EFUSE_MAX_SECTION_8723A 64
Jes Sorensen26f1fad2015-10-14 20:44:51 -040060#define EFUSE_REAL_CONTENT_LEN_8723A 512
61#define EFUSE_BT_MAP_LEN_8723A 1024
62#define EFUSE_MAX_WORD_UNIT 4
63
64struct rtl8xxxu_rx_desc {
65#ifdef __LITTLE_ENDIAN
66 u32 pktlen:14;
67 u32 crc32:1;
68 u32 icverr:1;
69 u32 drvinfo_sz:4;
70 u32 security:3;
71 u32 qos:1;
72 u32 shift:2;
73 u32 phy_stats:1;
74 u32 swdec:1;
75 u32 ls:1;
76 u32 fs:1;
77 u32 eor:1;
78 u32 own:1;
79
80 u32 macid:5;
81 u32 tid:4;
82 u32 hwrsvd:4;
83 u32 amsdu:1;
84 u32 paggr:1;
85 u32 faggr:1;
86 u32 a1fit:4;
87 u32 a2fit:4;
88 u32 pam:1;
89 u32 pwr:1;
90 u32 md:1;
91 u32 mf:1;
92 u32 type:2;
93 u32 mc:1;
94 u32 bc:1;
95
96 u32 seq:12;
97 u32 frag:4;
98 u32 nextpktlen:14;
99 u32 nextind:1;
100 u32 reserved0:1;
101
102 u32 rxmcs:6;
103 u32 rxht:1;
104 u32 gf:1;
105 u32 splcp:1;
106 u32 bw:1;
107 u32 htc:1;
108 u32 eosp:1;
109 u32 bssidfit:2;
110 u32 reserved1:16;
111 u32 unicastwake:1;
112 u32 magicwake:1;
113
114 u32 pattern0match:1;
115 u32 pattern1match:1;
116 u32 pattern2match:1;
117 u32 pattern3match:1;
118 u32 pattern4match:1;
119 u32 pattern5match:1;
120 u32 pattern6match:1;
121 u32 pattern7match:1;
122 u32 pattern8match:1;
123 u32 pattern9match:1;
124 u32 patternamatch:1;
125 u32 patternbmatch:1;
126 u32 patterncmatch:1;
127 u32 reserved2:19;
128#else
129 u32 own:1;
130 u32 eor:1;
131 u32 fs:1;
132 u32 ls:1;
133 u32 swdec:1;
134 u32 phy_stats:1;
135 u32 shift:2;
136 u32 qos:1;
137 u32 security:3;
138 u32 drvinfo_sz:4;
139 u32 icverr:1;
140 u32 crc32:1;
141 u32 pktlen:14;
142
143 u32 bc:1;
144 u32 mc:1;
145 u32 type:2;
146 u32 mf:1;
147 u32 md:1;
148 u32 pwr:1;
149 u32 pam:1;
150 u32 a2fit:4;
151 u32 a1fit:4;
152 u32 faggr:1;
153 u32 paggr:1;
154 u32 amsdu:1;
155 u32 hwrsvd:4;
156 u32 tid:4;
157 u32 macid:5;
158
159 u32 reserved0:1;
160 u32 nextind:1;
161 u32 nextpktlen:14;
162 u32 frag:4;
163 u32 seq:12;
164
165 u32 magicwake:1;
166 u32 unicastwake:1;
167 u32 reserved1:16;
168 u32 bssidfit:2;
169 u32 eosp:1;
170 u32 htc:1;
171 u32 bw:1;
172 u32 splcp:1;
173 u32 gf:1;
174 u32 rxht:1;
175 u32 rxmcs:6;
176
177 u32 reserved2:19;
178 u32 patterncmatch:1;
179 u32 patternbmatch:1;
180 u32 patternamatch:1;
181 u32 pattern9match:1;
182 u32 pattern8match:1;
183 u32 pattern7match:1;
184 u32 pattern6match:1;
185 u32 pattern5match:1;
186 u32 pattern4match:1;
187 u32 pattern3match:1;
188 u32 pattern2match:1;
189 u32 pattern1match:1;
190 u32 pattern0match:1;
191#endif
192 __le32 tsfl;
193#if 0
194 u32 bassn:12;
195 u32 bavld:1;
196 u32 reserved3:19;
197#endif
198};
199
200struct rtl8xxxu_tx_desc {
201 __le16 pkt_size;
202 u8 pkt_offset;
203 u8 txdw0;
204 __le32 txdw1;
205 __le32 txdw2;
206 __le32 txdw3;
207 __le32 txdw4;
208 __le32 txdw5;
209 __le32 txdw6;
210 __le16 csum;
211 __le16 txdw7;
212};
213
214/* CCK Rates, TxHT = 0 */
215#define DESC_RATE_1M 0x00
216#define DESC_RATE_2M 0x01
217#define DESC_RATE_5_5M 0x02
218#define DESC_RATE_11M 0x03
219
220/* OFDM Rates, TxHT = 0 */
221#define DESC_RATE_6M 0x04
222#define DESC_RATE_9M 0x05
223#define DESC_RATE_12M 0x06
224#define DESC_RATE_18M 0x07
225#define DESC_RATE_24M 0x08
226#define DESC_RATE_36M 0x09
227#define DESC_RATE_48M 0x0a
228#define DESC_RATE_54M 0x0b
229
230/* MCS Rates, TxHT = 1 */
231#define DESC_RATE_MCS0 0x0c
232#define DESC_RATE_MCS1 0x0d
233#define DESC_RATE_MCS2 0x0e
234#define DESC_RATE_MCS3 0x0f
235#define DESC_RATE_MCS4 0x10
236#define DESC_RATE_MCS5 0x11
237#define DESC_RATE_MCS6 0x12
238#define DESC_RATE_MCS7 0x13
239#define DESC_RATE_MCS8 0x14
240#define DESC_RATE_MCS9 0x15
241#define DESC_RATE_MCS10 0x16
242#define DESC_RATE_MCS11 0x17
243#define DESC_RATE_MCS12 0x18
244#define DESC_RATE_MCS13 0x19
245#define DESC_RATE_MCS14 0x1a
246#define DESC_RATE_MCS15 0x1b
247#define DESC_RATE_MCS15_SG 0x1c
248#define DESC_RATE_MCS32 0x20
249
250#define TXDESC_OFFSET_SZ 0
251#define TXDESC_OFFSET_SHT 16
252#if 0
253#define TXDESC_BMC BIT(24)
254#define TXDESC_LSG BIT(26)
255#define TXDESC_FSG BIT(27)
256#define TXDESC_OWN BIT(31)
257#else
258#define TXDESC_BROADMULTICAST BIT(0)
259#define TXDESC_LAST_SEGMENT BIT(2)
260#define TXDESC_FIRST_SEGMENT BIT(3)
261#define TXDESC_OWN BIT(7)
262#endif
263
264/* Word 1 */
265#define TXDESC_PKT_OFFSET_SZ 0
266#define TXDESC_AGG_ENABLE BIT(5)
267#define TXDESC_BK BIT(6)
268#define TXDESC_QUEUE_SHIFT 8
269#define TXDESC_QUEUE_MASK 0x1f00
270#define TXDESC_QUEUE_BK 0x2
271#define TXDESC_QUEUE_BE 0x0
272#define TXDESC_QUEUE_VI 0x5
273#define TXDESC_QUEUE_VO 0x7
274#define TXDESC_QUEUE_BEACON 0x10
275#define TXDESC_QUEUE_HIGH 0x11
276#define TXDESC_QUEUE_MGNT 0x12
277#define TXDESC_QUEUE_CMD 0x13
278#define TXDESC_QUEUE_MAX (TXDESC_QUEUE_CMD + 1)
279
280#define DESC_RATE_ID_SHIFT 16
281#define DESC_RATE_ID_MASK 0xf
282#define TXDESC_NAVUSEHDR BIT(20)
283#define TXDESC_SEC_RC4 0x00400000
284#define TXDESC_SEC_AES 0x00c00000
285#define TXDESC_PKT_OFFSET_SHIFT 26
286#define TXDESC_AGG_EN BIT(29)
287#define TXDESC_HWPC BIT(31)
288
289/* Word 2 */
290#define TXDESC_ACK_REPORT BIT(19)
291#define TXDESC_AMPDU_DENSITY_SHIFT 20
292
293/* Word 3 */
294#define TXDESC_SEQ_SHIFT 16
295#define TXDESC_SEQ_MASK 0x0fff0000
296
297/* Word 4 */
298#define TXDESC_QOS BIT(6)
299#define TXDESC_HW_SEQ_ENABLE BIT(7)
300#define TXDESC_USE_DRIVER_RATE BIT(8)
301#define TXDESC_DISABLE_DATA_FB BIT(10)
302#define TXDESC_CTS_SELF_ENABLE BIT(11)
303#define TXDESC_RTS_CTS_ENABLE BIT(12)
304#define TXDESC_HW_RTS_ENABLE BIT(13)
305#define TXDESC_PRIME_CH_OFF_LOWER BIT(20)
306#define TXDESC_PRIME_CH_OFF_UPPER BIT(21)
307#define TXDESC_SHORT_PREAMBLE BIT(24)
308#define TXDESC_DATA_BW BIT(25)
309#define TXDESC_RTS_DATA_BW BIT(27)
310#define TXDESC_RTS_PRIME_CH_OFF_LOWER BIT(28)
311#define TXDESC_RTS_PRIME_CH_OFF_UPPER BIT(29)
312
313/* Word 5 */
314#define TXDESC_RTS_RATE_SHIFT 0
315#define TXDESC_RTS_RATE_MASK 0x3f
316#define TXDESC_SHORT_GI BIT(6)
317#define TXDESC_CCX_TAG BIT(7)
318#define TXDESC_RETRY_LIMIT_ENABLE BIT(17)
319#define TXDESC_RETRY_LIMIT_SHIFT 18
320#define TXDESC_RETRY_LIMIT_MASK 0x00fc0000
321
322/* Word 6 */
323#define TXDESC_MAX_AGG_SHIFT 11
324
325struct phy_rx_agc_info {
326#ifdef __LITTLE_ENDIAN
327 u8 gain:7, trsw:1;
328#else
329 u8 trsw:1, gain:7;
330#endif
331};
332
333struct rtl8723au_phy_stats {
334 struct phy_rx_agc_info path_agc[RTL8723A_MAX_RF_PATHS];
335 u8 ch_corr[RTL8723A_MAX_RF_PATHS];
336 u8 cck_sig_qual_ofdm_pwdb_all;
337 u8 cck_agc_rpt_ofdm_cfosho_a;
338 u8 cck_rpt_b_ofdm_cfosho_b;
339 u8 reserved_1;
340 u8 noise_power_db_msb;
341 u8 path_cfotail[RTL8723A_MAX_RF_PATHS];
342 u8 pcts_mask[RTL8723A_MAX_RF_PATHS];
343 s8 stream_rxevm[RTL8723A_MAX_RF_PATHS];
344 u8 path_rxsnr[RTL8723A_MAX_RF_PATHS];
345 u8 noise_power_db_lsb;
346 u8 reserved_2[3];
347 u8 stream_csi[RTL8723A_MAX_RF_PATHS];
348 u8 stream_target_csi[RTL8723A_MAX_RF_PATHS];
349 s8 sig_evm;
350 u8 reserved_3;
351
352#ifdef __LITTLE_ENDIAN
353 u8 antsel_rx_keep_2:1; /* ex_intf_flg:1; */
354 u8 sgi_en:1;
355 u8 rxsc:2;
356 u8 idle_long:1;
357 u8 r_ant_train_en:1;
358 u8 antenna_select_b:1;
359 u8 antenna_select:1;
360#else /* _BIG_ENDIAN_ */
361 u8 antenna_select:1;
362 u8 antenna_select_b:1;
363 u8 r_ant_train_en:1;
364 u8 idle_long:1;
365 u8 rxsc:2;
366 u8 sgi_en:1;
367 u8 antsel_rx_keep_2:1; /* ex_intf_flg:1; */
368#endif
369};
370
371/*
372 * Regs to backup
373 */
374#define RTL8XXXU_ADDA_REGS 16
375#define RTL8XXXU_MAC_REGS 4
376#define RTL8XXXU_BB_REGS 9
377
378struct rtl8xxxu_firmware_header {
379 __le16 signature; /* 92C0: test chip; 92C,
380 88C0: test chip;
381 88C1: MP A-cut;
382 92C1: MP A-cut */
383 u8 category; /* AP/NIC and USB/PCI */
384 u8 function;
385
386 __le16 major_version; /* FW Version */
387 u8 minor_version; /* FW Subversion, default 0x00 */
388 u8 reserved1;
389
390 u8 month; /* Release time Month field */
391 u8 date; /* Release time Date field */
392 u8 hour; /* Release time Hour field */
393 u8 minute; /* Release time Minute field */
394
395 __le16 ramcodesize; /* Size of RAM code */
396 u16 reserved2;
397
398 __le32 svn_idx; /* SVN entry index */
399 u32 reserved3;
400
401 u32 reserved4;
402 u32 reserved5;
403
404 u8 data[0];
405};
406
407/*
408 * The 8723au has 3 channel groups: 1-3, 4-9, and 10-14
409 */
410struct rtl8723au_idx {
411#ifdef __LITTLE_ENDIAN
412 int a:4;
413 int b:4;
414#else
415 int b:4;
416 int a:4;
417#endif
418} __attribute__((packed));
419
420struct rtl8723au_efuse {
421 __le16 rtl_id;
422 u8 res0[0xe];
423 u8 cck_tx_power_index_A[3]; /* 0x10 */
424 u8 cck_tx_power_index_B[3];
425 u8 ht40_1s_tx_power_index_A[3]; /* 0x16 */
426 u8 ht40_1s_tx_power_index_B[3];
427 /*
428 * The following entries are half-bytes split as:
429 * bits 0-3: path A, bits 4-7: path B, all values 4 bits signed
430 */
431 struct rtl8723au_idx ht20_tx_power_index_diff[3];
432 struct rtl8723au_idx ofdm_tx_power_index_diff[3];
433 struct rtl8723au_idx ht40_max_power_offset[3];
434 struct rtl8723au_idx ht20_max_power_offset[3];
435 u8 channel_plan; /* 0x28 */
436 u8 tssi_a;
437 u8 thermal_meter;
438 u8 rf_regulatory;
439 u8 rf_option_2;
440 u8 rf_option_3;
441 u8 rf_option_4;
442 u8 res7;
443 u8 version /* 0x30 */;
444 u8 customer_id_major;
445 u8 customer_id_minor;
446 u8 xtal_k;
447 u8 chipset; /* 0x34 */
448 u8 res8[0x82];
449 u8 vid; /* 0xb7 */
450 u8 res9;
451 u8 pid; /* 0xb9 */
452 u8 res10[0x0c];
453 u8 mac_addr[ETH_ALEN]; /* 0xc6 */
454 u8 res11[2];
455 u8 vendor_name[7];
456 u8 res12[2];
457 u8 device_name[0x29]; /* 0xd7 */
458};
459
460struct rtl8192cu_efuse {
461 __le16 rtl_id;
462 __le16 hpon;
463 u8 res0[2];
464 __le16 clk;
465 __le16 testr;
466 __le16 vid;
467 __le16 did;
468 __le16 svid;
469 __le16 smid; /* 0x10 */
470 u8 res1[4];
471 u8 mac_addr[ETH_ALEN]; /* 0x16 */
472 u8 res2[2];
473 u8 vendor_name[7];
474 u8 res3[3];
475 u8 device_name[0x14]; /* 0x28 */
476 u8 res4[0x1e]; /* 0x3c */
477 u8 cck_tx_power_index_A[3]; /* 0x5a */
478 u8 cck_tx_power_index_B[3];
479 u8 ht40_1s_tx_power_index_A[3]; /* 0x60 */
480 u8 ht40_1s_tx_power_index_B[3];
481 /*
482 * The following entries are half-bytes split as:
483 * bits 0-3: path A, bits 4-7: path B, all values 4 bits signed
484 */
485 struct rtl8723au_idx ht40_2s_tx_power_index_diff[3];
486 struct rtl8723au_idx ht20_tx_power_index_diff[3]; /* 0x69 */
487 struct rtl8723au_idx ofdm_tx_power_index_diff[3];
488 struct rtl8723au_idx ht40_max_power_offset[3]; /* 0x6f */
489 struct rtl8723au_idx ht20_max_power_offset[3];
490 u8 channel_plan; /* 0x75 */
491 u8 tssi_a;
492 u8 tssi_b;
493 u8 thermal_meter; /* xtal_k */ /* 0x78 */
494 u8 rf_regulatory;
495 u8 rf_option_2;
496 u8 rf_option_3;
497 u8 rf_option_4;
498 u8 res5[1]; /* 0x7d */
499 u8 version;
500 u8 customer_id;
501};
502
Jes Sorensen3c836d62016-02-29 17:04:11 -0500503struct rtl8723bu_efuse {
504 __le16 rtl_id;
505 u8 res0[0x0e];
506 u8 cck_tx_power_index_A[3]; /* 0x10 */
507 u8 cck_tx_power_index_B[3];
508 u8 ht40_1s_tx_power_index_A[3]; /* 0x16 */
509 u8 ht40_1s_tx_power_index_B[3];
510 u8 res1[0x9c];
511 u8 channel_plan; /* 0xb8 */
512 u8 xtal_k;
513 u8 thermal_meter;
514 u8 iqk_lck;
515 u8 pa_type; /* 0xbc */
516 u8 lna_type_2g; /* 0xbd */
517 u8 res2[3];
518 u8 rf_board_option;
519 u8 rf_feature_option;
520 u8 rf_bt_setting;
521 u8 eeprom_version;
522 u8 eeprom_customer_id;
523 u8 res3[2];
524 u8 tx_pwr_calibrate_rate;
525 u8 rf_antenna_option; /* 0xc9 */
526 u8 rfe_option;
527 u8 res4[9];
528 u8 usb_optional_function;
529 u8 res5[0x1e];
530 u8 res6[2];
531 u8 serial[0x0b]; /* 0xf5 */
532 u8 vid; /* 0x100 */
533 u8 res7;
534 u8 pid;
535 u8 res8[4];
536 u8 mac_addr[ETH_ALEN]; /* 0x107 */
537 u8 res9[2];
538 u8 vendor_name[0x07];
539 u8 res10[2];
540 u8 device_name[0x14]; /* 0xe8 */
541 u8 res11[0xd4];
542};
543
Jes Sorensen3307d842016-02-29 17:03:59 -0500544struct rtl8192eu_efuse {
545 __le16 rtl_id;
546 u8 res0[0x0e];
547 u8 cck_tx_power_index_A[3]; /* 0x10 */
548 u8 cck_tx_power_index_B[3];
549 u8 ht40_1s_tx_power_index_A[3]; /* 0x16 */
550 u8 ht40_1s_tx_power_index_B[3];
551 u8 res1[0x9c];
552 u8 channel_plan; /* 0xb8 */
553 u8 xtal_k;
554 u8 thermal_meter;
555 u8 iqk_lck;
556 u8 pa_type; /* 0xbc */
557 u8 lna_type_2g; /* 0xbd */
558 u8 res2[1];
559 u8 lna_type_5g; /* 0xbf */
560 u8 res13[1];
561 u8 rf_board_option;
562 u8 rf_feature_option;
563 u8 rf_bt_setting;
564 u8 eeprom_version;
565 u8 eeprom_customer_id;
566 u8 res3[3];
567 u8 rf_antenna_option; /* 0xc9 */
568 u8 res4[6];
569 u8 vid; /* 0xd0 */
570 u8 res5[1];
571 u8 pid; /* 0xd2 */
572 u8 res6[1];
573 u8 usb_optional_function;
574 u8 res7[2];
575 u8 mac_addr[ETH_ALEN]; /* 0xd7 */
576 u8 res8[2];
577 u8 vendor_name[7];
578 u8 res9[2];
579 u8 device_name[0x0b]; /* 0xe8 */
580 u8 res10[2];
581 u8 serial[0x0b]; /* 0xf5 */
582 u8 res11[0x30];
583 u8 unknown[0x0d]; /* 0x130 */
584 u8 res12[0xc3];
585};
586
Jes Sorensen26f1fad2015-10-14 20:44:51 -0400587struct rtl8xxxu_reg8val {
588 u16 reg;
589 u8 val;
590};
591
592struct rtl8xxxu_reg32val {
593 u16 reg;
594 u32 val;
595};
596
597struct rtl8xxxu_rfregval {
598 u8 reg;
599 u32 val;
600};
601
602enum rtl8xxxu_rfpath {
603 RF_A = 0,
604 RF_B = 1,
605};
606
607struct rtl8xxxu_rfregs {
608 u16 hssiparm1;
609 u16 hssiparm2;
610 u16 lssiparm;
611 u16 hspiread;
612 u16 lssiread;
613 u16 rf_sw_ctrl;
614};
615
616#define H2C_MAX_MBOX 4
617#define H2C_EXT BIT(7)
618#define H2C_SET_POWER_MODE 1
619#define H2C_JOIN_BSS_REPORT 2
620#define H2C_JOIN_BSS_DISCONNECT 0
621#define H2C_JOIN_BSS_CONNECT 1
622#define H2C_SET_RSSI 5
623#define H2C_SET_RATE_MASK (6 | H2C_EXT)
624
625struct h2c_cmd {
626 union {
627 struct {
628 u8 cmd;
629 u8 data[5];
630 } __packed cmd;
631 struct {
632 __le32 data;
633 __le16 ext;
634 } __packed raw;
635 struct {
636 u8 cmd;
637 u8 data;
638 u8 pad[4];
639 } __packed joinbss;
640 struct {
641 u8 cmd;
642 __le16 mask_hi;
643 u8 arg;
644 __le16 mask_lo;
645 } __packed ramask;
646 };
647};
648
649struct rtl8xxxu_fileops;
650
651struct rtl8xxxu_priv {
652 struct ieee80211_hw *hw;
653 struct usb_device *udev;
654 struct rtl8xxxu_fileops *fops;
655
656 spinlock_t tx_urb_lock;
657 struct list_head tx_urb_free_list;
658 int tx_urb_free_count;
659 bool tx_stopped;
660
661 spinlock_t rx_urb_lock;
662 struct list_head rx_urb_pending_list;
663 int rx_urb_pending_count;
664 bool shutdown;
665 struct work_struct rx_urb_wq;
666
667 u8 mac_addr[ETH_ALEN];
668 char chip_name[8];
Jes Sorensen0e5d4352016-02-29 17:04:00 -0500669 char chip_vendor[8];
Jes Sorensen26f1fad2015-10-14 20:44:51 -0400670 u8 cck_tx_power_index_A[3]; /* 0x10 */
671 u8 cck_tx_power_index_B[3];
672 u8 ht40_1s_tx_power_index_A[3]; /* 0x16 */
673 u8 ht40_1s_tx_power_index_B[3];
674 /*
675 * The following entries are half-bytes split as:
676 * bits 0-3: path A, bits 4-7: path B, all values 4 bits signed
677 */
678 struct rtl8723au_idx ht40_2s_tx_power_index_diff[3];
679 struct rtl8723au_idx ht20_tx_power_index_diff[3];
680 struct rtl8723au_idx ofdm_tx_power_index_diff[3];
681 struct rtl8723au_idx ht40_max_power_offset[3];
682 struct rtl8723au_idx ht20_max_power_offset[3];
683 u32 chip_cut:4;
684 u32 rom_rev:4;
Jakub Sitnicki38451992016-02-03 13:39:49 -0500685 u32 is_multi_func:1;
Jes Sorensen26f1fad2015-10-14 20:44:51 -0400686 u32 has_wifi:1;
687 u32 has_bluetooth:1;
688 u32 enable_bluetooth:1;
689 u32 has_gps:1;
690 u32 hi_pa:1;
691 u32 vendor_umc:1;
Jes Sorensen0e5d4352016-02-29 17:04:00 -0500692 u32 vendor_smic:1;
Jes Sorensen26f1fad2015-10-14 20:44:51 -0400693 u32 has_polarity_ctrl:1;
694 u32 has_eeprom:1;
695 u32 boot_eeprom:1;
696 u32 ep_tx_high_queue:1;
697 u32 ep_tx_normal_queue:1;
698 u32 ep_tx_low_queue:1;
699 u32 path_a_hi_power:1;
700 u32 path_a_rf_paths:4;
701 unsigned int pipe_interrupt;
702 unsigned int pipe_in;
703 unsigned int pipe_out[TXDESC_QUEUE_MAX];
704 u8 out_ep[RTL8XXXU_OUT_ENDPOINTS];
705 u8 path_a_ig_value;
706 u8 ep_tx_count;
707 u8 rf_paths;
708 u8 rx_paths;
709 u8 tx_paths;
710 u32 rf_mode_ag[2];
711 u32 rege94;
712 u32 rege9c;
713 u32 regeb4;
714 u32 regebc;
715 int next_mbox;
716 int nr_out_eps;
717
718 struct mutex h2c_mutex;
719
720 struct usb_anchor rx_anchor;
721 struct usb_anchor tx_anchor;
722 struct usb_anchor int_anchor;
723 struct rtl8xxxu_firmware_header *fw_data;
724 size_t fw_size;
725 struct mutex usb_buf_mutex;
726 union {
727 __le32 val32;
728 __le16 val16;
729 u8 val8;
730 } usb_buf;
731 union {
Jes Sorensen3307d842016-02-29 17:03:59 -0500732 u8 raw[EFUSE_MAP_LEN];
Jes Sorensen26f1fad2015-10-14 20:44:51 -0400733 struct rtl8723au_efuse efuse8723;
Jes Sorensen3c836d62016-02-29 17:04:11 -0500734 struct rtl8723bu_efuse efuse8723bu;
Jes Sorensen26f1fad2015-10-14 20:44:51 -0400735 struct rtl8192cu_efuse efuse8192;
Jes Sorensen3307d842016-02-29 17:03:59 -0500736 struct rtl8192eu_efuse efuse8192eu;
Jes Sorensen26f1fad2015-10-14 20:44:51 -0400737 } efuse_wifi;
738 u32 adda_backup[RTL8XXXU_ADDA_REGS];
739 u32 mac_backup[RTL8XXXU_MAC_REGS];
740 u32 bb_backup[RTL8XXXU_BB_REGS];
741 u32 bb_recovery_backup[RTL8XXXU_BB_REGS];
742 u32 rtlchip;
743 u8 pi_enabled:1;
Jes Sorensen26f1fad2015-10-14 20:44:51 -0400744 u8 int_buf[USB_INTR_CONTENT_LENGTH];
745};
746
747struct rtl8xxxu_rx_urb {
748 struct urb urb;
749 struct ieee80211_hw *hw;
750 struct list_head list;
751};
752
753struct rtl8xxxu_tx_urb {
754 struct urb urb;
755 struct ieee80211_hw *hw;
756 struct list_head list;
757};
758
759struct rtl8xxxu_fileops {
760 int (*parse_efuse) (struct rtl8xxxu_priv *priv);
761 int (*load_firmware) (struct rtl8xxxu_priv *priv);
762 int (*power_on) (struct rtl8xxxu_priv *priv);
Jes Sorensen74b99be2016-02-29 17:04:04 -0500763 int (*llt_init) (struct rtl8xxxu_priv *priv, u8 last_tx_page);
Jes Sorensen26f1fad2015-10-14 20:44:51 -0400764 int writeN_block_size;
765};