xref: /OK3568_Linux_fs/kernel/drivers/net/wireless/rockchip_wlan/rtl8189es/include/rtl8812a_cmd.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /******************************************************************************
2  *
3  * Copyright(c) 2007 - 2011 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 __RTL8812A_CMD_H__
21 #define __RTL8812A_CMD_H__
22 
23 typedef enum _RTL8812_H2C_CMD
24 {
25 	H2C_8812_RSVDPAGE = 0,
26 	H2C_8812_MSRRPT = 1,
27 	H2C_8812_SCAN = 2,
28 	H2C_8812_KEEP_ALIVE_CTRL = 3,
29 	H2C_8812_DISCONNECT_DECISION = 4,
30 
31 	H2C_8812_INIT_OFFLOAD = 6,
32 	H2C_8812_AP_OFFLOAD = 8,
33 	H2C_8812_BCN_RSVDPAGE = 9,
34 	H2C_8812_PROBERSP_RSVDPAGE = 10,
35 
36 	H2C_8812_SETPWRMODE = 0x20,
37 	H2C_8812_PS_TUNING_PARA = 0x21,
38 	H2C_8812_PS_TUNING_PARA2 = 0x22,
39 	H2C_8812_PS_LPS_PARA = 0x23,
40 	H2C_8812_P2P_PS_OFFLOAD = 0x24,
41 	H2C_8812_RA_MASK = 0x40,
42 	H2C_8812_TxBF = 0x41,
43 	H2C_8812_RSSI_REPORT = 0x42,
44 	H2C_8812_IQ_CALIBRATION = 0x45,
45 	H2C_8812_RA_PARA_ADJUST = 0x46,
46 
47 	H2C_8812_BT_FW_PATCH = 0x6a,
48 
49 	H2C_8812_WO_WLAN = 0x80,
50 	H2C_8812_REMOTE_WAKE_CTRL = 0x81,
51 	H2C_8812_AOAC_GLOBAL_INFO = 0x82,
52 	H2C_8812_AOAC_RSVDPAGE = 0x83,
53 	H2C_8812_FW_SWCHANNL = 0x87,
54 
55 	H2C_8812_TSF_RESET = 0xC0,
56 
57 	MAX_8812_H2CCMD
58 }RTL8812_H2C_CMD;
59 
60 
61 typedef enum _RTL8812_C2H_EVT
62 {
63 	C2H_8812_DBG = 0,
64 	C2H_8812_LB = 1,
65 	C2H_8812_TXBF = 2,
66 	C2H_8812_TX_REPORT = 3,
67 	C2H_8812_BT_INFO = 9,
68 	C2H_8812_BT_MP = 11,
69 	C2H_8812_RA_RPT=12,
70 	C2H_8812_RA_PARA_RPT = 14,
71 
72 	C2H_8812_FW_SWCHNL = 0x10,
73 	C2H_8812_IQK_FINISH = 0x11,
74 	C2H_8812_MAILBOX_STATUS = 0x15,
75 #ifdef CONFIG_FW_C2H_DEBUG
76 	C2H_8812_EXTEND = 0xff,
77 #endif //CONFIG_FW_C2H_DEBUG
78 	MAX_8812_C2HEVENT
79 }RTL8812_C2H_EVT;
80 
81 typedef enum _RTL8812_EXTEND_C2H_EVT {
82 	EXTEND_C2H_8812_DBG_PRINT = 0
83 
84 } RTL8812_EXTEND_C2H_EVT;
85 
86 
87 struct cmd_msg_parm {
88 	u8 eid; //element id
89 	u8 sz; // sz
90 	u8 buf[6];
91 };
92 
93 enum{
94 	PWRS
95 };
96 
97 struct H2C_SS_RFOFF_PARAM{
98 	u8 ROFOn; // 1: on, 0:off
99 	u16 gpio_period; // unit: 1024 us
100 }__attribute__ ((packed));
101 
102 
103 
104 //_RSVDPAGE_LOC_CMD0
105 #define SET_8812_H2CCMD_RSVDPAGE_LOC_PROBE_RSP(__pH2CCmd, __Value)			SET_BITS_TO_LE_1BYTE_8BIT(__pH2CCmd, 0, 8, __Value)
106 #define SET_8812_H2CCMD_RSVDPAGE_LOC_PSPOLL(__pH2CCmd, __Value)				SET_BITS_TO_LE_1BYTE_8BIT((__pH2CCmd)+1, 0, 8, __Value)
107 #define SET_8812_H2CCMD_RSVDPAGE_LOC_NULL_DATA(__pH2CCmd, __Value)			SET_BITS_TO_LE_1BYTE_8BIT((__pH2CCmd)+2, 0, 8, __Value)
108 #define SET_8812_H2CCMD_RSVDPAGE_LOC_QOS_NULL_DATA(__pH2CCmd, __Value)		SET_BITS_TO_LE_1BYTE_8BIT((__pH2CCmd)+3, 0, 8, __Value)
109 #define SET_8812_H2CCMD_RSVDPAGE_LOC_BT_QOS_NULL_DATA(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE_8BIT((__pH2CCmd)+4, 0, 8, __Value)
110 
111 //_MEDIA_STATUS_RPT_PARM_CMD1
112 #define SET_8812_H2CCMD_MSRRPT_PARM_OPMODE(__pH2CCmd, __Value)				SET_BITS_TO_LE_1BYTE(__pH2CCmd, 0, 1, __Value)
113 #define SET_8812_H2CCMD_MSRRPT_PARM_MACID_IND(__pH2CCmd, __Value)				SET_BITS_TO_LE_1BYTE(__pH2CCmd, 1, 1, __Value)
114 #define SET_8812_H2CCMD_MSRRPT_PARM_MACID(__pH2CCmd, __Value)					SET_BITS_TO_LE_1BYTE_8BIT(__pH2CCmd+1, 0, 8, __Value)
115 #define SET_8812_H2CCMD_MSRRPT_PARM_MACID_END(__pH2CCmd, __Value)			SET_BITS_TO_LE_1BYTE_8BIT(__pH2CCmd+2, 0, 8, __Value)
116 
117 //_SETPWRMODE_PARM
118 #define SET_8812_H2CCMD_PWRMODE_PARM_MODE(__pH2CCmd, __Value)				SET_BITS_TO_LE_1BYTE_8BIT(__pH2CCmd, 0, 8, __Value)
119 #define SET_8812_H2CCMD_PWRMODE_PARM_RLBM(__pH2CCmd, __Value)				SET_BITS_TO_LE_1BYTE((__pH2CCmd)+1, 0, 4, __Value)
120 #define SET_8812_H2CCMD_PWRMODE_PARM_SMART_PS(__pH2CCmd, __Value)			SET_BITS_TO_LE_1BYTE((__pH2CCmd)+1, 4, 4, __Value)
121 #define SET_8812_H2CCMD_PWRMODE_PARM_BCN_PASS_TIME(__pH2CCmd, __Value)		SET_BITS_TO_LE_1BYTE_8BIT((__pH2CCmd)+2, 0, 8, __Value)
122 #define SET_8812_H2CCMD_PWRMODE_PARM_ALL_QUEUE_UAPSD(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE_8BIT((__pH2CCmd)+3, 0, 8, __Value)
123 #define SET_8812_H2CCMD_PWRMODE_PARM_PWR_STATE(__pH2CCmd, __Value)			SET_BITS_TO_LE_1BYTE_8BIT((__pH2CCmd)+4, 0, 8, __Value)
124 #define SET_8812_H2CCMD_PWRMODE_PARM_BYTE5(__pH2CCmd, __Value)				SET_BITS_TO_LE_1BYTE_8BIT((__pH2CCmd)+5, 0, 8, __Value)
125 
126 #define GET_8812_H2CCMD_PWRMODE_PARM_MODE(__pH2CCmd)							LE_BITS_TO_1BYTE(__pH2CCmd, 0, 8)
127 
128 //_P2P_PS_OFFLOAD
129 #define SET_8812_H2CCMD_P2P_PS_OFFLOAD_ENABLE(__pH2CCmd, __Value)				SET_BITS_TO_LE_1BYTE(__pH2CCmd, 0, 1, __Value)
130 #define SET_8812_H2CCMD_P2P_PS_OFFLOAD_ROLE(__pH2CCmd, __Value)				SET_BITS_TO_LE_1BYTE(__pH2CCmd, 1, 1, __Value)
131 #define SET_8812_H2CCMD_P2P_PS_OFFLOAD_CTWINDOW_EN(__pH2CCmd, __Value)		SET_BITS_TO_LE_1BYTE(__pH2CCmd, 2, 1, __Value)
132 #define SET_8812_H2CCMD_P2P_PS_OFFLOAD_NOA0_EN(__pH2CCmd, __Value)			SET_BITS_TO_LE_1BYTE(__pH2CCmd, 3, 1, __Value)
133 #define SET_8812_H2CCMD_P2P_PS_OFFLOAD_NOA1_EN(__pH2CCmd, __Value)			SET_BITS_TO_LE_1BYTE(__pH2CCmd, 4, 1, __Value)
134 #define SET_8812_H2CCMD_P2P_PS_OFFLOAD_ALLSTASLEEP(__pH2CCmd, __Value)		SET_BITS_TO_LE_1BYTE(__pH2CCmd, 5, 1, __Value)
135 #define SET_8812_H2CCMD_P2P_PS_OFFLOAD_DISCOVERY(__pH2CCmd, __Value)			SET_BITS_TO_LE_1BYTE(__pH2CCmd, 6, 1, __Value)
136 
137 
138 void	Set_RA_LDPC_8812(struct sta_info	*psta, BOOLEAN bLDPC);
139 
140 // host message to firmware cmd
141 s32 FillH2CCmd_8812(PADAPTER padapter, u8 ElementID, u32 CmdLen, u8 *pCmdBuffer);
142 void rtl8812_set_FwPwrMode_cmd(PADAPTER padapter, u8 PSMode);
143 void rtl8812_set_FwJoinBssReport_cmd(PADAPTER padapter, u8 mstatus);
144 u8 rtl8812_set_rssi_cmd(PADAPTER padapter, u8 *param);
145 void rtl8812_set_raid_cmd(PADAPTER padapter, u32 bitmap, u8* arg);
146 void rtl8812_Add_RateATid(PADAPTER padapter, u64 rate_bitmap, u8 *arg, u8 rssi_level);
147 void rtl8812_set_wowlan_cmd(_adapter* padapter, u8 enable);
148 s32 FillH2CCmd_8812(PADAPTER padapter, u8 ElementID, u32 CmdLen, u8 *pCmdBuffer);
149 u8 GetTxBufferRsvdPageNum8812(_adapter *padapter, bool wowlan);
150 
151 #ifdef CONFIG_BT_COEXIST
152 void rtl8812a_download_BTCoex_AP_mode_rsvd_page(PADAPTER padapter);
153 #endif // CONFIG_BT_COEXIST
154 #ifdef CONFIG_P2P_PS
155 void rtl8812_set_p2p_ps_offload_cmd(PADAPTER padapter, u8 p2p_ps_state);
156 #endif //CONFIG_P2P
157 
158 void CheckFwRsvdPageContent(PADAPTER padapter);
159 void rtl8812_set_FwMediaStatus_cmd(PADAPTER padapter, u16 mstatus_rpt );
160 
161 #ifdef CONFIG_TSF_RESET_OFFLOAD
162 int reset_tsf(PADAPTER Adapter, u8 reset_port );
163 #endif	// CONFIG_TSF_RESET_OFFLOAD
164 
165 #ifdef CONFIG_WOWLAN
166 void SetFwRelatedForWoWLAN8812(_adapter* padapter, u8 bHostIsGoingtoSleep);
167 #endif//CONFIG_WOWLAN
168 
169 //------------------------------------
170 //     C2H format
171 //------------------------------------
172 
173 // TX Beamforming
174 #define GET_8812_C2H_TXBF_ORIGINATE(_Header)			LE_BITS_TO_1BYTE(_Header, 0, 8)
175 #define GET_8812_C2H_TXBF_MACID(_Header)				LE_BITS_TO_1BYTE((_Header + 1), 0, 8)
176 
177 
178 
179 /// TX Feedback Content
180 #define 	USEC_UNIT_FOR_8812_C2H_TX_RPT_QUEUE_TIME			256
181 
182 #define	GET_8812_C2H_TX_RPT_QUEUE_SELECT(_Header)			LE_BITS_TO_1BYTE((_Header + 0), 0, 5)
183 #define	GET_8812_C2H_TX_RPT_PKT_BROCAST(_Header)			LE_BITS_TO_1BYTE((_Header + 0), 5, 1)
184 #define	GET_8812_C2H_TX_RPT_LIFE_TIME_OVER(_Header)			LE_BITS_TO_1BYTE((_Header + 0), 6, 1)
185 #define	GET_8812_C2H_TX_RPT_RETRY_OVER(_Header)				LE_BITS_TO_1BYTE((_Header + 0), 7, 1)
186 #define	GET_8812_C2H_TX_RPT_MAC_ID(_Header)					LE_BITS_TO_1BYTE((_Header + 1), 0, 8)
187 #define	GET_8812_C2H_TX_RPT_DATA_RETRY_CNT(_Header)		LE_BITS_TO_1BYTE((_Header + 2), 0, 6)
188 #define	GET_8812_C2H_TX_RPT_QUEUE_TIME(_Header)				LE_BITS_TO_2BYTE((_Header + 3), 0, 16)	// In unit of 256 microseconds.
189 #define	GET_8812_C2H_TX_RPT_FINAL_DATA_RATE(_Header)		LE_BITS_TO_1BYTE((_Header + 5), 0, 8)
190 
191 // BT_FW_PATCH
192 #define SET_8812_H2CCMD_BT_FW_PATCH_SIZE(__pH2CCmd, __Value)					SET_BITS_TO_LE_2BYTE((pu1Byte)(__pH2CCmd), 0, 16, __Value)
193 #define SET_8812_H2CCMD_BT_FW_PATCH_ADDR0(__pH2CCmd, __Value)					SET_BITS_TO_LE_1BYTE((pu1Byte)(__pH2CCmd)+2, 0, 8, __Value)
194 #define SET_8812_H2CCMD_BT_FW_PATCH_ADDR1(__pH2CCmd, __Value)					SET_BITS_TO_LE_1BYTE((pu1Byte)(__pH2CCmd)+3, 0, 8, __Value)
195 #define SET_8812_H2CCMD_BT_FW_PATCH_ADDR2(__pH2CCmd, __Value)					SET_BITS_TO_LE_1BYTE((pu1Byte)(__pH2CCmd)+4, 0, 8, __Value)
196 #define SET_8812_H2CCMD_BT_FW_PATCH_ADDR3(__pH2CCmd, __Value)					SET_BITS_TO_LE_1BYTE((pu1Byte)(__pH2CCmd)+5, 0, 8, __Value)
197 
198 int	rtl8812_iqk_wait(_adapter* padapter, u32 timeout_ms);
199 void	rtl8812_iqk_done(_adapter* padapter);
200 
201 s32
202 _C2HContentParsing8812(
203 	IN	PADAPTER	Adapter,
204 	IN	u8			c2hCmdId,
205 	IN	u8			c2hCmdLen,
206 	IN	u8 			*tmpBuf
207 );
208 void	C2HPacketHandler_8812(PADAPTER Adapter, u8 *Buffer, u8 Length);
209 
210 #endif//__RTL8812A_CMD_H__
211 
212