rtl8xxxu.h 34 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454
  1. /*
  2. * Copyright (c) 2014 - 2017 Jes Sorensen <Jes.Sorensen@gmail.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. #include <asm/byteorder.h>
  16. #define RTL8XXXU_DEBUG_REG_WRITE 0x01
  17. #define RTL8XXXU_DEBUG_REG_READ 0x02
  18. #define RTL8XXXU_DEBUG_RFREG_WRITE 0x04
  19. #define RTL8XXXU_DEBUG_RFREG_READ 0x08
  20. #define RTL8XXXU_DEBUG_CHANNEL 0x10
  21. #define RTL8XXXU_DEBUG_TX 0x20
  22. #define RTL8XXXU_DEBUG_TX_DUMP 0x40
  23. #define RTL8XXXU_DEBUG_RX 0x80
  24. #define RTL8XXXU_DEBUG_RX_DUMP 0x100
  25. #define RTL8XXXU_DEBUG_USB 0x200
  26. #define RTL8XXXU_DEBUG_KEY 0x400
  27. #define RTL8XXXU_DEBUG_H2C 0x800
  28. #define RTL8XXXU_DEBUG_ACTION 0x1000
  29. #define RTL8XXXU_DEBUG_EFUSE 0x2000
  30. #define RTL8XXXU_DEBUG_INTERRUPT 0x4000
  31. #define RTW_USB_CONTROL_MSG_TIMEOUT 500
  32. #define RTL8XXXU_MAX_REG_POLL 500
  33. #define USB_INTR_CONTENT_LENGTH 56
  34. #define RTL8XXXU_OUT_ENDPOINTS 4
  35. #define REALTEK_USB_READ 0xc0
  36. #define REALTEK_USB_WRITE 0x40
  37. #define REALTEK_USB_CMD_REQ 0x05
  38. #define REALTEK_USB_CMD_IDX 0x00
  39. #define TX_TOTAL_PAGE_NUM 0xf8
  40. #define TX_TOTAL_PAGE_NUM_8192E 0xf3
  41. #define TX_TOTAL_PAGE_NUM_8723B 0xf7
  42. /* (HPQ + LPQ + NPQ + PUBQ) = TX_TOTAL_PAGE_NUM */
  43. #define TX_PAGE_NUM_PUBQ 0xe7
  44. #define TX_PAGE_NUM_HI_PQ 0x0c
  45. #define TX_PAGE_NUM_LO_PQ 0x02
  46. #define TX_PAGE_NUM_NORM_PQ 0x02
  47. #define TX_PAGE_NUM_PUBQ_8192E 0xe7
  48. #define TX_PAGE_NUM_HI_PQ_8192E 0x08
  49. #define TX_PAGE_NUM_LO_PQ_8192E 0x0c
  50. #define TX_PAGE_NUM_NORM_PQ_8192E 0x00
  51. #define TX_PAGE_NUM_PUBQ_8723B 0xe7
  52. #define TX_PAGE_NUM_HI_PQ_8723B 0x0c
  53. #define TX_PAGE_NUM_LO_PQ_8723B 0x02
  54. #define TX_PAGE_NUM_NORM_PQ_8723B 0x02
  55. #define RTL_FW_PAGE_SIZE 4096
  56. #define RTL8XXXU_FIRMWARE_POLL_MAX 1000
  57. #define RTL8723A_CHANNEL_GROUPS 3
  58. #define RTL8723A_MAX_RF_PATHS 2
  59. #define RTL8723B_CHANNEL_GROUPS 6
  60. #define RTL8723B_TX_COUNT 4
  61. #define RTL8723B_MAX_RF_PATHS 4
  62. #define RTL8XXXU_MAX_CHANNEL_GROUPS 6
  63. #define RF6052_MAX_TX_PWR 0x3f
  64. #define EFUSE_MAP_LEN 512
  65. #define EFUSE_MAX_SECTION_8723A 64
  66. #define EFUSE_REAL_CONTENT_LEN_8723A 512
  67. #define EFUSE_BT_MAP_LEN_8723A 1024
  68. #define EFUSE_MAX_WORD_UNIT 4
  69. enum 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. enum rtl8xxxu_rx_type {
  93. RX_TYPE_DATA_PKT = 0,
  94. RX_TYPE_C2H = 1,
  95. RX_TYPE_ERROR = -1
  96. };
  97. struct rtl8xxxu_rxdesc16 {
  98. #ifdef __LITTLE_ENDIAN
  99. u32 pktlen:14;
  100. u32 crc32:1;
  101. u32 icverr:1;
  102. u32 drvinfo_sz:4;
  103. u32 security:3;
  104. u32 qos:1;
  105. u32 shift:2;
  106. u32 phy_stats:1;
  107. u32 swdec:1;
  108. u32 ls:1;
  109. u32 fs:1;
  110. u32 eor:1;
  111. u32 own:1;
  112. u32 macid:5;
  113. u32 tid:4;
  114. u32 hwrsvd:4;
  115. u32 amsdu:1;
  116. u32 paggr:1;
  117. u32 faggr:1;
  118. u32 a1fit:4;
  119. u32 a2fit:4;
  120. u32 pam:1;
  121. u32 pwr:1;
  122. u32 md:1;
  123. u32 mf:1;
  124. u32 type:2;
  125. u32 mc:1;
  126. u32 bc:1;
  127. u32 seq:12;
  128. u32 frag:4;
  129. u32 pkt_cnt:8;
  130. u32 reserved:6;
  131. u32 nextind:1;
  132. u32 reserved0:1;
  133. u32 rxmcs:6;
  134. u32 rxht:1;
  135. u32 gf:1;
  136. u32 splcp:1;
  137. u32 bw:1;
  138. u32 htc:1;
  139. u32 eosp:1;
  140. u32 bssidfit:2;
  141. u32 reserved1:16;
  142. u32 unicastwake:1;
  143. u32 magicwake:1;
  144. u32 pattern0match:1;
  145. u32 pattern1match:1;
  146. u32 pattern2match:1;
  147. u32 pattern3match:1;
  148. u32 pattern4match:1;
  149. u32 pattern5match:1;
  150. u32 pattern6match:1;
  151. u32 pattern7match:1;
  152. u32 pattern8match:1;
  153. u32 pattern9match:1;
  154. u32 patternamatch:1;
  155. u32 patternbmatch:1;
  156. u32 patterncmatch:1;
  157. u32 reserved2:19;
  158. #else
  159. u32 own:1;
  160. u32 eor:1;
  161. u32 fs:1;
  162. u32 ls:1;
  163. u32 swdec:1;
  164. u32 phy_stats:1;
  165. u32 shift:2;
  166. u32 qos:1;
  167. u32 security:3;
  168. u32 drvinfo_sz:4;
  169. u32 icverr:1;
  170. u32 crc32:1;
  171. u32 pktlen:14;
  172. u32 bc:1;
  173. u32 mc:1;
  174. u32 type:2;
  175. u32 mf:1;
  176. u32 md:1;
  177. u32 pwr:1;
  178. u32 pam:1;
  179. u32 a2fit:4;
  180. u32 a1fit:4;
  181. u32 faggr:1;
  182. u32 paggr:1;
  183. u32 amsdu:1;
  184. u32 hwrsvd:4;
  185. u32 tid:4;
  186. u32 macid:5;
  187. u32 reserved0:1;
  188. u32 nextind:1;
  189. u32 reserved:6;
  190. u32 pkt_cnt:8;
  191. u32 frag:4;
  192. u32 seq:12;
  193. u32 magicwake:1;
  194. u32 unicastwake:1;
  195. u32 reserved1:16;
  196. u32 bssidfit:2;
  197. u32 eosp:1;
  198. u32 htc:1;
  199. u32 bw:1;
  200. u32 splcp:1;
  201. u32 gf:1;
  202. u32 rxht:1;
  203. u32 rxmcs:6;
  204. u32 reserved2:19;
  205. u32 patterncmatch:1;
  206. u32 patternbmatch:1;
  207. u32 patternamatch:1;
  208. u32 pattern9match:1;
  209. u32 pattern8match:1;
  210. u32 pattern7match:1;
  211. u32 pattern6match:1;
  212. u32 pattern5match:1;
  213. u32 pattern4match:1;
  214. u32 pattern3match:1;
  215. u32 pattern2match:1;
  216. u32 pattern1match:1;
  217. u32 pattern0match:1;
  218. #endif
  219. u32 tsfl;
  220. #if 0
  221. u32 bassn:12;
  222. u32 bavld:1;
  223. u32 reserved3:19;
  224. #endif
  225. };
  226. struct rtl8xxxu_rxdesc24 {
  227. #ifdef __LITTLE_ENDIAN
  228. u32 pktlen:14;
  229. u32 crc32:1;
  230. u32 icverr:1;
  231. u32 drvinfo_sz:4;
  232. u32 security:3;
  233. u32 qos:1;
  234. u32 shift:2;
  235. u32 phy_stats:1;
  236. u32 swdec:1;
  237. u32 ls:1;
  238. u32 fs:1;
  239. u32 eor:1;
  240. u32 own:1;
  241. u32 macid:7;
  242. u32 dummy1_0:1;
  243. u32 tid:4;
  244. u32 dummy1_1:1;
  245. u32 amsdu:1;
  246. u32 rxid_match:1;
  247. u32 paggr:1;
  248. u32 a1fit:4; /* 16 */
  249. u32 chkerr:1;
  250. u32 ipver:1;
  251. u32 tcpudp:1;
  252. u32 chkvld:1;
  253. u32 pam:1;
  254. u32 pwr:1;
  255. u32 more_data:1;
  256. u32 more_frag:1;
  257. u32 type:2;
  258. u32 mc:1;
  259. u32 bc:1;
  260. u32 seq:12;
  261. u32 frag:4;
  262. u32 rx_is_qos:1; /* 16 */
  263. u32 dummy2_0:1;
  264. u32 wlanhd_iv_len:6;
  265. u32 dummy2_1:4;
  266. u32 rpt_sel:1;
  267. u32 dummy2_2:3;
  268. u32 rxmcs:7;
  269. u32 dummy3_0:3;
  270. u32 htc:1;
  271. u32 eosp:1;
  272. u32 bssidfit:2;
  273. u32 dummy3_1:2;
  274. u32 usb_agg_pktnum:8; /* 16 */
  275. u32 dummy3_2:5;
  276. u32 pattern_match:1;
  277. u32 unicast_match:1;
  278. u32 magic_match:1;
  279. u32 splcp:1;
  280. u32 ldcp:1;
  281. u32 stbc:1;
  282. u32 dummy4_0:1;
  283. u32 bw:2;
  284. u32 dummy4_1:26;
  285. #else
  286. u32 own:1;
  287. u32 eor:1;
  288. u32 fs:1;
  289. u32 ls:1;
  290. u32 swdec:1;
  291. u32 phy_stats:1;
  292. u32 shift:2;
  293. u32 qos:1;
  294. u32 security:3;
  295. u32 drvinfo_sz:4;
  296. u32 icverr:1;
  297. u32 crc32:1;
  298. u32 pktlen:14;
  299. u32 bc:1;
  300. u32 mc:1;
  301. u32 type:2;
  302. u32 mf:1;
  303. u32 md:1;
  304. u32 pwr:1;
  305. u32 pam:1;
  306. u32 a2fit:4;
  307. u32 a1fit:4;
  308. u32 faggr:1;
  309. u32 paggr:1;
  310. u32 amsdu:1;
  311. u32 hwrsvd:4;
  312. u32 tid:4;
  313. u32 macid:5;
  314. u32 dummy2_2:3;
  315. u32 rpt_sel:1;
  316. u32 dummy2_1:4;
  317. u32 wlanhd_iv_len:6;
  318. u32 dummy2_0:1;
  319. u32 rx_is_qos:1;
  320. u32 frag:4; /* 16 */
  321. u32 seq:12;
  322. u32 magic_match:1;
  323. u32 unicast_match:1;
  324. u32 pattern_match:1;
  325. u32 dummy3_2:5;
  326. u32 usb_agg_pktnum:8;
  327. u32 dummy3_1:2; /* 16 */
  328. u32 bssidfit:2;
  329. u32 eosp:1;
  330. u32 htc:1;
  331. u32 dummy3_0:3;
  332. u32 rxmcs:7;
  333. u32 dumm4_1:26;
  334. u32 bw:2;
  335. u32 dummy4_0:1;
  336. u32 stbc:1;
  337. u32 ldcp:1;
  338. u32 splcp:1;
  339. #endif
  340. u32 tsfl;
  341. };
  342. struct rtl8xxxu_txdesc32 {
  343. __le16 pkt_size;
  344. u8 pkt_offset;
  345. u8 txdw0;
  346. __le32 txdw1;
  347. __le32 txdw2;
  348. __le32 txdw3;
  349. __le32 txdw4;
  350. __le32 txdw5;
  351. __le32 txdw6;
  352. __le16 csum;
  353. __le16 txdw7;
  354. };
  355. struct rtl8xxxu_txdesc40 {
  356. __le16 pkt_size;
  357. u8 pkt_offset;
  358. u8 txdw0;
  359. __le32 txdw1;
  360. __le32 txdw2;
  361. __le32 txdw3;
  362. __le32 txdw4;
  363. __le32 txdw5;
  364. __le32 txdw6;
  365. __le16 csum;
  366. __le16 txdw7;
  367. __le32 txdw8;
  368. __le32 txdw9;
  369. };
  370. /* CCK Rates, TxHT = 0 */
  371. #define DESC_RATE_1M 0x00
  372. #define DESC_RATE_2M 0x01
  373. #define DESC_RATE_5_5M 0x02
  374. #define DESC_RATE_11M 0x03
  375. /* OFDM Rates, TxHT = 0 */
  376. #define DESC_RATE_6M 0x04
  377. #define DESC_RATE_9M 0x05
  378. #define DESC_RATE_12M 0x06
  379. #define DESC_RATE_18M 0x07
  380. #define DESC_RATE_24M 0x08
  381. #define DESC_RATE_36M 0x09
  382. #define DESC_RATE_48M 0x0a
  383. #define DESC_RATE_54M 0x0b
  384. /* MCS Rates, TxHT = 1 */
  385. #define DESC_RATE_MCS0 0x0c
  386. #define DESC_RATE_MCS1 0x0d
  387. #define DESC_RATE_MCS2 0x0e
  388. #define DESC_RATE_MCS3 0x0f
  389. #define DESC_RATE_MCS4 0x10
  390. #define DESC_RATE_MCS5 0x11
  391. #define DESC_RATE_MCS6 0x12
  392. #define DESC_RATE_MCS7 0x13
  393. #define DESC_RATE_MCS8 0x14
  394. #define DESC_RATE_MCS9 0x15
  395. #define DESC_RATE_MCS10 0x16
  396. #define DESC_RATE_MCS11 0x17
  397. #define DESC_RATE_MCS12 0x18
  398. #define DESC_RATE_MCS13 0x19
  399. #define DESC_RATE_MCS14 0x1a
  400. #define DESC_RATE_MCS15 0x1b
  401. #define DESC_RATE_MCS15_SG 0x1c
  402. #define DESC_RATE_MCS32 0x20
  403. #define TXDESC_OFFSET_SZ 0
  404. #define TXDESC_OFFSET_SHT 16
  405. #if 0
  406. #define TXDESC_BMC BIT(24)
  407. #define TXDESC_LSG BIT(26)
  408. #define TXDESC_FSG BIT(27)
  409. #define TXDESC_OWN BIT(31)
  410. #else
  411. #define TXDESC_BROADMULTICAST BIT(0)
  412. #define TXDESC_HTC BIT(1)
  413. #define TXDESC_LAST_SEGMENT BIT(2)
  414. #define TXDESC_FIRST_SEGMENT BIT(3)
  415. #define TXDESC_LINIP BIT(4)
  416. #define TXDESC_NO_ACM BIT(5)
  417. #define TXDESC_GF BIT(6)
  418. #define TXDESC_OWN BIT(7)
  419. #endif
  420. /* Word 1 */
  421. /*
  422. * Bits 0-7 differ dependent on chip generation. For 8723au bits 5/6 are
  423. * aggregation enable and break respectively. For 8723bu, bits 0-7 are macid.
  424. */
  425. #define TXDESC_PKT_OFFSET_SZ 0
  426. #define TXDESC32_AGG_ENABLE BIT(5)
  427. #define TXDESC32_AGG_BREAK BIT(6)
  428. #define TXDESC40_MACID_SHIFT 0
  429. #define TXDESC40_MACID_MASK 0x00f0
  430. #define TXDESC_QUEUE_SHIFT 8
  431. #define TXDESC_QUEUE_MASK 0x1f00
  432. #define TXDESC_QUEUE_BK 0x2
  433. #define TXDESC_QUEUE_BE 0x0
  434. #define TXDESC_QUEUE_VI 0x5
  435. #define TXDESC_QUEUE_VO 0x7
  436. #define TXDESC_QUEUE_BEACON 0x10
  437. #define TXDESC_QUEUE_HIGH 0x11
  438. #define TXDESC_QUEUE_MGNT 0x12
  439. #define TXDESC_QUEUE_CMD 0x13
  440. #define TXDESC_QUEUE_MAX (TXDESC_QUEUE_CMD + 1)
  441. #define TXDESC40_RDG_NAV_EXT BIT(13)
  442. #define TXDESC40_LSIG_TXOP_ENABLE BIT(14)
  443. #define TXDESC40_PIFS BIT(15)
  444. #define DESC_RATE_ID_SHIFT 16
  445. #define DESC_RATE_ID_MASK 0xf
  446. #define TXDESC_NAVUSEHDR BIT(20)
  447. #define TXDESC_SEC_RC4 0x00400000
  448. #define TXDESC_SEC_AES 0x00c00000
  449. #define TXDESC_PKT_OFFSET_SHIFT 26
  450. #define TXDESC_AGG_EN BIT(29)
  451. #define TXDESC_HWPC BIT(31)
  452. /* Word 2 */
  453. #define TXDESC40_PAID_SHIFT 0
  454. #define TXDESC40_PAID_MASK 0x1ff
  455. #define TXDESC40_CCA_RTS_SHIFT 10
  456. #define TXDESC40_CCA_RTS_MASK 0xc00
  457. #define TXDESC40_AGG_ENABLE BIT(12)
  458. #define TXDESC40_RDG_ENABLE BIT(13)
  459. #define TXDESC40_AGG_BREAK BIT(16)
  460. #define TXDESC40_MORE_FRAG BIT(17)
  461. #define TXDESC40_RAW BIT(18)
  462. #define TXDESC32_ACK_REPORT BIT(19)
  463. #define TXDESC40_SPE_RPT BIT(19)
  464. #define TXDESC_AMPDU_DENSITY_SHIFT 20
  465. #define TXDESC40_BT_INT BIT(23)
  466. #define TXDESC40_GID_SHIFT 24
  467. /* Word 3 */
  468. #define TXDESC40_USE_DRIVER_RATE BIT(8)
  469. #define TXDESC40_CTS_SELF_ENABLE BIT(11)
  470. #define TXDESC40_RTS_CTS_ENABLE BIT(12)
  471. #define TXDESC40_HW_RTS_ENABLE BIT(13)
  472. #define TXDESC32_SEQ_SHIFT 16
  473. #define TXDESC32_SEQ_MASK 0x0fff0000
  474. /* Word 4 */
  475. #define TXDESC32_RTS_RATE_SHIFT 0
  476. #define TXDESC32_RTS_RATE_MASK 0x3f
  477. #define TXDESC32_QOS BIT(6)
  478. #define TXDESC32_HW_SEQ_ENABLE BIT(7)
  479. #define TXDESC32_USE_DRIVER_RATE BIT(8)
  480. #define TXDESC_DISABLE_DATA_FB BIT(10)
  481. #define TXDESC32_CTS_SELF_ENABLE BIT(11)
  482. #define TXDESC32_RTS_CTS_ENABLE BIT(12)
  483. #define TXDESC32_HW_RTS_ENABLE BIT(13)
  484. #define TXDESC_PRIME_CH_OFF_LOWER BIT(20)
  485. #define TXDESC_PRIME_CH_OFF_UPPER BIT(21)
  486. #define TXDESC32_SHORT_PREAMBLE BIT(24)
  487. #define TXDESC_DATA_BW BIT(25)
  488. #define TXDESC_RTS_DATA_BW BIT(27)
  489. #define TXDESC_RTS_PRIME_CH_OFF_LOWER BIT(28)
  490. #define TXDESC_RTS_PRIME_CH_OFF_UPPER BIT(29)
  491. #define TXDESC40_DATA_RATE_FB_SHIFT 8
  492. #define TXDESC40_DATA_RATE_FB_MASK 0x00001f00
  493. #define TXDESC40_RETRY_LIMIT_ENABLE BIT(17)
  494. #define TXDESC40_RETRY_LIMIT_SHIFT 18
  495. #define TXDESC40_RETRY_LIMIT_MASK 0x00fc0000
  496. #define TXDESC40_RTS_RATE_SHIFT 24
  497. #define TXDESC40_RTS_RATE_MASK 0x3f000000
  498. /* Word 5 */
  499. #define TXDESC40_SHORT_PREAMBLE BIT(4)
  500. #define TXDESC32_SHORT_GI BIT(6)
  501. #define TXDESC_CCX_TAG BIT(7)
  502. #define TXDESC32_RETRY_LIMIT_ENABLE BIT(17)
  503. #define TXDESC32_RETRY_LIMIT_SHIFT 18
  504. #define TXDESC32_RETRY_LIMIT_MASK 0x00fc0000
  505. /* Word 6 */
  506. #define TXDESC_MAX_AGG_SHIFT 11
  507. /* Word 8 */
  508. #define TXDESC40_HW_SEQ_ENABLE BIT(15)
  509. /* Word 9 */
  510. #define TXDESC40_SEQ_SHIFT 12
  511. #define TXDESC40_SEQ_MASK 0x00fff000
  512. struct phy_rx_agc_info {
  513. #ifdef __LITTLE_ENDIAN
  514. u8 gain:7, trsw:1;
  515. #else
  516. u8 trsw:1, gain:7;
  517. #endif
  518. };
  519. struct rtl8723au_phy_stats {
  520. struct phy_rx_agc_info path_agc[RTL8723A_MAX_RF_PATHS];
  521. u8 ch_corr[RTL8723A_MAX_RF_PATHS];
  522. u8 cck_sig_qual_ofdm_pwdb_all;
  523. u8 cck_agc_rpt_ofdm_cfosho_a;
  524. u8 cck_rpt_b_ofdm_cfosho_b;
  525. u8 reserved_1;
  526. u8 noise_power_db_msb;
  527. u8 path_cfotail[RTL8723A_MAX_RF_PATHS];
  528. u8 pcts_mask[RTL8723A_MAX_RF_PATHS];
  529. s8 stream_rxevm[RTL8723A_MAX_RF_PATHS];
  530. u8 path_rxsnr[RTL8723A_MAX_RF_PATHS];
  531. u8 noise_power_db_lsb;
  532. u8 reserved_2[3];
  533. u8 stream_csi[RTL8723A_MAX_RF_PATHS];
  534. u8 stream_target_csi[RTL8723A_MAX_RF_PATHS];
  535. s8 sig_evm;
  536. u8 reserved_3;
  537. #ifdef __LITTLE_ENDIAN
  538. u8 antsel_rx_keep_2:1; /* ex_intf_flg:1; */
  539. u8 sgi_en:1;
  540. u8 rxsc:2;
  541. u8 idle_long:1;
  542. u8 r_ant_train_en:1;
  543. u8 antenna_select_b:1;
  544. u8 antenna_select:1;
  545. #else /* _BIG_ENDIAN_ */
  546. u8 antenna_select:1;
  547. u8 antenna_select_b:1;
  548. u8 r_ant_train_en:1;
  549. u8 idle_long:1;
  550. u8 rxsc:2;
  551. u8 sgi_en:1;
  552. u8 antsel_rx_keep_2:1; /* ex_intf_flg:1; */
  553. #endif
  554. };
  555. /*
  556. * Regs to backup
  557. */
  558. #define RTL8XXXU_ADDA_REGS 16
  559. #define RTL8XXXU_MAC_REGS 4
  560. #define RTL8XXXU_BB_REGS 9
  561. struct rtl8xxxu_firmware_header {
  562. __le16 signature; /* 92C0: test chip; 92C,
  563. 88C0: test chip;
  564. 88C1: MP A-cut;
  565. 92C1: MP A-cut */
  566. u8 category; /* AP/NIC and USB/PCI */
  567. u8 function;
  568. __le16 major_version; /* FW Version */
  569. u8 minor_version; /* FW Subversion, default 0x00 */
  570. u8 reserved1;
  571. u8 month; /* Release time Month field */
  572. u8 date; /* Release time Date field */
  573. u8 hour; /* Release time Hour field */
  574. u8 minute; /* Release time Minute field */
  575. __le16 ramcodesize; /* Size of RAM code */
  576. u16 reserved2;
  577. __le32 svn_idx; /* SVN entry index */
  578. u32 reserved3;
  579. u32 reserved4;
  580. u32 reserved5;
  581. u8 data[0];
  582. };
  583. /*
  584. * 8723au/8192cu/8188ru required base power index offset tables.
  585. */
  586. struct rtl8xxxu_power_base {
  587. u32 reg_0e00;
  588. u32 reg_0e04;
  589. u32 reg_0e08;
  590. u32 reg_086c;
  591. u32 reg_0e10;
  592. u32 reg_0e14;
  593. u32 reg_0e18;
  594. u32 reg_0e1c;
  595. u32 reg_0830;
  596. u32 reg_0834;
  597. u32 reg_0838;
  598. u32 reg_086c_2;
  599. u32 reg_083c;
  600. u32 reg_0848;
  601. u32 reg_084c;
  602. u32 reg_0868;
  603. };
  604. /*
  605. * The 8723au has 3 channel groups: 1-3, 4-9, and 10-14
  606. */
  607. struct rtl8723au_idx {
  608. #ifdef __LITTLE_ENDIAN
  609. int a:4;
  610. int b:4;
  611. #else
  612. int b:4;
  613. int a:4;
  614. #endif
  615. } __attribute__((packed));
  616. struct rtl8723au_efuse {
  617. __le16 rtl_id;
  618. u8 res0[0xe];
  619. u8 cck_tx_power_index_A[3]; /* 0x10 */
  620. u8 cck_tx_power_index_B[3];
  621. u8 ht40_1s_tx_power_index_A[3]; /* 0x16 */
  622. u8 ht40_1s_tx_power_index_B[3];
  623. /*
  624. * The following entries are half-bytes split as:
  625. * bits 0-3: path A, bits 4-7: path B, all values 4 bits signed
  626. */
  627. struct rtl8723au_idx ht20_tx_power_index_diff[3];
  628. struct rtl8723au_idx ofdm_tx_power_index_diff[3];
  629. struct rtl8723au_idx ht40_max_power_offset[3];
  630. struct rtl8723au_idx ht20_max_power_offset[3];
  631. u8 channel_plan; /* 0x28 */
  632. u8 tssi_a;
  633. u8 thermal_meter;
  634. u8 rf_regulatory;
  635. u8 rf_option_2;
  636. u8 rf_option_3;
  637. u8 rf_option_4;
  638. u8 res7;
  639. u8 version /* 0x30 */;
  640. u8 customer_id_major;
  641. u8 customer_id_minor;
  642. u8 xtal_k;
  643. u8 chipset; /* 0x34 */
  644. u8 res8[0x82];
  645. u8 vid; /* 0xb7 */
  646. u8 res9;
  647. u8 pid; /* 0xb9 */
  648. u8 res10[0x0c];
  649. u8 mac_addr[ETH_ALEN]; /* 0xc6 */
  650. u8 res11[2];
  651. u8 vendor_name[7];
  652. u8 res12[2];
  653. u8 device_name[0x29]; /* 0xd7 */
  654. };
  655. struct rtl8192cu_efuse {
  656. __le16 rtl_id;
  657. __le16 hpon;
  658. u8 res0[2];
  659. __le16 clk;
  660. __le16 testr;
  661. __le16 vid;
  662. __le16 did;
  663. __le16 svid;
  664. __le16 smid; /* 0x10 */
  665. u8 res1[4];
  666. u8 mac_addr[ETH_ALEN]; /* 0x16 */
  667. u8 res2[2];
  668. u8 vendor_name[7];
  669. u8 res3[3];
  670. u8 device_name[0x14]; /* 0x28 */
  671. u8 res4[0x1e]; /* 0x3c */
  672. u8 cck_tx_power_index_A[3]; /* 0x5a */
  673. u8 cck_tx_power_index_B[3];
  674. u8 ht40_1s_tx_power_index_A[3]; /* 0x60 */
  675. u8 ht40_1s_tx_power_index_B[3];
  676. /*
  677. * The following entries are half-bytes split as:
  678. * bits 0-3: path A, bits 4-7: path B, all values 4 bits signed
  679. */
  680. struct rtl8723au_idx ht40_2s_tx_power_index_diff[3];
  681. struct rtl8723au_idx ht20_tx_power_index_diff[3]; /* 0x69 */
  682. struct rtl8723au_idx ofdm_tx_power_index_diff[3];
  683. struct rtl8723au_idx ht40_max_power_offset[3]; /* 0x6f */
  684. struct rtl8723au_idx ht20_max_power_offset[3];
  685. u8 channel_plan; /* 0x75 */
  686. u8 tssi_a;
  687. u8 tssi_b;
  688. u8 thermal_meter; /* xtal_k */ /* 0x78 */
  689. u8 rf_regulatory;
  690. u8 rf_option_2;
  691. u8 rf_option_3;
  692. u8 rf_option_4;
  693. u8 res5[1]; /* 0x7d */
  694. u8 version;
  695. u8 customer_id;
  696. };
  697. struct rtl8723bu_pwr_idx {
  698. #ifdef __LITTLE_ENDIAN
  699. int ht20:4;
  700. int ht40:4;
  701. int ofdm:4;
  702. int cck:4;
  703. #else
  704. int cck:4;
  705. int ofdm:4;
  706. int ht40:4;
  707. int ht20:4;
  708. #endif
  709. } __attribute__((packed));
  710. struct rtl8723bu_efuse_tx_power {
  711. u8 cck_base[6];
  712. u8 ht40_base[5];
  713. struct rtl8723au_idx ht20_ofdm_1s_diff;
  714. struct rtl8723bu_pwr_idx pwr_diff[3];
  715. u8 dummy5g[24]; /* max channel group (14) + power diff offset (10) */
  716. };
  717. struct rtl8723bu_efuse {
  718. __le16 rtl_id;
  719. u8 res0[0x0e];
  720. struct rtl8723bu_efuse_tx_power tx_power_index_A; /* 0x10 */
  721. struct rtl8723bu_efuse_tx_power tx_power_index_B; /* 0x3a */
  722. struct rtl8723bu_efuse_tx_power tx_power_index_C; /* 0x64 */
  723. struct rtl8723bu_efuse_tx_power tx_power_index_D; /* 0x8e */
  724. u8 channel_plan; /* 0xb8 */
  725. u8 xtal_k;
  726. u8 thermal_meter;
  727. u8 iqk_lck;
  728. u8 pa_type; /* 0xbc */
  729. u8 lna_type_2g; /* 0xbd */
  730. u8 res2[3];
  731. u8 rf_board_option;
  732. u8 rf_feature_option;
  733. u8 rf_bt_setting;
  734. u8 eeprom_version;
  735. u8 eeprom_customer_id;
  736. u8 res3[2];
  737. u8 tx_pwr_calibrate_rate;
  738. u8 rf_antenna_option; /* 0xc9 */
  739. u8 rfe_option;
  740. u8 res4[9];
  741. u8 usb_optional_function;
  742. u8 res5[0x1e];
  743. u8 res6[2];
  744. u8 serial[0x0b]; /* 0xf5 */
  745. u8 vid; /* 0x100 */
  746. u8 res7;
  747. u8 pid;
  748. u8 res8[4];
  749. u8 mac_addr[ETH_ALEN]; /* 0x107 */
  750. u8 res9[2];
  751. u8 vendor_name[0x07];
  752. u8 res10[2];
  753. u8 device_name[0x14];
  754. u8 res11[0xcf];
  755. u8 package_type; /* 0x1fb */
  756. u8 res12[0x4];
  757. };
  758. struct rtl8192eu_efuse_tx_power {
  759. u8 cck_base[6];
  760. u8 ht40_base[5];
  761. struct rtl8723au_idx ht20_ofdm_1s_diff;
  762. struct rtl8723bu_pwr_idx pwr_diff[3];
  763. u8 dummy5g[24]; /* max channel group (14) + power diff offset (10) */
  764. };
  765. struct rtl8192eu_efuse {
  766. __le16 rtl_id;
  767. u8 res0[0x0e];
  768. struct rtl8192eu_efuse_tx_power tx_power_index_A; /* 0x10 */
  769. struct rtl8192eu_efuse_tx_power tx_power_index_B; /* 0x3a */
  770. u8 res2[0x54];
  771. u8 channel_plan; /* 0xb8 */
  772. u8 xtal_k;
  773. u8 thermal_meter;
  774. u8 iqk_lck;
  775. u8 pa_type; /* 0xbc */
  776. u8 lna_type_2g; /* 0xbd */
  777. u8 res3[1];
  778. u8 lna_type_5g; /* 0xbf */
  779. u8 res4[1];
  780. u8 rf_board_option;
  781. u8 rf_feature_option;
  782. u8 rf_bt_setting;
  783. u8 eeprom_version;
  784. u8 eeprom_customer_id;
  785. u8 res5[3];
  786. u8 rf_antenna_option; /* 0xc9 */
  787. u8 res6[6];
  788. u8 vid; /* 0xd0 */
  789. u8 res7[1];
  790. u8 pid; /* 0xd2 */
  791. u8 res8[1];
  792. u8 usb_optional_function;
  793. u8 res9[2];
  794. u8 mac_addr[ETH_ALEN]; /* 0xd7 */
  795. u8 res10[2];
  796. u8 vendor_name[7];
  797. u8 res11[2];
  798. u8 device_name[0x0b]; /* 0xe8 */
  799. u8 res12[2];
  800. u8 serial[0x0b]; /* 0xf5 */
  801. u8 res13[0x30];
  802. u8 unknown[0x0d]; /* 0x130 */
  803. u8 res14[0xc3];
  804. };
  805. struct rtl8xxxu_reg8val {
  806. u16 reg;
  807. u8 val;
  808. };
  809. struct rtl8xxxu_reg32val {
  810. u16 reg;
  811. u32 val;
  812. };
  813. struct rtl8xxxu_rfregval {
  814. u8 reg;
  815. u32 val;
  816. };
  817. enum rtl8xxxu_rfpath {
  818. RF_A = 0,
  819. RF_B = 1,
  820. };
  821. struct rtl8xxxu_rfregs {
  822. u16 hssiparm1;
  823. u16 hssiparm2;
  824. u16 lssiparm;
  825. u16 hspiread;
  826. u16 lssiread;
  827. u16 rf_sw_ctrl;
  828. };
  829. #define H2C_MAX_MBOX 4
  830. #define H2C_EXT BIT(7)
  831. #define H2C_JOIN_BSS_DISCONNECT 0
  832. #define H2C_JOIN_BSS_CONNECT 1
  833. /*
  834. * H2C (firmware) commands differ between the older generation chips
  835. * 8188[cr]u, 819[12]cu, and 8723au, and the more recent chips 8723bu,
  836. * 8192[de]u, 8192eu, and 8812.
  837. */
  838. enum h2c_cmd_8723a {
  839. H2C_SET_POWER_MODE = 1,
  840. H2C_JOIN_BSS_REPORT = 2,
  841. H2C_SET_RSSI = 5,
  842. H2C_SET_RATE_MASK = (6 | H2C_EXT),
  843. };
  844. enum h2c_cmd_8723b {
  845. /*
  846. * Common Class: 000
  847. */
  848. H2C_8723B_RSVD_PAGE = 0x00,
  849. H2C_8723B_MEDIA_STATUS_RPT = 0x01,
  850. H2C_8723B_SCAN_ENABLE = 0x02,
  851. H2C_8723B_KEEP_ALIVE = 0x03,
  852. H2C_8723B_DISCON_DECISION = 0x04,
  853. H2C_8723B_PSD_OFFLOAD = 0x05,
  854. H2C_8723B_AP_OFFLOAD = 0x08,
  855. H2C_8723B_BCN_RSVDPAGE = 0x09,
  856. H2C_8723B_PROBERSP_RSVDPAGE = 0x0A,
  857. H2C_8723B_FCS_RSVDPAGE = 0x10,
  858. H2C_8723B_FCS_INFO = 0x11,
  859. H2C_8723B_AP_WOW_GPIO_CTRL = 0x13,
  860. /*
  861. * PoweSave Class: 001
  862. */
  863. H2C_8723B_SET_PWR_MODE = 0x20,
  864. H2C_8723B_PS_TUNING_PARA = 0x21,
  865. H2C_8723B_PS_TUNING_PARA2 = 0x22,
  866. H2C_8723B_P2P_LPS_PARAM = 0x23,
  867. H2C_8723B_P2P_PS_OFFLOAD = 0x24,
  868. H2C_8723B_PS_SCAN_ENABLE = 0x25,
  869. H2C_8723B_SAP_PS_ = 0x26,
  870. H2C_8723B_INACTIVE_PS_ = 0x27,
  871. H2C_8723B_FWLPS_IN_IPS_ = 0x28,
  872. /*
  873. * Dynamic Mechanism Class: 010
  874. */
  875. H2C_8723B_MACID_CFG_RAID = 0x40,
  876. H2C_8723B_TXBF = 0x41,
  877. H2C_8723B_RSSI_SETTING = 0x42,
  878. H2C_8723B_AP_REQ_TXRPT = 0x43,
  879. H2C_8723B_INIT_RATE_COLLECT = 0x44,
  880. /*
  881. * BT Class: 011
  882. */
  883. H2C_8723B_B_TYPE_TDMA = 0x60,
  884. H2C_8723B_BT_INFO = 0x61,
  885. H2C_8723B_FORCE_BT_TXPWR = 0x62,
  886. H2C_8723B_BT_IGNORE_WLANACT = 0x63,
  887. H2C_8723B_DAC_SWING_VALUE = 0x64,
  888. H2C_8723B_ANT_SEL_RSV = 0x65,
  889. H2C_8723B_WL_OPMODE = 0x66,
  890. H2C_8723B_BT_MP_OPER = 0x67,
  891. H2C_8723B_BT_CONTROL = 0x68,
  892. H2C_8723B_BT_WIFI_CTRL = 0x69,
  893. H2C_8723B_BT_FW_PATCH = 0x6a,
  894. H2C_8723B_BT_WLAN_CALIBRATION = 0x6d,
  895. H2C_8723B_BT_GRANT = 0x6e,
  896. /*
  897. * WOWLAN Class: 100
  898. */
  899. H2C_8723B_WOWLAN = 0x80,
  900. H2C_8723B_REMOTE_WAKE_CTRL = 0x81,
  901. H2C_8723B_AOAC_GLOBAL_INFO = 0x82,
  902. H2C_8723B_AOAC_RSVD_PAGE = 0x83,
  903. H2C_8723B_AOAC_RSVD_PAGE2 = 0x84,
  904. H2C_8723B_D0_SCAN_OFFLOAD_CTRL = 0x85,
  905. H2C_8723B_D0_SCAN_OFFLOAD_INFO = 0x86,
  906. H2C_8723B_CHNL_SWITCH_OFFLOAD = 0x87,
  907. H2C_8723B_RESET_TSF = 0xC0,
  908. };
  909. struct h2c_cmd {
  910. union {
  911. struct {
  912. u8 cmd;
  913. u8 data[7];
  914. } __packed cmd;
  915. struct {
  916. __le32 data;
  917. __le16 ext;
  918. } __packed raw;
  919. struct {
  920. __le32 data;
  921. __le32 ext;
  922. } __packed raw_wide;
  923. struct {
  924. u8 cmd;
  925. u8 data;
  926. } __packed joinbss;
  927. struct {
  928. u8 cmd;
  929. __le16 mask_hi;
  930. u8 arg;
  931. __le16 mask_lo;
  932. } __packed ramask;
  933. struct {
  934. u8 cmd;
  935. u8 parm;
  936. u8 macid;
  937. u8 macid_end;
  938. } __packed media_status_rpt;
  939. struct {
  940. u8 cmd;
  941. u8 macid;
  942. /*
  943. * [0:4] - RAID
  944. * [7] - SGI
  945. */
  946. u8 data1;
  947. /*
  948. * [0:1] - Bandwidth
  949. * [3] - No Update
  950. * [4:5] - VHT enable
  951. * [6] - DISPT
  952. * [7] - DISRA
  953. */
  954. u8 data2;
  955. u8 ramask0;
  956. u8 ramask1;
  957. u8 ramask2;
  958. u8 ramask3;
  959. } __packed b_macid_cfg;
  960. struct {
  961. u8 cmd;
  962. u8 data1;
  963. u8 data2;
  964. u8 data3;
  965. u8 data4;
  966. u8 data5;
  967. } __packed b_type_dma;
  968. struct {
  969. u8 cmd;
  970. u8 data;
  971. } __packed bt_info;
  972. struct {
  973. u8 cmd;
  974. u8 operreq;
  975. u8 opcode;
  976. u8 data;
  977. u8 addr;
  978. } __packed bt_mp_oper;
  979. struct {
  980. u8 cmd;
  981. u8 data;
  982. } __packed bt_wlan_calibration;
  983. struct {
  984. u8 cmd;
  985. u8 data;
  986. } __packed ignore_wlan;
  987. struct {
  988. u8 cmd;
  989. u8 ant_inverse;
  990. u8 int_switch_type;
  991. } __packed ant_sel_rsv;
  992. struct {
  993. u8 cmd;
  994. u8 data;
  995. } __packed bt_grant;
  996. };
  997. };
  998. enum c2h_evt_8723b {
  999. C2H_8723B_DEBUG = 0,
  1000. C2H_8723B_TSF = 1,
  1001. C2H_8723B_AP_RPT_RSP = 2,
  1002. C2H_8723B_CCX_TX_RPT = 3,
  1003. C2H_8723B_BT_RSSI = 4,
  1004. C2H_8723B_BT_OP_MODE = 5,
  1005. C2H_8723B_EXT_RA_RPT = 6,
  1006. C2H_8723B_BT_INFO = 9,
  1007. C2H_8723B_HW_INFO_EXCH = 0x0a,
  1008. C2H_8723B_BT_MP_INFO = 0x0b,
  1009. C2H_8723B_RA_REPORT = 0x0c,
  1010. C2H_8723B_FW_DEBUG = 0xff,
  1011. };
  1012. enum bt_info_src_8723b {
  1013. BT_INFO_SRC_8723B_WIFI_FW = 0x0,
  1014. BT_INFO_SRC_8723B_BT_RSP = 0x1,
  1015. BT_INFO_SRC_8723B_BT_ACTIVE_SEND = 0x2,
  1016. };
  1017. enum bt_mp_oper_opcode_8723b {
  1018. BT_MP_OP_GET_BT_VERSION = 0x00,
  1019. BT_MP_OP_RESET = 0x01,
  1020. BT_MP_OP_TEST_CTRL = 0x02,
  1021. BT_MP_OP_SET_BT_MODE = 0x03,
  1022. BT_MP_OP_SET_CHNL_TX_GAIN = 0x04,
  1023. BT_MP_OP_SET_PKT_TYPE_LEN = 0x05,
  1024. BT_MP_OP_SET_PKT_CNT_L_PL_TYPE = 0x06,
  1025. BT_MP_OP_SET_PKT_CNT_H_PKT_INTV = 0x07,
  1026. BT_MP_OP_SET_PKT_HEADER = 0x08,
  1027. BT_MP_OP_SET_WHITENCOEFF = 0x09,
  1028. BT_MP_OP_SET_BD_ADDR_L = 0x0a,
  1029. BT_MP_OP_SET_BD_ADDR_H = 0x0b,
  1030. BT_MP_OP_WRITE_REG_ADDR = 0x0c,
  1031. BT_MP_OP_WRITE_REG_VALUE = 0x0d,
  1032. BT_MP_OP_GET_BT_STATUS = 0x0e,
  1033. BT_MP_OP_GET_BD_ADDR_L = 0x0f,
  1034. BT_MP_OP_GET_BD_ADDR_H = 0x10,
  1035. BT_MP_OP_READ_REG = 0x11,
  1036. BT_MP_OP_SET_TARGET_BD_ADDR_L = 0x12,
  1037. BT_MP_OP_SET_TARGET_BD_ADDR_H = 0x13,
  1038. BT_MP_OP_SET_TX_POWER_CALIBRATION = 0x14,
  1039. BT_MP_OP_GET_RX_PKT_CNT_L = 0x15,
  1040. BT_MP_OP_GET_RX_PKT_CNT_H = 0x16,
  1041. BT_MP_OP_GET_RX_ERROR_BITS_L = 0x17,
  1042. BT_MP_OP_GET_RX_ERROR_BITS_H = 0x18,
  1043. BT_MP_OP_GET_RSSI = 0x19,
  1044. BT_MP_OP_GET_CFO_HDR_QUALITY_L = 0x1a,
  1045. BT_MP_OP_GET_CFO_HDR_QUALITY_H = 0x1b,
  1046. BT_MP_OP_GET_TARGET_BD_ADDR_L = 0x1c,
  1047. BT_MP_OP_GET_TARGET_BD_ADDR_H = 0x1d,
  1048. BT_MP_OP_GET_AFH_MAP_L = 0x1e,
  1049. BT_MP_OP_GET_AFH_MAP_M = 0x1f,
  1050. BT_MP_OP_GET_AFH_MAP_H = 0x20,
  1051. BT_MP_OP_GET_AFH_STATUS = 0x21,
  1052. BT_MP_OP_SET_TRACKING_INTERVAL = 0x22,
  1053. BT_MP_OP_SET_THERMAL_METER = 0x23,
  1054. BT_MP_OP_ENABLE_CFO_TRACKING = 0x24,
  1055. };
  1056. struct rtl8723bu_c2h {
  1057. u8 id;
  1058. u8 seq;
  1059. union {
  1060. struct {
  1061. u8 payload[0];
  1062. } __packed raw;
  1063. struct {
  1064. u8 ext_id;
  1065. u8 status:4;
  1066. u8 retlen:4;
  1067. u8 opcode_ver:4;
  1068. u8 req_num:4;
  1069. u8 payload[2];
  1070. } __packed bt_mp_info;
  1071. struct {
  1072. u8 response_source:4;
  1073. u8 dummy0_0:4;
  1074. u8 bt_info;
  1075. u8 retry_count:4;
  1076. u8 dummy2_0:1;
  1077. u8 bt_page:1;
  1078. u8 tx_rx_mask:1;
  1079. u8 dummy2_2:1;
  1080. u8 rssi;
  1081. u8 basic_rate:1;
  1082. u8 bt_has_reset:1;
  1083. u8 dummy4_1:1;
  1084. u8 ignore_wlan:1;
  1085. u8 auto_report:1;
  1086. u8 dummy4_2:3;
  1087. u8 a4;
  1088. u8 a5;
  1089. } __packed bt_info;
  1090. struct {
  1091. u8 rate:7;
  1092. u8 dummy0_0:1;
  1093. u8 macid;
  1094. u8 ldpc:1;
  1095. u8 txbf:1;
  1096. u8 noisy_state:1;
  1097. u8 dummy2_0:5;
  1098. u8 dummy3_0;
  1099. } __packed ra_report;
  1100. };
  1101. };
  1102. struct rtl8xxxu_fileops;
  1103. struct rtl8xxxu_priv {
  1104. struct ieee80211_hw *hw;
  1105. struct usb_device *udev;
  1106. struct rtl8xxxu_fileops *fops;
  1107. spinlock_t tx_urb_lock;
  1108. struct list_head tx_urb_free_list;
  1109. int tx_urb_free_count;
  1110. bool tx_stopped;
  1111. spinlock_t rx_urb_lock;
  1112. struct list_head rx_urb_pending_list;
  1113. int rx_urb_pending_count;
  1114. bool shutdown;
  1115. struct work_struct rx_urb_wq;
  1116. u8 mac_addr[ETH_ALEN];
  1117. char chip_name[8];
  1118. char chip_vendor[8];
  1119. u8 cck_tx_power_index_A[RTL8XXXU_MAX_CHANNEL_GROUPS];
  1120. u8 cck_tx_power_index_B[RTL8XXXU_MAX_CHANNEL_GROUPS];
  1121. u8 ht40_1s_tx_power_index_A[RTL8XXXU_MAX_CHANNEL_GROUPS];
  1122. u8 ht40_1s_tx_power_index_B[RTL8XXXU_MAX_CHANNEL_GROUPS];
  1123. /*
  1124. * The following entries are half-bytes split as:
  1125. * bits 0-3: path A, bits 4-7: path B, all values 4 bits signed
  1126. */
  1127. struct rtl8723au_idx ht40_2s_tx_power_index_diff[
  1128. RTL8723A_CHANNEL_GROUPS];
  1129. struct rtl8723au_idx ht20_tx_power_index_diff[RTL8723A_CHANNEL_GROUPS];
  1130. struct rtl8723au_idx ofdm_tx_power_index_diff[RTL8723A_CHANNEL_GROUPS];
  1131. struct rtl8723au_idx ht40_max_power_offset[RTL8723A_CHANNEL_GROUPS];
  1132. struct rtl8723au_idx ht20_max_power_offset[RTL8723A_CHANNEL_GROUPS];
  1133. /*
  1134. * Newer generation chips only keep power diffs per TX count,
  1135. * not per channel group.
  1136. */
  1137. struct rtl8723au_idx ofdm_tx_power_diff[RTL8723B_TX_COUNT];
  1138. struct rtl8723au_idx ht20_tx_power_diff[RTL8723B_TX_COUNT];
  1139. struct rtl8723au_idx ht40_tx_power_diff[RTL8723B_TX_COUNT];
  1140. struct rtl8xxxu_power_base *power_base;
  1141. u32 chip_cut:4;
  1142. u32 rom_rev:4;
  1143. u32 is_multi_func:1;
  1144. u32 has_wifi:1;
  1145. u32 has_bluetooth:1;
  1146. u32 enable_bluetooth:1;
  1147. u32 has_gps:1;
  1148. u32 hi_pa:1;
  1149. u32 vendor_umc:1;
  1150. u32 vendor_smic:1;
  1151. u32 has_polarity_ctrl:1;
  1152. u32 has_eeprom:1;
  1153. u32 boot_eeprom:1;
  1154. u32 usb_interrupts:1;
  1155. u32 ep_tx_high_queue:1;
  1156. u32 ep_tx_normal_queue:1;
  1157. u32 ep_tx_low_queue:1;
  1158. u32 has_xtalk:1;
  1159. u32 rx_buf_aggregation:1;
  1160. u8 xtalk;
  1161. unsigned int pipe_interrupt;
  1162. unsigned int pipe_in;
  1163. unsigned int pipe_out[TXDESC_QUEUE_MAX];
  1164. u8 out_ep[RTL8XXXU_OUT_ENDPOINTS];
  1165. u8 ep_tx_count;
  1166. u8 rf_paths;
  1167. u8 rx_paths;
  1168. u8 tx_paths;
  1169. u32 rege94;
  1170. u32 rege9c;
  1171. u32 regeb4;
  1172. u32 regebc;
  1173. int next_mbox;
  1174. int nr_out_eps;
  1175. struct mutex h2c_mutex;
  1176. struct usb_anchor rx_anchor;
  1177. struct usb_anchor tx_anchor;
  1178. struct usb_anchor int_anchor;
  1179. struct rtl8xxxu_firmware_header *fw_data;
  1180. size_t fw_size;
  1181. struct mutex usb_buf_mutex;
  1182. union {
  1183. __le32 val32;
  1184. __le16 val16;
  1185. u8 val8;
  1186. } usb_buf;
  1187. union {
  1188. u8 raw[EFUSE_MAP_LEN];
  1189. struct rtl8723au_efuse efuse8723;
  1190. struct rtl8723bu_efuse efuse8723bu;
  1191. struct rtl8192cu_efuse efuse8192;
  1192. struct rtl8192eu_efuse efuse8192eu;
  1193. } efuse_wifi;
  1194. u32 adda_backup[RTL8XXXU_ADDA_REGS];
  1195. u32 mac_backup[RTL8XXXU_MAC_REGS];
  1196. u32 bb_backup[RTL8XXXU_BB_REGS];
  1197. u32 bb_recovery_backup[RTL8XXXU_BB_REGS];
  1198. enum rtl8xxxu_rtl_chip rtl_chip;
  1199. u8 pi_enabled:1;
  1200. u8 no_pape:1;
  1201. u8 int_buf[USB_INTR_CONTENT_LENGTH];
  1202. };
  1203. struct rtl8xxxu_rx_urb {
  1204. struct urb urb;
  1205. struct ieee80211_hw *hw;
  1206. struct list_head list;
  1207. };
  1208. struct rtl8xxxu_tx_urb {
  1209. struct urb urb;
  1210. struct ieee80211_hw *hw;
  1211. struct list_head list;
  1212. };
  1213. struct rtl8xxxu_fileops {
  1214. int (*parse_efuse) (struct rtl8xxxu_priv *priv);
  1215. int (*load_firmware) (struct rtl8xxxu_priv *priv);
  1216. int (*power_on) (struct rtl8xxxu_priv *priv);
  1217. void (*power_off) (struct rtl8xxxu_priv *priv);
  1218. void (*reset_8051) (struct rtl8xxxu_priv *priv);
  1219. int (*llt_init) (struct rtl8xxxu_priv *priv);
  1220. void (*init_phy_bb) (struct rtl8xxxu_priv *priv);
  1221. int (*init_phy_rf) (struct rtl8xxxu_priv *priv);
  1222. void (*phy_init_antenna_selection) (struct rtl8xxxu_priv *priv);
  1223. void (*phy_iq_calibrate) (struct rtl8xxxu_priv *priv);
  1224. void (*config_channel) (struct ieee80211_hw *hw);
  1225. int (*parse_rx_desc) (struct rtl8xxxu_priv *priv, struct sk_buff *skb);
  1226. void (*init_aggregation) (struct rtl8xxxu_priv *priv);
  1227. void (*init_statistics) (struct rtl8xxxu_priv *priv);
  1228. void (*enable_rf) (struct rtl8xxxu_priv *priv);
  1229. void (*disable_rf) (struct rtl8xxxu_priv *priv);
  1230. void (*usb_quirks) (struct rtl8xxxu_priv *priv);
  1231. void (*set_tx_power) (struct rtl8xxxu_priv *priv, int channel,
  1232. bool ht40);
  1233. void (*update_rate_mask) (struct rtl8xxxu_priv *priv,
  1234. u32 ramask, int sgi);
  1235. void (*report_connect) (struct rtl8xxxu_priv *priv,
  1236. u8 macid, bool connect);
  1237. void (*fill_txdesc) (struct ieee80211_hw *hw, struct ieee80211_hdr *hdr,
  1238. struct ieee80211_tx_info *tx_info,
  1239. struct rtl8xxxu_txdesc32 *tx_desc, bool sgi,
  1240. bool short_preamble, bool ampdu_enable,
  1241. u32 rts_rate);
  1242. int writeN_block_size;
  1243. int rx_agg_buf_size;
  1244. char tx_desc_size;
  1245. char rx_desc_size;
  1246. u8 has_s0s1:1;
  1247. u8 has_tx_report:1;
  1248. u8 gen2_thermal_meter:1;
  1249. u8 needs_full_init:1;
  1250. u32 adda_1t_init;
  1251. u32 adda_1t_path_on;
  1252. u32 adda_2t_path_on_a;
  1253. u32 adda_2t_path_on_b;
  1254. u16 trxff_boundary;
  1255. u8 pbp_rx;
  1256. u8 pbp_tx;
  1257. struct rtl8xxxu_reg8val *mactable;
  1258. u8 total_page_num;
  1259. u8 page_num_hi;
  1260. u8 page_num_lo;
  1261. u8 page_num_norm;
  1262. };
  1263. extern int rtl8xxxu_debug;
  1264. extern struct rtl8xxxu_reg8val rtl8xxxu_gen1_mac_init_table[];
  1265. extern const u32 rtl8xxxu_iqk_phy_iq_bb_reg[];
  1266. u8 rtl8xxxu_read8(struct rtl8xxxu_priv *priv, u16 addr);
  1267. u16 rtl8xxxu_read16(struct rtl8xxxu_priv *priv, u16 addr);
  1268. u32 rtl8xxxu_read32(struct rtl8xxxu_priv *priv, u16 addr);
  1269. int rtl8xxxu_write8(struct rtl8xxxu_priv *priv, u16 addr, u8 val);
  1270. int rtl8xxxu_write16(struct rtl8xxxu_priv *priv, u16 addr, u16 val);
  1271. int rtl8xxxu_write32(struct rtl8xxxu_priv *priv, u16 addr, u32 val);
  1272. u32 rtl8xxxu_read_rfreg(struct rtl8xxxu_priv *priv,
  1273. enum rtl8xxxu_rfpath path, u8 reg);
  1274. int rtl8xxxu_write_rfreg(struct rtl8xxxu_priv *priv,
  1275. enum rtl8xxxu_rfpath path, u8 reg, u32 data);
  1276. void rtl8xxxu_save_regs(struct rtl8xxxu_priv *priv, const u32 *regs,
  1277. u32 *backup, int count);
  1278. void rtl8xxxu_restore_regs(struct rtl8xxxu_priv *priv, const u32 *regs,
  1279. u32 *backup, int count);
  1280. void rtl8xxxu_save_mac_regs(struct rtl8xxxu_priv *priv,
  1281. const u32 *reg, u32 *backup);
  1282. void rtl8xxxu_restore_mac_regs(struct rtl8xxxu_priv *priv,
  1283. const u32 *reg, u32 *backup);
  1284. void rtl8xxxu_path_adda_on(struct rtl8xxxu_priv *priv, const u32 *regs,
  1285. bool path_a_on);
  1286. void rtl8xxxu_mac_calibration(struct rtl8xxxu_priv *priv,
  1287. const u32 *regs, u32 *backup);
  1288. void rtl8xxxu_fill_iqk_matrix_a(struct rtl8xxxu_priv *priv, bool iqk_ok,
  1289. int result[][8], int candidate, bool tx_only);
  1290. void rtl8xxxu_fill_iqk_matrix_b(struct rtl8xxxu_priv *priv, bool iqk_ok,
  1291. int result[][8], int candidate, bool tx_only);
  1292. int rtl8xxxu_init_phy_rf(struct rtl8xxxu_priv *priv,
  1293. struct rtl8xxxu_rfregval *table,
  1294. enum rtl8xxxu_rfpath path);
  1295. int rtl8xxxu_init_phy_regs(struct rtl8xxxu_priv *priv,
  1296. struct rtl8xxxu_reg32val *array);
  1297. int rtl8xxxu_load_firmware(struct rtl8xxxu_priv *priv, char *fw_name);
  1298. void rtl8xxxu_firmware_self_reset(struct rtl8xxxu_priv *priv);
  1299. void rtl8xxxu_power_off(struct rtl8xxxu_priv *priv);
  1300. void rtl8xxxu_reset_8051(struct rtl8xxxu_priv *priv);
  1301. int rtl8xxxu_auto_llt_table(struct rtl8xxxu_priv *priv);
  1302. void rtl8xxxu_gen2_prepare_calibrate(struct rtl8xxxu_priv *priv, u8 start);
  1303. int rtl8xxxu_flush_fifo(struct rtl8xxxu_priv *priv);
  1304. int rtl8xxxu_gen2_h2c_cmd(struct rtl8xxxu_priv *priv,
  1305. struct h2c_cmd *h2c, int len);
  1306. int rtl8xxxu_active_to_lps(struct rtl8xxxu_priv *priv);
  1307. void rtl8xxxu_disabled_to_emu(struct rtl8xxxu_priv *priv);
  1308. int rtl8xxxu_init_llt_table(struct rtl8xxxu_priv *priv);
  1309. void rtl8xxxu_gen1_phy_iq_calibrate(struct rtl8xxxu_priv *priv);
  1310. void rtl8xxxu_gen1_init_phy_bb(struct rtl8xxxu_priv *priv);
  1311. void rtl8xxxu_gen1_set_tx_power(struct rtl8xxxu_priv *priv,
  1312. int channel, bool ht40);
  1313. void rtl8xxxu_gen1_config_channel(struct ieee80211_hw *hw);
  1314. void rtl8xxxu_gen2_config_channel(struct ieee80211_hw *hw);
  1315. void rtl8xxxu_gen1_usb_quirks(struct rtl8xxxu_priv *priv);
  1316. void rtl8xxxu_gen2_usb_quirks(struct rtl8xxxu_priv *priv);
  1317. void rtl8xxxu_update_rate_mask(struct rtl8xxxu_priv *priv,
  1318. u32 ramask, int sgi);
  1319. void rtl8xxxu_gen2_update_rate_mask(struct rtl8xxxu_priv *priv,
  1320. u32 ramask, int sgi);
  1321. void rtl8xxxu_gen1_report_connect(struct rtl8xxxu_priv *priv,
  1322. u8 macid, bool connect);
  1323. void rtl8xxxu_gen2_report_connect(struct rtl8xxxu_priv *priv,
  1324. u8 macid, bool connect);
  1325. void rtl8xxxu_gen1_init_aggregation(struct rtl8xxxu_priv *priv);
  1326. void rtl8xxxu_gen1_enable_rf(struct rtl8xxxu_priv *priv);
  1327. void rtl8xxxu_gen1_disable_rf(struct rtl8xxxu_priv *priv);
  1328. void rtl8xxxu_gen2_disable_rf(struct rtl8xxxu_priv *priv);
  1329. int rtl8xxxu_parse_rxdesc16(struct rtl8xxxu_priv *priv, struct sk_buff *skb);
  1330. int rtl8xxxu_parse_rxdesc24(struct rtl8xxxu_priv *priv, struct sk_buff *skb);
  1331. int rtl8xxxu_gen2_channel_to_group(int channel);
  1332. bool rtl8xxxu_gen2_simularity_compare(struct rtl8xxxu_priv *priv,
  1333. int result[][8], int c1, int c2);
  1334. void rtl8xxxu_fill_txdesc_v1(struct ieee80211_hw *hw, struct ieee80211_hdr *hdr,
  1335. struct ieee80211_tx_info *tx_info,
  1336. struct rtl8xxxu_txdesc32 *tx_desc, bool sgi,
  1337. bool short_preamble, bool ampdu_enable,
  1338. u32 rts_rate);
  1339. void rtl8xxxu_fill_txdesc_v2(struct ieee80211_hw *hw, struct ieee80211_hdr *hdr,
  1340. struct ieee80211_tx_info *tx_info,
  1341. struct rtl8xxxu_txdesc32 *tx_desc32, bool sgi,
  1342. bool short_preamble, bool ampdu_enable,
  1343. u32 rts_rate);
  1344. extern struct rtl8xxxu_fileops rtl8192cu_fops;
  1345. extern struct rtl8xxxu_fileops rtl8192eu_fops;
  1346. extern struct rtl8xxxu_fileops rtl8723au_fops;
  1347. extern struct rtl8xxxu_fileops rtl8723bu_fops;