1 1.1 cegger /* 2 1.1 cegger * Copyright (c) 2008-2009 Sam Leffler, Errno Consulting 3 1.1 cegger * Copyright (c) 2008 Atheros Communications, Inc. 4 1.1 cegger * 5 1.1 cegger * Permission to use, copy, modify, and/or distribute this software for any 6 1.1 cegger * purpose with or without fee is hereby granted, provided that the above 7 1.1 cegger * copyright notice and this permission notice appear in all copies. 8 1.1 cegger * 9 1.1 cegger * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 1.1 cegger * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 1.1 cegger * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 1.1 cegger * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 1.1 cegger * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 1.1 cegger * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15 1.1 cegger * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 1.1 cegger * 17 1.1 cegger * $FreeBSD: src/sys/dev/ath/ath_hal/ar5416/ar9285_attach.c,v 1.5 2010/06/01 15:33:10 rpaulo Exp $ 18 1.1 cegger */ 19 1.1 cegger #include "opt_ah.h" 20 1.1 cegger 21 1.1 cegger #include "ah.h" 22 1.1 cegger #include "ah_internal.h" 23 1.1 cegger #include "ah_devid.h" 24 1.1 cegger 25 1.1 cegger #include "ah_eeprom_v4k.h" /* XXX for tx/rx gain */ 26 1.1 cegger 27 1.1 cegger #include "ar5416/ar9280.h" 28 1.1 cegger #include "ar5416/ar9285.h" 29 1.1 cegger #include "ar5416/ar5416reg.h" 30 1.1 cegger #include "ar5416/ar5416phy.h" 31 1.1 cegger 32 1.1 cegger #include "ar5416/ar9285.ini" 33 1.1 cegger #include "ar5416/ar9285v2.ini" 34 1.1 cegger #include "ar5416/ar9280v2.ini" /* XXX ini for tx/rx gain */ 35 1.1 cegger 36 1.1 cegger static const HAL_PERCAL_DATA ar9280_iq_cal = { /* single sample */ 37 1.1 cegger .calName = "IQ", .calType = IQ_MISMATCH_CAL, 38 1.1 cegger .calNumSamples = MIN_CAL_SAMPLES, 39 1.1 cegger .calCountMax = PER_MAX_LOG_COUNT, 40 1.1 cegger .calCollect = ar5416IQCalCollect, 41 1.1 cegger .calPostProc = ar5416IQCalibration 42 1.1 cegger }; 43 1.1 cegger static const HAL_PERCAL_DATA ar9280_adc_gain_cal = { /* single sample */ 44 1.1 cegger .calName = "ADC Gain", .calType = ADC_GAIN_CAL, 45 1.1 cegger .calNumSamples = MIN_CAL_SAMPLES, 46 1.1 cegger .calCountMax = PER_MIN_LOG_COUNT, 47 1.1 cegger .calCollect = ar5416AdcGainCalCollect, 48 1.1 cegger .calPostProc = ar5416AdcGainCalibration 49 1.1 cegger }; 50 1.1 cegger static const HAL_PERCAL_DATA ar9280_adc_dc_cal = { /* single sample */ 51 1.1 cegger .calName = "ADC DC", .calType = ADC_DC_CAL, 52 1.1 cegger .calNumSamples = MIN_CAL_SAMPLES, 53 1.1 cegger .calCountMax = PER_MIN_LOG_COUNT, 54 1.1 cegger .calCollect = ar5416AdcDcCalCollect, 55 1.1 cegger .calPostProc = ar5416AdcDcCalibration 56 1.1 cegger }; 57 1.1 cegger static const HAL_PERCAL_DATA ar9280_adc_init_dc_cal = { 58 1.1 cegger .calName = "ADC Init DC", .calType = ADC_DC_INIT_CAL, 59 1.1 cegger .calNumSamples = MIN_CAL_SAMPLES, 60 1.1 cegger .calCountMax = INIT_LOG_COUNT, 61 1.1 cegger .calCollect = ar5416AdcDcCalCollect, 62 1.1 cegger .calPostProc = ar5416AdcDcCalibration 63 1.1 cegger }; 64 1.1 cegger 65 1.1 cegger static void ar9285ConfigPCIE(struct ath_hal *ah, HAL_BOOL restore); 66 1.1 cegger static HAL_BOOL ar9285FillCapabilityInfo(struct ath_hal *ah); 67 1.1 cegger static void ar9285WriteIni(struct ath_hal *ah, 68 1.1 cegger HAL_CHANNEL_INTERNAL *chan); 69 1.1 cegger 70 1.1 cegger static void 71 1.1 cegger ar9285AniSetup(struct ath_hal *ah) 72 1.1 cegger { 73 1.1 cegger /* NB: disable ANI for reliable RIFS rx */ 74 1.1 cegger ar5212AniAttach(ah, AH_NULL, AH_NULL, AH_FALSE); 75 1.1 cegger } 76 1.1 cegger 77 1.1 cegger /* 78 1.1 cegger * Attach for an AR9285 part. 79 1.1 cegger */ 80 1.1 cegger static struct ath_hal * 81 1.1 cegger ar9285Attach(uint16_t devid, HAL_SOFTC sc, 82 1.1 cegger HAL_BUS_TAG st, HAL_BUS_HANDLE sh, HAL_STATUS *status) 83 1.1 cegger { 84 1.1 cegger struct ath_hal_9285 *ahp9285; 85 1.1 cegger struct ath_hal_5212 *ahp; 86 1.1 cegger struct ath_hal *ah; 87 1.1 cegger uint32_t val; 88 1.1 cegger HAL_STATUS ecode; 89 1.1 cegger HAL_BOOL rfStatus; 90 1.1 cegger 91 1.1 cegger HALDEBUG(AH_NULL, HAL_DEBUG_ATTACH, "%s: sc %p st %p sh %p\n", 92 1.1 cegger __func__, sc, (void*) st, (void*) sh); 93 1.1 cegger 94 1.1 cegger /* NB: memory is returned zero'd */ 95 1.1 cegger ahp9285 = ath_hal_malloc(sizeof (struct ath_hal_9285)); 96 1.1 cegger if (ahp9285 == AH_NULL) { 97 1.1 cegger HALDEBUG(AH_NULL, HAL_DEBUG_ANY, 98 1.1 cegger "%s: cannot allocate memory for state block\n", __func__); 99 1.1 cegger *status = HAL_ENOMEM; 100 1.1 cegger return AH_NULL; 101 1.1 cegger } 102 1.1 cegger ahp = AH5212(ahp9285); 103 1.1 cegger ah = &ahp->ah_priv.h; 104 1.1 cegger 105 1.1 cegger ar5416InitState(AH5416(ah), devid, sc, st, sh, status); 106 1.1 cegger 107 1.1 cegger /* XXX override with 9285 specific state */ 108 1.1 cegger /* override 5416 methods for our needs */ 109 1.1 cegger ah->ah_setAntennaSwitch = ar9285SetAntennaSwitch; 110 1.1 cegger ah->ah_configPCIE = ar9285ConfigPCIE; 111 1.1 cegger ah->ah_setTxPower = ar9285SetTransmitPower; 112 1.1 cegger ah->ah_setBoardValues = ar9285SetBoardValues; 113 1.1 cegger 114 1.1 cegger AH5416(ah)->ah_cal.iqCalData.calData = &ar9280_iq_cal; 115 1.1 cegger AH5416(ah)->ah_cal.adcGainCalData.calData = &ar9280_adc_gain_cal; 116 1.1 cegger AH5416(ah)->ah_cal.adcDcCalData.calData = &ar9280_adc_dc_cal; 117 1.1 cegger AH5416(ah)->ah_cal.adcDcCalInitData.calData = &ar9280_adc_init_dc_cal; 118 1.1 cegger AH5416(ah)->ah_cal.suppCals = ADC_GAIN_CAL | ADC_DC_CAL | IQ_MISMATCH_CAL; 119 1.1 cegger 120 1.1 cegger AH5416(ah)->ah_spurMitigate = ar9280SpurMitigate; 121 1.1 cegger AH5416(ah)->ah_writeIni = ar9285WriteIni; 122 1.1 cegger AH5416(ah)->ah_rx_chainmask = AR9285_DEFAULT_RXCHAINMASK; 123 1.1 cegger AH5416(ah)->ah_tx_chainmask = AR9285_DEFAULT_TXCHAINMASK; 124 1.1 cegger 125 1.1 cegger ahp->ah_maxTxTrigLev = MAX_TX_FIFO_THRESHOLD >> 1; 126 1.1 cegger 127 1.1 cegger if (!ar5416SetResetReg(ah, HAL_RESET_POWER_ON)) { 128 1.1 cegger /* reset chip */ 129 1.1 cegger HALDEBUG(ah, HAL_DEBUG_ANY, "%s: couldn't reset chip\n", 130 1.1 cegger __func__); 131 1.1 cegger ecode = HAL_EIO; 132 1.1 cegger goto bad; 133 1.1 cegger } 134 1.1 cegger 135 1.1 cegger if (!ar5416SetPowerMode(ah, HAL_PM_AWAKE, AH_TRUE)) { 136 1.1 cegger HALDEBUG(ah, HAL_DEBUG_ANY, "%s: couldn't wakeup chip\n", 137 1.1 cegger __func__); 138 1.1 cegger ecode = HAL_EIO; 139 1.1 cegger goto bad; 140 1.1 cegger } 141 1.1 cegger /* Read Revisions from Chips before taking out of reset */ 142 1.1 cegger val = OS_REG_READ(ah, AR_SREV); 143 1.1 cegger HALDEBUG(ah, HAL_DEBUG_ATTACH, 144 1.1 cegger "%s: ID 0x%x VERSION 0x%x TYPE 0x%x REVISION 0x%x\n", 145 1.1 cegger __func__, MS(val, AR_XSREV_ID), MS(val, AR_XSREV_VERSION), 146 1.1 cegger MS(val, AR_XSREV_TYPE), MS(val, AR_XSREV_REVISION)); 147 1.1 cegger /* NB: include chip type to differentiate from pre-Sowl versions */ 148 1.1 cegger AH_PRIVATE(ah)->ah_macVersion = 149 1.1 cegger (val & AR_XSREV_VERSION) >> AR_XSREV_TYPE_S; 150 1.1 cegger AH_PRIVATE(ah)->ah_macRev = MS(val, AR_XSREV_REVISION); 151 1.1 cegger AH_PRIVATE(ah)->ah_ispcie = (val & AR_XSREV_TYPE_HOST_MODE) == 0; 152 1.1 cegger 153 1.1 cegger /* setup common ini data; rf backends handle remainder */ 154 1.1 cegger if (AR_SREV_KITE_12_OR_LATER(ah)) { 155 1.1 cegger HAL_INI_INIT(&ahp->ah_ini_modes, ar9285Modes_v2, 6); 156 1.1 cegger HAL_INI_INIT(&ahp->ah_ini_common, ar9285Common_v2, 2); 157 1.1 cegger HAL_INI_INIT(&AH5416(ah)->ah_ini_pcieserdes, 158 1.1 cegger ar9285PciePhy_clkreq_always_on_L1_v2, 2); 159 1.1 cegger } else { 160 1.1 cegger HAL_INI_INIT(&ahp->ah_ini_modes, ar9285Modes, 6); 161 1.1 cegger HAL_INI_INIT(&ahp->ah_ini_common, ar9285Common, 2); 162 1.1 cegger HAL_INI_INIT(&AH5416(ah)->ah_ini_pcieserdes, 163 1.1 cegger ar9285PciePhy_clkreq_always_on_L1, 2); 164 1.1 cegger } 165 1.1 cegger ar5416AttachPCIE(ah); 166 1.1 cegger 167 1.1 cegger ecode = ath_hal_v4kEepromAttach(ah); 168 1.1 cegger if (ecode != HAL_OK) 169 1.1 cegger goto bad; 170 1.1 cegger 171 1.1 cegger if (!ar5416ChipReset(ah, AH_NULL)) { /* reset chip */ 172 1.1 cegger HALDEBUG(ah, HAL_DEBUG_ANY, "%s: chip reset failed\n", 173 1.1 cegger __func__); 174 1.1 cegger ecode = HAL_EIO; 175 1.1 cegger goto bad; 176 1.1 cegger } 177 1.1 cegger 178 1.1 cegger AH_PRIVATE(ah)->ah_phyRev = OS_REG_READ(ah, AR_PHY_CHIP_ID); 179 1.1 cegger 180 1.1 cegger if (!ar5212ChipTest(ah)) { 181 1.1 cegger HALDEBUG(ah, HAL_DEBUG_ANY, "%s: hardware self-test failed\n", 182 1.1 cegger __func__); 183 1.1 cegger ecode = HAL_ESELFTEST; 184 1.1 cegger goto bad; 185 1.1 cegger } 186 1.1 cegger 187 1.1 cegger /* 188 1.1 cegger * Set correct Baseband to analog shift 189 1.1 cegger * setting to access analog chips. 190 1.1 cegger */ 191 1.1 cegger OS_REG_WRITE(ah, AR_PHY(0), 0x00000007); 192 1.1 cegger 193 1.1 cegger /* Read Radio Chip Rev Extract */ 194 1.1 cegger AH_PRIVATE(ah)->ah_analog5GhzRev = ar5416GetRadioRev(ah); 195 1.1 cegger switch (AH_PRIVATE(ah)->ah_analog5GhzRev & AR_RADIO_SREV_MAJOR) { 196 1.1 cegger case AR_RAD2133_SREV_MAJOR: /* Sowl: 2G/3x3 */ 197 1.1 cegger case AR_RAD5133_SREV_MAJOR: /* Sowl: 2+5G/3x3 */ 198 1.1 cegger break; 199 1.1 cegger default: 200 1.1 cegger if (AH_PRIVATE(ah)->ah_analog5GhzRev == 0) { 201 1.1 cegger AH_PRIVATE(ah)->ah_analog5GhzRev = 202 1.1 cegger AR_RAD5133_SREV_MAJOR; 203 1.1 cegger break; 204 1.1 cegger } 205 1.1 cegger #ifdef AH_DEBUG 206 1.1 cegger HALDEBUG(ah, HAL_DEBUG_ANY, 207 1.1 cegger "%s: 5G Radio Chip Rev 0x%02X is not supported by " 208 1.1 cegger "this driver\n", __func__, 209 1.1 cegger AH_PRIVATE(ah)->ah_analog5GhzRev); 210 1.1 cegger ecode = HAL_ENOTSUPP; 211 1.1 cegger goto bad; 212 1.1 cegger #endif 213 1.1 cegger } 214 1.1 cegger rfStatus = ar9285RfAttach(ah, &ecode); 215 1.1 cegger if (!rfStatus) { 216 1.1 cegger HALDEBUG(ah, HAL_DEBUG_ANY, "%s: RF setup failed, status %u\n", 217 1.1 cegger __func__, ecode); 218 1.1 cegger goto bad; 219 1.1 cegger } 220 1.1 cegger 221 1.1 cegger HAL_INI_INIT(&ahp9285->ah_ini_rxgain, ar9280Modes_original_rxgain_v2, 222 1.1 cegger 6); 223 1.1 cegger /* setup txgain table */ 224 1.1 cegger switch (ath_hal_eepromGet(ah, AR_EEP_TXGAIN_TYPE, AH_NULL)) { 225 1.1 cegger case AR5416_EEP_TXGAIN_HIGH_POWER: 226 1.1 cegger HAL_INI_INIT(&ahp9285->ah_ini_txgain, 227 1.1 cegger ar9285Modes_high_power_tx_gain_v2, 6); 228 1.1 cegger break; 229 1.1 cegger case AR5416_EEP_TXGAIN_ORIG: 230 1.1 cegger HAL_INI_INIT(&ahp9285->ah_ini_txgain, 231 1.1 cegger ar9285Modes_original_tx_gain_v2, 6); 232 1.1 cegger break; 233 1.1 cegger default: 234 1.1 cegger HALASSERT(AH_FALSE); 235 1.1 cegger goto bad; /* XXX ? try to continue */ 236 1.1 cegger } 237 1.1 cegger 238 1.1 cegger /* 239 1.1 cegger * Got everything we need now to setup the capabilities. 240 1.1 cegger */ 241 1.1 cegger if (!ar9285FillCapabilityInfo(ah)) { 242 1.1 cegger ecode = HAL_EEREAD; 243 1.1 cegger goto bad; 244 1.1 cegger } 245 1.1 cegger 246 1.1 cegger ecode = ath_hal_eepromGet(ah, AR_EEP_MACADDR, ahp->ah_macaddr); 247 1.1 cegger if (ecode != HAL_OK) { 248 1.1 cegger HALDEBUG(ah, HAL_DEBUG_ANY, 249 1.1 cegger "%s: error getting mac address from EEPROM\n", __func__); 250 1.1 cegger goto bad; 251 1.1 cegger } 252 1.1 cegger /* XXX How about the serial number ? */ 253 1.1 cegger /* Read Reg Domain */ 254 1.1 cegger AH_PRIVATE(ah)->ah_currentRD = 255 1.1 cegger ath_hal_eepromGet(ah, AR_EEP_REGDMN_0, AH_NULL); 256 1.1 cegger 257 1.1 cegger /* 258 1.1 cegger * ah_miscMode is populated by ar5416FillCapabilityInfo() 259 1.1 cegger * starting from griffin. Set here to make sure that 260 1.1 cegger * AR_MISC_MODE_MIC_NEW_LOC_ENABLE is set before a GTK is 261 1.1 cegger * placed into hardware. 262 1.1 cegger */ 263 1.1 cegger if (ahp->ah_miscMode != 0) 264 1.1 cegger OS_REG_WRITE(ah, AR_MISC_MODE, ahp->ah_miscMode); 265 1.1 cegger 266 1.1 cegger ar9285AniSetup(ah); /* Anti Noise Immunity */ 267 1.1 cegger ar5416InitNfHistBuff(AH5416(ah)->ah_cal.nfCalHist); 268 1.1 cegger 269 1.1 cegger HALDEBUG(ah, HAL_DEBUG_ATTACH, "%s: return\n", __func__); 270 1.1 cegger 271 1.1 cegger return ah; 272 1.1 cegger bad: 273 1.1 cegger if (ah != AH_NULL) 274 1.1 cegger ah->ah_detach(ah); 275 1.1 cegger if (status) 276 1.1 cegger *status = ecode; 277 1.1 cegger return AH_NULL; 278 1.1 cegger } 279 1.1 cegger 280 1.1 cegger static void 281 1.1 cegger ar9285ConfigPCIE(struct ath_hal *ah, HAL_BOOL restore) 282 1.1 cegger { 283 1.1 cegger if (AH_PRIVATE(ah)->ah_ispcie && !restore) { 284 1.1 cegger ath_hal_ini_write(ah, &AH5416(ah)->ah_ini_pcieserdes, 1, 0); 285 1.1 cegger OS_DELAY(1000); 286 1.1 cegger OS_REG_SET_BIT(ah, AR_PCIE_PM_CTRL, AR_PCIE_PM_CTRL_ENA); 287 1.1 cegger OS_REG_WRITE(ah, AR_WA, AR9285_WA_DEFAULT); 288 1.1 cegger } 289 1.1 cegger } 290 1.1 cegger 291 1.1 cegger static void 292 1.1 cegger ar9285WriteIni(struct ath_hal *ah, HAL_CHANNEL_INTERNAL *chan) 293 1.1 cegger { 294 1.2 martin u_int modesIndex; 295 1.1 cegger int regWrites = 0; 296 1.1 cegger 297 1.1 cegger /* Setup the indices for the next set of register array writes */ 298 1.1 cegger /* XXX Ignore 11n dynamic mode on the AR5416 for the moment */ 299 1.1 cegger if (IS_CHAN_HT40(chan)) 300 1.1 cegger modesIndex = 3; 301 1.1 cegger else if (IS_CHAN_108G(chan)) 302 1.1 cegger modesIndex = 5; 303 1.1 cegger else 304 1.1 cegger modesIndex = 4; 305 1.1 cegger 306 1.1 cegger /* Set correct Baseband to analog shift setting to access analog chips. */ 307 1.1 cegger OS_REG_WRITE(ah, AR_PHY(0), 0x00000007); 308 1.1 cegger OS_REG_WRITE(ah, AR_PHY_ADC_SERIAL_CTL, AR_PHY_SEL_INTERNAL_ADDAC); 309 1.1 cegger regWrites = ath_hal_ini_write(ah, &AH5212(ah)->ah_ini_modes, 310 1.1 cegger modesIndex, regWrites); 311 1.1 cegger if (AR_SREV_KITE_12_OR_LATER(ah)) { 312 1.1 cegger regWrites = ath_hal_ini_write(ah, &AH9285(ah)->ah_ini_txgain, 313 1.1 cegger modesIndex, regWrites); 314 1.1 cegger } 315 1.1 cegger regWrites = ath_hal_ini_write(ah, &AH5212(ah)->ah_ini_common, 316 1.1 cegger 1, regWrites); 317 1.1 cegger 318 1.1 cegger OS_REG_SET_BIT(ah, AR_DIAG_SW, (AR_DIAG_RX_DIS | AR_DIAG_RX_ABORT)); 319 1.1 cegger 320 1.1 cegger if (AR_SREV_MERLIN_10_OR_LATER(ah)) { 321 1.1 cegger uint32_t val; 322 1.1 cegger val = OS_REG_READ(ah, AR_PCU_MISC_MODE2) & 323 1.1 cegger (~AR_PCU_MISC_MODE2_HWWAR1); 324 1.1 cegger OS_REG_WRITE(ah, AR_PCU_MISC_MODE2, val); 325 1.1 cegger OS_REG_WRITE(ah, 0x9800 + (651 << 2), 0x11); 326 1.1 cegger } 327 1.1 cegger 328 1.1 cegger } 329 1.1 cegger 330 1.1 cegger /* 331 1.1 cegger * Fill all software cached or static hardware state information. 332 1.1 cegger * Return failure if capabilities are to come from EEPROM and 333 1.1 cegger * cannot be read. 334 1.1 cegger */ 335 1.1 cegger static HAL_BOOL 336 1.1 cegger ar9285FillCapabilityInfo(struct ath_hal *ah) 337 1.1 cegger { 338 1.1 cegger HAL_CAPABILITIES *pCap = &AH_PRIVATE(ah)->ah_caps; 339 1.1 cegger 340 1.1 cegger if (!ar5416FillCapabilityInfo(ah)) 341 1.1 cegger return AH_FALSE; 342 1.1 cegger pCap->halNumGpioPins = 12; 343 1.1 cegger pCap->halWowSupport = AH_TRUE; 344 1.1 cegger pCap->halWowMatchPatternExact = AH_TRUE; 345 1.1 cegger #if 0 346 1.1 cegger pCap->halWowMatchPatternDword = AH_TRUE; 347 1.1 cegger #endif 348 1.1 cegger pCap->halCSTSupport = AH_TRUE; 349 1.1 cegger pCap->halRifsRxSupport = AH_TRUE; 350 1.1 cegger pCap->halRifsTxSupport = AH_TRUE; 351 1.1 cegger pCap->halRtsAggrLimit = 64*1024; /* 802.11n max */ 352 1.1 cegger pCap->halExtChanDfsSupport = AH_TRUE; 353 1.1 cegger #if 0 354 1.1 cegger /* XXX bluetooth */ 355 1.1 cegger pCap->halBtCoexSupport = AH_TRUE; 356 1.1 cegger #endif 357 1.1 cegger pCap->halAutoSleepSupport = AH_FALSE; /* XXX? */ 358 1.1 cegger #if 0 359 1.1 cegger pCap->hal4kbSplitTransSupport = AH_FALSE; 360 1.1 cegger #endif 361 1.1 cegger pCap->halRxStbcSupport = 1; 362 1.1 cegger pCap->halTxStbcSupport = 1; 363 1.1 cegger 364 1.1 cegger return AH_TRUE; 365 1.1 cegger } 366 1.1 cegger 367 1.1 cegger HAL_BOOL 368 1.1 cegger ar9285SetAntennaSwitch(struct ath_hal *ah, HAL_ANT_SETTING settings) 369 1.1 cegger { 370 1.1 cegger #define ANTENNA0_CHAINMASK 0x1 371 1.1 cegger #define ANTENNA1_CHAINMASK 0x2 372 1.1 cegger struct ath_hal_5416 *ahp = AH5416(ah); 373 1.1 cegger 374 1.1 cegger /* Antenna selection is done by setting the tx/rx chainmasks approp. */ 375 1.1 cegger switch (settings) { 376 1.1 cegger case HAL_ANT_FIXED_A: 377 1.1 cegger /* Enable first antenna only */ 378 1.1 cegger ahp->ah_tx_chainmask = ANTENNA0_CHAINMASK; 379 1.1 cegger ahp->ah_rx_chainmask = ANTENNA0_CHAINMASK; 380 1.1 cegger break; 381 1.1 cegger case HAL_ANT_FIXED_B: 382 1.1 cegger /* Enable second antenna only, after checking capability */ 383 1.1 cegger if (AH_PRIVATE(ah)->ah_caps.halTxChainMask > ANTENNA1_CHAINMASK) 384 1.1 cegger ahp->ah_tx_chainmask = ANTENNA1_CHAINMASK; 385 1.1 cegger ahp->ah_rx_chainmask = ANTENNA1_CHAINMASK; 386 1.1 cegger break; 387 1.1 cegger case HAL_ANT_VARIABLE: 388 1.1 cegger /* Restore original chainmask settings */ 389 1.1 cegger /* XXX */ 390 1.1 cegger ahp->ah_tx_chainmask = AR9285_DEFAULT_TXCHAINMASK; 391 1.1 cegger ahp->ah_rx_chainmask = AR9285_DEFAULT_RXCHAINMASK; 392 1.1 cegger break; 393 1.1 cegger } 394 1.1 cegger return AH_TRUE; 395 1.1 cegger #undef ANTENNA0_CHAINMASK 396 1.1 cegger #undef ANTENNA1_CHAINMASK 397 1.1 cegger } 398 1.1 cegger 399 1.1 cegger static const char* 400 1.1 cegger ar9285Probe(uint16_t vendorid, uint16_t devid) 401 1.1 cegger { 402 1.1 cegger if (vendorid == ATHEROS_VENDOR_ID && devid == AR9285_DEVID_PCIE) 403 1.1 cegger return "Atheros 9285"; 404 1.1 cegger return AH_NULL; 405 1.1 cegger } 406 1.1 cegger AH_CHIP(AR9285, ar9285Probe, ar9285Attach); 407