Merge git://git.kernel.org/pub/scm/linux/kernel/git/mason/btrfs-unstable
[linux-2.6] / drivers / staging / rt2860 / rt_ate.h
1 /*
2  *************************************************************************
3  * Ralink Tech Inc.
4  * 5F., No.36, Taiyuan St., Jhubei City,
5  * Hsinchu County 302,
6  * Taiwan, R.O.C.
7  *
8  * (c) Copyright 2002-2007, Ralink Technology, Inc.
9  *
10  * This program is free software; you can redistribute it and/or modify  *
11  * it under the terms of the GNU General Public License as published by  *
12  * the Free Software Foundation; either version 2 of the License, or     *
13  * (at your option) any later version.                                   *
14  *                                                                       *
15  * This program is distributed in the hope that it will be useful,       *
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
18  * GNU General Public License for more details.                          *
19  *                                                                       *
20  * You should have received a copy of the GNU General Public License     *
21  * along with this program; if not, write to the                         *
22  * Free Software Foundation, Inc.,                                       *
23  * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
24  *                                                                       *
25  *************************************************************************
26  */
27
28 #ifndef __ATE_H__
29 #define __ATE_H__
30
31 #ifndef UCOS
32 #define ate_print printk
33 #define ATEDBGPRINT DBGPRINT
34 #define EEPROM_SIZE                                                             0x200
35 #ifdef CONFIG_STA_SUPPORT
36 #define EEPROM_BIN_FILE_NAME  "/etc/Wireless/RT2860STA/e2p.bin"
37 #endif // CONFIG_STA_SUPPORT //
38
39 #else // !UCOS //
40 #define fATE_LOAD_EEPROM                                                0x0C43
41 #ifdef CONFIG_PRINTK
42 extern INT ConsoleResponse(IN PUCHAR buff);
43 extern int (*remote_display)(char *);
44 extern void puts (const char *s);
45
46 /* specificly defined to redirect and show ate-related messages to host. */
47 /* Try to define ate_print as a macro. */
48 #define ate_print(fmt, args...)                 \
49 do{   int (*org_remote_display)(char *) = NULL;   \
50         org_remote_display = remote_display;\
51         /* Save original "remote_display" */\
52         remote_display = (int (*)(char *))ConsoleResponse;           \
53         printk(fmt, ## args);                       \
54         /* Restore the remote_display function pointer */        \
55         remote_display = org_remote_display; }while(0)
56
57 #define ATEDBGPRINT(Level, Fmt)         \
58 {                                   \
59     if ((Level) <= RTDebugLevel)      \
60     {                               \
61         ate_print Fmt;                                  \
62     }                               \
63 }
64 #endif // CONFIG_PRINTK //
65 #endif // !UCOS //
66
67 #define ATE_ON(_p)              (((_p)->ate.Mode) != ATE_STOP)
68
69 /* RT2880_iNIC will define "RT2860". */
70 #define ATE_BBP_IO_READ8_BY_REG_ID(_A, _I, _pV)        \
71 {                                                       \
72     BBP_CSR_CFG_STRUC  BbpCsr;                             \
73     int             i, k;                               \
74     for (i=0; i<MAX_BUSY_COUNT; i++)                    \
75     {                                                   \
76         RTMP_IO_READ32(_A, BBP_CSR_CFG, &BbpCsr.word);     \
77         if (BbpCsr.field.Busy == BUSY)                  \
78         {                                               \
79             continue;                                   \
80         }                                               \
81         BbpCsr.word = 0;                                \
82         BbpCsr.field.fRead = 1;                         \
83         BbpCsr.field.BBP_RW_MODE = 1;                         \
84         BbpCsr.field.Busy = 1;                          \
85         BbpCsr.field.RegNum = _I;                       \
86         RTMP_IO_WRITE32(_A, BBP_CSR_CFG, BbpCsr.word);     \
87         for (k=0; k<MAX_BUSY_COUNT; k++)                \
88         {                                               \
89             RTMP_IO_READ32(_A, BBP_CSR_CFG, &BbpCsr.word); \
90             if (BbpCsr.field.Busy == IDLE)              \
91                 break;                                  \
92         }                                               \
93         if ((BbpCsr.field.Busy == IDLE) &&              \
94             (BbpCsr.field.RegNum == _I))                \
95         {                                               \
96             *(_pV) = (UCHAR)BbpCsr.field.Value;         \
97             break;                                      \
98         }                                               \
99     }                                                   \
100     if (BbpCsr.field.Busy == BUSY)                      \
101     {                                                   \
102         ATEDBGPRINT(RT_DEBUG_ERROR, ("BBP read R%d fail\n", _I));      \
103         *(_pV) = (_A)->BbpWriteLatch[_I];               \
104     }                                                   \
105 }
106
107 #define ATE_BBP_IO_WRITE8_BY_REG_ID(_A, _I, _V)        \
108 {                                                       \
109     BBP_CSR_CFG_STRUC  BbpCsr;                             \
110     int             BusyCnt;                            \
111     for (BusyCnt=0; BusyCnt<MAX_BUSY_COUNT; BusyCnt++)  \
112     {                                                   \
113         RTMP_IO_READ32(_A, BBP_CSR_CFG, &BbpCsr.word);     \
114         if (BbpCsr.field.Busy == BUSY)                  \
115             continue;                                   \
116         BbpCsr.word = 0;                                \
117         BbpCsr.field.fRead = 0;                         \
118         BbpCsr.field.BBP_RW_MODE = 1;                         \
119         BbpCsr.field.Busy = 1;                          \
120         BbpCsr.field.Value = _V;                        \
121         BbpCsr.field.RegNum = _I;                       \
122         RTMP_IO_WRITE32(_A, BBP_CSR_CFG, BbpCsr.word);     \
123         (_A)->BbpWriteLatch[_I] = _V;                   \
124         break;                                          \
125     }                                                   \
126     if (BusyCnt == MAX_BUSY_COUNT)                      \
127     {                                                   \
128         ATEDBGPRINT(RT_DEBUG_ERROR, ("BBP write R%d fail\n", _I));     \
129     }                                                   \
130 }
131
132 /* RT2880_iNIC will define RT2860. */
133 #define EEPROM_SIZE                                                             0x200
134 /* iNIC has its own EEPROM_BIN_FILE_NAME */
135 #ifndef UCOS
136 #ifdef CONFIG_STA_SUPPORT
137 #define EEPROM_BIN_FILE_NAME  "/etc/Wireless/RT2860STA/e2p.bin"
138 #endif // CONFIG_STA_SUPPORT //
139 #endif // !UCOS //
140
141
142
143 VOID rt_ee_read_all(
144         IN  PRTMP_ADAPTER   pAd,
145         OUT USHORT *Data);
146
147
148 VOID rt_ee_write_all(
149         IN  PRTMP_ADAPTER   pAd,
150         IN  USHORT *Data);
151
152 INT Set_ATE_Proc(
153         IN      PRTMP_ADAPTER   pAd,
154         IN      PUCHAR                  arg);
155
156 INT     Set_ATE_DA_Proc(
157         IN      PRTMP_ADAPTER   pAd,
158         IN      PUCHAR                  arg);
159
160 INT     Set_ATE_SA_Proc(
161         IN      PRTMP_ADAPTER   pAd,
162         IN      PUCHAR                  arg);
163
164 INT     Set_ATE_BSSID_Proc(
165         IN      PRTMP_ADAPTER   pAd,
166         IN      PUCHAR                  arg);
167
168 INT     Set_ATE_CHANNEL_Proc(
169         IN      PRTMP_ADAPTER   pAd,
170         IN      PUCHAR                  arg);
171
172 INT     Set_ATE_TX_POWER0_Proc(
173         IN      PRTMP_ADAPTER   pAd,
174         IN      PUCHAR                  arg);
175
176 INT     Set_ATE_TX_POWER1_Proc(
177         IN      PRTMP_ADAPTER   pAd,
178         IN      PUCHAR                  arg);
179
180 INT     Set_ATE_TX_Antenna_Proc(
181         IN      PRTMP_ADAPTER   pAd,
182         IN      PUCHAR                  arg);
183
184 INT     Set_ATE_RX_Antenna_Proc(
185         IN      PRTMP_ADAPTER   pAd,
186         IN      PUCHAR                  arg);
187
188 INT     Set_ATE_TX_FREQOFFSET_Proc(
189         IN      PRTMP_ADAPTER   pAd,
190         IN      PUCHAR                  arg);
191
192 INT     Set_ATE_TX_BW_Proc(
193         IN      PRTMP_ADAPTER   pAd,
194         IN      PUCHAR                  arg);
195
196 INT     Set_ATE_TX_LENGTH_Proc(
197         IN      PRTMP_ADAPTER   pAd,
198         IN      PUCHAR                  arg);
199
200 INT     Set_ATE_TX_COUNT_Proc(
201         IN      PRTMP_ADAPTER   pAd,
202         IN      PUCHAR                  arg);
203
204 INT     Set_ATE_TX_MCS_Proc(
205         IN      PRTMP_ADAPTER   pAd,
206         IN      PUCHAR                  arg);
207
208 INT     Set_ATE_TX_MODE_Proc(
209         IN      PRTMP_ADAPTER   pAd,
210         IN      PUCHAR                  arg);
211
212 INT     Set_ATE_TX_GI_Proc(
213         IN      PRTMP_ADAPTER   pAd,
214         IN      PUCHAR                  arg);
215
216
217 INT     Set_ATE_RX_FER_Proc(
218         IN      PRTMP_ADAPTER   pAd,
219         IN      PUCHAR                  arg);
220
221 INT Set_ATE_Read_RF_Proc(
222         IN      PRTMP_ADAPTER   pAd,
223         IN      PUCHAR                  arg);
224
225 INT Set_ATE_Write_RF1_Proc(
226         IN      PRTMP_ADAPTER   pAd,
227         IN      PUCHAR                  arg);
228
229 INT Set_ATE_Write_RF2_Proc(
230         IN      PRTMP_ADAPTER   pAd,
231         IN      PUCHAR                  arg);
232
233 INT Set_ATE_Write_RF3_Proc(
234         IN      PRTMP_ADAPTER   pAd,
235         IN      PUCHAR                  arg);
236
237 INT Set_ATE_Write_RF4_Proc(
238         IN      PRTMP_ADAPTER   pAd,
239         IN      PUCHAR                  arg);
240
241 INT Set_ATE_Load_E2P_Proc(
242         IN      PRTMP_ADAPTER   pAd,
243         IN      PUCHAR                  arg);
244
245 INT Set_ATE_Read_E2P_Proc(
246         IN      PRTMP_ADAPTER   pAd,
247         IN      PUCHAR                  arg);
248
249 INT     Set_ATE_Show_Proc(
250         IN      PRTMP_ADAPTER   pAd,
251         IN      PUCHAR                  arg);
252
253 INT     Set_ATE_Help_Proc(
254         IN      PRTMP_ADAPTER   pAd,
255         IN      PUCHAR                  arg);
256
257 #ifdef RALINK_ATE
258 #ifdef RALINK_28xx_QA
259 VOID ATE_QA_Statistics(
260         IN PRTMP_ADAPTER                pAd,
261         IN PRXWI_STRUC                  pRxWI,
262         IN PRT28XX_RXD_STRUC    p28xxRxD,
263         IN PHEADER_802_11               pHeader);
264
265 VOID RtmpDoAte(
266         IN      PRTMP_ADAPTER   pAdapter,
267         IN      struct iwreq    *wrq);
268
269 VOID BubbleSort(
270         IN  INT32 n,
271         IN  INT32 a[]);
272
273 VOID CalNoiseLevel(
274         IN  PRTMP_ADAPTER   pAdapter,
275         IN  UCHAR           channel,
276         OUT INT32           buffer[3][10]);
277
278 BOOLEAN SyncTxRxConfig(
279         IN      PRTMP_ADAPTER   pAdapter,
280         IN      USHORT                  offset,
281         IN      UCHAR                   value);
282
283 #if 0
284 INT Set_TxStart_Proc(
285         IN      PRTMP_ADAPTER   pAd,
286         IN      PUCHAR                  arg);
287 #endif  // 0 //
288
289 INT Set_TxStop_Proc(
290         IN      PRTMP_ADAPTER   pAd,
291         IN      PUCHAR                  arg);
292
293 INT Set_RxStop_Proc(
294         IN      PRTMP_ADAPTER   pAd,
295         IN      PUCHAR                  arg);
296
297 #if 0
298 INT Set_EERead_Proc(
299         IN      PRTMP_ADAPTER   pAd,
300         IN      PUCHAR                  arg);
301
302 INT Set_EEWrite_Proc(
303         IN      PRTMP_ADAPTER   pAd,
304         IN      PUCHAR                  arg);
305
306 INT Set_BBPRead_Proc(
307         IN      PRTMP_ADAPTER   pAd,
308         IN      PUCHAR                  arg);
309
310 INT Set_BBPWrite_Proc(
311         IN      PRTMP_ADAPTER   pAd,
312         IN      PUCHAR                  arg);
313
314 INT Set_RFWrite_Proc(
315         IN      PRTMP_ADAPTER   pAd,
316         IN      PUCHAR                  arg);
317 #endif // end of #if 0 //
318 #endif // RALINK_28xx_QA //
319 #endif // RALINK_ATE //
320
321 VOID ATEAsicSwitchChannel(
322         IN PRTMP_ADAPTER pAd);
323
324 VOID ATEAsicAdjustTxPower(
325         IN PRTMP_ADAPTER pAd);
326
327 VOID ATEDisableAsicProtect(
328         IN              PRTMP_ADAPTER   pAd);
329
330 CHAR ATEConvertToRssi(
331         IN PRTMP_ADAPTER  pAd,
332         IN CHAR                         Rssi,
333         IN UCHAR    RssiNumber);
334
335 VOID ATESampleRssi(
336         IN PRTMP_ADAPTER        pAd,
337         IN PRXWI_STRUC          pRxWI);
338
339
340 #ifdef CONFIG_STA_SUPPORT
341 VOID RTMPStationStop(
342     IN  PRTMP_ADAPTER   pAd);
343
344 VOID RTMPStationStart(
345     IN  PRTMP_ADAPTER   pAd);
346 #endif // CONFIG_STA_SUPPORT //
347 #endif // __ATE_H__ //