aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/ath5k/hw.h
diff options
context:
space:
mode:
authorJiri Slaby <jirislaby@gmail.com>2007-08-12 11:33:16 -0400
committerDavid S. Miller <davem@davemloft.net>2008-01-28 18:09:35 -0500
commitfa1c114fdaa605496045e56c42d0c8aa4c139e57 (patch)
treedf8345d8ef17cea23da3c0bbe388729b79920bfe /drivers/net/wireless/ath5k/hw.h
parent3543f8069d3cc932202e64095d1d3986a10d34ed (diff)
[PATCH] Net: add ath5k wireless driver
add ath5k wireless driver Portions of this driver are covered by one or both of the ISC and 3-clause BSD licenses. Specific license information is cited at the top of each file. Acked-by and Signed-off-by information is collected from individual patches as collected in the wireless-2.6 tree prior to upstream submission. Acked-by: Matthew W. S. Bell <mentor@madwifi.org> Acked-by: Michael Taylor <mike.taylor@apprion.com> Acked-by: Pavel Roskin <proski@gnu.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Bradley M. Kuhn <bkuhn@softwarefreedom.org> Signed-off-by: Bruno Randolf <bruno@thinktube.com> Signed-off-by: Dave Young <hidave.darkstar@gmail.com> Signed-off-by: Francesco Gringoli <francesco.gringoli@ing.unibs.it> Signed-off-by: Jiri Slaby <jirislaby@gmail.com> Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Signed-off-by: Karen Sandler <karen@softwarefreedom.org> Signed-off-by: Krzysztof Halasa <khc@pm.waw.pl> Signed-off-by: Luis R. Rodriguez <mcgrof@gmail.com> Signed-off-by: Matt Norwood <norwood@softwarefreedom.org> Signed-off-by: Nick Kossifidis <mickflemm@gmail.com> Signed-off-by: Richard Fontana <fontana@softwarefreedom.org> Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org> Signed-off-by: Ulrich Meis <meis@nets.rwth-aachen.de> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/ath5k/hw.h')
-rw-r--r--drivers/net/wireless/ath5k/hw.h588
1 files changed, 588 insertions, 0 deletions
diff --git a/drivers/net/wireless/ath5k/hw.h b/drivers/net/wireless/ath5k/hw.h
new file mode 100644
index 000000000000..d9a7c0973f53
--- /dev/null
+++ b/drivers/net/wireless/ath5k/hw.h
@@ -0,0 +1,588 @@
1/*
2 * Copyright (c) 2004-2007 Reyk Floeter <reyk@openbsd.org>
3 * Copyright (c) 2006-2007 Nick Kossifidis <mickflemm@gmail.com>
4 * Copyright (c) 2007 Matthew W. S. Bell <mentor@madwifi.org>
5 * Copyright (c) 2007 Luis Rodriguez <mcgrof@winlab.rutgers.edu>
6 *
7 * Permission to use, copy, modify, and distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
10 *
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 */
19
20#include <linux/delay.h>
21
22/*
23 * Gain settings
24 */
25
26enum ath5k_rfgain {
27 AR5K_RFGAIN_INACTIVE = 0,
28 AR5K_RFGAIN_READ_REQUESTED,
29 AR5K_RFGAIN_NEED_CHANGE,
30};
31
32#define AR5K_GAIN_CRN_FIX_BITS_5111 4
33#define AR5K_GAIN_CRN_FIX_BITS_5112 7
34#define AR5K_GAIN_CRN_MAX_FIX_BITS AR5K_GAIN_CRN_FIX_BITS_5112
35#define AR5K_GAIN_DYN_ADJUST_HI_MARGIN 15
36#define AR5K_GAIN_DYN_ADJUST_LO_MARGIN 20
37#define AR5K_GAIN_CCK_PROBE_CORR 5
38#define AR5K_GAIN_CCK_OFDM_GAIN_DELTA 15
39#define AR5K_GAIN_STEP_COUNT 10
40#define AR5K_GAIN_PARAM_TX_CLIP 0
41#define AR5K_GAIN_PARAM_PD_90 1
42#define AR5K_GAIN_PARAM_PD_84 2
43#define AR5K_GAIN_PARAM_GAIN_SEL 3
44#define AR5K_GAIN_PARAM_MIX_ORN 0
45#define AR5K_GAIN_PARAM_PD_138 1
46#define AR5K_GAIN_PARAM_PD_137 2
47#define AR5K_GAIN_PARAM_PD_136 3
48#define AR5K_GAIN_PARAM_PD_132 4
49#define AR5K_GAIN_PARAM_PD_131 5
50#define AR5K_GAIN_PARAM_PD_130 6
51#define AR5K_GAIN_CHECK_ADJUST(_g) \
52 ((_g)->g_current <= (_g)->g_low || (_g)->g_current >= (_g)->g_high)
53
54struct ath5k_gain_opt_step {
55 s16 gos_param[AR5K_GAIN_CRN_MAX_FIX_BITS];
56 s32 gos_gain;
57};
58
59struct ath5k_gain {
60 u32 g_step_idx;
61 u32 g_current;
62 u32 g_target;
63 u32 g_low;
64 u32 g_high;
65 u32 g_f_corr;
66 u32 g_active;
67 const struct ath5k_gain_opt_step *g_step;
68};
69
70
71/*
72 * HW SPECIFIC STRUCTS
73 */
74
75/* Some EEPROM defines */
76#define AR5K_EEPROM_EEP_SCALE 100
77#define AR5K_EEPROM_EEP_DELTA 10
78#define AR5K_EEPROM_N_MODES 3
79#define AR5K_EEPROM_N_5GHZ_CHAN 10
80#define AR5K_EEPROM_N_2GHZ_CHAN 3
81#define AR5K_EEPROM_MAX_CHAN 10
82#define AR5K_EEPROM_N_PCDAC 11
83#define AR5K_EEPROM_N_TEST_FREQ 8
84#define AR5K_EEPROM_N_EDGES 8
85#define AR5K_EEPROM_N_INTERCEPTS 11
86#define AR5K_EEPROM_FREQ_M(_v) AR5K_EEPROM_OFF(_v, 0x7f, 0xff)
87#define AR5K_EEPROM_PCDAC_M 0x3f
88#define AR5K_EEPROM_PCDAC_START 1
89#define AR5K_EEPROM_PCDAC_STOP 63
90#define AR5K_EEPROM_PCDAC_STEP 1
91#define AR5K_EEPROM_NON_EDGE_M 0x40
92#define AR5K_EEPROM_CHANNEL_POWER 8
93#define AR5K_EEPROM_N_OBDB 4
94#define AR5K_EEPROM_OBDB_DIS 0xffff
95#define AR5K_EEPROM_CHANNEL_DIS 0xff
96#define AR5K_EEPROM_SCALE_OC_DELTA(_x) (((_x) * 2) / 10)
97#define AR5K_EEPROM_N_CTLS(_v) AR5K_EEPROM_OFF(_v, 16, 32)
98#define AR5K_EEPROM_MAX_CTLS 32
99#define AR5K_EEPROM_N_XPD_PER_CHANNEL 4
100#define AR5K_EEPROM_N_XPD0_POINTS 4
101#define AR5K_EEPROM_N_XPD3_POINTS 3
102#define AR5K_EEPROM_N_INTERCEPT_10_2GHZ 35
103#define AR5K_EEPROM_N_INTERCEPT_10_5GHZ 55
104#define AR5K_EEPROM_POWER_M 0x3f
105#define AR5K_EEPROM_POWER_MIN 0
106#define AR5K_EEPROM_POWER_MAX 3150
107#define AR5K_EEPROM_POWER_STEP 50
108#define AR5K_EEPROM_POWER_TABLE_SIZE 64
109#define AR5K_EEPROM_N_POWER_LOC_11B 4
110#define AR5K_EEPROM_N_POWER_LOC_11G 6
111#define AR5K_EEPROM_I_GAIN 10
112#define AR5K_EEPROM_CCK_OFDM_DELTA 15
113#define AR5K_EEPROM_N_IQ_CAL 2
114
115/* Struct to hold EEPROM calibration data */
116struct ath5k_eeprom_info {
117 u16 ee_magic;
118 u16 ee_protect;
119 u16 ee_regdomain;
120 u16 ee_version;
121 u16 ee_header;
122 u16 ee_ant_gain;
123 u16 ee_misc0;
124 u16 ee_misc1;
125 u16 ee_cck_ofdm_gain_delta;
126 u16 ee_cck_ofdm_power_delta;
127 u16 ee_scaled_cck_delta;
128
129 /* Used for tx thermal adjustment (eeprom_init, rfregs) */
130 u16 ee_tx_clip;
131 u16 ee_pwd_84;
132 u16 ee_pwd_90;
133 u16 ee_gain_select;
134
135 /* RF Calibration settings (reset, rfregs) */
136 u16 ee_i_cal[AR5K_EEPROM_N_MODES];
137 u16 ee_q_cal[AR5K_EEPROM_N_MODES];
138 u16 ee_fixed_bias[AR5K_EEPROM_N_MODES];
139 u16 ee_turbo_max_power[AR5K_EEPROM_N_MODES];
140 u16 ee_xr_power[AR5K_EEPROM_N_MODES];
141 u16 ee_switch_settling[AR5K_EEPROM_N_MODES];
142 u16 ee_ant_tx_rx[AR5K_EEPROM_N_MODES];
143 u16 ee_ant_control[AR5K_EEPROM_N_MODES][AR5K_EEPROM_N_PCDAC];
144 u16 ee_ob[AR5K_EEPROM_N_MODES][AR5K_EEPROM_N_OBDB];
145 u16 ee_db[AR5K_EEPROM_N_MODES][AR5K_EEPROM_N_OBDB];
146 u16 ee_tx_end2xlna_enable[AR5K_EEPROM_N_MODES];
147 u16 ee_tx_end2xpa_disable[AR5K_EEPROM_N_MODES];
148 u16 ee_tx_frm2xpa_enable[AR5K_EEPROM_N_MODES];
149 u16 ee_thr_62[AR5K_EEPROM_N_MODES];
150 u16 ee_xlna_gain[AR5K_EEPROM_N_MODES];
151 u16 ee_xpd[AR5K_EEPROM_N_MODES];
152 u16 ee_x_gain[AR5K_EEPROM_N_MODES];
153 u16 ee_i_gain[AR5K_EEPROM_N_MODES];
154 u16 ee_margin_tx_rx[AR5K_EEPROM_N_MODES];
155
156 /* Unused */
157 u16 ee_false_detect[AR5K_EEPROM_N_MODES];
158 u16 ee_cal_pier[AR5K_EEPROM_N_MODES][AR5K_EEPROM_N_2GHZ_CHAN];
159 u16 ee_channel[AR5K_EEPROM_N_MODES][AR5K_EEPROM_MAX_CHAN]; /*empty*/
160
161 /* Conformance test limits (Unused) */
162 u16 ee_ctls;
163 u16 ee_ctl[AR5K_EEPROM_MAX_CTLS];
164
165 /* Noise Floor Calibration settings */
166 s16 ee_noise_floor_thr[AR5K_EEPROM_N_MODES];
167 s8 ee_adc_desired_size[AR5K_EEPROM_N_MODES];
168 s8 ee_pga_desired_size[AR5K_EEPROM_N_MODES];
169};
170
171/*
172 * Internal RX/TX descriptor structures
173 * (rX: reserved fields possibily used by future versions of the ar5k chipset)
174 */
175
176struct ath5k_rx_desc {
177 u32 rx_control_0; /* RX control word 0 */
178
179#define AR5K_DESC_RX_CTL0 0x00000000
180
181 u32 rx_control_1; /* RX control word 1 */
182
183#define AR5K_DESC_RX_CTL1_BUF_LEN 0x00000fff
184#define AR5K_DESC_RX_CTL1_INTREQ 0x00002000
185} __packed;
186
187/*
188 * 5210/5211 rx status descriptor
189 */
190struct ath5k_hw_old_rx_status {
191 u32 rx_status_0; /* RX status word 0 */
192
193#define AR5K_OLD_RX_DESC_STATUS0_DATA_LEN 0x00000fff
194#define AR5K_OLD_RX_DESC_STATUS0_MORE 0x00001000
195#define AR5K_OLD_RX_DESC_STATUS0_RECEIVE_RATE 0x00078000
196#define AR5K_OLD_RX_DESC_STATUS0_RECEIVE_RATE_S 15
197#define AR5K_OLD_RX_DESC_STATUS0_RECEIVE_SIGNAL 0x07f80000
198#define AR5K_OLD_RX_DESC_STATUS0_RECEIVE_SIGNAL_S 19
199#define AR5K_OLD_RX_DESC_STATUS0_RECEIVE_ANTENNA 0x38000000
200#define AR5K_OLD_RX_DESC_STATUS0_RECEIVE_ANTENNA_S 27
201
202 u32 rx_status_1; /* RX status word 1 */
203
204#define AR5K_OLD_RX_DESC_STATUS1_DONE 0x00000001
205#define AR5K_OLD_RX_DESC_STATUS1_FRAME_RECEIVE_OK 0x00000002
206#define AR5K_OLD_RX_DESC_STATUS1_CRC_ERROR 0x00000004
207#define AR5K_OLD_RX_DESC_STATUS1_FIFO_OVERRUN 0x00000008
208#define AR5K_OLD_RX_DESC_STATUS1_DECRYPT_CRC_ERROR 0x00000010
209#define AR5K_OLD_RX_DESC_STATUS1_PHY_ERROR 0x000000e0
210#define AR5K_OLD_RX_DESC_STATUS1_PHY_ERROR_S 5
211#define AR5K_OLD_RX_DESC_STATUS1_KEY_INDEX_VALID 0x00000100
212#define AR5K_OLD_RX_DESC_STATUS1_KEY_INDEX 0x00007e00
213#define AR5K_OLD_RX_DESC_STATUS1_KEY_INDEX_S 9
214#define AR5K_OLD_RX_DESC_STATUS1_RECEIVE_TIMESTAMP 0x0fff8000
215#define AR5K_OLD_RX_DESC_STATUS1_RECEIVE_TIMESTAMP_S 15
216#define AR5K_OLD_RX_DESC_STATUS1_KEY_CACHE_MISS 0x10000000
217} __packed;
218
219/*
220 * 5212 rx status descriptor
221 */
222struct ath5k_hw_new_rx_status {
223 u32 rx_status_0; /* RX status word 0 */
224
225#define AR5K_NEW_RX_DESC_STATUS0_DATA_LEN 0x00000fff
226#define AR5K_NEW_RX_DESC_STATUS0_MORE 0x00001000
227#define AR5K_NEW_RX_DESC_STATUS0_DECOMP_CRC_ERROR 0x00002000
228#define AR5K_NEW_RX_DESC_STATUS0_RECEIVE_RATE 0x000f8000
229#define AR5K_NEW_RX_DESC_STATUS0_RECEIVE_RATE_S 15
230#define AR5K_NEW_RX_DESC_STATUS0_RECEIVE_SIGNAL 0x0ff00000
231#define AR5K_NEW_RX_DESC_STATUS0_RECEIVE_SIGNAL_S 20
232#define AR5K_NEW_RX_DESC_STATUS0_RECEIVE_ANTENNA 0xf0000000
233#define AR5K_NEW_RX_DESC_STATUS0_RECEIVE_ANTENNA_S 28
234
235 u32 rx_status_1; /* RX status word 1 */
236
237#define AR5K_NEW_RX_DESC_STATUS1_DONE 0x00000001
238#define AR5K_NEW_RX_DESC_STATUS1_FRAME_RECEIVE_OK 0x00000002
239#define AR5K_NEW_RX_DESC_STATUS1_CRC_ERROR 0x00000004
240#define AR5K_NEW_RX_DESC_STATUS1_DECRYPT_CRC_ERROR 0x00000008
241#define AR5K_NEW_RX_DESC_STATUS1_PHY_ERROR 0x00000010
242#define AR5K_NEW_RX_DESC_STATUS1_MIC_ERROR 0x00000020
243#define AR5K_NEW_RX_DESC_STATUS1_KEY_INDEX_VALID 0x00000100
244#define AR5K_NEW_RX_DESC_STATUS1_KEY_INDEX 0x0000fe00
245#define AR5K_NEW_RX_DESC_STATUS1_KEY_INDEX_S 9
246#define AR5K_NEW_RX_DESC_STATUS1_RECEIVE_TIMESTAMP 0x7fff0000
247#define AR5K_NEW_RX_DESC_STATUS1_RECEIVE_TIMESTAMP_S 16
248#define AR5K_NEW_RX_DESC_STATUS1_KEY_CACHE_MISS 0x80000000
249} __packed;
250
251struct ath5k_hw_rx_error {
252 u32 rx_error_0; /* RX error word 0 */
253
254#define AR5K_RX_DESC_ERROR0 0x00000000
255
256 u32 rx_error_1; /* RX error word 1 */
257
258#define AR5K_RX_DESC_ERROR1_PHY_ERROR_CODE 0x0000ff00
259#define AR5K_RX_DESC_ERROR1_PHY_ERROR_CODE_S 8
260} __packed;
261
262#define AR5K_DESC_RX_PHY_ERROR_NONE 0x00
263#define AR5K_DESC_RX_PHY_ERROR_TIMING 0x20
264#define AR5K_DESC_RX_PHY_ERROR_PARITY 0x40
265#define AR5K_DESC_RX_PHY_ERROR_RATE 0x60
266#define AR5K_DESC_RX_PHY_ERROR_LENGTH 0x80
267#define AR5K_DESC_RX_PHY_ERROR_64QAM 0xa0
268#define AR5K_DESC_RX_PHY_ERROR_SERVICE 0xc0
269#define AR5K_DESC_RX_PHY_ERROR_TRANSMITOVR 0xe0
270
271struct ath5k_hw_2w_tx_desc {
272 u32 tx_control_0; /* TX control word 0 */
273
274#define AR5K_2W_TX_DESC_CTL0_FRAME_LEN 0x00000fff
275#define AR5K_2W_TX_DESC_CTL0_HEADER_LEN 0x0003f000 /*[5210 ?]*/
276#define AR5K_2W_TX_DESC_CTL0_HEADER_LEN_S 12
277#define AR5K_2W_TX_DESC_CTL0_XMIT_RATE 0x003c0000
278#define AR5K_2W_TX_DESC_CTL0_XMIT_RATE_S 18
279#define AR5K_2W_TX_DESC_CTL0_RTSENA 0x00400000
280#define AR5K_2W_TX_DESC_CTL0_CLRDMASK 0x01000000
281#define AR5K_2W_TX_DESC_CTL0_LONG_PACKET 0x00800000 /*[5210]*/
282#define AR5K_2W_TX_DESC_CTL0_VEOL 0x00800000 /*[5211]*/
283#define AR5K_2W_TX_DESC_CTL0_FRAME_TYPE 0x1c000000 /*[5210]*/
284#define AR5K_2W_TX_DESC_CTL0_FRAME_TYPE_S 26
285#define AR5K_2W_TX_DESC_CTL0_ANT_MODE_XMIT_5210 0x02000000
286#define AR5K_2W_TX_DESC_CTL0_ANT_MODE_XMIT_5211 0x1e000000
287#define AR5K_2W_TX_DESC_CTL0_ANT_MODE_XMIT (ah->ah_version == AR5K_AR5210 ? \
288 AR5K_2W_TX_DESC_CTL0_ANT_MODE_XMIT_5210 : \
289 AR5K_2W_TX_DESC_CTL0_ANT_MODE_XMIT_5211)
290#define AR5K_2W_TX_DESC_CTL0_ANT_MODE_XMIT_S 25
291#define AR5K_2W_TX_DESC_CTL0_INTREQ 0x20000000
292#define AR5K_2W_TX_DESC_CTL0_ENCRYPT_KEY_VALID 0x40000000
293
294 u32 tx_control_1; /* TX control word 1 */
295
296#define AR5K_2W_TX_DESC_CTL1_BUF_LEN 0x00000fff
297#define AR5K_2W_TX_DESC_CTL1_MORE 0x00001000
298#define AR5K_2W_TX_DESC_CTL1_ENCRYPT_KEY_INDEX_5210 0x0007e000
299#define AR5K_2W_TX_DESC_CTL1_ENCRYPT_KEY_INDEX_5211 0x000fe000
300#define AR5K_2W_TX_DESC_CTL1_ENCRYPT_KEY_INDEX (ah->ah_version == AR5K_AR5210 ? \
301 AR5K_2W_TX_DESC_CTL1_ENCRYPT_KEY_INDEX_5210 : \
302 AR5K_2W_TX_DESC_CTL1_ENCRYPT_KEY_INDEX_5211)
303#define AR5K_2W_TX_DESC_CTL1_ENCRYPT_KEY_INDEX_S 13
304#define AR5K_2W_TX_DESC_CTL1_FRAME_TYPE 0x00700000 /*[5211]*/
305#define AR5K_2W_TX_DESC_CTL1_FRAME_TYPE_S 20
306#define AR5K_2W_TX_DESC_CTL1_NOACK 0x00800000 /*[5211]*/
307#define AR5K_2W_TX_DESC_CTL1_RTS_DURATION 0xfff80000 /*[5210 ?]*/
308} __packed;
309
310#define AR5K_AR5210_TX_DESC_FRAME_TYPE_NORMAL 0x00
311#define AR5K_AR5210_TX_DESC_FRAME_TYPE_ATIM 0x04
312#define AR5K_AR5210_TX_DESC_FRAME_TYPE_PSPOLL 0x08
313#define AR5K_AR5210_TX_DESC_FRAME_TYPE_NO_DELAY 0x0c
314#define AR5K_AR5210_TX_DESC_FRAME_TYPE_PIFS 0x10
315
316/*
317 * 5212 4-word tx control descriptor
318 */
319struct ath5k_hw_4w_tx_desc {
320 u32 tx_control_0; /* TX control word 0 */
321
322#define AR5K_4W_TX_DESC_CTL0_FRAME_LEN 0x00000fff
323#define AR5K_4W_TX_DESC_CTL0_XMIT_POWER 0x003f0000
324#define AR5K_4W_TX_DESC_CTL0_XMIT_POWER_S 16
325#define AR5K_4W_TX_DESC_CTL0_RTSENA 0x00400000
326#define AR5K_4W_TX_DESC_CTL0_VEOL 0x00800000
327#define AR5K_4W_TX_DESC_CTL0_CLRDMASK 0x01000000
328#define AR5K_4W_TX_DESC_CTL0_ANT_MODE_XMIT 0x1e000000
329#define AR5K_4W_TX_DESC_CTL0_ANT_MODE_XMIT_S 25
330#define AR5K_4W_TX_DESC_CTL0_INTREQ 0x20000000
331#define AR5K_4W_TX_DESC_CTL0_ENCRYPT_KEY_VALID 0x40000000
332#define AR5K_4W_TX_DESC_CTL0_CTSENA 0x80000000
333
334 u32 tx_control_1; /* TX control word 1 */
335
336#define AR5K_4W_TX_DESC_CTL1_BUF_LEN 0x00000fff
337#define AR5K_4W_TX_DESC_CTL1_MORE 0x00001000
338#define AR5K_4W_TX_DESC_CTL1_ENCRYPT_KEY_INDEX 0x000fe000
339#define AR5K_4W_TX_DESC_CTL1_ENCRYPT_KEY_INDEX_S 13
340#define AR5K_4W_TX_DESC_CTL1_FRAME_TYPE 0x00f00000
341#define AR5K_4W_TX_DESC_CTL1_FRAME_TYPE_S 20
342#define AR5K_4W_TX_DESC_CTL1_NOACK 0x01000000
343#define AR5K_4W_TX_DESC_CTL1_COMP_PROC 0x06000000
344#define AR5K_4W_TX_DESC_CTL1_COMP_PROC_S 25
345#define AR5K_4W_TX_DESC_CTL1_COMP_IV_LEN 0x18000000
346#define AR5K_4W_TX_DESC_CTL1_COMP_IV_LEN_S 27
347#define AR5K_4W_TX_DESC_CTL1_COMP_ICV_LEN 0x60000000
348#define AR5K_4W_TX_DESC_CTL1_COMP_ICV_LEN_S 29
349
350 u32 tx_control_2; /* TX control word 2 */
351
352#define AR5K_4W_TX_DESC_CTL2_RTS_DURATION 0x00007fff
353#define AR5K_4W_TX_DESC_CTL2_DURATION_UPDATE_ENABLE 0x00008000
354#define AR5K_4W_TX_DESC_CTL2_XMIT_TRIES0 0x000f0000
355#define AR5K_4W_TX_DESC_CTL2_XMIT_TRIES0_S 16
356#define AR5K_4W_TX_DESC_CTL2_XMIT_TRIES1 0x00f00000
357#define AR5K_4W_TX_DESC_CTL2_XMIT_TRIES1_S 20
358#define AR5K_4W_TX_DESC_CTL2_XMIT_TRIES2 0x0f000000
359#define AR5K_4W_TX_DESC_CTL2_XMIT_TRIES2_S 24
360#define AR5K_4W_TX_DESC_CTL2_XMIT_TRIES3 0xf0000000
361#define AR5K_4W_TX_DESC_CTL2_XMIT_TRIES3_S 28
362
363 u32 tx_control_3; /* TX control word 3 */
364
365#define AR5K_4W_TX_DESC_CTL3_XMIT_RATE0 0x0000001f
366#define AR5K_4W_TX_DESC_CTL3_XMIT_RATE1 0x000003e0
367#define AR5K_4W_TX_DESC_CTL3_XMIT_RATE1_S 5
368#define AR5K_4W_TX_DESC_CTL3_XMIT_RATE2 0x00007c00
369#define AR5K_4W_TX_DESC_CTL3_XMIT_RATE2_S 10
370#define AR5K_4W_TX_DESC_CTL3_XMIT_RATE3 0x000f8000
371#define AR5K_4W_TX_DESC_CTL3_XMIT_RATE3_S 15
372#define AR5K_4W_TX_DESC_CTL3_RTS_CTS_RATE 0x01f00000
373#define AR5K_4W_TX_DESC_CTL3_RTS_CTS_RATE_S 20
374} __packed;
375
376/*
377 * Common tx status descriptor
378 */
379struct ath5k_hw_tx_status {
380 u32 tx_status_0; /* TX status word 0 */
381
382#define AR5K_DESC_TX_STATUS0_FRAME_XMIT_OK 0x00000001
383#define AR5K_DESC_TX_STATUS0_EXCESSIVE_RETRIES 0x00000002
384#define AR5K_DESC_TX_STATUS0_FIFO_UNDERRUN 0x00000004
385#define AR5K_DESC_TX_STATUS0_FILTERED 0x00000008
386/*???
387#define AR5K_DESC_TX_STATUS0_RTS_FAIL_COUNT 0x000000f0
388#define AR5K_DESC_TX_STATUS0_RTS_FAIL_COUNT_S 4
389*/
390#define AR5K_DESC_TX_STATUS0_SHORT_RETRY_COUNT 0x000000f0
391#define AR5K_DESC_TX_STATUS0_SHORT_RETRY_COUNT_S 4
392/*???
393#define AR5K_DESC_TX_STATUS0_DATA_FAIL_COUNT 0x00000f00
394#define AR5K_DESC_TX_STATUS0_DATA_FAIL_COUNT_S 8
395*/
396#define AR5K_DESC_TX_STATUS0_LONG_RETRY_COUNT 0x00000f00
397#define AR5K_DESC_TX_STATUS0_LONG_RETRY_COUNT_S 8
398#define AR5K_DESC_TX_STATUS0_VIRT_COLL_COUNT 0x0000f000
399#define AR5K_DESC_TX_STATUS0_VIRT_COLL_COUNT_S 12
400#define AR5K_DESC_TX_STATUS0_SEND_TIMESTAMP 0xffff0000
401#define AR5K_DESC_TX_STATUS0_SEND_TIMESTAMP_S 16
402
403 u32 tx_status_1; /* TX status word 1 */
404
405#define AR5K_DESC_TX_STATUS1_DONE 0x00000001
406#define AR5K_DESC_TX_STATUS1_SEQ_NUM 0x00001ffe
407#define AR5K_DESC_TX_STATUS1_SEQ_NUM_S 1
408#define AR5K_DESC_TX_STATUS1_ACK_SIG_STRENGTH 0x001fe000
409#define AR5K_DESC_TX_STATUS1_ACK_SIG_STRENGTH_S 13
410#define AR5K_DESC_TX_STATUS1_FINAL_TS_INDEX 0x00600000
411#define AR5K_DESC_TX_STATUS1_FINAL_TS_INDEX_S 21
412#define AR5K_DESC_TX_STATUS1_COMP_SUCCESS 0x00800000
413#define AR5K_DESC_TX_STATUS1_XMIT_ANTENNA 0x01000000
414} __packed;
415
416
417/*
418 * AR5K REGISTER ACCESS
419 */
420
421/*Swap RX/TX Descriptor for big endian archs*/
422#if defined(__BIG_ENDIAN)
423#define AR5K_INIT_CFG ( \
424 AR5K_CFG_SWTD | AR5K_CFG_SWRD \
425)
426#else
427#define AR5K_INIT_CFG 0x00000000
428#endif
429
430/*#define AR5K_REG_READ(_reg) ath5k_hw_reg_read(ah, _reg)
431
432#define AR5K_REG_WRITE(_reg, _val) ath5k_hw_reg_write(ah, _val, _reg)*/
433
434#define AR5K_REG_SM(_val, _flags) \
435 (((_val) << _flags##_S) & (_flags))
436
437#define AR5K_REG_MS(_val, _flags) \
438 (((_val) & (_flags)) >> _flags##_S)
439
440/* Some registers can hold multiple values of interest. For this
441 * reason when we want to write to these registers we must first
442 * retrieve the values which we do not want to clear (lets call this
443 * old_data) and then set the register with this and our new_value:
444 * ( old_data | new_value) */
445#define AR5K_REG_WRITE_BITS(ah, _reg, _flags, _val) \
446 ath5k_hw_reg_write(ah, (ath5k_hw_reg_read(ah, _reg) & ~(_flags)) | \
447 (((_val) << _flags##_S) & (_flags)), _reg)
448
449#define AR5K_REG_MASKED_BITS(ah, _reg, _flags, _mask) \
450 ath5k_hw_reg_write(ah, (ath5k_hw_reg_read(ah, _reg) & \
451 (_mask)) | (_flags), _reg)
452
453#define AR5K_REG_ENABLE_BITS(ah, _reg, _flags) \
454 ath5k_hw_reg_write(ah, ath5k_hw_reg_read(ah, _reg) | (_flags), _reg)
455
456#define AR5K_REG_DISABLE_BITS(ah, _reg, _flags) \
457 ath5k_hw_reg_write(ah, ath5k_hw_reg_read(ah, _reg) & ~(_flags), _reg)
458
459#define AR5K_PHY_WRITE(ah, _reg, _val) \
460 ath5k_hw_reg_write(ah, _val, (ah)->ah_phy + ((_reg) << 2))
461
462#define AR5K_PHY_READ(ah, _reg) \
463 ath5k_hw_reg_read(ah, (ah)->ah_phy + ((_reg) << 2))
464
465#define AR5K_REG_WAIT(_i) do { \
466 if (_i % 64) \
467 udelay(1); \
468} while (0)
469
470#define AR5K_EEPROM_READ(_o, _v) do { \
471 if ((ret = ath5k_hw_eeprom_read(ah, (_o), &(_v))) != 0) \
472 return (ret); \
473} while (0)
474
475#define AR5K_EEPROM_READ_HDR(_o, _v) \
476 AR5K_EEPROM_READ(_o, ah->ah_capabilities.cap_eeprom._v); \
477
478/* Read status of selected queue */
479#define AR5K_REG_READ_Q(ah, _reg, _queue) \
480 (ath5k_hw_reg_read(ah, _reg) & (1 << _queue)) \
481
482#define AR5K_REG_WRITE_Q(ah, _reg, _queue) \
483 ath5k_hw_reg_write(ah, (1 << _queue), _reg)
484
485#define AR5K_Q_ENABLE_BITS(_reg, _queue) do { \
486 _reg |= 1 << _queue; \
487} while (0)
488
489#define AR5K_Q_DISABLE_BITS(_reg, _queue) do { \
490 _reg &= ~(1 << _queue); \
491} while (0)
492
493#define AR5K_LOW_ID(_a)( \
494(_a)[0] | (_a)[1] << 8 | (_a)[2] << 16 | (_a)[3] << 24 \
495)
496
497#define AR5K_HIGH_ID(_a) ((_a)[4] | (_a)[5] << 8)
498
499/*
500 * Initial register values
501 */
502
503/*
504 * Common initial register values
505 */
506#define AR5K_INIT_MODE CHANNEL_B
507
508#define AR5K_INIT_TX_LATENCY 502
509#define AR5K_INIT_USEC 39
510#define AR5K_INIT_USEC_TURBO 79
511#define AR5K_INIT_USEC_32 31
512#define AR5K_INIT_CARR_SENSE_EN 1
513#define AR5K_INIT_PROG_IFS 920
514#define AR5K_INIT_PROG_IFS_TURBO 960
515#define AR5K_INIT_EIFS 3440
516#define AR5K_INIT_EIFS_TURBO 6880
517#define AR5K_INIT_SLOT_TIME 396
518#define AR5K_INIT_SLOT_TIME_TURBO 480
519#define AR5K_INIT_ACK_CTS_TIMEOUT 1024
520#define AR5K_INIT_ACK_CTS_TIMEOUT_TURBO 0x08000800
521#define AR5K_INIT_SIFS 560
522#define AR5K_INIT_SIFS_TURBO 480
523#define AR5K_INIT_SH_RETRY 10
524#define AR5K_INIT_LG_RETRY AR5K_INIT_SH_RETRY
525#define AR5K_INIT_SSH_RETRY 32
526#define AR5K_INIT_SLG_RETRY AR5K_INIT_SSH_RETRY
527#define AR5K_INIT_TX_RETRY 10
528#define AR5K_INIT_TOPS 8
529#define AR5K_INIT_RXNOFRM 8
530#define AR5K_INIT_RPGTO 0
531#define AR5K_INIT_TXNOFRM 0
532#define AR5K_INIT_BEACON_PERIOD 65535
533#define AR5K_INIT_TIM_OFFSET 0
534#define AR5K_INIT_BEACON_EN 0
535#define AR5K_INIT_RESET_TSF 0
536
537#define AR5K_INIT_TRANSMIT_LATENCY ( \
538 (AR5K_INIT_TX_LATENCY << 14) | (AR5K_INIT_USEC_32 << 7) | \
539 (AR5K_INIT_USEC) \
540)
541#define AR5K_INIT_TRANSMIT_LATENCY_TURBO ( \
542 (AR5K_INIT_TX_LATENCY << 14) | (AR5K_INIT_USEC_32 << 7) | \
543 (AR5K_INIT_USEC_TURBO) \
544)
545#define AR5K_INIT_PROTO_TIME_CNTRL ( \
546 (AR5K_INIT_CARR_SENSE_EN << 26) | (AR5K_INIT_EIFS << 12) | \
547 (AR5K_INIT_PROG_IFS) \
548)
549#define AR5K_INIT_PROTO_TIME_CNTRL_TURBO ( \
550 (AR5K_INIT_CARR_SENSE_EN << 26) | (AR5K_INIT_EIFS_TURBO << 12) | \
551 (AR5K_INIT_PROG_IFS_TURBO) \
552)
553#define AR5K_INIT_BEACON_CONTROL ( \
554 (AR5K_INIT_RESET_TSF << 24) | (AR5K_INIT_BEACON_EN << 23) | \
555 (AR5K_INIT_TIM_OFFSET << 16) | (AR5K_INIT_BEACON_PERIOD) \
556)
557
558/*
559 * Non-common initial register values which have to be loaded into the
560 * card at boot time and after each reset.
561 */
562
563/* Register dumps are done per operation mode */
564#define AR5K_INI_RFGAIN_5GHZ 0
565#define AR5K_INI_RFGAIN_2GHZ 1
566
567#define AR5K_INI_VAL_11A 0
568#define AR5K_INI_VAL_11A_TURBO 1
569#define AR5K_INI_VAL_11B 2
570#define AR5K_INI_VAL_11G 3
571#define AR5K_INI_VAL_11G_TURBO 4
572#define AR5K_INI_VAL_XR 0
573#define AR5K_INI_VAL_MAX 5
574
575#define AR5K_RF5111_INI_RF_MAX_BANKS AR5K_MAX_RF_BANKS
576#define AR5K_RF5112_INI_RF_MAX_BANKS AR5K_MAX_RF_BANKS
577
578static inline u32 ath5k_hw_bitswap(u32 val, unsigned int bits)
579{
580 u32 retval = 0, bit, i;
581
582 for (i = 0; i < bits; i++) {
583 bit = (val >> i) & 1;
584 retval = (retval << 1) | bit;
585 }
586
587 return retval;
588}