1 /* 2 * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting 3 * Copyright (c) 2002-2008 Atheros Communications, Inc. 4 * 5 * Permission to use, copy, modify, and/or distribute this software for any 6 * purpose with or without fee is hereby granted, provided that the above 7 * copyright notice and this permission notice appear in all copies. 8 * 9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 * 17 * $FreeBSD$ 18 */ 19 #ifndef _ATH_AR5416_H_ 20 #define _ATH_AR5416_H_ 21 22 #include "ar5212/ar5212.h" 23 #include "ar5416_cal.h" 24 #include "ah_eeprom_v14.h" /* for CAL_TARGET_POWER_* */ 25 26 #define AR5416_MAGIC 0x20065416 27 28 enum { 29 HAL_RESET_POWER_ON, 30 HAL_RESET_WARM, 31 HAL_RESET_COLD, 32 }; 33 34 typedef struct { 35 uint16_t synth_center; 36 uint16_t ctl_center; 37 uint16_t ext_center; 38 } CHAN_CENTERS; 39 40 #define AR5416_DEFAULT_RXCHAINMASK 7 41 #define AR5416_DEFAULT_TXCHAINMASK 1 42 #define AR5416_MAX_RATE_POWER 63 43 #define AR5416_KEYTABLE_SIZE 128 44 45 #define AR5416_CCA_MAX_GOOD_VALUE -85 46 #define AR5416_CCA_MAX_HIGH_VALUE -62 47 #define AR5416_CCA_MIN_BAD_VALUE -140 48 #define AR9285_CCA_MAX_GOOD_VALUE -118 49 50 #define AR5416_SPUR_RSSI_THRESH 40 51 52 struct ar5416NfLimits { 53 int16_t max; 54 int16_t min; 55 int16_t nominal; 56 }; 57 58 struct ath_hal_5416 { 59 struct ath_hal_5212 ah_5212; 60 61 /* NB: RF data setup at attach */ 62 HAL_INI_ARRAY ah_ini_bb_rfgain; 63 HAL_INI_ARRAY ah_ini_bank0; 64 HAL_INI_ARRAY ah_ini_bank1; 65 HAL_INI_ARRAY ah_ini_bank2; 66 HAL_INI_ARRAY ah_ini_bank3; 67 HAL_INI_ARRAY ah_ini_bank6; 68 HAL_INI_ARRAY ah_ini_bank7; 69 HAL_INI_ARRAY ah_ini_addac; 70 HAL_INI_ARRAY ah_ini_pcieserdes; 71 72 void (*ah_writeIni)(struct ath_hal *, 73 const struct ieee80211_channel *); 74 void (*ah_spurMitigate)(struct ath_hal *, 75 const struct ieee80211_channel *); 76 77 /* calibration ops */ 78 HAL_BOOL (*ah_cal_initcal)(struct ath_hal *, 79 const struct ieee80211_channel *); 80 void (*ah_cal_pacal)(struct ath_hal *, 81 HAL_BOOL is_reset); 82 83 /* optional open-loop tx power control related methods */ 84 void (*ah_olcInit)(struct ath_hal *); 85 void (*ah_olcTempCompensation)(struct ath_hal *); 86 87 /* tx power control */ 88 HAL_BOOL (*ah_setPowerCalTable) (struct ath_hal *ah, 89 struct ar5416eeprom *pEepData, 90 const struct ieee80211_channel *chan, 91 int16_t *pTxPowerIndexOffset); 92 93 u_int ah_globaltxtimeout; /* global tx timeout */ 94 u_int ah_gpioMask; 95 int ah_hangs; /* h/w hangs state */ 96 uint8_t ah_keytype[AR5416_KEYTABLE_SIZE]; 97 /* 98 * Extension Channel Rx Clear State 99 */ 100 uint32_t ah_cycleCount; 101 uint32_t ah_ctlBusy; 102 uint32_t ah_extBusy; 103 uint32_t ah_rx_chainmask; 104 uint32_t ah_tx_chainmask; 105 106 HAL_ANI_CMD ah_ani_function; 107 108 struct ar5416PerCal ah_cal; /* periodic calibration state */ 109 110 struct ar5416NfLimits nf_2g; 111 struct ar5416NfLimits nf_5g; 112 113 int initPDADC; 114 115 int ah_need_an_top2_fixup; /* merlin or later chips that may need this workaround */ 116 }; 117 #define AH5416(_ah) ((struct ath_hal_5416 *)(_ah)) 118 119 #define IS_5416_PCI(ah) ((AH_PRIVATE(ah)->ah_macVersion) == AR_SREV_VERSION_OWL_PCI) 120 #define IS_5416_PCIE(ah) ((AH_PRIVATE(ah)->ah_macVersion) == AR_SREV_VERSION_OWL_PCIE) 121 #undef IS_PCIE 122 #define IS_PCIE(ah) (IS_5416_PCIE(ah)) 123 124 extern HAL_BOOL ar2133RfAttach(struct ath_hal *, HAL_STATUS *); 125 126 struct ath_hal; 127 128 extern uint32_t ar5416GetRadioRev(struct ath_hal *ah); 129 extern void ar5416InitState(struct ath_hal_5416 *, uint16_t devid, 130 HAL_SOFTC sc, HAL_BUS_TAG st, HAL_BUS_HANDLE sh, 131 HAL_STATUS *status); 132 extern void ar5416Detach(struct ath_hal *ah); 133 extern void ar5416AttachPCIE(struct ath_hal *ah); 134 extern HAL_BOOL ar5416FillCapabilityInfo(struct ath_hal *ah); 135 136 #define IS_5GHZ_FAST_CLOCK_EN(_ah, _c) \ 137 (IEEE80211_IS_CHAN_5GHZ(_c) && \ 138 ath_hal_eepromGetFlag(ah, AR_EEP_FSTCLK_5G)) 139 140 extern void ar5416AniAttach(struct ath_hal *, const struct ar5212AniParams *, 141 const struct ar5212AniParams *, HAL_BOOL ena); 142 extern void ar5416AniDetach(struct ath_hal *); 143 extern HAL_BOOL ar5416AniControl(struct ath_hal *, HAL_ANI_CMD cmd, int param); 144 extern HAL_BOOL ar5416AniSetParams(struct ath_hal *, 145 const struct ar5212AniParams *, const struct ar5212AniParams *); 146 extern void ar5416ProcessMibIntr(struct ath_hal *, const HAL_NODE_STATS *); 147 extern void ar5416RxMonitor(struct ath_hal *, const HAL_NODE_STATS *, 148 const struct ieee80211_channel *); 149 extern void ar5416AniPoll(struct ath_hal *, const struct ieee80211_channel *); 150 extern void ar5416AniReset(struct ath_hal *, const struct ieee80211_channel *, 151 HAL_OPMODE, int); 152 153 extern void ar5416SetBeaconTimers(struct ath_hal *, const HAL_BEACON_TIMERS *); 154 extern void ar5416BeaconInit(struct ath_hal *ah, 155 uint32_t next_beacon, uint32_t beacon_period); 156 extern void ar5416ResetStaBeaconTimers(struct ath_hal *ah); 157 extern void ar5416SetStaBeaconTimers(struct ath_hal *ah, 158 const HAL_BEACON_STATE *); 159 160 extern HAL_BOOL ar5416EepromRead(struct ath_hal *, u_int off, uint16_t *data); 161 extern HAL_BOOL ar5416EepromWrite(struct ath_hal *, u_int off, uint16_t data); 162 163 extern HAL_BOOL ar5416IsInterruptPending(struct ath_hal *ah); 164 extern HAL_BOOL ar5416GetPendingInterrupts(struct ath_hal *, HAL_INT *masked); 165 extern HAL_INT ar5416SetInterrupts(struct ath_hal *ah, HAL_INT ints); 166 167 extern HAL_BOOL ar5416GpioCfgOutput(struct ath_hal *, uint32_t gpio, 168 HAL_GPIO_MUX_TYPE); 169 extern HAL_BOOL ar5416GpioCfgInput(struct ath_hal *, uint32_t gpio); 170 extern HAL_BOOL ar5416GpioSet(struct ath_hal *, uint32_t gpio, uint32_t val); 171 extern uint32_t ar5416GpioGet(struct ath_hal *ah, uint32_t gpio); 172 extern void ar5416GpioSetIntr(struct ath_hal *ah, u_int, uint32_t ilevel); 173 174 extern u_int ar5416GetWirelessModes(struct ath_hal *ah); 175 extern void ar5416SetLedState(struct ath_hal *ah, HAL_LED_STATE state); 176 extern void ar5416ResetTsf(struct ath_hal *ah); 177 extern HAL_BOOL ar5416SetAntennaSwitch(struct ath_hal *, HAL_ANT_SETTING); 178 extern HAL_BOOL ar5416SetDecompMask(struct ath_hal *, uint16_t, int); 179 extern void ar5416SetCoverageClass(struct ath_hal *, uint8_t, int); 180 extern uint32_t ar5416Get11nExtBusy(struct ath_hal *ah); 181 extern void ar5416Set11nMac2040(struct ath_hal *ah, HAL_HT_MACMODE mode); 182 extern HAL_HT_RXCLEAR ar5416Get11nRxClear(struct ath_hal *ah); 183 extern void ar5416Set11nRxClear(struct ath_hal *ah, HAL_HT_RXCLEAR rxclear); 184 extern HAL_STATUS ar5416GetCapability(struct ath_hal *ah, 185 HAL_CAPABILITY_TYPE type, uint32_t capability, uint32_t *result); 186 extern HAL_BOOL ar5416GetDiagState(struct ath_hal *ah, int request, 187 const void *args, uint32_t argsize, 188 void **result, uint32_t *resultsize); 189 190 extern HAL_BOOL ar5416SetPowerMode(struct ath_hal *ah, HAL_POWER_MODE mode, 191 int setChip); 192 extern HAL_POWER_MODE ar5416GetPowerMode(struct ath_hal *ah); 193 extern HAL_BOOL ar5416GetPowerStatus(struct ath_hal *ah); 194 195 extern HAL_BOOL ar5416ResetKeyCacheEntry(struct ath_hal *ah, uint16_t entry); 196 extern HAL_BOOL ar5416SetKeyCacheEntry(struct ath_hal *ah, uint16_t entry, 197 const HAL_KEYVAL *k, const uint8_t *mac, int xorKey); 198 199 extern void ar5416StartPcuReceive(struct ath_hal *ah); 200 extern void ar5416StopPcuReceive(struct ath_hal *ah); 201 extern HAL_BOOL ar5416SetupRxDesc(struct ath_hal *, 202 struct ath_desc *, uint32_t size, u_int flags); 203 extern HAL_STATUS ar5416ProcRxDesc(struct ath_hal *ah, struct ath_desc *, 204 uint32_t, struct ath_desc *, uint64_t, 205 struct ath_rx_status *); 206 207 extern HAL_BOOL ar5416Reset(struct ath_hal *ah, HAL_OPMODE opmode, 208 struct ieee80211_channel *chan, 209 HAL_BOOL bChannelChange, HAL_STATUS *status); 210 extern HAL_BOOL ar5416PhyDisable(struct ath_hal *ah); 211 extern HAL_RFGAIN ar5416GetRfgain(struct ath_hal *ah); 212 extern HAL_BOOL ar5416Disable(struct ath_hal *ah); 213 extern HAL_BOOL ar5416ChipReset(struct ath_hal *ah, 214 const struct ieee80211_channel *); 215 extern int ar5416GetRegChainOffset(struct ath_hal *ah, int i); 216 extern HAL_BOOL ar5416SetBoardValues(struct ath_hal *, 217 const struct ieee80211_channel *); 218 extern HAL_BOOL ar5416SetResetReg(struct ath_hal *, uint32_t type); 219 extern HAL_BOOL ar5416SetTxPowerLimit(struct ath_hal *ah, uint32_t limit); 220 extern HAL_BOOL ar5416SetTransmitPower(struct ath_hal *, 221 const struct ieee80211_channel *, uint16_t *); 222 extern HAL_BOOL ar5416GetChipPowerLimits(struct ath_hal *ah, 223 struct ieee80211_channel *chan); 224 extern void ar5416GetChannelCenters(struct ath_hal *, 225 const struct ieee80211_channel *chan, CHAN_CENTERS *centers); 226 extern void ar5416GetTargetPowers(struct ath_hal *ah, 227 const struct ieee80211_channel *chan, 228 CAL_TARGET_POWER_HT *powInfo, 229 uint16_t numChannels, CAL_TARGET_POWER_HT *pNewPower, 230 uint16_t numRates, HAL_BOOL isHt40Target); 231 extern void ar5416GetTargetPowersLeg(struct ath_hal *ah, 232 const struct ieee80211_channel *chan, 233 CAL_TARGET_POWER_LEG *powInfo, 234 uint16_t numChannels, CAL_TARGET_POWER_LEG *pNewPower, 235 uint16_t numRates, HAL_BOOL isExtTarget); 236 extern void ar5416InitChainMasks(struct ath_hal *ah); 237 extern void ar5416RestoreChainMask(struct ath_hal *ah); 238 239 /* TX power setup related routines in ar5416_reset.c */ 240 extern void ar5416GetGainBoundariesAndPdadcs(struct ath_hal *ah, 241 const struct ieee80211_channel *chan, CAL_DATA_PER_FREQ *pRawDataSet, 242 uint8_t * bChans, uint16_t availPiers, 243 uint16_t tPdGainOverlap, int16_t *pMinCalPower, 244 uint16_t * pPdGainBoundaries, uint8_t * pPDADCValues, 245 uint16_t numXpdGains); 246 extern void ar5416SetGainBoundariesClosedLoop(struct ath_hal *ah, 247 int i, uint16_t pdGainOverlap_t2, 248 uint16_t gainBoundaries[]); 249 extern uint16_t ar5416GetXpdGainValues(struct ath_hal *ah, uint16_t xpdMask, 250 uint16_t xpdGainValues[]); 251 extern void ar5416WriteDetectorGainBiases(struct ath_hal *ah, 252 uint16_t numXpdGain, uint16_t xpdGainValues[]); 253 extern void ar5416WritePdadcValues(struct ath_hal *ah, int i, 254 uint8_t pdadcValues[]); 255 extern HAL_BOOL ar5416SetPowerCalTable(struct ath_hal *ah, 256 struct ar5416eeprom *pEepData, const struct ieee80211_channel *chan, 257 int16_t *pTxPowerIndexOffset); 258 259 extern HAL_BOOL ar5416StopTxDma(struct ath_hal *ah, u_int q); 260 extern HAL_BOOL ar5416SetupTxDesc(struct ath_hal *ah, struct ath_desc *ds, 261 u_int pktLen, u_int hdrLen, HAL_PKT_TYPE type, u_int txPower, 262 u_int txRate0, u_int txTries0, 263 u_int keyIx, u_int antMode, u_int flags, 264 u_int rtsctsRate, u_int rtsctsDuration, 265 u_int compicvLen, u_int compivLen, u_int comp); 266 extern HAL_BOOL ar5416SetupXTxDesc(struct ath_hal *, struct ath_desc *, 267 u_int txRate1, u_int txRetries1, 268 u_int txRate2, u_int txRetries2, 269 u_int txRate3, u_int txRetries3); 270 extern HAL_BOOL ar5416FillTxDesc(struct ath_hal *ah, struct ath_desc *ds, 271 u_int segLen, HAL_BOOL firstSeg, HAL_BOOL lastSeg, 272 const struct ath_desc *ds0); 273 extern HAL_STATUS ar5416ProcTxDesc(struct ath_hal *ah, 274 struct ath_desc *, struct ath_tx_status *); 275 extern HAL_BOOL ar5416GetTxCompletionRates(struct ath_hal *ah, 276 const struct ath_desc *ds0, int *rates, int *tries); 277 278 extern HAL_BOOL ar5416ResetTxQueue(struct ath_hal *ah, u_int q); 279 extern int ar5416SetupTxQueue(struct ath_hal *ah, HAL_TX_QUEUE type, 280 const HAL_TXQ_INFO *qInfo); 281 282 extern HAL_BOOL ar5416ChainTxDesc(struct ath_hal *ah, struct ath_desc *ds, 283 u_int pktLen, u_int hdrLen, HAL_PKT_TYPE type, u_int keyIx, 284 HAL_CIPHER cipher, uint8_t delims, u_int segLen, HAL_BOOL firstSeg, 285 HAL_BOOL lastSeg); 286 extern HAL_BOOL ar5416SetupFirstTxDesc(struct ath_hal *ah, struct ath_desc *ds, 287 u_int aggrLen, u_int flags, u_int txPower, u_int txRate0, u_int txTries0, 288 u_int antMode, u_int rtsctsRate, u_int rtsctsDuration); 289 extern HAL_BOOL ar5416SetupLastTxDesc(struct ath_hal *ah, struct ath_desc *ds, 290 const struct ath_desc *ds0); 291 extern HAL_BOOL ar5416SetGlobalTxTimeout(struct ath_hal *ah, u_int tu); 292 extern u_int ar5416GetGlobalTxTimeout(struct ath_hal *ah); 293 extern void ar5416Set11nRateScenario(struct ath_hal *ah, struct ath_desc *ds, 294 u_int durUpdateEn, u_int rtsctsRate, HAL_11N_RATE_SERIES series[], 295 u_int nseries, u_int flags); 296 extern void ar5416Set11nAggrMiddle(struct ath_hal *ah, struct ath_desc *ds, u_int numDelims); 297 extern void ar5416Clr11nAggr(struct ath_hal *ah, struct ath_desc *ds); 298 extern void ar5416Set11nBurstDuration(struct ath_hal *ah, struct ath_desc *ds, u_int burstDuration); 299 300 extern const HAL_RATE_TABLE *ar5416GetRateTable(struct ath_hal *, u_int mode); 301 #endif /* _ATH_AR5416_H_ */ 302