xref: /freebsd/sys/dev/ath/ath_hal/ar5211/ar5211_misc.c (revision 95ee2897e98f5d444f26ed2334cc7c439f9c16c6)
16e778a7eSPedro F. Giffuni /*-
26e778a7eSPedro F. Giffuni  * SPDX-License-Identifier: ISC
36e778a7eSPedro F. Giffuni  *
459efa8b5SSam Leffler  * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting
514779705SSam Leffler  * Copyright (c) 2002-2006 Atheros Communications, Inc.
614779705SSam Leffler  *
714779705SSam Leffler  * Permission to use, copy, modify, and/or distribute this software for any
814779705SSam Leffler  * purpose with or without fee is hereby granted, provided that the above
914779705SSam Leffler  * copyright notice and this permission notice appear in all copies.
1014779705SSam Leffler  *
1114779705SSam Leffler  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
1214779705SSam Leffler  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
1314779705SSam Leffler  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
1414779705SSam Leffler  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
1514779705SSam Leffler  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
1614779705SSam Leffler  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
1714779705SSam Leffler  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1814779705SSam Leffler  */
1914779705SSam Leffler #include "opt_ah.h"
2014779705SSam Leffler 
2114779705SSam Leffler #include "ah.h"
2214779705SSam Leffler #include "ah_internal.h"
2314779705SSam Leffler 
2414779705SSam Leffler #include "ar5211/ar5211.h"
2514779705SSam Leffler #include "ar5211/ar5211reg.h"
2614779705SSam Leffler #include "ar5211/ar5211phy.h"
2714779705SSam Leffler 
2814779705SSam Leffler #include "ah_eeprom_v3.h"
2914779705SSam Leffler 
3014779705SSam Leffler #define	AR_NUM_GPIO	6		/* 6 GPIO bits */
3114779705SSam Leffler #define	AR_GPIOD_MASK	0x2f		/* 6-bit mask */
3214779705SSam Leffler 
3314779705SSam Leffler void
ar5211GetMacAddress(struct ath_hal * ah,uint8_t * mac)3414779705SSam Leffler ar5211GetMacAddress(struct ath_hal *ah, uint8_t *mac)
3514779705SSam Leffler {
3614779705SSam Leffler 	struct ath_hal_5211 *ahp = AH5211(ah);
3714779705SSam Leffler 
3814779705SSam Leffler 	OS_MEMCPY(mac, ahp->ah_macaddr, IEEE80211_ADDR_LEN);
3914779705SSam Leffler }
4014779705SSam Leffler 
4114779705SSam Leffler HAL_BOOL
ar5211SetMacAddress(struct ath_hal * ah,const uint8_t * mac)4214779705SSam Leffler ar5211SetMacAddress(struct ath_hal *ah, const uint8_t *mac)
4314779705SSam Leffler {
4414779705SSam Leffler 	struct ath_hal_5211 *ahp = AH5211(ah);
4514779705SSam Leffler 
4614779705SSam Leffler 	OS_MEMCPY(ahp->ah_macaddr, mac, IEEE80211_ADDR_LEN);
4714779705SSam Leffler 	return AH_TRUE;
4814779705SSam Leffler }
4914779705SSam Leffler 
5014779705SSam Leffler void
ar5211GetBssIdMask(struct ath_hal * ah,uint8_t * mask)5114779705SSam Leffler ar5211GetBssIdMask(struct ath_hal *ah, uint8_t *mask)
5214779705SSam Leffler {
5314779705SSam Leffler 	static const uint8_t ones[IEEE80211_ADDR_LEN] =
5414779705SSam Leffler 		{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
5514779705SSam Leffler 	OS_MEMCPY(mask, ones, IEEE80211_ADDR_LEN);
5614779705SSam Leffler }
5714779705SSam Leffler 
5814779705SSam Leffler HAL_BOOL
ar5211SetBssIdMask(struct ath_hal * ah,const uint8_t * mask)5914779705SSam Leffler ar5211SetBssIdMask(struct ath_hal *ah, const uint8_t *mask)
6014779705SSam Leffler {
6114779705SSam Leffler 	return AH_FALSE;
6214779705SSam Leffler }
6314779705SSam Leffler 
6414779705SSam Leffler /*
6514779705SSam Leffler  * Read 16 bits of data from the specified EEPROM offset.
6614779705SSam Leffler  */
6714779705SSam Leffler HAL_BOOL
ar5211EepromRead(struct ath_hal * ah,u_int off,uint16_t * data)6814779705SSam Leffler ar5211EepromRead(struct ath_hal *ah, u_int off, uint16_t *data)
6914779705SSam Leffler {
7014779705SSam Leffler 	OS_REG_WRITE(ah, AR_EEPROM_ADDR, off);
7114779705SSam Leffler 	OS_REG_WRITE(ah, AR_EEPROM_CMD, AR_EEPROM_CMD_READ);
7214779705SSam Leffler 
7314779705SSam Leffler 	if (!ath_hal_wait(ah, AR_EEPROM_STS,
7414779705SSam Leffler 	    AR_EEPROM_STS_READ_COMPLETE | AR_EEPROM_STS_READ_ERROR,
7514779705SSam Leffler 	    AR_EEPROM_STS_READ_COMPLETE)) {
7614779705SSam Leffler 		HALDEBUG(ah, HAL_DEBUG_ANY,
7714779705SSam Leffler 		    "%s: read failed for entry 0x%x\n", __func__, off);
7814779705SSam Leffler 		return AH_FALSE;
7914779705SSam Leffler 	}
8014779705SSam Leffler 	*data = OS_REG_READ(ah, AR_EEPROM_DATA) & 0xffff;
8114779705SSam Leffler 	return AH_TRUE;
8214779705SSam Leffler }
8314779705SSam Leffler 
8414779705SSam Leffler #ifdef AH_SUPPORT_WRITE_EEPROM
8514779705SSam Leffler /*
8614779705SSam Leffler  * Write 16 bits of data to the specified EEPROM offset.
8714779705SSam Leffler  */
8814779705SSam Leffler HAL_BOOL
ar5211EepromWrite(struct ath_hal * ah,u_int off,uint16_t data)8914779705SSam Leffler ar5211EepromWrite(struct ath_hal *ah, u_int off, uint16_t data)
9014779705SSam Leffler {
9114779705SSam Leffler 	return AH_FALSE;
9214779705SSam Leffler }
9314779705SSam Leffler #endif /* AH_SUPPORT_WRITE_EEPROM */
9414779705SSam Leffler 
9514779705SSam Leffler /*
9614779705SSam Leffler  * Attempt to change the cards operating regulatory domain to the given value
9714779705SSam Leffler  */
9814779705SSam Leffler HAL_BOOL
ar5211SetRegulatoryDomain(struct ath_hal * ah,uint16_t regDomain,HAL_STATUS * status)9914779705SSam Leffler ar5211SetRegulatoryDomain(struct ath_hal *ah,
10014779705SSam Leffler 	uint16_t regDomain, HAL_STATUS *status)
10114779705SSam Leffler {
10214779705SSam Leffler 	HAL_STATUS ecode;
10314779705SSam Leffler 
10414779705SSam Leffler 	if (AH_PRIVATE(ah)->ah_currentRD == regDomain) {
10514779705SSam Leffler 		ecode = HAL_EINVAL;
10614779705SSam Leffler 		goto bad;
10714779705SSam Leffler 	}
10814779705SSam Leffler 	/*
10914779705SSam Leffler 	 * Check if EEPROM is configured to allow this; must
11014779705SSam Leffler 	 * be a proper version and the protection bits must
11114779705SSam Leffler 	 * permit re-writing that segment of the EEPROM.
11214779705SSam Leffler 	 */
11314779705SSam Leffler 	if (ath_hal_eepromGetFlag(ah, AR_EEP_WRITEPROTECT)) {
11414779705SSam Leffler 		ecode = HAL_EEWRITE;
11514779705SSam Leffler 		goto bad;
11614779705SSam Leffler 	}
11714779705SSam Leffler #ifdef AH_SUPPORT_WRITE_REGDOMAIN
11814779705SSam Leffler 	if (ar5211EepromWrite(ah, AR_EEPROM_REG_DOMAIN, regDomain)) {
11914779705SSam Leffler 		HALDEBUG(ah, HAL_DEBUG_ANY,
12014779705SSam Leffler 		    "%s: set regulatory domain to %u (0x%x)\n",
12114779705SSam Leffler 		    __func__, regDomain, regDomain);
12214779705SSam Leffler 		AH_PRIVATE(ah)->ah_currentRD = regDomain;
12314779705SSam Leffler 		return AH_TRUE;
12414779705SSam Leffler 	}
12514779705SSam Leffler #endif
12614779705SSam Leffler 	ecode = HAL_EIO;
12714779705SSam Leffler bad:
12814779705SSam Leffler 	if (status)
12914779705SSam Leffler 		*status = ecode;
13014779705SSam Leffler 	return AH_FALSE;
13114779705SSam Leffler }
13214779705SSam Leffler 
13314779705SSam Leffler /*
13414779705SSam Leffler  * Return the wireless modes (a,b,g,t) supported by hardware.
13514779705SSam Leffler  *
13614779705SSam Leffler  * This value is what is actually supported by the hardware
13714779705SSam Leffler  * and is unaffected by regulatory/country code settings.
13814779705SSam Leffler  *
13914779705SSam Leffler  */
14014779705SSam Leffler u_int
ar5211GetWirelessModes(struct ath_hal * ah)14114779705SSam Leffler ar5211GetWirelessModes(struct ath_hal *ah)
14214779705SSam Leffler {
14314779705SSam Leffler 	u_int mode = 0;
14414779705SSam Leffler 
14514779705SSam Leffler 	if (ath_hal_eepromGetFlag(ah, AR_EEP_AMODE)) {
14614779705SSam Leffler 		mode = HAL_MODE_11A;
14714779705SSam Leffler 		if (!ath_hal_eepromGetFlag(ah, AR_EEP_TURBO5DISABLE))
14814779705SSam Leffler 			mode |= HAL_MODE_TURBO | HAL_MODE_108A;
14914779705SSam Leffler 	}
15014779705SSam Leffler 	if (ath_hal_eepromGetFlag(ah, AR_EEP_BMODE))
15114779705SSam Leffler 		mode |= HAL_MODE_11B;
15214779705SSam Leffler 	return mode;
15314779705SSam Leffler }
15414779705SSam Leffler 
15514779705SSam Leffler #if 0
15614779705SSam Leffler HAL_BOOL
15714779705SSam Leffler ar5211GetTurboDisable(struct ath_hal *ah)
15814779705SSam Leffler {
15914779705SSam Leffler 	return (AH5211(ah)->ah_turboDisable != 0);
16014779705SSam Leffler }
16114779705SSam Leffler #endif
16214779705SSam Leffler 
16314779705SSam Leffler /*
16414779705SSam Leffler  * Called if RfKill is supported (according to EEPROM).  Set the interrupt and
16514779705SSam Leffler  * GPIO values so the ISR and can disable RF on a switch signal
16614779705SSam Leffler  */
16714779705SSam Leffler void
ar5211EnableRfKill(struct ath_hal * ah)16814779705SSam Leffler ar5211EnableRfKill(struct ath_hal *ah)
16914779705SSam Leffler {
17014779705SSam Leffler 	uint16_t rfsilent = AH_PRIVATE(ah)->ah_rfsilent;
17114779705SSam Leffler 	int select = MS(rfsilent, AR_EEPROM_RFSILENT_GPIO_SEL);
17214779705SSam Leffler 	int polarity = MS(rfsilent, AR_EEPROM_RFSILENT_POLARITY);
17314779705SSam Leffler 
17414779705SSam Leffler 	/*
17514779705SSam Leffler 	 * Configure the desired GPIO port for input
17614779705SSam Leffler 	 * and enable baseband rf silence.
17714779705SSam Leffler 	 */
17814779705SSam Leffler 	ar5211GpioCfgInput(ah, select);
17914779705SSam Leffler 	OS_REG_SET_BIT(ah, AR_PHY_BASE, 0x00002000);
18014779705SSam Leffler 	/*
18114779705SSam Leffler 	 * If radio disable switch connection to GPIO bit x is enabled
18214779705SSam Leffler 	 * program GPIO interrupt.
18314779705SSam Leffler 	 * If rfkill bit on eeprom is 1, setupeeprommap routine has already
18414779705SSam Leffler 	 * verified that it is a later version of eeprom, it has a place for
18514779705SSam Leffler 	 * rfkill bit and it is set to 1, indicating that GPIO bit x hardware
18614779705SSam Leffler 	 * connection is present.
18714779705SSam Leffler 	 */
18814779705SSam Leffler 	ar5211GpioSetIntr(ah, select, (ar5211GpioGet(ah, select) != polarity));
18914779705SSam Leffler }
19014779705SSam Leffler 
19114779705SSam Leffler /*
19214779705SSam Leffler  * Configure GPIO Output lines
19314779705SSam Leffler  */
19414779705SSam Leffler HAL_BOOL
ar5211GpioCfgOutput(struct ath_hal * ah,uint32_t gpio,HAL_GPIO_MUX_TYPE type)195869ff02eSSam Leffler ar5211GpioCfgOutput(struct ath_hal *ah, uint32_t gpio, HAL_GPIO_MUX_TYPE type)
19614779705SSam Leffler {
19714779705SSam Leffler 	uint32_t reg;
19814779705SSam Leffler 
19914779705SSam Leffler 	HALASSERT(gpio < AR_NUM_GPIO);
20014779705SSam Leffler 
20114779705SSam Leffler 	reg =  OS_REG_READ(ah, AR_GPIOCR);
20214779705SSam Leffler 	reg &= ~(AR_GPIOCR_0_CR_A << (gpio * AR_GPIOCR_CR_SHIFT));
20314779705SSam Leffler 	reg |= AR_GPIOCR_0_CR_A << (gpio * AR_GPIOCR_CR_SHIFT);
20414779705SSam Leffler 
20514779705SSam Leffler 	OS_REG_WRITE(ah, AR_GPIOCR, reg);
20614779705SSam Leffler 	return AH_TRUE;
20714779705SSam Leffler }
20814779705SSam Leffler 
20914779705SSam Leffler /*
21014779705SSam Leffler  * Configure GPIO Input lines
21114779705SSam Leffler  */
21214779705SSam Leffler HAL_BOOL
ar5211GpioCfgInput(struct ath_hal * ah,uint32_t gpio)21314779705SSam Leffler ar5211GpioCfgInput(struct ath_hal *ah, uint32_t gpio)
21414779705SSam Leffler {
21514779705SSam Leffler 	uint32_t reg;
21614779705SSam Leffler 
21714779705SSam Leffler 	HALASSERT(gpio < AR_NUM_GPIO);
21814779705SSam Leffler 
21914779705SSam Leffler 	reg =  OS_REG_READ(ah, AR_GPIOCR);
22014779705SSam Leffler 	reg &= ~(AR_GPIOCR_0_CR_A << (gpio * AR_GPIOCR_CR_SHIFT));
22114779705SSam Leffler 	reg |= AR_GPIOCR_0_CR_N << (gpio * AR_GPIOCR_CR_SHIFT);
22214779705SSam Leffler 
22314779705SSam Leffler 	OS_REG_WRITE(ah, AR_GPIOCR, reg);
22414779705SSam Leffler 	return AH_TRUE;
22514779705SSam Leffler }
22614779705SSam Leffler 
22714779705SSam Leffler /*
22814779705SSam Leffler  * Once configured for I/O - set output lines
22914779705SSam Leffler  */
23014779705SSam Leffler HAL_BOOL
ar5211GpioSet(struct ath_hal * ah,uint32_t gpio,uint32_t val)23114779705SSam Leffler ar5211GpioSet(struct ath_hal *ah, uint32_t gpio, uint32_t val)
23214779705SSam Leffler {
23314779705SSam Leffler 	uint32_t reg;
23414779705SSam Leffler 
23514779705SSam Leffler 	HALASSERT(gpio < AR_NUM_GPIO);
23614779705SSam Leffler 
23714779705SSam Leffler 	reg =  OS_REG_READ(ah, AR_GPIODO);
23814779705SSam Leffler 	reg &= ~(1 << gpio);
23914779705SSam Leffler 	reg |= (val&1) << gpio;
24014779705SSam Leffler 
24114779705SSam Leffler 	OS_REG_WRITE(ah, AR_GPIODO, reg);
24214779705SSam Leffler 	return AH_TRUE;
24314779705SSam Leffler }
24414779705SSam Leffler 
24514779705SSam Leffler /*
24614779705SSam Leffler  * Once configured for I/O - get input lines
24714779705SSam Leffler  */
24814779705SSam Leffler uint32_t
ar5211GpioGet(struct ath_hal * ah,uint32_t gpio)24914779705SSam Leffler ar5211GpioGet(struct ath_hal *ah, uint32_t gpio)
25014779705SSam Leffler {
25114779705SSam Leffler 	if (gpio < AR_NUM_GPIO) {
25214779705SSam Leffler 		uint32_t val = OS_REG_READ(ah, AR_GPIODI);
25314779705SSam Leffler 		val = ((val & AR_GPIOD_MASK) >> gpio) & 0x1;
25414779705SSam Leffler 		return val;
25514779705SSam Leffler 	} else  {
25614779705SSam Leffler 		return 0xffffffff;
25714779705SSam Leffler 	}
25814779705SSam Leffler }
25914779705SSam Leffler 
26014779705SSam Leffler /*
26114779705SSam Leffler  * Set the GPIO 0 Interrupt (gpio is ignored)
26214779705SSam Leffler  */
26314779705SSam Leffler void
ar5211GpioSetIntr(struct ath_hal * ah,u_int gpio,uint32_t ilevel)26414779705SSam Leffler ar5211GpioSetIntr(struct ath_hal *ah, u_int gpio, uint32_t ilevel)
26514779705SSam Leffler {
26614779705SSam Leffler 	uint32_t val = OS_REG_READ(ah, AR_GPIOCR);
26714779705SSam Leffler 
26814779705SSam Leffler 	/* Clear the bits that we will modify. */
26914779705SSam Leffler 	val &= ~(AR_GPIOCR_INT_SEL0 | AR_GPIOCR_INT_SELH | AR_GPIOCR_INT_ENA |
27014779705SSam Leffler 			AR_GPIOCR_0_CR_A);
27114779705SSam Leffler 
27214779705SSam Leffler 	val |= AR_GPIOCR_INT_SEL0 | AR_GPIOCR_INT_ENA;
27314779705SSam Leffler 	if (ilevel)
27414779705SSam Leffler 		val |= AR_GPIOCR_INT_SELH;
27514779705SSam Leffler 
27614779705SSam Leffler 	/* Don't need to change anything for low level interrupt. */
27714779705SSam Leffler 	OS_REG_WRITE(ah, AR_GPIOCR, val);
27814779705SSam Leffler 
27914779705SSam Leffler 	/* Change the interrupt mask. */
28014779705SSam Leffler 	ar5211SetInterrupts(ah, AH5211(ah)->ah_maskReg | HAL_INT_GPIO);
28114779705SSam Leffler }
28214779705SSam Leffler 
28314779705SSam Leffler /*
28414779705SSam Leffler  * Change the LED blinking pattern to correspond to the connectivity
28514779705SSam Leffler  */
28614779705SSam Leffler void
ar5211SetLedState(struct ath_hal * ah,HAL_LED_STATE state)28714779705SSam Leffler ar5211SetLedState(struct ath_hal *ah, HAL_LED_STATE state)
28814779705SSam Leffler {
28914779705SSam Leffler 	static const uint32_t ledbits[8] = {
29014779705SSam Leffler 		AR_PCICFG_LEDCTL_NONE|AR_PCICFG_LEDMODE_PROP, /* HAL_LED_INIT */
29114779705SSam Leffler 		AR_PCICFG_LEDCTL_PEND|AR_PCICFG_LEDMODE_PROP, /* HAL_LED_SCAN */
29214779705SSam Leffler 		AR_PCICFG_LEDCTL_PEND|AR_PCICFG_LEDMODE_PROP, /* HAL_LED_AUTH */
29314779705SSam Leffler 		AR_PCICFG_LEDCTL_ASSOC|AR_PCICFG_LEDMODE_PROP,/* HAL_LED_ASSOC*/
29414779705SSam Leffler 		AR_PCICFG_LEDCTL_ASSOC|AR_PCICFG_LEDMODE_PROP,/* HAL_LED_RUN */
29514779705SSam Leffler 		AR_PCICFG_LEDCTL_NONE|AR_PCICFG_LEDMODE_RAND,
29614779705SSam Leffler 		AR_PCICFG_LEDCTL_NONE|AR_PCICFG_LEDMODE_RAND,
29714779705SSam Leffler 		AR_PCICFG_LEDCTL_NONE|AR_PCICFG_LEDMODE_RAND,
29814779705SSam Leffler 	};
29914779705SSam Leffler 	OS_REG_WRITE(ah, AR_PCICFG,
30014779705SSam Leffler 		(OS_REG_READ(ah, AR_PCICFG) &~
30114779705SSam Leffler 			(AR_PCICFG_LEDCTL | AR_PCICFG_LEDMODE))
30214779705SSam Leffler 		| ledbits[state & 0x7]
30314779705SSam Leffler 	);
30414779705SSam Leffler }
30514779705SSam Leffler 
30614779705SSam Leffler /*
30714779705SSam Leffler  * Change association related fields programmed into the hardware.
30814779705SSam Leffler  * Writing a valid BSSID to the hardware effectively enables the hardware
30914779705SSam Leffler  * to synchronize its TSF to the correct beacons and receive frames coming
31014779705SSam Leffler  * from that BSSID. It is called by the SME JOIN operation.
31114779705SSam Leffler  */
31214779705SSam Leffler void
ar5211WriteAssocid(struct ath_hal * ah,const uint8_t * bssid,uint16_t assocId)31314779705SSam Leffler ar5211WriteAssocid(struct ath_hal *ah, const uint8_t *bssid, uint16_t assocId)
31414779705SSam Leffler {
31514779705SSam Leffler 	struct ath_hal_5211 *ahp = AH5211(ah);
31614779705SSam Leffler 
31714779705SSam Leffler 	/* XXX save bssid for possible re-use on reset */
31814779705SSam Leffler 	OS_MEMCPY(ahp->ah_bssid, bssid, IEEE80211_ADDR_LEN);
31914779705SSam Leffler 	OS_REG_WRITE(ah, AR_BSS_ID0, LE_READ_4(ahp->ah_bssid));
32014779705SSam Leffler 	OS_REG_WRITE(ah, AR_BSS_ID1, LE_READ_2(ahp->ah_bssid+4) |
32114779705SSam Leffler 				     ((assocId & 0x3fff)<<AR_BSS_ID1_AID_S));
32214779705SSam Leffler }
32314779705SSam Leffler 
32414779705SSam Leffler /*
32514779705SSam Leffler  * Get the current hardware tsf for stamlme.
32614779705SSam Leffler  */
32714779705SSam Leffler uint64_t
ar5211GetTsf64(struct ath_hal * ah)32814779705SSam Leffler ar5211GetTsf64(struct ath_hal *ah)
32914779705SSam Leffler {
33014779705SSam Leffler 	uint32_t low1, low2, u32;
33114779705SSam Leffler 
33214779705SSam Leffler 	/* sync multi-word read */
33314779705SSam Leffler 	low1 = OS_REG_READ(ah, AR_TSF_L32);
33414779705SSam Leffler 	u32 = OS_REG_READ(ah, AR_TSF_U32);
33514779705SSam Leffler 	low2 = OS_REG_READ(ah, AR_TSF_L32);
33614779705SSam Leffler 	if (low2 < low1) {	/* roll over */
33714779705SSam Leffler 		/*
33814779705SSam Leffler 		 * If we are not preempted this will work.  If we are
33914779705SSam Leffler 		 * then we re-reading AR_TSF_U32 does no good as the
34014779705SSam Leffler 		 * low bits will be meaningless.  Likewise reading
34114779705SSam Leffler 		 * L32, U32, U32, then comparing the last two reads
34214779705SSam Leffler 		 * to check for rollover doesn't help if preempted--so
34314779705SSam Leffler 		 * we take this approach as it costs one less PCI
34414779705SSam Leffler 		 * read which can be noticeable when doing things
34514779705SSam Leffler 		 * like timestamping packets in monitor mode.
34614779705SSam Leffler 		 */
34714779705SSam Leffler 		u32++;
34814779705SSam Leffler 	}
34914779705SSam Leffler 	return (((uint64_t) u32) << 32) | ((uint64_t) low2);
35014779705SSam Leffler }
35114779705SSam Leffler 
35214779705SSam Leffler /*
35314779705SSam Leffler  * Get the current hardware tsf for stamlme.
35414779705SSam Leffler  */
35514779705SSam Leffler uint32_t
ar5211GetTsf32(struct ath_hal * ah)35614779705SSam Leffler ar5211GetTsf32(struct ath_hal *ah)
35714779705SSam Leffler {
35814779705SSam Leffler 	return OS_REG_READ(ah, AR_TSF_L32);
35914779705SSam Leffler }
36014779705SSam Leffler 
36114779705SSam Leffler /*
36214779705SSam Leffler  * Reset the current hardware tsf for stamlme
36314779705SSam Leffler  */
36414779705SSam Leffler void
ar5211ResetTsf(struct ath_hal * ah)36514779705SSam Leffler ar5211ResetTsf(struct ath_hal *ah)
36614779705SSam Leffler {
36714779705SSam Leffler 	uint32_t val = OS_REG_READ(ah, AR_BEACON);
36814779705SSam Leffler 
36914779705SSam Leffler 	OS_REG_WRITE(ah, AR_BEACON, val | AR_BEACON_RESET_TSF);
37014779705SSam Leffler }
37114779705SSam Leffler 
37214779705SSam Leffler /*
37314779705SSam Leffler  * Grab a semi-random value from hardware registers - may not
37414779705SSam Leffler  * change often
37514779705SSam Leffler  */
37614779705SSam Leffler uint32_t
ar5211GetRandomSeed(struct ath_hal * ah)37714779705SSam Leffler ar5211GetRandomSeed(struct ath_hal *ah)
37814779705SSam Leffler {
37914779705SSam Leffler 	uint32_t nf;
38014779705SSam Leffler 
38114779705SSam Leffler 	nf = (OS_REG_READ(ah, AR_PHY(25)) >> 19) & 0x1ff;
38214779705SSam Leffler 	if (nf & 0x100)
38314779705SSam Leffler 		nf = 0 - ((nf ^ 0x1ff) + 1);
38414779705SSam Leffler 	return (OS_REG_READ(ah, AR_TSF_U32) ^
38514779705SSam Leffler 		OS_REG_READ(ah, AR_TSF_L32) ^ nf);
38614779705SSam Leffler }
38714779705SSam Leffler 
38814779705SSam Leffler /*
38914779705SSam Leffler  * Detect if our card is present
39014779705SSam Leffler  */
39114779705SSam Leffler HAL_BOOL
ar5211DetectCardPresent(struct ath_hal * ah)39214779705SSam Leffler ar5211DetectCardPresent(struct ath_hal *ah)
39314779705SSam Leffler {
39414779705SSam Leffler 	uint16_t macVersion, macRev;
39514779705SSam Leffler 	uint32_t v;
39614779705SSam Leffler 
39714779705SSam Leffler 	/*
39814779705SSam Leffler 	 * Read the Silicon Revision register and compare that
39914779705SSam Leffler 	 * to what we read at attach time.  If the same, we say
40014779705SSam Leffler 	 * a card/device is present.
40114779705SSam Leffler 	 */
40214779705SSam Leffler 	v = OS_REG_READ(ah, AR_SREV) & AR_SREV_ID_M;
40314779705SSam Leffler 	macVersion = v >> AR_SREV_ID_S;
40414779705SSam Leffler 	macRev = v & AR_SREV_REVISION_M;
40514779705SSam Leffler 	return (AH_PRIVATE(ah)->ah_macVersion == macVersion &&
40614779705SSam Leffler 		AH_PRIVATE(ah)->ah_macRev == macRev);
40714779705SSam Leffler }
40814779705SSam Leffler 
40914779705SSam Leffler /*
41014779705SSam Leffler  * Update MIB Counters
41114779705SSam Leffler  */
41214779705SSam Leffler void
ar5211UpdateMibCounters(struct ath_hal * ah,HAL_MIB_STATS * stats)41314779705SSam Leffler ar5211UpdateMibCounters(struct ath_hal *ah, HAL_MIB_STATS *stats)
41414779705SSam Leffler {
41514779705SSam Leffler 	stats->ackrcv_bad += OS_REG_READ(ah, AR_ACK_FAIL);
41614779705SSam Leffler 	stats->rts_bad	  += OS_REG_READ(ah, AR_RTS_FAIL);
41714779705SSam Leffler 	stats->fcs_bad	  += OS_REG_READ(ah, AR_FCS_FAIL);
41814779705SSam Leffler 	stats->rts_good	  += OS_REG_READ(ah, AR_RTS_OK);
41914779705SSam Leffler 	stats->beacons	  += OS_REG_READ(ah, AR_BEACON_CNT);
42014779705SSam Leffler }
42114779705SSam Leffler 
42214779705SSam Leffler HAL_BOOL
ar5211SetSifsTime(struct ath_hal * ah,u_int us)42314779705SSam Leffler ar5211SetSifsTime(struct ath_hal *ah, u_int us)
42414779705SSam Leffler {
42514779705SSam Leffler 	struct ath_hal_5211 *ahp = AH5211(ah);
42614779705SSam Leffler 
42714779705SSam Leffler 	if (us > ath_hal_mac_usec(ah, 0xffff)) {
42814779705SSam Leffler 		HALDEBUG(ah, HAL_DEBUG_ANY, "%s: bad SIFS time %u\n",
42914779705SSam Leffler 		    __func__, us);
43014779705SSam Leffler 		ahp->ah_sifstime = (u_int) -1;	/* restore default handling */
43114779705SSam Leffler 		return AH_FALSE;
43214779705SSam Leffler 	} else {
43314779705SSam Leffler 		/* convert to system clocks */
43414779705SSam Leffler 		OS_REG_WRITE(ah, AR_D_GBL_IFS_SIFS, ath_hal_mac_clks(ah, us));
43559efa8b5SSam Leffler 		ahp->ah_slottime = us;
43614779705SSam Leffler 		return AH_TRUE;
43714779705SSam Leffler 	}
43814779705SSam Leffler }
43914779705SSam Leffler 
44014779705SSam Leffler u_int
ar5211GetSifsTime(struct ath_hal * ah)44114779705SSam Leffler ar5211GetSifsTime(struct ath_hal *ah)
44214779705SSam Leffler {
44314779705SSam Leffler 	u_int clks = OS_REG_READ(ah, AR_D_GBL_IFS_SIFS) & 0xffff;
44414779705SSam Leffler 	return ath_hal_mac_usec(ah, clks);	/* convert from system clocks */
44514779705SSam Leffler }
44614779705SSam Leffler 
44714779705SSam Leffler HAL_BOOL
ar5211SetSlotTime(struct ath_hal * ah,u_int us)44814779705SSam Leffler ar5211SetSlotTime(struct ath_hal *ah, u_int us)
44914779705SSam Leffler {
45014779705SSam Leffler 	struct ath_hal_5211 *ahp = AH5211(ah);
45114779705SSam Leffler 
45214779705SSam Leffler 	if (us < HAL_SLOT_TIME_9 || us > ath_hal_mac_usec(ah, 0xffff)) {
45314779705SSam Leffler 		HALDEBUG(ah, HAL_DEBUG_ANY, "%s: bad slot time %u\n",
45414779705SSam Leffler 		    __func__, us);
45514779705SSam Leffler 		ahp->ah_slottime = us;	/* restore default handling */
45614779705SSam Leffler 		return AH_FALSE;
45714779705SSam Leffler 	} else {
45814779705SSam Leffler 		/* convert to system clocks */
45914779705SSam Leffler 		OS_REG_WRITE(ah, AR_D_GBL_IFS_SLOT, ath_hal_mac_clks(ah, us));
46014779705SSam Leffler 		ahp->ah_slottime = us;
46114779705SSam Leffler 		return AH_TRUE;
46214779705SSam Leffler 	}
46314779705SSam Leffler }
46414779705SSam Leffler 
46514779705SSam Leffler u_int
ar5211GetSlotTime(struct ath_hal * ah)46614779705SSam Leffler ar5211GetSlotTime(struct ath_hal *ah)
46714779705SSam Leffler {
46814779705SSam Leffler 	u_int clks = OS_REG_READ(ah, AR_D_GBL_IFS_SLOT) & 0xffff;
46914779705SSam Leffler 	return ath_hal_mac_usec(ah, clks);	/* convert from system clocks */
47014779705SSam Leffler }
47114779705SSam Leffler 
47214779705SSam Leffler HAL_BOOL
ar5211SetAckTimeout(struct ath_hal * ah,u_int us)47314779705SSam Leffler ar5211SetAckTimeout(struct ath_hal *ah, u_int us)
47414779705SSam Leffler {
47514779705SSam Leffler 	struct ath_hal_5211 *ahp = AH5211(ah);
47614779705SSam Leffler 
47714779705SSam Leffler 	if (us > ath_hal_mac_usec(ah, MS(0xffffffff, AR_TIME_OUT_ACK))) {
47814779705SSam Leffler 		HALDEBUG(ah, HAL_DEBUG_ANY, "%s: bad ack timeout %u\n",
47914779705SSam Leffler 		    __func__, us);
48014779705SSam Leffler 		ahp->ah_acktimeout = (u_int) -1; /* restore default handling */
48114779705SSam Leffler 		return AH_FALSE;
48214779705SSam Leffler 	} else {
48314779705SSam Leffler 		/* convert to system clocks */
48414779705SSam Leffler 		OS_REG_RMW_FIELD(ah, AR_TIME_OUT,
48514779705SSam Leffler 			AR_TIME_OUT_ACK, ath_hal_mac_clks(ah, us));
48614779705SSam Leffler 		ahp->ah_acktimeout = us;
48714779705SSam Leffler 		return AH_TRUE;
48814779705SSam Leffler 	}
48914779705SSam Leffler }
49014779705SSam Leffler 
49114779705SSam Leffler u_int
ar5211GetAckTimeout(struct ath_hal * ah)49214779705SSam Leffler ar5211GetAckTimeout(struct ath_hal *ah)
49314779705SSam Leffler {
49414779705SSam Leffler 	u_int clks = MS(OS_REG_READ(ah, AR_TIME_OUT), AR_TIME_OUT_ACK);
49514779705SSam Leffler 	return ath_hal_mac_usec(ah, clks);	/* convert from system clocks */
49614779705SSam Leffler }
49714779705SSam Leffler 
49814779705SSam Leffler u_int
ar5211GetAckCTSRate(struct ath_hal * ah)49914779705SSam Leffler ar5211GetAckCTSRate(struct ath_hal *ah)
50014779705SSam Leffler {
50114779705SSam Leffler 	return ((AH5211(ah)->ah_staId1Defaults & AR_STA_ID1_ACKCTS_6MB) == 0);
50214779705SSam Leffler }
50314779705SSam Leffler 
50414779705SSam Leffler HAL_BOOL
ar5211SetAckCTSRate(struct ath_hal * ah,u_int high)50514779705SSam Leffler ar5211SetAckCTSRate(struct ath_hal *ah, u_int high)
50614779705SSam Leffler {
50714779705SSam Leffler 	struct ath_hal_5211 *ahp = AH5211(ah);
50814779705SSam Leffler 
50914779705SSam Leffler 	if (high) {
51014779705SSam Leffler 		OS_REG_CLR_BIT(ah, AR_STA_ID1, AR_STA_ID1_ACKCTS_6MB);
51114779705SSam Leffler 		ahp->ah_staId1Defaults &= ~AR_STA_ID1_ACKCTS_6MB;
51214779705SSam Leffler 	} else {
51314779705SSam Leffler 		OS_REG_SET_BIT(ah, AR_STA_ID1, AR_STA_ID1_ACKCTS_6MB);
51414779705SSam Leffler 		ahp->ah_staId1Defaults |= AR_STA_ID1_ACKCTS_6MB;
51514779705SSam Leffler 	}
51614779705SSam Leffler 	return AH_TRUE;
51714779705SSam Leffler }
51814779705SSam Leffler 
51914779705SSam Leffler HAL_BOOL
ar5211SetCTSTimeout(struct ath_hal * ah,u_int us)52014779705SSam Leffler ar5211SetCTSTimeout(struct ath_hal *ah, u_int us)
52114779705SSam Leffler {
52214779705SSam Leffler 	struct ath_hal_5211 *ahp = AH5211(ah);
52314779705SSam Leffler 
52414779705SSam Leffler 	if (us > ath_hal_mac_usec(ah, MS(0xffffffff, AR_TIME_OUT_CTS))) {
52514779705SSam Leffler 		HALDEBUG(ah, HAL_DEBUG_ANY, "%s: bad cts timeout %u\n",
52614779705SSam Leffler 		    __func__, us);
52714779705SSam Leffler 		ahp->ah_ctstimeout = (u_int) -1; /* restore default handling */
52814779705SSam Leffler 		return AH_FALSE;
52914779705SSam Leffler 	} else {
53014779705SSam Leffler 		/* convert to system clocks */
53114779705SSam Leffler 		OS_REG_RMW_FIELD(ah, AR_TIME_OUT,
53214779705SSam Leffler 			AR_TIME_OUT_CTS, ath_hal_mac_clks(ah, us));
53314779705SSam Leffler 		ahp->ah_ctstimeout = us;
53414779705SSam Leffler 		return AH_TRUE;
53514779705SSam Leffler 	}
53614779705SSam Leffler }
53714779705SSam Leffler 
53814779705SSam Leffler u_int
ar5211GetCTSTimeout(struct ath_hal * ah)53914779705SSam Leffler ar5211GetCTSTimeout(struct ath_hal *ah)
54014779705SSam Leffler {
54114779705SSam Leffler 	u_int clks = MS(OS_REG_READ(ah, AR_TIME_OUT), AR_TIME_OUT_CTS);
54214779705SSam Leffler 	return ath_hal_mac_usec(ah, clks);	/* convert from system clocks */
54314779705SSam Leffler }
54414779705SSam Leffler 
54514779705SSam Leffler HAL_BOOL
ar5211SetDecompMask(struct ath_hal * ah,uint16_t keyidx,int en)54614779705SSam Leffler ar5211SetDecompMask(struct ath_hal *ah, uint16_t keyidx, int en)
54714779705SSam Leffler {
54814779705SSam Leffler 	/* nothing to do */
54914779705SSam Leffler         return AH_TRUE;
55014779705SSam Leffler }
55114779705SSam Leffler 
55214779705SSam Leffler void
ar5211SetCoverageClass(struct ath_hal * ah,uint8_t coverageclass,int now)55314779705SSam Leffler ar5211SetCoverageClass(struct ath_hal *ah, uint8_t coverageclass, int now)
55414779705SSam Leffler {
55514779705SSam Leffler }
55614779705SSam Leffler 
557aa36f34dSAdrian Chadd HAL_STATUS
ar5211SetQuiet(struct ath_hal * ah,uint32_t period,uint32_t duration,uint32_t next_start,HAL_QUIET_FLAG flags)558aa36f34dSAdrian Chadd ar5211SetQuiet(struct ath_hal *ah, uint32_t period, uint32_t duration,
559aa36f34dSAdrian Chadd     uint32_t next_start, HAL_QUIET_FLAG flags)
560aa36f34dSAdrian Chadd {
561aa36f34dSAdrian Chadd 	return HAL_OK;
562aa36f34dSAdrian Chadd }
563aa36f34dSAdrian Chadd 
56414779705SSam Leffler /*
56514779705SSam Leffler  * Control Adaptive Noise Immunity Parameters
56614779705SSam Leffler  */
56714779705SSam Leffler HAL_BOOL
ar5211AniControl(struct ath_hal * ah,HAL_ANI_CMD cmd,int param)56814779705SSam Leffler ar5211AniControl(struct ath_hal *ah, HAL_ANI_CMD cmd, int param)
56914779705SSam Leffler {
57014779705SSam Leffler 	return AH_FALSE;
57114779705SSam Leffler }
57214779705SSam Leffler 
57314779705SSam Leffler void
ar5211AniPoll(struct ath_hal * ah,const struct ieee80211_channel * chan)574a108ab63SAdrian Chadd ar5211AniPoll(struct ath_hal *ah, const struct ieee80211_channel *chan)
575a108ab63SAdrian Chadd {
576a108ab63SAdrian Chadd }
577a108ab63SAdrian Chadd 
578a108ab63SAdrian Chadd void
ar5211RxMonitor(struct ath_hal * ah,const HAL_NODE_STATS * stats,const struct ieee80211_channel * chan)579a108ab63SAdrian Chadd ar5211RxMonitor(struct ath_hal *ah, const HAL_NODE_STATS *stats,
58059efa8b5SSam Leffler 	const struct ieee80211_channel *chan)
58114779705SSam Leffler {
58214779705SSam Leffler }
58314779705SSam Leffler 
58414779705SSam Leffler void
ar5211MibEvent(struct ath_hal * ah,const HAL_NODE_STATS * stats)58514779705SSam Leffler ar5211MibEvent(struct ath_hal *ah, const HAL_NODE_STATS *stats)
58614779705SSam Leffler {
58714779705SSam Leffler }
58814779705SSam Leffler 
58914779705SSam Leffler /*
59014779705SSam Leffler  * Get the rssi of frame curently being received.
59114779705SSam Leffler  */
59214779705SSam Leffler uint32_t
ar5211GetCurRssi(struct ath_hal * ah)59314779705SSam Leffler ar5211GetCurRssi(struct ath_hal *ah)
59414779705SSam Leffler {
59514779705SSam Leffler 	return (OS_REG_READ(ah, AR_PHY_CURRENT_RSSI) & 0xff);
59614779705SSam Leffler }
59714779705SSam Leffler 
59814779705SSam Leffler u_int
ar5211GetDefAntenna(struct ath_hal * ah)59914779705SSam Leffler ar5211GetDefAntenna(struct ath_hal *ah)
60014779705SSam Leffler {
60114779705SSam Leffler 	return (OS_REG_READ(ah, AR_DEF_ANTENNA) & 0x7);
60214779705SSam Leffler }
60314779705SSam Leffler 
60414779705SSam Leffler void
ar5211SetDefAntenna(struct ath_hal * ah,u_int antenna)60514779705SSam Leffler ar5211SetDefAntenna(struct ath_hal *ah, u_int antenna)
60614779705SSam Leffler {
60714779705SSam Leffler 	OS_REG_WRITE(ah, AR_DEF_ANTENNA, (antenna & 0x7));
60814779705SSam Leffler }
60914779705SSam Leffler 
61014779705SSam Leffler HAL_ANT_SETTING
ar5211GetAntennaSwitch(struct ath_hal * ah)61114779705SSam Leffler ar5211GetAntennaSwitch(struct ath_hal *ah)
61214779705SSam Leffler {
61314779705SSam Leffler 	return AH5211(ah)->ah_diversityControl;
61414779705SSam Leffler }
61514779705SSam Leffler 
61614779705SSam Leffler HAL_BOOL
ar5211SetAntennaSwitch(struct ath_hal * ah,HAL_ANT_SETTING settings)61714779705SSam Leffler ar5211SetAntennaSwitch(struct ath_hal *ah, HAL_ANT_SETTING settings)
61814779705SSam Leffler {
61959efa8b5SSam Leffler 	const struct ieee80211_channel *chan = AH_PRIVATE(ah)->ah_curchan;
62014779705SSam Leffler 
62114779705SSam Leffler 	if (chan == AH_NULL) {
62214779705SSam Leffler 		AH5211(ah)->ah_diversityControl = settings;
62314779705SSam Leffler 		return AH_TRUE;
62414779705SSam Leffler 	}
62514779705SSam Leffler 	return ar5211SetAntennaSwitchInternal(ah, settings, chan);
62614779705SSam Leffler }
62714779705SSam Leffler 
62814779705SSam Leffler HAL_STATUS
ar5211GetCapability(struct ath_hal * ah,HAL_CAPABILITY_TYPE type,uint32_t capability,uint32_t * result)62914779705SSam Leffler ar5211GetCapability(struct ath_hal *ah, HAL_CAPABILITY_TYPE type,
63014779705SSam Leffler 	uint32_t capability, uint32_t *result)
63114779705SSam Leffler {
63214779705SSam Leffler 
63314779705SSam Leffler 	switch (type) {
63414779705SSam Leffler 	case HAL_CAP_CIPHER:		/* cipher handled in hardware */
63514779705SSam Leffler 		switch (capability) {
63614779705SSam Leffler 		case HAL_CIPHER_AES_OCB:
63714779705SSam Leffler 		case HAL_CIPHER_WEP:
63814779705SSam Leffler 		case HAL_CIPHER_CLR:
63914779705SSam Leffler 			return HAL_OK;
64014779705SSam Leffler 		default:
64114779705SSam Leffler 			return HAL_ENOTSUPP;
64214779705SSam Leffler 		}
64314779705SSam Leffler 	default:
64414779705SSam Leffler 		return ath_hal_getcapability(ah, type, capability, result);
64514779705SSam Leffler 	}
64614779705SSam Leffler }
64714779705SSam Leffler 
64814779705SSam Leffler HAL_BOOL
ar5211SetCapability(struct ath_hal * ah,HAL_CAPABILITY_TYPE type,uint32_t capability,uint32_t setting,HAL_STATUS * status)64914779705SSam Leffler ar5211SetCapability(struct ath_hal *ah, HAL_CAPABILITY_TYPE type,
65014779705SSam Leffler 	uint32_t capability, uint32_t setting, HAL_STATUS *status)
65114779705SSam Leffler {
65214779705SSam Leffler 	switch (type) {
65314779705SSam Leffler 	case HAL_CAP_DIAG:		/* hardware diagnostic support */
65414779705SSam Leffler 		/*
65514779705SSam Leffler 		 * NB: could split this up into virtual capabilities,
65614779705SSam Leffler 		 *     (e.g. 1 => ACK, 2 => CTS, etc.) but it hardly
65714779705SSam Leffler 		 *     seems worth the additional complexity.
65814779705SSam Leffler 		 */
65914779705SSam Leffler #ifdef AH_DEBUG
66014779705SSam Leffler 		AH_PRIVATE(ah)->ah_diagreg = setting;
66114779705SSam Leffler #else
66214779705SSam Leffler 		AH_PRIVATE(ah)->ah_diagreg = setting & 0x6;	/* ACK+CTS */
66314779705SSam Leffler #endif
66414779705SSam Leffler 		OS_REG_WRITE(ah, AR_DIAG_SW, AH_PRIVATE(ah)->ah_diagreg);
66514779705SSam Leffler 		return AH_TRUE;
66614779705SSam Leffler 	default:
66714779705SSam Leffler 		return ath_hal_setcapability(ah, type, capability,
66814779705SSam Leffler 			setting, status);
66914779705SSam Leffler 	}
67014779705SSam Leffler }
67114779705SSam Leffler 
67214779705SSam Leffler HAL_BOOL
ar5211GetDiagState(struct ath_hal * ah,int request,const void * args,uint32_t argsize,void ** result,uint32_t * resultsize)67314779705SSam Leffler ar5211GetDiagState(struct ath_hal *ah, int request,
67414779705SSam Leffler 	const void *args, uint32_t argsize,
67514779705SSam Leffler 	void **result, uint32_t *resultsize)
67614779705SSam Leffler {
67714779705SSam Leffler 	struct ath_hal_5211 *ahp = AH5211(ah);
67814779705SSam Leffler 
67914779705SSam Leffler 	(void) ahp;
68014779705SSam Leffler 	if (ath_hal_getdiagstate(ah, request, args, argsize, result, resultsize))
68114779705SSam Leffler 		return AH_TRUE;
68214779705SSam Leffler 	switch (request) {
68314779705SSam Leffler 	case HAL_DIAG_EEPROM:
68414779705SSam Leffler 		return ath_hal_eepromDiag(ah, request,
68514779705SSam Leffler 		    args, argsize, result, resultsize);
68614779705SSam Leffler 	case HAL_DIAG_RFGAIN:
68714779705SSam Leffler 		*result = &ahp->ah_gainValues;
68814779705SSam Leffler 		*resultsize = sizeof(GAIN_VALUES);
68914779705SSam Leffler 		return AH_TRUE;
69014779705SSam Leffler 	case HAL_DIAG_RFGAIN_CURSTEP:
69114779705SSam Leffler 		*result = __DECONST(void *, ahp->ah_gainValues.currStep);
69214779705SSam Leffler 		*resultsize = (*result == AH_NULL) ?
69314779705SSam Leffler 			0 : sizeof(GAIN_OPTIMIZATION_STEP);
69414779705SSam Leffler 		return AH_TRUE;
69514779705SSam Leffler 	}
69614779705SSam Leffler 	return AH_FALSE;
69714779705SSam Leffler }
698352f07f6SAdrian Chadd 
699352f07f6SAdrian Chadd /*
700352f07f6SAdrian Chadd  * Return what percentage of the extension channel is busy.
701352f07f6SAdrian Chadd  * This is always disabled for AR5211 series NICs.
702352f07f6SAdrian Chadd  */
703352f07f6SAdrian Chadd uint32_t
ar5211Get11nExtBusy(struct ath_hal * ah)704352f07f6SAdrian Chadd ar5211Get11nExtBusy(struct ath_hal *ah)
705352f07f6SAdrian Chadd {
706352f07f6SAdrian Chadd 	return (0);
707352f07f6SAdrian Chadd }
708352f07f6SAdrian Chadd 
709352f07f6SAdrian Chadd /*
710352f07f6SAdrian Chadd  * There's no channel survey support for the AR5211.
711352f07f6SAdrian Chadd  */
712352f07f6SAdrian Chadd HAL_BOOL
ar5211GetMibCycleCounts(struct ath_hal * ah,HAL_SURVEY_SAMPLE * hsample)713352f07f6SAdrian Chadd ar5211GetMibCycleCounts(struct ath_hal *ah, HAL_SURVEY_SAMPLE *hsample)
714352f07f6SAdrian Chadd {
715352f07f6SAdrian Chadd 
716352f07f6SAdrian Chadd 	return (AH_FALSE);
717352f07f6SAdrian Chadd }
718a41607fcSAdrian Chadd 
719a41607fcSAdrian Chadd void
ar5211SetChainMasks(struct ath_hal * ah,uint32_t txchainmask,uint32_t rxchainmask)720d2a72d67SAdrian Chadd ar5211SetChainMasks(struct ath_hal *ah, uint32_t txchainmask,
721d2a72d67SAdrian Chadd     uint32_t rxchainmask)
722d2a72d67SAdrian Chadd {
723d2a72d67SAdrian Chadd }
724d2a72d67SAdrian Chadd 
725d2a72d67SAdrian Chadd void
ar5211EnableDfs(struct ath_hal * ah,HAL_PHYERR_PARAM * pe)726a41607fcSAdrian Chadd ar5211EnableDfs(struct ath_hal *ah, HAL_PHYERR_PARAM *pe)
727a41607fcSAdrian Chadd {
728a41607fcSAdrian Chadd }
729a41607fcSAdrian Chadd 
730a41607fcSAdrian Chadd void
ar5211GetDfsThresh(struct ath_hal * ah,HAL_PHYERR_PARAM * pe)731a41607fcSAdrian Chadd ar5211GetDfsThresh(struct ath_hal *ah, HAL_PHYERR_PARAM *pe)
732a41607fcSAdrian Chadd {
733a41607fcSAdrian Chadd }
734*bed90bf8SAdrian Chadd 
735*bed90bf8SAdrian Chadd /*
736*bed90bf8SAdrian Chadd  * Get the current NAV value from the hardware.
737*bed90bf8SAdrian Chadd  */
738*bed90bf8SAdrian Chadd u_int
ar5211GetNav(struct ath_hal * ah)739*bed90bf8SAdrian Chadd ar5211GetNav(struct ath_hal *ah)
740*bed90bf8SAdrian Chadd {
741*bed90bf8SAdrian Chadd 	uint32_t reg;
742*bed90bf8SAdrian Chadd 
743*bed90bf8SAdrian Chadd 	reg = OS_REG_READ(ah, AR_NAV);
744*bed90bf8SAdrian Chadd 	return (reg);
745*bed90bf8SAdrian Chadd }
746*bed90bf8SAdrian Chadd 
747*bed90bf8SAdrian Chadd /*
748*bed90bf8SAdrian Chadd  * Set the current NAV value to the hardware.
749*bed90bf8SAdrian Chadd  */
750*bed90bf8SAdrian Chadd void
ar5211SetNav(struct ath_hal * ah,u_int val)751*bed90bf8SAdrian Chadd ar5211SetNav(struct ath_hal *ah, u_int val)
752*bed90bf8SAdrian Chadd {
753*bed90bf8SAdrian Chadd 
754*bed90bf8SAdrian Chadd 	OS_REG_WRITE(ah, AR_NAV, val);
755*bed90bf8SAdrian Chadd }
756*bed90bf8SAdrian Chadd 
757