net: wireless: rockchip_wlan: add rtl8723bs support
[firefly-linux-kernel-4.4.55.git] / drivers / net / wireless / rockchip_wlan / rtl8723bs / include / hal_com_phycfg.h
1 /******************************************************************************
2  *
3  * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
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  * You should have received a copy of the GNU General Public License along with
15  * this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
17  *
18  *
19  ******************************************************************************/
20 #ifndef __HAL_COM_PHYCFG_H__
21 #define __HAL_COM_PHYCFG_H__
22
23 #define         PathA                                           0x0     // Useless
24 #define         PathB                                           0x1
25 #define         PathC                                           0x2
26 #define         PathD                                           0x3
27
28 typedef enum _RF_TX_NUM {
29         RF_1TX = 0,
30         RF_2TX,
31         RF_3TX,
32         RF_4TX,
33         RF_MAX_TX_NUM,
34         RF_TX_NUM_NONIMPLEMENT,
35 } RF_TX_NUM;
36
37 #define MAX_POWER_INDEX                 0x3F
38
39 typedef enum _REGULATION_TXPWR_LMT {
40         TXPWR_LMT_FCC = 0,
41         TXPWR_LMT_MKK = 1,
42         TXPWR_LMT_ETSI = 2,
43         TXPWR_LMT_WW = 3,       
44
45         TXPWR_LMT_MAX_REGULATION_NUM = 4
46 } REGULATION_TXPWR_LMT;
47
48 #define TX_PWR_LMT_REF_VHT_FROM_HT      BIT0
49 #define TX_PWR_LMT_REF_HT_FROM_VHT      BIT1
50
51 /*------------------------------Define structure----------------------------*/ 
52 typedef struct _BB_REGISTER_DEFINITION{
53         u32 rfintfs;                    // set software control: 
54                                                 //              0x870~0x877[8 bytes]
55                                                         
56         u32 rfintfo;                    // output data: 
57                                                 //              0x860~0x86f [16 bytes]
58                                                         
59         u32 rfintfe;                    // output enable: 
60                                                 //              0x860~0x86f [16 bytes]
61                                                         
62         u32 rf3wireOffset;      // LSSI data:
63                                                 //              0x840~0x84f [16 bytes]
64
65         u32 rfHSSIPara2;        // wire parameter control2 : 
66                                                 //              0x824~0x827,0x82c~0x82f, 0x834~0x837, 0x83c~0x83f [16 bytes]
67                                                                 
68         u32 rfLSSIReadBack;     //LSSI RF readback data SI mode
69                                                 //              0x8a0~0x8af [16 bytes]
70
71         u32 rfLSSIReadBackPi;   //LSSI RF readback data PI mode 0x8b8-8bc for Path A and B
72
73 }BB_REGISTER_DEFINITION_T, *PBB_REGISTER_DEFINITION_T;
74
75
76 //----------------------------------------------------------------------
77 u8
78 PHY_GetTxPowerByRateBase(
79         IN      PADAPTER                Adapter,
80         IN      u8                              Band,
81         IN      u8                              RfPath,
82         IN      u8                              TxNum,
83         IN      RATE_SECTION    RateSection
84         );
85
86 #ifdef TX_POWER_BY_RATE_OLD
87 u8
88 PHY_GetRateSectionIndexOfTxPowerByRate(
89         IN      PADAPTER        pAdapter,
90         IN      u32                     RegAddr,
91         IN      u32                     BitMask
92         );
93 #endif /* TX_POWER_BY_RATE_OLD */
94
95 VOID
96 PHY_GetRateValuesOfTxPowerByRate(
97         IN      PADAPTER pAdapter,
98         IN      u32 RegAddr,
99         IN      u32 BitMask,
100         IN      u32 Value,
101         OUT     u8 *Rate,
102         OUT     s8 *PwrByRateVal,
103         OUT     u8 *RateNum
104         );
105
106 u8
107 PHY_GetRateIndexOfTxPowerByRate(
108         IN      u8      Rate
109         );
110
111 VOID 
112 PHY_SetTxPowerIndexByRateSection(
113         IN      PADAPTER                pAdapter,
114         IN      u8                              RFPath, 
115         IN      u8                              Channel,
116         IN      u8                              RateSection
117         );
118
119 s8
120 _PHY_GetTxPowerByRate(
121         IN      PADAPTER        pAdapter,
122         IN      u8                      Band,
123         IN      u8                      RFPath,
124         IN      u8                      TxNum,
125         IN      u8                      RateIndex
126         );
127
128 s8
129 PHY_GetTxPowerByRate( 
130         IN      PADAPTER        pAdapter, 
131         IN      u8                      Band, 
132         IN      u8                      RFPath, 
133         IN      u8                      TxNum, 
134         IN      u8                      RateIndex
135         );
136
137 VOID
138 PHY_SetTxPowerByRate( 
139         IN      PADAPTER        pAdapter, 
140         IN      u8                      Band, 
141         IN      u8                      RFPath, 
142         IN      u8                      TxNum, 
143         IN      u8                      Rate,
144         IN      s8                      Value
145         );
146
147 VOID
148 PHY_SetTxPowerLevelByPath(
149         IN      PADAPTER        Adapter,
150         IN      u8                      channel,
151         IN      u8                      path
152         );
153
154 VOID 
155 PHY_SetTxPowerIndexByRateArray(
156         IN      PADAPTER                pAdapter,
157         IN      u8                              RFPath,
158         IN      CHANNEL_WIDTH   BandWidth,      
159         IN      u8                              Channel,
160         IN      u8*                             Rates,
161         IN      u8                              RateArraySize
162         );
163
164 VOID
165 PHY_InitTxPowerByRate(
166         IN      PADAPTER        pAdapter
167         );
168
169 VOID
170 PHY_StoreTxPowerByRate(
171         IN      PADAPTER        pAdapter,
172         IN      u32                     Band,
173         IN      u32                     RfPath,
174         IN      u32                     TxNum,
175         IN      u32                     RegAddr,
176         IN      u32                     BitMask,
177         IN      u32                     Data
178         );
179
180 VOID
181 PHY_TxPowerByRateConfiguration(
182         IN  PADAPTER                    pAdapter
183         );
184
185 u8
186 PHY_GetTxPowerIndexBase(
187         IN      PADAPTER                pAdapter,
188         IN      u8                              RFPath,
189         IN      u8                              Rate,   
190         IN      CHANNEL_WIDTH   BandWidth,      
191         IN      u8                              Channel,
192         OUT PBOOLEAN            bIn24G
193         );
194
195 s8
196 PHY_GetTxPowerLimit(
197         IN      PADAPTER                Adapter,
198         IN      u32                             RegPwrTblSel,
199         IN      BAND_TYPE               Band,
200         IN      CHANNEL_WIDTH   Bandwidth,
201         IN      u8                              RfPath,
202         IN      u8                              DataRate,
203         IN      u8                              Channel
204         );
205
206 VOID 
207 PHY_ConvertTxPowerLimitToPowerIndex(
208         IN      PADAPTER                        Adapter
209         );
210
211 VOID
212 PHY_InitTxPowerLimit(
213         IN      PADAPTER                        Adapter
214         );
215
216 s8
217 PHY_GetTxPowerTrackingOffset( 
218         PADAPTER        pAdapter,
219         u8                      Rate,
220         u8                      RFPath
221         );
222
223 u8
224 PHY_GetTxPowerIndex(
225         IN      PADAPTER                        pAdapter,
226         IN      u8                                      RFPath,
227         IN      u8                                      Rate,   
228         IN      CHANNEL_WIDTH           BandWidth,      
229         IN      u8                                      Channel
230         );
231
232 VOID
233 PHY_SetTxPowerIndex(
234         IN      PADAPTER                pAdapter,
235         IN      u32                             PowerIndex,
236         IN      u8                              RFPath, 
237         IN      u8                              Rate
238         );
239
240 bool phy_is_tx_power_limit_needed(_adapter *adapter);
241 bool phy_is_tx_power_by_rate_needed(_adapter *adapter);
242 int phy_load_tx_power_by_rate(_adapter *adapter, const char *hal_file_name, u8 force);
243 int phy_load_tx_power_limit(_adapter *adapter, const char *hal_file_name, u8 force);
244 void phy_load_tx_power_ext_info(_adapter *adapter, u8 chk_file, u8 force);
245 void phy_reload_tx_power_ext_info(_adapter *adapter);
246 void phy_reload_default_tx_power_ext_info(_adapter *adapter);
247
248 void dump_tx_power_ext_info(void *sel, _adapter *adapter);
249 void dump_target_tx_power(void *sel, _adapter *adapter);
250 void dump_tx_power_by_rate(void *sel, _adapter *adapter);
251 void dump_tx_power_limit(void *sel, _adapter *adapter);
252
253 int rtw_is_phy_file_readable(const char *hal_file_name);
254
255 #ifdef CONFIG_LOAD_PHY_PARA_FROM_FILE
256 #define MAX_PARA_FILE_BUF_LEN   25600
257
258 #define LOAD_MAC_PARA_FILE                              BIT0
259 #define LOAD_BB_PARA_FILE                                       BIT1
260 #define LOAD_BB_PG_PARA_FILE                            BIT2
261 #define LOAD_BB_MP_PARA_FILE                            BIT3
262 #define LOAD_RF_PARA_FILE                                       BIT4
263 #define LOAD_RF_TXPWR_TRACK_PARA_FILE   BIT5
264 #define LOAD_RF_TXPWR_LMT_PARA_FILE             BIT6
265
266 int phy_ConfigMACWithParaFile(IN PADAPTER       Adapter, IN char*       pFileName);
267
268 int phy_ConfigBBWithParaFile(IN PADAPTER        Adapter, IN char*       pFileName, IN u32       ConfigType);
269
270 int phy_ConfigBBWithPgParaFile(IN PADAPTER      Adapter, IN const char *pFileName);
271
272 int phy_ConfigBBWithMpParaFile(IN PADAPTER      Adapter, IN char*       pFileName);
273
274 int PHY_ConfigRFWithParaFile(IN PADAPTER        Adapter, IN char*       pFileName, IN u8        eRFPath);
275
276 int PHY_ConfigRFWithTxPwrTrackParaFile(IN PADAPTER      Adapter, IN char*       pFileName);
277
278 int PHY_ConfigRFWithPowerLimitTableParaFile(IN PADAPTER Adapter, IN const char *pFileName);
279
280 void phy_free_filebuf_mask(_adapter *padapter, u8 mask);
281 void phy_free_filebuf(_adapter *padapter);
282 #endif /* CONFIG_LOAD_PHY_PARA_FROM_FILE */
283
284 #endif /* __HAL_COMMON_H__ */
285