1 /* SPDX-License-Identifier: GPL-2.0 */
2 /******************************************************************************
3  *
4  * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved.
5  *
6  * Modifications for inclusion into the Linux staging tree are
7  * Copyright(c) 2010 Larry Finger. All rights reserved.
8  *
9  * Contact information:
10  * WLAN FAE <wlanfae@realtek.com>
11  * Larry Finger <Larry.Finger@lwfinger.net>
12  *
13  ******************************************************************************/
14 #ifndef __RTL8712_CMD_H_
15 #define __RTL8712_CMD_H_
16 
17 #define CMD_HDR_SZ      8
18 
19 u8 r8712_fw_cmd(struct _adapter *pAdapter, u32 cmd);
20 void r8712_fw_cmd_data(struct _adapter *pAdapter, u32 *value, u8 flag);
21 
22 struct cmd_hdr {
23 	u32 cmd_dw0;
24 	u32 cmd_dw1;
25 };
26 
27 enum rtl8712_h2c_cmd {
28 	GEN_CMD_CODE(_Read_MACREG),	/*0*/
29 	GEN_CMD_CODE(_Write_MACREG),
30 	GEN_CMD_CODE(_Read_BBREG),
31 	GEN_CMD_CODE(_Write_BBREG),
32 	GEN_CMD_CODE(_Read_RFREG),
33 	GEN_CMD_CODE(_Write_RFREG), /*5*/
34 	GEN_CMD_CODE(_Read_EEPROM),
35 	GEN_CMD_CODE(_Write_EEPROM),
36 	GEN_CMD_CODE(_Read_EFUSE),
37 	GEN_CMD_CODE(_Write_EFUSE),
38 
39 	GEN_CMD_CODE(_Read_CAM),	/*10*/
40 	GEN_CMD_CODE(_Write_CAM),
41 	GEN_CMD_CODE(_setBCNITV),
42 	GEN_CMD_CODE(_setMBIDCFG),
43 	GEN_CMD_CODE(_JoinBss),   /*14*/
44 	GEN_CMD_CODE(_DisConnect), /*15*/
45 	GEN_CMD_CODE(_CreateBss),
46 	GEN_CMD_CODE(_SetOpMode),
47 	GEN_CMD_CODE(_SiteSurvey),  /*18*/
48 	GEN_CMD_CODE(_SetAuth),
49 
50 	GEN_CMD_CODE(_SetKey),	/*20*/
51 	GEN_CMD_CODE(_SetStaKey),
52 	GEN_CMD_CODE(_SetAssocSta),
53 	GEN_CMD_CODE(_DelAssocSta),
54 	GEN_CMD_CODE(_SetStaPwrState),
55 	GEN_CMD_CODE(_SetBasicRate), /*25*/
56 	GEN_CMD_CODE(_GetBasicRate),
57 	GEN_CMD_CODE(_SetDataRate),
58 	GEN_CMD_CODE(_GetDataRate),
59 	GEN_CMD_CODE(_SetPhyInfo),
60 
61 	GEN_CMD_CODE(_GetPhyInfo),	/*30*/
62 	GEN_CMD_CODE(_SetPhy),
63 	GEN_CMD_CODE(_GetPhy),
64 	GEN_CMD_CODE(_readRssi),
65 	GEN_CMD_CODE(_readGain),
66 	GEN_CMD_CODE(_SetAtim), /*35*/
67 	GEN_CMD_CODE(_SetPwrMode),
68 	GEN_CMD_CODE(_JoinbssRpt),
69 	GEN_CMD_CODE(_SetRaTable),
70 	GEN_CMD_CODE(_GetRaTable),
71 
72 	GEN_CMD_CODE(_GetCCXReport), /*40*/
73 	GEN_CMD_CODE(_GetDTMReport),
74 	GEN_CMD_CODE(_GetTXRateStatistics),
75 	GEN_CMD_CODE(_SetUsbSuspend),
76 	GEN_CMD_CODE(_SetH2cLbk),
77 	GEN_CMD_CODE(_AddBAReq), /*45*/
78 
79 	GEN_CMD_CODE(_SetChannel), /*46*/
80 /* MP_OFFLOAD Start (47~54)*/
81 	GEN_CMD_CODE(_SetTxPower),
82 	GEN_CMD_CODE(_SwitchAntenna),
83 	GEN_CMD_CODE(_SetCrystalCap),
84 	GEN_CMD_CODE(_SetSingleCarrierTx), /*50*/
85 	GEN_CMD_CODE(_SetSingleToneTx),
86 	GEN_CMD_CODE(_SetCarrierSuppressionTx),
87 	GEN_CMD_CODE(_SetContinuousTx),
88 	GEN_CMD_CODE(_SwitchBandwidth), /*54*/
89 /* MP_OFFLOAD End*/
90 	GEN_CMD_CODE(_TX_Beacon), /*55*/
91 	GEN_CMD_CODE(_SetPowerTracking),
92 	GEN_CMD_CODE(_AMSDU_TO_AMPDU), /*57*/
93 	GEN_CMD_CODE(_SetMacAddress), /*58*/
94 
95 	GEN_CMD_CODE(_DisconnectCtrl), /*59*/
96 	GEN_CMD_CODE(_SetChannelPlan), /*60*/
97 	GEN_CMD_CODE(_DisconnectCtrlEx), /*61*/
98 
99 	/* To do, modify these h2c cmd, add or delete */
100 	GEN_CMD_CODE(_GetH2cLbk),
101 
102 	/* WPS extra IE */
103 	GEN_CMD_CODE(_SetProbeReqExtraIE),
104 	GEN_CMD_CODE(_SetAssocReqExtraIE),
105 	GEN_CMD_CODE(_SetProbeRspExtraIE),
106 	GEN_CMD_CODE(_SetAssocRspExtraIE),
107 
108 	/* the following is driver will do */
109 	GEN_CMD_CODE(_GetCurDataRate),
110 
111 	GEN_CMD_CODE(_GetTxRetrycnt),  /* to record times that Tx retry to
112 					* transmit packet after association
113 					*/
114 	GEN_CMD_CODE(_GetRxRetrycnt),  /* to record total number of the
115 					* received frame with ReTry bit set in
116 					* the WLAN header
117 					*/
118 
119 	GEN_CMD_CODE(_GetBCNOKcnt),
120 	GEN_CMD_CODE(_GetBCNERRcnt),
121 	GEN_CMD_CODE(_GetCurTxPwrLevel),
122 
123 	GEN_CMD_CODE(_SetDIG),
124 	GEN_CMD_CODE(_SetRA),
125 	GEN_CMD_CODE(_SetPT),
126 	GEN_CMD_CODE(_ReadTSSI),
127 
128 	MAX_H2CCMD
129 };
130 
131 #define _GetBBReg_CMD_		_Read_BBREG_CMD_
132 #define _SetBBReg_CMD_		_Write_BBREG_CMD_
133 #define _GetRFReg_CMD_		_Read_RFREG_CMD_
134 #define _SetRFReg_CMD_		_Write_RFREG_CMD_
135 #define _DRV_INT_CMD_		(MAX_H2CCMD + 1)
136 #define _SetRFIntFs_CMD_	(MAX_H2CCMD + 2)
137 
138 #ifdef _RTL8712_CMD_C_
139 static struct _cmd_callback	cmd_callback[] = {
140 	{GEN_CMD_CODE(_Read_MACREG), NULL}, /*0*/
141 	{GEN_CMD_CODE(_Write_MACREG), NULL},
142 	{GEN_CMD_CODE(_Read_BBREG), NULL},
143 	{GEN_CMD_CODE(_Write_BBREG), NULL},
144 	{GEN_CMD_CODE(_Read_RFREG), &r8712_getbbrfreg_cmdrsp_callback},
145 	{GEN_CMD_CODE(_Write_RFREG), NULL}, /*5*/
146 	{GEN_CMD_CODE(_Read_EEPROM), NULL},
147 	{GEN_CMD_CODE(_Write_EEPROM), NULL},
148 	{GEN_CMD_CODE(_Read_EFUSE), NULL},
149 	{GEN_CMD_CODE(_Write_EFUSE), NULL},
150 
151 	{GEN_CMD_CODE(_Read_CAM),	NULL},	/*10*/
152 	{GEN_CMD_CODE(_Write_CAM),	 NULL},
153 	{GEN_CMD_CODE(_setBCNITV), NULL},
154 	{GEN_CMD_CODE(_setMBIDCFG), NULL},
155 	{GEN_CMD_CODE(_JoinBss), &r8712_joinbss_cmd_callback},  /*14*/
156 	{GEN_CMD_CODE(_DisConnect), &r8712_disassoc_cmd_callback}, /*15*/
157 	{GEN_CMD_CODE(_CreateBss), &r8712_createbss_cmd_callback},
158 	{GEN_CMD_CODE(_SetOpMode), NULL},
159 	{GEN_CMD_CODE(_SiteSurvey), &r8712_survey_cmd_callback}, /*18*/
160 	{GEN_CMD_CODE(_SetAuth), NULL},
161 
162 	{GEN_CMD_CODE(_SetKey), NULL},	/*20*/
163 	{GEN_CMD_CODE(_SetStaKey), &r8712_setstaKey_cmdrsp_callback},
164 	{GEN_CMD_CODE(_SetAssocSta), &r8712_setassocsta_cmdrsp_callback},
165 	{GEN_CMD_CODE(_DelAssocSta), NULL},
166 	{GEN_CMD_CODE(_SetStaPwrState), NULL},
167 	{GEN_CMD_CODE(_SetBasicRate), NULL}, /*25*/
168 	{GEN_CMD_CODE(_GetBasicRate), NULL},
169 	{GEN_CMD_CODE(_SetDataRate), NULL},
170 	{GEN_CMD_CODE(_GetDataRate), NULL},
171 	{GEN_CMD_CODE(_SetPhyInfo), NULL},
172 
173 	{GEN_CMD_CODE(_GetPhyInfo), NULL}, /*30*/
174 	{GEN_CMD_CODE(_SetPhy), NULL},
175 	{GEN_CMD_CODE(_GetPhy), NULL},
176 	{GEN_CMD_CODE(_readRssi), NULL},
177 	{GEN_CMD_CODE(_readGain), NULL},
178 	{GEN_CMD_CODE(_SetAtim), NULL}, /*35*/
179 	{GEN_CMD_CODE(_SetPwrMode), NULL},
180 	{GEN_CMD_CODE(_JoinbssRpt), NULL},
181 	{GEN_CMD_CODE(_SetRaTable), NULL},
182 	{GEN_CMD_CODE(_GetRaTable), NULL},
183 
184 	{GEN_CMD_CODE(_GetCCXReport), NULL}, /*40*/
185 	{GEN_CMD_CODE(_GetDTMReport),	NULL},
186 	{GEN_CMD_CODE(_GetTXRateStatistics), NULL},
187 	{GEN_CMD_CODE(_SetUsbSuspend), NULL},
188 	{GEN_CMD_CODE(_SetH2cLbk), NULL},
189 	{GEN_CMD_CODE(_AddBAReq), NULL}, /*45*/
190 
191 	{GEN_CMD_CODE(_SetChannel), NULL},		/*46*/
192 /* MP_OFFLOAD Start (47~54)*/
193 	{GEN_CMD_CODE(_SetTxPower), NULL},
194 	{GEN_CMD_CODE(_SwitchAntenna), NULL},
195 	{GEN_CMD_CODE(_SetCrystalCap), NULL},
196 	{GEN_CMD_CODE(_SetSingleCarrierTx), NULL},	/*50*/
197 	{GEN_CMD_CODE(_SetSingleToneTx), NULL},
198 	{GEN_CMD_CODE(_SetCarrierSuppressionTx), NULL},
199 	{GEN_CMD_CODE(_SetContinuousTx), NULL},
200 	{GEN_CMD_CODE(_SwitchBandwidth), NULL},		/*54*/
201 /* MP_OFFLOAD End*/
202 	{GEN_CMD_CODE(_TX_Beacon), NULL}, /*55*/
203 	{GEN_CMD_CODE(_SetPowerTracking), NULL},
204 	{GEN_CMD_CODE(_AMSDU_TO_AMPDU), NULL}, /*57*/
205 	{GEN_CMD_CODE(_SetMacAddress), NULL}, /*58*/
206 
207 	{GEN_CMD_CODE(_DisconnectCtrl), NULL}, /*59*/
208 	{GEN_CMD_CODE(_SetChannelPlan), NULL}, /*60*/
209 	{GEN_CMD_CODE(_DisconnectCtrlEx), NULL}, /*61*/
210 
211 	/* To do, modify these h2c cmd, add or delete */
212 	{GEN_CMD_CODE(_GetH2cLbk), NULL},
213 
214 	{_SetProbeReqExtraIE_CMD_, NULL},
215 	{_SetAssocReqExtraIE_CMD_, NULL},
216 	{_SetProbeRspExtraIE_CMD_, NULL},
217 	{_SetAssocRspExtraIE_CMD_, NULL},
218 	{_GetCurDataRate_CMD_, NULL},
219 	{_GetTxRetrycnt_CMD_, NULL},
220 	{_GetRxRetrycnt_CMD_, NULL},
221 	{_GetBCNOKcnt_CMD_, NULL},
222 	{_GetBCNERRcnt_CMD_, NULL},
223 	{_GetCurTxPwrLevel_CMD_, NULL},
224 	{_SetDIG_CMD_, NULL},
225 	{_SetRA_CMD_, NULL},
226 	{_SetPT_CMD_, NULL},
227 	{GEN_CMD_CODE(_ReadTSSI), &r8712_readtssi_cmdrsp_callback}
228 };
229 #endif
230 
231 #endif
232