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  ******************************************************************************/
15 #ifndef __HAL_COM_PHYCFG_H__
16 #define __HAL_COM_PHYCFG_H__
17 
18 #define		PathA		0x0	/*  Useless */
19 #define		PathB		0x1
20 #define		PathC		0x2
21 #define		PathD		0x3
22 
23 enum RATE_SECTION {
24 	CCK = 0,
25 	OFDM,
26 	HT_MCS0_MCS7,
27 	HT_MCS8_MCS15,
28 	HT_MCS16_MCS23,
29 	HT_MCS24_MCS31,
30 	VHT_1SSMCS0_1SSMCS9,
31 	VHT_2SSMCS0_2SSMCS9,
32 	VHT_3SSMCS0_3SSMCS9,
33 	VHT_4SSMCS0_4SSMCS9,
34 };
35 
36 enum RF_TX_NUM {
37 	RF_1TX = 0,
38 	RF_2TX,
39 	RF_3TX,
40 	RF_4TX,
41 	RF_MAX_TX_NUM,
42 	RF_TX_NUM_NONIMPLEMENT,
43 };
44 
45 #define MAX_POWER_INDEX			0x3F
46 
47 enum _REGULATION_TXPWR_LMT {
48 	TXPWR_LMT_FCC = 0,
49 	TXPWR_LMT_MKK,
50 	TXPWR_LMT_ETSI,
51 	TXPWR_LMT_WW,
52 	TXPWR_LMT_MAX_REGULATION_NUM,
53 };
54 
55 /*------------------------------Define structure----------------------------*/
56 struct bb_register_def {
57 	u32 rfintfs;			/*  set software control: */
58 					/* 	0x870~0x877[8 bytes] */
59 
60 	u32 rfintfo;			/*  output data: */
61 					/* 	0x860~0x86f [16 bytes] */
62 
63 	u32 rfintfe;			/*  output enable: */
64 					/* 	0x860~0x86f [16 bytes] */
65 
66 	u32 rf3wireOffset;		/*  LSSI data: */
67 					/* 	0x840~0x84f [16 bytes] */
68 
69 	u32 rfHSSIPara2;		/*  wire parameter control2 : */
70 					/* 	0x824~0x827, 0x82c~0x82f,
71 					 *	0x834~0x837, 0x83c~0x83f
72 					 */
73 	u32 rfLSSIReadBack;		/* LSSI RF readback data SI mode */
74 					/* 	0x8a0~0x8af [16 bytes] */
75 
76 	u32 rfLSSIReadBackPi;		/* LSSI RF readback data PI mode
77 					 *	0x8b8-8bc for Path A and B */
78 
79 };
80 
81 u8
82 PHY_GetTxPowerByRateBase(
83 struct adapter *	Adapter,
84 u8 		Band,
85 u8 		RfPath,
86 u8 		TxNum,
87 enum RATE_SECTION	RateSection
88 	);
89 
90 u8
91 PHY_GetRateSectionIndexOfTxPowerByRate(
92 struct adapter *padapter,
93 u32 		RegAddr,
94 u32 		BitMask
95 	);
96 
97 void
98 PHY_GetRateValuesOfTxPowerByRate(
99 struct adapter *padapter,
100 u32 		RegAddr,
101 u32 		BitMask,
102 u32 		Value,
103 	u8*		RateIndex,
104 	s8*		PwrByRateVal,
105 	u8*		RateNum
106 	);
107 
108 u8
109 PHY_GetRateIndexOfTxPowerByRate(
110 u8 Rate
111 	);
112 
113 void
114 PHY_SetTxPowerIndexByRateSection(
115 struct adapter *	padapter,
116 u8 		RFPath,
117 u8 		Channel,
118 u8 		RateSection
119 	);
120 
121 s8
122 PHY_GetTxPowerByRate(
123 struct adapter *padapter,
124 u8 	Band,
125 u8 	RFPath,
126 u8 	TxNum,
127 u8 	RateIndex
128 	);
129 
130 void
131 PHY_SetTxPowerByRate(
132 struct adapter *padapter,
133 u8 	Band,
134 u8 	RFPath,
135 u8 	TxNum,
136 u8 	Rate,
137 s8			Value
138 	);
139 
140 void
141 PHY_SetTxPowerLevelByPath(
142 struct adapter *Adapter,
143 u8 	channel,
144 u8 	path
145 	);
146 
147 void
148 PHY_SetTxPowerIndexByRateArray(
149 struct adapter *	padapter,
150 u8 		RFPath,
151 enum CHANNEL_WIDTH	BandWidth,
152 u8 		Channel,
153 u8*			Rates,
154 u8 		RateArraySize
155 	);
156 
157 void
158 PHY_InitTxPowerByRate(
159 struct adapter *padapter
160 	);
161 
162 void
163 PHY_StoreTxPowerByRate(
164 struct adapter *padapter,
165 u32 		Band,
166 u32 		RfPath,
167 u32 		TxNum,
168 u32 		RegAddr,
169 u32 		BitMask,
170 u32 		Data
171 	);
172 
173 void
174 PHY_TxPowerByRateConfiguration(
175 	struct adapter *		padapter
176 	);
177 
178 u8
179 PHY_GetTxPowerIndexBase(
180 struct adapter *	padapter,
181 u8 		RFPath,
182 u8 		Rate,
183 enum CHANNEL_WIDTH	BandWidth,
184 u8 		Channel,
185 	bool		*bIn24G
186 	);
187 
188 s8 PHY_GetTxPowerLimit (struct adapter *adapter, u32 RegPwrTblSel,
189 			enum BAND_TYPE Band, enum CHANNEL_WIDTH Bandwidth,
190 u8 		RfPath,
191 u8 		DataRate,
192 u8 		Channel
193 	);
194 
195 void
196 PHY_SetTxPowerLimit(
197 struct adapter *		Adapter,
198 u8 			*Regulation,
199 u8 			*Band,
200 u8 			*Bandwidth,
201 u8 			*RateSection,
202 u8 			*RfPath,
203 u8 			*Channel,
204 u8 			*PowerLimit
205 	);
206 
207 void
208 PHY_ConvertTxPowerLimitToPowerIndex(
209 struct adapter *		Adapter
210 	);
211 
212 void
213 PHY_InitTxPowerLimit(
214 struct adapter *		Adapter
215 	);
216 
217 s8
218 PHY_GetTxPowerTrackingOffset(
219 	struct adapter *padapter,
220 	u8 	Rate,
221 	u8 	RFPath
222 	);
223 
224 u8
225 PHY_GetTxPowerIndex(
226 struct adapter *		padapter,
227 u8 			RFPath,
228 u8 			Rate,
229 enum CHANNEL_WIDTH		BandWidth,
230 u8 			Channel
231 	);
232 
233 void
234 PHY_SetTxPowerIndex(
235 struct adapter *	padapter,
236 u32 			PowerIndex,
237 u8 		RFPath,
238 u8 		Rate
239 	);
240 
241 void
242 Hal_ChannelPlanToRegulation(
243 struct adapter *	Adapter,
244 u16 			ChannelPlan
245 	);
246 
247 #define MAX_PARA_FILE_BUF_LEN	25600
248 
249 #define LOAD_MAC_PARA_FILE				BIT0
250 #define LOAD_BB_PARA_FILE					BIT1
251 #define LOAD_BB_PG_PARA_FILE				BIT2
252 #define LOAD_BB_MP_PARA_FILE				BIT3
253 #define LOAD_RF_PARA_FILE					BIT4
254 #define LOAD_RF_TXPWR_TRACK_PARA_FILE	BIT5
255 #define LOAD_RF_TXPWR_LMT_PARA_FILE		BIT6
256 
257 int phy_ConfigMACWithParaFile(struct adapter *Adapter, char*pFileName);
258 
259 int phy_ConfigBBWithParaFile(struct adapter *Adapter, char*pFileName, u32 ConfigType);
260 
261 int phy_ConfigBBWithPgParaFile(struct adapter *Adapter, char*pFileName);
262 
263 int phy_ConfigBBWithMpParaFile(struct adapter *Adapter, char*pFileName);
264 
265 int PHY_ConfigRFWithParaFile(struct adapter *Adapter, char*pFileName, u8 eRFPath);
266 
267 int PHY_ConfigRFWithTxPwrTrackParaFile(struct adapter *Adapter, char*pFileName);
268 
269 int PHY_ConfigRFWithPowerLimitTableParaFile(struct adapter *Adapter, char*pFileName);
270 
271 void phy_free_filebuf(struct adapter *padapter);
272 
273 #endif /* __HAL_COMMON_H__ */
274