Merge tag 'xtensa-20210902' of git://github.com/jcmvbkbc/linux-xtensa
[linux-2.6-microblaze.git] / drivers / staging / rtl8712 / rtl871x_mp_ioctl.h
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
152 enum MP_MODE {
153         MP_START_MODE,
154         MP_STOP_MODE,
155         MP_ERR_MODE
156 };
157
158 struct rwreg_param {
159         unsigned int offset;
160         unsigned int width;
161         unsigned int value;
162 };
163
164 struct bbreg_param {
165         unsigned int offset;
166         unsigned int phymask;
167         unsigned int value;
168 };
169
170 struct txpower_param {
171         unsigned int pwr_index;
172 };
173
174 struct datarate_param {
175         unsigned int rate_index;
176 };
177
178 struct rfintfs_parm {
179         unsigned int rfintfs;
180 };
181
182 struct mp_xmit_packet {
183         unsigned int len;
184 };
185
186 struct psmode_param {
187         unsigned int ps_mode;
188         unsigned int smart_ps;
189 };
190
191 struct mp_ioctl_handler {
192         unsigned int paramsize;
193         unsigned int (*handler)(struct oid_par_priv *poid_par_priv);
194         unsigned int oid;
195 };
196
197 struct mp_ioctl_param {
198         unsigned int subcode;
199         unsigned int len;
200         unsigned char data[];
201 };
202
203 #define GEN_MP_IOCTL_SUBCODE(code) _MP_IOCTL_ ## code ## _CMD_
204
205 enum RTL871X_MP_IOCTL_SUBCODE {
206         GEN_MP_IOCTL_SUBCODE(MP_START),                 /*0*/
207         GEN_MP_IOCTL_SUBCODE(MP_STOP),                  /*1*/
208         GEN_MP_IOCTL_SUBCODE(READ_REG),                 /*2*/
209         GEN_MP_IOCTL_SUBCODE(WRITE_REG),
210         GEN_MP_IOCTL_SUBCODE(SET_CHANNEL),              /*4*/
211         GEN_MP_IOCTL_SUBCODE(SET_TXPOWER),              /*5*/
212         GEN_MP_IOCTL_SUBCODE(SET_DATARATE),             /*6*/
213         GEN_MP_IOCTL_SUBCODE(READ_BB_REG),              /*7*/
214         GEN_MP_IOCTL_SUBCODE(WRITE_BB_REG),
215         GEN_MP_IOCTL_SUBCODE(READ_RF_REG),              /*9*/
216         GEN_MP_IOCTL_SUBCODE(WRITE_RF_REG),
217         GEN_MP_IOCTL_SUBCODE(SET_RF_INTFS),
218         GEN_MP_IOCTL_SUBCODE(IOCTL_XMIT_PACKET),        /*12*/
219         GEN_MP_IOCTL_SUBCODE(PS_STATE),                 /*13*/
220         GEN_MP_IOCTL_SUBCODE(READ16_EEPROM),            /*14*/
221         GEN_MP_IOCTL_SUBCODE(WRITE16_EEPROM),           /*15*/
222         GEN_MP_IOCTL_SUBCODE(SET_PTM),                  /*16*/
223         GEN_MP_IOCTL_SUBCODE(READ_TSSI),                /*17*/
224         GEN_MP_IOCTL_SUBCODE(CNTU_TX),                  /*18*/
225         GEN_MP_IOCTL_SUBCODE(SET_BANDWIDTH),            /*19*/
226         GEN_MP_IOCTL_SUBCODE(SET_RX_PKT_TYPE),          /*20*/
227         GEN_MP_IOCTL_SUBCODE(RESET_PHY_RX_PKT_CNT),     /*21*/
228         GEN_MP_IOCTL_SUBCODE(GET_PHY_RX_PKT_RECV),      /*22*/
229         GEN_MP_IOCTL_SUBCODE(GET_PHY_RX_PKT_ERROR),     /*23*/
230         GEN_MP_IOCTL_SUBCODE(SET_POWER_DOWN),           /*24*/
231         GEN_MP_IOCTL_SUBCODE(GET_THERMAL_METER),        /*25*/
232         GEN_MP_IOCTL_SUBCODE(GET_POWER_MODE),           /*26*/
233         GEN_MP_IOCTL_SUBCODE(EFUSE),                    /*27*/
234         GEN_MP_IOCTL_SUBCODE(EFUSE_MAP),                /*28*/
235         GEN_MP_IOCTL_SUBCODE(GET_EFUSE_MAX_SIZE),       /*29*/
236         GEN_MP_IOCTL_SUBCODE(GET_EFUSE_CURRENT_SIZE),   /*30*/
237         GEN_MP_IOCTL_SUBCODE(SC_TX),                    /*31*/
238         GEN_MP_IOCTL_SUBCODE(CS_TX),                    /*32*/
239         GEN_MP_IOCTL_SUBCODE(ST_TX),                    /*33*/
240         GEN_MP_IOCTL_SUBCODE(SET_ANTENNA),              /*34*/
241         MAX_MP_IOCTL_SUBCODE,
242 };
243
244 unsigned int mp_ioctl_xmit_packet_hdl(struct oid_par_priv *poid_par_priv);
245
246 #ifdef _RTL871X_MP_IOCTL_C_ /* CAUTION!!! */
247 /* This ifdef _MUST_ be left in!! */
248
249 static struct mp_ioctl_handler mp_ioctl_hdl[] = {
250         {sizeof(u32), oid_rt_pro_start_test_hdl,
251                              OID_RT_PRO_START_TEST},/*0*/
252         {sizeof(u32), oid_rt_pro_stop_test_hdl,
253                              OID_RT_PRO_STOP_TEST},/*1*/
254         {sizeof(struct rwreg_param),
255                              oid_rt_pro_read_register_hdl,
256                              OID_RT_PRO_READ_REGISTER},/*2*/
257         {sizeof(struct rwreg_param),
258                              oid_rt_pro_write_register_hdl,
259                              OID_RT_PRO_WRITE_REGISTER},
260         {sizeof(u32),
261                              oid_rt_pro_set_channel_direct_call_hdl,
262                              OID_RT_PRO_SET_CHANNEL_DIRECT_CALL},
263         {sizeof(struct txpower_param),
264                              oid_rt_pro_set_tx_power_control_hdl,
265                              OID_RT_PRO_SET_TX_POWER_CONTROL},
266         {sizeof(u32),
267                              oid_rt_pro_set_data_rate_hdl,
268                              OID_RT_PRO_SET_DATA_RATE},
269         {sizeof(struct bb_reg_param),
270                              oid_rt_pro_read_bb_reg_hdl,
271                              OID_RT_PRO_READ_BB_REG},/*7*/
272         {sizeof(struct bb_reg_param),
273                              oid_rt_pro_write_bb_reg_hdl,
274                              OID_RT_PRO_WRITE_BB_REG},
275         {sizeof(struct rwreg_param),
276                              oid_rt_pro_read_rf_reg_hdl,
277                              OID_RT_PRO_RF_READ_REGISTRY},/*9*/
278         {sizeof(struct rwreg_param),
279                              oid_rt_pro_write_rf_reg_hdl,
280                              OID_RT_PRO_RF_WRITE_REGISTRY},
281         {sizeof(struct rfintfs_parm), NULL, 0},
282         {0, mp_ioctl_xmit_packet_hdl, 0},/*12*/
283         {sizeof(struct psmode_param), NULL, 0},/*13*/
284         {sizeof(struct eeprom_rw_param), NULL, 0},/*14*/
285         {sizeof(struct eeprom_rw_param), NULL, 0},/*15*/
286         {sizeof(unsigned char), NULL, 0},/*16*/
287         {sizeof(u32), NULL, 0},/*17*/
288         {sizeof(u32), oid_rt_pro_set_continuous_tx_hdl,
289                              OID_RT_PRO_SET_CONTINUOUS_TX},/*18*/
290         {sizeof(u32), oid_rt_set_bandwidth_hdl,
291                              OID_RT_SET_BANDWIDTH},/*19*/
292         {sizeof(u32), oid_rt_set_rx_packet_type_hdl,
293                              OID_RT_SET_RX_PACKET_TYPE},/*20*/
294         {0, oid_rt_reset_phy_rx_packet_count_hdl,
295                              OID_RT_RESET_PHY_RX_PACKET_COUNT},/*21*/
296         {sizeof(u32), oid_rt_get_phy_rx_packet_received_hdl,
297                              OID_RT_GET_PHY_RX_PACKET_RECEIVED},/*22*/
298         {sizeof(u32), oid_rt_get_phy_rx_packet_crc32_error_hdl,
299                              OID_RT_GET_PHY_RX_PACKET_CRC32_ERROR},/*23*/
300         {sizeof(unsigned char), oid_rt_set_power_down_hdl,
301                              OID_RT_SET_POWER_DOWN},/*24*/
302         {sizeof(u32), oid_rt_get_thermal_meter_hdl,
303                              OID_RT_PRO_GET_THERMAL_METER},/*25*/
304         {sizeof(u32), oid_rt_get_power_mode_hdl,
305                              OID_RT_GET_POWER_MODE},/*26*/
306         {sizeof(struct EFUSE_ACCESS_STRUCT),
307                              oid_rt_pro_efuse_hdl, OID_RT_PRO_EFUSE},/*27*/
308         {EFUSE_MAP_MAX_SIZE, oid_rt_pro_efuse_map_hdl,
309                              OID_RT_PRO_EFUSE_MAP},/*28*/
310         {sizeof(u32), oid_rt_get_efuse_max_size_hdl,
311                              OID_RT_GET_EFUSE_MAX_SIZE},/*29*/
312         {sizeof(u32), oid_rt_get_efuse_current_size_hdl,
313                              OID_RT_GET_EFUSE_CURRENT_SIZE},/*30*/
314         {sizeof(u32), oid_rt_pro_set_single_carrier_tx_hdl,
315                              OID_RT_PRO_SET_SINGLE_CARRIER_TX},/*31*/
316         {sizeof(u32), oid_rt_pro_set_carrier_suppression_tx_hdl,
317                              OID_RT_PRO_SET_CARRIER_SUPPRESSION_TX},/*32*/
318         {sizeof(u32), oid_rt_pro_set_single_tone_tx_hdl,
319                              OID_RT_PRO_SET_SINGLE_TONE_TX},/*33*/
320         {sizeof(u32), oid_rt_pro_set_antenna_bb_hdl,
321                              OID_RT_PRO_SET_ANTENNA_BB},/*34*/
322 };
323
324 #else /* _RTL871X_MP_IOCTL_C_ */
325 extern struct mp_ioctl_handler mp_ioctl_hdl[];
326 #endif /* _RTL871X_MP_IOCTL_C_ */
327
328 #endif
329