xref: /linux/drivers/staging/rtl8712/rtl871x_mp_ioctl.h (revision 4f2c0a4acffbec01079c28f839422e64ddeff004)
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 _RTL871X_MP_IOCTL_H
15 #define _RTL871X_MP_IOCTL_H
16 
17 #include "osdep_service.h"
18 #include "drv_types.h"
19 #include "mp_custom_oid.h"
20 #include "rtl871x_ioctl.h"
21 #include "rtl871x_ioctl_rtl.h"
22 #include "rtl8712_efuse.h"
23 
24 #define TESTFWCMDNUMBER			1000000
25 #define TEST_H2CINT_WAIT_TIME		500
26 #define TEST_C2HINT_WAIT_TIME		500
27 #define HCI_TEST_SYSCFG_HWMASK		1
28 #define _BUSCLK_40M			(4 << 2)
29 
30 struct CFG_DBG_MSG_STRUCT {
31 	u32 DebugLevel;
32 	u32 DebugComponent_H32;
33 	u32 DebugComponent_L32;
34 };
35 
36 struct mp_rw_reg {
37 	uint offset;
38 	uint width;
39 	u32 value;
40 };
41 
42 /* for OID_RT_PRO_READ16_EEPROM & OID_RT_PRO_WRITE16_EEPROM */
43 struct eeprom_rw_param {
44 	uint offset;
45 	u16 value;
46 };
47 
48 struct EFUSE_ACCESS_STRUCT {
49 	u16	start_addr;
50 	u16	cnts;
51 	u8	data[];
52 };
53 
54 struct burst_rw_reg {
55 	uint offset;
56 	uint len;
57 	u8 Data[256];
58 };
59 
60 struct usb_vendor_req {
61 	u8	bRequest;
62 	u16	wValue;
63 	u16	wIndex;
64 	u16	wLength;
65 	u8	u8Dir;/*0:OUT, 1:IN */
66 	u8	u8InData;
67 };
68 
69 struct DR_VARIABLE_STRUCT {
70 	u8 offset;
71 	u32 variable;
72 };
73 
74 /* oid_rtl_seg_87_11_00 */
75 uint oid_rt_pro_read_register_hdl(struct oid_par_priv *poid_par_priv);
76 uint oid_rt_pro_write_register_hdl(struct oid_par_priv *poid_par_priv);
77 /* oid_rtl_seg_81_80_00 */
78 uint oid_rt_pro_set_data_rate_hdl(
79 				struct oid_par_priv *poid_par_priv);
80 uint oid_rt_pro_start_test_hdl(struct oid_par_priv *poid_par_priv);
81 uint oid_rt_pro_stop_test_hdl(struct oid_par_priv *poid_par_priv);
82 uint oid_rt_pro_set_channel_direct_call_hdl(
83 				struct oid_par_priv *poid_par_priv);
84 uint oid_rt_pro_set_antenna_bb_hdl(
85 				struct oid_par_priv *poid_par_priv);
86 uint oid_rt_pro_set_tx_power_control_hdl(
87 				struct oid_par_priv *poid_par_priv);
88 /* oid_rtl_seg_81_80_20 */
89 uint oid_rt_pro_query_tx_packet_sent_hdl(
90 				struct oid_par_priv *poid_par_priv);
91 uint oid_rt_pro_query_rx_packet_received_hdl(
92 				struct oid_par_priv *poid_par_priv);
93 uint oid_rt_pro_query_rx_packet_crc32_error_hdl(
94 				struct oid_par_priv *poid_par_priv);
95 uint oid_rt_pro_reset_tx_packet_sent_hdl(
96 				struct oid_par_priv *poid_par_priv);
97 uint oid_rt_pro_reset_rx_packet_received_hdl(
98 				struct oid_par_priv *poid_par_priv);
99 uint oid_rt_pro_set_modulation_hdl(struct oid_par_priv *poid_par_priv);
100 uint oid_rt_pro_set_continuous_tx_hdl(
101 				struct oid_par_priv *poid_par_priv);
102 uint oid_rt_pro_set_single_carrier_tx_hdl(
103 				struct oid_par_priv *poid_par_priv);
104 uint oid_rt_pro_set_carrier_suppression_tx_hdl(
105 				struct oid_par_priv *poid_par_priv);
106 uint oid_rt_pro_set_single_tone_tx_hdl(
107 				struct oid_par_priv *poid_par_priv);
108 /* oid_rtl_seg_81_87 */
109 uint oid_rt_pro_write_bb_reg_hdl(struct oid_par_priv *poid_par_priv);
110 uint oid_rt_pro_read_bb_reg_hdl(struct oid_par_priv *poid_par_priv);
111 uint oid_rt_pro_write_rf_reg_hdl(struct oid_par_priv *poid_par_priv);
112 uint oid_rt_pro_read_rf_reg_hdl(struct oid_par_priv *poid_par_priv);
113 /* oid_rtl_seg_81_85 */
114 uint oid_rt_wireless_mode_hdl(struct oid_par_priv *poid_par_priv);
115 uint oid_rt_pro_read_efuse_hdl(struct oid_par_priv *poid_par_priv);
116 uint oid_rt_pro_write_efuse_hdl(struct oid_par_priv *poid_par_priv);
117 uint oid_rt_get_efuse_current_size_hdl(
118 				struct oid_par_priv *poid_par_priv);
119 uint oid_rt_pro_efuse_hdl(struct oid_par_priv *poid_par_priv);
120 uint oid_rt_pro_efuse_map_hdl(struct oid_par_priv *poid_par_priv);
121 uint oid_rt_set_bandwidth_hdl(struct oid_par_priv *poid_par_priv);
122 uint oid_rt_set_rx_packet_type_hdl(struct oid_par_priv *poid_par_priv);
123 uint oid_rt_get_efuse_max_size_hdl(struct oid_par_priv *poid_par_priv);
124 uint oid_rt_get_thermal_meter_hdl(
125 				struct oid_par_priv *poid_par_priv);
126 uint oid_rt_reset_phy_rx_packet_count_hdl(
127 				struct oid_par_priv *poid_par_priv);
128 uint oid_rt_get_phy_rx_packet_received_hdl(
129 				struct oid_par_priv *poid_par_priv);
130 uint oid_rt_get_phy_rx_packet_crc32_error_hdl(
131 				struct oid_par_priv *poid_par_priv);
132 uint oid_rt_set_power_down_hdl(
133 				struct oid_par_priv *poid_par_priv);
134 uint oid_rt_get_power_mode_hdl(
135 				struct oid_par_priv *poid_par_priv);
136 #ifdef _RTL871X_MP_IOCTL_C_ /* CAUTION!!! */
137 /* This ifdef _MUST_ be left in!! */
138 
139 #else /* _RTL871X_MP_IOCTL_C_ */
140 extern struct oid_obj_priv oid_rtl_seg_81_87[5];
141 extern struct oid_obj_priv oid_rtl_seg_87_11_00[32];
142 extern struct oid_obj_priv oid_rtl_seg_87_11_20[5];
143 extern struct oid_obj_priv oid_rtl_seg_87_11_50[2];
144 extern struct oid_obj_priv oid_rtl_seg_87_11_80[1];
145 extern struct oid_obj_priv oid_rtl_seg_87_11_B0[1];
146 extern struct oid_obj_priv oid_rtl_seg_87_11_F0[16];
147 extern struct oid_obj_priv oid_rtl_seg_87_12_00[32];
148 
149 #endif /* _RTL871X_MP_IOCTL_C_ */
150 
151 enum MP_MODE {
152 	MP_START_MODE,
153 	MP_STOP_MODE,
154 	MP_ERR_MODE
155 };
156 
157 struct rwreg_param {
158 	unsigned int offset;
159 	unsigned int width;
160 	unsigned int value;
161 };
162 
163 struct bbreg_param {
164 	unsigned int offset;
165 	unsigned int phymask;
166 	unsigned int value;
167 };
168 
169 struct txpower_param {
170 	unsigned int pwr_index;
171 };
172 
173 struct datarate_param {
174 	unsigned int rate_index;
175 };
176 
177 struct rfintfs_parm {
178 	unsigned int rfintfs;
179 };
180 
181 struct mp_xmit_packet {
182 	unsigned int len;
183 };
184 
185 struct psmode_param {
186 	unsigned int ps_mode;
187 	unsigned int smart_ps;
188 };
189 
190 struct mp_ioctl_handler {
191 	unsigned int paramsize;
192 	unsigned int (*handler)(struct oid_par_priv *poid_par_priv);
193 	unsigned int oid;
194 };
195 
196 struct mp_ioctl_param {
197 	unsigned int subcode;
198 	unsigned int len;
199 	unsigned char data[];
200 };
201 
202 #define GEN_MP_IOCTL_SUBCODE(code) _MP_IOCTL_ ## code ## _CMD_
203 
204 enum RTL871X_MP_IOCTL_SUBCODE {
205 	GEN_MP_IOCTL_SUBCODE(MP_START),			/*0*/
206 	GEN_MP_IOCTL_SUBCODE(MP_STOP),			/*1*/
207 	GEN_MP_IOCTL_SUBCODE(READ_REG),			/*2*/
208 	GEN_MP_IOCTL_SUBCODE(WRITE_REG),
209 	GEN_MP_IOCTL_SUBCODE(SET_CHANNEL),		/*4*/
210 	GEN_MP_IOCTL_SUBCODE(SET_TXPOWER),		/*5*/
211 	GEN_MP_IOCTL_SUBCODE(SET_DATARATE),		/*6*/
212 	GEN_MP_IOCTL_SUBCODE(READ_BB_REG),		/*7*/
213 	GEN_MP_IOCTL_SUBCODE(WRITE_BB_REG),
214 	GEN_MP_IOCTL_SUBCODE(READ_RF_REG),		/*9*/
215 	GEN_MP_IOCTL_SUBCODE(WRITE_RF_REG),
216 	GEN_MP_IOCTL_SUBCODE(SET_RF_INTFS),
217 	GEN_MP_IOCTL_SUBCODE(IOCTL_XMIT_PACKET),	/*12*/
218 	GEN_MP_IOCTL_SUBCODE(PS_STATE),			/*13*/
219 	GEN_MP_IOCTL_SUBCODE(READ16_EEPROM),		/*14*/
220 	GEN_MP_IOCTL_SUBCODE(WRITE16_EEPROM),		/*15*/
221 	GEN_MP_IOCTL_SUBCODE(SET_PTM),			/*16*/
222 	GEN_MP_IOCTL_SUBCODE(READ_TSSI),		/*17*/
223 	GEN_MP_IOCTL_SUBCODE(CNTU_TX),			/*18*/
224 	GEN_MP_IOCTL_SUBCODE(SET_BANDWIDTH),		/*19*/
225 	GEN_MP_IOCTL_SUBCODE(SET_RX_PKT_TYPE),		/*20*/
226 	GEN_MP_IOCTL_SUBCODE(RESET_PHY_RX_PKT_CNT),	/*21*/
227 	GEN_MP_IOCTL_SUBCODE(GET_PHY_RX_PKT_RECV),	/*22*/
228 	GEN_MP_IOCTL_SUBCODE(GET_PHY_RX_PKT_ERROR),	/*23*/
229 	GEN_MP_IOCTL_SUBCODE(SET_POWER_DOWN),		/*24*/
230 	GEN_MP_IOCTL_SUBCODE(GET_THERMAL_METER),	/*25*/
231 	GEN_MP_IOCTL_SUBCODE(GET_POWER_MODE),		/*26*/
232 	GEN_MP_IOCTL_SUBCODE(EFUSE),			/*27*/
233 	GEN_MP_IOCTL_SUBCODE(EFUSE_MAP),		/*28*/
234 	GEN_MP_IOCTL_SUBCODE(GET_EFUSE_MAX_SIZE),	/*29*/
235 	GEN_MP_IOCTL_SUBCODE(GET_EFUSE_CURRENT_SIZE),	/*30*/
236 	GEN_MP_IOCTL_SUBCODE(SC_TX),			/*31*/
237 	GEN_MP_IOCTL_SUBCODE(CS_TX),			/*32*/
238 	GEN_MP_IOCTL_SUBCODE(ST_TX),			/*33*/
239 	GEN_MP_IOCTL_SUBCODE(SET_ANTENNA),		/*34*/
240 	MAX_MP_IOCTL_SUBCODE,
241 };
242 
243 unsigned int mp_ioctl_xmit_packet_hdl(struct oid_par_priv *poid_par_priv);
244 
245 #ifdef _RTL871X_MP_IOCTL_C_ /* CAUTION!!! */
246 /* This ifdef _MUST_ be left in!! */
247 
248 static struct mp_ioctl_handler mp_ioctl_hdl[] = {
249 	{sizeof(u32), oid_rt_pro_start_test_hdl,
250 			     OID_RT_PRO_START_TEST},/*0*/
251 	{sizeof(u32), oid_rt_pro_stop_test_hdl,
252 			     OID_RT_PRO_STOP_TEST},/*1*/
253 	{sizeof(struct rwreg_param),
254 			     oid_rt_pro_read_register_hdl,
255 			     OID_RT_PRO_READ_REGISTER},/*2*/
256 	{sizeof(struct rwreg_param),
257 			     oid_rt_pro_write_register_hdl,
258 			     OID_RT_PRO_WRITE_REGISTER},
259 	{sizeof(u32),
260 			     oid_rt_pro_set_channel_direct_call_hdl,
261 			     OID_RT_PRO_SET_CHANNEL_DIRECT_CALL},
262 	{sizeof(struct txpower_param),
263 			     oid_rt_pro_set_tx_power_control_hdl,
264 			     OID_RT_PRO_SET_TX_POWER_CONTROL},
265 	{sizeof(u32),
266 			     oid_rt_pro_set_data_rate_hdl,
267 			     OID_RT_PRO_SET_DATA_RATE},
268 	{sizeof(struct bb_reg_param),
269 			     oid_rt_pro_read_bb_reg_hdl,
270 			     OID_RT_PRO_READ_BB_REG},/*7*/
271 	{sizeof(struct bb_reg_param),
272 			     oid_rt_pro_write_bb_reg_hdl,
273 			     OID_RT_PRO_WRITE_BB_REG},
274 	{sizeof(struct rwreg_param),
275 			     oid_rt_pro_read_rf_reg_hdl,
276 			     OID_RT_PRO_RF_READ_REGISTRY},/*9*/
277 	{sizeof(struct rwreg_param),
278 			     oid_rt_pro_write_rf_reg_hdl,
279 			     OID_RT_PRO_RF_WRITE_REGISTRY},
280 	{sizeof(struct rfintfs_parm), NULL, 0},
281 	{0, mp_ioctl_xmit_packet_hdl, 0},/*12*/
282 	{sizeof(struct psmode_param), NULL, 0},/*13*/
283 	{sizeof(struct eeprom_rw_param), NULL, 0},/*14*/
284 	{sizeof(struct eeprom_rw_param), NULL, 0},/*15*/
285 	{sizeof(unsigned char), NULL, 0},/*16*/
286 	{sizeof(u32), NULL, 0},/*17*/
287 	{sizeof(u32), oid_rt_pro_set_continuous_tx_hdl,
288 			     OID_RT_PRO_SET_CONTINUOUS_TX},/*18*/
289 	{sizeof(u32), oid_rt_set_bandwidth_hdl,
290 			     OID_RT_SET_BANDWIDTH},/*19*/
291 	{sizeof(u32), oid_rt_set_rx_packet_type_hdl,
292 			     OID_RT_SET_RX_PACKET_TYPE},/*20*/
293 	{0, oid_rt_reset_phy_rx_packet_count_hdl,
294 			     OID_RT_RESET_PHY_RX_PACKET_COUNT},/*21*/
295 	{sizeof(u32), oid_rt_get_phy_rx_packet_received_hdl,
296 			     OID_RT_GET_PHY_RX_PACKET_RECEIVED},/*22*/
297 	{sizeof(u32), oid_rt_get_phy_rx_packet_crc32_error_hdl,
298 			     OID_RT_GET_PHY_RX_PACKET_CRC32_ERROR},/*23*/
299 	{sizeof(unsigned char), oid_rt_set_power_down_hdl,
300 			     OID_RT_SET_POWER_DOWN},/*24*/
301 	{sizeof(u32), oid_rt_get_thermal_meter_hdl,
302 			     OID_RT_PRO_GET_THERMAL_METER},/*25*/
303 	{sizeof(u32), oid_rt_get_power_mode_hdl,
304 			     OID_RT_GET_POWER_MODE},/*26*/
305 	{sizeof(struct EFUSE_ACCESS_STRUCT),
306 			     oid_rt_pro_efuse_hdl, OID_RT_PRO_EFUSE},/*27*/
307 	{EFUSE_MAP_MAX_SIZE, oid_rt_pro_efuse_map_hdl,
308 			     OID_RT_PRO_EFUSE_MAP},/*28*/
309 	{sizeof(u32), oid_rt_get_efuse_max_size_hdl,
310 			     OID_RT_GET_EFUSE_MAX_SIZE},/*29*/
311 	{sizeof(u32), oid_rt_get_efuse_current_size_hdl,
312 			     OID_RT_GET_EFUSE_CURRENT_SIZE},/*30*/
313 	{sizeof(u32), oid_rt_pro_set_single_carrier_tx_hdl,
314 			     OID_RT_PRO_SET_SINGLE_CARRIER_TX},/*31*/
315 	{sizeof(u32), oid_rt_pro_set_carrier_suppression_tx_hdl,
316 			     OID_RT_PRO_SET_CARRIER_SUPPRESSION_TX},/*32*/
317 	{sizeof(u32), oid_rt_pro_set_single_tone_tx_hdl,
318 			     OID_RT_PRO_SET_SINGLE_TONE_TX},/*33*/
319 	{sizeof(u32), oid_rt_pro_set_antenna_bb_hdl,
320 			     OID_RT_PRO_SET_ANTENNA_BB},/*34*/
321 };
322 
323 #else /* _RTL871X_MP_IOCTL_C_ */
324 extern struct mp_ioctl_handler mp_ioctl_hdl[];
325 #endif /* _RTL871X_MP_IOCTL_C_ */
326 
327 #endif
328 
329