fw.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2009-2014 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. * Larry Finger <Larry.Finger@lwfinger.net>
  22. *
  23. *****************************************************************************/
  24. #ifndef __RTL92E__FW__H__
  25. #define __RTL92E__FW__H__
  26. #define FW_8192C_SIZE 0x8000
  27. #define FW_8192C_START_ADDRESS 0x1000
  28. #define FW_8192C_END_ADDRESS 0x5FFF
  29. #define FW_8192C_PAGE_SIZE 4096
  30. #define FW_8192C_POLLING_DELAY 5
  31. #define FW_8192C_POLLING_TIMEOUT_COUNT 3000
  32. #define IS_FW_HEADER_EXIST(_pfwhdr) \
  33. ((_pfwhdr->signature&0xFFF0) == 0x92E0)
  34. #define USE_OLD_WOWLAN_DEBUG_FW 0
  35. #define H2C_92E_RSVDPAGE_LOC_LEN 5
  36. #define H2C_92E_PWEMODE_LENGTH 5
  37. #define H2C_92E_JOINBSSRPT_LENGTH 1
  38. #define H2C_92E_AP_OFFLOAD_LENGTH 3
  39. #define H2C_92E_WOWLAN_LENGTH 3
  40. #define H2C_92E_KEEP_ALIVE_CTRL_LENGTH 3
  41. #if (USE_OLD_WOWLAN_DEBUG_FW == 0)
  42. #define H2C_92E_REMOTE_WAKE_CTRL_LEN 1
  43. #else
  44. #define H2C_92E_REMOTE_WAKE_CTRL_LEN 3
  45. #endif
  46. #define H2C_92E_AOAC_GLOBAL_INFO_LEN 2
  47. #define H2C_92E_AOAC_RSVDPAGE_LOC_LEN 7
  48. /* Fw PS state for RPWM.
  49. *BIT[2:0] = HW state
  50. *BIT[3] = Protocol PS state, 1: register active state, 0: register sleep state
  51. *BIT[4] = sub-state
  52. */
  53. #define FW_PS_RF_ON BIT(2)
  54. #define FW_PS_REGISTER_ACTIVE BIT(3)
  55. #define FW_PS_ACK BIT(6)
  56. #define FW_PS_TOGGLE BIT(7)
  57. /* 92E RPWM value*/
  58. /* BIT[0] = 1: 32k, 0: 40M*/
  59. #define FW_PS_CLOCK_OFF BIT(0) /* 32k */
  60. #define FW_PS_CLOCK_ON 0 /* 40M */
  61. #define FW_PS_STATE_MASK (0x0F)
  62. #define FW_PS_STATE_HW_MASK (0x07)
  63. #define FW_PS_STATE_INT_MASK (0x3F)
  64. #define FW_PS_STATE(x) (FW_PS_STATE_MASK & (x))
  65. #define FW_PS_STATE_ALL_ON_92E (FW_PS_CLOCK_ON)
  66. #define FW_PS_STATE_RF_ON_92E (FW_PS_CLOCK_ON)
  67. #define FW_PS_STATE_RF_OFF_92E (FW_PS_CLOCK_ON)
  68. #define FW_PS_STATE_RF_OFF_LOW_PWR (FW_PS_CLOCK_OFF)
  69. /* For 92E H2C PwrMode Cmd ID 5.*/
  70. #define FW_PWR_STATE_ACTIVE ((FW_PS_RF_ON) | (FW_PS_REGISTER_ACTIVE))
  71. #define FW_PWR_STATE_RF_OFF 0
  72. #define FW_PS_IS_ACK(x) ((x) & FW_PS_ACK)
  73. #define IS_IN_LOW_POWER_STATE_92E(__state) \
  74. (FW_PS_STATE(__state) == FW_PS_CLOCK_OFF)
  75. #define FW_PWR_STATE_ACTIVE ((FW_PS_RF_ON) | (FW_PS_REGISTER_ACTIVE))
  76. #define FW_PWR_STATE_RF_OFF 0
  77. struct rtl92c_firmware_header {
  78. u16 signature;
  79. u8 category;
  80. u8 function;
  81. u16 version;
  82. u8 subversion;
  83. u8 rsvd1;
  84. u8 month;
  85. u8 date;
  86. u8 hour;
  87. u8 minute;
  88. u16 ramcodesize;
  89. u16 rsvd2;
  90. u32 svnindex;
  91. u32 rsvd3;
  92. u32 rsvd4;
  93. u32 rsvd5;
  94. };
  95. enum rtl8192e_h2c_cmd {
  96. H2C_92E_RSVDPAGE = 0,
  97. H2C_92E_MSRRPT = 1,
  98. H2C_92E_SCAN = 2,
  99. H2C_92E_KEEP_ALIVE_CTRL = 3,
  100. H2C_92E_DISCONNECT_DECISION = 4,
  101. #if (USE_OLD_WOWLAN_DEBUG_FW == 1)
  102. H2C_92E_WO_WLAN = 5,
  103. #endif
  104. H2C_92E_INIT_OFFLOAD = 6,
  105. #if (USE_OLD_WOWLAN_DEBUG_FW == 1)
  106. H2C_92E_REMOTE_WAKE_CTRL = 7,
  107. #endif
  108. H2C_92E_AP_OFFLOAD = 8,
  109. H2C_92E_BCN_RSVDPAGE = 9,
  110. H2C_92E_PROBERSP_RSVDPAGE = 10,
  111. H2C_92E_SETPWRMODE = 0x20,
  112. H2C_92E_PS_TUNING_PARA = 0x21,
  113. H2C_92E_PS_TUNING_PARA2 = 0x22,
  114. H2C_92E_PS_LPS_PARA = 0x23,
  115. H2C_92E_P2P_PS_OFFLOAD = 024,
  116. #if (USE_OLD_WOWLAN_DEBUG_FW == 0)
  117. H2C_92E_WO_WLAN = 0x80,
  118. H2C_92E_REMOTE_WAKE_CTRL = 0x81,
  119. H2C_92E_AOAC_GLOBAL_INFO = 0x82,
  120. H2C_92E_AOAC_RSVDPAGE = 0x83,
  121. #endif
  122. H2C_92E_RA_MASK = 0x40,
  123. H2C_92E_RSSI_REPORT = 0x42,
  124. H2C_92E_SELECTIVE_SUSPEND_ROF_CMD,
  125. H2C_92E_P2P_PS_MODE,
  126. H2C_92E_PSD_RESULT,
  127. /*Not defined CTW CMD for P2P yet*/
  128. H2C_92E_P2P_PS_CTW_CMD,
  129. MAX_92E_H2CCMD
  130. };
  131. enum rtl8192e_c2h_evt {
  132. C2H_8192E_DBG = 0,
  133. C2H_8192E_LB = 1,
  134. C2H_8192E_TXBF = 2,
  135. C2H_8192E_TX_REPORT = 3,
  136. C2H_8192E_BT_INFO = 9,
  137. C2H_8192E_BT_MP = 11,
  138. C2H_8192E_RA_RPT = 12,
  139. MAX_8192E_C2HEVENT
  140. };
  141. #define pagenum_128(_len) \
  142. (u32)(((_len) >> 7) + ((_len) & 0x7F ? 1 : 0))
  143. #define SET_H2CCMD_PWRMODE_PARM_MODE(__ph2ccmd, __val) \
  144. SET_BITS_TO_LE_1BYTE(__ph2ccmd, 0, 8, __val)
  145. #define SET_H2CCMD_PWRMODE_PARM_RLBM(__cmd, __val) \
  146. SET_BITS_TO_LE_1BYTE((__cmd)+1, 0, 4, __val)
  147. #define SET_H2CCMD_PWRMODE_PARM_SMART_PS(__cmd, __val) \
  148. SET_BITS_TO_LE_1BYTE((__cmd)+1, 4, 4, __val)
  149. #define SET_H2CCMD_PWRMODE_PARM_AWAKE_INTERVAL(__cmd, __val) \
  150. SET_BITS_TO_LE_1BYTE((__cmd)+2, 0, 8, __val)
  151. #define SET_H2CCMD_PWRMODE_PARM_ALL_QUEUE_UAPSD(__cmd, __val) \
  152. SET_BITS_TO_LE_1BYTE((__cmd)+3, 0, 8, __val)
  153. #define SET_H2CCMD_PWRMODE_PARM_PWR_STATE(__cmd, __val) \
  154. SET_BITS_TO_LE_1BYTE((__cmd)+4, 0, 8, __val)
  155. #define GET_92E_H2CCMD_PWRMODE_PARM_MODE(__cmd) \
  156. LE_BITS_TO_1BYTE(__cmd, 0, 8)
  157. #define SET_H2CCMD_JOINBSSRPT_PARM_OPMODE(__ph2ccmd, __val) \
  158. SET_BITS_TO_LE_1BYTE(__ph2ccmd, 0, 8, __val)
  159. #define SET_H2CCMD_RSVDPAGE_LOC_PROBE_RSP(__ph2ccmd, __val) \
  160. SET_BITS_TO_LE_1BYTE(__ph2ccmd, 0, 8, __val)
  161. #define SET_H2CCMD_RSVDPAGE_LOC_PSPOLL(__ph2ccmd, __val) \
  162. SET_BITS_TO_LE_1BYTE((__ph2ccmd)+1, 0, 8, __val)
  163. #define SET_H2CCMD_RSVDPAGE_LOC_NULL_DATA(__ph2ccmd, __val) \
  164. SET_BITS_TO_LE_1BYTE((__ph2ccmd)+2, 0, 8, __val)
  165. /* _MEDIA_STATUS_RPT_PARM_CMD1 */
  166. #define SET_H2CCMD_MSRRPT_PARM_OPMODE(__cmd, __val) \
  167. SET_BITS_TO_LE_1BYTE(__cmd, 0, 1, __val)
  168. #define SET_H2CCMD_MSRRPT_PARM_MACID_IND(__cmd, __val) \
  169. SET_BITS_TO_LE_1BYTE(__cmd, 1, 1, __val)
  170. #define SET_H2CCMD_MSRRPT_PARM_MACID(__cmd, __val) \
  171. SET_BITS_TO_LE_1BYTE(__cmd+1, 0, 8, __val)
  172. #define SET_H2CCMD_MSRRPT_PARM_MACID_END(__cmd, __val) \
  173. SET_BITS_TO_LE_1BYTE(__cmd+2, 0, 8, __val)
  174. int rtl92ee_download_fw(struct ieee80211_hw *hw, bool buse_wake_on_wlan_fw);
  175. void rtl92ee_fill_h2c_cmd(struct ieee80211_hw *hw, u8 element_id,
  176. u32 cmd_len, u8 *cmdbuffer);
  177. void rtl92ee_firmware_selfreset(struct ieee80211_hw *hw);
  178. void rtl92ee_set_fw_pwrmode_cmd(struct ieee80211_hw *hw, u8 mode);
  179. void rtl92ee_set_fw_media_status_rpt_cmd(struct ieee80211_hw *hw, u8 mstatus);
  180. void rtl92ee_set_fw_rsvdpagepkt(struct ieee80211_hw *hw, bool b_dl_finished);
  181. void rtl92ee_set_p2p_ps_offload_cmd(struct ieee80211_hw *hw, u8 p2p_ps_state);
  182. void rtl92ee_c2h_packet_handler(struct ieee80211_hw *hw, u8 *buffer, u8 len);
  183. #endif