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_AH_INTERAL_H_
20 #define _ATH_AH_INTERAL_H_
21 /*
22  * Atheros Device Hardware Access Layer (HAL).
23  *
24  * Internal definitions.
25  */
26 #define	AH_NULL	0
27 #define	AH_MIN(a,b)	((a)<(b)?(a):(b))
28 #define	AH_MAX(a,b)	((a)>(b)?(a):(b))
29 
30 #include <netproto/802_11/_ieee80211.h>
31 #include "opt_ah.h"			/* needed for AH_SUPPORT_AR5416 */
32 
33 #ifndef	AH_SUPPORT_AR5416
34 #define	AH_SUPPORT_AR5416	1
35 #endif
36 
37 #ifndef NBBY
38 #define	NBBY	8			/* number of bits/byte */
39 #endif
40 
41 #ifndef roundup
42 #define	roundup(x, y)	((((x)+((y)-1))/(y))*(y))  /* to any y */
43 #endif
44 #ifndef howmany
45 #define	howmany(x, y)	(((x)+((y)-1))/(y))
46 #endif
47 
48 #ifndef offsetof
49 #define	offsetof(type, field)	((size_t)(&((type *)0)->field))
50 #endif
51 
52 typedef struct {
53 	uint16_t	start;		/* first register */
54 	uint16_t	end;		/* ending register or zero */
55 } HAL_REGRANGE;
56 
57 typedef struct {
58 	uint32_t	addr;		/* regiser address/offset */
59 	uint32_t	value;		/* value to write */
60 } HAL_REGWRITE;
61 
62 /*
63  * Transmit power scale factor.
64  *
65  * NB: This is not public because we want to discourage the use of
66  *     scaling; folks should use the tx power limit interface.
67  */
68 typedef enum {
69 	HAL_TP_SCALE_MAX	= 0,		/* no scaling (default) */
70 	HAL_TP_SCALE_50		= 1,		/* 50% of max (-3 dBm) */
71 	HAL_TP_SCALE_25		= 2,		/* 25% of max (-6 dBm) */
72 	HAL_TP_SCALE_12		= 3,		/* 12% of max (-9 dBm) */
73 	HAL_TP_SCALE_MIN	= 4,		/* min, but still on */
74 } HAL_TP_SCALE;
75 
76 typedef enum {
77  	HAL_CAP_RADAR		= 0,		/* Radar capability */
78  	HAL_CAP_AR		= 1,		/* AR capability */
79 } HAL_PHYDIAG_CAPS;
80 
81 /*
82  * Enable/disable strong signal fast diversity
83  */
84 #define	HAL_CAP_STRONG_DIV		2
85 
86 /*
87  * Each chip or class of chips registers to offer support.
88  */
89 struct ath_hal_chip {
90 	const char	*name;
91 	const char	*(*probe)(uint16_t vendorid, uint16_t devid);
92 	struct ath_hal	*(*attach)(uint16_t devid, HAL_SOFTC,
93 			    HAL_BUS_TAG, HAL_BUS_HANDLE, uint16_t *eepromdata,
94 			    HAL_STATUS *error);
95 };
96 #ifndef AH_CHIP
97 #define	AH_CHIP(_name, _probe, _attach)				\
98 static struct ath_hal_chip _name##_chip = {			\
99 	.name		= #_name,				\
100 	.probe		= _probe,				\
101 	.attach		= _attach				\
102 };								\
103 OS_DATA_SET(ah_chips, _name##_chip)
104 #endif
105 
106 /*
107  * Each RF backend registers to offer support; this is mostly
108  * used by multi-chip 5212 solutions.  Single-chip solutions
109  * have a fixed idea about which RF to use.
110  */
111 struct ath_hal_rf {
112 	const char	*name;
113 	HAL_BOOL	(*probe)(struct ath_hal *ah);
114 	HAL_BOOL	(*attach)(struct ath_hal *ah, HAL_STATUS *ecode);
115 };
116 #ifndef AH_RF
117 #define	AH_RF(_name, _probe, _attach)				\
118 static struct ath_hal_rf _name##_rf = {				\
119 	.name		= __STRING(_name),			\
120 	.probe		= _probe,				\
121 	.attach		= _attach				\
122 };								\
123 OS_DATA_SET(ah_rfs, _name##_rf)
124 #endif
125 
126 struct ath_hal_rf *ath_hal_rfprobe(struct ath_hal *ah, HAL_STATUS *ecode);
127 
128 /*
129  * Maximum number of internal channels.  Entries are per unique
130  * frequency so this might be need to be increased to handle all
131  * usage cases; typically no more than 32 are really needed but
132  * dynamically allocating the data structures is a bit painful
133  * right now.
134  */
135 #ifndef AH_MAXCHAN
136 #define	AH_MAXCHAN	96
137 #endif
138 
139 #define	HAL_NF_CAL_HIST_LEN_FULL	5
140 #define	HAL_NF_CAL_HIST_LEN_SMALL	1
141 #define	HAL_NUM_NF_READINGS		6	/* 3 chains * (ctl + ext) */
142 #define	HAL_NF_LOAD_DELAY		1000
143 
144 /*
145  * PER_CHAN doesn't work for now, as it looks like the device layer
146  * has to pre-populate the per-channel list with nominal values.
147  */
148 //#define	ATH_NF_PER_CHAN		1
149 
150 typedef struct {
151     u_int8_t    curr_index;
152     int8_t      invalidNFcount; /* TO DO: REMOVE THIS! */
153     int16_t     priv_nf[HAL_NUM_NF_READINGS];
154 } HAL_NFCAL_BASE;
155 
156 typedef struct {
157     HAL_NFCAL_BASE base;
158     int16_t     nf_cal_buffer[HAL_NF_CAL_HIST_LEN_FULL][HAL_NUM_NF_READINGS];
159 } HAL_NFCAL_HIST_FULL;
160 
161 typedef struct {
162     HAL_NFCAL_BASE base;
163     int16_t     nf_cal_buffer[HAL_NF_CAL_HIST_LEN_SMALL][HAL_NUM_NF_READINGS];
164 } HAL_NFCAL_HIST_SMALL;
165 
166 #ifdef	ATH_NF_PER_CHAN
167 typedef HAL_NFCAL_HIST_FULL HAL_CHAN_NFCAL_HIST;
168 #define	AH_HOME_CHAN_NFCAL_HIST(ah, ichan) (ichan ? &ichan->nf_cal_hist: NULL)
169 #else
170 typedef HAL_NFCAL_HIST_SMALL HAL_CHAN_NFCAL_HIST;
171 #define	AH_HOME_CHAN_NFCAL_HIST(ah, ichan) (&AH_PRIVATE(ah)->nf_cal_hist)
172 #endif	/* ATH_NF_PER_CHAN */
173 
174 /*
175  * Internal per-channel state.  These are found
176  * using ic_devdata in the ieee80211_channel.
177  */
178 typedef struct {
179 	uint16_t	channel;	/* h/w frequency, NB: may be mapped */
180 	uint8_t		privFlags;
181 #define	CHANNEL_IQVALID		0x01	/* IQ calibration valid */
182 #define	CHANNEL_ANI_INIT	0x02	/* ANI state initialized */
183 #define	CHANNEL_ANI_SETUP	0x04	/* ANI state setup */
184 #define	CHANNEL_MIMO_NF_VALID	0x04	/* Mimo NF values are valid */
185 	uint8_t		calValid;	/* bitmask of cal types */
186 	int8_t		iCoff;
187 	int8_t		qCoff;
188 	int16_t		rawNoiseFloor;
189 	int16_t		noiseFloorAdjust;
190 #ifdef	AH_SUPPORT_AR5416
191 	int16_t		noiseFloorCtl[AH_MAX_CHAINS];
192 	int16_t		noiseFloorExt[AH_MAX_CHAINS];
193 #endif	/* AH_SUPPORT_AR5416 */
194 	uint16_t	mainSpur;	/* cached spur value for this channel */
195 
196 	/*XXX TODO: make these part of privFlags */
197 	uint8_t  paprd_done:1,           /* 1: PAPRD DONE, 0: PAPRD Cal not done */
198 	       paprd_table_write_done:1; /* 1: DONE, 0: Cal data write not done */
199 	int		one_time_cals_done;
200 	HAL_CHAN_NFCAL_HIST nf_cal_hist;
201 } HAL_CHANNEL_INTERNAL;
202 
203 /* channel requires noise floor check */
204 #define	CHANNEL_NFCREQUIRED	IEEE80211_CHAN_PRIV0
205 
206 /* all full-width channels */
207 #define	IEEE80211_CHAN_ALLFULL \
208 	(IEEE80211_CHAN_ALL - (IEEE80211_CHAN_HALF | IEEE80211_CHAN_QUARTER))
209 #define	IEEE80211_CHAN_ALLTURBOFULL \
210 	(IEEE80211_CHAN_ALLTURBO - \
211 	 (IEEE80211_CHAN_HALF | IEEE80211_CHAN_QUARTER))
212 
213 typedef struct {
214 	uint32_t	halChanSpreadSupport 		: 1,
215 			halSleepAfterBeaconBroken	: 1,
216 			halCompressSupport		: 1,
217 			halBurstSupport			: 1,
218 			halFastFramesSupport		: 1,
219 			halChapTuningSupport		: 1,
220 			halTurboGSupport		: 1,
221 			halTurboPrimeSupport		: 1,
222 			halMicAesCcmSupport		: 1,
223 			halMicCkipSupport		: 1,
224 			halMicTkipSupport		: 1,
225 			halTkipMicTxRxKeySupport	: 1,
226 			halCipherAesCcmSupport		: 1,
227 			halCipherCkipSupport		: 1,
228 			halCipherTkipSupport		: 1,
229 			halPSPollBroken			: 1,
230 			halVEOLSupport			: 1,
231 			halBssIdMaskSupport		: 1,
232 			halMcastKeySrchSupport		: 1,
233 			halTsfAddSupport		: 1,
234 			halChanHalfRate			: 1,
235 			halChanQuarterRate		: 1,
236 			halHTSupport			: 1,
237 			halHTSGI20Support		: 1,
238 			halRfSilentSupport		: 1,
239 			halHwPhyCounterSupport		: 1,
240 			halWowSupport			: 1,
241 			halWowMatchPatternExact		: 1,
242 			halAutoSleepSupport		: 1,
243 			halFastCCSupport		: 1,
244 			halBtCoexSupport		: 1;
245 	uint32_t	halRxStbcSupport		: 1,
246 			halTxStbcSupport		: 1,
247 			halGTTSupport			: 1,
248 			halCSTSupport			: 1,
249 			halRifsRxSupport		: 1,
250 			halRifsTxSupport		: 1,
251 			hal4AddrAggrSupport		: 1,
252 			halExtChanDfsSupport		: 1,
253 			halUseCombinedRadarRssi		: 1,
254 			halForcePpmSupport		: 1,
255 			halEnhancedPmSupport		: 1,
256 			halEnhancedDfsSupport		: 1,
257 			halMbssidAggrSupport		: 1,
258 			halBssidMatchSupport		: 1,
259 			hal4kbSplitTransSupport		: 1,
260 			halHasRxSelfLinkedTail		: 1,
261 			halSupportsFastClock5GHz	: 1,
262 			halHasLongRxDescTsf		: 1,
263 			halHasBBReadWar			: 1,
264 			halSerialiseRegWar		: 1,
265 			halMciSupport			: 1,
266 			halRxTxAbortSupport		: 1,
267 			halPaprdEnabled			: 1,
268 			halHasUapsdSupport		: 1,
269 			halWpsPushButtonSupport		: 1,
270 			halBtCoexApsmWar		: 1,
271 			halGenTimerSupport		: 1,
272 			halLDPCSupport			: 1,
273 			halHwBeaconProcSupport		: 1,
274 			halEnhancedDmaSupport		: 1;
275 	uint32_t	halIsrRacSupport		: 1,
276 			halApmEnable			: 1,
277 			halIntrMitigation		: 1,
278 			hal49GhzSupport			: 1,
279 			halAntDivCombSupport		: 1,
280 			halAntDivCombSupportOrg		: 1,
281 			halRadioRetentionSupport	: 1,
282 			halSpectralScanSupport		: 1,
283 			halRxUsingLnaMixing		: 1,
284 			halRxDoMyBeacon			: 1;
285 
286 	uint32_t	halWirelessModes;
287 	uint16_t	halTotalQueues;
288 	uint16_t	halKeyCacheSize;
289 	uint16_t	halLow5GhzChan, halHigh5GhzChan;
290 	uint16_t	halLow2GhzChan, halHigh2GhzChan;
291 	int		halTstampPrecision;
292 	int		halRtsAggrLimit;
293 	uint8_t		halTxChainMask;
294 	uint8_t		halRxChainMask;
295 	uint8_t		halNumGpioPins;
296 	uint8_t		halNumAntCfg2GHz;
297 	uint8_t		halNumAntCfg5GHz;
298 	uint32_t	halIntrMask;
299 	uint8_t		halTxStreams;
300 	uint8_t		halRxStreams;
301 	HAL_MFP_OPT_T	halMfpSupport;
302 
303 	/* AR9300 HAL porting capabilities */
304 	int		hal_paprd_enabled;
305 	int		hal_pcie_lcr_offset;
306 	int		hal_pcie_lcr_extsync_en;
307 	int		halNumTxMaps;
308 	int		halTxDescLen;
309 	int		halTxStatusLen;
310 	int		halRxStatusLen;
311 	int		halRxHpFifoDepth;
312 	int		halRxLpFifoDepth;
313 	uint32_t	halRegCap;		/* XXX needed? */
314 	int		halNumMRRetries;
315 	int		hal_ani_poll_interval;
316 	int		hal_channel_switch_time_usec;
317 } HAL_CAPABILITIES;
318 
319 struct regDomain;
320 
321 /*
322  * Definitions for ah_flags in ath_hal_private
323  */
324 #define		AH_USE_EEPROM	0x1
325 #define		AH_IS_HB63	0x2
326 
327 /*
328  * The ``private area'' follows immediately after the ``public area''
329  * in the data structure returned by ath_hal_attach.  Private data are
330  * used by device-independent code such as the regulatory domain support.
331  * In general, code within the HAL should never depend on data in the
332  * public area.  Instead any public data needed internally should be
333  * shadowed here.
334  *
335  * When declaring a device-specific ath_hal data structure this structure
336  * is assumed to at the front; e.g.
337  *
338  *	struct ath_hal_5212 {
339  *		struct ath_hal_private	ah_priv;
340  *		...
341  *	};
342  *
343  * It might be better to manage the method pointers in this structure
344  * using an indirect pointer to a read-only data structure but this would
345  * disallow class-style method overriding.
346  */
347 struct ath_hal_private {
348 	struct ath_hal	h;			/* public area */
349 
350 	/* NB: all methods go first to simplify initialization */
351 	HAL_BOOL	(*ah_getChannelEdges)(struct ath_hal*,
352 				uint16_t channelFlags,
353 				uint16_t *lowChannel, uint16_t *highChannel);
354 	u_int		(*ah_getWirelessModes)(struct ath_hal*);
355 	HAL_BOOL	(*ah_eepromRead)(struct ath_hal *, u_int off,
356 				uint16_t *data);
357 	HAL_BOOL	(*ah_eepromWrite)(struct ath_hal *, u_int off,
358 				uint16_t data);
359 	HAL_BOOL	(*ah_getChipPowerLimits)(struct ath_hal *,
360 				struct ieee80211_channel *);
361 	int16_t		(*ah_getNfAdjust)(struct ath_hal *,
362 				const HAL_CHANNEL_INTERNAL*);
363 	void		(*ah_getNoiseFloor)(struct ath_hal *,
364 				int16_t nfarray[]);
365 
366 	void		*ah_eeprom;		/* opaque EEPROM state */
367 	uint16_t	ah_eeversion;		/* EEPROM version */
368 	void		(*ah_eepromDetach)(struct ath_hal *);
369 	HAL_STATUS	(*ah_eepromGet)(struct ath_hal *, int, void *);
370 	HAL_STATUS	(*ah_eepromSet)(struct ath_hal *, int, int);
371 	uint16_t	(*ah_getSpurChan)(struct ath_hal *, int, HAL_BOOL);
372 	HAL_BOOL	(*ah_eepromDiag)(struct ath_hal *, int request,
373 			    const void *args, uint32_t argsize,
374 			    void **result, uint32_t *resultsize);
375 
376 	/*
377 	 * Device revision information.
378 	 */
379 	uint16_t	ah_devid;		/* PCI device ID */
380 	uint16_t	ah_subvendorid;		/* PCI subvendor ID */
381 	uint32_t	ah_macVersion;		/* MAC version id */
382 	uint16_t	ah_macRev;		/* MAC revision */
383 	uint16_t	ah_phyRev;		/* PHY revision */
384 	uint16_t	ah_analog5GhzRev;	/* 2GHz radio revision */
385 	uint16_t	ah_analog2GhzRev;	/* 5GHz radio revision */
386 	uint32_t	ah_flags;		/* misc flags */
387 	uint8_t		ah_ispcie;		/* PCIE, special treatment */
388 	uint8_t		ah_devType;		/* card type - CB, PCI, PCIe */
389 
390 	HAL_OPMODE	ah_opmode;		/* operating mode from reset */
391 	const struct ieee80211_channel *ah_curchan;/* operating channel */
392 	HAL_CAPABILITIES ah_caps;		/* device capabilities */
393 	uint32_t	ah_diagreg;		/* user-specified AR_DIAG_SW */
394 	int16_t		ah_powerLimit;		/* tx power cap */
395 	uint16_t	ah_maxPowerLevel;	/* calculated max tx power */
396 	u_int		ah_tpScale;		/* tx power scale factor */
397 	u_int16_t	ah_extraTxPow;		/* low rates extra-txpower */
398 	uint32_t	ah_11nCompat;		/* 11n compat controls */
399 
400 	/*
401 	 * State for regulatory domain handling.
402 	 */
403 	HAL_REG_DOMAIN	ah_currentRD;		/* EEPROM regulatory domain */
404 	HAL_REG_DOMAIN	ah_currentRDext;	/* EEPROM extended regdomain flags */
405 	HAL_DFS_DOMAIN	ah_dfsDomain;		/* current DFS domain */
406 	HAL_CHANNEL_INTERNAL ah_channels[AH_MAXCHAN]; /* private chan state */
407 	u_int		ah_nchan;		/* valid items in ah_channels */
408 	const struct regDomain *ah_rd2GHz;	/* reg state for 2G band */
409 	const struct regDomain *ah_rd5GHz;	/* reg state for 5G band */
410 
411 	uint8_t    	ah_coverageClass;   	/* coverage class */
412 	/*
413 	 * RF Silent handling; setup according to the EEPROM.
414 	 */
415 	uint16_t	ah_rfsilent;		/* GPIO pin + polarity */
416 	HAL_BOOL	ah_rfkillEnabled;	/* enable/disable RfKill */
417 	/*
418 	 * Diagnostic support for discriminating HIUERR reports.
419 	 */
420 	uint32_t	ah_fatalState[6];	/* AR_ISR+shadow regs */
421 	int		ah_rxornIsFatal;	/* how to treat HAL_INT_RXORN */
422 
423 #ifndef	ATH_NF_PER_CHAN
424 	HAL_NFCAL_HIST_FULL	nf_cal_hist;
425 #endif	/* ! ATH_NF_PER_CHAN */
426 };
427 
428 #define	AH_PRIVATE(_ah)	((struct ath_hal_private *)(_ah))
429 
430 #define	ath_hal_getChannelEdges(_ah, _cf, _lc, _hc) \
431 	AH_PRIVATE(_ah)->ah_getChannelEdges(_ah, _cf, _lc, _hc)
432 #define	ath_hal_getWirelessModes(_ah) \
433 	AH_PRIVATE(_ah)->ah_getWirelessModes(_ah)
434 #define	ath_hal_eepromRead(_ah, _off, _data) \
435 	AH_PRIVATE(_ah)->ah_eepromRead(_ah, _off, _data)
436 #define	ath_hal_eepromWrite(_ah, _off, _data) \
437 	AH_PRIVATE(_ah)->ah_eepromWrite(_ah, _off, _data)
438 #define	ath_hal_gpioCfgOutput(_ah, _gpio, _type) \
439 	(_ah)->ah_gpioCfgOutput(_ah, _gpio, _type)
440 #define	ath_hal_gpioCfgInput(_ah, _gpio) \
441 	(_ah)->ah_gpioCfgInput(_ah, _gpio)
442 #define	ath_hal_gpioGet(_ah, _gpio) \
443 	(_ah)->ah_gpioGet(_ah, _gpio)
444 #define	ath_hal_gpioSet(_ah, _gpio, _val) \
445 	(_ah)->ah_gpioSet(_ah, _gpio, _val)
446 #define	ath_hal_gpioSetIntr(_ah, _gpio, _ilevel) \
447 	(_ah)->ah_gpioSetIntr(_ah, _gpio, _ilevel)
448 #define	ath_hal_getpowerlimits(_ah, _chan) \
449 	AH_PRIVATE(_ah)->ah_getChipPowerLimits(_ah, _chan)
450 #define ath_hal_getNfAdjust(_ah, _c) \
451 	AH_PRIVATE(_ah)->ah_getNfAdjust(_ah, _c)
452 #define	ath_hal_getNoiseFloor(_ah, _nfArray) \
453 	AH_PRIVATE(_ah)->ah_getNoiseFloor(_ah, _nfArray)
454 #define	ath_hal_configPCIE(_ah, _reset, _poweroff) \
455 	(_ah)->ah_configPCIE(_ah, _reset, _poweroff)
456 #define	ath_hal_disablePCIE(_ah) \
457 	(_ah)->ah_disablePCIE(_ah)
458 #define	ath_hal_setInterrupts(_ah, _mask) \
459 	(_ah)->ah_setInterrupts(_ah, _mask)
460 
461 #define ath_hal_isrfkillenabled(_ah)  \
462     (ath_hal_getcapability(_ah, HAL_CAP_RFSILENT, 1, AH_NULL) == HAL_OK)
463 #define ath_hal_enable_rfkill(_ah, _v) \
464     ath_hal_setcapability(_ah, HAL_CAP_RFSILENT, 1, _v, AH_NULL)
465 #define ath_hal_hasrfkill_int(_ah)  \
466     (ath_hal_getcapability(_ah, HAL_CAP_RFSILENT, 3, AH_NULL) == HAL_OK)
467 
468 #define	ath_hal_eepromDetach(_ah) do {				\
469 	if (AH_PRIVATE(_ah)->ah_eepromDetach != AH_NULL)	\
470 		AH_PRIVATE(_ah)->ah_eepromDetach(_ah);		\
471 } while (0)
472 #define	ath_hal_eepromGet(_ah, _param, _val) \
473 	AH_PRIVATE(_ah)->ah_eepromGet(_ah, _param, _val)
474 #define	ath_hal_eepromSet(_ah, _param, _val) \
475 	AH_PRIVATE(_ah)->ah_eepromSet(_ah, _param, _val)
476 #define	ath_hal_eepromGetFlag(_ah, _param) \
477 	(AH_PRIVATE(_ah)->ah_eepromGet(_ah, _param, AH_NULL) == HAL_OK)
478 #define ath_hal_getSpurChan(_ah, _ix, _is2G) \
479 	AH_PRIVATE(_ah)->ah_getSpurChan(_ah, _ix, _is2G)
480 #define	ath_hal_eepromDiag(_ah, _request, _a, _asize, _r, _rsize) \
481 	AH_PRIVATE(_ah)->ah_eepromDiag(_ah, _request, _a, _asize,  _r, _rsize)
482 
483 #ifndef _NET_IF_IEEE80211_H_
484 /*
485  * Stuff that would naturally come from _ieee80211.h
486  */
487 #define	IEEE80211_ADDR_LEN		6
488 
489 #define	IEEE80211_WEP_IVLEN			3	/* 24bit */
490 #define	IEEE80211_WEP_KIDLEN			1	/* 1 octet */
491 #define	IEEE80211_WEP_CRCLEN			4	/* CRC-32 */
492 
493 #define	IEEE80211_CRC_LEN			4
494 
495 #define	IEEE80211_MAX_LEN			(2300 + IEEE80211_CRC_LEN + \
496     (IEEE80211_WEP_IVLEN + IEEE80211_WEP_KIDLEN + IEEE80211_WEP_CRCLEN))
497 #endif /* _NET_IF_IEEE80211_H_ */
498 
499 #define HAL_TXQ_USE_LOCKOUT_BKOFF_DIS	0x00000001
500 
501 #define INIT_AIFS		2
502 #define INIT_CWMIN		15
503 #define INIT_CWMIN_11B		31
504 #define INIT_CWMAX		1023
505 #define INIT_SH_RETRY		10
506 #define INIT_LG_RETRY		10
507 #define INIT_SSH_RETRY		32
508 #define INIT_SLG_RETRY		32
509 
510 typedef struct {
511 	uint32_t	tqi_ver;		/* HAL TXQ verson */
512 	HAL_TX_QUEUE	tqi_type;		/* hw queue type*/
513 	HAL_TX_QUEUE_SUBTYPE tqi_subtype;	/* queue subtype, if applicable */
514 	HAL_TX_QUEUE_FLAGS tqi_qflags;		/* queue flags */
515 	uint32_t	tqi_priority;
516 	uint32_t	tqi_aifs;		/* aifs */
517 	uint32_t	tqi_cwmin;		/* cwMin */
518 	uint32_t	tqi_cwmax;		/* cwMax */
519 	uint16_t	tqi_shretry;		/* frame short retry limit */
520 	uint16_t	tqi_lgretry;		/* frame long retry limit */
521 	uint32_t	tqi_cbrPeriod;
522 	uint32_t	tqi_cbrOverflowLimit;
523 	uint32_t	tqi_burstTime;
524 	uint32_t	tqi_readyTime;
525 	uint32_t	tqi_physCompBuf;
526 	uint32_t	tqi_intFlags;		/* flags for internal use */
527 } HAL_TX_QUEUE_INFO;
528 
529 extern	HAL_BOOL ath_hal_setTxQProps(struct ath_hal *ah,
530 		HAL_TX_QUEUE_INFO *qi, const HAL_TXQ_INFO *qInfo);
531 extern	HAL_BOOL ath_hal_getTxQProps(struct ath_hal *ah,
532 		HAL_TXQ_INFO *qInfo, const HAL_TX_QUEUE_INFO *qi);
533 
534 #define	HAL_SPUR_VAL_MASK		0x3FFF
535 #define	HAL_SPUR_CHAN_WIDTH		87
536 #define	HAL_BIN_WIDTH_BASE_100HZ	3125
537 #define	HAL_BIN_WIDTH_TURBO_100HZ	6250
538 #define	HAL_MAX_BINS_ALLOWED		28
539 
540 #define	IS_CHAN_5GHZ(_c)	((_c)->channel > 4900)
541 #define	IS_CHAN_2GHZ(_c)	(!IS_CHAN_5GHZ(_c))
542 
543 #define	IS_CHAN_IN_PUBLIC_SAFETY_BAND(_c) ((_c) > 4940 && (_c) < 4990)
544 
545 /*
546  * Deduce if the host cpu has big- or litt-endian byte order.
547  */
548 static __inline__ int
549 isBigEndian(void)
550 {
551 	union {
552 		int32_t i;
553 		char c[4];
554 	} u;
555 	u.i = 1;
556 	return (u.c[0] == 0);
557 }
558 
559 /* unalligned little endian access */
560 #define LE_READ_2(p)							\
561 	((uint16_t)							\
562 	 ((((const uint8_t *)(p))[0]    ) | (((const uint8_t *)(p))[1]<< 8)))
563 #define LE_READ_4(p)							\
564 	((uint32_t)							\
565 	 ((((const uint8_t *)(p))[0]    ) | (((const uint8_t *)(p))[1]<< 8) |\
566 	  (((const uint8_t *)(p))[2]<<16) | (((const uint8_t *)(p))[3]<<24)))
567 
568 /*
569  * Register manipulation macros that expect bit field defines
570  * to follow the convention that an _S suffix is appended for
571  * a shift count, while the field mask has no suffix.
572  */
573 #define	SM(_v, _f)	(((_v) << _f##_S) & (_f))
574 #define	MS(_v, _f)	(((_v) & (_f)) >> _f##_S)
575 #define OS_REG_RMW(_a, _r, _set, _clr)    \
576 	OS_REG_WRITE(_a, _r, (OS_REG_READ(_a, _r) & ~(_clr)) | (_set))
577 #define	OS_REG_RMW_FIELD(_a, _r, _f, _v) \
578 	OS_REG_WRITE(_a, _r, \
579 		(OS_REG_READ(_a, _r) &~ (_f)) | (((_v) << _f##_S) & (_f)))
580 #define	OS_REG_SET_BIT(_a, _r, _f) \
581 	OS_REG_WRITE(_a, _r, OS_REG_READ(_a, _r) | (_f))
582 #define	OS_REG_CLR_BIT(_a, _r, _f) \
583 	OS_REG_WRITE(_a, _r, OS_REG_READ(_a, _r) &~ (_f))
584 #define OS_REG_IS_BIT_SET(_a, _r, _f) \
585 	    ((OS_REG_READ(_a, _r) & (_f)) != 0)
586 #define	OS_REG_RMW_FIELD_ALT(_a, _r, _f, _v) \
587 	    OS_REG_WRITE(_a, _r, \
588 	    (OS_REG_READ(_a, _r) &~(_f<<_f##_S)) | \
589 	    (((_v) << _f##_S) & (_f<<_f##_S)))
590 #define	OS_REG_READ_FIELD(_a, _r, _f) \
591 	    (((OS_REG_READ(_a, _r) & _f) >> _f##_S))
592 #define	OS_REG_READ_FIELD_ALT(_a, _r, _f) \
593 	    ((OS_REG_READ(_a, _r) >> (_f##_S))&(_f))
594 
595 /* Analog register writes may require a delay between each one (eg Merlin?) */
596 #define	OS_A_REG_RMW_FIELD(_a, _r, _f, _v) \
597 	do { OS_REG_WRITE(_a, _r, (OS_REG_READ(_a, _r) &~ (_f)) | \
598 	    (((_v) << _f##_S) & (_f))) ; OS_DELAY(100); } while (0)
599 #define	OS_A_REG_WRITE(_a, _r, _v) \
600 	do { OS_REG_WRITE(_a, _r, _v); OS_DELAY(100); } while (0)
601 
602 /* wait for the register contents to have the specified value */
603 extern	HAL_BOOL ath_hal_wait(struct ath_hal *, u_int reg,
604 		uint32_t mask, uint32_t val);
605 extern	HAL_BOOL ath_hal_waitfor(struct ath_hal *, u_int reg,
606 		uint32_t mask, uint32_t val, uint32_t timeout);
607 
608 /* return the first n bits in val reversed */
609 extern	uint32_t ath_hal_reverseBits(uint32_t val, uint32_t n);
610 
611 /* printf interfaces */
612 extern	void ath_hal_printf(struct ath_hal *, const char*, ...)
613 		__printflike(2,3);
614 extern	void ath_hal_vprintf(struct ath_hal *, const char*, __va_list)
615 		__printflike(2, 0);
616 extern	const char* ath_hal_ether_sprintf(const uint8_t *mac);
617 
618 /* allocate and free memory */
619 extern	void *ath_hal_malloc(size_t);
620 extern	void ath_hal_free(void *);
621 
622 /* common debugging interfaces */
623 #ifdef AH_DEBUG
624 #include "ah_debug.h"
625 extern	int ath_hal_debug;	/* Global debug flags */
626 
627 /*
628  * The typecast is purely because some callers will pass in
629  * AH_NULL directly rather than using a NULL ath_hal pointer.
630  */
631 #define	HALDEBUG(_ah, __m, ...) \
632 	do {							\
633 		if ((__m) == HAL_DEBUG_UNMASKABLE ||		\
634 		    ath_hal_debug & (__m) ||			\
635 		    ((_ah) != NULL &&				\
636 		      ((struct ath_hal *) (_ah))->ah_config.ah_debug & (__m))) {	\
637 			DO_HALDEBUG((_ah), (__m), __VA_ARGS__);	\
638 		}						\
639 	} while(0);
640 
641 extern	void DO_HALDEBUG(struct ath_hal *ah, u_int mask, const char* fmt, ...)
642 	__printflike(3,4);
643 #else
644 #define HALDEBUG(_ah, __m, ...)
645 #endif /* AH_DEBUG */
646 
647 /*
648  * Register logging definitions shared with ardecode.
649  */
650 #include "ah_decode.h"
651 
652 /*
653  * Common assertion interface.  Note: it is a bad idea to generate
654  * an assertion failure for any recoverable event.  Instead catch
655  * the violation and, if possible, fix it up or recover from it; either
656  * with an error return value or a diagnostic messages.  System software
657  * does not panic unless the situation is hopeless.
658  */
659 #ifdef AH_ASSERT
660 extern	void ath_hal_assert_failed(const char* filename,
661 		int lineno, const char* msg);
662 
663 #define	HALASSERT(_x) do {					\
664 	if (!(_x)) {						\
665 		ath_hal_assert_failed(__FILE__, __LINE__, #_x);	\
666 	}							\
667 } while (0)
668 #else
669 #define	HALASSERT(_x)
670 #endif /* AH_ASSERT */
671 
672 /*
673  * Regulatory domain support.
674  */
675 
676 /*
677  * Return the max allowed antenna gain and apply any regulatory
678  * domain specific changes.
679  */
680 u_int	ath_hal_getantennareduction(struct ath_hal *ah,
681 	    const struct ieee80211_channel *chan, u_int twiceGain);
682 
683 /*
684  * Return the test group for the specific channel based on
685  * the current regulatory setup.
686  */
687 u_int	ath_hal_getctl(struct ath_hal *, const struct ieee80211_channel *);
688 
689 /*
690  * Map a public channel definition to the corresponding
691  * internal data structure.  This implicitly specifies
692  * whether or not the specified channel is ok to use
693  * based on the current regulatory domain constraints.
694  */
695 #ifndef AH_DEBUG
696 static OS_INLINE HAL_CHANNEL_INTERNAL *
697 ath_hal_checkchannel(struct ath_hal *ah, const struct ieee80211_channel *c)
698 {
699 	HAL_CHANNEL_INTERNAL *cc;
700 
701 	HALASSERT(c->ic_devdata < AH_PRIVATE(ah)->ah_nchan);
702 	cc = &AH_PRIVATE(ah)->ah_channels[c->ic_devdata];
703 	HALASSERT(c->ic_freq == cc->channel || IEEE80211_IS_CHAN_GSM(c));
704 	return cc;
705 }
706 #else
707 /* NB: non-inline version that checks state */
708 HAL_CHANNEL_INTERNAL *ath_hal_checkchannel(struct ath_hal *,
709 		const struct ieee80211_channel *);
710 #endif /* AH_DEBUG */
711 
712 /*
713  * Return the h/w frequency for a channel.  This may be
714  * different from ic_freq if this is a GSM device that
715  * takes 2.4GHz frequencies and down-converts them.
716  */
717 static OS_INLINE uint16_t
718 ath_hal_gethwchannel(struct ath_hal *ah, const struct ieee80211_channel *c)
719 {
720 	return ath_hal_checkchannel(ah, c)->channel;
721 }
722 
723 /*
724  * Convert between microseconds and core system clocks.
725  */
726 extern	u_int ath_hal_mac_clks(struct ath_hal *ah, u_int usecs);
727 extern	u_int ath_hal_mac_usec(struct ath_hal *ah, u_int clks);
728 
729 /*
730  * Generic get/set capability support.  Each chip overrides
731  * this routine to support chip-specific capabilities.
732  */
733 extern	HAL_STATUS ath_hal_getcapability(struct ath_hal *ah,
734 		HAL_CAPABILITY_TYPE type, uint32_t capability,
735 		uint32_t *result);
736 extern	HAL_BOOL ath_hal_setcapability(struct ath_hal *ah,
737 		HAL_CAPABILITY_TYPE type, uint32_t capability,
738 		uint32_t setting, HAL_STATUS *status);
739 
740 /* The diagnostic codes used to be internally defined here -adrian */
741 #include "ah_diagcodes.h"
742 
743 /*
744  * The AR5416 and later HALs have MAC and baseband hang checking.
745  */
746 typedef struct {
747 	uint32_t hang_reg_offset;
748 	uint32_t hang_val;
749 	uint32_t hang_mask;
750 	uint32_t hang_offset;
751 } hal_hw_hang_check_t;
752 
753 typedef struct {
754 	uint32_t dma_dbg_3;
755 	uint32_t dma_dbg_4;
756 	uint32_t dma_dbg_5;
757 	uint32_t dma_dbg_6;
758 } mac_dbg_regs_t;
759 
760 typedef enum {
761 	dcu_chain_state		= 0x1,
762 	dcu_complete_state	= 0x2,
763 	qcu_state		= 0x4,
764 	qcu_fsp_ok		= 0x8,
765 	qcu_fsp_state		= 0x10,
766 	qcu_stitch_state	= 0x20,
767 	qcu_fetch_state		= 0x40,
768 	qcu_complete_state	= 0x80
769 } hal_mac_hangs_t;
770 
771 typedef struct {
772 	int states;
773 	uint8_t dcu_chain_state;
774 	uint8_t dcu_complete_state;
775 	uint8_t qcu_state;
776 	uint8_t qcu_fsp_ok;
777 	uint8_t qcu_fsp_state;
778 	uint8_t qcu_stitch_state;
779 	uint8_t qcu_fetch_state;
780 	uint8_t qcu_complete_state;
781 } hal_mac_hang_check_t;
782 
783 enum {
784     HAL_BB_HANG_DFS		= 0x0001,
785     HAL_BB_HANG_RIFS		= 0x0002,
786     HAL_BB_HANG_RX_CLEAR	= 0x0004,
787     HAL_BB_HANG_UNKNOWN		= 0x0080,
788 
789     HAL_MAC_HANG_SIG1		= 0x0100,
790     HAL_MAC_HANG_SIG2		= 0x0200,
791     HAL_MAC_HANG_UNKNOWN	= 0x8000,
792 
793     HAL_BB_HANGS = HAL_BB_HANG_DFS
794 		 | HAL_BB_HANG_RIFS
795 		 | HAL_BB_HANG_RX_CLEAR
796 		 | HAL_BB_HANG_UNKNOWN,
797     HAL_MAC_HANGS = HAL_MAC_HANG_SIG1
798 		 | HAL_MAC_HANG_SIG2
799 		 | HAL_MAC_HANG_UNKNOWN,
800 };
801 
802 /* Merge these with above */
803 typedef enum hal_hw_hangs {
804     HAL_DFS_BB_HANG_WAR          = 0x1,
805     HAL_RIFS_BB_HANG_WAR         = 0x2,
806     HAL_RX_STUCK_LOW_BB_HANG_WAR = 0x4,
807     HAL_MAC_HANG_WAR             = 0x8,
808     HAL_PHYRESTART_CLR_WAR       = 0x10,
809     HAL_MAC_HANG_DETECTED        = 0x40000000,
810     HAL_BB_HANG_DETECTED         = 0x80000000
811 } hal_hw_hangs_t;
812 
813 /*
814  * Device revision information.
815  */
816 typedef struct {
817 	uint16_t	ah_devid;		/* PCI device ID */
818 	uint16_t	ah_subvendorid;		/* PCI subvendor ID */
819 	uint32_t	ah_macVersion;		/* MAC version id */
820 	uint16_t	ah_macRev;		/* MAC revision */
821 	uint16_t	ah_phyRev;		/* PHY revision */
822 	uint16_t	ah_analog5GhzRev;	/* 2GHz radio revision */
823 	uint16_t	ah_analog2GhzRev;	/* 5GHz radio revision */
824 } HAL_REVS;
825 
826 /*
827  * Argument payload for HAL_DIAG_SETKEY.
828  */
829 typedef struct {
830 	HAL_KEYVAL	dk_keyval;
831 	uint16_t	dk_keyix;	/* key index */
832 	uint8_t		dk_mac[IEEE80211_ADDR_LEN];
833 	int		dk_xor;		/* XOR key data */
834 } HAL_DIAG_KEYVAL;
835 
836 /*
837  * Argument payload for HAL_DIAG_EEWRITE.
838  */
839 typedef struct {
840 	uint16_t	ee_off;		/* eeprom offset */
841 	uint16_t	ee_data;	/* write data */
842 } HAL_DIAG_EEVAL;
843 
844 
845 typedef struct {
846 	u_int offset;		/* reg offset */
847 	uint32_t val;		/* reg value  */
848 } HAL_DIAG_REGVAL;
849 
850 /*
851  * 11n compatibility tweaks.
852  */
853 #define	HAL_DIAG_11N_SERVICES	0x00000003
854 #define	HAL_DIAG_11N_SERVICES_S	0
855 #define	HAL_DIAG_11N_TXSTOMP	0x0000000c
856 #define	HAL_DIAG_11N_TXSTOMP_S	2
857 
858 typedef struct {
859 	int		maxNoiseImmunityLevel;	/* [0..4] */
860 	int		totalSizeDesired[5];
861 	int		coarseHigh[5];
862 	int		coarseLow[5];
863 	int		firpwr[5];
864 
865 	int		maxSpurImmunityLevel;	/* [0..7] */
866 	int		cycPwrThr1[8];
867 
868 	int		maxFirstepLevel;	/* [0..2] */
869 	int		firstep[3];
870 
871 	uint32_t	ofdmTrigHigh;
872 	uint32_t	ofdmTrigLow;
873 	int32_t		cckTrigHigh;
874 	int32_t		cckTrigLow;
875 	int32_t		rssiThrLow;
876 	int32_t		rssiThrHigh;
877 
878 	int		period;			/* update listen period */
879 } HAL_ANI_PARAMS;
880 
881 extern	HAL_BOOL ath_hal_getdiagstate(struct ath_hal *ah, int request,
882 			const void *args, uint32_t argsize,
883 			void **result, uint32_t *resultsize);
884 
885 /*
886  * Setup a h/w rate table for use.
887  */
888 extern	void ath_hal_setupratetable(struct ath_hal *ah, HAL_RATE_TABLE *rt);
889 
890 /*
891  * Common routine for implementing getChanNoise api.
892  */
893 int16_t	ath_hal_getChanNoise(struct ath_hal *, const struct ieee80211_channel *);
894 
895 /*
896  * Initialization support.
897  */
898 typedef struct {
899 	const uint32_t	*data;
900 	int		rows, cols;
901 } HAL_INI_ARRAY;
902 
903 #define	HAL_INI_INIT(_ia, _data, _cols) do {			\
904 	(_ia)->data = (const uint32_t *)(_data);		\
905 	(_ia)->rows = sizeof(_data) / sizeof((_data)[0]);	\
906 	(_ia)->cols = (_cols);					\
907 } while (0)
908 #define	HAL_INI_VAL(_ia, _r, _c) \
909 	((_ia)->data[((_r)*(_ia)->cols) + (_c)])
910 
911 /*
912  * OS_DELAY() does a PIO READ on the PCI bus which allows
913  * other cards' DMA reads to complete in the middle of our reset.
914  */
915 #define DMA_YIELD(x) do {		\
916 	if ((++(x) % 64) == 0)		\
917 		OS_DELAY(1);		\
918 } while (0)
919 
920 #define HAL_INI_WRITE_ARRAY(ah, regArray, col, regWr) do {             	\
921 	int r;								\
922 	for (r = 0; r < N(regArray); r++) {				\
923 		OS_REG_WRITE(ah, (regArray)[r][0], (regArray)[r][col]);	\
924 		DMA_YIELD(regWr);					\
925 	}								\
926 } while (0)
927 
928 #define HAL_INI_WRITE_BANK(ah, regArray, bankData, regWr) do {		\
929 	int r;								\
930 	for (r = 0; r < N(regArray); r++) {				\
931 		OS_REG_WRITE(ah, (regArray)[r][0], (bankData)[r]);	\
932 		DMA_YIELD(regWr);					\
933 	}								\
934 } while (0)
935 
936 extern	int ath_hal_ini_write(struct ath_hal *ah, const HAL_INI_ARRAY *ia,
937 		int col, int regWr);
938 extern	void ath_hal_ini_bank_setup(uint32_t data[], const HAL_INI_ARRAY *ia,
939 		int col);
940 extern	int ath_hal_ini_bank_write(struct ath_hal *ah, const HAL_INI_ARRAY *ia,
941 		const uint32_t data[], int regWr);
942 
943 #define	CCK_SIFS_TIME		10
944 #define	CCK_PREAMBLE_BITS	144
945 #define	CCK_PLCP_BITS		48
946 
947 #define	OFDM_SIFS_TIME		16
948 #define	OFDM_PREAMBLE_TIME	20
949 #define	OFDM_PLCP_BITS		22
950 #define	OFDM_SYMBOL_TIME	4
951 
952 #define	OFDM_HALF_SIFS_TIME	32
953 #define	OFDM_HALF_PREAMBLE_TIME	40
954 #define	OFDM_HALF_PLCP_BITS	22
955 #define	OFDM_HALF_SYMBOL_TIME	8
956 
957 #define	OFDM_QUARTER_SIFS_TIME 		64
958 #define	OFDM_QUARTER_PREAMBLE_TIME	80
959 #define	OFDM_QUARTER_PLCP_BITS		22
960 #define	OFDM_QUARTER_SYMBOL_TIME	16
961 
962 #define	TURBO_SIFS_TIME		8
963 #define	TURBO_PREAMBLE_TIME	14
964 #define	TURBO_PLCP_BITS		22
965 #define	TURBO_SYMBOL_TIME	4
966 
967 #define	WLAN_CTRL_FRAME_SIZE	(2+2+6+4)	/* ACK+FCS */
968 
969 /* Generic EEPROM board value functions */
970 extern	HAL_BOOL ath_ee_getLowerUpperIndex(uint8_t target, uint8_t *pList,
971 	uint16_t listSize, uint16_t *indexL, uint16_t *indexR);
972 extern	HAL_BOOL ath_ee_FillVpdTable(uint8_t pwrMin, uint8_t pwrMax,
973 	uint8_t *pPwrList, uint8_t *pVpdList, uint16_t numIntercepts,
974 	uint8_t *pRetVpdList);
975 extern	int16_t ath_ee_interpolate(uint16_t target, uint16_t srcLeft,
976 	uint16_t srcRight, int16_t targetLeft, int16_t targetRight);
977 
978 /* Whether 5ghz fast clock is needed */
979 /*
980  * The chipset (Merlin, AR9300/later) should set the capability flag below;
981  * this flag simply says that the hardware can do it, not that the EEPROM
982  * says it can.
983  *
984  * Merlin 2.0/2.1 chips with an EEPROM version > 16 do 5ghz fast clock
985  *   if the relevant eeprom flag is set.
986  * Merlin 2.0/2.1 chips with an EEPROM version <= 16 do 5ghz fast clock
987  *   by default.
988  */
989 #define	IS_5GHZ_FAST_CLOCK_EN(_ah, _c) \
990 	(IEEE80211_IS_CHAN_5GHZ(_c) && \
991 	 AH_PRIVATE((_ah))->ah_caps.halSupportsFastClock5GHz && \
992 	ath_hal_eepromGetFlag((_ah), AR_EEP_FSTCLK_5G))
993 
994 /*
995  * Fetch the maximum regulatory domain power for the given channel
996  * in 1/2dBm steps.
997  */
998 static inline int
999 ath_hal_get_twice_max_regpower(struct ath_hal_private *ahp,
1000     const HAL_CHANNEL_INTERNAL *ichan, const struct ieee80211_channel *chan)
1001 {
1002 	struct ath_hal *ah = &ahp->h;
1003 
1004 	if (! chan) {
1005 		ath_hal_printf(ah, "%s: called with chan=NULL!\n", __func__);
1006 		return (0);
1007 	}
1008 	return (chan->ic_maxpower);
1009 }
1010 
1011 /*
1012  * Get the maximum antenna gain allowed, in 1/2dBm steps.
1013  */
1014 static inline int
1015 ath_hal_getantennaallowed(struct ath_hal *ah,
1016     const struct ieee80211_channel *chan)
1017 {
1018 
1019 	if (! chan)
1020 		return (0);
1021 
1022 	return (chan->ic_maxantgain);
1023 }
1024 
1025 /*
1026  * Map the given 2GHz channel to an IEEE number.
1027  */
1028 extern	int ath_hal_mhz2ieee_2ghz(struct ath_hal *, HAL_CHANNEL_INTERNAL *);
1029 
1030 #endif /* _ATH_AH_INTERAL_H_ */
1031