Deleted Added
full compact
ar9280_attach.c (218764) ar9280_attach.c (219393)
1/*
2 * Copyright (c) 2008-2009 Sam Leffler, Errno Consulting
3 * Copyright (c) 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 *
1/*
2 * Copyright (c) 2008-2009 Sam Leffler, Errno Consulting
3 * Copyright (c) 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: head/sys/dev/ath/ath_hal/ar9002/ar9280_attach.c 218764 2011-02-17 05:56:03Z adrian $
17 * $FreeBSD: head/sys/dev/ath/ath_hal/ar9002/ar9280_attach.c 219393 2011-03-08 06:59:59Z adrian $
18 */
19#include "opt_ah.h"
20
21#include "ah.h"
22#include "ah_internal.h"
23#include "ah_devid.h"
24
25#include "ah_eeprom_v14.h" /* XXX for tx/rx gain */
26
27#include "ar9002/ar9280.h"
28#include "ar5416/ar5416reg.h"
29#include "ar5416/ar5416phy.h"
30
31#include "ar9002/ar9280v1.ini"
32#include "ar9002/ar9280v2.ini"
18 */
19#include "opt_ah.h"
20
21#include "ah.h"
22#include "ah_internal.h"
23#include "ah_devid.h"
24
25#include "ah_eeprom_v14.h" /* XXX for tx/rx gain */
26
27#include "ar9002/ar9280.h"
28#include "ar5416/ar5416reg.h"
29#include "ar5416/ar5416phy.h"
30
31#include "ar9002/ar9280v1.ini"
32#include "ar9002/ar9280v2.ini"
33#include "ar9002/ar9280_olc.h"
33
34static const HAL_PERCAL_DATA ar9280_iq_cal = { /* single sample */
35 .calName = "IQ", .calType = IQ_MISMATCH_CAL,
36 .calNumSamples = MIN_CAL_SAMPLES,
37 .calCountMax = PER_MAX_LOG_COUNT,
38 .calCollect = ar5416IQCalCollect,
39 .calPostProc = ar5416IQCalibration
40};

--- 66 unchanged lines hidden (view full) ---

