Merge tag 'staging-4.21-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh...
[sfrench/cifs-2.6.git] / drivers / staging / rtlwifi / phydm / phydm_hwconfig.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /******************************************************************************
3  *
4  * Copyright(c) 2007 - 2016  Realtek Corporation.
5  *
6  * Contact Information:
7  * wlanfae <wlanfae@realtek.com>
8  * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
9  * Hsinchu 300, Taiwan.
10  *
11  * Larry Finger <Larry.Finger@lwfinger.net>
12  *
13  *****************************************************************************/
14
15 #ifndef __HALHWOUTSRC_H__
16 #define __HALHWOUTSRC_H__
17
18 /*--------------------------Define -------------------------------------------*/
19 #define CCK_RSSI_INIT_COUNT 5
20
21 #define RA_RSSI_STATE_INIT 0
22 #define RA_RSSI_STATE_SEND 1
23 #define RA_RSSI_STATE_HOLD 2
24
25 #define CFO_HW_RPT_2_MHZ(val) ((val << 1) + (val >> 1))
26 /* ((X* 3125)  / 10)>>7 = (X*10)>>2 = X*2.5 = X<<1 + X>>1  */
27
28 #define AGC_DIFF_CONFIG_MP(ic, band)                                           \
29         (odm_read_and_config_mp_##ic##_agc_tab_diff(                           \
30                 dm, array_mp_##ic##_agc_tab_diff_##band,                       \
31                 sizeof(array_mp_##ic##_agc_tab_diff_##band) / sizeof(u32)))
32 #define AGC_DIFF_CONFIG_TC(ic, band)                                           \
33         (odm_read_and_config_tc_##ic##_agc_tab_diff(                           \
34                 dm, array_tc_##ic##_agc_tab_diff_##band,                       \
35                 sizeof(array_tc_##ic##_agc_tab_diff_##band) / sizeof(u32)))
36
37 #define AGC_DIFF_CONFIG(ic, band)                                              \
38         do {                                                                   \
39                 if (dm->is_mp_chip)                                            \
40                         AGC_DIFF_CONFIG_MP(ic, band);                          \
41                 else                                                           \
42                         AGC_DIFF_CONFIG_TC(ic, band);                          \
43         } while (0)
44
45 /* ************************************************************
46  * structure and define
47  * *************************************************************/
48
49 struct phy_rx_agc_info {
50 #if (ODM_ENDIAN_TYPE == ODM_ENDIAN_LITTLE)
51         u8 gain : 7, trsw : 1;
52 #else
53         u8 trsw : 1, gain : 7;
54 #endif
55 };
56
57 struct phy_status_rpt_8192cd {
58         struct phy_rx_agc_info path_agc[2];
59         u8 ch_corr[2];
60         u8 cck_sig_qual_ofdm_pwdb_all;
61         u8 cck_agc_rpt_ofdm_cfosho_a;
62         u8 cck_rpt_b_ofdm_cfosho_b;
63         u8 rsvd_1; /*ch_corr_msb;*/
64         u8 noise_power_db_msb;
65         s8 path_cfotail[2];
66         u8 pcts_mask[2];
67         s8 stream_rxevm[2];
68         u8 path_rxsnr[2];
69         u8 noise_power_db_lsb;
70         u8 rsvd_2[3];
71         u8 stream_csi[2];
72         u8 stream_target_csi[2];
73         s8 sig_evm;
74         u8 rsvd_3;
75
76 #if (ODM_ENDIAN_TYPE == ODM_ENDIAN_LITTLE)
77         u8 antsel_rx_keep_2 : 1; /*ex_intf_flg:1;*/
78         u8 sgi_en : 1;
79         u8 rxsc : 2;
80         u8 idle_long : 1;
81         u8 r_ant_train_en : 1;
82         u8 ant_sel_b : 1;
83         u8 ant_sel : 1;
84 #else /*_BIG_ENDIAN_    */
85         u8 ant_sel : 1;
86         u8 ant_sel_b : 1;
87         u8 r_ant_train_en : 1;
88         u8 idle_long : 1;
89         u8 rxsc : 2;
90         u8 sgi_en : 1;
91         u8 antsel_rx_keep_2 : 1; /*ex_intf_flg:1;*/
92 #endif
93 };
94
95 struct phy_status_rpt_8812 {
96         /*      DWORD 0*/
97         u8 gain_trsw[2]; /*path-A and path-B {TRSW, gain[6:0] }*/
98         u8 chl_num_LSB; /*channel number[7:0]*/
99 #if (ODM_ENDIAN_TYPE == ODM_ENDIAN_LITTLE)
100         u8 chl_num_MSB : 2; /*channel number[9:8]*/
101         u8 sub_chnl : 4; /*sub-channel location[3:0]*/
102         u8 r_RFMOD : 2; /*RF mode[1:0]*/
103 #else /*_BIG_ENDIAN_    */
104         u8 r_RFMOD : 2;
105         u8 sub_chnl : 4;
106         u8 chl_num_MSB : 2;
107 #endif
108
109         /*      DWORD 1*/
110         u8 pwdb_all; /*CCK signal quality / OFDM pwdb all*/
111         s8 cfosho[2]; /*DW1 byte 1 DW1 byte2 */
112 /*CCK AGC report and CCK_BB_Power / OFDM path-A and path-B short CFO*/
113 #if (ODM_ENDIAN_TYPE == ODM_ENDIAN_LITTLE)
114         /*this should be checked again
115          *because the definition of 8812 and 8814 is different
116          */
117         u8 resvd_0 : 6;
118         u8 bt_RF_ch_MSB : 2; /*8812A:2'b0, 8814A: bt rf channel keep[7:6]*/
119 #else /*_BIG_ENDIAN_*/
120         u8 bt_RF_ch_MSB : 2;
121         u8 resvd_0 : 6;
122 #endif
123
124 /*      DWORD 2*/
125 #if (ODM_ENDIAN_TYPE == ODM_ENDIAN_LITTLE)
126         u8 ant_div_sw_a : 1; /*8812A: ant_div_sw_a, 8814A: 1'b0*/
127         u8 ant_div_sw_b : 1; /*8812A: ant_div_sw_b, 8814A: 1'b0*/
128         u8 bt_RF_ch_LSB : 6; /*8812A: 6'b0, 8814A: bt rf channel keep[5:0]*/
129 #else /*_BIG_ENDIAN_    */
130         u8 bt_RF_ch_LSB : 6;
131         u8 ant_div_sw_b : 1;
132         u8 ant_div_sw_a : 1;
133 #endif
134         s8 cfotail[2]; /*DW2 byte 1 DW2 byte 2  path-A and path-B CFO tail*/
135         u8 PCTS_MSK_RPT_0; /*PCTS mask report[7:0]*/
136         u8 PCTS_MSK_RPT_1; /*PCTS mask report[15:8]*/
137
138         /*      DWORD 3*/
139         s8 rxevm[2]; /*DW3 byte 1 DW3 byte 2    stream 1 and stream 2 RX EVM*/
140         s8 rxsnr[2]; /*DW3 byte 3 DW4 byte 0    path-A and path-B RX SNR*/
141
142         /*      DWORD 4*/
143         u8 PCTS_MSK_RPT_2; /*PCTS mask report[23:16]*/
144 #if (ODM_ENDIAN_TYPE == ODM_ENDIAN_LITTLE)
145         u8 PCTS_MSK_RPT_3 : 6; /*PCTS mask report[29:24]*/
146         u8 pcts_rpt_valid : 1; /*pcts_rpt_valid*/
147         u8 resvd_1 : 1; /*1'b0*/
148 #else /*_BIG_ENDIAN_*/
149         u8 resvd_1 : 1;
150         u8 pcts_rpt_valid : 1;
151         u8 PCTS_MSK_RPT_3 : 6;
152 #endif
153         s8 rxevm_cd[2]; /*DW 4 byte 3 DW5 byte 0 */
154         /* 8812A: 16'b0, 8814A: stream 3 and stream 4 RX EVM*/
155
156         /*      DWORD 5*/
157         u8 csi_current[2]; /*DW5 byte 1 DW5 byte 2 */
158         /* 8812A: stream 1 and 2 CSI, 8814A: path-C and path-D RX SNR*/
159         u8 gain_trsw_cd[2]; /*DW5 byte 3 DW6 byte 0 */
160         /* path-C and path-D {TRSW, gain[6:0] }*/
161
162         /*      DWORD 6*/
163         s8 sigevm; /*signal field EVM*/
164 #if (ODM_ENDIAN_TYPE == ODM_ENDIAN_LITTLE)
165         u8 antidx_antc : 3; /*8812A: 3'b0       8814A: antidx_antc[2:0]*/
166         u8 antidx_antd : 3; /*8812A: 3'b0       8814A: antidx_antd[2:0]*/
167         u8 dpdt_ctrl_keep : 1; /*8812A: 1'b0    8814A: dpdt_ctrl_keep*/
168         u8 GNT_BT_keep : 1; /*8812A: 1'b0       8814A: GNT_BT_keep*/
169 #else /*_BIG_ENDIAN_*/
170         u8 GNT_BT_keep : 1;
171         u8 dpdt_ctrl_keep : 1;
172         u8 antidx_antd : 3;
173         u8 antidx_antc : 3;
174 #endif
175 #if (ODM_ENDIAN_TYPE == ODM_ENDIAN_LITTLE)
176         u8 antidx_anta : 3; /*antidx_anta[2:0]*/
177         u8 antidx_antb : 3; /*antidx_antb[2:0]*/
178         u8 hw_antsw_occur : 2; /*1'b0*/
179 #else /*_BIG_ENDIAN_*/
180         u8 hw_antsw_occur : 2;
181         u8 antidx_antb : 3;
182         u8 antidx_anta : 3;
183 #endif
184 };
185
186 void phydm_reset_rssi_for_dm(struct phy_dm_struct *dm, u8 station_id);
187
188 void odm_init_rssi_for_dm(struct phy_dm_struct *dm);
189
190 void odm_phy_status_query(struct phy_dm_struct *dm,
191                           struct dm_phy_status_info *phy_info, u8 *phy_status,
192                           struct dm_per_pkt_info *pktinfo);
193
194 void odm_mac_status_query(struct phy_dm_struct *dm, u8 *mac_status, u8 mac_id,
195                           bool is_packet_match_bssid, bool is_packet_to_self,
196                           bool is_packet_beacon);
197
198 enum hal_status
199 odm_config_rf_with_tx_pwr_track_header_file(struct phy_dm_struct *dm);
200
201 enum hal_status
202 odm_config_rf_with_header_file(struct phy_dm_struct *dm,
203                                enum odm_rf_config_type config_type,
204                                enum odm_rf_radio_path e_rf_path);
205
206 enum hal_status
207 odm_config_bb_with_header_file(struct phy_dm_struct *dm,
208                                enum odm_bb_config_type config_type);
209
210 enum hal_status odm_config_mac_with_header_file(struct phy_dm_struct *dm);
211
212 enum hal_status
213 odm_config_fw_with_header_file(struct phy_dm_struct *dm,
214                                enum odm_fw_config_type config_type,
215                                u8 *p_firmware, u32 *size);
216
217 u32 odm_get_hw_img_version(struct phy_dm_struct *dm);
218
219 /*For 8822B only!! need to move to FW finally */
220 /*==============================================*/
221 void phydm_rx_phy_status_new_type(struct phy_dm_struct *phydm, u8 *phy_status,
222                                   struct dm_per_pkt_info *pktinfo,
223                                   struct dm_phy_status_info *phy_info);
224
225 bool phydm_query_is_mu_api(struct phy_dm_struct *phydm, u8 ppdu_idx,
226                            u8 *p_data_rate, u8 *p_gid);
227
228 struct phy_status_rpt_jaguar2_type0 {
229         /* DW0 */
230         u8 page_num;
231         u8 pwdb;
232 #if (ODM_ENDIAN_TYPE == ODM_ENDIAN_LITTLE)
233         u8 gain : 6;
234         u8 rsvd_0 : 1;
235         u8 trsw : 1;
236 #else
237         u8 trsw : 1;
238         u8 rsvd_0 : 1;
239         u8 gain : 6;
240 #endif
241         u8 rsvd_1;
242
243         /* DW1 */
244         u8 rsvd_2;
245 #if (ODM_ENDIAN_TYPE == ODM_ENDIAN_LITTLE)
246         u8 rxsc : 4;
247         u8 agc_table : 4;
248 #else
249         u8 agc_table : 4;
250         u8 rxsc : 4;
251 #endif
252         u8 channel;
253         u8 band;
254
255         /* DW2 */
256         u16 length;
257 #if (ODM_ENDIAN_TYPE == ODM_ENDIAN_LITTLE)
258         u8 antidx_a : 3;
259         u8 antidx_b : 3;
260         u8 rsvd_3 : 2;
261         u8 antidx_c : 3;
262         u8 antidx_d : 3;
263         u8 rsvd_4 : 2;
264 #else
265         u8 rsvd_3 : 2;
266         u8 antidx_b : 3;
267         u8 antidx_a : 3;
268         u8 rsvd_4 : 2;
269         u8 antidx_d : 3;
270         u8 antidx_c : 3;
271 #endif
272
273         /* DW3 */
274         u8 signal_quality;
275 #if (ODM_ENDIAN_TYPE == ODM_ENDIAN_LITTLE)
276         u8 vga : 5;
277         u8 lna_l : 3;
278         u8 bb_power : 6;
279         u8 rsvd_9 : 1;
280         u8 lna_h : 1;
281 #else
282         u8 lna_l : 3;
283         u8 vga : 5;
284         u8 lna_h : 1;
285         u8 rsvd_9 : 1;
286         u8 bb_power : 6;
287 #endif
288         u8 rsvd_5;
289
290         /* DW4 */
291         u32 rsvd_6;
292
293         /* DW5 */
294         u32 rsvd_7;
295
296         /* DW6 */
297         u32 rsvd_8;
298 };
299
300 struct phy_status_rpt_jaguar2_type1 {
301         /* DW0 and DW1 */
302         u8 page_num;
303         u8 pwdb[4];
304 #if (ODM_ENDIAN_TYPE == ODM_ENDIAN_LITTLE)
305         u8 l_rxsc : 4;
306         u8 ht_rxsc : 4;
307 #else
308         u8 ht_rxsc : 4;
309         u8 l_rxsc : 4;
310 #endif
311         u8 channel;
312 #if (ODM_ENDIAN_TYPE == ODM_ENDIAN_LITTLE)
313         u8 band : 2;
314         u8 rsvd_0 : 1;
315         u8 hw_antsw_occu : 1;
316         u8 gnt_bt : 1;
317         u8 ldpc : 1;
318         u8 stbc : 1;
319         u8 beamformed : 1;
320 #else
321         u8 beamformed : 1;
322         u8 stbc : 1;
323         u8 ldpc : 1;
324         u8 gnt_bt : 1;
325         u8 hw_antsw_occu : 1;
326         u8 rsvd_0 : 1;
327         u8 band : 2;
328 #endif
329
330         /* DW2 */
331         u16 lsig_length;
332 #if (ODM_ENDIAN_TYPE == ODM_ENDIAN_LITTLE)
333         u8 antidx_a : 3;
334         u8 antidx_b : 3;
335         u8 rsvd_1 : 2;
336         u8 antidx_c : 3;
337         u8 antidx_d : 3;
338         u8 rsvd_2 : 2;
339 #else
340         u8 rsvd_1 : 2;
341         u8 antidx_b : 3;
342         u8 antidx_a : 3;
343         u8 rsvd_2 : 2;
344         u8 antidx_d : 3;
345         u8 antidx_c : 3;
346 #endif
347
348         /* DW3 */
349         u8 paid;
350 #if (ODM_ENDIAN_TYPE == ODM_ENDIAN_LITTLE)
351         u8 paid_msb : 1;
352         u8 gid : 6;
353         u8 rsvd_3 : 1;
354 #else
355         u8 rsvd_3 : 1;
356         u8 gid : 6;
357         u8 paid_msb : 1;
358 #endif
359         u8 intf_pos;
360 #if (ODM_ENDIAN_TYPE == ODM_ENDIAN_LITTLE)
361         u8 intf_pos_msb : 1;
362         u8 rsvd_4 : 2;
363         u8 nb_intf_flag : 1;
364         u8 rf_mode : 2;
365         u8 rsvd_5 : 2;
366 #else
367         u8 rsvd_5 : 2;
368         u8 rf_mode : 2;
369         u8 nb_intf_flag : 1;
370         u8 rsvd_4 : 2;
371         u8 intf_pos_msb : 1;
372 #endif
373
374         /* DW4 */
375         s8 rxevm[4]; /* s(8,1) */
376
377         /* DW5 */
378         s8 cfo_tail[4]; /* s(8,7) */
379
380         /* DW6 */
381         s8 rxsnr[4]; /* s(8,1) */
382 };
383
384 struct phy_status_rpt_jaguar2_type2 {
385         /* DW0 ane DW1 */
386         u8 page_num;
387         u8 pwdb[4];
388 #if (ODM_ENDIAN_TYPE == ODM_ENDIAN_LITTLE)
389         u8 l_rxsc : 4;
390         u8 ht_rxsc : 4;
391 #else
392         u8 ht_rxsc : 4;
393         u8 l_rxsc : 4;
394 #endif
395         u8 channel;
396 #if (ODM_ENDIAN_TYPE == ODM_ENDIAN_LITTLE)
397         u8 band : 2;
398         u8 rsvd_0 : 1;
399         u8 hw_antsw_occu : 1;
400         u8 gnt_bt : 1;
401         u8 ldpc : 1;
402         u8 stbc : 1;
403         u8 beamformed : 1;
404 #else
405         u8 beamformed : 1;
406         u8 stbc : 1;
407         u8 ldpc : 1;
408         u8 gnt_bt : 1;
409         u8 hw_antsw_occu : 1;
410         u8 rsvd_0 : 1;
411         u8 band : 2;
412 #endif
413
414 /* DW2 */
415 #if (ODM_ENDIAN_TYPE == ODM_ENDIAN_LITTLE)
416         u8 shift_l_map : 6;
417         u8 rsvd_1 : 2;
418 #else
419         u8 rsvd_1 : 2;
420         u8 shift_l_map : 6;
421 #endif
422         u8 cnt_pw2cca;
423 #if (ODM_ENDIAN_TYPE == ODM_ENDIAN_LITTLE)
424         u8 agc_table_a : 4;
425         u8 agc_table_b : 4;
426         u8 agc_table_c : 4;
427         u8 agc_table_d : 4;
428 #else
429         u8 agc_table_b : 4;
430         u8 agc_table_a : 4;
431         u8 agc_table_d : 4;
432         u8 agc_table_c : 4;
433 #endif
434
435         /* DW3 ~ DW6*/
436         u8 cnt_cca2agc_rdy;
437 #if (ODM_ENDIAN_TYPE == ODM_ENDIAN_LITTLE)
438         u8 gain_a : 6;
439         u8 rsvd_2 : 1;
440         u8 trsw_a : 1;
441         u8 gain_b : 6;
442         u8 rsvd_3 : 1;
443         u8 trsw_b : 1;
444         u8 gain_c : 6;
445         u8 rsvd_4 : 1;
446         u8 trsw_c : 1;
447         u8 gain_d : 6;
448         u8 rsvd_5 : 1;
449         u8 trsw_d : 1;
450         u8 aagc_step_a : 2;
451         u8 aagc_step_b : 2;
452         u8 aagc_step_c : 2;
453         u8 aagc_step_d : 2;
454 #else
455         u8 trsw_a : 1;
456         u8 rsvd_2 : 1;
457         u8 gain_a : 6;
458         u8 trsw_b : 1;
459         u8 rsvd_3 : 1;
460         u8 gain_b : 6;
461         u8 trsw_c : 1;
462         u8 rsvd_4 : 1;
463         u8 gain_c : 6;
464         u8 trsw_d : 1;
465         u8 rsvd_5 : 1;
466         u8 gain_d : 6;
467         u8 aagc_step_d : 2;
468         u8 aagc_step_c : 2;
469         u8 aagc_step_b : 2;
470         u8 aagc_step_a : 2;
471 #endif
472         u8 ht_aagc_gain[4];
473         u8 dagc_gain[4];
474 #if (ODM_ENDIAN_TYPE == ODM_ENDIAN_LITTLE)
475         u8 counter : 6;
476         u8 rsvd_6 : 2;
477         u8 syn_count : 5;
478         u8 rsvd_7 : 3;
479 #else
480         u8 rsvd_6 : 2;
481         u8 counter : 6;
482         u8 rsvd_7 : 3;
483         u8 syn_count : 5;
484 #endif
485 };
486
487 #endif /*#ifndef        __HALHWOUTSRC_H__*/