1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
7 * Purpose: Provide functions to setup NIC operation mode
9 * s_vSafeResetTx - Rest Tx
10 * CARDvSetRSPINF - Set RSPINF
11 * CARDvUpdateBasicTopRate - Update BasicTopRate
12 * CARDbAddBasicRate - Add to BasicRateSet
13 * CARDbIsOFDMinBasicRate - Check if any OFDM rate is in BasicRateSet
14 * CARDqGetTSFOffset - Calculate TSFOffset
15 * CARDbGetCurrentTSF - Read Current NIC TSF counter
16 * CARDqGetNextTBTT - Calculate Next Beacon TSF counter
17 * CARDvSetFirstNextTBTT - Set NIC Beacon time
18 * CARDvUpdateNextTBTT - Sync. NIC Beacon time
19 * CARDbRadioPowerOff - Turn Off NIC Radio Power
22 * 06-10-2003 Bryan YC Fan: Re-write codes to support VT3253 spec.
23 * 08-26-2003 Kyle Hsu: Modify the definition type of iobase.
24 * 09-01-2003 Bryan YC Fan: Add vUpdateIFS().
36 /*--------------------- Static Definitions -------------------------*/
38 #define C_SIFS_A 16 /* micro sec. */
41 #define C_EIFS 80 /* micro sec. */
43 #define C_SLOT_SHORT 9 /* micro sec. */
44 #define C_SLOT_LONG 20
46 #define C_CWMIN_A 15 /* slot time */
49 #define C_CWMAX 1023 /* slot time */
51 #define WAIT_BEACON_TX_DOWN_TMO 3 /* Times */
53 /*--------------------- Static Variables --------------------------*/
55 static const unsigned short cwRXBCNTSFOff
[MAX_RATE
] = {
56 17, 17, 17, 17, 34, 23, 17, 11, 8, 5, 4, 3};
58 /*--------------------- Static Functions --------------------------*/
60 static void s_vCalculateOFDMRParameter(unsigned char byRate
, u8 bb_type
,
61 unsigned char *pbyTxRate
,
62 unsigned char *pbyRsvTime
);
64 /*--------------------- Export Functions --------------------------*/
67 * Description: Calculate TxRate and RsvTime fields for RSPINF in OFDM mode.
72 * byPktType - Tx Packet type
74 * pbyTxRate - pointer to RSPINF TxRate field
75 * pbyRsvTime - pointer to RSPINF RsvTime field
79 static void s_vCalculateOFDMRParameter(unsigned char byRate
,
81 unsigned char *pbyTxRate
,
82 unsigned char *pbyRsvTime
)
86 if (bb_type
== BB_TYPE_11A
) { /* 5GHZ */
96 if (bb_type
== BB_TYPE_11A
) { /* 5GHZ */
106 if (bb_type
== BB_TYPE_11A
) { /* 5GHZ */
116 if (bb_type
== BB_TYPE_11A
) { /* 5GHZ */
126 if (bb_type
== BB_TYPE_11A
) { /* 5GHZ */
136 if (bb_type
== BB_TYPE_11A
) { /* 5GHZ */
146 if (bb_type
== BB_TYPE_11A
) { /* 5GHZ */
157 if (bb_type
== BB_TYPE_11A
) { /* 5GHZ */
168 /*--------------------- Export Functions --------------------------*/
171 * Description: Update IFS
175 * priv - The adapter to be set
179 * Return Value: None.
181 bool CARDbSetPhyParameter(struct vnt_private
*priv
, u8 bb_type
)
183 unsigned char byCWMaxMin
= 0;
184 unsigned char bySlot
= 0;
185 unsigned char bySIFS
= 0;
186 unsigned char byDIFS
= 0;
187 unsigned char byData
;
190 /* Set SIFS, DIFS, EIFS, SlotTime, CwMin */
191 if (bb_type
== BB_TYPE_11A
) {
192 if (priv
->byRFType
== RF_AIROHA7230
) {
193 /* AL7230 use single PAPE and connect to PAPE_2.4G */
194 MACvSetBBType(priv
->PortOffset
, BB_TYPE_11G
);
195 priv
->abyBBVGA
[0] = 0x20;
196 priv
->abyBBVGA
[2] = 0x10;
197 priv
->abyBBVGA
[3] = 0x10;
198 bb_read_embedded(priv
, 0xE7, &byData
);
200 bb_write_embedded(priv
, 0xE7, priv
->abyBBVGA
[0]);
202 } else if (priv
->byRFType
== RF_UW2452
) {
203 MACvSetBBType(priv
->PortOffset
, BB_TYPE_11A
);
204 priv
->abyBBVGA
[0] = 0x18;
205 bb_read_embedded(priv
, 0xE7, &byData
);
206 if (byData
== 0x14) {
207 bb_write_embedded(priv
, 0xE7, priv
->abyBBVGA
[0]);
208 bb_write_embedded(priv
, 0xE1, 0x57);
211 MACvSetBBType(priv
->PortOffset
, BB_TYPE_11A
);
213 bb_write_embedded(priv
, 0x88, 0x03);
214 bySlot
= C_SLOT_SHORT
;
216 byDIFS
= C_SIFS_A
+ 2 * C_SLOT_SHORT
;
218 } else if (bb_type
== BB_TYPE_11B
) {
219 MACvSetBBType(priv
->PortOffset
, BB_TYPE_11B
);
220 if (priv
->byRFType
== RF_AIROHA7230
) {
221 priv
->abyBBVGA
[0] = 0x1C;
222 priv
->abyBBVGA
[2] = 0x00;
223 priv
->abyBBVGA
[3] = 0x00;
224 bb_read_embedded(priv
, 0xE7, &byData
);
226 bb_write_embedded(priv
, 0xE7, priv
->abyBBVGA
[0]);
228 } else if (priv
->byRFType
== RF_UW2452
) {
229 priv
->abyBBVGA
[0] = 0x14;
230 bb_read_embedded(priv
, 0xE7, &byData
);
231 if (byData
== 0x18) {
232 bb_write_embedded(priv
, 0xE7, priv
->abyBBVGA
[0]);
233 bb_write_embedded(priv
, 0xE1, 0xD3);
236 bb_write_embedded(priv
, 0x88, 0x02);
237 bySlot
= C_SLOT_LONG
;
239 byDIFS
= C_SIFS_BG
+ 2 * C_SLOT_LONG
;
241 } else { /* PK_TYPE_11GA & PK_TYPE_11GB */
242 MACvSetBBType(priv
->PortOffset
, BB_TYPE_11G
);
243 if (priv
->byRFType
== RF_AIROHA7230
) {
244 priv
->abyBBVGA
[0] = 0x1C;
245 priv
->abyBBVGA
[2] = 0x00;
246 priv
->abyBBVGA
[3] = 0x00;
247 bb_read_embedded(priv
, 0xE7, &byData
);
249 bb_write_embedded(priv
, 0xE7, priv
->abyBBVGA
[0]);
251 } else if (priv
->byRFType
== RF_UW2452
) {
252 priv
->abyBBVGA
[0] = 0x14;
253 bb_read_embedded(priv
, 0xE7, &byData
);
254 if (byData
== 0x18) {
255 bb_write_embedded(priv
, 0xE7, priv
->abyBBVGA
[0]);
256 bb_write_embedded(priv
, 0xE1, 0xD3);
259 bb_write_embedded(priv
, 0x88, 0x08);
262 if (priv
->bShortSlotTime
) {
263 bySlot
= C_SLOT_SHORT
;
264 byDIFS
= C_SIFS_BG
+ 2 * C_SLOT_SHORT
;
266 bySlot
= C_SLOT_LONG
;
267 byDIFS
= C_SIFS_BG
+ 2 * C_SLOT_LONG
;
272 for (i
= RATE_54M
; i
>= RATE_6M
; i
--) {
273 if (priv
->basic_rates
& ((u32
)(0x1 << i
))) {
280 if (priv
->byRFType
== RF_RFMD2959
) {
282 * bcs TX_PE will reserve 3 us hardware's processing
288 * TX_PE will reserve 3 us for MAX2829 A mode only, it is for
289 * better TX throughput; MAC will need 2 us to process, so the
290 * SIFS, DIFS can be shorter by 2 us.
294 if (priv
->bySIFS
!= bySIFS
) {
295 priv
->bySIFS
= bySIFS
;
296 VNSvOutPortB(priv
->PortOffset
+ MAC_REG_SIFS
, priv
->bySIFS
);
298 if (priv
->byDIFS
!= byDIFS
) {
299 priv
->byDIFS
= byDIFS
;
300 VNSvOutPortB(priv
->PortOffset
+ MAC_REG_DIFS
, priv
->byDIFS
);
302 if (priv
->byEIFS
!= C_EIFS
) {
303 priv
->byEIFS
= C_EIFS
;
304 VNSvOutPortB(priv
->PortOffset
+ MAC_REG_EIFS
, priv
->byEIFS
);
306 if (priv
->bySlot
!= bySlot
) {
307 priv
->bySlot
= bySlot
;
308 VNSvOutPortB(priv
->PortOffset
+ MAC_REG_SLOT
, priv
->bySlot
);
310 bb_set_short_slot_time(priv
);
312 if (priv
->byCWMaxMin
!= byCWMaxMin
) {
313 priv
->byCWMaxMin
= byCWMaxMin
;
314 VNSvOutPortB(priv
->PortOffset
+ MAC_REG_CWMAXMIN0
,
318 priv
->byPacketType
= CARDbyGetPktType(priv
);
320 CARDvSetRSPINF(priv
, bb_type
);
326 * Description: Sync. TSF counter to BSS
327 * Get TSF offset and write to HW
331 * priv - The adapter to be sync.
332 * byRxRate - data rate of receive beacon
333 * qwBSSTimestamp - Rx BCN's TSF
334 * qwLocalTSF - Local TSF
340 bool CARDbUpdateTSF(struct vnt_private
*priv
, unsigned char byRxRate
,
346 CARDbGetCurrentTSF(priv
, &local_tsf
);
348 if (qwBSSTimestamp
!= local_tsf
) {
349 qwTSFOffset
= CARDqGetTSFOffset(byRxRate
, qwBSSTimestamp
,
351 /* adjust TSF, HW's TSF add TSF Offset reg */
352 VNSvOutPortD(priv
->PortOffset
+ MAC_REG_TSFOFST
,
354 VNSvOutPortD(priv
->PortOffset
+ MAC_REG_TSFOFST
+ 4,
355 (u32
)(qwTSFOffset
>> 32));
356 MACvRegBitsOn(priv
->PortOffset
, MAC_REG_TFTCTL
,
363 * Description: Set NIC TSF counter for first Beacon time
364 * Get NEXTTBTT from adjusted TSF and Beacon Interval
368 * priv - The adapter to be set.
369 * wBeaconInterval - Beacon Interval
373 * Return Value: true if succeed; otherwise false
375 bool CARDbSetBeaconPeriod(struct vnt_private
*priv
,
376 unsigned short wBeaconInterval
)
380 CARDbGetCurrentTSF(priv
, &qwNextTBTT
); /* Get Local TSF counter */
382 qwNextTBTT
= CARDqGetNextTBTT(qwNextTBTT
, wBeaconInterval
);
384 /* set HW beacon interval */
385 VNSvOutPortW(priv
->PortOffset
+ MAC_REG_BI
, wBeaconInterval
);
386 priv
->wBeaconInterval
= wBeaconInterval
;
388 VNSvOutPortD(priv
->PortOffset
+ MAC_REG_NEXTTBTT
, (u32
)qwNextTBTT
);
389 VNSvOutPortD(priv
->PortOffset
+ MAC_REG_NEXTTBTT
+ 4,
390 (u32
)(qwNextTBTT
>> 32));
391 MACvRegBitsOn(priv
->PortOffset
, MAC_REG_TFTCTL
, TFTCTL_TBTTSYNCEN
);
397 * Description: Turn off Radio power
401 * priv - The adapter to be turned off
406 void CARDbRadioPowerOff(struct vnt_private
*priv
)
411 switch (priv
->byRFType
) {
413 MACvWordRegBitsOff(priv
->PortOffset
, MAC_REG_SOFTPWRCTL
,
415 MACvWordRegBitsOn(priv
->PortOffset
, MAC_REG_SOFTPWRCTL
,
422 MACvWordRegBitsOff(priv
->PortOffset
, MAC_REG_SOFTPWRCTL
,
424 MACvWordRegBitsOff(priv
->PortOffset
, MAC_REG_SOFTPWRCTL
,
429 MACvRegBitsOff(priv
->PortOffset
, MAC_REG_HOSTCR
, HOSTCR_RXON
);
431 bb_set_deep_sleep(priv
, priv
->byLocalID
);
433 priv
->bRadioOff
= true;
434 pr_debug("chester power off\n");
435 MACvRegBitsOn(priv
->PortOffset
, MAC_REG_GPIOCTL0
,
436 LED_ACTSET
); /* LED issue */
439 void CARDvSafeResetTx(struct vnt_private
*priv
)
442 struct vnt_tx_desc
*pCurrTD
;
444 /* initialize TD index */
445 priv
->apTailTD
[0] = &priv
->apTD0Rings
[0];
446 priv
->apCurrTD
[0] = &priv
->apTD0Rings
[0];
448 priv
->apTailTD
[1] = &priv
->apTD1Rings
[0];
449 priv
->apCurrTD
[1] = &priv
->apTD1Rings
[0];
451 for (uu
= 0; uu
< TYPE_MAXTD
; uu
++)
452 priv
->iTDUsed
[uu
] = 0;
454 for (uu
= 0; uu
< priv
->opts
.tx_descs
[0]; uu
++) {
455 pCurrTD
= &priv
->apTD0Rings
[uu
];
456 pCurrTD
->td0
.owner
= OWNED_BY_HOST
;
457 /* init all Tx Packet pointer to NULL */
459 for (uu
= 0; uu
< priv
->opts
.tx_descs
[1]; uu
++) {
460 pCurrTD
= &priv
->apTD1Rings
[uu
];
461 pCurrTD
->td0
.owner
= OWNED_BY_HOST
;
462 /* init all Tx Packet pointer to NULL */
465 /* set MAC TD pointer */
466 MACvSetCurrTXDescAddr(TYPE_TXDMA0
, priv
, priv
->td0_pool_dma
);
468 MACvSetCurrTXDescAddr(TYPE_AC0DMA
, priv
, priv
->td1_pool_dma
);
470 /* set MAC Beacon TX pointer */
471 MACvSetCurrBCNTxDescAddr(priv
->PortOffset
,
472 (priv
->tx_beacon_dma
));
481 * priv - Pointer to the adapter
487 void CARDvSafeResetRx(struct vnt_private
*priv
)
490 struct vnt_rx_desc
*pDesc
;
492 /* initialize RD index */
493 priv
->pCurrRD
[0] = &priv
->aRD0Ring
[0];
494 priv
->pCurrRD
[1] = &priv
->aRD1Ring
[0];
496 /* init state, all RD is chip's */
497 for (uu
= 0; uu
< priv
->opts
.rx_descs0
; uu
++) {
498 pDesc
= &priv
->aRD0Ring
[uu
];
499 pDesc
->rd0
.res_count
= cpu_to_le16(priv
->rx_buf_sz
);
500 pDesc
->rd0
.owner
= OWNED_BY_NIC
;
501 pDesc
->rd1
.req_count
= cpu_to_le16(priv
->rx_buf_sz
);
504 /* init state, all RD is chip's */
505 for (uu
= 0; uu
< priv
->opts
.rx_descs1
; uu
++) {
506 pDesc
= &priv
->aRD1Ring
[uu
];
507 pDesc
->rd0
.res_count
= cpu_to_le16(priv
->rx_buf_sz
);
508 pDesc
->rd0
.owner
= OWNED_BY_NIC
;
509 pDesc
->rd1
.req_count
= cpu_to_le16(priv
->rx_buf_sz
);
512 /* set perPkt mode */
513 MACvRx0PerPktMode(priv
->PortOffset
);
514 MACvRx1PerPktMode(priv
->PortOffset
);
515 /* set MAC RD pointer */
516 MACvSetCurrRx0DescAddr(priv
, priv
->rd0_pool_dma
);
518 MACvSetCurrRx1DescAddr(priv
, priv
->rd1_pool_dma
);
522 * Description: Get response Control frame rate in CCK mode
526 * priv - The adapter to be set
527 * wRateIdx - Receiving data rate
531 * Return Value: response Control frame rate
533 static unsigned short CARDwGetCCKControlRate(struct vnt_private
*priv
,
534 unsigned short wRateIdx
)
536 unsigned int ui
= (unsigned int)wRateIdx
;
538 while (ui
> RATE_1M
) {
539 if (priv
->basic_rates
& ((u32
)0x1 << ui
))
540 return (unsigned short)ui
;
544 return (unsigned short)RATE_1M
;
548 * Description: Get response Control frame rate in OFDM mode
552 * priv - The adapter to be set
553 * wRateIdx - Receiving data rate
557 * Return Value: response Control frame rate
559 static unsigned short CARDwGetOFDMControlRate(struct vnt_private
*priv
,
560 unsigned short wRateIdx
)
562 unsigned int ui
= (unsigned int)wRateIdx
;
564 pr_debug("BASIC RATE: %X\n", priv
->basic_rates
);
566 if (!CARDbIsOFDMinBasicRate((void *)priv
)) {
567 pr_debug("%s:(NO OFDM) %d\n", __func__
, wRateIdx
);
568 if (wRateIdx
> RATE_24M
)
572 while (ui
> RATE_11M
) {
573 if (priv
->basic_rates
& ((u32
)0x1 << ui
)) {
574 pr_debug("%s : %d\n", __func__
, ui
);
575 return (unsigned short)ui
;
579 pr_debug("%s: 6M\n", __func__
);
580 return (unsigned short)RATE_24M
;
584 * Description: Set RSPINF
588 * priv - The adapter to be set
592 * Return Value: None.
594 void CARDvSetRSPINF(struct vnt_private
*priv
, u8 bb_type
)
596 union vnt_phy_field_swap phy
;
597 unsigned char byTxRate
, byRsvTime
; /* For OFDM */
600 spin_lock_irqsave(&priv
->lock
, flags
);
603 MACvSelectPage1(priv
->PortOffset
);
606 vnt_get_phy_field(priv
, 14,
607 CARDwGetCCKControlRate(priv
, RATE_1M
),
608 PK_TYPE_11B
, &phy
.field_read
);
610 /* swap over to get correct write order */
611 swap(phy
.swap
[0], phy
.swap
[1]);
613 VNSvOutPortD(priv
->PortOffset
+ MAC_REG_RSPINF_B_1
, phy
.field_write
);
616 vnt_get_phy_field(priv
, 14,
617 CARDwGetCCKControlRate(priv
, RATE_2M
),
618 PK_TYPE_11B
, &phy
.field_read
);
620 swap(phy
.swap
[0], phy
.swap
[1]);
622 VNSvOutPortD(priv
->PortOffset
+ MAC_REG_RSPINF_B_2
, phy
.field_write
);
625 vnt_get_phy_field(priv
, 14,
626 CARDwGetCCKControlRate(priv
, RATE_5M
),
627 PK_TYPE_11B
, &phy
.field_read
);
629 swap(phy
.swap
[0], phy
.swap
[1]);
631 VNSvOutPortD(priv
->PortOffset
+ MAC_REG_RSPINF_B_5
, phy
.field_write
);
634 vnt_get_phy_field(priv
, 14,
635 CARDwGetCCKControlRate(priv
, RATE_11M
),
636 PK_TYPE_11B
, &phy
.field_read
);
638 swap(phy
.swap
[0], phy
.swap
[1]);
640 VNSvOutPortD(priv
->PortOffset
+ MAC_REG_RSPINF_B_11
, phy
.field_write
);
643 s_vCalculateOFDMRParameter(RATE_6M
,
647 VNSvOutPortW(priv
->PortOffset
+ MAC_REG_RSPINF_A_6
,
648 MAKEWORD(byTxRate
, byRsvTime
));
650 s_vCalculateOFDMRParameter(RATE_9M
,
654 VNSvOutPortW(priv
->PortOffset
+ MAC_REG_RSPINF_A_9
,
655 MAKEWORD(byTxRate
, byRsvTime
));
657 s_vCalculateOFDMRParameter(RATE_12M
,
661 VNSvOutPortW(priv
->PortOffset
+ MAC_REG_RSPINF_A_12
,
662 MAKEWORD(byTxRate
, byRsvTime
));
664 s_vCalculateOFDMRParameter(RATE_18M
,
668 VNSvOutPortW(priv
->PortOffset
+ MAC_REG_RSPINF_A_18
,
669 MAKEWORD(byTxRate
, byRsvTime
));
671 s_vCalculateOFDMRParameter(RATE_24M
,
675 VNSvOutPortW(priv
->PortOffset
+ MAC_REG_RSPINF_A_24
,
676 MAKEWORD(byTxRate
, byRsvTime
));
678 s_vCalculateOFDMRParameter(CARDwGetOFDMControlRate((void *)priv
,
683 VNSvOutPortW(priv
->PortOffset
+ MAC_REG_RSPINF_A_36
,
684 MAKEWORD(byTxRate
, byRsvTime
));
686 s_vCalculateOFDMRParameter(CARDwGetOFDMControlRate((void *)priv
,
691 VNSvOutPortW(priv
->PortOffset
+ MAC_REG_RSPINF_A_48
,
692 MAKEWORD(byTxRate
, byRsvTime
));
694 s_vCalculateOFDMRParameter(CARDwGetOFDMControlRate((void *)priv
,
699 VNSvOutPortW(priv
->PortOffset
+ MAC_REG_RSPINF_A_54
,
700 MAKEWORD(byTxRate
, byRsvTime
));
702 s_vCalculateOFDMRParameter(CARDwGetOFDMControlRate((void *)priv
,
707 VNSvOutPortW(priv
->PortOffset
+ MAC_REG_RSPINF_A_72
,
708 MAKEWORD(byTxRate
, byRsvTime
));
710 MACvSelectPage0(priv
->PortOffset
);
712 spin_unlock_irqrestore(&priv
->lock
, flags
);
715 void CARDvUpdateBasicTopRate(struct vnt_private
*priv
)
717 unsigned char byTopOFDM
= RATE_24M
, byTopCCK
= RATE_1M
;
720 /* Determines the highest basic rate. */
721 for (ii
= RATE_54M
; ii
>= RATE_6M
; ii
--) {
722 if ((priv
->basic_rates
) & ((u32
)(1 << ii
))) {
727 priv
->byTopOFDMBasicRate
= byTopOFDM
;
729 for (ii
= RATE_11M
;; ii
--) {
730 if ((priv
->basic_rates
) & ((u32
)(1 << ii
))) {
737 priv
->byTopCCKBasicRate
= byTopCCK
;
740 bool CARDbIsOFDMinBasicRate(struct vnt_private
*priv
)
744 for (ii
= RATE_54M
; ii
>= RATE_6M
; ii
--) {
745 if ((priv
->basic_rates
) & ((u32
)BIT(ii
)))
751 unsigned char CARDbyGetPktType(struct vnt_private
*priv
)
753 if (priv
->byBBType
== BB_TYPE_11A
|| priv
->byBBType
== BB_TYPE_11B
)
754 return (unsigned char)priv
->byBBType
;
755 else if (CARDbIsOFDMinBasicRate((void *)priv
))
762 * Description: Calculate TSF offset of two TSF input
763 * Get TSF Offset from RxBCN's TSF and local TSF
767 * priv - The adapter to be sync.
768 * qwTSF1 - Rx BCN's TSF
773 * Return Value: TSF Offset value
775 u64
CARDqGetTSFOffset(unsigned char byRxRate
, u64 qwTSF1
, u64 qwTSF2
)
777 unsigned short wRxBcnTSFOffst
;
779 wRxBcnTSFOffst
= cwRXBCNTSFOff
[byRxRate
% MAX_RATE
];
781 qwTSF2
+= (u64
)wRxBcnTSFOffst
;
783 return qwTSF1
- qwTSF2
;
787 * Description: Read NIC TSF counter
788 * Get local TSF counter
792 * priv - The adapter to be read
794 * qwCurrTSF - Current TSF counter
796 * Return Value: true if success; otherwise false
798 bool CARDbGetCurrentTSF(struct vnt_private
*priv
, u64
*pqwCurrTSF
)
800 void __iomem
*iobase
= priv
->PortOffset
;
802 unsigned char byData
;
804 MACvRegBitsOn(iobase
, MAC_REG_TFTCTL
, TFTCTL_TSFCNTRRD
);
805 for (ww
= 0; ww
< W_MAX_TIMEOUT
; ww
++) {
806 VNSvInPortB(iobase
+ MAC_REG_TFTCTL
, &byData
);
807 if (!(byData
& TFTCTL_TSFCNTRRD
))
810 if (ww
== W_MAX_TIMEOUT
)
812 VNSvInPortD(iobase
+ MAC_REG_TSFCNTR
, (u32
*)pqwCurrTSF
);
813 VNSvInPortD(iobase
+ MAC_REG_TSFCNTR
+ 4, (u32
*)pqwCurrTSF
+ 1);
819 * Description: Read NIC TSF counter
820 * Get NEXTTBTT from adjusted TSF and Beacon Interval
824 * qwTSF - Current TSF counter
825 * wbeaconInterval - Beacon Interval
827 * qwCurrTSF - Current TSF counter
829 * Return Value: TSF value of next Beacon
831 u64
CARDqGetNextTBTT(u64 qwTSF
, unsigned short wBeaconInterval
)
835 beacon_int
= wBeaconInterval
* 1024;
837 do_div(qwTSF
, beacon_int
);
846 * Description: Set NIC TSF counter for first Beacon time
847 * Get NEXTTBTT from adjusted TSF and Beacon Interval
852 * wBeaconInterval - Beacon Interval
858 void CARDvSetFirstNextTBTT(struct vnt_private
*priv
,
859 unsigned short wBeaconInterval
)
861 void __iomem
*iobase
= priv
->PortOffset
;
864 CARDbGetCurrentTSF(priv
, &qwNextTBTT
); /* Get Local TSF counter */
866 qwNextTBTT
= CARDqGetNextTBTT(qwNextTBTT
, wBeaconInterval
);
868 VNSvOutPortD(iobase
+ MAC_REG_NEXTTBTT
, (u32
)qwNextTBTT
);
869 VNSvOutPortD(iobase
+ MAC_REG_NEXTTBTT
+ 4, (u32
)(qwNextTBTT
>> 32));
870 MACvRegBitsOn(iobase
, MAC_REG_TFTCTL
, TFTCTL_TBTTSYNCEN
);
874 * Description: Sync NIC TSF counter for Beacon time
875 * Get NEXTTBTT and write to HW
879 * priv - The adapter to be set
880 * qwTSF - Current TSF counter
881 * wBeaconInterval - Beacon Interval
887 void CARDvUpdateNextTBTT(struct vnt_private
*priv
, u64 qwTSF
,
888 unsigned short wBeaconInterval
)
890 void __iomem
*iobase
= priv
->PortOffset
;
892 qwTSF
= CARDqGetNextTBTT(qwTSF
, wBeaconInterval
);
894 VNSvOutPortD(iobase
+ MAC_REG_NEXTTBTT
, (u32
)qwTSF
);
895 VNSvOutPortD(iobase
+ MAC_REG_NEXTTBTT
+ 4, (u32
)(qwTSF
>> 32));
896 MACvRegBitsOn(iobase
, MAC_REG_TFTCTL
, TFTCTL_TBTTSYNCEN
);
897 pr_debug("Card:Update Next TBTT[%8llx]\n", qwTSF
);