• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2  *
3  * Copyright(c) 2007 - 2017  Realtek Corporation.
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  * The full GNU General Public License is included in this distribution in the
15  * file called LICENSE.
16  *
17  * Contact Information:
18  * wlanfae <wlanfae@realtek.com>
19  * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
20  * Hsinchu 300, Taiwan.
21  *
22  * Larry Finger <Larry.Finger@lwfinger.net>
23  *
24  *****************************************************************************/
25 
26 #ifndef __PHYDMPATHDIV_H__
27 #define __PHYDMPATHDIV_H__
28 
29 #ifdef CONFIG_PATH_DIVERSITY
30 /* @2019.03.07 open resp tx path h2c only for 1ss status*/
31 #define PATHDIV_VERSION "4.4"
32 
33 #if (RTL8192F_SUPPORT || RTL8822B_SUPPORT || RTL8822C_SUPPORT ||\
34 	RTL8812F_SUPPORT || RTL8197G_SUPPORT)
35 	#define PHYDM_CONFIG_PATH_DIV_V2
36 #endif
37 
38 #define USE_PATH_A_AS_DEFAULT_ANT /* @for 8814 dynamic TX path selection */
39 
40 #define NUM_RESET_DTP_PERIOD 5
41 #define ANT_DECT_RSSI_TH 3
42 
43 #define PATH_A 1
44 #define PATH_B 2
45 #define PATH_C 3
46 #define PATH_D 4
47 
48 #define PHYDM_AUTO_PATH 0
49 #define PHYDM_FIX_PATH 1
50 
51 #define NUM_CHOOSE2_FROM4 6
52 #define NUM_CHOOSE3_FROM4 4
53 
54 enum phydm_dtp_state {
55 	PHYDM_DTP_INIT = 1,
56 	PHYDM_DTP_RUNNING_1
57 };
58 
59 enum phydm_path_div_type {
60 	PHYDM_2R_PATH_DIV = 1,
61 	PHYDM_4R_PATH_DIV = 2
62 };
63 
64 enum phydm_path_ctrl {
65 	TX_PATH_BY_REG = 0,
66 	TX_PATH_BY_DESC = 1,
67 	TX_PATH_CTRL_INIT
68 };
69 
70 struct path_txdesc_ctrl {
71 	u8 ant_map_a : 2;
72 	u8 ant_map_b : 2;
73 	u8 ntx_map : 4;
74 };
75 
76 struct _ODM_PATH_DIVERSITY_ {
77 	boolean stop_path_div; /*@Limit by enabled path number*/
78 	boolean path_div_in_progress;
79 	boolean	cck_fix_path_en; /*@ BB Reg for Adv-Ctrl (or debug mode)*/
80 	boolean	ofdm_fix_path_en; /*@ BB Reg for Adv-Ctrl (or debug mode)*/
81 	enum bb_path cck_fix_path_sel; /*@ BB Reg for Adv-Ctrl (or debug mode)*/
82 	enum bb_path ofdm_fix_path_sel;/*@ BB Reg for Adv-Ctrl (or debug mode)*/
83 	enum phydm_path_ctrl tx_path_ctrl;
84 	enum bb_path default_tx_path;
85 	enum bb_path path_sel[ODM_ASSOCIATE_ENTRY_NUM];
86 	u32	path_a_sum[ODM_ASSOCIATE_ENTRY_NUM];
87 	u32	path_b_sum[ODM_ASSOCIATE_ENTRY_NUM];
88 	u16	path_a_cnt[ODM_ASSOCIATE_ENTRY_NUM];
89 	u16	path_b_cnt[ODM_ASSOCIATE_ENTRY_NUM];
90 	u8	phydm_path_div_type;
91 	boolean force_update;
92 #if RTL8814A_SUPPORT
93 
94 	u32	path_a_sum_all;
95 	u32	path_b_sum_all;
96 	u32	path_c_sum_all;
97 	u32	path_d_sum_all;
98 
99 	u32	path_a_cnt_all;
100 	u32	path_b_cnt_all;
101 	u32	path_c_cnt_all;
102 	u32	path_d_cnt_all;
103 
104 	u8	dtp_period;
105 	boolean	is_become_linked;
106 	boolean	is_u3_mode;
107 	u8	num_tx_path;
108 	u8	default_path;
109 	u8	num_candidate;
110 	u8	ant_candidate_1;
111 	u8	ant_candidate_2;
112 	u8	ant_candidate_3;
113 	u8     phydm_dtp_state;
114 	u8	dtp_check_patha_counter;
115 	boolean	fix_path_bfer;
116 	u8	search_space_2[NUM_CHOOSE2_FROM4];
117 	u8	search_space_3[NUM_CHOOSE3_FROM4];
118 
119 	u8	pre_tx_path;
120 	u8	use_path_a_as_default_ant;
121 	boolean	is_path_a_exist;
122 
123 #endif
124 };
125 
126 void phydm_set_tx_path_by_bb_reg(void *dm_void, enum bb_path tx_path_sel_1ss);
127 
128 void phydm_get_tx_path_txdesc_jgr3(void *dm_void, u8 macid,
129 				   struct path_txdesc_ctrl *desc);
130 
131 void phydm_c2h_dtp_handler(void *dm_void, u8 *cmd_buf, u8 cmd_len);
132 
133 void phydm_tx_path_diversity_init(void *dm_void);
134 
135 void phydm_tx_path_diversity(void *dm_void);
136 
137 void phydm_process_rssi_for_path_div(void *dm_void, void *phy_info_void,
138 				     void *pkt_info_void);
139 
140 void phydm_pathdiv_debug(void *dm_void, char input[][16], u32 *_used,
141 			 char *output, u32 *_out_len);
142 
143 #endif /* @#ifdef CONFIG_PATH_DIVERSITY */
144 #endif /* @#ifndef  __PHYDMPATHDIV_H__ */
145 
146