def.h 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401
  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. /* Add vendor information into chip version definition.
  107. * Add UMC B-Cut and RTL8723 chip info definition.
  108. *
  109. * BIT 7 Reserved
  110. * BIT 6 UMC BCut
  111. * BIT 5 Manufacturer(TSMC/UMC)
  112. * BIT 4 TEST/NORMAL
  113. * BIT 3 8723 Version
  114. * BIT 2 8723?
  115. * BIT 1 1T2R?
  116. * BIT 0 88C/92C
  117. */
  118. enum version_8192c {
  119. VERSION_A_CHIP_92C = 0x01,
  120. VERSION_A_CHIP_88C = 0x00,
  121. VERSION_B_CHIP_92C = 0x11,
  122. VERSION_B_CHIP_88C = 0x10,
  123. VERSION_TEST_CHIP_88C = 0x00,
  124. VERSION_TEST_CHIP_92C = 0x01,
  125. VERSION_NORMAL_TSMC_CHIP_88C = 0x10,
  126. VERSION_NORMAL_TSMC_CHIP_92C = 0x11,
  127. VERSION_NORMAL_TSMC_CHIP_92C_1T2R = 0x13,
  128. VERSION_NORMAL_UMC_CHIP_88C_A_CUT = 0x30,
  129. VERSION_NORMAL_UMC_CHIP_92C_A_CUT = 0x31,
  130. VERSION_NORMAL_UMC_CHIP_92C_1T2R_A_CUT = 0x33,
  131. VERSION_NORMA_UMC_CHIP_8723_1T1R_A_CUT = 0x34,
  132. VERSION_NORMA_UMC_CHIP_8723_1T1R_B_CUT = 0x3c,
  133. VERSION_NORMAL_UMC_CHIP_88C_B_CUT = 0x70,
  134. VERSION_NORMAL_UMC_CHIP_92C_B_CUT = 0x71,
  135. VERSION_NORMAL_UMC_CHIP_92C_1T2R_B_CUT = 0x73,
  136. VERSION_UNKNOWN = 0x88,
  137. };
  138. #define IS_CHIP_VER_B(version) ((version & CHIP_VER_B) ? true : false)
  139. #define IS_92C_SERIAL(version) ((version & CHIP_92C_BITMASK) ? true : false)
  140. enum rtl819x_loopback_e {
  141. RTL819X_NO_LOOPBACK = 0,
  142. RTL819X_MAC_LOOPBACK = 1,
  143. RTL819X_DMA_LOOPBACK = 2,
  144. RTL819X_CCK_LOOPBACK = 3,
  145. };
  146. enum rf_optype {
  147. RF_OP_BY_SW_3WIRE = 0,
  148. RF_OP_BY_FW,
  149. RF_OP_MAX
  150. };
  151. enum rf_power_state {
  152. RF_ON,
  153. RF_OFF,
  154. RF_SLEEP,
  155. RF_SHUT_DOWN,
  156. };
  157. enum power_save_mode {
  158. POWER_SAVE_MODE_ACTIVE,
  159. POWER_SAVE_MODE_SAVE,
  160. };
  161. enum power_polocy_config {
  162. POWERCFG_MAX_POWER_SAVINGS,
  163. POWERCFG_GLOBAL_POWER_SAVINGS,
  164. POWERCFG_LOCAL_POWER_SAVINGS,
  165. POWERCFG_LENOVO,
  166. };
  167. enum interface_select_pci {
  168. INTF_SEL1_MINICARD = 0,
  169. INTF_SEL0_PCIE = 1,
  170. INTF_SEL2_RSV = 2,
  171. INTF_SEL3_RSV = 3,
  172. };
  173. enum hal_fw_c2h_cmd_id {
  174. HAL_FW_C2H_CMD_Read_MACREG = 0,
  175. HAL_FW_C2H_CMD_Read_BBREG = 1,
  176. HAL_FW_C2H_CMD_Read_RFREG = 2,
  177. HAL_FW_C2H_CMD_Read_EEPROM = 3,
  178. HAL_FW_C2H_CMD_Read_EFUSE = 4,
  179. HAL_FW_C2H_CMD_Read_CAM = 5,
  180. HAL_FW_C2H_CMD_Get_BasicRate = 6,
  181. HAL_FW_C2H_CMD_Get_DataRate = 7,
  182. HAL_FW_C2H_CMD_Survey = 8,
  183. HAL_FW_C2H_CMD_SurveyDone = 9,
  184. HAL_FW_C2H_CMD_JoinBss = 10,
  185. HAL_FW_C2H_CMD_AddSTA = 11,
  186. HAL_FW_C2H_CMD_DelSTA = 12,
  187. HAL_FW_C2H_CMD_AtimDone = 13,
  188. HAL_FW_C2H_CMD_TX_Report = 14,
  189. HAL_FW_C2H_CMD_CCX_Report = 15,
  190. HAL_FW_C2H_CMD_DTM_Report = 16,
  191. HAL_FW_C2H_CMD_TX_Rate_Statistics = 17,
  192. HAL_FW_C2H_CMD_C2HLBK = 18,
  193. HAL_FW_C2H_CMD_C2HDBG = 19,
  194. HAL_FW_C2H_CMD_C2HFEEDBACK = 20,
  195. HAL_FW_C2H_CMD_MAX
  196. };
  197. enum rtl_desc_qsel {
  198. QSLT_BK = 0x2,
  199. QSLT_BE = 0x0,
  200. QSLT_VI = 0x5,
  201. QSLT_VO = 0x7,
  202. QSLT_BEACON = 0x10,
  203. QSLT_HIGH = 0x11,
  204. QSLT_MGNT = 0x12,
  205. QSLT_CMD = 0x13,
  206. };
  207. enum rtl_desc92c_rate {
  208. DESC92C_RATE1M = 0x00,
  209. DESC92C_RATE2M = 0x01,
  210. DESC92C_RATE5_5M = 0x02,
  211. DESC92C_RATE11M = 0x03,
  212. DESC92C_RATE6M = 0x04,
  213. DESC92C_RATE9M = 0x05,
  214. DESC92C_RATE12M = 0x06,
  215. DESC92C_RATE18M = 0x07,
  216. DESC92C_RATE24M = 0x08,
  217. DESC92C_RATE36M = 0x09,
  218. DESC92C_RATE48M = 0x0a,
  219. DESC92C_RATE54M = 0x0b,
  220. DESC92C_RATEMCS0 = 0x0c,
  221. DESC92C_RATEMCS1 = 0x0d,
  222. DESC92C_RATEMCS2 = 0x0e,
  223. DESC92C_RATEMCS3 = 0x0f,
  224. DESC92C_RATEMCS4 = 0x10,
  225. DESC92C_RATEMCS5 = 0x11,
  226. DESC92C_RATEMCS6 = 0x12,
  227. DESC92C_RATEMCS7 = 0x13,
  228. DESC92C_RATEMCS8 = 0x14,
  229. DESC92C_RATEMCS9 = 0x15,
  230. DESC92C_RATEMCS10 = 0x16,
  231. DESC92C_RATEMCS11 = 0x17,
  232. DESC92C_RATEMCS12 = 0x18,
  233. DESC92C_RATEMCS13 = 0x19,
  234. DESC92C_RATEMCS14 = 0x1a,
  235. DESC92C_RATEMCS15 = 0x1b,
  236. DESC92C_RATEMCS15_SG = 0x1c,
  237. DESC92C_RATEMCS32 = 0x20,
  238. };
  239. struct phy_sts_cck_8192s_t {
  240. u8 adc_pwdb_X[4];
  241. u8 sq_rpt;
  242. u8 cck_agc_rpt;
  243. };
  244. struct h2c_cmd_8192c {
  245. u8 element_id;
  246. u32 cmd_len;
  247. u8 *p_cmdbuffer;
  248. };
  249. static inline u8 _rtl92c_get_chnl_group(u8 chnl)
  250. {
  251. u8 group = 0;
  252. if (chnl < 3)
  253. group = 0;
  254. else if (chnl < 9)
  255. group = 1;
  256. else
  257. group = 2;
  258. return group;
  259. }
  260. /* NOTE: reference to rtl8192c_rates struct */
  261. static inline int _rtl92c_rate_mapping(struct ieee80211_hw *hw, bool isHT,
  262. u8 desc_rate, bool first_ampdu)
  263. {
  264. struct rtl_priv *rtlpriv = rtl_priv(hw);
  265. int rate_idx = 0;
  266. if (first_ampdu) {
  267. if (false == isHT) {
  268. switch (desc_rate) {
  269. case DESC92C_RATE1M:
  270. rate_idx = 0;
  271. break;
  272. case DESC92C_RATE2M:
  273. rate_idx = 1;
  274. break;
  275. case DESC92C_RATE5_5M:
  276. rate_idx = 2;
  277. break;
  278. case DESC92C_RATE11M:
  279. rate_idx = 3;
  280. break;
  281. case DESC92C_RATE6M:
  282. rate_idx = 4;
  283. break;
  284. case DESC92C_RATE9M:
  285. rate_idx = 5;
  286. break;
  287. case DESC92C_RATE12M:
  288. rate_idx = 6;
  289. break;
  290. case DESC92C_RATE18M:
  291. rate_idx = 7;
  292. break;
  293. case DESC92C_RATE24M:
  294. rate_idx = 8;
  295. break;
  296. case DESC92C_RATE36M:
  297. rate_idx = 9;
  298. break;
  299. case DESC92C_RATE48M:
  300. rate_idx = 10;
  301. break;
  302. case DESC92C_RATE54M:
  303. rate_idx = 11;
  304. break;
  305. default:
  306. RT_TRACE(rtlpriv, COMP_ERR, DBG_DMESG,
  307. ("Rate %d is not support, set to "
  308. "1M rate.\n", desc_rate));
  309. rate_idx = 0;
  310. break;
  311. }
  312. } else {
  313. rate_idx = 11;
  314. }
  315. return rate_idx;
  316. }
  317. switch (desc_rate) {
  318. case DESC92C_RATE1M:
  319. rate_idx = 0;
  320. break;
  321. case DESC92C_RATE2M:
  322. rate_idx = 1;
  323. break;
  324. case DESC92C_RATE5_5M:
  325. rate_idx = 2;
  326. break;
  327. case DESC92C_RATE11M:
  328. rate_idx = 3;
  329. break;
  330. case DESC92C_RATE6M:
  331. rate_idx = 4;
  332. break;
  333. case DESC92C_RATE9M:
  334. rate_idx = 5;
  335. break;
  336. case DESC92C_RATE12M:
  337. rate_idx = 6;
  338. break;
  339. case DESC92C_RATE18M:
  340. rate_idx = 7;
  341. break;
  342. case DESC92C_RATE24M:
  343. rate_idx = 8;
  344. break;
  345. case DESC92C_RATE36M:
  346. rate_idx = 9;
  347. break;
  348. case DESC92C_RATE48M:
  349. rate_idx = 10;
  350. break;
  351. case DESC92C_RATE54M:
  352. rate_idx = 11;
  353. break;
  354. /* TODO: How to mapping MCS rate? */
  355. /* NOTE: referenc to __ieee80211_rx */
  356. default:
  357. rate_idx = 11;
  358. break;
  359. }
  360. return rate_idx;
  361. }
  362. #endif