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

📄 ar5211_attach.c.svn-base

📁 最新之atheros芯片driver source code, 基于linux操作系统,內含atheros芯片HAL全部代码
💻 SVN-BASE
📖 第 1 页 / 共 2 页
字号:
/* * Copyright (c) 2002-2008 Sam Leffler, Errno Consulting * Copyright (c) 2002-2006 Atheros Communications, Inc. * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * $Id: ar5211_attach.c,v 1.11 2008/11/27 22:29:52 sam Exp $ */#include "opt_ah.h"#include "ah.h"#include "ah_internal.h"#include "ah_devid.h"#include "ar5211/ar5211.h"#include "ar5211/ar5211reg.h"#include "ar5211/ar5211phy.h"#include "ah_eeprom_v3.h"static HAL_BOOL ar5211GetChannelEdges(struct ath_hal *ah,		uint16_t flags, uint16_t *low, uint16_t *high);static HAL_BOOL ar5211GetChipPowerLimits(struct ath_hal *ah,		HAL_CHANNEL *chans, uint32_t nchans);static const struct ath_hal_private ar5211hal = {{	.ah_magic			= AR5211_MAGIC,	.ah_abi				= HAL_ABI_VERSION,	.ah_countryCode			= CTRY_DEFAULT,	.ah_getRateTable		= ar5211GetRateTable,	.ah_detach			= ar5211Detach,	/* Reset Functions */	.ah_reset			= ar5211Reset,	.ah_phyDisable			= ar5211PhyDisable,	.ah_disable			= ar5211Disable,	.ah_setPCUConfig		= ar5211SetPCUConfig,	.ah_perCalibration		= ar5211PerCalibration,	.ah_perCalibrationN		= ar5211PerCalibrationN,	.ah_resetCalValid		= ar5211ResetCalValid,	.ah_setTxPowerLimit		= ar5211SetTxPowerLimit,	.ah_getChanNoise		= ath_hal_getChanNoise,	/* Transmit functions */	.ah_updateTxTrigLevel		= ar5211UpdateTxTrigLevel,	.ah_setupTxQueue		= ar5211SetupTxQueue,	.ah_setTxQueueProps             = ar5211SetTxQueueProps,	.ah_getTxQueueProps             = ar5211GetTxQueueProps,	.ah_releaseTxQueue		= ar5211ReleaseTxQueue,	.ah_resetTxQueue		= ar5211ResetTxQueue,	.ah_getTxDP			= ar5211GetTxDP,	.ah_setTxDP			= ar5211SetTxDP,	.ah_numTxPending		= ar5211NumTxPending,	.ah_startTxDma			= ar5211StartTxDma,	.ah_stopTxDma			= ar5211StopTxDma,	.ah_setupTxDesc			= ar5211SetupTxDesc,	.ah_setupXTxDesc		= ar5211SetupXTxDesc,	.ah_fillTxDesc			= ar5211FillTxDesc,	.ah_procTxDesc			= ar5211ProcTxDesc,	.ah_getTxIntrQueue		= ar5211GetTxIntrQueue,	.ah_reqTxIntrDesc 		= ar5211IntrReqTxDesc,	/* RX Functions */	.ah_getRxDP			= ar5211GetRxDP,	.ah_setRxDP			= ar5211SetRxDP,	.ah_enableReceive		= ar5211EnableReceive,	.ah_stopDmaReceive		= ar5211StopDmaReceive,	.ah_startPcuReceive		= ar5211StartPcuReceive,	.ah_stopPcuReceive		= ar5211StopPcuReceive,	.ah_setMulticastFilter		= ar5211SetMulticastFilter,	.ah_setMulticastFilterIndex	= ar5211SetMulticastFilterIndex,	.ah_clrMulticastFilterIndex	= ar5211ClrMulticastFilterIndex,	.ah_getRxFilter			= ar5211GetRxFilter,	.ah_setRxFilter			= ar5211SetRxFilter,	.ah_setupRxDesc			= ar5211SetupRxDesc,	.ah_procRxDesc			= ar5211ProcRxDesc,	.ah_rxMonitor			= ar5211AniPoll,	.ah_procMibEvent		= ar5211MibEvent,	/* Misc Functions */	.ah_getCapability		= ar5211GetCapability,	.ah_setCapability		= ar5211SetCapability,	.ah_getDiagState		= ar5211GetDiagState,	.ah_getMacAddress		= ar5211GetMacAddress,	.ah_setMacAddress		= ar5211SetMacAddress,	.ah_getBssIdMask		= ar5211GetBssIdMask,	.ah_setBssIdMask		= ar5211SetBssIdMask,	.ah_setRegulatoryDomain		= ar5211SetRegulatoryDomain,	.ah_setLedState			= ar5211SetLedState,	.ah_writeAssocid		= ar5211WriteAssocid,	.ah_gpioCfgInput		= ar5211GpioCfgInput,	.ah_gpioCfgOutput		= ar5211GpioCfgOutput,	.ah_gpioGet			= ar5211GpioGet,	.ah_gpioSet			= ar5211GpioSet,	.ah_gpioSetIntr			= ar5211GpioSetIntr,	.ah_getTsf32			= ar5211GetTsf32,	.ah_getTsf64			= ar5211GetTsf64,	.ah_resetTsf			= ar5211ResetTsf,	.ah_detectCardPresent		= ar5211DetectCardPresent,	.ah_updateMibCounters		= ar5211UpdateMibCounters,	.ah_getRfGain			= ar5211GetRfgain,	.ah_getDefAntenna		= ar5211GetDefAntenna,	.ah_setDefAntenna		= ar5211SetDefAntenna,	.ah_getAntennaSwitch		= ar5211GetAntennaSwitch,	.ah_setAntennaSwitch		= ar5211SetAntennaSwitch,	.ah_setSifsTime			= ar5211SetSifsTime,	.ah_getSifsTime			= ar5211GetSifsTime,	.ah_setSlotTime			= ar5211SetSlotTime,	.ah_getSlotTime			= ar5211GetSlotTime,	.ah_setAckTimeout		= ar5211SetAckTimeout,	.ah_getAckTimeout		= ar5211GetAckTimeout,	.ah_setAckCTSRate		= ar5211SetAckCTSRate,	.ah_getAckCTSRate		= ar5211GetAckCTSRate,	.ah_setCTSTimeout		= ar5211SetCTSTimeout,	.ah_getCTSTimeout		= ar5211GetCTSTimeout,	.ah_setDecompMask               = ar5211SetDecompMask,	.ah_setCoverageClass            = ar5211SetCoverageClass,	/* Key Cache Functions */	.ah_getKeyCacheSize		= ar5211GetKeyCacheSize,	.ah_resetKeyCacheEntry		= ar5211ResetKeyCacheEntry,	.ah_isKeyCacheEntryValid	= ar5211IsKeyCacheEntryValid,	.ah_setKeyCacheEntry		= ar5211SetKeyCacheEntry,	.ah_setKeyCacheEntryMac		= ar5211SetKeyCacheEntryMac,	/* Power Management Functions */	.ah_setPowerMode		= ar5211SetPowerMode,	.ah_getPowerMode		= ar5211GetPowerMode,	/* Beacon Functions */	.ah_setBeaconTimers		= ar5211SetBeaconTimers,	.ah_beaconInit			= ar5211BeaconInit,	.ah_setStationBeaconTimers	= ar5211SetStaBeaconTimers,	.ah_resetStationBeaconTimers	= ar5211ResetStaBeaconTimers,	/* Interrupt Functions */	.ah_isInterruptPending		= ar5211IsInterruptPending,	.ah_getPendingInterrupts	= ar5211GetPendingInterrupts,	.ah_getInterrupts		= ar5211GetInterrupts,	.ah_setInterrupts		= ar5211SetInterrupts },	.ah_getChannelEdges		= ar5211GetChannelEdges,	.ah_getWirelessModes		= ar5211GetWirelessModes,	.ah_eepromRead			= ar5211EepromRead,#ifdef AH_SUPPORT_WRITE_EEPROM	.ah_eepromWrite			= ar5211EepromWrite,#endif	.ah_gpioCfgInput		= ar5211GpioCfgInput,	.ah_gpioCfgOutput		= ar5211GpioCfgOutput,	.ah_gpioGet			= ar5211GpioGet,	.ah_gpioSet			= ar5211GpioSet,	.ah_gpioSetIntr			= ar5211GpioSetIntr,	.ah_getChipPowerLimits		= ar5211GetChipPowerLimits,};static HAL_BOOL ar5211ChipTest(struct ath_hal *);static HAL_BOOL ar5211FillCapabilityInfo(struct ath_hal *ah);/* * Return the revsion id for the radio chip.  This * fetched via the PHY. */static uint32_tar5211GetRadioRev(struct ath_hal *ah){	uint32_t val;	int i;	OS_REG_WRITE(ah, (AR_PHY_BASE + (0x34 << 2)), 0x00001c16);	for (i = 0; i < 8; i++)		OS_REG_WRITE(ah, (AR_PHY_BASE + (0x20 << 2)), 0x00010000);	val = (OS_REG_READ(ah, AR_PHY_BASE + (256 << 2)) >> 24) & 0xff;	val = ((val & 0xf0) >> 4) | ((val & 0x0f) << 4);	return ath_hal_reverseBits(val, 8);}/* * Attach for an AR5211 part. */struct ath_hal *ar5211Attach(uint16_t devid, HAL_SOFTC sc,	HAL_BUS_TAG st, HAL_BUS_HANDLE sh, HAL_STATUS *status){#define	N(a)	(sizeof(a)/sizeof(a[0]))	struct ath_hal_5211 *ahp;	struct ath_hal *ah;	uint32_t val;	uint16_t eeval;	HAL_STATUS ecode;	HALDEBUG(AH_NULL, HAL_DEBUG_ATTACH, "%s: sc %p st %p sh %p\n",	    __func__, sc, (void*) st, (void*) sh);	/* NB: memory is returned zero'd */	ahp = ath_hal_malloc(sizeof (struct ath_hal_5211));	if (ahp == AH_NULL) {		HALDEBUG(AH_NULL, HAL_DEBUG_ANY,		    "%s: cannot allocate memory for state block\n", __func__);		ecode = HAL_ENOMEM;		goto bad;	}	ah = &ahp->ah_priv.h;	/* set initial values */	OS_MEMCPY(&ahp->ah_priv, &ar5211hal, sizeof(struct ath_hal_private));	ah->ah_sc = sc;	ah->ah_st = st;	ah->ah_sh = sh;	ah->ah_devid = devid;			/* NB: for AH_DEBUG_ALQ */	AH_PRIVATE(ah)->ah_devid = devid;	AH_PRIVATE(ah)->ah_subvendorid = 0;	/* XXX */	AH_PRIVATE(ah)->ah_powerLimit = MAX_RATE_POWER;	AH_PRIVATE(ah)->ah_tpScale = HAL_TP_SCALE_MAX;	/* no scaling */	ahp->ah_diversityControl = HAL_ANT_VARIABLE;	ahp->ah_staId1Defaults = 0;	ahp->ah_rssiThr = INIT_RSSI_THR;	ahp->ah_sifstime = (u_int) -1;	ahp->ah_slottime = (u_int) -1;	ahp->ah_acktimeout = (u_int) -1;	ahp->ah_ctstimeout = (u_int) -1;	if (!ar5211ChipReset(ah, AH_FALSE)) {	/* reset chip */		HALDEBUG(ah, HAL_DEBUG_ANY, "%s: chip reset failed\n", __func__);		ecode = HAL_EIO;		goto bad;	}	if (AH_PRIVATE(ah)->ah_devid == AR5211_FPGA11B) {		/* set it back to OFDM mode to be able to read analog rev id */		OS_REG_WRITE(ah, AR5211_PHY_MODE, AR5211_PHY_MODE_OFDM);		OS_REG_WRITE(ah, AR_PHY_PLL_CTL, AR_PHY_PLL_CTL_44);		OS_DELAY(1000);	}	/* Read Revisions from Chips */	val = OS_REG_READ(ah, AR_SREV) & AR_SREV_ID_M;	AH_PRIVATE(ah)->ah_macVersion = val >> AR_SREV_ID_S;	AH_PRIVATE(ah)->ah_macRev = val & AR_SREV_REVISION_M;	if (AH_PRIVATE(ah)->ah_macVersion < AR_SREV_VERSION_MAUI_2 ||	    AH_PRIVATE(ah)->ah_macVersion > AR_SREV_VERSION_OAHU) {		HALDEBUG(ah, HAL_DEBUG_ANY,		    "%s: Mac Chip Rev 0x%x is not supported by this driver\n",		    __func__, AH_PRIVATE(ah)->ah_macVersion);		ecode = HAL_ENOTSUPP;		goto bad;	}

⌨️ 快捷键说明

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