def.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2009-2010 Realtek Corporation.
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms of version 2 of the GNU General Public License as
  7. * published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. * more details.
  13. *
  14. * The full GNU General Public License is included in this distribution in the
  15. * file called LICENSE.
  16. *
  17. * Contact Information:
  18. * wlanfae <wlanfae@realtek.com>
  19. * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
  20. * Hsinchu 300, Taiwan.
  21. *
  22. * Larry Finger <Larry.Finger@lwfinger.net>
  23. *
  24. *****************************************************************************/
  25. #ifndef __RTL8821AE_DEF_H__
  26. #define __RTL8821AE_DEF_H__
  27. /*--------------------------Define -------------------------------------------*/
  28. #define USE_SPECIFIC_FW_TO_SUPPORT_WOWLAN 1
  29. /* BIT 7 HT Rate*/
  30. /*TxHT = 0*/
  31. #define MGN_1M 0x02
  32. #define MGN_2M 0x04
  33. #define MGN_5_5M 0x0b
  34. #define MGN_11M 0x16
  35. #define MGN_6M 0x0c
  36. #define MGN_9M 0x12
  37. #define MGN_12M 0x18
  38. #define MGN_18M 0x24
  39. #define MGN_24M 0x30
  40. #define MGN_36M 0x48
  41. #define MGN_48M 0x60
  42. #define MGN_54M 0x6c
  43. /* TxHT = 1 */
  44. #define MGN_MCS0 0x80
  45. #define MGN_MCS1 0x81
  46. #define MGN_MCS2 0x82
  47. #define MGN_MCS3 0x83
  48. #define MGN_MCS4 0x84
  49. #define MGN_MCS5 0x85
  50. #define MGN_MCS6 0x86
  51. #define MGN_MCS7 0x87
  52. #define MGN_MCS8 0x88
  53. #define MGN_MCS9 0x89
  54. #define MGN_MCS10 0x8a
  55. #define MGN_MCS11 0x8b
  56. #define MGN_MCS12 0x8c
  57. #define MGN_MCS13 0x8d
  58. #define MGN_MCS14 0x8e
  59. #define MGN_MCS15 0x8f
  60. /* VHT rate */
  61. #define MGN_VHT1SS_MCS0 0x90
  62. #define MGN_VHT1SS_MCS1 0x91
  63. #define MGN_VHT1SS_MCS2 0x92
  64. #define MGN_VHT1SS_MCS3 0x93
  65. #define MGN_VHT1SS_MCS4 0x94
  66. #define MGN_VHT1SS_MCS5 0x95
  67. #define MGN_VHT1SS_MCS6 0x96
  68. #define MGN_VHT1SS_MCS7 0x97
  69. #define MGN_VHT1SS_MCS8 0x98
  70. #define MGN_VHT1SS_MCS9 0x99
  71. #define MGN_VHT2SS_MCS0 0x9a
  72. #define MGN_VHT2SS_MCS1 0x9b
  73. #define MGN_VHT2SS_MCS2 0x9c
  74. #define MGN_VHT2SS_MCS3 0x9d
  75. #define MGN_VHT2SS_MCS4 0x9e
  76. #define MGN_VHT2SS_MCS5 0x9f
  77. #define MGN_VHT2SS_MCS6 0xa0
  78. #define MGN_VHT2SS_MCS7 0xa1
  79. #define MGN_VHT2SS_MCS8 0xa2
  80. #define MGN_VHT2SS_MCS9 0xa3
  81. #define MGN_VHT3SS_MCS0 0xa4
  82. #define MGN_VHT3SS_MCS1 0xa5
  83. #define MGN_VHT3SS_MCS2 0xa6
  84. #define MGN_VHT3SS_MCS3 0xa7
  85. #define MGN_VHT3SS_MCS4 0xa8
  86. #define MGN_VHT3SS_MCS5 0xa9
  87. #define MGN_VHT3SS_MCS6 0xaa
  88. #define MGN_VHT3SS_MCS7 0xab
  89. #define MGN_VHT3SS_MCS8 0xac
  90. #define MGN_VHT3SS_MCS9 0xad
  91. #define MGN_MCS0_SG 0xc0
  92. #define MGN_MCS1_SG 0xc1
  93. #define MGN_MCS2_SG 0xc2
  94. #define MGN_MCS3_SG 0xc3
  95. #define MGN_MCS4_SG 0xc4
  96. #define MGN_MCS5_SG 0xc5
  97. #define MGN_MCS6_SG 0xc6
  98. #define MGN_MCS7_SG 0xc7
  99. #define MGN_MCS8_SG 0xc8
  100. #define MGN_MCS9_SG 0xc9
  101. #define MGN_MCS10_SG 0xca
  102. #define MGN_MCS11_SG 0xcb
  103. #define MGN_MCS12_SG 0xcc
  104. #define MGN_MCS13_SG 0xcd
  105. #define MGN_MCS14_SG 0xce
  106. #define MGN_MCS15_SG 0xcf
  107. #define MGN_UNKNOWN 0xff
  108. /* 30 ms */
  109. #define WIFI_NAV_UPPER_US 30000
  110. #define HAL_92C_NAV_UPPER_UNIT 128
  111. #define MAX_RX_DMA_BUFFER_SIZE 0x3E80
  112. #define HAL_PRIME_CHNL_OFFSET_DONT_CARE 0
  113. #define HAL_PRIME_CHNL_OFFSET_LOWER 1
  114. #define HAL_PRIME_CHNL_OFFSET_UPPER 2
  115. #define RX_MPDU_QUEUE 0
  116. #define RX_CMD_QUEUE 1
  117. #define MAX_RX_DMA_BUFFER_SIZE_8812 0x3E80
  118. #define C2H_RX_CMD_HDR_LEN 8
  119. #define GET_C2H_CMD_CMD_LEN(__prxhdr) \
  120. LE_BITS_TO_4BYTE((__prxhdr), 0, 16)
  121. #define GET_C2H_CMD_ELEMENT_ID(__prxhdr) \
  122. LE_BITS_TO_4BYTE((__prxhdr), 16, 8)
  123. #define GET_C2H_CMD_CMD_SEQ(__prxhdr) \
  124. LE_BITS_TO_4BYTE((__prxhdr), 24, 7)
  125. #define GET_C2H_CMD_CONTINUE(__prxhdr) \
  126. LE_BITS_TO_4BYTE((__prxhdr), 31, 1)
  127. #define GET_C2H_CMD_CONTENT(__prxhdr) \
  128. ((u8 *)(__prxhdr) + C2H_RX_CMD_HDR_LEN)
  129. #define GET_C2H_CMD_FEEDBACK_ELEMENT_ID(__pcmdfbhdr) \
  130. LE_BITS_TO_4BYTE((__pcmdfbhdr), 0, 8)
  131. #define GET_C2H_CMD_FEEDBACK_CCX_LEN(__pcmdfbhdr) \
  132. LE_BITS_TO_4BYTE((__pcmdfbhdr), 8, 8)
  133. #define GET_C2H_CMD_FEEDBACK_CCX_CMD_CNT(__pcmdfbhdr) \
  134. LE_BITS_TO_4BYTE((__pcmdfbhdr), 16, 16)
  135. #define GET_C2H_CMD_FEEDBACK_CCX_MAC_ID(__pcmdfbhdr) \
  136. LE_BITS_TO_4BYTE(((__pcmdfbhdr) + 4), 0, 5)
  137. #define GET_C2H_CMD_FEEDBACK_CCX_VALID(__pcmdfbhdr) \
  138. LE_BITS_TO_4BYTE(((__pcmdfbhdr) + 4), 7, 1)
  139. #define GET_C2H_CMD_FEEDBACK_CCX_RETRY_CNT(__pcmdfbhdr) \
  140. LE_BITS_TO_4BYTE(((__pcmdfbhdr) + 4), 8, 5)
  141. #define GET_C2H_CMD_FEEDBACK_CCX_TOK(__pcmdfbhdr) \
  142. LE_BITS_TO_4BYTE(((__pcmdfbhdr) + 4), 15, 1)
  143. #define GET_C2H_CMD_FEEDBACK_CCX_QSEL(__pcmdfbhdr) \
  144. LE_BITS_TO_4BYTE(((__pcmdfbhdr) + 4), 16, 4)
  145. #define GET_C2H_CMD_FEEDBACK_CCX_SEQ(__pcmdfbhdr) \
  146. LE_BITS_TO_4BYTE(((__pcmdfbhdr) + 4), 20, 12)
  147. #define CHIP_BONDING_IDENTIFIER(_value) (((_value)>>22)&0x3)
  148. #define CHIP_8812 BIT(2)
  149. #define CHIP_8821 (BIT(0)|BIT(2))
  150. #define CHIP_8821A (BIT(0)|BIT(2))
  151. #define NORMAL_CHIP BIT(3)
  152. #define RF_TYPE_1T1R (~(BIT(4)|BIT(5)|BIT(6)))
  153. #define RF_TYPE_1T2R BIT(4)
  154. #define RF_TYPE_2T2R BIT(5)
  155. #define CHIP_VENDOR_UMC BIT(7)
  156. #define B_CUT_VERSION BIT(12)
  157. #define C_CUT_VERSION BIT(13)
  158. #define D_CUT_VERSION ((BIT(12)|BIT(13)))
  159. #define E_CUT_VERSION BIT(14)
  160. #define RF_RL_ID (BIT(31)|BIT(30)|BIT(29)|BIT(28))
  161. enum version_8821ae {
  162. VERSION_TEST_CHIP_1T1R_8812 = 0x0004,
  163. VERSION_TEST_CHIP_2T2R_8812 = 0x0024,
  164. VERSION_NORMAL_TSMC_CHIP_1T1R_8812 = 0x100c,
  165. VERSION_NORMAL_TSMC_CHIP_2T2R_8812 = 0x102c,
  166. VERSION_NORMAL_TSMC_CHIP_1T1R_8812_C_CUT = 0x200c,
  167. VERSION_NORMAL_TSMC_CHIP_2T2R_8812_C_CUT = 0x202c,
  168. VERSION_TEST_CHIP_8821 = 0x0005,
  169. VERSION_NORMAL_TSMC_CHIP_8821 = 0x000d,
  170. VERSION_NORMAL_TSMC_CHIP_8821_B_CUT = 0x100d,
  171. VERSION_UNKNOWN = 0xFF,
  172. };
  173. enum vht_data_sc {
  174. VHT_DATA_SC_DONOT_CARE = 0,
  175. VHT_DATA_SC_20_UPPER_OF_80MHZ = 1,
  176. VHT_DATA_SC_20_LOWER_OF_80MHZ = 2,
  177. VHT_DATA_SC_20_UPPERST_OF_80MHZ = 3,
  178. VHT_DATA_SC_20_LOWEST_OF_80MHZ = 4,
  179. VHT_DATA_SC_20_RECV1 = 5,
  180. VHT_DATA_SC_20_RECV2 = 6,
  181. VHT_DATA_SC_20_RECV3 = 7,
  182. VHT_DATA_SC_20_RECV4 = 8,
  183. VHT_DATA_SC_40_UPPER_OF_80MHZ = 9,
  184. VHT_DATA_SC_40_LOWER_OF_80MHZ = 10,
  185. };
  186. /* MASK */
  187. #define IC_TYPE_MASK (BIT(0)|BIT(1)|BIT(2))
  188. #define CHIP_TYPE_MASK BIT(3)
  189. #define RF_TYPE_MASK (BIT(4)|BIT(5)|BIT(6))
  190. #define MANUFACTUER_MASK BIT(7)
  191. #define ROM_VERSION_MASK (BIT(11)|BIT(10)|BIT(9)|BIT(8))
  192. #define CUT_VERSION_MASK (BIT(15)|BIT(14)|BIT(13)|BIT(12))
  193. /* Get element */
  194. #define GET_CVID_IC_TYPE(version) ((version) & IC_TYPE_MASK)
  195. #define GET_CVID_CHIP_TYPE(version) ((version) & CHIP_TYPE_MASK)
  196. #define GET_CVID_RF_TYPE(version) ((version) & RF_TYPE_MASK)
  197. #define GET_CVID_MANUFACTUER(version) ((version) & MANUFACTUER_MASK)
  198. #define GET_CVID_ROM_VERSION(version) ((version) & ROM_VERSION_MASK)
  199. #define GET_CVID_CUT_VERSION(version) ((version) & CUT_VERSION_MASK)
  200. #define IS_1T1R(version) ((GET_CVID_RF_TYPE(version)) ? false : true)
  201. #define IS_1T2R(version) ((GET_CVID_RF_TYPE(version) == RF_TYPE_1T2R)\
  202. ? true : false)
  203. #define IS_2T2R(version) ((GET_CVID_RF_TYPE(version) == RF_TYPE_2T2R)\
  204. ? true : false)
  205. #define IS_8812_SERIES(version) ((GET_CVID_IC_TYPE(version) == CHIP_8812) ? \
  206. true : false)
  207. #define IS_8821_SERIES(version) ((GET_CVID_IC_TYPE(version) == CHIP_8821) ? \
  208. true : false)
  209. #define IS_VENDOR_8812A_TEST_CHIP(version) ((IS_8812_SERIES(version)) ? \
  210. ((IS_NORMAL_CHIP(version)) ? \
  211. false : true) : false)
  212. #define IS_VENDOR_8812A_MP_CHIP(version) ((IS_8812_SERIES(version)) ? \
  213. ((IS_NORMAL_CHIP(version)) ? \
  214. true : false) : false)
  215. #define IS_VENDOR_8812A_C_CUT(version) ((IS_8812_SERIES(version)) ? \
  216. ((GET_CVID_CUT_VERSION(version) == \
  217. C_CUT_VERSION) ? \
  218. true : false) : false)
  219. #define IS_VENDOR_8821A_TEST_CHIP(version) ((IS_8821_SERIES(version)) ? \
  220. ((IS_NORMAL_CHIP(version)) ? \
  221. false : true) : false)
  222. #define IS_VENDOR_8821A_MP_CHIP(version) ((IS_8821_SERIES(version)) ? \
  223. ((IS_NORMAL_CHIP(version)) ? \
  224. true : false) : false)
  225. #define IS_VENDOR_8821A_B_CUT(version) ((IS_8821_SERIES(version)) ? \
  226. ((GET_CVID_CUT_VERSION(version) == \
  227. B_CUT_VERSION) ? \
  228. true : false) : false)
  229. enum board_type {
  230. ODM_BOARD_DEFAULT = 0, /* The DEFAULT case. */
  231. ODM_BOARD_MINICARD = BIT(0), /* 0 = non-mini card, 1 = mini card. */
  232. ODM_BOARD_SLIM = BIT(1), /* 0 = non-slim card, 1 = slim card */
  233. ODM_BOARD_BT = BIT(2), /* 0 = without BT card, 1 = with BT */
  234. ODM_BOARD_EXT_PA = BIT(3), /* 1 = existing 2G ext-PA */
  235. ODM_BOARD_EXT_LNA = BIT(4), /* 1 = existing 2G ext-LNA */
  236. ODM_BOARD_EXT_TRSW = BIT(5), /* 1 = existing ext-TRSW */
  237. ODM_BOARD_EXT_PA_5G = BIT(6), /* 1 = existing 5G ext-PA */
  238. ODM_BOARD_EXT_LNA_5G = BIT(7), /* 1 = existing 5G ext-LNA */
  239. };
  240. enum rf_optype {
  241. RF_OP_BY_SW_3WIRE = 0,
  242. RF_OP_BY_FW,
  243. RF_OP_MAX
  244. };
  245. enum rf_power_state {
  246. RF_ON,
  247. RF_OFF,
  248. RF_SLEEP,
  249. RF_SHUT_DOWN,
  250. };
  251. enum power_save_mode {
  252. POWER_SAVE_MODE_ACTIVE,
  253. POWER_SAVE_MODE_SAVE,
  254. };
  255. enum power_polocy_config {
  256. POWERCFG_MAX_POWER_SAVINGS,
  257. POWERCFG_GLOBAL_POWER_SAVINGS,
  258. POWERCFG_LOCAL_POWER_SAVINGS,
  259. POWERCFG_LENOVO,
  260. };
  261. enum interface_select_pci {
  262. INTF_SEL1_MINICARD = 0,
  263. INTF_SEL0_PCIE = 1,
  264. INTF_SEL2_RSV = 2,
  265. INTF_SEL3_RSV = 3,
  266. };
  267. enum hal_fw_c2h_cmd_id {
  268. HAL_FW_C2H_CMD_READ_MACREG = 0,
  269. HAL_FW_C2H_CMD_READ_BBREG = 1,
  270. HAL_FW_C2H_CMD_READ_RFREG = 2,
  271. HAL_FW_C2H_CMD_READ_EEPROM = 3,
  272. HAL_FW_C2H_CMD_READ_EFUSE = 4,
  273. HAL_FW_C2H_CMD_READ_CAM = 5,
  274. HAL_FW_C2H_CMD_GET_BASICRATE = 6,
  275. HAL_FW_C2H_CMD_GET_DATARATE = 7,
  276. HAL_FW_C2H_CMD_SURVEY = 8,
  277. HAL_FW_C2H_CMD_SURVEYDONE = 9,
  278. HAL_FW_C2H_CMD_JOINBSS = 10,
  279. HAL_FW_C2H_CMD_ADDSTA = 11,
  280. HAL_FW_C2H_CMD_DELSTA = 12,
  281. HAL_FW_C2H_CMD_ATIMDONE = 13,
  282. HAL_FW_C2H_CMD_TX_REPORT = 14,
  283. HAL_FW_C2H_CMD_CCX_REPORT = 15,
  284. HAL_FW_C2H_CMD_DTM_REPORT = 16,
  285. HAL_FW_C2H_CMD_TX_RATE_STATISTICS = 17,
  286. HAL_FW_C2H_CMD_C2HLBK = 18,
  287. HAL_FW_C2H_CMD_C2HDBG = 19,
  288. HAL_FW_C2H_CMD_C2HFEEDBACK = 20,
  289. HAL_FW_C2H_CMD_MAX
  290. };
  291. enum rtl_desc_qsel {
  292. QSLT_BK = 0x2,
  293. QSLT_BE = 0x0,
  294. QSLT_VI = 0x5,
  295. QSLT_VO = 0x7,
  296. QSLT_BEACON = 0x10,
  297. QSLT_HIGH = 0x11,
  298. QSLT_MGNT = 0x12,
  299. QSLT_CMD = 0x13,
  300. };
  301. enum rx_packet_type {
  302. NORMAL_RX,
  303. TX_REPORT1,
  304. TX_REPORT2,
  305. HIS_REPORT,
  306. C2H_PACKET,
  307. };
  308. struct phy_sts_cck_8821ae_t {
  309. u8 adc_pwdb_X[4];
  310. u8 sq_rpt;
  311. u8 cck_agc_rpt;
  312. };
  313. struct h2c_cmd_8821ae {
  314. u8 element_id;
  315. u32 cmd_len;
  316. u8 *p_cmdbuffer;
  317. };
  318. #endif