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

📄 ar5212_attach.c

📁 Atheros wifi driver source code
💻 C
📖 第 1 页 / 共 2 页
字号:
				break;			}			if (IS_2413(ah)) {		/* Griffin */				AH_PRIVATE(ah)->ah_analog5GhzRev = 0x51;				break;			}			if (IS_5413(ah)) {		/* Eagle */					AH_PRIVATE(ah)->ah_analog5GhzRev = 0x62;				break;			}		}#ifdef AH_DEBUG		HALDEBUG(ah, "%s: 5G Radio Chip Rev 0x%02X is not supported by "			"this driver\n", __func__,			AH_PRIVATE(ah)->ah_analog5GhzRev);		ecode = HAL_ENOTSUPP;		goto bad;#endif	}	if (!IS_5413(ah) && IS_5112(ah) && IS_RAD5112_REV1(ah)) {		HALDEBUG(ah, "%s: 5112 Rev 1 is not supported by this "			"driver (analog5GhzRev 0x%x)\n", __func__,			AH_PRIVATE(ah)->ah_analog5GhzRev);		ecode = HAL_ENOTSUPP;		goto bad;	}	ecode = AH_PRIVATE(ah)->ah_eepromAttach(ah);	if (ecode != HAL_OK)		goto bad;	/*	 * Got everything we need now to setup the capabilities.	 */	if (!ar5212FillCapabilityInfo(ah)) {		HALDEBUG(ah, "%s:failed ar5212FillCapabilityInfo\n", __func__);		ecode = HAL_EEREAD;		goto bad;	}		/* ah_regdomain is populated by ar5212FillCapabilityInfo() with Owl */	AH_PRIVATE(ah)->ah_currentRD = ahp->ah_regdomain;			/*	 * If Bmode and AR5212, verify 2.4 analog exists.	 * Call this after parsing the capabilities info because	 * the 5416's data is in a different form. 	 */	if (ahp->ah_Bmode &&	    (AH_PRIVATE(ah)->ah_analog5GhzRev & 0xF0) == AR_RAD5111_SREV_MAJOR) {		/*		 * Set correct Baseband to analog shift		 * setting to access analog chips.		 */		OS_REG_WRITE(ah, AR_PHY(0), 0x00004007);		OS_DELAY(2000);		AH_PRIVATE(ah)->ah_analog2GhzRev = ar5212GetRadioRev(ah);		/* Set baseband for 5GHz chip */		OS_REG_WRITE(ah, AR_PHY(0), 0x00000007);		OS_DELAY(2000);		if ((AH_PRIVATE(ah)->ah_analog2GhzRev & 0xF0) != AR_RAD2111_SREV_MAJOR) {			HALDEBUG(ah, "%s: 2G Radio Chip Rev 0x%02X is not "				"supported by this driver\n", __func__,				AH_PRIVATE(ah)->ah_analog2GhzRev);			ecode = HAL_ENOTSUPP;			goto bad;		}	}	/*	 * Got everything we need now to setup the capabilities.	 */	if (!ar5212FillCapabilityInfo(ah)) {		HALDEBUG(ah, "%s:failed ar5212FillCapabilityInfo\n", __func__);		ecode = HAL_EEREAD;		goto bad;	}	rfStatus = AH_FALSE;	if (IS_5413(ah)) {#ifdef AH_SUPPORT_5413		rfStatus = ar5413RfAttach(ah, &ecode);#else		ecode = HAL_ENOTSUPP;#endif	}	else if (IS_2413(ah))#ifdef AH_SUPPORT_2413		rfStatus = ar2413RfAttach(ah, &ecode);#else		ecode = HAL_ENOTSUPP;#endif	else if (IS_5112(ah))#ifdef AH_SUPPORT_5112		rfStatus = ar5112RfAttach(ah, &ecode);#else		ecode = HAL_ENOTSUPP;#endif	else#ifdef AH_SUPPORT_5111		rfStatus = ar5111RfAttach(ah, &ecode);#else		ecode = HAL_ENOTSUPP;#endif	if (!rfStatus) {		HALDEBUG(ah, "%s: RF setup failed, status %u\n",			__func__, ecode);		goto bad;	}	/* Initialize gain ladder thermal calibration structure */	ar5212InitializeGainValues(ah);	HALDEBUG(ah, "%s: return ah %p\n", __func__, ah);	ar5212AniSetup(ah);	/* setup 5212-specific ANI tables */	ar5212AniAttach(ah);	/* Setup of Radar/AR structures happens in ath_hal_initchannels*/	/* XXX EAR stuff goes here */	return ah;bad:	if (ahp)		ar5212Detach((struct ath_hal *) ahp);	if (status)		*status = ecode;	return AH_NULL;}voidar5212Detach(struct ath_hal *ah){	HALDEBUG(ah, "%s: ah %p\n", __func__, ah);	HALASSERT(ah != AH_NULL);	HALASSERT(ah->ah_magic == AR5212_MAGIC);	/* XXX EEPROM allocated state */	ar5212AniDetach(ah);	ar5212RfDetach(ah);	ar5212SetPowerMode(ah, HAL_PM_FULL_SLEEP, AH_TRUE);	if (AH_PRIVATE(ah)->ah_eepromDetach != AH_NULL)		AH_PRIVATE(ah)->ah_eepromDetach(ah);#if 0#endif	if (ah == AH_NULL)		return;	ath_hal_free(ah);	return;}HAL_BOOLar5212ChipTest(struct ath_hal *ah){	u_int32_t regAddr[2] = { AR_STA_ID0, AR_PHY_BASE+(8 << 2) };	u_int32_t regHold[2];	u_int32_t patternData[4] =	    { 0x55555555, 0xaaaaaaaa, 0x66666666, 0x99999999 };	int i, j;	/* Test PHY & MAC registers */	for (i = 0; i < 2; i++) {		u_int32_t addr = regAddr[i];		u_int32_t wrData, rdData;		regHold[i] = OS_REG_READ(ah, addr);		for (j = 0; j < 0x100; j++) {			wrData = (j << 16) | j;			OS_REG_WRITE(ah, addr, wrData);			rdData = OS_REG_READ(ah, addr);			if (rdData != wrData) {				HALDEBUG(ah,"%s: address test failed addr: 0x%08x - wr:0x%08x != rd:0x%08x\n",				__func__, addr, wrData, rdData);				return AH_FALSE;			}		}		for (j = 0; j < 4; j++) {			wrData = patternData[j];			OS_REG_WRITE(ah, addr, wrData);			rdData = OS_REG_READ(ah, addr);			if (wrData != rdData) {				HALDEBUG(ah,"%s: address test failed addr: 0x%08x - wr:0x%08x != rd:0x%08x\n",					__func__, addr, wrData, rdData);				return AH_FALSE;			}		}		OS_REG_WRITE(ah, regAddr[i], regHold[i]);	}	OS_DELAY(100);	return AH_TRUE;}/* * Store the channel edges for the requested operational mode */HAL_BOOLar5212GetChannelEdges(struct ath_hal *ah,	u_int16_t flags, u_int16_t *low, u_int16_t *high){	if (flags & CHANNEL_5GHZ) {		*low = 4915;		*high = 6100;		return AH_TRUE;	}	if ((flags & CHANNEL_2GHZ) && AH5212(ah)->ah_Bmode) {		*low = 2312;		*high = 2732;		return AH_TRUE;	}	return AH_FALSE;}static HAL_BOOLar5212GetChipPowerLimits(struct ath_hal *ah, HAL_CHANNEL *chans, u_int32_t nchans){	struct ath_hal_5212 *ahp = AH5212(ah);	return ahp->ah_rfHal.getChipPowerLim(ah, chans, nchans);}/* * Fill all software cached or static hardware state information. * Return failure if capabilities are to come from EEPROM and * cannot be read. */HAL_BOOLar5212FillCapabilityInfo(struct ath_hal *ah){#define	AR_KEYTABLE_SIZE	128#define	IS_GRIFFIN_LITE(ah) \    (AH_PRIVATE(ah)->ah_macVersion == AR_SREV_VERSION_GRIFFIN && \     AH_PRIVATE(ah)->ah_macRev == AR_SREV_GRIFFIN_LITE)#define	IS_COBRA(ah) \    (AH_PRIVATE(ah)->ah_macVersion == AR_SREV_VERSION_COBRA)#define IS_2112(ah) \	((AH_PRIVATE(ah)->ah_analog5GhzRev & 0xF0) == AR_RAD2112_SREV_MAJOR)#define IS_2G_RADIO(ah) (IS_2112(ah))	struct ath_hal_5212 *ahp = AH5212(ah);	struct ath_hal_private *ahpriv = AH_PRIVATE(ah);	HAL_CAPABILITIES *pCap = &ahpriv->ah_caps;	u_int16_t capField = 0;	/* The routine below gets common Eeprom info that is stored	 * in a chip specific eeprom layout 	 */	if ( !ahpriv->ah_getEepromCapabilityInfo(ah, &capField)) {		HALDEBUG(ah, "%s: unable to get chip specific eeprom capabilities\n", __func__);		return AH_FALSE;		}	if (IS_2G_RADIO(ah)) {		HALDEBUG(ah,"%s 2Ghz radio\n",__func__);		ahp->ah_Amode = AH_FALSE;	}#if 0	/* Read the capability EEPROM location */	capField = 0;	if (ahp->ah_eeversion >= AR_EEPROM_VER5_1 &&	    !ath_hal_eepromRead(ah, AR_EEPROM_CAPABILITIES_OFFSET, &capField)) {		HALDEBUG(ah, "%s: unable to read caps from eeprom\n", __func__);		return AH_FALSE;	}			if (capField == 0 && IS_GRIFFIN_LITE(ah)) {		/*		 * WAR for griffin-lite cards with unprogrammed capabilities.		 */		capField = AR_EEPROM_EEPCAP_COMPRESS_DIS			 | AR_EEPROM_EEPCAP_FASTFRAME_DIS			 ;		ahp->ah_turbo5Disable = AH_TRUE;		ahp->ah_turbo2Disable = AH_TRUE;		HALDEBUG(ah, "%s: override caps for griffin-lite, "			"now 0x%x (+no turbo)\n", __func__, capField);	}#endif 	/* Modify reg domain on newer cards that need to work with older sw */	if (ahpriv->ah_opmode != HAL_M_HOSTAP &&	    ahpriv->ah_subvendorid == AR_SUBVENDOR_ID_NEW_A) {		if (ahpriv->ah_currentRD == 0x64 ||		    ahpriv->ah_currentRD == 0x65)			ahpriv->ah_currentRD += 5;		else if (ahpriv->ah_currentRD == 0x41)			ahpriv->ah_currentRD = 0x43;		HALDEBUG(ah, "%s: regdomain mapped to 0x%x\n",			__func__, ahpriv->ah_currentRD);	}#if 0	/* Construct wireless mode from EEPROM */	pCap->halWirelessModes = 0;	if (ahp->ah_Amode) {		pCap->halWirelessModes |= HAL_MODE_11A;		if (!ahp->ah_turbo5Disable)			pCap->halWirelessModes |= HAL_MODE_TURBO;	}	if (ahp->ah_Bmode)		pCap->halWirelessModes |= HAL_MODE_11B;	if (ahp->ah_Gmode &&	    ahpriv->ah_subvendorid != AR_SUBVENDOR_ID_NOG) {		pCap->halWirelessModes |= HAL_MODE_11G;		if (!ahp->ah_turbo2Disable)			pCap->halWirelessModes |= HAL_MODE_108G;	}#endif	pCap->halLow2GhzChan = 2312;	if (IS_5112(ah) || IS_2413(ah) || IS_5413(ah))		pCap->halHigh2GhzChan = 2500;	else		pCap->halHigh2GhzChan = 2732;	pCap->halLow5GhzChan = 4915;	//pCap->halLow5GhzChan = 4920;	pCap->halHigh5GhzChan = 6100;	pCap->halCipherCkipSupport = AH_FALSE;	pCap->halCipherTkipSupport = AH_TRUE;	pCap->halCipherAesCcmSupport =		(!(capField & AR_EEPROM_EEPCAP_AES_DIS) &&		 ((AH_PRIVATE(ah)->ah_macVersion > AR_SREV_VERSION_VENICE) ||		  ((AH_PRIVATE(ah)->ah_macVersion == AR_SREV_VERSION_VENICE) &&		   (AH_PRIVATE(ah)->ah_macRev >= AR_SREV_VERSION_OAHU))));	pCap->halMicCkipSupport    = AH_FALSE;	pCap->halMicTkipSupport    = AH_TRUE;	pCap->halMicAesCcmSupport  = !(capField & AR_EEPROM_EEPCAP_AES_DIS);	pCap->halChanSpreadSupport = AH_TRUE;	pCap->halSleepAfterBeaconBroken = AH_TRUE;	if ((ahpriv->ah_macRev > 1) || IS_COBRA(ah)) {		pCap->halCompressSupport   =			!(capField & AR_EEPROM_EEPCAP_COMPRESS_DIS) &&			(pCap->halWirelessModes & (HAL_MODE_11A|HAL_MODE_11G)) != 0;		pCap->halBurstSupport =			!(capField & AR_EEPROM_EEPCAP_BURST_DIS);		pCap->halFastFramesSupport =			!(capField & AR_EEPROM_EEPCAP_FASTFRAME_DIS) &&			(pCap->halWirelessModes & (HAL_MODE_11A|HAL_MODE_11G)) != 0;		pCap->halChapTuningSupport = AH_TRUE;		pCap->halTurboPrimeSupport = AH_TRUE;			pCap->halHTSupport = AH_TRUE;	}	pCap->halTurboGSupport = pCap->halWirelessModes & HAL_MODE_108G;	/* Give XR support unless both disable bits are set */	pCap->halXrSupport = !(ahp->ah_disableXr5 && ahp->ah_disableXr2);	pCap->halPSPollBroken = AH_TRUE;	/* XXX fixed in later revs? */	pCap->halVEOLSupport = AH_TRUE;	pCap->halBssIdMaskSupport = AH_TRUE;	pCap->halMcastKeySrchSupport = AH_TRUE;	if ((ahpriv->ah_macVersion == AR_SREV_VERSION_VENICE &&	     ahpriv->ah_macRev == 8) ||	    ahpriv->ah_macVersion > AR_SREV_VERSION_VENICE)		pCap->halTsfAddSupport = AH_TRUE;	if (capField & AR_EEPROM_EEPCAP_MAXQCU)		pCap->halTotalQueues = MS(capField, AR_EEPROM_EEPCAP_MAXQCU);	else		pCap->halTotalQueues = HAL_NUM_TX_QUEUES;	if (capField & AR_EEPROM_EEPCAP_KC_ENTRIES)		pCap->halKeyCacheSize =			1 << MS(capField, AR_EEPROM_EEPCAP_KC_ENTRIES);	else		pCap->halKeyCacheSize = AR_KEYTABLE_SIZE;	if (IS_5112(ah)) {		pCap->halChanHalfRate = AH_TRUE;		pCap->halChanQuarterRate = AH_TRUE;	} else {		pCap->halChanHalfRate = AH_FALSE;		pCap->halChanQuarterRate = AH_FALSE;	}#if 0	if (ahp->ah_rfKill &&	    ath_hal_eepromRead(ah, AR_EEPROM_RFSILENT, &ahpriv->ah_rfsilent)) {	    		/* NB: enabled by default */		ahpriv->ah_rfkillEnabled = AH_TRUE;		pCap->halRfSilentSupport = AH_TRUE;	}#endif	return AH_TRUE;#undef IS_COBRA#undef IS_GRIFFIN_LITE#undef AR_KEYTABLE_SIZE}static HAL_BOOLar5212DummyStartTxDma(struct ath_hal *ah, u_int q){	HAL_CHANNEL hchan;	ar5212RadarWait(ah,&hchan);	return AH_TRUE;}voidar5212TxEnable(struct ath_hal *ah,HAL_BOOL enable){	if (enable == AH_TRUE) 		ah->ah_startTxDma = ar5212StartTxDma;	else		ah->ah_startTxDma = ar5212DummyStartTxDma;}#endif /* AH_SUPPORT_AR5212 */

⌨️ 快捷键说明

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