rt2500usb.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856
  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: rt2500usb
  17. Abstract: Data structures and registers for the rt2500usb module.
  18. Supported chipsets: RT2570.
  19. */
  20. #ifndef RT2500USB_H
  21. #define RT2500USB_H
  22. /*
  23. * RF chip defines.
  24. */
  25. #define RF2522 0x0000
  26. #define RF2523 0x0001
  27. #define RF2524 0x0002
  28. #define RF2525 0x0003
  29. #define RF2525E 0x0005
  30. #define RF5222 0x0010
  31. /*
  32. * RT2570 version
  33. */
  34. #define RT2570_VERSION_B 2
  35. #define RT2570_VERSION_C 3
  36. #define RT2570_VERSION_D 4
  37. /*
  38. * Signal information.
  39. * Default offset is required for RSSI <-> dBm conversion.
  40. */
  41. #define DEFAULT_RSSI_OFFSET 120
  42. /*
  43. * Register layout information.
  44. */
  45. #define CSR_REG_BASE 0x0400
  46. #define CSR_REG_SIZE 0x0100
  47. #define EEPROM_BASE 0x0000
  48. #define EEPROM_SIZE 0x006a
  49. #define BBP_BASE 0x0000
  50. #define BBP_SIZE 0x0060
  51. #define RF_BASE 0x0004
  52. #define RF_SIZE 0x0010
  53. /*
  54. * Number of TX queues.
  55. */
  56. #define NUM_TX_QUEUES 2
  57. /*
  58. * Control/Status Registers(CSR).
  59. * Some values are set in TU, whereas 1 TU == 1024 us.
  60. */
  61. /*
  62. * MAC_CSR0: ASIC revision number.
  63. */
  64. #define MAC_CSR0 0x0400
  65. /*
  66. * MAC_CSR1: System control.
  67. * SOFT_RESET: Software reset, 1: reset, 0: normal.
  68. * BBP_RESET: Hardware reset, 1: reset, 0, release.
  69. * HOST_READY: Host ready after initialization.
  70. */
  71. #define MAC_CSR1 0x0402
  72. #define MAC_CSR1_SOFT_RESET FIELD16(0x00000001)
  73. #define MAC_CSR1_BBP_RESET FIELD16(0x00000002)
  74. #define MAC_CSR1_HOST_READY FIELD16(0x00000004)
  75. /*
  76. * MAC_CSR2: STA MAC register 0.
  77. */
  78. #define MAC_CSR2 0x0404
  79. #define MAC_CSR2_BYTE0 FIELD16(0x00ff)
  80. #define MAC_CSR2_BYTE1 FIELD16(0xff00)
  81. /*
  82. * MAC_CSR3: STA MAC register 1.
  83. */
  84. #define MAC_CSR3 0x0406
  85. #define MAC_CSR3_BYTE2 FIELD16(0x00ff)
  86. #define MAC_CSR3_BYTE3 FIELD16(0xff00)
  87. /*
  88. * MAC_CSR4: STA MAC register 2.
  89. */
  90. #define MAC_CSR4 0X0408
  91. #define MAC_CSR4_BYTE4 FIELD16(0x00ff)
  92. #define MAC_CSR4_BYTE5 FIELD16(0xff00)
  93. /*
  94. * MAC_CSR5: BSSID register 0.
  95. */
  96. #define MAC_CSR5 0x040a
  97. #define MAC_CSR5_BYTE0 FIELD16(0x00ff)
  98. #define MAC_CSR5_BYTE1 FIELD16(0xff00)
  99. /*
  100. * MAC_CSR6: BSSID register 1.
  101. */
  102. #define MAC_CSR6 0x040c
  103. #define MAC_CSR6_BYTE2 FIELD16(0x00ff)
  104. #define MAC_CSR6_BYTE3 FIELD16(0xff00)
  105. /*
  106. * MAC_CSR7: BSSID register 2.
  107. */
  108. #define MAC_CSR7 0x040e
  109. #define MAC_CSR7_BYTE4 FIELD16(0x00ff)
  110. #define MAC_CSR7_BYTE5 FIELD16(0xff00)
  111. /*
  112. * MAC_CSR8: Max frame length.
  113. */
  114. #define MAC_CSR8 0x0410
  115. #define MAC_CSR8_MAX_FRAME_UNIT FIELD16(0x0fff)
  116. /*
  117. * Misc MAC_CSR registers.
  118. * MAC_CSR9: Timer control.
  119. * MAC_CSR10: Slot time.
  120. * MAC_CSR11: SIFS.
  121. * MAC_CSR12: EIFS.
  122. * MAC_CSR13: Power mode0.
  123. * MAC_CSR14: Power mode1.
  124. * MAC_CSR15: Power saving transition0
  125. * MAC_CSR16: Power saving transition1
  126. */
  127. #define MAC_CSR9 0x0412
  128. #define MAC_CSR10 0x0414
  129. #define MAC_CSR11 0x0416
  130. #define MAC_CSR12 0x0418
  131. #define MAC_CSR13 0x041a
  132. #define MAC_CSR14 0x041c
  133. #define MAC_CSR15 0x041e
  134. #define MAC_CSR16 0x0420
  135. /*
  136. * MAC_CSR17: Manual power control / status register.
  137. * Allowed state: 0 deep_sleep, 1: sleep, 2: standby, 3: awake.
  138. * SET_STATE: Set state. Write 1 to trigger, self cleared.
  139. * BBP_DESIRE_STATE: BBP desired state.
  140. * RF_DESIRE_STATE: RF desired state.
  141. * BBP_CURRENT_STATE: BBP current state.
  142. * RF_CURRENT_STATE: RF current state.
  143. * PUT_TO_SLEEP: Put to sleep. Write 1 to trigger, self cleared.
  144. */
  145. #define MAC_CSR17 0x0422
  146. #define MAC_CSR17_SET_STATE FIELD16(0x0001)
  147. #define MAC_CSR17_BBP_DESIRE_STATE FIELD16(0x0006)
  148. #define MAC_CSR17_RF_DESIRE_STATE FIELD16(0x0018)
  149. #define MAC_CSR17_BBP_CURR_STATE FIELD16(0x0060)
  150. #define MAC_CSR17_RF_CURR_STATE FIELD16(0x0180)
  151. #define MAC_CSR17_PUT_TO_SLEEP FIELD16(0x0200)
  152. /*
  153. * MAC_CSR18: Wakeup timer register.
  154. * DELAY_AFTER_BEACON: Delay after Tbcn expired in units of 1/16 TU.
  155. * BEACONS_BEFORE_WAKEUP: Number of beacon before wakeup.
  156. * AUTO_WAKE: Enable auto wakeup / sleep mechanism.
  157. */
  158. #define MAC_CSR18 0x0424
  159. #define MAC_CSR18_DELAY_AFTER_BEACON FIELD16(0x00ff)
  160. #define MAC_CSR18_BEACONS_BEFORE_WAKEUP FIELD16(0x7f00)
  161. #define MAC_CSR18_AUTO_WAKE FIELD16(0x8000)
  162. /*
  163. * MAC_CSR19: GPIO control register.
  164. * MAC_CSR19_VALx: GPIO value
  165. * MAC_CSR19_DIRx: GPIO direction: 0 = input; 1 = output
  166. */
  167. #define MAC_CSR19 0x0426
  168. #define MAC_CSR19_VAL0 FIELD16(0x0001)
  169. #define MAC_CSR19_VAL1 FIELD16(0x0002)
  170. #define MAC_CSR19_VAL2 FIELD16(0x0004)
  171. #define MAC_CSR19_VAL3 FIELD16(0x0008)
  172. #define MAC_CSR19_VAL4 FIELD16(0x0010)
  173. #define MAC_CSR19_VAL5 FIELD16(0x0020)
  174. #define MAC_CSR19_VAL6 FIELD16(0x0040)
  175. #define MAC_CSR19_VAL7 FIELD16(0x0080)
  176. #define MAC_CSR19_DIR0 FIELD16(0x0100)
  177. #define MAC_CSR19_DIR1 FIELD16(0x0200)
  178. #define MAC_CSR19_DIR2 FIELD16(0x0400)
  179. #define MAC_CSR19_DIR3 FIELD16(0x0800)
  180. #define MAC_CSR19_DIR4 FIELD16(0x1000)
  181. #define MAC_CSR19_DIR5 FIELD16(0x2000)
  182. #define MAC_CSR19_DIR6 FIELD16(0x4000)
  183. #define MAC_CSR19_DIR7 FIELD16(0x8000)
  184. /*
  185. * MAC_CSR20: LED control register.
  186. * ACTIVITY: 0: idle, 1: active.
  187. * LINK: 0: linkoff, 1: linkup.
  188. * ACTIVITY_POLARITY: 0: active low, 1: active high.
  189. */
  190. #define MAC_CSR20 0x0428
  191. #define MAC_CSR20_ACTIVITY FIELD16(0x0001)
  192. #define MAC_CSR20_LINK FIELD16(0x0002)
  193. #define MAC_CSR20_ACTIVITY_POLARITY FIELD16(0x0004)
  194. /*
  195. * MAC_CSR21: LED control register.
  196. * ON_PERIOD: On period, default 70ms.
  197. * OFF_PERIOD: Off period, default 30ms.
  198. */
  199. #define MAC_CSR21 0x042a
  200. #define MAC_CSR21_ON_PERIOD FIELD16(0x00ff)
  201. #define MAC_CSR21_OFF_PERIOD FIELD16(0xff00)
  202. /*
  203. * MAC_CSR22: Collision window control register.
  204. */
  205. #define MAC_CSR22 0x042c
  206. /*
  207. * Transmit related CSRs.
  208. * Some values are set in TU, whereas 1 TU == 1024 us.
  209. */
  210. /*
  211. * TXRX_CSR0: Security control register.
  212. */
  213. #define TXRX_CSR0 0x0440
  214. #define TXRX_CSR0_ALGORITHM FIELD16(0x0007)
  215. #define TXRX_CSR0_IV_OFFSET FIELD16(0x01f8)
  216. #define TXRX_CSR0_KEY_ID FIELD16(0x1e00)
  217. /*
  218. * TXRX_CSR1: TX configuration.
  219. * ACK_TIMEOUT: ACK Timeout in unit of 1-us.
  220. * TSF_OFFSET: TSF offset in MAC header.
  221. * AUTO_SEQUENCE: Let ASIC control frame sequence number.
  222. */
  223. #define TXRX_CSR1 0x0442
  224. #define TXRX_CSR1_ACK_TIMEOUT FIELD16(0x00ff)
  225. #define TXRX_CSR1_TSF_OFFSET FIELD16(0x7f00)
  226. #define TXRX_CSR1_AUTO_SEQUENCE FIELD16(0x8000)
  227. /*
  228. * TXRX_CSR2: RX control.
  229. * DISABLE_RX: Disable rx engine.
  230. * DROP_CRC: Drop crc error.
  231. * DROP_PHYSICAL: Drop physical error.
  232. * DROP_CONTROL: Drop control frame.
  233. * DROP_NOT_TO_ME: Drop not to me unicast frame.
  234. * DROP_TODS: Drop frame tods bit is true.
  235. * DROP_VERSION_ERROR: Drop version error frame.
  236. * DROP_MCAST: Drop multicast frames.
  237. * DROP_BCAST: Drop broadcast frames.
  238. */
  239. #define TXRX_CSR2 0x0444
  240. #define TXRX_CSR2_DISABLE_RX FIELD16(0x0001)
  241. #define TXRX_CSR2_DROP_CRC FIELD16(0x0002)
  242. #define TXRX_CSR2_DROP_PHYSICAL FIELD16(0x0004)
  243. #define TXRX_CSR2_DROP_CONTROL FIELD16(0x0008)
  244. #define TXRX_CSR2_DROP_NOT_TO_ME FIELD16(0x0010)
  245. #define TXRX_CSR2_DROP_TODS FIELD16(0x0020)
  246. #define TXRX_CSR2_DROP_VERSION_ERROR FIELD16(0x0040)
  247. #define TXRX_CSR2_DROP_MULTICAST FIELD16(0x0200)
  248. #define TXRX_CSR2_DROP_BROADCAST FIELD16(0x0400)
  249. /*
  250. * RX BBP ID registers
  251. * TXRX_CSR3: CCK RX BBP ID.
  252. * TXRX_CSR4: OFDM RX BBP ID.
  253. */
  254. #define TXRX_CSR3 0x0446
  255. #define TXRX_CSR4 0x0448
  256. /*
  257. * TXRX_CSR5: CCK TX BBP ID0.
  258. */
  259. #define TXRX_CSR5 0x044a
  260. #define TXRX_CSR5_BBP_ID0 FIELD16(0x007f)
  261. #define TXRX_CSR5_BBP_ID0_VALID FIELD16(0x0080)
  262. #define TXRX_CSR5_BBP_ID1 FIELD16(0x7f00)
  263. #define TXRX_CSR5_BBP_ID1_VALID FIELD16(0x8000)
  264. /*
  265. * TXRX_CSR6: CCK TX BBP ID1.
  266. */
  267. #define TXRX_CSR6 0x044c
  268. #define TXRX_CSR6_BBP_ID0 FIELD16(0x007f)
  269. #define TXRX_CSR6_BBP_ID0_VALID FIELD16(0x0080)
  270. #define TXRX_CSR6_BBP_ID1 FIELD16(0x7f00)
  271. #define TXRX_CSR6_BBP_ID1_VALID FIELD16(0x8000)
  272. /*
  273. * TXRX_CSR7: OFDM TX BBP ID0.
  274. */
  275. #define TXRX_CSR7 0x044e
  276. #define TXRX_CSR7_BBP_ID0 FIELD16(0x007f)
  277. #define TXRX_CSR7_BBP_ID0_VALID FIELD16(0x0080)
  278. #define TXRX_CSR7_BBP_ID1 FIELD16(0x7f00)
  279. #define TXRX_CSR7_BBP_ID1_VALID FIELD16(0x8000)
  280. /*
  281. * TXRX_CSR8: OFDM TX BBP ID1.
  282. */
  283. #define TXRX_CSR8 0x0450
  284. #define TXRX_CSR8_BBP_ID0 FIELD16(0x007f)
  285. #define TXRX_CSR8_BBP_ID0_VALID FIELD16(0x0080)
  286. #define TXRX_CSR8_BBP_ID1 FIELD16(0x7f00)
  287. #define TXRX_CSR8_BBP_ID1_VALID FIELD16(0x8000)
  288. /*
  289. * TXRX_CSR9: TX ACK time-out.
  290. */
  291. #define TXRX_CSR9 0x0452
  292. /*
  293. * TXRX_CSR10: Auto responder control.
  294. */
  295. #define TXRX_CSR10 0x0454
  296. #define TXRX_CSR10_AUTORESPOND_PREAMBLE FIELD16(0x0004)
  297. /*
  298. * TXRX_CSR11: Auto responder basic rate.
  299. */
  300. #define TXRX_CSR11 0x0456
  301. /*
  302. * ACK/CTS time registers.
  303. */
  304. #define TXRX_CSR12 0x0458
  305. #define TXRX_CSR13 0x045a
  306. #define TXRX_CSR14 0x045c
  307. #define TXRX_CSR15 0x045e
  308. #define TXRX_CSR16 0x0460
  309. #define TXRX_CSR17 0x0462
  310. /*
  311. * TXRX_CSR18: Synchronization control register.
  312. */
  313. #define TXRX_CSR18 0x0464
  314. #define TXRX_CSR18_OFFSET FIELD16(0x000f)
  315. #define TXRX_CSR18_INTERVAL FIELD16(0xfff0)
  316. /*
  317. * TXRX_CSR19: Synchronization control register.
  318. * TSF_COUNT: Enable TSF auto counting.
  319. * TSF_SYNC: Tsf sync, 0: disable, 1: infra, 2: ad-hoc/master mode.
  320. * TBCN: Enable Tbcn with reload value.
  321. * BEACON_GEN: Enable beacon generator.
  322. */
  323. #define TXRX_CSR19 0x0466
  324. #define TXRX_CSR19_TSF_COUNT FIELD16(0x0001)
  325. #define TXRX_CSR19_TSF_SYNC FIELD16(0x0006)
  326. #define TXRX_CSR19_TBCN FIELD16(0x0008)
  327. #define TXRX_CSR19_BEACON_GEN FIELD16(0x0010)
  328. /*
  329. * TXRX_CSR20: Tx BEACON offset time control register.
  330. * OFFSET: In units of usec.
  331. * BCN_EXPECT_WINDOW: Default: 2^CWmin
  332. */
  333. #define TXRX_CSR20 0x0468
  334. #define TXRX_CSR20_OFFSET FIELD16(0x1fff)
  335. #define TXRX_CSR20_BCN_EXPECT_WINDOW FIELD16(0xe000)
  336. /*
  337. * TXRX_CSR21
  338. */
  339. #define TXRX_CSR21 0x046a
  340. /*
  341. * Encryption related CSRs.
  342. *
  343. */
  344. /*
  345. * SEC_CSR0: Shared key 0, word 0
  346. * SEC_CSR1: Shared key 0, word 1
  347. * SEC_CSR2: Shared key 0, word 2
  348. * SEC_CSR3: Shared key 0, word 3
  349. * SEC_CSR4: Shared key 0, word 4
  350. * SEC_CSR5: Shared key 0, word 5
  351. * SEC_CSR6: Shared key 0, word 6
  352. * SEC_CSR7: Shared key 0, word 7
  353. */
  354. #define SEC_CSR0 0x0480
  355. #define SEC_CSR1 0x0482
  356. #define SEC_CSR2 0x0484
  357. #define SEC_CSR3 0x0486
  358. #define SEC_CSR4 0x0488
  359. #define SEC_CSR5 0x048a
  360. #define SEC_CSR6 0x048c
  361. #define SEC_CSR7 0x048e
  362. /*
  363. * SEC_CSR8: Shared key 1, word 0
  364. * SEC_CSR9: Shared key 1, word 1
  365. * SEC_CSR10: Shared key 1, word 2
  366. * SEC_CSR11: Shared key 1, word 3
  367. * SEC_CSR12: Shared key 1, word 4
  368. * SEC_CSR13: Shared key 1, word 5
  369. * SEC_CSR14: Shared key 1, word 6
  370. * SEC_CSR15: Shared key 1, word 7
  371. */
  372. #define SEC_CSR8 0x0490
  373. #define SEC_CSR9 0x0492
  374. #define SEC_CSR10 0x0494
  375. #define SEC_CSR11 0x0496
  376. #define SEC_CSR12 0x0498
  377. #define SEC_CSR13 0x049a
  378. #define SEC_CSR14 0x049c
  379. #define SEC_CSR15 0x049e
  380. /*
  381. * SEC_CSR16: Shared key 2, word 0
  382. * SEC_CSR17: Shared key 2, word 1
  383. * SEC_CSR18: Shared key 2, word 2
  384. * SEC_CSR19: Shared key 2, word 3
  385. * SEC_CSR20: Shared key 2, word 4
  386. * SEC_CSR21: Shared key 2, word 5
  387. * SEC_CSR22: Shared key 2, word 6
  388. * SEC_CSR23: Shared key 2, word 7
  389. */
  390. #define SEC_CSR16 0x04a0
  391. #define SEC_CSR17 0x04a2
  392. #define SEC_CSR18 0X04A4
  393. #define SEC_CSR19 0x04a6
  394. #define SEC_CSR20 0x04a8
  395. #define SEC_CSR21 0x04aa
  396. #define SEC_CSR22 0x04ac
  397. #define SEC_CSR23 0x04ae
  398. /*
  399. * SEC_CSR24: Shared key 3, word 0
  400. * SEC_CSR25: Shared key 3, word 1
  401. * SEC_CSR26: Shared key 3, word 2
  402. * SEC_CSR27: Shared key 3, word 3
  403. * SEC_CSR28: Shared key 3, word 4
  404. * SEC_CSR29: Shared key 3, word 5
  405. * SEC_CSR30: Shared key 3, word 6
  406. * SEC_CSR31: Shared key 3, word 7
  407. */
  408. #define SEC_CSR24 0x04b0
  409. #define SEC_CSR25 0x04b2
  410. #define SEC_CSR26 0x04b4
  411. #define SEC_CSR27 0x04b6
  412. #define SEC_CSR28 0x04b8
  413. #define SEC_CSR29 0x04ba
  414. #define SEC_CSR30 0x04bc
  415. #define SEC_CSR31 0x04be
  416. #define KEY_ENTRY(__idx) \
  417. ( SEC_CSR0 + ((__idx) * 16) )
  418. /*
  419. * PHY control registers.
  420. */
  421. /*
  422. * PHY_CSR0: RF switching timing control.
  423. */
  424. #define PHY_CSR0 0x04c0
  425. /*
  426. * PHY_CSR1: TX PA configuration.
  427. */
  428. #define PHY_CSR1 0x04c2
  429. /*
  430. * MAC configuration registers.
  431. */
  432. /*
  433. * PHY_CSR2: TX MAC configuration.
  434. * NOTE: Both register fields are complete dummy,
  435. * documentation and legacy drivers are unclear un
  436. * what this register means or what fields exists.
  437. */
  438. #define PHY_CSR2 0x04c4
  439. #define PHY_CSR2_LNA FIELD16(0x0002)
  440. #define PHY_CSR2_LNA_MODE FIELD16(0x3000)
  441. /*
  442. * PHY_CSR3: RX MAC configuration.
  443. */
  444. #define PHY_CSR3 0x04c6
  445. /*
  446. * PHY_CSR4: Interface configuration.
  447. */
  448. #define PHY_CSR4 0x04c8
  449. #define PHY_CSR4_LOW_RF_LE FIELD16(0x0001)
  450. /*
  451. * BBP pre-TX registers.
  452. * PHY_CSR5: BBP pre-TX CCK.
  453. */
  454. #define PHY_CSR5 0x04ca
  455. #define PHY_CSR5_CCK FIELD16(0x0003)
  456. #define PHY_CSR5_CCK_FLIP FIELD16(0x0004)
  457. /*
  458. * BBP pre-TX registers.
  459. * PHY_CSR6: BBP pre-TX OFDM.
  460. */
  461. #define PHY_CSR6 0x04cc
  462. #define PHY_CSR6_OFDM FIELD16(0x0003)
  463. #define PHY_CSR6_OFDM_FLIP FIELD16(0x0004)
  464. /*
  465. * PHY_CSR7: BBP access register 0.
  466. * BBP_DATA: BBP data.
  467. * BBP_REG_ID: BBP register ID.
  468. * BBP_READ_CONTROL: 0: write, 1: read.
  469. */
  470. #define PHY_CSR7 0x04ce
  471. #define PHY_CSR7_DATA FIELD16(0x00ff)
  472. #define PHY_CSR7_REG_ID FIELD16(0x7f00)
  473. #define PHY_CSR7_READ_CONTROL FIELD16(0x8000)
  474. /*
  475. * PHY_CSR8: BBP access register 1.
  476. * BBP_BUSY: ASIC is busy execute BBP programming.
  477. */
  478. #define PHY_CSR8 0x04d0
  479. #define PHY_CSR8_BUSY FIELD16(0x0001)
  480. /*
  481. * PHY_CSR9: RF access register.
  482. * RF_VALUE: Register value + id to program into rf/if.
  483. */
  484. #define PHY_CSR9 0x04d2
  485. #define PHY_CSR9_RF_VALUE FIELD16(0xffff)
  486. /*
  487. * PHY_CSR10: RF access register.
  488. * RF_VALUE: Register value + id to program into rf/if.
  489. * RF_NUMBER_OF_BITS: Number of bits used in value (i:20, rfmd:22).
  490. * RF_IF_SELECT: Chip to program: 0: rf, 1: if.
  491. * RF_PLL_LD: Rf pll_ld status.
  492. * RF_BUSY: 1: asic is busy execute rf programming.
  493. */
  494. #define PHY_CSR10 0x04d4
  495. #define PHY_CSR10_RF_VALUE FIELD16(0x00ff)
  496. #define PHY_CSR10_RF_NUMBER_OF_BITS FIELD16(0x1f00)
  497. #define PHY_CSR10_RF_IF_SELECT FIELD16(0x2000)
  498. #define PHY_CSR10_RF_PLL_LD FIELD16(0x4000)
  499. #define PHY_CSR10_RF_BUSY FIELD16(0x8000)
  500. /*
  501. * STA_CSR0: FCS error count.
  502. * FCS_ERROR: FCS error count, cleared when read.
  503. */
  504. #define STA_CSR0 0x04e0
  505. #define STA_CSR0_FCS_ERROR FIELD16(0xffff)
  506. /*
  507. * STA_CSR1: PLCP error count.
  508. */
  509. #define STA_CSR1 0x04e2
  510. /*
  511. * STA_CSR2: LONG error count.
  512. */
  513. #define STA_CSR2 0x04e4
  514. /*
  515. * STA_CSR3: CCA false alarm.
  516. * FALSE_CCA_ERROR: False CCA error count, cleared when read.
  517. */
  518. #define STA_CSR3 0x04e6
  519. #define STA_CSR3_FALSE_CCA_ERROR FIELD16(0xffff)
  520. /*
  521. * STA_CSR4: RX FIFO overflow.
  522. */
  523. #define STA_CSR4 0x04e8
  524. /*
  525. * STA_CSR5: Beacon sent counter.
  526. */
  527. #define STA_CSR5 0x04ea
  528. /*
  529. * Statistics registers
  530. */
  531. #define STA_CSR6 0x04ec
  532. #define STA_CSR7 0x04ee
  533. #define STA_CSR8 0x04f0
  534. #define STA_CSR9 0x04f2
  535. #define STA_CSR10 0x04f4
  536. /*
  537. * BBP registers.
  538. * The wordsize of the BBP is 8 bits.
  539. */
  540. /*
  541. * R2: TX antenna control
  542. */
  543. #define BBP_R2_TX_ANTENNA FIELD8(0x03)
  544. #define BBP_R2_TX_IQ_FLIP FIELD8(0x04)
  545. /*
  546. * R14: RX antenna control
  547. */
  548. #define BBP_R14_RX_ANTENNA FIELD8(0x03)
  549. #define BBP_R14_RX_IQ_FLIP FIELD8(0x04)
  550. /*
  551. * RF registers.
  552. */
  553. /*
  554. * RF 1
  555. */
  556. #define RF1_TUNER FIELD32(0x00020000)
  557. /*
  558. * RF 3
  559. */
  560. #define RF3_TUNER FIELD32(0x00000100)
  561. #define RF3_TXPOWER FIELD32(0x00003e00)
  562. /*
  563. * EEPROM contents.
  564. */
  565. /*
  566. * HW MAC address.
  567. */
  568. #define EEPROM_MAC_ADDR_0 0x0002
  569. #define EEPROM_MAC_ADDR_BYTE0 FIELD16(0x00ff)
  570. #define EEPROM_MAC_ADDR_BYTE1 FIELD16(0xff00)
  571. #define EEPROM_MAC_ADDR1 0x0003
  572. #define EEPROM_MAC_ADDR_BYTE2 FIELD16(0x00ff)
  573. #define EEPROM_MAC_ADDR_BYTE3 FIELD16(0xff00)
  574. #define EEPROM_MAC_ADDR_2 0x0004
  575. #define EEPROM_MAC_ADDR_BYTE4 FIELD16(0x00ff)
  576. #define EEPROM_MAC_ADDR_BYTE5 FIELD16(0xff00)
  577. /*
  578. * EEPROM antenna.
  579. * ANTENNA_NUM: Number of antenna's.
  580. * TX_DEFAULT: Default antenna 0: diversity, 1: A, 2: B.
  581. * RX_DEFAULT: Default antenna 0: diversity, 1: A, 2: B.
  582. * LED_MODE: 0: default, 1: TX/RX activity, 2: Single (ignore link), 3: rsvd.
  583. * DYN_TXAGC: Dynamic TX AGC control.
  584. * HARDWARE_RADIO: 1: Hardware controlled radio. Read GPIO0.
  585. * RF_TYPE: Rf_type of this adapter.
  586. */
  587. #define EEPROM_ANTENNA 0x000b
  588. #define EEPROM_ANTENNA_NUM FIELD16(0x0003)
  589. #define EEPROM_ANTENNA_TX_DEFAULT FIELD16(0x000c)
  590. #define EEPROM_ANTENNA_RX_DEFAULT FIELD16(0x0030)
  591. #define EEPROM_ANTENNA_LED_MODE FIELD16(0x01c0)
  592. #define EEPROM_ANTENNA_DYN_TXAGC FIELD16(0x0200)
  593. #define EEPROM_ANTENNA_HARDWARE_RADIO FIELD16(0x0400)
  594. #define EEPROM_ANTENNA_RF_TYPE FIELD16(0xf800)
  595. /*
  596. * EEPROM NIC config.
  597. * CARDBUS_ACCEL: 0: enable, 1: disable.
  598. * DYN_BBP_TUNE: 0: enable, 1: disable.
  599. * CCK_TX_POWER: CCK TX power compensation.
  600. */
  601. #define EEPROM_NIC 0x000c
  602. #define EEPROM_NIC_CARDBUS_ACCEL FIELD16(0x0001)
  603. #define EEPROM_NIC_DYN_BBP_TUNE FIELD16(0x0002)
  604. #define EEPROM_NIC_CCK_TX_POWER FIELD16(0x000c)
  605. /*
  606. * EEPROM geography.
  607. * GEO: Default geography setting for device.
  608. */
  609. #define EEPROM_GEOGRAPHY 0x000d
  610. #define EEPROM_GEOGRAPHY_GEO FIELD16(0x0f00)
  611. /*
  612. * EEPROM BBP.
  613. */
  614. #define EEPROM_BBP_START 0x000e
  615. #define EEPROM_BBP_SIZE 16
  616. #define EEPROM_BBP_VALUE FIELD16(0x00ff)
  617. #define EEPROM_BBP_REG_ID FIELD16(0xff00)
  618. /*
  619. * EEPROM TXPOWER
  620. */
  621. #define EEPROM_TXPOWER_START 0x001e
  622. #define EEPROM_TXPOWER_SIZE 7
  623. #define EEPROM_TXPOWER_1 FIELD16(0x00ff)
  624. #define EEPROM_TXPOWER_2 FIELD16(0xff00)
  625. /*
  626. * EEPROM Tuning threshold
  627. */
  628. #define EEPROM_BBPTUNE 0x0030
  629. #define EEPROM_BBPTUNE_THRESHOLD FIELD16(0x00ff)
  630. /*
  631. * EEPROM BBP R24 Tuning.
  632. */
  633. #define EEPROM_BBPTUNE_R24 0x0031
  634. #define EEPROM_BBPTUNE_R24_LOW FIELD16(0x00ff)
  635. #define EEPROM_BBPTUNE_R24_HIGH FIELD16(0xff00)
  636. /*
  637. * EEPROM BBP R25 Tuning.
  638. */
  639. #define EEPROM_BBPTUNE_R25 0x0032
  640. #define EEPROM_BBPTUNE_R25_LOW FIELD16(0x00ff)
  641. #define EEPROM_BBPTUNE_R25_HIGH FIELD16(0xff00)
  642. /*
  643. * EEPROM BBP R24 Tuning.
  644. */
  645. #define EEPROM_BBPTUNE_R61 0x0033
  646. #define EEPROM_BBPTUNE_R61_LOW FIELD16(0x00ff)
  647. #define EEPROM_BBPTUNE_R61_HIGH FIELD16(0xff00)
  648. /*
  649. * EEPROM BBP VGC Tuning.
  650. */
  651. #define EEPROM_BBPTUNE_VGC 0x0034
  652. #define EEPROM_BBPTUNE_VGCUPPER FIELD16(0x00ff)
  653. #define EEPROM_BBPTUNE_VGCLOWER FIELD16(0xff00)
  654. /*
  655. * EEPROM BBP R17 Tuning.
  656. */
  657. #define EEPROM_BBPTUNE_R17 0x0035
  658. #define EEPROM_BBPTUNE_R17_LOW FIELD16(0x00ff)
  659. #define EEPROM_BBPTUNE_R17_HIGH FIELD16(0xff00)
  660. /*
  661. * RSSI <-> dBm offset calibration
  662. */
  663. #define EEPROM_CALIBRATE_OFFSET 0x0036
  664. #define EEPROM_CALIBRATE_OFFSET_RSSI FIELD16(0x00ff)
  665. /*
  666. * DMA descriptor defines.
  667. */
  668. #define TXD_DESC_SIZE ( 5 * sizeof(__le32) )
  669. #define RXD_DESC_SIZE ( 4 * sizeof(__le32) )
  670. /*
  671. * TX descriptor format for TX, PRIO, ATIM and Beacon Ring.
  672. */
  673. /*
  674. * Word0
  675. */
  676. #define TXD_W0_PACKET_ID FIELD32(0x0000000f)
  677. #define TXD_W0_RETRY_LIMIT FIELD32(0x000000f0)
  678. #define TXD_W0_MORE_FRAG FIELD32(0x00000100)
  679. #define TXD_W0_ACK FIELD32(0x00000200)
  680. #define TXD_W0_TIMESTAMP FIELD32(0x00000400)
  681. #define TXD_W0_OFDM FIELD32(0x00000800)
  682. #define TXD_W0_NEW_SEQ FIELD32(0x00001000)
  683. #define TXD_W0_IFS FIELD32(0x00006000)
  684. #define TXD_W0_DATABYTE_COUNT FIELD32(0x0fff0000)
  685. #define TXD_W0_CIPHER FIELD32(0x20000000)
  686. #define TXD_W0_KEY_ID FIELD32(0xc0000000)
  687. /*
  688. * Word1
  689. */
  690. #define TXD_W1_IV_OFFSET FIELD32(0x0000003f)
  691. #define TXD_W1_AIFS FIELD32(0x000000c0)
  692. #define TXD_W1_CWMIN FIELD32(0x00000f00)
  693. #define TXD_W1_CWMAX FIELD32(0x0000f000)
  694. /*
  695. * Word2: PLCP information
  696. */
  697. #define TXD_W2_PLCP_SIGNAL FIELD32(0x000000ff)
  698. #define TXD_W2_PLCP_SERVICE FIELD32(0x0000ff00)
  699. #define TXD_W2_PLCP_LENGTH_LOW FIELD32(0x00ff0000)
  700. #define TXD_W2_PLCP_LENGTH_HIGH FIELD32(0xff000000)
  701. /*
  702. * Word3
  703. */
  704. #define TXD_W3_IV FIELD32(0xffffffff)
  705. /*
  706. * Word4
  707. */
  708. #define TXD_W4_EIV FIELD32(0xffffffff)
  709. /*
  710. * RX descriptor format for RX Ring.
  711. */
  712. /*
  713. * Word0
  714. */
  715. #define RXD_W0_UNICAST_TO_ME FIELD32(0x00000002)
  716. #define RXD_W0_MULTICAST FIELD32(0x00000004)
  717. #define RXD_W0_BROADCAST FIELD32(0x00000008)
  718. #define RXD_W0_MY_BSS FIELD32(0x00000010)
  719. #define RXD_W0_CRC_ERROR FIELD32(0x00000020)
  720. #define RXD_W0_OFDM FIELD32(0x00000040)
  721. #define RXD_W0_PHYSICAL_ERROR FIELD32(0x00000080)
  722. #define RXD_W0_CIPHER FIELD32(0x00000100)
  723. #define RXD_W0_CIPHER_ERROR FIELD32(0x00000200)
  724. #define RXD_W0_DATABYTE_COUNT FIELD32(0x0fff0000)
  725. /*
  726. * Word1
  727. */
  728. #define RXD_W1_RSSI FIELD32(0x000000ff)
  729. #define RXD_W1_SIGNAL FIELD32(0x0000ff00)
  730. /*
  731. * Word2
  732. */
  733. #define RXD_W2_IV FIELD32(0xffffffff)
  734. /*
  735. * Word3
  736. */
  737. #define RXD_W3_EIV FIELD32(0xffffffff)
  738. /*
  739. * Macros for converting txpower from EEPROM to mac80211 value
  740. * and from mac80211 value to register value.
  741. */
  742. #define MIN_TXPOWER 0
  743. #define MAX_TXPOWER 31
  744. #define DEFAULT_TXPOWER 24
  745. #define TXPOWER_FROM_DEV(__txpower) \
  746. (((u8)(__txpower)) > MAX_TXPOWER) ? DEFAULT_TXPOWER : (__txpower)
  747. #define TXPOWER_TO_DEV(__txpower) \
  748. clamp_t(char, __txpower, MIN_TXPOWER, MAX_TXPOWER)
  749. #endif /* RT2500USB_H */