]> CyberLeo.Net >> Repos - FreeBSD/releng/8.1.git/blob - sys/dev/ath/ath_hal/ar5416/ar5416.h
Copy stable/8 to releng/8.1 in preparation for 8.1-RC1.
[FreeBSD/releng/8.1.git] / sys / dev / ath / ath_hal / ar5416 / ar5416.h
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 ath_hal_5416 {
53         struct ath_hal_5212 ah_5212;
54
55         /* NB: RF data setup at attach */
56         HAL_INI_ARRAY   ah_ini_bb_rfgain;
57         HAL_INI_ARRAY   ah_ini_bank0;
58         HAL_INI_ARRAY   ah_ini_bank1;
59         HAL_INI_ARRAY   ah_ini_bank2;
60         HAL_INI_ARRAY   ah_ini_bank3;
61         HAL_INI_ARRAY   ah_ini_bank6;
62         HAL_INI_ARRAY   ah_ini_bank7;
63         HAL_INI_ARRAY   ah_ini_addac;
64         HAL_INI_ARRAY   ah_ini_pcieserdes;
65
66         void            (*ah_writeIni)(struct ath_hal *,
67                             const struct ieee80211_channel *);
68         void            (*ah_spurMitigate)(struct ath_hal *,
69                             const struct ieee80211_channel *);
70
71         u_int           ah_globaltxtimeout;     /* global tx timeout */
72         u_int           ah_gpioMask;
73         int             ah_hangs;               /* h/w hangs state */
74         uint8_t         ah_keytype[AR5416_KEYTABLE_SIZE];
75         /*
76          * Extension Channel Rx Clear State
77          */
78         uint32_t        ah_cycleCount;
79         uint32_t        ah_ctlBusy;
80         uint32_t        ah_extBusy;
81         uint32_t        ah_rx_chainmask;
82         uint32_t        ah_tx_chainmask;
83
84         struct ar5416PerCal ah_cal;             /* periodic calibration state */
85 };
86 #define AH5416(_ah)     ((struct ath_hal_5416 *)(_ah))
87
88 #define IS_5416_PCI(ah) ((AH_PRIVATE(ah)->ah_macVersion) == AR_SREV_VERSION_OWL_PCI)
89 #define IS_5416_PCIE(ah) ((AH_PRIVATE(ah)->ah_macVersion) == AR_SREV_VERSION_OWL_PCIE)
90 #undef IS_PCIE
91 #define IS_PCIE(ah) (IS_5416_PCIE(ah))
92
93 extern  HAL_BOOL ar2133RfAttach(struct ath_hal *, HAL_STATUS *);
94
95 struct ath_hal;
96
97 extern  uint32_t ar5416GetRadioRev(struct ath_hal *ah);
98 extern  void ar5416InitState(struct ath_hal_5416 *, uint16_t devid,
99                 HAL_SOFTC sc, HAL_BUS_TAG st, HAL_BUS_HANDLE sh,
100                 HAL_STATUS *status);
101 extern  void ar5416Detach(struct ath_hal *ah);
102 extern  void ar5416AttachPCIE(struct ath_hal *ah);
103 extern  HAL_BOOL ar5416FillCapabilityInfo(struct ath_hal *ah);
104
105 #define IS_5GHZ_FAST_CLOCK_EN(_ah, _c) \
106         (IEEE80211_IS_CHAN_5GHZ(_c) && \
107          ath_hal_eepromGetFlag(ah, AR_EEP_FSTCLK_5G))
108
109 extern  void ar5416AniAttach(struct ath_hal *, const struct ar5212AniParams *,
110                 const struct ar5212AniParams *, HAL_BOOL ena);
111 extern  void ar5416AniDetach(struct ath_hal *);
112 extern  HAL_BOOL ar5416AniControl(struct ath_hal *, HAL_ANI_CMD cmd, int param);
113 extern  HAL_BOOL ar5416AniSetParams(struct ath_hal *,
114                 const struct ar5212AniParams *, const struct ar5212AniParams *);
115 extern  void ar5416ProcessMibIntr(struct ath_hal *, const HAL_NODE_STATS *);
116 extern  void ar5416AniPoll(struct ath_hal *, const HAL_NODE_STATS *,
117                              const struct ieee80211_channel *);
118 extern  void ar5416AniReset(struct ath_hal *, const struct ieee80211_channel *,
119                 HAL_OPMODE, int);
120
121 extern  void ar5416SetBeaconTimers(struct ath_hal *, const HAL_BEACON_TIMERS *);
122 extern  void ar5416BeaconInit(struct ath_hal *ah,
123                 uint32_t next_beacon, uint32_t beacon_period);
124 extern  void ar5416ResetStaBeaconTimers(struct ath_hal *ah);
125 extern  void ar5416SetStaBeaconTimers(struct ath_hal *ah,
126                 const HAL_BEACON_STATE *);
127
128 extern  HAL_BOOL ar5416EepromRead(struct ath_hal *, u_int off, uint16_t *data);
129 extern  HAL_BOOL ar5416EepromWrite(struct ath_hal *, u_int off, uint16_t data);
130
131 extern  HAL_BOOL ar5416IsInterruptPending(struct ath_hal *ah);
132 extern  HAL_BOOL ar5416GetPendingInterrupts(struct ath_hal *, HAL_INT *masked);
133 extern  HAL_INT ar5416SetInterrupts(struct ath_hal *ah, HAL_INT ints);
134
135 extern  HAL_BOOL ar5416GpioCfgOutput(struct ath_hal *, uint32_t gpio,
136                 HAL_GPIO_MUX_TYPE);
137 extern  HAL_BOOL ar5416GpioCfgInput(struct ath_hal *, uint32_t gpio);
138 extern  HAL_BOOL ar5416GpioSet(struct ath_hal *, uint32_t gpio, uint32_t val);
139 extern  uint32_t ar5416GpioGet(struct ath_hal *ah, uint32_t gpio);
140 extern  void ar5416GpioSetIntr(struct ath_hal *ah, u_int, uint32_t ilevel);
141
142 extern  u_int ar5416GetWirelessModes(struct ath_hal *ah);
143 extern  void ar5416SetLedState(struct ath_hal *ah, HAL_LED_STATE state);
144 extern  void ar5416ResetTsf(struct ath_hal *ah);
145 extern  HAL_BOOL ar5416SetAntennaSwitch(struct ath_hal *, HAL_ANT_SETTING);
146 extern  HAL_BOOL ar5416SetDecompMask(struct ath_hal *, uint16_t, int);
147 extern  void ar5416SetCoverageClass(struct ath_hal *, uint8_t, int);
148 extern  uint32_t ar5416Get11nExtBusy(struct ath_hal *ah);
149 extern  void ar5416Set11nMac2040(struct ath_hal *ah, HAL_HT_MACMODE mode);
150 extern  HAL_HT_RXCLEAR ar5416Get11nRxClear(struct ath_hal *ah);
151 extern  void ar5416Set11nRxClear(struct ath_hal *ah, HAL_HT_RXCLEAR rxclear);
152 extern  HAL_STATUS ar5416GetCapability(struct ath_hal *ah,
153             HAL_CAPABILITY_TYPE type, uint32_t capability, uint32_t *result);
154 extern  HAL_BOOL ar5416GetDiagState(struct ath_hal *ah, int request,
155             const void *args, uint32_t argsize,
156             void **result, uint32_t *resultsize);
157
158 extern  HAL_BOOL ar5416SetPowerMode(struct ath_hal *ah, HAL_POWER_MODE mode,
159                 int setChip);
160 extern  HAL_POWER_MODE ar5416GetPowerMode(struct ath_hal *ah);
161 extern  HAL_BOOL ar5416GetPowerStatus(struct ath_hal *ah);
162
163 extern  HAL_BOOL ar5416ResetKeyCacheEntry(struct ath_hal *ah, uint16_t entry);
164 extern  HAL_BOOL ar5416SetKeyCacheEntry(struct ath_hal *ah, uint16_t entry,
165                const HAL_KEYVAL *k, const uint8_t *mac, int xorKey);
166
167 extern  void ar5416StartPcuReceive(struct ath_hal *ah);
168 extern  void ar5416StopPcuReceive(struct ath_hal *ah);
169 extern  HAL_BOOL ar5416SetupRxDesc(struct ath_hal *,
170                 struct ath_desc *, uint32_t size, u_int flags);
171 extern  HAL_STATUS ar5416ProcRxDesc(struct ath_hal *ah, struct ath_desc *,
172                 uint32_t, struct ath_desc *, uint64_t,
173                 struct ath_rx_status *);
174
175 extern  HAL_BOOL ar5416Reset(struct ath_hal *ah, HAL_OPMODE opmode,
176                 struct ieee80211_channel *chan,
177                 HAL_BOOL bChannelChange, HAL_STATUS *status);
178 extern  HAL_BOOL ar5416PhyDisable(struct ath_hal *ah);
179 extern  HAL_RFGAIN ar5416GetRfgain(struct ath_hal *ah);
180 extern  HAL_BOOL ar5416Disable(struct ath_hal *ah);
181 extern  HAL_BOOL ar5416ChipReset(struct ath_hal *ah,
182                 const struct ieee80211_channel *);
183 extern  HAL_BOOL ar5416SetBoardValues(struct ath_hal *,
184                 const struct ieee80211_channel *);
185 extern  HAL_BOOL ar5416SetResetReg(struct ath_hal *, uint32_t type);
186 extern  HAL_BOOL ar5416SetTxPowerLimit(struct ath_hal *ah, uint32_t limit);
187 extern  HAL_BOOL ar5416SetTransmitPower(struct ath_hal *,
188                 const struct ieee80211_channel *, uint16_t *);
189 extern  HAL_BOOL ar5416GetChipPowerLimits(struct ath_hal *ah,
190                 struct ieee80211_channel *chan);
191 extern  void ar5416GetChannelCenters(struct ath_hal *,
192                 const struct ieee80211_channel *chan, CHAN_CENTERS *centers);
193 extern  void ar5416GetTargetPowers(struct ath_hal *ah, 
194                 const struct ieee80211_channel *chan,
195                 CAL_TARGET_POWER_HT *powInfo,
196                 uint16_t numChannels, CAL_TARGET_POWER_HT *pNewPower,
197                 uint16_t numRates, HAL_BOOL isHt40Target);
198 extern  void ar5416GetTargetPowersLeg(struct ath_hal *ah, 
199                 const struct ieee80211_channel *chan,
200                 CAL_TARGET_POWER_LEG *powInfo,
201                 uint16_t numChannels, CAL_TARGET_POWER_LEG *pNewPower,
202                 uint16_t numRates, HAL_BOOL isExtTarget);
203
204
205 extern  HAL_BOOL ar5416StopTxDma(struct ath_hal *ah, u_int q);
206 extern  HAL_BOOL ar5416SetupTxDesc(struct ath_hal *ah, struct ath_desc *ds,
207                 u_int pktLen, u_int hdrLen, HAL_PKT_TYPE type, u_int txPower,
208                 u_int txRate0, u_int txTries0,
209                 u_int keyIx, u_int antMode, u_int flags,
210                 u_int rtsctsRate, u_int rtsctsDuration,
211                 u_int compicvLen, u_int compivLen, u_int comp);
212 extern  HAL_BOOL ar5416SetupXTxDesc(struct ath_hal *, struct ath_desc *,
213                 u_int txRate1, u_int txRetries1,
214                 u_int txRate2, u_int txRetries2,
215                 u_int txRate3, u_int txRetries3);
216 extern  HAL_BOOL ar5416FillTxDesc(struct ath_hal *ah, struct ath_desc *ds,
217                 u_int segLen, HAL_BOOL firstSeg, HAL_BOOL lastSeg,
218                 const struct ath_desc *ds0);
219 extern  HAL_STATUS ar5416ProcTxDesc(struct ath_hal *ah,
220                 struct ath_desc *, struct ath_tx_status *);
221
222 extern  const HAL_RATE_TABLE *ar5416GetRateTable(struct ath_hal *, u_int mode);
223 #endif  /* _ATH_AR5416_H_ */