rtl8822b_hal.h 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2015 - 2016 Realtek Corporation. All rights reserved.
  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. *
  19. ******************************************************************************/
  20. #ifndef _RTL8822B_HAL_H_
  21. #define _RTL8822B_HAL_H_
  22. #include <osdep_service.h> /* BIT(x) */
  23. #include <drv_types.h> /* PADAPTER */
  24. #include "../hal/halmac/halmac_api.h" /* MAC REG definition */
  25. #define MAX_RECVBUF_SZ HALMAC_RX_FIFO_SIZE_8822B
  26. /*
  27. * MAC Register definition
  28. */
  29. #define REG_AFE_XTAL_CTRL REG_AFE_CTRL1_8822B /* hal_com.c & phydm */
  30. #define REG_AFE_PLL_CTRL REG_AFE_CTRL2_8822B /* hal_com.c & phydm */
  31. #define REG_MAC_PHY_CTRL REG_AFE_CTRL3_8822B /* phydm only */
  32. #define REG_LEDCFG0 REG_LED_CFG_8822B /* rtw_mp.c */
  33. #define MSR (REG_CR_8822B + 2) /* rtw_mp.c & hal_com.c */
  34. #define MSR1 REG_CR_EXT_8822B /* rtw_mp.c & hal_com.c */
  35. #define REG_C2HEVT_MSG_NORMAL 0x1A0 /* hal_com.c */
  36. #define REG_C2HEVT_CLEAR 0x1AF /* hal_com.c */
  37. #define REG_BCN_CTRL_1 REG_BCN_CTRL_CLINT0_8822B /* hal_com.c */
  38. #define REG_TSFTR1 REG_FREERUN_CNT_8822B /* hal_com.c */
  39. #define REG_RXFLTMAP2 REG_RXFLTMAP_8822B /* rtw_mp.c */
  40. #define REG_WOWLAN_WAKE_REASON 0x01C7 /* hal_com.c */
  41. #define REG_GPIO_PIN_CTRL_2 REG_GPIO_EXT_CTRL_8822B /* hal_com.c */
  42. /* RXERR_RPT, for rtw_mp.c */
  43. #define RXERR_TYPE_OFDM_PPDU 0
  44. #define RXERR_TYPE_OFDM_FALSE_ALARM 2
  45. #define RXERR_TYPE_OFDM_MPDU_OK 0
  46. #define RXERR_TYPE_OFDM_MPDU_FAIL 1
  47. #define RXERR_TYPE_CCK_PPDU 3
  48. #define RXERR_TYPE_CCK_FALSE_ALARM 5
  49. #define RXERR_TYPE_CCK_MPDU_OK 3
  50. #define RXERR_TYPE_CCK_MPDU_FAIL 4
  51. #define RXERR_TYPE_HT_PPDU 8
  52. #define RXERR_TYPE_HT_FALSE_ALARM 9
  53. #define RXERR_TYPE_HT_MPDU_TOTAL 6
  54. #define RXERR_TYPE_HT_MPDU_OK 6
  55. #define RXERR_TYPE_HT_MPDU_FAIL 7
  56. #define RXERR_TYPE_RX_FULL_DROP 10
  57. #define RXERR_COUNTER_MASK BIT_MASK_RPT_COUNTER_8822B
  58. #define RXERR_RPT_RST BIT_RXERR_RPT_RST_8822B
  59. #define _RXERR_RPT_SEL(type) (BIT_RXERR_RPT_SEL_V1_3_0_8822B(type) \
  60. | ((type & 0x10) ? BIT_RXERR_RPT_SEL_V1_4_8822B : 0))
  61. /*
  62. * BB Register definition
  63. */
  64. #define rPMAC_Reset 0x100 /* hal_mp.c */
  65. #define rFPGA0_RFMOD 0x800
  66. #define rFPGA0_TxInfo 0x804
  67. #define rOFDMCCKEN_Jaguar 0x808 /* hal_mp.c */
  68. #define rFPGA0_TxGainStage 0x80C /* phydm only */
  69. #define rFPGA0_XA_HSSIParameter1 0x820 /* hal_mp.c */
  70. #define rFPGA0_XA_HSSIParameter2 0x824 /* hal_mp.c */
  71. #define rFPGA0_XB_HSSIParameter1 0x828 /* hal_mp.c */
  72. #define rFPGA0_XB_HSSIParameter2 0x82C /* hal_mp.c */
  73. #define rTxAGC_B_Rate18_06 0x830
  74. #define rTxAGC_B_Rate54_24 0x834
  75. #define rTxAGC_B_CCK1_55_Mcs32 0x838
  76. #define rCCAonSec_Jaguar 0x838 /* hal_mp.c */
  77. #define rTxAGC_B_Mcs03_Mcs00 0x83C
  78. #define rTxAGC_B_Mcs07_Mcs04 0x848
  79. #define rTxAGC_B_Mcs11_Mcs08 0x84C
  80. #define rFPGA0_XA_RFInterfaceOE 0x860
  81. #define rFPGA0_XB_RFInterfaceOE 0x864
  82. #define rTxAGC_B_Mcs15_Mcs12 0x868
  83. #define rTxAGC_B_CCK11_A_CCK2_11 0x86C
  84. #define rFPGA0_XAB_RFInterfaceSW 0x870
  85. #define rFPGA0_XAB_RFParameter 0x878
  86. #define rFPGA0_AnalogParameter4 0x88C /* hal_mp.c & phydm */
  87. #define rFPGA0_XB_LSSIReadBack 0x8A4 /* phydm */
  88. #define rHSSIRead_Jaguar 0x8B0 /* RF read addr (rtl8822b_phy.c) */
  89. #define rC_TxScale_Jaguar2 0x181C /* Pah_C TX scaling factor (hal_mp.c) */
  90. #define rC_IGI_Jaguar2 0x1850 /* Initial Gain for path-C (hal_mp.c) */
  91. #define rFPGA1_TxInfo 0x90C /* hal_mp.c */
  92. #define rSingleTone_ContTx_Jaguar 0x914 /* hal_mp.c */
  93. /* TX BeamForming */
  94. #define REG_BB_TX_PATH_SEL_1_8822B 0x93C /* rtl8822b_phy.c */
  95. #define REG_BB_TX_PATH_SEL_2_8822B 0x940 /* rtl8822b_phy.c */
  96. /* TX BeamForming */
  97. #define REG_BB_TXBF_ANT_SET_BF1_8822B 0x19AC /* rtl8822b_phy.c */
  98. #define REG_BB_TXBF_ANT_SET_BF0_8822B 0x19B4 /* rtl8822b_phy.c */
  99. #define rCCK0_System 0xA00
  100. #define rCCK0_AFESetting 0xA04
  101. #define rCCK0_DSPParameter2 0xA1C
  102. #define rCCK0_TxFilter1 0xA20
  103. #define rCCK0_TxFilter2 0xA24
  104. #define rCCK0_DebugPort 0xA28
  105. #define rCCK0_FalseAlarmReport 0xA2C
  106. #define rD_TxScale_Jaguar2 0x1A1C /* Path_D TX scaling factor (hal_mp.c) */
  107. #define rD_IGI_Jaguar2 0x1A50 /* Initial Gain for path-D (hal_mp.c) */
  108. #define rOFDM0_TRxPathEnable 0xC04
  109. #define rOFDM0_TRMuxPar 0xC08
  110. #define rA_TxScale_Jaguar 0xC1C /* Pah_A TX scaling factor (hal_mp.c) */
  111. #define rOFDM0_RxDetector1 0xC30 /* rtw_mp.c */
  112. #define rOFDM0_ECCAThreshold 0xC4C /* phydm only */
  113. #define rOFDM0_XAAGCCore1 0xC50 /* phydm only */
  114. #define rA_IGI_Jaguar 0xC50 /* Initial Gain for path-A (hal_mp.c) */
  115. #define rOFDM0_XBAGCCore1 0xC58 /* phydm only */
  116. #define rOFDM0_XATxIQImbalance 0xC80 /* phydm only */
  117. #define rA_LSSIWrite_Jaguar 0xC90 /* RF write addr, LSSI Parameter (rtl8822b_phy.c) */
  118. #define rA_RFE_Pinmux_Jaguar 0xCB0 /* hal_mp.c */
  119. #define rOFDM1_LSTF 0xD00
  120. #define rOFDM1_TRxPathEnable 0xD04 /* hal_mp.c */
  121. #define rA_PIRead_Jaguar 0xD04 /* RF readback with PI (rtl8822b_phy.c) */
  122. #define rA_SIRead_Jaguar 0xD08 /* RF readback with SI (rtl8822b_phy.c) */
  123. #define rB_PIRead_Jaguar 0xD44 /* RF readback with PI (rtl8822b_phy.c) */
  124. #define rB_SIRead_Jaguar 0xD48 /* RF readback with SI (rtl8822b_phy.c) */
  125. #define rTxAGC_A_Rate18_06 0xE00
  126. #define rTxAGC_A_Rate54_24 0xE04
  127. #define rTxAGC_A_CCK1_Mcs32 0xE08
  128. #define rTxAGC_A_Mcs03_Mcs00 0xE10
  129. #define rTxAGC_A_Mcs07_Mcs04 0xE14
  130. #define rTxAGC_A_Mcs11_Mcs08 0xE18
  131. #define rTxAGC_A_Mcs15_Mcs12 0xE1C
  132. #define rB_TxScale_Jaguar 0xE1C /* Path_B TX scaling factor (hal_mp.c) */
  133. #define rB_IGI_Jaguar 0xE50 /* Initial Gain for path-B (hal_mp.c) */
  134. #define rB_LSSIWrite_Jaguar 0xE90 /* RF write addr, LSSI Parameter (rtl8822b_phy.c) */
  135. #define rB_RFE_Pinmux_Jaguar 0xEB0 /* hal_mp.c */
  136. /* Page1(0x100) */
  137. #define bBBResetB 0x100
  138. /* Page8(0x800) */
  139. #define bCCKEn 0x1000000
  140. #define bOFDMEn 0x2000000
  141. /* Reg 0x80C rFPGA0_TxGainStage */
  142. #define bXBTxAGC 0xF00
  143. #define bXCTxAGC 0xF000
  144. #define bXDTxAGC 0xF0000
  145. /* PageA(0xA00) */
  146. #define bCCKBBMode 0x3
  147. #define bCCKScramble 0x8
  148. #define bCCKTxRate 0x3000
  149. /* General */
  150. #define bMaskByte0 0xFF /* mp, rtw_odm.c & phydm */
  151. #define bMaskByte1 0xFF00 /* hal_mp.c & phydm */
  152. #define bMaskByte2 0xFF0000 /* hal_mp.c & phydm */
  153. #define bMaskByte3 0xFF000000 /* hal_mp.c & phydm */
  154. #define bMaskHWord 0xFFFF0000 /* hal_com.c, rtw_mp.c */
  155. #define bMaskLWord 0x0000FFFF /* mp, hal_com.c & phydm */
  156. #define bMaskDWord 0xFFFFFFFF /* mp, hal, rtw_odm.c & phydm */
  157. #define bEnable 0x1 /* hal_mp.c, rtw_mp.c */
  158. #define bDisable 0x0 /* rtw_mp.c */
  159. #define MAX_STALL_TIME 50 /* unit: us, hal_com_phycfg.c */
  160. #define Rx_Smooth_Factor 20 /* phydm only */
  161. /*
  162. * RF Register definition
  163. */
  164. #define RF_AC 0x00
  165. #define RF_AC_Jaguar 0x00 /* hal_mp.c */
  166. #define RF_CHNLBW 0x18 /* rtl8822b_phy.c */
  167. #define RF_ModeTableAddr 0x30 /* rtl8822b_phy.c */
  168. #define RF_ModeTableData0 0x31 /* rtl8822b_phy.c */
  169. #define RF_ModeTableData1 0x32 /* rtl8822b_phy.c */
  170. #define RF_0x52 0x52
  171. #define RF_WeLut_Jaguar 0xEF /* rtl8822b_phy.c */
  172. /* General Functions */
  173. void rtl8822b_init_hal_spec(PADAPTER); /* hal/hal_com.c */
  174. #ifdef CONFIG_MP_INCLUDED
  175. /* MP Functions */
  176. #include <rtw_mp.h> /* struct mp_priv */
  177. void rtl8822b_phy_init_haldm(PADAPTER); /* rtw_mp.c */
  178. void rtl8822b_prepare_mp_txdesc(PADAPTER, struct mp_priv *); /* rtw_mp.c */
  179. void rtl8822b_mp_config_rfpath(PADAPTER); /* hal_mp.c */
  180. #endif
  181. #ifdef CONFIG_USB_HCI
  182. #include <rtl8822bu_hal.h>
  183. #elif defined(CONFIG_SDIO_HCI)
  184. #include <rtl8822bs_hal.h>
  185. #elif defined(CONFIG_PCI_HCI)
  186. #include <rtl8822be_hal.h>
  187. #endif
  188. #endif /* _RTL8822B_HAL_H_ */