fw.h 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  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 __RTL8723BE__FW__H__
  25. #define __RTL8723BE__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 6000
  32. #define IS_FW_HEADER_EXIST(_pfwhdr) \
  33. ((_pfwhdr->signature&0xFFF0) == 0x5300)
  34. #define USE_OLD_WOWLAN_DEBUG_FW 0
  35. #define H2C_8723BE_RSVDPAGE_LOC_LEN 5
  36. #define H2C_8723BE_PWEMODE_LENGTH 5
  37. #define H2C_8723BE_JOINBSSRPT_LENGTH 1
  38. #define H2C_8723BE_AP_OFFLOAD_LENGTH 3
  39. #define H2C_8723BE_WOWLAN_LENGTH 3
  40. #define H2C_8723BE_KEEP_ALIVE_CTRL_LENGTH 3
  41. #if (USE_OLD_WOWLAN_DEBUG_FW == 0)
  42. #define H2C_8723BE_REMOTE_WAKE_CTRL_LEN 1
  43. #else
  44. #define H2C_8723BE_REMOTE_WAKE_CTRL_LEN 3
  45. #endif
  46. #define H2C_8723BE_AOAC_GLOBAL_INFO_LEN 2
  47. #define H2C_8723BE_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_GO_ON BIT(0)
  54. #define FW_PS_TX_NULL BIT(1)
  55. #define FW_PS_RF_ON BIT(2)
  56. #define FW_PS_REGISTER_ACTIVE BIT(3)
  57. #define FW_PS_DPS BIT(0)
  58. #define FW_PS_LCLK (FW_PS_DPS)
  59. #define FW_PS_RF_OFF BIT(1)
  60. #define FW_PS_ALL_ON BIT(2)
  61. #define FW_PS_ST_ACTIVE BIT(3)
  62. #define FW_PS_ISR_ENABLE BIT(4)
  63. #define FW_PS_IMR_ENABLE BIT(5)
  64. #define FW_PS_ACK BIT(6)
  65. #define FW_PS_TOGGLE BIT(7)
  66. /* 88E RPWM value*/
  67. /* BIT[0] = 1: 32k, 0: 40M*/
  68. #define FW_PS_CLOCK_OFF BIT(0) /* 32k*/
  69. #define FW_PS_CLOCK_ON 0 /*40M*/
  70. #define FW_PS_STATE_MASK (0x0F)
  71. #define FW_PS_STATE_HW_MASK (0x07)
  72. /*ISR_ENABLE, IMR_ENABLE, and PS mode should be inherited.*/
  73. #define FW_PS_STATE_INT_MASK (0x3F)
  74. #define FW_PS_STATE(x) (FW_PS_STATE_MASK & (x))
  75. #define FW_PS_STATE_HW(x) (FW_PS_STATE_HW_MASK & (x))
  76. #define FW_PS_STATE_INT(x) (FW_PS_STATE_INT_MASK & (x))
  77. #define FW_PS_ISR_VAL(x) ((x) & 0x70)
  78. #define FW_PS_IMR_MASK(x) ((x) & 0xDF)
  79. #define FW_PS_KEEP_IMR(x) ((x) & 0x20)
  80. #define FW_PS_STATE_S0 (FW_PS_DPS)
  81. #define FW_PS_STATE_S1 (FW_PS_LCLK)
  82. #define FW_PS_STATE_S2 (FW_PS_RF_OFF)
  83. #define FW_PS_STATE_S3 (FW_PS_ALL_ON)
  84. #define FW_PS_STATE_S4 ((FW_PS_ST_ACTIVE) | (FW_PS_ALL_ON))
  85. /* ((FW_PS_RF_ON) | (FW_PS_REGISTER_ACTIVE))*/
  86. #define FW_PS_STATE_ALL_ON_88E (FW_PS_CLOCK_ON)
  87. /* (FW_PS_RF_ON)*/
  88. #define FW_PS_STATE_RF_ON_88E (FW_PS_CLOCK_ON)
  89. /* 0x0*/
  90. #define FW_PS_STATE_RF_OFF_88E (FW_PS_CLOCK_ON)
  91. /* (FW_PS_STATE_RF_OFF)*/
  92. #define FW_PS_STATE_RF_OFF_LOW_PWR_88E (FW_PS_CLOCK_OFF)
  93. #define FW_PS_STATE_ALL_ON_92C (FW_PS_STATE_S4)
  94. #define FW_PS_STATE_RF_ON_92C (FW_PS_STATE_S3)
  95. #define FW_PS_STATE_RF_OFF_92C (FW_PS_STATE_S2)
  96. #define FW_PS_STATE_RF_OFF_LOW_PWR_92C (FW_PS_STATE_S1)
  97. /* For 88E H2C PwrMode Cmd ID 5.*/
  98. #define FW_PWR_STATE_ACTIVE ((FW_PS_RF_ON) | (FW_PS_REGISTER_ACTIVE))
  99. #define FW_PWR_STATE_RF_OFF 0
  100. #define FW_PS_IS_ACK(x) ((x) & FW_PS_ACK)
  101. #define FW_PS_IS_CLK_ON(x) ((x) & (FW_PS_RF_OFF | FW_PS_ALL_ON))
  102. #define FW_PS_IS_RF_ON(x) ((x) & (FW_PS_ALL_ON))
  103. #define FW_PS_IS_ACTIVE(x) ((x) & (FW_PS_ST_ACTIVE))
  104. #define FW_PS_IS_CPWM_INT(x) ((x) & 0x40)
  105. #define FW_CLR_PS_STATE(x) ((x) = ((x) & (0xF0)))
  106. #define IS_IN_LOW_POWER_STATE_88E(fwpsstate) \
  107. (FW_PS_STATE(fwpsstate) == FW_PS_CLOCK_OFF)
  108. #define FW_PWR_STATE_ACTIVE ((FW_PS_RF_ON) | (FW_PS_REGISTER_ACTIVE))
  109. #define FW_PWR_STATE_RF_OFF 0
  110. #define pagenum_128(_len) (u32)(((_len)>>7) + ((_len)&0x7F ? 1 : 0))
  111. #define SET_88E_H2CCMD_WOWLAN_FUNC_ENABLE(__ph2ccmd, __val) \
  112. SET_BITS_TO_LE_1BYTE(__ph2ccmd, 0, 1, __val)
  113. #define SET_88E_H2CCMD_WOWLAN_PATTERN_MATCH_ENABLE(__ph2ccmd, __val) \
  114. SET_BITS_TO_LE_1BYTE(__ph2ccmd, 1, 1, __val)
  115. #define SET_88E_H2CCMD_WOWLAN_MAGIC_PKT_ENABLE(__ph2ccmd, __val) \
  116. SET_BITS_TO_LE_1BYTE(__ph2ccmd, 2, 1, __val)
  117. #define SET_88E_H2CCMD_WOWLAN_UNICAST_PKT_ENABLE(__ph2ccmd, __val) \
  118. SET_BITS_TO_LE_1BYTE(__ph2ccmd, 3, 1, __val)
  119. #define SET_88E_H2CCMD_WOWLAN_ALL_PKT_DROP(__ph2ccmd, __val) \
  120. SET_BITS_TO_LE_1BYTE(__ph2ccmd, 4, 1, __val)
  121. #define SET_88E_H2CCMD_WOWLAN_GPIO_ACTIVE(__ph2ccmd, __val) \
  122. SET_BITS_TO_LE_1BYTE(__ph2ccmd, 5, 1, __val)
  123. #define SET_88E_H2CCMD_WOWLAN_REKEY_WAKE_UP(__ph2ccmd, __val) \
  124. SET_BITS_TO_LE_1BYTE(__ph2ccmd, 6, 1, __val)
  125. #define SET_88E_H2CCMD_WOWLAN_DISCONNECT_WAKE_UP(__ph2ccmd, __val) \
  126. SET_BITS_TO_LE_1BYTE(__ph2ccmd, 7, 1, __val)
  127. #define SET_88E_H2CCMD_WOWLAN_GPIONUM(__ph2ccmd, __val) \
  128. SET_BITS_TO_LE_1BYTE((__ph2ccmd)+1, 0, 8, __val)
  129. #define SET_88E_H2CCMD_WOWLAN_GPIO_DURATION(__ph2ccmd, __val) \
  130. SET_BITS_TO_LE_1BYTE((__ph2ccmd)+2, 0, 8, __val)
  131. #define SET_H2CCMD_PWRMODE_PARM_MODE(__ph2ccmd, __val) \
  132. SET_BITS_TO_LE_1BYTE(__ph2ccmd, 0, 8, __val)
  133. #define SET_H2CCMD_PWRMODE_PARM_RLBM(__ph2ccmd, __val) \
  134. SET_BITS_TO_LE_1BYTE((__ph2ccmd)+1, 0, 4, __val)
  135. #define SET_H2CCMD_PWRMODE_PARM_SMART_PS(__ph2ccmd, __val) \
  136. SET_BITS_TO_LE_1BYTE((__ph2ccmd)+1, 4, 4, __val)
  137. #define SET_H2CCMD_PWRMODE_PARM_AWAKE_INTERVAL(__ph2ccmd, __val) \
  138. SET_BITS_TO_LE_1BYTE((__ph2ccmd)+2, 0, 8, __val)
  139. #define SET_H2CCMD_PWRMODE_PARM_ALL_QUEUE_UAPSD(__ph2ccmd, __val) \
  140. SET_BITS_TO_LE_1BYTE((__ph2ccmd)+3, 0, 8, __val)
  141. #define SET_H2CCMD_PWRMODE_PARM_PWR_STATE(__ph2ccmd, __val) \
  142. SET_BITS_TO_LE_1BYTE((__ph2ccmd)+4, 0, 8, __val)
  143. #define GET_88E_H2CCMD_PWRMODE_PARM_MODE(__ph2ccmd) \
  144. LE_BITS_TO_1BYTE(__ph2ccmd, 0, 8)
  145. #define SET_H2CCMD_JOINBSSRPT_PARM_OPMODE(__ph2ccmd, __val) \
  146. SET_BITS_TO_LE_1BYTE(__ph2ccmd, 0, 8, __val)
  147. #define SET_H2CCMD_RSVDPAGE_LOC_PROBE_RSP(__ph2ccmd, __val) \
  148. SET_BITS_TO_LE_1BYTE(__ph2ccmd, 0, 8, __val)
  149. #define SET_H2CCMD_RSVDPAGE_LOC_PSPOLL(__ph2ccmd, __val) \
  150. SET_BITS_TO_LE_1BYTE((__ph2ccmd)+1, 0, 8, __val)
  151. #define SET_H2CCMD_RSVDPAGE_LOC_NULL_DATA(__ph2ccmd, __val) \
  152. SET_BITS_TO_LE_1BYTE((__ph2ccmd)+2, 0, 8, __val)
  153. /* AP_OFFLOAD */
  154. #define SET_H2CCMD_AP_OFFLOAD_ON(__ph2ccmd, __val) \
  155. SET_BITS_TO_LE_1BYTE(__ph2ccmd, 0, 8, __val)
  156. #define SET_H2CCMD_AP_OFFLOAD_HIDDEN(__ph2ccmd, __val) \
  157. SET_BITS_TO_LE_1BYTE((__ph2ccmd)+1, 0, 8, __val)
  158. #define SET_H2CCMD_AP_OFFLOAD_DENYANY(__ph2ccmd, __val) \
  159. SET_BITS_TO_LE_1BYTE((__ph2ccmd)+2, 0, 8, __val)
  160. #define SET_H2CCMD_AP_OFFLOAD_WAKEUP_EVT_RPT(__ph2ccmd, __val) \
  161. SET_BITS_TO_LE_1BYTE((__ph2ccmd)+3, 0, 8, __val)
  162. /* Keep Alive Control*/
  163. #define SET_88E_H2CCMD_KEEP_ALIVE_ENABLE(__ph2ccmd, __val) \
  164. SET_BITS_TO_LE_1BYTE(__ph2ccmd, 0, 1, __val)
  165. #define SET_88E_H2CCMD_KEEP_ALIVE_ACCPEPT_USER_DEFINED(__ph2ccmd, __val)\
  166. SET_BITS_TO_LE_1BYTE(__ph2ccmd, 1, 1, __val)
  167. #define SET_88E_H2CCMD_KEEP_ALIVE_PERIOD(__ph2ccmd, __val) \
  168. SET_BITS_TO_LE_1BYTE((__ph2ccmd)+1, 0, 8, __val)
  169. /*REMOTE_WAKE_CTRL */
  170. #define SET_88E_H2CCMD_REMOTE_WAKE_CTRL_EN(__ph2ccmd, __val) \
  171. SET_BITS_TO_LE_1BYTE(__ph2ccmd, 0, 1, __val)
  172. #if (USE_OLD_WOWLAN_DEBUG_FW == 0)
  173. #define SET_88E_H2CCMD_REMOTE_WAKE_CTRL_ARP_OFFLOAD_EN(__ph2ccmd, __val)\
  174. SET_BITS_TO_LE_1BYTE(__ph2ccmd, 1, 1, __val)
  175. #define SET_88E_H2CCMD_REMOTE_WAKE_CTRL_NDP_OFFLOAD_EN(__ph2ccmd, __val)\
  176. SET_BITS_TO_LE_1BYTE(__ph2ccmd, 2, 1, __val)
  177. #define SET_88E_H2CCMD_REMOTE_WAKE_CTRL_GTK_OFFLOAD_EN(__ph2ccmd, __val)\
  178. SET_BITS_TO_LE_1BYTE(__ph2ccmd, 3, 1, __val)
  179. #else
  180. #define SET_88E_H2CCMD_REMOTE_WAKE_CTRL_PAIRWISE_ENC_ALG(__ph2ccmd, __val)\
  181. SET_BITS_TO_LE_1BYTE((__ph2ccmd)+1, 0, 8, __val)
  182. #define SET_88E_H2CCMD_REMOTE_WAKE_CTRL_GROUP_ENC_ALG(__ph2ccmd, __val) \
  183. SET_BITS_TO_LE_1BYTE((__ph2ccmd)+2, 0, 8, __val)
  184. #endif
  185. /* GTK_OFFLOAD */
  186. #define SET_88E_H2CCMD_AOAC_GLOBAL_INFO_PAIRWISE_ENC_ALG(__ph2ccmd, __val)\
  187. SET_BITS_TO_LE_1BYTE(__ph2ccmd, 0, 8, __val)
  188. #define SET_88E_H2CCMD_AOAC_GLOBAL_INFO_GROUP_ENC_ALG(__ph2ccmd, __val) \
  189. SET_BITS_TO_LE_1BYTE((__ph2ccmd)+1, 0, 8, __val)
  190. /* AOAC_RSVDPAGE_LOC */
  191. #define SET_88E_H2CCMD_AOAC_RSVDPAGE_LOC_REM_WAKE_CTRL_INFO(__ph2ccmd, __val)\
  192. SET_BITS_TO_LE_1BYTE((__ph2ccmd), 0, 8, __val)
  193. #define SET_88E_H2CCMD_AOAC_RSVDPAGE_LOC_ARP_RSP(__ph2ccmd, __val) \
  194. SET_BITS_TO_LE_1BYTE((__ph2ccmd)+1, 0, 8, __val)
  195. #define SET_88E_H2CCMD_AOAC_RSVDPAGE_LOC_NEIGHBOR_ADV(__ph2ccmd, __val) \
  196. SET_BITS_TO_LE_1BYTE((__ph2ccmd)+2, 0, 8, __val)
  197. #define SET_88E_H2CCMD_AOAC_RSVDPAGE_LOC_GTK_RSP(__ph2ccmd, __val) \
  198. SET_BITS_TO_LE_1BYTE((__ph2ccmd)+3, 0, 8, __val)
  199. #define SET_88E_H2CCMD_AOAC_RSVDPAGE_LOC_GTK_INFO(__ph2ccmd, __val) \
  200. SET_BITS_TO_LE_1BYTE((__ph2ccmd)+4, 0, 8, __val)
  201. void rtl8723be_set_fw_pwrmode_cmd(struct ieee80211_hw *hw, u8 mode);
  202. void rtl8723be_set_fw_ap_off_load_cmd(struct ieee80211_hw *hw,
  203. u8 ap_offload_enable);
  204. void rtl8723be_fill_h2c_cmd(struct ieee80211_hw *hw, u8 element_id,
  205. u32 cmd_len, u8 *p_cmdbuffer);
  206. void rtl8723be_firmware_selfreset(struct ieee80211_hw *hw);
  207. void rtl8723be_set_fw_rsvdpagepkt(struct ieee80211_hw *hw,
  208. bool dl_finished);
  209. void rtl8723be_set_fw_joinbss_report_cmd(struct ieee80211_hw *hw, u8 mstatus);
  210. int rtl8723be_download_fw(struct ieee80211_hw *hw,
  211. bool buse_wake_on_wlan_fw);
  212. void rtl8723be_set_p2p_ps_offload_cmd(struct ieee80211_hw *hw,
  213. u8 p2p_ps_state);
  214. #endif