def.h 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375
  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. * You should have received a copy of the GNU General Public License along with
  15. * this program; if not, write to the Free Software Foundation, Inc.,
  16. * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
  17. *
  18. * The full GNU General Public License is included in this distribution in the
  19. * file called LICENSE.
  20. *
  21. * Contact Information:
  22. * wlanfae <wlanfae@realtek.com>
  23. * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
  24. * Hsinchu 300, Taiwan.
  25. *
  26. * Larry Finger <Larry.Finger@lwfinger.net>
  27. *
  28. *****************************************************************************/
  29. #ifndef __RTL92C_DEF_H__
  30. #define __RTL92C_DEF_H__
  31. #define HAL_RETRY_LIMIT_INFRA 48
  32. #define HAL_RETRY_LIMIT_AP_ADHOC 7
  33. #define PHY_RSSI_SLID_WIN_MAX 100
  34. #define PHY_LINKQUALITY_SLID_WIN_MAX 20
  35. #define PHY_BEACON_RSSI_SLID_WIN_MAX 10
  36. #define RESET_DELAY_8185 20
  37. #define RT_IBSS_INT_MASKS (IMR_BCNINT | IMR_TBDOK | IMR_TBDER)
  38. #define RT_AC_INT_MASKS (IMR_VIDOK | IMR_VODOK | IMR_BEDOK|IMR_BKDOK)
  39. #define NUM_OF_FIRMWARE_QUEUE 10
  40. #define NUM_OF_PAGES_IN_FW 0x100
  41. #define NUM_OF_PAGE_IN_FW_QUEUE_BK 0x07
  42. #define NUM_OF_PAGE_IN_FW_QUEUE_BE 0x07
  43. #define NUM_OF_PAGE_IN_FW_QUEUE_VI 0x07
  44. #define NUM_OF_PAGE_IN_FW_QUEUE_VO 0x07
  45. #define NUM_OF_PAGE_IN_FW_QUEUE_HCCA 0x0
  46. #define NUM_OF_PAGE_IN_FW_QUEUE_CMD 0x0
  47. #define NUM_OF_PAGE_IN_FW_QUEUE_MGNT 0x02
  48. #define NUM_OF_PAGE_IN_FW_QUEUE_HIGH 0x02
  49. #define NUM_OF_PAGE_IN_FW_QUEUE_BCN 0x2
  50. #define NUM_OF_PAGE_IN_FW_QUEUE_PUB 0xA1
  51. #define NUM_OF_PAGE_IN_FW_QUEUE_BK_DTM 0x026
  52. #define NUM_OF_PAGE_IN_FW_QUEUE_BE_DTM 0x048
  53. #define NUM_OF_PAGE_IN_FW_QUEUE_VI_DTM 0x048
  54. #define NUM_OF_PAGE_IN_FW_QUEUE_VO_DTM 0x026
  55. #define NUM_OF_PAGE_IN_FW_QUEUE_PUB_DTM 0x00
  56. #define MAX_LINES_HWCONFIG_TXT 1000
  57. #define MAX_BYTES_LINE_HWCONFIG_TXT 256
  58. #define SW_THREE_WIRE 0
  59. #define HW_THREE_WIRE 2
  60. #define BT_DEMO_BOARD 0
  61. #define BT_QA_BOARD 1
  62. #define BT_FPGA 2
  63. #define RX_SMOOTH_FACTOR 20
  64. #define HAL_PRIME_CHNL_OFFSET_DONT_CARE 0
  65. #define HAL_PRIME_CHNL_OFFSET_LOWER 1
  66. #define HAL_PRIME_CHNL_OFFSET_UPPER 2
  67. #define MAX_H2C_QUEUE_NUM 10
  68. #define RX_MPDU_QUEUE 0
  69. #define RX_CMD_QUEUE 1
  70. #define RX_MAX_QUEUE 2
  71. #define AC2QUEUEID(_AC) (_AC)
  72. #define C2H_RX_CMD_HDR_LEN 8
  73. #define GET_C2H_CMD_CMD_LEN(__prxhdr) \
  74. LE_BITS_TO_4BYTE((__prxhdr), 0, 16)
  75. #define GET_C2H_CMD_ELEMENT_ID(__prxhdr) \
  76. LE_BITS_TO_4BYTE((__prxhdr), 16, 8)
  77. #define GET_C2H_CMD_CMD_SEQ(__prxhdr) \
  78. LE_BITS_TO_4BYTE((__prxhdr), 24, 7)
  79. #define GET_C2H_CMD_CONTINUE(__prxhdr) \
  80. LE_BITS_TO_4BYTE((__prxhdr), 31, 1)
  81. #define GET_C2H_CMD_CONTENT(__prxhdr) \
  82. ((u8 *)(__prxhdr) + C2H_RX_CMD_HDR_LEN)
  83. #define GET_C2H_CMD_FEEDBACK_ELEMENT_ID(__pcmdfbhdr) \
  84. LE_BITS_TO_4BYTE((__pcmdfbhdr), 0, 8)
  85. #define GET_C2H_CMD_FEEDBACK_CCX_LEN(__pcmdfbhdr) \
  86. LE_BITS_TO_4BYTE((__pcmdfbhdr), 8, 8)
  87. #define GET_C2H_CMD_FEEDBACK_CCX_CMD_CNT(__pcmdfbhdr) \
  88. LE_BITS_TO_4BYTE((__pcmdfbhdr), 16, 16)
  89. #define GET_C2H_CMD_FEEDBACK_CCX_MAC_ID(__pcmdfbhdr) \
  90. LE_BITS_TO_4BYTE(((__pcmdfbhdr) + 4), 0, 5)
  91. #define GET_C2H_CMD_FEEDBACK_CCX_VALID(__pcmdfbhdr) \
  92. LE_BITS_TO_4BYTE(((__pcmdfbhdr) + 4), 7, 1)
  93. #define GET_C2H_CMD_FEEDBACK_CCX_RETRY_CNT(__pcmdfbhdr) \
  94. LE_BITS_TO_4BYTE(((__pcmdfbhdr) + 4), 8, 5)
  95. #define GET_C2H_CMD_FEEDBACK_CCX_TOK(__pcmdfbhdr) \
  96. LE_BITS_TO_4BYTE(((__pcmdfbhdr) + 4), 15, 1)
  97. #define GET_C2H_CMD_FEEDBACK_CCX_QSEL(__pcmdfbhdr) \
  98. LE_BITS_TO_4BYTE(((__pcmdfbhdr) + 4), 16, 4)
  99. #define GET_C2H_CMD_FEEDBACK_CCX_SEQ(__pcmdfbhdr) \
  100. LE_BITS_TO_4BYTE(((__pcmdfbhdr) + 4), 20, 12)
  101. #define CHIP_VER_B BIT(4)
  102. #define CHIP_92C_BITMASK BIT(0)
  103. #define CHIP_92C_1T2R 0x03
  104. #define CHIP_92C 0x01
  105. #define CHIP_88C 0x00
  106. enum version_8192c {
  107. VERSION_A_CHIP_92C = 0x01,
  108. VERSION_A_CHIP_88C = 0x00,
  109. VERSION_B_CHIP_92C = 0x11,
  110. VERSION_B_CHIP_88C = 0x10,
  111. VERSION_TEST_CHIP_88C = 0x00,
  112. VERSION_TEST_CHIP_92C = 0x01,
  113. VERSION_NORMAL_TSMC_CHIP_88C = 0x10,
  114. VERSION_NORMAL_TSMC_CHIP_92C = 0x11,
  115. VERSION_NORMAL_TSMC_CHIP_92C_1T2R = 0x13,
  116. VERSION_NORMAL_UMC_CHIP_88C_A_CUT = 0x30,
  117. VERSION_NORMAL_UMC_CHIP_92C_A_CUT = 0x31,
  118. VERSION_NORMAL_UMC_CHIP_92C_1T2R_A_CUT = 0x33,
  119. VERSION_NORMA_UMC_CHIP_8723_1T1R_A_CUT = 0x34,
  120. VERSION_NORMA_UMC_CHIP_8723_1T1R_B_CUT = 0x3c,
  121. VERSION_NORMAL_UMC_CHIP_88C_B_CUT = 0x70,
  122. VERSION_NORMAL_UMC_CHIP_92C_B_CUT = 0x71,
  123. VERSION_NORMAL_UMC_CHIP_92C_1T2R_B_CUT = 0x73,
  124. VERSION_UNKNOWN = 0x88,
  125. };
  126. #define IS_CHIP_VER_B(version) ((version & CHIP_VER_B) ? true : false)
  127. #define IS_92C_SERIAL(version) ((version & CHIP_92C_BITMASK) ? true : false)
  128. enum rtl819x_loopback_e {
  129. RTL819X_NO_LOOPBACK = 0,
  130. RTL819X_MAC_LOOPBACK = 1,
  131. RTL819X_DMA_LOOPBACK = 2,
  132. RTL819X_CCK_LOOPBACK = 3,
  133. };
  134. enum rf_optype {
  135. RF_OP_BY_SW_3WIRE = 0,
  136. RF_OP_BY_FW,
  137. RF_OP_MAX
  138. };
  139. enum rf_power_state {
  140. RF_ON,
  141. RF_OFF,
  142. RF_SLEEP,
  143. RF_SHUT_DOWN,
  144. };
  145. enum power_save_mode {
  146. POWER_SAVE_MODE_ACTIVE,
  147. POWER_SAVE_MODE_SAVE,
  148. };
  149. enum power_polocy_config {
  150. POWERCFG_MAX_POWER_SAVINGS,
  151. POWERCFG_GLOBAL_POWER_SAVINGS,
  152. POWERCFG_LOCAL_POWER_SAVINGS,
  153. POWERCFG_LENOVO,
  154. };
  155. enum interface_select_pci {
  156. INTF_SEL1_MINICARD = 0,
  157. INTF_SEL0_PCIE = 1,
  158. INTF_SEL2_RSV = 2,
  159. INTF_SEL3_RSV = 3,
  160. };
  161. enum hal_fw_c2h_cmd_id {
  162. HAL_FW_C2H_CMD_Read_MACREG = 0,
  163. HAL_FW_C2H_CMD_Read_BBREG = 1,
  164. HAL_FW_C2H_CMD_Read_RFREG = 2,
  165. HAL_FW_C2H_CMD_Read_EEPROM = 3,
  166. HAL_FW_C2H_CMD_Read_EFUSE = 4,
  167. HAL_FW_C2H_CMD_Read_CAM = 5,
  168. HAL_FW_C2H_CMD_Get_BasicRate = 6,
  169. HAL_FW_C2H_CMD_Get_DataRate = 7,
  170. HAL_FW_C2H_CMD_Survey = 8,
  171. HAL_FW_C2H_CMD_SurveyDone = 9,
  172. HAL_FW_C2H_CMD_JoinBss = 10,
  173. HAL_FW_C2H_CMD_AddSTA = 11,
  174. HAL_FW_C2H_CMD_DelSTA = 12,
  175. HAL_FW_C2H_CMD_AtimDone = 13,
  176. HAL_FW_C2H_CMD_TX_Report = 14,
  177. HAL_FW_C2H_CMD_CCX_Report = 15,
  178. HAL_FW_C2H_CMD_DTM_Report = 16,
  179. HAL_FW_C2H_CMD_TX_Rate_Statistics = 17,
  180. HAL_FW_C2H_CMD_C2HLBK = 18,
  181. HAL_FW_C2H_CMD_C2HDBG = 19,
  182. HAL_FW_C2H_CMD_C2HFEEDBACK = 20,
  183. HAL_FW_C2H_CMD_MAX
  184. };
  185. enum rtl_desc_qsel {
  186. QSLT_BK = 0x2,
  187. QSLT_BE = 0x0,
  188. QSLT_VI = 0x5,
  189. QSLT_VO = 0x7,
  190. QSLT_BEACON = 0x10,
  191. QSLT_HIGH = 0x11,
  192. QSLT_MGNT = 0x12,
  193. QSLT_CMD = 0x13,
  194. };
  195. enum rtl_desc92c_rate {
  196. DESC92C_RATE1M = 0x00,
  197. DESC92C_RATE2M = 0x01,
  198. DESC92C_RATE5_5M = 0x02,
  199. DESC92C_RATE11M = 0x03,
  200. DESC92C_RATE6M = 0x04,
  201. DESC92C_RATE9M = 0x05,
  202. DESC92C_RATE12M = 0x06,
  203. DESC92C_RATE18M = 0x07,
  204. DESC92C_RATE24M = 0x08,
  205. DESC92C_RATE36M = 0x09,
  206. DESC92C_RATE48M = 0x0a,
  207. DESC92C_RATE54M = 0x0b,
  208. DESC92C_RATEMCS0 = 0x0c,
  209. DESC92C_RATEMCS1 = 0x0d,
  210. DESC92C_RATEMCS2 = 0x0e,
  211. DESC92C_RATEMCS3 = 0x0f,
  212. DESC92C_RATEMCS4 = 0x10,
  213. DESC92C_RATEMCS5 = 0x11,
  214. DESC92C_RATEMCS6 = 0x12,
  215. DESC92C_RATEMCS7 = 0x13,
  216. DESC92C_RATEMCS8 = 0x14,
  217. DESC92C_RATEMCS9 = 0x15,
  218. DESC92C_RATEMCS10 = 0x16,
  219. DESC92C_RATEMCS11 = 0x17,
  220. DESC92C_RATEMCS12 = 0x18,
  221. DESC92C_RATEMCS13 = 0x19,
  222. DESC92C_RATEMCS14 = 0x1a,
  223. DESC92C_RATEMCS15 = 0x1b,
  224. DESC92C_RATEMCS15_SG = 0x1c,
  225. DESC92C_RATEMCS32 = 0x20,
  226. };
  227. struct phy_sts_cck_8192s_t {
  228. u8 adc_pwdb_X[4];
  229. u8 sq_rpt;
  230. u8 cck_agc_rpt;
  231. };
  232. struct h2c_cmd_8192c {
  233. u8 element_id;
  234. u32 cmd_len;
  235. u8 *p_cmdbuffer;
  236. };
  237. /* NOTE: reference to rtl8192c_rates struct */
  238. static inline int _rtl92c_rate_mapping(struct ieee80211_hw *hw, bool isHT,
  239. u8 desc_rate, bool first_ampdu)
  240. {
  241. struct rtl_priv *rtlpriv = rtl_priv(hw);
  242. int rate_idx = 0;
  243. if (first_ampdu) {
  244. if (false == isHT) {
  245. switch (desc_rate) {
  246. case DESC92C_RATE1M:
  247. rate_idx = 0;
  248. break;
  249. case DESC92C_RATE2M:
  250. rate_idx = 1;
  251. break;
  252. case DESC92C_RATE5_5M:
  253. rate_idx = 2;
  254. break;
  255. case DESC92C_RATE11M:
  256. rate_idx = 3;
  257. break;
  258. case DESC92C_RATE6M:
  259. rate_idx = 4;
  260. break;
  261. case DESC92C_RATE9M:
  262. rate_idx = 5;
  263. break;
  264. case DESC92C_RATE12M:
  265. rate_idx = 6;
  266. break;
  267. case DESC92C_RATE18M:
  268. rate_idx = 7;
  269. break;
  270. case DESC92C_RATE24M:
  271. rate_idx = 8;
  272. break;
  273. case DESC92C_RATE36M:
  274. rate_idx = 9;
  275. break;
  276. case DESC92C_RATE48M:
  277. rate_idx = 10;
  278. break;
  279. case DESC92C_RATE54M:
  280. rate_idx = 11;
  281. break;
  282. default:
  283. RT_TRACE(rtlpriv, COMP_ERR, DBG_DMESG,
  284. ("Rate %d is not support, set to "
  285. "1M rate.\n", desc_rate));
  286. rate_idx = 0;
  287. break;
  288. }
  289. } else {
  290. rate_idx = 11;
  291. }
  292. return rate_idx;
  293. }
  294. switch (desc_rate) {
  295. case DESC92C_RATE1M:
  296. rate_idx = 0;
  297. break;
  298. case DESC92C_RATE2M:
  299. rate_idx = 1;
  300. break;
  301. case DESC92C_RATE5_5M:
  302. rate_idx = 2;
  303. break;
  304. case DESC92C_RATE11M:
  305. rate_idx = 3;
  306. break;
  307. case DESC92C_RATE6M:
  308. rate_idx = 4;
  309. break;
  310. case DESC92C_RATE9M:
  311. rate_idx = 5;
  312. break;
  313. case DESC92C_RATE12M:
  314. rate_idx = 6;
  315. break;
  316. case DESC92C_RATE18M:
  317. rate_idx = 7;
  318. break;
  319. case DESC92C_RATE24M:
  320. rate_idx = 8;
  321. break;
  322. case DESC92C_RATE36M:
  323. rate_idx = 9;
  324. break;
  325. case DESC92C_RATE48M:
  326. rate_idx = 10;
  327. break;
  328. case DESC92C_RATE54M:
  329. rate_idx = 11;
  330. break;
  331. /* TODO: How to mapping MCS rate? */
  332. /* NOTE: referenc to __ieee80211_rx */
  333. default:
  334. rate_idx = 11;
  335. break;
  336. }
  337. return rate_idx;
  338. }
  339. #endif