Home | History | Annotate | Line # | Download | only in ic
atwreg.h revision 1.5
      1 /*	$NetBSD: atwreg.h,v 1.5 2004/01/29 09:53:18 dyoung Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 2003 The NetBSD Foundation, Inc.  All rights reserved.
      5  *
      6  * This code is derived from software contributed to The NetBSD Foundation
      7  * by David Young.
      8  *
      9  * Redistribution and use in source and binary forms, with or without
     10  * modification, are permitted provided that the following conditions
     11  * are met:
     12  * 1. Redistributions of source code must retain the above copyright
     13  *    notice, this list of conditions and the following disclaimer.
     14  * 2. Redistributions in binary form must reproduce the above copyright
     15  *    notice, this list of conditions and the following disclaimer in the
     16  *    documentation and/or other materials provided with the distribution.
     17  * 3. All advertising materials mentioning features or use of this software
     18  *    must display the following acknowledgement:
     19  *	This product includes software developed by the NetBSD
     20  *	Foundation, Inc. and its contributors.
     21  * 4. Neither the name of the author nor the names of any co-contributors
     22  *    may be used to endorse or promote products derived from this software
     23  *    without specific prior written permission.
     24  *
     25  * THIS SOFTWARE IS PROVIDED BY David Young AND CONTRIBUTORS ``AS IS'' AND
     26  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     27  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     28  * ARE DISCLAIMED.  IN NO EVENT SHALL David Young
     29  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     31  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     32  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     33  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     34  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
     35  * THE POSSIBILITY OF SUCH DAMAGE.
     36  */
     37 
     38 /* glossary */
     39 
     40 /* DTIM   Delivery Traffic Indication Map, sent by AP
     41  * ATIM   Ad Hoc Traffic Indication Map
     42  * TU     1024 microseconds
     43  * TSF    time synchronization function
     44  * TBTT   target beacon transmission time
     45  * DIFS   distributed inter-frame space
     46  * SIFS   short inter-frame space
     47  * EIFS   extended inter-frame space
     48  */
     49 
     50 /* Macros for bit twiddling. */
     51 
     52 #ifndef _BIT_TWIDDLE
     53 #define _BIT_TWIDDLE
     54 /* nth bit, BIT(0) == 0x1. */
     55 #define BIT(n) (((n) == 32) ? 0 : ((u_int32_t) 1 << (n)))
     56 
     57 /* bits m through n, m < n. */
     58 #define BITS(m, n) ((BIT(MAX((m), (n)) + 1) - 1) ^ (BIT(MIN((m), (n))) - 1))
     59 
     60 /* find least significant bit that is set */
     61 #define LOWEST_SET_BIT(x) ((((x) - 1) & (x)) ^ (x))
     62 
     63 /* for x a power of two and p a non-negative integer, is x a greater power than 2**p? */
     64 #define GTEQ_POWER(x, p) (((u_long)(x) >> (p)) != 0)
     65 
     66 #define MASK_TO_SHIFT2(m) (GTEQ_POWER(LOWEST_SET_BIT((m)), 1) ? 1 : 0)
     67 
     68 #define MASK_TO_SHIFT4(m) \
     69 	(GTEQ_POWER(LOWEST_SET_BIT((m)), 2) \
     70 	    ? 2 + MASK_TO_SHIFT2((m) >> 2) \
     71 	    : MASK_TO_SHIFT2((m)))
     72 
     73 #define MASK_TO_SHIFT8(m) \
     74 	(GTEQ_POWER(LOWEST_SET_BIT((m)), 4) \
     75 	    ? 4 + MASK_TO_SHIFT4((m) >> 4) \
     76 	    : MASK_TO_SHIFT4((m)))
     77 
     78 #define MASK_TO_SHIFT16(m) \
     79 	(GTEQ_POWER(LOWEST_SET_BIT((m)), 8) \
     80 	    ? 8 + MASK_TO_SHIFT8((m) >> 8) \
     81 	    : MASK_TO_SHIFT8((m)))
     82 
     83 #define MASK_TO_SHIFT(m) \
     84 	(GTEQ_POWER(LOWEST_SET_BIT((m)), 16) \
     85 	    ? 16 + MASK_TO_SHIFT16((m) >> 16) \
     86 	    : MASK_TO_SHIFT16((m)))
     87 
     88 #define MASK_AND_RSHIFT(x, mask) (((x) & (mask)) >> MASK_TO_SHIFT(mask))
     89 #define LSHIFT(x, mask) ((x) << MASK_TO_SHIFT(mask))
     90 #define MASK_AND_REPLACE(reg, val, mask) ((reg & ~mask) | LSHIFT(val, mask))
     91 
     92 #endif /* _BIT_TWIDDLE */
     93 
     94 /* ADM8211 Host Control and Status Registers */
     95 
     96 #define ATW_PAR		0x00	/* PCI access */
     97 #define ATW_FRCTL	0x04	/* Frame control */
     98 #define ATW_TDR		0x08	/* Transmit demand */
     99 #define ATW_WTDP	0x0C	/* Current transmit descriptor pointer */
    100 #define ATW_RDR		0x10	/* Receive demand */
    101 #define ATW_WRDP	0x14	/* Current receive descriptor pointer */
    102 #define ATW_RDB		0x18	/* Receive descriptor base address */
    103 #define ATW_CSR3A	0x1C	/* Unused */
    104 #define ATW_TDBD	0x20	/* Transmit descriptor base address, DCF */
    105 #define ATW_TDBP	0x24	/* Transmit descriptor base address, PCF */
    106 #define ATW_STSR	0x28	/* Status */
    107 #define ATW_CSR5A	0x2C	/* Unused */
    108 #define ATW_NAR		0x30	/* Network access */
    109 #define ATW_CSR6A	0x34	/* Unused */
    110 #define ATW_IER		0x38	/* Interrupt enable */
    111 #define ATW_CSR7A	0x3C
    112 #define ATW_LPC		0x40	/* Lost packet counter */
    113 #define ATW_TEST1	0x44	/* Test register 1 */
    114 #define ATW_SPR		0x48	/* Serial port */
    115 #define ATW_TEST0	0x4C	/* Test register 0 */
    116 #define ATW_WCSR	0x50	/* Wake-up control/status */
    117 #define ATW_WPDR	0x54	/* Wake-up pattern data */
    118 #define ATW_GPTMR	0x58	/* General purpose timer */
    119 #define ATW_GPIO	0x5C	/* GPIO[5:0] configuration and control */
    120 #define ATW_BBPCTL	0x60	/* BBP control port */
    121 #define ATW_SYNCTL	0x64	/* synthesizer control port */
    122 #define ATW_PLCPHD	0x68	/* PLCP header setting */
    123 #define ATW_MMIWADDR	0x6C	/* MMI write address */
    124 #define ATW_MMIRADDR1	0x70	/* MMI read address 1 */
    125 #define ATW_MMIRADDR2	0x74	/* MMI read address 2 */
    126 #define ATW_TXBR	0x78	/* Transmit burst counter */
    127 #define ATW_CSR15A	0x7C	/* Unused */
    128 #define ATW_ALCSTAT	0x80	/* ALC statistics */
    129 #define ATW_TOFS2	0x84	/* Timing offset parameter 2, 16b */
    130 #define ATW_CMDR	0x88	/* Command */
    131 #define ATW_PCIC	0x8C	/* PCI bus performance counter */
    132 #define ATW_PMCSR	0x90	/* Power management command and status */
    133 #define ATW_PAR0	0x94	/* Local MAC address register 0, 32b */
    134 #define ATW_PAR1	0x98	/* Local MAC address register 1, 16b */
    135 #define ATW_MAR0	0x9C	/* Multicast address hash table register 0 */
    136 #define ATW_MAR1	0xA0	/* Multicast address hash table register 1 */
    137 #define ATW_ATIMDA0	0xA4	/* Ad Hoc Traffic Indication Map (ATIM)
    138 				 * frame DA, byte[3:0]
    139 				 */
    140 #define ATW_ABDA1	0xA8	/* BSSID address byte[5:4];
    141 				 * ATIM frame DA byte[5:4]
    142 				 */
    143 #define ATW_BSSID0	0xAC	/* BSSID  address byte[3:0] */
    144 #define ATW_TXLMT	0xB0	/* WLAN retry limit, 8b;
    145 				 * Max TX MSDU lifetime, 16b
    146 				 */
    147 #define ATW_MIBCNT	0xB4	/* RTS/ACK/FCS MIB count, 32b */
    148 #define ATW_BCNT	0xB8	/* Beacon transmission time, 32b */
    149 #define ATW_TSFTH	0xBC	/* TSFT[63:32], 32b */
    150 #define ATW_TSC		0xC0	/* TSFT[39:32] down count value */
    151 #define ATW_SYNRF	0xC4	/* SYN RF IF direct control */
    152 #define ATW_BPLI	0xC8	/* Beacon interval, 16b.
    153 				 * STA listen interval, 16b.
    154 				 */
    155 #define ATW_CAP0	0xCC	/* Current channel, 4b. RCVDTIM, 1b. */
    156 #define ATW_CAP1	0xD0	/* Capability information, 16b.
    157 				 * ATIM window, 1b.
    158 				 */
    159 #define ATW_RMD		0xD4	/* RX max reception duration, 16b */
    160 #define ATW_CFPP	0xD8	/* CFP parameter, 32b */
    161 #define ATW_TOFS0	0xDC	/* Timing offset parameter 0, 28b */
    162 #define ATW_TOFS1	0xE0	/* Timing offset parameter 1, 24b */
    163 #define ATW_IFST	0xE4	/* IFS timing parameter 1, 32b */
    164 #define ATW_RSPT	0xE8	/* Response time, 24b */
    165 #define ATW_TSFTL	0xEC	/* TSFT[31:0], 32b */
    166 #define ATW_WEPCTL	0xF0	/* WEP control */
    167 #define ATW_WESK	0xF4	/* Write entry for shared/individual key */
    168 #define ATW_WEPCNT	0xF8	/* WEP count */
    169 #define ATW_MACTEST	0xFC
    170 
    171 #define ATW_FER		0x100	/* Function event */
    172 #define ATW_FEMR	0x104	/* Function event mask */
    173 #define ATW_FPSR	0x108	/* Function present state */
    174 #define ATW_FFER	0x10C	/* Function force event */
    175 
    176 
    177 #define ATW_PAR_MWIE		BIT(24)		/* memory write and invalidate
    178 						 * enable
    179 						 */
    180 #define ATW_PAR_MRLE		BIT(23)		/* memory read line enable */
    181 #define ATW_PAR_MRME		BIT(21)		/* memory read multiple
    182 						 * enable
    183 						 */
    184 #define ATW_PAR_RAP_MASK	BITS(17, 18)	/* receive auto-polling in
    185 						 * receive suspended state
    186 						 */
    187 #define ATW_PAR_CAL_MASK	BITS(14, 15)	/* cache alignment */
    188 #define		ATW_PAR_CAL_PBL		0x0
    189 						/* min(8 DW, PBL) */
    190 #define		ATW_PAR_CAL_8DW		LSHIFT(0x1, ATW_PAR_CAL_MASK)
    191 						/* min(16 DW, PBL) */
    192 #define		ATW_PAR_CAL_16DW	LSHIFT(0x2, ATW_PAR_CAL_MASK)
    193 						/* min(32 DW, PBL) */
    194 #define		ATW_PAR_CAL_32DW	LSHIFT(0x3, ATW_PAR_CAL_MASK)
    195 #define ATW_PAR_PBL_MASK	BITS(8, 13)	/* programmable burst length */
    196 #define		ATW_PAR_PBL_UNLIMITED	0x0
    197 #define		ATW_PAR_PBL_1DW		LSHIFT(0x1, ATW_PAR_PBL_MASK)
    198 #define		ATW_PAR_PBL_2DW		LSHIFT(0x2, ATW_PAR_PBL_MASK)
    199 #define		ATW_PAR_PBL_4DW		LSHIFT(0x4, ATW_PAR_PBL_MASK)
    200 #define		ATW_PAR_PBL_8DW		LSHIFT(0x8, ATW_PAR_PBL_MASK)
    201 #define		ATW_PAR_PBL_16DW	LSHIFT(0x16, ATW_PAR_PBL_MASK)
    202 #define		ATW_PAR_PBL_32DW	LSHIFT(0x32, ATW_PAR_PBL_MASK)
    203 #define ATW_PAR_BLE		BIT(7)		/* big/little endian selection */
    204 #define ATW_PAR_DSL_MASK	BITS(2, 6)	/* descriptor skip length */
    205 #define ATW_PAR_BAR		BIT(1)		/* bus arbitration */
    206 #define ATW_PAR_SWR		BIT(0)		/* software reset */
    207 
    208 #define ATW_FRCTL_PWRMGMT	BIT(31)		/* power management */
    209 #define ATW_FRCTL_VER_MASK	BITS(29, 30)	/* protocol version */
    210 #define ATW_FRCTL_ORDER		BIT(28)		/* order bit */
    211 #define ATW_FRCTL_MAXPSP	BIT(27)		/* maximum power saving */
    212 #define ATW_FRCTL_DOZEFRM	BIT(18)		/* select pre-sleep frame */
    213 #define ATW_FRCTL_PSAWAKE	BIT(17)		/* MAC is awake (?) */
    214 #define ATW_FRCTL_PSMODE	BIT(16)		/* MAC is power-saving (?) */
    215 #define ATW_FRCTL_AID_MASK	BITS(0, 15)	/* STA Association ID */
    216 
    217 #define ATW_INTR_PCF		BIT(31)		/* started/ended CFP */
    218 #define ATW_INTR_BCNTC		BIT(30)		/* transmitted IBSS beacon */
    219 #define ATW_INTR_GPINT		BIT(29)		/* GPIO interrupt */
    220 #define ATW_INTR_LINKOFF	BIT(28)		/* lost ATW_WCSR_BLN beacons */
    221 #define ATW_INTR_ATIMTC		BIT(27)		/* transmitted ATIM */
    222 #define ATW_INTR_TSFTF		BIT(26)		/* TSFT out of range */
    223 #define ATW_INTR_TSCZ		BIT(25)		/* TSC countdown expired */
    224 #define ATW_INTR_LINKON		BIT(24)		/* matched SSID, BSSID */
    225 #define ATW_INTR_SQL		BIT(23)		/* Marvel signal quality */
    226 #define ATW_INTR_WEPTD		BIT(22)		/* switched WEP table */
    227 #define ATW_INTR_ATIME		BIT(21)		/* ended ATIM window */
    228 #define ATW_INTR_TBTT		BIT(20)		/* (TBTT) Target Beacon TX Time
    229 						 * passed
    230 						 */
    231 #define ATW_INTR_NISS		BIT(16)		/* normal interrupt status
    232 						 * summary: any of 31, 30, 27,
    233 						 * 24, 14, 12, 6, 2, 0.
    234 						 */
    235 #define ATW_INTR_AISS		BIT(15)		/* abnormal interrupt status
    236 						 * summary: any of 29, 28, 26,
    237 						 * 25, 23, 22, 13, 11, 8, 7, 5,
    238 						 * 4, 3, 1.
    239 						 */
    240 #define ATW_INTR_TEIS		BIT(14)		/* transmit early interrupt
    241 						 * status: moved TX packet to
    242 						 * FIFO
    243 						 */
    244 #define ATW_INTR_FBE		BIT(13)		/* fatal bus error */
    245 #define ATW_INTR_REIS		BIT(12)		/* receive early interrupt
    246 						 * status: RX packet filled
    247 						 * its first descriptor
    248 						 */
    249 #define ATW_INTR_GPTT		BIT(11)		/* general purpose timer expired */
    250 #define ATW_INTR_RPS		BIT(8)		/* stopped receive process */
    251 #define ATW_INTR_RDU		BIT(7)		/* receive descriptor
    252 						 * unavailable
    253 						 */
    254 #define ATW_INTR_RCI		BIT(6)		/* completed packet reception */
    255 #define ATW_INTR_TUF		BIT(5)		/* transmit underflow */
    256 #define ATW_INTR_TRT		BIT(4)		/* transmit retry count
    257 						 * expired
    258 						 */
    259 #define ATW_INTR_TLT		BIT(3)		/* transmit lifetime exceeded */
    260 #define ATW_INTR_TDU		BIT(2)		/* transmit descriptor
    261 						 * unavailable
    262 						 */
    263 #define ATW_INTR_TPS		BIT(1)		/* stopped transmit process */
    264 #define ATW_INTR_TCI		BIT(0)		/* completed transmit */
    265 #define ATW_NAR_TXCF		BIT(31)		/* stop process on TX failure */
    266 #define ATW_NAR_HF		BIT(30)		/* flush TX FIFO to host (?) */
    267 #define ATW_NAR_UTR		BIT(29)		/* select retry count source */
    268 #define ATW_NAR_PCF		BIT(28)		/* use one/both transmit
    269 						 * descriptor base addresses
    270 						 */
    271 #define ATW_NAR_CFP		BIT(27)		/* indicate more TX data to
    272 						 * point coordinator
    273 						 */
    274 #define ATW_NAR_SF		BIT(21)		/* store and forward: ignore
    275 						 * TX threshold
    276 						 */
    277 #define ATW_NAR_TR_MASK		BITS(14, 15)	/* TX threshold */
    278 #define		ATW_NAR_TR_L64		LSHIFT(0x0, ATW_NAR_TR_MASK)
    279 #define		ATW_NAR_TR_L160		LSHIFT(0x2, ATW_NAR_TR_MASK)
    280 #define		ATW_NAR_TR_L192		LSHIFT(0x3, ATW_NAR_TR_MASK)
    281 #define		ATW_NAR_TR_H96		LSHIFT(0x0, ATW_NAR_TR_MASK)
    282 #define		ATW_NAR_TR_H288		LSHIFT(0x2, ATW_NAR_TR_MASK)
    283 #define		ATW_NAR_TR_H544		LSHIFT(0x3, ATW_NAR_TR_MASK)
    284 #define ATW_NAR_ST		BIT(13)		/* start/stop transmit */
    285 #define ATW_NAR_OM_MASK		BITS(10, 11)	/* operating mode */
    286 #define		ATW_NAR_OM_NORMAL	0x0
    287 #define		ATW_NAR_OM_LOOPBACK	LSHIFT(0x1, ATW_NAR_OM_MASK)
    288 #define ATW_NAR_MM		BIT(7)		/* RX any multicast */
    289 #define ATW_NAR_PR		BIT(6)		/* promiscuous mode */
    290 #define ATW_NAR_EA		BIT(5)		/* match ad hoc packets (?) */
    291 #define ATW_NAR_PB		BIT(3)		/* pass bad packets */
    292 #define ATW_NAR_STPDMA		BIT(2)		/* stop DMA, abort packet */
    293 #define ATW_NAR_SR		BIT(1)		/* start/stop receive */
    294 #define ATW_NAR_CTX		BIT(0)		/* continuous TX mode */
    295 
    296 /* IER bits are identical to STSR bits. Use ATW_INTR_*. */
    297 #if 0
    298 #define ATW_IER_NIE		BIT(16)		/* normal interrupt enable */
    299 #define ATW_IER_AIE		BIT(15)		/* abnormal interrupt enable */
    300 /* normal interrupts: combine with ATW_IER_NIE */
    301 #define ATW_IER_PCFIE		BIT(31)		/* STA entered CFP */
    302 #define ATW_IER_BCNTCIE		BIT(30)		/* STA TX'd beacon */
    303 #define ATW_IER_ATIMTCIE	BIT(27)		/* transmitted ATIM */
    304 #define ATW_IER_LINKONIE	BIT(24)		/* matched beacon */
    305 #define ATW_IER_ATIMIE		BIT(21)		/* ended ATIM window */
    306 #define ATW_IER_TBTTIE		BIT(20)		/* TBTT */
    307 #define ATW_IER_TEIE		BIT(14)		/* moved TX packet to FIFO */
    308 #define ATW_IER_REIE		BIT(12)		/* RX packet filled its first
    309 						 * descriptor
    310 						 */
    311 #define ATW_IER_RCIE		BIT(6)		/* completed RX */
    312 #define ATW_IER_TDUIE		BIT(2)		/* transmit descriptor
    313 						 * unavailable
    314 						 */
    315 #define ATW_IER_TCIE		BIT(0)		/* completed TX */
    316 /* abnormal interrupts: combine with ATW_IER_AIE */
    317 #define ATW_IER_GPIE		BIT(29)		/* GPIO interrupt */
    318 #define ATW_IER_LINKOFFIE	BIT(28)		/* lost beacon */
    319 #define ATW_IER_TSFTFIE		BIT(26)		/* TSFT out of range */
    320 #define ATW_IER_TSCIE		BIT(25)		/* TSC countdown expired */
    321 #define ATW_IER_SQLIE		BIT(23)		/* signal quality */
    322 #define ATW_IER_WEPIE		BIT(22)		/* finished WEP table switch */
    323 #define ATW_IER_FBEIE		BIT(13)		/* fatal bus error */
    324 #define ATW_IER_GPTIE		BIT(11)		/* general purpose timer expired */
    325 #define ATW_IER_RPSIE		BIT(8)		/* stopped receive process */
    326 #define ATW_IER_RUIE		BIT(7)		/* receive descriptor unavailable */
    327 #define ATW_IER_TUIE		BIT(5)		/* transmit underflow */
    328 #define ATW_IER_TRTIE		BIT(4)		/* exceeded transmit retry count */
    329 #define ATW_IER_TLTTIE		BIT(3)		/* transmit lifetime exceeded */
    330 #define ATW_IER_TPSIE		BIT(1)		/* stopped transmit process */
    331 #endif
    332 
    333 #define ATW_LPC_LPCO		BIT(16)		/* lost packet counter overflow */
    334 #define ATW_LPC_LPC_MASK	BITS(0, 15)	/* lost packet counter */
    335 
    336 #define ATW_SPR_SRS		BIT(11)		/* activate SEEPROM access */
    337 #define ATW_SPR_SDO		BIT(3)		/* data out of SEEPROM */
    338 #define ATW_SPR_SDI		BIT(2)		/* data into SEEPROM */
    339 #define ATW_SPR_SCLK		BIT(1)		/* SEEPROM clock */
    340 #define ATW_SPR_SCS		BIT(0)		/* SEEPROM chip select */
    341 
    342 /* TBD CSR_TEST0 */
    343 #define ATW_TEST0_BE_MASK	BITS(31, 29)	/* Bus error state */
    344 #define ATW_TEST0_TS_MASK	BITS(28, 26)	/* Transmit process state */
    345 
    346 /* Stopped */
    347 #define ATW_TEST0_TS_STOPPED		LSHIFT(0, ATW_TEST0_TS_MASK)
    348 /* Running - fetch transmit descriptor */
    349 #define ATW_TEST0_TS_FETCH		LSHIFT(1, ATW_TEST0_TS_MASK)
    350 /* Running - wait for end of transmission */
    351 #define ATW_TEST0_TS_WAIT		LSHIFT(2, ATW_TEST0_TS_MASK)
    352 /* Running - read buffer from memory and queue into FIFO */
    353 #define ATW_TEST0_TS_READING		LSHIFT(3, ATW_TEST0_TS_MASK)
    354 #define ATW_TEST0_TS_RESERVED1		LSHIFT(4, ATW_TEST0_TS_MASK)
    355 #define ATW_TEST0_TS_RESERVED2		LSHIFT(5, ATW_TEST0_TS_MASK)
    356 /* Suspended */
    357 #define ATW_TEST0_TS_SUSPENDED		LSHIFT(6, ATW_TEST0_TS_MASK)
    358 /* Running - close transmit descriptor */
    359 #define ATW_TEST0_TS_CLOSE		LSHIFT(7, ATW_TEST0_TS_MASK)
    360 
    361 #define ATW_TEST0_RS_MASK	BITS(25, 23)	/* Receive process state */
    362 
    363 /* Stopped */
    364 #define	ATW_TEST0_RS_STOPPED		LSHIFT(0, ATW_TEST0_RS_MASK)
    365 /* Running - fetch receive descriptor */
    366 #define	ATW_TEST0_RS_FETCH		LSHIFT(1, ATW_TEST0_RS_MASK)
    367 /* Running - check for end of receive */
    368 #define	ATW_TEST0_RS_CHECK		LSHIFT(2, ATW_TEST0_RS_MASK)
    369 /* Running - wait for packet */
    370 #define	ATW_TEST0_RS_WAIT		LSHIFT(3, ATW_TEST0_RS_MASK)
    371 /* Suspended */
    372 #define	ATW_TEST0_RS_SUSPENDED		LSHIFT(4, ATW_TEST0_RS_MASK)
    373 /* Running - close receive descriptor */
    374 #define	ATW_TEST0_RS_CLOSE		LSHIFT(5, ATW_TEST0_RS_MASK)
    375 /* Running - flush current frame from FIFO */
    376 #define	ATW_TEST0_RS_FLUSH		LSHIFT(6, ATW_TEST0_RS_MASK)
    377 /* Running - queue current frame from FIFO into buffer */
    378 #define	ATW_TEST0_RS_QUEUE		LSHIFT(7, ATW_TEST0_RS_MASK)
    379 
    380 #define ATW_TEST0_EPNE		BIT(18)		/* SEEPROM not detected */
    381 #define ATW_TEST0_EPSNM		BIT(17)		/* SEEPROM bad signature */
    382 #define ATW_TEST0_EPTYP_MASK	BIT(16)		/* SEEPROM type
    383 						 * 1: 93c66,
    384 						 * 0: 93c46
    385 						 */
    386 #define	ATW_TEST0_EPTYP_93c66		ATW_TEST0_EPTYP_MASK
    387 #define	ATW_TEST0_EPTYP_93c46		0
    388 #define ATW_TEST0_EPRLD		BIT(15)		/* recall SEEPROM (write 1) */
    389 
    390 #define ATW_WCSR_CRCT		BIT(30)		/* CRC-16 type */
    391 #define ATW_WCSR_WP1E		BIT(29)		/* match wake-up pattern 1 */
    392 #define ATW_WCSR_WP2E		BIT(28)		/* match wake-up pattern 2 */
    393 #define ATW_WCSR_WP3E		BIT(27)		/* match wake-up pattern 3 */
    394 #define ATW_WCSR_WP4E		BIT(26)		/* match wake-up pattern 4 */
    395 #define ATW_WCSR_WP5E		BIT(25)		/* match wake-up pattern 5 */
    396 #define ATW_WCSR_BLN_MASK	BITS(21, 23)	/* lose link after BLN lost
    397 						 * beacons
    398 						 */
    399 #define ATW_WCSR_TSFTWE		BIT(20)		/* wake up on TSFT out of
    400 						 * range
    401 						 */
    402 #define ATW_WCSR_TIMWE		BIT(19)		/* wake up on TIM */
    403 #define ATW_WCSR_ATIMWE		BIT(18)		/* wake up on ATIM */
    404 #define ATW_WCSR_KEYWE		BIT(17)		/* wake up on key update */
    405 #define ATW_WCSR_WFRE		BIT(10)		/* wake up on wake-up frame */
    406 #define ATW_WCSR_MPRE		BIT(9)		/* wake up on magic packet */
    407 #define ATW_WCSR_LSOE		BIT(8)		/* wake up on link loss */
    408 /* wake-up reasons correspond to enable bits */
    409 #define ATW_WCSR_KEYUP		BIT(6)		/* */
    410 #define ATW_WCSR_TSFTW		BIT(5)		/* */
    411 #define ATW_WCSR_TIMW		BIT(4)		/* */
    412 #define ATW_WCSR_ATIMW		BIT(3)		/* */
    413 #define ATW_WCSR_WFR		BIT(2)		/* */
    414 #define ATW_WCSR_MPR		BIT(1)		/* */
    415 #define ATW_WCSR_LSO		BIT(0)		/* */
    416 
    417 #define ATW_GPTMR_COM_MASK	BIT(16)		/* continuous operation mode */
    418 #define ATW_GPTMR_GTV_MASK	BITS(0, 15)	/* set countdown in 204us ticks */
    419 
    420 #define ATW_GPIO_EC1_MASK	BITS(25, 24)	/* GPIO1 event configuration */
    421 #define ATW_GPIO_LAT_MASK	BITS(21, 20)	/* input latch */
    422 #define ATW_GPIO_INTEN_MASK	BITS(19, 18)	/* interrupt enable */
    423 #define ATW_GPIO_EN_MASK	BITS(17, 12)	/* output enable */
    424 #define ATW_GPIO_O_MASK		BITS(11, 6)	/* output value */
    425 #define ATW_GPIO_I_MASK		BITS(5, 0)	/* pin static input */
    426 
    427 #define ATW_BBPCTL_TWI			BIT(31)	/* Intersil 3-wire interface */
    428 #define ATW_BBPCTL_RF3KADDR_MASK	BITS(30, 24)	/* Address for RF3000 */
    429 #define ATW_BBPCTL_RF3KADDR_ADDR LSHIFT(0x20, ATW_BBPCTL_RF3KADDR_MASK)
    430 #define ATW_BBPCTL_NEGEDGE_DO		BIT(23)	/* data-out on negative edge */
    431 #define ATW_BBPCTL_NEGEDGE_DI		BIT(22)	/* data-in on negative edge */
    432 #define ATW_BBPCTL_CCA_ACTLO		BIT(21)	/* CCA low when busy */
    433 #define ATW_BBPCTL_TYPE_MASK		BITS(20, 18)	/* BBP type */
    434 #define ATW_BBPCTL_WR			BIT(17)	/* start write; reset on
    435 						 * completion
    436 						 */
    437 #define ATW_BBPCTL_RD		BIT(16)		/* start read; reset on
    438 						 * completion
    439 						 */
    440 #define ATW_BBPCTL_ADDR_MASK	BITS(15, 8)	/* BBP address */
    441 #define ATW_BBPCTL_DATA_MASK	BITS(7, 0)	/* BBP data */
    442 
    443 #define ATW_SYNCTL_WR		BIT(31)		/* start write; reset on
    444 						 * completion
    445 						 */
    446 #define ATW_SYNCTL_RD		BIT(30)		/* start read; reset on
    447 						 * completion
    448 						 */
    449 #define ATW_SYNCTL_CS0		BIT(29)		/* chip select */
    450 #define ATW_SYNCTL_CS1		BIT(28)
    451 #define ATW_SYNCTL_CAL		BIT(27)		/* generate RF CAL pulse after
    452 						 * Rx
    453 						 */
    454 #define ATW_SYNCTL_SELCAL	BIT(26)		/* RF CAL source, 0: CAL bit,
    455 						 * 1: MAC; needed by Intersil
    456 						 * BBP
    457 						 */
    458 #define ATW_SYNCTL_RFTYPE_MASK	BITS(24, 22)	/* RF type */
    459 #define ATW_SYNCTL_DATA_MASK	BITS(21, 0)	/* synthesizer setting */
    460 
    461 #define ATW_PLCPHD_SIGNAL_MASK	BITS(31, 24)	/* signal field in PLCP header,
    462 						 * only for beacon, ATIM, and
    463 						 * RTS.
    464 						 */
    465 #define ATW_PLCPHD_SERVICE_MASK	BITS(23, 16)	/* service field in PLCP
    466 						 * header
    467 						 */
    468 #define ATW_PLCPHD_PMBL		BIT(15)		/* 0: long preamble, 1: short */
    469 
    470 #define ATW_MMIWADDR_INTERSIL	0x100E0C0A
    471 #define ATW_MMIWADDR_RFMD	0x00009101
    472 
    473 #define ATW_MMIRADDR1_INTERSIL	0x00007c7e
    474 #define ATW_MMIRADDR1_RFMD	0x00000301
    475 
    476 #define ATW_MMIRADDR2_INTERSIL	0x00100000
    477 #define ATW_MMIRADDR2_RFMD	0x7e100000
    478 
    479 #define ATW_TXBR_ALCUPDATE_MASK	BIT(31)		/* auto-update BBP with ALCSET */
    480 #define ATW_TXBR_TBCNT_MASK	BITS(16, 20)	/* transmit burst count */
    481 #define ATW_TXBR_ALCSET_MASK	BITS(8, 15)	/* TX power level set point */
    482 #define ATW_TXBR_ALCREF_MASK	BITS(0, 7)	/* TX power level reference point */
    483 
    484 #define ATW_ALCSTAT_MCOV_MASK	BIT(27)		/* MPDU count overflow */
    485 #define ATW_ALCSTAT_ESOV_MASK	BIT(26)		/* error sum overflow */
    486 #define ATW_ALCSTAT_MCNT_MASK	BITS(16, 25)	/* MPDU count, unsigned integer */
    487 #define ATW_ALCSTAT_ERSUM_MASK	BITS(0, 15)	/* power error sum,
    488 						 * 2's complement signed integer
    489 						 */
    490 
    491 #define ATW_TOFS2_PWR1UP_MASK	BITS(31, 28)	/* delay of Tx/Rx from PE1,
    492 						 * Radio, PHYRST change after
    493 						 * power-up, in 2ms units
    494 						 */
    495 #define ATW_TOFS2_PWR0PAPE_MASK	BITS(27, 24)	/* delay of PAPE going low
    496 						 * after internal data
    497 						 * transmit end, in us
    498 						 */
    499 #define ATW_TOFS2_PWR1PAPE_MASK	BITS(23, 20)	/* delay of PAPE going high
    500 						 * after TXPE asserted, in us
    501 						 */
    502 #define ATW_TOFS2_PWR0TRSW_MASK	BITS(19, 16)	/* delay of TRSW going low
    503 						 * after internal data transmit
    504 						 * end, in us
    505 						 */
    506 #define ATW_TOFS2_PWR1TRSW_MASK	BITS(15, 12)	/* delay of TRSW going high
    507 						 * after TXPE asserted, in us
    508 						 */
    509 #define ATW_TOFS2_PWR0PE2_MASK	BITS(11, 8)	/* delay of PE2 going low
    510 						 * after internal data transmit
    511 						 * end, in us
    512 						 */
    513 #define ATW_TOFS2_PWR1PE2_MASK	BITS(7, 4)	/* delay of PE2 going high
    514 						 * after TXPE asserted, in us
    515 						 */
    516 #define ATW_TOFS2_PWR0TXPE_MASK	BITS(3, 0)	/* delay of TXPE going low
    517 						 * after internal data transmit
    518 						 * end, in us
    519 						 */
    520 
    521 #define ATW_CMDR_PM		BIT(19)		/* enables power mgmt
    522 						 * capabilities.
    523 						 */
    524 #define ATW_CMDR_APM		BIT(18)		/* APM mode, effective when
    525 						 * PM = 1.
    526 						 */
    527 #define ATW_CMDR_RTE		BIT(4)		/* enable Rx FIFO threshold */
    528 #define ATW_CMDR_DRT_MASK	BITS(3, 2)	/* drain Rx FIFO threshold */
    529 #define ATW_CMDR_SINT_MASK	BIT(1)		/* software interrupt---huh? */
    530 
    531 /* TBD PCIC */
    532 
    533 /* TBD PMCSR */
    534 
    535 
    536 #define ATW_PAR0_PAB0_MASK	BITS(0, 7)	/* MAC address byte 0 */
    537 #define ATW_PAR0_PAB1_MASK	BITS(8, 15)	/* MAC address byte 1 */
    538 #define ATW_PAR0_PAB2_MASK	BITS(16, 23)	/* MAC address byte 2 */
    539 #define ATW_PAR0_PAB3_MASK	BITS(24, 31)	/* MAC address byte 3 */
    540 
    541 #define ATW_PAR1_PAB5_MASK	BITS(8, 15)	/* MAC address byte 5 */
    542 #define ATW_PAR1_PAB4_MASK	BITS(0, 7)	/* MAC address byte 4 */
    543 
    544 #define ATW_MAR0_MAB3_MASK	BITS(31, 24)	/* multicast table bits 31:24 */
    545 #define ATW_MAR0_MAB2_MASK	BITS(23, 16)	/* multicast table bits 23:16 */
    546 #define ATW_MAR0_MAB1_MASK	BITS(15, 8)	/* multicast table bits 15:8 */
    547 #define ATW_MAR0_MAB0_MASK	BITS(7, 0)	/* multicast table bits 7:0 */
    548 
    549 #define ATW_MAR1_MAB7_MASK	BITS(31, 24)	/* multicast table bits 63:56 */
    550 #define ATW_MAR1_MAB6_MASK	BITS(23, 16)	/* multicast table bits 55:48 */
    551 #define ATW_MAR1_MAB5_MASK	BITS(15, 8)	/* multicast table bits 47:40 */
    552 #define ATW_MAR1_MAB4_MASK	BITS(7, 0)	/* multicast table bits 39:32 */
    553 
    554 /* ATIM destination address */
    555 #define ATW_ATIMDA0_ATIMB3_MASK	BITS(31,24)
    556 #define ATW_ATIMDA0_ATIMB2_MASK	BITS(23,16)
    557 #define ATW_ATIMDA0_ATIMB1_MASK	BITS(15,8)
    558 #define ATW_ATIMDA0_ATIMB0_MASK	BITS(7,0)
    559 
    560 /* ATIM destination address, BSSID */
    561 #define ATW_ABDA1_BSSIDB5_MASK	BITS(31,24)
    562 #define ATW_ABDA1_BSSIDB4_MASK	BITS(23,16)
    563 #define ATW_ABDA1_ATIMB5_MASK	BITS(15,8)
    564 #define ATW_ABDA1_ATIMB4_MASK	BITS(7,0)
    565 
    566 /* BSSID */
    567 #define ATW_BSSID0_BSSIDB3_MASK	BITS(31,24)
    568 #define ATW_BSSID0_BSSIDB2_MASK	BITS(23,16)
    569 #define ATW_BSSID0_BSSIDB1_MASK	BITS(15,8)
    570 #define ATW_BSSID0_BSSIDB0_MASK	BITS(7,0)
    571 
    572 #define ATW_TXLMT_MTMLT_MASK	BITS(31,16)	/* max TX MSDU lifetime in TU */
    573 #define ATW_TXLMT_SRTYLIM_MASK	BITS(7,0)	/* short retry limit */
    574 
    575 #define ATW_MIBCNT_FFCNT_MASK	BITS(31,24)	/* FCS failure count */
    576 #define ATW_MIBCNT_AFCNT_MASK	BITS(23,16)	/* ACK failure count */
    577 #define ATW_MIBCNT_RSCNT_MASK	BITS(15,8)	/* RTS success count */
    578 #define ATW_MIBCNT_RFCNT_MASK	BITS(7,0)	/* RTS failure count */
    579 
    580 #define ATW_BCNT_PLCPH_MASK	BITS(23,16)	/* 11M PLCP length (us) */
    581 #define ATW_BCNT_PLCPL_MASK	BITS(15,8)	/* 5.5M PLCP length (us) */
    582 #define ATW_BCNT_BCNT_MASK	BITS(7,0)	/* byte count of beacon frame */
    583 
    584 #define ATW_TSC_TSC_MASK	BITS(3,0)	/* TSFT countdown value */
    585 
    586 #define ATW_SYNRF_SELSYN	BIT(31)	/* 0: MAC controls SYN IF pins,
    587 					 * 1: ATW_SYNRF controls SYN IF pins.
    588 					 */
    589 #define ATW_SYNRF_SELRF		BIT(30)	/* 0: MAC controls RF IF pins,
    590 					 * 1: ATW_SYNRF controls RF IF pins.
    591 					 */
    592 #define ATW_SYNRF_LERF		BIT(29)	/* if SELSYN = 1, direct control of
    593 					 * LERF# pin
    594 					 */
    595 #define ATW_SYNRF_LEIF		BIT(28)	/* if SELSYN = 1, direct control of
    596 					 * LEIF# pin
    597 					 */
    598 #define ATW_SYNRF_SYNCLK	BIT(27)	/* if SELSYN = 1, direct control of
    599 					 * SYNCLK pin
    600 					 */
    601 #define ATW_SYNRF_SYNDATA	BIT(26)	/* if SELSYN = 1, direct control of
    602 					 * SYNDATA pin
    603 					 */
    604 #define ATW_SYNRF_PE1		BIT(25)	/* if SELRF = 1, direct control of
    605 					 * PE1 pin
    606 					 */
    607 #define ATW_SYNRF_PE2		BIT(24)	/* if SELRF = 1, direct control of
    608 					 * PE2 pin
    609 					 */
    610 #define ATW_SYNRF_PAPE		BIT(23)	/* if SELRF = 1, direct control of
    611 					 * PAPE pin
    612 					 */
    613 #define ATW_SYNRF_INTERSIL_EN	BIT(20)	/* if SELRF = 1, enables
    614 					 * some signal used by the
    615 					 * Intersil RF front-end?
    616 					 * Undocumented.
    617 					 */
    618 #define ATW_SYNRF_PHYRST	BIT(18)	/* if SELRF = 1, direct control of
    619 					 * PHYRST# pin
    620 					 */
    621 
    622 #define ATW_BPLI_BP_MASK	BITS(31,16)	/* beacon interval in TU */
    623 #define ATW_BPLI_LI_MASK	BITS(15,0)	/* STA listen interval in
    624 						 * beacon intervals
    625 						 */
    626 
    627 #define ATW_CAP0_RCVDTIM	BIT(4)		/* receive every DTIM */
    628 #define ATW_CAP0_CHN_MASK	BITS(3,0)	/* current DSSS channel */
    629 
    630 #define ATW_CAP1_CAPI_MASK	BITS(31,16)	/* capability information */
    631 #define ATW_CAP1_ATIMW_MASK	BITS(15,0)	/* ATIM window in TU */
    632 
    633 #define ATW_RMD_ATIMST		BIT(31)		/* ATIM frame TX status */
    634 #define ATW_RMD_CFP		BIT(30)		/* CFP indicator */
    635 #define ATW_RMD_PCNT		BITS(27,16)	/* idle time between
    636 						 * awake/ps mode
    637 						 */
    638 #define ATW_RMD_RMRD		BITS(15,0)	/* max RX reception duration
    639 						 * in us
    640 						 */
    641 
    642 #define ATW_CFPP_CFPP		BITS(31,24)	/* CFP unit DTIM */
    643 #define ATW_CFPP_CFPMD		BITS(23,8)	/* CFP max duration in TU */
    644 #define ATW_CFPP_DTIMP		BITS(7,0)	/* DTIM period in beacon
    645 						 * intervals
    646 						 */
    647 #define ATW_TOFS0_USCNT_MASK	BITS(29,24)	/* number of system clocks
    648 						 * in 1 microsecond.
    649 						 * Depends PCI bus speed?
    650 						 */
    651 #define ATW_TOFS0_TUCNT_MASK	BITS(9,0)	/* TU counter in microseconds */
    652 
    653 /* TBD TOFS1 */
    654 #define ATW_TOFS1_TSFTOFSR_MASK	BITS(31,24)	/* RX TSFT offset in
    655 						 * microseconds: RF+BBP
    656 						 * latency
    657 						 */
    658 #define ATW_TOFS1_TBTTPRE_MASK	BITS(23,8)	/* prediction time, (next
    659 						 * Nth TBTT - TBTTOFS) in
    660 						 * microseconds (huh?). To
    661 						 * match TSFT[25:10] (huh?).
    662 						 */
    663 #define ATW_TOFS1_TBTTOFS_MASK	BITS(7,0)	/* wake-up time offset before
    664 						 * TBTT in TU
    665 						 */
    666 #define ATW_IFST_SLOT_MASK	BITS(27,23)	/* SLOT time in us */
    667 #define ATW_IFST_SIFS_MASK	BITS(22,15)	/* SIFS time in us */
    668 #define ATW_IFST_DIFS_MASK	BITS(14,9)	/* DIFS time in us */
    669 #define ATW_IFST_EIFS_MASK	BITS(8,0)	/* EIFS time in us */
    670 
    671 #define ATW_RSPT_MART_MASK	BITS(31,16)	/* max response time in us */
    672 #define ATW_RSPT_MIRT_MASK	BITS(15,8)	/* min response time in us */
    673 #define ATW_RSPT_TSFTOFST_MASK	BITS(7,0)	/* TX TSFT offset in us */
    674 
    675 #define ATW_WEPCTL_WEPENABLE	BIT(31)		/* enable WEP engine */
    676 #define ATW_WEPCTL_AUTOSWITCH	BIT(30)		/* auto-switch enable (huh?) */
    677 #define ATW_WEPCTL_CURTBL	BIT(29)		/* current table in use */
    678 #define ATW_WEPCTL_WR		BIT(28)		/* */
    679 #define ATW_WEPCTL_RD		BIT(27)		/* */
    680 #define ATW_WEPCTL_WEPRXBYP	BIT(25)		/* bypass WEP on RX */
    681 #define ATW_WEPCTL_UNKNOWN0	BIT(23)		/* has something to do with
    682 						 * revision 0x20. Possibly
    683 						 * selects a different WEP
    684 						 * table.
    685 						 */
    686 #define ATW_WEPCTL_TBLADD_MASK	BITS(8,0)	/* add to table */
    687 
    688 /* set these bits in the second byte of a SRAM shared key record to affect
    689  * the use and interpretation of the key in the record.
    690  */
    691 #define ATW_WEP_ENABLED	BIT(7)
    692 #define ATW_WEP_104BIT	BIT(6)
    693 
    694 #define ATW_WESK_DATA_MASK	BITS(15,0)	/* data */
    695 #define ATW_WEPCNT_WIEC_MASK	BITS(15,0)	/* WEP ICV error count */
    696 
    697 #define ATW_MACTEST_FORCE_IV		BIT(23)
    698 #define ATW_MACTEST_FORCE_KEYID		BIT(22)
    699 #define ATW_MACTEST_KEYID_MASK		BITS(21,20)
    700 #define ATW_MACTEST_MMI_USETXCLK	BIT(11)
    701 
    702 /* Function Event/Status registers */
    703 
    704 #define ATW_FER_INTR		BIT(15)	/* interrupt: set regardless of mask */
    705 #define ATW_FER_GWAKE		BIT(4)	/* general wake-up: set regardless of mask */
    706 
    707 #define ATW_FEMR_INTR_EN	BIT(15)	/* enable INTA# */
    708 #define ATW_FEMR_WAKEUP_EN	BIT(14)	/* enable wake-up */
    709 #define ATW_FEMR_GWAKE_EN	BIT(4)	/* enable general wake-up */
    710 
    711 #define ATW_FPSR_INTR_STATUS	BIT(15)	/* interrupt status */
    712 #define ATW_FPSR_WAKEUP_STATUS	BIT(4)	/* CSTSCHG state */
    713 #define ATW_FFER_INTA_FORCE	BIT(15)	/* activate INTA (if not masked) */
    714 #define ATW_FFER_GWAKE_FORCE	BIT(4)	/* activate CSTSCHG (if not masked) */
    715 
    716 /* Serial EEPROM offsets */
    717 #define ATW_SR_CLASS_CODE	(0x00/2)
    718 #define ATW_SR_FORMAT_VERSION	(0x02/2)
    719 #define ATW_SR_MAC00		(0x08/2)	/* CSR21 */
    720 #define ATW_SR_MAC01		(0x0A/2)	/* CSR21/22 */
    721 #define ATW_SR_MAC10		(0x0C/2)	/* CSR22 */
    722 #define ATW_SR_CSR20		(0x16/2)
    723 #define		ATW_SR_ANT_MASK		BITS(12, 10)
    724 #define		ATW_SR_PWRSCALE_MASK	BITS(9, 8)
    725 #define		ATW_SR_CLKSAVE_MASK	BITS(7, 6)
    726 #define		ATW_SR_RFTYPE_MASK	BITS(5, 3)
    727 #define		ATW_SR_BBPTYPE_MASK	BITS(2, 0)
    728 #define ATW_SR_CR28_CR03	(0x18/2)
    729 #define ATW_SR_CTRY_CR29	(0x1A/2)
    730 #define		ATW_SR_CTRY_MASK	BITS(15,8)	/* country code */
    731 #define			COUNTRY_FCC	0
    732 #define			COUNTRY_IC	1
    733 #define			COUNTRY_ETSI	2
    734 #define			COUNTRY_SPAIN	3
    735 #define			COUNTRY_FRANCE	4
    736 #define			COUNTRY_MMK	5
    737 #define			COUNTRY_MMK2	6
    738 #define ATW_SR_PCI_DEVICE	(0x20/2)	/* CR0 */
    739 #define ATW_SR_PCI_VENDOR	(0x22/2)	/* CR0 */
    740 #define ATW_SR_SUB_DEVICE	(0x24/2)	/* CR11 */
    741 #define ATW_SR_SUB_VENDOR	(0x26/2)	/* CR11 */
    742 #define ATW_SR_CR15		(0x28/2)
    743 #define ATW_SR_LOCISPTR		(0x2A/2)	/* CR10 */
    744 #define ATW_SR_HICISPTR		(0x2C/2)	/* CR10 */
    745 #define ATW_SR_CSR18		(0x2E/2)
    746 #define ATW_SR_D0_D1_PWR	(0x40/2)	/* CR49 */
    747 #define ATW_SR_D2_D3_PWR	(0x42/2)	/* CR49 */
    748 #define ATW_SR_CIS_WORDS	(0x52/2)
    749 /* CR17 of RFMD RF3000 BBP: returns TWO channels */
    750 #define ATW_SR_TXPOWER(chnl)		(0x54/2 + ((chnl) - 1)/2)
    751 /* CR20 of RFMD RF3000 BBP: returns TWO channels */
    752 #define ATW_SR_LPF_CUTOFF(chnl)		(0x62/2 + ((chnl) - 1)/2)
    753 /* CR21 of RFMD RF3000 BBP: returns TWO channels */
    754 #define ATW_SR_LNA_GS_THRESH(chnl)	(0x70/2 + ((chnl) - 1)/2)
    755 #define ATW_SR_CHECKSUM		(0x7e/2)	/* for data 0x00-0x7d */
    756 #define ATW_SR_CIS		(0x80/2)	/* Cardbus CIS */
    757 
    758 /* Tx descriptor */
    759 struct atw_txdesc {
    760 	u_int32_t	at_ctl;
    761 #define at_stat at_ctl
    762 	u_int32_t	at_flags;
    763 	u_int32_t	at_buf1;
    764 	u_int32_t	at_buf2;
    765 };
    766 
    767 #define ATW_TXCTL_OWN		BIT(31)		/* 1: ready to transmit */
    768 #define ATW_TXCTL_DONE		BIT(30)		/* 0: not processed */
    769 #define ATW_TXCTL_TXDR_MASK	BITS(27,20)	/* TX data rate (?) */
    770 #define ATW_TXCTL_TL_MASK	BITS(19,0)	/* retry limit, 0 - 255 */
    771 
    772 #define ATW_TXSTAT_OWN		ATW_TXCTL_OWN	/* 0: not for transmission */
    773 #define ATW_TXSTAT_DONE		ATW_TXCTL_DONE	/* 1: been processed */
    774 #define ATW_TXSTAT_ES		BIT(29)		/* 0: TX successful */
    775 #define ATW_TXSTAT_TLT		BIT(28)		/* TX lifetime expired */
    776 #define ATW_TXSTAT_TRT		BIT(27)		/* TX retry limit expired */
    777 #define ATW_TXSTAT_TUF		BIT(26)		/* TX under-run error */
    778 #define ATW_TXSTAT_TRO		BIT(25)		/* TX over-run error */
    779 #define ATW_TXSTAT_SOFBR	BIT(24)		/* packet size != buffer size
    780 						 * (?)
    781 						 */
    782 #define ATW_TXSTAT_ARC_MASK	BITS(11,0)	/* accumulated retry count */
    783 
    784 #define ATW_TXFLAG_IC		BIT(31)		/* interrupt on completion */
    785 #define ATW_TXFLAG_LS		BIT(30)		/* packet's last descriptor */
    786 #define ATW_TXFLAG_FS		BIT(29)		/* packet's first descriptor */
    787 #define ATW_TXFLAG_TER		BIT(25)		/* end of ring */
    788 #define ATW_TXFLAG_TCH		BIT(24)		/* at_buf2 is 2nd chain */
    789 #define ATW_TXFLAG_TBS2_MASK	BITS(23,12)	/* at_buf2 byte count */
    790 #define ATW_TXFLAG_TBS1_MASK	BITS(11,0)	/* at_buf1 byte count */
    791 
    792 /* Rx descriptor */
    793 struct atw_rxdesc {
    794     u_int32_t	ar_stat;
    795     u_int32_t	ar_ctl;
    796     u_int32_t	ar_buf1;
    797     u_int32_t	ar_buf2;
    798 };
    799 
    800 #define	ar_rssi	ar_ctl
    801 
    802 #define ATW_RXCTL_RER		BIT(25)		/* end of ring */
    803 #define ATW_RXCTL_RCH		BIT(24)		/* ar_buf2 is 2nd chain */
    804 #define ATW_RXCTL_RBS2_MASK	BITS(23,12)	/* ar_buf2 byte count */
    805 #define ATW_RXCTL_RBS1_MASK	BITS(11,0)	/* ar_buf1 byte count */
    806 
    807 #define ATW_RXSTAT_OWN		BIT(31)		/* 1: NIC may fill descriptor */
    808 #define ATW_RXSTAT_ES		BIT(30)		/* error summary, 0 on
    809 						 * success
    810 						 */
    811 #define ATW_RXSTAT_SQL		BIT(29)		/* has signal quality (?) */
    812 #define ATW_RXSTAT_DE		BIT(28)		/* descriptor error---packet is
    813 						 * truncated. last descriptor
    814 						 * only
    815 						 */
    816 #define ATW_RXSTAT_FS		BIT(27)		/* packet's first descriptor */
    817 #define ATW_RXSTAT_LS		BIT(26)		/* packet's last descriptor */
    818 #define ATW_RXSTAT_PCF		BIT(25)		/* received during CFP */
    819 #define ATW_RXSTAT_SFDE		BIT(24)		/* PLCP SFD error */
    820 #define ATW_RXSTAT_SIGE		BIT(23)		/* PLCP signal error */
    821 #define ATW_RXSTAT_CRC16E	BIT(22)		/* PLCP CRC16 error */
    822 #define ATW_RXSTAT_RXTOE	BIT(21)		/* RX time-out, last descriptor
    823 						 * only.
    824 						 */
    825 #define ATW_RXSTAT_CRC32E	BIT(20)		/* CRC32 error */
    826 #define ATW_RXSTAT_ICVE		BIT(19)		/* WEP ICV error */
    827 #define ATW_RXSTAT_DA1		BIT(17)		/* DA bit 1, admin'd address */
    828 #define ATW_RXSTAT_DA0		BIT(16)		/* DA bit 0, group address */
    829 #define ATW_RXSTAT_RXDR_MASK	BITS(15,12)	/* RX data rate */
    830 #define ATW_RXSTAT_FL_MASK	BITS(11,0)	/* RX frame length, last
    831 						 * descriptor only
    832 						 */
    833 
    834 /* Static RAM (contains WEP keys, beacon content). Addresses and size
    835  * are in 16-bit words.
    836  */
    837 #define ATW_SRAM_ADDR_INDIVL_KEY	0x0
    838 #define ATW_SRAM_ADDR_SHARED_KEY	(0x160 * 2)
    839 #define ATW_SRAM_ADDR_SSID	(0x180 * 2)
    840 #define ATW_SRAM_ADDR_SUPRATES	(0x191 * 2)
    841 #define ATW_SRAM_SIZE		(0x200 * 2)
    842 
    843 /*
    844  * Registers for Silicon Laboratories Si4126/Si4126 RF synthesizer.
    845  */
    846 #define SI4126_MAIN	0	/* main configuration */
    847 #define		SI4126_MAIN_AUXSEL_MASK	BITS(13, 12)
    848 #define		SI4126_MAIN_IFDIV_MASK	BITS(11, 10)
    849 #define		SI4126_MAIN_XINDIV2	BIT(6)
    850 #define		SI4126_MAIN_LPWR	BIT(5)
    851 #define		SI4126_MAIN_AUTOPDB	BIT(3)
    852 #define SI4126_GAIN	1	/* phase detector gain */
    853 #define		SI4126_GAIN_KPI_MASK	BITS(5, 4)
    854 #define		SI4126_GAIN_KP2_MASK	BITS(3, 2)
    855 #define		SI4126_GAIN_KP1_MASK	BITS(1, 0)
    856 #define SI4126_POWER	2	/* powerdown */
    857 #define		SI4126_POWER_PDIB	BIT(1)
    858 #define		SI4126_POWER_PDRB	BIT(0)
    859 #define SI4126_RF1N	3	/* RF1 N divider */
    860 #define SI4126_RF2N	4	/* RF2 N divider */
    861 #define SI4126_IFN	5	/* IF N divider */
    862 #define SI4126_RF1R	6	/* RF1 R divider */
    863 #define SI4126_RF2R	7	/* RF2 R divider */
    864 #define SI4126_IFR	8	/* IF R divider */
    865 
    866 /*
    867  * Registers for RF Microdevices RF3000 spread-spectrum baseband modem.
    868  */
    869 #define RF3000_CTL		0x01		/* modem control */
    870 #define RF3000_RXSTAT		RF3000_CTL	/* RX status */
    871 #define		RF3000_CTL_MODE_MASK		BITS(7, 4)
    872 #define		RF3000_RXSTAT_ACQ		BIT(2)
    873 #define		RF3000_RXSTAT_SFD		BIT(1)
    874 #define		RF3000_RXSTAT_CRC		BIT(0)
    875 #define RF3000_CCACTL		0x02		/* CCA control */
    876 /* CCA mode */
    877 #define		RF3000_CCACTL_MODE_MASK		BITS(7, 6)
    878 #define		RF3000_CCACTL_MODE_RSSIT	0	/* RSSI threshold */
    879 #define		RF3000_CCACTL_MODE_ACQ		1	/* acquisition */
    880 #define		RF3000_CCACTL_MODE_BOTH		2	/* threshold or acq. */
    881 /* RSSI threshold for CCA */
    882 #define		RF3000_CCACTL_RSSIT_MASK	BITS(5, 0)
    883 #define RF3000_DIVCTL		0x03		/* diversity control */
    884 #define		RF3000_DIVCTL_ENABLE		BIT(7)	/* enable diversity */
    885 #define		RF3000_DIVCTL_ANTSEL		BIT(6)	/* if ENABLE = 0, set
    886 							 * ANT SEL
    887 							 */
    888 #define RF3000_RSSI		RF3000_DIVCTL	/* RSSI value */
    889 #define		RF3000_RSSI_MASK		BITS(5, 0)
    890 #define RF3000_GAINCTL		0x11		/* TX variable gain control */
    891 #define		RF3000_GAINCTL_TXVGC_MASK	BITS(7, 2)
    892 #define		RF3000_GAINCTL_SCRAMBLER	BIT(1)
    893 #define	RF3000_LOGAINCAL	0x14		/* low gain calibration */
    894 #define		RF3000_LOGAINCAL_CAL_MASK	BITS(5, 0)
    895 #define	RF3000_HIGAINCAL	0x15		/* high gain calibration */
    896 #define		RF3000_HIGAINCAL_CAL_MASK	BITS(5, 0)
    897 #define		RF3000_HIGAINCAL_DSSSPAD	BIT(6)	/* 6dB gain pad for DSSS
    898 							 * modes (meaning?)
    899 							 */
    900 #define RF3000_OPTIONS1		0x1C		/* Options Register 1 */
    901 /* Saturation threshold is 4 + offset, where -3 <= offset <= 3.
    902  * SAT_THRESH is the absolute value, SAT_THRESH_SIGN is the sign.
    903  */
    904 #define		RF3000_OPTIONS1_SAT_THRESH_SIGN	BIT(7)
    905 #define		RF3000_OPTIONS1_SAT_THRESH	BITS(6,5)
    906 #define		RF3000_OPTIONS1_ALTAGC		BIT(4)	/* 1: retrigger AGC
    907  							 * algorithm on ADC
    908  							 * saturation
    909 							 */
    910 #define		RF3000_OPTIONS1_ALTBUS		BIT(3)	/* 1: enable alternate
    911 							 * Tx/Rx data bus
    912 							 * interface.
    913 							 */
    914 #define		RF3000_OPTIONS1_RESERVED0_MASK	BITS(2,0)/* 0 */
    915 
    916 #define RF3000_OPTIONS2		0x1D		/* Options Register 2 */
    917 /* 1: delay next AGC 2us instead of 1us after a 1->0 LNAGS-pin transition. */
    918 #define		RF3000_OPTIONS2_LNAGS_DELAY	BIT(7)
    919 #define		RF3000_OPTIONS2_RESERVED0_MASK	BITS(6,3)	/* 0 */
    920 /* Threshold for AGC re-trigger. 0: high count, 1: low count. */
    921 #define		RF3000_OPTIONS2_RTG_THRESH	BIT(2)
    922 #define		RF3000_OPTIONS2_RESERVED1_MASK	BITS(1,0)	/* 0 */
    923 
    924