blob: 410f99a6d61635f10be16643c7053a433cc11df4 [file] [log] [blame]
Jiri Slabyfa1c1142007-08-12 17:33:16 +02001/*
Nick Kossifidisc6e387a2008-08-29 22:45:39 +03002 * Copyright (c) 2006-2008 Nick Kossifidis <mickflemm@gmail.com>
3 * Copyright (c) 2004-2008 Reyk Floeter <reyk@openbsd.org>
4 * Copyright (c) 2007-2008 Michael Taylor <mike.taylor@apprion.com>
Jiri Slabyfa1c1142007-08-12 17:33:16 +02005 *
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 *
18 */
19
20/*
21 * Register values for Atheros 5210/5211/5212 cards from OpenBSD's ar5k
22 * maintained by Reyk Floeter
23 *
24 * I tried to document those registers by looking at ar5k code, some
25 * 802.11 (802.11e mostly) papers and by reading various public available
26 * Atheros presentations and papers like these:
27 *
28 * 5210 - http://nova.stanford.edu/~bbaas/ps/isscc2002_slides.pdf
29 * http://www.it.iitb.ac.in/~janak/wifire/01222734.pdf
30 *
31 * 5211 - http://www.hotchips.org/archives/hc14/3_Tue/16_mcfarland.pdf
32 */
33
34
35
36/*====MAC DMA REGISTERS====*/
37
38/*
39 * AR5210-Specific TXDP registers
40 * 5210 has only 2 transmit queues so no DCU/QCU, just
41 * 2 transmit descriptor pointers...
42 */
43#define AR5K_NOQCU_TXDP0 0x0000 /* Queue 0 - data */
44#define AR5K_NOQCU_TXDP1 0x0004 /* Queue 1 - beacons */
45
46/*
47 * Mac Control Register
48 */
49#define AR5K_CR 0x0008 /* Register Address */
50#define AR5K_CR_TXE0 0x00000001 /* TX Enable for queue 0 on 5210 */
51#define AR5K_CR_TXE1 0x00000002 /* TX Enable for queue 1 on 5210 */
52#define AR5K_CR_RXE 0x00000004 /* RX Enable */
53#define AR5K_CR_TXD0 0x00000008 /* TX Disable for queue 0 on 5210 */
54#define AR5K_CR_TXD1 0x00000010 /* TX Disable for queue 1 on 5210 */
55#define AR5K_CR_RXD 0x00000020 /* RX Disable */
Nick Kossifidis0bacdf32008-07-30 13:18:59 +030056#define AR5K_CR_SWI 0x00000040 /* Software Interrupt */
Jiri Slabyfa1c1142007-08-12 17:33:16 +020057
58/*
59 * RX Descriptor Pointer register
60 */
61#define AR5K_RXDP 0x000c
62
63/*
64 * Configuration and status register
65 */
66#define AR5K_CFG 0x0014 /* Register Address */
67#define AR5K_CFG_SWTD 0x00000001 /* Byte-swap TX descriptor (for big endian archs) */
Nick Kossifidis0bacdf32008-07-30 13:18:59 +030068#define AR5K_CFG_SWTB 0x00000002 /* Byte-swap TX buffer */
Jiri Slabyfa1c1142007-08-12 17:33:16 +020069#define AR5K_CFG_SWRD 0x00000004 /* Byte-swap RX descriptor */
Nick Kossifidis0bacdf32008-07-30 13:18:59 +030070#define AR5K_CFG_SWRB 0x00000008 /* Byte-swap RX buffer */
71#define AR5K_CFG_SWRG 0x00000010 /* Byte-swap Register access */
72#define AR5K_CFG_ADHOC 0x00000020 /* AP/Adhoc indication [5211+] */
Jiri Slabyfa1c1142007-08-12 17:33:16 +020073#define AR5K_CFG_PHY_OK 0x00000100 /* [5211+] */
74#define AR5K_CFG_EEBS 0x00000200 /* EEPROM is busy */
Nick Kossifidis0bacdf32008-07-30 13:18:59 +030075#define AR5K_CFG_CLKGD 0x00000400 /* Clock gated (Disable dynamic clock) */
Jiri Slabyfa1c1142007-08-12 17:33:16 +020076#define AR5K_CFG_TXCNT 0x00007800 /* Tx frame count (?) [5210] */
77#define AR5K_CFG_TXCNT_S 11
78#define AR5K_CFG_TXFSTAT 0x00008000 /* Tx frame status (?) [5210] */
79#define AR5K_CFG_TXFSTRT 0x00010000 /* [5210] */
Nick Kossifidis0bacdf32008-07-30 13:18:59 +030080#define AR5K_CFG_PCI_THRES 0x00060000 /* PCI Master req q threshold [5211+] */
Jiri Slabyfa1c1142007-08-12 17:33:16 +020081#define AR5K_CFG_PCI_THRES_S 17
82
83/*
84 * Interrupt enable register
85 */
86#define AR5K_IER 0x0024 /* Register Address */
87#define AR5K_IER_DISABLE 0x00000000 /* Disable card interrupts */
88#define AR5K_IER_ENABLE 0x00000001 /* Enable card interrupts */
89
90
91/*
92 * 0x0028 is Beacon Control Register on 5210
93 * and first RTS duration register on 5211
94 */
95
96/*
97 * Beacon control register [5210]
98 */
99#define AR5K_BCR 0x0028 /* Register Address */
100#define AR5K_BCR_AP 0x00000000 /* AP mode */
101#define AR5K_BCR_ADHOC 0x00000001 /* Ad-Hoc mode */
102#define AR5K_BCR_BDMAE 0x00000002 /* DMA enable */
103#define AR5K_BCR_TQ1FV 0x00000004 /* Use Queue1 for CAB traffic */
104#define AR5K_BCR_TQ1V 0x00000008 /* Use Queue1 for Beacon traffic */
105#define AR5K_BCR_BCGET 0x00000010
106
107/*
108 * First RTS duration register [5211]
109 */
110#define AR5K_RTSD0 0x0028 /* Register Address */
111#define AR5K_RTSD0_6 0x000000ff /* 6Mb RTS duration mask (?) */
112#define AR5K_RTSD0_6_S 0 /* 6Mb RTS duration shift (?) */
113#define AR5K_RTSD0_9 0x0000ff00 /* 9Mb*/
114#define AR5K_RTSD0_9_S 8
115#define AR5K_RTSD0_12 0x00ff0000 /* 12Mb*/
116#define AR5K_RTSD0_12_S 16
117#define AR5K_RTSD0_18 0xff000000 /* 16Mb*/
118#define AR5K_RTSD0_18_S 24
119
120
121/*
122 * 0x002c is Beacon Status Register on 5210
123 * and second RTS duration register on 5211
124 */
125
126/*
127 * Beacon status register [5210]
128 *
129 * As i can see in ar5k_ar5210_tx_start Reyk uses some of the values of BCR
130 * for this register, so i guess TQ1V,TQ1FV and BDMAE have the same meaning
131 * here and SNP/SNAP means "snapshot" (so this register gets synced with BCR).
132 * So SNAPPEDBCRVALID sould also stand for "snapped BCR -values- valid", so i
133 * renamed it to SNAPSHOTSVALID to make more sense. I realy have no idea what
134 * else can it be. I also renamed SNPBCMD to SNPADHOC to match BCR.
135 */
136#define AR5K_BSR 0x002c /* Register Address */
137#define AR5K_BSR_BDLYSW 0x00000001 /* SW Beacon delay (?) */
138#define AR5K_BSR_BDLYDMA 0x00000002 /* DMA Beacon delay (?) */
139#define AR5K_BSR_TXQ1F 0x00000004 /* Beacon queue (1) finished */
140#define AR5K_BSR_ATIMDLY 0x00000008 /* ATIM delay (?) */
141#define AR5K_BSR_SNPADHOC 0x00000100 /* Ad-hoc mode set (?) */
142#define AR5K_BSR_SNPBDMAE 0x00000200 /* Beacon DMA enabled (?) */
143#define AR5K_BSR_SNPTQ1FV 0x00000400 /* Queue1 is used for CAB traffic (?) */
144#define AR5K_BSR_SNPTQ1V 0x00000800 /* Queue1 is used for Beacon traffic (?) */
145#define AR5K_BSR_SNAPSHOTSVALID 0x00001000 /* BCR snapshots are valid (?) */
146#define AR5K_BSR_SWBA_CNT 0x00ff0000
147
148/*
149 * Second RTS duration register [5211]
150 */
151#define AR5K_RTSD1 0x002c /* Register Address */
152#define AR5K_RTSD1_24 0x000000ff /* 24Mb */
153#define AR5K_RTSD1_24_S 0
154#define AR5K_RTSD1_36 0x0000ff00 /* 36Mb */
155#define AR5K_RTSD1_36_S 8
156#define AR5K_RTSD1_48 0x00ff0000 /* 48Mb */
157#define AR5K_RTSD1_48_S 16
158#define AR5K_RTSD1_54 0xff000000 /* 54Mb */
159#define AR5K_RTSD1_54_S 24
160
161
162/*
163 * Transmit configuration register
164 */
Nick Kossifidis0bacdf32008-07-30 13:18:59 +0300165#define AR5K_TXCFG 0x0030 /* Register Address */
166#define AR5K_TXCFG_SDMAMR 0x00000007 /* DMA size (read) */
167#define AR5K_TXCFG_SDMAMR_S 0
168#define AR5K_TXCFG_B_MODE 0x00000008 /* Set b mode for 5111 (enable 2111) */
169#define AR5K_TXCFG_TXFSTP 0x00000008 /* TX DMA full Stop [5210] */
170#define AR5K_TXCFG_TXFULL 0x000003f0 /* TX Triger level mask */
171#define AR5K_TXCFG_TXFULL_S 4
172#define AR5K_TXCFG_TXFULL_0B 0x00000000
173#define AR5K_TXCFG_TXFULL_64B 0x00000010
174#define AR5K_TXCFG_TXFULL_128B 0x00000020
175#define AR5K_TXCFG_TXFULL_192B 0x00000030
176#define AR5K_TXCFG_TXFULL_256B 0x00000040
177#define AR5K_TXCFG_TXCONT_EN 0x00000080
178#define AR5K_TXCFG_DMASIZE 0x00000100 /* Flag for passing DMA size [5210] */
179#define AR5K_TXCFG_JUMBO_DESC_EN 0x00000400 /* Enable jumbo tx descriptors [5211+] */
180#define AR5K_TXCFG_ADHOC_BCN_ATIM 0x00000800 /* Adhoc Beacon ATIM Policy */
181#define AR5K_TXCFG_ATIM_WINDOW_DEF_DIS 0x00001000 /* Disable ATIM window defer [5211+] */
182#define AR5K_TXCFG_RTSRND 0x00001000 /* [5211+] */
183#define AR5K_TXCFG_FRMPAD_DIS 0x00002000 /* [5211+] */
184#define AR5K_TXCFG_RDY_CBR_DIS 0x00004000 /* Ready time CBR disable [5211+] */
185#define AR5K_TXCFG_JUMBO_FRM_MODE 0x00008000 /* Jumbo frame mode [5211+] */
186#define AR5K_TXCFG_DCU_CACHING_DIS 0x00010000 /* Disable DCU caching */
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200187
188/*
189 * Receive configuration register
190 */
191#define AR5K_RXCFG 0x0034 /* Register Address */
Nick Kossifidis0bacdf32008-07-30 13:18:59 +0300192#define AR5K_RXCFG_SDMAMW 0x00000007 /* DMA size (write) */
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200193#define AR5K_RXCFG_SDMAMW_S 0
Nick Kossifidis0bacdf32008-07-30 13:18:59 +0300194#define AR5K_RXCFG_ZLFDMA 0x00000008 /* Enable Zero-length frame DMA */
195#define AR5K_RXCFG_DEF_ANTENNA 0x00000010 /* Default antenna (?) */
196#define AR5K_RXCFG_JUMBO_RXE 0x00000020 /* Enable jumbo rx descriptors [5211+] */
197#define AR5K_RXCFG_JUMBO_WRAP 0x00000040 /* Wrap jumbo frames [5211+] */
198#define AR5K_RXCFG_SLE_ENTRY 0x00000080 /* Sleep entry policy */
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200199
200/*
201 * Receive jumbo descriptor last address register
202 * Only found in 5211 (?)
203 */
204#define AR5K_RXJLA 0x0038
205
206/*
207 * MIB control register
208 */
209#define AR5K_MIBC 0x0040 /* Register Address */
Nick Kossifidis0bacdf32008-07-30 13:18:59 +0300210#define AR5K_MIBC_COW 0x00000001 /* Warn test indicator */
211#define AR5K_MIBC_FMC 0x00000002 /* Freeze MIB Counters */
212#define AR5K_MIBC_CMC 0x00000004 /* Clean MIB Counters */
213#define AR5K_MIBC_MCS 0x00000008 /* MIB counter strobe */
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200214
215/*
216 * Timeout prescale register
217 */
218#define AR5K_TOPS 0x0044
Nick Kossifidis0bacdf32008-07-30 13:18:59 +0300219#define AR5K_TOPS_M 0x0000ffff
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200220
221/*
222 * Receive timeout register (no frame received)
223 */
224#define AR5K_RXNOFRM 0x0048
Nick Kossifidis0bacdf32008-07-30 13:18:59 +0300225#define AR5K_RXNOFRM_M 0x000003ff
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200226
227/*
228 * Transmit timeout register (no frame sent)
229 */
230#define AR5K_TXNOFRM 0x004c
Nick Kossifidis0bacdf32008-07-30 13:18:59 +0300231#define AR5K_TXNOFRM_M 0x000003ff
232#define AR5K_TXNOFRM_QCU 0x000ffc00
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200233
234/*
235 * Receive frame gap timeout register
236 */
237#define AR5K_RPGTO 0x0050
Nick Kossifidis0bacdf32008-07-30 13:18:59 +0300238#define AR5K_RPGTO_M 0x000003ff
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200239
240/*
241 * Receive frame count limit register
242 */
243#define AR5K_RFCNT 0x0054
244#define AR5K_RFCNT_M 0x0000001f /* [5211+] (?) */
245#define AR5K_RFCNT_RFCL 0x0000000f /* [5210] */
246
247/*
248 * Misc settings register
Nick Kossifidis0bacdf32008-07-30 13:18:59 +0300249 * (reserved0-3)
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200250 */
251#define AR5K_MISC 0x0058 /* Register Address */
252#define AR5K_MISC_DMA_OBS_M 0x000001e0
253#define AR5K_MISC_DMA_OBS_S 5
254#define AR5K_MISC_MISC_OBS_M 0x00000e00
255#define AR5K_MISC_MISC_OBS_S 9
256#define AR5K_MISC_MAC_OBS_LSB_M 0x00007000
257#define AR5K_MISC_MAC_OBS_LSB_S 12
258#define AR5K_MISC_MAC_OBS_MSB_M 0x00038000
259#define AR5K_MISC_MAC_OBS_MSB_S 15
260#define AR5K_MISC_LED_DECAY 0x001c0000 /* [5210] */
261#define AR5K_MISC_LED_BLINK 0x00e00000 /* [5210] */
262
263/*
264 * QCU/DCU clock gating register (5311)
Nick Kossifidis0bacdf32008-07-30 13:18:59 +0300265 * (reserved4-5)
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200266 */
267#define AR5K_QCUDCU_CLKGT 0x005c /* Register Address (?) */
268#define AR5K_QCUDCU_CLKGT_QCU 0x0000ffff /* Mask for QCU clock */
269#define AR5K_QCUDCU_CLKGT_DCU 0x07ff0000 /* Mask for DCU clock */
270
271/*
272 * Interrupt Status Registers
273 *
274 * For 5210 there is only one status register but for
275 * 5211/5212 we have one primary and 4 secondary registers.
276 * So we have AR5K_ISR for 5210 and AR5K_PISR /SISRx for 5211/5212.
277 * Most of these bits are common for all chipsets.
278 */
279#define AR5K_ISR 0x001c /* Register Address [5210] */
280#define AR5K_PISR 0x0080 /* Register Address [5211+] */
281#define AR5K_ISR_RXOK 0x00000001 /* Frame successfuly recieved */
282#define AR5K_ISR_RXDESC 0x00000002 /* RX descriptor request */
283#define AR5K_ISR_RXERR 0x00000004 /* Receive error */
284#define AR5K_ISR_RXNOFRM 0x00000008 /* No frame received (receive timeout) */
285#define AR5K_ISR_RXEOL 0x00000010 /* Empty RX descriptor */
286#define AR5K_ISR_RXORN 0x00000020 /* Receive FIFO overrun */
287#define AR5K_ISR_TXOK 0x00000040 /* Frame successfuly transmited */
288#define AR5K_ISR_TXDESC 0x00000080 /* TX descriptor request */
289#define AR5K_ISR_TXERR 0x00000100 /* Transmit error */
290#define AR5K_ISR_TXNOFRM 0x00000200 /* No frame transmited (transmit timeout) */
291#define AR5K_ISR_TXEOL 0x00000400 /* Empty TX descriptor */
292#define AR5K_ISR_TXURN 0x00000800 /* Transmit FIFO underrun */
293#define AR5K_ISR_MIB 0x00001000 /* Update MIB counters */
Nick Kossifidis0bacdf32008-07-30 13:18:59 +0300294#define AR5K_ISR_SWI 0x00002000 /* Software interrupt */
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200295#define AR5K_ISR_RXPHY 0x00004000 /* PHY error */
Nick Kossifidis0bacdf32008-07-30 13:18:59 +0300296#define AR5K_ISR_RXKCM 0x00008000 /* RX Key cache miss */
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200297#define AR5K_ISR_SWBA 0x00010000 /* Software beacon alert */
298#define AR5K_ISR_BRSSI 0x00020000
299#define AR5K_ISR_BMISS 0x00040000 /* Beacon missed */
300#define AR5K_ISR_HIUERR 0x00080000 /* Host Interface Unit error [5211+] */
301#define AR5K_ISR_BNR 0x00100000 /* Beacon not ready [5211+] */
Nick Kossifidis0bacdf32008-07-30 13:18:59 +0300302#define AR5K_ISR_MCABT 0x00100000 /* Master Cycle Abort [5210] */
303#define AR5K_ISR_RXCHIRP 0x00200000 /* CHIRP Received [5212+] */
304#define AR5K_ISR_SSERR 0x00200000 /* Signaled System Error [5210] */
305#define AR5K_ISR_DPERR 0x00400000 /* Det par Error (?) [5210] */
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200306#define AR5K_ISR_TIM 0x00800000 /* [5210] */
307#define AR5K_ISR_BCNMISC 0x00800000 /* [5212+] */
308#define AR5K_ISR_GPIO 0x01000000 /* GPIO (rf kill)*/
309#define AR5K_ISR_QCBRORN 0x02000000 /* CBR overrun (?) [5211+] */
310#define AR5K_ISR_QCBRURN 0x04000000 /* CBR underrun (?) [5211+] */
311#define AR5K_ISR_QTRIG 0x08000000 /* [5211+] */
312
313/*
314 * Secondary status registers [5211+] (0 - 4)
315 *
316 * I guess from the names that these give the status for each
317 * queue, that's why only masks are defined here, haven't got
318 * any info about them (couldn't find them anywhere in ar5k code).
319 */
320#define AR5K_SISR0 0x0084 /* Register Address [5211+] */
321#define AR5K_SISR0_QCU_TXOK 0x000003ff /* Mask for QCU_TXOK */
322#define AR5K_SISR0_QCU_TXDESC 0x03ff0000 /* Mask for QCU_TXDESC */
323
324#define AR5K_SISR1 0x0088 /* Register Address [5211+] */
325#define AR5K_SISR1_QCU_TXERR 0x000003ff /* Mask for QCU_TXERR */
326#define AR5K_SISR1_QCU_TXEOL 0x03ff0000 /* Mask for QCU_TXEOL */
327
328#define AR5K_SISR2 0x008c /* Register Address [5211+] */
329#define AR5K_SISR2_QCU_TXURN 0x000003ff /* Mask for QCU_TXURN */
Nick Kossifidis0bacdf32008-07-30 13:18:59 +0300330#define AR5K_SISR2_MCABT 0x00100000 /* Master Cycle Abort */
331#define AR5K_SISR2_SSERR 0x00200000 /* Signaled System Error */
332#define AR5K_SISR2_DPERR 0x00400000 /* Det par Error (?) */
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200333#define AR5K_SISR2_TIM 0x01000000 /* [5212+] */
334#define AR5K_SISR2_CAB_END 0x02000000 /* [5212+] */
Nick Kossifidis0bacdf32008-07-30 13:18:59 +0300335#define AR5K_SISR2_DTIM_SYNC 0x04000000 /* DTIM sync lost [5212+] */
336#define AR5K_SISR2_BCN_TIMEOUT 0x08000000 /* Beacon Timeout [5212+] */
337#define AR5K_SISR2_CAB_TIMEOUT 0x10000000 /* CAB Timeout [5212+] */
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200338#define AR5K_SISR2_DTIM 0x20000000 /* [5212+] */
339
340#define AR5K_SISR3 0x0090 /* Register Address [5211+] */
341#define AR5K_SISR3_QCBRORN 0x000003ff /* Mask for QCBRORN */
342#define AR5K_SISR3_QCBRURN 0x03ff0000 /* Mask for QCBRURN */
343
344#define AR5K_SISR4 0x0094 /* Register Address [5211+] */
345#define AR5K_SISR4_QTRIG 0x000003ff /* Mask for QTRIG */
346
347/*
348 * Shadow read-and-clear interrupt status registers [5211+]
349 */
350#define AR5K_RAC_PISR 0x00c0 /* Read and clear PISR */
351#define AR5K_RAC_SISR0 0x00c4 /* Read and clear SISR0 */
352#define AR5K_RAC_SISR1 0x00c8 /* Read and clear SISR1 */
353#define AR5K_RAC_SISR2 0x00cc /* Read and clear SISR2 */
354#define AR5K_RAC_SISR3 0x00d0 /* Read and clear SISR3 */
355#define AR5K_RAC_SISR4 0x00d4 /* Read and clear SISR4 */
356
357/*
358 * Interrupt Mask Registers
359 *
360 * As whith ISRs 5210 has one IMR (AR5K_IMR) and 5211/5212 has one primary
361 * (AR5K_PIMR) and 4 secondary IMRs (AR5K_SIMRx). Note that ISR/IMR flags match.
362 */
363#define AR5K_IMR 0x0020 /* Register Address [5210] */
364#define AR5K_PIMR 0x00a0 /* Register Address [5211+] */
365#define AR5K_IMR_RXOK 0x00000001 /* Frame successfuly recieved*/
366#define AR5K_IMR_RXDESC 0x00000002 /* RX descriptor request*/
367#define AR5K_IMR_RXERR 0x00000004 /* Receive error*/
368#define AR5K_IMR_RXNOFRM 0x00000008 /* No frame received (receive timeout)*/
369#define AR5K_IMR_RXEOL 0x00000010 /* Empty RX descriptor*/
370#define AR5K_IMR_RXORN 0x00000020 /* Receive FIFO overrun*/
371#define AR5K_IMR_TXOK 0x00000040 /* Frame successfuly transmited*/
372#define AR5K_IMR_TXDESC 0x00000080 /* TX descriptor request*/
373#define AR5K_IMR_TXERR 0x00000100 /* Transmit error*/
374#define AR5K_IMR_TXNOFRM 0x00000200 /* No frame transmited (transmit timeout)*/
375#define AR5K_IMR_TXEOL 0x00000400 /* Empty TX descriptor*/
376#define AR5K_IMR_TXURN 0x00000800 /* Transmit FIFO underrun*/
377#define AR5K_IMR_MIB 0x00001000 /* Update MIB counters*/
Nick Kossifidis0bacdf32008-07-30 13:18:59 +0300378#define AR5K_IMR_SWI 0x00002000 /* Software interrupt */
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200379#define AR5K_IMR_RXPHY 0x00004000 /* PHY error*/
Nick Kossifidis0bacdf32008-07-30 13:18:59 +0300380#define AR5K_IMR_RXKCM 0x00008000 /* RX Key cache miss */
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200381#define AR5K_IMR_SWBA 0x00010000 /* Software beacon alert*/
382#define AR5K_IMR_BRSSI 0x00020000
383#define AR5K_IMR_BMISS 0x00040000 /* Beacon missed*/
384#define AR5K_IMR_HIUERR 0x00080000 /* Host Interface Unit error [5211+] */
385#define AR5K_IMR_BNR 0x00100000 /* Beacon not ready [5211+] */
Nick Kossifidis0bacdf32008-07-30 13:18:59 +0300386#define AR5K_IMR_MCABT 0x00100000 /* Master Cycle Abort [5210] */
387#define AR5K_IMR_RXCHIRP 0x00200000 /* CHIRP Received [5212+]*/
388#define AR5K_IMR_SSERR 0x00200000 /* Signaled System Error [5210] */
389#define AR5K_IMR_DPERR 0x00400000 /* Det par Error (?) [5210] */
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200390#define AR5K_IMR_TIM 0x00800000 /* [5211+] */
391#define AR5K_IMR_BCNMISC 0x00800000 /* [5212+] */
392#define AR5K_IMR_GPIO 0x01000000 /* GPIO (rf kill)*/
393#define AR5K_IMR_QCBRORN 0x02000000 /* CBR overrun (?) [5211+] */
394#define AR5K_IMR_QCBRURN 0x04000000 /* CBR underrun (?) [5211+] */
395#define AR5K_IMR_QTRIG 0x08000000 /* [5211+] */
396
397/*
398 * Secondary interrupt mask registers [5211+] (0 - 4)
399 */
400#define AR5K_SIMR0 0x00a4 /* Register Address [5211+] */
401#define AR5K_SIMR0_QCU_TXOK 0x000003ff /* Mask for QCU_TXOK */
402#define AR5K_SIMR0_QCU_TXOK_S 0
403#define AR5K_SIMR0_QCU_TXDESC 0x03ff0000 /* Mask for QCU_TXDESC */
404#define AR5K_SIMR0_QCU_TXDESC_S 16
405
406#define AR5K_SIMR1 0x00a8 /* Register Address [5211+] */
407#define AR5K_SIMR1_QCU_TXERR 0x000003ff /* Mask for QCU_TXERR */
408#define AR5K_SIMR1_QCU_TXERR_S 0
409#define AR5K_SIMR1_QCU_TXEOL 0x03ff0000 /* Mask for QCU_TXEOL */
410#define AR5K_SIMR1_QCU_TXEOL_S 16
411
412#define AR5K_SIMR2 0x00ac /* Register Address [5211+] */
413#define AR5K_SIMR2_QCU_TXURN 0x000003ff /* Mask for QCU_TXURN */
414#define AR5K_SIMR2_QCU_TXURN_S 0
Nick Kossifidis0bacdf32008-07-30 13:18:59 +0300415#define AR5K_SIMR2_MCABT 0x00100000 /* Master Cycle Abort */
416#define AR5K_SIMR2_SSERR 0x00200000 /* Signaled System Error */
417#define AR5K_SIMR2_DPERR 0x00400000 /* Det par Error (?) */
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200418#define AR5K_SIMR2_TIM 0x01000000 /* [5212+] */
419#define AR5K_SIMR2_CAB_END 0x02000000 /* [5212+] */
Nick Kossifidis0bacdf32008-07-30 13:18:59 +0300420#define AR5K_SIMR2_DTIM_SYNC 0x04000000 /* DTIM Sync lost [5212+] */
421#define AR5K_SIMR2_BCN_TIMEOUT 0x08000000 /* Beacon Timeout [5212+] */
422#define AR5K_SIMR2_CAB_TIMEOUT 0x10000000 /* CAB Timeout [5212+] */
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200423#define AR5K_SIMR2_DTIM 0x20000000 /* [5212+] */
424
425#define AR5K_SIMR3 0x00b0 /* Register Address [5211+] */
426#define AR5K_SIMR3_QCBRORN 0x000003ff /* Mask for QCBRORN */
427#define AR5K_SIMR3_QCBRORN_S 0
428#define AR5K_SIMR3_QCBRURN 0x03ff0000 /* Mask for QCBRURN */
429#define AR5K_SIMR3_QCBRURN_S 16
430
431#define AR5K_SIMR4 0x00b4 /* Register Address [5211+] */
432#define AR5K_SIMR4_QTRIG 0x000003ff /* Mask for QTRIG */
433#define AR5K_SIMR4_QTRIG_S 0
434
Nick Kossifidis0bacdf32008-07-30 13:18:59 +0300435/*
436 * DMA Debug registers 0-7
437 * 0xe0 - 0xfc
438 */
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200439
440/*
441 * Decompression mask registers [5212+]
442 */
Nick Kossifidis0bacdf32008-07-30 13:18:59 +0300443#define AR5K_DCM_ADDR 0x0400 /*Decompression mask address (index) */
444#define AR5K_DCM_DATA 0x0404 /*Decompression mask data */
445
446/*
447 * Wake On Wireless pattern control register [5212+]
448 */
449#define AR5K_WOW_PCFG 0x0410 /* Register Address */
450#define AR5K_WOW_PCFG_PAT_MATCH_EN 0x00000001 /* Pattern match enable */
451#define AR5K_WOW_PCFG_LONG_FRAME_POL 0x00000002 /* Long frame policy */
452#define AR5K_WOW_PCFG_WOBMISS 0x00000004 /* Wake on bea(con) miss (?) */
453#define AR5K_WOW_PCFG_PAT_0_EN 0x00000100 /* Enable pattern 0 */
454#define AR5K_WOW_PCFG_PAT_1_EN 0x00000200 /* Enable pattern 1 */
455#define AR5K_WOW_PCFG_PAT_2_EN 0x00000400 /* Enable pattern 2 */
456#define AR5K_WOW_PCFG_PAT_3_EN 0x00000800 /* Enable pattern 3 */
457#define AR5K_WOW_PCFG_PAT_4_EN 0x00001000 /* Enable pattern 4 */
458#define AR5K_WOW_PCFG_PAT_5_EN 0x00002000 /* Enable pattern 5 */
459
460/*
461 * Wake On Wireless pattern index register (?) [5212+]
462 */
463#define AR5K_WOW_PAT_IDX 0x0414
464
465/*
466 * Wake On Wireless pattern data register [5212+]
467 */
468#define AR5K_WOW_PAT_DATA 0x0418 /* Register Address */
469#define AR5K_WOW_PAT_DATA_0_3_V 0x00000001 /* Pattern 0, 3 value */
470#define AR5K_WOW_PAT_DATA_1_4_V 0x00000100 /* Pattern 1, 4 value */
471#define AR5K_WOW_PAT_DATA_2_5_V 0x00010000 /* Pattern 2, 5 value */
472#define AR5K_WOW_PAT_DATA_0_3_M 0x01000000 /* Pattern 0, 3 mask */
473#define AR5K_WOW_PAT_DATA_1_4_M 0x04000000 /* Pattern 1, 4 mask */
474#define AR5K_WOW_PAT_DATA_2_5_M 0x10000000 /* Pattern 2, 5 mask */
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200475
476/*
477 * Decompression configuration registers [5212+]
478 */
Nick Kossifidis0bacdf32008-07-30 13:18:59 +0300479#define AR5K_DCCFG 0x0420 /* Register Address */
480#define AR5K_DCCFG_GLOBAL_EN 0x00000001 /* Enable decompression on all queues */
481#define AR5K_DCCFG_BYPASS_EN 0x00000002 /* Bypass decompression */
482#define AR5K_DCCFG_BCAST_EN 0x00000004 /* Enable decompression for bcast frames */
483#define AR5K_DCCFG_MCAST_EN 0x00000008 /* Enable decompression for mcast frames */
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200484
485/*
486 * Compression configuration registers [5212+]
487 */
Nick Kossifidis0bacdf32008-07-30 13:18:59 +0300488#define AR5K_CCFG 0x0600 /* Register Address */
489#define AR5K_CCFG_WINDOW_SIZE 0x00000007 /* Compression window size */
490#define AR5K_CCFG_CPC_EN 0x00000008 /* Enable performance counters */
491
492#define AR5K_CCFG_CCU 0x0604 /* Register Address */
493#define AR5K_CCFG_CCU_CUP_EN 0x00000001 /* CCU Catchup enable */
494#define AR5K_CCFG_CCU_CREDIT 0x00000002 /* CCU Credit (field) */
495#define AR5K_CCFG_CCU_CD_THRES 0x00000080 /* CCU Cyc(lic?) debt threshold (field) */
496#define AR5K_CCFG_CCU_CUP_LCNT 0x00010000 /* CCU Catchup lit(?) count */
497#define AR5K_CCFG_CCU_INIT 0x00100200 /* Initial value during reset */
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200498
499/*
500 * Compression performance counter registers [5212+]
501 */
502#define AR5K_CPC0 0x0610 /* Compression performance counter 0 */
503#define AR5K_CPC1 0x0614 /* Compression performance counter 1*/
504#define AR5K_CPC2 0x0618 /* Compression performance counter 2 */
505#define AR5K_CPC3 0x061c /* Compression performance counter 3 */
Nick Kossifidis0bacdf32008-07-30 13:18:59 +0300506#define AR5K_CPCOVF 0x0620 /* Compression performance overflow */
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200507
508
509/*
510 * Queue control unit (QCU) registers [5211+]
511 *
512 * Card has 12 TX Queues but i see that only 0-9 are used (?)
513 * both in binary HAL (see ah.h) and ar5k. Each queue has it's own
514 * TXDP at addresses 0x0800 - 0x082c, a CBR (Constant Bit Rate)
515 * configuration register (0x08c0 - 0x08ec), a ready time configuration
516 * register (0x0900 - 0x092c), a misc configuration register (0x09c0 -
517 * 0x09ec) and a status register (0x0a00 - 0x0a2c). We also have some
518 * global registers, QCU transmit enable/disable and "one shot arm (?)"
519 * set/clear, which contain status for all queues (we shift by 1 for each
520 * queue). To access these registers easily we define some macros here
521 * that are used inside HAL. For more infos check out *_tx_queue functs.
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200522 */
523
524/*
525 * Generic QCU Register access macros
526 */
527#define AR5K_QUEUE_REG(_r, _q) (((_q) << 2) + _r)
528#define AR5K_QCU_GLOBAL_READ(_r, _q) (AR5K_REG_READ(_r) & (1 << _q))
529#define AR5K_QCU_GLOBAL_WRITE(_r, _q) AR5K_REG_WRITE(_r, (1 << _q))
530
531/*
532 * QCU Transmit descriptor pointer registers
533 */
534#define AR5K_QCU_TXDP_BASE 0x0800 /* Register Address - Queue0 TXDP */
535#define AR5K_QUEUE_TXDP(_q) AR5K_QUEUE_REG(AR5K_QCU_TXDP_BASE, _q)
536
537/*
538 * QCU Transmit enable register
539 */
540#define AR5K_QCU_TXE 0x0840
541#define AR5K_ENABLE_QUEUE(_q) AR5K_QCU_GLOBAL_WRITE(AR5K_QCU_TXE, _q)
542#define AR5K_QUEUE_ENABLED(_q) AR5K_QCU_GLOBAL_READ(AR5K_QCU_TXE, _q)
543
544/*
545 * QCU Transmit disable register
546 */
547#define AR5K_QCU_TXD 0x0880
548#define AR5K_DISABLE_QUEUE(_q) AR5K_QCU_GLOBAL_WRITE(AR5K_QCU_TXD, _q)
549#define AR5K_QUEUE_DISABLED(_q) AR5K_QCU_GLOBAL_READ(AR5K_QCU_TXD, _q)
550
551/*
552 * QCU Constant Bit Rate configuration registers
553 */
554#define AR5K_QCU_CBRCFG_BASE 0x08c0 /* Register Address - Queue0 CBRCFG */
555#define AR5K_QCU_CBRCFG_INTVAL 0x00ffffff /* CBR Interval mask */
556#define AR5K_QCU_CBRCFG_INTVAL_S 0
557#define AR5K_QCU_CBRCFG_ORN_THRES 0xff000000 /* CBR overrun threshold mask */
558#define AR5K_QCU_CBRCFG_ORN_THRES_S 24
559#define AR5K_QUEUE_CBRCFG(_q) AR5K_QUEUE_REG(AR5K_QCU_CBRCFG_BASE, _q)
560
561/*
562 * QCU Ready time configuration registers
563 */
564#define AR5K_QCU_RDYTIMECFG_BASE 0x0900 /* Register Address - Queue0 RDYTIMECFG */
565#define AR5K_QCU_RDYTIMECFG_INTVAL 0x00ffffff /* Ready time interval mask */
566#define AR5K_QCU_RDYTIMECFG_INTVAL_S 0
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200567#define AR5K_QCU_RDYTIMECFG_ENABLE 0x01000000 /* Ready time enable mask */
568#define AR5K_QUEUE_RDYTIMECFG(_q) AR5K_QUEUE_REG(AR5K_QCU_RDYTIMECFG_BASE, _q)
569
570/*
571 * QCU one shot arm set registers
572 */
573#define AR5K_QCU_ONESHOTARM_SET 0x0940 /* Register Address -QCU "one shot arm set (?)" */
574#define AR5K_QCU_ONESHOTARM_SET_M 0x0000ffff
575
576/*
577 * QCU one shot arm clear registers
578 */
579#define AR5K_QCU_ONESHOTARM_CLEAR 0x0980 /* Register Address -QCU "one shot arm clear (?)" */
580#define AR5K_QCU_ONESHOTARM_CLEAR_M 0x0000ffff
581
582/*
583 * QCU misc registers
584 */
585#define AR5K_QCU_MISC_BASE 0x09c0 /* Register Address -Queue0 MISC */
586#define AR5K_QCU_MISC_FRSHED_M 0x0000000f /* Frame sheduling mask */
Nick Kossifidis0bacdf32008-07-30 13:18:59 +0300587#define AR5K_QCU_MISC_FRSHED_ASAP 0 /* ASAP */
588#define AR5K_QCU_MISC_FRSHED_CBR 1 /* Constant Bit Rate */
589#define AR5K_QCU_MISC_FRSHED_DBA_GT 2 /* DMA Beacon alert gated (?) */
590#define AR5K_QCU_MISC_FRSHED_TIM_GT 3 /* Time gated (?) */
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200591#define AR5K_QCU_MISC_FRSHED_BCN_SENT_GT 4 /* Beacon sent gated (?) */
592#define AR5K_QCU_MISC_ONESHOT_ENABLE 0x00000010 /* Oneshot enable */
593#define AR5K_QCU_MISC_CBREXP 0x00000020 /* CBR expired (normal queue) */
594#define AR5K_QCU_MISC_CBREXP_BCN 0x00000040 /* CBR expired (beacon queue) */
Nick Kossifidis0bacdf32008-07-30 13:18:59 +0300595#define AR5K_QCU_MISC_BCN_ENABLE 0x00000080 /* Enable Beacon use */
596#define AR5K_QCU_MISC_CBR_THRES_ENABLE 0x00000100 /* CBR threshold enabled */
597#define AR5K_QCU_MISC_RDY_VEOL_POLICY 0x00000200 /* TXE reset when RDYTIME enalbed */
598#define AR5K_QCU_MISC_CBR_RESET_CNT 0x00000400 /* CBR threshold (counter) reset */
599#define AR5K_QCU_MISC_DCU_EARLY 0x00000800 /* DCU early termination */
600#define AR5K_QCU_MISC_DCU_CMP_EN 0x00001000 /* Enable frame compression */
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200601#define AR5K_QUEUE_MISC(_q) AR5K_QUEUE_REG(AR5K_QCU_MISC_BASE, _q)
602
603
604/*
605 * QCU status registers
606 */
607#define AR5K_QCU_STS_BASE 0x0a00 /* Register Address - Queue0 STS */
608#define AR5K_QCU_STS_FRMPENDCNT 0x00000003 /* Frames pending counter */
Nick Kossifidis0bacdf32008-07-30 13:18:59 +0300609#define AR5K_QCU_STS_CBREXPCNT 0x0000ff00 /* CBR expired counter */
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200610#define AR5K_QUEUE_STATUS(_q) AR5K_QUEUE_REG(AR5K_QCU_STS_BASE, _q)
611
612/*
613 * QCU ready time shutdown register
614 */
615#define AR5K_QCU_RDYTIMESHDN 0x0a40
616#define AR5K_QCU_RDYTIMESHDN_M 0x000003ff
617
618/*
619 * QCU compression buffer base registers [5212+]
620 */
621#define AR5K_QCU_CBB_SELECT 0x0b00
622#define AR5K_QCU_CBB_ADDR 0x0b04
Nick Kossifidis0bacdf32008-07-30 13:18:59 +0300623#define AR5K_QCU_CBB_ADDR_S 9
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200624
625/*
626 * QCU compression buffer configuration register [5212+]
Nick Kossifidis0bacdf32008-07-30 13:18:59 +0300627 * (buffer size)
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200628 */
629#define AR5K_QCU_CBCFG 0x0b08
630
631
632
633/*
634 * Distributed Coordination Function (DCF) control unit (DCU)
635 * registers [5211+]
636 *
637 * These registers control the various characteristics of each queue
638 * for 802.11e (WME) combatibility so they go together with
639 * QCU registers in pairs. For each queue we have a QCU mask register,
640 * (0x1000 - 0x102c), a local-IFS settings register (0x1040 - 0x106c),
641 * a retry limit register (0x1080 - 0x10ac), a channel time register
642 * (0x10c0 - 0x10ec), a misc-settings register (0x1100 - 0x112c) and
643 * a sequence number register (0x1140 - 0x116c). It seems that "global"
644 * registers here afect all queues (see use of DCU_GBL_IFS_SLOT in ar5k).
645 * We use the same macros here for easier register access.
646 *
647 */
648
649/*
650 * DCU QCU mask registers
651 */
652#define AR5K_DCU_QCUMASK_BASE 0x1000 /* Register Address -Queue0 DCU_QCUMASK */
653#define AR5K_DCU_QCUMASK_M 0x000003ff
654#define AR5K_QUEUE_QCUMASK(_q) AR5K_QUEUE_REG(AR5K_DCU_QCUMASK_BASE, _q)
655
656/*
657 * DCU local Inter Frame Space settings register
658 */
659#define AR5K_DCU_LCL_IFS_BASE 0x1040 /* Register Address -Queue0 DCU_LCL_IFS */
660#define AR5K_DCU_LCL_IFS_CW_MIN 0x000003ff /* Minimum Contention Window */
661#define AR5K_DCU_LCL_IFS_CW_MIN_S 0
662#define AR5K_DCU_LCL_IFS_CW_MAX 0x000ffc00 /* Maximum Contention Window */
663#define AR5K_DCU_LCL_IFS_CW_MAX_S 10
664#define AR5K_DCU_LCL_IFS_AIFS 0x0ff00000 /* Arbitrated Interframe Space */
665#define AR5K_DCU_LCL_IFS_AIFS_S 20
666#define AR5K_QUEUE_DFS_LOCAL_IFS(_q) AR5K_QUEUE_REG(AR5K_DCU_LCL_IFS_BASE, _q)
667
668/*
669 * DCU retry limit registers
670 */
671#define AR5K_DCU_RETRY_LMT_BASE 0x1080 /* Register Address -Queue0 DCU_RETRY_LMT */
672#define AR5K_DCU_RETRY_LMT_SH_RETRY 0x0000000f /* Short retry limit mask */
673#define AR5K_DCU_RETRY_LMT_SH_RETRY_S 0
674#define AR5K_DCU_RETRY_LMT_LG_RETRY 0x000000f0 /* Long retry limit mask */
675#define AR5K_DCU_RETRY_LMT_LG_RETRY_S 4
676#define AR5K_DCU_RETRY_LMT_SSH_RETRY 0x00003f00 /* Station short retry limit mask (?) */
677#define AR5K_DCU_RETRY_LMT_SSH_RETRY_S 8
678#define AR5K_DCU_RETRY_LMT_SLG_RETRY 0x000fc000 /* Station long retry limit mask (?) */
679#define AR5K_DCU_RETRY_LMT_SLG_RETRY_S 14
680#define AR5K_QUEUE_DFS_RETRY_LIMIT(_q) AR5K_QUEUE_REG(AR5K_DCU_RETRY_LMT_BASE, _q)
681
682/*
683 * DCU channel time registers
684 */
685#define AR5K_DCU_CHAN_TIME_BASE 0x10c0 /* Register Address -Queue0 DCU_CHAN_TIME */
686#define AR5K_DCU_CHAN_TIME_DUR 0x000fffff /* Channel time duration */
687#define AR5K_DCU_CHAN_TIME_DUR_S 0
688#define AR5K_DCU_CHAN_TIME_ENABLE 0x00100000 /* Enable channel time */
689#define AR5K_QUEUE_DFS_CHANNEL_TIME(_q) AR5K_QUEUE_REG(AR5K_DCU_CHAN_TIME_BASE, _q)
690
691/*
692 * DCU misc registers [5211+]
693 *
694 * For some of the registers i couldn't find in the code
695 * (only backoff stuff is there realy) i tried to match the
696 * names with 802.11e parameters etc, so i guess VIRTCOL here
697 * means Virtual Collision and HCFPOLL means Hybrid Coordination
698 * factor Poll (CF- Poll). Arbiter lockout control controls the
699 * behaviour on low priority queues when we have multiple queues
700 * with pending frames. Intra-frame lockout means we wait until
701 * the queue's current frame transmits (with post frame backoff and bursting)
702 * before we transmit anything else and global lockout means we
703 * wait for the whole queue to finish before higher priority queues
704 * can transmit (this is used on beacon and CAB queues).
705 * No lockout means there is no special handling.
706 */
707#define AR5K_DCU_MISC_BASE 0x1100 /* Register Address -Queue0 DCU_MISC */
Nick Kossifidis0bacdf32008-07-30 13:18:59 +0300708#define AR5K_DCU_MISC_BACKOFF 0x000007ff /* Mask for backoff threshold */
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200709#define AR5K_DCU_MISC_BACKOFF_FRAG 0x00000200 /* Enable backoff while bursting */
Nick Kossifidis0bacdf32008-07-30 13:18:59 +0300710#define AR5K_DCU_MISC_HCFPOLL_ENABLE 0x00000800 /* CF - Poll enable */
711#define AR5K_DCU_MISC_BACKOFF_PERSIST 0x00001000 /* Persistent backoff */
712#define AR5K_DCU_MISC_FRMPRFTCH_ENABLE 0x00002000 /* Enable frame pre-fetch */
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200713#define AR5K_DCU_MISC_VIRTCOL 0x0000c000 /* Mask for Virtual Collision (?) */
Nick Kossifidis0bacdf32008-07-30 13:18:59 +0300714#define AR5K_DCU_MISC_VIRTCOL_NORMAL 0
715#define AR5K_DCU_MISC_VIRTCOL_MODIFIED 1
716#define AR5K_DCU_MISC_VIRTCOL_IGNORE 2
717#define AR5K_DCU_MISC_BCN_ENABLE 0x00010000 /* Enable Beacon use */
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200718#define AR5K_DCU_MISC_ARBLOCK_CTL 0x00060000 /* Arbiter lockout control mask */
719#define AR5K_DCU_MISC_ARBLOCK_CTL_S 17
Nick Kossifidis0bacdf32008-07-30 13:18:59 +0300720#define AR5K_DCU_MISC_ARBLOCK_CTL_NONE 0 /* No arbiter lockout */
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200721#define AR5K_DCU_MISC_ARBLOCK_CTL_INTFRM 1 /* Intra-frame lockout */
722#define AR5K_DCU_MISC_ARBLOCK_CTL_GLOBAL 2 /* Global lockout */
Nick Kossifidis0bacdf32008-07-30 13:18:59 +0300723#define AR5K_DCU_MISC_ARBLOCK_IGNORE 0x00080000 /* Ignore Arbiter lockout */
724#define AR5K_DCU_MISC_SEQ_NUM_INCR_DIS 0x00100000 /* Disable sequence number increment */
725#define AR5K_DCU_MISC_POST_FR_BKOFF_DIS 0x00200000 /* Disable post-frame backoff */
726#define AR5K_DCU_MISC_VIRT_COLL_POLICY 0x00400000 /* Virtual Collision cw policy */
727#define AR5K_DCU_MISC_BLOWN_IFS_POLICY 0x00800000 /* Blown IFS policy (?) */
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200728#define AR5K_DCU_MISC_SEQNUM_CTL 0x01000000 /* Sequence number control (?) */
729#define AR5K_QUEUE_DFS_MISC(_q) AR5K_QUEUE_REG(AR5K_DCU_MISC_BASE, _q)
730
731/*
732 * DCU frame sequence number registers
733 */
Nick Kossifidis0bacdf32008-07-30 13:18:59 +0300734#define AR5K_DCU_SEQNUM_BASE 0x1140
735#define AR5K_DCU_SEQNUM_M 0x00000fff
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200736#define AR5K_QUEUE_DFS_SEQNUM(_q) AR5K_QUEUE_REG(AR5K_DCU_SEQNUM_BASE, _q)
737
738/*
Nick Kossifidis0bacdf32008-07-30 13:18:59 +0300739 * DCU global IFS SIFS register
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200740 */
741#define AR5K_DCU_GBL_IFS_SIFS 0x1030
742#define AR5K_DCU_GBL_IFS_SIFS_M 0x0000ffff
743
744/*
Nick Kossifidis0bacdf32008-07-30 13:18:59 +0300745 * DCU global IFS slot interval register
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200746 */
747#define AR5K_DCU_GBL_IFS_SLOT 0x1070
748#define AR5K_DCU_GBL_IFS_SLOT_M 0x0000ffff
749
750/*
Nick Kossifidis0bacdf32008-07-30 13:18:59 +0300751 * DCU global IFS EIFS register
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200752 */
753#define AR5K_DCU_GBL_IFS_EIFS 0x10b0
754#define AR5K_DCU_GBL_IFS_EIFS_M 0x0000ffff
755
756/*
Nick Kossifidis0bacdf32008-07-30 13:18:59 +0300757 * DCU global IFS misc register
758 *
759 * LFSR stands for Linear Feedback Shift Register
760 * and it's used for generating pseudo-random
761 * number sequences.
762 *
763 * (If i understand corectly, random numbers are
764 * used for idle sensing -multiplied with cwmin/max etc-)
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200765 */
766#define AR5K_DCU_GBL_IFS_MISC 0x10f0 /* Register Address */
Nick Kossifidis0bacdf32008-07-30 13:18:59 +0300767#define AR5K_DCU_GBL_IFS_MISC_LFSR_SLICE 0x00000007 /* LFSR Slice Select */
768#define AR5K_DCU_GBL_IFS_MISC_TURBO_MODE 0x00000008 /* Turbo mode */
769#define AR5K_DCU_GBL_IFS_MISC_SIFS_DUR_USEC 0x000003f0 /* SIFS Duration mask */
770#define AR5K_DCU_GBL_IFS_MISC_USEC_DUR 0x000ffc00 /* USEC Duration mask */
771#define AR5K_DCU_GBL_IFS_MISC_DCU_ARB_DELAY 0x00300000 /* DCU Arbiter delay mask */
772#define AR5K_DCU_GBL_IFS_MISC_SIFS_CNT_RST 0x00400000 /* SIFC cnt reset policy (?) */
773#define AR5K_DCU_GBL_IFS_MISC_AIFS_CNT_RST 0x00800000 /* AIFS cnt reset policy (?) */
774#define AR5K_DCU_GBL_IFS_MISC_RND_LFSR_SL_DIS 0x01000000 /* Disable random LFSR slice */
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200775
776/*
777 * DCU frame prefetch control register
778 */
Nick Kossifidis0bacdf32008-07-30 13:18:59 +0300779#define AR5K_DCU_FP 0x1230 /* Register Address */
780#define AR5K_DCU_FP_NOBURST_DCU_EN 0x00000001 /* Enable non-burst prefetch on DCU (?) */
781#define AR5K_DCU_FP_NOBURST_EN 0x00000010 /* Enable non-burst prefetch (?) */
782#define AR5K_DCU_FP_BURST_DCU_EN 0x00000020 /* Enable burst prefetch on DCU (?) */
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200783
784/*
785 * DCU transmit pause control/status register
786 */
787#define AR5K_DCU_TXP 0x1270 /* Register Address */
Nick Kossifidis0bacdf32008-07-30 13:18:59 +0300788#define AR5K_DCU_TXP_M 0x000003ff /* Tx pause mask */
789#define AR5K_DCU_TXP_STATUS 0x00010000 /* Tx pause status */
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200790
791/*
Nick Kossifidis0bacdf32008-07-30 13:18:59 +0300792 * DCU transmit filter table 0 (32 entries)
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200793 */
Nick Kossifidis0bacdf32008-07-30 13:18:59 +0300794#define AR5K_DCU_TX_FILTER_0_BASE 0x1038
795#define AR5K_DCU_TX_FILTER_0(_n) (AR5K_DCU_TX_FILTER_0_BASE + (_n * 64))
796
797/*
798 * DCU transmit filter table 1 (16 entries)
799 */
800#define AR5K_DCU_TX_FILTER_1_BASE 0x103c
801#define AR5K_DCU_TX_FILTER_1(_n) (AR5K_DCU_TX_FILTER_1_BASE + ((_n - 32) * 64))
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200802
803/*
804 * DCU clear transmit filter register
805 */
806#define AR5K_DCU_TX_FILTER_CLR 0x143c
807
808/*
809 * DCU set transmit filter register
810 */
811#define AR5K_DCU_TX_FILTER_SET 0x147c
812
813/*
814 * Reset control register
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200815 */
816#define AR5K_RESET_CTL 0x4000 /* Register Address */
817#define AR5K_RESET_CTL_PCU 0x00000001 /* Protocol Control Unit reset */
818#define AR5K_RESET_CTL_DMA 0x00000002 /* DMA (Rx/Tx) reset [5210] */
819#define AR5K_RESET_CTL_BASEBAND 0x00000002 /* Baseband reset [5211+] */
820#define AR5K_RESET_CTL_MAC 0x00000004 /* MAC reset (PCU+Baseband ?) [5210] */
821#define AR5K_RESET_CTL_PHY 0x00000008 /* PHY reset [5210] */
822#define AR5K_RESET_CTL_PCI 0x00000010 /* PCI Core reset (interrupts etc) */
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200823
824/*
825 * Sleep control register
826 */
827#define AR5K_SLEEP_CTL 0x4004 /* Register Address */
828#define AR5K_SLEEP_CTL_SLDUR 0x0000ffff /* Sleep duration mask */
829#define AR5K_SLEEP_CTL_SLDUR_S 0
830#define AR5K_SLEEP_CTL_SLE 0x00030000 /* Sleep enable mask */
831#define AR5K_SLEEP_CTL_SLE_S 16
832#define AR5K_SLEEP_CTL_SLE_WAKE 0x00000000 /* Force chip awake */
833#define AR5K_SLEEP_CTL_SLE_SLP 0x00010000 /* Force chip sleep */
834#define AR5K_SLEEP_CTL_SLE_ALLOW 0x00020000
835#define AR5K_SLEEP_CTL_SLE_UNITS 0x00000008 /* [5211+] */
Nick Kossifidis0bacdf32008-07-30 13:18:59 +0300836/* more bits */
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200837
838/*
839 * Interrupt pending register
840 */
841#define AR5K_INTPEND 0x4008
842#define AR5K_INTPEND_M 0x00000001
843
844/*
845 * Sleep force register
846 */
847#define AR5K_SFR 0x400c
Nick Kossifidis0bacdf32008-07-30 13:18:59 +0300848#define AR5K_SFR_EN 0x00000001
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200849
850/*
851 * PCI configuration register
852 */
853#define AR5K_PCICFG 0x4010 /* Register Address */
854#define AR5K_PCICFG_EEAE 0x00000001 /* Eeprom access enable [5210] */
Nick Kossifidis0bacdf32008-07-30 13:18:59 +0300855#define AR5K_PCICFG_SLEEP_CLOCK_EN 0x00000002 /* Enable sleep clock (?) */
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200856#define AR5K_PCICFG_CLKRUNEN 0x00000004 /* CLKRUN enable [5211+] */
857#define AR5K_PCICFG_EESIZE 0x00000018 /* Mask for EEPROM size [5211+] */
858#define AR5K_PCICFG_EESIZE_S 3
859#define AR5K_PCICFG_EESIZE_4K 0 /* 4K */
860#define AR5K_PCICFG_EESIZE_8K 1 /* 8K */
861#define AR5K_PCICFG_EESIZE_16K 2 /* 16K */
862#define AR5K_PCICFG_EESIZE_FAIL 3 /* Failed to get size (?) [5211+] */
863#define AR5K_PCICFG_LED 0x00000060 /* Led status [5211+] */
864#define AR5K_PCICFG_LED_NONE 0x00000000 /* Default [5211+] */
865#define AR5K_PCICFG_LED_PEND 0x00000020 /* Scan / Auth pending */
866#define AR5K_PCICFG_LED_ASSOC 0x00000040 /* Associated */
867#define AR5K_PCICFG_BUS_SEL 0x00000380 /* Mask for "bus select" [5211+] (?) */
868#define AR5K_PCICFG_CBEFIX_DIS 0x00000400 /* Disable CBE fix (?) */
869#define AR5K_PCICFG_SL_INTEN 0x00000800 /* Enable interrupts when asleep (?) */
870#define AR5K_PCICFG_LED_BCTL 0x00001000 /* Led blink (?) [5210] */
Nick Kossifidis0bacdf32008-07-30 13:18:59 +0300871#define AR5K_PCICFG_UNK 0x00001000 /* Passed on some parts durring attach (?) */
872#define AR5K_PCICFG_SL_INPEN 0x00002000 /* Sleep even whith pending interrupts (?) */
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200873#define AR5K_PCICFG_SPWR_DN 0x00010000 /* Mask for power status */
874#define AR5K_PCICFG_LEDMODE 0x000e0000 /* Ledmode [5211+] */
875#define AR5K_PCICFG_LEDMODE_PROP 0x00000000 /* Blink on standard traffic [5211+] */
876#define AR5K_PCICFG_LEDMODE_PROM 0x00020000 /* Default mode (blink on any traffic) [5211+] */
877#define AR5K_PCICFG_LEDMODE_PWR 0x00040000 /* Some other blinking mode (?) [5211+] */
878#define AR5K_PCICFG_LEDMODE_RAND 0x00060000 /* Random blinking (?) [5211+] */
Nick Kossifidis0bacdf32008-07-30 13:18:59 +0300879#define AR5K_PCICFG_LEDBLINK 0x00700000 /* Led blink rate */
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200880#define AR5K_PCICFG_LEDBLINK_S 20
Nick Kossifidis0bacdf32008-07-30 13:18:59 +0300881#define AR5K_PCICFG_LEDSLOW 0x00800000 /* Slowest led blink rate [5211+] */
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200882#define AR5K_PCICFG_LEDSTATE \
883 (AR5K_PCICFG_LED | AR5K_PCICFG_LEDMODE | \
884 AR5K_PCICFG_LEDBLINK | AR5K_PCICFG_LEDSLOW)
Nick Kossifidis0bacdf32008-07-30 13:18:59 +0300885#define AR5K_PCICFG_SLEEP_CLOCK_RATE 0x03000000 /* Sleep clock rate (field) */
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200886
887/*
888 * "General Purpose Input/Output" (GPIO) control register
889 *
890 * I'm not sure about this but after looking at the code
891 * for all chipsets here is what i got.
892 *
893 * We have 6 GPIOs (pins), each GPIO has 4 modes (2 bits)
894 * Mode 0 -> always input
895 * Mode 1 -> output when GPIODO for this GPIO is set to 0
896 * Mode 2 -> output when GPIODO for this GPIO is set to 1
897 * Mode 3 -> always output
898 *
899 * For more infos check out get_gpio/set_gpio and
900 * set_gpio_input/set_gpio_output functs.
901 * For more infos on gpio interrupt check out set_gpio_intr.
902 */
903#define AR5K_NUM_GPIO 6
904
905#define AR5K_GPIOCR 0x4014 /* Register Address */
906#define AR5K_GPIOCR_INT_ENA 0x00008000 /* Enable GPIO interrupt */
907#define AR5K_GPIOCR_INT_SELL 0x00000000 /* Generate interrupt when pin is off (?) */
908#define AR5K_GPIOCR_INT_SELH 0x00010000 /* Generate interrupt when pin is on */
909#define AR5K_GPIOCR_IN(n) (0 << ((n) * 2)) /* Mode 0 for pin n */
910#define AR5K_GPIOCR_OUT0(n) (1 << ((n) * 2)) /* Mode 1 for pin n */
911#define AR5K_GPIOCR_OUT1(n) (2 << ((n) * 2)) /* Mode 2 for pin n */
912#define AR5K_GPIOCR_OUT(n) (3 << ((n) * 2)) /* Mode 3 for pin n */
913#define AR5K_GPIOCR_INT_SEL(n) ((n) << 12) /* Interrupt for GPIO pin n */
914
915/*
916 * "General Purpose Input/Output" (GPIO) data output register
917 */
918#define AR5K_GPIODO 0x4018
919
920/*
921 * "General Purpose Input/Output" (GPIO) data input register
922 */
923#define AR5K_GPIODI 0x401c
924#define AR5K_GPIODI_M 0x0000002f
925
926
927/*
928 * Silicon revision register
929 */
930#define AR5K_SREV 0x4020 /* Register Address */
931#define AR5K_SREV_REV 0x0000000f /* Mask for revision */
932#define AR5K_SREV_REV_S 0
933#define AR5K_SREV_VER 0x000000ff /* Mask for version */
934#define AR5K_SREV_VER_S 4
935
936
937
938/*====EEPROM REGISTERS====*/
939
940/*
941 * EEPROM access registers
942 *
943 * Here we got a difference between 5210/5211-12
944 * read data register for 5210 is at 0x6800 and
945 * status register is at 0x6c00. There is also
946 * no eeprom command register on 5210 and the
947 * offsets are different.
948 *
949 * To read eeprom data for a specific offset:
950 * 5210 - enable eeprom access (AR5K_PCICFG_EEAE)
951 * read AR5K_EEPROM_BASE +(4 * offset)
952 * check the eeprom status register
953 * and read eeprom data register.
954 *
955 * 5211 - write offset to AR5K_EEPROM_BASE
956 * 5212 write AR5K_EEPROM_CMD_READ on AR5K_EEPROM_CMD
957 * check the eeprom status register
958 * and read eeprom data register.
959 *
960 * To write eeprom data for a specific offset:
961 * 5210 - enable eeprom access (AR5K_PCICFG_EEAE)
962 * write data to AR5K_EEPROM_BASE +(4 * offset)
963 * check the eeprom status register
964 * 5211 - write AR5K_EEPROM_CMD_RESET on AR5K_EEPROM_CMD
965 * 5212 write offset to AR5K_EEPROM_BASE
966 * write data to data register
967 * write AR5K_EEPROM_CMD_WRITE on AR5K_EEPROM_CMD
968 * check the eeprom status register
969 *
970 * For more infos check eeprom_* functs and the ar5k.c
971 * file posted in madwifi-devel mailing list.
972 * http://sourceforge.net/mailarchive/message.php?msg_id=8966525
973 *
974 */
975#define AR5K_EEPROM_BASE 0x6000
976
977/*
Jiri Slabyfa1c1142007-08-12 17:33:16 +0200978 * EEPROM data register
979 */
980#define AR5K_EEPROM_DATA_5211 0x6004
981#define AR5K_EEPROM_DATA_5210 0x6800
982#define AR5K_EEPROM_DATA (ah->ah_version == AR5K_AR5210 ? \
983 AR5K_EEPROM_DATA_5210 : AR5K_EEPROM_DATA_5211)
984
985/*
986 * EEPROM command register
987 */
988#define AR5K_EEPROM_CMD 0x6008 /* Register Addres */
989#define AR5K_EEPROM_CMD_READ 0x00000001 /* EEPROM read */
990#define AR5K_EEPROM_CMD_WRITE 0x00000002 /* EEPROM write */
991#define AR5K_EEPROM_CMD_RESET 0x00000004 /* EEPROM reset */
992
993/*
994 * EEPROM status register
995 */
996#define AR5K_EEPROM_STAT_5210 0x6c00 /* Register Address [5210] */
997#define AR5K_EEPROM_STAT_5211 0x600c /* Register Address [5211+] */
998#define AR5K_EEPROM_STATUS (ah->ah_version == AR5K_AR5210 ? \
999 AR5K_EEPROM_STAT_5210 : AR5K_EEPROM_STAT_5211)
1000#define AR5K_EEPROM_STAT_RDERR 0x00000001 /* EEPROM read failed */
1001#define AR5K_EEPROM_STAT_RDDONE 0x00000002 /* EEPROM read successful */
1002#define AR5K_EEPROM_STAT_WRERR 0x00000004 /* EEPROM write failed */
1003#define AR5K_EEPROM_STAT_WRDONE 0x00000008 /* EEPROM write successful */
1004
1005/*
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03001006 * EEPROM config register
Jiri Slabyfa1c1142007-08-12 17:33:16 +02001007 */
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03001008#define AR5K_EEPROM_CFG 0x6010 /* Register Addres */
1009#define AR5K_EEPROM_CFG_SIZE_OVR 0x00000001
1010#define AR5K_EEPROM_CFG_WR_WAIT_DIS 0x00000004 /* Disable write wait */
1011#define AR5K_EEPROM_CFG_CLK_RATE 0x00000018 /* Clock rate */
1012#define AR5K_EEPROM_CFG_PROT_KEY 0x00ffff00 /* Protectio key */
1013#define AR5K_EEPROM_CFG_LIND_EN 0x01000000 /* Enable length indicator (?) */
Jiri Slabyfa1c1142007-08-12 17:33:16 +02001014
1015
1016/*
1017 * Protocol Control Unit (PCU) registers
1018 */
1019/*
1020 * Used for checking initial register writes
1021 * during channel reset (see reset func)
1022 */
1023#define AR5K_PCU_MIN 0x8000
1024#define AR5K_PCU_MAX 0x8fff
1025
1026/*
1027 * First station id register (MAC address in lower 32 bits)
1028 */
1029#define AR5K_STA_ID0 0x8000
1030
1031/*
1032 * Second station id register (MAC address in upper 16 bits)
1033 */
1034#define AR5K_STA_ID1 0x8004 /* Register Address */
1035#define AR5K_STA_ID1_AP 0x00010000 /* Set AP mode */
1036#define AR5K_STA_ID1_ADHOC 0x00020000 /* Set Ad-Hoc mode */
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03001037#define AR5K_STA_ID1_PWR_SV 0x00040000 /* Power save reporting */
Jiri Slabyfa1c1142007-08-12 17:33:16 +02001038#define AR5K_STA_ID1_NO_KEYSRCH 0x00080000 /* No key search */
1039#define AR5K_STA_ID1_NO_PSPOLL 0x00100000 /* No power save polling [5210] */
1040#define AR5K_STA_ID1_PCF_5211 0x00100000 /* Enable PCF on [5211+] */
1041#define AR5K_STA_ID1_PCF_5210 0x00200000 /* Enable PCF on [5210]*/
1042#define AR5K_STA_ID1_PCF (ah->ah_version == AR5K_AR5210 ? \
1043 AR5K_STA_ID1_PCF_5210 : AR5K_STA_ID1_PCF_5211)
1044#define AR5K_STA_ID1_DEFAULT_ANTENNA 0x00200000 /* Use default antenna */
1045#define AR5K_STA_ID1_DESC_ANTENNA 0x00400000 /* Update antenna from descriptor */
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03001046#define AR5K_STA_ID1_RTS_DEF_ANTENNA 0x00800000 /* Use default antenna for RTS */
1047#define AR5K_STA_ID1_ACKCTS_6MB 0x01000000 /* Use 6Mbit/s for ACK/CTS */
Jiri Slabyfa1c1142007-08-12 17:33:16 +02001048#define AR5K_STA_ID1_BASE_RATE_11B 0x02000000 /* Use 11b base rate (for ACK/CTS ?) [5211+] */
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03001049#define AR5K_STA_ID1_SELF_GEN_SECTORE 0x04000000 /* Self generate sectore (?) */
1050#define AR5K_STA_ID1_CRYPT_MIC_EN 0x08000000 /* Enable MIC */
1051#define AR5K_STA_ID1_KEYSRCH_MODE 0x10000000 /* Keysearch mode (?) */
1052#define AR5K_STA_ID1_PRESERVE_SEQ_NUM 0x20000000 /* Preserve sequence number */
Jiri Slabyfa1c1142007-08-12 17:33:16 +02001053
1054/*
1055 * First BSSID register (MAC address, lower 32bits)
1056 */
1057#define AR5K_BSS_ID0 0x8008
1058
1059/*
1060 * Second BSSID register (MAC address in upper 16 bits)
1061 *
1062 * AID: Association ID
1063 */
1064#define AR5K_BSS_ID1 0x800c
1065#define AR5K_BSS_ID1_AID 0xffff0000
1066#define AR5K_BSS_ID1_AID_S 16
1067
1068/*
1069 * Backoff slot time register
1070 */
1071#define AR5K_SLOT_TIME 0x8010
1072
1073/*
1074 * ACK/CTS timeout register
1075 */
1076#define AR5K_TIME_OUT 0x8014 /* Register Address */
1077#define AR5K_TIME_OUT_ACK 0x00001fff /* ACK timeout mask */
1078#define AR5K_TIME_OUT_ACK_S 0
1079#define AR5K_TIME_OUT_CTS 0x1fff0000 /* CTS timeout mask */
1080#define AR5K_TIME_OUT_CTS_S 16
1081
1082/*
1083 * RSSI threshold register
1084 */
1085#define AR5K_RSSI_THR 0x8018 /* Register Address */
1086#define AR5K_RSSI_THR_M 0x000000ff /* Mask for RSSI threshold [5211+] */
1087#define AR5K_RSSI_THR_BMISS_5210 0x00000700 /* Mask for Beacon Missed threshold [5210] */
1088#define AR5K_RSSI_THR_BMISS_5210_S 8
1089#define AR5K_RSSI_THR_BMISS_5211 0x0000ff00 /* Mask for Beacon Missed threshold [5211+] */
1090#define AR5K_RSSI_THR_BMISS_5211_S 8
1091#define AR5K_RSSI_THR_BMISS (ah->ah_version == AR5K_AR5210 ? \
1092 AR5K_RSSI_THR_BMISS_5210 : AR5K_RSSI_THR_BMISS_5211)
1093#define AR5K_RSSI_THR_BMISS_S 8
1094
1095/*
1096 * 5210 has more PCU registers because there is no QCU/DCU
1097 * so queue parameters are set here, this way a lot common
1098 * registers have different address for 5210. To make things
1099 * easier we define a macro based on ah->ah_version for common
1100 * registers with different addresses and common flags.
1101 */
1102
1103/*
1104 * Retry limit register
1105 *
1106 * Retry limit register for 5210 (no QCU/DCU so it's done in PCU)
1107 */
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03001108#define AR5K_NODCU_RETRY_LMT 0x801c /* Register Address */
Jiri Slabyfa1c1142007-08-12 17:33:16 +02001109#define AR5K_NODCU_RETRY_LMT_SH_RETRY 0x0000000f /* Short retry limit mask */
1110#define AR5K_NODCU_RETRY_LMT_SH_RETRY_S 0
1111#define AR5K_NODCU_RETRY_LMT_LG_RETRY 0x000000f0 /* Long retry mask */
1112#define AR5K_NODCU_RETRY_LMT_LG_RETRY_S 4
1113#define AR5K_NODCU_RETRY_LMT_SSH_RETRY 0x00003f00 /* Station short retry limit mask */
1114#define AR5K_NODCU_RETRY_LMT_SSH_RETRY_S 8
1115#define AR5K_NODCU_RETRY_LMT_SLG_RETRY 0x000fc000 /* Station long retry limit mask */
1116#define AR5K_NODCU_RETRY_LMT_SLG_RETRY_S 14
1117#define AR5K_NODCU_RETRY_LMT_CW_MIN 0x3ff00000 /* Minimum contention window mask */
1118#define AR5K_NODCU_RETRY_LMT_CW_MIN_S 20
1119
1120/*
1121 * Transmit latency register
1122 */
1123#define AR5K_USEC_5210 0x8020 /* Register Address [5210] */
1124#define AR5K_USEC_5211 0x801c /* Register Address [5211+] */
1125#define AR5K_USEC (ah->ah_version == AR5K_AR5210 ? \
1126 AR5K_USEC_5210 : AR5K_USEC_5211)
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03001127#define AR5K_USEC_1 0x0000007f /* clock cycles for 1us */
Jiri Slabyfa1c1142007-08-12 17:33:16 +02001128#define AR5K_USEC_1_S 0
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03001129#define AR5K_USEC_32 0x00003f80 /* clock cycles for 1us while on 32Mhz clock */
Jiri Slabyfa1c1142007-08-12 17:33:16 +02001130#define AR5K_USEC_32_S 7
1131#define AR5K_USEC_TX_LATENCY_5211 0x007fc000
1132#define AR5K_USEC_TX_LATENCY_5211_S 14
1133#define AR5K_USEC_RX_LATENCY_5211 0x1f800000
1134#define AR5K_USEC_RX_LATENCY_5211_S 23
1135#define AR5K_USEC_TX_LATENCY_5210 0x000fc000 /* also for 5311 */
1136#define AR5K_USEC_TX_LATENCY_5210_S 14
1137#define AR5K_USEC_RX_LATENCY_5210 0x03f00000 /* also for 5311 */
1138#define AR5K_USEC_RX_LATENCY_5210_S 20
1139
1140/*
1141 * PCU beacon control register
1142 */
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03001143#define AR5K_BEACON_5210 0x8024 /*Register Address [5210] */
1144#define AR5K_BEACON_5211 0x8020 /*Register Address [5211+] */
Jiri Slabyfa1c1142007-08-12 17:33:16 +02001145#define AR5K_BEACON (ah->ah_version == AR5K_AR5210 ? \
1146 AR5K_BEACON_5210 : AR5K_BEACON_5211)
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03001147#define AR5K_BEACON_PERIOD 0x0000ffff /* Mask for beacon period */
Jiri Slabyfa1c1142007-08-12 17:33:16 +02001148#define AR5K_BEACON_PERIOD_S 0
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03001149#define AR5K_BEACON_TIM 0x007f0000 /* Mask for TIM offset */
Jiri Slabyfa1c1142007-08-12 17:33:16 +02001150#define AR5K_BEACON_TIM_S 16
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03001151#define AR5K_BEACON_ENABLE 0x00800000 /* Enable beacons */
1152#define AR5K_BEACON_RESET_TSF 0x01000000 /* Force TSF reset */
Jiri Slabyfa1c1142007-08-12 17:33:16 +02001153
1154/*
1155 * CFP period register
1156 */
1157#define AR5K_CFP_PERIOD_5210 0x8028
1158#define AR5K_CFP_PERIOD_5211 0x8024
1159#define AR5K_CFP_PERIOD (ah->ah_version == AR5K_AR5210 ? \
1160 AR5K_CFP_PERIOD_5210 : AR5K_CFP_PERIOD_5211)
1161
1162/*
1163 * Next beacon time register
1164 */
1165#define AR5K_TIMER0_5210 0x802c
1166#define AR5K_TIMER0_5211 0x8028
1167#define AR5K_TIMER0 (ah->ah_version == AR5K_AR5210 ? \
1168 AR5K_TIMER0_5210 : AR5K_TIMER0_5211)
1169
1170/*
1171 * Next DMA beacon alert register
1172 */
1173#define AR5K_TIMER1_5210 0x8030
1174#define AR5K_TIMER1_5211 0x802c
1175#define AR5K_TIMER1 (ah->ah_version == AR5K_AR5210 ? \
1176 AR5K_TIMER1_5210 : AR5K_TIMER1_5211)
1177
1178/*
1179 * Next software beacon alert register
1180 */
1181#define AR5K_TIMER2_5210 0x8034
1182#define AR5K_TIMER2_5211 0x8030
1183#define AR5K_TIMER2 (ah->ah_version == AR5K_AR5210 ? \
1184 AR5K_TIMER2_5210 : AR5K_TIMER2_5211)
1185
1186/*
1187 * Next ATIM window time register
1188 */
1189#define AR5K_TIMER3_5210 0x8038
1190#define AR5K_TIMER3_5211 0x8034
1191#define AR5K_TIMER3 (ah->ah_version == AR5K_AR5210 ? \
1192 AR5K_TIMER3_5210 : AR5K_TIMER3_5211)
1193
1194
1195/*
1196 * 5210 First inter frame spacing register (IFS)
1197 */
1198#define AR5K_IFS0 0x8040
1199#define AR5K_IFS0_SIFS 0x000007ff
1200#define AR5K_IFS0_SIFS_S 0
1201#define AR5K_IFS0_DIFS 0x007ff800
1202#define AR5K_IFS0_DIFS_S 11
1203
1204/*
1205 * 5210 Second inter frame spacing register (IFS)
1206 */
1207#define AR5K_IFS1 0x8044
1208#define AR5K_IFS1_PIFS 0x00000fff
1209#define AR5K_IFS1_PIFS_S 0
1210#define AR5K_IFS1_EIFS 0x03fff000
1211#define AR5K_IFS1_EIFS_S 12
1212#define AR5K_IFS1_CS_EN 0x04000000
1213
1214
1215/*
1216 * CFP duration register
1217 */
1218#define AR5K_CFP_DUR_5210 0x8048
1219#define AR5K_CFP_DUR_5211 0x8038
1220#define AR5K_CFP_DUR (ah->ah_version == AR5K_AR5210 ? \
1221 AR5K_CFP_DUR_5210 : AR5K_CFP_DUR_5211)
1222
1223/*
1224 * Receive filter register
Jiri Slabyfa1c1142007-08-12 17:33:16 +02001225 */
1226#define AR5K_RX_FILTER_5210 0x804c /* Register Address [5210] */
1227#define AR5K_RX_FILTER_5211 0x803c /* Register Address [5211+] */
1228#define AR5K_RX_FILTER (ah->ah_version == AR5K_AR5210 ? \
1229 AR5K_RX_FILTER_5210 : AR5K_RX_FILTER_5211)
1230#define AR5K_RX_FILTER_UCAST 0x00000001 /* Don't filter unicast frames */
1231#define AR5K_RX_FILTER_MCAST 0x00000002 /* Don't filter multicast frames */
1232#define AR5K_RX_FILTER_BCAST 0x00000004 /* Don't filter broadcast frames */
1233#define AR5K_RX_FILTER_CONTROL 0x00000008 /* Don't filter control frames */
1234#define AR5K_RX_FILTER_BEACON 0x00000010 /* Don't filter beacon frames */
1235#define AR5K_RX_FILTER_PROM 0x00000020 /* Set promiscuous mode */
1236#define AR5K_RX_FILTER_XRPOLL 0x00000040 /* Don't filter XR poll frame [5212+] */
1237#define AR5K_RX_FILTER_PROBEREQ 0x00000080 /* Don't filter probe requests [5212+] */
1238#define AR5K_RX_FILTER_PHYERR_5212 0x00000100 /* Don't filter phy errors [5212+] */
1239#define AR5K_RX_FILTER_RADARERR_5212 0x00000200 /* Don't filter phy radar errors [5212+] */
1240#define AR5K_RX_FILTER_PHYERR_5211 0x00000040 /* [5211] */
1241#define AR5K_RX_FILTER_RADARERR_5211 0x00000080 /* [5211] */
1242#define AR5K_RX_FILTER_PHYERR \
1243 ((ah->ah_version == AR5K_AR5211 ? \
1244 AR5K_RX_FILTER_PHYERR_5211 : AR5K_RX_FILTER_PHYERR_5212))
1245#define AR5K_RX_FILTER_RADARERR \
1246 ((ah->ah_version == AR5K_AR5211 ? \
1247 AR5K_RX_FILTER_RADARERR_5211 : AR5K_RX_FILTER_RADARERR_5212))
1248
1249/*
1250 * Multicast filter register (lower 32 bits)
1251 */
1252#define AR5K_MCAST_FILTER0_5210 0x8050
1253#define AR5K_MCAST_FILTER0_5211 0x8040
1254#define AR5K_MCAST_FILTER0 (ah->ah_version == AR5K_AR5210 ? \
1255 AR5K_MCAST_FILTER0_5210 : AR5K_MCAST_FILTER0_5211)
1256
1257/*
1258 * Multicast filter register (higher 16 bits)
1259 */
1260#define AR5K_MCAST_FILTER1_5210 0x8054
1261#define AR5K_MCAST_FILTER1_5211 0x8044
1262#define AR5K_MCAST_FILTER1 (ah->ah_version == AR5K_AR5210 ? \
1263 AR5K_MCAST_FILTER1_5210 : AR5K_MCAST_FILTER1_5211)
1264
1265
1266/*
1267 * Transmit mask register (lower 32 bits) [5210]
1268 */
1269#define AR5K_TX_MASK0 0x8058
1270
1271/*
1272 * Transmit mask register (higher 16 bits) [5210]
1273 */
1274#define AR5K_TX_MASK1 0x805c
1275
1276/*
1277 * Clear transmit mask [5210]
1278 */
1279#define AR5K_CLR_TMASK 0x8060
1280
1281/*
1282 * Trigger level register (before transmission) [5210]
1283 */
1284#define AR5K_TRIG_LVL 0x8064
1285
1286
1287/*
1288 * PCU control register
1289 *
1290 * Only DIS_RX is used in the code, the rest i guess are
1291 * for tweaking/diagnostics.
1292 */
1293#define AR5K_DIAG_SW_5210 0x8068 /* Register Address [5210] */
1294#define AR5K_DIAG_SW_5211 0x8048 /* Register Address [5211+] */
1295#define AR5K_DIAG_SW (ah->ah_version == AR5K_AR5210 ? \
1296 AR5K_DIAG_SW_5210 : AR5K_DIAG_SW_5211)
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03001297#define AR5K_DIAG_SW_DIS_WEP_ACK 0x00000001 /* Disable ACKs if WEP key is invalid */
1298#define AR5K_DIAG_SW_DIS_ACK 0x00000002 /* Disable ACKs */
1299#define AR5K_DIAG_SW_DIS_CTS 0x00000004 /* Disable CTSs */
1300#define AR5K_DIAG_SW_DIS_ENC 0x00000008 /* Disable encryption */
1301#define AR5K_DIAG_SW_DIS_DEC 0x00000010 /* Disable decryption */
Jiri Slabyfa1c1142007-08-12 17:33:16 +02001302#define AR5K_DIAG_SW_DIS_TX 0x00000020 /* Disable transmit [5210] */
1303#define AR5K_DIAG_SW_DIS_RX_5210 0x00000040 /* Disable recieve */
1304#define AR5K_DIAG_SW_DIS_RX_5211 0x00000020
1305#define AR5K_DIAG_SW_DIS_RX (ah->ah_version == AR5K_AR5210 ? \
1306 AR5K_DIAG_SW_DIS_RX_5210 : AR5K_DIAG_SW_DIS_RX_5211)
1307#define AR5K_DIAG_SW_LOOP_BACK_5210 0x00000080 /* Loopback (i guess it goes with DIS_TX) [5210] */
1308#define AR5K_DIAG_SW_LOOP_BACK_5211 0x00000040
1309#define AR5K_DIAG_SW_LOOP_BACK (ah->ah_version == AR5K_AR5210 ? \
1310 AR5K_DIAG_SW_LOOP_BACK_5210 : AR5K_DIAG_SW_LOOP_BACK_5211)
1311#define AR5K_DIAG_SW_CORR_FCS_5210 0x00000100
1312#define AR5K_DIAG_SW_CORR_FCS_5211 0x00000080
1313#define AR5K_DIAG_SW_CORR_FCS (ah->ah_version == AR5K_AR5210 ? \
1314 AR5K_DIAG_SW_CORR_FCS_5210 : AR5K_DIAG_SW_CORR_FCS_5211)
1315#define AR5K_DIAG_SW_CHAN_INFO_5210 0x00000200
1316#define AR5K_DIAG_SW_CHAN_INFO_5211 0x00000100
1317#define AR5K_DIAG_SW_CHAN_INFO (ah->ah_version == AR5K_AR5210 ? \
1318 AR5K_DIAG_SW_CHAN_INFO_5210 : AR5K_DIAG_SW_CHAN_INFO_5211)
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03001319#define AR5K_DIAG_SW_EN_SCRAM_SEED_5211 0x00000200 /* Enable scrambler seed */
Jiri Slabyfa1c1142007-08-12 17:33:16 +02001320#define AR5K_DIAG_SW_EN_SCRAM_SEED_5210 0x00000400
1321#define AR5K_DIAG_SW_EN_SCRAM_SEED (ah->ah_version == AR5K_AR5210 ? \
1322 AR5K_DIAG_SW_EN_SCRAM_SEED_5210 : AR5K_DIAG_SW_EN_SCRAM_SEED_5211)
1323#define AR5K_DIAG_SW_ECO_ENABLE 0x00000400 /* [5211+] */
1324#define AR5K_DIAG_SW_SCVRAM_SEED 0x0003f800 /* [5210] */
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03001325#define AR5K_DIAG_SW_SCRAM_SEED_M 0x0001fc00 /* Scrambler seed mask */
Jiri Slabyfa1c1142007-08-12 17:33:16 +02001326#define AR5K_DIAG_SW_SCRAM_SEED_S 10
1327#define AR5K_DIAG_SW_DIS_SEQ_INC 0x00040000 /* Disable seqnum increment (?)[5210] */
1328#define AR5K_DIAG_SW_FRAME_NV0_5210 0x00080000
1329#define AR5K_DIAG_SW_FRAME_NV0_5211 0x00020000
1330#define AR5K_DIAG_SW_FRAME_NV0 (ah->ah_version == AR5K_AR5210 ? \
1331 AR5K_DIAG_SW_FRAME_NV0_5210 : AR5K_DIAG_SW_FRAME_NV0_5211)
1332#define AR5K_DIAG_SW_OBSPT_M 0x000c0000
1333#define AR5K_DIAG_SW_OBSPT_S 18
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03001334/* more bits */
Jiri Slabyfa1c1142007-08-12 17:33:16 +02001335
1336/*
1337 * TSF (clock) register (lower 32 bits)
1338 */
1339#define AR5K_TSF_L32_5210 0x806c
1340#define AR5K_TSF_L32_5211 0x804c
1341#define AR5K_TSF_L32 (ah->ah_version == AR5K_AR5210 ? \
1342 AR5K_TSF_L32_5210 : AR5K_TSF_L32_5211)
1343
1344/*
1345 * TSF (clock) register (higher 32 bits)
1346 */
1347#define AR5K_TSF_U32_5210 0x8070
1348#define AR5K_TSF_U32_5211 0x8050
1349#define AR5K_TSF_U32 (ah->ah_version == AR5K_AR5210 ? \
1350 AR5K_TSF_U32_5210 : AR5K_TSF_U32_5211)
1351
1352/*
1353 * Last beacon timestamp register
1354 */
1355#define AR5K_LAST_TSTP 0x8080
1356
1357/*
1358 * ADDAC test register [5211+]
1359 */
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03001360#define AR5K_ADDAC_TEST 0x8054 /* Register Address */
1361#define AR5K_ADDAC_TEST_TXCONT 0x00000001 /* Test continuous tx */
1362#define AR5K_ADDAC_TEST_TST_MODE 0x00000002 /* Test mode */
1363#define AR5K_ADDAC_TEST_LOOP_EN 0x00000004 /* Enable loop */
1364#define AR5K_ADDAC_TEST_LOOP_LEN 0x00000008 /* Loop length (field) */
1365#define AR5K_ADDAC_TEST_USE_U8 0x00004000 /* Use upper 8 bits */
1366#define AR5K_ADDAC_TEST_MSB 0x00008000 /* State of MSB */
1367#define AR5K_ADDAC_TEST_TRIG_SEL 0x00010000 /* Trigger select */
1368#define AR5K_ADDAC_TEST_TRIG_PTY 0x00020000 /* Trigger polarity */
1369#define AR5K_ADDAC_TEST_RXCONT 0x00040000 /* Continuous capture */
1370#define AR5K_ADDAC_TEST_CAPTURE 0x00080000 /* Begin capture */
1371#define AR5K_ADDAC_TEST_TST_ARM 0x00100000 /* Test ARM (Adaptive Radio Mode ?) */
Jiri Slabyfa1c1142007-08-12 17:33:16 +02001372
1373/*
1374 * Default antenna register [5211+]
1375 */
1376#define AR5K_DEFAULT_ANTENNA 0x8058
1377
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03001378/*
1379 * Frame control QoS mask register (?) [5211+]
1380 * (FC_QOS_MASK)
1381 */
1382#define AR5K_FRAME_CTL_QOSM 0x805c
Jiri Slabyfa1c1142007-08-12 17:33:16 +02001383
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03001384/*
1385 * Seq mask register (?) [5211+]
1386 */
1387#define AR5K_SEQ_MASK 0x8060
Jiri Slabyfa1c1142007-08-12 17:33:16 +02001388
1389/*
1390 * Retry count register [5210]
1391 */
1392#define AR5K_RETRY_CNT 0x8084 /* Register Address [5210] */
1393#define AR5K_RETRY_CNT_SSH 0x0000003f /* Station short retry count (?) */
1394#define AR5K_RETRY_CNT_SLG 0x00000fc0 /* Station long retry count (?) */
1395
1396/*
1397 * Back-off status register [5210]
1398 */
1399#define AR5K_BACKOFF 0x8088 /* Register Address [5210] */
1400#define AR5K_BACKOFF_CW 0x000003ff /* Backoff Contention Window (?) */
1401#define AR5K_BACKOFF_CNT 0x03ff0000 /* Backoff count (?) */
1402
1403
1404
1405/*
1406 * NAV register (current)
1407 */
1408#define AR5K_NAV_5210 0x808c
1409#define AR5K_NAV_5211 0x8084
1410#define AR5K_NAV (ah->ah_version == AR5K_AR5210 ? \
1411 AR5K_NAV_5210 : AR5K_NAV_5211)
1412
1413/*
1414 * RTS success register
1415 */
1416#define AR5K_RTS_OK_5210 0x8090
1417#define AR5K_RTS_OK_5211 0x8088
1418#define AR5K_RTS_OK (ah->ah_version == AR5K_AR5210 ? \
1419 AR5K_RTS_OK_5210 : AR5K_RTS_OK_5211)
1420
1421/*
1422 * RTS failure register
1423 */
1424#define AR5K_RTS_FAIL_5210 0x8094
1425#define AR5K_RTS_FAIL_5211 0x808c
1426#define AR5K_RTS_FAIL (ah->ah_version == AR5K_AR5210 ? \
1427 AR5K_RTS_FAIL_5210 : AR5K_RTS_FAIL_5211)
1428
1429/*
1430 * ACK failure register
1431 */
1432#define AR5K_ACK_FAIL_5210 0x8098
1433#define AR5K_ACK_FAIL_5211 0x8090
1434#define AR5K_ACK_FAIL (ah->ah_version == AR5K_AR5210 ? \
1435 AR5K_ACK_FAIL_5210 : AR5K_ACK_FAIL_5211)
1436
1437/*
1438 * FCS failure register
1439 */
1440#define AR5K_FCS_FAIL_5210 0x809c
1441#define AR5K_FCS_FAIL_5211 0x8094
1442#define AR5K_FCS_FAIL (ah->ah_version == AR5K_AR5210 ? \
1443 AR5K_FCS_FAIL_5210 : AR5K_FCS_FAIL_5211)
1444
1445/*
1446 * Beacon count register
1447 */
1448#define AR5K_BEACON_CNT_5210 0x80a0
1449#define AR5K_BEACON_CNT_5211 0x8098
1450#define AR5K_BEACON_CNT (ah->ah_version == AR5K_AR5210 ? \
1451 AR5K_BEACON_CNT_5210 : AR5K_BEACON_CNT_5211)
1452
1453
1454/*===5212 Specific PCU registers===*/
1455
1456/*
1457 * XR (eXtended Range) mode register
1458 */
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03001459#define AR5K_XRMODE 0x80c0 /* Register Address */
1460#define AR5K_XRMODE_POLL_TYPE_M 0x0000003f /* Mask for Poll type (?) */
Jiri Slabyfa1c1142007-08-12 17:33:16 +02001461#define AR5K_XRMODE_POLL_TYPE_S 0
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03001462#define AR5K_XRMODE_POLL_SUBTYPE_M 0x0000003c /* Mask for Poll subtype (?) */
Jiri Slabyfa1c1142007-08-12 17:33:16 +02001463#define AR5K_XRMODE_POLL_SUBTYPE_S 2
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03001464#define AR5K_XRMODE_POLL_WAIT_ALL 0x00000080 /* Wait for poll */
1465#define AR5K_XRMODE_SIFS_DELAY 0x000fff00 /* Mask for SIFS delay */
1466#define AR5K_XRMODE_FRAME_HOLD_M 0xfff00000 /* Mask for frame hold (?) */
Jiri Slabyfa1c1142007-08-12 17:33:16 +02001467#define AR5K_XRMODE_FRAME_HOLD_S 20
1468
1469/*
1470 * XR delay register
1471 */
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03001472#define AR5K_XRDELAY 0x80c4 /* Register Address */
1473#define AR5K_XRDELAY_SLOT_DELAY_M 0x0000ffff /* Mask for slot delay */
Jiri Slabyfa1c1142007-08-12 17:33:16 +02001474#define AR5K_XRDELAY_SLOT_DELAY_S 0
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03001475#define AR5K_XRDELAY_CHIRP_DELAY_M 0xffff0000 /* Mask for CHIRP data delay */
Jiri Slabyfa1c1142007-08-12 17:33:16 +02001476#define AR5K_XRDELAY_CHIRP_DELAY_S 16
1477
1478/*
1479 * XR timeout register
1480 */
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03001481#define AR5K_XRTIMEOUT 0x80c8 /* Register Address */
1482#define AR5K_XRTIMEOUT_CHIRP_M 0x0000ffff /* Mask for CHIRP timeout */
Jiri Slabyfa1c1142007-08-12 17:33:16 +02001483#define AR5K_XRTIMEOUT_CHIRP_S 0
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03001484#define AR5K_XRTIMEOUT_POLL_M 0xffff0000 /* Mask for Poll timeout */
Jiri Slabyfa1c1142007-08-12 17:33:16 +02001485#define AR5K_XRTIMEOUT_POLL_S 16
1486
1487/*
1488 * XR chirp register
1489 */
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03001490#define AR5K_XRCHIRP 0x80cc /* Register Address */
1491#define AR5K_XRCHIRP_SEND 0x00000001 /* Send CHIRP */
1492#define AR5K_XRCHIRP_GAP 0xffff0000 /* Mask for CHIRP gap (?) */
Jiri Slabyfa1c1142007-08-12 17:33:16 +02001493
1494/*
1495 * XR stomp register
1496 */
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03001497#define AR5K_XRSTOMP 0x80d0 /* Register Address */
1498#define AR5K_XRSTOMP_TX 0x00000001 /* Stomp Tx (?) */
1499#define AR5K_XRSTOMP_RX 0x00000002 /* Stomp Rx (?) */
1500#define AR5K_XRSTOMP_TX_RSSI 0x00000004 /* Stomp Tx RSSI (?) */
1501#define AR5K_XRSTOMP_TX_BSSID 0x00000008 /* Stomp Tx BSSID (?) */
1502#define AR5K_XRSTOMP_DATA 0x00000010 /* Stomp data (?)*/
1503#define AR5K_XRSTOMP_RSSI_THRES 0x0000ff00 /* Mask for XR RSSI threshold */
Jiri Slabyfa1c1142007-08-12 17:33:16 +02001504
1505/*
1506 * First enhanced sleep register
1507 */
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03001508#define AR5K_SLEEP0 0x80d4 /* Register Address */
1509#define AR5K_SLEEP0_NEXT_DTIM 0x0007ffff /* Mask for next DTIM (?) */
Jiri Slabyfa1c1142007-08-12 17:33:16 +02001510#define AR5K_SLEEP0_NEXT_DTIM_S 0
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03001511#define AR5K_SLEEP0_ASSUME_DTIM 0x00080000 /* Assume DTIM */
1512#define AR5K_SLEEP0_ENH_SLEEP_EN 0x00100000 /* Enable enchanced sleep control */
1513#define AR5K_SLEEP0_CABTO 0xff000000 /* Mask for CAB Time Out */
Jiri Slabyfa1c1142007-08-12 17:33:16 +02001514#define AR5K_SLEEP0_CABTO_S 24
1515
1516/*
1517 * Second enhanced sleep register
1518 */
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03001519#define AR5K_SLEEP1 0x80d8 /* Register Address */
1520#define AR5K_SLEEP1_NEXT_TIM 0x0007ffff /* Mask for next TIM (?) */
Jiri Slabyfa1c1142007-08-12 17:33:16 +02001521#define AR5K_SLEEP1_NEXT_TIM_S 0
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03001522#define AR5K_SLEEP1_BEACON_TO 0xff000000 /* Mask for Beacon Time Out */
Jiri Slabyfa1c1142007-08-12 17:33:16 +02001523#define AR5K_SLEEP1_BEACON_TO_S 24
1524
1525/*
1526 * Third enhanced sleep register
1527 */
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03001528#define AR5K_SLEEP2 0x80dc /* Register Address */
1529#define AR5K_SLEEP2_TIM_PER 0x0000ffff /* Mask for TIM period (?) */
Jiri Slabyfa1c1142007-08-12 17:33:16 +02001530#define AR5K_SLEEP2_TIM_PER_S 0
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03001531#define AR5K_SLEEP2_DTIM_PER 0xffff0000 /* Mask for DTIM period (?) */
Jiri Slabyfa1c1142007-08-12 17:33:16 +02001532#define AR5K_SLEEP2_DTIM_PER_S 16
1533
1534/*
1535 * BSSID mask registers
1536 */
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03001537#define AR5K_BSS_IDM0 0x80e0 /* Upper bits */
1538#define AR5K_BSS_IDM1 0x80e4 /* Lower bits */
Jiri Slabyfa1c1142007-08-12 17:33:16 +02001539
1540/*
1541 * TX power control (TPC) register
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03001542 *
1543 * XXX: PCDAC steps (0.5dbm) or DBM ?
1544 *
1545 * XXX: Mask changes for newer chips to 7f
1546 * like tx power table ?
Jiri Slabyfa1c1142007-08-12 17:33:16 +02001547 */
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03001548#define AR5K_TXPC 0x80e8 /* Register Address */
1549#define AR5K_TXPC_ACK_M 0x0000003f /* Mask for ACK tx power */
Jiri Slabyfa1c1142007-08-12 17:33:16 +02001550#define AR5K_TXPC_ACK_S 0
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03001551#define AR5K_TXPC_CTS_M 0x00003f00 /* Mask for CTS tx power */
Jiri Slabyfa1c1142007-08-12 17:33:16 +02001552#define AR5K_TXPC_CTS_S 8
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03001553#define AR5K_TXPC_CHIRP_M 0x003f0000 /* Mask for CHIRP tx power */
Jiri Slabyfa1c1142007-08-12 17:33:16 +02001554#define AR5K_TXPC_CHIRP_S 22
1555
1556/*
1557 * Profile count registers
1558 */
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03001559#define AR5K_PROFCNT_TX 0x80ec /* Tx count */
1560#define AR5K_PROFCNT_RX 0x80f0 /* Rx count */
1561#define AR5K_PROFCNT_RXCLR 0x80f4 /* Clear Rx count */
1562#define AR5K_PROFCNT_CYCLE 0x80f8 /* Cycle count (?) */
1563
1564/*
1565 * Quiet (period) control registers (?)
1566 */
1567#define AR5K_QUIET_CTL1 0x80fc /* Register Address */
1568#define AR5K_QUIET_CTL1_NEXT_QT 0x0000ffff /* Mask for next quiet (period?) (?) */
1569#define AR5K_QUIET_CTL1_QT_EN 0x00010000 /* Enable quiet (period?) */
1570#define AR5K_QUIET_CTL2 0x8100 /* Register Address */
1571#define AR5K_QUIET_CTL2_QT_PER 0x0000ffff /* Mask for quiet period (?) */
1572#define AR5K_QUIET_CTL2_QT_DUR 0xffff0000 /* Mask for quiet duration (?) */
Jiri Slabyfa1c1142007-08-12 17:33:16 +02001573
1574/*
1575 * TSF parameter register
1576 */
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03001577#define AR5K_TSF_PARM 0x8104 /* Register Address */
1578#define AR5K_TSF_PARM_INC_M 0x000000ff /* Mask for TSF increment */
Jiri Slabyfa1c1142007-08-12 17:33:16 +02001579#define AR5K_TSF_PARM_INC_S 0
1580
1581/*
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03001582 * QoS register (?)
1583 */
1584#define AR5K_QOS 0x8108 /* Register Address */
1585#define AR5K_QOS_NOACK_2BIT_VALUES 0x00000000 /* (field) */
1586#define AR5K_QOS_NOACK_BIT_OFFSET 0x00000020 /* (field) */
1587#define AR5K_QOS_NOACK_BYTE_OFFSET 0x00000080 /* (field) */
1588
1589/*
Jiri Slabyfa1c1142007-08-12 17:33:16 +02001590 * PHY error filter register
1591 */
1592#define AR5K_PHY_ERR_FIL 0x810c
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03001593#define AR5K_PHY_ERR_FIL_RADAR 0x00000020 /* Radar signal */
1594#define AR5K_PHY_ERR_FIL_OFDM 0x00020000 /* OFDM false detect (ANI) */
1595#define AR5K_PHY_ERR_FIL_CCK 0x02000000 /* CCK false detect (ANI) */
Jiri Slabyfa1c1142007-08-12 17:33:16 +02001596
1597/*
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03001598 * XR latency register
1599 */
1600#define AR5K_XRLAT_TX 0x8110
1601
1602/*
1603 * ACK SIFS register
1604 */
1605#define AR5K_ACKSIFS 0x8114 /* Register Address */
1606#define AR5K_ACKSIFS_INC 0x00000000 /* ACK SIFS Increment (field) */
1607
1608/*
1609 * MIC QoS control register (?)
1610 */
1611#define AR5K_MIC_QOS_CTL 0x8118 /* Register Address */
1612#define AR5K_MIC_QOS_CTL_0 0x00000001 /* MIC QoS control 0 (?) */
1613#define AR5K_MIC_QOS_CTL_1 0x00000004 /* MIC QoS control 1 (?) */
1614#define AR5K_MIC_QOS_CTL_2 0x00000010 /* MIC QoS control 2 (?) */
1615#define AR5K_MIC_QOS_CTL_3 0x00000040 /* MIC QoS control 3 (?) */
1616#define AR5K_MIC_QOS_CTL_4 0x00000100 /* MIC QoS control 4 (?) */
1617#define AR5K_MIC_QOS_CTL_5 0x00000400 /* MIC QoS control 5 (?) */
1618#define AR5K_MIC_QOS_CTL_6 0x00001000 /* MIC QoS control 6 (?) */
1619#define AR5K_MIC_QOS_CTL_7 0x00004000 /* MIC QoS control 7 (?) */
1620#define AR5K_MIC_QOS_CTL_MQ_EN 0x00010000 /* Enable MIC QoS */
1621
1622/*
1623 * MIC QoS select register (?)
1624 */
1625#define AR5K_MIC_QOS_SEL 0x811c
1626#define AR5K_MIC_QOS_SEL_0 0x00000001
1627#define AR5K_MIC_QOS_SEL_1 0x00000010
1628#define AR5K_MIC_QOS_SEL_2 0x00000100
1629#define AR5K_MIC_QOS_SEL_3 0x00001000
1630#define AR5K_MIC_QOS_SEL_4 0x00010000
1631#define AR5K_MIC_QOS_SEL_5 0x00100000
1632#define AR5K_MIC_QOS_SEL_6 0x01000000
1633#define AR5K_MIC_QOS_SEL_7 0x10000000
1634
1635/*
1636 * Misc mode control register (?)
1637 */
1638#define AR5K_MISC_MODE 0x8120 /* Register Address */
1639#define AR5K_MISC_MODE_FBSSID_MATCH 0x00000001 /* Force BSSID match */
1640#define AR5K_MISC_MODE_ACKSIFS_MEM 0x00000002 /* ACK SIFS memory (?) */
1641/* more bits */
1642
1643/*
1644 * OFDM Filter counter
1645 */
1646#define AR5K_OFDM_FIL_CNT 0x8124
1647
1648/*
1649 * CCK Filter counter
1650 */
1651#define AR5K_CCK_FIL_CNT 0x8128
1652
1653/*
1654 * PHY Error Counters (?)
1655 */
1656#define AR5K_PHYERR_CNT1 0x812c
1657#define AR5K_PHYERR_CNT1_MASK 0x8130
1658
1659#define AR5K_PHYERR_CNT2 0x8134
1660#define AR5K_PHYERR_CNT2_MASK 0x8138
1661
1662/*
1663 * TSF Threshold register (?)
1664 */
1665#define AR5K_TSF_THRES 0x813c
1666
1667/*
1668 * Rate -> ACK SIFS mapping table (32 entries)
1669 */
1670#define AR5K_RATE_ACKSIFS_BASE 0x8680 /* Register Address */
1671#define AR5K_RATE_ACKSIFS(_n) (AR5K_RATE_ACKSIFS_BSE + ((_n) << 2))
1672#define AR5K_RATE_ACKSIFS_NORMAL 0x00000001 /* Normal SIFS (field) */
1673#define AR5K_RATE_ACKSIFS_TURBO 0x00000400 /* Turbo SIFS (field) */
1674
1675/*
1676 * Rate -> duration mapping table (32 entries)
Jiri Slabyfa1c1142007-08-12 17:33:16 +02001677 */
1678#define AR5K_RATE_DUR_BASE 0x8700
1679#define AR5K_RATE_DUR(_n) (AR5K_RATE_DUR_BASE + ((_n) << 2))
1680
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03001681/*
1682 * Rate -> db mapping table
1683 * (8 entries, each one has 4 8bit fields)
1684 */
1685#define AR5K_RATE2DB_BASE 0x87c0
1686#define AR5K_RATE2DB(_n) (AR5K_RATE2DB_BASE + ((_n) << 2))
1687
1688/*
1689 * db -> Rate mapping table
1690 * (8 entries, each one has 4 8bit fields)
1691 */
1692#define AR5K_DB2RATE_BASE 0x87e0
1693#define AR5K_DB2RATE(_n) (AR5K_DB2RATE_BASE + ((_n) << 2))
1694
Jiri Slabyfa1c1142007-08-12 17:33:16 +02001695/*===5212 end===*/
1696
1697/*
1698 * Key table (WEP) register
1699 */
1700#define AR5K_KEYTABLE_0_5210 0x9000
1701#define AR5K_KEYTABLE_0_5211 0x8800
1702#define AR5K_KEYTABLE_5210(_n) (AR5K_KEYTABLE_0_5210 + ((_n) << 5))
1703#define AR5K_KEYTABLE_5211(_n) (AR5K_KEYTABLE_0_5211 + ((_n) << 5))
1704#define AR5K_KEYTABLE(_n) (ah->ah_version == AR5K_AR5210 ? \
1705 AR5K_KEYTABLE_5210(_n) : AR5K_KEYTABLE_5211(_n))
1706#define AR5K_KEYTABLE_OFF(_n, x) (AR5K_KEYTABLE(_n) + (x << 2))
1707#define AR5K_KEYTABLE_TYPE(_n) AR5K_KEYTABLE_OFF(_n, 5)
1708#define AR5K_KEYTABLE_TYPE_40 0x00000000
1709#define AR5K_KEYTABLE_TYPE_104 0x00000001
1710#define AR5K_KEYTABLE_TYPE_128 0x00000003
1711#define AR5K_KEYTABLE_TYPE_TKIP 0x00000004 /* [5212+] */
1712#define AR5K_KEYTABLE_TYPE_AES 0x00000005 /* [5211+] */
1713#define AR5K_KEYTABLE_TYPE_CCM 0x00000006 /* [5212+] */
1714#define AR5K_KEYTABLE_TYPE_NULL 0x00000007 /* [5211+] */
1715#define AR5K_KEYTABLE_ANTENNA 0x00000008 /* [5212+] */
1716#define AR5K_KEYTABLE_MAC0(_n) AR5K_KEYTABLE_OFF(_n, 6)
1717#define AR5K_KEYTABLE_MAC1(_n) AR5K_KEYTABLE_OFF(_n, 7)
1718#define AR5K_KEYTABLE_VALID 0x00008000
1719
1720/* WEP 40-bit = 40-bit entered key + 24 bit IV = 64-bit
1721 * WEP 104-bit = 104-bit entered key + 24-bit IV = 128-bit
1722 * WEP 128-bit = 128-bit entered key + 24 bit IV = 152-bit
1723 *
1724 * Some vendors have introduced bigger WEP keys to address
1725 * security vulnerabilities in WEP. This includes:
1726 *
1727 * WEP 232-bit = 232-bit entered key + 24 bit IV = 256-bit
1728 *
1729 * We can expand this if we find ar5k Atheros cards with a larger
1730 * key table size.
1731 */
1732#define AR5K_KEYTABLE_SIZE_5210 64
1733#define AR5K_KEYTABLE_SIZE_5211 128
1734#define AR5K_KEYTABLE_SIZE (ah->ah_version == AR5K_AR5210 ? \
1735 AR5K_KEYTABLE_SIZE_5210 : AR5K_KEYTABLE_SIZE_5211)
1736
1737
1738/*===PHY REGISTERS===*/
1739
1740/*
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03001741 * PHY registers start
Jiri Slabyfa1c1142007-08-12 17:33:16 +02001742 */
1743#define AR5K_PHY_BASE 0x9800
1744#define AR5K_PHY(_n) (AR5K_PHY_BASE + ((_n) << 2))
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03001745
1746/*
1747 * TST_2 (Misc config parameters)
1748 */
1749#define AR5K_PHY_TST2 0x9800 /* Register Address */
1750#define AR5K_PHY_TST2_TRIG_SEL 0x00000001 /* Trigger select (?) (field ?) */
1751#define AR5K_PHY_TST2_TRIG 0x00000010 /* Trigger (?) (field ?) */
1752#define AR5K_PHY_TST2_CBUS_MODE 0x00000100 /* Cardbus mode (?) */
1753/* bit reserved */
1754#define AR5K_PHY_TST2_CLK32 0x00000400 /* CLK_OUT is CLK32 (32Khz external) */
1755#define AR5K_PHY_TST2_CHANCOR_DUMP_EN 0x00000800 /* Enable Chancor dump (?) */
1756#define AR5K_PHY_TST2_EVEN_CHANCOR_DUMP 0x00001000 /* Even Chancor dump (?) */
1757#define AR5K_PHY_TST2_RFSILENT_EN 0x00002000 /* Enable RFSILENT */
1758#define AR5K_PHY_TST2_ALT_RFDATA 0x00004000 /* Alternate RFDATA (5-2GHz switch) */
1759#define AR5K_PHY_TST2_MINI_OBS_EN 0x00008000 /* Enable mini OBS (?) */
1760#define AR5K_PHY_TST2_RX2_IS_RX5_INV 0x00010000 /* 2GHz rx path is the 5GHz path inverted (?) */
1761#define AR5K_PHY_TST2_SLOW_CLK160 0x00020000 /* Slow CLK160 (?) */
1762#define AR5K_PHY_TST2_AGC_OBS_SEL_3 0x00040000 /* AGC OBS Select 3 (?) */
1763#define AR5K_PHY_TST2_BBB_OBS_SEL 0x00080000 /* BB OBS Select (field ?) */
1764#define AR5K_PHY_TST2_ADC_OBS_SEL 0x00800000 /* ADC OBS Select (field ?) */
1765#define AR5K_PHY_TST2_RX_CLR_SEL 0x08000000 /* RX Clear Select (?) */
1766#define AR5K_PHY_TST2_FORCE_AGC_CLR 0x10000000 /* Force AGC clear (?) */
1767#define AR5K_PHY_SHIFT_2GHZ 0x00004007 /* Used to access 2GHz radios */
1768#define AR5K_PHY_SHIFT_5GHZ 0x00000007 /* Used to access 5GHz radios (default) */
Jiri Slabyfa1c1142007-08-12 17:33:16 +02001769
1770/*
1771 * PHY frame control register [5110] /turbo mode register [5111+]
1772 *
1773 * There is another frame control register for [5111+]
1774 * at address 0x9944 (see below) but the 2 first flags
1775 * are common here between 5110 frame control register
1776 * and [5111+] turbo mode register, so this also works as
1777 * a "turbo mode register" for 5110. We treat this one as
1778 * a frame control register for 5110 below.
1779 */
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03001780#define AR5K_PHY_TURBO 0x9804 /* Register Address */
1781#define AR5K_PHY_TURBO_MODE 0x00000001 /* Enable turbo mode */
1782#define AR5K_PHY_TURBO_SHORT 0x00000002 /* Short mode (20Mhz channels) (?) */
Jiri Slabyfa1c1142007-08-12 17:33:16 +02001783
1784/*
1785 * PHY agility command register
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03001786 * (aka TST_1)
Jiri Slabyfa1c1142007-08-12 17:33:16 +02001787 */
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03001788#define AR5K_PHY_AGC 0x9808 /* Register Address */
1789#define AR5K_PHY_TST1 0x9808
1790#define AR5K_PHY_AGC_DISABLE 0x08000000 /* Disable AGC to A2 (?)*/
1791#define AR5K_PHY_TST1_TXHOLD 0x00003800 /* Set tx hold (?) */
Jiri Slabyfa1c1142007-08-12 17:33:16 +02001792
1793/*
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03001794 * PHY timing register 3 [5112+]
Jiri Slabyfa1c1142007-08-12 17:33:16 +02001795 */
1796#define AR5K_PHY_TIMING_3 0x9814
1797#define AR5K_PHY_TIMING_3_DSC_MAN 0xfffe0000
1798#define AR5K_PHY_TIMING_3_DSC_MAN_S 17
1799#define AR5K_PHY_TIMING_3_DSC_EXP 0x0001e000
1800#define AR5K_PHY_TIMING_3_DSC_EXP_S 13
1801
1802/*
1803 * PHY chip revision register
1804 */
1805#define AR5K_PHY_CHIP_ID 0x9818
1806
1807/*
1808 * PHY activation register
1809 */
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03001810#define AR5K_PHY_ACT 0x981c /* Register Address */
1811#define AR5K_PHY_ACT_ENABLE 0x00000001 /* Activate PHY */
1812#define AR5K_PHY_ACT_DISABLE 0x00000002 /* Deactivate PHY */
1813
1814/*
1815 * PHY RF control registers
1816 * (i think these are delay times,
1817 * these calibration values exist
1818 * in EEPROM)
1819 */
1820#define AR5K_PHY_RF_CTL2 0x9824 /* Register Address */
1821#define AR5K_PHY_RF_CTL2_TXF2TXD_START 0x0000000f /* Mask for TX frame to TX d(esc?) start */
1822
1823#define AR5K_PHY_RF_CTL3 0x9828 /* Register Address */
1824#define AR5K_PHY_RF_CTL3_TXE2XLNA_ON 0x0000000f /* Mask for TX end to XLNA on */
1825
1826#define AR5K_PHY_RF_CTL4 0x9834 /* Register Address */
1827#define AR5K_PHY_RF_CTL4_TXF2XPA_A_ON 0x00000001 /* TX frame to XPA A on (field) */
1828#define AR5K_PHY_RF_CTL4_TXF2XPA_B_ON 0x00000100 /* TX frame to XPA B on (field) */
1829#define AR5K_PHY_RF_CTL4_TXE2XPA_A_OFF 0x00010000 /* TX end to XPA A off (field) */
1830#define AR5K_PHY_RF_CTL4_TXE2XPA_B_OFF 0x01000000 /* TX end to XPA B off (field) */
1831
1832/*
1833 * Pre-Amplifier control register
1834 * (XPA -> external pre-amplifier)
1835 */
1836#define AR5K_PHY_PA_CTL 0x9838 /* Register Address */
1837#define AR5K_PHY_PA_CTL_XPA_A_HI 0x00000001 /* XPA A high (?) */
1838#define AR5K_PHY_PA_CTL_XPA_B_HI 0x00000002 /* XPA B high (?) */
1839#define AR5K_PHY_PA_CTL_XPA_A_EN 0x00000004 /* Enable XPA A */
1840#define AR5K_PHY_PA_CTL_XPA_B_EN 0x00000008 /* Enable XPA B */
1841
1842/*
1843 * PHY settling register
1844 */
1845#define AR5K_PHY_SETTLING 0x9844 /* Register Address */
1846#define AR5K_PHY_SETTLING_AGC 0x0000007f /* Mask for AGC settling time */
1847#define AR5K_PHY_SETTLING_SWITCH 0x00003f80 /* Mask for Switch settlig time */
1848
1849/*
1850 * PHY Gain registers
1851 */
1852#define AR5K_PHY_GAIN 0x9848 /* Register Address */
1853#define AR5K_PHY_GAIN_TXRX_ATTEN 0x0003f000 /* Mask for TX-RX Attenuation */
1854
1855#define AR5K_PHY_GAIN_OFFSET 0x984c /* Register Address */
1856#define AR5K_PHY_GAIN_OFFSET_RXTX_FLAG 0x00020000 /* RX-TX flag (?) */
1857
1858/*
Nick Kossifidisc6e387a2008-08-29 22:45:39 +03001859 * Desired ADC/PGA size register
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03001860 * (for more infos read ANI patent)
1861 */
1862#define AR5K_PHY_DESIRED_SIZE 0x9850 /* Register Address */
1863#define AR5K_PHY_DESIRED_SIZE_ADC 0x000000ff /* Mask for ADC desired size */
1864#define AR5K_PHY_DESIRED_SIZE_PGA 0x0000ff00 /* Mask for PGA desired size */
Nick Kossifidisc6e387a2008-08-29 22:45:39 +03001865#define AR5K_PHY_DESIRED_SIZE_TOT 0x0ff00000 /* Mask for Total desired size */
Jiri Slabyfa1c1142007-08-12 17:33:16 +02001866
1867/*
1868 * PHY signal register
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03001869 * (for more infos read ANI patent)
Jiri Slabyfa1c1142007-08-12 17:33:16 +02001870 */
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03001871#define AR5K_PHY_SIG 0x9858 /* Register Address */
1872#define AR5K_PHY_SIG_FIRSTEP 0x0003f000 /* Mask for FIRSTEP */
Jiri Slabyfa1c1142007-08-12 17:33:16 +02001873#define AR5K_PHY_SIG_FIRSTEP_S 12
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03001874#define AR5K_PHY_SIG_FIRPWR 0x03fc0000 /* Mask for FIPWR */
Jiri Slabyfa1c1142007-08-12 17:33:16 +02001875#define AR5K_PHY_SIG_FIRPWR_S 18
1876
1877/*
1878 * PHY coarse agility control register
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03001879 * (for more infos read ANI patent)
Jiri Slabyfa1c1142007-08-12 17:33:16 +02001880 */
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03001881#define AR5K_PHY_AGCCOARSE 0x985c /* Register Address */
1882#define AR5K_PHY_AGCCOARSE_LO 0x00007f80 /* Mask for AGC Coarse low */
Jiri Slabyfa1c1142007-08-12 17:33:16 +02001883#define AR5K_PHY_AGCCOARSE_LO_S 7
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03001884#define AR5K_PHY_AGCCOARSE_HI 0x003f8000 /* Mask for AGC Coarse high */
Jiri Slabyfa1c1142007-08-12 17:33:16 +02001885#define AR5K_PHY_AGCCOARSE_HI_S 15
1886
1887/*
1888 * PHY agility control register
1889 */
1890#define AR5K_PHY_AGCCTL 0x9860 /* Register address */
1891#define AR5K_PHY_AGCCTL_CAL 0x00000001 /* Enable PHY calibration */
1892#define AR5K_PHY_AGCCTL_NF 0x00000002 /* Enable Noise Floor calibration */
1893
1894/*
1895 * PHY noise floor status register
1896 */
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03001897#define AR5K_PHY_NF 0x9864 /* Register address */
1898#define AR5K_PHY_NF_M 0x000001ff /* Noise floor mask */
1899#define AR5K_PHY_NF_ACTIVE 0x00000100 /* Noise floor calibration still active */
Jiri Slabyfa1c1142007-08-12 17:33:16 +02001900#define AR5K_PHY_NF_RVAL(_n) (((_n) >> 19) & AR5K_PHY_NF_M)
1901#define AR5K_PHY_NF_AVAL(_n) (-((_n) ^ AR5K_PHY_NF_M) + 1)
1902#define AR5K_PHY_NF_SVAL(_n) (((_n) & AR5K_PHY_NF_M) | (1 << 9))
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03001903#define AR5K_PHY_NF_THRESH62 0x00001000 /* Thresh62 -check ANI patent- (field) */
Jiri Slabyfa1c1142007-08-12 17:33:16 +02001904
1905/*
1906 * PHY ADC saturation register [5110]
1907 */
1908#define AR5K_PHY_ADCSAT 0x9868
1909#define AR5K_PHY_ADCSAT_ICNT 0x0001f800
1910#define AR5K_PHY_ADCSAT_ICNT_S 11
1911#define AR5K_PHY_ADCSAT_THR 0x000007e0
1912#define AR5K_PHY_ADCSAT_THR_S 5
1913
1914/*
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03001915 * PHY Weak ofdm signal detection threshold registers (ANI) [5212+]
1916 */
1917
1918/* High thresholds */
1919#define AR5K_PHY_WEAK_OFDM_HIGH_THR 0x9868
1920#define AR5K_PHY_WEAK_OFDM_HIGH_THR_M2_COUNT 0x0000001f
1921#define AR5K_PHY_WEAK_OFDM_HIGH_THR_M2_COUNT_S 0
1922#define AR5K_PHY_WEAK_OFDM_HIGH_THR_M1 0x00fe0000
1923#define AR5K_PHY_WEAK_OFDM_HIGH_THR_M1_S 17
1924#define AR5K_PHY_WEAK_OFDM_HIGH_THR_M2 0x7f000000
1925#define AR5K_PHY_WEAK_OFDM_HIGH_THR_M2_S 24
1926
1927/* Low thresholds */
1928#define AR5K_PHY_WEAK_OFDM_LOW_THR 0x986c
1929#define AR5K_PHY_WEAK_OFDM_LOW_THR_SELFCOR_EN 0x00000001
1930#define AR5K_PHY_WEAK_OFDM_LOW_THR_M2_COUNT 0x00003f00
1931#define AR5K_PHY_WEAK_OFDM_LOW_THR_M2_COUNT_S 8
1932#define AR5K_PHY_WEAK_OFDM_LOW_THR_M1 0x001fc000
1933#define AR5K_PHY_WEAK_OFDM_LOW_THR_M1_S 14
1934#define AR5K_PHY_WEAK_OFDM_LOW_THR_M2 0x0fe00000
1935#define AR5K_PHY_WEAK_OFDM_LOW_THR_M2_S 21
1936
1937
1938/*
Jiri Slabyfa1c1142007-08-12 17:33:16 +02001939 * PHY sleep registers [5112+]
1940 */
1941#define AR5K_PHY_SCR 0x9870
1942#define AR5K_PHY_SCR_32MHZ 0x0000001f
1943#define AR5K_PHY_SLMT 0x9874
1944#define AR5K_PHY_SLMT_32MHZ 0x0000007f
1945#define AR5K_PHY_SCAL 0x9878
1946#define AR5K_PHY_SCAL_32MHZ 0x0000000e
1947
1948/*
1949 * PHY PLL (Phase Locked Loop) control register
1950 */
1951#define AR5K_PHY_PLL 0x987c
1952#define AR5K_PHY_PLL_20MHZ 0x13 /* For half rate (?) [5111+] */
1953#define AR5K_PHY_PLL_40MHZ_5211 0x18 /* For 802.11a */
1954#define AR5K_PHY_PLL_40MHZ_5212 0x000000aa
1955#define AR5K_PHY_PLL_40MHZ (ah->ah_version == AR5K_AR5211 ? \
1956 AR5K_PHY_PLL_40MHZ_5211 : AR5K_PHY_PLL_40MHZ_5212)
1957#define AR5K_PHY_PLL_44MHZ_5211 0x19 /* For 802.11b/g */
1958#define AR5K_PHY_PLL_44MHZ_5212 0x000000ab
1959#define AR5K_PHY_PLL_44MHZ (ah->ah_version == AR5K_AR5211 ? \
1960 AR5K_PHY_PLL_44MHZ_5211 : AR5K_PHY_PLL_44MHZ_5212)
1961#define AR5K_PHY_PLL_RF5111 0x00000000
1962#define AR5K_PHY_PLL_RF5112 0x00000040
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03001963#define AR5K_PHY_PLL_HALF_RATE 0x00000100
1964#define AR5K_PHY_PLL_QUARTER_RATE 0x00000200
Jiri Slabyfa1c1142007-08-12 17:33:16 +02001965
1966/*
1967 * RF Buffer register
1968 *
1969 * There are some special control registers on the RF chip
1970 * that hold various operation settings related mostly to
1971 * the analog parts (channel, gain adjustment etc).
1972 *
1973 * We don't write on those registers directly but
1974 * we send a data packet on the buffer register and
1975 * then write on another special register to notify hw
1976 * to apply the settings. This is done so that control registers
1977 * can be dynamicaly programmed during operation and the settings
1978 * are applied faster on the hw.
1979 *
1980 * We sent such data packets during rf initialization and channel change
1981 * through ath5k_hw_rf*_rfregs and ath5k_hw_rf*_channel functions.
1982 *
1983 * The data packets we send during initializadion are inside ath5k_ini_rf
1984 * struct (see ath5k_hw.h) and each one is related to an "rf register bank".
1985 * We use *rfregs functions to modify them acording to current operation
1986 * mode and eeprom values and pass them all together to the chip.
1987 *
1988 * It's obvious from the code that 0x989c is the buffer register but
1989 * for the other special registers that we write to after sending each
1990 * packet, i have no idea. So i'll name them BUFFER_CONTROL_X registers
1991 * for now. It's interesting that they are also used for some other operations.
1992 *
1993 * Also check out hw.h and U.S. Patent 6677779 B1 (about buffer
1994 * registers and control registers):
1995 *
1996 * http://www.google.com/patents?id=qNURAAAAEBAJ
1997 */
1998
1999#define AR5K_RF_BUFFER 0x989c
2000#define AR5K_RF_BUFFER_CONTROL_0 0x98c0 /* Channel on 5110 */
2001#define AR5K_RF_BUFFER_CONTROL_1 0x98c4 /* Bank 7 on 5112 */
2002#define AR5K_RF_BUFFER_CONTROL_2 0x98cc /* Bank 7 on 5111 */
2003
2004#define AR5K_RF_BUFFER_CONTROL_3 0x98d0 /* Bank 2 on 5112 */
2005 /* Channel set on 5111 */
2006 /* Used to read radio revision*/
2007
2008#define AR5K_RF_BUFFER_CONTROL_4 0x98d4 /* RF Stage register on 5110 */
2009 /* Bank 0,1,2,6 on 5111 */
2010 /* Bank 1 on 5112 */
2011 /* Used during activation on 5111 */
2012
2013#define AR5K_RF_BUFFER_CONTROL_5 0x98d8 /* Bank 3 on 5111 */
2014 /* Used during activation on 5111 */
2015 /* Channel on 5112 */
2016 /* Bank 6 on 5112 */
2017
2018#define AR5K_RF_BUFFER_CONTROL_6 0x98dc /* Bank 3 on 5112 */
2019
2020/*
2021 * PHY RF stage register [5210]
2022 */
2023#define AR5K_PHY_RFSTG 0x98d4
2024#define AR5K_PHY_RFSTG_DISABLE 0x00000021
2025
2026/*
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03002027 * PHY Antenna control register
Jiri Slabyfa1c1142007-08-12 17:33:16 +02002028 */
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03002029#define AR5K_PHY_ANT_CTL 0x9910 /* Register Address */
2030#define AR5K_PHY_ANT_CTL_TXRX_EN 0x00000001 /* Enable TX/RX (?) */
2031#define AR5K_PHY_ANT_CTL_SECTORED_ANT 0x00000004 /* Sectored Antenna */
2032#define AR5K_PHY_ANT_CTL_HITUNE5 0x00000008 /* Hitune5 (?) */
2033#define AR5K_PHY_ANT_CTL_SWTABLE_IDLE 0x00000010 /* Switch table idle (?) */
Jiri Slabyfa1c1142007-08-12 17:33:16 +02002034
2035/*
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03002036 * PHY receiver delay register [5111+]
Jiri Slabyfa1c1142007-08-12 17:33:16 +02002037 */
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03002038#define AR5K_PHY_RX_DELAY 0x9914 /* Register Address */
2039#define AR5K_PHY_RX_DELAY_M 0x00003fff /* Mask for RX activate to receive delay (/100ns) */
2040
2041/*
2042 * PHY max rx length register (?) [5111]
2043 */
2044#define AR5K_PHY_MAX_RX_LEN 0x991c
2045
2046/*
2047 * PHY timing register 4
2048 * I(nphase)/Q(adrature) calibration register [5111+]
2049 */
2050#define AR5K_PHY_IQ 0x9920 /* Register Address */
Jiri Slabyfa1c1142007-08-12 17:33:16 +02002051#define AR5K_PHY_IQ_CORR_Q_Q_COFF 0x0000001f /* Mask for q correction info */
2052#define AR5K_PHY_IQ_CORR_Q_I_COFF 0x000007e0 /* Mask for i correction info */
2053#define AR5K_PHY_IQ_CORR_Q_I_COFF_S 5
2054#define AR5K_PHY_IQ_CORR_ENABLE 0x00000800 /* Enable i/q correction */
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03002055#define AR5K_PHY_IQ_CAL_NUM_LOG_MAX 0x0000f000 /* Mask for max number of samples in log scale */
Jiri Slabyfa1c1142007-08-12 17:33:16 +02002056#define AR5K_PHY_IQ_CAL_NUM_LOG_MAX_S 12
2057#define AR5K_PHY_IQ_RUN 0x00010000 /* Run i/q calibration */
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03002058#define AR5K_PHY_IQ_USE_PT_DF 0x00020000 /* Use pilot track df (?) */
2059#define AR5K_PHY_IQ_EARLY_TRIG_THR 0x00200000 /* Early trigger threshold (?) (field) */
2060#define AR5K_PHY_IQ_PILOT_MASK_EN 0x10000000 /* Enable pilot mask (?) */
2061#define AR5K_PHY_IQ_CHAN_MASK_EN 0x20000000 /* Enable channel mask (?) */
2062#define AR5K_PHY_IQ_SPUR_FILT_EN 0x40000000 /* Enable spur filter */
2063#define AR5K_PHY_IQ_SPUR_RSSI_EN 0x80000000 /* Enable spur rssi */
Jiri Slabyfa1c1142007-08-12 17:33:16 +02002064
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03002065/*
2066 * PHY timing register 5
2067 * OFDM Self-correlator Cyclic RSSI threshold params
2068 * (Check out bb_cycpwr_thr1 on ANI patent)
2069 */
2070#define AR5K_PHY_OFDM_SELFCORR 0x9924 /* Register Address */
2071#define AR5K_PHY_OFDM_SELFCORR_CYPWR_THR1_EN 0x00000001 /* Enable cyclic RSSI thr 1 */
2072#define AR5K_PHY_OFDM_SELFCORR_CYPWR_THR1 0x000000fe /* Mask for Cyclic RSSI threshold 1 */
2073#define AR5K_PHY_OFDM_SELFCORR_CYPWR_THR3 0x00000100 /* Cyclic RSSI threshold 3 (field) (?) */
2074#define AR5K_PHY_OFDM_SELFCORR_RSSI_1ATHR_EN 0x00008000 /* Enable 1A RSSI threshold (?) */
2075#define AR5K_PHY_OFDM_SELFCORR_RSSI_1ATHR 0x00010000 /* 1A RSSI threshold (field) (?) */
2076#define AR5K_PHY_OFDM_SELFCORR_LSCTHR_HIRSSI 0x00800000 /* Long sc threshold hi rssi (?) */
2077
2078/*
2079 * PHY-only warm reset register
2080 */
2081#define AR5K_PHY_WARM_RESET 0x9928
2082
2083/*
2084 * PHY-only control register
2085 */
2086#define AR5K_PHY_CTL 0x992c /* Register Address */
2087#define AR5K_PHY_CTL_RX_DRAIN_RATE 0x00000001 /* RX drain rate (?) */
2088#define AR5K_PHY_CTL_LATE_TX_SIG_SYM 0x00000002 /* Late tx signal symbol (?) */
2089#define AR5K_PHY_CTL_GEN_SCRAMBLER 0x00000004 /* Generate scrambler */
2090#define AR5K_PHY_CTL_TX_ANT_SEL 0x00000008 /* TX antenna select */
2091#define AR5K_PHY_CTL_TX_ANT_STATIC 0x00000010 /* Static TX antenna */
2092#define AR5K_PHY_CTL_RX_ANT_SEL 0x00000020 /* RX antenna select */
2093#define AR5K_PHY_CTL_RX_ANT_STATIC 0x00000040 /* Static RX antenna */
2094#define AR5K_PHY_CTL_LOW_FREQ_SLE_EN 0x00000080 /* Enable low freq sleep */
Jiri Slabyfa1c1142007-08-12 17:33:16 +02002095
2096/*
2097 * PHY PAPD probe register [5111+ (?)]
2098 * Is this only present in 5212 ?
2099 * Because it's always 0 in 5211 initialization code
2100 */
2101#define AR5K_PHY_PAPD_PROBE 0x9930
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03002102#define AR5K_PHY_PAPD_PROBE_SH_HI_PAR 0x00000001
2103#define AR5K_PHY_PAPD_PROBE_PCDAC_BIAS 0x00000002
2104#define AR5K_PHY_PAPD_PROBE_COMP_GAIN 0x00000040
Jiri Slabyfa1c1142007-08-12 17:33:16 +02002105#define AR5K_PHY_PAPD_PROBE_TXPOWER 0x00007e00
2106#define AR5K_PHY_PAPD_PROBE_TXPOWER_S 9
2107#define AR5K_PHY_PAPD_PROBE_TX_NEXT 0x00008000
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03002108#define AR5K_PHY_PAPD_PROBE_PREDIST_EN 0x00010000
Jiri Slabyfa1c1142007-08-12 17:33:16 +02002109#define AR5K_PHY_PAPD_PROBE_TYPE 0x01800000 /* [5112+] */
2110#define AR5K_PHY_PAPD_PROBE_TYPE_S 23
2111#define AR5K_PHY_PAPD_PROBE_TYPE_OFDM 0
2112#define AR5K_PHY_PAPD_PROBE_TYPE_XR 1
2113#define AR5K_PHY_PAPD_PROBE_TYPE_CCK 2
2114#define AR5K_PHY_PAPD_PROBE_GAINF 0xfe000000
2115#define AR5K_PHY_PAPD_PROBE_GAINF_S 25
2116#define AR5K_PHY_PAPD_PROBE_INI_5111 0x00004883 /* [5212+] */
2117#define AR5K_PHY_PAPD_PROBE_INI_5112 0x00004882 /* [5212+] */
2118
2119
2120/*
2121 * PHY TX rate power registers [5112+]
2122 */
2123#define AR5K_PHY_TXPOWER_RATE1 0x9934
2124#define AR5K_PHY_TXPOWER_RATE2 0x9938
2125#define AR5K_PHY_TXPOWER_RATE_MAX 0x993c
2126#define AR5K_PHY_TXPOWER_RATE_MAX_TPC_ENABLE 0x00000040
2127#define AR5K_PHY_TXPOWER_RATE3 0xa234
2128#define AR5K_PHY_TXPOWER_RATE4 0xa238
2129
2130/*
2131 * PHY frame control register [5111+]
2132 */
2133#define AR5K_PHY_FRAME_CTL_5210 0x9804
2134#define AR5K_PHY_FRAME_CTL_5211 0x9944
2135#define AR5K_PHY_FRAME_CTL (ah->ah_version == AR5K_AR5210 ? \
2136 AR5K_PHY_FRAME_CTL_5210 : AR5K_PHY_FRAME_CTL_5211)
2137/*---[5111+]---*/
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03002138#define AR5K_PHY_FRAME_CTL_TX_CLIP 0x00000038 /* Mask for tx clip (?) */
Jiri Slabyfa1c1142007-08-12 17:33:16 +02002139#define AR5K_PHY_FRAME_CTL_TX_CLIP_S 3
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03002140#define AR5K_PHY_FRAME_CTL_PREP_CHINFO 0x00010000 /* Prepend chan info */
Jiri Slabyfa1c1142007-08-12 17:33:16 +02002141/*---[5110/5111]---*/
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03002142#define AR5K_PHY_FRAME_CTL_TIMING_ERR 0x01000000 /* PHY timing error */
2143#define AR5K_PHY_FRAME_CTL_PARITY_ERR 0x02000000 /* Parity error */
2144#define AR5K_PHY_FRAME_CTL_ILLRATE_ERR 0x04000000 /* Illegal rate */
2145#define AR5K_PHY_FRAME_CTL_ILLLEN_ERR 0x08000000 /* Illegal length */
Jiri Slabyfa1c1142007-08-12 17:33:16 +02002146#define AR5K_PHY_FRAME_CTL_SERVICE_ERR 0x20000000
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03002147#define AR5K_PHY_FRAME_CTL_TXURN_ERR 0x40000000 /* TX underrun */
Jiri Slabyfa1c1142007-08-12 17:33:16 +02002148#define AR5K_PHY_FRAME_CTL_INI AR5K_PHY_FRAME_CTL_SERVICE_ERR | \
2149 AR5K_PHY_FRAME_CTL_TXURN_ERR | \
2150 AR5K_PHY_FRAME_CTL_ILLLEN_ERR | \
2151 AR5K_PHY_FRAME_CTL_ILLRATE_ERR | \
2152 AR5K_PHY_FRAME_CTL_PARITY_ERR | \
2153 AR5K_PHY_FRAME_CTL_TIMING_ERR
2154
2155/*
2156 * PHY radar detection register [5111+]
2157 */
2158#define AR5K_PHY_RADAR 0x9954
2159
2160/* Radar enable ........ ........ ........ .......1 */
2161#define AR5K_PHY_RADAR_ENABLE 0x00000001
2162#define AR5K_PHY_RADAR_DISABLE 0x00000000
2163#define AR5K_PHY_RADAR_ENABLE_S 0
2164
2165/* This is the value found on the card .1.111.1 .1.1.... 111....1 1...1...
2166at power on. */
2167#define AR5K_PHY_RADAR_PWONDEF_AR5213 0x5d50e188
2168
2169/* This is the value found on the card .1.1.111 ..11...1 .1...1.1 1...11.1
2170after DFS is enabled */
2171#define AR5K_PHY_RADAR_ENABLED_AR5213 0x5731458d
2172
2173/* Finite Impulse Response (FIR) filter .1111111 ........ ........ ........
2174 * power out threshold.
2175 * 7-bits, standard power range {0..127} in 1/2 dBm units. */
2176#define AR5K_PHY_RADAR_FIRPWROUTTHR 0x7f000000
2177#define AR5K_PHY_RADAR_FIRPWROUTTHR_S 24
2178
2179/* Radar RSSI/SNR threshold. ........ 111111.. ........ ........
2180 * 6-bits, dBm range {0..63} in dBm units. */
2181#define AR5K_PHY_RADAR_RADARRSSITHR 0x00fc0000
2182#define AR5K_PHY_RADAR_RADARRSSITHR_S 18
2183
2184/* Pulse height threshold ........ ......11 1111.... ........
2185 * 6-bits, dBm range {0..63} in dBm units. */
2186#define AR5K_PHY_RADAR_PULSEHEIGHTTHR 0x0003f000
2187#define AR5K_PHY_RADAR_PULSEHEIGHTTHR_S 12
2188
2189/* Pulse RSSI/SNR threshold ........ ........ ....1111 11......
2190 * 6-bits, dBm range {0..63} in dBm units. */
2191#define AR5K_PHY_RADAR_PULSERSSITHR 0x00000fc0
2192#define AR5K_PHY_RADAR_PULSERSSITHR_S 6
2193
2194/* Inband threshold ........ ........ ........ ..11111.
2195 * 5-bits, units unknown {0..31} (? MHz ?) */
2196#define AR5K_PHY_RADAR_INBANDTHR 0x0000003e
2197#define AR5K_PHY_RADAR_INBANDTHR_S 1
2198
2199/*
2200 * PHY antenna switch table registers [5110]
2201 */
2202#define AR5K_PHY_ANT_SWITCH_TABLE_0 0x9960
2203#define AR5K_PHY_ANT_SWITCH_TABLE_1 0x9964
2204
2205/*
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03002206 * PHY Noise floor threshold
2207 */
2208#define AR5K_PHY_NFTHRES 0x9968
2209
2210/*
Jiri Slabyfa1c1142007-08-12 17:33:16 +02002211 * PHY clock sleep registers [5112+]
2212 */
2213#define AR5K_PHY_SCLOCK 0x99f0
2214#define AR5K_PHY_SCLOCK_32MHZ 0x0000000c
2215#define AR5K_PHY_SDELAY 0x99f4
2216#define AR5K_PHY_SDELAY_32MHZ 0x000000ff
2217#define AR5K_PHY_SPENDING 0x99f8
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03002218#define AR5K_PHY_SPENDING_14 0x00000014
2219#define AR5K_PHY_SPENDING_18 0x00000018
Jiri Slabyfa1c1142007-08-12 17:33:16 +02002220#define AR5K_PHY_SPENDING_RF5111 0x00000018
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03002221#define AR5K_PHY_SPENDING_RF5112 0x00000014
2222/* #define AR5K_PHY_SPENDING_RF5112A 0x0000000e */
2223/* #define AR5K_PHY_SPENDING_RF5424 0x00000012 */
2224#define AR5K_PHY_SPENDING_RF5413 0x00000014
2225#define AR5K_PHY_SPENDING_RF2413 0x00000014
2226#define AR5K_PHY_SPENDING_RF2425 0x00000018
Jiri Slabyfa1c1142007-08-12 17:33:16 +02002227
2228/*
2229 * Misc PHY/radio registers [5110 - 5111]
2230 */
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03002231#define AR5K_BB_GAIN_BASE 0x9b00 /* BaseBand Amplifier Gain table base address */
Jiri Slabyfa1c1142007-08-12 17:33:16 +02002232#define AR5K_BB_GAIN(_n) (AR5K_BB_GAIN_BASE + ((_n) << 2))
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03002233#define AR5K_RF_GAIN_BASE 0x9a00 /* RF Amplrifier Gain table base address */
Jiri Slabyfa1c1142007-08-12 17:33:16 +02002234#define AR5K_RF_GAIN(_n) (AR5K_RF_GAIN_BASE + ((_n) << 2))
2235
2236/*
2237 * PHY timing IQ calibration result register [5111+]
2238 */
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03002239#define AR5K_PHY_IQRES_CAL_PWR_I 0x9c10 /* I (Inphase) power value */
2240#define AR5K_PHY_IQRES_CAL_PWR_Q 0x9c14 /* Q (Quadrature) power value */
Jiri Slabyfa1c1142007-08-12 17:33:16 +02002241#define AR5K_PHY_IQRES_CAL_CORR 0x9c18 /* I/Q Correlation */
2242
2243/*
2244 * PHY current RSSI register [5111+]
2245 */
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03002246#define AR5K_PHY_CURRENT_RSSI 0x9c1c
2247
2248/*
2249 * PHY RF Bus grant register (?)
2250 */
2251#define AR5K_PHY_RFBUS_GRANT 0x9c20
2252
2253/*
2254 * PHY ADC test register
2255 */
2256#define AR5K_PHY_ADC_TEST 0x9c24
2257#define AR5K_PHY_ADC_TEST_I 0x00000001
2258#define AR5K_PHY_ADC_TEST_Q 0x00000200
2259
2260/*
2261 * PHY DAC test register
2262 */
2263#define AR5K_PHY_DAC_TEST 0x9c28
2264#define AR5K_PHY_DAC_TEST_I 0x00000001
2265#define AR5K_PHY_DAC_TEST_Q 0x00000200
2266
2267/*
2268 * PHY PTAT register (?)
2269 */
2270#define AR5K_PHY_PTAT 0x9c2c
2271
2272/*
2273 * PHY Illegal TX rate register [5112+]
2274 */
2275#define AR5K_PHY_BAD_TX_RATE 0x9c30
2276
2277/*
2278 * PHY SPUR Power register [5112+]
2279 */
2280#define AR5K_PHY_SPUR_PWR 0x9c34 /* Register Address */
2281#define AR5K_PHY_SPUR_PWR_I 0x00000001 /* SPUR Power estimate for I (field) */
2282#define AR5K_PHY_SPUR_PWR_Q 0x00000100 /* SPUR Power estimate for Q (field) */
2283#define AR5K_PHY_SPUR_PWR_FILT 0x00010000 /* Power with SPUR removed (field) */
2284
2285/*
2286 * PHY Channel status register [5112+] (?)
2287 */
2288#define AR5K_PHY_CHAN_STATUS 0x9c38
2289#define AR5K_PHY_CHAN_STATUS_BT_ACT 0x00000001
2290#define AR5K_PHY_CHAN_STATUS_RX_CLR_RAW 0x00000002
2291#define AR5K_PHY_CHAN_STATUS_RX_CLR_MAC 0x00000004
2292#define AR5K_PHY_CHAN_STATUS_RX_CLR_PAP 0x00000008
2293
2294/*
2295 * PHY PAPD I (power?) table (?)
2296 * (92! entries)
2297 */
2298#define AR5K_PHY_PAPD_I_BASE 0xa000
2299#define AR5K_PHY_PAPD_I(_n) (AR5K_PHY_PAPD_I_BASE + ((_n) << 2))
Jiri Slabyfa1c1142007-08-12 17:33:16 +02002300
2301/*
2302 * PHY PCDAC TX power table
2303 */
2304#define AR5K_PHY_PCDAC_TXPOWER_BASE_5211 0xa180
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03002305#define AR5K_PHY_PCDAC_TXPOWER_BASE_2413 0xa280
2306#define AR5K_PHY_PCDAC_TXPOWER_BASE (ah->ah_radio >= AR5K_RF2413 ? \
2307 AR5K_PHY_PCDAC_TXPOWER_BASE_2413 :\
Jiri Slabyfa1c1142007-08-12 17:33:16 +02002308 AR5K_PHY_PCDAC_TXPOWER_BASE_5211)
2309#define AR5K_PHY_PCDAC_TXPOWER(_n) (AR5K_PHY_PCDAC_TXPOWER_BASE + ((_n) << 2))
2310
2311/*
2312 * PHY mode register [5111+]
2313 */
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03002314#define AR5K_PHY_MODE 0x0a200 /* Register Address */
2315#define AR5K_PHY_MODE_MOD 0x00000001 /* PHY Modulation bit */
Jiri Slabyfa1c1142007-08-12 17:33:16 +02002316#define AR5K_PHY_MODE_MOD_OFDM 0
2317#define AR5K_PHY_MODE_MOD_CCK 1
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03002318#define AR5K_PHY_MODE_FREQ 0x00000002 /* Freq mode bit */
Jiri Slabyfa1c1142007-08-12 17:33:16 +02002319#define AR5K_PHY_MODE_FREQ_5GHZ 0
2320#define AR5K_PHY_MODE_FREQ_2GHZ 2
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03002321#define AR5K_PHY_MODE_MOD_DYN 0x00000004 /* Enable Dynamic OFDM/CCK mode [5112+] */
Jiri Slabyfa1c1142007-08-12 17:33:16 +02002322#define AR5K_PHY_MODE_RAD 0x00000008 /* [5212+] */
2323#define AR5K_PHY_MODE_RAD_RF5111 0
2324#define AR5K_PHY_MODE_RAD_RF5112 8
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03002325#define AR5K_PHY_MODE_XR 0x00000010 /* Enable XR mode [5112+] */
2326#define AR5K_PHY_MODE_HALF_RATE 0x00000020 /* Enable Half rate (test) */
2327#define AR5K_PHY_MODE_QUARTER_RATE 0x00000040 /* Enable Quarter rat (test) */
Jiri Slabyfa1c1142007-08-12 17:33:16 +02002328
2329/*
2330 * PHY CCK transmit control register [5111+ (?)]
2331 */
2332#define AR5K_PHY_CCKTXCTL 0xa204
2333#define AR5K_PHY_CCKTXCTL_WORLD 0x00000000
2334#define AR5K_PHY_CCKTXCTL_JAPAN 0x00000010
Nick Kossifidis0bacdf32008-07-30 13:18:59 +03002335#define AR5K_PHY_CCKTXCTL_SCRAMBLER_DIS 0x00000001
2336#define AR5K_PHY_CCKTXCTK_DAC_SCALE 0x00000004
2337
2338/*
2339 * PHY CCK Cross-correlator Barker RSSI threshold register [5212+]
2340 */
2341#define AR5K_PHY_CCK_CROSSCORR 0xa208
2342#define AR5K_PHY_CCK_CROSSCORR_WEAK_SIG_THR 0x0000000f
2343#define AR5K_PHY_CCK_CROSSCORR_WEAK_SIG_THR_S 0
Jiri Slabyfa1c1142007-08-12 17:33:16 +02002344
2345/*
2346 * PHY 2GHz gain register [5111+]
2347 */
2348#define AR5K_PHY_GAIN_2GHZ 0xa20c
2349#define AR5K_PHY_GAIN_2GHZ_MARGIN_TXRX 0x00fc0000
2350#define AR5K_PHY_GAIN_2GHZ_MARGIN_TXRX_S 18
2351#define AR5K_PHY_GAIN_2GHZ_INI_5111 0x6480416c