Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Staging: rt2860: prepare for rt28[67]0/common/*.[ch] merge

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

authored by

Bartlomiej Zolnierkiewicz and committed by
Greg Kroah-Hartman
59fe2d89 3fb468ab

+3644 -22
+6
drivers/staging/rt2860/common/action.c
··· 527 527 MakeOutgoingFrame(pOutBuffer, &FrameLen, 528 528 sizeof(FRAME_BAR), &FrameBar, 529 529 END_OF_ARGS); 530 + 530 531 if (1) // Now we always send BAR. 531 532 { 533 + #ifndef RT30xx 532 534 MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen); 535 + #endif 536 + #ifdef RT30xx 537 + MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, FrameLen); 538 + #endif 533 539 } 534 540 MlmeFreeMemory(pAd, pOutBuffer); 535 541 }
+62 -1
drivers/staging/rt2860/common/ba_action.c
··· 531 531 pBAEntry->TimeOutValue = TimeOut; 532 532 pBAEntry->pAdapter = pAd; 533 533 534 + #ifdef RT30xx 535 + DBGPRINT(RT_DEBUG_TRACE,("Send AddBA to %02x:%02x:%02x:%02x:%02x:%02x Tid:%d isForced:%d Wcid:%d\n" 536 + ,pEntry->Addr[0],pEntry->Addr[1],pEntry->Addr[2] 537 + ,pEntry->Addr[3],pEntry->Addr[4],pEntry->Addr[5] 538 + ,TID,isForced,pEntry->Aid)); 539 + #endif 540 + 534 541 if (!(pEntry->TXBAbitmap & (1<<TID))) 535 542 { 536 543 RTMPInitTimer(pAd, &pBAEntry->ORIBATimer, GET_TIMER_FUNCTION(BAOriSessionSetupTimeout), pBAEntry, FALSE); ··· 1078 1071 AddbaReq.Token = pBAEntry->Token; 1079 1072 MlmeEnqueue(pAd, ACTION_STATE_MACHINE, MT2_MLME_ADD_BA_CATE, sizeof(MLME_ADDBA_REQ_STRUCT), (PVOID)&AddbaReq); 1080 1073 RT28XX_MLME_HANDLER(pAd); 1074 + #ifndef RT30xx 1081 1075 DBGPRINT(RT_DEBUG_TRACE,("BA Ori Session Timeout(%d) : Send ADD BA again\n", pBAEntry->Token)); 1082 - 1076 + #endif 1077 + #ifdef RT30xx 1078 + DBGPRINT(RT_DEBUG_TRACE,("BA Ori Session Timeout(%d) to %02x:%02x:%02x:%02x:%02x:%02x Tid:%d Wcid:%d\n" 1079 + ,pBAEntry->Token 1080 + ,pEntry->Addr[0],pEntry->Addr[1],pEntry->Addr[2] 1081 + ,pEntry->Addr[3],pEntry->Addr[4],pEntry->Addr[5] 1082 + ,pBAEntry->TID,pEntry->Aid)); 1083 + #endif 1083 1084 pBAEntry->Token++; 1084 1085 RTMPSetTimer(&pBAEntry->ORIBATimer, ORI_BA_SESSION_TIMEOUT); 1085 1086 } ··· 1391 1376 //ULONG Idx; 1392 1377 FRAME_PSMP_ACTION Frame; 1393 1378 ULONG FrameLen; 1379 + #ifdef RT30xx 1380 + UCHAR bbpdata=0; 1381 + UINT32 macdata; 1382 + #endif // RT30xx // 1394 1383 1395 1384 NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory 1396 1385 if (NStatus != NDIS_STATUS_SUCCESS) ··· 1410 1391 switch (Psmp) 1411 1392 { 1412 1393 case MMPS_ENABLE: 1394 + #ifdef RT30xx 1395 + if (IS_RT3090(pAd)) 1396 + { 1397 + // disable MMPS BBP control register 1398 + RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &bbpdata); 1399 + bbpdata &= ~(0x04); //bit 2 1400 + RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, bbpdata); 1401 + 1402 + // disable MMPS MAC control register 1403 + RTMP_IO_READ32(pAd, 0x1210, &macdata); 1404 + macdata &= ~(0x09); //bit 0, 3 1405 + RTMP_IO_WRITE32(pAd, 0x1210, macdata); 1406 + } 1407 + #endif // RT30xx // 1413 1408 Frame.Psmp = 0; 1414 1409 break; 1415 1410 case MMPS_DYNAMIC: 1411 + #ifdef RT30xx 1412 + if (IS_RT3090(pAd)) 1413 + { 1414 + // enable MMPS BBP control register 1415 + RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &bbpdata); 1416 + bbpdata |= 0x04; //bit 2 1417 + RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, bbpdata); 1418 + 1419 + // enable MMPS MAC control register 1420 + RTMP_IO_READ32(pAd, 0x1210, &macdata); 1421 + macdata |= 0x09; //bit 0, 3 1422 + RTMP_IO_WRITE32(pAd, 0x1210, macdata); 1423 + } 1424 + #endif // RT30xx // 1416 1425 Frame.Psmp = 3; 1417 1426 break; 1418 1427 case MMPS_STATIC: 1428 + #ifdef RT30xx 1429 + if (IS_RT3090(pAd)) 1430 + { 1431 + // enable MMPS BBP control register 1432 + RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &bbpdata); 1433 + bbpdata |= 0x04; //bit 2 1434 + RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, bbpdata); 1435 + 1436 + // enable MMPS MAC control register 1437 + RTMP_IO_READ32(pAd, 0x1210, &macdata); 1438 + macdata |= 0x09; //bit 0, 3 1439 + RTMP_IO_WRITE32(pAd, 0x1210, macdata); 1440 + } 1441 + #endif // RT30xx // 1419 1442 Frame.Psmp = 1; 1420 1443 break; 1421 1444 }
+222 -8
drivers/staging/rt2860/common/cmm_data.c
··· 105 105 PNDIS_PACKET pPacket; 106 106 NDIS_STATUS Status = NDIS_STATUS_SUCCESS; 107 107 ULONG FreeNum; 108 + #ifdef RT2860 108 109 unsigned long IrqFlags = 0; 110 + #endif 109 111 UCHAR IrqState; 110 112 UCHAR rtmpHwHdr[TXINFO_SIZE + TXWI_SIZE]; //RTMP_HW_HDR_LEN]; 111 113 ··· 119 117 120 118 IrqState = pAd->irq_disabled; 121 119 120 + #ifdef RT2860 122 121 if ((pAd->MACVersion == 0x28600100) && (!IrqState)) 123 122 RTMP_IRQ_LOCK(&pAd->irq_lock, IrqFlags); 124 - 123 + #endif 125 124 do 126 125 { 127 126 // Reset is in progress, stop immediately ··· 175 172 176 173 } while (FALSE); 177 174 175 + #ifdef RT2860 178 176 // 2860C use Tx Ring 179 177 if ((pAd->MACVersion == 0x28600100) && (!IrqState)) 180 178 RTMP_IRQ_UNLOCK(&pAd->irq_lock, IrqFlags); 181 - 179 + #endif 182 180 return Status; 183 181 } 184 182 185 - 183 + #ifdef RT2860 186 184 NDIS_STATUS MiniportMMRequestUnlock( 187 185 IN PRTMP_ADAPTER pAd, 188 186 IN UCHAR QueIdx, ··· 251 247 252 248 return Status; 253 249 } 250 + #endif 251 + #ifdef RT30xx 252 + NDIS_STATUS MlmeDataHardTransmit( 253 + IN PRTMP_ADAPTER pAd, 254 + IN UCHAR QueIdx, 255 + IN PNDIS_PACKET pPacket); 254 256 257 + #define MAX_DATAMM_RETRY 3 258 + /* 259 + ======================================================================== 260 + 261 + Routine Description: 262 + API for MLME to transmit management frame to AP (BSS Mode) 263 + or station (IBSS Mode) 264 + 265 + Arguments: 266 + pAd Pointer to our adapter 267 + pData Pointer to the outgoing 802.11 frame 268 + Length Size of outgoing management frame 269 + 270 + Return Value: 271 + NDIS_STATUS_FAILURE 272 + NDIS_STATUS_PENDING 273 + NDIS_STATUS_SUCCESS 274 + 275 + IRQL = PASSIVE_LEVEL 276 + IRQL = DISPATCH_LEVEL 277 + 278 + Note: 279 + 280 + ======================================================================== 281 + */ 282 + NDIS_STATUS MiniportDataMMRequest( 283 + IN PRTMP_ADAPTER pAd, 284 + IN UCHAR QueIdx, 285 + IN PUCHAR pData, 286 + IN UINT Length) 287 + { 288 + PNDIS_PACKET pPacket; 289 + NDIS_STATUS Status = NDIS_STATUS_SUCCESS; 290 + ULONG FreeNum; 291 + int retry = 0; 292 + UCHAR IrqState; 293 + UCHAR rtmpHwHdr[TXINFO_SIZE + TXWI_SIZE]; //RTMP_HW_HDR_LEN]; 294 + 295 + ASSERT(Length <= MGMT_DMA_BUFFER_SIZE); 296 + 297 + // 2860C use Tx Ring 298 + IrqState = pAd->irq_disabled; 299 + 300 + do 301 + { 302 + // Reset is in progress, stop immediately 303 + if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS) || 304 + RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS | fRTMP_ADAPTER_NIC_NOT_EXIST)|| 305 + !RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_START_UP)) 306 + { 307 + Status = NDIS_STATUS_FAILURE; 308 + break; 309 + } 310 + 311 + // Check Free priority queue 312 + // Since we use PBF Queue2 for management frame. Its corresponding DMA ring should be using TxRing. 313 + 314 + // 2860C use Tx Ring 315 + 316 + // free Tx(QueIdx) resources 317 + FreeNum = GET_TXRING_FREENO(pAd, QueIdx); 318 + 319 + if ((FreeNum > 0)) 320 + { 321 + // We need to reserve space for rtmp hardware header. i.e., TxWI for RT2860 and TxInfo+TxWI for RT2870 322 + NdisZeroMemory(&rtmpHwHdr, (TXINFO_SIZE + TXWI_SIZE)); 323 + Status = RTMPAllocateNdisPacket(pAd, &pPacket, (PUCHAR)&rtmpHwHdr, (TXINFO_SIZE + TXWI_SIZE), pData, Length); 324 + if (Status != NDIS_STATUS_SUCCESS) 325 + { 326 + DBGPRINT(RT_DEBUG_WARN, ("MiniportMMRequest (error:: can't allocate NDIS PACKET)\n")); 327 + break; 328 + } 329 + 330 + //pAd->CommonCfg.MlmeTransmit.field.MODE = MODE_CCK; 331 + //pAd->CommonCfg.MlmeRate = RATE_2; 332 + 333 + 334 + Status = MlmeDataHardTransmit(pAd, QueIdx, pPacket); 335 + if (Status != NDIS_STATUS_SUCCESS) 336 + RTMPFreeNdisPacket(pAd, pPacket); 337 + retry = MAX_DATAMM_RETRY; 338 + } 339 + else 340 + { 341 + retry ++; 342 + 343 + printk("retry %d\n", retry); 344 + pAd->RalinkCounters.MgmtRingFullCount++; 345 + 346 + if (retry >= MAX_DATAMM_RETRY) 347 + { 348 + DBGPRINT(RT_DEBUG_ERROR, ("Qidx(%d), not enough space in DataRing, MgmtRingFullCount=%ld!\n", 349 + QueIdx, pAd->RalinkCounters.MgmtRingFullCount)); 350 + } 351 + } 352 + 353 + } while (retry < MAX_DATAMM_RETRY); 354 + 355 + 356 + return Status; 357 + } 358 + #endif /* RT30xx */ 255 359 256 360 /* 257 361 ======================================================================== ··· 395 283 return NDIS_STATUS_FAILURE; 396 284 } 397 285 286 + #ifdef RT2860 398 287 if ( pAd->MACVersion == 0x28600100 ) 399 288 return MlmeHardTransmitTxRing(pAd,QueIdx,pPacket); 400 289 else 290 + #endif 401 291 return MlmeHardTransmitMgmtRing(pAd,QueIdx,pPacket); 402 292 403 293 } 404 294 405 - 295 + #ifdef RT2860 406 296 NDIS_STATUS MlmeHardTransmitTxRing( 407 297 IN PRTMP_ADAPTER pAd, 408 298 IN UCHAR QueIdx, ··· 586 472 587 473 return NDIS_STATUS_SUCCESS; 588 474 } 475 + #endif /* RT2860 */ 589 476 477 + #ifdef RT30xx 478 + NDIS_STATUS MlmeDataHardTransmit( 479 + IN PRTMP_ADAPTER pAd, 480 + IN UCHAR QueIdx, 481 + IN PNDIS_PACKET pPacket) 482 + { 483 + if ((pAd->CommonCfg.RadarDetect.RDMode != RD_NORMAL_MODE) 484 + ) 485 + { 486 + return NDIS_STATUS_FAILURE; 487 + } 488 + 489 + #ifdef RT2870 490 + return MlmeHardTransmitMgmtRing(pAd,QueIdx,pPacket); 491 + #endif // RT2870 // 492 + } 493 + #endif /* RT30xx */ 590 494 591 495 NDIS_STATUS MlmeHardTransmitMgmtRing( 592 496 IN PRTMP_ADAPTER pAd, ··· 632 500 633 501 // outgoing frame always wakeup PHY to prevent frame lost 634 502 if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE)) 503 + #ifdef RT2860 635 504 AsicForceWakeup(pAd, FROM_TX); 505 + #endif 506 + #ifdef RT2870 507 + AsicForceWakeup(pAd, TRUE); 508 + #endif 636 509 637 510 pFirstTxWI = (PTXWI_STRUC)(pSrcBufVA + TXINFO_SIZE); 638 511 pHeader_802_11 = (PHEADER_802_11) (pSrcBufVA + TXINFO_SIZE + TXWI_SIZE); //TXWI_SIZE); ··· 960 823 961 824 { 962 825 // If support WMM, enable it. 826 + #ifdef RT2860 963 827 if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_WMM_INUSED)) 828 + #endif 829 + #ifdef RT2870 830 + if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_WMM_INUSED) && 831 + CLIENT_STATUS_TEST_FLAG(pMacEntry, fCLIENT_STATUS_WMM_CAPABLE)) 832 + #endif 964 833 TX_BLK_SET_FLAG(pTxBlk, fTX_bWMM); 965 834 } 966 835 ··· 1013 870 } 1014 871 1015 872 return TRUE; 873 + 874 + #ifdef RT30xx 875 + FillTxBlkErr: 876 + return FALSE; 877 + #endif 1016 878 } 1017 879 1018 880 ··· 1105 957 if (QIdx == NUM_OF_TX_RING) 1106 958 { 1107 959 sQIdx = 0; 960 + //PS packets use HCCA queue when dequeue from PS unicast queue (WiFi WPA2 MA9_DT1 for Marvell B STA) 1108 961 eQIdx = 3; // 4 ACs, start from 0. 1109 962 } 1110 963 else ··· 1148 999 DEQUEUE_UNLOCK(&pAd->irq_lock, bIntContext, IrqFlags); 1149 1000 break; 1150 1001 } 1151 - 1002 + #ifdef RT2860 1152 1003 FreeNumber[QueIdx] = GET_TXRING_FREENO(pAd, QueIdx); 1153 1004 1154 1005 #ifdef DBG_DIAGNOSE ··· 1173 1024 RTMPFreeTXDUponTxDmaDone(pAd, QueIdx); 1174 1025 FreeNumber[QueIdx] = GET_TXRING_FREENO(pAd, QueIdx); 1175 1026 } 1176 - 1027 + #endif /* RT2860 */ 1177 1028 // probe the Queue Head 1178 1029 pQueue = &pAd->TxSwQueue[QueIdx]; 1179 1030 if ((pEntry = pQueue->Head) == NULL) ··· 1242 1093 pTxBlk->TxFrameType = TX_LEGACY_FRAME; 1243 1094 } 1244 1095 1096 + #ifdef RT2870 1097 + DEQUEUE_UNLOCK(&pAd->irq_lock, bIntContext, IrqFlags); 1098 + #endif // RT2870 // 1245 1099 1246 1100 Count += pTxBlk->TxPacketList.Number; 1247 1101 1248 1102 // Do HardTransmit now. 1249 1103 Status = STAHardTransmit(pAd, pTxBlk, QueIdx); 1250 1104 1105 + #ifdef RT2860 1251 1106 DEQUEUE_UNLOCK(&pAd->irq_lock, bIntContext, IrqFlags); 1252 1107 // static rate also need NICUpdateFifoStaCounters() function. 1253 1108 //if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_TX_RATE_SWITCH_ENABLED)) 1254 1109 NICUpdateFifoStaCounters(pAd); 1110 + #endif 1255 1111 } 1256 1112 1257 1113 RT28XX_STOP_DEQUEUE(pAd, QueIdx, IrqFlags); 1114 + 1115 + #ifdef RT2870 1116 + if (!hasTxDesc) 1117 + RTUSBKickBulkOut(pAd); 1118 + #endif // RT2870 // 1258 1119 } 1259 1120 1260 1121 } ··· 1792 1633 return (NULL); 1793 1634 } 1794 1635 1795 - 1636 + #ifdef RT2860 1796 1637 BOOLEAN RTMPFreeTXDUponTxDmaDone( 1797 1638 IN PRTMP_ADAPTER pAd, 1798 1639 IN UCHAR QueIdx) ··· 2175 2016 DBGPRINT_RAW(RT_DEBUG_TRACE,(" RxSwReadIdx [%d]=", AC0freeIdx)); 2176 2017 DBGPRINT_RAW(RT_DEBUG_TRACE,(" pending-NDIS=%ld\n", pAd->RalinkCounters.PendingNdisPacketCount)); 2177 2018 } 2019 + #endif /* RT2860 */ 2178 2020 2179 2021 /* 2180 2022 ======================================================================== ··· 2235 2075 { 2236 2076 DBGPRINT(RT_DEBUG_TRACE,("SCAN done, resume MSDU transmission ...\n")); 2237 2077 2238 - 2078 + #ifdef RT30xx 2079 + // After finish BSS_SCAN_IN_PROGRESS, we need to restore Current R66 value 2080 + // R66 should not be 0 2081 + if (pAd->BbpTuning.R66CurrentValue == 0) 2082 + { 2083 + pAd->BbpTuning.R66CurrentValue = 0x38; 2084 + DBGPRINT_ERR(("RTMPResumeMsduTransmission, R66CurrentValue=0...\n")); 2085 + } 2086 + #endif 2239 2087 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R66, pAd->BbpTuning.R66CurrentValue); 2240 2088 2241 2089 RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS); ··· 2466 2298 pEntry->AuthMode = pAd->StaCfg.AuthMode; 2467 2299 pEntry->WepStatus = pAd->StaCfg.WepStatus; 2468 2300 pEntry->PrivacyFilter = Ndis802_11PrivFilterAcceptAll; 2301 + #ifdef RT2860 2469 2302 AsicRemovePairwiseKeyEntry(pAd, pEntry->apidx, (UCHAR)i); 2303 + #endif 2470 2304 } 2471 2305 } 2472 2306 ··· 2476 2306 pEntry->PairwiseKey.KeyLen = 0; 2477 2307 pEntry->PairwiseKey.CipherAlg = CIPHER_NONE; 2478 2308 2309 + #ifdef RT2860 2479 2310 if ((pAd->OpMode == OPMODE_STA) && 2480 2311 (pAd->StaCfg.BssType == BSS_ADHOC)) 2481 2312 pEntry->PortSecured = WPA_802_1X_PORT_SECURED; 2482 2313 else 2314 + #endif 2483 2315 pEntry->PortSecured = WPA_802_1X_PORT_NOT_SECURED; 2484 2316 2485 2317 pEntry->PMKID_CacheIdx = ENTRY_NOT_FOUND; ··· 2617 2445 if (pAd->MacTab.Size == 0) 2618 2446 { 2619 2447 pAd->CommonCfg.AddHTInfo.AddHtInfo2.OperaionMode = 0; 2448 + #ifndef RT30xx 2620 2449 AsicUpdateProtect(pAd, 0 /*pAd->CommonCfg.AddHTInfo.AddHtInfo2.OperaionMode*/, (ALLN_SETPROTECT), TRUE, 0 /*pAd->MacTab.fAnyStationNonGF*/); 2450 + #endif 2451 + #ifdef RT30xx 2452 + RT28XX_UPDATE_PROTECT(pAd); // edit by johnli, fix "in_interrupt" error when call "MacTableDeleteEntry" in Rx tasklet 2453 + #endif 2621 2454 } 2622 2455 2623 2456 return TRUE; ··· 2646 2469 2647 2470 for (i=1; i<MAX_LEN_OF_MAC_TABLE; i++) 2648 2471 { 2472 + #ifdef RT2860 2649 2473 RT28XX_STA_ENTRY_MAC_RESET(pAd, i); 2474 + #endif 2650 2475 if (pAd->MacTab.Content[i].ValidAsCLI == TRUE) 2651 2476 { 2652 2477 // free resources of BA ··· 2658 2479 2659 2480 2660 2481 2482 + #ifdef RT2870 2483 + NdisZeroMemory(pAd->MacTab.Content[i].Addr, 6); 2484 + RT28XX_STA_ENTRY_MAC_RESET(pAd, i); 2485 + #endif // RT2870 // 2661 2486 2662 2487 //AsicDelWcidTab(pAd, i); 2663 2488 } ··· 2974 2791 2975 2792 STATS_INC_RX_PACKETS(pAd, FromWhichBSSID); 2976 2793 2794 + #ifdef RT2870 2795 + if (pAd->CommonCfg.bDisableReordering == 0) 2796 + { 2797 + PBA_REC_ENTRY pBAEntry; 2798 + ULONG Now32; 2799 + UCHAR Wcid = pRxBlk->pRxWI->WirelessCliID; 2800 + UCHAR TID = pRxBlk->pRxWI->TID; 2801 + USHORT Idx; 2802 + 2803 + #define REORDERING_PACKET_TIMEOUT ((100 * HZ)/1000) // system ticks -- 100 ms 2804 + 2805 + if (Wcid < MAX_LEN_OF_MAC_TABLE) 2806 + { 2807 + Idx = pAd->MacTab.Content[Wcid].BARecWcidArray[TID]; 2808 + if (Idx != 0) 2809 + { 2810 + pBAEntry = &pAd->BATable.BARecEntry[Idx]; 2811 + // update last rx time 2812 + NdisGetSystemUpTime(&Now32); 2813 + if ((pBAEntry->list.qlen > 0) && 2814 + RTMP_TIME_AFTER((unsigned long)Now32, (unsigned long)(pBAEntry->LastIndSeqAtTimer+(REORDERING_PACKET_TIMEOUT))) 2815 + ) 2816 + { 2817 + printk("Indicate_Legacy_Packet():flush reordering_timeout_mpdus! RxWI->Flags=%d, pRxWI.TID=%d, RxD->AMPDU=%d!\n", pRxBlk->Flags, pRxBlk->pRxWI->TID, pRxBlk->RxD.AMPDU); 2818 + hex_dump("Dump the legacy Packet:", GET_OS_PKT_DATAPTR(pRxBlk->pRxPacket), 64); 2819 + ba_flush_reordering_timeout_mpdus(pAd, pBAEntry, Now32); 2820 + } 2821 + } 2822 + } 2823 + } 2824 + #endif // RT2870 // 2977 2825 2978 2826 wlan_802_11_to_802_3_packet(pAd, pRxBlk, Header802_3, FromWhichBSSID); 2979 2827
+44 -1
drivers/staging/rt2860/common/cmm_info.c
··· 762 762 IN PRTMP_ADAPTER pAd, 763 763 IN PUCHAR arg) 764 764 { 765 + #ifdef RT2860 765 766 INT i, QueIdx=0; 766 767 PRT28XX_RXD_STRUC pRxD; 767 768 PTXD_STRUC pTxD; ··· 793 792 hex_dump("Rx Descriptor", (char *)pRxD, 16); 794 793 printk("pRxD->DDONE = %x\n", pRxD->DDONE); 795 794 } 796 - 795 + #endif /* RT2860 */ 797 796 return TRUE; 798 797 } 799 798 ··· 1419 1418 pAd->CommonCfg.DesiredHtPhy.RxSTBC = 0; 1420 1419 } 1421 1420 1421 + #ifndef RT30xx 1422 + #ifdef RT2870 1423 + /* Frank recommend ,If not, Tx maybe block in high power. Rx has no problem*/ 1424 + if(IS_RT3070(pAd) && ((pAd->RfIcType == RFIC_3020) || (pAd->RfIcType == RFIC_2020))) 1425 + { 1426 + pAd->CommonCfg.HtCapability.HtCapInfo.TxSTBC = 0; 1427 + pAd->CommonCfg.DesiredHtPhy.TxSTBC = 0; 1428 + } 1429 + #endif // RT2870 // 1430 + #endif 1422 1431 1423 1432 if(pHTPhyMode->SHORTGI == GI_400) 1424 1433 { ··· 1707 1696 } 1708 1697 1709 1698 // For key index and ext IV bit, so only need to update the position(offset+3). 1699 + #ifdef RT2860 1710 1700 RTMP_IO_WRITE8(pAd, offset+3, IVEIV); 1701 + #endif 1702 + #ifdef RT2870 1703 + RTUSBMultiWrite_OneByte(pAd, offset+3, &IVEIV); 1704 + #endif // RT2870 // 1711 1705 1712 1706 DBGPRINT(RT_DEBUG_TRACE,("RTMPAddWcidAttributeEntry: WCID #%d, KeyIndex #%d, Alg=%s\n",Wcid, KeyIdx, CipherName[CipherAlg])); 1713 1707 DBGPRINT(RT_DEBUG_TRACE,(" WCIDAttri = 0x%x \n", WCIDAttri)); ··· 2489 2473 2490 2474 Value = simple_strtol(arg, 0, 10); 2491 2475 if (Value == 0) 2476 + { 2492 2477 pAd->CommonCfg.BACapability.field.AutoBA = FALSE; 2478 + #ifdef RT30xx 2479 + pAd->CommonCfg.BACapability.field.Policy = BA_NOTUSE; 2480 + #endif 2481 + } 2493 2482 else if (Value == 1) 2483 + { 2494 2484 pAd->CommonCfg.BACapability.field.AutoBA = TRUE; 2485 + #ifdef RT30xx 2486 + pAd->CommonCfg.BACapability.field.Policy = IMMED_BA; 2487 + #endif 2488 + } 2495 2489 else 2496 2490 return FALSE; //Invalid argument 2497 2491 2498 2492 pAd->CommonCfg.REGBACapability.field.AutoBA = pAd->CommonCfg.BACapability.field.AutoBA; 2493 + #ifdef RT30xx 2494 + pAd->CommonCfg.REGBACapability.field.Policy = pAd->CommonCfg.BACapability.field.Policy; 2495 + #endif 2499 2496 SetCommonHT(pAd); 2500 2497 2501 2498 DBGPRINT(RT_DEBUG_TRACE, ("Set_HtAutoBa_Proc::(HtAutoBa=%d)\n",pAd->CommonCfg.BACapability.field.AutoBA)); ··· 2725 2696 { 2726 2697 case Ndis802_11AuthModeOpen: 2727 2698 return "OPEN"; 2699 + #if defined(RT2860) || defined(RT30xx) 2728 2700 default: 2701 + #endif 2729 2702 case Ndis802_11AuthModeWPAPSK: 2730 2703 return "WPAPSK"; 2731 2704 case Ndis802_11AuthModeShared: ··· 2742 2711 return "WPAPSKWPA2PSK"; 2743 2712 case Ndis802_11AuthModeWPA1WPA2: 2744 2713 return "WPA1WPA2"; 2714 + #ifndef RT30xx 2745 2715 case Ndis802_11AuthModeWPANone: 2746 2716 return "WPANONE"; 2717 + #ifdef RT2870 2718 + default: 2719 + return "UNKNOW"; 2720 + #endif 2721 + #endif 2747 2722 } 2748 2723 } 2749 2724 ··· 2758 2721 { 2759 2722 switch(encryMode) 2760 2723 { 2724 + #if defined(RT2860) || defined(RT30xx) 2761 2725 default: 2726 + #endif 2762 2727 case Ndis802_11WEPDisabled: 2763 2728 return "NONE"; 2764 2729 case Ndis802_11WEPEnabled: ··· 2771 2732 return "AES"; 2772 2733 case Ndis802_11Encryption4Enabled: 2773 2734 return "TKIPAES"; 2735 + #if !defined(RT2860) && !defined(RT30xx) 2736 + default: 2737 + return "UNKNOW"; 2738 + #endif 2774 2739 } 2775 2740 } 2776 2741
+12 -1
drivers/staging/rt2860/common/cmm_sync.c
··· 440 440 441 441 RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS); 442 442 } 443 + #ifdef RT2870 444 + else if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST) && (pAd->OpMode == OPMODE_STA)) 445 + { 446 + pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE; 447 + MlmeCntlConfirm(pAd, MT2_SCAN_CONF, MLME_FAIL_NO_RESOURCE); 448 + } 449 + #endif // RT2870 // 443 450 else 444 451 { 445 452 { 446 453 // BBP and RF are not accessible in PS mode, we has to wake them up first 447 454 if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE)) 455 + #ifdef RT2860 448 456 AsicForceWakeup(pAd, FROM_TX); 449 - 457 + #endif 458 + #ifdef RT2870 459 + AsicForceWakeup(pAd, TRUE); 460 + #endif 450 461 // leave PSM during scanning. otherwise we may lost ProbeRsp & BEACON 451 462 if (pAd->StaCfg.Psm == PWR_SAVE) 452 463 MlmeSetPsmBit(pAd, PWR_ACTIVE);
+10 -2
drivers/staging/rt2860/common/cmm_wpa.c
··· 39 39 // WPA OUI 40 40 UCHAR OUI_WPA_NONE_AKM[4] = {0x00, 0x50, 0xF2, 0x00}; 41 41 UCHAR OUI_WPA_VERSION[4] = {0x00, 0x50, 0xF2, 0x01}; 42 + #ifndef RT30xx 42 43 UCHAR OUI_WPA_WEP40[4] = {0x00, 0x50, 0xF2, 0x01}; 44 + #endif 43 45 UCHAR OUI_WPA_TKIP[4] = {0x00, 0x50, 0xF2, 0x02}; 44 46 UCHAR OUI_WPA_CCMP[4] = {0x00, 0x50, 0xF2, 0x04}; 47 + #ifndef RT30xx 45 48 UCHAR OUI_WPA_WEP104[4] = {0x00, 0x50, 0xF2, 0x05}; 49 + #endif 46 50 UCHAR OUI_WPA_8021X_AKM[4] = {0x00, 0x50, 0xF2, 0x01}; 47 51 UCHAR OUI_WPA_PSK_AKM[4] = {0x00, 0x50, 0xF2, 0x02}; 48 52 // WPA2 OUI ··· 55 51 UCHAR OUI_WPA2_CCMP[4] = {0x00, 0x0F, 0xAC, 0x04}; 56 52 UCHAR OUI_WPA2_8021X_AKM[4] = {0x00, 0x0F, 0xAC, 0x01}; 57 53 UCHAR OUI_WPA2_PSK_AKM[4] = {0x00, 0x0F, 0xAC, 0x02}; 54 + #ifndef RT30xx 58 55 UCHAR OUI_WPA2_WEP104[4] = {0x00, 0x0F, 0xAC, 0x05}; 56 + #endif 59 57 // MSA OUI 60 58 UCHAR OUI_MSA_8021X_AKM[4] = {0x00, 0x0F, 0xAC, 0x05}; // Not yet final - IEEE 802.11s-D1.06 61 59 UCHAR OUI_MSA_PSK_AKM[4] = {0x00, 0x0F, 0xAC, 0x06}; // Not yet final - IEEE 802.11s-D1.06 ··· 376 370 break; 377 371 } 378 372 373 + #ifndef RT30xx 379 374 if ((pAd->OpMode == OPMODE_STA) && 380 375 (pAd->StaCfg.GroupCipher != Ndis802_11Encryption2Enabled) && 381 376 (pAd->StaCfg.GroupCipher != Ndis802_11Encryption3Enabled)) ··· 392 385 break; 393 386 } 394 387 } 395 - 388 + #endif 396 389 // swap for big-endian platform 397 390 pRsnie_cipher->version = cpu2le16(pRsnie_cipher->version); 398 391 pRsnie_cipher->ucount = cpu2le16(pRsnie_cipher->ucount); ··· 453 446 break; 454 447 } 455 448 449 + #ifndef RT30xx 456 450 if ((pAd->OpMode == OPMODE_STA) && 457 451 (pAd->StaCfg.GroupCipher != Ndis802_11Encryption2Enabled) && 458 452 (pAd->StaCfg.GroupCipher != Ndis802_11Encryption3Enabled)) ··· 469 461 break; 470 462 } 471 463 } 472 - 464 + #endif 473 465 // swap for big-endian platform 474 466 pRsnie_cipher->version = cpu2le16(pRsnie_cipher->version); 475 467 pRsnie_cipher->ucount = cpu2le16(pRsnie_cipher->ucount);
+1267 -1
drivers/staging/rt2860/common/eeprom.c
··· 73 73 RaiseClock(pAd, &x); 74 74 75 75 RTMP_IO_READ32(pAd, E2PROM_CSR, &x); 76 - 76 + #ifdef RT30xx 77 + LowerClock(pAd, &x); //prevent read failed 78 + #endif 77 79 x &= ~(EEDI); 78 80 if(x & EEDO) 79 81 data |= 1; 80 82 83 + #ifndef RT30xx 81 84 LowerClock(pAd, &x); 85 + #endif 82 86 } 83 87 84 88 return data; ··· 185 181 UINT32 x; 186 182 USHORT data; 187 183 184 + #ifdef RT30xx 185 + if (pAd->NicConfig2.field.AntDiversity) 186 + { 187 + pAd->EepromAccess = TRUE; 188 + } 189 + //2008/09/11:KH add to support efuse<-- 190 + //2008/09/11:KH add to support efuse--> 191 + { 192 + #endif 188 193 Offset /= 2; 189 194 // reset bits and set EECS 190 195 RTMP_IO_READ32(pAd, E2PROM_CSR, &x); ··· 201 188 x |= EECS; 202 189 RTMP_IO_WRITE32(pAd, E2PROM_CSR, x); 203 190 191 + #ifdef RT30xx 192 + // patch can not access e-Fuse issue 193 + if (!IS_RT3090(pAd)) 194 + { 195 + #endif 204 196 // kick a pulse 205 197 RaiseClock(pAd, &x); 206 198 LowerClock(pAd, &x); 199 + #ifdef RT30xx 200 + } 201 + #endif 207 202 208 203 // output the read_opcode and register number in that order 209 204 ShiftOutBits(pAd, EEPROM_READ_OPCODE, 3); ··· 222 201 223 202 EEpromCleanup(pAd); 224 203 204 + #ifdef RT30xx 205 + // Antenna and EEPROM access are both using EESK pin, 206 + // Therefor we should avoid accessing EESK at the same time 207 + // Then restore antenna after EEPROM access 208 + if ((pAd->NicConfig2.field.AntDiversity) || (pAd->RfIcType == RFIC_3020)) 209 + { 210 + pAd->EepromAccess = FALSE; 211 + AsicSetRxAnt(pAd, pAd->RxAnt.Pair1PrimaryRxAnt); 212 + } 213 + } 214 + #endif 225 215 return data; 226 216 } //ReadEEprom 227 217 ··· 243 211 { 244 212 UINT32 x; 245 213 214 + #ifdef RT30xx 215 + if (pAd->NicConfig2.field.AntDiversity) 216 + { 217 + pAd->EepromAccess = TRUE; 218 + } 219 + //2008/09/11:KH add to support efuse<-- 220 + //2008/09/11:KH add to support efuse--> 221 + { 222 + #endif 246 223 Offset /= 2; 247 224 248 225 EWEN(pAd); ··· 262 221 x |= EECS; 263 222 RTMP_IO_WRITE32(pAd, E2PROM_CSR, x); 264 223 224 + #ifdef RT30xx 225 + // patch can not access e-Fuse issue 226 + if (!IS_RT3090(pAd)) 227 + { 228 + #endif 265 229 // kick a pulse 266 230 RaiseClock(pAd, &x); 267 231 LowerClock(pAd, &x); 232 + #ifdef RT30xx 233 + } 234 + #endif 268 235 269 236 // output the read_opcode ,register number and data in that order 270 237 ShiftOutBits(pAd, EEPROM_WRITE_OPCODE, 3); ··· 289 240 EWDS(pAd); 290 241 291 242 EEpromCleanup(pAd); 243 + 244 + #ifdef RT30xx 245 + // Antenna and EEPROM access are both using EESK pin, 246 + // Therefor we should avoid accessing EESK at the same time 247 + // Then restore antenna after EEPROM access 248 + if ((pAd->NicConfig2.field.AntDiversity) || (pAd->RfIcType == RFIC_3020)) 249 + { 250 + pAd->EepromAccess = FALSE; 251 + AsicSetRxAnt(pAd, pAd->RxAnt.Pair1PrimaryRxAnt); 252 + } 253 + } 254 + #endif 292 255 } 293 256 257 + //2008/09/11:KH add to support efuse<-- 258 + #ifdef RT30xx 259 + /* 260 + ======================================================================== 261 + 262 + Routine Description: 263 + 264 + Arguments: 265 + 266 + Return Value: 267 + 268 + IRQL = 269 + 270 + Note: 271 + 272 + ======================================================================== 273 + */ 274 + UCHAR eFuseReadRegisters( 275 + IN PRTMP_ADAPTER pAd, 276 + IN USHORT Offset, 277 + IN USHORT Length, 278 + OUT USHORT* pData) 279 + { 280 + EFUSE_CTRL_STRUC eFuseCtrlStruc; 281 + int i; 282 + USHORT efuseDataOffset; 283 + UINT32 data; 284 + 285 + RTMP_IO_READ32(pAd, EFUSE_CTRL, (PUINT32) &eFuseCtrlStruc); 286 + 287 + //Step0. Write 10-bit of address to EFSROM_AIN (0x580, bit25:bit16). The address must be 16-byte alignment. 288 + //Use the eeprom logical address and covert to address to block number 289 + eFuseCtrlStruc.field.EFSROM_AIN = Offset & 0xfff0; 290 + 291 + //Step1. Write EFSROM_MODE (0x580, bit7:bit6) to 0. 292 + eFuseCtrlStruc.field.EFSROM_MODE = 0; 293 + 294 + //Step2. Write EFSROM_KICK (0x580, bit30) to 1 to kick-off physical read procedure. 295 + eFuseCtrlStruc.field.EFSROM_KICK = 1; 296 + 297 + NdisMoveMemory(&data, &eFuseCtrlStruc, 4); 298 + RTMP_IO_WRITE32(pAd, EFUSE_CTRL, data); 299 + 300 + //Step3. Polling EFSROM_KICK(0x580, bit30) until it become 0 again. 301 + i = 0; 302 + while(i < 100) 303 + { 304 + //rtmp.HwMemoryReadDword(EFUSE_CTRL, (DWORD *) &eFuseCtrlStruc, 4); 305 + RTMP_IO_READ32(pAd, EFUSE_CTRL, (PUINT32) &eFuseCtrlStruc); 306 + if(eFuseCtrlStruc.field.EFSROM_KICK == 0) 307 + { 308 + break; 309 + } 310 + RTMPusecDelay(2); 311 + i++; 312 + } 313 + 314 + //if EFSROM_AOUT is not found in physical address, write 0xffff 315 + if (eFuseCtrlStruc.field.EFSROM_AOUT == 0x3f) 316 + { 317 + for(i=0; i<Length/2; i++) 318 + *(pData+2*i) = 0xffff; 319 + } 320 + else 321 + { 322 + //Step4. Read 16-byte of data from EFUSE_DATA0-3 (0x590-0x59C) 323 + efuseDataOffset = EFUSE_DATA3 - (Offset & 0xC) ; 324 + //data hold 4 bytes data. 325 + //In RTMP_IO_READ32 will automatically execute 32-bytes swapping 326 + RTMP_IO_READ32(pAd, efuseDataOffset, &data); 327 + //Decide the upper 2 bytes or the bottom 2 bytes. 328 + // Little-endian S | S Big-endian 329 + // addr 3 2 1 0 | 0 1 2 3 330 + // Ori-V D C B A | A B C D 331 + //After swapping 332 + // D C B A | D C B A 333 + //Return 2-bytes 334 + //The return byte statrs from S. Therefore, the little-endian will return BA, the Big-endian will return DC. 335 + //For returning the bottom 2 bytes, the Big-endian should shift right 2-bytes. 336 + data = data >> (8*(Offset & 0x3)); 337 + 338 + NdisMoveMemory(pData, &data, Length); 339 + } 340 + 341 + return (UCHAR) eFuseCtrlStruc.field.EFSROM_AOUT; 342 + 343 + } 344 + 345 + /* 346 + ======================================================================== 347 + 348 + Routine Description: 349 + 350 + Arguments: 351 + 352 + Return Value: 353 + 354 + IRQL = 355 + 356 + Note: 357 + 358 + ======================================================================== 359 + */ 360 + VOID eFusePhysicalReadRegisters( 361 + IN PRTMP_ADAPTER pAd, 362 + IN USHORT Offset, 363 + IN USHORT Length, 364 + OUT USHORT* pData) 365 + { 366 + EFUSE_CTRL_STRUC eFuseCtrlStruc; 367 + int i; 368 + USHORT efuseDataOffset; 369 + UINT32 data; 370 + 371 + RTMP_IO_READ32(pAd, EFUSE_CTRL, (PUINT32) &eFuseCtrlStruc); 372 + 373 + //Step0. Write 10-bit of address to EFSROM_AIN (0x580, bit25:bit16). The address must be 16-byte alignment. 374 + eFuseCtrlStruc.field.EFSROM_AIN = Offset & 0xfff0; 375 + 376 + //Step1. Write EFSROM_MODE (0x580, bit7:bit6) to 1. 377 + //Read in physical view 378 + eFuseCtrlStruc.field.EFSROM_MODE = 1; 379 + 380 + //Step2. Write EFSROM_KICK (0x580, bit30) to 1 to kick-off physical read procedure. 381 + eFuseCtrlStruc.field.EFSROM_KICK = 1; 382 + 383 + NdisMoveMemory(&data, &eFuseCtrlStruc, 4); 384 + RTMP_IO_WRITE32(pAd, EFUSE_CTRL, data); 385 + 386 + //Step3. Polling EFSROM_KICK(0x580, bit30) until it become 0 again. 387 + i = 0; 388 + while(i < 100) 389 + { 390 + RTMP_IO_READ32(pAd, EFUSE_CTRL, (PUINT32) &eFuseCtrlStruc); 391 + if(eFuseCtrlStruc.field.EFSROM_KICK == 0) 392 + break; 393 + RTMPusecDelay(2); 394 + i++; 395 + } 396 + 397 + //Step4. Read 16-byte of data from EFUSE_DATA0-3 (0x59C-0x590) 398 + //Because the size of each EFUSE_DATA is 4 Bytes, the size of address of each is 2 bits. 399 + //The previous 2 bits is the EFUSE_DATA number, the last 2 bits is used to decide which bytes 400 + //Decide which EFUSE_DATA to read 401 + //590:F E D C 402 + //594:B A 9 8 403 + //598:7 6 5 4 404 + //59C:3 2 1 0 405 + efuseDataOffset = EFUSE_DATA3 - (Offset & 0xC) ; 406 + 407 + RTMP_IO_READ32(pAd, efuseDataOffset, &data); 408 + 409 + data = data >> (8*(Offset & 0x3)); 410 + 411 + NdisMoveMemory(pData, &data, Length); 412 + 413 + } 414 + 415 + /* 416 + ======================================================================== 417 + 418 + Routine Description: 419 + 420 + Arguments: 421 + 422 + Return Value: 423 + 424 + IRQL = 425 + 426 + Note: 427 + 428 + ======================================================================== 429 + */ 430 + VOID eFuseReadPhysical( 431 + IN PRTMP_ADAPTER pAd, 432 + IN PUSHORT lpInBuffer, 433 + IN ULONG nInBufferSize, 434 + OUT PUSHORT lpOutBuffer, 435 + IN ULONG nOutBufferSize 436 + ) 437 + { 438 + USHORT* pInBuf = (USHORT*)lpInBuffer; 439 + USHORT* pOutBuf = (USHORT*)lpOutBuffer; 440 + 441 + USHORT Offset = pInBuf[0]; //addr 442 + USHORT Length = pInBuf[1]; //length 443 + int i; 444 + 445 + for(i=0; i<Length; i+=2) 446 + { 447 + eFusePhysicalReadRegisters(pAd,Offset+i, 2, &pOutBuf[i/2]); 448 + } 449 + } 450 + 451 + /* 452 + ======================================================================== 453 + 454 + Routine Description: 455 + 456 + Arguments: 457 + 458 + Return Value: 459 + 460 + IRQL = 461 + 462 + Note: 463 + 464 + ======================================================================== 465 + */ 466 + NTSTATUS eFuseRead( 467 + IN PRTMP_ADAPTER pAd, 468 + IN USHORT Offset, 469 + OUT PUCHAR pData, 470 + IN USHORT Length) 471 + { 472 + USHORT* pOutBuf = (USHORT*)pData; 473 + NTSTATUS Status = STATUS_SUCCESS; 474 + UCHAR EFSROM_AOUT; 475 + int i; 476 + 477 + for(i=0; i<Length; i+=2) 478 + { 479 + EFSROM_AOUT = eFuseReadRegisters(pAd, Offset+i, 2, &pOutBuf[i/2]); 480 + } 481 + return Status; 482 + } 483 + 484 + /* 485 + ======================================================================== 486 + 487 + Routine Description: 488 + 489 + Arguments: 490 + 491 + Return Value: 492 + 493 + IRQL = 494 + 495 + Note: 496 + 497 + ======================================================================== 498 + */ 499 + VOID eFusePhysicalWriteRegisters( 500 + IN PRTMP_ADAPTER pAd, 501 + IN USHORT Offset, 502 + IN USHORT Length, 503 + OUT USHORT* pData) 504 + { 505 + EFUSE_CTRL_STRUC eFuseCtrlStruc; 506 + int i; 507 + USHORT efuseDataOffset; 508 + UINT32 data, eFuseDataBuffer[4]; 509 + 510 + //Step0. Write 16-byte of data to EFUSE_DATA0-3 (0x590-0x59C), where EFUSE_DATA0 is the LSB DW, EFUSE_DATA3 is the MSB DW. 511 + 512 + ///////////////////////////////////////////////////////////////// 513 + //read current values of 16-byte block 514 + RTMP_IO_READ32(pAd, EFUSE_CTRL, (PUINT32) &eFuseCtrlStruc); 515 + 516 + //Step0. Write 10-bit of address to EFSROM_AIN (0x580, bit25:bit16). The address must be 16-byte alignment. 517 + eFuseCtrlStruc.field.EFSROM_AIN = Offset & 0xfff0; 518 + 519 + //Step1. Write EFSROM_MODE (0x580, bit7:bit6) to 1. 520 + eFuseCtrlStruc.field.EFSROM_MODE = 1; 521 + 522 + //Step2. Write EFSROM_KICK (0x580, bit30) to 1 to kick-off physical read procedure. 523 + eFuseCtrlStruc.field.EFSROM_KICK = 1; 524 + 525 + NdisMoveMemory(&data, &eFuseCtrlStruc, 4); 526 + RTMP_IO_WRITE32(pAd, EFUSE_CTRL, data); 527 + 528 + //Step3. Polling EFSROM_KICK(0x580, bit30) until it become 0 again. 529 + i = 0; 530 + while(i < 100) 531 + { 532 + RTMP_IO_READ32(pAd, EFUSE_CTRL, (PUINT32) &eFuseCtrlStruc); 533 + 534 + if(eFuseCtrlStruc.field.EFSROM_KICK == 0) 535 + break; 536 + RTMPusecDelay(2); 537 + i++; 538 + } 539 + 540 + //Step4. Read 16-byte of data from EFUSE_DATA0-3 (0x59C-0x590) 541 + efuseDataOffset = EFUSE_DATA3; 542 + for(i=0; i< 4; i++) 543 + { 544 + RTMP_IO_READ32(pAd, efuseDataOffset, (PUINT32) &eFuseDataBuffer[i]); 545 + efuseDataOffset -= 4; 546 + } 547 + 548 + //Update the value, the offset is multiple of 2, length is 2 549 + efuseDataOffset = (Offset & 0xc) >> 2; 550 + data = pData[0] & 0xffff; 551 + //The offset should be 0x***10 or 0x***00 552 + if((Offset % 4) != 0) 553 + { 554 + eFuseDataBuffer[efuseDataOffset] = (eFuseDataBuffer[efuseDataOffset] & 0xffff) | (data << 16); 555 + } 556 + else 557 + { 558 + eFuseDataBuffer[efuseDataOffset] = (eFuseDataBuffer[efuseDataOffset] & 0xffff0000) | data; 559 + } 560 + 561 + efuseDataOffset = EFUSE_DATA3; 562 + for(i=0; i< 4; i++) 563 + { 564 + RTMP_IO_WRITE32(pAd, efuseDataOffset, eFuseDataBuffer[i]); 565 + efuseDataOffset -= 4; 566 + } 567 + ///////////////////////////////////////////////////////////////// 568 + 569 + //Step1. Write 10-bit of address to EFSROM_AIN (0x580, bit25:bit16). The address must be 16-byte alignment. 570 + eFuseCtrlStruc.field.EFSROM_AIN = Offset & 0xfff0; 571 + 572 + //Step2. Write EFSROM_MODE (0x580, bit7:bit6) to 3. 573 + eFuseCtrlStruc.field.EFSROM_MODE = 3; 574 + 575 + //Step3. Write EFSROM_KICK (0x580, bit30) to 1 to kick-off physical write procedure. 576 + eFuseCtrlStruc.field.EFSROM_KICK = 1; 577 + 578 + NdisMoveMemory(&data, &eFuseCtrlStruc, 4); 579 + RTMP_IO_WRITE32(pAd, EFUSE_CTRL, data); 580 + 581 + //Step4. Polling EFSROM_KICK(0x580, bit30) until it become 0 again. It��s done. 582 + i = 0; 583 + while(i < 100) 584 + { 585 + RTMP_IO_READ32(pAd, EFUSE_CTRL, (PUINT32) &eFuseCtrlStruc); 586 + 587 + if(eFuseCtrlStruc.field.EFSROM_KICK == 0) 588 + break; 589 + 590 + RTMPusecDelay(2); 591 + i++; 592 + } 593 + } 594 + 595 + /* 596 + ======================================================================== 597 + 598 + Routine Description: 599 + 600 + Arguments: 601 + 602 + Return Value: 603 + 604 + IRQL = 605 + 606 + Note: 607 + 608 + ======================================================================== 609 + */ 610 + NTSTATUS eFuseWriteRegisters( 611 + IN PRTMP_ADAPTER pAd, 612 + IN USHORT Offset, 613 + IN USHORT Length, 614 + IN USHORT* pData) 615 + { 616 + USHORT i; 617 + USHORT eFuseData; 618 + USHORT LogicalAddress, BlkNum = 0xffff; 619 + UCHAR EFSROM_AOUT; 620 + 621 + USHORT addr,tmpaddr, InBuf[3], tmpOffset; 622 + USHORT buffer[8]; 623 + BOOLEAN bWriteSuccess = TRUE; 624 + 625 + DBGPRINT(RT_DEBUG_TRACE, ("eFuseWriteRegisters Offset=%x, pData=%x\n", Offset, *pData)); 626 + 627 + //Step 0. find the entry in the mapping table 628 + //The address of EEPROM is 2-bytes alignment. 629 + //The last bit is used for alignment, so it must be 0. 630 + tmpOffset = Offset & 0xfffe; 631 + EFSROM_AOUT = eFuseReadRegisters(pAd, tmpOffset, 2, &eFuseData); 632 + 633 + if( EFSROM_AOUT == 0x3f) 634 + { //find available logical address pointer 635 + //the logical address does not exist, find an empty one 636 + //from the first address of block 45=16*45=0x2d0 to the last address of block 47 637 + //==>48*16-3(reserved)=2FC 638 + for (i=EFUSE_USAGE_MAP_START; i<=EFUSE_USAGE_MAP_END; i+=2) 639 + { 640 + //Retrive the logical block nubmer form each logical address pointer 641 + //It will access two logical address pointer each time. 642 + eFusePhysicalReadRegisters(pAd, i, 2, &LogicalAddress); 643 + if( (LogicalAddress & 0xff) == 0) 644 + {//Not used logical address pointer 645 + BlkNum = i-EFUSE_USAGE_MAP_START; 646 + break; 647 + } 648 + else if(( (LogicalAddress >> 8) & 0xff) == 0) 649 + {//Not used logical address pointer 650 + if (i != EFUSE_USAGE_MAP_END) 651 + { 652 + BlkNum = i-EFUSE_USAGE_MAP_START+1; 653 + } 654 + break; 655 + } 656 + } 657 + } 658 + else 659 + { 660 + BlkNum = EFSROM_AOUT; 661 + } 662 + 663 + DBGPRINT(RT_DEBUG_TRACE, ("eFuseWriteRegisters BlkNum = %d \n", BlkNum)); 664 + 665 + if(BlkNum == 0xffff) 666 + { 667 + DBGPRINT(RT_DEBUG_TRACE, ("eFuseWriteRegisters: out of free E-fuse space!!!\n")); 668 + return FALSE; 669 + } 670 + 671 + //Step 1. Save data of this block which is pointed by the avaible logical address pointer 672 + // read and save the original block data 673 + for(i =0; i<8; i++) 674 + { 675 + addr = BlkNum * 0x10 ; 676 + 677 + InBuf[0] = addr+2*i; 678 + InBuf[1] = 2; 679 + InBuf[2] = 0x0; 680 + 681 + eFuseReadPhysical(pAd, &InBuf[0], 4, &InBuf[2], 2); 682 + 683 + buffer[i] = InBuf[2]; 684 + } 685 + 686 + //Step 2. Update the data in buffer, and write the data to Efuse 687 + buffer[ (Offset >> 1) % 8] = pData[0]; 688 + 689 + do 690 + { 691 + //Step 3. Write the data to Efuse 692 + if(!bWriteSuccess) 693 + { 694 + for(i =0; i<8; i++) 695 + { 696 + addr = BlkNum * 0x10 ; 697 + 698 + InBuf[0] = addr+2*i; 699 + InBuf[1] = 2; 700 + InBuf[2] = buffer[i]; 701 + 702 + eFuseWritePhysical(pAd, &InBuf[0], 6, NULL, 2); 703 + } 704 + } 705 + else 706 + { 707 + addr = BlkNum * 0x10 ; 708 + 709 + InBuf[0] = addr+(Offset % 16); 710 + InBuf[1] = 2; 711 + InBuf[2] = pData[0]; 712 + 713 + eFuseWritePhysical(pAd, &InBuf[0], 6, NULL, 2); 714 + } 715 + 716 + //Step 4. Write mapping table 717 + addr = EFUSE_USAGE_MAP_START+BlkNum; 718 + 719 + tmpaddr = addr; 720 + 721 + if(addr % 2 != 0) 722 + addr = addr -1; 723 + InBuf[0] = addr; 724 + InBuf[1] = 2; 725 + 726 + //convert the address from 10 to 8 bit ( bit7, 6 = parity and bit5 ~ 0 = bit9~4), and write to logical map entry 727 + tmpOffset = Offset; 728 + tmpOffset >>= 4; 729 + tmpOffset |= ((~((tmpOffset & 0x01) ^ ( tmpOffset >> 1 & 0x01) ^ (tmpOffset >> 2 & 0x01) ^ (tmpOffset >> 3 & 0x01))) << 6) & 0x40; 730 + tmpOffset |= ((~( (tmpOffset >> 2 & 0x01) ^ (tmpOffset >> 3 & 0x01) ^ (tmpOffset >> 4 & 0x01) ^ ( tmpOffset >> 5 & 0x01))) << 7) & 0x80; 731 + 732 + // write the logical address 733 + if(tmpaddr%2 != 0) 734 + InBuf[2] = tmpOffset<<8; 735 + else 736 + InBuf[2] = tmpOffset; 737 + 738 + eFuseWritePhysical(pAd,&InBuf[0], 6, NULL, 0); 739 + 740 + //Step 5. Compare data if not the same, invalidate the mapping entry, then re-write the data until E-fuse is exhausted 741 + bWriteSuccess = TRUE; 742 + for(i =0; i<8; i++) 743 + { 744 + addr = BlkNum * 0x10 ; 745 + 746 + InBuf[0] = addr+2*i; 747 + InBuf[1] = 2; 748 + InBuf[2] = 0x0; 749 + 750 + eFuseReadPhysical(pAd, &InBuf[0], 4, &InBuf[2], 2); 751 + 752 + if(buffer[i] != InBuf[2]) 753 + { 754 + bWriteSuccess = FALSE; 755 + break; 756 + } 757 + } 758 + 759 + //Step 6. invlidate mapping entry and find a free mapping entry if not succeed 760 + if (!bWriteSuccess) 761 + { 762 + DBGPRINT(RT_DEBUG_TRACE, ("Not bWriteSuccess BlkNum = %d\n", BlkNum)); 763 + 764 + // the offset of current mapping entry 765 + addr = EFUSE_USAGE_MAP_START+BlkNum; 766 + 767 + //find a new mapping entry 768 + BlkNum = 0xffff; 769 + for (i=EFUSE_USAGE_MAP_START; i<=EFUSE_USAGE_MAP_END; i+=2) 770 + { 771 + eFusePhysicalReadRegisters(pAd, i, 2, &LogicalAddress); 772 + if( (LogicalAddress & 0xff) == 0) 773 + { 774 + BlkNum = i-EFUSE_USAGE_MAP_START; 775 + break; 776 + } 777 + else if(( (LogicalAddress >> 8) & 0xff) == 0) 778 + { 779 + if (i != EFUSE_USAGE_MAP_END) 780 + { 781 + BlkNum = i+1-EFUSE_USAGE_MAP_START; 782 + } 783 + break; 784 + } 785 + } 786 + DBGPRINT(RT_DEBUG_TRACE, ("Not bWriteSuccess new BlkNum = %d\n", BlkNum)); 787 + if(BlkNum == 0xffff) 788 + { 789 + DBGPRINT(RT_DEBUG_TRACE, ("eFuseWriteRegisters: out of free E-fuse space!!!\n")); 790 + return FALSE; 791 + } 792 + 793 + //invalidate the original mapping entry if new entry is not found 794 + tmpaddr = addr; 795 + 796 + if(addr % 2 != 0) 797 + addr = addr -1; 798 + InBuf[0] = addr; 799 + InBuf[1] = 2; 800 + 801 + eFuseReadPhysical(pAd, &InBuf[0], 4, &InBuf[2], 2); 802 + 803 + // write the logical address 804 + if(tmpaddr%2 != 0) 805 + { 806 + // Invalidate the high byte 807 + for (i=8; i<15; i++) 808 + { 809 + if( ( (InBuf[2] >> i) & 0x01) == 0) 810 + { 811 + InBuf[2] |= (0x1 <<i); 812 + break; 813 + } 814 + } 815 + } 816 + else 817 + { 818 + // invalidate the low byte 819 + for (i=0; i<8; i++) 820 + { 821 + if( ( (InBuf[2] >> i) & 0x01) == 0) 822 + { 823 + InBuf[2] |= (0x1 <<i); 824 + break; 825 + } 826 + } 827 + } 828 + eFuseWritePhysical(pAd, &InBuf[0], 6, NULL, 0); 829 + } 830 + } 831 + while(!bWriteSuccess); 832 + 833 + return TRUE; 834 + } 835 + 836 + /* 837 + ======================================================================== 838 + 839 + Routine Description: 840 + 841 + Arguments: 842 + 843 + Return Value: 844 + 845 + IRQL = 846 + 847 + Note: 848 + 849 + ======================================================================== 850 + */ 851 + VOID eFuseWritePhysical( 852 + IN PRTMP_ADAPTER pAd, 853 + PUSHORT lpInBuffer, 854 + ULONG nInBufferSize, 855 + PUCHAR lpOutBuffer, 856 + ULONG nOutBufferSize 857 + ) 858 + { 859 + USHORT* pInBuf = (USHORT*)lpInBuffer; 860 + int i; 861 + //USHORT* pOutBuf = (USHORT*)ioBuffer; 862 + 863 + USHORT Offset = pInBuf[0]; //addr 864 + USHORT Length = pInBuf[1]; //length 865 + USHORT* pValueX = &pInBuf[2]; //value ... 866 + // Little-endian S | S Big-endian 867 + // addr 3 2 1 0 | 0 1 2 3 868 + // Ori-V D C B A | A B C D 869 + //After swapping 870 + // D C B A | D C B A 871 + //Both the little and big-endian use the same sequence to write data. 872 + //Therefore, we only need swap data when read the data. 873 + for(i=0; i<Length; i+=2) 874 + { 875 + eFusePhysicalWriteRegisters(pAd, Offset+i, 2, &pValueX[i/2]); 876 + } 877 + } 878 + 879 + 880 + /* 881 + ======================================================================== 882 + 883 + Routine Description: 884 + 885 + Arguments: 886 + 887 + Return Value: 888 + 889 + IRQL = 890 + 891 + Note: 892 + 893 + ======================================================================== 894 + */ 895 + NTSTATUS eFuseWrite( 896 + IN PRTMP_ADAPTER pAd, 897 + IN USHORT Offset, 898 + IN PUCHAR pData, 899 + IN USHORT length) 900 + { 901 + int i; 902 + 903 + USHORT* pValueX = (PUSHORT) pData; //value ... 904 + //The input value=3070 will be stored as following 905 + // Little-endian S | S Big-endian 906 + // addr 1 0 | 0 1 907 + // Ori-V 30 70 | 30 70 908 + //After swapping 909 + // 30 70 | 70 30 910 + //Casting 911 + // 3070 | 7030 (x) 912 + //The swapping should be removed for big-endian 913 + for(i=0; i<length; i+=2) 914 + { 915 + eFuseWriteRegisters(pAd, Offset+i, 2, &pValueX[i/2]); 916 + } 917 + 918 + return TRUE; 919 + } 920 + 921 + /* 922 + ======================================================================== 923 + 924 + Routine Description: 925 + 926 + Arguments: 927 + 928 + Return Value: 929 + 930 + IRQL = 931 + 932 + Note: 933 + 934 + ======================================================================== 935 + */ 936 + INT set_eFuseGetFreeBlockCount_Proc( 937 + IN PRTMP_ADAPTER pAd, 938 + IN PUCHAR arg) 939 + { 940 + USHORT i; 941 + USHORT LogicalAddress; 942 + USHORT efusefreenum=0; 943 + if(!pAd->bUseEfuse) 944 + return FALSE; 945 + for (i = EFUSE_USAGE_MAP_START; i <= EFUSE_USAGE_MAP_END; i+=2) 946 + { 947 + eFusePhysicalReadRegisters(pAd, i, 2, &LogicalAddress); 948 + if( (LogicalAddress & 0xff) == 0) 949 + { 950 + efusefreenum= (UCHAR) (EFUSE_USAGE_MAP_END-i+1); 951 + break; 952 + } 953 + else if(( (LogicalAddress >> 8) & 0xff) == 0) 954 + { 955 + efusefreenum = (UCHAR) (EFUSE_USAGE_MAP_END-i); 956 + break; 957 + } 958 + 959 + if(i == EFUSE_USAGE_MAP_END) 960 + efusefreenum = 0; 961 + } 962 + printk("efuseFreeNumber is %d\n",efusefreenum); 963 + return TRUE; 964 + } 965 + INT set_eFusedump_Proc( 966 + IN PRTMP_ADAPTER pAd, 967 + IN PUCHAR arg) 968 + { 969 + USHORT InBuf[3]; 970 + INT i=0; 971 + if(!pAd->bUseEfuse) 972 + return FALSE; 973 + for(i =0; i<EFUSE_USAGE_MAP_END/2; i++) 974 + { 975 + InBuf[0] = 2*i; 976 + InBuf[1] = 2; 977 + InBuf[2] = 0x0; 978 + 979 + eFuseReadPhysical(pAd, &InBuf[0], 4, &InBuf[2], 2); 980 + if(i%4==0) 981 + printk("\nBlock %x:",i/8); 982 + printk("%04x ",InBuf[2]); 983 + } 984 + return TRUE; 985 + } 986 + INT set_eFuseLoadFromBin_Proc( 987 + IN PRTMP_ADAPTER pAd, 988 + IN PUCHAR arg) 989 + { 990 + CHAR *src; 991 + struct file *srcf; 992 + INT retval, orgfsuid, orgfsgid; 993 + mm_segment_t orgfs; 994 + UCHAR *buffer; 995 + UCHAR BinFileSize=0; 996 + INT i = 0,j=0,k=1; 997 + USHORT *PDATA; 998 + USHORT DATA; 999 + BinFileSize=strlen("RT30xxEEPROM.bin"); 1000 + src = kmalloc(128, MEM_ALLOC_FLAG); 1001 + NdisZeroMemory(src, 128); 1002 + 1003 + if(strlen(arg)>0) 1004 + { 1005 + 1006 + NdisMoveMemory(src, arg, strlen(arg)); 1007 + } 1008 + 1009 + else 1010 + { 1011 + 1012 + NdisMoveMemory(src, "RT30xxEEPROM.bin", BinFileSize); 1013 + } 1014 + 1015 + DBGPRINT(RT_DEBUG_TRACE, ("FileName=%s\n",src)); 1016 + buffer = kmalloc(MAX_EEPROM_BIN_FILE_SIZE, MEM_ALLOC_FLAG); 1017 + 1018 + if(buffer == NULL) 1019 + { 1020 + kfree(src); 1021 + return FALSE; 1022 + } 1023 + PDATA=kmalloc(sizeof(USHORT)*8,MEM_ALLOC_FLAG); 1024 + 1025 + if(PDATA==NULL) 1026 + { 1027 + kfree(src); 1028 + 1029 + kfree(buffer); 1030 + return FALSE; 1031 + } 1032 + /* Don't change to uid 0, let the file be opened as the "normal" user */ 1033 + #if 0 1034 + orgfsuid = current->fsuid; 1035 + orgfsgid = current->fsgid; 1036 + current->fsuid=current->fsgid = 0; 1037 + #endif 1038 + orgfs = get_fs(); 1039 + set_fs(KERNEL_DS); 1040 + 1041 + if (src && *src) 1042 + { 1043 + srcf = filp_open(src, O_RDONLY, 0); 1044 + if (IS_ERR(srcf)) 1045 + { 1046 + DBGPRINT(RT_DEBUG_ERROR, ("--> Error %ld opening %s\n", -PTR_ERR(srcf),src)); 1047 + return FALSE; 1048 + } 1049 + else 1050 + { 1051 + // The object must have a read method 1052 + if (srcf->f_op && srcf->f_op->read) 1053 + { 1054 + memset(buffer, 0x00, MAX_EEPROM_BIN_FILE_SIZE); 1055 + while(srcf->f_op->read(srcf, &buffer[i], 1, &srcf->f_pos)==1) 1056 + { 1057 + DBGPRINT(RT_DEBUG_TRACE, ("%02X ",buffer[i])); 1058 + if((i+1)%8==0) 1059 + DBGPRINT(RT_DEBUG_TRACE, ("\n")); 1060 + i++; 1061 + if(i>=MAX_EEPROM_BIN_FILE_SIZE) 1062 + { 1063 + DBGPRINT(RT_DEBUG_ERROR, ("--> Error %ld reading %s, The file is too large[1024]\n", -PTR_ERR(srcf),src)); 1064 + kfree(PDATA); 1065 + kfree(buffer); 1066 + kfree(src); 1067 + return FALSE; 1068 + } 1069 + } 1070 + } 1071 + else 1072 + { 1073 + DBGPRINT(RT_DEBUG_ERROR, ("--> Error!! System doest not support read function\n")); 1074 + kfree(PDATA); 1075 + kfree(buffer); 1076 + kfree(src); 1077 + return FALSE; 1078 + } 1079 + } 1080 + 1081 + 1082 + } 1083 + else 1084 + { 1085 + DBGPRINT(RT_DEBUG_ERROR, ("--> Error src or srcf is null\n")); 1086 + kfree(PDATA); 1087 + kfree(buffer); 1088 + return FALSE; 1089 + 1090 + } 1091 + 1092 + 1093 + retval=filp_close(srcf,NULL); 1094 + 1095 + if (retval) 1096 + { 1097 + DBGPRINT(RT_DEBUG_TRACE, ("--> Error %d closing %s\n", -retval, src)); 1098 + } 1099 + set_fs(orgfs); 1100 + #if 0 1101 + current->fsuid = orgfsuid; 1102 + current->fsgid = orgfsgid; 1103 + #endif 1104 + for(j=0;j<i;j++) 1105 + { 1106 + DBGPRINT(RT_DEBUG_TRACE, ("%02X ",buffer[j])); 1107 + if((j+1)%2==0) 1108 + PDATA[j/2%8]=((buffer[j]<<8)&0xff00)|(buffer[j-1]&0xff); 1109 + if(j%16==0) 1110 + { 1111 + k=buffer[j]; 1112 + } 1113 + else 1114 + { 1115 + k&=buffer[j]; 1116 + if((j+1)%16==0) 1117 + { 1118 + 1119 + DBGPRINT(RT_DEBUG_TRACE, (" result=%02X,blk=%02x\n",k,j/16)); 1120 + 1121 + if(k!=0xff) 1122 + eFuseWriteRegistersFromBin(pAd,(USHORT)j-15, 16, PDATA); 1123 + else 1124 + { 1125 + if(eFuseReadRegisters(pAd,j, 2,(PUSHORT)&DATA)!=0x3f) 1126 + eFuseWriteRegistersFromBin(pAd,(USHORT)j-15, 16, PDATA); 1127 + } 1128 + /* 1129 + for(l=0;l<8;l++) 1130 + printk("%04x ",PDATA[l]); 1131 + printk("\n"); 1132 + */ 1133 + NdisZeroMemory(PDATA,16); 1134 + 1135 + 1136 + } 1137 + } 1138 + 1139 + 1140 + } 1141 + 1142 + 1143 + kfree(PDATA); 1144 + kfree(buffer); 1145 + kfree(src); 1146 + return TRUE; 1147 + } 1148 + NTSTATUS eFuseWriteRegistersFromBin( 1149 + IN PRTMP_ADAPTER pAd, 1150 + IN USHORT Offset, 1151 + IN USHORT Length, 1152 + IN USHORT* pData) 1153 + { 1154 + USHORT i; 1155 + USHORT eFuseData; 1156 + USHORT LogicalAddress, BlkNum = 0xffff; 1157 + UCHAR EFSROM_AOUT,Loop=0; 1158 + EFUSE_CTRL_STRUC eFuseCtrlStruc; 1159 + USHORT efuseDataOffset; 1160 + UINT32 data,tempbuffer; 1161 + USHORT addr,tmpaddr, InBuf[3], tmpOffset; 1162 + UINT32 buffer[4]; 1163 + BOOLEAN bWriteSuccess = TRUE; 1164 + BOOLEAN bNotWrite=TRUE; 1165 + BOOLEAN bAllocateNewBlk=TRUE; 1166 + 1167 + DBGPRINT(RT_DEBUG_TRACE, ("eFuseWriteRegistersFromBin Offset=%x, pData=%04x:%04x:%04x:%04x\n", Offset, *pData,*(pData+1),*(pData+2),*(pData+3))); 1168 + 1169 + do 1170 + { 1171 + //Step 0. find the entry in the mapping table 1172 + //The address of EEPROM is 2-bytes alignment. 1173 + //The last bit is used for alignment, so it must be 0. 1174 + Loop++; 1175 + tmpOffset = Offset & 0xfffe; 1176 + EFSROM_AOUT = eFuseReadRegisters(pAd, tmpOffset, 2, &eFuseData); 1177 + 1178 + if( EFSROM_AOUT == 0x3f) 1179 + { //find available logical address pointer 1180 + //the logical address does not exist, find an empty one 1181 + //from the first address of block 45=16*45=0x2d0 to the last address of block 47 1182 + //==>48*16-3(reserved)=2FC 1183 + bAllocateNewBlk=TRUE; 1184 + for (i=EFUSE_USAGE_MAP_START; i<=EFUSE_USAGE_MAP_END; i+=2) 1185 + { 1186 + //Retrive the logical block nubmer form each logical address pointer 1187 + //It will access two logical address pointer each time. 1188 + eFusePhysicalReadRegisters(pAd, i, 2, &LogicalAddress); 1189 + if( (LogicalAddress & 0xff) == 0) 1190 + {//Not used logical address pointer 1191 + BlkNum = i-EFUSE_USAGE_MAP_START; 1192 + break; 1193 + } 1194 + else if(( (LogicalAddress >> 8) & 0xff) == 0) 1195 + {//Not used logical address pointer 1196 + if (i != EFUSE_USAGE_MAP_END) 1197 + { 1198 + BlkNum = i-EFUSE_USAGE_MAP_START+1; 1199 + } 1200 + break; 1201 + } 1202 + } 1203 + } 1204 + else 1205 + { 1206 + bAllocateNewBlk=FALSE; 1207 + BlkNum = EFSROM_AOUT; 1208 + } 1209 + 1210 + DBGPRINT(RT_DEBUG_TRACE, ("eFuseWriteRegisters BlkNum = %d \n", BlkNum)); 1211 + 1212 + if(BlkNum == 0xffff) 1213 + { 1214 + DBGPRINT(RT_DEBUG_TRACE, ("eFuseWriteRegisters: out of free E-fuse space!!!\n")); 1215 + return FALSE; 1216 + } 1217 + //Step 1.1.0 1218 + //If the block is not existing in mapping table, create one 1219 + //and write down the 16-bytes data to the new block 1220 + if(bAllocateNewBlk) 1221 + { 1222 + DBGPRINT(RT_DEBUG_TRACE, ("Allocate New Blk\n")); 1223 + efuseDataOffset = EFUSE_DATA3; 1224 + for(i=0; i< 4; i++) 1225 + { 1226 + DBGPRINT(RT_DEBUG_TRACE, ("Allocate New Blk, Data%d=%04x%04x\n",3-i,pData[2*i+1],pData[2*i])); 1227 + tempbuffer=((pData[2*i+1]<<16)&0xffff0000)|pData[2*i]; 1228 + 1229 + 1230 + RTMP_IO_WRITE32(pAd, efuseDataOffset,tempbuffer); 1231 + efuseDataOffset -= 4; 1232 + 1233 + } 1234 + ///////////////////////////////////////////////////////////////// 1235 + 1236 + //Step1.1.1. Write 10-bit of address to EFSROM_AIN (0x580, bit25:bit16). The address must be 16-byte alignment. 1237 + eFuseCtrlStruc.field.EFSROM_AIN = BlkNum* 0x10 ; 1238 + 1239 + //Step1.1.2. Write EFSROM_MODE (0x580, bit7:bit6) to 3. 1240 + eFuseCtrlStruc.field.EFSROM_MODE = 3; 1241 + 1242 + //Step1.1.3. Write EFSROM_KICK (0x580, bit30) to 1 to kick-off physical write procedure. 1243 + eFuseCtrlStruc.field.EFSROM_KICK = 1; 1244 + 1245 + NdisMoveMemory(&data, &eFuseCtrlStruc, 4); 1246 + 1247 + RTMP_IO_WRITE32(pAd, EFUSE_CTRL, data); 1248 + 1249 + //Step1.1.4. Polling EFSROM_KICK(0x580, bit30) until it become 0 again. It��s done. 1250 + i = 0; 1251 + while(i < 100) 1252 + { 1253 + RTMP_IO_READ32(pAd, EFUSE_CTRL, (PUINT32) &eFuseCtrlStruc); 1254 + 1255 + if(eFuseCtrlStruc.field.EFSROM_KICK == 0) 1256 + break; 1257 + 1258 + RTMPusecDelay(2); 1259 + i++; 1260 + } 1261 + 1262 + } 1263 + else 1264 + { //Step1.2. 1265 + //If the same logical number is existing, check if the writting data and the data 1266 + //saving in this block are the same. 1267 + ///////////////////////////////////////////////////////////////// 1268 + //read current values of 16-byte block 1269 + RTMP_IO_READ32(pAd, EFUSE_CTRL, (PUINT32) &eFuseCtrlStruc); 1270 + 1271 + //Step1.2.0. Write 10-bit of address to EFSROM_AIN (0x580, bit25:bit16). The address must be 16-byte alignment. 1272 + eFuseCtrlStruc.field.EFSROM_AIN = Offset & 0xfff0; 1273 + 1274 + //Step1.2.1. Write EFSROM_MODE (0x580, bit7:bit6) to 1. 1275 + eFuseCtrlStruc.field.EFSROM_MODE = 0; 1276 + 1277 + //Step1.2.2. Write EFSROM_KICK (0x580, bit30) to 1 to kick-off physical read procedure. 1278 + eFuseCtrlStruc.field.EFSROM_KICK = 1; 1279 + 1280 + NdisMoveMemory(&data, &eFuseCtrlStruc, 4); 1281 + RTMP_IO_WRITE32(pAd, EFUSE_CTRL, data); 1282 + 1283 + //Step1.2.3. Polling EFSROM_KICK(0x580, bit30) until it become 0 again. 1284 + i = 0; 1285 + while(i < 100) 1286 + { 1287 + RTMP_IO_READ32(pAd, EFUSE_CTRL, (PUINT32) &eFuseCtrlStruc); 1288 + 1289 + if(eFuseCtrlStruc.field.EFSROM_KICK == 0) 1290 + break; 1291 + RTMPusecDelay(2); 1292 + i++; 1293 + } 1294 + 1295 + //Step1.2.4. Read 16-byte of data from EFUSE_DATA0-3 (0x59C-0x590) 1296 + efuseDataOffset = EFUSE_DATA3; 1297 + for(i=0; i< 4; i++) 1298 + { 1299 + RTMP_IO_READ32(pAd, efuseDataOffset, (PUINT32) &buffer[i]); 1300 + efuseDataOffset -= 4; 1301 + } 1302 + //Step1.2.5. Check if the data of efuse and the writing data are the same. 1303 + for(i =0; i<4; i++) 1304 + { 1305 + tempbuffer=((pData[2*i+1]<<16)&0xffff0000)|pData[2*i]; 1306 + DBGPRINT(RT_DEBUG_TRACE, ("buffer[%d]=%x,pData[%d]=%x,pData[%d]=%x,tempbuffer=%x\n",i,buffer[i],2*i,pData[2*i],2*i+1,pData[2*i+1],tempbuffer)); 1307 + 1308 + if(((buffer[i]&0xffff0000)==(pData[2*i+1]<<16))&&((buffer[i]&0xffff)==pData[2*i])) 1309 + bNotWrite&=TRUE; 1310 + else 1311 + { 1312 + bNotWrite&=FALSE; 1313 + break; 1314 + } 1315 + } 1316 + if(!bNotWrite) 1317 + { 1318 + printk("The data is not the same\n"); 1319 + 1320 + for(i =0; i<8; i++) 1321 + { 1322 + addr = BlkNum * 0x10 ; 1323 + 1324 + InBuf[0] = addr+2*i; 1325 + InBuf[1] = 2; 1326 + InBuf[2] = pData[i]; 1327 + 1328 + eFuseWritePhysical(pAd, &InBuf[0], 6, NULL, 2); 1329 + } 1330 + 1331 + } 1332 + else 1333 + return TRUE; 1334 + } 1335 + 1336 + 1337 + 1338 + //Step 2. Write mapping table 1339 + addr = EFUSE_USAGE_MAP_START+BlkNum; 1340 + 1341 + tmpaddr = addr; 1342 + 1343 + if(addr % 2 != 0) 1344 + addr = addr -1; 1345 + InBuf[0] = addr; 1346 + InBuf[1] = 2; 1347 + 1348 + //convert the address from 10 to 8 bit ( bit7, 6 = parity and bit5 ~ 0 = bit9~4), and write to logical map entry 1349 + tmpOffset = Offset; 1350 + tmpOffset >>= 4; 1351 + tmpOffset |= ((~((tmpOffset & 0x01) ^ ( tmpOffset >> 1 & 0x01) ^ (tmpOffset >> 2 & 0x01) ^ (tmpOffset >> 3 & 0x01))) << 6) & 0x40; 1352 + tmpOffset |= ((~( (tmpOffset >> 2 & 0x01) ^ (tmpOffset >> 3 & 0x01) ^ (tmpOffset >> 4 & 0x01) ^ ( tmpOffset >> 5 & 0x01))) << 7) & 0x80; 1353 + 1354 + // write the logical address 1355 + if(tmpaddr%2 != 0) 1356 + InBuf[2] = tmpOffset<<8; 1357 + else 1358 + InBuf[2] = tmpOffset; 1359 + 1360 + eFuseWritePhysical(pAd,&InBuf[0], 6, NULL, 0); 1361 + 1362 + //Step 3. Compare data if not the same, invalidate the mapping entry, then re-write the data until E-fuse is exhausted 1363 + bWriteSuccess = TRUE; 1364 + for(i =0; i<8; i++) 1365 + { 1366 + addr = BlkNum * 0x10 ; 1367 + 1368 + InBuf[0] = addr+2*i; 1369 + InBuf[1] = 2; 1370 + InBuf[2] = 0x0; 1371 + 1372 + eFuseReadPhysical(pAd, &InBuf[0], 4, &InBuf[2], 2); 1373 + DBGPRINT(RT_DEBUG_TRACE, ("addr=%x, buffer[i]=%x,InBuf[2]=%x\n",InBuf[0],pData[i],InBuf[2])); 1374 + if(pData[i] != InBuf[2]) 1375 + { 1376 + bWriteSuccess = FALSE; 1377 + break; 1378 + } 1379 + } 1380 + 1381 + //Step 4. invlidate mapping entry and find a free mapping entry if not succeed 1382 + 1383 + if (!bWriteSuccess&&Loop<2) 1384 + { 1385 + DBGPRINT(RT_DEBUG_TRACE, ("eFuseWriteRegistersFromBin::Not bWriteSuccess BlkNum = %d\n", BlkNum)); 1386 + 1387 + // the offset of current mapping entry 1388 + addr = EFUSE_USAGE_MAP_START+BlkNum; 1389 + 1390 + //find a new mapping entry 1391 + BlkNum = 0xffff; 1392 + for (i=EFUSE_USAGE_MAP_START; i<=EFUSE_USAGE_MAP_END; i+=2) 1393 + { 1394 + eFusePhysicalReadRegisters(pAd, i, 2, &LogicalAddress); 1395 + if( (LogicalAddress & 0xff) == 0) 1396 + { 1397 + BlkNum = i-EFUSE_USAGE_MAP_START; 1398 + break; 1399 + } 1400 + else if(( (LogicalAddress >> 8) & 0xff) == 0) 1401 + { 1402 + if (i != EFUSE_USAGE_MAP_END) 1403 + { 1404 + BlkNum = i+1-EFUSE_USAGE_MAP_START; 1405 + } 1406 + break; 1407 + } 1408 + } 1409 + DBGPRINT(RT_DEBUG_TRACE, ("eFuseWriteRegistersFromBin::Not bWriteSuccess new BlkNum = %d\n", BlkNum)); 1410 + if(BlkNum == 0xffff) 1411 + { 1412 + DBGPRINT(RT_DEBUG_TRACE, ("eFuseWriteRegistersFromBin: out of free E-fuse space!!!\n")); 1413 + return FALSE; 1414 + } 1415 + 1416 + //invalidate the original mapping entry if new entry is not found 1417 + tmpaddr = addr; 1418 + 1419 + if(addr % 2 != 0) 1420 + addr = addr -1; 1421 + InBuf[0] = addr; 1422 + InBuf[1] = 2; 1423 + 1424 + eFuseReadPhysical(pAd, &InBuf[0], 4, &InBuf[2], 2); 1425 + 1426 + // write the logical address 1427 + if(tmpaddr%2 != 0) 1428 + { 1429 + // Invalidate the high byte 1430 + for (i=8; i<15; i++) 1431 + { 1432 + if( ( (InBuf[2] >> i) & 0x01) == 0) 1433 + { 1434 + InBuf[2] |= (0x1 <<i); 1435 + break; 1436 + } 1437 + } 1438 + } 1439 + else 1440 + { 1441 + // invalidate the low byte 1442 + for (i=0; i<8; i++) 1443 + { 1444 + if( ( (InBuf[2] >> i) & 0x01) == 0) 1445 + { 1446 + InBuf[2] |= (0x1 <<i); 1447 + break; 1448 + } 1449 + } 1450 + } 1451 + eFuseWritePhysical(pAd, &InBuf[0], 6, NULL, 0); 1452 + } 1453 + 1454 + } 1455 + while(!bWriteSuccess&&Loop<2); 1456 + 1457 + return TRUE; 1458 + } 1459 + 1460 + #endif // RT30xx // 1461 + //2008/09/11:KH add to support efuse-->
+1156 -7
drivers/staging/rt2860/common/mlme.c
··· 338 338 UCHAR Wpa2Ie = IE_WPA2; 339 339 UCHAR IbssIe = IE_IBSS_PARM; 340 340 UCHAR Ccx2Ie = IE_CCX_V2; 341 + #ifdef RT2870 342 + UCHAR WapiIe = IE_WAPI; 343 + #endif 341 344 342 345 extern UCHAR WPA_OUI[]; 343 346 ··· 449 446 {13, 247, 2, 2}, 450 447 {14, 248, 2, 4}, 451 448 }; 449 + #ifndef RT30xx 452 450 #define NUM_OF_3020_CHNL (sizeof(FreqItems3020) / sizeof(FREQUENCY_ITEM)) 451 + #endif 452 + #ifdef RT30xx 453 + //2008/07/10:KH Modified to share this variable 454 + UCHAR NUM_OF_3020_CHNL=(sizeof(FreqItems3020) / sizeof(FREQUENCY_ITEM)); 455 + #endif 453 456 454 457 /* 455 458 ========================================================================== ··· 513 504 // software-based RX Antenna diversity 514 505 RTMPInitTimer(pAd, &pAd->Mlme.RxAntEvalTimer, GET_TIMER_FUNCTION(AsicRxAntEvalTimeout), pAd, FALSE); 515 506 507 + #ifdef RT2860 516 508 { 517 509 if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_ADVANCE_POWER_SAVE_PCIE_DEVICE)) 518 510 { ··· 522 512 RTMPInitTimer(pAd, &pAd->Mlme.RadioOnOffTimer, GET_TIMER_FUNCTION(RadioOnExec), pAd, FALSE); 523 513 } 524 514 } 515 + #endif 525 516 } while (FALSE); 526 517 527 518 DBGPRINT(RT_DEBUG_TRACE, ("<-- MLME Initialize\n")); ··· 577 566 //From message type, determine which state machine I should drive 578 567 if (MlmeDequeue(&pAd->Mlme.Queue, &Elem)) 579 568 { 569 + #ifdef RT2870 570 + if (Elem->MsgType == MT2_RESET_CONF) 571 + { 572 + DBGPRINT_RAW(RT_DEBUG_TRACE, ("!!! reset MLME state machine !!!\n")); 573 + MlmeRestartStateMachine(pAd); 574 + Elem->Occupied = FALSE; 575 + Elem->MsgLen = 0; 576 + continue; 577 + } 578 + #endif // RT2870 // 580 579 581 580 // if dequeue success 582 581 switch (Elem->Machine) ··· 657 636 IN PRTMP_ADAPTER pAd) 658 637 { 659 638 BOOLEAN Cancelled; 639 + #ifdef RT3070 640 + UINT32 TxPinCfg = 0x00050F0F; 641 + #endif // RT3070 // 660 642 661 643 DBGPRINT(RT_DEBUG_TRACE, ("==> MlmeHalt\n")); 662 644 ··· 677 653 RTMPCancelTimer(&pAd->MlmeAux.AuthTimer, &Cancelled); 678 654 RTMPCancelTimer(&pAd->MlmeAux.BeaconTimer, &Cancelled); 679 655 RTMPCancelTimer(&pAd->MlmeAux.ScanTimer, &Cancelled); 656 + #ifdef RT2860 680 657 if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_ADVANCE_POWER_SAVE_PCIE_DEVICE)) 681 658 { 682 659 RTMPCancelTimer(&pAd->Mlme.PsPollTimer, &Cancelled); 683 660 RTMPCancelTimer(&pAd->Mlme.RadioOnOffTimer, &Cancelled); 684 661 } 662 + #endif 685 663 } 686 664 687 665 RTMPCancelTimer(&pAd->Mlme.PeriodicTimer, &Cancelled); ··· 696 670 // Set LED 697 671 RTMPSetLED(pAd, LED_HALT); 698 672 RTMPSetSignalLED(pAd, -100); // Force signal strength Led to be turned off, firmware is not done it. 673 + #ifdef RT2870 674 + { 675 + LED_CFG_STRUC LedCfg; 676 + RTMP_IO_READ32(pAd, LED_CFG, &LedCfg.word); 677 + LedCfg.field.LedPolar = 0; 678 + LedCfg.field.RLedMode = 0; 679 + LedCfg.field.GLedMode = 0; 680 + LedCfg.field.YLedMode = 0; 681 + RTMP_IO_WRITE32(pAd, LED_CFG, LedCfg.word); 682 + } 683 + #endif // RT2870 // 684 + #ifdef RT3070 685 + // 686 + // Turn off LNA_PE 687 + // 688 + if (IS_RT3070(pAd) || IS_RT3071(pAd)) 689 + { 690 + TxPinCfg &= 0xFFFFF0F0; 691 + RTUSBWriteMACRegister(pAd, TX_PIN_CFG, TxPinCfg); 692 + } 693 + #endif // RT3070 // 699 694 } 700 695 701 696 RTMPusecDelay(5000); // 5 msec to gurantee Ant Diversity timer canceled ··· 787 740 ULONG TxTotalCnt; 788 741 PRTMP_ADAPTER pAd = (RTMP_ADAPTER *)FunctionContext; 789 742 743 + #ifdef RT2860 790 744 //Baron 2008/07/10 791 745 //printk("Baron_Test:\t%s", RTMPGetRalinkEncryModeStr(pAd->StaCfg.WepStatus)); 792 746 //If the STA security setting is OPEN or WEP, pAd->StaCfg.WpaSupplicantUP = 0. ··· 840 792 } 841 793 } 842 794 } 795 + #endif /* RT2860 */ 843 796 844 797 // Do nothing if the driver is starting halt state. 845 798 // This might happen when timer already been fired before cancel timer with mlmehalt ··· 850 801 fRTMP_ADAPTER_RESET_IN_PROGRESS)))) 851 802 return; 852 803 804 + #ifdef RT2860 853 805 { 854 806 if ((pAd->RalinkCounters.LastReceivedByteCount == pAd->RalinkCounters.ReceivedByteCount) && (pAd->StaCfg.bRadio == TRUE)) 855 807 { ··· 888 838 AsicResetFromDMABusy(pAd); 889 839 } 890 840 } 891 - 841 + #endif /* RT2860 */ 892 842 RT28XX_MLME_PRE_SANITY_CHECK(pAd); 893 843 894 844 { ··· 921 871 // RECBATimerTimeout(SystemSpecific1,FunctionContext,SystemSpecific2,SystemSpecific3); 922 872 pAd->Mlme.PeriodicRound ++; 923 873 874 + #ifdef RT3070 875 + // execute every 100ms, update the Tx FIFO Cnt for update Tx Rate. 876 + NICUpdateFifoStaCounters(pAd); 877 + #endif // RT3070 // 924 878 // execute every 500ms 925 879 if ((pAd->Mlme.PeriodicRound % 5 == 0) && RTMPAutoRateSwitchCheck(pAd)/*(OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_TX_RATE_SWITCH_ENABLED))*/) 926 880 { ··· 973 919 // the dynamic tuning mechanism below are based on most up-to-date information 974 920 NICUpdateRawCounters(pAd); 975 921 922 + #ifdef RT2870 923 + RT2870_WatchDog(pAd); 924 + #endif // RT2870 // 925 + 976 926 // Need statistics after read counter. So put after NICUpdateRawCounters 977 927 ORIBATimerTimeout(pAd); 978 928 ··· 987 929 pAd->RalinkCounters.OneSecTxRetryOkCount + 988 930 pAd->RalinkCounters.OneSecTxFailCount; 989 931 932 + // dynamic adjust antenna evaluation period according to the traffic 990 933 if (TxTotalCnt > 50) 991 934 { 992 935 if (pAd->Mlme.OneSecPeriodicRound % 10 == 0) ··· 1009 950 MlmeResetRalinkCounters(pAd); 1010 951 1011 952 { 953 + #ifdef RT2860 1012 954 if (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST) && (pAd->bPCIclkOff == FALSE)) 955 + #endif 1013 956 { 1014 957 // When Adhoc beacon is enabled and RTS/CTS is enabled, there is a chance that hardware MAC FSM will run into a deadlock 1015 958 // and sending CTS-to-self over and over. ··· 1037 976 RT28XX_MLME_HANDLER(pAd); 1038 977 } 1039 978 1040 - 1041 979 pAd->bUpdateBcnCntDone = FALSE; 1042 980 } 1043 981 1044 982 VOID STAMlmePeriodicExec( 1045 983 PRTMP_ADAPTER pAd) 1046 984 { 985 + #ifdef RT2860 1047 986 ULONG TxTotalCnt; 987 + #endif 988 + #ifdef RT2870 989 + ULONG TxTotalCnt; 990 + int i; 991 + #endif 1048 992 1049 993 if (pAd->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_DISABLE) 1050 994 { ··· 1058 992 pAd->StaCfg.bBlockAssoc = FALSE; 1059 993 } 1060 994 995 + #ifdef RT2860 1061 996 //Baron 2008/07/10 1062 997 //printk("Baron_Test:\t%s", RTMPGetRalinkEncryModeStr(pAd->StaCfg.WepStatus)); 1063 998 //If the STA security setting is OPEN or WEP, pAd->StaCfg.WpaSupplicantUP = 0. ··· 1071 1004 { 1072 1005 pAd->StaCfg.WpaSupplicantUP = 1; 1073 1006 } 1007 + #endif 1074 1008 1075 1009 if ((pAd->PreMediaState != pAd->IndicateMediaState) && (pAd->CommonCfg.bWirelessEvent)) 1076 1010 { ··· 1082 1014 pAd->PreMediaState = pAd->IndicateMediaState; 1083 1015 } 1084 1016 1017 + #ifdef RT2860 1085 1018 if ((pAd->OpMode == OPMODE_STA) && (IDLE_ON(pAd)) && 1086 1019 (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_ADVANCE_POWER_SAVE_PCIE_DEVICE)) && 1087 1020 (pAd->Mlme.SyncMachine.CurrState == SYNC_IDLE) && ··· 1092 1023 { 1093 1024 RT28xxPciAsicRadioOff(pAd, GUI_IDLE_POWER_SAVE, 0); 1094 1025 } 1026 + #endif 1095 1027 1096 1028 1097 1029 ··· 1189 1119 } 1190 1120 else if (ADHOC_ON(pAd)) 1191 1121 { 1122 + #ifdef RT2860 1192 1123 // 2003-04-17 john. this is a patch that driver forces a BEACON out if ASIC fails 1193 1124 // the "TX BEACON competition" for the entire past 1 sec. 1194 1125 // So that even when ASIC's BEACONgen engine been blocked ··· 1230 1159 pAd->StaCfg.Adhoc20NJoined = FALSE; 1231 1160 } 1232 1161 } 1162 + #endif /* RT2860 */ 1233 1163 1234 1164 //radar detect 1235 1165 if ((pAd->CommonCfg.Channel > 14) ··· 1255 1183 MlmeEnqueue(pAd, SYNC_STATE_MACHINE, MT2_MLME_START_REQ, sizeof(MLME_START_REQ_STRUCT), &StartReq); 1256 1184 pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_START; 1257 1185 } 1186 + 1187 + #ifdef RT2870 1188 + for (i = 1; i < MAX_LEN_OF_MAC_TABLE; i++) 1189 + { 1190 + MAC_TABLE_ENTRY *pEntry = &pAd->MacTab.Content[i]; 1191 + 1192 + if (pEntry->ValidAsCLI == FALSE) 1193 + continue; 1194 + 1195 + if (pEntry->LastBeaconRxTime + ADHOC_BEACON_LOST_TIME < pAd->Mlme.Now32) 1196 + MacTableDeleteEntry(pAd, pEntry->Aid, pEntry->Addr); 1197 + } 1198 + #endif 1258 1199 } 1259 1200 else // no INFRA nor ADHOC connection 1260 1201 { ··· 1435 1350 if ((pAd->OpMode == OPMODE_STA) && ADHOC_ON(pAd)) 1436 1351 { 1437 1352 if ((pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED) && 1353 + #ifdef RT2860 1438 1354 !pAd->StaCfg.AdhocBOnlyJoined && 1439 1355 !pAd->StaCfg.AdhocBGJoined && 1440 1356 (pAd->StaActive.SupportedPhyInfo.MCSSet[0] == 0xff) && 1441 1357 ((pAd->StaActive.SupportedPhyInfo.MCSSet[1] == 0x00) || (pAd->Antenna.field.TxPath == 1))) 1358 + #endif 1359 + #ifdef RT2870 1360 + (pEntry->HTCapability.MCSSet[0] == 0xff) && 1361 + ((pEntry->HTCapability.MCSSet[1] == 0x00) || (pAd->Antenna.field.TxPath == 1))) 1362 + #endif 1442 1363 {// 11N 1S Adhoc 1443 1364 *ppTable = RateSwitchTable11N1S; 1444 1365 *pTableSize = RateSwitchTable11N1S[0]; ··· 1452 1361 1453 1362 } 1454 1363 else if ((pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED) && 1364 + #ifdef RT2860 1455 1365 !pAd->StaCfg.AdhocBOnlyJoined && 1456 1366 !pAd->StaCfg.AdhocBGJoined && 1457 1367 (pAd->StaActive.SupportedPhyInfo.MCSSet[0] == 0xff) && 1458 1368 (pAd->StaActive.SupportedPhyInfo.MCSSet[1] == 0xff) && 1369 + #endif 1370 + #ifdef RT2870 1371 + (pEntry->HTCapability.MCSSet[0] == 0xff) && 1372 + (pEntry->HTCapability.MCSSet[1] == 0xff) && 1373 + #endif 1459 1374 (pAd->Antenna.field.TxPath == 2)) 1460 1375 {// 11N 2S Adhoc 1461 1376 if (pAd->LatchRfRegs.Channel <= 14) ··· 1479 1382 1480 1383 } 1481 1384 else 1385 + #ifdef RT2860 1482 1386 if (pAd->CommonCfg.PhyMode == PHY_11B) 1483 1387 { 1484 1388 *ppTable = RateSwitchTable11B; ··· 1488 1390 1489 1391 } 1490 1392 else if((pAd->LatchRfRegs.Channel <= 14) && (pAd->StaCfg.AdhocBOnlyJoined == TRUE)) 1393 + #endif 1394 + #ifdef RT2870 1395 + if ((pEntry->RateLen == 4) 1396 + && (pEntry->HTCapability.MCSSet[0] == 0) && (pEntry->HTCapability.MCSSet[1] == 0) 1397 + ) 1398 + #endif 1491 1399 { 1492 1400 // USe B Table when Only b-only Station in my IBSS . 1493 1401 *ppTable = RateSwitchTable11B; ··· 1577 1473 1578 1474 //else if ((pAd->StaActive.SupRateLen == 4) && (pAd->StaActive.ExtRateLen == 0) && (pAd->StaActive.SupportedPhyInfo.MCSSet[0] == 0) && (pAd->StaActive.SupportedPhyInfo.MCSSet[1] == 0)) 1579 1475 if ((pEntry->RateLen == 4) 1476 + #ifndef RT30xx 1477 + //Iverson mark for Adhoc b mode,sta will use rate 54 Mbps when connect with sta b/g/n mode 1580 1478 && (pEntry->HTCapability.MCSSet[0] == 0) && (pEntry->HTCapability.MCSSet[1] == 0) 1479 + #endif 1581 1480 ) 1582 1481 {// B only AP 1583 1482 *ppTable = RateSwitchTable11B; ··· 2041 1934 2042 1935 if ((pAd->MacTab.Size == 1) || (pEntry->ValidAsDls)) 2043 1936 { 1937 + #ifdef RT2860 2044 1938 Rssi = RTMPMaxRssi(pAd, (CHAR)pAd->StaCfg.RssiSample.AvgRssi0, (CHAR)pAd->StaCfg.RssiSample.AvgRssi1, (CHAR)pAd->StaCfg.RssiSample.AvgRssi2); 1939 + #endif 1940 + #ifdef RT2870 1941 + Rssi = RTMPMaxRssi(pAd, 1942 + pAd->StaCfg.RssiSample.AvgRssi0, 1943 + pAd->StaCfg.RssiSample.AvgRssi1, 1944 + pAd->StaCfg.RssiSample.AvgRssi2); 1945 + #endif 2045 1946 2046 1947 // Update statistic counter 2047 1948 RTMP_IO_READ32(pAd, TX_STA_CNT0, &TxStaCnt0.word); ··· 2079 1964 } 2080 1965 else 2081 1966 { 1967 + #ifdef RT2860 2082 1968 Rssi = RTMPMaxRssi(pAd, (CHAR)pEntry->RssiSample.AvgRssi0, (CHAR)pEntry->RssiSample.AvgRssi1, (CHAR)pEntry->RssiSample.AvgRssi2); 1969 + #endif 1970 + #ifdef RT2870 1971 + if (INFRA_ON(pAd) && (i == 1)) 1972 + Rssi = RTMPMaxRssi(pAd, 1973 + pAd->StaCfg.RssiSample.AvgRssi0, 1974 + pAd->StaCfg.RssiSample.AvgRssi1, 1975 + pAd->StaCfg.RssiSample.AvgRssi2); 1976 + else 1977 + Rssi = RTMPMaxRssi(pAd, 1978 + pEntry->RssiSample.AvgRssi0, 1979 + pEntry->RssiSample.AvgRssi1, 1980 + pEntry->RssiSample.AvgRssi2); 1981 + #endif 2083 1982 2084 1983 TxTotalCnt = pEntry->OneSecTxNoRetryOkCount + 2085 1984 pEntry->OneSecTxRetryOkCount + ··· 2517 2388 UCHAR UpRateIdx = 0, DownRateIdx = 0, CurrRateIdx = 0; 2518 2389 ULONG TxTotalCnt; 2519 2390 ULONG TxErrorRatio = 0; 2391 + #ifdef RT2860 2520 2392 BOOLEAN bTxRateChanged = TRUE; //, bUpgradeQuality = FALSE; 2393 + #endif 2394 + #ifdef RT2870 2395 + BOOLEAN bTxRateChanged; //, bUpgradeQuality = FALSE; 2396 + #endif 2521 2397 PRTMP_TX_RATE_SWITCH pCurrTxRate, pNextTxRate = NULL; 2522 2398 PUCHAR pTable; 2523 2399 UCHAR TableSize = 0; ··· 2547 2413 if (RTMPCheckEntryEnableAutoRateSwitch(pAd, pEntry) == FALSE) 2548 2414 continue; 2549 2415 2416 + #ifdef RT2860 2550 2417 //Rssi = RTMPMaxRssi(pAd, (CHAR)pAd->StaCfg.AvgRssi0, (CHAR)pAd->StaCfg.AvgRssi1, (CHAR)pAd->StaCfg.AvgRssi2); 2551 2418 if (pAd->Antenna.field.TxPath > 1) 2552 2419 Rssi = (pAd->StaCfg.RssiSample.AvgRssi0 + pAd->StaCfg.RssiSample.AvgRssi1) >> 1; 2553 2420 else 2554 2421 Rssi = pAd->StaCfg.RssiSample.AvgRssi0; 2422 + #endif 2423 + #ifdef RT2870 2424 + if (INFRA_ON(pAd) && (i == 1)) 2425 + Rssi = RTMPMaxRssi(pAd, 2426 + pAd->StaCfg.RssiSample.AvgRssi0, 2427 + pAd->StaCfg.RssiSample.AvgRssi1, 2428 + pAd->StaCfg.RssiSample.AvgRssi2); 2429 + else 2430 + Rssi = RTMPMaxRssi(pAd, 2431 + pEntry->RssiSample.AvgRssi0, 2432 + pEntry->RssiSample.AvgRssi1, 2433 + pEntry->RssiSample.AvgRssi2); 2434 + #endif 2555 2435 2556 2436 CurrRateIdx = pAd->CommonCfg.TxRateIndex; 2557 2437 ··· 2705 2557 pAd->DrsCounters.TxRateUpPenalty = 0; 2706 2558 NdisZeroMemory(pAd->DrsCounters.TxQuality, sizeof(USHORT) * MAX_STEP_OF_TX_RATE_SWITCH); 2707 2559 NdisZeroMemory(pAd->DrsCounters.PER, sizeof(UCHAR) * MAX_STEP_OF_TX_RATE_SWITCH); 2560 + #ifdef RT2870 2561 + bTxRateChanged = TRUE; 2562 + #endif 2708 2563 } 2709 2564 // if rate-down happen, only clear DownRate's bad history 2710 2565 else if (pAd->CommonCfg.TxRateIndex < CurrRateIdx) ··· 2717 2566 pAd->DrsCounters.TxRateUpPenalty = 0; // no penalty 2718 2567 pAd->DrsCounters.TxQuality[pAd->CommonCfg.TxRateIndex] = 0; 2719 2568 pAd->DrsCounters.PER[pAd->CommonCfg.TxRateIndex] = 0; 2569 + #ifdef RT2870 2570 + bTxRateChanged = TRUE; 2571 + #endif 2720 2572 } 2721 2573 else 2722 2574 { ··· 2775 2621 if (INFRA_ON(pAd) && 2776 2622 (PowerMode != Ndis802_11PowerModeCAM) && 2777 2623 (pAd->StaCfg.Psm == PWR_ACTIVE) && 2624 + #ifdef RT2860 2778 2625 RTMP_TEST_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP)) 2626 + #endif 2627 + #if !defined(RT2860) && !defined(RT30xx) 2628 + (pAd->Mlme.CntlMachine.CurrState == CNTL_IDLE)) 2629 + #endif 2630 + #ifndef RT30xx 2779 2631 { 2780 2632 NdisGetSystemUpTime(&pAd->Mlme.LastSendNULLpsmTime); 2781 2633 pAd->RalinkCounters.RxCountSinceLastNULL = 0; ··· 2795 2635 RTMPSendNullFrame(pAd, pAd->CommonCfg.TxRate, TRUE); 2796 2636 } 2797 2637 } 2638 + #endif 2639 + #ifdef RT30xx 2640 + // (! RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS)) 2641 + (pAd->Mlme.CntlMachine.CurrState == CNTL_IDLE) /*&& 2642 + (pAd->RalinkCounters.OneSecTxNoRetryOkCount == 0) && 2643 + (pAd->RalinkCounters.OneSecTxRetryOkCount == 0)*/) 2644 + { 2645 + // add by johnli, use Rx OK data count per second to calculate throughput 2646 + // If Ttraffic is too high ( > 400 Rx per second), don't go to sleep mode. If tx rate is low, use low criteria 2647 + // Mode=CCK/MCS=3 => 11 Mbps, Mode=OFDM/MCS=3 => 18 Mbps 2648 + if (((pAd->StaCfg.HTPhyMode.field.MCS <= 3) && 2649 + /* Iverson mark 2650 + (pAd->StaCfg.HTPhyMode.field.MODE <= MODE_OFDM) && 2651 + */ 2652 + (pAd->RalinkCounters.OneSecRxOkDataCnt < (ULONG)100)) || 2653 + ((pAd->StaCfg.HTPhyMode.field.MCS > 3) && 2654 + /* Iverson mark 2655 + (pAd->StaCfg.HTPhyMode.field.MODE > MODE_OFDM) && 2656 + */ 2657 + (pAd->RalinkCounters.OneSecRxOkDataCnt < (ULONG)400))) 2658 + { 2659 + // Get this time 2660 + NdisGetSystemUpTime(&pAd->Mlme.LastSendNULLpsmTime); 2661 + pAd->RalinkCounters.RxCountSinceLastNULL = 0; 2662 + MlmeSetPsmBit(pAd, PWR_SAVE); 2663 + if (!(pAd->CommonCfg.bAPSDCapable && pAd->CommonCfg.APEdcaParm.bAPSDCapable)) 2664 + { 2665 + RTMPSendNullFrame(pAd, pAd->CommonCfg.TxRate, FALSE); 2666 + } 2667 + else 2668 + { 2669 + RTMPSendNullFrame(pAd, pAd->CommonCfg.TxRate, TRUE); 2670 + } 2671 + } 2672 + } 2673 + #endif 2798 2674 } 2799 2675 2800 2676 // IRQL = PASSIVE_LEVEL ··· 2845 2649 RTMP_IO_READ32(pAd, AUTO_RSP_CFG, &csr4.word); 2846 2650 csr4.field.AckCtsPsmBit = (psm == PWR_SAVE)? 1:0; 2847 2651 RTMP_IO_WRITE32(pAd, AUTO_RSP_CFG, csr4.word); 2652 + #ifndef RT30xx 2848 2653 DBGPRINT(RT_DEBUG_TRACE, ("MlmeSetPsmBit = %d\n", psm)); 2654 + #endif 2849 2655 } 2850 2656 2851 2657 // IRQL = DISPATCH_LEVEL ··· 3877 3679 } 3878 3680 else 3879 3681 { 3682 + #ifdef RT30xx 3683 + /* avoid Hidden SSID form beacon to overwirite correct SSID from probe response */ 3684 + if ((SSID_EQUAL(Ssid, SsidLen, Tab->BssEntry[Idx].Ssid, Tab->BssEntry[Idx].SsidLen)) || 3685 + (NdisEqualMemory(Tab->BssEntry[Idx].Ssid, ZeroSsid, Tab->BssEntry[Idx].SsidLen))) 3686 + { 3687 + #endif 3880 3688 BssEntrySet(pAd, &Tab->BssEntry[Idx], pBssid, Ssid, SsidLen, BssType, BeaconPeriod,CfParm, AtimWin, 3881 3689 CapabilityInfo, SupRate, SupRateLen, ExtRate, ExtRateLen,pHtCapability, pAddHtInfo,HtCapabilityLen, AddHtInfoLen, 3882 3690 NewExtChanOffset, ChannelNo, Rssi, TimeStamp, CkipFlag, pEdcaParm, pQosCapability, pQbssLoad, LengthVIE, pVIE); 3691 + #ifdef RT30xx 3692 + } 3693 + #endif 3883 3694 } 3884 3695 3885 3696 return Idx; ··· 3949 3742 continue; 3950 3743 3951 3744 // check group cipher 3745 + #ifndef RT30xx 3952 3746 if ((pAd->StaCfg.WepStatus < pInBss->WPA.GroupCipher) && 3953 3747 (pInBss->WPA.GroupCipher != Ndis802_11GroupWEP40Enabled) && 3954 3748 (pInBss->WPA.GroupCipher != Ndis802_11GroupWEP104Enabled)) 3749 + #endif 3750 + #ifdef RT30xx 3751 + if (pAd->StaCfg.WepStatus < pInBss->WPA.GroupCipher) 3752 + #endif 3955 3753 continue; 3956 3754 3957 3755 // check pairwise cipher, skip if none matched ··· 3975 3763 continue; 3976 3764 3977 3765 // check group cipher 3766 + #ifndef RT30xx 3978 3767 if ((pAd->StaCfg.WepStatus < pInBss->WPA.GroupCipher) && 3979 3768 (pInBss->WPA2.GroupCipher != Ndis802_11GroupWEP40Enabled) && 3980 3769 (pInBss->WPA2.GroupCipher != Ndis802_11GroupWEP104Enabled)) 3770 + #endif 3771 + #ifdef RT30xx 3772 + if (pAd->StaCfg.WepStatus < pInBss->WPA2.GroupCipher) 3773 + #endif 3981 3774 continue; 3982 3775 3983 3776 // check pairwise cipher, skip if none matched ··· 4260 4043 switch (*pTmp) 4261 4044 { 4262 4045 case 1: 4046 + #ifndef RT30xx 4263 4047 pBss->WPA.GroupCipher = Ndis802_11GroupWEP40Enabled; 4264 4048 break; 4265 4049 case 5: 4266 4050 pBss->WPA.GroupCipher = Ndis802_11GroupWEP104Enabled; 4051 + #endif 4052 + #ifdef RT30xx 4053 + case 5: // Although WEP is not allowed in WPA related auth mode, we parse it anyway 4054 + pBss->WPA.GroupCipher = Ndis802_11Encryption1Enabled; 4055 + #endif 4267 4056 break; 4268 4057 case 2: 4269 4058 pBss->WPA.GroupCipher = Ndis802_11Encryption2Enabled; ··· 4356 4133 pBss->AuthMode = Ndis802_11AuthModeWPANone; 4357 4134 pBss->AuthModeAux = Ndis802_11AuthModeWPANone; 4358 4135 pBss->WepStatus = pBss->WPA.GroupCipher; 4359 - // Patched bugs for old driver 4360 4136 if (pBss->WPA.PairCipherAux == Ndis802_11WEPDisabled) 4361 4137 pBss->WPA.PairCipherAux = pBss->WPA.GroupCipher; 4362 4138 } ··· 4385 4163 switch (pCipher->Type) 4386 4164 { 4387 4165 case 1: 4166 + #ifndef RT30xx 4388 4167 pBss->WPA2.GroupCipher = Ndis802_11GroupWEP40Enabled; 4389 4168 break; 4390 4169 case 5: 4391 4170 pBss->WPA2.GroupCipher = Ndis802_11GroupWEP104Enabled; 4171 + #endif 4172 + #ifdef RT30xx 4173 + case 5: // Although WEP is not allowed in WPA related auth mode, we parse it anyway 4174 + pBss->WPA2.GroupCipher = Ndis802_11Encryption1Enabled; 4175 + #endif 4392 4176 break; 4393 4177 case 2: 4394 4178 pBss->WPA2.GroupCipher = Ndis802_11Encryption2Enabled; ··· 4488 4260 pBss->WPA.PairCipherAux = pBss->WPA2.PairCipherAux; 4489 4261 pBss->WPA.GroupCipher = pBss->WPA2.GroupCipher; 4490 4262 pBss->WepStatus = pBss->WPA.GroupCipher; 4491 - // Patched bugs for old driver 4492 4263 if (pBss->WPA.PairCipherAux == Ndis802_11WEPDisabled) 4493 4264 pBss->WPA.PairCipherAux = pBss->WPA.GroupCipher; 4494 4265 } ··· 4846 4619 VOID MlmeRestartStateMachine( 4847 4620 IN PRTMP_ADAPTER pAd) 4848 4621 { 4622 + #ifdef RT2860 4849 4623 MLME_QUEUE_ELEM *Elem = NULL; 4624 + #endif 4850 4625 BOOLEAN Cancelled; 4851 4626 4852 4627 DBGPRINT(RT_DEBUG_TRACE, ("MlmeRestartStateMachine \n")); 4853 4628 4629 + #ifdef RT2860 4854 4630 NdisAcquireSpinLock(&pAd->Mlme.TaskLock); 4855 4631 if(pAd->Mlme.bRunning) 4856 4632 { ··· 4881 4651 DBGPRINT_ERR(("MlmeRestartStateMachine: MlmeQueue empty\n")); 4882 4652 } 4883 4653 } 4654 + #endif /* RT2860 */ 4884 4655 4885 4656 { 4886 4657 // Cancel all timer events ··· 4911 4680 pAd->Mlme.ActMachine.CurrState = ACT_IDLE; 4912 4681 } 4913 4682 4683 + #ifdef RT2860 4914 4684 // Remove running state 4915 4685 NdisAcquireSpinLock(&pAd->Mlme.TaskLock); 4916 4686 pAd->Mlme.bRunning = FALSE; 4917 4687 NdisReleaseSpinLock(&pAd->Mlme.TaskLock); 4688 + #endif 4918 4689 } 4919 4690 4920 4691 /*! \brief test if the MLME Queue is empty ··· 5635 5402 } 5636 5403 } 5637 5404 5405 + #ifdef RT30xx 5406 + /* 5407 + ======================================================================== 5408 + 5409 + Routine Description: Write RT30xx RF register through MAC 5410 + 5411 + Arguments: 5412 + 5413 + Return Value: 5414 + 5415 + IRQL = 5416 + 5417 + Note: 5418 + 5419 + ======================================================================== 5420 + */ 5421 + NTSTATUS RT30xxWriteRFRegister( 5422 + IN PRTMP_ADAPTER pAd, 5423 + IN UCHAR RegID, 5424 + IN UCHAR Value) 5425 + { 5426 + RF_CSR_CFG_STRUC rfcsr; 5427 + UINT i = 0; 5428 + 5429 + do 5430 + { 5431 + RTMP_IO_READ32(pAd, RF_CSR_CFG, &rfcsr.word); 5432 + 5433 + if (!rfcsr.field.RF_CSR_KICK) 5434 + break; 5435 + i++; 5436 + } 5437 + while ((i < RETRY_LIMIT) && (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST))); 5438 + 5439 + if ((i == RETRY_LIMIT) || (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST))) 5440 + { 5441 + DBGPRINT_RAW(RT_DEBUG_ERROR, ("Retry count exhausted or device removed!!!\n")); 5442 + return STATUS_UNSUCCESSFUL; 5443 + } 5444 + 5445 + rfcsr.field.RF_CSR_WR = 1; 5446 + rfcsr.field.RF_CSR_KICK = 1; 5447 + rfcsr.field.TESTCSR_RFACC_REGNUM = RegID; 5448 + rfcsr.field.RF_CSR_DATA = Value; 5449 + 5450 + RTMP_IO_WRITE32(pAd, RF_CSR_CFG, rfcsr.word); 5451 + 5452 + return STATUS_SUCCESS; 5453 + } 5454 + 5455 + 5456 + /* 5457 + ======================================================================== 5458 + 5459 + Routine Description: Read RT30xx RF register through MAC 5460 + 5461 + Arguments: 5462 + 5463 + Return Value: 5464 + 5465 + IRQL = 5466 + 5467 + Note: 5468 + 5469 + ======================================================================== 5470 + */ 5471 + NTSTATUS RT30xxReadRFRegister( 5472 + IN PRTMP_ADAPTER pAd, 5473 + IN UCHAR RegID, 5474 + IN PUCHAR pValue) 5475 + { 5476 + RF_CSR_CFG_STRUC rfcsr; 5477 + UINT i=0, k=0; 5478 + 5479 + for (i=0; i<MAX_BUSY_COUNT; i++) 5480 + { 5481 + RTMP_IO_READ32(pAd, RF_CSR_CFG, &rfcsr.word); 5482 + 5483 + if (rfcsr.field.RF_CSR_KICK == BUSY) 5484 + { 5485 + continue; 5486 + } 5487 + rfcsr.word = 0; 5488 + rfcsr.field.RF_CSR_WR = 0; 5489 + rfcsr.field.RF_CSR_KICK = 1; 5490 + rfcsr.field.TESTCSR_RFACC_REGNUM = RegID; 5491 + RTMP_IO_WRITE32(pAd, RF_CSR_CFG, rfcsr.word); 5492 + for (k=0; k<MAX_BUSY_COUNT; k++) 5493 + { 5494 + RTMP_IO_READ32(pAd, RF_CSR_CFG, &rfcsr.word); 5495 + 5496 + if (rfcsr.field.RF_CSR_KICK == IDLE) 5497 + break; 5498 + } 5499 + if ((rfcsr.field.RF_CSR_KICK == IDLE) && 5500 + (rfcsr.field.TESTCSR_RFACC_REGNUM == RegID)) 5501 + { 5502 + *pValue = (UCHAR)rfcsr.field.RF_CSR_DATA; 5503 + break; 5504 + } 5505 + } 5506 + if (rfcsr.field.RF_CSR_KICK == BUSY) 5507 + { 5508 + DBGPRINT_ERR(("RF read R%d=0x%x fail, i[%d], k[%d]\n", RegID, rfcsr.word,i,k)); 5509 + return STATUS_UNSUCCESSFUL; 5510 + } 5511 + 5512 + return STATUS_SUCCESS; 5513 + } 5514 + #endif // RT30xx // 5515 + 5516 + #ifdef RT30xx 5517 + // add by johnli, RF power sequence setup 5518 + /* 5519 + ========================================================================== 5520 + Description: 5521 + 5522 + Load RF normal operation-mode setup 5523 + 5524 + ========================================================================== 5525 + */ 5526 + VOID RT30xxLoadRFNormalModeSetup( 5527 + IN PRTMP_ADAPTER pAd) 5528 + { 5529 + UCHAR RFValue; 5530 + 5531 + // RX0_PD & TX0_PD, RF R1 register Bit 2 & Bit 3 to 0 and RF_BLOCK_en,RX1_PD & TX1_PD, Bit0, Bit 4 & Bit5 to 1 5532 + RT30xxReadRFRegister(pAd, RF_R01, &RFValue); 5533 + RFValue = (RFValue & (~0x0C)) | 0x31; 5534 + RT30xxWriteRFRegister(pAd, RF_R01, RFValue); 5535 + 5536 + // TX_LO2_en, RF R15 register Bit 3 to 0 5537 + RT30xxReadRFRegister(pAd, RF_R15, &RFValue); 5538 + RFValue &= (~0x08); 5539 + RT30xxWriteRFRegister(pAd, RF_R15, RFValue); 5540 + 5541 + // TX_LO1_en, RF R17 register Bit 3 to 0 5542 + RT30xxReadRFRegister(pAd, RF_R17, &RFValue); 5543 + RFValue &= (~0x08); 5544 + // to fix rx long range issue 5545 + if (((pAd->MACVersion & 0xffff) >= 0x0211) && (pAd->NicConfig2.field.ExternalLNAForG == 0)) 5546 + { 5547 + RFValue |= 0x20; 5548 + } 5549 + RT30xxWriteRFRegister(pAd, RF_R17, RFValue); 5550 + 5551 + // RX_LO1_en, RF R20 register Bit 3 to 0 5552 + RT30xxReadRFRegister(pAd, RF_R20, &RFValue); 5553 + RFValue &= (~0x08); 5554 + RT30xxWriteRFRegister(pAd, RF_R20, RFValue); 5555 + 5556 + // RX_LO2_en, RF R21 register Bit 3 to 0 5557 + RT30xxReadRFRegister(pAd, RF_R21, &RFValue); 5558 + RFValue &= (~0x08); 5559 + RT30xxWriteRFRegister(pAd, RF_R21, RFValue); 5560 + 5561 + // LDORF_VC, RF R27 register Bit 2 to 0 5562 + RT30xxReadRFRegister(pAd, RF_R27, &RFValue); 5563 + if ((pAd->MACVersion & 0xffff) < 0x0211) 5564 + RFValue = (RFValue & (~0x77)) | 0x3; 5565 + else 5566 + RFValue = (RFValue & (~0x77)); 5567 + RT30xxWriteRFRegister(pAd, RF_R27, RFValue); 5568 + /* end johnli */ 5569 + } 5570 + 5571 + /* 5572 + ========================================================================== 5573 + Description: 5574 + 5575 + Load RF sleep-mode setup 5576 + 5577 + ========================================================================== 5578 + */ 5579 + VOID RT30xxLoadRFSleepModeSetup( 5580 + IN PRTMP_ADAPTER pAd) 5581 + { 5582 + UCHAR RFValue; 5583 + UINT32 MACValue; 5584 + 5585 + // RF_BLOCK_en. RF R1 register Bit 0 to 0 5586 + RT30xxReadRFRegister(pAd, RF_R01, &RFValue); 5587 + RFValue &= (~0x01); 5588 + RT30xxWriteRFRegister(pAd, RF_R01, RFValue); 5589 + 5590 + // VCO_IC, RF R7 register Bit 4 & Bit 5 to 0 5591 + RT30xxReadRFRegister(pAd, RF_R07, &RFValue); 5592 + RFValue &= (~0x30); 5593 + RT30xxWriteRFRegister(pAd, RF_R07, RFValue); 5594 + 5595 + // Idoh, RF R9 register Bit 1, Bit 2 & Bit 3 to 0 5596 + RT30xxReadRFRegister(pAd, RF_R09, &RFValue); 5597 + RFValue &= (~0x0E); 5598 + RT30xxWriteRFRegister(pAd, RF_R09, RFValue); 5599 + 5600 + // RX_CTB_en, RF R21 register Bit 7 to 0 5601 + RT30xxReadRFRegister(pAd, RF_R21, &RFValue); 5602 + RFValue &= (~0x80); 5603 + RT30xxWriteRFRegister(pAd, RF_R21, RFValue); 5604 + 5605 + // LDORF_VC, RF R27 register Bit 0, Bit 1 & Bit 2 to 1 5606 + RT30xxReadRFRegister(pAd, RF_R27, &RFValue); 5607 + RFValue |= 0x77; 5608 + RT30xxWriteRFRegister(pAd, RF_R27, RFValue); 5609 + 5610 + RTMP_IO_READ32(pAd, LDO_CFG0, &MACValue); 5611 + MACValue |= 0x1D000000; 5612 + RTMP_IO_WRITE32(pAd, LDO_CFG0, MACValue); 5613 + } 5614 + 5615 + /* 5616 + ========================================================================== 5617 + Description: 5618 + 5619 + Reverse RF sleep-mode setup 5620 + 5621 + ========================================================================== 5622 + */ 5623 + VOID RT30xxReverseRFSleepModeSetup( 5624 + IN PRTMP_ADAPTER pAd) 5625 + { 5626 + UCHAR RFValue; 5627 + UINT32 MACValue; 5628 + 5629 + // RF_BLOCK_en, RF R1 register Bit 0 to 1 5630 + RT30xxReadRFRegister(pAd, RF_R01, &RFValue); 5631 + RFValue |= 0x01; 5632 + RT30xxWriteRFRegister(pAd, RF_R01, RFValue); 5633 + 5634 + // VCO_IC, RF R7 register Bit 4 & Bit 5 to 1 5635 + RT30xxReadRFRegister(pAd, RF_R07, &RFValue); 5636 + RFValue |= 0x30; 5637 + RT30xxWriteRFRegister(pAd, RF_R07, RFValue); 5638 + 5639 + // Idoh, RF R9 register Bit 1, Bit 2 & Bit 3 to 1 5640 + RT30xxReadRFRegister(pAd, RF_R09, &RFValue); 5641 + RFValue |= 0x0E; 5642 + RT30xxWriteRFRegister(pAd, RF_R09, RFValue); 5643 + 5644 + // RX_CTB_en, RF R21 register Bit 7 to 1 5645 + RT30xxReadRFRegister(pAd, RF_R21, &RFValue); 5646 + RFValue |= 0x80; 5647 + RT30xxWriteRFRegister(pAd, RF_R21, RFValue); 5648 + 5649 + // LDORF_VC, RF R27 register Bit 2 to 0 5650 + RT30xxReadRFRegister(pAd, RF_R27, &RFValue); 5651 + if ((pAd->MACVersion & 0xffff) < 0x0211) 5652 + RFValue = (RFValue & (~0x77)) | 0x3; 5653 + else 5654 + RFValue = (RFValue & (~0x77)); 5655 + RT30xxWriteRFRegister(pAd, RF_R27, RFValue); 5656 + 5657 + // RT3071 version E has fixed this issue 5658 + if ((pAd->NicConfig2.field.DACTestBit == 1) && ((pAd->MACVersion & 0xffff) < 0x0211)) 5659 + { 5660 + // patch tx EVM issue temporarily 5661 + RTMP_IO_READ32(pAd, LDO_CFG0, &MACValue); 5662 + MACValue = ((MACValue & 0xE0FFFFFF) | 0x0D000000); 5663 + RTMP_IO_WRITE32(pAd, LDO_CFG0, MACValue); 5664 + } 5665 + else 5666 + { 5667 + RTMP_IO_READ32(pAd, LDO_CFG0, &MACValue); 5668 + MACValue = ((MACValue & 0xE0FFFFFF) | 0x01000000); 5669 + RTMP_IO_WRITE32(pAd, LDO_CFG0, MACValue); 5670 + } 5671 + } 5672 + // end johnli 5673 + #endif // RT30xx // 5674 + 5638 5675 /* 5639 5676 ========================================================================== 5640 5677 Description: ··· 5926 5423 RTMP_RF_REGS *RFRegTable; 5927 5424 5928 5425 // Search Tx power value 5426 + #ifdef RT30xx 5427 + // We can't use ChannelList to search channel, since some central channl's txpowr doesn't list 5428 + // in ChannelList, so use TxPower array instead. 5429 + // 5430 + for (index = 0; index < MAX_NUM_OF_CHANNELS; index++) 5431 + { 5432 + if (Channel == pAd->TxPower[index].Channel) 5433 + { 5434 + TxPwer = pAd->TxPower[index].Power; 5435 + TxPwer2 = pAd->TxPower[index].Power2; 5436 + break; 5437 + } 5438 + } 5439 + #endif 5440 + #ifndef RT30xx 5929 5441 for (index = 0; index < pAd->ChannelListNum; index++) 5930 5442 { 5931 5443 if (Channel == pAd->ChannelList[index].Channel) ··· 5950 5432 break; 5951 5433 } 5952 5434 } 5435 + #endif 5953 5436 5954 5437 if (index == MAX_NUM_OF_CHANNELS) 5955 5438 { 5439 + #ifndef RT30xx 5956 5440 DBGPRINT(RT_DEBUG_ERROR, ("AsicSwitchChannel: Cant find the Channel#%d \n", Channel)); 5441 + #endif 5442 + #ifdef RT30xx 5443 + DBGPRINT(RT_DEBUG_ERROR, ("AsicSwitchChannel: Can't find the Channel#%d \n", Channel)); 5444 + #endif 5957 5445 } 5958 5446 5447 + #ifdef RT2870 5448 + // The RF programming sequence is difference between 3xxx and 2xxx 5449 + #ifdef RT30xx 5450 + if ((IS_RT3070(pAd) || IS_RT3090(pAd)) && ((pAd->RfIcType == RFIC_3020) || (pAd->RfIcType == RFIC_2020) || 5451 + (pAd->RfIcType == RFIC_3021) || (pAd->RfIcType == RFIC_3022))) 5452 + #endif 5453 + #ifndef RT30xx 5454 + if (IS_RT3070(pAd) && ((pAd->RfIcType == RFIC_3020) || (pAd->RfIcType == RFIC_2020))) 5455 + #endif 5456 + { 5457 + /* modify by WY for Read RF Reg. error */ 5458 + UCHAR RFValue; 5459 + 5460 + for (index = 0; index < NUM_OF_3020_CHNL; index++) 5461 + { 5462 + if (Channel == FreqItems3020[index].Channel) 5463 + { 5464 + // Programming channel parameters 5465 + RT30xxWriteRFRegister(pAd, RF_R02, FreqItems3020[index].N); 5466 + RT30xxWriteRFRegister(pAd, RF_R03, FreqItems3020[index].K); 5467 + 5468 + #ifndef RT30xx 5469 + RT30xxReadRFRegister(pAd, RF_R06, (PUCHAR)&RFValue); 5470 + RFValue = (RFValue & 0xFC) | FreqItems3020[index].R; 5471 + RT30xxWriteRFRegister(pAd, RF_R06, (UCHAR)RFValue); 5472 + 5473 + // Set Tx Power 5474 + RT30xxReadRFRegister(pAd, RF_R12, (PUCHAR)&RFValue); 5475 + RFValue = (RFValue & 0xE0) | TxPwer; 5476 + RT30xxWriteRFRegister(pAd, RF_R12, (UCHAR)RFValue); 5477 + 5478 + // Set RF offset 5479 + RT30xxReadRFRegister(pAd, RF_R23, (PUCHAR)&RFValue); 5480 + RFValue = (RFValue & 0x80) | pAd->RfFreqOffset; 5481 + RT30xxWriteRFRegister(pAd, RF_R23, (UCHAR)RFValue); 5482 + #endif 5483 + #ifdef RT30xx 5484 + RT30xxReadRFRegister(pAd, RF_R06, &RFValue); 5485 + RFValue = (RFValue & 0xFC) | FreqItems3020[index].R; 5486 + RT30xxWriteRFRegister(pAd, RF_R06, RFValue); 5487 + 5488 + // Set Tx0 Power 5489 + RT30xxReadRFRegister(pAd, RF_R12, &RFValue); 5490 + RFValue = (RFValue & 0xE0) | TxPwer; 5491 + RT30xxWriteRFRegister(pAd, RF_R12, RFValue); 5492 + 5493 + // Set Tx1 Power 5494 + RT30xxReadRFRegister(pAd, RF_R13, &RFValue); 5495 + RFValue = (RFValue & 0xE0) | TxPwer2; 5496 + RT30xxWriteRFRegister(pAd, RF_R13, RFValue); 5497 + 5498 + // Tx/Rx Stream setting 5499 + RT30xxReadRFRegister(pAd, RF_R01, &RFValue); 5500 + //if (IS_RT3090(pAd)) 5501 + // RFValue |= 0x01; // Enable RF block. 5502 + RFValue &= 0x03; //clear bit[7~2] 5503 + if (pAd->Antenna.field.TxPath == 1) 5504 + RFValue |= 0xA0; 5505 + else if (pAd->Antenna.field.TxPath == 2) 5506 + RFValue |= 0x80; 5507 + if (pAd->Antenna.field.RxPath == 1) 5508 + RFValue |= 0x50; 5509 + else if (pAd->Antenna.field.RxPath == 2) 5510 + RFValue |= 0x40; 5511 + RT30xxWriteRFRegister(pAd, RF_R01, RFValue); 5512 + 5513 + // Set RF offset 5514 + RT30xxReadRFRegister(pAd, RF_R23, &RFValue); 5515 + RFValue = (RFValue & 0x80) | pAd->RfFreqOffset; 5516 + RT30xxWriteRFRegister(pAd, RF_R23, RFValue); 5517 + #endif 5518 + 5519 + // Set BW 5520 + if (!bScan && (pAd->CommonCfg.BBPCurrentBW == BW_40)) 5521 + { 5522 + RFValue = pAd->Mlme.CaliBW40RfR24; 5523 + //DISABLE_11N_CHECK(pAd); 5524 + } 5525 + else 5526 + { 5527 + RFValue = pAd->Mlme.CaliBW20RfR24; 5528 + } 5529 + #ifndef RT30xx 5530 + RT30xxWriteRFRegister(pAd, RF_R24, (UCHAR)RFValue); 5531 + 5532 + // Enable RF tuning 5533 + RT30xxReadRFRegister(pAd, RF_R07, (PUCHAR)&RFValue); 5534 + RFValue = RFValue | 0x1; 5535 + RT30xxWriteRFRegister(pAd, RF_R07, (UCHAR)RFValue); 5536 + 5537 + // latch channel for future usage. 5538 + pAd->LatchRfRegs.Channel = Channel; 5539 + #endif 5540 + #ifdef RT30xx 5541 + RT30xxWriteRFRegister(pAd, RF_R24, RFValue); 5542 + RT30xxWriteRFRegister(pAd, RF_R31, RFValue); 5543 + 5544 + // Enable RF tuning 5545 + RT30xxReadRFRegister(pAd, RF_R07, &RFValue); 5546 + RFValue = RFValue | 0x1; 5547 + RT30xxWriteRFRegister(pAd, RF_R07, RFValue); 5548 + 5549 + // latch channel for future usage. 5550 + pAd->LatchRfRegs.Channel = Channel; 5551 + 5552 + DBGPRINT(RT_DEBUG_TRACE, ("SwitchChannel#%d(RF=%d, Pwr0=%d, Pwr1=%d, %dT), N=0x%02X, K=0x%02X, R=0x%02X\n", 5553 + Channel, 5554 + pAd->RfIcType, 5555 + TxPwer, 5556 + TxPwer2, 5557 + pAd->Antenna.field.TxPath, 5558 + FreqItems3020[index].N, 5559 + FreqItems3020[index].K, 5560 + FreqItems3020[index].R)); 5561 + #endif 5562 + 5563 + break; 5564 + } 5565 + } 5566 + 5567 + #ifndef RT30xx 5568 + DBGPRINT(RT_DEBUG_TRACE, ("SwitchChannel#%d(RF=%d, Pwr0=%d, Pwr1=%d, %dT), N=0x%02X, K=0x%02X, R=0x%02X\n", 5569 + Channel, 5570 + pAd->RfIcType, 5571 + TxPwer, 5572 + TxPwer2, 5573 + pAd->Antenna.field.TxPath, 5574 + FreqItems3020[index].N, 5575 + FreqItems3020[index].K, 5576 + FreqItems3020[index].R)); 5577 + #endif 5578 + } 5579 + else 5580 + #endif // RT2870 // 5959 5581 { 5960 5582 RFRegTable = RF2850RegTable; 5961 5583 ··· 6349 5691 IN PRTMP_ADAPTER pAd, 6350 5692 IN UCHAR Channel) 6351 5693 { 5694 + #ifdef RT30xx 5695 + if (pAd->Mlme.OneSecPeriodicRound % 2 == 1) 5696 + { 5697 + // patch for AsicSetRxAnt failed 5698 + pAd->RxAnt.EvaluatePeriod = 0; 5699 + 5700 + // check every 2 second. If rcv-beacon less than 5 in the past 2 second, then AvgRSSI is no longer a 5701 + // valid indication of the distance between this AP and its clients. 5702 + if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED)) 5703 + { 5704 + SHORT realavgrssi1; 5705 + 5706 + // if no traffic then reset average rssi to trigger evaluation 5707 + if (pAd->StaCfg.NumOfAvgRssiSample < 5) 5708 + { 5709 + pAd->RxAnt.Pair1LastAvgRssi = (-99); 5710 + pAd->RxAnt.Pair2LastAvgRssi = (-99); 5711 + DBGPRINT(RT_DEBUG_TRACE, ("MlmePeriodicExec: no traffic/beacon, reset RSSI\n")); 5712 + } 5713 + 5714 + pAd->StaCfg.NumOfAvgRssiSample = 0; 5715 + realavgrssi1 = (pAd->RxAnt.Pair1AvgRssi[pAd->RxAnt.Pair1PrimaryRxAnt] >> 3); 5716 + 5717 + DBGPRINT(RT_DEBUG_TRACE,("Ant-realrssi0(%d), Lastrssi0(%d), EvaluateStableCnt=%d\n", realavgrssi1, pAd->RxAnt.Pair1LastAvgRssi, pAd->RxAnt.EvaluateStableCnt)); 5718 + 5719 + // if the difference between two rssi is larger or less than 5, then evaluate the other antenna 5720 + if ((pAd->RxAnt.EvaluateStableCnt < 2) || (realavgrssi1 > (pAd->RxAnt.Pair1LastAvgRssi + 5)) || (realavgrssi1 < (pAd->RxAnt.Pair1LastAvgRssi - 5))) 5721 + { 5722 + pAd->RxAnt.Pair1LastAvgRssi = realavgrssi1; 5723 + AsicEvaluateRxAnt(pAd); 5724 + } 5725 + } 5726 + else 5727 + { 5728 + // if not connected, always switch antenna to try to connect 5729 + UCHAR temp; 5730 + 5731 + temp = pAd->RxAnt.Pair1PrimaryRxAnt; 5732 + pAd->RxAnt.Pair1PrimaryRxAnt = pAd->RxAnt.Pair1SecondaryRxAnt; 5733 + pAd->RxAnt.Pair1SecondaryRxAnt = temp; 5734 + 5735 + DBGPRINT(RT_DEBUG_TRACE, ("MlmePeriodicExec: no connect, switch to another one to try connection\n")); 5736 + 5737 + AsicSetRxAnt(pAd, pAd->RxAnt.Pair1PrimaryRxAnt); 5738 + } 5739 + } 5740 + #endif /* RT30xx */ 6352 5741 } 6353 5742 6354 5743 /* ··· 6465 5760 ULONG TxPwr[5]; 6466 5761 CHAR Value; 6467 5762 5763 + #ifdef RT2860 6468 5764 if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE) 6469 5765 || (pAd->bPCIclkOff == TRUE) 6470 5766 || RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_IDLE_RADIO_OFF) 6471 5767 || RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS)) 6472 5768 return; 5769 + #endif 6473 5770 6474 5771 if (pAd->CommonCfg.BBPCurrentBW == BW_40) 6475 5772 { ··· 6727 6020 */ 6728 6021 VOID AsicForceWakeup( 6729 6022 IN PRTMP_ADAPTER pAd, 6023 + #ifdef RT2860 6730 6024 IN UCHAR Level) 6025 + #endif 6026 + #ifdef RT2870 6027 + IN BOOLEAN bFromTx) 6028 + #endif 6731 6029 { 6732 6030 DBGPRINT(RT_DEBUG_TRACE, ("--> AsicForceWakeup \n")); 6031 + #ifdef RT2860 6733 6032 RT28XX_STA_FORCE_WAKEUP(pAd, Level); 6033 + #endif 6034 + #ifdef RT2870 6035 + RT28XX_STA_FORCE_WAKEUP(pAd, bFromTx); 6036 + #endif 6734 6037 } 6735 6038 6736 6039 /* ··· 6951 6234 csr9.field.bTsfTicking = 0; 6952 6235 RTMP_IO_WRITE32(pAd, BCN_TIME_CFG, csr9.word); 6953 6236 6237 + #ifdef RT2860 6954 6238 // move BEACON TXD and frame content to on-chip memory 6955 6239 ptr = (PUCHAR)&pAd->BeaconTxWI; 6956 6240 for (i=0; i<TXWI_SIZE; i+=4) // 16-byte TXWI field ··· 6969 6251 RTMP_IO_WRITE32(pAd, HW_BEACON_BASE0 + TXWI_SIZE + i, longptr); 6970 6252 ptr +=4; 6971 6253 } 6254 + #endif 6255 + #ifdef RT2870 6256 + // move BEACON TXD and frame content to on-chip memory 6257 + ptr = (PUCHAR)&pAd->BeaconTxWI; 6258 + for (i=0; i<TXWI_SIZE; i+=2) // 16-byte TXWI field 6259 + { 6260 + RTUSBMultiWrite(pAd, HW_BEACON_BASE0 + i, ptr, 2); 6261 + ptr += 2; 6262 + } 6263 + 6264 + // start right after the 16-byte TXWI field 6265 + ptr = pAd->BeaconBuf; 6266 + for (i=0; i< pAd->BeaconTxWI.MPDUtotalByteCount; i+=2) 6267 + { 6268 + RTUSBMultiWrite(pAd, HW_BEACON_BASE0 + TXWI_SIZE + i, ptr, 2); 6269 + ptr +=2; 6270 + } 6271 + #endif // RT2870 // 6972 6272 6973 6273 // start sending BEACON 6974 6274 csr9.field.BeaconInterval = pAd->CommonCfg.BeaconPeriod << 4; // ASIC register in units of 1/16 TU ··· 7142 6406 Ac2Cfg.field.Aifsn -= 1; 7143 6407 7144 6408 // Tuning for TGn Wi-Fi 5.2.32 7145 - // STA TestBed changes in this item: conexant legacy sta ==> broadcom 11n sta 6409 + // STA TestBed changes in this item: connexant legacy sta ==> broadcom 11n sta 7146 6410 if (STA_TGN_WIFI_ON(pAd) && 7147 6411 pEdcaParm->Aifsn[QID_AC_VI] == 10) 7148 6412 { 7149 6413 Ac0Cfg.field.Aifsn = 3; 7150 6414 Ac2Cfg.field.AcTxop = 5; 7151 6415 } 6416 + 6417 + #ifdef RT30xx 6418 + if (pAd->RfIcType == RFIC_3020 || pAd->RfIcType == RFIC_2020) 6419 + { 6420 + // Tuning for WiFi WMM S3-T07: connexant legacy sta ==> broadcom 11n sta. 6421 + Ac2Cfg.field.Aifsn = 5; 6422 + } 6423 + #endif // RT30xx // 7152 6424 } 7153 6425 7154 6426 Ac3Cfg.field.AcTxop = pEdcaParm->Txop[QID_AC_VO]; ··· 7223 6479 AifsnCsr.field.Aifsn2 = Ac2Cfg.field.Aifsn - 4; 7224 6480 7225 6481 // Tuning for TGn Wi-Fi 5.2.32 7226 - // STA TestBed changes in this item: conexant legacy sta ==> broadcom 11n sta 6482 + // STA TestBed changes in this item: connexant legacy sta ==> broadcom 11n sta 7227 6483 if (STA_TGN_WIFI_ON(pAd) && 7228 6484 pEdcaParm->Aifsn[QID_AC_VI] == 10) 7229 6485 { 7230 6486 AifsnCsr.field.Aifsn0 = 3; 7231 6487 AifsnCsr.field.Aifsn2 = 7; 7232 6488 } 6489 + #ifdef RT2870 6490 + if (INFRA_ON(pAd)) 6491 + CLIENT_STATUS_SET_FLAG(&pAd->MacTab.Content[BSSID_WCID], fCLIENT_STATUS_WMM_CAPABLE); 6492 + #endif 7233 6493 } 7234 6494 7235 6495 AifsnCsr.field.Aifsn3 = Ac3Cfg.field.Aifsn - 1; //pEdcaParm->Aifsn[QID_AC_VO]; //for TGn wifi test 6496 + #ifdef RT30xx 6497 + if (pAd->RfIcType == RFIC_3020 || pAd->RfIcType == RFIC_2020) 6498 + AifsnCsr.field.Aifsn2 = 0x2; //pEdcaParm->Aifsn[QID_AC_VI]; //for WiFi WMM S4-T04. 6499 + #endif // RT30xx // 7236 6500 7237 6501 RTMP_IO_WRITE32(pAd, WMM_AIFSN_CFG, AifsnCsr.word); 7238 6502 ··· 7303 6551 SlotTime = (bUseShortSlotTime)? 9 : 20; 7304 6552 7305 6553 { 6554 + #ifndef RT30xx 7306 6555 // force using short SLOT time for FAE to demo performance when TxBurst is ON 7307 6556 if (((pAd->StaActive.SupportedPhyInfo.bHtEnable == FALSE) && (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_WMM_INUSED))) 7308 6557 || ((pAd->StaActive.SupportedPhyInfo.bHtEnable == TRUE) && (pAd->CommonCfg.BACapability.field.Policy == BA_NOTUSE)) ··· 7313 6560 // And we will not set to short slot when bEnableTxBurst is TRUE. 7314 6561 } 7315 6562 else if (pAd->CommonCfg.bEnableTxBurst) 6563 + #endif 6564 + #ifdef RT30xx 6565 + if (pAd->CommonCfg.bEnableTxBurst) 6566 + #endif 7316 6567 SlotTime = 9; 7317 6568 } 7318 6569 ··· 7357 6600 { 7358 6601 ULONG offset; //, csr0; 7359 6602 SHAREDKEY_MODE_STRUC csr1; 6603 + #ifdef RT2860 7360 6604 INT i; 6605 + #endif 7361 6606 7362 6607 DBGPRINT(RT_DEBUG_TRACE, ("AsicAddSharedKeyEntry BssIndex=%d, KeyIdx=%d\n", BssIndex,KeyIdx)); 7363 6608 //============================================================================================ ··· 7381 6622 // 7382 6623 // fill key material - key + TX MIC + RX MIC 7383 6624 // 6625 + 7384 6626 offset = SHARED_KEY_TABLE_BASE + (4*BssIndex + KeyIdx)*HW_KEY_ENTRY_SIZE; 6627 + #ifdef RT2860 7385 6628 for (i=0; i<MAX_LEN_OF_SHARE_KEY; i++) 7386 6629 { 7387 6630 RTMP_IO_WRITE8(pAd, offset + i, pKey[i]); 7388 6631 } 7389 - 6632 + #endif 6633 + #ifdef RT2870 6634 + RTUSBMultiWrite(pAd, offset, pKey, MAX_LEN_OF_SHARE_KEY); 6635 + #endif 7390 6636 offset += MAX_LEN_OF_SHARE_KEY; 7391 6637 if (pTxMic) 7392 6638 { 6639 + #ifdef RT2860 7393 6640 for (i=0; i<8; i++) 7394 6641 { 7395 6642 RTMP_IO_WRITE8(pAd, offset + i, pTxMic[i]); 7396 6643 } 6644 + #endif 6645 + #ifdef RT2870 6646 + RTUSBMultiWrite(pAd, offset, pTxMic, 8); 6647 + #endif 7397 6648 } 7398 6649 7399 6650 offset += 8; 7400 6651 if (pRxMic) 7401 6652 { 6653 + #ifdef RT2860 7402 6654 for (i=0; i<8; i++) 7403 6655 { 7404 6656 RTMP_IO_WRITE8(pAd, offset + i, pRxMic[i]); 7405 6657 } 6658 + #endif 6659 + #ifdef RT2870 6660 + RTUSBMultiWrite(pAd, offset, pRxMic, 8); 6661 + #endif 7406 6662 } 7407 6663 7408 6664 ··· 7593 6819 PUCHAR pTxtsc = pCipherKey->TxTsc; 7594 6820 UCHAR CipherAlg = pCipherKey->CipherAlg; 7595 6821 SHAREDKEY_MODE_STRUC csr1; 6822 + #ifdef RT2860 7596 6823 UCHAR i; 6824 + #endif 7597 6825 7598 6826 DBGPRINT(RT_DEBUG_TRACE, ("==> AsicAddKeyEntry\n")); 7599 6827 // ··· 7610 6834 // 2.) Set Key to Asic 7611 6835 // 7612 6836 //for (i = 0; i < KeyLen; i++) 6837 + #ifdef RT2860 7613 6838 for (i = 0; i < MAX_LEN_OF_PEER_KEY; i++) 7614 6839 { 7615 6840 RTMP_IO_WRITE8(pAd, offset + i, pKey[i]); 7616 6841 } 6842 + #endif 6843 + #ifdef RT2870 6844 + RTUSBMultiWrite(pAd, offset, pKey, MAX_LEN_OF_PEER_KEY); 6845 + #endif 7617 6846 offset += MAX_LEN_OF_PEER_KEY; 7618 6847 7619 6848 // ··· 7626 6845 // 7627 6846 if (pTxMic) 7628 6847 { 6848 + #ifdef RT2860 7629 6849 for (i = 0; i < 8; i++) 7630 6850 { 7631 6851 RTMP_IO_WRITE8(pAd, offset + i, pTxMic[i]); 7632 6852 } 6853 + #endif 6854 + #ifdef RT2870 6855 + RTUSBMultiWrite(pAd, offset, pTxMic, 8); 6856 + #endif 7633 6857 } 7634 6858 offset += LEN_TKIP_TXMICK; 7635 6859 7636 6860 if (pRxMic) 7637 6861 { 6862 + #ifdef RT2860 7638 6863 for (i = 0; i < 8; i++) 7639 6864 { 7640 6865 RTMP_IO_WRITE8(pAd, offset + i, pRxMic[i]); 7641 6866 } 6867 + #endif 6868 + #ifdef RT2870 6869 + RTUSBMultiWrite(pAd, offset, pRxMic, 8); 6870 + #endif 7642 6871 } 7643 6872 7644 6873 ··· 7658 6867 // 7659 6868 if (bTxKey) 7660 6869 { 6870 + #ifdef RT2860 7661 6871 offset = MAC_IVEIV_TABLE_BASE + (WCID * HW_IVEIV_ENTRY_SIZE); 7662 6872 // 7663 6873 // Write IV ··· 7682 6890 RTMP_IO_WRITE8(pAd, offset + i, pTxtsc[i + 2]); 7683 6891 } 7684 6892 6893 + #endif 6894 + #ifdef RT2870 6895 + UINT32 tmpVal; 6896 + 6897 + // 6898 + // Write IV 6899 + // 6900 + IV4 = (KeyIdx << 6); 6901 + if ((CipherAlg == CIPHER_TKIP) || (CipherAlg == CIPHER_TKIP_NO_MIC) ||(CipherAlg == CIPHER_AES)) 6902 + IV4 |= 0x20; // turn on extension bit means EIV existence 6903 + 6904 + tmpVal = pTxtsc[1] + (((pTxtsc[1] | 0x20) & 0x7f) << 8) + (pTxtsc[0] << 16) + (IV4 << 24); 6905 + RTMP_IO_WRITE32(pAd, offset, tmpVal); 6906 + 6907 + // 6908 + // Write EIV 6909 + // 6910 + offset += 4; 6911 + RTMP_IO_WRITE32(pAd, offset, *(PUINT32)&pCipherKey->TxTsc[2]); 6912 + #endif // RT2870 // 7685 6913 AsicUpdateWCIDAttribute(pAd, WCID, BssIndex, CipherAlg, bUsePairewiseKeyTable); 7686 6914 } 7687 6915 ··· 7766 6954 7767 6955 // EKEY 7768 6956 offset = PAIRWISE_KEY_TABLE_BASE + (WCID * HW_KEY_ENTRY_SIZE); 6957 + #ifdef RT2860 7769 6958 for (i=0; i<MAX_LEN_OF_PEER_KEY; i++) 7770 6959 { 7771 6960 RTMP_IO_WRITE8(pAd, offset + i, pKey[i]); 7772 6961 } 6962 + #endif 6963 + #ifdef RT2870 6964 + RTUSBMultiWrite(pAd, offset, &pCipherKey->Key[0], MAX_LEN_OF_PEER_KEY); 6965 + #endif // RT2870 // 7773 6966 for (i=0; i<MAX_LEN_OF_PEER_KEY; i+=4) 7774 6967 { 7775 6968 UINT32 Value; ··· 7786 6969 // MIC KEY 7787 6970 if (pTxMic) 7788 6971 { 6972 + #ifdef RT2860 7789 6973 for (i=0; i<8; i++) 7790 6974 { 7791 6975 RTMP_IO_WRITE8(pAd, offset+i, pTxMic[i]); 7792 6976 } 6977 + #endif 6978 + #ifdef RT2870 6979 + RTUSBMultiWrite(pAd, offset, &pCipherKey->TxMic[0], 8); 6980 + #endif // RT2870 // 7793 6981 } 7794 6982 offset += 8; 7795 6983 if (pRxMic) 7796 6984 { 6985 + #ifdef RT2860 7797 6986 for (i=0; i<8; i++) 7798 6987 { 7799 6988 RTMP_IO_WRITE8(pAd, offset+i, pRxMic[i]); 7800 6989 } 6990 + #endif 6991 + #ifdef RT2870 6992 + RTUSBMultiWrite(pAd, offset, &pCipherKey->RxMic[0], 8); 6993 + #endif // RT2870 // 7801 6994 } 7802 6995 7803 6996 DBGPRINT(RT_DEBUG_TRACE,("AsicAddPairwiseKeyEntry: WCID #%d Alg=%s\n",WCID, CipherName[CipherAlg])); ··· 7869 7042 if (i >= 100) 7870 7043 { 7871 7044 { 7045 + #ifdef RT2860 7872 7046 UINT32 Data; 7873 7047 7874 7048 // Reset DMA ··· 7891 7063 RTMP_IO_READ32(pAd, PBF_SYS_CTRL, &Data); 7892 7064 Data &= 0xfffffffd; 7893 7065 RTMP_IO_WRITE32(pAd, PBF_SYS_CTRL, Data); 7066 + #endif /* RT2860 */ 7894 7067 DBGPRINT_ERR(("H2M_MAILBOX still hold by MCU. command fail\n")); 7895 7068 } 7896 7069 //return FALSE; 7070 + #ifdef RT2870 7071 + return FALSE; 7072 + #endif 7897 7073 } 7898 7074 7899 7075 H2MMailbox.field.Owner = 1; // pass ownership to MCU ··· 7917 7085 return TRUE; 7918 7086 } 7919 7087 7088 + #ifdef RT2860 7920 7089 BOOLEAN AsicCheckCommanOk( 7921 7090 IN PRTMP_ADAPTER pAd, 7922 7091 IN UCHAR Command) ··· 7982 7149 7983 7150 return FALSE; 7984 7151 } 7152 + #endif /* RT8260 */ 7985 7153 7986 7154 /* 7987 7155 ======================================================================== ··· 8331 7497 return larger; 8332 7498 } 8333 7499 7500 + #ifdef RT30xx 7501 + // Antenna divesity use GPIO3 and EESK pin for control 7502 + // Antenna and EEPROM access are both using EESK pin, 7503 + // Therefor we should avoid accessing EESK at the same time 7504 + // Then restore antenna after EEPROM access 7505 + VOID AsicSetRxAnt( 7506 + IN PRTMP_ADAPTER pAd, 7507 + IN UCHAR Ant) 7508 + { 7509 + #ifdef RT30xx 7510 + UINT32 Value; 7511 + UINT32 x; 7512 + 7513 + if ((pAd->EepromAccess) || 7514 + (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS)) || 7515 + (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS)) || 7516 + (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF)) || 7517 + (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST))) 7518 + { 7519 + return; 7520 + } 7521 + 7522 + // the antenna selection is through firmware and MAC register(GPIO3) 7523 + if (Ant == 0) 7524 + { 7525 + // Main antenna 7526 + RTMP_IO_READ32(pAd, E2PROM_CSR, &x); 7527 + x |= (EESK); 7528 + RTMP_IO_WRITE32(pAd, E2PROM_CSR, x); 7529 + 7530 + RTMP_IO_READ32(pAd, GPIO_CTRL_CFG, &Value); 7531 + Value &= ~(0x0808); 7532 + RTMP_IO_WRITE32(pAd, GPIO_CTRL_CFG, Value); 7533 + DBGPRINT_RAW(RT_DEBUG_TRACE, ("AsicSetRxAnt, switch to main antenna\n")); 7534 + } 7535 + else 7536 + { 7537 + // Aux antenna 7538 + RTMP_IO_READ32(pAd, E2PROM_CSR, &x); 7539 + x &= ~(EESK); 7540 + RTMP_IO_WRITE32(pAd, E2PROM_CSR, x); 7541 + 7542 + RTMP_IO_READ32(pAd, GPIO_CTRL_CFG, &Value); 7543 + Value &= ~(0x0808); 7544 + Value |= 0x08; 7545 + RTMP_IO_WRITE32(pAd, GPIO_CTRL_CFG, Value); 7546 + DBGPRINT_RAW(RT_DEBUG_TRACE, ("AsicSetRxAnt, switch to aux antenna\n")); 7547 + } 7548 + #endif // RT30xx // 7549 + } 7550 + #endif /* RT30xx */ 7551 + 8334 7552 /* 8335 7553 ======================================================================== 8336 7554 Routine Description: ··· 8401 7515 { 8402 7516 UCHAR BBPR3 = 0; 8403 7517 7518 + #ifndef RT30xx 8404 7519 { 8405 7520 if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS | 8406 7521 fRTMP_ADAPTER_HALT_IN_PROGRESS | ··· 8430 7543 } 8431 7544 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, BBPR3); 8432 7545 7546 + #ifdef RT2860 8433 7547 pAd->StaCfg.BBPR3 = BBPR3; 7548 + #endif 7549 + #ifdef RT2870 7550 + if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED) 7551 + ) 7552 + { 7553 + ULONG TxTotalCnt = pAd->RalinkCounters.OneSecTxNoRetryOkCount + 7554 + pAd->RalinkCounters.OneSecTxRetryOkCount + 7555 + pAd->RalinkCounters.OneSecTxFailCount; 7556 + 7557 + if (TxTotalCnt > 50) 7558 + { 7559 + RTMPSetTimer(&pAd->Mlme.RxAntEvalTimer, 20); 7560 + pAd->Mlme.bLowThroughput = FALSE; 7561 + } 7562 + else 7563 + { 7564 + RTMPSetTimer(&pAd->Mlme.RxAntEvalTimer, 300); 7565 + pAd->Mlme.bLowThroughput = TRUE; 7566 + } 7567 + } 7568 + #endif 7569 + #endif /* RT30xx */ 7570 + #ifdef RT30xx 7571 + if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS | 7572 + fRTMP_ADAPTER_HALT_IN_PROGRESS | 7573 + fRTMP_ADAPTER_RADIO_OFF | 7574 + fRTMP_ADAPTER_NIC_NOT_EXIST | 7575 + fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS) || 7576 + OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE) 7577 + #ifdef RT30xx 7578 + || (pAd->EepromAccess) 7579 + #endif // RT30xx // 7580 + ) 7581 + return; 7582 + 7583 + 7584 + { 7585 + //if (pAd->StaCfg.Psm == PWR_SAVE) 7586 + // return; 7587 + } 7588 + 7589 + // two antenna selection mechanism- one is antenna diversity, the other is failed antenna remove 7590 + // one is antenna diversity:there is only one antenna can rx and tx 7591 + // the other is failed antenna remove:two physical antenna can rx and tx 7592 + if (pAd->NicConfig2.field.AntDiversity) 7593 + { 7594 + DBGPRINT(RT_DEBUG_TRACE,("AntDiv - before evaluate Pair1-Ant (%d,%d)\n", 7595 + pAd->RxAnt.Pair1PrimaryRxAnt, pAd->RxAnt.Pair1SecondaryRxAnt)); 7596 + 7597 + AsicSetRxAnt(pAd, pAd->RxAnt.Pair1SecondaryRxAnt); 7598 + 7599 + pAd->RxAnt.EvaluatePeriod = 1; // 1:Means switch to SecondaryRxAnt, 0:Means switch to Pair1PrimaryRxAnt 7600 + pAd->RxAnt.FirstPktArrivedWhenEvaluate = FALSE; 7601 + pAd->RxAnt.RcvPktNumWhenEvaluate = 0; 7602 + 7603 + // a one-shot timer to end the evalution 7604 + // dynamic adjust antenna evaluation period according to the traffic 7605 + if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED)) 7606 + RTMPSetTimer(&pAd->Mlme.RxAntEvalTimer, 100); 7607 + else 7608 + RTMPSetTimer(&pAd->Mlme.RxAntEvalTimer, 300); 7609 + } 7610 + else 7611 + { 7612 + if (pAd->StaCfg.Psm == PWR_SAVE) 7613 + return; 7614 + 7615 + RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &BBPR3); 7616 + BBPR3 &= (~0x18); 7617 + if(pAd->Antenna.field.RxPath == 3) 7618 + { 7619 + BBPR3 |= (0x10); 7620 + } 7621 + else if(pAd->Antenna.field.RxPath == 2) 7622 + { 7623 + BBPR3 |= (0x8); 7624 + } 7625 + else if(pAd->Antenna.field.RxPath == 1) 7626 + { 7627 + BBPR3 |= (0x0); 7628 + } 7629 + RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, BBPR3); 7630 + } 7631 + #endif /* RT30xx */ 8434 7632 8435 7633 if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED) 8436 7634 ) ··· 8524 7552 pAd->RalinkCounters.OneSecTxRetryOkCount + 8525 7553 pAd->RalinkCounters.OneSecTxFailCount; 8526 7554 7555 + // dynamic adjust antenna evaluation period according to the traffic 8527 7556 if (TxTotalCnt > 50) 8528 7557 { 8529 7558 RTMPSetTimer(&pAd->Mlme.RxAntEvalTimer, 20); ··· 8561 7588 UCHAR BBPR3 = 0; 8562 7589 CHAR larger = -127, rssi0, rssi1, rssi2; 8563 7590 7591 + #ifndef RT30xx 8564 7592 { 8565 7593 if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS) || 8566 7594 RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS) || ··· 8619 7645 BBPR3 |= (0x0); 8620 7646 } 8621 7647 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, BBPR3); 7648 + #ifdef RT2860 8622 7649 pAd->StaCfg.BBPR3 = BBPR3; 7650 + #endif 8623 7651 } 7652 + #endif /* RT30xx */ 7653 + #ifdef RT30xx 7654 + if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS | 7655 + fRTMP_ADAPTER_HALT_IN_PROGRESS | 7656 + fRTMP_ADAPTER_RADIO_OFF | 7657 + fRTMP_ADAPTER_NIC_NOT_EXIST) || 7658 + OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE) 7659 + #ifdef RT30xx 7660 + || (pAd->EepromAccess) 7661 + #endif // RT30xx // 7662 + ) 7663 + return; 7664 + 7665 + { 7666 + //if (pAd->StaCfg.Psm == PWR_SAVE) 7667 + // return; 7668 + 7669 + if (pAd->NicConfig2.field.AntDiversity) 7670 + { 7671 + if ((pAd->RxAnt.RcvPktNumWhenEvaluate != 0) && (pAd->RxAnt.Pair1AvgRssi[pAd->RxAnt.Pair1SecondaryRxAnt] >= pAd->RxAnt.Pair1AvgRssi[pAd->RxAnt.Pair1PrimaryRxAnt])) 7672 + { 7673 + UCHAR temp; 7674 + 7675 + // 7676 + // select PrimaryRxAntPair 7677 + // Role change, Used Pair1SecondaryRxAnt as PrimaryRxAntPair. 7678 + // Since Pair1SecondaryRxAnt Quality good than Pair1PrimaryRxAnt 7679 + // 7680 + temp = pAd->RxAnt.Pair1PrimaryRxAnt; 7681 + pAd->RxAnt.Pair1PrimaryRxAnt = pAd->RxAnt.Pair1SecondaryRxAnt; 7682 + pAd->RxAnt.Pair1SecondaryRxAnt = temp; 7683 + 7684 + pAd->RxAnt.Pair1LastAvgRssi = (pAd->RxAnt.Pair1AvgRssi[pAd->RxAnt.Pair1SecondaryRxAnt] >> 3); 7685 + pAd->RxAnt.EvaluateStableCnt = 0; 7686 + } 7687 + else 7688 + { 7689 + // if the evaluated antenna is not better than original, switch back to original antenna 7690 + AsicSetRxAnt(pAd, pAd->RxAnt.Pair1PrimaryRxAnt); 7691 + pAd->RxAnt.EvaluateStableCnt ++; 7692 + } 7693 + 7694 + pAd->RxAnt.EvaluatePeriod = 0; // 1:Means switch to SecondaryRxAnt, 0:Means switch to Pair1PrimaryRxAnt 7695 + 7696 + DBGPRINT(RT_DEBUG_TRACE,("AsicRxAntEvalAction::After Eval(fix in #%d), <%d, %d>, RcvPktNumWhenEvaluate=%ld\n", 7697 + pAd->RxAnt.Pair1PrimaryRxAnt, (pAd->RxAnt.Pair1AvgRssi[0] >> 3), (pAd->RxAnt.Pair1AvgRssi[1] >> 3), pAd->RxAnt.RcvPktNumWhenEvaluate)); 7698 + } 7699 + else 7700 + { 7701 + if (pAd->StaCfg.Psm == PWR_SAVE) 7702 + return; 7703 + 7704 + // if the traffic is low, use average rssi as the criteria 7705 + if (pAd->Mlme.bLowThroughput == TRUE) 7706 + { 7707 + rssi0 = pAd->StaCfg.RssiSample.LastRssi0; 7708 + rssi1 = pAd->StaCfg.RssiSample.LastRssi1; 7709 + rssi2 = pAd->StaCfg.RssiSample.LastRssi2; 7710 + } 7711 + else 7712 + { 7713 + rssi0 = pAd->StaCfg.RssiSample.AvgRssi0; 7714 + rssi1 = pAd->StaCfg.RssiSample.AvgRssi1; 7715 + rssi2 = pAd->StaCfg.RssiSample.AvgRssi2; 7716 + } 7717 + 7718 + if(pAd->Antenna.field.RxPath == 3) 7719 + { 7720 + larger = max(rssi0, rssi1); 7721 + 7722 + if (larger > (rssi2 + 20)) 7723 + pAd->Mlme.RealRxPath = 2; 7724 + else 7725 + pAd->Mlme.RealRxPath = 3; 7726 + } 7727 + else if(pAd->Antenna.field.RxPath == 2) 7728 + { 7729 + if (rssi0 > (rssi1 + 20)) 7730 + pAd->Mlme.RealRxPath = 1; 7731 + else 7732 + pAd->Mlme.RealRxPath = 2; 7733 + } 7734 + 7735 + RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &BBPR3); 7736 + BBPR3 &= (~0x18); 7737 + if(pAd->Mlme.RealRxPath == 3) 7738 + { 7739 + BBPR3 |= (0x10); 7740 + } 7741 + else if(pAd->Mlme.RealRxPath == 2) 7742 + { 7743 + BBPR3 |= (0x8); 7744 + } 7745 + else if(pAd->Mlme.RealRxPath == 1) 7746 + { 7747 + BBPR3 |= (0x0); 7748 + } 7749 + RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, BBPR3); 7750 + } 7751 + } 7752 + #endif /* RT30xx */ 8624 7753 } 8625 7754 8626 7755 ··· 8922 7845 && (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED) 8923 7846 ) 8924 7847 && !(OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE)) 7848 + #ifdef RT2860 8925 7849 && (pAd->bPCIclkOff == FALSE)) 7850 + #endif 7851 + #ifdef RT2870 7852 + ) 7853 + #endif 8926 7854 { 8927 7855 RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R66, &OrigR66Value); 8928 7856 R66 = OrigR66Value; ··· 8939 7857 8940 7858 if (pAd->LatchRfRegs.Channel <= 14) 8941 7859 { //BG band 7860 + #ifdef RT2870 7861 + // RT3070 is a no LNA solution, it should have different control regarding to AGC gain control 7862 + // Otherwise, it will have some throughput side effect when low RSSI 7863 + #ifndef RT30xx 7864 + if (IS_RT3070(pAd)) 7865 + #endif 7866 + #ifdef RT30xx 7867 + if (IS_RT30xx(pAd)) 7868 + #endif 7869 + { 7870 + if (Rssi > RSSI_FOR_MID_LOW_SENSIBILITY) 7871 + { 7872 + R66 = 0x1C + 2*GET_LNA_GAIN(pAd) + 0x20; 7873 + if (OrigR66Value != R66) 7874 + { 7875 + #ifndef RT30xx 7876 + RTUSBWriteBBPRegister(pAd, BBP_R66, R66); 7877 + #endif 7878 + #ifdef RT30xx 7879 + RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R66, R66); 7880 + #endif 7881 + } 7882 + } 7883 + else 7884 + { 7885 + R66 = 0x1C + 2*GET_LNA_GAIN(pAd); 7886 + if (OrigR66Value != R66) 7887 + { 7888 + #ifndef RT30xx 7889 + RTUSBWriteBBPRegister(pAd, BBP_R66, R66); 7890 + #endif 7891 + #ifdef RT30xx 7892 + RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R66, R66); 7893 + #endif 7894 + } 7895 + } 7896 + } 7897 + else 7898 + #endif // RT2870 // 8942 7899 { 8943 7900 if (Rssi > RSSI_FOR_MID_LOW_SENSIBILITY) 8944 7901 { ··· 9043 7922 } 9044 7923 } 9045 7924 7925 + #ifdef RT2860 9046 7926 VOID AsicResetFromDMABusy( 9047 7927 IN PRTMP_ADAPTER pAd) 9048 7928 { ··· 9143 8021 DBGPRINT(RT_DEBUG_TRACE, ("<--- Asic HardReset PBF !!!! \n")); 9144 8022 } 9145 8023 } 8024 + #endif /* RT2860 */ 9146 8025 9147 8026 VOID RTMPSetAGCInitValue( 9148 8027 IN PRTMP_ADAPTER pAd, ··· 9182 8059 UCHAR index; 9183 8060 RTMP_RF_REGS *RFRegTable; 9184 8061 8062 + #ifdef RT30xx 8063 + // The RF programming sequence is difference between 3xxx and 2xxx 8064 + if (IS_RT3090(pAd)) 8065 + { 8066 + RT30xxLoadRFSleepModeSetup(pAd); // add by johnli, RF power sequence setup, load RF sleep-mode setup 8067 + } 8068 + else 8069 + { 8070 + #endif // RT30xx // 9185 8071 RFRegTable = RF2850RegTable; 9186 8072 9187 8073 switch (pAd->RfIcType) ··· 9232 8100 default: 9233 8101 break; 9234 8102 } 8103 + #ifdef RT30xx 8104 + } 8105 + #endif // RT30xx // 8106 + 9235 8107 } 9236 8108 9237 8109 ··· 9249 8113 UCHAR index; 9250 8114 RTMP_RF_REGS *RFRegTable; 9251 8115 8116 + #ifdef RT30xx 8117 + // The RF programming sequence is difference between 3xxx and 2xxx 8118 + if (IS_RT3090(pAd)) 8119 + { 8120 + } 8121 + else 8122 + { 8123 + #endif // RT30xx // 9252 8124 RFRegTable = RF2850RegTable; 9253 8125 9254 8126 switch (pAd->RfIcType) ··· 9303 8159 break; 9304 8160 } 9305 8161 8162 + #ifndef RT30xx 9306 8163 DBGPRINT(RT_DEBUG_TRACE, ("AsicTurnOnRFClk#%d(RF=%d, ) , R2=0x%08x\n", 9307 8164 Channel, 9308 8165 pAd->RfIcType, 9309 8166 R2)); 8167 + #endif 8168 + #ifdef RT30xx 8169 + } 8170 + #endif // RT30xx // 9310 8171 } 9311 8172
+860 -1
drivers/staging/rt2860/common/rtmp_init.c
··· 38 38 Jan Lee 2006-09-15 RT2860. Change for 802.11n , EEPROM, Led, BA, HT. 39 39 */ 40 40 #include "../rt_config.h" 41 - #include "firmware.h" 41 + #ifndef RT30xx 42 + #ifdef RT2860 43 + #include "firmware.h" 42 44 #include <linux/bitrev.h> 45 + #endif 46 + #ifdef RT2870 47 + #include "../../rt2870/common/firmware.h" 48 + #endif 49 + #endif 50 + #ifdef RT30xx 51 + #include "../../rt3070/firmware.h" 52 + #endif 43 53 44 54 UCHAR BIT8[] = {0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80}; 45 55 ULONG BIT32[] = {0x00000001, 0x00000002, 0x00000004, 0x00000008, ··· 100 90 #define ByteCRC16(v, crc) \ 101 91 (unsigned short)((crc << 8) ^ ccitt_16Table[((crc >> 8) ^ (v)) & 255]) 102 92 93 + #ifdef RT2870 94 + unsigned char BitReverse(unsigned char x) 95 + { 96 + int i; 97 + unsigned char Temp=0; 98 + for(i=0; ; i++) 99 + { 100 + if(x & 0x80) Temp |= 0x80; 101 + if(i==7) break; 102 + x <<= 1; 103 + Temp >>= 1; 104 + } 105 + return Temp; 106 + } 107 + #endif 108 + 103 109 // 104 110 // BBP register initialization set 105 111 // ··· 140 114 // 141 115 // RF register initialization set 142 116 // 117 + #ifdef RT2870 118 + REG_PAIR RT30xx_RFRegTable[] = { 119 + {RF_R04, 0x40}, 120 + {RF_R05, 0x03}, 121 + {RF_R06, 0x02}, 122 + {RF_R07, 0x70}, 123 + {RF_R09, 0x0F}, 124 + #ifndef RT30xx 125 + {RF_R10, 0x71}, 126 + #endif 127 + #ifdef RT30xx 128 + {RF_R10, 0x41}, 129 + #endif 130 + {RF_R11, 0x21}, 131 + {RF_R12, 0x7B}, 132 + {RF_R14, 0x90}, 133 + {RF_R15, 0x58}, 134 + {RF_R16, 0xB3}, 135 + {RF_R17, 0x92}, 136 + {RF_R18, 0x2C}, 137 + {RF_R19, 0x02}, 138 + {RF_R20, 0xBA}, 139 + {RF_R21, 0xDB}, 140 + {RF_R24, 0x16}, 141 + {RF_R25, 0x01}, 142 + #ifndef RT30xx 143 + {RF_R27, 0x03}, 144 + #endif 145 + {RF_R29, 0x1F}, 146 + }; 147 + #define NUM_RF_REG_PARMS (sizeof(RT30xx_RFRegTable) / sizeof(REG_PAIR)) 148 + #endif // RT2870 // 143 149 144 150 // 145 151 // ASIC register initialization sets ··· 204 146 {AUTO_RSP_CFG, 0x00000013}, // Initial Auto_Responder, because QA will turn off Auto-Responder 205 147 {CCK_PROT_CFG, 0x05740003 /*0x01740003*/}, // Initial Auto_Responder, because QA will turn off Auto-Responder. And RTS threshold is enabled. 206 148 {OFDM_PROT_CFG, 0x05740003 /*0x01740003*/}, // Initial Auto_Responder, because QA will turn off Auto-Responder. And RTS threshold is enabled. 149 + //PS packets use Tx1Q (for HCCA) when dequeue from PS unicast queue (WiFi WPA2 MA9_DT1 for Marvell B STA) 150 + #ifdef RT2870 151 + {PBF_CFG, 0xf40006}, // Only enable Queue 2 152 + {MM40_PROT_CFG, 0x3F44084}, // Initial Auto_Responder, because QA will turn off Auto-Responder 153 + {WPDMA_GLO_CFG, 0x00000030}, 154 + #endif // RT2870 // 207 155 {GF20_PROT_CFG, 0x01744004}, // set 19:18 --> Short NAV for MIMO PS 208 156 {GF40_PROT_CFG, 0x03F44084}, 209 157 {MM20_PROT_CFG, 0x01744004}, 158 + #ifdef RT2860 210 159 {MM40_PROT_CFG, 0x03F54084}, 160 + #endif 211 161 {TXOP_CTRL_CFG, 0x0000583f, /*0x0000243f*/ /*0x000024bf*/}, //Extension channel backoff. 212 162 {TX_RTS_CFG, 0x00092b20}, 213 163 {EXP_ACK_TIME, 0x002400ca}, // default value ··· 238 172 #define NUM_MAC_REG_PARMS (sizeof(MACRegTable) / sizeof(RTMP_REG_PAIR)) 239 173 #define NUM_STA_MAC_REG_PARMS (sizeof(STAMACRegTable) / sizeof(RTMP_REG_PAIR)) 240 174 175 + #ifdef RT2870 176 + // 177 + // RT2870 Firmware Spec only used 1 oct for version expression 178 + // 179 + #define FIRMWARE_MINOR_VERSION 7 180 + 181 + #endif // RT2870 // 241 182 242 183 // New 8k byte firmware size for RT3071/RT3072 243 184 #define FIRMWAREIMAGE_MAX_LENGTH 0x2000 ··· 254 181 #define FIRMWAREIMAGEV1_LENGTH 0x1000 255 182 #define FIRMWAREIMAGEV2_LENGTH 0x1000 256 183 184 + #ifdef RT2860 257 185 #define FIRMWARE_MINOR_VERSION 2 186 + #endif 258 187 259 188 260 189 /* ··· 314 239 315 240 // Init spin locks 316 241 NdisAllocateSpinLock(&pAd->MgmtRingLock); 242 + #ifdef RT2860 317 243 NdisAllocateSpinLock(&pAd->RxRingLock); 244 + #endif 318 245 319 246 for (index =0 ; index < NUM_OF_TX_RING; index++) 320 247 { ··· 1082 1005 } 1083 1006 1084 1007 1008 + #ifdef RT2870 1009 + /* 1010 + ======================================================================== 1011 + 1012 + Routine Description: 1013 + For RF filter calibration purpose 1014 + 1015 + Arguments: 1016 + pAd Pointer to our adapter 1017 + 1018 + Return Value: 1019 + None 1020 + 1021 + IRQL = PASSIVE_LEVEL 1022 + 1023 + ======================================================================== 1024 + */ 1025 + #ifndef RT30xx 1026 + VOID RTUSBFilterCalibration( 1027 + IN PRTMP_ADAPTER pAd) 1028 + { 1029 + UCHAR R55x = 0, value, FilterTarget = 0x1E, BBPValue; 1030 + UINT loop = 0, count = 0, loopcnt = 0, ReTry = 0; 1031 + UCHAR RF_R24_Value = 0; 1032 + 1033 + // Give bbp filter initial value 1034 + pAd->Mlme.CaliBW20RfR24 = 0x16; 1035 + pAd->Mlme.CaliBW40RfR24 = 0x36; //Bit[5] must be 1 for BW 40 1036 + 1037 + do 1038 + { 1039 + if (loop == 1) //BandWidth = 40 MHz 1040 + { 1041 + // Write 0x27 to RF_R24 to program filter 1042 + RF_R24_Value = 0x27; 1043 + RT30xxWriteRFRegister(pAd, RF_R24, RF_R24_Value); 1044 + FilterTarget = 0x19; 1045 + 1046 + // when calibrate BW40, BBP mask must set to BW40. 1047 + RTUSBReadBBPRegister(pAd, BBP_R4, &BBPValue); 1048 + BBPValue&= (~0x18); 1049 + BBPValue|= (0x10); 1050 + RTUSBWriteBBPRegister(pAd, BBP_R4, BBPValue); 1051 + } 1052 + else //BandWidth = 20 MHz 1053 + { 1054 + // Write 0x07 to RF_R24 to program filter 1055 + RF_R24_Value = 0x07; 1056 + RT30xxWriteRFRegister(pAd, RF_R24, RF_R24_Value); 1057 + FilterTarget = 0x16; 1058 + } 1059 + 1060 + // Write 0x01 to RF_R22 to enable baseband loopback mode 1061 + RT30xxReadRFRegister(pAd, RF_R22, &value); 1062 + value |= 0x01; 1063 + RT30xxWriteRFRegister(pAd, RF_R22, value); 1064 + 1065 + // Write 0x00 to BBP_R24 to set power & frequency of passband test tone 1066 + RTUSBWriteBBPRegister(pAd, BBP_R24, 0); 1067 + 1068 + do 1069 + { 1070 + // Write 0x90 to BBP_R25 to transmit test tone 1071 + RTUSBWriteBBPRegister(pAd, BBP_R25, 0x90); 1072 + 1073 + RTMPusecDelay(1000); 1074 + // Read BBP_R55[6:0] for received power, set R55x = BBP_R55[6:0] 1075 + RTUSBReadBBPRegister(pAd, BBP_R55, &value); 1076 + R55x = value & 0xFF; 1077 + 1078 + } while ((ReTry++ < 100) && (R55x == 0)); 1079 + 1080 + // Write 0x06 to BBP_R24 to set power & frequency of stopband test tone 1081 + RTUSBWriteBBPRegister(pAd, BBP_R24, 0x06); 1082 + 1083 + while(TRUE) 1084 + { 1085 + // Write 0x90 to BBP_R25 to transmit test tone 1086 + RTUSBWriteBBPRegister(pAd, BBP_R25, 0x90); 1087 + 1088 + //We need to wait for calibration 1089 + RTMPusecDelay(1000); 1090 + RTUSBReadBBPRegister(pAd, BBP_R55, &value); 1091 + value &= 0xFF; 1092 + if ((R55x - value) < FilterTarget) 1093 + { 1094 + RF_R24_Value ++; 1095 + } 1096 + else if ((R55x - value) == FilterTarget) 1097 + { 1098 + RF_R24_Value ++; 1099 + count ++; 1100 + } 1101 + else 1102 + { 1103 + break; 1104 + } 1105 + 1106 + // prevent infinite loop cause driver hang. 1107 + if (loopcnt++ > 100) 1108 + { 1109 + DBGPRINT(RT_DEBUG_ERROR, ("RTUSBFilterCalibration - can't find a valid value, loopcnt=%d stop calibrating", loopcnt)); 1110 + break; 1111 + } 1112 + 1113 + // Write RF_R24 to program filter 1114 + RT30xxWriteRFRegister(pAd, RF_R24, RF_R24_Value); 1115 + } 1116 + 1117 + if (count > 0) 1118 + { 1119 + RF_R24_Value = RF_R24_Value - ((count) ? (1) : (0)); 1120 + } 1121 + 1122 + // Store for future usage 1123 + if (loopcnt < 100) 1124 + { 1125 + if (loop++ == 0) 1126 + { 1127 + //BandWidth = 20 MHz 1128 + pAd->Mlme.CaliBW20RfR24 = (UCHAR)RF_R24_Value; 1129 + } 1130 + else 1131 + { 1132 + //BandWidth = 40 MHz 1133 + pAd->Mlme.CaliBW40RfR24 = (UCHAR)RF_R24_Value; 1134 + break; 1135 + } 1136 + } 1137 + else 1138 + break; 1139 + 1140 + RT30xxWriteRFRegister(pAd, RF_R24, RF_R24_Value); 1141 + 1142 + // reset count 1143 + count = 0; 1144 + } while(TRUE); 1145 + 1146 + // 1147 + // Set back to initial state 1148 + // 1149 + RTUSBWriteBBPRegister(pAd, BBP_R24, 0); 1150 + 1151 + RT30xxReadRFRegister(pAd, RF_R22, &value); 1152 + value &= ~(0x01); 1153 + RT30xxWriteRFRegister(pAd, RF_R22, value); 1154 + 1155 + // set BBP back to BW20 1156 + RTUSBReadBBPRegister(pAd, BBP_R4, &BBPValue); 1157 + BBPValue&= (~0x18); 1158 + RTUSBWriteBBPRegister(pAd, BBP_R4, BBPValue); 1159 + 1160 + DBGPRINT(RT_DEBUG_TRACE, ("RTUSBFilterCalibration - CaliBW20RfR24=0x%x, CaliBW40RfR24=0x%x\n", pAd->Mlme.CaliBW20RfR24, pAd->Mlme.CaliBW40RfR24)); 1161 + } 1162 + #endif /* RT30xx */ 1163 + #ifdef RT30xx 1164 + VOID RTMPFilterCalibration( 1165 + IN PRTMP_ADAPTER pAd) 1166 + { 1167 + UCHAR R55x = 0, value, FilterTarget = 0x1E, BBPValue=0; 1168 + UINT loop = 0, count = 0, loopcnt = 0, ReTry = 0; 1169 + UCHAR RF_R24_Value = 0; 1170 + 1171 + // Give bbp filter initial value 1172 + pAd->Mlme.CaliBW20RfR24 = 0x1F; 1173 + pAd->Mlme.CaliBW40RfR24 = 0x2F; //Bit[5] must be 1 for BW 40 1174 + 1175 + do 1176 + { 1177 + if (loop == 1) //BandWidth = 40 MHz 1178 + { 1179 + // Write 0x27 to RF_R24 to program filter 1180 + RF_R24_Value = 0x27; 1181 + RT30xxWriteRFRegister(pAd, RF_R24, RF_R24_Value); 1182 + if (IS_RT3090(pAd)) 1183 + FilterTarget = 0x15; 1184 + else 1185 + FilterTarget = 0x19; 1186 + 1187 + // when calibrate BW40, BBP mask must set to BW40. 1188 + RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &BBPValue); 1189 + BBPValue&= (~0x18); 1190 + BBPValue|= (0x10); 1191 + RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, BBPValue); 1192 + 1193 + // set to BW40 1194 + RT30xxReadRFRegister(pAd, RF_R31, &value); 1195 + value |= 0x20; 1196 + RT30xxWriteRFRegister(pAd, RF_R31, value); 1197 + } 1198 + else //BandWidth = 20 MHz 1199 + { 1200 + // Write 0x07 to RF_R24 to program filter 1201 + RF_R24_Value = 0x07; 1202 + RT30xxWriteRFRegister(pAd, RF_R24, RF_R24_Value); 1203 + if (IS_RT3090(pAd)) 1204 + FilterTarget = 0x13; 1205 + else 1206 + FilterTarget = 0x16; 1207 + 1208 + // set to BW20 1209 + RT30xxReadRFRegister(pAd, RF_R31, &value); 1210 + value &= (~0x20); 1211 + RT30xxWriteRFRegister(pAd, RF_R31, value); 1212 + } 1213 + 1214 + // Write 0x01 to RF_R22 to enable baseband loopback mode 1215 + RT30xxReadRFRegister(pAd, RF_R22, &value); 1216 + value |= 0x01; 1217 + RT30xxWriteRFRegister(pAd, RF_R22, value); 1218 + 1219 + // Write 0x00 to BBP_R24 to set power & frequency of passband test tone 1220 + RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R24, 0); 1221 + 1222 + do 1223 + { 1224 + // Write 0x90 to BBP_R25 to transmit test tone 1225 + RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R25, 0x90); 1226 + 1227 + RTMPusecDelay(1000); 1228 + // Read BBP_R55[6:0] for received power, set R55x = BBP_R55[6:0] 1229 + RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R55, &value); 1230 + R55x = value & 0xFF; 1231 + 1232 + } while ((ReTry++ < 100) && (R55x == 0)); 1233 + 1234 + // Write 0x06 to BBP_R24 to set power & frequency of stopband test tone 1235 + RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R24, 0x06); 1236 + 1237 + while(TRUE) 1238 + { 1239 + // Write 0x90 to BBP_R25 to transmit test tone 1240 + RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R25, 0x90); 1241 + 1242 + //We need to wait for calibration 1243 + RTMPusecDelay(1000); 1244 + RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R55, &value); 1245 + value &= 0xFF; 1246 + if ((R55x - value) < FilterTarget) 1247 + { 1248 + RF_R24_Value ++; 1249 + } 1250 + else if ((R55x - value) == FilterTarget) 1251 + { 1252 + RF_R24_Value ++; 1253 + count ++; 1254 + } 1255 + else 1256 + { 1257 + break; 1258 + } 1259 + 1260 + // prevent infinite loop cause driver hang. 1261 + if (loopcnt++ > 100) 1262 + { 1263 + DBGPRINT(RT_DEBUG_ERROR, ("RTMPFilterCalibration - can't find a valid value, loopcnt=%d stop calibrating", loopcnt)); 1264 + break; 1265 + } 1266 + 1267 + // Write RF_R24 to program filter 1268 + RT30xxWriteRFRegister(pAd, RF_R24, RF_R24_Value); 1269 + } 1270 + 1271 + if (count > 0) 1272 + { 1273 + RF_R24_Value = RF_R24_Value - ((count) ? (1) : (0)); 1274 + } 1275 + 1276 + // Store for future usage 1277 + if (loopcnt < 100) 1278 + { 1279 + if (loop++ == 0) 1280 + { 1281 + //BandWidth = 20 MHz 1282 + pAd->Mlme.CaliBW20RfR24 = (UCHAR)RF_R24_Value; 1283 + } 1284 + else 1285 + { 1286 + //BandWidth = 40 MHz 1287 + pAd->Mlme.CaliBW40RfR24 = (UCHAR)RF_R24_Value; 1288 + break; 1289 + } 1290 + } 1291 + else 1292 + break; 1293 + 1294 + RT30xxWriteRFRegister(pAd, RF_R24, RF_R24_Value); 1295 + 1296 + // reset count 1297 + count = 0; 1298 + } while(TRUE); 1299 + 1300 + // 1301 + // Set back to initial state 1302 + // 1303 + RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R24, 0); 1304 + 1305 + RT30xxReadRFRegister(pAd, RF_R22, &value); 1306 + value &= ~(0x01); 1307 + RT30xxWriteRFRegister(pAd, RF_R22, value); 1308 + 1309 + // set BBP back to BW20 1310 + RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &BBPValue); 1311 + BBPValue&= (~0x18); 1312 + RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, BBPValue); 1313 + 1314 + DBGPRINT(RT_DEBUG_TRACE, ("RTMPFilterCalibration - CaliBW20RfR24=0x%x, CaliBW40RfR24=0x%x\n", pAd->Mlme.CaliBW20RfR24, pAd->Mlme.CaliBW40RfR24)); 1315 + } 1316 + #endif /* RT30xx */ 1317 + 1318 + VOID NICInitRT30xxRFRegisters(IN PRTMP_ADAPTER pAd) 1319 + { 1320 + INT i; 1321 + // Driver must read EEPROM to get RfIcType before initial RF registers 1322 + // Initialize RF register to default value 1323 + #ifndef RT30xx 1324 + if (IS_RT3070(pAd) && ((pAd->RfIcType == RFIC_3020) ||(pAd->RfIcType == RFIC_2020))) 1325 + { 1326 + // Init RF calibration 1327 + // Driver should toggle RF R30 bit7 before init RF registers 1328 + ULONG RfReg = 0; 1329 + RT30xxReadRFRegister(pAd, RF_R30, (PUCHAR)&RfReg); 1330 + RfReg |= 0x80; 1331 + RT30xxWriteRFRegister(pAd, RF_R30, (UCHAR)RfReg); 1332 + RTMPusecDelay(1000); 1333 + RfReg &= 0x7F; 1334 + RT30xxWriteRFRegister(pAd, RF_R30, (UCHAR)RfReg); 1335 + 1336 + // Initialize RF register to default value 1337 + for (i = 0; i < NUM_RF_REG_PARMS; i++) 1338 + { 1339 + RT30xxWriteRFRegister(pAd, RT30xx_RFRegTable[i].Register, RT30xx_RFRegTable[i].Value); 1340 + } 1341 + 1342 + //For RF filter Calibration 1343 + RTUSBFilterCalibration(pAd); 1344 + } 1345 + #endif 1346 + #ifdef RT30xx 1347 + if (IS_RT3070(pAd) || IS_RT3071(pAd)) 1348 + { 1349 + // Init RF calibration 1350 + // Driver should toggle RF R30 bit7 before init RF registers 1351 + UINT32 RfReg = 0; 1352 + UINT32 data; 1353 + 1354 + RT30xxReadRFRegister(pAd, RF_R30, (PUCHAR)&RfReg); 1355 + RfReg |= 0x80; 1356 + RT30xxWriteRFRegister(pAd, RF_R30, (UCHAR)RfReg); 1357 + RTMPusecDelay(1000); 1358 + RfReg &= 0x7F; 1359 + RT30xxWriteRFRegister(pAd, RF_R30, (UCHAR)RfReg); 1360 + 1361 + // Initialize RF register to default value 1362 + for (i = 0; i < NUM_RF_REG_PARMS; i++) 1363 + { 1364 + RT30xxWriteRFRegister(pAd, RT30xx_RFRegTable[i].Register, RT30xx_RFRegTable[i].Value); 1365 + } 1366 + 1367 + // add by johnli 1368 + if (IS_RT3070(pAd)) 1369 + { 1370 + // Update MAC 0x05D4 from 01xxxxxx to 0Dxxxxxx (voltage 1.2V to 1.35V) for RT3070 to improve yield rate 1371 + RTUSBReadMACRegister(pAd, LDO_CFG0, &data); 1372 + data = ((data & 0xF0FFFFFF) | 0x0D000000); 1373 + RTUSBWriteMACRegister(pAd, LDO_CFG0, data); 1374 + } 1375 + else if (IS_RT3071(pAd)) 1376 + { 1377 + // Driver should set RF R6 bit6 on before init RF registers 1378 + RT30xxReadRFRegister(pAd, RF_R06, (PUCHAR)&RfReg); 1379 + RfReg |= 0x40; 1380 + RT30xxWriteRFRegister(pAd, RF_R06, (UCHAR)RfReg); 1381 + 1382 + // init R31 1383 + RT30xxWriteRFRegister(pAd, RF_R31, 0x14); 1384 + 1385 + // RT3071 version E has fixed this issue 1386 + if ((pAd->NicConfig2.field.DACTestBit == 1) && ((pAd->MACVersion & 0xffff) < 0x0211)) 1387 + { 1388 + // patch tx EVM issue temporarily 1389 + RTUSBReadMACRegister(pAd, LDO_CFG0, &data); 1390 + data = ((data & 0xE0FFFFFF) | 0x0D000000); 1391 + RTUSBWriteMACRegister(pAd, LDO_CFG0, data); 1392 + } 1393 + else 1394 + { 1395 + RTMP_IO_READ32(pAd, LDO_CFG0, &data); 1396 + data = ((data & 0xE0FFFFFF) | 0x01000000); 1397 + RTMP_IO_WRITE32(pAd, LDO_CFG0, data); 1398 + } 1399 + 1400 + // patch LNA_PE_G1 failed issue 1401 + RTUSBReadMACRegister(pAd, GPIO_SWITCH, &data); 1402 + data &= ~(0x20); 1403 + RTUSBWriteMACRegister(pAd, GPIO_SWITCH, data); 1404 + } 1405 + 1406 + //For RF filter Calibration 1407 + RTMPFilterCalibration(pAd); 1408 + 1409 + // Initialize RF R27 register, set RF R27 must be behind RTMPFilterCalibration() 1410 + if ((pAd->MACVersion & 0xffff) < 0x0211) 1411 + RT30xxWriteRFRegister(pAd, RF_R27, 0x3); 1412 + 1413 + // set led open drain enable 1414 + RTUSBReadMACRegister(pAd, OPT_14, &data); 1415 + data |= 0x01; 1416 + RTUSBWriteMACRegister(pAd, OPT_14, data); 1417 + 1418 + if (IS_RT3071(pAd)) 1419 + { 1420 + // add by johnli, RF power sequence setup, load RF normal operation-mode setup 1421 + RT30xxLoadRFNormalModeSetup(pAd); 1422 + } 1423 + } 1424 + #endif 1425 + } 1426 + #endif // RT2870 // 1085 1427 1086 1428 1087 1429 /* ··· 1675 1179 Antenna.word = pAd->EEPROMDefaultValue[0]; 1676 1180 if (Antenna.word == 0xFFFF) 1677 1181 { 1182 + #ifdef RT30xx 1183 + if(IS_RT3090(pAd)) 1184 + { 1185 + Antenna.word = 0; 1186 + Antenna.field.RfIcType = RFIC_3020; 1187 + Antenna.field.TxPath = 1; 1188 + Antenna.field.RxPath = 1; 1189 + } 1190 + else 1191 + { 1192 + #endif // RT30xx // 1678 1193 Antenna.word = 0; 1679 1194 Antenna.field.RfIcType = RFIC_2820; 1680 1195 Antenna.field.TxPath = 1; 1681 1196 Antenna.field.RxPath = 2; 1682 1197 DBGPRINT(RT_DEBUG_WARN, ("E2PROM error, hard code as 0x%04x\n", Antenna.word)); 1198 + #ifdef RT30xx 1199 + } 1200 + #endif // RT30xx // 1683 1201 } 1684 1202 1685 1203 // Choose the desired Tx&Rx stream. ··· 1722 1212 NicConfig2.word = pAd->EEPROMDefaultValue[1]; 1723 1213 1724 1214 { 1215 + #ifndef RT30xx 1725 1216 NicConfig2.word = 0; 1217 + #endif 1726 1218 if ((NicConfig2.word & 0x00ff) == 0xff) 1727 1219 { 1728 1220 NicConfig2.word &= 0xff00; ··· 1917 1405 1918 1406 RTMPReadTxPwrPerRate(pAd); 1919 1407 1408 + #ifdef RT30xx 1409 + if (IS_RT30xx(pAd)) 1410 + { 1411 + eFusePhysicalReadRegisters(pAd, EFUSE_TAG, 2, &value); 1412 + pAd->EFuseTag = (value & 0xff); 1413 + } 1414 + #endif // RT30xx // 1415 + 1920 1416 DBGPRINT(RT_DEBUG_TRACE, ("<-- NICReadEEPROMParameters\n")); 1921 1417 } 1922 1418 ··· 1969 1449 } 1970 1450 } 1971 1451 1452 + #ifndef RT30xx 1972 1453 Antenna.word = pAd->Antenna.word; 1454 + #endif 1455 + #ifdef RT30xx 1456 + Antenna.word = pAd->EEPROMDefaultValue[0]; 1457 + if (Antenna.word == 0xFFFF) 1458 + { 1459 + DBGPRINT(RT_DEBUG_ERROR, ("E2PROM error, hard code as 0x%04x\n", Antenna.word)); 1460 + BUG_ON(Antenna.word == 0xFFFF); 1461 + } 1462 + #endif 1973 1463 pAd->Mlme.RealRxPath = (UCHAR) Antenna.field.RxPath; 1974 1464 pAd->RfIcType = (UCHAR) Antenna.field.RfIcType; 1975 1465 1466 + #ifdef RT30xx 1467 + DBGPRINT(RT_DEBUG_WARN, ("pAd->RfIcType = %d, RealRxPath=%d, TxPath = %d\n", pAd->RfIcType, pAd->Mlme.RealRxPath,Antenna.field.TxPath)); 1468 + 1469 + // Save the antenna for future use 1470 + pAd->Antenna.word = Antenna.word; 1471 + #endif 1976 1472 NicConfig2.word = pAd->EEPROMDefaultValue[1]; 1977 1473 1474 + #ifdef RT30xx 1475 + { 1476 + if ((NicConfig2.word & 0x00ff) == 0xff) 1477 + { 1478 + NicConfig2.word &= 0xff00; 1479 + } 1978 1480 1481 + if ((NicConfig2.word >> 8) == 0xff) 1482 + { 1483 + NicConfig2.word &= 0x00ff; 1484 + } 1485 + } 1486 + #endif 1979 1487 // Save the antenna for future use 1980 1488 pAd->NicConfig2.word = NicConfig2.word; 1981 1489 1490 + #ifdef RT30xx 1491 + // set default antenna as main 1492 + if (pAd->RfIcType == RFIC_3020) 1493 + AsicSetRxAnt(pAd, pAd->RxAnt.Pair1PrimaryRxAnt); 1494 + #endif 1982 1495 // 1983 1496 // Send LED Setting to MCU. 1984 1497 // ··· 2020 1467 pAd->LedCntl.word = 0x01; 2021 1468 pAd->Led1 = 0x5555; 2022 1469 pAd->Led2 = 0x2221; 1470 + #ifdef RT2860 2023 1471 pAd->Led3 = 0xA9F8; 1472 + #endif 1473 + 1474 + #ifdef RT2870 1475 + pAd->Led3 = 0x5627; 1476 + #endif // RT2870 // 2024 1477 } 2025 1478 2026 1479 AsicSendCommandToMcu(pAd, 0x52, 0xff, (UCHAR)pAd->Led1, (UCHAR)(pAd->Led1 >> 8)); ··· 2060 1501 else 2061 1502 { 2062 1503 RTMPSetLED(pAd, LED_RADIO_ON); 1504 + #ifdef RT2860 2063 1505 AsicSendCommandToMcu(pAd, 0x30, 0xff, 0xff, 0x02); 2064 1506 AsicSendCommandToMcu(pAd, 0x31, PowerWakeCID, 0x00, 0x00); 2065 1507 // 2-1. wait command ok. 2066 1508 AsicCheckCommanOk(pAd, PowerWakeCID); 1509 + #endif 2067 1510 } 2068 1511 } 2069 1512 ··· 2140 1579 { 2141 1580 NDIS_STATUS Status = NDIS_STATUS_SUCCESS; 2142 1581 WPDMA_GLO_CFG_STRUC GloCfg; 1582 + #ifdef RT2860 2143 1583 UINT32 Value; 2144 1584 DELAY_INT_CFG_STRUC IntCfg; 1585 + #endif 2145 1586 ULONG i =0, j=0; 2146 1587 AC_TXOP_CSR0_STRUC csr0; 2147 1588 ··· 2182 1619 2183 1620 // asic simulation sequence put this ahead before loading firmware. 2184 1621 // pbf hardware reset 1622 + #ifdef RT2860 2185 1623 RTMP_IO_WRITE32(pAd, WPDMA_RST_IDX, 0x1003f); // 0x10000 for reset rx, 0x3f resets all 6 tx rings. 2186 1624 RTMP_IO_WRITE32(pAd, PBF_SYS_CTRL, 0xe1f); 2187 1625 RTMP_IO_WRITE32(pAd, PBF_SYS_CTRL, 0xe00); 1626 + #endif 2188 1627 2189 1628 // Initialze ASIC for TX & Rx operation 2190 1629 if (NICInitializeAsic(pAd , bHardReset) != NDIS_STATUS_SUCCESS) ··· 2200 1635 } 2201 1636 2202 1637 1638 + #ifdef RT2860 2203 1639 // Write AC_BK base address register 2204 1640 Value = RTMP_GetPhysicalAddressLow(pAd->TxRing[QID_AC_BK].Cell[0].AllocPa); 2205 1641 RTMP_IO_WRITE32(pAd, TX_BASE_PTR1, Value); ··· 2273 1707 // Write RX_RING_CSR register 2274 1708 Value = RX_RING_SIZE; 2275 1709 RTMP_IO_WRITE32(pAd, RX_MAX_CNT, Value); 1710 + #endif /* RT2860 */ 2276 1711 2277 1712 2278 1713 // WMM parameter ··· 2292 1725 RTMP_IO_WRITE32(pAd, WMM_TXOP1_CFG, csr0.word); 2293 1726 2294 1727 1728 + #ifdef RT2860 2295 1729 // 3. Set DMA global configuration except TX_DMA_EN and RX_DMA_EN bits: 2296 1730 i = 0; 2297 1731 do ··· 2311 1743 2312 1744 IntCfg.word = 0; 2313 1745 RTMP_IO_WRITE32(pAd, DELAY_INT_CFG, IntCfg.word); 1746 + #endif 2314 1747 2315 1748 2316 1749 // reset action ··· 2347 1778 ULONG Index = 0; 2348 1779 UCHAR R0 = 0xff; 2349 1780 UINT32 MacCsr12 = 0, Counter = 0; 1781 + #ifdef RT2870 1782 + UINT32 MacCsr0 = 0; 1783 + NTSTATUS Status; 1784 + UCHAR Value = 0xff; 1785 + #endif // RT2870 // 1786 + #ifdef RT30xx 1787 + UINT32 eFuseCtrl; 1788 + #endif // RT30xx // 2350 1789 USHORT KeyIdx; 2351 1790 INT i,apidx; 2352 1791 2353 1792 DBGPRINT(RT_DEBUG_TRACE, ("--> NICInitializeAsic\n")); 2354 1793 1794 + #ifdef RT2860 2355 1795 if (bHardReset == TRUE) 2356 1796 { 2357 1797 RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, 0x3); 2358 1798 } 2359 1799 else 2360 1800 RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, 0x1); 1801 + #endif 1802 + #ifdef RT2870 1803 + // 1804 + // Make sure MAC gets ready after NICLoadFirmware(). 1805 + // 1806 + Index = 0; 1807 + 1808 + //To avoid hang-on issue when interface up in kernel 2.4, 1809 + //we use a local variable "MacCsr0" instead of using "pAd->MACVersion" directly. 1810 + do 1811 + { 1812 + RTMP_IO_READ32(pAd, MAC_CSR0, &MacCsr0); 1813 + 1814 + if ((MacCsr0 != 0x00) && (MacCsr0 != 0xFFFFFFFF)) 1815 + break; 1816 + 1817 + RTMPusecDelay(10); 1818 + } while (Index++ < 100); 1819 + 1820 + pAd->MACVersion = MacCsr0; 1821 + DBGPRINT(RT_DEBUG_TRACE, ("MAC_CSR0 [ Ver:Rev=0x%08x]\n", pAd->MACVersion)); 1822 + // turn on bit13 (set to zero) after rt2860D. This is to solve high-current issue. 1823 + RTMP_IO_READ32(pAd, PBF_SYS_CTRL, &MacCsr12); 1824 + MacCsr12 &= (~0x2000); 1825 + RTMP_IO_WRITE32(pAd, PBF_SYS_CTRL, MacCsr12); 1826 + 1827 + RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, 0x3); 1828 + RTMP_IO_WRITE32(pAd, USB_DMA_CFG, 0x0); 1829 + Status = RTUSBVenderReset(pAd); 1830 + #endif 2361 1831 2362 1832 RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, 0x0); 1833 + 2363 1834 // Initialize MAC register to default value 1835 + #ifdef RT2860 2364 1836 for (Index = 0; Index < NUM_MAC_REG_PARMS; Index++) 2365 1837 { 2366 1838 RTMP_IO_WRITE32(pAd, MACRegTable[Index].Register, MACRegTable[Index].Value); 2367 1839 } 1840 + #endif 1841 + #ifdef RT2870 1842 + for(Index=0; Index<NUM_MAC_REG_PARMS; Index++) 1843 + { 1844 + #ifdef RT3070 1845 + if ((MACRegTable[Index].Register == TX_SW_CFG0) && (IS_RT3070(pAd) || IS_RT3071(pAd))) 1846 + { 1847 + MACRegTable[Index].Value = 0x00000400; 1848 + } 1849 + #endif // RT3070 // 1850 + RTMP_IO_WRITE32(pAd, (USHORT)MACRegTable[Index].Register, MACRegTable[Index].Value); 1851 + } 1852 + 1853 + #ifndef RT30xx 1854 + if(IS_RT3070(pAd)) 1855 + { 1856 + // According to Frank Hsu (from Gary Tsao) 1857 + RTMP_IO_WRITE32(pAd, (USHORT)TX_SW_CFG0, 0x00000400); 1858 + 1859 + // Initialize RT3070 serial MAC registers which is different from RT2870 serial 1860 + RTUSBWriteMACRegister(pAd, TX_SW_CFG1, 0); 1861 + RTUSBWriteMACRegister(pAd, TX_SW_CFG2, 0); 1862 + } 1863 + #endif 1864 + #endif // RT2870 // 2368 1865 2369 1866 2370 1867 { 2371 1868 for (Index = 0; Index < NUM_STA_MAC_REG_PARMS; Index++) 2372 1869 { 1870 + #ifdef RT2860 2373 1871 RTMP_IO_WRITE32(pAd, STAMACRegTable[Index].Register, STAMACRegTable[Index].Value); 1872 + #endif 1873 + #ifdef RT2870 1874 + RTMP_IO_WRITE32(pAd, (USHORT)STAMACRegTable[Index].Register, STAMACRegTable[Index].Value); 1875 + #endif 2374 1876 } 2375 1877 } 1878 + 1879 + #ifdef RT30xx 1880 + // Initialize RT3070 serial MAc registers which is different from RT2870 serial 1881 + if (IS_RT3090(pAd)) 1882 + { 1883 + RTMP_IO_WRITE32(pAd, TX_SW_CFG1, 0); 1884 + 1885 + // RT3071 version E has fixed this issue 1886 + if ((pAd->MACVersion & 0xffff) < 0x0211) 1887 + { 1888 + if (pAd->NicConfig2.field.DACTestBit == 1) 1889 + { 1890 + RTMP_IO_WRITE32(pAd, TX_SW_CFG2, 0x1F); // To fix throughput drop drastically 1891 + } 1892 + else 1893 + { 1894 + RTMP_IO_WRITE32(pAd, TX_SW_CFG2, 0x0F); // To fix throughput drop drastically 1895 + } 1896 + } 1897 + else 1898 + { 1899 + RTMP_IO_WRITE32(pAd, TX_SW_CFG2, 0x0); 1900 + } 1901 + } 1902 + else if (IS_RT3070(pAd)) 1903 + { 1904 + RTMP_IO_WRITE32(pAd, TX_SW_CFG1, 0); 1905 + RTMP_IO_WRITE32(pAd, TX_SW_CFG2, 0x1F); // To fix throughput drop drastically 1906 + } 1907 + #endif // RT30xx // 2376 1908 2377 1909 // 2378 1910 // Before program BBP, we need to wait BBP/RF get wake up. ··· 2514 1844 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBPRegTable[Index].Register, BBPRegTable[Index].Value); 2515 1845 } 2516 1846 1847 + #ifndef RT30xx 2517 1848 // for rt2860E and after, init BBP_R84 with 0x19. This is for extension channel overlapping IOT. 2518 1849 if ((pAd->MACVersion&0xffff) != 0x0101) 2519 1850 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R84, 0x19); 2520 1851 1852 + #ifdef RT2870 1853 + //write RT3070 BBP wchich different with 2870 after write RT2870 BBP 1854 + if (IS_RT3070(pAd)) 1855 + { 1856 + RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R70, 0x0a); 1857 + RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R84, 0x99); 1858 + RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R105, 0x05); 1859 + } 1860 + #endif // RT2870 // 1861 + #endif 1862 + #ifdef RT30xx 1863 + // for rt2860E and after, init BBP_R84 with 0x19. This is for extension channel overlapping IOT. 1864 + // RT3090 should not program BBP R84 to 0x19, otherwise TX will block. 1865 + if (((pAd->MACVersion&0xffff) != 0x0101) && (!IS_RT30xx(pAd))) 1866 + RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R84, 0x19); 2521 1867 1868 + // add by johnli, RF power sequence setup 1869 + if (IS_RT30xx(pAd)) 1870 + { //update for RT3070/71/72/90/91/92. 1871 + RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R79, 0x13); 1872 + RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R80, 0x05); 1873 + RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R81, 0x33); 1874 + } 1875 + 1876 + if (IS_RT3090(pAd)) 1877 + { 1878 + UCHAR bbpreg=0; 1879 + 1880 + // enable DC filter 1881 + if ((pAd->MACVersion & 0xffff) >= 0x0211) 1882 + { 1883 + RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R103, 0xc0); 1884 + } 1885 + 1886 + // improve power consumption 1887 + RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R138, &bbpreg); 1888 + if (pAd->Antenna.field.TxPath == 1) 1889 + { 1890 + // turn off tx DAC_1 1891 + bbpreg = (bbpreg | 0x20); 1892 + } 1893 + 1894 + if (pAd->Antenna.field.RxPath == 1) 1895 + { 1896 + // turn off tx ADC_1 1897 + bbpreg &= (~0x2); 1898 + } 1899 + RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R138, bbpreg); 1900 + 1901 + // improve power consumption in RT3071 Ver.E 1902 + if ((pAd->MACVersion & 0xffff) >= 0x0211) 1903 + { 1904 + RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R31, &bbpreg); 1905 + bbpreg &= (~0x3); 1906 + RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R31, bbpreg); 1907 + } 1908 + } 1909 + #endif 2522 1910 if (pAd->MACVersion == 0x28600100) 2523 1911 { 2524 1912 RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R69, 0x16); ··· 2593 1865 RTMP_IO_WRITE32(pAd, MAX_LEN_CFG, csr); 2594 1866 } 2595 1867 1868 + #ifdef RT2870 1869 + { 1870 + UCHAR MAC_Value[]={0xff,0xff,0xff,0xff,0xff,0xff,0xff,0,0}; 1871 + 1872 + //Initialize WCID table 1873 + Value = 0xff; 1874 + for(Index =0 ;Index < 254;Index++) 1875 + { 1876 + RTUSBMultiWrite(pAd, (USHORT)(MAC_WCID_BASE + Index * 8), MAC_Value, 8); 1877 + } 1878 + } 1879 + #endif // RT2870 // 2596 1880 2597 1881 // Add radio off control 2598 1882 { ··· 2652 1912 RTMP_IO_WRITE32(pAd, pAd->BeaconOffset[apidx] + i, 0x00); 2653 1913 } 2654 1914 } 1915 + #ifdef RT2870 1916 + AsicDisableSync(pAd); 1917 + // Clear raw counters 1918 + RTMP_IO_READ32(pAd, RX_STA_CNT0, &Counter); 1919 + RTMP_IO_READ32(pAd, RX_STA_CNT1, &Counter); 1920 + RTMP_IO_READ32(pAd, RX_STA_CNT2, &Counter); 1921 + RTMP_IO_READ32(pAd, TX_STA_CNT0, &Counter); 1922 + RTMP_IO_READ32(pAd, TX_STA_CNT1, &Counter); 1923 + RTMP_IO_READ32(pAd, TX_STA_CNT2, &Counter); 1924 + // Default PCI clock cycle per ms is different as default setting, which is based on PCI. 1925 + RTMP_IO_READ32(pAd, USB_CYC_CFG, &Counter); 1926 + Counter&=0xffffff00; 1927 + Counter|=0x000001e; 1928 + RTMP_IO_WRITE32(pAd, USB_CYC_CFG, Counter); 1929 + #endif // RT2870 // 1930 + #ifdef RT30xx 1931 + pAd->bUseEfuse=FALSE; 1932 + RTMP_IO_READ32(pAd, EFUSE_CTRL, &eFuseCtrl); 1933 + pAd->bUseEfuse = ( (eFuseCtrl & 0x80000000) == 0x80000000) ? 1 : 0; 1934 + if(pAd->bUseEfuse) 1935 + { 1936 + DBGPRINT(RT_DEBUG_TRACE, ("NVM is Efuse\n")); 1937 + } 1938 + else 1939 + { 1940 + DBGPRINT(RT_DEBUG_TRACE, ("NVM is EEPROM\n")); 1941 + 1942 + } 1943 + #endif // RT30xx // 2655 1944 2656 1945 { 2657 1946 // for rt2860E and after, init TXOP_CTRL_CFG with 0x583f. This is for extension channel overlapping IOT. ··· 2693 1924 } 2694 1925 2695 1926 1927 + #ifdef RT2860 2696 1928 VOID NICRestoreBBPValue( 2697 1929 IN PRTMP_ADAPTER pAd) 2698 1930 { ··· 2817 2047 2818 2048 DBGPRINT(RT_DEBUG_TRACE, ("<--- NICRestoreBBPValue !!!!!!!!!!!!!!!!!!!!!!! \n")); 2819 2049 } 2050 + #endif /* RT2860 */ 2820 2051 2821 2052 /* 2822 2053 ======================================================================== ··· 3070 2299 // Update RX Overflow counter 3071 2300 pAd->Counters8023.RxNoBuffer += (RxStaCnt2.field.RxFifoOverflowCount); 3072 2301 2302 + #ifdef RT2870 2303 + if (pAd->RalinkCounters.RxCount != pAd->watchDogRxCnt) 2304 + { 2305 + pAd->watchDogRxCnt = pAd->RalinkCounters.RxCount; 2306 + pAd->watchDogRxOverFlowCnt = 0; 2307 + } 2308 + else 2309 + { 2310 + if (RxStaCnt2.field.RxFifoOverflowCount) 2311 + pAd->watchDogRxOverFlowCnt++; 2312 + else 2313 + pAd->watchDogRxOverFlowCnt = 0; 2314 + } 2315 + #endif // RT2870 // 2316 + 2317 + 3073 2318 if (!pAd->bUpdateBcnCntDone) 3074 2319 { 3075 2320 // Update BEACON sent count ··· 3318 2531 ULONG FileLength, Index; 3319 2532 //ULONG firm; 3320 2533 UINT32 MacReg = 0; 2534 + #ifdef RT2870 2535 + UINT32 Version = (pAd->MACVersion >> 16); 2536 + #endif // RT2870 // 3321 2537 3322 2538 pFirmwareImage = FirmwareImage; 3323 2539 FileLength = sizeof(FirmwareImage); 2540 + #ifdef RT2870 2541 + // New 8k byte firmware size for RT3071/RT3072 2542 + //printk("Usb Chip\n"); 2543 + if (FIRMWAREIMAGE_LENGTH == FIRMWAREIMAGE_MAX_LENGTH) 2544 + //The firmware image consists of two parts. One is the origianl and the other is the new. 2545 + //Use Second Part 2546 + { 2547 + if ((Version != 0x2860) && (Version != 0x2872) && (Version != 0x3070)) 2548 + { // Use Firmware V2. 2549 + //printk("KH:Use New Version,part2\n"); 2550 + pFirmwareImage = (PUCHAR)&FirmwareImage[FIRMWAREIMAGEV1_LENGTH]; 2551 + FileLength = FIRMWAREIMAGEV2_LENGTH; 2552 + } 2553 + else 2554 + { 2555 + //printk("KH:Use New Version,part1\n"); 2556 + pFirmwareImage = FirmwareImage; 2557 + FileLength = FIRMWAREIMAGEV1_LENGTH; 2558 + } 2559 + } 2560 + else 2561 + { 2562 + DBGPRINT(RT_DEBUG_ERROR, ("KH: bin file should be 8KB.\n")); 2563 + Status = NDIS_STATUS_FAILURE; 2564 + } 2565 + 2566 + #endif // RT2870 // 2567 + 3324 2568 RT28XX_WRITE_FIRMWARE(pAd, pFirmwareImage, FileLength); 3325 2569 3326 2570 /* check if MCU is ready */ ··· 3617 2799 // 3618 2800 // part I. intialize common configuration 3619 2801 // 2802 + #ifdef RT2870 2803 + pAd->BulkOutReq = 0; 2804 + 2805 + pAd->BulkOutComplete = 0; 2806 + pAd->BulkOutCompleteOther = 0; 2807 + pAd->BulkOutCompleteCancel = 0; 2808 + pAd->BulkInReq = 0; 2809 + pAd->BulkInComplete = 0; 2810 + pAd->BulkInCompleteFail = 0; 2811 + 2812 + //pAd->QuickTimerP = 100; 2813 + //pAd->TurnAggrBulkInCount = 0; 2814 + pAd->bUsbTxBulkAggre = 0; 2815 + 2816 + // init as unsed value to ensure driver will set to MCU once. 2817 + pAd->LedIndicatorStregth = 0xFF; 2818 + 2819 + pAd->CommonCfg.MaxPktOneTxBulk = 2; 2820 + pAd->CommonCfg.TxBulkFactor = 1; 2821 + pAd->CommonCfg.RxBulkFactor =1; 2822 + 2823 + pAd->CommonCfg.TxPower = 100; //mW 2824 + 2825 + NdisZeroMemory(&pAd->CommonCfg.IOTestParm, sizeof(pAd->CommonCfg.IOTestParm)); 2826 + #endif // RT2870 // 3620 2827 3621 2828 for(key_index=0; key_index<SHARE_KEY_NUM; key_index++) 3622 2829 { ··· 3652 2809 } 3653 2810 } 3654 2811 2812 + #ifdef RT30xx 2813 + pAd->EepromAccess = FALSE; 2814 + #endif 3655 2815 pAd->Antenna.word = 0; 3656 2816 pAd->CommonCfg.BBPCurrentBW = BW_20; 3657 2817 3658 2818 pAd->LedCntl.word = 0; 2819 + #ifdef RT2860 3659 2820 pAd->LedIndicatorStregth = 0; 3660 2821 pAd->RLnkCtrlOffset = 0; 3661 2822 pAd->HostLnkCtrlOffset = 0; 3662 2823 pAd->CheckDmaBusyCount = 0; 2824 + #endif 3663 2825 3664 2826 pAd->bAutoTxAgcA = FALSE; // Default is OFF 3665 2827 pAd->bAutoTxAgcG = FALSE; // Default is OFF ··· 3868 3020 NdisAllocateSpinLock(&pAd->MacTabLock); 3869 3021 3870 3022 pAd->CommonCfg.bWiFiTest = FALSE; 3023 + #ifdef RT2860 3871 3024 pAd->bPCIclkOff = FALSE; 3872 3025 3873 3026 RTMP_SET_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP); 3027 + #endif 3874 3028 DBGPRINT(RT_DEBUG_TRACE, ("<-- UserCfgInit\n")); 3875 3029 } 3876 3030 ··· 3974 3124 pTimer->State = FALSE; 3975 3125 pTimer->cookie = (ULONG) pData; 3976 3126 3127 + #ifdef RT2870 3128 + pTimer->pAd = pAd; 3129 + #endif // RT2870 // 3977 3130 3978 3131 RTMP_OS_Init_Timer(pAd, &pTimer->TimerObj, pTimerFunc, (PVOID) pTimer); 3979 3132 } ··· 4103 3250 if (*pCancelled == TRUE) 4104 3251 pTimer->State = TRUE; 4105 3252 3253 + #ifdef RT2870 3254 + // We need to go-through the TimerQ to findout this timer handler and remove it if 3255 + // it's still waiting for execution. 3256 + 3257 + RT2870_TimerQ_Remove(pTimer->pAd, pTimer); 3258 + #endif // RT2870 // 4106 3259 } 4107 3260 else 4108 3261 {
+5
drivers/staging/rt2860/common/spectrum.c
··· 1570 1570 1571 1571 if ((pMeasureReportInfo = kmalloc(sizeof(MEASURE_RPI_REPORT), GFP_ATOMIC)) == NULL) 1572 1572 { 1573 + #ifndef RT30xx 1573 1574 DBGPRINT(RT_DEBUG_ERROR, ("%s unable to alloc memory for measure report buffer (size=%zu).\n", __func__, sizeof(MEASURE_RPI_REPORT))); 1575 + #endif 1576 + #ifdef RT30xx 1577 + DBGPRINT(RT_DEBUG_ERROR, ("%s unable to alloc memory for measure report buffer (size=%d).\n", __func__, sizeof(MEASURE_RPI_REPORT))); 1578 + #endif 1574 1579 return; 1575 1580 } 1576 1581