Port ah_writeIni and ar5416SpurMitigate from FreeBSD HAL
[madwifi/.git] / ath_hal / ar5416 / ar5416.h
1 /*
2  * Copyright (c) 2002-2008 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  * $Id: ar5416.h,v 1.19 2008/11/11 21:38:13 sam Exp $
18  */
19 #ifndef _ATH_AR5416_H_
20 #define _ATH_AR5416_H_
21
22 #include "ar5212/ar5212.h"
23 #include "ar5416_cal.h"
24
25 #define AR5416_MAGIC    0x20065416
26
27 enum {
28         HAL_RESET_POWER_ON,
29         HAL_RESET_WARM,
30         HAL_RESET_COLD,
31 };
32
33 typedef struct {
34         uint16_t        synth_center;
35         uint16_t        ctl_center;
36         uint16_t        ext_center;
37 } CHAN_CENTERS;
38
39 #define AR5416_DEFAULT_RXCHAINMASK      7
40 #define AR5416_DEFAULT_TXCHAINMASK      1
41 #define AR5416_MAX_RATE_POWER           63
42 #define AR5416_KEYTABLE_SIZE            128
43
44 #define AR5416_CCA_MAX_GOOD_VALUE       -85
45 #define AR5416_CCA_MAX_HIGH_VALUE       -62
46 #define AR5416_CCA_MIN_BAD_VALUE        -140
47
48 #define AR5416_SPUR_RSSI_THRESH         40
49
50 struct ath_hal_5416 {
51         struct ath_hal_5212 ah_5212;
52
53         /* NB: RF data setup at attach */
54         HAL_INI_ARRAY   ah_ini_bb_rfgain;
55         HAL_INI_ARRAY   ah_ini_bank0;
56         HAL_INI_ARRAY   ah_ini_bank1;
57         HAL_INI_ARRAY   ah_ini_bank2;
58         HAL_INI_ARRAY   ah_ini_bank3;
59         HAL_INI_ARRAY   ah_ini_bank6;
60         HAL_INI_ARRAY   ah_ini_bank7;
61         HAL_INI_ARRAY   ah_ini_addac;
62         HAL_INI_ARRAY   ah_ini_pcieserdes;
63
64         void            (*ah_writeIni)(struct ath_hal *,
65                             const HAL_CHANNEL *);
66         void            (*ah_spurMitigate)(struct ath_hal *,
67                             HAL_CHANNEL_INTERNAL *);
68
69         u_int           ah_globaltxtimeout;     /* global tx timeout */
70         int             ah_hangs;               /* h/w hangs state */
71         uint8_t         ah_keytype[AR5416_KEYTABLE_SIZE];
72         /*
73          * Extension Channel Rx Clear State
74          */
75         uint32_t        ah_cycleCount;
76         uint32_t        ah_ctlBusy;
77         uint32_t        ah_extBusy;
78         uint32_t        ah_rx_chainmask;
79         uint32_t        ah_tx_chainmask;
80
81         struct ar5416PerCal ah_cal;             /* periodic calibration state */
82 };
83 #define AH5416(_ah)     ((struct ath_hal_5416 *)(_ah))
84
85 #define IS_5416_PCI(ah) ((AH_PRIVATE(ah)->ah_macVersion) == AR_SREV_VERSION_OWL_PCI)
86 #define IS_5416_PCIE(ah) ((AH_PRIVATE(ah)->ah_macVersion) == AR_SREV_VERSION_OWL_PCIE)
87 #undef IS_PCIE
88 #define IS_PCIE(ah) (IS_5416_PCIE(ah))
89
90 extern  HAL_BOOL ar2133RfAttach(struct ath_hal *, HAL_STATUS *);
91
92 struct ath_hal;
93
94 extern  uint32_t ar5416GetRadioRev(struct ath_hal *ah);
95 extern  void ar5416InitState(struct ath_hal_5416 *, uint16_t devid,
96                 HAL_SOFTC sc, HAL_BUS_TAG st, HAL_BUS_HANDLE sh,
97                 HAL_STATUS *status);
98 extern  void ar5416Detach(struct ath_hal *ah);
99 extern  void ar5416AttachPCIE(struct ath_hal *ah);
100 extern  HAL_BOOL ar5416FillCapabilityInfo(struct ath_hal *ah);
101
102 #define IS_5GHZ_FAST_CLOCK_EN(_ah, _c) \
103         (IS_CHAN_5GHZ(_c) && ath_hal_eepromGetFlag(ah, AR_EEP_FSTCLK_5G))
104
105 extern  void ar5416AniAttach(struct ath_hal *, const struct ar5212AniParams *,
106                 const struct ar5212AniParams *, HAL_BOOL ena);
107 extern  void ar5416AniDetach(struct ath_hal *);
108 extern  HAL_BOOL ar5416AniControl(struct ath_hal *, HAL_ANI_CMD cmd, int param);
109 extern  HAL_BOOL ar5416AniSetParams(struct ath_hal *,
110                 const struct ar5212AniParams *, const struct ar5212AniParams *);
111 extern  void ar5416ProcessMibIntr(struct ath_hal *, const HAL_NODE_STATS *);
112 extern  void ar5416AniPoll(struct ath_hal *, const HAL_NODE_STATS *,
113                              HAL_CHANNEL *);
114 extern  void ar5416AniReset(struct ath_hal *, HAL_CHANNEL_INTERNAL *,
115                 HAL_OPMODE, int);
116
117 extern  void ar5416SetBeaconTimers(struct ath_hal *, const HAL_BEACON_TIMERS *);
118 extern  void ar5416BeaconInit(struct ath_hal *ah,
119                 uint32_t next_beacon, uint32_t beacon_period);
120 extern  void ar5416ResetStaBeaconTimers(struct ath_hal *ah);
121 extern  void ar5416SetStaBeaconTimers(struct ath_hal *ah,
122                 const HAL_BEACON_STATE *);
123
124 extern  HAL_BOOL ar5416EepromRead(struct ath_hal *, u_int off, uint16_t *data);
125 extern  HAL_BOOL ar5416EepromWrite(struct ath_hal *, u_int off, uint16_t data);
126
127 extern  HAL_BOOL ar5416IsInterruptPending(struct ath_hal *ah);
128 extern  HAL_BOOL ar5416GetPendingInterrupts(struct ath_hal *, HAL_INT *masked);
129 extern  HAL_INT ar5416SetInterrupts(struct ath_hal *ah, HAL_INT ints);
130
131 extern  HAL_BOOL ar5416GpioCfgOutput(struct ath_hal *, uint32_t gpio);
132 extern  HAL_BOOL ar5416GpioCfgInput(struct ath_hal *, uint32_t gpio);
133 extern  HAL_BOOL ar5416GpioSet(struct ath_hal *, uint32_t gpio, uint32_t val);
134 extern  uint32_t ar5416GpioGet(struct ath_hal *ah, uint32_t gpio);
135 extern  void ar5416GpioSetIntr(struct ath_hal *ah, u_int, uint32_t ilevel);
136
137 extern  u_int ar5416GetWirelessModes(struct ath_hal *ah);
138 extern  void ar5416SetLedState(struct ath_hal *ah, HAL_LED_STATE state);
139 extern  void ar5416ResetTsf(struct ath_hal *ah);
140 extern  HAL_BOOL ar5416SetAntennaSwitch(struct ath_hal *, HAL_ANT_SETTING);
141 extern  HAL_BOOL ar5416SetDecompMask(struct ath_hal *, uint16_t, int);
142 extern  void ar5416SetCoverageClass(struct ath_hal *, uint8_t, int);
143 extern  uint32_t ar5416Get11nExtBusy(struct ath_hal *ah);
144 extern  void ar5416Set11nMac2040(struct ath_hal *ah, HAL_HT_MACMODE mode);
145 extern  HAL_HT_RXCLEAR ar5416Get11nRxClear(struct ath_hal *ah);
146 extern  void ar5416Set11nRxClear(struct ath_hal *ah, HAL_HT_RXCLEAR rxclear);
147 extern  HAL_STATUS ar5416GetCapability(struct ath_hal *ah,
148             HAL_CAPABILITY_TYPE type, uint32_t capability, uint32_t *result);
149 extern  HAL_BOOL ar5416GetDiagState(struct ath_hal *ah, int request,
150             const void *args, uint32_t argsize,
151             void **result, uint32_t *resultsize);
152
153 extern  HAL_BOOL ar5416SetPowerMode(struct ath_hal *ah, HAL_POWER_MODE mode,
154                 int setChip);
155 extern  HAL_POWER_MODE ar5416GetPowerMode(struct ath_hal *ah);
156 extern  HAL_BOOL ar5416GetPowerStatus(struct ath_hal *ah);
157
158 extern  HAL_BOOL ar5416ResetKeyCacheEntry(struct ath_hal *ah, uint16_t entry);
159 extern  HAL_BOOL ar5416SetKeyCacheEntry(struct ath_hal *ah, uint16_t entry,
160                const HAL_KEYVAL *k, const uint8_t *mac, int xorKey);
161
162 extern  void ar5416StartPcuReceive(struct ath_hal *ah);
163 extern  void ar5416StopPcuReceive(struct ath_hal *ah);
164 extern  HAL_BOOL ar5416SetupRxDesc(struct ath_hal *,
165                 struct ath_desc *, uint32_t size, u_int flags);
166 extern  HAL_STATUS ar5416ProcRxDesc(struct ath_hal *ah, struct ath_desc *,
167                 uint32_t, struct ath_desc *, uint64_t,
168                 struct ath_rx_status *);
169
170 extern  HAL_BOOL ar5416Reset(struct ath_hal *ah, HAL_OPMODE opmode,
171                 HAL_CHANNEL *chan, HAL_BOOL bChannelChange, HAL_STATUS *status);
172 extern  HAL_BOOL ar5416PhyDisable(struct ath_hal *ah);
173 extern  HAL_RFGAIN ar5416GetRfgain(struct ath_hal *ah);
174 extern  HAL_BOOL ar5416Disable(struct ath_hal *ah);
175 extern  HAL_BOOL ar5416ChipReset(struct ath_hal *ah, HAL_CHANNEL *);
176 extern  HAL_BOOL ar5416SetResetReg(struct ath_hal *, uint32_t type);
177 extern  HAL_BOOL ar5416SetTxPowerLimit(struct ath_hal *ah, uint32_t limit);
178 extern  HAL_BOOL ar5416GetChipPowerLimits(struct ath_hal *ah,
179                 HAL_CHANNEL *chans, uint32_t nchans);
180 extern  void ar5416GetChannelCenters(struct ath_hal *,
181                 HAL_CHANNEL_INTERNAL *chan, CHAN_CENTERS *centers);
182
183 extern  HAL_BOOL ar5416StopTxDma(struct ath_hal *ah, u_int q);
184 extern  HAL_BOOL ar5416SetupTxDesc(struct ath_hal *ah, struct ath_desc *ds,
185                 u_int pktLen, u_int hdrLen, HAL_PKT_TYPE type, u_int txPower,
186                 u_int txRate0, u_int txTries0,
187                 u_int keyIx, u_int antMode, u_int flags,
188                 u_int rtsctsRate, u_int rtsctsDuration,
189                 u_int compicvLen, u_int compivLen, u_int comp);
190 extern  HAL_BOOL ar5416SetupXTxDesc(struct ath_hal *, struct ath_desc *,
191                 u_int txRate1, u_int txRetries1,
192                 u_int txRate2, u_int txRetries2,
193                 u_int txRate3, u_int txRetries3);
194 extern  HAL_BOOL ar5416FillTxDesc(struct ath_hal *ah, struct ath_desc *ds,
195                 u_int segLen, HAL_BOOL firstSeg, HAL_BOOL lastSeg,
196                 const struct ath_desc *ds0);
197 extern  HAL_STATUS ar5416ProcTxDesc(struct ath_hal *ah,
198                 struct ath_desc *, struct ath_tx_status *);
199
200 extern  const HAL_RATE_TABLE *ar5416GetRateTable(struct ath_hal *, u_int mode);
201 #endif  /* _ATH_AR5416_H_ */