blob: 662cfea7527e2ef321c53c538c972513a7fd00d7 [file] [log] [blame]
Forest Bond92b96792009-06-13 07:38:31 -04001/*
2 * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
3 * All rights reserved.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * File: card.c
20 * Purpose: Provide functions to setup NIC operation mode
21 * Functions:
22 * s_vSafeResetTx - Rest Tx
23 * CARDvSetRSPINF - Set RSPINF
24 * vUpdateIFS - Update slotTime,SIFS,DIFS, and EIFS
25 * CARDvUpdateBasicTopRate - Update BasicTopRate
26 * CARDbAddBasicRate - Add to BasicRateSet
27 * CARDbSetBasicRate - Set Basic Tx Rate
28 * CARDbIsOFDMinBasicRate - Check if any OFDM rate is in BasicRateSet
29 * CARDvSetLoopbackMode - Set Loopback mode
30 * CARDbSoftwareReset - Sortware reset NIC
Justin P. Mattocka0a1f612012-08-26 08:16:43 -070031 * CARDqGetTSFOffset - Calculate TSFOffset
Forest Bond92b96792009-06-13 07:38:31 -040032 * CARDbGetCurrentTSF - Read Current NIC TSF counter
Justin P. Mattocka0a1f612012-08-26 08:16:43 -070033 * CARDqGetNextTBTT - Calculate Next Beacon TSF counter
Forest Bond92b96792009-06-13 07:38:31 -040034 * CARDvSetFirstNextTBTT - Set NIC Beacon time
35 * CARDvUpdateNextTBTT - Sync. NIC Beacon time
36 * CARDbRadioPowerOff - Turn Off NIC Radio Power
37 * CARDbRadioPowerOn - Turn On NIC Radio Power
38 * CARDbSetWEPMode - Set NIC Wep mode
39 * CARDbSetTxPower - Set NIC tx power
40 *
41 * Revision History:
42 * 06-10-2003 Bryan YC Fan: Re-write codes to support VT3253 spec.
Justin P. Mattocka0a1f612012-08-26 08:16:43 -070043 * 08-26-2003 Kyle Hsu: Modify the definition type of dwIoBase.
Forest Bond92b96792009-06-13 07:38:31 -040044 * 09-01-2003 Bryan YC Fan: Add vUpdateIFS().
45 *
46 */
47
Malcolm Priestleydd0a7742012-12-10 21:59:10 +000048#include "device.h"
Forest Bond92b96792009-06-13 07:38:31 -040049#include "tmacro.h"
Forest Bond92b96792009-06-13 07:38:31 -040050#include "card.h"
Forest Bond92b96792009-06-13 07:38:31 -040051#include "baseband.h"
Forest Bond92b96792009-06-13 07:38:31 -040052#include "mac.h"
Forest Bond92b96792009-06-13 07:38:31 -040053#include "desc.h"
Forest Bond92b96792009-06-13 07:38:31 -040054#include "rf.h"
Forest Bond92b96792009-06-13 07:38:31 -040055#include "power.h"
Forest Bond92b96792009-06-13 07:38:31 -040056#include "key.h"
Forest Bond92b96792009-06-13 07:38:31 -040057#include "rc4.h"
Forest Bond92b96792009-06-13 07:38:31 -040058#include "country.h"
Forest Bond92b96792009-06-13 07:38:31 -040059#include "datarate.h"
Forest Bond92b96792009-06-13 07:38:31 -040060#include "rndis.h"
Forest Bond92b96792009-06-13 07:38:31 -040061#include "control.h"
Forest Bond92b96792009-06-13 07:38:31 -040062
Forest Bond92b96792009-06-13 07:38:31 -040063//static int msglevel =MSG_LEVEL_DEBUG;
64static int msglevel =MSG_LEVEL_INFO;
65
Andres More3eaca0d2013-02-25 20:32:52 -050066//const u16 cwRXBCNTSFOff[MAX_RATE] =
Forest Bond92b96792009-06-13 07:38:31 -040067//{17, 34, 96, 192, 34, 23, 17, 11, 8, 5, 4, 3};
68
Valentina Manea3b138852013-11-04 10:44:02 +020069static const u16 cwRXBCNTSFOff[MAX_RATE] =
Forest Bond92b96792009-06-13 07:38:31 -040070{192, 96, 34, 17, 34, 23, 17, 11, 8, 5, 4, 3};
71
Forest Bond92b96792009-06-13 07:38:31 -040072/*
73 * Description: Set NIC media channel
74 *
75 * Parameters:
76 * In:
77 * pDevice - The adapter to be set
78 * uConnectionChannel - Channel to be set
79 * Out:
80 * none
Forest Bond92b96792009-06-13 07:38:31 -040081 */
Malcolm Priestleydd0a7742012-12-10 21:59:10 +000082void CARDbSetMediaChannel(struct vnt_private *pDevice, u32 uConnectionChannel)
Forest Bond92b96792009-06-13 07:38:31 -040083{
Forest Bond92b96792009-06-13 07:38:31 -040084
85 if (pDevice->byBBType == BB_TYPE_11A) { // 15 ~ 38
86 if ((uConnectionChannel < (CB_MAX_CHANNEL_24G+1)) || (uConnectionChannel > CB_MAX_CHANNEL))
87 uConnectionChannel = (CB_MAX_CHANNEL_24G+1);
88 } else {
89 if ((uConnectionChannel > CB_MAX_CHANNEL_24G) || (uConnectionChannel == 0)) // 1 ~ 14
90 uConnectionChannel = 1;
91 }
92
93 // clear NAV
94 MACvRegBitsOn(pDevice, MAC_REG_MACCR, MACCR_CLRNAV);
95
96 // Set Channel[7] = 0 to tell H/W channel is changing now.
97 MACvRegBitsOff(pDevice, MAC_REG_CHANNEL, 0x80);
98
99 //if (pMgmt->uCurrChannel == uConnectionChannel)
100 // return bResult;
101
102 CONTROLnsRequestOut(pDevice,
103 MESSAGE_TYPE_SELECT_CHANNLE,
Andres More3eaca0d2013-02-25 20:32:52 -0500104 (u16) uConnectionChannel,
Forest Bond92b96792009-06-13 07:38:31 -0400105 0,
106 0,
107 NULL
108 );
109
110 //{{ RobertYu: 20041202
111 //// TX_PE will reserve 3 us for MAX2829 A mode only, it is for better TX throughput
112
113 if (pDevice->byBBType == BB_TYPE_11A) {
114 pDevice->byCurPwr = 0xFF;
115 RFbRawSetPower(pDevice, pDevice->abyOFDMAPwrTbl[uConnectionChannel-15], RATE_54M);
116 } else if (pDevice->byBBType == BB_TYPE_11G) {
117 pDevice->byCurPwr = 0xFF;
118 RFbRawSetPower(pDevice, pDevice->abyOFDMPwrTbl[uConnectionChannel-1], RATE_54M);
119 } else {
120 pDevice->byCurPwr = 0xFF;
121 RFbRawSetPower(pDevice, pDevice->abyCCKPwrTbl[uConnectionChannel-1], RATE_1M);
122 }
Andres Moreb902fbf2013-02-25 20:32:51 -0500123 ControlvWriteByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_CHANNEL,(u8)(uConnectionChannel|0x80));
Forest Bond92b96792009-06-13 07:38:31 -0400124}
125
126/*
127 * Description: Get CCK mode basic rate
128 *
129 * Parameters:
130 * In:
131 * pDevice - The adapter to be set
132 * wRateIdx - Receiving data rate
133 * Out:
134 * none
135 *
136 * Return Value: response Control frame rate
137 *
138 */
Malcolm Priestleydd0a7742012-12-10 21:59:10 +0000139static u16 swGetCCKControlRate(struct vnt_private *pDevice, u16 wRateIdx)
Forest Bond92b96792009-06-13 07:38:31 -0400140{
Malcolm Priestleydd0a7742012-12-10 21:59:10 +0000141 u16 ui = wRateIdx;
142
143 while (ui > RATE_1M) {
144 if (pDevice->wBasicRate & (1 << ui))
145 return ui;
146 ui--;
147 }
148
149 return RATE_1M;
Forest Bond92b96792009-06-13 07:38:31 -0400150}
151
152/*
153 * Description: Get OFDM mode basic rate
154 *
155 * Parameters:
156 * In:
157 * pDevice - The adapter to be set
158 * wRateIdx - Receiving data rate
159 * Out:
160 * none
161 *
162 * Return Value: response Control frame rate
163 *
164 */
Malcolm Priestleydd0a7742012-12-10 21:59:10 +0000165static u16 swGetOFDMControlRate(struct vnt_private *pDevice, u16 wRateIdx)
Forest Bond92b96792009-06-13 07:38:31 -0400166{
Malcolm Priestleydd0a7742012-12-10 21:59:10 +0000167 u16 ui = wRateIdx;
Forest Bond92b96792009-06-13 07:38:31 -0400168
Malcolm Priestleydd0a7742012-12-10 21:59:10 +0000169 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"BASIC RATE: %X\n",
170 pDevice->wBasicRate);
Forest Bond92b96792009-06-13 07:38:31 -0400171
Malcolm Priestleydd0a7742012-12-10 21:59:10 +0000172 if (!CARDbIsOFDMinBasicRate(pDevice)) {
173 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO
174 "swGetOFDMControlRate:(NO OFDM) %d\n", wRateIdx);
Dave Jones0b7cb692013-09-05 00:00:52 -0400175 if (wRateIdx > RATE_24M)
176 wRateIdx = RATE_24M;
Malcolm Priestleydd0a7742012-12-10 21:59:10 +0000177 return wRateIdx;
178 }
179
180 while (ui > RATE_11M) {
181 if (pDevice->wBasicRate & (1 << ui)) {
182 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO
183 "swGetOFDMControlRate: %d\n", ui);
184 return ui;
185 }
186 ui--;
187 }
188
189 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"swGetOFDMControlRate: 6M\n");
190
191 return RATE_24M;
Forest Bond92b96792009-06-13 07:38:31 -0400192}
193
194/*
Justin P. Mattocka0a1f612012-08-26 08:16:43 -0700195 * Description: Calculate TxRate and RsvTime fields for RSPINF in OFDM mode.
Forest Bond92b96792009-06-13 07:38:31 -0400196 *
197 * Parameters:
198 * In:
199 * wRate - Tx Rate
200 * byPktType - Tx Packet type
201 * Out:
202 * pbyTxRate - pointer to RSPINF TxRate field
203 * pbyRsvTime - pointer to RSPINF RsvTime field
204 *
205 * Return Value: none
206 *
207 */
Valentina Manea3b138852013-11-04 10:44:02 +0200208static void
Justin P. Mattockbda79782012-08-26 08:16:44 -0700209CARDvCalculateOFDMRParameter (
Andres More3eaca0d2013-02-25 20:32:52 -0500210 u16 wRate,
Andres Moreb902fbf2013-02-25 20:32:51 -0500211 u8 byBBType,
212 u8 * pbyTxRate,
213 u8 * pbyRsvTime
Forest Bond92b96792009-06-13 07:38:31 -0400214 )
215{
216 switch (wRate) {
217 case RATE_6M :
218 if (byBBType == BB_TYPE_11A) {//5GHZ
219 *pbyTxRate = 0x9B;
220 *pbyRsvTime = 24;
221 }
222 else {
223 *pbyTxRate = 0x8B;
224 *pbyRsvTime = 30;
225 }
226 break;
227
228 case RATE_9M :
229 if (byBBType == BB_TYPE_11A) {//5GHZ
230 *pbyTxRate = 0x9F;
231 *pbyRsvTime = 16;
232 }
233 else {
234 *pbyTxRate = 0x8F;
235 *pbyRsvTime = 22;
236 }
237 break;
238
239 case RATE_12M :
240 if (byBBType == BB_TYPE_11A) {//5GHZ
241 *pbyTxRate = 0x9A;
242 *pbyRsvTime = 12;
243 }
244 else {
245 *pbyTxRate = 0x8A;
246 *pbyRsvTime = 18;
247 }
248 break;
249
250 case RATE_18M :
251 if (byBBType == BB_TYPE_11A) {//5GHZ
252 *pbyTxRate = 0x9E;
253 *pbyRsvTime = 8;
254 }
255 else {
256 *pbyTxRate = 0x8E;
257 *pbyRsvTime = 14;
258 }
259 break;
260
261 case RATE_36M :
262 if (byBBType == BB_TYPE_11A) {//5GHZ
263 *pbyTxRate = 0x9D;
264 *pbyRsvTime = 4;
265 }
266 else {
267 *pbyTxRate = 0x8D;
268 *pbyRsvTime = 10;
269 }
270 break;
271
272 case RATE_48M :
273 if (byBBType == BB_TYPE_11A) {//5GHZ
274 *pbyTxRate = 0x98;
275 *pbyRsvTime = 4;
276 }
277 else {
278 *pbyTxRate = 0x88;
279 *pbyRsvTime = 10;
280 }
281 break;
282
283 case RATE_54M :
284 if (byBBType == BB_TYPE_11A) {//5GHZ
285 *pbyTxRate = 0x9C;
286 *pbyRsvTime = 4;
287 }
288 else {
289 *pbyTxRate = 0x8C;
290 *pbyRsvTime = 10;
291 }
292 break;
293
294 case RATE_24M :
295 default :
296 if (byBBType == BB_TYPE_11A) {//5GHZ
297 *pbyTxRate = 0x99;
298 *pbyRsvTime = 8;
299 }
300 else {
301 *pbyTxRate = 0x89;
302 *pbyRsvTime = 14;
303 }
304 break;
305 }
306}
307
308/*
309 * Description: Set RSPINF
310 *
311 * Parameters:
312 * In:
313 * pDevice - The adapter to be set
314 * Out:
315 * none
316 *
317 * Return Value: None.
318 *
319 */
Malcolm Priestleydd0a7742012-12-10 21:59:10 +0000320void CARDvSetRSPINF(struct vnt_private *pDevice, u8 byBBType)
Forest Bond92b96792009-06-13 07:38:31 -0400321{
Malcolm Priestleyaed387c2013-08-20 22:52:30 +0100322 struct vnt_phy_field phy[4];
Malcolm Priestleydd0a7742012-12-10 21:59:10 +0000323 u8 abyTxRate[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0}; /* For OFDM */
324 u8 abyRsvTime[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
325 u8 abyData[34];
326 int i;
Forest Bond92b96792009-06-13 07:38:31 -0400327
328 //RSPINF_b_1
Malcolm Priestleyaed387c2013-08-20 22:52:30 +0100329 BBvCalculateParameter(pDevice, 14,
330 swGetCCKControlRate(pDevice, RATE_1M), PK_TYPE_11B, &phy[0]);
Forest Bond92b96792009-06-13 07:38:31 -0400331
332 ///RSPINF_b_2
Malcolm Priestleyaed387c2013-08-20 22:52:30 +0100333 BBvCalculateParameter(pDevice, 14,
334 swGetCCKControlRate(pDevice, RATE_2M), PK_TYPE_11B, &phy[1]);
Forest Bond92b96792009-06-13 07:38:31 -0400335
336 //RSPINF_b_5
Malcolm Priestleyaed387c2013-08-20 22:52:30 +0100337 BBvCalculateParameter(pDevice, 14,
338 swGetCCKControlRate(pDevice, RATE_5M), PK_TYPE_11B, &phy[2]);
Forest Bond92b96792009-06-13 07:38:31 -0400339
340 //RSPINF_b_11
Malcolm Priestleyaed387c2013-08-20 22:52:30 +0100341 BBvCalculateParameter(pDevice, 14,
342 swGetCCKControlRate(pDevice, RATE_11M), PK_TYPE_11B, &phy[3]);
Forest Bond92b96792009-06-13 07:38:31 -0400343
344 //RSPINF_a_6
Justin P. Mattockbda79782012-08-26 08:16:44 -0700345 CARDvCalculateOFDMRParameter (RATE_6M,
Forest Bond92b96792009-06-13 07:38:31 -0400346 byBBType,
347 &abyTxRate[0],
348 &abyRsvTime[0]);
349
350 //RSPINF_a_9
Justin P. Mattockbda79782012-08-26 08:16:44 -0700351 CARDvCalculateOFDMRParameter (RATE_9M,
Forest Bond92b96792009-06-13 07:38:31 -0400352 byBBType,
353 &abyTxRate[1],
354 &abyRsvTime[1]);
355
356 //RSPINF_a_12
Justin P. Mattockbda79782012-08-26 08:16:44 -0700357 CARDvCalculateOFDMRParameter (RATE_12M,
Forest Bond92b96792009-06-13 07:38:31 -0400358 byBBType,
359 &abyTxRate[2],
360 &abyRsvTime[2]);
361
362 //RSPINF_a_18
Justin P. Mattockbda79782012-08-26 08:16:44 -0700363 CARDvCalculateOFDMRParameter (RATE_18M,
Forest Bond92b96792009-06-13 07:38:31 -0400364 byBBType,
365 &abyTxRate[3],
366 &abyRsvTime[3]);
367
368 //RSPINF_a_24
Justin P. Mattockbda79782012-08-26 08:16:44 -0700369 CARDvCalculateOFDMRParameter (RATE_24M,
Forest Bond92b96792009-06-13 07:38:31 -0400370 byBBType,
371 &abyTxRate[4],
372 &abyRsvTime[4]);
373
374 //RSPINF_a_36
Justin P. Mattockbda79782012-08-26 08:16:44 -0700375 CARDvCalculateOFDMRParameter (swGetOFDMControlRate(pDevice, RATE_36M),
Forest Bond92b96792009-06-13 07:38:31 -0400376 byBBType,
377 &abyTxRate[5],
378 &abyRsvTime[5]);
379
380 //RSPINF_a_48
Justin P. Mattockbda79782012-08-26 08:16:44 -0700381 CARDvCalculateOFDMRParameter (swGetOFDMControlRate(pDevice, RATE_48M),
Forest Bond92b96792009-06-13 07:38:31 -0400382 byBBType,
383 &abyTxRate[6],
384 &abyRsvTime[6]);
385
386 //RSPINF_a_54
Justin P. Mattockbda79782012-08-26 08:16:44 -0700387 CARDvCalculateOFDMRParameter (swGetOFDMControlRate(pDevice, RATE_54M),
Forest Bond92b96792009-06-13 07:38:31 -0400388 byBBType,
389 &abyTxRate[7],
390 &abyRsvTime[7]);
391
392 //RSPINF_a_72
Justin P. Mattockbda79782012-08-26 08:16:44 -0700393 CARDvCalculateOFDMRParameter (swGetOFDMControlRate(pDevice, RATE_54M),
Forest Bond92b96792009-06-13 07:38:31 -0400394 byBBType,
395 &abyTxRate[8],
396 &abyRsvTime[8]);
397
Malcolm Priestleyaed387c2013-08-20 22:52:30 +0100398 put_unaligned(phy[0].len, (u16 *)&abyData[0]);
399 abyData[2] = phy[0].signal;
400 abyData[3] = phy[0].service;
Forest Bond92b96792009-06-13 07:38:31 -0400401
Malcolm Priestleyaed387c2013-08-20 22:52:30 +0100402 put_unaligned(phy[1].len, (u16 *)&abyData[4]);
403 abyData[6] = phy[1].signal;
404 abyData[7] = phy[1].service;
Forest Bond92b96792009-06-13 07:38:31 -0400405
Malcolm Priestleyaed387c2013-08-20 22:52:30 +0100406 put_unaligned(phy[2].len, (u16 *)&abyData[8]);
407 abyData[10] = phy[2].signal;
408 abyData[11] = phy[2].service;
Forest Bond92b96792009-06-13 07:38:31 -0400409
Malcolm Priestleyaed387c2013-08-20 22:52:30 +0100410 put_unaligned(phy[3].len, (u16 *)&abyData[12]);
411 abyData[14] = phy[3].signal;
412 abyData[15] = phy[3].service;
Forest Bond92b96792009-06-13 07:38:31 -0400413
Andres More33d33e422010-05-19 23:50:00 -0300414 for (i = 0; i < 9; i++) {
415 abyData[16+i*2] = abyTxRate[i];
416 abyData[16+i*2+1] = abyRsvTime[i];
Forest Bond92b96792009-06-13 07:38:31 -0400417 }
418
Forest Bond92b96792009-06-13 07:38:31 -0400419 CONTROLnsRequestOut(pDevice,
420 MESSAGE_TYPE_WRITE,
421 MAC_REG_RSPINF_B_1,
422 MESSAGE_REQUEST_MACREG,
423 34,
424 &abyData[0]);
425
426}
427
428/*
429 * Description: Update IFS
430 *
431 * Parameters:
432 * In:
433 * pDevice - The adapter to be set
434 * Out:
435 * none
436 *
437 * Return Value: None.
438 *
439 */
Malcolm Priestleydd0a7742012-12-10 21:59:10 +0000440void vUpdateIFS(struct vnt_private *pDevice)
Forest Bond92b96792009-06-13 07:38:31 -0400441{
Malcolm Priestleydd0a7742012-12-10 21:59:10 +0000442 u8 byMaxMin = 0;
443 u8 byData[4];
Forest Bond92b96792009-06-13 07:38:31 -0400444
445 if (pDevice->byPacketType==PK_TYPE_11A) {//0000 0000 0000 0000,11a
446 pDevice->uSlot = C_SLOT_SHORT;
447 pDevice->uSIFS = C_SIFS_A;
448 pDevice->uDIFS = C_SIFS_A + 2*C_SLOT_SHORT;
449 pDevice->uCwMin = C_CWMIN_A;
450 byMaxMin = 4;
451 }
452 else if (pDevice->byPacketType==PK_TYPE_11B) {//0000 0001 0000 0000,11b
453 pDevice->uSlot = C_SLOT_LONG;
454 pDevice->uSIFS = C_SIFS_BG;
455 pDevice->uDIFS = C_SIFS_BG + 2*C_SLOT_LONG;
456 pDevice->uCwMin = C_CWMIN_B;
457 byMaxMin = 5;
458 }
459 else {// PK_TYPE_11GA & PK_TYPE_11GB
Andres Moreb902fbf2013-02-25 20:32:51 -0500460 u8 byRate = 0;
Andres Moree269fc22013-02-12 20:36:29 -0500461 bool bOFDMRate = false;
Andres Morecc856e62010-05-17 21:34:01 -0300462 unsigned int ii = 0;
Forest Bond92b96792009-06-13 07:38:31 -0400463 PWLAN_IE_SUPP_RATES pItemRates = NULL;
464
465 pDevice->uSIFS = C_SIFS_BG;
466 if (pDevice->bShortSlotTime) {
467 pDevice->uSlot = C_SLOT_SHORT;
468 } else {
469 pDevice->uSlot = C_SLOT_LONG;
470 }
471 pDevice->uDIFS = C_SIFS_BG + 2*pDevice->uSlot;
472
Malcolm Priestley14c5ef52013-01-17 23:19:37 +0000473 pItemRates = (PWLAN_IE_SUPP_RATES)pDevice->vnt_mgmt.abyCurrSuppRates;
Forest Bond92b96792009-06-13 07:38:31 -0400474 for (ii = 0; ii < pItemRates->len; ii++) {
Andres Moreb902fbf2013-02-25 20:32:51 -0500475 byRate = (u8)(pItemRates->abyRates[ii]&0x7F);
Forest Bond92b96792009-06-13 07:38:31 -0400476 if (RATEwGetRateIdx(byRate) > RATE_11M) {
Andres More4e9b5e22013-02-12 20:36:30 -0500477 bOFDMRate = true;
Forest Bond92b96792009-06-13 07:38:31 -0400478 break;
479 }
480 }
Andres Moree269fc22013-02-12 20:36:29 -0500481 if (bOFDMRate == false) {
Malcolm Priestley14c5ef52013-01-17 23:19:37 +0000482 pItemRates = (PWLAN_IE_SUPP_RATES)pDevice->vnt_mgmt
483 .abyCurrExtSuppRates;
Forest Bond92b96792009-06-13 07:38:31 -0400484 for (ii = 0; ii < pItemRates->len; ii++) {
Andres Moreb902fbf2013-02-25 20:32:51 -0500485 byRate = (u8)(pItemRates->abyRates[ii]&0x7F);
Forest Bond92b96792009-06-13 07:38:31 -0400486 if (RATEwGetRateIdx(byRate) > RATE_11M) {
Andres More4e9b5e22013-02-12 20:36:30 -0500487 bOFDMRate = true;
Forest Bond92b96792009-06-13 07:38:31 -0400488 break;
489 }
490 }
491 }
Andres More4e9b5e22013-02-12 20:36:30 -0500492 if (bOFDMRate == true) {
Forest Bond92b96792009-06-13 07:38:31 -0400493 pDevice->uCwMin = C_CWMIN_A;
494 byMaxMin = 4;
495 } else {
496 pDevice->uCwMin = C_CWMIN_B;
497 byMaxMin = 5;
498 }
499 }
500
501 pDevice->uCwMax = C_CWMAX;
502 pDevice->uEIFS = C_EIFS;
503
Andres Moreb902fbf2013-02-25 20:32:51 -0500504 byData[0] = (u8)pDevice->uSIFS;
505 byData[1] = (u8)pDevice->uDIFS;
506 byData[2] = (u8)pDevice->uEIFS;
507 byData[3] = (u8)pDevice->uSlot;
Forest Bond92b96792009-06-13 07:38:31 -0400508 CONTROLnsRequestOut(pDevice,
509 MESSAGE_TYPE_WRITE,
510 MAC_REG_SIFS,
511 MESSAGE_REQUEST_MACREG,
512 4,
513 &byData[0]);
514
515 byMaxMin |= 0xA0;//1010 1111,C_CWMAX = 1023
516 CONTROLnsRequestOut(pDevice,
517 MESSAGE_TYPE_WRITE,
518 MAC_REG_CWMAXMIN0,
519 MESSAGE_REQUEST_MACREG,
520 1,
521 &byMaxMin);
522}
523
Malcolm Priestleydd0a7742012-12-10 21:59:10 +0000524void CARDvUpdateBasicTopRate(struct vnt_private *pDevice)
Forest Bond92b96792009-06-13 07:38:31 -0400525{
Malcolm Priestleydd0a7742012-12-10 21:59:10 +0000526 u8 byTopOFDM = RATE_24M, byTopCCK = RATE_1M;
527 u8 ii;
Forest Bond92b96792009-06-13 07:38:31 -0400528
529 //Determines the highest basic rate.
530 for (ii = RATE_54M; ii >= RATE_6M; ii --) {
Andres More3eaca0d2013-02-25 20:32:52 -0500531 if ( (pDevice->wBasicRate) & ((u16)(1<<ii)) ) {
Forest Bond92b96792009-06-13 07:38:31 -0400532 byTopOFDM = ii;
533 break;
534 }
535 }
536 pDevice->byTopOFDMBasicRate = byTopOFDM;
537
538 for (ii = RATE_11M;; ii --) {
Andres More3eaca0d2013-02-25 20:32:52 -0500539 if ( (pDevice->wBasicRate) & ((u16)(1<<ii)) ) {
Forest Bond92b96792009-06-13 07:38:31 -0400540 byTopCCK = ii;
541 break;
542 }
543 if (ii == RATE_1M)
544 break;
545 }
546 pDevice->byTopCCKBasicRate = byTopCCK;
547 }
548
549/*
550 * Description: Set NIC Tx Basic Rate
551 *
552 * Parameters:
553 * In:
554 * pDevice - The adapter to be set
555 * wBasicRate - Basic Rate to be set
556 * Out:
557 * none
558 *
Andres More4e9b5e22013-02-12 20:36:30 -0500559 * Return Value: true if succeeded; false if failed.
Forest Bond92b96792009-06-13 07:38:31 -0400560 *
561 */
Malcolm Priestleydd0a7742012-12-10 21:59:10 +0000562void CARDbAddBasicRate(struct vnt_private *pDevice, u16 wRateIdx)
Forest Bond92b96792009-06-13 07:38:31 -0400563{
Malcolm Priestleydd0a7742012-12-10 21:59:10 +0000564 u16 wRate = (1 << wRateIdx);
Forest Bond92b96792009-06-13 07:38:31 -0400565
566 pDevice->wBasicRate |= wRate;
567
568 //Determines the highest basic rate.
569 CARDvUpdateBasicTopRate(pDevice);
Forest Bond92b96792009-06-13 07:38:31 -0400570}
571
Malcolm Priestleydd0a7742012-12-10 21:59:10 +0000572int CARDbIsOFDMinBasicRate(struct vnt_private *pDevice)
Forest Bond92b96792009-06-13 07:38:31 -0400573{
Malcolm Priestleydd0a7742012-12-10 21:59:10 +0000574 int ii;
Forest Bond92b96792009-06-13 07:38:31 -0400575
576 for (ii = RATE_54M; ii >= RATE_6M; ii --) {
Andres More3eaca0d2013-02-25 20:32:52 -0500577 if ((pDevice->wBasicRate) & ((u16)(1<<ii)))
Andres More4e9b5e22013-02-12 20:36:30 -0500578 return true;
Forest Bond92b96792009-06-13 07:38:31 -0400579 }
Andres Moree269fc22013-02-12 20:36:29 -0500580 return false;
Forest Bond92b96792009-06-13 07:38:31 -0400581}
582
Malcolm Priestleydd0a7742012-12-10 21:59:10 +0000583u8 CARDbyGetPktType(struct vnt_private *pDevice)
Forest Bond92b96792009-06-13 07:38:31 -0400584{
Forest Bond92b96792009-06-13 07:38:31 -0400585
586 if (pDevice->byBBType == BB_TYPE_11A || pDevice->byBBType == BB_TYPE_11B) {
Andres Moreb902fbf2013-02-25 20:32:51 -0500587 return (u8)pDevice->byBBType;
Forest Bond92b96792009-06-13 07:38:31 -0400588 }
589 else if (CARDbIsOFDMinBasicRate(pDevice)) {
590 return PK_TYPE_11GA;
591 }
592 else {
593 return PK_TYPE_11GB;
594 }
595}
596
Forest Bond92b96792009-06-13 07:38:31 -0400597/*
Justin P. Mattocka0a1f612012-08-26 08:16:43 -0700598 * Description: Calculate TSF offset of two TSF input
Forest Bond92b96792009-06-13 07:38:31 -0400599 * Get TSF Offset from RxBCN's TSF and local TSF
600 *
601 * Parameters:
602 * In:
603 * pDevice - The adapter to be sync.
604 * qwTSF1 - Rx BCN's TSF
605 * qwTSF2 - Local TSF
606 * Out:
607 * none
608 *
609 * Return Value: TSF Offset value
610 *
611 */
Andres Moreb902fbf2013-02-25 20:32:51 -0500612u64 CARDqGetTSFOffset(u8 byRxRate, u64 qwTSF1, u64 qwTSF2)
Forest Bond92b96792009-06-13 07:38:31 -0400613{
Malcolm Priestley7c65fa22012-11-28 21:11:02 +0000614 u64 qwTSFOffset = 0;
Andres More3eaca0d2013-02-25 20:32:52 -0500615 u16 wRxBcnTSFOffst = 0;
Forest Bond92b96792009-06-13 07:38:31 -0400616
Malcolm Priestley7c65fa22012-11-28 21:11:02 +0000617 wRxBcnTSFOffst = cwRXBCNTSFOff[byRxRate % MAX_RATE];
Forest Bond92b96792009-06-13 07:38:31 -0400618
Malcolm Priestley7c65fa22012-11-28 21:11:02 +0000619 qwTSF2 += (u64)wRxBcnTSFOffst;
620
621 qwTSFOffset = qwTSF1 - qwTSF2;
622
623 return qwTSFOffset;
Forest Bond92b96792009-06-13 07:38:31 -0400624}
625
Forest Bond92b96792009-06-13 07:38:31 -0400626/*
627 * Description: Sync. TSF counter to BSS
628 * Get TSF offset and write to HW
629 *
630 * Parameters:
631 * In:
632 * pDevice - The adapter to be sync.
633 * qwBSSTimestamp - Rx BCN's TSF
634 * qwLocalTSF - Local TSF
635 * Out:
636 * none
637 *
638 * Return Value: none
639 *
640 */
Malcolm Priestleydd0a7742012-12-10 21:59:10 +0000641void CARDvAdjustTSF(struct vnt_private *pDevice, u8 byRxRate,
Malcolm Priestley7c65fa22012-11-28 21:11:02 +0000642 u64 qwBSSTimestamp, u64 qwLocalTSF)
Forest Bond92b96792009-06-13 07:38:31 -0400643{
Malcolm Priestley7c65fa22012-11-28 21:11:02 +0000644 u64 qwTSFOffset = 0;
Malcolm Priestleydd0a7742012-12-10 21:59:10 +0000645 u8 pbyData[8];
Forest Bond92b96792009-06-13 07:38:31 -0400646
Forest Bond92b96792009-06-13 07:38:31 -0400647 qwTSFOffset = CARDqGetTSFOffset(byRxRate, qwBSSTimestamp, qwLocalTSF);
648 // adjust TSF
649 // HW's TSF add TSF Offset reg
Forest Bond92b96792009-06-13 07:38:31 -0400650
Malcolm Priestley7c65fa22012-11-28 21:11:02 +0000651 pbyData[0] = (u8)qwTSFOffset;
652 pbyData[1] = (u8)(qwTSFOffset >> 8);
653 pbyData[2] = (u8)(qwTSFOffset >> 16);
654 pbyData[3] = (u8)(qwTSFOffset >> 24);
655 pbyData[4] = (u8)(qwTSFOffset >> 32);
656 pbyData[5] = (u8)(qwTSFOffset >> 40);
657 pbyData[6] = (u8)(qwTSFOffset >> 48);
658 pbyData[7] = (u8)(qwTSFOffset >> 56);
Forest Bond92b96792009-06-13 07:38:31 -0400659
660 CONTROLnsRequestOut(pDevice,
661 MESSAGE_TYPE_SET_TSFTBTT,
662 MESSAGE_REQUEST_TSF,
663 0,
664 8,
665 pbyData
666 );
667
668}
669/*
670 * Description: Read NIC TSF counter
671 * Get local TSF counter
672 *
673 * Parameters:
674 * In:
675 * pDevice - The adapter to be read
676 * Out:
677 * qwCurrTSF - Current TSF counter
678 *
Andres More4e9b5e22013-02-12 20:36:30 -0500679 * Return Value: true if success; otherwise false
Forest Bond92b96792009-06-13 07:38:31 -0400680 *
681 */
Andres Moredfdcc422013-02-12 20:36:28 -0500682bool CARDbGetCurrentTSF(struct vnt_private *pDevice, u64 *pqwCurrTSF)
Forest Bond92b96792009-06-13 07:38:31 -0400683{
Forest Bond92b96792009-06-13 07:38:31 -0400684
Malcolm Priestley7c65fa22012-11-28 21:11:02 +0000685 *pqwCurrTSF = pDevice->qwCurrTSF;
Forest Bond92b96792009-06-13 07:38:31 -0400686
Andres More4e9b5e22013-02-12 20:36:30 -0500687 return true;
Forest Bond92b96792009-06-13 07:38:31 -0400688}
689
Forest Bond92b96792009-06-13 07:38:31 -0400690/*
691 * Description: Clear NIC TSF counter
692 * Clear local TSF counter
693 *
694 * Parameters:
695 * In:
696 * pDevice - The adapter to be read
697 *
Andres More4e9b5e22013-02-12 20:36:30 -0500698 * Return Value: true if success; otherwise false
Forest Bond92b96792009-06-13 07:38:31 -0400699 *
700 */
Andres Moredfdcc422013-02-12 20:36:28 -0500701bool CARDbClearCurrentTSF(struct vnt_private *pDevice)
Forest Bond92b96792009-06-13 07:38:31 -0400702{
Forest Bond92b96792009-06-13 07:38:31 -0400703
Malcolm Priestleydd0a7742012-12-10 21:59:10 +0000704 MACvRegBitsOn(pDevice, MAC_REG_TFTCTL, TFTCTL_TSFCNTRST);
Forest Bond92b96792009-06-13 07:38:31 -0400705
Malcolm Priestley7c65fa22012-11-28 21:11:02 +0000706 pDevice->qwCurrTSF = 0;
Forest Bond92b96792009-06-13 07:38:31 -0400707
Andres More4e9b5e22013-02-12 20:36:30 -0500708 return true;
Forest Bond92b96792009-06-13 07:38:31 -0400709}
710
711/*
712 * Description: Read NIC TSF counter
713 * Get NEXTTBTT from adjusted TSF and Beacon Interval
714 *
715 * Parameters:
716 * In:
717 * qwTSF - Current TSF counter
718 * wbeaconInterval - Beacon Interval
719 * Out:
720 * qwCurrTSF - Current TSF counter
721 *
722 * Return Value: TSF value of next Beacon
723 *
724 */
Andres More3eaca0d2013-02-25 20:32:52 -0500725u64 CARDqGetNextTBTT(u64 qwTSF, u16 wBeaconInterval)
Forest Bond92b96792009-06-13 07:38:31 -0400726{
727
Andres Morecc856e62010-05-17 21:34:01 -0300728 unsigned int uLowNextTBTT;
729 unsigned int uHighRemain, uLowRemain;
730 unsigned int uBeaconInterval;
Forest Bond92b96792009-06-13 07:38:31 -0400731
732 uBeaconInterval = wBeaconInterval * 1024;
733 // Next TBTT = ((local_current_TSF / beacon_interval) + 1 ) * beacon_interval
Malcolm Priestley7c65fa22012-11-28 21:11:02 +0000734 uLowNextTBTT = ((qwTSF & 0xffffffffU) >> 10) << 10;
735 uLowRemain = (uLowNextTBTT) % uBeaconInterval;
736 uHighRemain = ((0x80000000 % uBeaconInterval) * 2 * (u32)(qwTSF >> 32))
737 % uBeaconInterval;
738 uLowRemain = (uHighRemain + uLowRemain) % uBeaconInterval;
739 uLowRemain = uBeaconInterval - uLowRemain;
Forest Bond92b96792009-06-13 07:38:31 -0400740
741 // check if carry when add one beacon interval
Malcolm Priestley7c65fa22012-11-28 21:11:02 +0000742 if ((~uLowNextTBTT) < uLowRemain)
743 qwTSF = ((qwTSF >> 32) + 1) << 32;
Forest Bond92b96792009-06-13 07:38:31 -0400744
Geert Uytterhoevenaa1e1232013-03-04 20:42:00 +0100745 qwTSF = (qwTSF & 0xffffffff00000000ULL) |
Malcolm Priestley7c65fa22012-11-28 21:11:02 +0000746 (u64)(uLowNextTBTT + uLowRemain);
Forest Bond92b96792009-06-13 07:38:31 -0400747
748 return (qwTSF);
749}
750
Forest Bond92b96792009-06-13 07:38:31 -0400751/*
752 * Description: Set NIC TSF counter for first Beacon time
753 * Get NEXTTBTT from adjusted TSF and Beacon Interval
754 *
755 * Parameters:
756 * In:
757 * dwIoBase - IO Base
758 * wBeaconInterval - Beacon Interval
759 * Out:
760 * none
761 *
762 * Return Value: none
763 *
764 */
Andres More3eaca0d2013-02-25 20:32:52 -0500765void CARDvSetFirstNextTBTT(struct vnt_private *pDevice, u16 wBeaconInterval)
Forest Bond92b96792009-06-13 07:38:31 -0400766{
Malcolm Priestley7c65fa22012-11-28 21:11:02 +0000767 u64 qwNextTBTT = 0;
Malcolm Priestleydd0a7742012-12-10 21:59:10 +0000768 u8 pbyData[8];
Forest Bond92b96792009-06-13 07:38:31 -0400769
Malcolm Priestley7c65fa22012-11-28 21:11:02 +0000770 CARDbClearCurrentTSF(pDevice);
Forest Bond92b96792009-06-13 07:38:31 -0400771 //CARDbGetCurrentTSF(pDevice, &qwNextTBTT); //Get Local TSF counter
Malcolm Priestley7c65fa22012-11-28 21:11:02 +0000772 qwNextTBTT = CARDqGetNextTBTT(qwNextTBTT, wBeaconInterval);
Forest Bond92b96792009-06-13 07:38:31 -0400773 // Set NextTBTT
774
Malcolm Priestley7c65fa22012-11-28 21:11:02 +0000775 pbyData[0] = (u8)qwNextTBTT;
776 pbyData[1] = (u8)(qwNextTBTT >> 8);
777 pbyData[2] = (u8)(qwNextTBTT >> 16);
778 pbyData[3] = (u8)(qwNextTBTT >> 24);
779 pbyData[4] = (u8)(qwNextTBTT >> 32);
780 pbyData[5] = (u8)(qwNextTBTT >> 40);
781 pbyData[6] = (u8)(qwNextTBTT >> 48);
782 pbyData[7] = (u8)(qwNextTBTT >> 56);
Forest Bond92b96792009-06-13 07:38:31 -0400783
784 CONTROLnsRequestOut(pDevice,
785 MESSAGE_TYPE_SET_TSFTBTT,
786 MESSAGE_REQUEST_TBTT,
787 0,
788 8,
789 pbyData
790 );
791
792 return;
793}
794
Forest Bond92b96792009-06-13 07:38:31 -0400795/*
796 * Description: Sync NIC TSF counter for Beacon time
797 * Get NEXTTBTT and write to HW
798 *
799 * Parameters:
800 * In:
801 * pDevice - The adapter to be set
802 * qwTSF - Current TSF counter
803 * wBeaconInterval - Beacon Interval
804 * Out:
805 * none
806 *
807 * Return Value: none
808 *
809 */
Malcolm Priestleydd0a7742012-12-10 21:59:10 +0000810void CARDvUpdateNextTBTT(struct vnt_private *pDevice, u64 qwTSF,
811 u16 wBeaconInterval)
Forest Bond92b96792009-06-13 07:38:31 -0400812{
Malcolm Priestleydd0a7742012-12-10 21:59:10 +0000813 u8 pbyData[8];
Forest Bond92b96792009-06-13 07:38:31 -0400814
815 qwTSF = CARDqGetNextTBTT(qwTSF, wBeaconInterval);
816
817 // Set NextTBTT
Forest Bond92b96792009-06-13 07:38:31 -0400818
Malcolm Priestley7c65fa22012-11-28 21:11:02 +0000819 pbyData[0] = (u8)qwTSF;
820 pbyData[1] = (u8)(qwTSF >> 8);
821 pbyData[2] = (u8)(qwTSF >> 16);
822 pbyData[3] = (u8)(qwTSF >> 24);
823 pbyData[4] = (u8)(qwTSF >> 32);
824 pbyData[5] = (u8)(qwTSF >> 40);
825 pbyData[6] = (u8)(qwTSF >> 48);
826 pbyData[7] = (u8)(qwTSF >> 56);
Forest Bond92b96792009-06-13 07:38:31 -0400827
828 CONTROLnsRequestOut(pDevice,
829 MESSAGE_TYPE_SET_TSFTBTT,
830 MESSAGE_REQUEST_TBTT,
831 0,
832 8,
833 pbyData
834 );
835
Malcolm Priestley7c65fa22012-11-28 21:11:02 +0000836 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO
837 "Card:Update Next TBTT[%8lx]\n", (unsigned long)qwTSF);
Forest Bond92b96792009-06-13 07:38:31 -0400838
839 return;
840}
841
842/*
843 * Description: Turn off Radio power
844 *
845 * Parameters:
846 * In:
847 * pDevice - The adapter to be turned off
848 * Out:
849 * none
850 *
Andres More4e9b5e22013-02-12 20:36:30 -0500851 * Return Value: true if success; otherwise false
Forest Bond92b96792009-06-13 07:38:31 -0400852 *
853 */
Malcolm Priestleydd0a7742012-12-10 21:59:10 +0000854int CARDbRadioPowerOff(struct vnt_private *pDevice)
Forest Bond92b96792009-06-13 07:38:31 -0400855{
Andres More4e9b5e22013-02-12 20:36:30 -0500856 int bResult = true;
Forest Bond92b96792009-06-13 07:38:31 -0400857
Andres More4e9b5e22013-02-12 20:36:30 -0500858 //if (pDevice->bRadioOff == true)
859 // return true;
Forest Bond92b96792009-06-13 07:38:31 -0400860
Andres More4e9b5e22013-02-12 20:36:30 -0500861 pDevice->bRadioOff = true;
Forest Bond92b96792009-06-13 07:38:31 -0400862
863 switch (pDevice->byRFType) {
864 case RF_AL2230:
865 case RF_AL2230S:
866 case RF_AIROHA7230:
867 case RF_VT3226: //RobertYu:20051111
868 case RF_VT3226D0:
869 case RF_VT3342A0: //RobertYu:20060609
870 MACvRegBitsOff(pDevice, MAC_REG_SOFTPWRCTL, (SOFTPWRCTL_SWPE2 | SOFTPWRCTL_SWPE3));
871 break;
872 }
873
874 MACvRegBitsOff(pDevice, MAC_REG_HOSTCR, HOSTCR_RXON);
875
876 BBvSetDeepSleep(pDevice);
877
878 return bResult;
879}
880
Forest Bond92b96792009-06-13 07:38:31 -0400881/*
882 * Description: Turn on Radio power
883 *
884 * Parameters:
885 * In:
886 * pDevice - The adapter to be turned on
887 * Out:
888 * none
889 *
Andres More4e9b5e22013-02-12 20:36:30 -0500890 * Return Value: true if success; otherwise false
Forest Bond92b96792009-06-13 07:38:31 -0400891 *
892 */
Malcolm Priestleydd0a7742012-12-10 21:59:10 +0000893int CARDbRadioPowerOn(struct vnt_private *pDevice)
Forest Bond92b96792009-06-13 07:38:31 -0400894{
Andres More4e9b5e22013-02-12 20:36:30 -0500895 int bResult = true;
Forest Bond92b96792009-06-13 07:38:31 -0400896
Andres More4e9b5e22013-02-12 20:36:30 -0500897 if ((pDevice->bHWRadioOff == true) || (pDevice->bRadioControlOff == true)) {
Andres Moree269fc22013-02-12 20:36:29 -0500898 return false;
Forest Bond92b96792009-06-13 07:38:31 -0400899 }
900
Andres Moree269fc22013-02-12 20:36:29 -0500901 //if (pDevice->bRadioOff == false)
Andres More4e9b5e22013-02-12 20:36:30 -0500902 // return true;
Forest Bond92b96792009-06-13 07:38:31 -0400903
Andres Moree269fc22013-02-12 20:36:29 -0500904 pDevice->bRadioOff = false;
Forest Bond92b96792009-06-13 07:38:31 -0400905
906 BBvExitDeepSleep(pDevice);
907
908 MACvRegBitsOn(pDevice, MAC_REG_HOSTCR, HOSTCR_RXON);
909
910 switch (pDevice->byRFType) {
911 case RF_AL2230:
912 case RF_AL2230S:
913 case RF_AIROHA7230:
914 case RF_VT3226: //RobertYu:20051111
915 case RF_VT3226D0:
916 case RF_VT3342A0: //RobertYu:20060609
917 MACvRegBitsOn(pDevice, MAC_REG_SOFTPWRCTL, (SOFTPWRCTL_SWPE2 | SOFTPWRCTL_SWPE3));
918 break;
919 }
920
921 return bResult;
922}
923
Malcolm Priestleydd0a7742012-12-10 21:59:10 +0000924void CARDvSetBSSMode(struct vnt_private *pDevice)
Forest Bond92b96792009-06-13 07:38:31 -0400925{
Forest Bond92b96792009-06-13 07:38:31 -0400926 // Set BB and packet type at the same time.//{{RobertYu:20050222, AL7230 have two TX PA output, only connet to b/g now
927 // so in 11a mode need to set the MAC Reg0x4C to 11b/g mode to turn on PA
928 if( (pDevice->byRFType == RF_AIROHA7230 ) && (pDevice->byBBType == BB_TYPE_11A) )
929 {
930 MACvSetBBType(pDevice, BB_TYPE_11G);
931 }
932 else
933 {
934 MACvSetBBType(pDevice, pDevice->byBBType);
935 }
936 pDevice->byPacketType = CARDbyGetPktType(pDevice);
937
938 if (pDevice->byBBType == BB_TYPE_11A) {
939 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x88, 0x03);
940 } else if (pDevice->byBBType == BB_TYPE_11B) {
941 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x88, 0x02);
942 } else if (pDevice->byBBType == BB_TYPE_11G) {
943 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x88, 0x08);
944 }
945
946 vUpdateIFS(pDevice);
Andres Moreb902fbf2013-02-25 20:32:51 -0500947 CARDvSetRSPINF(pDevice, (u8)pDevice->byBBType);
Forest Bond92b96792009-06-13 07:38:31 -0400948
949 if ( pDevice->byBBType == BB_TYPE_11A ) {
950 //request by Jack 2005-04-26
951 if (pDevice->byRFType == RF_AIROHA7230) {
952 pDevice->abyBBVGA[0] = 0x20;
953 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xE7, pDevice->abyBBVGA[0]);
954 }
955 pDevice->abyBBVGA[2] = 0x10;
956 pDevice->abyBBVGA[3] = 0x10;
957 } else {
958 //request by Jack 2005-04-26
959 if (pDevice->byRFType == RF_AIROHA7230) {
960 pDevice->abyBBVGA[0] = 0x1C;
961 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xE7, pDevice->abyBBVGA[0]);
962 }
963 pDevice->abyBBVGA[2] = 0x0;
964 pDevice->abyBBVGA[3] = 0x0;
965 }
966}