rt73usb.h 30 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079
  1. /*
  2. Copyright (C) 2004 - 2009 Ivo van Doorn <IvDoorn@gmail.com>
  3. <http://rt2x00.serialmonkey.com>
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, see <http://www.gnu.org/licenses/>.
  14. */
  15. /*
  16. Module: rt73usb
  17. Abstract: Data structures and registers for the rt73usb module.
  18. Supported chipsets: rt2571W & rt2671.
  19. */
  20. #ifndef RT73USB_H
  21. #define RT73USB_H
  22. /*
  23. * RF chip defines.
  24. */
  25. #define RF5226 0x0001
  26. #define RF2528 0x0002
  27. #define RF5225 0x0003
  28. #define RF2527 0x0004
  29. /*
  30. * Signal information.
  31. * Default offset is required for RSSI <-> dBm conversion.
  32. */
  33. #define DEFAULT_RSSI_OFFSET 120
  34. /*
  35. * Register layout information.
  36. */
  37. #define CSR_REG_BASE 0x3000
  38. #define CSR_REG_SIZE 0x04b0
  39. #define EEPROM_BASE 0x0000
  40. #define EEPROM_SIZE 0x0100
  41. #define BBP_BASE 0x0000
  42. #define BBP_SIZE 0x0080
  43. #define RF_BASE 0x0004
  44. #define RF_SIZE 0x0010
  45. /*
  46. * Number of TX queues.
  47. */
  48. #define NUM_TX_QUEUES 4
  49. /*
  50. * USB registers.
  51. */
  52. /*
  53. * MCU_LEDCS: LED control for MCU Mailbox.
  54. */
  55. #define MCU_LEDCS_LED_MODE FIELD16(0x001f)
  56. #define MCU_LEDCS_RADIO_STATUS FIELD16(0x0020)
  57. #define MCU_LEDCS_LINK_BG_STATUS FIELD16(0x0040)
  58. #define MCU_LEDCS_LINK_A_STATUS FIELD16(0x0080)
  59. #define MCU_LEDCS_POLARITY_GPIO_0 FIELD16(0x0100)
  60. #define MCU_LEDCS_POLARITY_GPIO_1 FIELD16(0x0200)
  61. #define MCU_LEDCS_POLARITY_GPIO_2 FIELD16(0x0400)
  62. #define MCU_LEDCS_POLARITY_GPIO_3 FIELD16(0x0800)
  63. #define MCU_LEDCS_POLARITY_GPIO_4 FIELD16(0x1000)
  64. #define MCU_LEDCS_POLARITY_ACT FIELD16(0x2000)
  65. #define MCU_LEDCS_POLARITY_READY_BG FIELD16(0x4000)
  66. #define MCU_LEDCS_POLARITY_READY_A FIELD16(0x8000)
  67. /*
  68. * 8051 firmware image.
  69. */
  70. #define FIRMWARE_RT2571 "rt73.bin"
  71. #define FIRMWARE_IMAGE_BASE 0x0800
  72. /*
  73. * Security key table memory.
  74. * 16 entries 32-byte for shared key table
  75. * 64 entries 32-byte for pairwise key table
  76. * 64 entries 8-byte for pairwise ta key table
  77. */
  78. #define SHARED_KEY_TABLE_BASE 0x1000
  79. #define PAIRWISE_KEY_TABLE_BASE 0x1200
  80. #define PAIRWISE_TA_TABLE_BASE 0x1a00
  81. #define SHARED_KEY_ENTRY(__idx) \
  82. ( SHARED_KEY_TABLE_BASE + \
  83. ((__idx) * sizeof(struct hw_key_entry)) )
  84. #define PAIRWISE_KEY_ENTRY(__idx) \
  85. ( PAIRWISE_KEY_TABLE_BASE + \
  86. ((__idx) * sizeof(struct hw_key_entry)) )
  87. #define PAIRWISE_TA_ENTRY(__idx) \
  88. ( PAIRWISE_TA_TABLE_BASE + \
  89. ((__idx) * sizeof(struct hw_pairwise_ta_entry)) )
  90. struct hw_key_entry {
  91. u8 key[16];
  92. u8 tx_mic[8];
  93. u8 rx_mic[8];
  94. } __packed;
  95. struct hw_pairwise_ta_entry {
  96. u8 address[6];
  97. u8 cipher;
  98. u8 reserved;
  99. } __packed;
  100. /*
  101. * Since NULL frame won't be that long (256 byte),
  102. * We steal 16 tail bytes to save debugging settings.
  103. */
  104. #define HW_DEBUG_SETTING_BASE 0x2bf0
  105. /*
  106. * On-chip BEACON frame space.
  107. */
  108. #define HW_BEACON_BASE0 0x2400
  109. #define HW_BEACON_BASE1 0x2500
  110. #define HW_BEACON_BASE2 0x2600
  111. #define HW_BEACON_BASE3 0x2700
  112. #define HW_BEACON_OFFSET(__index) \
  113. ( HW_BEACON_BASE0 + (__index * 0x0100) )
  114. /*
  115. * MAC Control/Status Registers(CSR).
  116. * Some values are set in TU, whereas 1 TU == 1024 us.
  117. */
  118. /*
  119. * MAC_CSR0: ASIC revision number.
  120. */
  121. #define MAC_CSR0 0x3000
  122. #define MAC_CSR0_REVISION FIELD32(0x0000000f)
  123. #define MAC_CSR0_CHIPSET FIELD32(0x000ffff0)
  124. /*
  125. * MAC_CSR1: System control register.
  126. * SOFT_RESET: Software reset bit, 1: reset, 0: normal.
  127. * BBP_RESET: Hardware reset BBP.
  128. * HOST_READY: Host is ready after initialization, 1: ready.
  129. */
  130. #define MAC_CSR1 0x3004
  131. #define MAC_CSR1_SOFT_RESET FIELD32(0x00000001)
  132. #define MAC_CSR1_BBP_RESET FIELD32(0x00000002)
  133. #define MAC_CSR1_HOST_READY FIELD32(0x00000004)
  134. /*
  135. * MAC_CSR2: STA MAC register 0.
  136. */
  137. #define MAC_CSR2 0x3008
  138. #define MAC_CSR2_BYTE0 FIELD32(0x000000ff)
  139. #define MAC_CSR2_BYTE1 FIELD32(0x0000ff00)
  140. #define MAC_CSR2_BYTE2 FIELD32(0x00ff0000)
  141. #define MAC_CSR2_BYTE3 FIELD32(0xff000000)
  142. /*
  143. * MAC_CSR3: STA MAC register 1.
  144. * UNICAST_TO_ME_MASK:
  145. * Used to mask off bits from byte 5 of the MAC address
  146. * to determine the UNICAST_TO_ME bit for RX frames.
  147. * The full mask is complemented by BSS_ID_MASK:
  148. * MASK = BSS_ID_MASK & UNICAST_TO_ME_MASK
  149. */
  150. #define MAC_CSR3 0x300c
  151. #define MAC_CSR3_BYTE4 FIELD32(0x000000ff)
  152. #define MAC_CSR3_BYTE5 FIELD32(0x0000ff00)
  153. #define MAC_CSR3_UNICAST_TO_ME_MASK FIELD32(0x00ff0000)
  154. /*
  155. * MAC_CSR4: BSSID register 0.
  156. */
  157. #define MAC_CSR4 0x3010
  158. #define MAC_CSR4_BYTE0 FIELD32(0x000000ff)
  159. #define MAC_CSR4_BYTE1 FIELD32(0x0000ff00)
  160. #define MAC_CSR4_BYTE2 FIELD32(0x00ff0000)
  161. #define MAC_CSR4_BYTE3 FIELD32(0xff000000)
  162. /*
  163. * MAC_CSR5: BSSID register 1.
  164. * BSS_ID_MASK:
  165. * This mask is used to mask off bits 0 and 1 of byte 5 of the
  166. * BSSID. This will make sure that those bits will be ignored
  167. * when determining the MY_BSS of RX frames.
  168. * 0: 1-BSSID mode (BSS index = 0)
  169. * 1: 2-BSSID mode (BSS index: Byte5, bit 0)
  170. * 2: 2-BSSID mode (BSS index: byte5, bit 1)
  171. * 3: 4-BSSID mode (BSS index: byte5, bit 0 - 1)
  172. */
  173. #define MAC_CSR5 0x3014
  174. #define MAC_CSR5_BYTE4 FIELD32(0x000000ff)
  175. #define MAC_CSR5_BYTE5 FIELD32(0x0000ff00)
  176. #define MAC_CSR5_BSS_ID_MASK FIELD32(0x00ff0000)
  177. /*
  178. * MAC_CSR6: Maximum frame length register.
  179. */
  180. #define MAC_CSR6 0x3018
  181. #define MAC_CSR6_MAX_FRAME_UNIT FIELD32(0x00000fff)
  182. /*
  183. * MAC_CSR7: Reserved
  184. */
  185. #define MAC_CSR7 0x301c
  186. /*
  187. * MAC_CSR8: SIFS/EIFS register.
  188. * All units are in US.
  189. */
  190. #define MAC_CSR8 0x3020
  191. #define MAC_CSR8_SIFS FIELD32(0x000000ff)
  192. #define MAC_CSR8_SIFS_AFTER_RX_OFDM FIELD32(0x0000ff00)
  193. #define MAC_CSR8_EIFS FIELD32(0xffff0000)
  194. /*
  195. * MAC_CSR9: Back-Off control register.
  196. * SLOT_TIME: Slot time, default is 20us for 802.11BG.
  197. * CWMIN: Bit for Cwmin. default Cwmin is 31 (2^5 - 1).
  198. * CWMAX: Bit for Cwmax, default Cwmax is 1023 (2^10 - 1).
  199. * CW_SELECT: 1: CWmin/Cwmax select from register, 0:select from TxD.
  200. */
  201. #define MAC_CSR9 0x3024
  202. #define MAC_CSR9_SLOT_TIME FIELD32(0x000000ff)
  203. #define MAC_CSR9_CWMIN FIELD32(0x00000f00)
  204. #define MAC_CSR9_CWMAX FIELD32(0x0000f000)
  205. #define MAC_CSR9_CW_SELECT FIELD32(0x00010000)
  206. /*
  207. * MAC_CSR10: Power state configuration.
  208. */
  209. #define MAC_CSR10 0x3028
  210. /*
  211. * MAC_CSR11: Power saving transition time register.
  212. * DELAY_AFTER_TBCN: Delay after Tbcn expired in units of TU.
  213. * TBCN_BEFORE_WAKEUP: Number of beacon before wakeup.
  214. * WAKEUP_LATENCY: In unit of TU.
  215. */
  216. #define MAC_CSR11 0x302c
  217. #define MAC_CSR11_DELAY_AFTER_TBCN FIELD32(0x000000ff)
  218. #define MAC_CSR11_TBCN_BEFORE_WAKEUP FIELD32(0x00007f00)
  219. #define MAC_CSR11_AUTOWAKE FIELD32(0x00008000)
  220. #define MAC_CSR11_WAKEUP_LATENCY FIELD32(0x000f0000)
  221. /*
  222. * MAC_CSR12: Manual power control / status register (merge CSR20 & PWRCSR1).
  223. * CURRENT_STATE: 0:sleep, 1:awake.
  224. * FORCE_WAKEUP: This has higher priority than PUT_TO_SLEEP.
  225. * BBP_CURRENT_STATE: 0: BBP sleep, 1: BBP awake.
  226. */
  227. #define MAC_CSR12 0x3030
  228. #define MAC_CSR12_CURRENT_STATE FIELD32(0x00000001)
  229. #define MAC_CSR12_PUT_TO_SLEEP FIELD32(0x00000002)
  230. #define MAC_CSR12_FORCE_WAKEUP FIELD32(0x00000004)
  231. #define MAC_CSR12_BBP_CURRENT_STATE FIELD32(0x00000008)
  232. /*
  233. * MAC_CSR13: GPIO.
  234. * MAC_CSR13_VALx: GPIO value
  235. * MAC_CSR13_DIRx: GPIO direction: 0 = input; 1 = output
  236. */
  237. #define MAC_CSR13 0x3034
  238. #define MAC_CSR13_VAL0 FIELD32(0x00000001)
  239. #define MAC_CSR13_VAL1 FIELD32(0x00000002)
  240. #define MAC_CSR13_VAL2 FIELD32(0x00000004)
  241. #define MAC_CSR13_VAL3 FIELD32(0x00000008)
  242. #define MAC_CSR13_VAL4 FIELD32(0x00000010)
  243. #define MAC_CSR13_VAL5 FIELD32(0x00000020)
  244. #define MAC_CSR13_VAL6 FIELD32(0x00000040)
  245. #define MAC_CSR13_VAL7 FIELD32(0x00000080)
  246. #define MAC_CSR13_DIR0 FIELD32(0x00000100)
  247. #define MAC_CSR13_DIR1 FIELD32(0x00000200)
  248. #define MAC_CSR13_DIR2 FIELD32(0x00000400)
  249. #define MAC_CSR13_DIR3 FIELD32(0x00000800)
  250. #define MAC_CSR13_DIR4 FIELD32(0x00001000)
  251. #define MAC_CSR13_DIR5 FIELD32(0x00002000)
  252. #define MAC_CSR13_DIR6 FIELD32(0x00004000)
  253. #define MAC_CSR13_DIR7 FIELD32(0x00008000)
  254. /*
  255. * MAC_CSR14: LED control register.
  256. * ON_PERIOD: On period, default 70ms.
  257. * OFF_PERIOD: Off period, default 30ms.
  258. * HW_LED: HW TX activity, 1: normal OFF, 0: normal ON.
  259. * SW_LED: s/w LED, 1: ON, 0: OFF.
  260. * HW_LED_POLARITY: 0: active low, 1: active high.
  261. */
  262. #define MAC_CSR14 0x3038
  263. #define MAC_CSR14_ON_PERIOD FIELD32(0x000000ff)
  264. #define MAC_CSR14_OFF_PERIOD FIELD32(0x0000ff00)
  265. #define MAC_CSR14_HW_LED FIELD32(0x00010000)
  266. #define MAC_CSR14_SW_LED FIELD32(0x00020000)
  267. #define MAC_CSR14_HW_LED_POLARITY FIELD32(0x00040000)
  268. #define MAC_CSR14_SW_LED2 FIELD32(0x00080000)
  269. /*
  270. * MAC_CSR15: NAV control.
  271. */
  272. #define MAC_CSR15 0x303c
  273. /*
  274. * TXRX control registers.
  275. * Some values are set in TU, whereas 1 TU == 1024 us.
  276. */
  277. /*
  278. * TXRX_CSR0: TX/RX configuration register.
  279. * TSF_OFFSET: Default is 24.
  280. * AUTO_TX_SEQ: 1: ASIC auto replace sequence nr in outgoing frame.
  281. * DISABLE_RX: Disable Rx engine.
  282. * DROP_CRC: Drop CRC error.
  283. * DROP_PHYSICAL: Drop physical error.
  284. * DROP_CONTROL: Drop control frame.
  285. * DROP_NOT_TO_ME: Drop not to me unicast frame.
  286. * DROP_TO_DS: Drop fram ToDs bit is true.
  287. * DROP_VERSION_ERROR: Drop version error frame.
  288. * DROP_MULTICAST: Drop multicast frames.
  289. * DROP_BORADCAST: Drop broadcast frames.
  290. * DROP_ACK_CTS: Drop received ACK and CTS.
  291. */
  292. #define TXRX_CSR0 0x3040
  293. #define TXRX_CSR0_RX_ACK_TIMEOUT FIELD32(0x000001ff)
  294. #define TXRX_CSR0_TSF_OFFSET FIELD32(0x00007e00)
  295. #define TXRX_CSR0_AUTO_TX_SEQ FIELD32(0x00008000)
  296. #define TXRX_CSR0_DISABLE_RX FIELD32(0x00010000)
  297. #define TXRX_CSR0_DROP_CRC FIELD32(0x00020000)
  298. #define TXRX_CSR0_DROP_PHYSICAL FIELD32(0x00040000)
  299. #define TXRX_CSR0_DROP_CONTROL FIELD32(0x00080000)
  300. #define TXRX_CSR0_DROP_NOT_TO_ME FIELD32(0x00100000)
  301. #define TXRX_CSR0_DROP_TO_DS FIELD32(0x00200000)
  302. #define TXRX_CSR0_DROP_VERSION_ERROR FIELD32(0x00400000)
  303. #define TXRX_CSR0_DROP_MULTICAST FIELD32(0x00800000)
  304. #define TXRX_CSR0_DROP_BROADCAST FIELD32(0x01000000)
  305. #define TXRX_CSR0_DROP_ACK_CTS FIELD32(0x02000000)
  306. #define TXRX_CSR0_TX_WITHOUT_WAITING FIELD32(0x04000000)
  307. /*
  308. * TXRX_CSR1
  309. */
  310. #define TXRX_CSR1 0x3044
  311. #define TXRX_CSR1_BBP_ID0 FIELD32(0x0000007f)
  312. #define TXRX_CSR1_BBP_ID0_VALID FIELD32(0x00000080)
  313. #define TXRX_CSR1_BBP_ID1 FIELD32(0x00007f00)
  314. #define TXRX_CSR1_BBP_ID1_VALID FIELD32(0x00008000)
  315. #define TXRX_CSR1_BBP_ID2 FIELD32(0x007f0000)
  316. #define TXRX_CSR1_BBP_ID2_VALID FIELD32(0x00800000)
  317. #define TXRX_CSR1_BBP_ID3 FIELD32(0x7f000000)
  318. #define TXRX_CSR1_BBP_ID3_VALID FIELD32(0x80000000)
  319. /*
  320. * TXRX_CSR2
  321. */
  322. #define TXRX_CSR2 0x3048
  323. #define TXRX_CSR2_BBP_ID0 FIELD32(0x0000007f)
  324. #define TXRX_CSR2_BBP_ID0_VALID FIELD32(0x00000080)
  325. #define TXRX_CSR2_BBP_ID1 FIELD32(0x00007f00)
  326. #define TXRX_CSR2_BBP_ID1_VALID FIELD32(0x00008000)
  327. #define TXRX_CSR2_BBP_ID2 FIELD32(0x007f0000)
  328. #define TXRX_CSR2_BBP_ID2_VALID FIELD32(0x00800000)
  329. #define TXRX_CSR2_BBP_ID3 FIELD32(0x7f000000)
  330. #define TXRX_CSR2_BBP_ID3_VALID FIELD32(0x80000000)
  331. /*
  332. * TXRX_CSR3
  333. */
  334. #define TXRX_CSR3 0x304c
  335. #define TXRX_CSR3_BBP_ID0 FIELD32(0x0000007f)
  336. #define TXRX_CSR3_BBP_ID0_VALID FIELD32(0x00000080)
  337. #define TXRX_CSR3_BBP_ID1 FIELD32(0x00007f00)
  338. #define TXRX_CSR3_BBP_ID1_VALID FIELD32(0x00008000)
  339. #define TXRX_CSR3_BBP_ID2 FIELD32(0x007f0000)
  340. #define TXRX_CSR3_BBP_ID2_VALID FIELD32(0x00800000)
  341. #define TXRX_CSR3_BBP_ID3 FIELD32(0x7f000000)
  342. #define TXRX_CSR3_BBP_ID3_VALID FIELD32(0x80000000)
  343. /*
  344. * TXRX_CSR4: Auto-Responder/Tx-retry register.
  345. * AUTORESPOND_PREAMBLE: 0:long, 1:short preamble.
  346. * OFDM_TX_RATE_DOWN: 1:enable.
  347. * OFDM_TX_RATE_STEP: 0:1-step, 1: 2-step, 2:3-step, 3:4-step.
  348. * OFDM_TX_FALLBACK_CCK: 0: Fallback to OFDM 6M only, 1: Fallback to CCK 1M,2M.
  349. */
  350. #define TXRX_CSR4 0x3050
  351. #define TXRX_CSR4_TX_ACK_TIMEOUT FIELD32(0x000000ff)
  352. #define TXRX_CSR4_CNTL_ACK_POLICY FIELD32(0x00000700)
  353. #define TXRX_CSR4_ACK_CTS_PSM FIELD32(0x00010000)
  354. #define TXRX_CSR4_AUTORESPOND_ENABLE FIELD32(0x00020000)
  355. #define TXRX_CSR4_AUTORESPOND_PREAMBLE FIELD32(0x00040000)
  356. #define TXRX_CSR4_OFDM_TX_RATE_DOWN FIELD32(0x00080000)
  357. #define TXRX_CSR4_OFDM_TX_RATE_STEP FIELD32(0x00300000)
  358. #define TXRX_CSR4_OFDM_TX_FALLBACK_CCK FIELD32(0x00400000)
  359. #define TXRX_CSR4_LONG_RETRY_LIMIT FIELD32(0x0f000000)
  360. #define TXRX_CSR4_SHORT_RETRY_LIMIT FIELD32(0xf0000000)
  361. /*
  362. * TXRX_CSR5
  363. */
  364. #define TXRX_CSR5 0x3054
  365. /*
  366. * TXRX_CSR6: ACK/CTS payload consumed time
  367. */
  368. #define TXRX_CSR6 0x3058
  369. /*
  370. * TXRX_CSR7: OFDM ACK/CTS payload consumed time for 6/9/12/18 mbps.
  371. */
  372. #define TXRX_CSR7 0x305c
  373. #define TXRX_CSR7_ACK_CTS_6MBS FIELD32(0x000000ff)
  374. #define TXRX_CSR7_ACK_CTS_9MBS FIELD32(0x0000ff00)
  375. #define TXRX_CSR7_ACK_CTS_12MBS FIELD32(0x00ff0000)
  376. #define TXRX_CSR7_ACK_CTS_18MBS FIELD32(0xff000000)
  377. /*
  378. * TXRX_CSR8: OFDM ACK/CTS payload consumed time for 24/36/48/54 mbps.
  379. */
  380. #define TXRX_CSR8 0x3060
  381. #define TXRX_CSR8_ACK_CTS_24MBS FIELD32(0x000000ff)
  382. #define TXRX_CSR8_ACK_CTS_36MBS FIELD32(0x0000ff00)
  383. #define TXRX_CSR8_ACK_CTS_48MBS FIELD32(0x00ff0000)
  384. #define TXRX_CSR8_ACK_CTS_54MBS FIELD32(0xff000000)
  385. /*
  386. * TXRX_CSR9: Synchronization control register.
  387. * BEACON_INTERVAL: In unit of 1/16 TU.
  388. * TSF_TICKING: Enable TSF auto counting.
  389. * TSF_SYNC: Tsf sync, 0: disable, 1: infra, 2: ad-hoc/master mode.
  390. * BEACON_GEN: Enable beacon generator.
  391. */
  392. #define TXRX_CSR9 0x3064
  393. #define TXRX_CSR9_BEACON_INTERVAL FIELD32(0x0000ffff)
  394. #define TXRX_CSR9_TSF_TICKING FIELD32(0x00010000)
  395. #define TXRX_CSR9_TSF_SYNC FIELD32(0x00060000)
  396. #define TXRX_CSR9_TBTT_ENABLE FIELD32(0x00080000)
  397. #define TXRX_CSR9_BEACON_GEN FIELD32(0x00100000)
  398. #define TXRX_CSR9_TIMESTAMP_COMPENSATE FIELD32(0xff000000)
  399. /*
  400. * TXRX_CSR10: BEACON alignment.
  401. */
  402. #define TXRX_CSR10 0x3068
  403. /*
  404. * TXRX_CSR11: AES mask.
  405. */
  406. #define TXRX_CSR11 0x306c
  407. /*
  408. * TXRX_CSR12: TSF low 32.
  409. */
  410. #define TXRX_CSR12 0x3070
  411. #define TXRX_CSR12_LOW_TSFTIMER FIELD32(0xffffffff)
  412. /*
  413. * TXRX_CSR13: TSF high 32.
  414. */
  415. #define TXRX_CSR13 0x3074
  416. #define TXRX_CSR13_HIGH_TSFTIMER FIELD32(0xffffffff)
  417. /*
  418. * TXRX_CSR14: TBTT timer.
  419. */
  420. #define TXRX_CSR14 0x3078
  421. /*
  422. * TXRX_CSR15: TKIP MIC priority byte "AND" mask.
  423. */
  424. #define TXRX_CSR15 0x307c
  425. /*
  426. * PHY control registers.
  427. * Some values are set in TU, whereas 1 TU == 1024 us.
  428. */
  429. /*
  430. * PHY_CSR0: RF/PS control.
  431. */
  432. #define PHY_CSR0 0x3080
  433. #define PHY_CSR0_PA_PE_BG FIELD32(0x00010000)
  434. #define PHY_CSR0_PA_PE_A FIELD32(0x00020000)
  435. /*
  436. * PHY_CSR1
  437. */
  438. #define PHY_CSR1 0x3084
  439. #define PHY_CSR1_RF_RPI FIELD32(0x00010000)
  440. /*
  441. * PHY_CSR2: Pre-TX BBP control.
  442. */
  443. #define PHY_CSR2 0x3088
  444. /*
  445. * PHY_CSR3: BBP serial control register.
  446. * VALUE: Register value to program into BBP.
  447. * REG_NUM: Selected BBP register.
  448. * READ_CONTROL: 0: Write BBP, 1: Read BBP.
  449. * BUSY: 1: ASIC is busy execute BBP programming.
  450. */
  451. #define PHY_CSR3 0x308c
  452. #define PHY_CSR3_VALUE FIELD32(0x000000ff)
  453. #define PHY_CSR3_REGNUM FIELD32(0x00007f00)
  454. #define PHY_CSR3_READ_CONTROL FIELD32(0x00008000)
  455. #define PHY_CSR3_BUSY FIELD32(0x00010000)
  456. /*
  457. * PHY_CSR4: RF serial control register
  458. * VALUE: Register value (include register id) serial out to RF/IF chip.
  459. * NUMBER_OF_BITS: Number of bits used in RFRegValue (I:20, RFMD:22).
  460. * IF_SELECT: 1: select IF to program, 0: select RF to program.
  461. * PLL_LD: RF PLL_LD status.
  462. * BUSY: 1: ASIC is busy execute RF programming.
  463. */
  464. #define PHY_CSR4 0x3090
  465. #define PHY_CSR4_VALUE FIELD32(0x00ffffff)
  466. #define PHY_CSR4_NUMBER_OF_BITS FIELD32(0x1f000000)
  467. #define PHY_CSR4_IF_SELECT FIELD32(0x20000000)
  468. #define PHY_CSR4_PLL_LD FIELD32(0x40000000)
  469. #define PHY_CSR4_BUSY FIELD32(0x80000000)
  470. /*
  471. * PHY_CSR5: RX to TX signal switch timing control.
  472. */
  473. #define PHY_CSR5 0x3094
  474. #define PHY_CSR5_IQ_FLIP FIELD32(0x00000004)
  475. /*
  476. * PHY_CSR6: TX to RX signal timing control.
  477. */
  478. #define PHY_CSR6 0x3098
  479. #define PHY_CSR6_IQ_FLIP FIELD32(0x00000004)
  480. /*
  481. * PHY_CSR7: TX DAC switching timing control.
  482. */
  483. #define PHY_CSR7 0x309c
  484. /*
  485. * Security control register.
  486. */
  487. /*
  488. * SEC_CSR0: Shared key table control.
  489. */
  490. #define SEC_CSR0 0x30a0
  491. #define SEC_CSR0_BSS0_KEY0_VALID FIELD32(0x00000001)
  492. #define SEC_CSR0_BSS0_KEY1_VALID FIELD32(0x00000002)
  493. #define SEC_CSR0_BSS0_KEY2_VALID FIELD32(0x00000004)
  494. #define SEC_CSR0_BSS0_KEY3_VALID FIELD32(0x00000008)
  495. #define SEC_CSR0_BSS1_KEY0_VALID FIELD32(0x00000010)
  496. #define SEC_CSR0_BSS1_KEY1_VALID FIELD32(0x00000020)
  497. #define SEC_CSR0_BSS1_KEY2_VALID FIELD32(0x00000040)
  498. #define SEC_CSR0_BSS1_KEY3_VALID FIELD32(0x00000080)
  499. #define SEC_CSR0_BSS2_KEY0_VALID FIELD32(0x00000100)
  500. #define SEC_CSR0_BSS2_KEY1_VALID FIELD32(0x00000200)
  501. #define SEC_CSR0_BSS2_KEY2_VALID FIELD32(0x00000400)
  502. #define SEC_CSR0_BSS2_KEY3_VALID FIELD32(0x00000800)
  503. #define SEC_CSR0_BSS3_KEY0_VALID FIELD32(0x00001000)
  504. #define SEC_CSR0_BSS3_KEY1_VALID FIELD32(0x00002000)
  505. #define SEC_CSR0_BSS3_KEY2_VALID FIELD32(0x00004000)
  506. #define SEC_CSR0_BSS3_KEY3_VALID FIELD32(0x00008000)
  507. /*
  508. * SEC_CSR1: Shared key table security mode register.
  509. */
  510. #define SEC_CSR1 0x30a4
  511. #define SEC_CSR1_BSS0_KEY0_CIPHER_ALG FIELD32(0x00000007)
  512. #define SEC_CSR1_BSS0_KEY1_CIPHER_ALG FIELD32(0x00000070)
  513. #define SEC_CSR1_BSS0_KEY2_CIPHER_ALG FIELD32(0x00000700)
  514. #define SEC_CSR1_BSS0_KEY3_CIPHER_ALG FIELD32(0x00007000)
  515. #define SEC_CSR1_BSS1_KEY0_CIPHER_ALG FIELD32(0x00070000)
  516. #define SEC_CSR1_BSS1_KEY1_CIPHER_ALG FIELD32(0x00700000)
  517. #define SEC_CSR1_BSS1_KEY2_CIPHER_ALG FIELD32(0x07000000)
  518. #define SEC_CSR1_BSS1_KEY3_CIPHER_ALG FIELD32(0x70000000)
  519. /*
  520. * Pairwise key table valid bitmap registers.
  521. * SEC_CSR2: pairwise key table valid bitmap 0.
  522. * SEC_CSR3: pairwise key table valid bitmap 1.
  523. */
  524. #define SEC_CSR2 0x30a8
  525. #define SEC_CSR3 0x30ac
  526. /*
  527. * SEC_CSR4: Pairwise key table lookup control.
  528. */
  529. #define SEC_CSR4 0x30b0
  530. #define SEC_CSR4_ENABLE_BSS0 FIELD32(0x00000001)
  531. #define SEC_CSR4_ENABLE_BSS1 FIELD32(0x00000002)
  532. #define SEC_CSR4_ENABLE_BSS2 FIELD32(0x00000004)
  533. #define SEC_CSR4_ENABLE_BSS3 FIELD32(0x00000008)
  534. /*
  535. * SEC_CSR5: shared key table security mode register.
  536. */
  537. #define SEC_CSR5 0x30b4
  538. #define SEC_CSR5_BSS2_KEY0_CIPHER_ALG FIELD32(0x00000007)
  539. #define SEC_CSR5_BSS2_KEY1_CIPHER_ALG FIELD32(0x00000070)
  540. #define SEC_CSR5_BSS2_KEY2_CIPHER_ALG FIELD32(0x00000700)
  541. #define SEC_CSR5_BSS2_KEY3_CIPHER_ALG FIELD32(0x00007000)
  542. #define SEC_CSR5_BSS3_KEY0_CIPHER_ALG FIELD32(0x00070000)
  543. #define SEC_CSR5_BSS3_KEY1_CIPHER_ALG FIELD32(0x00700000)
  544. #define SEC_CSR5_BSS3_KEY2_CIPHER_ALG FIELD32(0x07000000)
  545. #define SEC_CSR5_BSS3_KEY3_CIPHER_ALG FIELD32(0x70000000)
  546. /*
  547. * STA control registers.
  548. */
  549. /*
  550. * STA_CSR0: RX PLCP error count & RX FCS error count.
  551. */
  552. #define STA_CSR0 0x30c0
  553. #define STA_CSR0_FCS_ERROR FIELD32(0x0000ffff)
  554. #define STA_CSR0_PLCP_ERROR FIELD32(0xffff0000)
  555. /*
  556. * STA_CSR1: RX False CCA count & RX LONG frame count.
  557. */
  558. #define STA_CSR1 0x30c4
  559. #define STA_CSR1_PHYSICAL_ERROR FIELD32(0x0000ffff)
  560. #define STA_CSR1_FALSE_CCA_ERROR FIELD32(0xffff0000)
  561. /*
  562. * STA_CSR2: TX Beacon count and RX FIFO overflow count.
  563. */
  564. #define STA_CSR2 0x30c8
  565. #define STA_CSR2_RX_FIFO_OVERFLOW_COUNT FIELD32(0x0000ffff)
  566. #define STA_CSR2_RX_OVERFLOW_COUNT FIELD32(0xffff0000)
  567. /*
  568. * STA_CSR3: TX Beacon count.
  569. */
  570. #define STA_CSR3 0x30cc
  571. #define STA_CSR3_TX_BEACON_COUNT FIELD32(0x0000ffff)
  572. /*
  573. * STA_CSR4: TX Retry count.
  574. */
  575. #define STA_CSR4 0x30d0
  576. #define STA_CSR4_TX_NO_RETRY_COUNT FIELD32(0x0000ffff)
  577. #define STA_CSR4_TX_ONE_RETRY_COUNT FIELD32(0xffff0000)
  578. /*
  579. * STA_CSR5: TX Retry count.
  580. */
  581. #define STA_CSR5 0x30d4
  582. #define STA_CSR4_TX_MULTI_RETRY_COUNT FIELD32(0x0000ffff)
  583. #define STA_CSR4_TX_RETRY_FAIL_COUNT FIELD32(0xffff0000)
  584. /*
  585. * QOS control registers.
  586. */
  587. /*
  588. * QOS_CSR1: TXOP holder MAC address register.
  589. */
  590. #define QOS_CSR1 0x30e4
  591. #define QOS_CSR1_BYTE4 FIELD32(0x000000ff)
  592. #define QOS_CSR1_BYTE5 FIELD32(0x0000ff00)
  593. /*
  594. * QOS_CSR2: TXOP holder timeout register.
  595. */
  596. #define QOS_CSR2 0x30e8
  597. /*
  598. * RX QOS-CFPOLL MAC address register.
  599. * QOS_CSR3: RX QOS-CFPOLL MAC address 0.
  600. * QOS_CSR4: RX QOS-CFPOLL MAC address 1.
  601. */
  602. #define QOS_CSR3 0x30ec
  603. #define QOS_CSR4 0x30f0
  604. /*
  605. * QOS_CSR5: "QosControl" field of the RX QOS-CFPOLL.
  606. */
  607. #define QOS_CSR5 0x30f4
  608. /*
  609. * WMM Scheduler Register
  610. */
  611. /*
  612. * AIFSN_CSR: AIFSN for each EDCA AC.
  613. * AIFSN0: For AC_VO.
  614. * AIFSN1: For AC_VI.
  615. * AIFSN2: For AC_BE.
  616. * AIFSN3: For AC_BK.
  617. */
  618. #define AIFSN_CSR 0x0400
  619. #define AIFSN_CSR_AIFSN0 FIELD32(0x0000000f)
  620. #define AIFSN_CSR_AIFSN1 FIELD32(0x000000f0)
  621. #define AIFSN_CSR_AIFSN2 FIELD32(0x00000f00)
  622. #define AIFSN_CSR_AIFSN3 FIELD32(0x0000f000)
  623. /*
  624. * CWMIN_CSR: CWmin for each EDCA AC.
  625. * CWMIN0: For AC_VO.
  626. * CWMIN1: For AC_VI.
  627. * CWMIN2: For AC_BE.
  628. * CWMIN3: For AC_BK.
  629. */
  630. #define CWMIN_CSR 0x0404
  631. #define CWMIN_CSR_CWMIN0 FIELD32(0x0000000f)
  632. #define CWMIN_CSR_CWMIN1 FIELD32(0x000000f0)
  633. #define CWMIN_CSR_CWMIN2 FIELD32(0x00000f00)
  634. #define CWMIN_CSR_CWMIN3 FIELD32(0x0000f000)
  635. /*
  636. * CWMAX_CSR: CWmax for each EDCA AC.
  637. * CWMAX0: For AC_VO.
  638. * CWMAX1: For AC_VI.
  639. * CWMAX2: For AC_BE.
  640. * CWMAX3: For AC_BK.
  641. */
  642. #define CWMAX_CSR 0x0408
  643. #define CWMAX_CSR_CWMAX0 FIELD32(0x0000000f)
  644. #define CWMAX_CSR_CWMAX1 FIELD32(0x000000f0)
  645. #define CWMAX_CSR_CWMAX2 FIELD32(0x00000f00)
  646. #define CWMAX_CSR_CWMAX3 FIELD32(0x0000f000)
  647. /*
  648. * AC_TXOP_CSR0: AC_VO/AC_VI TXOP register.
  649. * AC0_TX_OP: For AC_VO, in unit of 32us.
  650. * AC1_TX_OP: For AC_VI, in unit of 32us.
  651. */
  652. #define AC_TXOP_CSR0 0x040c
  653. #define AC_TXOP_CSR0_AC0_TX_OP FIELD32(0x0000ffff)
  654. #define AC_TXOP_CSR0_AC1_TX_OP FIELD32(0xffff0000)
  655. /*
  656. * AC_TXOP_CSR1: AC_BE/AC_BK TXOP register.
  657. * AC2_TX_OP: For AC_BE, in unit of 32us.
  658. * AC3_TX_OP: For AC_BK, in unit of 32us.
  659. */
  660. #define AC_TXOP_CSR1 0x0410
  661. #define AC_TXOP_CSR1_AC2_TX_OP FIELD32(0x0000ffff)
  662. #define AC_TXOP_CSR1_AC3_TX_OP FIELD32(0xffff0000)
  663. /*
  664. * BBP registers.
  665. * The wordsize of the BBP is 8 bits.
  666. */
  667. /*
  668. * R2
  669. */
  670. #define BBP_R2_BG_MODE FIELD8(0x20)
  671. /*
  672. * R3
  673. */
  674. #define BBP_R3_SMART_MODE FIELD8(0x01)
  675. /*
  676. * R4: RX antenna control
  677. * FRAME_END: 1 - DPDT, 0 - SPDT (Only valid for 802.11G, RF2527 & RF2529)
  678. */
  679. /*
  680. * ANTENNA_CONTROL semantics (guessed):
  681. * 0x1: Software controlled antenna switching (fixed or SW diversity)
  682. * 0x2: Hardware diversity.
  683. */
  684. #define BBP_R4_RX_ANTENNA_CONTROL FIELD8(0x03)
  685. #define BBP_R4_RX_FRAME_END FIELD8(0x20)
  686. /*
  687. * R77
  688. */
  689. #define BBP_R77_RX_ANTENNA FIELD8(0x03)
  690. /*
  691. * RF registers
  692. */
  693. /*
  694. * RF 3
  695. */
  696. #define RF3_TXPOWER FIELD32(0x00003e00)
  697. /*
  698. * RF 4
  699. */
  700. #define RF4_FREQ_OFFSET FIELD32(0x0003f000)
  701. /*
  702. * EEPROM content.
  703. * The wordsize of the EEPROM is 16 bits.
  704. */
  705. /*
  706. * HW MAC address.
  707. */
  708. #define EEPROM_MAC_ADDR_0 0x0002
  709. #define EEPROM_MAC_ADDR_BYTE0 FIELD16(0x00ff)
  710. #define EEPROM_MAC_ADDR_BYTE1 FIELD16(0xff00)
  711. #define EEPROM_MAC_ADDR1 0x0003
  712. #define EEPROM_MAC_ADDR_BYTE2 FIELD16(0x00ff)
  713. #define EEPROM_MAC_ADDR_BYTE3 FIELD16(0xff00)
  714. #define EEPROM_MAC_ADDR_2 0x0004
  715. #define EEPROM_MAC_ADDR_BYTE4 FIELD16(0x00ff)
  716. #define EEPROM_MAC_ADDR_BYTE5 FIELD16(0xff00)
  717. /*
  718. * EEPROM antenna.
  719. * ANTENNA_NUM: Number of antennas.
  720. * TX_DEFAULT: Default antenna 0: diversity, 1: A, 2: B.
  721. * RX_DEFAULT: Default antenna 0: diversity, 1: A, 2: B.
  722. * FRAME_TYPE: 0: DPDT , 1: SPDT , noted this bit is valid for g only.
  723. * DYN_TXAGC: Dynamic TX AGC control.
  724. * HARDWARE_RADIO: 1: Hardware controlled radio. Read GPIO0.
  725. * RF_TYPE: Rf_type of this adapter.
  726. */
  727. #define EEPROM_ANTENNA 0x0010
  728. #define EEPROM_ANTENNA_NUM FIELD16(0x0003)
  729. #define EEPROM_ANTENNA_TX_DEFAULT FIELD16(0x000c)
  730. #define EEPROM_ANTENNA_RX_DEFAULT FIELD16(0x0030)
  731. #define EEPROM_ANTENNA_FRAME_TYPE FIELD16(0x0040)
  732. #define EEPROM_ANTENNA_DYN_TXAGC FIELD16(0x0200)
  733. #define EEPROM_ANTENNA_HARDWARE_RADIO FIELD16(0x0400)
  734. #define EEPROM_ANTENNA_RF_TYPE FIELD16(0xf800)
  735. /*
  736. * EEPROM NIC config.
  737. * EXTERNAL_LNA: External LNA.
  738. */
  739. #define EEPROM_NIC 0x0011
  740. #define EEPROM_NIC_EXTERNAL_LNA FIELD16(0x0010)
  741. /*
  742. * EEPROM geography.
  743. * GEO_A: Default geographical setting for 5GHz band
  744. * GEO: Default geographical setting.
  745. */
  746. #define EEPROM_GEOGRAPHY 0x0012
  747. #define EEPROM_GEOGRAPHY_GEO_A FIELD16(0x00ff)
  748. #define EEPROM_GEOGRAPHY_GEO FIELD16(0xff00)
  749. /*
  750. * EEPROM BBP.
  751. */
  752. #define EEPROM_BBP_START 0x0013
  753. #define EEPROM_BBP_SIZE 16
  754. #define EEPROM_BBP_VALUE FIELD16(0x00ff)
  755. #define EEPROM_BBP_REG_ID FIELD16(0xff00)
  756. /*
  757. * EEPROM TXPOWER 802.11G
  758. */
  759. #define EEPROM_TXPOWER_G_START 0x0023
  760. #define EEPROM_TXPOWER_G_SIZE 7
  761. #define EEPROM_TXPOWER_G_1 FIELD16(0x00ff)
  762. #define EEPROM_TXPOWER_G_2 FIELD16(0xff00)
  763. /*
  764. * EEPROM Frequency
  765. */
  766. #define EEPROM_FREQ 0x002f
  767. #define EEPROM_FREQ_OFFSET FIELD16(0x00ff)
  768. #define EEPROM_FREQ_SEQ_MASK FIELD16(0xff00)
  769. #define EEPROM_FREQ_SEQ FIELD16(0x0300)
  770. /*
  771. * EEPROM LED.
  772. * POLARITY_RDY_G: Polarity RDY_G setting.
  773. * POLARITY_RDY_A: Polarity RDY_A setting.
  774. * POLARITY_ACT: Polarity ACT setting.
  775. * POLARITY_GPIO_0: Polarity GPIO0 setting.
  776. * POLARITY_GPIO_1: Polarity GPIO1 setting.
  777. * POLARITY_GPIO_2: Polarity GPIO2 setting.
  778. * POLARITY_GPIO_3: Polarity GPIO3 setting.
  779. * POLARITY_GPIO_4: Polarity GPIO4 setting.
  780. * LED_MODE: Led mode.
  781. */
  782. #define EEPROM_LED 0x0030
  783. #define EEPROM_LED_POLARITY_RDY_G FIELD16(0x0001)
  784. #define EEPROM_LED_POLARITY_RDY_A FIELD16(0x0002)
  785. #define EEPROM_LED_POLARITY_ACT FIELD16(0x0004)
  786. #define EEPROM_LED_POLARITY_GPIO_0 FIELD16(0x0008)
  787. #define EEPROM_LED_POLARITY_GPIO_1 FIELD16(0x0010)
  788. #define EEPROM_LED_POLARITY_GPIO_2 FIELD16(0x0020)
  789. #define EEPROM_LED_POLARITY_GPIO_3 FIELD16(0x0040)
  790. #define EEPROM_LED_POLARITY_GPIO_4 FIELD16(0x0080)
  791. #define EEPROM_LED_LED_MODE FIELD16(0x1f00)
  792. /*
  793. * EEPROM TXPOWER 802.11A
  794. */
  795. #define EEPROM_TXPOWER_A_START 0x0031
  796. #define EEPROM_TXPOWER_A_SIZE 12
  797. #define EEPROM_TXPOWER_A_1 FIELD16(0x00ff)
  798. #define EEPROM_TXPOWER_A_2 FIELD16(0xff00)
  799. /*
  800. * EEPROM RSSI offset 802.11BG
  801. */
  802. #define EEPROM_RSSI_OFFSET_BG 0x004d
  803. #define EEPROM_RSSI_OFFSET_BG_1 FIELD16(0x00ff)
  804. #define EEPROM_RSSI_OFFSET_BG_2 FIELD16(0xff00)
  805. /*
  806. * EEPROM RSSI offset 802.11A
  807. */
  808. #define EEPROM_RSSI_OFFSET_A 0x004e
  809. #define EEPROM_RSSI_OFFSET_A_1 FIELD16(0x00ff)
  810. #define EEPROM_RSSI_OFFSET_A_2 FIELD16(0xff00)
  811. /*
  812. * DMA descriptor defines.
  813. */
  814. #define TXD_DESC_SIZE ( 6 * sizeof(__le32) )
  815. #define TXINFO_SIZE ( 6 * sizeof(__le32) )
  816. #define RXD_DESC_SIZE ( 6 * sizeof(__le32) )
  817. /*
  818. * TX descriptor format for TX, PRIO and Beacon Ring.
  819. */
  820. /*
  821. * Word0
  822. * BURST: Next frame belongs to same "burst" event.
  823. * TKIP_MIC: ASIC appends TKIP MIC if TKIP is used.
  824. * KEY_TABLE: Use per-client pairwise KEY table.
  825. * KEY_INDEX:
  826. * Key index (0~31) to the pairwise KEY table.
  827. * 0~3 to shared KEY table 0 (BSS0).
  828. * 4~7 to shared KEY table 1 (BSS1).
  829. * 8~11 to shared KEY table 2 (BSS2).
  830. * 12~15 to shared KEY table 3 (BSS3).
  831. * BURST2: For backward compatibility, set to same value as BURST.
  832. */
  833. #define TXD_W0_BURST FIELD32(0x00000001)
  834. #define TXD_W0_VALID FIELD32(0x00000002)
  835. #define TXD_W0_MORE_FRAG FIELD32(0x00000004)
  836. #define TXD_W0_ACK FIELD32(0x00000008)
  837. #define TXD_W0_TIMESTAMP FIELD32(0x00000010)
  838. #define TXD_W0_OFDM FIELD32(0x00000020)
  839. #define TXD_W0_IFS FIELD32(0x00000040)
  840. #define TXD_W0_RETRY_MODE FIELD32(0x00000080)
  841. #define TXD_W0_TKIP_MIC FIELD32(0x00000100)
  842. #define TXD_W0_KEY_TABLE FIELD32(0x00000200)
  843. #define TXD_W0_KEY_INDEX FIELD32(0x0000fc00)
  844. #define TXD_W0_DATABYTE_COUNT FIELD32(0x0fff0000)
  845. #define TXD_W0_BURST2 FIELD32(0x10000000)
  846. #define TXD_W0_CIPHER_ALG FIELD32(0xe0000000)
  847. /*
  848. * Word1
  849. * HOST_Q_ID: EDCA/HCCA queue ID.
  850. * HW_SEQUENCE: MAC overwrites the frame sequence number.
  851. * BUFFER_COUNT: Number of buffers in this TXD.
  852. */
  853. #define TXD_W1_HOST_Q_ID FIELD32(0x0000000f)
  854. #define TXD_W1_AIFSN FIELD32(0x000000f0)
  855. #define TXD_W1_CWMIN FIELD32(0x00000f00)
  856. #define TXD_W1_CWMAX FIELD32(0x0000f000)
  857. #define TXD_W1_IV_OFFSET FIELD32(0x003f0000)
  858. #define TXD_W1_HW_SEQUENCE FIELD32(0x10000000)
  859. #define TXD_W1_BUFFER_COUNT FIELD32(0xe0000000)
  860. /*
  861. * Word2: PLCP information
  862. */
  863. #define TXD_W2_PLCP_SIGNAL FIELD32(0x000000ff)
  864. #define TXD_W2_PLCP_SERVICE FIELD32(0x0000ff00)
  865. #define TXD_W2_PLCP_LENGTH_LOW FIELD32(0x00ff0000)
  866. #define TXD_W2_PLCP_LENGTH_HIGH FIELD32(0xff000000)
  867. /*
  868. * Word3
  869. */
  870. #define TXD_W3_IV FIELD32(0xffffffff)
  871. /*
  872. * Word4
  873. */
  874. #define TXD_W4_EIV FIELD32(0xffffffff)
  875. /*
  876. * Word5
  877. * FRAME_OFFSET: Frame start offset inside ASIC TXFIFO (after TXINFO field).
  878. * PACKET_ID: Driver assigned packet ID to categorize TXResult in interrupt.
  879. * WAITING_DMA_DONE_INT: TXD been filled with data
  880. * and waiting for TxDoneISR housekeeping.
  881. */
  882. #define TXD_W5_FRAME_OFFSET FIELD32(0x000000ff)
  883. #define TXD_W5_PACKET_ID FIELD32(0x0000ff00)
  884. #define TXD_W5_TX_POWER FIELD32(0x00ff0000)
  885. #define TXD_W5_WAITING_DMA_DONE_INT FIELD32(0x01000000)
  886. /*
  887. * RX descriptor format for RX Ring.
  888. */
  889. /*
  890. * Word0
  891. * CIPHER_ERROR: 1:ICV error, 2:MIC error, 3:invalid key.
  892. * KEY_INDEX: Decryption key actually used.
  893. */
  894. #define RXD_W0_OWNER_NIC FIELD32(0x00000001)
  895. #define RXD_W0_DROP FIELD32(0x00000002)
  896. #define RXD_W0_UNICAST_TO_ME FIELD32(0x00000004)
  897. #define RXD_W0_MULTICAST FIELD32(0x00000008)
  898. #define RXD_W0_BROADCAST FIELD32(0x00000010)
  899. #define RXD_W0_MY_BSS FIELD32(0x00000020)
  900. #define RXD_W0_CRC_ERROR FIELD32(0x00000040)
  901. #define RXD_W0_OFDM FIELD32(0x00000080)
  902. #define RXD_W0_CIPHER_ERROR FIELD32(0x00000300)
  903. #define RXD_W0_KEY_INDEX FIELD32(0x0000fc00)
  904. #define RXD_W0_DATABYTE_COUNT FIELD32(0x0fff0000)
  905. #define RXD_W0_CIPHER_ALG FIELD32(0xe0000000)
  906. /*
  907. * WORD1
  908. * SIGNAL: RX raw data rate reported by BBP.
  909. * RSSI: RSSI reported by BBP.
  910. */
  911. #define RXD_W1_SIGNAL FIELD32(0x000000ff)
  912. #define RXD_W1_RSSI_AGC FIELD32(0x00001f00)
  913. #define RXD_W1_RSSI_LNA FIELD32(0x00006000)
  914. #define RXD_W1_FRAME_OFFSET FIELD32(0x7f000000)
  915. /*
  916. * Word2
  917. * IV: Received IV of originally encrypted.
  918. */
  919. #define RXD_W2_IV FIELD32(0xffffffff)
  920. /*
  921. * Word3
  922. * EIV: Received EIV of originally encrypted.
  923. */
  924. #define RXD_W3_EIV FIELD32(0xffffffff)
  925. /*
  926. * Word4
  927. * ICV: Received ICV of originally encrypted.
  928. * NOTE: This is a guess, the official definition is "reserved"
  929. */
  930. #define RXD_W4_ICV FIELD32(0xffffffff)
  931. /*
  932. * the above 20-byte is called RXINFO and will be DMAed to MAC RX block
  933. * and passed to the HOST driver.
  934. * The following fields are for DMA block and HOST usage only.
  935. * Can't be touched by ASIC MAC block.
  936. */
  937. /*
  938. * Word5
  939. */
  940. #define RXD_W5_RESERVED FIELD32(0xffffffff)
  941. /*
  942. * Macros for converting txpower from EEPROM to mac80211 value
  943. * and from mac80211 value to register value.
  944. */
  945. #define MIN_TXPOWER 0
  946. #define MAX_TXPOWER 31
  947. #define DEFAULT_TXPOWER 24
  948. #define TXPOWER_FROM_DEV(__txpower) \
  949. (((u8)(__txpower)) > MAX_TXPOWER) ? DEFAULT_TXPOWER : (__txpower)
  950. #define TXPOWER_TO_DEV(__txpower) \
  951. clamp_t(char, __txpower, MIN_TXPOWER, MAX_TXPOWER)
  952. #endif /* RT73USB_H */