107 HAL_STATUS *status)
108{
109 struct ath_hal_9280 *ahp9280;
110 struct ath_hal_5212 *ahp;
111 struct ath_hal *ah;
112 uint32_t val;
113 HAL_STATUS ecode;
114 HAL_BOOL rfStatus;
34
35static const HAL_PERCAL_DATA ar9280_iq_cal = { /* single sample */
36 .calName = "IQ", .calType = IQ_MISMATCH_CAL,
37 .calNumSamples = MIN_CAL_SAMPLES,
38 .calCountMax = PER_MAX_LOG_COUNT,
39 .calCollect = ar5416IQCalCollect,
40 .calPostProc = ar5416IQCalibration
41};

--- 66 unchanged lines hidden (view full) ---

108 HAL_STATUS *status)
109{
110 struct ath_hal_9280 *ahp9280;
111 struct ath_hal_5212 *ahp;
112 struct ath_hal *ah;
113 uint32_t val;
114 HAL_STATUS ecode;
115 HAL_BOOL rfStatus;
116 int8_t pwr_table_offset;
115
116 HALDEBUG(AH_NULL, HAL_DEBUG_ATTACH, "%s: sc %p st %p sh %p\n",
117 __func__, sc, (void*) st, (void*) sh);
118
119 /* NB: memory is returned zero'd */
120 ahp9280 = ath_hal_malloc(sizeof (struct ath_hal_9280));
121 if (ahp9280 == AH_NULL) {
122 HALDEBUG(AH_NULL, HAL_DEBUG_ANY,

--- 14 unchanged lines hidden (view full) ---

137 AH5416(ah)->ah_cal.iqCalData.calData = &ar9280_iq_cal;
138 AH5416(ah)->ah_cal.adcGainCalData.calData = &ar9280_adc_gain_cal;
139 AH5416(ah)->ah_cal.adcDcCalData.calData = &ar9280_adc_dc_cal;
140 AH5416(ah)->ah_cal.adcDcCalInitData.calData = &ar9280_adc_init_dc_cal;
141 AH5416(ah)->ah_cal.suppCals = ADC_GAIN_CAL | ADC_DC_CAL | IQ_MISMATCH_CAL;
142
143 AH5416(ah)->ah_spurMitigate = ar9280SpurMitigate;
144 AH5416(ah)->ah_writeIni = ar9280WriteIni;
117
118 HALDEBUG(AH_NULL, HAL_DEBUG_ATTACH, "%s: sc %p st %p sh %p\n",
119 __func__, sc, (void*) st, (void*) sh);
120
121 /* NB: memory is returned zero'd */
122 ahp9280 = ath_hal_malloc(sizeof (struct ath_hal_9280));
123 if (ahp9280 == AH_NULL) {
124 HALDEBUG(AH_NULL, HAL_DEBUG_ANY,

--- 14 unchanged lines hidden (view full) ---

139 AH5416(ah)->ah_cal.iqCalData.calData = &ar9280_iq_cal;
140 AH5416(ah)->ah_cal.adcGainCalData.calData = &ar9280_adc_gain_cal;
141 AH5416(ah)->ah_cal.adcDcCalData.calData = &ar9280_adc_dc_cal;
142 AH5416(ah)->ah_cal.adcDcCalInitData.calData = &ar9280_adc_init_dc_cal;
143 AH5416(ah)->ah_cal.suppCals = ADC_GAIN_CAL | ADC_DC_CAL | IQ_MISMATCH_CAL;
144
145 AH5416(ah)->ah_spurMitigate = ar9280SpurMitigate;
146 AH5416(ah)->ah_writeIni = ar9280WriteIni;
147 AH5416(ah)->ah_olcInit = ar9280olcInit;
148 AH5416(ah)->ah_olcTempCompensation = ar9280olcTemperatureCompensation;
149 AH5416(ah)->ah_setPowerCalTable = ar9280SetPowerCalTable;
150
145 AH5416(ah)->ah_rx_chainmask = AR9280_DEFAULT_RXCHAINMASK;
146 AH5416(ah)->ah_tx_chainmask = AR9280_DEFAULT_TXCHAINMASK;
147
148 if (!ar5416SetResetReg(ah, HAL_RESET_POWER_ON)) {
149 /* reset chip */
150 HALDEBUG(ah, HAL_DEBUG_ANY, "%s: couldn't reset chip\n",
151 __func__);
152 ecode = HAL_EIO;

--- 82 unchanged lines hidden (view full) ---

235 }
236 rfStatus = ar9280RfAttach(ah, &ecode);
237 if (!rfStatus) {
238 HALDEBUG(ah, HAL_DEBUG_ANY, "%s: RF setup failed, status %u\n",
239 __func__, ecode);
240 goto bad;
241 }
242
151 AH5416(ah)->ah_rx_chainmask = AR9280_DEFAULT_RXCHAINMASK;
152 AH5416(ah)->ah_tx_chainmask = AR9280_DEFAULT_TXCHAINMASK;
153
154 if (!ar5416SetResetReg(ah, HAL_RESET_POWER_ON)) {
155 /* reset chip */
156 HALDEBUG(ah, HAL_DEBUG_ANY, "%s: couldn't reset chip\n",
157 __func__);
158 ecode = HAL_EIO;

--- 82 unchanged lines hidden (view full) ---

241 }
242 rfStatus = ar9280RfAttach(ah, &ecode);
243 if (!rfStatus) {
244 HALDEBUG(ah, HAL_DEBUG_ANY, "%s: RF setup failed, status %u\n",
245 __func__, ecode);
246 goto bad;
247 }
248
249 /*
250 * Check whether the power table offset isn't the default.
251 * This can occur with eeprom minor V21 or greater on Merlin.
252 */
253 (void) ath_hal_eepromGet(ah, AR_EEP_PWR_TABLE_OFFSET, &pwr_table_offset);
254 if (pwr_table_offset != AR5416_PWR_TABLE_OFFSET_DB) {
255 ath_hal_printf(ah, "ERROR: default pwr offset: %d dBm != EEPROM pwr offset: %d dBm\n",
256 AR5416_PWR_TABLE_OFFSET_DB, (int) pwr_table_offset);
257 ecode = HAL_ENOTSUPP;
258 goto bad;
259 }
260
243 if (AR_SREV_MERLIN_20_OR_LATER(ah)) {
244 /* setup rxgain table */
245 switch (ath_hal_eepromGet(ah, AR_EEP_RXGAIN_TYPE, AH_NULL)) {
246 case AR5416_EEP_RXGAIN_13dB_BACKOFF:
247 HAL_INI_INIT(&ahp9280->ah_ini_rxgain,
248 ar9280Modes_backoff_13db_rxgain_v2, 6);
249 break;
250 case AR5416_EEP_RXGAIN_23dB_BACKOFF:

--- 536 unchanged lines hidden ---
261 if (AR_SREV_MERLIN_20_OR_LATER(ah)) {
262 /* setup rxgain table */
263 switch (ath_hal_eepromGet(ah, AR_EEP_RXGAIN_TYPE, AH_NULL)) {
264 case AR5416_EEP_RXGAIN_13dB_BACKOFF:
265 HAL_INI_INIT(&ahp9280->ah_ini_rxgain,
266 ar9280Modes_backoff_13db_rxgain_v2, 6);
267 break;
268 case AR5416_EEP_RXGAIN_23dB_BACKOFF:

--- 536 unchanged lines hidden ---