Jes Sorensen | 26f1fad | 2015-10-14 20:44:51 -0400 | [diff] [blame] | 1 | /* |
| 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 Sorensen | 35a741f | 2016-02-29 17:04:10 -0500 | [diff] [blame] | 37 | #define RTL8XXXU_OUT_ENDPOINTS 4 |
Jes Sorensen | 26f1fad | 2015-10-14 20:44:51 -0400 | [diff] [blame] | 38 | |
| 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 |
Jes Sorensen | 21db997 | 2016-02-29 17:05:21 -0500 | [diff] [blame] | 56 | #define RTL8723B_CHANNEL_GROUPS 6 |
Jes Sorensen | 3be2699 | 2016-02-29 17:05:22 -0500 | [diff] [blame] | 57 | #define RTL8723B_TX_COUNT 4 |
Jes Sorensen | 4a0d7db | 2016-02-29 17:05:18 -0500 | [diff] [blame] | 58 | #define RTL8723B_MAX_RF_PATHS 4 |
Jes Sorensen | 21db997 | 2016-02-29 17:05:21 -0500 | [diff] [blame] | 59 | #define RTL8XXXU_MAX_CHANNEL_GROUPS 6 |
Jes Sorensen | 26f1fad | 2015-10-14 20:44:51 -0400 | [diff] [blame] | 60 | #define RF6052_MAX_TX_PWR 0x3f |
| 61 | |
Jes Sorensen | 3307d84 | 2016-02-29 17:03:59 -0500 | [diff] [blame] | 62 | #define EFUSE_MAP_LEN 512 |
| 63 | #define EFUSE_MAX_SECTION_8723A 64 |
Jes Sorensen | 26f1fad | 2015-10-14 20:44:51 -0400 | [diff] [blame] | 64 | #define EFUSE_REAL_CONTENT_LEN_8723A 512 |
| 65 | #define EFUSE_BT_MAP_LEN_8723A 1024 |
| 66 | #define EFUSE_MAX_WORD_UNIT 4 |
| 67 | |
Jes Sorensen | b18cdfd | 2016-02-29 17:04:47 -0500 | [diff] [blame] | 68 | enum rtl8xxxu_rx_type { |
| 69 | RX_TYPE_DATA_PKT = 0, |
| 70 | RX_TYPE_C2H = 1, |
| 71 | RX_TYPE_ERROR = -1 |
| 72 | }; |
| 73 | |
Jes Sorensen | 26f1fad | 2015-10-14 20:44:51 -0400 | [diff] [blame] | 74 | struct rtl8xxxu_rx_desc { |
| 75 | #ifdef __LITTLE_ENDIAN |
| 76 | u32 pktlen:14; |
| 77 | u32 crc32:1; |
| 78 | u32 icverr:1; |
| 79 | u32 drvinfo_sz:4; |
| 80 | u32 security:3; |
| 81 | u32 qos:1; |
| 82 | u32 shift:2; |
| 83 | u32 phy_stats:1; |
| 84 | u32 swdec:1; |
| 85 | u32 ls:1; |
| 86 | u32 fs:1; |
| 87 | u32 eor:1; |
| 88 | u32 own:1; |
| 89 | |
| 90 | u32 macid:5; |
| 91 | u32 tid:4; |
| 92 | u32 hwrsvd:4; |
| 93 | u32 amsdu:1; |
| 94 | u32 paggr:1; |
| 95 | u32 faggr:1; |
| 96 | u32 a1fit:4; |
| 97 | u32 a2fit:4; |
| 98 | u32 pam:1; |
| 99 | u32 pwr:1; |
| 100 | u32 md:1; |
| 101 | u32 mf:1; |
| 102 | u32 type:2; |
| 103 | u32 mc:1; |
| 104 | u32 bc:1; |
| 105 | |
| 106 | u32 seq:12; |
| 107 | u32 frag:4; |
| 108 | u32 nextpktlen:14; |
| 109 | u32 nextind:1; |
| 110 | u32 reserved0:1; |
| 111 | |
| 112 | u32 rxmcs:6; |
| 113 | u32 rxht:1; |
| 114 | u32 gf:1; |
| 115 | u32 splcp:1; |
| 116 | u32 bw:1; |
| 117 | u32 htc:1; |
| 118 | u32 eosp:1; |
| 119 | u32 bssidfit:2; |
| 120 | u32 reserved1:16; |
| 121 | u32 unicastwake:1; |
| 122 | u32 magicwake:1; |
| 123 | |
| 124 | u32 pattern0match:1; |
| 125 | u32 pattern1match:1; |
| 126 | u32 pattern2match:1; |
| 127 | u32 pattern3match:1; |
| 128 | u32 pattern4match:1; |
| 129 | u32 pattern5match:1; |
| 130 | u32 pattern6match:1; |
| 131 | u32 pattern7match:1; |
| 132 | u32 pattern8match:1; |
| 133 | u32 pattern9match:1; |
| 134 | u32 patternamatch:1; |
| 135 | u32 patternbmatch:1; |
| 136 | u32 patterncmatch:1; |
| 137 | u32 reserved2:19; |
| 138 | #else |
| 139 | u32 own:1; |
| 140 | u32 eor:1; |
| 141 | u32 fs:1; |
| 142 | u32 ls:1; |
| 143 | u32 swdec:1; |
| 144 | u32 phy_stats:1; |
| 145 | u32 shift:2; |
| 146 | u32 qos:1; |
| 147 | u32 security:3; |
| 148 | u32 drvinfo_sz:4; |
| 149 | u32 icverr:1; |
| 150 | u32 crc32:1; |
| 151 | u32 pktlen:14; |
| 152 | |
| 153 | u32 bc:1; |
| 154 | u32 mc:1; |
| 155 | u32 type:2; |
| 156 | u32 mf:1; |
| 157 | u32 md:1; |
| 158 | u32 pwr:1; |
| 159 | u32 pam:1; |
| 160 | u32 a2fit:4; |
| 161 | u32 a1fit:4; |
| 162 | u32 faggr:1; |
| 163 | u32 paggr:1; |
| 164 | u32 amsdu:1; |
| 165 | u32 hwrsvd:4; |
| 166 | u32 tid:4; |
| 167 | u32 macid:5; |
| 168 | |
| 169 | u32 reserved0:1; |
| 170 | u32 nextind:1; |
| 171 | u32 nextpktlen:14; |
| 172 | u32 frag:4; |
| 173 | u32 seq:12; |
| 174 | |
| 175 | u32 magicwake:1; |
| 176 | u32 unicastwake:1; |
| 177 | u32 reserved1:16; |
| 178 | u32 bssidfit:2; |
| 179 | u32 eosp:1; |
| 180 | u32 htc:1; |
| 181 | u32 bw:1; |
| 182 | u32 splcp:1; |
| 183 | u32 gf:1; |
| 184 | u32 rxht:1; |
| 185 | u32 rxmcs:6; |
| 186 | |
| 187 | u32 reserved2:19; |
| 188 | u32 patterncmatch:1; |
| 189 | u32 patternbmatch:1; |
| 190 | u32 patternamatch:1; |
| 191 | u32 pattern9match:1; |
| 192 | u32 pattern8match:1; |
| 193 | u32 pattern7match:1; |
| 194 | u32 pattern6match:1; |
| 195 | u32 pattern5match:1; |
| 196 | u32 pattern4match:1; |
| 197 | u32 pattern3match:1; |
| 198 | u32 pattern2match:1; |
| 199 | u32 pattern1match:1; |
| 200 | u32 pattern0match:1; |
| 201 | #endif |
| 202 | __le32 tsfl; |
| 203 | #if 0 |
| 204 | u32 bassn:12; |
| 205 | u32 bavld:1; |
| 206 | u32 reserved3:19; |
| 207 | #endif |
| 208 | }; |
| 209 | |
Jes Sorensen | a6c80d2 | 2016-02-29 17:04:46 -0500 | [diff] [blame] | 210 | struct rtl8723bu_rx_desc { |
| 211 | #ifdef __LITTLE_ENDIAN |
| 212 | u32 pktlen:14; |
| 213 | u32 crc32:1; |
| 214 | u32 icverr:1; |
| 215 | u32 drvinfo_sz:4; |
| 216 | u32 security:3; |
| 217 | u32 qos:1; |
| 218 | u32 shift:2; |
| 219 | u32 phy_stats:1; |
| 220 | u32 swdec:1; |
| 221 | u32 ls:1; |
| 222 | u32 fs:1; |
| 223 | u32 eor:1; |
| 224 | u32 own:1; |
| 225 | |
| 226 | u32 macid:7; |
| 227 | u32 dummy1_0:1; |
| 228 | u32 tid:4; |
| 229 | u32 dummy1_1:1; |
| 230 | u32 amsdu:1; |
| 231 | u32 rxid_match:1; |
| 232 | u32 paggr:1; |
| 233 | u32 a1fit:4; /* 16 */ |
| 234 | u32 chkerr:1; |
| 235 | u32 ipver:1; |
| 236 | u32 tcpudp:1; |
| 237 | u32 chkvld:1; |
| 238 | u32 pam:1; |
| 239 | u32 pwr:1; |
| 240 | u32 more_data:1; |
| 241 | u32 more_frag:1; |
| 242 | u32 type:2; |
| 243 | u32 mc:1; |
| 244 | u32 bc:1; |
| 245 | |
| 246 | u32 seq:12; |
| 247 | u32 frag:4; |
| 248 | u32 rx_is_qos:1; /* 16 */ |
| 249 | u32 dummy2_0:1; |
| 250 | u32 wlanhd_iv_len:6; |
| 251 | u32 dummy2_1:4; |
| 252 | u32 rpt_sel:1; |
| 253 | u32 dummy2_2:3; |
| 254 | |
| 255 | u32 rxmcs:7; |
| 256 | u32 dummy3_0:3; |
| 257 | u32 htc:1; |
| 258 | u32 eosp:1; |
| 259 | u32 bssidfit:2; |
| 260 | u32 dummy3_1:2; |
| 261 | u32 usb_agg_pktnum:8; /* 16 */ |
| 262 | u32 dummy3_2:5; |
| 263 | u32 pattern_match:1; |
| 264 | u32 unicast_match:1; |
| 265 | u32 magic_match:1; |
| 266 | |
| 267 | u32 splcp:1; |
| 268 | u32 ldcp:1; |
| 269 | u32 stbc:1; |
| 270 | u32 dummy4_0:1; |
| 271 | u32 bw:2; |
| 272 | u32 dummy4_1:26; |
| 273 | #else |
| 274 | u32 own:1; |
| 275 | u32 eor:1; |
| 276 | u32 fs:1; |
| 277 | u32 ls:1; |
| 278 | u32 swdec:1; |
| 279 | u32 phy_stats:1; |
| 280 | u32 shift:2; |
| 281 | u32 qos:1; |
| 282 | u32 security:3; |
| 283 | u32 drvinfo_sz:4; |
| 284 | u32 icverr:1; |
| 285 | u32 crc32:1; |
| 286 | u32 pktlen:14; |
| 287 | |
| 288 | u32 bc:1; |
| 289 | u32 mc:1; |
| 290 | u32 type:2; |
| 291 | u32 mf:1; |
| 292 | u32 md:1; |
| 293 | u32 pwr:1; |
| 294 | u32 pam:1; |
| 295 | u32 a2fit:4; |
| 296 | u32 a1fit:4; |
| 297 | u32 faggr:1; |
| 298 | u32 paggr:1; |
| 299 | u32 amsdu:1; |
| 300 | u32 hwrsvd:4; |
| 301 | u32 tid:4; |
| 302 | u32 macid:5; |
| 303 | |
| 304 | u32 dummy2_2:3; |
| 305 | u32 rpt_sel:1; |
| 306 | u32 dummy2_1:4; |
| 307 | u32 wlanhd_iv_len:6; |
| 308 | u32 dummy2_0:1; |
| 309 | u32 rx_is_qos:1; |
| 310 | u32 frag:4; /* 16 */ |
| 311 | u32 seq:12; |
| 312 | |
| 313 | u32 magic_match:1; |
| 314 | u32 unicast_match:1; |
| 315 | u32 pattern_match:1; |
| 316 | u32 dummy3_2:5; |
| 317 | u32 usb_agg_pktnum:8; |
| 318 | u32 dummy3_1:2; /* 16 */ |
| 319 | u32 bssidfit:2; |
| 320 | u32 eosp:1; |
| 321 | u32 htc:1; |
| 322 | u32 dummy3_0:3; |
| 323 | u32 rxmcs:7; |
| 324 | |
| 325 | u32 dumm4_1:26; |
| 326 | u32 bw:2; |
| 327 | u32 dummy4_0:1; |
| 328 | u32 stbc:1; |
| 329 | u32 ldcp:1; |
| 330 | u32 splcp:1; |
| 331 | #endif |
| 332 | __le32 tsfl; |
| 333 | }; |
| 334 | |
Jes Sorensen | 179e174 | 2016-02-29 17:05:27 -0500 | [diff] [blame^] | 335 | struct rtl8723au_tx_desc { |
Jes Sorensen | 26f1fad | 2015-10-14 20:44:51 -0400 | [diff] [blame] | 336 | __le16 pkt_size; |
| 337 | u8 pkt_offset; |
| 338 | u8 txdw0; |
| 339 | __le32 txdw1; |
| 340 | __le32 txdw2; |
| 341 | __le32 txdw3; |
| 342 | __le32 txdw4; |
| 343 | __le32 txdw5; |
| 344 | __le32 txdw6; |
| 345 | __le16 csum; |
| 346 | __le16 txdw7; |
| 347 | }; |
| 348 | |
Jes Sorensen | 80491a1 | 2016-02-29 17:05:26 -0500 | [diff] [blame] | 349 | struct rtl8723bu_tx_desc { |
| 350 | __le16 pkt_size; |
| 351 | u8 pkt_offset; |
| 352 | u8 txdw0; |
| 353 | __le32 txdw1; |
| 354 | __le32 txdw2; |
| 355 | __le32 txdw3; |
| 356 | __le32 txdw4; |
| 357 | __le32 txdw5; |
| 358 | __le32 txdw6; |
| 359 | __le16 csum; |
| 360 | __le16 txdw7; |
| 361 | __le32 txdw8; |
| 362 | __le32 txdw9; |
| 363 | }; |
| 364 | |
Jes Sorensen | 26f1fad | 2015-10-14 20:44:51 -0400 | [diff] [blame] | 365 | /* CCK Rates, TxHT = 0 */ |
| 366 | #define DESC_RATE_1M 0x00 |
| 367 | #define DESC_RATE_2M 0x01 |
| 368 | #define DESC_RATE_5_5M 0x02 |
| 369 | #define DESC_RATE_11M 0x03 |
| 370 | |
| 371 | /* OFDM Rates, TxHT = 0 */ |
| 372 | #define DESC_RATE_6M 0x04 |
| 373 | #define DESC_RATE_9M 0x05 |
| 374 | #define DESC_RATE_12M 0x06 |
| 375 | #define DESC_RATE_18M 0x07 |
| 376 | #define DESC_RATE_24M 0x08 |
| 377 | #define DESC_RATE_36M 0x09 |
| 378 | #define DESC_RATE_48M 0x0a |
| 379 | #define DESC_RATE_54M 0x0b |
| 380 | |
| 381 | /* MCS Rates, TxHT = 1 */ |
| 382 | #define DESC_RATE_MCS0 0x0c |
| 383 | #define DESC_RATE_MCS1 0x0d |
| 384 | #define DESC_RATE_MCS2 0x0e |
| 385 | #define DESC_RATE_MCS3 0x0f |
| 386 | #define DESC_RATE_MCS4 0x10 |
| 387 | #define DESC_RATE_MCS5 0x11 |
| 388 | #define DESC_RATE_MCS6 0x12 |
| 389 | #define DESC_RATE_MCS7 0x13 |
| 390 | #define DESC_RATE_MCS8 0x14 |
| 391 | #define DESC_RATE_MCS9 0x15 |
| 392 | #define DESC_RATE_MCS10 0x16 |
| 393 | #define DESC_RATE_MCS11 0x17 |
| 394 | #define DESC_RATE_MCS12 0x18 |
| 395 | #define DESC_RATE_MCS13 0x19 |
| 396 | #define DESC_RATE_MCS14 0x1a |
| 397 | #define DESC_RATE_MCS15 0x1b |
| 398 | #define DESC_RATE_MCS15_SG 0x1c |
| 399 | #define DESC_RATE_MCS32 0x20 |
| 400 | |
| 401 | #define TXDESC_OFFSET_SZ 0 |
| 402 | #define TXDESC_OFFSET_SHT 16 |
| 403 | #if 0 |
| 404 | #define TXDESC_BMC BIT(24) |
| 405 | #define TXDESC_LSG BIT(26) |
| 406 | #define TXDESC_FSG BIT(27) |
| 407 | #define TXDESC_OWN BIT(31) |
| 408 | #else |
| 409 | #define TXDESC_BROADMULTICAST BIT(0) |
| 410 | #define TXDESC_LAST_SEGMENT BIT(2) |
| 411 | #define TXDESC_FIRST_SEGMENT BIT(3) |
| 412 | #define TXDESC_OWN BIT(7) |
| 413 | #endif |
| 414 | |
| 415 | /* Word 1 */ |
| 416 | #define TXDESC_PKT_OFFSET_SZ 0 |
| 417 | #define TXDESC_AGG_ENABLE BIT(5) |
| 418 | #define TXDESC_BK BIT(6) |
| 419 | #define TXDESC_QUEUE_SHIFT 8 |
| 420 | #define TXDESC_QUEUE_MASK 0x1f00 |
| 421 | #define TXDESC_QUEUE_BK 0x2 |
| 422 | #define TXDESC_QUEUE_BE 0x0 |
| 423 | #define TXDESC_QUEUE_VI 0x5 |
| 424 | #define TXDESC_QUEUE_VO 0x7 |
| 425 | #define TXDESC_QUEUE_BEACON 0x10 |
| 426 | #define TXDESC_QUEUE_HIGH 0x11 |
| 427 | #define TXDESC_QUEUE_MGNT 0x12 |
| 428 | #define TXDESC_QUEUE_CMD 0x13 |
| 429 | #define TXDESC_QUEUE_MAX (TXDESC_QUEUE_CMD + 1) |
| 430 | |
| 431 | #define DESC_RATE_ID_SHIFT 16 |
| 432 | #define DESC_RATE_ID_MASK 0xf |
| 433 | #define TXDESC_NAVUSEHDR BIT(20) |
| 434 | #define TXDESC_SEC_RC4 0x00400000 |
| 435 | #define TXDESC_SEC_AES 0x00c00000 |
| 436 | #define TXDESC_PKT_OFFSET_SHIFT 26 |
| 437 | #define TXDESC_AGG_EN BIT(29) |
| 438 | #define TXDESC_HWPC BIT(31) |
| 439 | |
| 440 | /* Word 2 */ |
| 441 | #define TXDESC_ACK_REPORT BIT(19) |
| 442 | #define TXDESC_AMPDU_DENSITY_SHIFT 20 |
| 443 | |
| 444 | /* Word 3 */ |
| 445 | #define TXDESC_SEQ_SHIFT 16 |
| 446 | #define TXDESC_SEQ_MASK 0x0fff0000 |
| 447 | |
| 448 | /* Word 4 */ |
| 449 | #define TXDESC_QOS BIT(6) |
| 450 | #define TXDESC_HW_SEQ_ENABLE BIT(7) |
| 451 | #define TXDESC_USE_DRIVER_RATE BIT(8) |
| 452 | #define TXDESC_DISABLE_DATA_FB BIT(10) |
| 453 | #define TXDESC_CTS_SELF_ENABLE BIT(11) |
| 454 | #define TXDESC_RTS_CTS_ENABLE BIT(12) |
| 455 | #define TXDESC_HW_RTS_ENABLE BIT(13) |
| 456 | #define TXDESC_PRIME_CH_OFF_LOWER BIT(20) |
| 457 | #define TXDESC_PRIME_CH_OFF_UPPER BIT(21) |
| 458 | #define TXDESC_SHORT_PREAMBLE BIT(24) |
| 459 | #define TXDESC_DATA_BW BIT(25) |
| 460 | #define TXDESC_RTS_DATA_BW BIT(27) |
| 461 | #define TXDESC_RTS_PRIME_CH_OFF_LOWER BIT(28) |
| 462 | #define TXDESC_RTS_PRIME_CH_OFF_UPPER BIT(29) |
| 463 | |
| 464 | /* Word 5 */ |
| 465 | #define TXDESC_RTS_RATE_SHIFT 0 |
| 466 | #define TXDESC_RTS_RATE_MASK 0x3f |
| 467 | #define TXDESC_SHORT_GI BIT(6) |
| 468 | #define TXDESC_CCX_TAG BIT(7) |
| 469 | #define TXDESC_RETRY_LIMIT_ENABLE BIT(17) |
| 470 | #define TXDESC_RETRY_LIMIT_SHIFT 18 |
| 471 | #define TXDESC_RETRY_LIMIT_MASK 0x00fc0000 |
| 472 | |
| 473 | /* Word 6 */ |
| 474 | #define TXDESC_MAX_AGG_SHIFT 11 |
| 475 | |
| 476 | struct phy_rx_agc_info { |
| 477 | #ifdef __LITTLE_ENDIAN |
| 478 | u8 gain:7, trsw:1; |
| 479 | #else |
| 480 | u8 trsw:1, gain:7; |
| 481 | #endif |
| 482 | }; |
| 483 | |
| 484 | struct rtl8723au_phy_stats { |
| 485 | struct phy_rx_agc_info path_agc[RTL8723A_MAX_RF_PATHS]; |
| 486 | u8 ch_corr[RTL8723A_MAX_RF_PATHS]; |
| 487 | u8 cck_sig_qual_ofdm_pwdb_all; |
| 488 | u8 cck_agc_rpt_ofdm_cfosho_a; |
| 489 | u8 cck_rpt_b_ofdm_cfosho_b; |
| 490 | u8 reserved_1; |
| 491 | u8 noise_power_db_msb; |
| 492 | u8 path_cfotail[RTL8723A_MAX_RF_PATHS]; |
| 493 | u8 pcts_mask[RTL8723A_MAX_RF_PATHS]; |
| 494 | s8 stream_rxevm[RTL8723A_MAX_RF_PATHS]; |
| 495 | u8 path_rxsnr[RTL8723A_MAX_RF_PATHS]; |
| 496 | u8 noise_power_db_lsb; |
| 497 | u8 reserved_2[3]; |
| 498 | u8 stream_csi[RTL8723A_MAX_RF_PATHS]; |
| 499 | u8 stream_target_csi[RTL8723A_MAX_RF_PATHS]; |
| 500 | s8 sig_evm; |
| 501 | u8 reserved_3; |
| 502 | |
| 503 | #ifdef __LITTLE_ENDIAN |
| 504 | u8 antsel_rx_keep_2:1; /* ex_intf_flg:1; */ |
| 505 | u8 sgi_en:1; |
| 506 | u8 rxsc:2; |
| 507 | u8 idle_long:1; |
| 508 | u8 r_ant_train_en:1; |
| 509 | u8 antenna_select_b:1; |
| 510 | u8 antenna_select:1; |
| 511 | #else /* _BIG_ENDIAN_ */ |
| 512 | u8 antenna_select:1; |
| 513 | u8 antenna_select_b:1; |
| 514 | u8 r_ant_train_en:1; |
| 515 | u8 idle_long:1; |
| 516 | u8 rxsc:2; |
| 517 | u8 sgi_en:1; |
| 518 | u8 antsel_rx_keep_2:1; /* ex_intf_flg:1; */ |
| 519 | #endif |
| 520 | }; |
| 521 | |
| 522 | /* |
| 523 | * Regs to backup |
| 524 | */ |
| 525 | #define RTL8XXXU_ADDA_REGS 16 |
| 526 | #define RTL8XXXU_MAC_REGS 4 |
| 527 | #define RTL8XXXU_BB_REGS 9 |
| 528 | |
| 529 | struct rtl8xxxu_firmware_header { |
| 530 | __le16 signature; /* 92C0: test chip; 92C, |
| 531 | 88C0: test chip; |
| 532 | 88C1: MP A-cut; |
| 533 | 92C1: MP A-cut */ |
| 534 | u8 category; /* AP/NIC and USB/PCI */ |
| 535 | u8 function; |
| 536 | |
| 537 | __le16 major_version; /* FW Version */ |
| 538 | u8 minor_version; /* FW Subversion, default 0x00 */ |
| 539 | u8 reserved1; |
| 540 | |
| 541 | u8 month; /* Release time Month field */ |
| 542 | u8 date; /* Release time Date field */ |
| 543 | u8 hour; /* Release time Hour field */ |
| 544 | u8 minute; /* Release time Minute field */ |
| 545 | |
| 546 | __le16 ramcodesize; /* Size of RAM code */ |
| 547 | u16 reserved2; |
| 548 | |
| 549 | __le32 svn_idx; /* SVN entry index */ |
| 550 | u32 reserved3; |
| 551 | |
| 552 | u32 reserved4; |
| 553 | u32 reserved5; |
| 554 | |
| 555 | u8 data[0]; |
| 556 | }; |
| 557 | |
| 558 | /* |
| 559 | * The 8723au has 3 channel groups: 1-3, 4-9, and 10-14 |
| 560 | */ |
| 561 | struct rtl8723au_idx { |
| 562 | #ifdef __LITTLE_ENDIAN |
| 563 | int a:4; |
| 564 | int b:4; |
| 565 | #else |
| 566 | int b:4; |
| 567 | int a:4; |
| 568 | #endif |
| 569 | } __attribute__((packed)); |
| 570 | |
| 571 | struct rtl8723au_efuse { |
| 572 | __le16 rtl_id; |
| 573 | u8 res0[0xe]; |
| 574 | u8 cck_tx_power_index_A[3]; /* 0x10 */ |
| 575 | u8 cck_tx_power_index_B[3]; |
| 576 | u8 ht40_1s_tx_power_index_A[3]; /* 0x16 */ |
| 577 | u8 ht40_1s_tx_power_index_B[3]; |
| 578 | /* |
| 579 | * The following entries are half-bytes split as: |
| 580 | * bits 0-3: path A, bits 4-7: path B, all values 4 bits signed |
| 581 | */ |
| 582 | struct rtl8723au_idx ht20_tx_power_index_diff[3]; |
| 583 | struct rtl8723au_idx ofdm_tx_power_index_diff[3]; |
| 584 | struct rtl8723au_idx ht40_max_power_offset[3]; |
| 585 | struct rtl8723au_idx ht20_max_power_offset[3]; |
| 586 | u8 channel_plan; /* 0x28 */ |
| 587 | u8 tssi_a; |
| 588 | u8 thermal_meter; |
| 589 | u8 rf_regulatory; |
| 590 | u8 rf_option_2; |
| 591 | u8 rf_option_3; |
| 592 | u8 rf_option_4; |
| 593 | u8 res7; |
| 594 | u8 version /* 0x30 */; |
| 595 | u8 customer_id_major; |
| 596 | u8 customer_id_minor; |
| 597 | u8 xtal_k; |
| 598 | u8 chipset; /* 0x34 */ |
| 599 | u8 res8[0x82]; |
| 600 | u8 vid; /* 0xb7 */ |
| 601 | u8 res9; |
| 602 | u8 pid; /* 0xb9 */ |
| 603 | u8 res10[0x0c]; |
| 604 | u8 mac_addr[ETH_ALEN]; /* 0xc6 */ |
| 605 | u8 res11[2]; |
| 606 | u8 vendor_name[7]; |
| 607 | u8 res12[2]; |
| 608 | u8 device_name[0x29]; /* 0xd7 */ |
| 609 | }; |
| 610 | |
| 611 | struct rtl8192cu_efuse { |
| 612 | __le16 rtl_id; |
| 613 | __le16 hpon; |
| 614 | u8 res0[2]; |
| 615 | __le16 clk; |
| 616 | __le16 testr; |
| 617 | __le16 vid; |
| 618 | __le16 did; |
| 619 | __le16 svid; |
| 620 | __le16 smid; /* 0x10 */ |
| 621 | u8 res1[4]; |
| 622 | u8 mac_addr[ETH_ALEN]; /* 0x16 */ |
| 623 | u8 res2[2]; |
| 624 | u8 vendor_name[7]; |
| 625 | u8 res3[3]; |
| 626 | u8 device_name[0x14]; /* 0x28 */ |
| 627 | u8 res4[0x1e]; /* 0x3c */ |
| 628 | u8 cck_tx_power_index_A[3]; /* 0x5a */ |
| 629 | u8 cck_tx_power_index_B[3]; |
| 630 | u8 ht40_1s_tx_power_index_A[3]; /* 0x60 */ |
| 631 | u8 ht40_1s_tx_power_index_B[3]; |
| 632 | /* |
| 633 | * The following entries are half-bytes split as: |
| 634 | * bits 0-3: path A, bits 4-7: path B, all values 4 bits signed |
| 635 | */ |
| 636 | struct rtl8723au_idx ht40_2s_tx_power_index_diff[3]; |
| 637 | struct rtl8723au_idx ht20_tx_power_index_diff[3]; /* 0x69 */ |
| 638 | struct rtl8723au_idx ofdm_tx_power_index_diff[3]; |
| 639 | struct rtl8723au_idx ht40_max_power_offset[3]; /* 0x6f */ |
| 640 | struct rtl8723au_idx ht20_max_power_offset[3]; |
| 641 | u8 channel_plan; /* 0x75 */ |
| 642 | u8 tssi_a; |
| 643 | u8 tssi_b; |
| 644 | u8 thermal_meter; /* xtal_k */ /* 0x78 */ |
| 645 | u8 rf_regulatory; |
| 646 | u8 rf_option_2; |
| 647 | u8 rf_option_3; |
| 648 | u8 rf_option_4; |
| 649 | u8 res5[1]; /* 0x7d */ |
| 650 | u8 version; |
| 651 | u8 customer_id; |
| 652 | }; |
| 653 | |
Jes Sorensen | 3be2699 | 2016-02-29 17:05:22 -0500 | [diff] [blame] | 654 | struct rtl8723bu_pwr_idx { |
| 655 | #ifdef __LITTLE_ENDIAN |
| 656 | int ht20:4; |
| 657 | int ht40:4; |
| 658 | int ofdm:4; |
| 659 | int cck:4; |
| 660 | #else |
| 661 | int cck:4; |
| 662 | int ofdm:4; |
| 663 | int ht40:4; |
| 664 | int ht20:4; |
| 665 | #endif |
| 666 | } __attribute__((packed)); |
| 667 | |
Jes Sorensen | 4a0d7db | 2016-02-29 17:05:18 -0500 | [diff] [blame] | 668 | struct rtl8723bu_efuse_tx_power { |
| 669 | u8 cck_base[6]; |
| 670 | u8 ht40_base[5]; |
| 671 | struct rtl8723au_idx ht20_ofdm_1s_diff; |
Jes Sorensen | 3be2699 | 2016-02-29 17:05:22 -0500 | [diff] [blame] | 672 | struct rtl8723bu_pwr_idx pwr_diff[3]; |
Jes Sorensen | 4a0d7db | 2016-02-29 17:05:18 -0500 | [diff] [blame] | 673 | u8 dummy5g[24]; /* max channel group (14) + power diff offset (10) */ |
| 674 | }; |
| 675 | |
Jes Sorensen | 3c836d6 | 2016-02-29 17:04:11 -0500 | [diff] [blame] | 676 | struct rtl8723bu_efuse { |
| 677 | __le16 rtl_id; |
| 678 | u8 res0[0x0e]; |
Jes Sorensen | 4a0d7db | 2016-02-29 17:05:18 -0500 | [diff] [blame] | 679 | struct rtl8723bu_efuse_tx_power tx_power_index_A; /* 0x10 */ |
| 680 | struct rtl8723bu_efuse_tx_power tx_power_index_B; /* 0x3a */ |
| 681 | struct rtl8723bu_efuse_tx_power tx_power_index_C; /* 0x64 */ |
| 682 | struct rtl8723bu_efuse_tx_power tx_power_index_D; /* 0x8e */ |
Jes Sorensen | 3c836d6 | 2016-02-29 17:04:11 -0500 | [diff] [blame] | 683 | u8 channel_plan; /* 0xb8 */ |
| 684 | u8 xtal_k; |
| 685 | u8 thermal_meter; |
| 686 | u8 iqk_lck; |
| 687 | u8 pa_type; /* 0xbc */ |
| 688 | u8 lna_type_2g; /* 0xbd */ |
| 689 | u8 res2[3]; |
| 690 | u8 rf_board_option; |
| 691 | u8 rf_feature_option; |
| 692 | u8 rf_bt_setting; |
| 693 | u8 eeprom_version; |
| 694 | u8 eeprom_customer_id; |
| 695 | u8 res3[2]; |
| 696 | u8 tx_pwr_calibrate_rate; |
| 697 | u8 rf_antenna_option; /* 0xc9 */ |
| 698 | u8 rfe_option; |
| 699 | u8 res4[9]; |
| 700 | u8 usb_optional_function; |
| 701 | u8 res5[0x1e]; |
| 702 | u8 res6[2]; |
| 703 | u8 serial[0x0b]; /* 0xf5 */ |
| 704 | u8 vid; /* 0x100 */ |
| 705 | u8 res7; |
| 706 | u8 pid; |
| 707 | u8 res8[4]; |
| 708 | u8 mac_addr[ETH_ALEN]; /* 0x107 */ |
| 709 | u8 res9[2]; |
| 710 | u8 vendor_name[0x07]; |
| 711 | u8 res10[2]; |
Jes Sorensen | 22a31d4 | 2016-02-29 17:04:15 -0500 | [diff] [blame] | 712 | u8 device_name[0x14]; |
| 713 | u8 res11[0xcf]; |
| 714 | u8 package_type; /* 0x1fb */ |
| 715 | u8 res12[0x4]; |
Jes Sorensen | 3c836d6 | 2016-02-29 17:04:11 -0500 | [diff] [blame] | 716 | }; |
| 717 | |
Jakub Sitnicki | e6f9a9c | 2016-02-29 17:04:39 -0500 | [diff] [blame] | 718 | struct rtl8192eu_efuse_tx_power { |
| 719 | u8 cck_base[6]; |
| 720 | u8 ht40_base[5]; |
| 721 | struct rtl8723au_idx ht20_ofdm_1s_diff; |
| 722 | struct rtl8723au_idx ht40_ht20_2s_diff; |
| 723 | struct rtl8723au_idx ofdm_cck_2s_diff; /* not used */ |
| 724 | struct rtl8723au_idx ht40_ht20_3s_diff; |
| 725 | struct rtl8723au_idx ofdm_cck_3s_diff; /* not used */ |
| 726 | struct rtl8723au_idx ht40_ht20_4s_diff; |
| 727 | struct rtl8723au_idx ofdm_cck_4s_diff; /* not used */ |
| 728 | }; |
| 729 | |
Jes Sorensen | 3307d84 | 2016-02-29 17:03:59 -0500 | [diff] [blame] | 730 | struct rtl8192eu_efuse { |
| 731 | __le16 rtl_id; |
| 732 | u8 res0[0x0e]; |
Jakub Sitnicki | e6f9a9c | 2016-02-29 17:04:39 -0500 | [diff] [blame] | 733 | struct rtl8192eu_efuse_tx_power tx_power_index_A; /* 0x10 */ |
| 734 | struct rtl8192eu_efuse_tx_power tx_power_index_B; /* 0x22 */ |
| 735 | struct rtl8192eu_efuse_tx_power tx_power_index_C; /* 0x34 */ |
| 736 | struct rtl8192eu_efuse_tx_power tx_power_index_D; /* 0x46 */ |
| 737 | u8 res1[0x60]; |
Jes Sorensen | 3307d84 | 2016-02-29 17:03:59 -0500 | [diff] [blame] | 738 | u8 channel_plan; /* 0xb8 */ |
| 739 | u8 xtal_k; |
| 740 | u8 thermal_meter; |
| 741 | u8 iqk_lck; |
| 742 | u8 pa_type; /* 0xbc */ |
| 743 | u8 lna_type_2g; /* 0xbd */ |
| 744 | u8 res2[1]; |
| 745 | u8 lna_type_5g; /* 0xbf */ |
| 746 | u8 res13[1]; |
| 747 | u8 rf_board_option; |
| 748 | u8 rf_feature_option; |
| 749 | u8 rf_bt_setting; |
| 750 | u8 eeprom_version; |
| 751 | u8 eeprom_customer_id; |
| 752 | u8 res3[3]; |
| 753 | u8 rf_antenna_option; /* 0xc9 */ |
| 754 | u8 res4[6]; |
| 755 | u8 vid; /* 0xd0 */ |
| 756 | u8 res5[1]; |
| 757 | u8 pid; /* 0xd2 */ |
| 758 | u8 res6[1]; |
| 759 | u8 usb_optional_function; |
| 760 | u8 res7[2]; |
| 761 | u8 mac_addr[ETH_ALEN]; /* 0xd7 */ |
| 762 | u8 res8[2]; |
| 763 | u8 vendor_name[7]; |
| 764 | u8 res9[2]; |
| 765 | u8 device_name[0x0b]; /* 0xe8 */ |
| 766 | u8 res10[2]; |
| 767 | u8 serial[0x0b]; /* 0xf5 */ |
| 768 | u8 res11[0x30]; |
| 769 | u8 unknown[0x0d]; /* 0x130 */ |
| 770 | u8 res12[0xc3]; |
| 771 | }; |
| 772 | |
Jes Sorensen | 26f1fad | 2015-10-14 20:44:51 -0400 | [diff] [blame] | 773 | struct rtl8xxxu_reg8val { |
| 774 | u16 reg; |
| 775 | u8 val; |
| 776 | }; |
| 777 | |
| 778 | struct rtl8xxxu_reg32val { |
| 779 | u16 reg; |
| 780 | u32 val; |
| 781 | }; |
| 782 | |
| 783 | struct rtl8xxxu_rfregval { |
| 784 | u8 reg; |
| 785 | u32 val; |
| 786 | }; |
| 787 | |
| 788 | enum rtl8xxxu_rfpath { |
| 789 | RF_A = 0, |
| 790 | RF_B = 1, |
| 791 | }; |
| 792 | |
| 793 | struct rtl8xxxu_rfregs { |
| 794 | u16 hssiparm1; |
| 795 | u16 hssiparm2; |
| 796 | u16 lssiparm; |
| 797 | u16 hspiread; |
| 798 | u16 lssiread; |
| 799 | u16 rf_sw_ctrl; |
| 800 | }; |
| 801 | |
| 802 | #define H2C_MAX_MBOX 4 |
| 803 | #define H2C_EXT BIT(7) |
Jes Sorensen | 26f1fad | 2015-10-14 20:44:51 -0400 | [diff] [blame] | 804 | #define H2C_JOIN_BSS_DISCONNECT 0 |
| 805 | #define H2C_JOIN_BSS_CONNECT 1 |
Jes Sorensen | d940c24 | 2016-02-29 17:04:22 -0500 | [diff] [blame] | 806 | |
| 807 | /* |
| 808 | * H2C (firmware) commands differ between the older generation chips |
| 809 | * 8188[cr]u, 819[12]cu, and 8723au, and the more recent chips 8723bu, |
| 810 | * 8192[de]u, 8192eu, and 8812. |
| 811 | */ |
| 812 | enum h2c_cmd_8723a { |
| 813 | H2C_SET_POWER_MODE = 1, |
| 814 | H2C_JOIN_BSS_REPORT = 2, |
| 815 | H2C_SET_RSSI = 5, |
| 816 | H2C_SET_RATE_MASK = (6 | H2C_EXT), |
| 817 | }; |
| 818 | |
| 819 | enum h2c_cmd_8723b { |
| 820 | /* |
| 821 | * Common Class: 000 |
| 822 | */ |
| 823 | H2C_8723B_RSVD_PAGE = 0x00, |
| 824 | H2C_8723B_MEDIA_STATUS_RPT = 0x01, |
| 825 | H2C_8723B_SCAN_ENABLE = 0x02, |
| 826 | H2C_8723B_KEEP_ALIVE = 0x03, |
| 827 | H2C_8723B_DISCON_DECISION = 0x04, |
| 828 | H2C_8723B_PSD_OFFLOAD = 0x05, |
| 829 | H2C_8723B_AP_OFFLOAD = 0x08, |
| 830 | H2C_8723B_BCN_RSVDPAGE = 0x09, |
| 831 | H2C_8723B_PROBERSP_RSVDPAGE = 0x0A, |
| 832 | H2C_8723B_FCS_RSVDPAGE = 0x10, |
| 833 | H2C_8723B_FCS_INFO = 0x11, |
| 834 | H2C_8723B_AP_WOW_GPIO_CTRL = 0x13, |
| 835 | |
| 836 | /* |
| 837 | * PoweSave Class: 001 |
| 838 | */ |
| 839 | H2C_8723B_SET_PWR_MODE = 0x20, |
| 840 | H2C_8723B_PS_TUNING_PARA = 0x21, |
| 841 | H2C_8723B_PS_TUNING_PARA2 = 0x22, |
| 842 | H2C_8723B_P2P_LPS_PARAM = 0x23, |
| 843 | H2C_8723B_P2P_PS_OFFLOAD = 0x24, |
| 844 | H2C_8723B_PS_SCAN_ENABLE = 0x25, |
| 845 | H2C_8723B_SAP_PS_ = 0x26, |
| 846 | H2C_8723B_INACTIVE_PS_ = 0x27, |
| 847 | H2C_8723B_FWLPS_IN_IPS_ = 0x28, |
| 848 | |
| 849 | /* |
| 850 | * Dynamic Mechanism Class: 010 |
| 851 | */ |
| 852 | H2C_8723B_MACID_CFG = 0x40, |
| 853 | H2C_8723B_TXBF = 0x41, |
| 854 | H2C_8723B_RSSI_SETTING = 0x42, |
| 855 | H2C_8723B_AP_REQ_TXRPT = 0x43, |
| 856 | H2C_8723B_INIT_RATE_COLLECT = 0x44, |
| 857 | |
| 858 | /* |
| 859 | * BT Class: 011 |
| 860 | */ |
| 861 | H2C_8723B_B_TYPE_TDMA = 0x60, |
| 862 | H2C_8723B_BT_INFO = 0x61, |
| 863 | H2C_8723B_FORCE_BT_TXPWR = 0x62, |
| 864 | H2C_8723B_BT_IGNORE_WLANACT = 0x63, |
| 865 | H2C_8723B_DAC_SWING_VALUE = 0x64, |
| 866 | H2C_8723B_ANT_SEL_RSV = 0x65, |
| 867 | H2C_8723B_WL_OPMODE = 0x66, |
| 868 | H2C_8723B_BT_MP_OPER = 0x67, |
| 869 | H2C_8723B_BT_CONTROL = 0x68, |
| 870 | H2C_8723B_BT_WIFI_CTRL = 0x69, |
Jes Sorensen | f37e922 | 2016-02-29 17:04:41 -0500 | [diff] [blame] | 871 | H2C_8723B_BT_FW_PATCH = 0x6a, |
| 872 | H2C_8723B_BT_WLAN_CALIBRATION = 0x6d, |
| 873 | H2C_8723B_BT_GRANT = 0x6e, |
Jes Sorensen | d940c24 | 2016-02-29 17:04:22 -0500 | [diff] [blame] | 874 | |
| 875 | /* |
| 876 | * WOWLAN Class: 100 |
| 877 | */ |
| 878 | H2C_8723B_WOWLAN = 0x80, |
| 879 | H2C_8723B_REMOTE_WAKE_CTRL = 0x81, |
| 880 | H2C_8723B_AOAC_GLOBAL_INFO = 0x82, |
| 881 | H2C_8723B_AOAC_RSVD_PAGE = 0x83, |
| 882 | H2C_8723B_AOAC_RSVD_PAGE2 = 0x84, |
| 883 | H2C_8723B_D0_SCAN_OFFLOAD_CTRL = 0x85, |
| 884 | H2C_8723B_D0_SCAN_OFFLOAD_INFO = 0x86, |
| 885 | H2C_8723B_CHNL_SWITCH_OFFLOAD = 0x87, |
| 886 | |
| 887 | H2C_8723B_RESET_TSF = 0xC0, |
| 888 | }; |
| 889 | |
Jes Sorensen | 26f1fad | 2015-10-14 20:44:51 -0400 | [diff] [blame] | 890 | |
| 891 | struct h2c_cmd { |
| 892 | union { |
| 893 | struct { |
| 894 | u8 cmd; |
Jes Sorensen | ed35d09 | 2016-02-29 17:04:19 -0500 | [diff] [blame] | 895 | u8 data[7]; |
Jes Sorensen | 26f1fad | 2015-10-14 20:44:51 -0400 | [diff] [blame] | 896 | } __packed cmd; |
| 897 | struct { |
| 898 | __le32 data; |
| 899 | __le16 ext; |
| 900 | } __packed raw; |
| 901 | struct { |
Jes Sorensen | ed35d09 | 2016-02-29 17:04:19 -0500 | [diff] [blame] | 902 | __le32 data; |
| 903 | __le32 ext; |
| 904 | } __packed raw_wide; |
| 905 | struct { |
Jes Sorensen | 26f1fad | 2015-10-14 20:44:51 -0400 | [diff] [blame] | 906 | u8 cmd; |
| 907 | u8 data; |
Jes Sorensen | 26f1fad | 2015-10-14 20:44:51 -0400 | [diff] [blame] | 908 | } __packed joinbss; |
| 909 | struct { |
| 910 | u8 cmd; |
| 911 | __le16 mask_hi; |
| 912 | u8 arg; |
| 913 | __le16 mask_lo; |
| 914 | } __packed ramask; |
Jes Sorensen | c7a5a19 | 2016-02-29 17:04:30 -0500 | [diff] [blame] | 915 | struct { |
| 916 | u8 cmd; |
Jes Sorensen | 3ca7b32 | 2016-02-29 17:04:43 -0500 | [diff] [blame] | 917 | u8 data1; |
| 918 | u8 data2; |
| 919 | u8 data3; |
| 920 | u8 data4; |
| 921 | u8 data5; |
| 922 | } __packed b_type_dma; |
| 923 | struct { |
| 924 | u8 cmd; |
Jes Sorensen | 6b9eae0 | 2016-02-29 17:04:50 -0500 | [diff] [blame] | 925 | u8 data; |
| 926 | } __packed bt_info; |
| 927 | struct { |
| 928 | u8 cmd; |
Jes Sorensen | 394f1bd | 2016-02-29 17:04:49 -0500 | [diff] [blame] | 929 | u8 operreq; |
| 930 | u8 opcode; |
| 931 | u8 data; |
| 932 | u8 addr; |
| 933 | } __packed bt_mp_oper; |
| 934 | struct { |
| 935 | u8 cmd; |
Jes Sorensen | c7a5a19 | 2016-02-29 17:04:30 -0500 | [diff] [blame] | 936 | u8 data; |
| 937 | } __packed bt_wlan_calibration; |
Jes Sorensen | f37e922 | 2016-02-29 17:04:41 -0500 | [diff] [blame] | 938 | struct { |
| 939 | u8 cmd; |
Jes Sorensen | 7297f49 | 2016-02-29 17:04:44 -0500 | [diff] [blame] | 940 | u8 data; |
| 941 | } __packed ignore_wlan; |
| 942 | struct { |
| 943 | u8 cmd; |
Jes Sorensen | f37e922 | 2016-02-29 17:04:41 -0500 | [diff] [blame] | 944 | u8 ant_inverse; |
| 945 | u8 int_switch_type; |
| 946 | } __packed ant_sel_rsv; |
| 947 | struct { |
| 948 | u8 cmd; |
| 949 | u8 data; |
| 950 | } __packed bt_grant; |
Jes Sorensen | 26f1fad | 2015-10-14 20:44:51 -0400 | [diff] [blame] | 951 | }; |
| 952 | }; |
| 953 | |
Jes Sorensen | b2b43b7 | 2016-02-29 17:04:48 -0500 | [diff] [blame] | 954 | enum c2h_evt_8723b { |
| 955 | C2H_8723B_DEBUG = 0, |
| 956 | C2H_8723B_TSF = 1, |
| 957 | C2H_8723B_AP_RPT_RSP = 2, |
| 958 | C2H_8723B_CCX_TX_RPT = 3, |
| 959 | C2H_8723B_BT_RSSI = 4, |
| 960 | C2H_8723B_BT_OP_MODE = 5, |
| 961 | C2H_8723B_EXT_RA_RPT = 6, |
| 962 | C2H_8723B_BT_INFO = 9, |
Jes Sorensen | 394f1bd | 2016-02-29 17:04:49 -0500 | [diff] [blame] | 963 | C2H_8723B_HW_INFO_EXCH = 0x0a, |
| 964 | C2H_8723B_BT_MP_INFO = 0x0b, |
Jes Sorensen | b2b43b7 | 2016-02-29 17:04:48 -0500 | [diff] [blame] | 965 | C2H_8723B_FW_DEBUG = 0xff, |
| 966 | }; |
| 967 | |
| 968 | enum bt_info_src_8723b { |
| 969 | BT_INFO_SRC_8723B_WIFI_FW = 0x0, |
| 970 | BT_INFO_SRC_8723B_BT_RSP = 0x1, |
| 971 | BT_INFO_SRC_8723B_BT_ACTIVE_SEND = 0x2, |
| 972 | }; |
| 973 | |
Jes Sorensen | 394f1bd | 2016-02-29 17:04:49 -0500 | [diff] [blame] | 974 | enum bt_mp_oper_opcode_8723b { |
| 975 | BT_MP_OP_GET_BT_VERSION = 0x00, |
| 976 | BT_MP_OP_RESET = 0x01, |
| 977 | BT_MP_OP_TEST_CTRL = 0x02, |
| 978 | BT_MP_OP_SET_BT_MODE = 0x03, |
| 979 | BT_MP_OP_SET_CHNL_TX_GAIN = 0x04, |
| 980 | BT_MP_OP_SET_PKT_TYPE_LEN = 0x05, |
| 981 | BT_MP_OP_SET_PKT_CNT_L_PL_TYPE = 0x06, |
| 982 | BT_MP_OP_SET_PKT_CNT_H_PKT_INTV = 0x07, |
| 983 | BT_MP_OP_SET_PKT_HEADER = 0x08, |
| 984 | BT_MP_OP_SET_WHITENCOEFF = 0x09, |
| 985 | BT_MP_OP_SET_BD_ADDR_L = 0x0a, |
| 986 | BT_MP_OP_SET_BD_ADDR_H = 0x0b, |
| 987 | BT_MP_OP_WRITE_REG_ADDR = 0x0c, |
| 988 | BT_MP_OP_WRITE_REG_VALUE = 0x0d, |
| 989 | BT_MP_OP_GET_BT_STATUS = 0x0e, |
| 990 | BT_MP_OP_GET_BD_ADDR_L = 0x0f, |
| 991 | BT_MP_OP_GET_BD_ADDR_H = 0x10, |
| 992 | BT_MP_OP_READ_REG = 0x11, |
| 993 | BT_MP_OP_SET_TARGET_BD_ADDR_L = 0x12, |
| 994 | BT_MP_OP_SET_TARGET_BD_ADDR_H = 0x13, |
| 995 | BT_MP_OP_SET_TX_POWER_CALIBRATION = 0x14, |
| 996 | BT_MP_OP_GET_RX_PKT_CNT_L = 0x15, |
| 997 | BT_MP_OP_GET_RX_PKT_CNT_H = 0x16, |
| 998 | BT_MP_OP_GET_RX_ERROR_BITS_L = 0x17, |
| 999 | BT_MP_OP_GET_RX_ERROR_BITS_H = 0x18, |
| 1000 | BT_MP_OP_GET_RSSI = 0x19, |
| 1001 | BT_MP_OP_GET_CFO_HDR_QUALITY_L = 0x1a, |
| 1002 | BT_MP_OP_GET_CFO_HDR_QUALITY_H = 0x1b, |
| 1003 | BT_MP_OP_GET_TARGET_BD_ADDR_L = 0x1c, |
| 1004 | BT_MP_OP_GET_TARGET_BD_ADDR_H = 0x1d, |
| 1005 | BT_MP_OP_GET_AFH_MAP_L = 0x1e, |
| 1006 | BT_MP_OP_GET_AFH_MAP_M = 0x1f, |
| 1007 | BT_MP_OP_GET_AFH_MAP_H = 0x20, |
| 1008 | BT_MP_OP_GET_AFH_STATUS = 0x21, |
| 1009 | BT_MP_OP_SET_TRACKING_INTERVAL = 0x22, |
| 1010 | BT_MP_OP_SET_THERMAL_METER = 0x23, |
| 1011 | BT_MP_OP_ENABLE_CFO_TRACKING = 0x24, |
| 1012 | }; |
| 1013 | |
Jes Sorensen | b2b43b7 | 2016-02-29 17:04:48 -0500 | [diff] [blame] | 1014 | struct rtl8723bu_c2h { |
| 1015 | u8 id; |
| 1016 | u8 seq; |
| 1017 | union { |
| 1018 | struct { |
| 1019 | u8 payload[0]; |
| 1020 | } __packed raw; |
| 1021 | struct { |
Jes Sorensen | 394f1bd | 2016-02-29 17:04:49 -0500 | [diff] [blame] | 1022 | u8 ext_id; |
| 1023 | u8 status:4; |
| 1024 | u8 retlen:4; |
| 1025 | u8 opcode_ver:4; |
| 1026 | u8 req_num:4; |
| 1027 | u8 payload[2]; |
| 1028 | } __packed bt_mp_info; |
| 1029 | struct { |
Jes Sorensen | b2b43b7 | 2016-02-29 17:04:48 -0500 | [diff] [blame] | 1030 | u8 response_source:4; |
| 1031 | u8 dummy0_0:4; |
| 1032 | |
| 1033 | u8 bt_info; |
| 1034 | |
| 1035 | u8 retry_count:4; |
| 1036 | u8 dummy2_0:1; |
| 1037 | u8 bt_page:1; |
| 1038 | u8 tx_rx_mask:1; |
| 1039 | u8 dummy2_2:1; |
| 1040 | |
| 1041 | u8 rssi; |
| 1042 | |
| 1043 | u8 basic_rate:1; |
| 1044 | u8 bt_has_reset:1; |
| 1045 | u8 dummy4_1:1;; |
| 1046 | u8 ignore_wlan:1; |
| 1047 | u8 auto_report:1; |
| 1048 | u8 dummy4_2:3; |
| 1049 | |
| 1050 | u8 a4; |
| 1051 | u8 a5; |
| 1052 | } __packed bt_info; |
| 1053 | }; |
| 1054 | }; |
| 1055 | |
Jes Sorensen | 26f1fad | 2015-10-14 20:44:51 -0400 | [diff] [blame] | 1056 | struct rtl8xxxu_fileops; |
| 1057 | |
| 1058 | struct rtl8xxxu_priv { |
| 1059 | struct ieee80211_hw *hw; |
| 1060 | struct usb_device *udev; |
| 1061 | struct rtl8xxxu_fileops *fops; |
| 1062 | |
| 1063 | spinlock_t tx_urb_lock; |
| 1064 | struct list_head tx_urb_free_list; |
| 1065 | int tx_urb_free_count; |
| 1066 | bool tx_stopped; |
| 1067 | |
| 1068 | spinlock_t rx_urb_lock; |
| 1069 | struct list_head rx_urb_pending_list; |
| 1070 | int rx_urb_pending_count; |
| 1071 | bool shutdown; |
| 1072 | struct work_struct rx_urb_wq; |
| 1073 | |
| 1074 | u8 mac_addr[ETH_ALEN]; |
| 1075 | char chip_name[8]; |
Jes Sorensen | 0e5d435 | 2016-02-29 17:04:00 -0500 | [diff] [blame] | 1076 | char chip_vendor[8]; |
Jes Sorensen | 21db997 | 2016-02-29 17:05:21 -0500 | [diff] [blame] | 1077 | u8 cck_tx_power_index_A[RTL8XXXU_MAX_CHANNEL_GROUPS]; |
| 1078 | u8 cck_tx_power_index_B[RTL8XXXU_MAX_CHANNEL_GROUPS]; |
| 1079 | u8 ht40_1s_tx_power_index_A[RTL8XXXU_MAX_CHANNEL_GROUPS]; |
| 1080 | u8 ht40_1s_tx_power_index_B[RTL8XXXU_MAX_CHANNEL_GROUPS]; |
Jes Sorensen | 26f1fad | 2015-10-14 20:44:51 -0400 | [diff] [blame] | 1081 | /* |
| 1082 | * The following entries are half-bytes split as: |
| 1083 | * bits 0-3: path A, bits 4-7: path B, all values 4 bits signed |
| 1084 | */ |
Jes Sorensen | 21db997 | 2016-02-29 17:05:21 -0500 | [diff] [blame] | 1085 | struct rtl8723au_idx ht40_2s_tx_power_index_diff[ |
Jes Sorensen | 3be2699 | 2016-02-29 17:05:22 -0500 | [diff] [blame] | 1086 | RTL8723A_CHANNEL_GROUPS]; |
| 1087 | struct rtl8723au_idx ht20_tx_power_index_diff[RTL8723A_CHANNEL_GROUPS]; |
| 1088 | struct rtl8723au_idx ofdm_tx_power_index_diff[RTL8723A_CHANNEL_GROUPS]; |
| 1089 | struct rtl8723au_idx ht40_max_power_offset[RTL8723A_CHANNEL_GROUPS]; |
| 1090 | struct rtl8723au_idx ht20_max_power_offset[RTL8723A_CHANNEL_GROUPS]; |
| 1091 | /* |
| 1092 | * Newer generation chips only keep power diffs per TX count, |
| 1093 | * not per channel group. |
| 1094 | */ |
| 1095 | struct rtl8723au_idx ofdm_tx_power_diff[RTL8723B_TX_COUNT]; |
| 1096 | struct rtl8723au_idx ht20_tx_power_diff[RTL8723B_TX_COUNT]; |
| 1097 | struct rtl8723au_idx ht40_tx_power_diff[RTL8723B_TX_COUNT]; |
Jes Sorensen | 26f1fad | 2015-10-14 20:44:51 -0400 | [diff] [blame] | 1098 | u32 chip_cut:4; |
| 1099 | u32 rom_rev:4; |
Jakub Sitnicki | 3845199 | 2016-02-03 13:39:49 -0500 | [diff] [blame] | 1100 | u32 is_multi_func:1; |
Jes Sorensen | 26f1fad | 2015-10-14 20:44:51 -0400 | [diff] [blame] | 1101 | u32 has_wifi:1; |
| 1102 | u32 has_bluetooth:1; |
| 1103 | u32 enable_bluetooth:1; |
| 1104 | u32 has_gps:1; |
| 1105 | u32 hi_pa:1; |
| 1106 | u32 vendor_umc:1; |
Jes Sorensen | 0e5d435 | 2016-02-29 17:04:00 -0500 | [diff] [blame] | 1107 | u32 vendor_smic:1; |
Jes Sorensen | 26f1fad | 2015-10-14 20:44:51 -0400 | [diff] [blame] | 1108 | u32 has_polarity_ctrl:1; |
| 1109 | u32 has_eeprom:1; |
| 1110 | u32 boot_eeprom:1; |
Jes Sorensen | 0e28b97 | 2016-02-29 17:04:13 -0500 | [diff] [blame] | 1111 | u32 usb_interrupts:1; |
Jes Sorensen | 26f1fad | 2015-10-14 20:44:51 -0400 | [diff] [blame] | 1112 | u32 ep_tx_high_queue:1; |
| 1113 | u32 ep_tx_normal_queue:1; |
| 1114 | u32 ep_tx_low_queue:1; |
Jes Sorensen | 4ef22eb | 2016-02-29 17:04:55 -0500 | [diff] [blame] | 1115 | u32 has_xtalk:1; |
| 1116 | u8 xtalk; |
Jes Sorensen | 26f1fad | 2015-10-14 20:44:51 -0400 | [diff] [blame] | 1117 | unsigned int pipe_interrupt; |
| 1118 | unsigned int pipe_in; |
| 1119 | unsigned int pipe_out[TXDESC_QUEUE_MAX]; |
| 1120 | u8 out_ep[RTL8XXXU_OUT_ENDPOINTS]; |
Jes Sorensen | 26f1fad | 2015-10-14 20:44:51 -0400 | [diff] [blame] | 1121 | u8 ep_tx_count; |
| 1122 | u8 rf_paths; |
| 1123 | u8 rx_paths; |
| 1124 | u8 tx_paths; |
| 1125 | u32 rf_mode_ag[2]; |
| 1126 | u32 rege94; |
| 1127 | u32 rege9c; |
| 1128 | u32 regeb4; |
| 1129 | u32 regebc; |
| 1130 | int next_mbox; |
| 1131 | int nr_out_eps; |
| 1132 | |
| 1133 | struct mutex h2c_mutex; |
| 1134 | |
| 1135 | struct usb_anchor rx_anchor; |
| 1136 | struct usb_anchor tx_anchor; |
| 1137 | struct usb_anchor int_anchor; |
| 1138 | struct rtl8xxxu_firmware_header *fw_data; |
| 1139 | size_t fw_size; |
| 1140 | struct mutex usb_buf_mutex; |
| 1141 | union { |
| 1142 | __le32 val32; |
| 1143 | __le16 val16; |
| 1144 | u8 val8; |
| 1145 | } usb_buf; |
| 1146 | union { |
Jes Sorensen | 3307d84 | 2016-02-29 17:03:59 -0500 | [diff] [blame] | 1147 | u8 raw[EFUSE_MAP_LEN]; |
Jes Sorensen | 26f1fad | 2015-10-14 20:44:51 -0400 | [diff] [blame] | 1148 | struct rtl8723au_efuse efuse8723; |
Jes Sorensen | 3c836d6 | 2016-02-29 17:04:11 -0500 | [diff] [blame] | 1149 | struct rtl8723bu_efuse efuse8723bu; |
Jes Sorensen | 26f1fad | 2015-10-14 20:44:51 -0400 | [diff] [blame] | 1150 | struct rtl8192cu_efuse efuse8192; |
Jes Sorensen | 3307d84 | 2016-02-29 17:03:59 -0500 | [diff] [blame] | 1151 | struct rtl8192eu_efuse efuse8192eu; |
Jes Sorensen | 26f1fad | 2015-10-14 20:44:51 -0400 | [diff] [blame] | 1152 | } efuse_wifi; |
| 1153 | u32 adda_backup[RTL8XXXU_ADDA_REGS]; |
| 1154 | u32 mac_backup[RTL8XXXU_MAC_REGS]; |
| 1155 | u32 bb_backup[RTL8XXXU_BB_REGS]; |
| 1156 | u32 bb_recovery_backup[RTL8XXXU_BB_REGS]; |
| 1157 | u32 rtlchip; |
| 1158 | u8 pi_enabled:1; |
Jes Sorensen | 26f1fad | 2015-10-14 20:44:51 -0400 | [diff] [blame] | 1159 | u8 int_buf[USB_INTR_CONTENT_LENGTH]; |
| 1160 | }; |
| 1161 | |
| 1162 | struct rtl8xxxu_rx_urb { |
| 1163 | struct urb urb; |
| 1164 | struct ieee80211_hw *hw; |
| 1165 | struct list_head list; |
| 1166 | }; |
| 1167 | |
| 1168 | struct rtl8xxxu_tx_urb { |
| 1169 | struct urb urb; |
| 1170 | struct ieee80211_hw *hw; |
| 1171 | struct list_head list; |
| 1172 | }; |
| 1173 | |
| 1174 | struct rtl8xxxu_fileops { |
| 1175 | int (*parse_efuse) (struct rtl8xxxu_priv *priv); |
| 1176 | int (*load_firmware) (struct rtl8xxxu_priv *priv); |
| 1177 | int (*power_on) (struct rtl8xxxu_priv *priv); |
Jes Sorensen | 74b99be | 2016-02-29 17:04:04 -0500 | [diff] [blame] | 1178 | int (*llt_init) (struct rtl8xxxu_priv *priv, u8 last_tx_page); |
Jes Sorensen | f0d9f5e | 2016-02-29 17:04:16 -0500 | [diff] [blame] | 1179 | void (*phy_init_antenna_selection) (struct rtl8xxxu_priv *priv); |
Jes Sorensen | e1547c5 | 2016-02-29 17:04:35 -0500 | [diff] [blame] | 1180 | void (*phy_iq_calibrate) (struct rtl8xxxu_priv *priv); |
Jes Sorensen | c3f9506 | 2016-02-29 17:04:40 -0500 | [diff] [blame] | 1181 | void (*config_channel) (struct ieee80211_hw *hw); |
Jes Sorensen | f37e922 | 2016-02-29 17:04:41 -0500 | [diff] [blame] | 1182 | void (*init_bt) (struct rtl8xxxu_priv *priv); |
Jes Sorensen | b18cdfd | 2016-02-29 17:04:47 -0500 | [diff] [blame] | 1183 | int (*parse_rx_desc) (struct rtl8xxxu_priv *priv, struct sk_buff *skb, |
| 1184 | struct ieee80211_rx_status *rx_status); |
Jes Sorensen | 3e88ca4 | 2016-02-29 17:05:08 -0500 | [diff] [blame] | 1185 | void (*init_aggregation) (struct rtl8xxxu_priv *priv); |
Jes Sorensen | 9c79bf9 | 2016-02-29 17:05:10 -0500 | [diff] [blame] | 1186 | void (*init_statistics) (struct rtl8xxxu_priv *priv); |
Jes Sorensen | db08de9 | 2016-02-29 17:05:17 -0500 | [diff] [blame] | 1187 | void (*enable_rf) (struct rtl8xxxu_priv *priv); |
Jes Sorensen | e796dab | 2016-02-29 17:05:19 -0500 | [diff] [blame] | 1188 | void (*set_tx_power) (struct rtl8xxxu_priv *priv, int channel, |
| 1189 | bool ht40); |
Jes Sorensen | 26f1fad | 2015-10-14 20:44:51 -0400 | [diff] [blame] | 1190 | int writeN_block_size; |
Jes Sorensen | ed35d09 | 2016-02-29 17:04:19 -0500 | [diff] [blame] | 1191 | u16 mbox_ext_reg; |
| 1192 | char mbox_ext_width; |
Jes Sorensen | 179e174 | 2016-02-29 17:05:27 -0500 | [diff] [blame^] | 1193 | char tx_desc_size; |
Jes Sorensen | 0d698de | 2016-02-29 17:04:36 -0500 | [diff] [blame] | 1194 | char has_s0s1; |
Jes Sorensen | 8634af5 | 2016-02-29 17:04:33 -0500 | [diff] [blame] | 1195 | u32 adda_1t_init; |
| 1196 | u32 adda_1t_path_on; |
| 1197 | u32 adda_2t_path_on_a; |
| 1198 | u32 adda_2t_path_on_b; |
Jes Sorensen | 26f1fad | 2015-10-14 20:44:51 -0400 | [diff] [blame] | 1199 | }; |