fw.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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 USE_OLD_WOWLAN_DEBUG_FW 0
  32. #define H2C_PWEMODE_LENGTH 7
  33. /* Fw PS state for RPWM.
  34. *BIT[2:0] = HW state
  35. *BIT[3] = Protocol PS state, 1: register active state , 0: register sleep state
  36. *BIT[4] = sub-state
  37. */
  38. #define FW_PS_RF_ON BIT(2)
  39. #define FW_PS_REGISTER_ACTIVE BIT(3)
  40. #define FW_PS_ACK BIT(6)
  41. #define FW_PS_TOGGLE BIT(7)
  42. /* 8723BE RPWM value*/
  43. /* BIT[0] = 1: 32k, 0: 40M*/
  44. #define FW_PS_CLOCK_OFF BIT(0) /* 32k*/
  45. #define FW_PS_CLOCK_ON 0 /*40M*/
  46. #define FW_PS_STATE_MASK (0x0F)
  47. #define FW_PS_STATE_HW_MASK (0x07)
  48. /*ISR_ENABLE, IMR_ENABLE, and PS mode should be inherited.*/
  49. #define FW_PS_STATE_INT_MASK (0x3F)
  50. #define FW_PS_STATE(x) (FW_PS_STATE_MASK & (x))
  51. /* ((FW_PS_RF_ON) | (FW_PS_REGISTER_ACTIVE))*/
  52. #define FW_PS_STATE_ALL_ON (FW_PS_CLOCK_ON)
  53. /* (FW_PS_RF_ON)*/
  54. #define FW_PS_STATE_RF_ON (FW_PS_CLOCK_ON)
  55. /* 0x0*/
  56. #define FW_PS_STATE_RF_OFF (FW_PS_CLOCK_ON)
  57. /* (FW_PS_STATE_RF_OFF)*/
  58. #define FW_PS_STATE_RF_OFF_LOW_PWR (FW_PS_CLOCK_OFF)
  59. /* For 8723BE H2C PwrMode Cmd ID 5.*/
  60. #define FW_PWR_STATE_ACTIVE ((FW_PS_RF_ON) | (FW_PS_REGISTER_ACTIVE))
  61. #define FW_PWR_STATE_RF_OFF 0
  62. #define FW_PS_IS_ACK(x) ((x) & FW_PS_ACK)
  63. #define IS_IN_LOW_POWER_STATE(__fwpsstate) \
  64. (FW_PS_STATE(__fwpsstate) == FW_PS_CLOCK_OFF)
  65. #define FW_PWR_STATE_ACTIVE ((FW_PS_RF_ON) | (FW_PS_REGISTER_ACTIVE))
  66. #define FW_PWR_STATE_RF_OFF 0
  67. enum rtl8723b_h2c_cmd {
  68. H2C_8723B_RSVDPAGE = 0,
  69. H2C_8723B_MSRRPT = 1,
  70. H2C_8723B_SCAN = 2,
  71. H2C_8723B_KEEP_ALIVE_CTRL = 3,
  72. H2C_8723B_DISCONNECT_DECISION = 4,
  73. H2C_8723B_BCN_RSVDPAGE = 9,
  74. H2C_8723B_PROBERSP_RSVDPAGE = 10,
  75. H2C_8723B_SETPWRMODE = 0x20,
  76. H2C_8723B_PS_LPS_PARA = 0x23,
  77. H2C_8723B_P2P_PS_OFFLOAD = 0x24,
  78. H2C_8723B_RA_MASK = 0x40,
  79. H2C_RSSIBE_REPORT = 0x42,
  80. /*Not defined CTW CMD for P2P yet*/
  81. H2C_8723B_P2P_PS_CTW_CMD,
  82. MAX_8723B_H2CCMD
  83. };
  84. #define pagenum_128(_len) (u32)(((_len)>>7) + ((_len)&0x7F ? 1 : 0))
  85. #define SET_H2CCMD_PWRMODE_PARM_MODE(__ph2ccmd, __val) \
  86. SET_BITS_TO_LE_1BYTE(__ph2ccmd, 0, 8, __val)
  87. #define SET_H2CCMD_PWRMODE_PARM_RLBM(__ph2ccmd, __val) \
  88. SET_BITS_TO_LE_1BYTE((__ph2ccmd)+1, 0, 4, __val)
  89. #define SET_H2CCMD_PWRMODE_PARM_SMART_PS(__ph2ccmd, __val) \
  90. SET_BITS_TO_LE_1BYTE((__ph2ccmd)+1, 4, 4, __val)
  91. #define SET_H2CCMD_PWRMODE_PARM_AWAKE_INTERVAL(__ph2ccmd, __val) \
  92. SET_BITS_TO_LE_1BYTE((__ph2ccmd)+2, 0, 8, __val)
  93. #define SET_H2CCMD_PWRMODE_PARM_ALL_QUEUE_UAPSD(__ph2ccmd, __val) \
  94. SET_BITS_TO_LE_1BYTE((__ph2ccmd)+3, 0, 8, __val)
  95. #define SET_H2CCMD_PWRMODE_PARM_PWR_STATE(__ph2ccmd, __val) \
  96. SET_BITS_TO_LE_1BYTE((__ph2ccmd)+4, 0, 8, __val)
  97. #define SET_H2CCMD_PWRMODE_PARM_BYTE5(__ph2ccmd, __val) \
  98. SET_BITS_TO_LE_1BYTE((__ph2ccmd) + 5, 0, 8, __val)
  99. #define GET_88E_H2CCMD_PWRMODE_PARM_MODE(__ph2ccmd) \
  100. LE_BITS_TO_1BYTE(__ph2ccmd, 0, 8)
  101. #define SET_H2CCMD_MSRRPT_PARM_OPMODE(__ph2ccmd, __val) \
  102. SET_BITS_TO_LE_1BYTE(__ph2ccmd, 0, 1, __val)
  103. #define SET_H2CCMD_MSRRPT_PARM_MACID_IND(__ph2ccmd, __val) \
  104. SET_BITS_TO_LE_1BYTE(__ph2ccmd, 1, 1, __val)
  105. #define SET_H2CCMD_RSVDPAGE_LOC_PROBE_RSP(__ph2ccmd, __val) \
  106. SET_BITS_TO_LE_1BYTE(__ph2ccmd, 0, 8, __val)
  107. #define SET_H2CCMD_RSVDPAGE_LOC_PSPOLL(__ph2ccmd, __val) \
  108. SET_BITS_TO_LE_1BYTE((__ph2ccmd)+1, 0, 8, __val)
  109. #define SET_H2CCMD_RSVDPAGE_LOC_NULL_DATA(__ph2ccmd, __val) \
  110. SET_BITS_TO_LE_1BYTE((__ph2ccmd)+2, 0, 8, __val)
  111. #define SET_H2CCMD_RSVDPAGE_LOC_QOS_NULL_DATA(__ph2ccmd, __val) \
  112. SET_BITS_TO_LE_1BYTE((__ph2ccmd) + 3, 0, 8, __val)
  113. #define SET_H2CCMD_RSVDPAGE_LOC_BT_QOS_NULL_DATA(__ph2ccmd, __val) \
  114. SET_BITS_TO_LE_1BYTE((__ph2ccmd) + 4, 0, 8, __val)
  115. void rtl8723be_fill_h2c_cmd(struct ieee80211_hw *hw, u8 element_id,
  116. u32 cmd_len, u8 *p_cmdbuffer);
  117. void rtl8723be_set_fw_pwrmode_cmd(struct ieee80211_hw *hw, u8 mode);
  118. void rtl8723be_set_fw_media_status_rpt_cmd(struct ieee80211_hw *hw, u8 mstatus);
  119. void rtl8723be_set_fw_rsvdpagepkt(struct ieee80211_hw *hw, bool b_dl_finished);
  120. void rtl8723be_set_p2p_ps_offload_cmd(struct ieee80211_hw *hw, u8 p2p_ps_state);
  121. #endif