2 * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
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.
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.
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.
20 * Purpose: Provide functions to setup NIC operation mode
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
31 * CARDqGetTSFOffset - Calculate TSFOffset
32 * CARDbGetCurrentTSF - Read Current NIC TSF counter
33 * CARDqGetNextTBTT - Calculate Next Beacon TSF counter
34 * 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
42 * 06-10-2003 Bryan YC Fan: Re-write codes to support VT3253 spec.
43 * 08-26-2003 Kyle Hsu: Modify the definition type of dwIoBase.
44 * 09-01-2003 Bryan YC Fan: Add vUpdateIFS().
62 /*--------------------- Static Definitions -------------------------*/
64 //static int msglevel =MSG_LEVEL_DEBUG;
65 static int msglevel =MSG_LEVEL_INFO;
68 /*--------------------- Static Definitions -------------------------*/
70 /*--------------------- Static Classes ----------------------------*/
72 /*--------------------- Static Variables --------------------------*/
73 //const WORD cwRXBCNTSFOff[MAX_RATE] =
74 //{17, 34, 96, 192, 34, 23, 17, 11, 8, 5, 4, 3};
76 const WORD cwRXBCNTSFOff[MAX_RATE] =
77 {192, 96, 34, 17, 34, 23, 17, 11, 8, 5, 4, 3};
79 /*--------------------- Static Functions --------------------------*/
81 /*--------------------- Export Variables --------------------------*/
83 /*--------------------- Export Functions --------------------------*/
85 * Description: Set NIC media channel
89 * pDevice - The adapter to be set
90 * uConnectionChannel - Channel to be set
94 void CARDbSetMediaChannel(void *pDeviceHandler, unsigned int uConnectionChannel)
96 PSDevice pDevice = (PSDevice) pDeviceHandler;
98 if (pDevice->byBBType == BB_TYPE_11A) { // 15 ~ 38
99 if ((uConnectionChannel < (CB_MAX_CHANNEL_24G+1)) || (uConnectionChannel > CB_MAX_CHANNEL))
100 uConnectionChannel = (CB_MAX_CHANNEL_24G+1);
102 if ((uConnectionChannel > CB_MAX_CHANNEL_24G) || (uConnectionChannel == 0)) // 1 ~ 14
103 uConnectionChannel = 1;
107 MACvRegBitsOn(pDevice, MAC_REG_MACCR, MACCR_CLRNAV);
109 // Set Channel[7] = 0 to tell H/W channel is changing now.
110 MACvRegBitsOff(pDevice, MAC_REG_CHANNEL, 0x80);
112 //if (pMgmt->uCurrChannel == uConnectionChannel)
115 CONTROLnsRequestOut(pDevice,
116 MESSAGE_TYPE_SELECT_CHANNLE,
117 (WORD) uConnectionChannel,
123 //{{ RobertYu: 20041202
124 //// TX_PE will reserve 3 us for MAX2829 A mode only, it is for better TX throughput
126 if (pDevice->byBBType == BB_TYPE_11A) {
127 pDevice->byCurPwr = 0xFF;
128 RFbRawSetPower(pDevice, pDevice->abyOFDMAPwrTbl[uConnectionChannel-15], RATE_54M);
129 } else if (pDevice->byBBType == BB_TYPE_11G) {
130 pDevice->byCurPwr = 0xFF;
131 RFbRawSetPower(pDevice, pDevice->abyOFDMPwrTbl[uConnectionChannel-1], RATE_54M);
133 pDevice->byCurPwr = 0xFF;
134 RFbRawSetPower(pDevice, pDevice->abyCCKPwrTbl[uConnectionChannel-1], RATE_1M);
136 ControlvWriteByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_CHANNEL,(BYTE)(uConnectionChannel|0x80));
140 * Description: Get CCK mode basic rate
144 * pDevice - The adapter to be set
145 * wRateIdx - Receiving data rate
149 * Return Value: response Control frame rate
152 static WORD swGetCCKControlRate(void *pDeviceHandler, WORD wRateIdx)
154 PSDevice pDevice = (PSDevice) pDeviceHandler;
155 unsigned int ui = (unsigned int)wRateIdx;
156 while (ui > RATE_1M) {
157 if (pDevice->wBasicRate & ((WORD)1 << ui)) {
162 return (WORD)RATE_1M;
166 * Description: Get OFDM mode basic rate
170 * pDevice - The adapter to be set
171 * wRateIdx - Receiving data rate
175 * Return Value: response Control frame rate
178 static WORD swGetOFDMControlRate(void *pDeviceHandler, WORD wRateIdx)
180 PSDevice pDevice = (PSDevice) pDeviceHandler;
181 unsigned int ui = (unsigned int)wRateIdx;
183 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"BASIC RATE: %X\n", pDevice->wBasicRate);
185 if (!CARDbIsOFDMinBasicRate(pDevice)) {
186 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"swGetOFDMControlRate:(NO OFDM) %d\n", wRateIdx);
187 if (wRateIdx > RATE_24M)
191 while (ui > RATE_11M) {
192 if (pDevice->wBasicRate & ((WORD)1 << ui)) {
193 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"swGetOFDMControlRate : %d\n", ui);
198 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"swGetOFDMControlRate: 6M\n");
199 return (WORD)RATE_24M;
203 * Description: Calculate TxRate and RsvTime fields for RSPINF in OFDM mode.
208 * byPktType - Tx Packet type
210 * pbyTxRate - pointer to RSPINF TxRate field
211 * pbyRsvTime - pointer to RSPINF RsvTime field
217 CARDvCalculateOFDMRParameter (
226 if (byBBType == BB_TYPE_11A) {//5GHZ
237 if (byBBType == BB_TYPE_11A) {//5GHZ
248 if (byBBType == BB_TYPE_11A) {//5GHZ
259 if (byBBType == BB_TYPE_11A) {//5GHZ
270 if (byBBType == BB_TYPE_11A) {//5GHZ
281 if (byBBType == BB_TYPE_11A) {//5GHZ
292 if (byBBType == BB_TYPE_11A) {//5GHZ
304 if (byBBType == BB_TYPE_11A) {//5GHZ
317 * Description: Set RSPINF
321 * pDevice - The adapter to be set
325 * Return Value: None.
328 void CARDvSetRSPINF(void *pDeviceHandler, BYTE byBBType)
330 PSDevice pDevice = (PSDevice) pDeviceHandler;
331 BYTE abyServ[4] = {0,0,0,0}; // For CCK
332 BYTE abySignal[4] = {0,0,0,0};
333 WORD awLen[4] = {0,0,0,0};
334 BYTE abyTxRate[9] = {0,0,0,0,0,0,0,0,0}; // For OFDM
335 BYTE abyRsvTime[9] = {0,0,0,0,0,0,0,0,0};
340 BBvCalculateParameter(pDevice,
342 swGetCCKControlRate(pDevice, RATE_1M),
350 BBvCalculateParameter(pDevice,
352 swGetCCKControlRate(pDevice, RATE_2M),
360 BBvCalculateParameter(pDevice,
362 swGetCCKControlRate(pDevice, RATE_5M),
370 BBvCalculateParameter(pDevice,
372 swGetCCKControlRate(pDevice, RATE_11M),
380 CARDvCalculateOFDMRParameter (RATE_6M,
386 CARDvCalculateOFDMRParameter (RATE_9M,
392 CARDvCalculateOFDMRParameter (RATE_12M,
398 CARDvCalculateOFDMRParameter (RATE_18M,
404 CARDvCalculateOFDMRParameter (RATE_24M,
410 CARDvCalculateOFDMRParameter (swGetOFDMControlRate(pDevice, RATE_36M),
416 CARDvCalculateOFDMRParameter (swGetOFDMControlRate(pDevice, RATE_48M),
422 CARDvCalculateOFDMRParameter (swGetOFDMControlRate(pDevice, RATE_54M),
428 CARDvCalculateOFDMRParameter (swGetOFDMControlRate(pDevice, RATE_54M),
433 abyData[0] = (BYTE)(awLen[0]&0xFF);
434 abyData[1] = (BYTE)(awLen[0]>>8);
435 abyData[2] = abySignal[0];
436 abyData[3] = abyServ[0];
438 abyData[4] = (BYTE)(awLen[1]&0xFF);
439 abyData[5] = (BYTE)(awLen[1]>>8);
440 abyData[6] = abySignal[1];
441 abyData[7] = abyServ[1];
443 abyData[8] = (BYTE)(awLen[2]&0xFF);
444 abyData[9] = (BYTE)(awLen[2]>>8);
445 abyData[10] = abySignal[2];
446 abyData[11] = abyServ[2];
448 abyData[12] = (BYTE)(awLen[3]&0xFF);
449 abyData[13] = (BYTE)(awLen[3]>>8);
450 abyData[14] = abySignal[3];
451 abyData[15] = abyServ[3];
453 for (i = 0; i < 9; i++) {
454 abyData[16+i*2] = abyTxRate[i];
455 abyData[16+i*2+1] = abyRsvTime[i];
458 CONTROLnsRequestOut(pDevice,
461 MESSAGE_REQUEST_MACREG,
468 * Description: Update IFS
472 * pDevice - The adapter to be set
476 * Return Value: None.
479 void vUpdateIFS(void *pDeviceHandler)
481 PSDevice pDevice = (PSDevice) pDeviceHandler;
482 //Set SIFS, DIFS, EIFS, SlotTime, CwMin
486 if (pDevice->byPacketType==PK_TYPE_11A) {//0000 0000 0000 0000,11a
487 pDevice->uSlot = C_SLOT_SHORT;
488 pDevice->uSIFS = C_SIFS_A;
489 pDevice->uDIFS = C_SIFS_A + 2*C_SLOT_SHORT;
490 pDevice->uCwMin = C_CWMIN_A;
493 else if (pDevice->byPacketType==PK_TYPE_11B) {//0000 0001 0000 0000,11b
494 pDevice->uSlot = C_SLOT_LONG;
495 pDevice->uSIFS = C_SIFS_BG;
496 pDevice->uDIFS = C_SIFS_BG + 2*C_SLOT_LONG;
497 pDevice->uCwMin = C_CWMIN_B;
500 else {// PK_TYPE_11GA & PK_TYPE_11GB
502 BOOL bOFDMRate = FALSE;
504 PWLAN_IE_SUPP_RATES pItemRates = NULL;
506 pDevice->uSIFS = C_SIFS_BG;
507 if (pDevice->bShortSlotTime) {
508 pDevice->uSlot = C_SLOT_SHORT;
510 pDevice->uSlot = C_SLOT_LONG;
512 pDevice->uDIFS = C_SIFS_BG + 2*pDevice->uSlot;
514 pItemRates = (PWLAN_IE_SUPP_RATES)pDevice->sMgmtObj.abyCurrSuppRates;
515 for (ii = 0; ii < pItemRates->len; ii++) {
516 byRate = (BYTE)(pItemRates->abyRates[ii]&0x7F);
517 if (RATEwGetRateIdx(byRate) > RATE_11M) {
522 if (bOFDMRate == FALSE) {
523 pItemRates = (PWLAN_IE_SUPP_RATES)pDevice->sMgmtObj.abyCurrExtSuppRates;
524 for (ii = 0; ii < pItemRates->len; ii++) {
525 byRate = (BYTE)(pItemRates->abyRates[ii]&0x7F);
526 if (RATEwGetRateIdx(byRate) > RATE_11M) {
532 if (bOFDMRate == TRUE) {
533 pDevice->uCwMin = C_CWMIN_A;
536 pDevice->uCwMin = C_CWMIN_B;
541 pDevice->uCwMax = C_CWMAX;
542 pDevice->uEIFS = C_EIFS;
544 byData[0] = (BYTE)pDevice->uSIFS;
545 byData[1] = (BYTE)pDevice->uDIFS;
546 byData[2] = (BYTE)pDevice->uEIFS;
547 byData[3] = (BYTE)pDevice->uSlot;
548 CONTROLnsRequestOut(pDevice,
551 MESSAGE_REQUEST_MACREG,
555 byMaxMin |= 0xA0;//1010 1111,C_CWMAX = 1023
556 CONTROLnsRequestOut(pDevice,
559 MESSAGE_REQUEST_MACREG,
564 void CARDvUpdateBasicTopRate(void *pDeviceHandler)
566 PSDevice pDevice = (PSDevice) pDeviceHandler;
567 BYTE byTopOFDM = RATE_24M, byTopCCK = RATE_1M;
570 //Determines the highest basic rate.
571 for (ii = RATE_54M; ii >= RATE_6M; ii --) {
572 if ( (pDevice->wBasicRate) & ((WORD)(1<<ii)) ) {
577 pDevice->byTopOFDMBasicRate = byTopOFDM;
579 for (ii = RATE_11M;; ii --) {
580 if ( (pDevice->wBasicRate) & ((WORD)(1<<ii)) ) {
587 pDevice->byTopCCKBasicRate = byTopCCK;
591 * Description: Set NIC Tx Basic Rate
595 * pDevice - The adapter to be set
596 * wBasicRate - Basic Rate to be set
600 * Return Value: TRUE if succeeded; FALSE if failed.
603 void CARDbAddBasicRate(void *pDeviceHandler, WORD wRateIdx)
605 PSDevice pDevice = (PSDevice) pDeviceHandler;
606 WORD wRate = (WORD)(1<<wRateIdx);
608 pDevice->wBasicRate |= wRate;
610 //Determines the highest basic rate.
611 CARDvUpdateBasicTopRate(pDevice);
614 BOOL CARDbIsOFDMinBasicRate(void *pDeviceHandler)
616 PSDevice pDevice = (PSDevice) pDeviceHandler;
619 for (ii = RATE_54M; ii >= RATE_6M; ii --) {
620 if ((pDevice->wBasicRate) & ((WORD)(1<<ii)))
626 BYTE CARDbyGetPktType(void *pDeviceHandler)
628 PSDevice pDevice = (PSDevice) pDeviceHandler;
630 if (pDevice->byBBType == BB_TYPE_11A || pDevice->byBBType == BB_TYPE_11B) {
631 return (BYTE)pDevice->byBBType;
633 else if (CARDbIsOFDMinBasicRate(pDevice)) {
643 * Description: Calculate TSF offset of two TSF input
644 * Get TSF Offset from RxBCN's TSF and local TSF
648 * pDevice - The adapter to be sync.
649 * qwTSF1 - Rx BCN's TSF
654 * Return Value: TSF Offset value
657 u64 CARDqGetTSFOffset(BYTE byRxRate, u64 qwTSF1, u64 qwTSF2)
660 WORD wRxBcnTSFOffst = 0;
662 wRxBcnTSFOffst = cwRXBCNTSFOff[byRxRate % MAX_RATE];
664 qwTSF2 += (u64)wRxBcnTSFOffst;
666 qwTSFOffset = qwTSF1 - qwTSF2;
674 * Description: Sync. TSF counter to BSS
675 * Get TSF offset and write to HW
679 * pDevice - The adapter to be sync.
680 * qwBSSTimestamp - Rx BCN's TSF
681 * qwLocalTSF - Local TSF
688 void CARDvAdjustTSF(void *pDeviceHandler, BYTE byRxRate,
689 u64 qwBSSTimestamp, u64 qwLocalTSF)
692 PSDevice pDevice = (PSDevice) pDeviceHandler;
697 qwTSFOffset = CARDqGetTSFOffset(byRxRate, qwBSSTimestamp, qwLocalTSF);
699 // HW's TSF add TSF Offset reg
701 pbyData[0] = (u8)qwTSFOffset;
702 pbyData[1] = (u8)(qwTSFOffset >> 8);
703 pbyData[2] = (u8)(qwTSFOffset >> 16);
704 pbyData[3] = (u8)(qwTSFOffset >> 24);
705 pbyData[4] = (u8)(qwTSFOffset >> 32);
706 pbyData[5] = (u8)(qwTSFOffset >> 40);
707 pbyData[6] = (u8)(qwTSFOffset >> 48);
708 pbyData[7] = (u8)(qwTSFOffset >> 56);
710 CONTROLnsRequestOut(pDevice,
711 MESSAGE_TYPE_SET_TSFTBTT,
720 * Description: Read NIC TSF counter
721 * Get local TSF counter
725 * pDevice - The adapter to be read
727 * qwCurrTSF - Current TSF counter
729 * Return Value: TRUE if success; otherwise FALSE
732 BOOL CARDbGetCurrentTSF(void *pDeviceHandler, u64 *pqwCurrTSF)
734 PSDevice pDevice = (PSDevice) pDeviceHandler;
736 *pqwCurrTSF = pDevice->qwCurrTSF;
743 * Description: Clear NIC TSF counter
744 * Clear local TSF counter
748 * pDevice - The adapter to be read
750 * Return Value: TRUE if success; otherwise FALSE
753 BOOL CARDbClearCurrentTSF(void *pDeviceHandler)
755 PSDevice pDevice = (PSDevice) pDeviceHandler;
757 MACvRegBitsOn(pDevice,MAC_REG_TFTCTL,TFTCTL_TSFCNTRST);
759 pDevice->qwCurrTSF = 0;
765 * Description: Read NIC TSF counter
766 * Get NEXTTBTT from adjusted TSF and Beacon Interval
770 * qwTSF - Current TSF counter
771 * wbeaconInterval - Beacon Interval
773 * qwCurrTSF - Current TSF counter
775 * Return Value: TSF value of next Beacon
778 u64 CARDqGetNextTBTT(u64 qwTSF, WORD wBeaconInterval)
781 unsigned int uLowNextTBTT;
782 unsigned int uHighRemain, uLowRemain;
783 unsigned int uBeaconInterval;
785 uBeaconInterval = wBeaconInterval * 1024;
786 // Next TBTT = ((local_current_TSF / beacon_interval) + 1 ) * beacon_interval
787 uLowNextTBTT = ((qwTSF & 0xffffffffU) >> 10) << 10;
788 uLowRemain = (uLowNextTBTT) % uBeaconInterval;
789 uHighRemain = ((0x80000000 % uBeaconInterval) * 2 * (u32)(qwTSF >> 32))
791 uLowRemain = (uHighRemain + uLowRemain) % uBeaconInterval;
792 uLowRemain = uBeaconInterval - uLowRemain;
794 // check if carry when add one beacon interval
795 if ((~uLowNextTBTT) < uLowRemain)
796 qwTSF = ((qwTSF >> 32) + 1) << 32;
798 qwTSF = (qwTSF & 0xffffffff00000000U) |
799 (u64)(uLowNextTBTT + uLowRemain);
806 * Description: Set NIC TSF counter for first Beacon time
807 * Get NEXTTBTT from adjusted TSF and Beacon Interval
812 * wBeaconInterval - Beacon Interval
819 void CARDvSetFirstNextTBTT(void *pDeviceHandler, WORD wBeaconInterval)
822 PSDevice pDevice = (PSDevice) pDeviceHandler;
826 CARDbClearCurrentTSF(pDevice);
827 //CARDbGetCurrentTSF(pDevice, &qwNextTBTT); //Get Local TSF counter
828 qwNextTBTT = CARDqGetNextTBTT(qwNextTBTT, wBeaconInterval);
831 pbyData[0] = (u8)qwNextTBTT;
832 pbyData[1] = (u8)(qwNextTBTT >> 8);
833 pbyData[2] = (u8)(qwNextTBTT >> 16);
834 pbyData[3] = (u8)(qwNextTBTT >> 24);
835 pbyData[4] = (u8)(qwNextTBTT >> 32);
836 pbyData[5] = (u8)(qwNextTBTT >> 40);
837 pbyData[6] = (u8)(qwNextTBTT >> 48);
838 pbyData[7] = (u8)(qwNextTBTT >> 56);
840 CONTROLnsRequestOut(pDevice,
841 MESSAGE_TYPE_SET_TSFTBTT,
842 MESSAGE_REQUEST_TBTT,
853 * Description: Sync NIC TSF counter for Beacon time
854 * Get NEXTTBTT and write to HW
858 * pDevice - The adapter to be set
859 * qwTSF - Current TSF counter
860 * wBeaconInterval - Beacon Interval
867 void CARDvUpdateNextTBTT(void *pDeviceHandler, u64 qwTSF,
868 WORD wBeaconInterval)
870 PSDevice pDevice = (PSDevice) pDeviceHandler;
873 qwTSF = CARDqGetNextTBTT(qwTSF, wBeaconInterval);
877 pbyData[0] = (u8)qwTSF;
878 pbyData[1] = (u8)(qwTSF >> 8);
879 pbyData[2] = (u8)(qwTSF >> 16);
880 pbyData[3] = (u8)(qwTSF >> 24);
881 pbyData[4] = (u8)(qwTSF >> 32);
882 pbyData[5] = (u8)(qwTSF >> 40);
883 pbyData[6] = (u8)(qwTSF >> 48);
884 pbyData[7] = (u8)(qwTSF >> 56);
886 CONTROLnsRequestOut(pDevice,
887 MESSAGE_TYPE_SET_TSFTBTT,
888 MESSAGE_REQUEST_TBTT,
895 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO
896 "Card:Update Next TBTT[%8lx]\n", (unsigned long)qwTSF);
902 * Description: Turn off Radio power
906 * pDevice - The adapter to be turned off
910 * Return Value: TRUE if success; otherwise FALSE
913 BOOL CARDbRadioPowerOff(void *pDeviceHandler)
915 PSDevice pDevice = (PSDevice) pDeviceHandler;
918 //if (pDevice->bRadioOff == TRUE)
921 pDevice->bRadioOff = TRUE;
923 switch (pDevice->byRFType) {
927 case RF_VT3226: //RobertYu:20051111
929 case RF_VT3342A0: //RobertYu:20060609
930 MACvRegBitsOff(pDevice, MAC_REG_SOFTPWRCTL, (SOFTPWRCTL_SWPE2 | SOFTPWRCTL_SWPE3));
934 MACvRegBitsOff(pDevice, MAC_REG_HOSTCR, HOSTCR_RXON);
936 BBvSetDeepSleep(pDevice);
943 * Description: Turn on Radio power
947 * pDevice - The adapter to be turned on
951 * Return Value: TRUE if success; otherwise FALSE
954 BOOL CARDbRadioPowerOn(void *pDeviceHandler)
956 PSDevice pDevice = (PSDevice) pDeviceHandler;
960 if ((pDevice->bHWRadioOff == TRUE) || (pDevice->bRadioControlOff == TRUE)) {
964 //if (pDevice->bRadioOff == FALSE)
967 pDevice->bRadioOff = FALSE;
969 BBvExitDeepSleep(pDevice);
971 MACvRegBitsOn(pDevice, MAC_REG_HOSTCR, HOSTCR_RXON);
973 switch (pDevice->byRFType) {
977 case RF_VT3226: //RobertYu:20051111
979 case RF_VT3342A0: //RobertYu:20060609
980 MACvRegBitsOn(pDevice, MAC_REG_SOFTPWRCTL, (SOFTPWRCTL_SWPE2 | SOFTPWRCTL_SWPE3));
987 void CARDvSetBSSMode(void *pDeviceHandler)
989 PSDevice pDevice = (PSDevice) pDeviceHandler;
990 // Set BB and packet type at the same time.//{{RobertYu:20050222, AL7230 have two TX PA output, only connet to b/g now
991 // so in 11a mode need to set the MAC Reg0x4C to 11b/g mode to turn on PA
992 if( (pDevice->byRFType == RF_AIROHA7230 ) && (pDevice->byBBType == BB_TYPE_11A) )
994 MACvSetBBType(pDevice, BB_TYPE_11G);
998 MACvSetBBType(pDevice, pDevice->byBBType);
1000 pDevice->byPacketType = CARDbyGetPktType(pDevice);
1002 if (pDevice->byBBType == BB_TYPE_11A) {
1003 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x88, 0x03);
1004 } else if (pDevice->byBBType == BB_TYPE_11B) {
1005 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x88, 0x02);
1006 } else if (pDevice->byBBType == BB_TYPE_11G) {
1007 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x88, 0x08);
1010 vUpdateIFS(pDevice);
1011 CARDvSetRSPINF(pDevice, (BYTE)pDevice->byBBType);
1013 if ( pDevice->byBBType == BB_TYPE_11A ) {
1014 //request by Jack 2005-04-26
1015 if (pDevice->byRFType == RF_AIROHA7230) {
1016 pDevice->abyBBVGA[0] = 0x20;
1017 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xE7, pDevice->abyBBVGA[0]);
1019 pDevice->abyBBVGA[2] = 0x10;
1020 pDevice->abyBBVGA[3] = 0x10;
1022 //request by Jack 2005-04-26
1023 if (pDevice->byRFType == RF_AIROHA7230) {
1024 pDevice->abyBBVGA[0] = 0x1C;
1025 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xE7, pDevice->abyBBVGA[0]);
1027 pDevice->abyBBVGA[2] = 0x0;
1028 pDevice->abyBBVGA[3] = 0x0;
1035 * Do Channel Switch defined in 802.11h
1039 * hDeviceContext - device structure point
1043 * Return Value: none.
1047 CARDbChannelSwitch (
1048 void *pDeviceHandler,
1054 PSDevice pDevice = (PSDevice) pDeviceHandler;
1055 BOOL bResult = TRUE;
1058 pDevice->sMgmtObj.uCurrChannel = byNewChannel;
1059 CARDbSetMediaChannel(pDevice, byNewChannel);
1063 pDevice->byChannelSwitchCount = byCount;
1064 pDevice->byNewChannel = byNewChannel;
1065 pDevice->bChannelSwitch = TRUE;
1068 //bResult=CARDbStopTxPacket(pDevice, PKT_TYPE_802_11_ALL);
1069 pDevice->bStopDataPkt = TRUE;