rtl818x.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406
  1. /*
  2. * Definitions for RTL818x hardware
  3. *
  4. * Copyright 2007 Michael Wu <flamingice@sourmilk.net>
  5. * Copyright 2007 Andrea Merello <andrea.merello@gmail.com>
  6. *
  7. * Based on the r8187 driver, which is:
  8. * Copyright 2005 Andrea Merello <andrea.merello@gmail.com>, et al.
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License version 2 as
  12. * published by the Free Software Foundation.
  13. */
  14. #ifndef RTL818X_H
  15. #define RTL818X_H
  16. struct rtl818x_csr {
  17. u8 MAC[6];
  18. u8 reserved_0[2];
  19. union {
  20. __le32 MAR[2]; /* 0x8 */
  21. struct{ /* rtl8187se */
  22. u8 rf_sw_config; /* 0x8 */
  23. u8 reserved_01[3];
  24. __le32 TMGDA; /* 0xc */
  25. } __packed;
  26. } __packed;
  27. union { /* 0x10 */
  28. struct {
  29. u8 RX_FIFO_COUNT;
  30. u8 reserved_1;
  31. u8 TX_FIFO_COUNT;
  32. u8 BQREQ;
  33. } __packed;
  34. __le32 TBKDA; /* for 8187se */
  35. } __packed;
  36. __le32 TBEDA; /* 0x14 - for rtl8187se */
  37. __le32 TSFT[2];
  38. union { /* 0x20 */
  39. __le32 TLPDA;
  40. __le32 TVIDA; /* for 8187se */
  41. } __packed;
  42. union { /* 0x24 */
  43. __le32 TNPDA;
  44. __le32 TVODA; /* for 8187se */
  45. } __packed;
  46. /* hi pri ring for all cards */
  47. __le32 THPDA; /* 0x28 */
  48. union { /* 0x2c */
  49. struct {
  50. u8 reserved_2a;
  51. u8 EIFS_8187SE;
  52. } __packed;
  53. __le16 BRSR;
  54. } __packed;
  55. u8 BSSID[6]; /* 0x2e */
  56. union { /* 0x34 */
  57. struct {
  58. u8 RESP_RATE;
  59. u8 EIFS;
  60. } __packed;
  61. __le16 BRSR_8187SE;
  62. } __packed;
  63. u8 reserved_3[1]; /* 0x36 */
  64. u8 CMD; /* 0x37 */
  65. #define RTL818X_CMD_TX_ENABLE (1 << 2)
  66. #define RTL818X_CMD_RX_ENABLE (1 << 3)
  67. #define RTL818X_CMD_RESET (1 << 4)
  68. u8 reserved_4[4]; /* 0x38 */
  69. union {
  70. struct {
  71. __le16 INT_MASK;
  72. __le16 INT_STATUS;
  73. } __packed;
  74. __le32 INT_STATUS_SE; /* 0x3c */
  75. } __packed;
  76. /* status bits for rtl8187 and rtl8180/8185 */
  77. #define RTL818X_INT_RX_OK (1 << 0)
  78. #define RTL818X_INT_RX_ERR (1 << 1)
  79. #define RTL818X_INT_TXL_OK (1 << 2)
  80. #define RTL818X_INT_TXL_ERR (1 << 3)
  81. #define RTL818X_INT_RX_DU (1 << 4)
  82. #define RTL818X_INT_RX_FO (1 << 5)
  83. #define RTL818X_INT_TXN_OK (1 << 6)
  84. #define RTL818X_INT_TXN_ERR (1 << 7)
  85. #define RTL818X_INT_TXH_OK (1 << 8)
  86. #define RTL818X_INT_TXH_ERR (1 << 9)
  87. #define RTL818X_INT_TXB_OK (1 << 10)
  88. #define RTL818X_INT_TXB_ERR (1 << 11)
  89. #define RTL818X_INT_ATIM (1 << 12)
  90. #define RTL818X_INT_BEACON (1 << 13)
  91. #define RTL818X_INT_TIME_OUT (1 << 14)
  92. #define RTL818X_INT_TX_FO (1 << 15)
  93. /* status bits for rtl8187se */
  94. #define RTL818X_INT_SE_TIMER3 (1 << 0)
  95. #define RTL818X_INT_SE_TIMER2 (1 << 1)
  96. #define RTL818X_INT_SE_RQ0SOR (1 << 2)
  97. #define RTL818X_INT_SE_TXBED_OK (1 << 3)
  98. #define RTL818X_INT_SE_TXBED_ERR (1 << 4)
  99. #define RTL818X_INT_SE_TXBE_OK (1 << 5)
  100. #define RTL818X_INT_SE_TXBE_ERR (1 << 6)
  101. #define RTL818X_INT_SE_RX_OK (1 << 7)
  102. #define RTL818X_INT_SE_RX_ERR (1 << 8)
  103. #define RTL818X_INT_SE_TXL_OK (1 << 9)
  104. #define RTL818X_INT_SE_TXL_ERR (1 << 10)
  105. #define RTL818X_INT_SE_RX_DU (1 << 11)
  106. #define RTL818X_INT_SE_RX_FIFO (1 << 12)
  107. #define RTL818X_INT_SE_TXN_OK (1 << 13)
  108. #define RTL818X_INT_SE_TXN_ERR (1 << 14)
  109. #define RTL818X_INT_SE_TXH_OK (1 << 15)
  110. #define RTL818X_INT_SE_TXH_ERR (1 << 16)
  111. #define RTL818X_INT_SE_TXB_OK (1 << 17)
  112. #define RTL818X_INT_SE_TXB_ERR (1 << 18)
  113. #define RTL818X_INT_SE_ATIM_TO (1 << 19)
  114. #define RTL818X_INT_SE_BK_TO (1 << 20)
  115. #define RTL818X_INT_SE_TIMER1 (1 << 21)
  116. #define RTL818X_INT_SE_TX_FIFO (1 << 22)
  117. #define RTL818X_INT_SE_WAKEUP (1 << 23)
  118. #define RTL818X_INT_SE_BK_DMA (1 << 24)
  119. #define RTL818X_INT_SE_TMGD_OK (1 << 30)
  120. __le32 TX_CONF; /* 0x40 */
  121. #define RTL818X_TX_CONF_LOOPBACK_MAC (1 << 17)
  122. #define RTL818X_TX_CONF_LOOPBACK_CONT (3 << 17)
  123. #define RTL818X_TX_CONF_NO_ICV (1 << 19)
  124. #define RTL818X_TX_CONF_DISCW (1 << 20)
  125. #define RTL818X_TX_CONF_SAT_HWPLCP (1 << 24)
  126. #define RTL818X_TX_CONF_R8180_ABCD (2 << 25)
  127. #define RTL818X_TX_CONF_R8180_F (3 << 25)
  128. #define RTL818X_TX_CONF_R8185_ABC (4 << 25)
  129. #define RTL818X_TX_CONF_R8185_D (5 << 25)
  130. #define RTL818X_TX_CONF_R8187vD (5 << 25)
  131. #define RTL818X_TX_CONF_R8187vD_B (6 << 25)
  132. #define RTL818X_TX_CONF_RTL8187SE (6 << 25)
  133. #define RTL818X_TX_CONF_HWVER_MASK (7 << 25)
  134. #define RTL818X_TX_CONF_DISREQQSIZE (1 << 28)
  135. #define RTL818X_TX_CONF_PROBE_DTS (1 << 29)
  136. #define RTL818X_TX_CONF_HW_SEQNUM (1 << 30)
  137. #define RTL818X_TX_CONF_CW_MIN (1 << 31)
  138. __le32 RX_CONF;
  139. #define RTL818X_RX_CONF_MONITOR (1 << 0)
  140. #define RTL818X_RX_CONF_NICMAC (1 << 1)
  141. #define RTL818X_RX_CONF_MULTICAST (1 << 2)
  142. #define RTL818X_RX_CONF_BROADCAST (1 << 3)
  143. #define RTL818X_RX_CONF_FCS (1 << 5)
  144. #define RTL818X_RX_CONF_DATA (1 << 18)
  145. #define RTL818X_RX_CONF_CTRL (1 << 19)
  146. #define RTL818X_RX_CONF_MGMT (1 << 20)
  147. #define RTL818X_RX_CONF_ADDR3 (1 << 21)
  148. #define RTL818X_RX_CONF_PM (1 << 22)
  149. #define RTL818X_RX_CONF_BSSID (1 << 23)
  150. #define RTL818X_RX_CONF_RX_AUTORESETPHY (1 << 28)
  151. #define RTL818X_RX_CONF_CSDM1 (1 << 29)
  152. #define RTL818X_RX_CONF_CSDM2 (1 << 30)
  153. #define RTL818X_RX_CONF_ONLYERLPKT (1 << 31)
  154. __le32 INT_TIMEOUT;
  155. __le32 TBDA;
  156. u8 EEPROM_CMD;
  157. #define RTL818X_EEPROM_CMD_READ (1 << 0)
  158. #define RTL818X_EEPROM_CMD_WRITE (1 << 1)
  159. #define RTL818X_EEPROM_CMD_CK (1 << 2)
  160. #define RTL818X_EEPROM_CMD_CS (1 << 3)
  161. #define RTL818X_EEPROM_CMD_NORMAL (0 << 6)
  162. #define RTL818X_EEPROM_CMD_LOAD (1 << 6)
  163. #define RTL818X_EEPROM_CMD_PROGRAM (2 << 6)
  164. #define RTL818X_EEPROM_CMD_CONFIG (3 << 6)
  165. u8 CONFIG0;
  166. u8 CONFIG1;
  167. u8 CONFIG2;
  168. #define RTL818X_CONFIG2_ANTENNA_DIV (1 << 6)
  169. __le32 ANAPARAM;
  170. u8 MSR;
  171. #define RTL818X_MSR_NO_LINK (0 << 2)
  172. #define RTL818X_MSR_ADHOC (1 << 2)
  173. #define RTL818X_MSR_INFRA (2 << 2)
  174. #define RTL818X_MSR_MASTER (3 << 2)
  175. #define RTL818X_MSR_ENEDCA (4 << 2)
  176. u8 CONFIG3;
  177. #define RTL818X_CONFIG3_ANAPARAM_WRITE (1 << 6)
  178. #define RTL818X_CONFIG3_GNT_SELECT (1 << 7)
  179. u8 CONFIG4;
  180. #define RTL818X_CONFIG4_POWEROFF (1 << 6)
  181. #define RTL818X_CONFIG4_VCOOFF (1 << 7)
  182. u8 TESTR;
  183. u8 reserved_9[2];
  184. u8 PGSELECT;
  185. u8 SECURITY;
  186. __le32 ANAPARAM2;
  187. u8 reserved_10[8];
  188. __le32 IMR; /* 0x6c - Interrupt mask reg for 8187se */
  189. #define IMR_TMGDOK ((1 << 30))
  190. #define IMR_DOT11HINT ((1 << 25)) /* 802.11h Measurement Interrupt */
  191. #define IMR_BCNDMAINT ((1 << 24)) /* Beacon DMA Interrupt */
  192. #define IMR_WAKEINT ((1 << 23)) /* Wake Up Interrupt */
  193. #define IMR_TXFOVW ((1 << 22)) /* Tx FIFO Overflow */
  194. #define IMR_TIMEOUT1 ((1 << 21)) /* Time Out Interrupt 1 */
  195. #define IMR_BCNINT ((1 << 20)) /* Beacon Time out */
  196. #define IMR_ATIMINT ((1 << 19)) /* ATIM Time Out */
  197. #define IMR_TBDER ((1 << 18)) /* Tx Beacon Descriptor Error */
  198. #define IMR_TBDOK ((1 << 17)) /* Tx Beacon Descriptor OK */
  199. #define IMR_THPDER ((1 << 16)) /* Tx High Priority Descriptor Error */
  200. #define IMR_THPDOK ((1 << 15)) /* Tx High Priority Descriptor OK */
  201. #define IMR_TVODER ((1 << 14)) /* Tx AC_VO Descriptor Error Int */
  202. #define IMR_TVODOK ((1 << 13)) /* Tx AC_VO Descriptor OK Interrupt */
  203. #define IMR_FOVW ((1 << 12)) /* Rx FIFO Overflow Interrupt */
  204. #define IMR_RDU ((1 << 11)) /* Rx Descriptor Unavailable */
  205. #define IMR_TVIDER ((1 << 10)) /* Tx AC_VI Descriptor Error */
  206. #define IMR_TVIDOK ((1 << 9)) /* Tx AC_VI Descriptor OK Interrupt */
  207. #define IMR_RER ((1 << 8)) /* Rx Error Interrupt */
  208. #define IMR_ROK ((1 << 7)) /* Receive OK Interrupt */
  209. #define IMR_TBEDER ((1 << 6)) /* Tx AC_BE Descriptor Error */
  210. #define IMR_TBEDOK ((1 << 5)) /* Tx AC_BE Descriptor OK */
  211. #define IMR_TBKDER ((1 << 4)) /* Tx AC_BK Descriptor Error */
  212. #define IMR_TBKDOK ((1 << 3)) /* Tx AC_BK Descriptor OK */
  213. #define IMR_RQOSOK ((1 << 2)) /* Rx QoS OK Interrupt */
  214. #define IMR_TIMEOUT2 ((1 << 1)) /* Time Out Interrupt 2 */
  215. #define IMR_TIMEOUT3 ((1 << 0)) /* Time Out Interrupt 3 */
  216. __le16 BEACON_INTERVAL; /* 0x70 */
  217. __le16 ATIM_WND; /* 0x72 */
  218. __le16 BEACON_INTERVAL_TIME; /* 0x74 */
  219. __le16 ATIMTR_INTERVAL; /* 0x76 */
  220. u8 PHY_DELAY; /* 0x78 */
  221. u8 CARRIER_SENSE_COUNTER; /* 0x79 */
  222. u8 reserved_11[2]; /* 0x7a */
  223. u8 PHY[4]; /* 0x7c */
  224. __le16 RFPinsOutput; /* 0x80 */
  225. __le16 RFPinsEnable; /* 0x82 */
  226. __le16 RFPinsSelect; /* 0x84 */
  227. __le16 RFPinsInput; /* 0x86 */
  228. __le32 RF_PARA; /* 0x88 */
  229. __le32 RF_TIMING; /* 0x8c */
  230. u8 GP_ENABLE; /* 0x90 */
  231. u8 GPIO0; /* 0x91 */
  232. u8 GPIO1; /* 0x92 */
  233. u8 TPPOLL_STOP; /* 0x93 - rtl8187se only */
  234. #define RTL818x_TPPOLL_STOP_BQ (1 << 7)
  235. #define RTL818x_TPPOLL_STOP_VI (1 << 4)
  236. #define RTL818x_TPPOLL_STOP_VO (1 << 5)
  237. #define RTL818x_TPPOLL_STOP_BE (1 << 3)
  238. #define RTL818x_TPPOLL_STOP_BK (1 << 2)
  239. #define RTL818x_TPPOLL_STOP_MG (1 << 1)
  240. #define RTL818x_TPPOLL_STOP_HI (1 << 6)
  241. __le32 HSSI_PARA; /* 0x94 */
  242. u8 reserved_13[4]; /* 0x98 */
  243. u8 TX_AGC_CTL; /* 0x9c */
  244. #define RTL818X_TX_AGC_CTL_PERPACKET_GAIN (1 << 0)
  245. #define RTL818X_TX_AGC_CTL_PERPACKET_ANTSEL (1 << 1)
  246. #define RTL818X_TX_AGC_CTL_FEEDBACK_ANT (1 << 2)
  247. u8 TX_GAIN_CCK;
  248. u8 TX_GAIN_OFDM;
  249. u8 TX_ANTENNA;
  250. u8 reserved_14[16];
  251. u8 WPA_CONF;
  252. u8 reserved_15[3];
  253. u8 SIFS;
  254. u8 DIFS;
  255. u8 SLOT;
  256. u8 reserved_16[5];
  257. u8 CW_CONF;
  258. #define RTL818X_CW_CONF_PERPACKET_CW (1 << 0)
  259. #define RTL818X_CW_CONF_PERPACKET_RETRY (1 << 1)
  260. u8 CW_VAL;
  261. u8 RATE_FALLBACK;
  262. #define RTL818X_RATE_FALLBACK_ENABLE (1 << 7)
  263. u8 ACM_CONTROL;
  264. u8 reserved_17[24];
  265. u8 CONFIG5;
  266. u8 TX_DMA_POLLING;
  267. u8 PHY_PR;
  268. u8 reserved_18;
  269. __le16 CWR;
  270. u8 RETRY_CTR;
  271. u8 reserved_19[3];
  272. __le16 INT_MIG;
  273. /* RTL818X_R8187B_*: magic numbers from ioregisters */
  274. #define RTL818X_R8187B_B 0
  275. #define RTL818X_R8187B_D 1
  276. #define RTL818X_R8187B_E 2
  277. __le32 RDSAR;
  278. __le16 TID_AC_MAP;
  279. u8 reserved_20[4];
  280. union {
  281. __le16 ANAPARAM3; /* 0xee */
  282. u8 ANAPARAM3A; /* for rtl8187 */
  283. };
  284. #define AC_PARAM_TXOP_LIMIT_SHIFT 16
  285. #define AC_PARAM_ECW_MAX_SHIFT 12
  286. #define AC_PARAM_ECW_MIN_SHIFT 8
  287. #define AC_PARAM_AIFS_SHIFT 0
  288. __le32 AC_VO_PARAM; /* 0xf0 */
  289. union { /* 0xf4 */
  290. __le32 AC_VI_PARAM;
  291. __le16 FEMR;
  292. } __packed;
  293. union{ /* 0xf8 */
  294. __le32 AC_BE_PARAM; /* rtl8187se */
  295. struct{
  296. u8 reserved_21[2];
  297. __le16 TALLY_CNT; /* 0xfa */
  298. } __packed;
  299. } __packed;
  300. union {
  301. u8 TALLY_SEL; /* 0xfc */
  302. __le32 AC_BK_PARAM;
  303. } __packed;
  304. } __packed;
  305. /* These are addresses with NON-standard usage.
  306. * They have offsets very far from this struct.
  307. * I don't like to introduce a ton of "reserved"..
  308. * They are for RTL8187SE
  309. */
  310. #define REG_ADDR1(addr) ((u8 __iomem *)priv->map + (addr))
  311. #define REG_ADDR2(addr) ((__le16 __iomem *)priv->map + ((addr) >> 1))
  312. #define REG_ADDR4(addr) ((__le32 __iomem *)priv->map + ((addr) >> 2))
  313. #define FEMR_SE REG_ADDR2(0x1D4)
  314. #define ARFR REG_ADDR2(0x1E0)
  315. #define RFSW_CTRL REG_ADDR2(0x272)
  316. #define SW_3W_DB0 REG_ADDR2(0x274)
  317. #define SW_3W_DB0_4 REG_ADDR4(0x274)
  318. #define SW_3W_DB1 REG_ADDR2(0x278)
  319. #define SW_3W_DB1_4 REG_ADDR4(0x278)
  320. #define SW_3W_CMD1 REG_ADDR1(0x27D)
  321. #define PI_DATA_REG REG_ADDR2(0x360)
  322. #define SI_DATA_REG REG_ADDR2(0x362)
  323. struct rtl818x_rf_ops {
  324. char *name;
  325. void (*init)(struct ieee80211_hw *);
  326. void (*stop)(struct ieee80211_hw *);
  327. void (*set_chan)(struct ieee80211_hw *, struct ieee80211_conf *);
  328. u8 (*calc_rssi)(u8 agc, u8 sq);
  329. };
  330. /**
  331. * enum rtl818x_tx_desc_flags - Tx/Rx flags are common between RTL818X chips
  332. *
  333. * @RTL818X_TX_DESC_FLAG_NO_ENC: Disable hardware based encryption.
  334. * @RTL818X_TX_DESC_FLAG_TX_OK: TX frame was ACKed.
  335. * @RTL818X_TX_DESC_FLAG_SPLCP: Use short preamble.
  336. * @RTL818X_TX_DESC_FLAG_MOREFRAG: More fragments follow.
  337. * @RTL818X_TX_DESC_FLAG_CTS: Use CTS-to-self protection.
  338. * @RTL818X_TX_DESC_FLAG_RTS: Use RTS/CTS protection.
  339. * @RTL818X_TX_DESC_FLAG_LS: Last segment of the frame.
  340. * @RTL818X_TX_DESC_FLAG_FS: First segment of the frame.
  341. */
  342. enum rtl818x_tx_desc_flags {
  343. RTL818X_TX_DESC_FLAG_NO_ENC = (1 << 15),
  344. RTL818X_TX_DESC_FLAG_TX_OK = (1 << 15),
  345. RTL818X_TX_DESC_FLAG_SPLCP = (1 << 16),
  346. RTL818X_TX_DESC_FLAG_RX_UNDER = (1 << 16),
  347. RTL818X_TX_DESC_FLAG_MOREFRAG = (1 << 17),
  348. RTL818X_TX_DESC_FLAG_CTS = (1 << 18),
  349. RTL818X_TX_DESC_FLAG_RTS = (1 << 23),
  350. RTL818X_TX_DESC_FLAG_LS = (1 << 28),
  351. RTL818X_TX_DESC_FLAG_FS = (1 << 29),
  352. RTL818X_TX_DESC_FLAG_DMA = (1 << 30),
  353. RTL818X_TX_DESC_FLAG_OWN = (1 << 31)
  354. };
  355. enum rtl818x_rx_desc_flags {
  356. RTL818X_RX_DESC_FLAG_ICV_ERR = (1 << 12),
  357. RTL818X_RX_DESC_FLAG_CRC32_ERR = (1 << 13),
  358. RTL818X_RX_DESC_FLAG_PM = (1 << 14),
  359. RTL818X_RX_DESC_FLAG_RX_ERR = (1 << 15),
  360. RTL818X_RX_DESC_FLAG_BCAST = (1 << 16),
  361. RTL818X_RX_DESC_FLAG_PAM = (1 << 17),
  362. RTL818X_RX_DESC_FLAG_MCAST = (1 << 18),
  363. RTL818X_RX_DESC_FLAG_QOS = (1 << 19), /* RTL8187(B) only */
  364. RTL818X_RX_DESC_FLAG_TRSW = (1 << 24), /* RTL8187(B) only */
  365. RTL818X_RX_DESC_FLAG_SPLCP = (1 << 25),
  366. RTL818X_RX_DESC_FLAG_FOF = (1 << 26),
  367. RTL818X_RX_DESC_FLAG_DMA_FAIL = (1 << 27),
  368. RTL818X_RX_DESC_FLAG_LS = (1 << 28),
  369. RTL818X_RX_DESC_FLAG_FS = (1 << 29),
  370. RTL818X_RX_DESC_FLAG_EOR = (1 << 30),
  371. RTL818X_RX_DESC_FLAG_OWN = (1 << 31)
  372. };
  373. #endif /* RTL818X_H */