mdio-sun4i: oops in error handling in probe
[linux/fpc-iii.git] / drivers / staging / vt6656 / card.c
blobd662e5431daddc66629b951a64de5eb312dc32af
1 /*
2 * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
3 * All rights reserved.
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.
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
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
41 * Revision History:
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().
48 #include "device.h"
49 #include "tmacro.h"
50 #include "card.h"
51 #include "baseband.h"
52 #include "mac.h"
53 #include "desc.h"
54 #include "rf.h"
55 #include "power.h"
56 #include "key.h"
57 #include "rc4.h"
58 #include "country.h"
59 #include "datarate.h"
60 #include "usbpipe.h"
62 //const u16 cwRXBCNTSFOff[MAX_RATE] =
63 //{17, 34, 96, 192, 34, 23, 17, 11, 8, 5, 4, 3};
65 static const u16 cwRXBCNTSFOff[MAX_RATE] =
66 {192, 96, 34, 17, 34, 23, 17, 11, 8, 5, 4, 3};
69 * Description: Set NIC media channel
71 * Parameters:
72 * In:
73 * pDevice - The adapter to be set
74 * connection_channel - Channel to be set
75 * Out:
76 * none
78 void CARDbSetMediaChannel(struct vnt_private *priv, u32 connection_channel)
81 if (priv->byBBType == BB_TYPE_11A) {
82 if ((connection_channel < (CB_MAX_CHANNEL_24G + 1)) ||
83 (connection_channel > CB_MAX_CHANNEL))
84 connection_channel = (CB_MAX_CHANNEL_24G + 1);
85 } else {
86 if ((connection_channel > CB_MAX_CHANNEL_24G) ||
87 (connection_channel == 0))
88 connection_channel = 1;
91 /* clear NAV */
92 MACvRegBitsOn(priv, MAC_REG_MACCR, MACCR_CLRNAV);
94 /* Set Channel[7] = 0 to tell H/W channel is changing now. */
95 MACvRegBitsOff(priv, MAC_REG_CHANNEL, 0xb0);
97 vnt_control_out(priv, MESSAGE_TYPE_SELECT_CHANNLE,
98 connection_channel, 0, 0, NULL);
100 if (priv->byBBType == BB_TYPE_11A) {
101 priv->byCurPwr = 0xff;
102 vnt_rf_set_txpower(priv,
103 priv->abyOFDMAPwrTbl[connection_channel-15], RATE_54M);
104 } else if (priv->byBBType == BB_TYPE_11G) {
105 priv->byCurPwr = 0xff;
106 vnt_rf_set_txpower(priv,
107 priv->abyOFDMPwrTbl[connection_channel-1], RATE_54M);
108 } else {
109 priv->byCurPwr = 0xff;
110 vnt_rf_set_txpower(priv,
111 priv->abyCCKPwrTbl[connection_channel-1], RATE_1M);
114 vnt_control_out_u8(priv, MESSAGE_REQUEST_MACREG, MAC_REG_CHANNEL,
115 (u8)(connection_channel|0x80));
119 * Description: Get CCK mode basic rate
121 * Parameters:
122 * In:
123 * priv - The adapter to be set
124 * rate_idx - Receiving data rate
125 * Out:
126 * none
128 * Return Value: response Control frame rate
131 static u16 swGetCCKControlRate(struct vnt_private *priv, u16 rate_idx)
133 u16 ui = rate_idx;
135 while (ui > RATE_1M) {
136 if (priv->wBasicRate & (1 << ui))
137 return ui;
138 ui--;
141 return RATE_1M;
145 * Description: Get OFDM mode basic rate
147 * Parameters:
148 * In:
149 * priv - The adapter to be set
150 * rate_idx - Receiving data rate
151 * Out:
152 * none
154 * Return Value: response Control frame rate
157 static u16 swGetOFDMControlRate(struct vnt_private *priv, u16 rate_idx)
159 u16 ui = rate_idx;
161 dev_dbg(&priv->usb->dev, "%s basic rate: %d\n",
162 __func__, priv->wBasicRate);
164 if (!CARDbIsOFDMinBasicRate(priv)) {
165 dev_dbg(&priv->usb->dev, "%s (NO OFDM) %d\n",
166 __func__, rate_idx);
167 if (rate_idx > RATE_24M)
168 rate_idx = RATE_24M;
169 return rate_idx;
172 while (ui > RATE_11M) {
173 if (priv->wBasicRate & (1 << ui)) {
174 dev_dbg(&priv->usb->dev, "%s rate: %d\n",
175 __func__, ui);
176 return ui;
178 ui--;
181 dev_dbg(&priv->usb->dev, "%s basic rate: 24M\n", __func__);
183 return RATE_24M;
187 * Description: Calculate TxRate and RsvTime fields for RSPINF in OFDM mode.
189 * Parameters:
190 * In:
191 * rate - Tx Rate
192 * bb_type - Tx Packet type
193 * Out:
194 * tx_rate - pointer to RSPINF TxRate field
195 * rsv_time- pointer to RSPINF RsvTime field
197 * Return Value: none
200 static void CARDvCalculateOFDMRParameter(u16 rate, u8 bb_type,
201 u8 *tx_rate, u8 *rsv_time)
204 switch (rate) {
205 case RATE_6M:
206 if (bb_type == BB_TYPE_11A) {
207 *tx_rate = 0x9b;
208 *rsv_time = 24;
209 } else {
210 *tx_rate = 0x8b;
211 *rsv_time = 30;
213 break;
214 case RATE_9M:
215 if (bb_type == BB_TYPE_11A) {
216 *tx_rate = 0x9f;
217 *rsv_time = 16;
218 } else {
219 *tx_rate = 0x8f;
220 *rsv_time = 22;
222 break;
223 case RATE_12M:
224 if (bb_type == BB_TYPE_11A) {
225 *tx_rate = 0x9a;
226 *rsv_time = 12;
227 } else {
228 *tx_rate = 0x8a;
229 *rsv_time = 18;
231 break;
232 case RATE_18M:
233 if (bb_type == BB_TYPE_11A) {
234 *tx_rate = 0x9e;
235 *rsv_time = 8;
236 } else {
237 *tx_rate = 0x8e;
238 *rsv_time = 14;
240 break;
241 case RATE_36M:
242 if (bb_type == BB_TYPE_11A) {
243 *tx_rate = 0x9d;
244 *rsv_time = 4;
245 } else {
246 *tx_rate = 0x8d;
247 *rsv_time = 10;
249 break;
250 case RATE_48M:
251 if (bb_type == BB_TYPE_11A) {
252 *tx_rate = 0x98;
253 *rsv_time = 4;
254 } else {
255 *tx_rate = 0x88;
256 *rsv_time = 10;
258 break;
259 case RATE_54M:
260 if (bb_type == BB_TYPE_11A) {
261 *tx_rate = 0x9c;
262 *rsv_time = 4;
263 } else {
264 *tx_rate = 0x8c;
265 *rsv_time = 10;
267 break;
268 case RATE_24M:
269 default:
270 if (bb_type == BB_TYPE_11A) {
271 *tx_rate = 0x99;
272 *rsv_time = 8;
273 } else {
274 *tx_rate = 0x89;
275 *rsv_time = 14;
277 break;
282 * Description: Set RSPINF
284 * Parameters:
285 * In:
286 * pDevice - The adapter to be set
287 * Out:
288 * none
290 * Return Value: None.
294 void CARDvSetRSPINF(struct vnt_private *priv, u8 bb_type)
296 struct vnt_phy_field phy[4];
297 u8 tx_rate[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0}; /* For OFDM */
298 u8 rsv_time[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
299 u8 data[34];
300 int i;
302 /*RSPINF_b_1*/
303 BBvCalculateParameter(priv, 14,
304 swGetCCKControlRate(priv, RATE_1M), PK_TYPE_11B, &phy[0]);
306 /*RSPINF_b_2*/
307 BBvCalculateParameter(priv, 14,
308 swGetCCKControlRate(priv, RATE_2M), PK_TYPE_11B, &phy[1]);
310 /*RSPINF_b_5*/
311 BBvCalculateParameter(priv, 14,
312 swGetCCKControlRate(priv, RATE_5M), PK_TYPE_11B, &phy[2]);
314 /*RSPINF_b_11*/
315 BBvCalculateParameter(priv, 14,
316 swGetCCKControlRate(priv, RATE_11M), PK_TYPE_11B, &phy[3]);
319 /*RSPINF_a_6*/
320 CARDvCalculateOFDMRParameter(RATE_6M, bb_type,
321 &tx_rate[0], &rsv_time[0]);
323 /*RSPINF_a_9*/
324 CARDvCalculateOFDMRParameter(RATE_9M, bb_type,
325 &tx_rate[1], &rsv_time[1]);
327 /*RSPINF_a_12*/
328 CARDvCalculateOFDMRParameter(RATE_12M, bb_type,
329 &tx_rate[2], &rsv_time[2]);
331 /*RSPINF_a_18*/
332 CARDvCalculateOFDMRParameter(RATE_18M, bb_type,
333 &tx_rate[3], &rsv_time[3]);
335 /*RSPINF_a_24*/
336 CARDvCalculateOFDMRParameter(RATE_24M, bb_type,
337 &tx_rate[4], &rsv_time[4]);
339 /*RSPINF_a_36*/
340 CARDvCalculateOFDMRParameter(swGetOFDMControlRate(priv, RATE_36M),
341 bb_type, &tx_rate[5], &rsv_time[5]);
343 /*RSPINF_a_48*/
344 CARDvCalculateOFDMRParameter(swGetOFDMControlRate(priv, RATE_48M),
345 bb_type, &tx_rate[6], &rsv_time[6]);
347 /*RSPINF_a_54*/
348 CARDvCalculateOFDMRParameter(swGetOFDMControlRate(priv, RATE_54M),
349 bb_type, &tx_rate[7], &rsv_time[7]);
351 /*RSPINF_a_72*/
352 CARDvCalculateOFDMRParameter(swGetOFDMControlRate(priv, RATE_54M),
353 bb_type, &tx_rate[8], &rsv_time[8]);
355 put_unaligned(phy[0].len, (u16 *)&data[0]);
356 data[2] = phy[0].signal;
357 data[3] = phy[0].service;
359 put_unaligned(phy[1].len, (u16 *)&data[4]);
360 data[6] = phy[1].signal;
361 data[7] = phy[1].service;
363 put_unaligned(phy[2].len, (u16 *)&data[8]);
364 data[10] = phy[2].signal;
365 data[11] = phy[2].service;
367 put_unaligned(phy[3].len, (u16 *)&data[12]);
368 data[14] = phy[3].signal;
369 data[15] = phy[3].service;
371 for (i = 0; i < 9; i++) {
372 data[16 + i * 2] = tx_rate[i];
373 data[16 + i * 2 + 1] = rsv_time[i];
376 vnt_control_out(priv, MESSAGE_TYPE_WRITE,
377 MAC_REG_RSPINF_B_1, MESSAGE_REQUEST_MACREG, 34, &data[0]);
381 * Description: Update IFS
383 * Parameters:
384 * In:
385 * priv - The adapter to be set
386 * Out:
387 * none
389 * Return Value: None.
392 void vUpdateIFS(struct vnt_private *priv)
394 u8 max_min = 0;
395 u8 data[4];
397 if (priv->byPacketType == PK_TYPE_11A) {
398 priv->uSlot = C_SLOT_SHORT;
399 priv->uSIFS = C_SIFS_A;
400 priv->uDIFS = C_SIFS_A + 2 * C_SLOT_SHORT;
401 priv->uCwMin = C_CWMIN_A;
402 max_min = 4;
403 } else if (priv->byPacketType == PK_TYPE_11B) {
404 priv->uSlot = C_SLOT_LONG;
405 priv->uSIFS = C_SIFS_BG;
406 priv->uDIFS = C_SIFS_BG + 2 * C_SLOT_LONG;
407 priv->uCwMin = C_CWMIN_B;
408 max_min = 5;
409 } else {/* PK_TYPE_11GA & PK_TYPE_11GB */
410 u8 rate = 0;
411 bool ofdm_rate = false;
412 unsigned int ii = 0;
413 PWLAN_IE_SUPP_RATES item_rates = NULL;
415 priv->uSIFS = C_SIFS_BG;
417 if (priv->bShortSlotTime)
418 priv->uSlot = C_SLOT_SHORT;
419 else
420 priv->uSlot = C_SLOT_LONG;
422 priv->uDIFS = C_SIFS_BG + 2 * priv->uSlot;
424 item_rates =
425 (PWLAN_IE_SUPP_RATES)priv->vnt_mgmt.abyCurrSuppRates;
427 for (ii = 0; ii < item_rates->len; ii++) {
428 rate = (u8)(item_rates->abyRates[ii] & 0x7f);
429 if (RATEwGetRateIdx(rate) > RATE_11M) {
430 ofdm_rate = true;
431 break;
435 if (ofdm_rate == false) {
436 item_rates = (PWLAN_IE_SUPP_RATES)priv->vnt_mgmt
437 .abyCurrExtSuppRates;
438 for (ii = 0; ii < item_rates->len; ii++) {
439 rate = (u8)(item_rates->abyRates[ii] & 0x7f);
440 if (RATEwGetRateIdx(rate) > RATE_11M) {
441 ofdm_rate = true;
442 break;
447 if (ofdm_rate == true) {
448 priv->uCwMin = C_CWMIN_A;
449 max_min = 4;
450 } else {
451 priv->uCwMin = C_CWMIN_B;
452 max_min = 5;
456 priv->uCwMax = C_CWMAX;
457 priv->uEIFS = C_EIFS;
459 data[0] = (u8)priv->uSIFS;
460 data[1] = (u8)priv->uDIFS;
461 data[2] = (u8)priv->uEIFS;
462 data[3] = (u8)priv->uSlot;
464 vnt_control_out(priv, MESSAGE_TYPE_WRITE, MAC_REG_SIFS,
465 MESSAGE_REQUEST_MACREG, 4, &data[0]);
467 max_min |= 0xa0;
469 vnt_control_out(priv, MESSAGE_TYPE_WRITE, MAC_REG_CWMAXMIN0,
470 MESSAGE_REQUEST_MACREG, 1, &max_min);
473 void CARDvUpdateBasicTopRate(struct vnt_private *priv)
475 u8 top_ofdm = RATE_24M, top_cck = RATE_1M;
476 u8 i;
478 /*Determines the highest basic rate.*/
479 for (i = RATE_54M; i >= RATE_6M; i--) {
480 if (priv->wBasicRate & (u16)(1 << i)) {
481 top_ofdm = i;
482 break;
486 priv->byTopOFDMBasicRate = top_ofdm;
488 for (i = RATE_11M;; i--) {
489 if (priv->wBasicRate & (u16)(1 << i)) {
490 top_cck = i;
491 break;
493 if (i == RATE_1M)
494 break;
497 priv->byTopCCKBasicRate = top_cck;
501 * Description: Set NIC Tx Basic Rate
503 * Parameters:
504 * In:
505 * pDevice - The adapter to be set
506 * wBasicRate - Basic Rate to be set
507 * Out:
508 * none
510 * Return Value: true if succeeded; false if failed.
513 void CARDbAddBasicRate(struct vnt_private *priv, u16 rate_idx)
516 priv->wBasicRate |= (1 << rate_idx);
518 /*Determines the highest basic rate.*/
519 CARDvUpdateBasicTopRate(priv);
522 int CARDbIsOFDMinBasicRate(struct vnt_private *priv)
524 int ii;
526 for (ii = RATE_54M; ii >= RATE_6M; ii--) {
527 if ((priv->wBasicRate) & ((u16)(1 << ii)))
528 return true;
531 return false;
534 u8 CARDbyGetPktType(struct vnt_private *priv)
537 if (priv->byBBType == BB_TYPE_11A || priv->byBBType == BB_TYPE_11B)
538 return (u8)priv->byBBType;
539 else if (CARDbIsOFDMinBasicRate(priv))
540 return PK_TYPE_11GA;
541 else
542 return PK_TYPE_11GB;
546 * Description: Calculate TSF offset of two TSF input
547 * Get TSF Offset from RxBCN's TSF and local TSF
549 * Parameters:
550 * In:
551 * rx_rate - rx rate.
552 * tsf1 - Rx BCN's TSF
553 * tsf2 - Local TSF
554 * Out:
555 * none
557 * Return Value: TSF Offset value
560 u64 CARDqGetTSFOffset(u8 rx_rate, u64 tsf1, u64 tsf2)
562 u64 tsf_offset = 0;
563 u16 rx_bcn_offset = 0;
565 rx_bcn_offset = cwRXBCNTSFOff[rx_rate % MAX_RATE];
567 tsf2 += (u64)rx_bcn_offset;
569 tsf_offset = tsf1 - tsf2;
571 return tsf_offset;
575 * Description: Sync. TSF counter to BSS
576 * Get TSF offset and write to HW
578 * Parameters:
579 * In:
580 * priv - The adapter to be sync.
581 * time_stamp - Rx BCN's TSF
582 * local_tsf - Local TSF
583 * Out:
584 * none
586 * Return Value: none
589 void CARDvAdjustTSF(struct vnt_private *priv, u8 rx_rate,
590 u64 time_stamp, u64 local_tsf)
592 u64 tsf_offset = 0;
593 u8 data[8];
595 tsf_offset = CARDqGetTSFOffset(rx_rate, time_stamp, local_tsf);
597 data[0] = (u8)tsf_offset;
598 data[1] = (u8)(tsf_offset >> 8);
599 data[2] = (u8)(tsf_offset >> 16);
600 data[3] = (u8)(tsf_offset >> 24);
601 data[4] = (u8)(tsf_offset >> 32);
602 data[5] = (u8)(tsf_offset >> 40);
603 data[6] = (u8)(tsf_offset >> 48);
604 data[7] = (u8)(tsf_offset >> 56);
606 vnt_control_out(priv, MESSAGE_TYPE_SET_TSFTBTT,
607 MESSAGE_REQUEST_TSF, 0, 8, data);
610 * Description: Read NIC TSF counter
611 * Get local TSF counter
613 * Parameters:
614 * In:
615 * priv - The adapter to be read
616 * Out:
617 * current_tsf - Current TSF counter
619 * Return Value: true if success; otherwise false
622 bool CARDbGetCurrentTSF(struct vnt_private *priv, u64 *current_tsf)
625 *current_tsf = priv->qwCurrTSF;
627 return true;
631 * Description: Clear NIC TSF counter
632 * Clear local TSF counter
634 * Parameters:
635 * In:
636 * priv - The adapter to be read
638 * Return Value: true if success; otherwise false
641 bool CARDbClearCurrentTSF(struct vnt_private *priv)
644 MACvRegBitsOn(priv, MAC_REG_TFTCTL, TFTCTL_TSFCNTRST);
646 priv->qwCurrTSF = 0;
648 return true;
652 * Description: Read NIC TSF counter
653 * Get NEXTTBTT from adjusted TSF and Beacon Interval
655 * Parameters:
656 * In:
657 * tsf - Current TSF counter
658 * beacon_interval - Beacon Interval
659 * Out:
660 * tsf - Current TSF counter
662 * Return Value: TSF value of next Beacon
665 u64 CARDqGetNextTBTT(u64 tsf, u16 beacon_interval)
667 u32 beacon_int;
669 beacon_int = beacon_interval * 1024;
671 /* Next TBTT =
672 * ((local_current_TSF / beacon_interval) + 1) * beacon_interval
674 if (beacon_int) {
675 do_div(tsf, beacon_int);
676 tsf += 1;
677 tsf *= beacon_int;
680 return tsf;
684 * Description: Set NIC TSF counter for first Beacon time
685 * Get NEXTTBTT from adjusted TSF and Beacon Interval
687 * Parameters:
688 * In:
689 * dwIoBase - IO Base
690 * beacon_interval - Beacon Interval
691 * Out:
692 * none
694 * Return Value: none
697 void CARDvSetFirstNextTBTT(struct vnt_private *priv, u16 beacon_interval)
699 u64 next_tbtt = 0;
700 u8 data[8];
702 CARDbClearCurrentTSF(priv);
704 next_tbtt = CARDqGetNextTBTT(next_tbtt, beacon_interval);
706 data[0] = (u8)next_tbtt;
707 data[1] = (u8)(next_tbtt >> 8);
708 data[2] = (u8)(next_tbtt >> 16);
709 data[3] = (u8)(next_tbtt >> 24);
710 data[4] = (u8)(next_tbtt >> 32);
711 data[5] = (u8)(next_tbtt >> 40);
712 data[6] = (u8)(next_tbtt >> 48);
713 data[7] = (u8)(next_tbtt >> 56);
715 vnt_control_out(priv, MESSAGE_TYPE_SET_TSFTBTT,
716 MESSAGE_REQUEST_TBTT, 0, 8, data);
718 return;
722 * Description: Sync NIC TSF counter for Beacon time
723 * Get NEXTTBTT and write to HW
725 * Parameters:
726 * In:
727 * priv - The adapter to be set
728 * tsf - Current TSF counter
729 * beacon_interval - Beacon Interval
730 * Out:
731 * none
733 * Return Value: none
736 void CARDvUpdateNextTBTT(struct vnt_private *priv, u64 tsf,
737 u16 beacon_interval)
739 u8 data[8];
741 tsf = CARDqGetNextTBTT(tsf, beacon_interval);
743 data[0] = (u8)tsf;
744 data[1] = (u8)(tsf >> 8);
745 data[2] = (u8)(tsf >> 16);
746 data[3] = (u8)(tsf >> 24);
747 data[4] = (u8)(tsf >> 32);
748 data[5] = (u8)(tsf >> 40);
749 data[6] = (u8)(tsf >> 48);
750 data[7] = (u8)(tsf >> 56);
752 vnt_control_out(priv, MESSAGE_TYPE_SET_TSFTBTT,
753 MESSAGE_REQUEST_TBTT, 0, 8, data);
755 dev_dbg(&priv->usb->dev, "%s TBTT: %8llx\n", __func__, tsf);
757 return;
761 * Description: Turn off Radio power
763 * Parameters:
764 * In:
765 * priv - The adapter to be turned off
766 * Out:
767 * none
769 * Return Value: true if success; otherwise false
772 int CARDbRadioPowerOff(struct vnt_private *priv)
774 int ret = true;
776 priv->bRadioOff = true;
778 switch (priv->byRFType) {
779 case RF_AL2230:
780 case RF_AL2230S:
781 case RF_AIROHA7230:
782 case RF_VT3226:
783 case RF_VT3226D0:
784 case RF_VT3342A0:
785 MACvRegBitsOff(priv, MAC_REG_SOFTPWRCTL,
786 (SOFTPWRCTL_SWPE2 | SOFTPWRCTL_SWPE3));
787 break;
790 MACvRegBitsOff(priv, MAC_REG_HOSTCR, HOSTCR_RXON);
792 BBvSetDeepSleep(priv);
794 return ret;
798 * Description: Turn on Radio power
800 * Parameters:
801 * In:
802 * priv - The adapter to be turned on
803 * Out:
804 * none
806 * Return Value: true if success; otherwise false
809 int CARDbRadioPowerOn(struct vnt_private *priv)
811 int ret = true;
813 if (priv->bHWRadioOff == true || priv->bRadioControlOff == true)
814 return false;
816 priv->bRadioOff = false;
818 BBvExitDeepSleep(priv);
820 MACvRegBitsOn(priv, MAC_REG_HOSTCR, HOSTCR_RXON);
822 switch (priv->byRFType) {
823 case RF_AL2230:
824 case RF_AL2230S:
825 case RF_AIROHA7230:
826 case RF_VT3226:
827 case RF_VT3226D0:
828 case RF_VT3342A0:
829 MACvRegBitsOn(priv, MAC_REG_SOFTPWRCTL,
830 (SOFTPWRCTL_SWPE2 | SOFTPWRCTL_SWPE3));
831 break;
834 return ret;
837 void CARDvSetBSSMode(struct vnt_private *priv)
839 if (priv->byRFType == RF_AIROHA7230 && priv->byBBType == BB_TYPE_11A)
840 MACvSetBBType(priv, BB_TYPE_11G);
841 else
842 MACvSetBBType(priv, priv->byBBType);
844 priv->byPacketType = CARDbyGetPktType(priv);
846 if (priv->byBBType == BB_TYPE_11A)
847 vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x88, 0x03);
848 else if (priv->byBBType == BB_TYPE_11B)
849 vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x88, 0x02);
850 else if (priv->byBBType == BB_TYPE_11G)
851 vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x88, 0x08);
853 vUpdateIFS(priv);
854 CARDvSetRSPINF(priv, (u8)priv->byBBType);
856 if (priv->byBBType == BB_TYPE_11A) {
857 if (priv->byRFType == RF_AIROHA7230) {
858 priv->abyBBVGA[0] = 0x20;
860 vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG,
861 0xe7, priv->abyBBVGA[0]);
864 priv->abyBBVGA[2] = 0x10;
865 priv->abyBBVGA[3] = 0x10;
866 } else {
867 if (priv->byRFType == RF_AIROHA7230) {
868 priv->abyBBVGA[0] = 0x1c;
870 vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG,
871 0xe7, priv->abyBBVGA[0]);
874 priv->abyBBVGA[2] = 0x0;
875 priv->abyBBVGA[3] = 0x0;