Staging: rt28x0: fix some build warnings
[pandora-kernel.git] / drivers / staging / rt2860 / chip / rtmp_phy.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         Module Name:
28         rtmp_phy.h
29
30         Abstract:
31         Ralink Wireless Chip PHY(BBP/RF) related definition & structures
32
33         Revision History:
34         Who                     When              What
35         --------        ----------        ----------------------------------------------
36 */
37
38 #ifndef __RTMP_PHY_H__
39 #define __RTMP_PHY_H__
40
41
42 /*
43         RF sections
44 */
45 #define RF_R00                  0
46 #define RF_R01                  1
47 #define RF_R02                  2
48 #define RF_R03                  3
49 #define RF_R04                  4
50 #define RF_R05                  5
51 #define RF_R06                  6
52 #define RF_R07                  7
53 #define RF_R08                  8
54 #define RF_R09                  9
55 #define RF_R10                  10
56 #define RF_R11                  11
57 #define RF_R12                  12
58 #define RF_R13                  13
59 #define RF_R14                  14
60 #define RF_R15                  15
61 #define RF_R16                  16
62 #define RF_R17                  17
63 #define RF_R18                  18
64 #define RF_R19                  19
65 #define RF_R20                  20
66 #define RF_R21                  21
67 #define RF_R22                  22
68 #define RF_R23                  23
69 #define RF_R24                  24
70 #define RF_R25                  25
71 #define RF_R26                  26
72 #define RF_R27                  27
73 #define RF_R28                  28
74 #define RF_R29                  29
75 #define RF_R30                  30
76 #define RF_R31                  31
77
78
79 // value domain of pAd->RfIcType
80 #define RFIC_2820                   1       // 2.4G 2T3R
81 #define RFIC_2850                   2       // 2.4G/5G 2T3R
82 #define RFIC_2720                   3       // 2.4G 1T2R
83 #define RFIC_2750                   4       // 2.4G/5G 1T2R
84 #define RFIC_3020                   5       // 2.4G 1T1R
85 #define RFIC_2020                   6       // 2.4G B/G
86 #define RFIC_3021                   7       // 2.4G 1T2R
87 #define RFIC_3022                   8       // 2.4G 2T2R
88 #define RFIC_3052                   9       // 2.4G/5G 2T2R
89
90 /*
91         BBP sections
92 */
93 #define BBP_R0                  0  // version
94 #define BBP_R1                  1  // TSSI
95 #define BBP_R2                  2  // TX configure
96 #define BBP_R3                  3
97 #define BBP_R4                  4
98 #define BBP_R5                  5
99 #define BBP_R6                  6
100 #define BBP_R14                 14 // RX configure
101 #define BBP_R16                 16
102 #define BBP_R17                 17 // RX sensibility
103 #define BBP_R18                 18
104 #define BBP_R21                 21
105 #define BBP_R22                 22
106 #define BBP_R24                 24
107 #define BBP_R25                 25
108 #define BBP_R26                 26
109 #define BBP_R27                 27
110 #define BBP_R31                 31
111 #define BBP_R49                 49 //TSSI
112 #define BBP_R50                 50
113 #define BBP_R51                 51
114 #define BBP_R52                 52
115 #define BBP_R55                 55
116 #define BBP_R62                 62 // Rx SQ0 Threshold HIGH
117 #define BBP_R63                 63
118 #define BBP_R64                 64
119 #define BBP_R65                 65
120 #define BBP_R66                 66
121 #define BBP_R67                 67
122 #define BBP_R68                 68
123 #define BBP_R69                 69
124 #define BBP_R70                 70 // Rx AGC SQ CCK Xcorr threshold
125 #define BBP_R73                 73
126 #define BBP_R75                 75
127 #define BBP_R77                 77
128 #define BBP_R78                 78
129 #define BBP_R79                 79
130 #define BBP_R80                 80
131 #define BBP_R81                 81
132 #define BBP_R82                 82
133 #define BBP_R83                 83
134 #define BBP_R84                 84
135 #define BBP_R86                 86
136 #define BBP_R91                 91
137 #define BBP_R92                 92
138 #define BBP_R94                 94 // Tx Gain Control
139 #define BBP_R103                103
140 #define BBP_R105                105
141 #define BBP_R106                106
142 #define BBP_R113                113
143 #define BBP_R114                114
144 #define BBP_R115                115
145 #define BBP_R116                116
146 #define BBP_R117                117
147 #define BBP_R118                118
148 #define BBP_R119                119
149 #define BBP_R120                120
150 #define BBP_R121                121
151 #define BBP_R122                122
152 #define BBP_R123                123
153 #ifdef RT30xx
154 #define BBP_R138                138 // add by johnli, RF power sequence setup, ADC dynamic on/off control
155 #endif // RT30xx //
156
157 #define BBPR94_DEFAULT  0x06 // Add 1 value will gain 1db
158
159 //
160 // BBP & RF are using indirect access. Before write any value into it.
161 // We have to make sure there is no outstanding command pending via checking busy bit.
162 //
163 #define MAX_BUSY_COUNT  100         // Number of retry before failing access BBP & RF indirect register
164
165 //#define PHY_TR_SWITCH_TIME          5  // usec
166
167 //#define BBP_R17_LOW_SENSIBILITY     0x50
168 //#define BBP_R17_MID_SENSIBILITY     0x41
169 //#define BBP_R17_DYNAMIC_UP_BOUND    0x40
170
171 #define RSSI_FOR_VERY_LOW_SENSIBILITY   -35
172 #define RSSI_FOR_LOW_SENSIBILITY                -58
173 #define RSSI_FOR_MID_LOW_SENSIBILITY    -80
174 #define RSSI_FOR_MID_SENSIBILITY                -90
175
176 /*****************************************************************************
177         RF register Read/Write marco definition
178  *****************************************************************************/
179 #ifdef RTMP_MAC_PCI
180 #define RTMP_RF_IO_WRITE32(_A, _V)                  \
181 {                                                                                       \
182         if ((_A)->bPCIclkOff == FALSE)                  \
183         {                                                                                               \
184                 PHY_CSR4_STRUC  _value;                          \
185                 ULONG           _busyCnt = 0;                    \
186                                                                                         \
187                 do {                                            \
188                         RTMP_IO_READ32((_A), RF_CSR_CFG0, &_value.word);  \
189                         if (_value.field.Busy == IDLE)               \
190                                 break;                                  \
191                         _busyCnt++;                                  \
192                 }while (_busyCnt < MAX_BUSY_COUNT);                     \
193                 if(_busyCnt < MAX_BUSY_COUNT)                   \
194                 {                                               \
195                         RTMP_IO_WRITE32((_A), RF_CSR_CFG0, (_V));          \
196                 }                                               \
197         }                                                               \
198 }
199 #endif // RTMP_MAC_PCI //
200 #ifdef RTMP_MAC_USB
201 #define RTMP_RF_IO_WRITE32(_A, _V)                 RTUSBWriteRFRegister(_A, _V)
202 #endif // RTMP_MAC_USB //
203
204 #ifdef RT30xx
205 #define RTMP_RF_IO_READ8_BY_REG_ID(_A, _I, _pV)    RT30xxReadRFRegister(_A, _I, _pV)
206 #define RTMP_RF_IO_WRITE8_BY_REG_ID(_A, _I, _V)    RT30xxWriteRFRegister(_A, _I, _V)
207 #endif // RT30xx //
208
209 /*****************************************************************************
210         BBP register Read/Write marco definitions.
211         we read/write the bbp value by register's ID.
212         Generate PER to test BA
213  *****************************************************************************/
214 #ifdef RTMP_MAC_PCI
215 /*
216         basic marco for BBP read operation.
217         _pAd: the data structure pointer of RTMP_ADAPTER
218         _bbpID : the bbp register ID
219         _pV: data pointer used to save the value of queried bbp register.
220         _bViaMCU: if we need access the bbp via the MCU.
221 */
222 #define RTMP_BBP_IO_READ8(_pAd, _bbpID, _pV, _bViaMCU)                  \
223         do{                                                                                                                     \
224                 BBP_CSR_CFG_STRUC  BbpCsr;                                                              \
225                 int   _busyCnt, _secCnt, _regID;                                                \
226                                                                                                                                 \
227                 _regID = ((_bViaMCU) == TRUE ? H2M_BBP_AGENT : BBP_CSR_CFG);    \
228                 for (_busyCnt=0; _busyCnt<MAX_BUSY_COUNT; _busyCnt++)      \
229                 {                                                                                                       \
230                         RTMP_IO_READ32(_pAd, _regID, &BbpCsr.word);             \
231                         if (BbpCsr.field.Busy == BUSY)                  \
232                                 continue;                                               \
233                         BbpCsr.word = 0;                                \
234                         BbpCsr.field.fRead = 1;                         \
235                         BbpCsr.field.BBP_RW_MODE = 1;                         \
236                         BbpCsr.field.Busy = 1;                          \
237                         BbpCsr.field.RegNum = _bbpID;                       \
238                         RTMP_IO_WRITE32(_pAd, _regID, BbpCsr.word);     \
239                         if ((_bViaMCU) == TRUE)                                                 \
240                         {                                                                                                       \
241                                 AsicSendCommandToMcu(_pAd, 0x80, 0xff, 0x0, 0x0); \
242                                 RTMPusecDelay(1000);    \
243                         }                                                       \
244                         for (_secCnt=0; _secCnt<MAX_BUSY_COUNT; _secCnt++)       \
245                         {                                               \
246                                 RTMP_IO_READ32(_pAd, _regID, &BbpCsr.word); \
247                                 if (BbpCsr.field.Busy == IDLE)              \
248                                         break;                                  \
249                         }                                               \
250                         if ((BbpCsr.field.Busy == IDLE) &&              \
251                                 (BbpCsr.field.RegNum == _bbpID))                \
252                         {                                               \
253                                 *(_pV) = (UCHAR)BbpCsr.field.Value;         \
254                                 break;                                      \
255                         }                                               \
256                 }                                                   \
257                 if (BbpCsr.field.Busy == BUSY)                      \
258                 {                                                   \
259                         DBGPRINT_ERR(("BBP(viaMCU=%d) read R%d fail\n", (_bViaMCU), _bbpID));      \
260                         *(_pV) = (_pAd)->BbpWriteLatch[_bbpID];               \
261                         if ((_bViaMCU) == TRUE)                         \
262                         {                                                                       \
263                                 RTMP_IO_READ32(_pAd, _regID, &BbpCsr.word);                             \
264                                 BbpCsr.field.Busy = 0;                          \
265                                 RTMP_IO_WRITE32(_pAd, _regID, BbpCsr.word);                             \
266                         }                               \
267                 }                                                                                                       \
268         }while(0)
269
270 /*
271         This marco used for the BBP read operation which didn't need via MCU.
272 */
273 #define BBP_IO_READ8_BY_REG_ID(_A, _I, _pV)                     \
274         RTMP_BBP_IO_READ8((_A), (_I), (_pV), FALSE)
275
276 /*
277         This marco used for the BBP read operation which need via MCU.
278         But for some chipset which didn't have mcu (e.g., RBUS based chipset), we
279         will use this function too and didn't access the bbp register via the MCU.
280 */
281 #if 0
282 #define RTMP_BBP_IO_READ8_BY_REG_ID(_A, _I, _pV)                        \
283         do{                                                                                                             \
284                 if ((_A)->bPCIclkOff == FALSE)                                                  \
285                 {                                                                                                       \
286                         if ((_A)->infType == RTMP_DEV_INF_RBUS)                 \
287                                 RTMP_BBP_IO_READ8((_A), (_I), (_pV), FALSE);    \
288                         else                                                                                            \
289                                 RTMP_BBP_IO_READ8((_A), (_I), (_pV), TRUE);     \
290                 }                                                                                                       \
291         }while(0)
292 #else
293 // Read BBP register by register's ID. Generate PER to test BA
294 #define RTMP_BBP_IO_READ8_BY_REG_ID(_A, _I, _pV)                                                \
295 {                                                                                                                                               \
296         BBP_CSR_CFG_STRUC       BbpCsr;                                                                                 \
297         int                                     i, k;                   \
298         BOOLEAN                                 brc;                    \
299         BbpCsr.field.Busy = IDLE;                       \
300         if ((IS_RT3090((_A)) || IS_RT3572((_A)) || IS_RT3390((_A))) && ((_A)->StaCfg.PSControl.field.rt30xxPowerMode == 3)      \
301                 && ((_A)->StaCfg.PSControl.field.EnableNewPS == TRUE)   \
302                 && ((_A)->bPCIclkOff == FALSE)  \
303                 && ((_A)->brt30xxBanMcuCmd == FALSE))   \
304         {                                                                                                                                       \
305                 for (i=0; i<MAX_BUSY_COUNT; i++)                                                                        \
306                 {                                                                                                                                       \
307                         RTMP_IO_READ32(_A, H2M_BBP_AGENT, &BbpCsr.word);                                \
308                         if (BbpCsr.field.Busy == BUSY)                                                                  \
309                         {                                                                                                                               \
310                                 continue;                                                                                                       \
311                         }                                                                                                                               \
312                         BbpCsr.word = 0;                                                                                                \
313                         BbpCsr.field.fRead = 1;                                                                                 \
314                         BbpCsr.field.BBP_RW_MODE = 1;                                                                   \
315                         BbpCsr.field.Busy = 1;                                                                                  \
316                         BbpCsr.field.RegNum = _I;                                                                               \
317                         RTMP_IO_WRITE32(_A, H2M_BBP_AGENT, BbpCsr.word);                                \
318                         brc = AsicSendCommandToMcu(_A, 0x80, 0xff, 0x0, 0x0);                                   \
319                         if (brc == TRUE)                                                                                                                                \
320                         {                                                                                                                               \
321                                 for (k=0; k<MAX_BUSY_COUNT; k++)                                                                \
322                                 {                                                                                                                               \
323                                         RTMP_IO_READ32(_A, H2M_BBP_AGENT, &BbpCsr.word);                        \
324                                         if (BbpCsr.field.Busy == IDLE)                                                          \
325                                                 break;                                                                                                  \
326                                 }                                                                                                                               \
327                                 if ((BbpCsr.field.Busy == IDLE) &&                                                              \
328                                         (BbpCsr.field.RegNum == _I))                                                            \
329                                 {                                                                                                                               \
330                                         *(_pV) = (UCHAR)BbpCsr.field.Value;                                                     \
331                                         break;                                                                                                          \
332                                 }                                                                                                                               \
333                         }                                                                                                                               \
334                         else                                                                                                                            \
335                         {                                                                                                                               \
336                                 BbpCsr.field.Busy = 0;                                                                                  \
337                                 RTMP_IO_WRITE32(_A, H2M_BBP_AGENT, BbpCsr.word);                                \
338                         }                                                                                                                               \
339                 }                                                                                                                                       \
340         }       \
341         else if (!((IS_RT3090((_A)) || IS_RT3572((_A)) || IS_RT3390((_A))) && ((_A)->StaCfg.PSControl.field.rt30xxPowerMode == 3)       \
342                 && ((_A)->StaCfg.PSControl.field.EnableNewPS == TRUE))  \
343                 && ((_A)->bPCIclkOff == FALSE)) \
344         {                                                                                                                                       \
345                 for (i=0; i<MAX_BUSY_COUNT; i++)                                                                        \
346                 {                                                                                                                                       \
347                         RTMP_IO_READ32(_A, H2M_BBP_AGENT, &BbpCsr.word);                                \
348                         if (BbpCsr.field.Busy == BUSY)                                                                  \
349                         {                                                                                                                               \
350                                 continue;                                                                                                       \
351                         }                                                                                                                               \
352                         BbpCsr.word = 0;                                                                                                \
353                         BbpCsr.field.fRead = 1;                                                                                 \
354                         BbpCsr.field.BBP_RW_MODE = 1;                                                                   \
355                         BbpCsr.field.Busy = 1;                                                                                  \
356                         BbpCsr.field.RegNum = _I;                                                                               \
357                         RTMP_IO_WRITE32(_A, H2M_BBP_AGENT, BbpCsr.word);                                \
358                         AsicSendCommandToMcu(_A, 0x80, 0xff, 0x0, 0x0);                                 \
359                         for (k=0; k<MAX_BUSY_COUNT; k++)                                                                \
360                         {                                                                                                                               \
361                                 RTMP_IO_READ32(_A, H2M_BBP_AGENT, &BbpCsr.word);                        \
362                                 if (BbpCsr.field.Busy == IDLE)                                                          \
363                                         break;                                                                                                  \
364                         }                                                                                                                               \
365                         if ((BbpCsr.field.Busy == IDLE) &&                                                              \
366                                 (BbpCsr.field.RegNum == _I))                                                            \
367                         {                                                                                                                               \
368                                 *(_pV) = (UCHAR)BbpCsr.field.Value;                                                     \
369                                 break;                                                                                                          \
370                         }                                                                                                                               \
371                 }                                                                                                                                       \
372         }                                                                                                                                       \
373         else                                                                            \
374         {                                                                                                                                       \
375                 DBGPRINT_ERR((" , brt30xxBanMcuCmd = %d, Read BBP %d \n", (_A)->brt30xxBanMcuCmd, (_I)));       \
376                 *(_pV) = (_A)->BbpWriteLatch[_I];                                                               \
377         }                                                                                                                                       \
378         if ((BbpCsr.field.Busy == BUSY) || ((_A)->bPCIclkOff == TRUE))                                                                          \
379         {                                                                                                                                       \
380                 DBGPRINT_ERR(("BBP read R%d=0x%x fail\n", _I, BbpCsr.word));    \
381                 *(_pV) = (_A)->BbpWriteLatch[_I];                                                               \
382         }                                                                                                                                       \
383 }
384 #endif // 0 //
385
386 /*
387         basic marco for BBP write operation.
388         _pAd: the data structure pointer of RTMP_ADAPTER
389         _bbpID : the bbp register ID
390         _pV: data used to save the value of queried bbp register.
391         _bViaMCU: if we need access the bbp via the MCU.
392 */
393 #define RTMP_BBP_IO_WRITE8(_pAd, _bbpID, _pV, _bViaMCU)                 \
394         do{                                                                                                                     \
395                 BBP_CSR_CFG_STRUC  BbpCsr;                             \
396                 int             _busyCnt, _regID;                                                       \
397                                                                                                                                 \
398                 _regID = ((_bViaMCU) == TRUE ? H2M_BBP_AGENT : BBP_CSR_CFG);    \
399                 for (_busyCnt=0; _busyCnt<MAX_BUSY_COUNT; _busyCnt++)  \
400                 {                                                   \
401                         RTMP_IO_READ32((_pAd), BBP_CSR_CFG, &BbpCsr.word);     \
402                         if (BbpCsr.field.Busy == BUSY)                  \
403                                 continue;                                   \
404                         BbpCsr.word = 0;                                \
405                         BbpCsr.field.fRead = 0;                         \
406                         BbpCsr.field.BBP_RW_MODE = 1;                         \
407                         BbpCsr.field.Busy = 1;                          \
408                         BbpCsr.field.Value = _pV;                        \
409                         BbpCsr.field.RegNum = _bbpID;                       \
410                         RTMP_IO_WRITE32((_pAd), BBP_CSR_CFG, BbpCsr.word);     \
411                         if ((_bViaMCU) == TRUE)                                                                 \
412                         {                                                                                                               \
413                                 AsicSendCommandToMcu(_pAd, 0x80, 0xff, 0x0, 0x0);               \
414                                 if ((_pAd)->OpMode == OPMODE_AP)                                                \
415                                         RTMPusecDelay(1000);                                                    \
416                         }                                                                                                               \
417                         (_pAd)->BbpWriteLatch[_bbpID] = _pV;                                    \
418                         break;                                                                                                  \
419                 }                                                                                                               \
420                 if (_busyCnt == MAX_BUSY_COUNT)                                                         \
421                 {                                                                                                               \
422                         DBGPRINT_ERR(("BBP write R%d fail\n", _bbpID));                         \
423                         if((_bViaMCU) == TRUE)                                                                  \
424                         {                                                                                                               \
425                                 RTMP_IO_READ32(_pAd, H2M_BBP_AGENT, &BbpCsr.word);      \
426                                 BbpCsr.field.Busy = 0;                                                                  \
427                                 RTMP_IO_WRITE32(_pAd, H2M_BBP_AGENT, BbpCsr.word);      \
428                         }                                                                                                               \
429                 }                                                                                                               \
430         }while(0)
431
432
433 /*
434         This marco used for the BBP write operation which didn't need via MCU.
435 */
436 #define BBP_IO_WRITE8_BY_REG_ID(_A, _I, _pV)                    \
437         RTMP_BBP_IO_WRITE8((_A), (_I), (_pV), FALSE)
438
439 /*
440         This marco used for the BBP write operation which need via MCU.
441         But for some chipset which didn't have mcu (e.g., RBUS based chipset), we
442         will use this function too and didn't access the bbp register via the MCU.
443 */
444 #if 0
445 #define RTMP_BBP_IO_WRITE8_BY_REG_ID(_A, _I, _pV)                       \
446         do{                                                                                                             \
447                 if ((_A)->bPCIclkOff == FALSE)                                                  \
448                 {                                                                                                       \
449                         if ((_A)->infType == RTMP_DEV_INF_RBUS)                 \
450                                 RTMP_BBP_IO_WRITE8((_A), (_I), (_pV), FALSE);   \
451                         else                                                                                            \
452                                 RTMP_BBP_IO_WRITE8((_A), (_I), (_pV), TRUE);    \
453                 }                                                                                                       \
454         }while(0)
455 #else
456 // Write BBP register by register's ID & value
457 #define RTMP_BBP_IO_WRITE8_BY_REG_ID(_A, _I, _V)                                                \
458 {                                                                                                                                               \
459         BBP_CSR_CFG_STRUC       BbpCsr;                                                                                 \
460         INT                                     BusyCnt = 0;                                                                            \
461         BOOLEAN                                 brc;                    \
462         if (_I < MAX_NUM_OF_BBP_LATCH)                                                                          \
463         {                                                                                                                                       \
464                 if ((IS_RT3090((_A)) || IS_RT3572((_A)) || IS_RT3390((_A))) && ((_A)->StaCfg.PSControl.field.rt30xxPowerMode == 3)      \
465                         && ((_A)->StaCfg.PSControl.field.EnableNewPS == TRUE)   \
466                         && ((_A)->bPCIclkOff == FALSE)  \
467                         && ((_A)->brt30xxBanMcuCmd == FALSE))   \
468                 {                                                                                                                                       \
469                         if (_A->AccessBBPFailCount > 20)                                                                        \
470                         {                                                                                                                                       \
471                                 AsicResetBBPAgent(_A);                          \
472                                 _A->AccessBBPFailCount = 0;                                                                                     \
473                         }                                                                                                                                       \
474                         for (BusyCnt=0; BusyCnt<MAX_BUSY_COUNT; BusyCnt++)                                      \
475                         {                                                                                                                                       \
476                                 RTMP_IO_READ32(_A, H2M_BBP_AGENT, &BbpCsr.word);                                \
477                                 if (BbpCsr.field.Busy == BUSY)                                                                  \
478                                         continue;                                                                                                       \
479                                 BbpCsr.word = 0;                                                                                                \
480                                 BbpCsr.field.fRead = 0;                                                                                 \
481                                 BbpCsr.field.BBP_RW_MODE = 1;                                                                   \
482                                 BbpCsr.field.Busy = 1;                                                                                  \
483                                 BbpCsr.field.Value = _V;                                                                                \
484                                 BbpCsr.field.RegNum = _I;                                                                               \
485                                 RTMP_IO_WRITE32(_A, H2M_BBP_AGENT, BbpCsr.word);                                \
486                                 brc = AsicSendCommandToMcu(_A, 0x80, 0xff, 0x0, 0x0);                                   \
487                                 if (brc == TRUE)                                                                                                                                \
488                                 {                                                                                                                               \
489                                         (_A)->BbpWriteLatch[_I] = _V;                                                                   \
490                                 }                                                                                                                               \
491                                 else                                                                                                                            \
492                                 {                                                                                                                               \
493                                         BbpCsr.field.Busy = 0;                                                                                  \
494                                         RTMP_IO_WRITE32(_A, H2M_BBP_AGENT, BbpCsr.word);                                \
495                                 }                                                                                                                               \
496                                 break;                                                                                                                  \
497                         }                                                                                                                                       \
498                 }                                                                                                                                       \
499                 else if (!((IS_RT3090((_A)) || IS_RT3572((_A)) || IS_RT3390((_A))) && ((_A)->StaCfg.PSControl.field.rt30xxPowerMode == 3)       \
500                         && ((_A)->StaCfg.PSControl.field.EnableNewPS == TRUE))  \
501                         && ((_A)->bPCIclkOff == FALSE)) \
502                 {                                                                                                                                       \
503                         if (_A->AccessBBPFailCount > 20)                                                                        \
504                         {                                                                                                                                       \
505                                 AsicResetBBPAgent(_A);                          \
506                                 _A->AccessBBPFailCount = 0;                                                                                     \
507                         }                                                                                                                                       \
508                         for (BusyCnt=0; BusyCnt<MAX_BUSY_COUNT; BusyCnt++)                                      \
509                         {                                                                                                                                       \
510                                 RTMP_IO_READ32(_A, H2M_BBP_AGENT, &BbpCsr.word);                                \
511                                 if (BbpCsr.field.Busy == BUSY)                                                                  \
512                                         continue;                                                                                                       \
513                                 BbpCsr.word = 0;                                                                                                \
514                                 BbpCsr.field.fRead = 0;                                                                                 \
515                                 BbpCsr.field.BBP_RW_MODE = 1;                                                                   \
516                                 BbpCsr.field.Busy = 1;                                                                                  \
517                                 BbpCsr.field.Value = _V;                                                                                \
518                                 BbpCsr.field.RegNum = _I;                                                                               \
519                                 RTMP_IO_WRITE32(_A, H2M_BBP_AGENT, BbpCsr.word);                                \
520                                 AsicSendCommandToMcu(_A, 0x80, 0xff, 0x0, 0x0);                                 \
521                                 (_A)->BbpWriteLatch[_I] = _V;                                                                   \
522                                 break;                                                                                                                  \
523                         }                                                                                                                                       \
524                 }                                                                                                                                       \
525                 else                                                                            \
526                 {                                                                                                                                       \
527                         DBGPRINT_ERR(("  brt30xxBanMcuCmd = %d. Write BBP %d \n",  (_A)->brt30xxBanMcuCmd, (_I)));      \
528                 }                                                                                                                                       \
529                 if ((BusyCnt == MAX_BUSY_COUNT) || ((_A)->bPCIclkOff == TRUE))                  \
530                 {                                                                                                                                       \
531                         if (BusyCnt == MAX_BUSY_COUNT)                                  \
532                                 (_A)->AccessBBPFailCount++;                                     \
533                         DBGPRINT_ERR(("BBP write R%d=0x%x fail. BusyCnt= %d.bPCIclkOff = %d. \n", _I, BbpCsr.word, BusyCnt, (_A)->bPCIclkOff ));        \
534                 }                                                                                                                                       \
535         }                                                                                                                                               \
536         else                                                                                                                                            \
537         {                                                                                                                                               \
538                 DBGPRINT_ERR(("****** BBP_Write_Latch Buffer exceeds max boundry ****** \n"));  \
539         }                                                                                                                                               \
540 }
541 #endif // 0 //
542
543 #endif // RTMP_MAC_PCI //
544 #ifdef RTMP_MAC_USB
545 #define RTMP_BBP_IO_READ8_BY_REG_ID(_A, _I, _pV)   RTUSBReadBBPRegister(_A, _I, _pV)
546 #define RTMP_BBP_IO_WRITE8_BY_REG_ID(_A, _I, _V)   RTUSBWriteBBPRegister(_A, _I, _V)
547
548 #define BBP_IO_WRITE8_BY_REG_ID(_A, _I, _V)                     RTUSBWriteBBPRegister(_A, _I, _V)
549 #define BBP_IO_READ8_BY_REG_ID(_A, _I, _pV)             RTUSBReadBBPRegister(_A, _I, _pV)
550 #endif // RTMP_MAC_USB //
551
552 #ifdef RT30xx
553 #define RTMP_ASIC_MMPS_DISABLE(_pAd)                                                    \
554         do{                                                                                                                     \
555                 UINT32 _macData; \
556                 UCHAR _bbpData = 0; \
557                 /* disable MMPS BBP control register */                                         \
558                 RTMP_BBP_IO_READ8_BY_REG_ID(_pAd, BBP_R3, &_bbpData);   \
559                 _bbpData &= ~(0x04);    /*bit 2*/                                                               \
560                 RTMP_BBP_IO_WRITE8_BY_REG_ID(_pAd, BBP_R3, _bbpData);   \
561                                                                                                                                 \
562                 /* disable MMPS MAC control register */                                         \
563                 RTMP_IO_READ32(_pAd, 0x1210, &_macData);                                \
564                 _macData &= ~(0x09);    /*bit 0, 3*/                                                    \
565                 RTMP_IO_WRITE32(_pAd, 0x1210, _macData);                                \
566         }while(0)
567
568
569 #define RTMP_ASIC_MMPS_ENABLE(_pAd)                                                     \
570         do{                                                                                                                     \
571                 UINT32 _macData; \
572                 UCHAR _bbpData = 0; \
573                 /* enable MMPS BBP control register */                                          \
574                 RTMP_BBP_IO_READ8_BY_REG_ID(_pAd, BBP_R3, &_bbpData);   \
575                 _bbpData |= (0x04);     /*bit 2*/                                                               \
576                 RTMP_BBP_IO_WRITE8_BY_REG_ID(_pAd, BBP_R3, _bbpData);   \
577                                                                                                                                 \
578                 /* enable MMPS MAC control register */                                          \
579                 RTMP_IO_READ32(_pAd, 0x1210, &_macData);                                \
580                 _macData |= (0x09);     /*bit 0, 3*/                                                    \
581                 RTMP_IO_WRITE32(_pAd, 0x1210, _macData);                                \
582         }while(0)
583
584 #endif // RT30xx //
585
586 #endif // __RTMP_PHY_H__ //