net: wireless: rockchip_wlan: add rtl8723bs support
[firefly-linux-kernel-4.4.55.git] / drivers / net / wireless / rockchip_wlan / rtl8723bs / include / rtl8812a_cmd.h
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 struct cmd_msg_parm {
61         u8 eid; //element id
62         u8 sz; // sz
63         u8 buf[6];
64 };
65
66 enum{
67         PWRS
68 };
69
70 struct H2C_SS_RFOFF_PARAM{
71         u8 ROFOn; // 1: on, 0:off
72         u16 gpio_period; // unit: 1024 us
73 }__attribute__ ((packed));
74
75
76
77 //_RSVDPAGE_LOC_CMD0
78 #define SET_8812_H2CCMD_RSVDPAGE_LOC_PROBE_RSP(__pH2CCmd, __Value)                      SET_BITS_TO_LE_1BYTE(__pH2CCmd, 0, 8, __Value)
79 #define SET_8812_H2CCMD_RSVDPAGE_LOC_PSPOLL(__pH2CCmd, __Value)                         SET_BITS_TO_LE_1BYTE((__pH2CCmd)+1, 0, 8, __Value)
80 #define SET_8812_H2CCMD_RSVDPAGE_LOC_NULL_DATA(__pH2CCmd, __Value)                      SET_BITS_TO_LE_1BYTE((__pH2CCmd)+2, 0, 8, __Value)
81 #define SET_8812_H2CCMD_RSVDPAGE_LOC_QOS_NULL_DATA(__pH2CCmd, __Value)          SET_BITS_TO_LE_1BYTE((__pH2CCmd)+3, 0, 8, __Value)
82 #define SET_8812_H2CCMD_RSVDPAGE_LOC_BT_QOS_NULL_DATA(__pH2CCmd, __Value)       SET_BITS_TO_LE_1BYTE((__pH2CCmd)+4, 0, 8, __Value)
83
84 //_SETPWRMODE_PARM
85 #define SET_8812_H2CCMD_PWRMODE_PARM_MODE(__pH2CCmd, __Value)                           SET_BITS_TO_LE_1BYTE(__pH2CCmd, 0, 8, __Value)
86 #define SET_8812_H2CCMD_PWRMODE_PARM_RLBM(__pH2CCmd, __Value)                           SET_BITS_TO_LE_1BYTE((__pH2CCmd)+1, 0, 4, __Value)
87 #define SET_8812_H2CCMD_PWRMODE_PARM_SMART_PS(__pH2CCmd, __Value)                       SET_BITS_TO_LE_1BYTE((__pH2CCmd)+1, 4, 4, __Value)
88 #define SET_8812_H2CCMD_PWRMODE_PARM_BCN_PASS_TIME(__pH2CCmd, __Value)          SET_BITS_TO_LE_1BYTE((__pH2CCmd)+2, 0, 8, __Value)
89 #define SET_8812_H2CCMD_PWRMODE_PARM_ALL_QUEUE_UAPSD(__pH2CCmd, __Value)        SET_BITS_TO_LE_1BYTE((__pH2CCmd)+3, 0, 8, __Value)
90 #define SET_8812_H2CCMD_PWRMODE_PARM_BCN_EARLY_C2H_RPT(__pH2CCmd, __Value)      SET_BITS_TO_LE_1BYTE((__pH2CCmd)+3, 2, 1, __Value)
91 #define SET_8812_H2CCMD_PWRMODE_PARM_PWR_STATE(__pH2CCmd, __Value)                      SET_BITS_TO_LE_1BYTE((__pH2CCmd)+4, 0, 8, __Value)
92 #define SET_8812_H2CCMD_PWRMODE_PARM_BYTE5(__pH2CCmd, __Value)                          SET_BITS_TO_LE_1BYTE((__pH2CCmd)+5, 0, 8, __Value)
93
94 #define GET_8812_H2CCMD_PWRMODE_PARM_MODE(__pH2CCmd)                                                    LE_BITS_TO_1BYTE(__pH2CCmd, 0, 8)
95
96 //_P2P_PS_OFFLOAD
97 #define SET_8812_H2CCMD_P2P_PS_OFFLOAD_ENABLE(__pH2CCmd, __Value)                               SET_BITS_TO_LE_1BYTE(__pH2CCmd, 0, 1, __Value)
98 #define SET_8812_H2CCMD_P2P_PS_OFFLOAD_ROLE(__pH2CCmd, __Value)                         SET_BITS_TO_LE_1BYTE(__pH2CCmd, 1, 1, __Value)
99 #define SET_8812_H2CCMD_P2P_PS_OFFLOAD_CTWINDOW_EN(__pH2CCmd, __Value)          SET_BITS_TO_LE_1BYTE(__pH2CCmd, 2, 1, __Value)
100 #define SET_8812_H2CCMD_P2P_PS_OFFLOAD_NOA0_EN(__pH2CCmd, __Value)                      SET_BITS_TO_LE_1BYTE(__pH2CCmd, 3, 1, __Value)
101 #define SET_8812_H2CCMD_P2P_PS_OFFLOAD_NOA1_EN(__pH2CCmd, __Value)                      SET_BITS_TO_LE_1BYTE(__pH2CCmd, 4, 1, __Value)
102 #define SET_8812_H2CCMD_P2P_PS_OFFLOAD_ALLSTASLEEP(__pH2CCmd, __Value)          SET_BITS_TO_LE_1BYTE(__pH2CCmd, 5, 1, __Value)
103 #define SET_8812_H2CCMD_P2P_PS_OFFLOAD_DISCOVERY(__pH2CCmd, __Value)                    SET_BITS_TO_LE_1BYTE(__pH2CCmd, 6, 1, __Value)
104
105
106 void    Set_RA_LDPC_8812(struct sta_info        *psta, BOOLEAN bLDPC);
107
108 // host message to firmware cmd
109 s32 FillH2CCmd_8812(PADAPTER padapter, u8 ElementID, u32 CmdLen, u8 *pCmdBuffer);
110 void rtl8812_set_FwPwrMode_cmd(PADAPTER padapter, u8 PSMode);
111 void rtl8812_set_FwJoinBssReport_cmd(PADAPTER padapter, u8 mstatus);
112 u8 rtl8812_set_rssi_cmd(PADAPTER padapter, u8 *param);
113 void rtl8812_set_raid_cmd(PADAPTER padapter, u32 bitmap, u8* arg);
114 void rtl8812_Add_RateATid(PADAPTER padapter, u64 rate_bitmap, u8 *arg, u8 rssi_level);
115 void rtl8812_set_wowlan_cmd(_adapter* padapter, u8 enable);
116 s32 FillH2CCmd_8812(PADAPTER padapter, u8 ElementID, u32 CmdLen, u8 *pCmdBuffer);
117 u8 GetTxBufferRsvdPageNum8812(_adapter *padapter, bool wowlan);
118
119 #ifdef CONFIG_BT_COEXIST
120 void rtl8812a_download_BTCoex_AP_mode_rsvd_page(PADAPTER padapter);
121 #endif // CONFIG_BT_COEXIST
122 #ifdef CONFIG_P2P_PS
123 void rtl8812_set_p2p_ps_offload_cmd(PADAPTER padapter, u8 p2p_ps_state);
124 #endif //CONFIG_P2P
125
126 void CheckFwRsvdPageContent(PADAPTER padapter);
127
128 #ifdef CONFIG_TDLS
129 #ifdef CONFIG_TDLS_CH_SW
130 void rtl8812_set_BcnEarly_C2H_Rpt_cmd(PADAPTER padapter, u8 enable);
131 #endif
132 #endif
133
134 #ifdef CONFIG_TSF_RESET_OFFLOAD
135 int reset_tsf(PADAPTER Adapter, u8 reset_port );
136 #endif  // CONFIG_TSF_RESET_OFFLOAD
137
138 //------------------------------------
139 //     C2H format
140 //------------------------------------
141
142 // TX Beamforming
143 #define GET_8812_C2H_TXBF_ORIGINATE(_Header)                    LE_BITS_TO_1BYTE(_Header, 0, 8)
144 #define GET_8812_C2H_TXBF_MACID(_Header)                                LE_BITS_TO_1BYTE((_Header + 1), 0, 8)
145
146
147
148 /// TX Feedback Content
149 #define         USEC_UNIT_FOR_8812_C2H_TX_RPT_QUEUE_TIME                        256
150
151 #define GET_8812_C2H_TX_RPT_QUEUE_SELECT(_Header)                       LE_BITS_TO_1BYTE((_Header + 0), 0, 5)
152 #define GET_8812_C2H_TX_RPT_PKT_BROCAST(_Header)                        LE_BITS_TO_1BYTE((_Header + 0), 5, 1)
153 #define GET_8812_C2H_TX_RPT_LIFE_TIME_OVER(_Header)                     LE_BITS_TO_1BYTE((_Header + 0), 6, 1)
154 #define GET_8812_C2H_TX_RPT_RETRY_OVER(_Header)                         LE_BITS_TO_1BYTE((_Header + 0), 7, 1)
155 #define GET_8812_C2H_TX_RPT_MAC_ID(_Header)                                     LE_BITS_TO_1BYTE((_Header + 1), 0, 8)
156 #define GET_8812_C2H_TX_RPT_DATA_RETRY_CNT(_Header)             LE_BITS_TO_1BYTE((_Header + 2), 0, 6)
157 #define GET_8812_C2H_TX_RPT_QUEUE_TIME(_Header)                         LE_BITS_TO_2BYTE((_Header + 3), 0, 16)  // In unit of 256 microseconds.
158 #define GET_8812_C2H_TX_RPT_FINAL_DATA_RATE(_Header)            LE_BITS_TO_1BYTE((_Header + 5), 0, 8)
159
160 // BT_FW_PATCH
161 #define SET_8812_H2CCMD_BT_FW_PATCH_SIZE(__pH2CCmd, __Value)                                    SET_BITS_TO_LE_2BYTE((pu1Byte)(__pH2CCmd), 0, 16, __Value)
162 #define SET_8812_H2CCMD_BT_FW_PATCH_ADDR0(__pH2CCmd, __Value)                                   SET_BITS_TO_LE_1BYTE((pu1Byte)(__pH2CCmd)+2, 0, 8, __Value)
163 #define SET_8812_H2CCMD_BT_FW_PATCH_ADDR1(__pH2CCmd, __Value)                                   SET_BITS_TO_LE_1BYTE((pu1Byte)(__pH2CCmd)+3, 0, 8, __Value)
164 #define SET_8812_H2CCMD_BT_FW_PATCH_ADDR2(__pH2CCmd, __Value)                                   SET_BITS_TO_LE_1BYTE((pu1Byte)(__pH2CCmd)+4, 0, 8, __Value)
165 #define SET_8812_H2CCMD_BT_FW_PATCH_ADDR3(__pH2CCmd, __Value)                                   SET_BITS_TO_LE_1BYTE((pu1Byte)(__pH2CCmd)+5, 0, 8, __Value)
166
167 int     rtl8812_iqk_wait(_adapter* padapter, u32 timeout_ms);
168 void    rtl8812_iqk_done(_adapter* padapter);
169
170 s32
171 _C2HContentParsing8812(
172         IN      PADAPTER        Adapter,
173         IN      u8                      c2hCmdId, 
174         IN      u8                      c2hCmdLen,
175         IN      u8                      *tmpBuf
176 );
177 void    C2HPacketHandler_8812(PADAPTER Adapter, u8 *Buffer, u8 Length);
178
179 #endif//__RTL8812A_CMD_H__
180