⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cmm_asic.c

📁 ralink 2870 usb无线网卡 最新驱动
💻 C
📖 第 1 页 / 共 5 页
字号:
				if (bNonGFExist)				{					// PROT_NAV(19:18)  -- 01 (Short NAV protectiion)					// PROT_CTRL(17:16) -- 01 (RTS/CTS)					Protect[4] = 0x01754004;					Protect[5] = 0x03f54084;				}				pAd->CommonCfg.IOTestParm.bRTSLongProtOn = FALSE;				break;				 			case 1:				// This is "HT non-member protection mode."				// If there may be non-HT STAs my BSS				ProtCfg.word = 0x01744004;	// PROT_CTRL(17:16) : 0 (None)				ProtCfg4.word = 0x03f44084; // duplicaet legacy 24M. BW set 1.				if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_BG_PROTECTION_INUSED))				{					ProtCfg.word = 0x01740003;	//ERP use Protection bit is set, use protection rate at Clause 18..					ProtCfg4.word = 0x03f40003; // Don't duplicate RTS/CTS in CCK mode. 0x03f40083; 				}				//Assign Protection method for 20&40 MHz packets				ProtCfg.field.ProtectCtrl = ASIC_RTS;				ProtCfg.field.ProtectNav = ASIC_SHORTNAV;				ProtCfg4.field.ProtectCtrl = ASIC_RTS;				ProtCfg4.field.ProtectNav = ASIC_SHORTNAV;				Protect[2] = ProtCfg.word;				Protect[3] = ProtCfg4.word;				Protect[4] = ProtCfg.word;				Protect[5] = ProtCfg4.word;				pAd->CommonCfg.IOTestParm.bRTSLongProtOn = TRUE;				break;							case 2:				// If only HT STAs are in BSS. at least one is 20MHz. Only protect 40MHz packets				ProtCfg.word = 0x01744004;  // PROT_CTRL(17:16) : 0 (None)				ProtCfg4.word = 0x03f44084; // duplicaet legacy 24M. BW set 1.				//Assign Protection method for 40MHz packets				ProtCfg4.field.ProtectCtrl = ASIC_RTS;				ProtCfg4.field.ProtectNav = ASIC_SHORTNAV;				Protect[2] = ProtCfg.word;				Protect[3] = ProtCfg4.word;				if (bNonGFExist)				{					ProtCfg.field.ProtectCtrl = ASIC_RTS;					ProtCfg.field.ProtectNav = ASIC_SHORTNAV;				}				Protect[4] = ProtCfg.word;				Protect[5] = ProtCfg4.word;				pAd->CommonCfg.IOTestParm.bRTSLongProtOn = FALSE;				break;							case 3:				// HT mixed mode.	 PROTECT ALL!				// Assign Rate				ProtCfg.word = 0x01744004;	//duplicaet legacy 24M. BW set 1.				ProtCfg4.word = 0x03f44084;				// both 20MHz and 40MHz are protected. Whether use RTS or CTS-to-self depends on the				if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_BG_PROTECTION_INUSED))				{					ProtCfg.word = 0x01740003;	//ERP use Protection bit is set, use protection rate at Clause 18..					ProtCfg4.word = 0x03f40003; // Don't duplicate RTS/CTS in CCK mode. 0x03f40083				}				//Assign Protection method for 20&40 MHz packets				ProtCfg.field.ProtectCtrl = ASIC_RTS;				ProtCfg.field.ProtectNav = ASIC_SHORTNAV;				ProtCfg4.field.ProtectCtrl = ASIC_RTS;				ProtCfg4.field.ProtectNav = ASIC_SHORTNAV;				Protect[2] = ProtCfg.word;				Protect[3] = ProtCfg4.word;				Protect[4] = ProtCfg.word;				Protect[5] = ProtCfg4.word;				pAd->CommonCfg.IOTestParm.bRTSLongProtOn = TRUE;				break;								case 8:				// Special on for Atheros problem n chip.				Protect[2] = 0x01754004;				Protect[3] = 0x03f54084;				Protect[4] = 0x01754004;				Protect[5] = 0x03f54084;				pAd->CommonCfg.IOTestParm.bRTSLongProtOn = TRUE;				break;				}	}#endif // DOT11_N_SUPPORT //		offset = CCK_PROT_CFG;	for (i = 0;i < 6;i++)	{			if ((SetMask & (1<< i)))		{		RTMP_IO_WRITE32(pAd, offset + i*4, Protect[i]);	}}}/*	==========================================================================	Description:	IRQL = PASSIVE_LEVEL	IRQL = DISPATCH_LEVEL		========================================================================== */VOID AsicSwitchChannel(					  IN PRTMP_ADAPTER pAd, 	IN	UCHAR			Channel,	IN	BOOLEAN			bScan) {	ULONG			R2 = 0, R3 = DEFAULT_RF_TX_POWER, R4 = 0;	CHAR    TxPwer = 0, TxPwer2 = DEFAULT_RF_TX_POWER; //Bbp94 = BBPR94_DEFAULT, TxPwer2 = DEFAULT_RF_TX_POWER;	UCHAR	index;	UINT32 	Value = 0; //BbpReg, Value;	RTMP_RF_REGS *RFRegTable;	UCHAR 	RFValue;	RFValue = 0;	// Search Tx power value	// We can't use ChannelList to search channel, since some central channl's txpowr doesn't list 	// in ChannelList, so use TxPower array instead.	//	for (index = 0; index < MAX_NUM_OF_CHANNELS; index++)	{		if (Channel == pAd->TxPower[index].Channel)		{			TxPwer = pAd->TxPower[index].Power;			TxPwer2 = pAd->TxPower[index].Power2;			break;		}	}	if (index == MAX_NUM_OF_CHANNELS)	{		DBGPRINT(RT_DEBUG_ERROR, ("AsicSwitchChannel: Can't find the Channel#%d \n", Channel));	}	{		RFRegTable = RF2850RegTable;		switch (pAd->RfIcType)		{			case RFIC_2820:			case RFIC_2850:			case RFIC_2720:			case RFIC_2750:				for (index = 0; index < NUM_OF_2850_CHNL; index++)				{					if (Channel == RFRegTable[index].Channel)					{						R2 = RFRegTable[index].R2;						if (pAd->Antenna.field.TxPath == 1)						{							R2 |= 0x4000;	// If TXpath is 1, bit 14 = 1;						}						if (pAd->Antenna.field.RxPath == 2)						{							R2 |= 0x40;	// write 1 to off Rxpath.						}						else if (pAd->Antenna.field.RxPath == 1)						{							R2 |= 0x20040;	// write 1 to off RxPath						}						if (Channel > 14)						{							// initialize R3, R4							R3 = (RFRegTable[index].R3 & 0xffffc1ff);							R4 = (RFRegTable[index].R4 & (~0x001f87c0)) | (pAd->RfFreqOffset << 15);							// 5G band power range: 0xF9~0X0F, TX0 Reg3 bit9/TX1 Reg4 bit6="0" means the TX power reduce 7dB							// R3							if ((TxPwer >= -7) && (TxPwer < 0))							{								TxPwer = (7+TxPwer);								TxPwer = (TxPwer > 0xF) ? (0xF) : (TxPwer);								R3 |= (TxPwer << 10);								DBGPRINT(RT_DEBUG_ERROR, ("AsicSwitchChannel: TxPwer=%d \n", TxPwer));							}							else							{								TxPwer = (TxPwer > 0xF) ? (0xF) : (TxPwer);								R3 |= (TxPwer << 10) | (1 << 9);							}							// R4							if ((TxPwer2 >= -7) && (TxPwer2 < 0))							{								TxPwer2 = (7+TxPwer2);								TxPwer2 = (TxPwer2 > 0xF) ? (0xF) : (TxPwer2);								R4 |= (TxPwer2 << 7);								DBGPRINT(RT_DEBUG_ERROR, ("AsicSwitchChannel: TxPwer2=%d \n", TxPwer2));							}							else							{								TxPwer2 = (TxPwer2 > 0xF) ? (0xF) : (TxPwer2);								R4 |= (TxPwer2 << 7) | (1 << 6);							}                        						}						else						{							R3 = (RFRegTable[index].R3 & 0xffffc1ff) | (TxPwer << 9); // set TX power0						R4 = (RFRegTable[index].R4 & (~0x001f87c0)) | (pAd->RfFreqOffset << 15) | (TxPwer2 <<6);// Set freq Offset & TxPwr1						}						// Based on BBP current mode before changing RF channel.						if (!bScan && (pAd->CommonCfg.BBPCurrentBW == BW_40))						{							R4 |=0x200000;						}						// Update variables						pAd->LatchRfRegs.Channel = Channel;						pAd->LatchRfRegs.R1 = RFRegTable[index].R1;						pAd->LatchRfRegs.R2 = R2;						pAd->LatchRfRegs.R3 = R3;						pAd->LatchRfRegs.R4 = R4;#ifdef DFS_DEBUG#ifdef DFS_FCC_BW40_FIX						// FCC DFS test						pAd->LatchRfRegs.R1 |= 0x100;						pAd->LatchRfRegs.R4 |= 0x00400000;#endif // DFS_FCC_BW40_FIX //#endif // DFS_DEBUG //						// Set RF value 1's set R3[bit2] = [0]						RTMP_RF_IO_WRITE32(pAd, pAd->LatchRfRegs.R1);						RTMP_RF_IO_WRITE32(pAd, pAd->LatchRfRegs.R2);						RTMP_RF_IO_WRITE32(pAd, (pAd->LatchRfRegs.R3 & (~0x04)));						RTMP_RF_IO_WRITE32(pAd, pAd->LatchRfRegs.R4);						RTMPusecDelay(200);						// Set RF value 2's set R3[bit2] = [1]						RTMP_RF_IO_WRITE32(pAd, pAd->LatchRfRegs.R1);						RTMP_RF_IO_WRITE32(pAd, pAd->LatchRfRegs.R2);						RTMP_RF_IO_WRITE32(pAd, (pAd->LatchRfRegs.R3 | 0x04));						RTMP_RF_IO_WRITE32(pAd, pAd->LatchRfRegs.R4);						RTMPusecDelay(200);						// Set RF value 3's set R3[bit2] = [0]						RTMP_RF_IO_WRITE32(pAd, pAd->LatchRfRegs.R1);						RTMP_RF_IO_WRITE32(pAd, pAd->LatchRfRegs.R2);						RTMP_RF_IO_WRITE32(pAd, (pAd->LatchRfRegs.R3 & (~0x04)));						RTMP_RF_IO_WRITE32(pAd, pAd->LatchRfRegs.R4);						break;					}				}				break;			default:				break;		}		DBGPRINT(RT_DEBUG_TRACE, ("SwitchChannel#%d(RF=%d, Pwr0=%lu, Pwr1=%lu, %dT) to , R1=0x%08lx, R2=0x%08lx, R3=0x%08lx, R4=0x%08lx\n",							  Channel, 							  pAd->RfIcType, 							  (R3 & 0x00003e00) >> 9,							  (R4 & 0x000007c0) >> 6,							  pAd->Antenna.field.TxPath,							  pAd->LatchRfRegs.R1, 							  pAd->LatchRfRegs.R2, 							  pAd->LatchRfRegs.R3, 							  pAd->LatchRfRegs.R4));	}	// Change BBP setting during siwtch from a->g, g->a	if (Channel <= 14)	{		ULONG	TxPinCfg = 0x00050F0A;//Gary 2007/08/09 0x050A0A		RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R62, (0x37 - GET_LNA_GAIN(pAd)));		RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R63, (0x37 - GET_LNA_GAIN(pAd)));		RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R64, (0x37 - GET_LNA_GAIN(pAd)));		RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R86, 0);//(0x44 - GET_LNA_GAIN(pAd)));	// According the Rory's suggestion to solve the middle range issue.		//RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R82, 0x62);		// Rx High power VGA offset for LNA select		if (pAd->NicConfig2.field.ExternalLNAForG)		{			RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R82, 0x62);			RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R75, 0x46);		}		else		{			RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R82, 0x84);			RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R75, 0x50);		}		// 5G band selection PIN, bit1 and bit2 are complement		RTMP_IO_READ32(pAd, TX_BAND_CFG, &Value);		Value &= (~0x6);		Value |= (0x04);		RTMP_IO_WRITE32(pAd, TX_BAND_CFG, Value);		// Turn off unused PA or LNA when only 1T or 1R		if (pAd->Antenna.field.TxPath == 1)		{			TxPinCfg &= 0xFFFFFFF3;		}		if (pAd->Antenna.field.RxPath == 1)		{			TxPinCfg &= 0xFFFFF3FF;		}		RTMP_IO_WRITE32(pAd, TX_PIN_CFG, TxPinCfg);	}	else	{		ULONG	TxPinCfg = 0x00050F05;//Gary 2007/8/9 0x050505		RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R62, (0x37 - GET_LNA_GAIN(pAd)));		RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R63, (0x37 - GET_LNA_GAIN(pAd)));		RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R64, (0x37 - GET_LNA_GAIN(pAd)));		RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R86, 0);//(0x44 - GET_LNA_GAIN(pAd)));   // According the Rory's suggestion to solve the middle range issue.     			RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R82, 0xF2);		// Rx High power VGA offset for LNA select		if (pAd->NicConfig2.field.ExternalLNAForA)		{			RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R75, 0x46);		}		else		{			RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R75, 0x50);		}		// 5G band selection PIN, bit1 and bit2 are complement		RTMP_IO_READ32(pAd, TX_BAND_CFG, &Value);		Value &= (~0x6);		Value |= (0x02);		RTMP_IO_WRITE32(pAd, TX_BAND_CFG, Value);		// Turn off unused PA or LNA when only 1T or 1R		if (pAd->Antenna.field.TxPath == 1)		{			TxPinCfg &= 0xFFFFFFF3;		}		if (pAd->Antenna.field.RxPath == 1)		{			TxPinCfg &= 0xFFFFF3FF;		}				RTMP_IO_WRITE32(pAd, TX_PIN_CFG, TxPinCfg);	}	// R66 should be set according to Channel and use 20MHz when scanning	//RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R66, (0x2E + GET_LNA_GAIN(pAd)));	if (bScan)		RTMPSetAGCInitValue(pAd, BW_20);	else		RTMPSetAGCInitValue(pAd, pAd->CommonCfg.BBPCurrentBW);	//	// On 11A, We should delay and wait RF/BBP to be stable	// and the appropriate time should be 1000 micro seconds 	// 2005/06/05 - On 11G, We also need this delay time. Otherwise it's difficult to pass the WHQL.	//	RTMPusecDelay(1000);  }/*	==========================================================================	Description:		This function is required for 2421 only, and should not be used during		site survey. It's only required after NIC decided to stay at a channel		for a longer period.		When this function is called, it's always after AsicSwitchChannel().	IRQL = PASSIVE_LEVEL	IRQL = DISPATCH_LEVEL		========================================================================== */VOID AsicLockChannel(	IN PRTMP_ADAPTER pAd, 	IN UCHAR Channel) {}/*	==========================================================================	Description:	IRQL = PASSIVE_LEVEL	IRQL = DISPATCH_LEVEL		========================================================================== */VOID	AsicAntennaSelect(	IN	PRTMP_ADAPTER	pAd,	IN	UCHAR			Channel) {}/*	========================================================================		Routine Description:		Antenna miscellaneous setting.	Arguments:		pAd						Pointer to our adapter		BandState				Indicate current Band State.	Return Value:		None	IRQL <= DISPATCH_LEVEL		Note:		1.) Frame End type control			only valid for G only (RF_2527 & RF_2529)			0: means DPDT, set BBP R4 bit 5 to 1			1: means SPDT, set BBP R4 bit 5 to 0			

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -