xref: /OK3568_Linux_fs/external/rkwifibt/drivers/rtl8189fs/include/rtl8812a_cmd.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /******************************************************************************
2  *
3  * Copyright(c) 2007 - 2017 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  *****************************************************************************/
15 #ifndef __RTL8812A_CMD_H__
16 #define __RTL8812A_CMD_H__
17 
18 typedef enum _RTL8812_H2C_CMD {
19 	H2C_8812_RSVDPAGE = 0,
20 	H2C_8812_MSRRPT = 1,
21 	H2C_8812_SCAN = 2,
22 	H2C_8812_KEEP_ALIVE_CTRL = 3,
23 	H2C_8812_DISCONNECT_DECISION = 4,
24 
25 	H2C_8812_INIT_OFFLOAD = 6,
26 	H2C_8812_AP_OFFLOAD = 8,
27 	H2C_8812_BCN_RSVDPAGE = 9,
28 	H2C_8812_PROBERSP_RSVDPAGE = 10,
29 
30 	H2C_8812_SETPWRMODE = 0x20,
31 	H2C_8812_PS_TUNING_PARA = 0x21,
32 	H2C_8812_PS_TUNING_PARA2 = 0x22,
33 	H2C_8812_PS_LPS_PARA = 0x23,
34 	H2C_8812_P2P_PS_OFFLOAD = 0x24,
35 	H2C_8812_INACTIVE_PS = 0x27,
36 	H2C_8812_RA_MASK = 0x40,
37 	H2C_8812_TxBF = 0x41,
38 	H2C_8812_RSSI_REPORT = 0x42,
39 	H2C_8812_IQ_CALIBRATION = 0x45,
40 	H2C_8812_RA_PARA_ADJUST = 0x46,
41 
42 	H2C_8812_BT_FW_PATCH = 0x6a,
43 
44 	H2C_8812_WO_WLAN = 0x80,
45 	H2C_8812_REMOTE_WAKE_CTRL = 0x81,
46 	H2C_8812_AOAC_GLOBAL_INFO = 0x82,
47 	H2C_8812_AOAC_RSVDPAGE = 0x83,
48 	H2C_8812_FW_SWCHANNL = 0x87,
49 
50 	H2C_8812_TSF_RESET = 0xC0,
51 
52 	MAX_8812_H2CCMD
53 } RTL8812_H2C_CMD;
54 
55 struct cmd_msg_parm {
56 	u8 eid; /* element id */
57 	u8 sz; /* sz */
58 	u8 buf[6];
59 };
60 
61 enum {
62 	PWRS
63 };
64 
65 struct H2C_SS_RFOFF_PARAM {
66 	u8 ROFOn; /* 1: on, 0:off */
67 	u16 gpio_period; /* unit: 1024 us */
68 } __attribute__((packed));
69 
70 
71 
72 /* _RSVDPAGE_LOC_CMD0 */
73 #define SET_8812_H2CCMD_RSVDPAGE_LOC_PROBE_RSP(__pH2CCmd, __Value)			SET_BITS_TO_LE_1BYTE(__pH2CCmd, 0, 8, __Value)
74 #define SET_8812_H2CCMD_RSVDPAGE_LOC_PSPOLL(__pH2CCmd, __Value)				SET_BITS_TO_LE_1BYTE((__pH2CCmd)+1, 0, 8, __Value)
75 #define SET_8812_H2CCMD_RSVDPAGE_LOC_NULL_DATA(__pH2CCmd, __Value)			SET_BITS_TO_LE_1BYTE((__pH2CCmd)+2, 0, 8, __Value)
76 #define SET_8812_H2CCMD_RSVDPAGE_LOC_QOS_NULL_DATA(__pH2CCmd, __Value)		SET_BITS_TO_LE_1BYTE((__pH2CCmd)+3, 0, 8, __Value)
77 #define SET_8812_H2CCMD_RSVDPAGE_LOC_BT_QOS_NULL_DATA(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE((__pH2CCmd)+4, 0, 8, __Value)
78 
79 /* _SETPWRMODE_PARM */
80 #define SET_8812_H2CCMD_PWRMODE_PARM_MODE(__pH2CCmd, __Value)				SET_BITS_TO_LE_1BYTE(__pH2CCmd, 0, 8, __Value)
81 #define SET_8812_H2CCMD_PWRMODE_PARM_RLBM(__pH2CCmd, __Value)				SET_BITS_TO_LE_1BYTE((__pH2CCmd)+1, 0, 4, __Value)
82 #define SET_8812_H2CCMD_PWRMODE_PARM_SMART_PS(__pH2CCmd, __Value)			SET_BITS_TO_LE_1BYTE((__pH2CCmd)+1, 4, 4, __Value)
83 #define SET_8812_H2CCMD_PWRMODE_PARM_BCN_PASS_TIME(__pH2CCmd, __Value)		SET_BITS_TO_LE_1BYTE((__pH2CCmd)+2, 0, 8, __Value)
84 #define SET_8812_H2CCMD_PWRMODE_PARM_ALL_QUEUE_UAPSD(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE((__pH2CCmd)+3, 0, 8, __Value)
85 #define SET_8812_H2CCMD_PWRMODE_PARM_BCN_EARLY_C2H_RPT(__pH2CCmd, __Value)	SET_BITS_TO_LE_1BYTE((__pH2CCmd)+3, 2, 1, __Value)
86 #define SET_8812_H2CCMD_PWRMODE_PARM_PWR_STATE(__pH2CCmd, __Value)			SET_BITS_TO_LE_1BYTE((__pH2CCmd)+4, 0, 8, __Value)
87 
88 #define GET_8812_H2CCMD_PWRMODE_PARM_MODE(__pH2CCmd)							LE_BITS_TO_1BYTE(__pH2CCmd, 0, 8)
89 
90 /* _P2P_PS_OFFLOAD */
91 #define SET_8812_H2CCMD_P2P_PS_OFFLOAD_ENABLE(__pH2CCmd, __Value)				SET_BITS_TO_LE_1BYTE(__pH2CCmd, 0, 1, __Value)
92 #define SET_8812_H2CCMD_P2P_PS_OFFLOAD_ROLE(__pH2CCmd, __Value)				SET_BITS_TO_LE_1BYTE(__pH2CCmd, 1, 1, __Value)
93 #define SET_8812_H2CCMD_P2P_PS_OFFLOAD_CTWINDOW_EN(__pH2CCmd, __Value)		SET_BITS_TO_LE_1BYTE(__pH2CCmd, 2, 1, __Value)
94 #define SET_8812_H2CCMD_P2P_PS_OFFLOAD_NOA0_EN(__pH2CCmd, __Value)			SET_BITS_TO_LE_1BYTE(__pH2CCmd, 3, 1, __Value)
95 #define SET_8812_H2CCMD_P2P_PS_OFFLOAD_NOA1_EN(__pH2CCmd, __Value)			SET_BITS_TO_LE_1BYTE(__pH2CCmd, 4, 1, __Value)
96 #define SET_8812_H2CCMD_P2P_PS_OFFLOAD_ALLSTASLEEP(__pH2CCmd, __Value)		SET_BITS_TO_LE_1BYTE(__pH2CCmd, 5, 1, __Value)
97 #define SET_8812_H2CCMD_P2P_PS_OFFLOAD_DISCOVERY(__pH2CCmd, __Value)			SET_BITS_TO_LE_1BYTE(__pH2CCmd, 6, 1, __Value)
98 
99 
100 void	set_ra_ldpc_8812(struct cmn_sta_info *cmn_sta_info, BOOLEAN bLDPC);
101 
102 /* host message to firmware cmd */
103 s32 fill_h2c_cmd_8812(PADAPTER padapter, u8 ElementID, u32 CmdLen, u8 *pCmdBuffer);
104 void rtl8812_set_FwPwrMode_cmd(PADAPTER padapter, u8 PSMode);
105 void rtl8812_set_FwJoinBssReport_cmd(PADAPTER padapter, u8 mstatus);
106 u8 rtl8812_set_rssi_cmd(PADAPTER padapter, u8 *param);
107 void rtl8812_set_wowlan_cmd(_adapter *padapter, u8 enable);
108 u8 GetTxBufferRsvdPageNum8812(_adapter *padapter, bool wowlan);
109 
110 #ifdef CONFIG_BT_COEXIST
111 void rtl8812a_download_BTCoex_AP_mode_rsvd_page(PADAPTER padapter);
112 #endif /* CONFIG_BT_COEXIST */
113 #ifdef CONFIG_P2P_PS
114 void rtl8812_set_p2p_ps_offload_cmd(PADAPTER padapter, u8 p2p_ps_state);
115 #endif /* CONFIG_P2P */
116 
117 #ifdef CONFIG_FWLPS_IN_IPS
118 void rtl8812_set_FwPwrModeInIPS_cmd(PADAPTER padapter, u8 cmd_param);
119 #endif
120 
121 #ifdef CONFIG_TDLS
122 #ifdef CONFIG_TDLS_CH_SW
123 void rtl8812_set_BcnEarly_C2H_Rpt_cmd(PADAPTER padapter, u8 enable);
124 #endif
125 #endif
126 
127 /* ------------------------------------
128  * C2H format
129  * ------------------------------------ */
130 
131 /* TX Beamforming */
132 #define GET_8812_C2H_TXBF_ORIGINATE(_Header)			LE_BITS_TO_1BYTE(_Header, 0, 8)
133 #define GET_8812_C2H_TXBF_MACID(_Header)				LE_BITS_TO_1BYTE((_Header + 1), 0, 8)
134 
135 
136 
137 /* / TX Feedback Content */
138 #define	USEC_UNIT_FOR_8812_C2H_TX_RPT_QUEUE_TIME			256
139 
140 #define	GET_8812_C2H_TX_RPT_QUEUE_SELECT(_Header)			LE_BITS_TO_1BYTE((_Header + 0), 0, 5)
141 #define	GET_8812_C2H_TX_RPT_PKT_BROCAST(_Header)			LE_BITS_TO_1BYTE((_Header + 0), 5, 1)
142 #define	GET_8812_C2H_TX_RPT_LIFE_TIME_OVER(_Header)			LE_BITS_TO_1BYTE((_Header + 0), 6, 1)
143 #define	GET_8812_C2H_TX_RPT_RETRY_OVER(_Header)				LE_BITS_TO_1BYTE((_Header + 0), 7, 1)
144 #define	GET_8812_C2H_TX_RPT_MAC_ID(_Header)					LE_BITS_TO_1BYTE((_Header + 1), 0, 8)
145 #define	GET_8812_C2H_TX_RPT_DATA_RETRY_CNT(_Header)		LE_BITS_TO_1BYTE((_Header + 2), 0, 6)
146 #define	GET_8812_C2H_TX_RPT_QUEUE_TIME(_Header)				LE_BITS_TO_2BYTE((_Header + 3), 0, 16)	/* In unit of 256 microseconds. */
147 #define	GET_8812_C2H_TX_RPT_FINAL_DATA_RATE(_Header)		LE_BITS_TO_1BYTE((_Header + 5), 0, 8)
148 
149 /* BT_FW_PATCH */
150 #define SET_8812_H2CCMD_BT_FW_PATCH_SIZE(__pH2CCmd, __Value)					SET_BITS_TO_LE_2BYTE((u8 *)(__pH2CCmd), 0, 16, __Value)
151 #define SET_8812_H2CCMD_BT_FW_PATCH_ADDR0(__pH2CCmd, __Value)					SET_BITS_TO_LE_1BYTE((u8 *)(__pH2CCmd)+2, 0, 8, __Value)
152 #define SET_8812_H2CCMD_BT_FW_PATCH_ADDR1(__pH2CCmd, __Value)					SET_BITS_TO_LE_1BYTE((u8 *)(__pH2CCmd)+3, 0, 8, __Value)
153 #define SET_8812_H2CCMD_BT_FW_PATCH_ADDR2(__pH2CCmd, __Value)					SET_BITS_TO_LE_1BYTE((u8 *)(__pH2CCmd)+4, 0, 8, __Value)
154 #define SET_8812_H2CCMD_BT_FW_PATCH_ADDR3(__pH2CCmd, __Value)					SET_BITS_TO_LE_1BYTE((u8 *)(__pH2CCmd)+5, 0, 8, __Value)
155 
156 s32 c2h_handler_8812a(_adapter *adapter, u8 id, u8 seq, u8 plen, u8 *payload);
157 
158 #endif/* __RTL8812A_CMD_H__ */
159