2 * Copyright (c) 2002-2008 Sam Leffler, Errno Consulting
3 * Copyright (c) 2002-2008 Atheros Communications, Inc.
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.
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.
19 #ifndef _ATH_AR5416_H_
20 #define _ATH_AR5416_H_
22 #include "ar5212/ar5212.h"
24 #define AR5416_MAGIC 0x20065416
33 uint16_t synth_center
;
38 #define AR5416_DEFAULT_RXCHAINMASK 7
39 #define AR5416_DEFAULT_TXCHAINMASK 1
40 #define AR5416_MAX_RATE_POWER 63
41 #define AR5416_KEYTABLE_SIZE 128
43 #define AR5416_NUM_NF_READINGS 6 /* (3 chains * (ctl + ext) */
44 #define AR5416_CCA_MAX_GOOD_VALUE -85
45 #define AR5416_CCA_MAX_HIGH_VALUE -62
46 #define AR5416_CCA_MIN_BAD_VALUE -140
48 #define INIT_CAL(_perCal) do { \
49 (_perCal)->calState = CAL_WAITING; \
50 (_perCal)->calNext = AH_NULL; \
53 #define INSERT_CAL(_ahp, _perCal) do { \
54 if ((_ahp)->ah_cal_last == AH_NULL) { \
55 (_ahp)->ah_cal_list = (_ahp)->ah_cal_last = (_perCal); \
56 ((_ahp)->ah_cal_last)->calNext = (_perCal); \
58 ((_ahp)->ah_cal_last)->calNext = (_perCal); \
59 (_ahp)->ah_cal_last = (_perCal); \
60 (_perCal)->calNext = (_ahp)->ah_cal_list; \
64 typedef enum cal_types
{
65 ADC_DC_INIT_CAL
= 0x1,
72 typedef enum cal_state
{
84 #define MIN_CAL_SAMPLES 1
85 #define MAX_CAL_SAMPLES 64
86 #define INIT_LOG_COUNT 5
87 #define PER_MIN_LOG_COUNT 2
88 #define PER_MAX_LOG_COUNT 10
90 /* Per Calibration data structure */
91 typedef struct per_cal_data
{
92 const char *calName
; /* for diagnostics */
93 HAL_CAL_TYPE calType
; /* Type of calibration */
94 uint32_t calNumSamples
; /* # SW samples to collect */
95 uint32_t calCountMax
; /* # HW samples to collect */
96 void (*calCollect
)(struct ath_hal
*); /* Accumulator function */
97 /* Post-processing function */
98 void (*calPostProc
)(struct ath_hal
*, uint8_t);
101 /* List structure for calibration data */
102 typedef struct cal_list
{
103 struct cal_list
*calNext
;
104 HAL_CAL_STATE calState
;
105 const HAL_PERCAL_DATA
*calData
;
108 struct ath_hal_5416
{
109 struct ath_hal_5212 ah_5212
;
111 /* NB: RF data setup at attach */
112 HAL_INI_ARRAY ah_ini_bb_rfgain
;
113 HAL_INI_ARRAY ah_ini_bank0
;
114 HAL_INI_ARRAY ah_ini_bank1
;
115 HAL_INI_ARRAY ah_ini_bank2
;
116 HAL_INI_ARRAY ah_ini_bank3
;
117 HAL_INI_ARRAY ah_ini_bank6
;
118 HAL_INI_ARRAY ah_ini_bank7
;
119 HAL_INI_ARRAY ah_ini_addac
;
121 u_int ah_globaltxtimeout
; /* global tx timeout */
123 int ah_hangs
; /* h/w hangs state */
124 uint8_t ah_keytype
[AR5416_KEYTABLE_SIZE
];
126 * Extension Channel Rx Clear State
128 uint32_t ah_cycleCount
;
131 uint32_t ah_rx_chainmask
;
132 uint32_t ah_tx_chainmask
;
134 * Periodic calibration state.
136 HAL_CAL_TYPE ah_suppCals
;
137 HAL_CAL_LIST ah_iqCalData
;
138 HAL_CAL_LIST ah_adcGainCalData
;
139 HAL_CAL_LIST ah_adcDcCalInitData
;
140 HAL_CAL_LIST ah_adcDcCalData
;
141 HAL_CAL_LIST
*ah_cal_list
;
142 HAL_CAL_LIST
*ah_cal_last
;
143 HAL_CAL_LIST
*ah_cal_curr
;
144 #define AR5416_MAX_CHAINS 3 /* XXX dup's eeprom def */
145 HAL_CAL_SAMPLE ah_caldata
[4][AR5416_MAX_CHAINS
];
148 * Noise floor cal histogram support.
149 * XXX be nice to re-use space in ar5212
151 struct ar5212NfCalHist ah_nfCalHist
[AR5416_NUM_NF_READINGS
];
153 #define AH5416(_ah) ((struct ath_hal_5416 *)(_ah))
156 #define ah_totalPowerMeasI(i) ah_caldata[0][i].u
157 #define ah_totalPowerMeasQ(i) ah_caldata[1][i].u
158 #define ah_totalIqCorrMeas(i) ah_caldata[2][i].s
159 /* Adc Gain Cal aliases */
160 #define ah_totalAdcIOddPhase(i) ah_caldata[0][i].u
161 #define ah_totalAdcIEvenPhase(i) ah_caldata[1][i].u
162 #define ah_totalAdcQOddPhase(i) ah_caldata[2][i].u
163 #define ah_totalAdcQEvenPhase(i) ah_caldata[3][i].u
164 /* Adc DC Offset Cal aliases */
165 #define ah_totalAdcDcOffsetIOddPhase(i) ah_caldata[0][i].s
166 #define ah_totalAdcDcOffsetIEvenPhase(i) ah_caldata[1][i].s
167 #define ah_totalAdcDcOffsetQOddPhase(i) ah_caldata[2][i].s
168 #define ah_totalAdcDcOffsetQEvenPhase(i) ah_caldata[3][i].s
170 #define IS_5416_PCI(ah) ((AH_PRIVATE(ah)->ah_macVersion) == AR_SREV_VERSION_OWL_PCI)
171 #define IS_5416_PCIE(ah) ((AH_PRIVATE(ah)->ah_macVersion) == AR_SREV_VERSION_OWL_PCIE)
173 #define IS_PCIE(ah) (IS_5416_PCIE(ah))
175 extern HAL_BOOL
ar2133RfAttach(struct ath_hal
*, HAL_STATUS
*);
179 extern struct ath_hal
* ar5416Attach(uint16_t devid
, HAL_SOFTC sc
,
180 HAL_BUS_TAG st
, HAL_BUS_HANDLE sh
, HAL_STATUS
*status
);
181 extern void ar5416InitState(struct ath_hal_5416
*, uint16_t devid
,
182 HAL_SOFTC sc
, HAL_BUS_TAG st
, HAL_BUS_HANDLE sh
,
184 extern void ar5416Detach(struct ath_hal
*ah
);
185 extern HAL_BOOL
ar5416FillCapabilityInfo(struct ath_hal
*ah
);
187 #define IS_5GHZ_FAST_CLOCK_EN(_ah, _c) \
188 (IS_CHAN_5GHZ(_c) && ath_hal_eepromGetFlag(ah, AR_EEP_FSTCLK_5G))
190 extern HAL_BOOL
ar5416AniAttach(struct ath_hal
*ah
);
191 extern void ar5416AniDetach(struct ath_hal
*ah
);
193 extern void ar5416SetBeaconTimers(struct ath_hal
*, const HAL_BEACON_TIMERS
*);
194 extern void ar5416BeaconInit(struct ath_hal
*ah
,
195 uint32_t next_beacon
, uint32_t beacon_period
);
196 extern void ar5416ResetStaBeaconTimers(struct ath_hal
*ah
);
197 extern void ar5416SetStaBeaconTimers(struct ath_hal
*ah
,
198 const HAL_BEACON_STATE
*);
200 extern HAL_BOOL
ar5416EepromRead(struct ath_hal
*, u_int off
, uint16_t *data
);
201 extern HAL_BOOL
ar5416EepromWrite(struct ath_hal
*, u_int off
, uint16_t data
);
203 extern HAL_BOOL
ar5416IsInterruptPending(struct ath_hal
*ah
);
204 extern HAL_BOOL
ar5416GetPendingInterrupts(struct ath_hal
*, HAL_INT
*masked
);
205 extern HAL_INT
ar5416SetInterrupts(struct ath_hal
*ah
, HAL_INT ints
);
207 extern HAL_BOOL
ar5416GpioCfgOutput(struct ath_hal
*, uint32_t gpio
);
208 extern HAL_BOOL
ar5416GpioCfgInput(struct ath_hal
*, uint32_t gpio
);
209 extern HAL_BOOL
ar5416GpioSet(struct ath_hal
*, uint32_t gpio
, uint32_t val
);
210 extern uint32_t ar5416GpioGet(struct ath_hal
*ah
, uint32_t gpio
);
211 extern void ar5416GpioSetIntr(struct ath_hal
*ah
, u_int
, uint32_t ilevel
);
213 extern u_int
ar5416GetWirelessModes(struct ath_hal
*ah
);
214 extern void ar5416SetLedState(struct ath_hal
*ah
, HAL_LED_STATE state
);
215 extern void ar5416ResetTsf(struct ath_hal
*ah
);
216 extern HAL_BOOL
ar5416SetAntennaSwitch(struct ath_hal
*, HAL_ANT_SETTING
);
217 extern HAL_BOOL
ar5416SetDecompMask(struct ath_hal
*, uint16_t, int);
218 extern void ar5416SetCoverageClass(struct ath_hal
*, uint8_t, int);
219 extern uint32_t ar5416Get11nExtBusy(struct ath_hal
*ah
);
220 extern void ar5416Set11nMac2040(struct ath_hal
*ah
, HAL_HT_MACMODE mode
);
221 extern HAL_HT_RXCLEAR
ar5416Get11nRxClear(struct ath_hal
*ah
);
222 extern void ar5416Set11nRxClear(struct ath_hal
*ah
, HAL_HT_RXCLEAR rxclear
);
223 extern HAL_STATUS
ar5416GetCapability(struct ath_hal
*ah
,
224 HAL_CAPABILITY_TYPE type
, uint32_t capability
, uint32_t *result
);
225 extern HAL_BOOL
ar5416GetDiagState(struct ath_hal
*ah
, int request
,
226 const void *args
, uint32_t argsize
,
227 void **result
, uint32_t *resultsize
);
229 extern HAL_BOOL
ar5416SetPowerMode(struct ath_hal
*ah
, HAL_POWER_MODE mode
,
231 extern HAL_POWER_MODE
ar5416GetPowerMode(struct ath_hal
*ah
);
232 extern HAL_BOOL
ar5416GetPowerStatus(struct ath_hal
*ah
);
234 extern HAL_BOOL
ar5416ResetKeyCacheEntry(struct ath_hal
*ah
, uint16_t entry
);
235 extern HAL_BOOL
ar5416SetKeyCacheEntry(struct ath_hal
*ah
, uint16_t entry
,
236 const HAL_KEYVAL
*k
, const uint8_t *mac
, int xorKey
);
238 extern void ar5416StartPcuReceive(struct ath_hal
*ah
);
239 extern void ar5416StopPcuReceive(struct ath_hal
*ah
);
240 extern HAL_BOOL
ar5416SetupRxDesc(struct ath_hal
*,
241 struct ath_desc
*, uint32_t size
, u_int flags
);
242 extern HAL_STATUS
ar5416ProcRxDesc(struct ath_hal
*ah
, struct ath_desc
*,
243 uint32_t, struct ath_desc
*, uint64_t,
244 struct ath_rx_status
*);
246 extern HAL_BOOL
ar5416Reset(struct ath_hal
*ah
, HAL_OPMODE opmode
,
247 HAL_CHANNEL
*chan
, HAL_BOOL bChannelChange
, HAL_STATUS
*status
);
248 extern HAL_BOOL
ar5416PhyDisable(struct ath_hal
*ah
);
249 extern HAL_RFGAIN
ar5416GetRfgain(struct ath_hal
*ah
);
250 extern HAL_BOOL
ar5416Disable(struct ath_hal
*ah
);
251 extern HAL_BOOL
ar5416ChipReset(struct ath_hal
*ah
, HAL_CHANNEL
*);
252 extern HAL_BOOL
ar5416SetResetReg(struct ath_hal
*, uint32_t type
);
253 extern HAL_BOOL
ar5416PerCalibration(struct ath_hal
*, HAL_CHANNEL
*,
255 extern void ar5416ResetCalValid(struct ath_hal
*ah
, HAL_CHANNEL
*chan
,
257 extern void ar5416IQCalCollect(struct ath_hal
*ah
);
258 extern void ar5416IQCalibration(struct ath_hal
*ah
, uint8_t numChains
);
259 extern void ar5416AdcGainCalCollect(struct ath_hal
*ah
);
260 extern void ar5416AdcGainCalibration(struct ath_hal
*ah
, uint8_t numChains
);
261 extern void ar5416AdcDcCalCollect(struct ath_hal
*ah
);
262 extern void ar5416AdcDcCalibration(struct ath_hal
*ah
, uint8_t numChains
);
263 extern void ar5416InitNfHistBuff(struct ar5212NfCalHist
*h
);
264 extern HAL_BOOL
ar5416SetTxPowerLimit(struct ath_hal
*ah
, uint32_t limit
);
265 extern HAL_BOOL
ar5416GetChipPowerLimits(struct ath_hal
*ah
,
266 HAL_CHANNEL
*chans
, uint32_t nchans
);
267 extern void ar5416GetChannelCenters(struct ath_hal
*,
268 HAL_CHANNEL_INTERNAL
*chan
, CHAN_CENTERS
*centers
);
270 extern HAL_BOOL
ar5416StopTxDma(struct ath_hal
*ah
, u_int q
);
271 extern HAL_BOOL
ar5416SetupTxDesc(struct ath_hal
*ah
, struct ath_desc
*ds
,
272 u_int pktLen
, u_int hdrLen
, HAL_PKT_TYPE type
, u_int txPower
,
273 u_int txRate0
, u_int txTries0
,
274 u_int keyIx
, u_int antMode
, u_int flags
,
275 u_int rtsctsRate
, u_int rtsctsDuration
,
276 u_int compicvLen
, u_int compivLen
, u_int comp
);
277 extern HAL_BOOL
ar5416SetupXTxDesc(struct ath_hal
*, struct ath_desc
*,
278 u_int txRate1
, u_int txRetries1
,
279 u_int txRate2
, u_int txRetries2
,
280 u_int txRate3
, u_int txRetries3
);
281 extern HAL_BOOL
ar5416FillTxDesc(struct ath_hal
*ah
, struct ath_desc
*ds
,
282 u_int segLen
, HAL_BOOL firstSeg
, HAL_BOOL lastSeg
,
283 const struct ath_desc
*ds0
);
284 extern HAL_STATUS
ar5416ProcTxDesc(struct ath_hal
*ah
,
285 struct ath_desc
*, struct ath_tx_status
*);
287 extern const HAL_RATE_TABLE
*ar5416GetRateTable(struct ath_hal
*, u_int mode
);
288 #endif /* _ATH_AR5416_H_ */