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

📄 cmm_asic.c

📁 ralink 2870 usb无线网卡 最新驱动
💻 C
📖 第 1 页 / 共 5 页
字号:
/* ************************************************************************* * Ralink Tech Inc. * 5F., No.36, Taiyuan St., Jhubei City, * Hsinchu County 302, * Taiwan, R.O.C. * * (c) Copyright 2002-2007, Ralink Technology, Inc. * * This program is free software; you can redistribute it and/or modify  *  * it under the terms of the GNU General Public License as published by  *  * the Free Software Foundation; either version 2 of the License, or     *  * (at your option) any later version.                                   *  *                                                                       *  * This program is distributed in the hope that it will be useful,       *  * but WITHOUT ANY WARRANTY; without even the implied warranty of        *  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *  * GNU General Public License for more details.                          *  *                                                                       *  * You should have received a copy of the GNU General Public License     *  * along with this program; if not, write to the                         *  * Free Software Foundation, Inc.,                                       *  * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *  *                                                                       *  *************************************************************************	Module Name:	cmm_asic.c	Abstract:	Functions used to communicate with ASIC		Revision History:	Who			When			What	--------	----------		----------------------------------------------*/#include "rt_config.h"// Reset the RFIC setting to new series    RTMP_RF_REGS RF2850RegTable[] = {//		ch	 R1 		 R2 		 R3(TX0~4=0) R4		{1,  0x98402ecc, 0x984c0786, 0x9816b455, 0x9800510b},		{2,  0x98402ecc, 0x984c0786, 0x98168a55, 0x9800519f},		{3,  0x98402ecc, 0x984c078a, 0x98168a55, 0x9800518b},		{4,  0x98402ecc, 0x984c078a, 0x98168a55, 0x9800519f},		{5,  0x98402ecc, 0x984c078e, 0x98168a55, 0x9800518b},		{6,  0x98402ecc, 0x984c078e, 0x98168a55, 0x9800519f},		{7,  0x98402ecc, 0x984c0792, 0x98168a55, 0x9800518b},		{8,  0x98402ecc, 0x984c0792, 0x98168a55, 0x9800519f},		{9,  0x98402ecc, 0x984c0796, 0x98168a55, 0x9800518b},		{10, 0x98402ecc, 0x984c0796, 0x98168a55, 0x9800519f},		{11, 0x98402ecc, 0x984c079a, 0x98168a55, 0x9800518b},		{12, 0x98402ecc, 0x984c079a, 0x98168a55, 0x9800519f},		{13, 0x98402ecc, 0x984c079e, 0x98168a55, 0x9800518b},		{14, 0x98402ecc, 0x984c07a2, 0x98168a55, 0x98005193},		// 802.11 UNI / HyperLan 2		{36, 0x98402ecc, 0x984c099a, 0x98158a55, 0x980ed1a3},		{38, 0x98402ecc, 0x984c099e, 0x98158a55, 0x980ed193},		{40, 0x98402ec8, 0x984c0682, 0x98158a55, 0x980ed183},		{44, 0x98402ec8, 0x984c0682, 0x98158a55, 0x980ed1a3},		{46, 0x98402ec8, 0x984c0686, 0x98158a55, 0x980ed18b},		{48, 0x98402ec8, 0x984c0686, 0x98158a55, 0x980ed19b},		{52, 0x98402ec8, 0x984c068a, 0x98158a55, 0x980ed193},		{54, 0x98402ec8, 0x984c068a, 0x98158a55, 0x980ed1a3},		{56, 0x98402ec8, 0x984c068e, 0x98158a55, 0x980ed18b},		{60, 0x98402ec8, 0x984c0692, 0x98158a55, 0x980ed183},		{62, 0x98402ec8, 0x984c0692, 0x98158a55, 0x980ed193},		{64, 0x98402ec8, 0x984c0692, 0x98158a55, 0x980ed1a3}, // Plugfest#4, Day4, change RFR3 left4th 9->5.		// 802.11 HyperLan 2		{100, 0x98402ec8, 0x984c06b2, 0x98178a55, 0x980ed783},				// 2008.04.30 modified 		// The system team has AN to improve the EVM value 		// for channel 102 to 108 for the RT2850/RT2750 dual band solution.		{102, 0x98402ec8, 0x985c06b2, 0x98578a55, 0x980ed793},		{104, 0x98402ec8, 0x985c06b2, 0x98578a55, 0x980ed1a3},		{108, 0x98402ecc, 0x985c0a32, 0x98578a55, 0x980ed193},		{110, 0x98402ecc, 0x984c0a36, 0x98178a55, 0x980ed183},		{112, 0x98402ecc, 0x984c0a36, 0x98178a55, 0x980ed19b},		{116, 0x98402ecc, 0x984c0a3a, 0x98178a55, 0x980ed1a3},		{118, 0x98402ecc, 0x984c0a3e, 0x98178a55, 0x980ed193},		{120, 0x98402ec4, 0x984c0382, 0x98178a55, 0x980ed183},		{124, 0x98402ec4, 0x984c0382, 0x98178a55, 0x980ed193},		{126, 0x98402ec4, 0x984c0382, 0x98178a55, 0x980ed15b}, // 0x980ed1bb->0x980ed15b required by Rory 20070927		{128, 0x98402ec4, 0x984c0382, 0x98178a55, 0x980ed1a3},		{132, 0x98402ec4, 0x984c0386, 0x98178a55, 0x980ed18b},		{134, 0x98402ec4, 0x984c0386, 0x98178a55, 0x980ed193},		{136, 0x98402ec4, 0x984c0386, 0x98178a55, 0x980ed19b},		{140, 0x98402ec4, 0x984c038a, 0x98178a55, 0x980ed183},		// 802.11 UNII		{149, 0x98402ec4, 0x984c038a, 0x98178a55, 0x980ed1a7},		{151, 0x98402ec4, 0x984c038e, 0x98178a55, 0x980ed187},		{153, 0x98402ec4, 0x984c038e, 0x98178a55, 0x980ed18f},		{157, 0x98402ec4, 0x984c038e, 0x98178a55, 0x980ed19f},		{159, 0x98402ec4, 0x984c038e, 0x98178a55, 0x980ed1a7},		{161, 0x98402ec4, 0x984c0392, 0x98178a55, 0x980ed187},		{165, 0x98402ec4, 0x984c0392, 0x98178a55, 0x980ed197},		{167, 0x98402ec4, 0x984c03d2, 0x98179855, 0x9815531f},		{169, 0x98402ec4, 0x984c03d2, 0x98179855, 0x98155327},		{171, 0x98402ec4, 0x984c03d6, 0x98179855, 0x98155307},		{173, 0x98402ec4, 0x984c03d6, 0x98179855, 0x9815530f},		// Japan		{184, 0x95002ccc, 0x9500491e, 0x9509be55, 0x950c0a0b},		{188, 0x95002ccc, 0x95004922, 0x9509be55, 0x950c0a13},		{192, 0x95002ccc, 0x95004926, 0x9509be55, 0x950c0a1b},		{196, 0x95002ccc, 0x9500492a, 0x9509be55, 0x950c0a23},		{208, 0x95002ccc, 0x9500493a, 0x9509be55, 0x950c0a13},		{212, 0x95002ccc, 0x9500493e, 0x9509be55, 0x950c0a1b},		{216, 0x95002ccc, 0x95004982, 0x9509be55, 0x950c0a23},		// still lack of MMAC(Japan) ch 34,38,42,46};UCHAR	NUM_OF_2850_CHNL = (sizeof(RF2850RegTable) / sizeof(RTMP_RF_REGS));FREQUENCY_ITEM FreqItems3020[] ={		/**************************************************/	// ISM : 2.4 to 2.483 GHz                         //	/**************************************************/	// 11g	/**************************************************/	//-CH---N-------R---K-----------	{1,    241,  2,  2},	{2,    241,	 2,  7},	{3,    242,	 2,  2},	{4,    242,	 2,  7},	{5,    243,	 2,  2},	{6,    243,	 2,  7},	{7,    244,	 2,  2},	{8,    244,	 2,  7},	{9,    245,	 2,  2},	{10,   245,	 2,  7},	{11,   246,	 2,  2},	{12,   246,	 2,  7},	{13,   247,	 2,  2},	{14,   248,	 2,  4},};UCHAR	NUM_OF_3020_CHNL = (sizeof(FreqItems3020) / sizeof(FREQUENCY_ITEM));VOID AsicUpdateAutoFallBackTable(	IN	PRTMP_ADAPTER	pAd,	IN	PUCHAR			pRateTable){	UCHAR					i;	HT_FBK_CFG0_STRUC		HtCfg0;	HT_FBK_CFG1_STRUC		HtCfg1;	LG_FBK_CFG0_STRUC		LgCfg0;	LG_FBK_CFG1_STRUC		LgCfg1;	PRTMP_TX_RATE_SWITCH	pCurrTxRate, pNextTxRate;	// set to initial value	HtCfg0.word = 0x65432100;	HtCfg1.word = 0xedcba988;	LgCfg0.word = 0xedcba988;	LgCfg1.word = 0x00002100;	pNextTxRate = (PRTMP_TX_RATE_SWITCH)pRateTable+1;	for (i = 1; i < *((PUCHAR) pRateTable); i++)	{		pCurrTxRate = (PRTMP_TX_RATE_SWITCH)pRateTable+1+i;		switch (pCurrTxRate->Mode)		{			case 0:		//CCK				break;			case 1:		//OFDM				{					switch(pCurrTxRate->CurrMCS)					{						case 0:							LgCfg0.field.OFDMMCS0FBK = (pNextTxRate->Mode == MODE_OFDM) ? (pNextTxRate->CurrMCS+8): pNextTxRate->CurrMCS;							break;						case 1:							LgCfg0.field.OFDMMCS1FBK = (pNextTxRate->Mode == MODE_OFDM) ? (pNextTxRate->CurrMCS+8): pNextTxRate->CurrMCS;							break;						case 2:							LgCfg0.field.OFDMMCS2FBK = (pNextTxRate->Mode == MODE_OFDM) ? (pNextTxRate->CurrMCS+8): pNextTxRate->CurrMCS;							break;						case 3:							LgCfg0.field.OFDMMCS3FBK = (pNextTxRate->Mode == MODE_OFDM) ? (pNextTxRate->CurrMCS+8): pNextTxRate->CurrMCS;							break;						case 4:							LgCfg0.field.OFDMMCS4FBK = (pNextTxRate->Mode == MODE_OFDM) ? (pNextTxRate->CurrMCS+8): pNextTxRate->CurrMCS;							break;						case 5:							LgCfg0.field.OFDMMCS5FBK = (pNextTxRate->Mode == MODE_OFDM) ? (pNextTxRate->CurrMCS+8): pNextTxRate->CurrMCS;							break;						case 6:							LgCfg0.field.OFDMMCS6FBK = (pNextTxRate->Mode == MODE_OFDM) ? (pNextTxRate->CurrMCS+8): pNextTxRate->CurrMCS;							break;						case 7:							LgCfg0.field.OFDMMCS7FBK = (pNextTxRate->Mode == MODE_OFDM) ? (pNextTxRate->CurrMCS+8): pNextTxRate->CurrMCS;							break;					}				}				break;#ifdef DOT11_N_SUPPORT			case 2:		//HT-MIX			case 3:		//HT-GF				{					if ((pNextTxRate->Mode >= MODE_HTMIX) && (pCurrTxRate->CurrMCS != pNextTxRate->CurrMCS))					{						switch(pCurrTxRate->CurrMCS)						{							case 0:								HtCfg0.field.HTMCS0FBK = pNextTxRate->CurrMCS;								break;							case 1:								HtCfg0.field.HTMCS1FBK = pNextTxRate->CurrMCS;								break;							case 2:								HtCfg0.field.HTMCS2FBK = pNextTxRate->CurrMCS;								break;							case 3:								HtCfg0.field.HTMCS3FBK = pNextTxRate->CurrMCS;								break;							case 4:								HtCfg0.field.HTMCS4FBK = pNextTxRate->CurrMCS;								break;							case 5:								HtCfg0.field.HTMCS5FBK = pNextTxRate->CurrMCS;								break;							case 6:								HtCfg0.field.HTMCS6FBK = pNextTxRate->CurrMCS;								break;							case 7:								HtCfg0.field.HTMCS7FBK = pNextTxRate->CurrMCS;								break;							case 8:								HtCfg1.field.HTMCS8FBK = pNextTxRate->CurrMCS;								break;							case 9:								HtCfg1.field.HTMCS9FBK = pNextTxRate->CurrMCS;								break;							case 10:								HtCfg1.field.HTMCS10FBK = pNextTxRate->CurrMCS;								break;							case 11:								HtCfg1.field.HTMCS11FBK = pNextTxRate->CurrMCS;								break;							case 12:								HtCfg1.field.HTMCS12FBK = pNextTxRate->CurrMCS;								break;							case 13:								HtCfg1.field.HTMCS13FBK = pNextTxRate->CurrMCS;								break;							case 14:								HtCfg1.field.HTMCS14FBK = pNextTxRate->CurrMCS;								break;							case 15:								HtCfg1.field.HTMCS15FBK = pNextTxRate->CurrMCS;								break;							default:								DBGPRINT(RT_DEBUG_ERROR, ("AsicUpdateAutoFallBackTable: not support CurrMCS=%d\n", pCurrTxRate->CurrMCS));						}					}				}				break;#endif // DOT11_N_SUPPORT //		}		pNextTxRate = pCurrTxRate;	}	RTMP_IO_WRITE32(pAd, HT_FBK_CFG0, HtCfg0.word);	RTMP_IO_WRITE32(pAd, HT_FBK_CFG1, HtCfg1.word);	RTMP_IO_WRITE32(pAd, LG_FBK_CFG0, LgCfg0.word);	RTMP_IO_WRITE32(pAd, LG_FBK_CFG1, LgCfg1.word);}/*	========================================================================	Routine Description:		Set MAC register value according operation mode.		OperationMode AND bNonGFExist are for MM and GF Proteciton.		If MM or GF mask is not set, those passing argument doesn't not take effect.				Operation mode meaning:		= 0 : Pure HT, no preotection.		= 0x01; there may be non-HT devices in both the control and extension channel, protection is optional in BSS.		= 0x10: No Transmission in 40M is protected.		= 0x11: Transmission in both 40M and 20M shall be protected		if (bNonGFExist)			we should choose not to use GF. But still set correct ASIC registers.	========================================================================*/VOID 	AsicUpdateProtect(	IN		PRTMP_ADAPTER	pAd,	IN 		USHORT			OperationMode,	IN 		UCHAR			SetMask,	IN		BOOLEAN			bDisableBGProtect,	IN		BOOLEAN			bNonGFExist)	{	PROT_CFG_STRUC	ProtCfg, ProtCfg4;	UINT32 Protect[6];	USHORT			offset;	UCHAR			i;	UINT32 MacReg = 0;#ifdef RALINK_ATE	if (ATE_ON(pAd))		return;#endif // RALINK_ATE //#ifdef DOT11_N_SUPPORT	if (!(pAd->CommonCfg.bHTProtect) && (OperationMode != 8))	{		return;	}	if (pAd->BATable.numDoneOriginator)	{		// 		// enable the RTS/CTS to avoid channel collision		// 		SetMask = ALLN_SETPROTECT;		OperationMode = 8;	}#endif // DOT11_N_SUPPORT //	// Config ASIC RTS threshold register	RTMP_IO_READ32(pAd, TX_RTS_CFG, &MacReg);	MacReg &= 0xFF0000FF;	// If the user want disable RtsThreshold and enbale Amsdu/Ralink-Aggregation, set the RtsThreshold as 4096        if ((#ifdef DOT11_N_SUPPORT			(pAd->CommonCfg.BACapability.field.AmsduEnable) || #endif // DOT11_N_SUPPORT //			(pAd->CommonCfg.bAggregationCapable == TRUE))            && pAd->CommonCfg.RtsThreshold == MAX_RTS_THRESHOLD)        {			MacReg |= (0x1000 << 8);        }        else        {			MacReg |= (pAd->CommonCfg.RtsThreshold << 8);        }	RTMP_IO_WRITE32(pAd, TX_RTS_CFG, MacReg);	// Initial common protection settings	RTMPZeroMemory(Protect, sizeof(Protect));	ProtCfg4.word = 0;	ProtCfg.word = 0;	ProtCfg.field.TxopAllowGF40 = 1;	ProtCfg.field.TxopAllowGF20 = 1;	ProtCfg.field.TxopAllowMM40 = 1;	ProtCfg.field.TxopAllowMM20 = 1;	ProtCfg.field.TxopAllowOfdm = 1;	ProtCfg.field.TxopAllowCck = 1;	ProtCfg.field.RTSThEn = 1;	ProtCfg.field.ProtectNav = ASIC_SHORTNAV;	// update PHY mode and rate	if (pAd->CommonCfg.Channel > 14)		ProtCfg.field.ProtectRate = 0x4000;	ProtCfg.field.ProtectRate |= pAd->CommonCfg.RtsRate;		// Handle legacy(B/G) protection	if (bDisableBGProtect)	{		//ProtCfg.field.ProtectRate = pAd->CommonCfg.RtsRate;		ProtCfg.field.ProtectCtrl = 0;		Protect[0] = ProtCfg.word;		Protect[1] = ProtCfg.word;		pAd->FlgCtsEnabled = 0; /* CTS-self is not used */	}	else	{		//ProtCfg.field.ProtectRate = pAd->CommonCfg.RtsRate;		ProtCfg.field.ProtectCtrl = 0;			// CCK do not need to be protected		Protect[0] = ProtCfg.word;		ProtCfg.field.ProtectCtrl = ASIC_CTS;	// OFDM needs using CCK to protect		Protect[1] = ProtCfg.word;		pAd->FlgCtsEnabled = 1; /* CTS-self is used */	}#ifdef DOT11_N_SUPPORT	// Decide HT frame protection.	if ((SetMask & ALLN_SETPROTECT) != 0)	{		switch(OperationMode)		{			case 0x0:				// NO PROTECT 				// 1.All STAs in the BSS are 20/40 MHz HT				// 2. in ai 20/40MHz BSS				// 3. all STAs are 20MHz in a 20MHz BSS				// Pure HT. no protection.				// MM20_PROT_CFG				//	Reserved (31:27)				// 	PROT_TXOP(25:20) -- 010111				//	PROT_NAV(19:18)  -- 01 (Short NAV protection)				//  PROT_CTRL(17:16) -- 00 (None)				// 	PROT_RATE(15:0)  -- 0x4004 (OFDM 24M)				Protect[2] = 0x01744004;					// MM40_PROT_CFG				//	Reserved (31:27)				// 	PROT_TXOP(25:20) -- 111111				//	PROT_NAV(19:18)  -- 01 (Short NAV protection)				//  PROT_CTRL(17:16) -- 00 (None) 				// 	PROT_RATE(15:0)  -- 0x4084 (duplicate OFDM 24M)				Protect[3] = 0x03f44084;				// CF20_PROT_CFG				//	Reserved (31:27)				// 	PROT_TXOP(25:20) -- 010111				//	PROT_NAV(19:18)  -- 01 (Short NAV protection)				//  PROT_CTRL(17:16) -- 00 (None)				// 	PROT_RATE(15:0)  -- 0x4004 (OFDM 24M)				Protect[4] = 0x01744004;				// CF40_PROT_CFG				//	Reserved (31:27)				// 	PROT_TXOP(25:20) -- 111111				//	PROT_NAV(19:18)  -- 01 (Short NAV protection)				//  PROT_CTRL(17:16) -- 00 (None)				// 	PROT_RATE(15:0)  -- 0x4084 (duplicate OFDM 24M)				Protect[5] = 0x03f44084;

⌨️ 快捷键说明

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