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

📄 ar5210_misc.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-2004 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: ar5210_misc.c,v 1.6 2008/11/27 22:29:37 sam Exp $ */#include "opt_ah.h"#include "ah.h"#include "ah_internal.h"#include "ar5210/ar5210.h"#include "ar5210/ar5210reg.h"#include "ar5210/ar5210phy.h"#include "ah_eeprom_v1.h"#define	AR_NUM_GPIO	6		/* 6 GPIO bits */#define	AR_GPIOD_MASK	0x2f		/* 6-bit mask */voidar5210GetMacAddress(struct ath_hal *ah, uint8_t *mac){	struct ath_hal_5210 *ahp = AH5210(ah);	OS_MEMCPY(mac, ahp->ah_macaddr, IEEE80211_ADDR_LEN);}HAL_BOOLar5210SetMacAddress(struct ath_hal *ah, const uint8_t *mac){	struct ath_hal_5210 *ahp = AH5210(ah);	OS_MEMCPY(ahp->ah_macaddr, mac, IEEE80211_ADDR_LEN);	return AH_TRUE;}voidar5210GetBssIdMask(struct ath_hal *ah, uint8_t *mask){	static const uint8_t ones[IEEE80211_ADDR_LEN] =		{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };	OS_MEMCPY(mask, ones, IEEE80211_ADDR_LEN);}HAL_BOOLar5210SetBssIdMask(struct ath_hal *ah, const uint8_t *mask){	return AH_FALSE;}/* * Read 16 bits of data from the specified EEPROM offset. */HAL_BOOLar5210EepromRead(struct ath_hal *ah, u_int off, uint16_t *data){	(void) OS_REG_READ(ah, AR_EP_AIR(off));	/* activate read op */	if (!ath_hal_wait(ah, AR_EP_STA,	    AR_EP_STA_RDCMPLT | AR_EP_STA_RDERR, AR_EP_STA_RDCMPLT)) {		HALDEBUG(ah, HAL_DEBUG_ANY, "%s: read failed for entry 0x%x\n",		    __func__, AR_EP_AIR(off));		return AH_FALSE;	}	*data = OS_REG_READ(ah, AR_EP_RDATA) & 0xffff;	return AH_TRUE;}#ifdef AH_SUPPORT_WRITE_EEPROM/* * Write 16 bits of data to the specified EEPROM offset. */HAL_BOOLar5210EepromWrite(struct ath_hal *ah, u_int off, uint16_t data){	return AH_FALSE;}#endif /* AH_SUPPORT_WRITE_EEPROM *//* * Attempt to change the cards operating regulatory domain to the given value */HAL_BOOLar5210SetRegulatoryDomain(struct ath_hal *ah,	uint16_t regDomain, HAL_STATUS *status){	HAL_STATUS ecode;	if (AH_PRIVATE(ah)->ah_currentRD == regDomain) {		ecode = HAL_EINVAL;		goto bad;	}	/*	 * Check if EEPROM is configured to allow this; must	 * be a proper version and the protection bits must	 * permit re-writing that segment of the EEPROM.	 */	if (ath_hal_eepromGetFlag(ah, AR_EEP_WRITEPROTECT)) {		ecode = HAL_EEWRITE;		goto bad;	}	ecode = HAL_EIO;		/* disallow all writes */bad:	if (status)		*status = ecode;	return AH_FALSE;}/* * Return the wireless modes (a,b,g,t) supported by hardware. * * This value is what is actually supported by the hardware * and is unaffected by regulatory/country code settings. * */u_intar5210GetWirelessModes(struct ath_hal *ah){	/* XXX could enable turbo mode but can't do all rates */	return HAL_MODE_11A;}/* * Called if RfKill is supported (according to EEPROM).  Set the interrupt and * GPIO values so the ISR and can disable RF on a switch signal */voidar5210EnableRfKill(struct ath_hal *ah){	uint16_t rfsilent = AH_PRIVATE(ah)->ah_rfsilent;	int select = MS(rfsilent, AR_EEPROM_RFSILENT_GPIO_SEL);	int polarity = MS(rfsilent, AR_EEPROM_RFSILENT_POLARITY);	/*	 * If radio disable switch connection to GPIO bit 0 is enabled	 * program GPIO interrupt.	 * If rfkill bit on eeprom is 1, setupeeprommap routine has already	 * verified that it is a later version of eeprom, it has a place for	 * rfkill bit and it is set to 1, indicating that GPIO bit 0 hardware	 * connection is present.	 */	ar5210Gpio0SetIntr(ah, select, (ar5210GpioGet(ah, select) == polarity));}/* * Configure GPIO Output lines */HAL_BOOLar5210GpioCfgOutput(struct ath_hal *ah, uint32_t gpio){	HALASSERT(gpio < AR_NUM_GPIO);	OS_REG_WRITE(ah, AR_GPIOCR, 		  (OS_REG_READ(ah, AR_GPIOCR) &~ AR_GPIOCR_ALL(gpio))		| AR_GPIOCR_OUT1(gpio));	return AH_TRUE;}/* * Configure GPIO Input lines */HAL_BOOLar5210GpioCfgInput(struct ath_hal *ah, uint32_t gpio){	HALASSERT(gpio < AR_NUM_GPIO);	OS_REG_WRITE(ah, AR_GPIOCR, 		  (OS_REG_READ(ah, AR_GPIOCR) &~ AR_GPIOCR_ALL(gpio))		| AR_GPIOCR_IN(gpio));	return AH_TRUE;}/* * Once configured for I/O - set output lines */HAL_BOOLar5210GpioSet(struct ath_hal *ah, uint32_t gpio, uint32_t val){	uint32_t reg;	HALASSERT(gpio < AR_NUM_GPIO);	reg =  OS_REG_READ(ah, AR_GPIODO);	reg &= ~(1 << gpio);	reg |= (val&1) << gpio;	OS_REG_WRITE(ah, AR_GPIODO, reg);	return AH_TRUE;}/* * Once configured for I/O - get input lines */uint32_tar5210GpioGet(struct ath_hal *ah, uint32_t gpio){	if (gpio < AR_NUM_GPIO) {		uint32_t val = OS_REG_READ(ah, AR_GPIODI);		val = ((val & AR_GPIOD_MASK) >> gpio) & 0x1;		return val;	} else  {		return 0xffffffff;	}}/* * Set the GPIO 0 Interrupt */voidar5210Gpio0SetIntr(struct ath_hal *ah, u_int gpio, uint32_t ilevel){	uint32_t val = OS_REG_READ(ah, AR_GPIOCR);	/* Clear the bits that we will modify. */	val &= ~(AR_GPIOCR_INT_SEL(gpio) | AR_GPIOCR_INT_SELH | AR_GPIOCR_INT_ENA |			AR_GPIOCR_ALL(gpio));	val |= AR_GPIOCR_INT_SEL(gpio) | AR_GPIOCR_INT_ENA;	if (ilevel)		val |= AR_GPIOCR_INT_SELH;	/* Don't need to change anything for low level interrupt. */	OS_REG_WRITE(ah, AR_GPIOCR, val);	/* Change the interrupt mask. */	ar5210SetInterrupts(ah, AH5210(ah)->ah_maskReg | HAL_INT_GPIO);}/* * Change the LED blinking pattern to correspond to the connectivity */voidar5210SetLedState(struct ath_hal *ah, HAL_LED_STATE state){	uint32_t val;	val = OS_REG_READ(ah, AR_PCICFG);	switch (state) {	case HAL_LED_INIT:		val &= ~(AR_PCICFG_LED_PEND | AR_PCICFG_LED_ACT);		break;	case HAL_LED_RUN:		/* normal blink when connected */		val &= ~AR_PCICFG_LED_PEND;		val |= AR_PCICFG_LED_ACT;		break;	default:		val |= AR_PCICFG_LED_PEND;		val &= ~AR_PCICFG_LED_ACT;		break;	}	OS_REG_WRITE(ah, AR_PCICFG, val);}/* * Return 1 or 2 for the corresponding antenna that is in use */u_intar5210GetDefAntenna(struct ath_hal *ah){	uint32_t val = OS_REG_READ(ah, AR_STA_ID1);	return (val & AR_STA_ID1_DEFAULT_ANTENNA ?  2 : 1);}voidar5210SetDefAntenna(struct ath_hal *ah, u_int antenna){	uint32_t val = OS_REG_READ(ah, AR_STA_ID1);	if (antenna != (val & AR_STA_ID1_DEFAULT_ANTENNA ?  2 : 1)) {		/*		 * Antenna change requested, force a toggle of the default.		 */		OS_REG_WRITE(ah, AR_STA_ID1, val | AR_STA_ID1_DEFAULT_ANTENNA);	}}HAL_ANT_SETTINGar5210GetAntennaSwitch(struct ath_hal *ah){	return HAL_ANT_VARIABLE;}HAL_BOOLar5210SetAntennaSwitch(struct ath_hal *ah, HAL_ANT_SETTING settings){	/* XXX not sure how to fix antenna */	return (settings == HAL_ANT_VARIABLE);}/* * Change association related fields programmed into the hardware. * Writing a valid BSSID to the hardware effectively enables the hardware * to synchronize its TSF to the correct beacons and receive frames coming * from that BSSID. It is called by the SME JOIN operation. */voidar5210WriteAssocid(struct ath_hal *ah, const uint8_t *bssid, uint16_t assocId){	struct ath_hal_5210 *ahp = AH5210(ah);	/* XXX save bssid for possible re-use on reset */	OS_MEMCPY(ahp->ah_bssid, bssid, IEEE80211_ADDR_LEN);	OS_REG_WRITE(ah, AR_BSS_ID0, LE_READ_4(ahp->ah_bssid));	OS_REG_WRITE(ah, AR_BSS_ID1, LE_READ_2(ahp->ah_bssid+4) |				     ((assocId & 0x3fff)<<AR_BSS_ID1_AID_S));	if (assocId == 0)		OS_REG_SET_BIT(ah, AR_STA_ID1, AR_STA_ID1_NO_PSPOLL);

⌨️ 快捷键说明

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