xref: /onnv-gate/usr/src/uts/common/io/rtw/rtwreg.h (revision 10448:fe6b44e693c2)
14689Sql147931 /*
2*10448SMikore.Li@Sun.COM  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
34689Sql147931  * Use is subject to license terms.
44689Sql147931  */
54689Sql147931 /*
64689Sql147931  * Copyright (c) 2004, 2005 David Young.  All rights reserved.
74689Sql147931  *
84689Sql147931  * Programmed for NetBSD by David Young.
94689Sql147931  *
104689Sql147931  * Redistribution and use in source and binary forms, with or without
114689Sql147931  * modification, are permitted provided that the following conditions
124689Sql147931  * are met:
134689Sql147931  * 1. Redistributions of source code must retain the above copyright
144689Sql147931  *    notice, this list of conditions and the following disclaimer.
154689Sql147931  * 2. Redistributions in binary form must reproduce the above copyright
164689Sql147931  *    notice, this list of conditions and the following disclaimer in the
174689Sql147931  *    documentation and/or other materials provided with the distribution.
184689Sql147931  * 3. The name of David Young may not be used to endorse or promote
194689Sql147931  *    products derived from this software without specific prior
204689Sql147931  *    written permission.
214689Sql147931  *
224689Sql147931  * THIS SOFTWARE IS PROVIDED BY David Young ``AS IS'' AND ANY
234689Sql147931  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
244689Sql147931  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
254689Sql147931  * PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL David
264689Sql147931  * Young BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
274689Sql147931  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
284689Sql147931  * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
294689Sql147931  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
304689Sql147931  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
314689Sql147931  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
324689Sql147931  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
334689Sql147931  * OF SUCH DAMAGE.
344689Sql147931  */
354689Sql147931 /* Macros for bit twiddling. */
364689Sql147931 
374689Sql147931 #ifndef _RTW_REG_H_
384689Sql147931 #define	_RTW_REG_H_
394689Sql147931 
40*10448SMikore.Li@Sun.COM #ifdef __cplusplus
41*10448SMikore.Li@Sun.COM extern "C" {
42*10448SMikore.Li@Sun.COM #endif
43*10448SMikore.Li@Sun.COM 
444689Sql147931 #ifndef _BIT_TWIDDLE
454689Sql147931 #define	_BIT_TWIDDLE
464689Sql147931 /*
474689Sql147931  * nth bit, BIT(0) == 0x1.
484689Sql147931  */
494689Sql147931 #define	BIT(n) (((n) == 32) ? 0 : ((uint32_t)1 << (n)))
504689Sql147931 
514689Sql147931 /*
524689Sql147931  * bits m through n, m < n.
534689Sql147931  */
544689Sql147931 #define	BITS(m, n) ((BIT(MAX((m), (n)) + 1) - 1) ^ (BIT(MIN((m), (n))) - 1))
554689Sql147931 
564689Sql147931 /*
574689Sql147931  * find least significant bit that is set
584689Sql147931  */
594689Sql147931 #define	LOWEST_SET_BIT(x) ((((x) - 1) & (x)) ^ (x))
604689Sql147931 
614689Sql147931 /*
624689Sql147931  * for x a power of two and p a non-negative integer, is x a greater
634689Sql147931  * power than 2**p?
644689Sql147931  */
654689Sql147931 #define	GTEQ_POWER(x, p) (((ulong_t)(x) >> (p)) != 0)
664689Sql147931 
674689Sql147931 #define	MASK_TO_SHIFT2(m) (GTEQ_POWER(LOWEST_SET_BIT((m)), 1) ? 1 : 0)
684689Sql147931 
694689Sql147931 #define	MASK_TO_SHIFT4(m) \
704689Sql147931 	(GTEQ_POWER(LOWEST_SET_BIT((m)), 2) \
714689Sql147931 	    ? 2 + MASK_TO_SHIFT2((m) >> 2) \
724689Sql147931 	    : MASK_TO_SHIFT2((m)))
734689Sql147931 
744689Sql147931 #define	MASK_TO_SHIFT8(m) \
754689Sql147931 	(GTEQ_POWER(LOWEST_SET_BIT((m)), 4) \
764689Sql147931 	    ? 4 + MASK_TO_SHIFT4((m) >> 4) \
774689Sql147931 	    : MASK_TO_SHIFT4((m)))
784689Sql147931 
794689Sql147931 #define	MASK_TO_SHIFT16(m) \
804689Sql147931 	(GTEQ_POWER(LOWEST_SET_BIT((m)), 8) \
814689Sql147931 	    ? 8 + MASK_TO_SHIFT8((m) >> 8) \
824689Sql147931 	    : MASK_TO_SHIFT8((m)))
834689Sql147931 
844689Sql147931 #define	MASK_TO_SHIFT(m) \
854689Sql147931 	(GTEQ_POWER(LOWEST_SET_BIT((m)), 16) \
864689Sql147931 	    ? 16 + MASK_TO_SHIFT16((m) >> 16) \
874689Sql147931 	    : MASK_TO_SHIFT16((m)))
884689Sql147931 
894689Sql147931 #define	MASK_AND_RSHIFT(x, mask) (((x) & (mask)) >> MASK_TO_SHIFT(mask))
904689Sql147931 #define	LSHIFT(x, mask) ((x) << MASK_TO_SHIFT(mask))
914689Sql147931 #define	MASK_AND_REPLACE(reg, val, mask) ((reg & ~mask) | LSHIFT(val, mask))
924689Sql147931 #define	PRESHIFT(m) MASK_AND_RSHIFT((m), (m))
934689Sql147931 
944689Sql147931 #endif /* _BIT_TWIDDLE */
954689Sql147931 
964689Sql147931 /* RTL8180L Host Control and Status Registers */
974689Sql147931 
984689Sql147931 /*
994689Sql147931  * ID Register: MAC addr, 6 bytes.
1004689Sql147931  * Auto-loaded from EEPROM. Read by byte, by word, or by double word,
1014689Sql147931  * but write only by double word.
1024689Sql147931  */
1034689Sql147931 #define	RTW_IDR0	0x00
1044689Sql147931 #define	RTW_IDR1	0x04
1054689Sql147931 
1064689Sql147931 #define	RTW_MAR0	0x08	/* Multicast filter, 64b. */
1074689Sql147931 #define	RTW_MAR1	0x0c
1084689Sql147931 
1094689Sql147931 /*
1104689Sql147931  * Timing Synchronization Function Timer Register,
1114689Sql147931  * low word, 32b, read-only.
1124689Sql147931  */
1134689Sql147931 #define	RTW_TSFTRL	0x18
1144689Sql147931 #define	RTW_TSFTRH	0x1c	/* High word, 32b, read-only. */
1154689Sql147931 /*
1164689Sql147931  * Transmit Low Priority Descriptors Start Address,
1174689Sql147931  * 32b, 256-byte alignment.
1184689Sql147931  */
1194689Sql147931 #define	RTW_TLPDA	0x20
1204689Sql147931 /*
1214689Sql147931  * Transmit Normal Priority Descriptors Start  Address,
1224689Sql147931  * 32b, 256-byte alignment.
1234689Sql147931  */
1244689Sql147931 #define	RTW_TNPDA	0x24
1254689Sql147931 /*
1264689Sql147931  * Transmit High Priority Descriptors Start Address,
1274689Sql147931  * 32b, 256-byte alignment.
1284689Sql147931  */
1294689Sql147931 #define	RTW_THPDA	0x28
1304689Sql147931 
1314689Sql147931 #define	RTW_BRSR	0x2c	/* Basic Rate Set Register, 16b */
1324689Sql147931 /*
1334689Sql147931  * 1: use short PLCP header for CTS/ACK packet,
1344689Sql147931  * 0: use long PLCP header
1354689Sql147931  */
1364689Sql147931 #define	RTW_BRSR_BPLCP	BIT(8)
1374689Sql147931 #define	RTW_BRSR_MBR8180_MASK	BITS(1, 0)	/* Maximum Basic Service Rate */
1384689Sql147931 #define	RTW_BRSR_MBR8180_1MBPS	LSHIFT(0, RTW_BRSR_MBR8180_MASK)
1394689Sql147931 #define	RTW_BRSR_MBR8180_2MBPS	LSHIFT(1, RTW_BRSR_MBR8180_MASK)
1404689Sql147931 #define	RTW_BRSR_MBR8180_5MBPS	LSHIFT(2, RTW_BRSR_MBR8180_MASK)
1414689Sql147931 #define	RTW_BRSR_MBR8180_11MBPS	LSHIFT(3, RTW_BRSR_MBR8180_MASK)
1424689Sql147931 
1434689Sql147931 /*
1444689Sql147931  * 8181 and 8180 docs conflict!
1454689Sql147931  */
1464689Sql147931 #define	RTW_BRSR_MBR8181_1MBPS	BIT(0)
1474689Sql147931 #define	RTW_BRSR_MBR8181_2MBPS	BIT(1)
1484689Sql147931 #define	RTW_BRSR_MBR8181_5MBPS	BIT(2)
1494689Sql147931 #define	RTW_BRSR_MBR8181_11MBPS	BIT(3)
1504689Sql147931 
1514689Sql147931 #define	RTW_BSSID	0x2e
1524689Sql147931 /*
1534689Sql147931  * BSSID, 6 bytes
1544689Sql147931  */
1554689Sql147931 #define	RTW_BSSID16	0x2e		/* first two bytes */
1564689Sql147931 #define	RTW_BSSID32	(0x2e + 4)	/* remaining four bytes */
1574689Sql147931 #define	RTW_BSSID0	RTW_BSSID16		/* BSSID[0], 8b */
1584689Sql147931 #define	RTW_BSSID1	(RTW_BSSID0 + 1)	/* BSSID[1], 8b */
1594689Sql147931 #define	RTW_BSSID2	(RTW_BSSID1 + 1)	/* BSSID[2], 8b */
1604689Sql147931 #define	RTW_BSSID3	(RTW_BSSID2 + 1)	/* BSSID[3], 8b */
1614689Sql147931 #define	RTW_BSSID4	(RTW_BSSID3 + 1)	/* BSSID[4], 8b */
1624689Sql147931 #define	RTW_BSSID5	(RTW_BSSID4 + 1)	/* BSSID[5], 8b */
1634689Sql147931 
1644689Sql147931 #define	RTW_CR		0x37	/* Command Register, 8b */
1654689Sql147931 /*
1664689Sql147931  * Reset: host sets to 1 to disable
1674689Sql147931  * transmitter & receiver, reinitialize FIFO.
1684689Sql147931  * RTL8180L sets to 0 to signal completion.
1694689Sql147931  */
1704689Sql147931 #define	RTW_CR_RST	BIT(4)
1714689Sql147931 /*
1724689Sql147931  * Receiver Enable: host enables receiver
1734689Sql147931  * by writing 1. RTL8180L indicates receiver
1744689Sql147931  * is active with 1. After power-up, host
1754689Sql147931  * must wait for reset before writing.
1764689Sql147931  */
1774689Sql147931 #define	RTW_CR_RE	BIT(3)
1784689Sql147931 /*
1794689Sql147931  * Transmitter Enable: host enables transmitter
1804689Sql147931  * by writing 1. RTL8180L indicates transmitter
1814689Sql147931  * is active with 1. After power-up, host
1824689Sql147931  * must wait for reset before writing.
1834689Sql147931  */
1844689Sql147931 #define	RTW_CR_TE	BIT(2)
1854689Sql147931 /*
1864689Sql147931  * PCI Multiple Read/Write enable:
1874689Sql147931  * 1 enables,
1884689Sql147931  * 0 disables. XXX RTL8180, only?
1894689Sql147931  */
1904689Sql147931 #define	RTW_CR_MULRW	BIT(0)
1914689Sql147931 
1924689Sql147931 #define	RTW_IMR		0x3c	/* Interrupt Mask Register, 16b */
1934689Sql147931 #define	RTW_ISR		0x3e	/* Interrupt status register, 16b */
1944689Sql147931 
1954689Sql147931 #define	RTW_INTR_TXFOVW	BIT(15)		/* Tx FIFO Overflow */
1964689Sql147931 /*
1974689Sql147931  * Time Out: 1 indicates RTW_TSFTR[0:31] = RTW_TINT
1984689Sql147931  */
1994689Sql147931 #define	RTW_INTR_TIMEOUT	BIT(14)
2004689Sql147931 /*
2014689Sql147931  * Beacon Time Out: time for host to prepare beacon:
2024689Sql147931  * RTW_TSFTR % (RTW_BCNITV_BCNITV * TU) =
2034689Sql147931  * (RTW_BCNITV_BCNITV * TU - RTW_BINTRITV)
2044689Sql147931  */
2054689Sql147931 #define	RTW_INTR_BCNINT	BIT(13)
2064689Sql147931 /*
2074689Sql147931  * ATIM Time Out: ATIM interval will pass,
2084689Sql147931  * RTW_TSFTR % (RTW_BCNITV_BCNITV * TU) =
2094689Sql147931  * (RTW_ATIMWND_ATIMWND * TU - RTW_ATIMTRITV)
2104689Sql147931  */
2114689Sql147931 #define	RTW_INTR_ATIMINT	BIT(12)
2124689Sql147931 /*
2134689Sql147931  * Tx Beacon Descriptor Error:
2144689Sql147931  * beacon transmission aborted because
2154689Sql147931  * frame Rx'd
2164689Sql147931  */
2174689Sql147931 #define	RTW_INTR_TBDER	BIT(11)
2184689Sql147931 #define	RTW_INTR_TBDOK	BIT(10)	/* Tx Beacon Descriptor OK */
2194689Sql147931 /*
2204689Sql147931  * Tx High Priority Descriptor Error:
2214689Sql147931  * reached short/long retry limit
2224689Sql147931  */
2234689Sql147931 #define	RTW_INTR_THPDER	BIT(9)
2244689Sql147931 #define	RTW_INTR_THPDOK	BIT(8)	/* Tx High Priority Descriptor OK */
2254689Sql147931 /*
2264689Sql147931  * Tx Normal Priority Descriptor Error:
2274689Sql147931  * reached short/long retry limit
2284689Sql147931  */
2294689Sql147931 #define	RTW_INTR_TNPDER	BIT(7)
2304689Sql147931 #define	RTW_INTR_TNPDOK	BIT(6)	/* Tx Normal Priority Descriptor OK */
2314689Sql147931 /*
2324689Sql147931  * Rx FIFO Overflow: either RDU (see below)
2334689Sql147931  * or PCI bus too slow/busy
2344689Sql147931  */
2354689Sql147931 #define	RTW_INTR_RXFOVW	BIT(5)
2364689Sql147931 #define	RTW_INTR_RDU	BIT(4)	/* Rx Descriptor Unavailable */
2374689Sql147931 /*
2384689Sql147931  * Tx Low Priority Descriptor Error
2394689Sql147931  * reached short/long retry limit
2404689Sql147931  */
2414689Sql147931 #define	RTW_INTR_TLPDER	BIT(3)
2424689Sql147931 #define	RTW_INTR_TLPDOK	BIT(2)	/* Tx Low Priority Descriptor OK */
2434689Sql147931 #define	RTW_INTR_RER	BIT(1)	/* Rx Error: CRC32 or ICV error */
2444689Sql147931 #define	RTW_INTR_ROK	BIT(0)	/* Rx OK */
2454689Sql147931 
2464689Sql147931 /*
2474689Sql147931  * Convenient interrupt conjunctions.
2484689Sql147931  */
2494689Sql147931 #define	RTW_INTR_RX	(RTW_INTR_RER|RTW_INTR_ROK | \
2504689Sql147931 			RTW_INTR_RDU |RTW_INTR_RXFOVW)
2514689Sql147931 #define	RTW_INTR_TX	(RTW_INTR_TLPDER|RTW_INTR_TLPDOK|RTW_INTR_THPDER|\
2524689Sql147931 			RTW_INTR_THPDOK|RTW_INTR_TNPDER|RTW_INTR_TNPDOK|\
2534689Sql147931 			RTW_INTR_TBDER|RTW_INTR_TBDOK)
2544689Sql147931 #define	RTW_INTR_BEACON	(RTW_INTR_BCNINT)
2554689Sql147931 #define	RTW_INTR_IOERROR	(RTW_INTR_TXFOVW|RTW_INTR_RXFOVW|RTW_INTR_RDU)
2564689Sql147931 
2574689Sql147931 #define	RTW_TCR		0x40	/* Transmit Configuration Register, 32b */
2584689Sql147931 #define	RTW_TCR_CWMIN	BIT(31)	/* 1: CWmin = 8, 0: CWmin = 32. */
2594689Sql147931 /*
2604689Sql147931  * 1: host assigns 802.11 sequence number,
2614689Sql147931  * 0: hardware assigns sequence number
2624689Sql147931  */
2634689Sql147931 #define	RTW_TCR_SWSEQ	BIT(30)
2644689Sql147931 /* Hardware version ID, read-only */
2654689Sql147931 #define	RTW_TCR_HWVERID_MASK	BITS(29, 25)
2664689Sql147931 #define	RTW_TCR_HWVERID_D	LSHIFT(26, RTW_TCR_HWVERID_MASK)
2674689Sql147931 #define	RTW_TCR_HWVERID_F	LSHIFT(27, RTW_TCR_HWVERID_MASK)
2684689Sql147931 #define	RTW_TCR_HWVERID_RTL8180	RTW_TCR_HWVERID_F
2694689Sql147931 
2704689Sql147931 /*
2714689Sql147931  * Set ACK/CTS Timeout (EIFS).
2724689Sql147931  * 1: ACK rate = max(RTW_BRSR_MBR, Rx rate) (XXX not min? typo in datasheet?)
2734689Sql147931  * 0: ACK rate = 1Mbps
2744689Sql147931  */
2754689Sql147931 #define	RTW_TCR_SAT	BIT(24)
2764689Sql147931 /* Max DMA Burst Size per Tx DMA Burst */
2774689Sql147931 #define	RTW_TCR_MXDMA_MASK	BITS(23, 21)
2784689Sql147931 #define	RTW_TCR_MXDMA_16	LSHIFT(0, RTW_TCR_MXDMA_MASK)
2794689Sql147931 #define	RTW_TCR_MXDMA_32	LSHIFT(1, RTW_TCR_MXDMA_MASK)
2804689Sql147931 #define	RTW_TCR_MXDMA_64	LSHIFT(2, RTW_TCR_MXDMA_MASK)
2814689Sql147931 #define	RTW_TCR_MXDMA_128	LSHIFT(3, RTW_TCR_MXDMA_MASK)
2824689Sql147931 #define	RTW_TCR_MXDMA_256	LSHIFT(4, RTW_TCR_MXDMA_MASK)
2834689Sql147931 #define	RTW_TCR_MXDMA_512	LSHIFT(5, RTW_TCR_MXDMA_MASK)
2844689Sql147931 #define	RTW_TCR_MXDMA_1024	LSHIFT(6, RTW_TCR_MXDMA_MASK)
2854689Sql147931 #define	RTW_TCR_MXDMA_2048	LSHIFT(7, RTW_TCR_MXDMA_MASK)
2864689Sql147931 
2874689Sql147931 #define	RTW_TCR_DISCW		BIT(20)	/* disable 802.11 random backoff */
2884689Sql147931 
2894689Sql147931 /*
2904689Sql147931  * host lets RTL8180 append ICV to WEP packets
2914689Sql147931  */
2924689Sql147931 #define	RTW_TCR_ICV		BIT(19)
2934689Sql147931 
2944689Sql147931 /*
2954689Sql147931  * Loopback Test: disables TXI/TXQ outputs.
2964689Sql147931  */
2974689Sql147931 #define	RTW_TCR_LBK_MASK	BITS(18, 17)
2984689Sql147931 #define	RTW_TCR_LBK_NORMAL	LSHIFT(0, RTW_TCR_LBK_MASK) /* normal ops */
2994689Sql147931 #define	RTW_TCR_LBK_MAC		LSHIFT(1, RTW_TCR_LBK_MASK) /* MAC loopback */
3004689Sql147931 #define	RTW_TCR_LBK_BBP		LSHIFT(2, RTW_TCR_LBK_MASK) /* baseband loop. */
3014689Sql147931 #define	RTW_TCR_LBK_CONT	LSHIFT(3, RTW_TCR_LBK_MASK) /* continuous Tx */
3024689Sql147931 
3034689Sql147931 /*
3044689Sql147931  * 0: RTL8180 appends CRC32
3054689Sql147931  * 1: host appends CRC32
3064689Sql147931  *
3074689Sql147931  * (I *think* this is right.  The docs have a mysterious
3084689Sql147931  *  description in the  passive voice.)
3094689Sql147931  */
3104689Sql147931 #define	RTW_TCR_CRC	BIT(16)
3114689Sql147931 #define	RTW_TCR_SRL_MASK	BITS(15, 8)	/* Short Retry Limit */
3124689Sql147931 #define	RTW_TCR_LRL_MASK	BITS(7, 0)	/* Long Retry Limit */
3134689Sql147931 
3144689Sql147931 #define	RTW_RCR		0x44	/* Receive Configuration Register, 32b */
3154689Sql147931 /*
3164689Sql147931  * only do Early Rx on packets longer than 1536 bytes
3174689Sql147931  */
3184689Sql147931 #define	RTW_RCR_ONLYERLPKT	BIT(31)
3194689Sql147931 #define	RTW_RCR_ENCS2		BIT(30)	/* enable carrier sense method 2 */
3204689Sql147931 #define	RTW_RCR_ENCS1		BIT(29)	/* enable carrier sense method 1 */
3214689Sql147931 #define	RTW_RCR_ENMARP		BIT(28)	/* enable MAC auto-reset PHY */
3224689Sql147931 /*
3234689Sql147931  * Check BSSID/ToDS/FromDS: set "Link On" when received BSSID
3244689Sql147931  * matches RTW_BSSID and received ToDS/FromDS are appropriate
3254689Sql147931  * according to RTW_MSR_NETYPE.
3264689Sql147931  */
3274689Sql147931 #define	RTW_RCR_CBSSID		BIT(23)
3284689Sql147931 #define	RTW_RCR_APWRMGT		BIT(22)	/* accept packets w/ PWRMGMT bit set */
3294689Sql147931 /*
3304689Sql147931  * when RTW_MSR_NETYPE ==  RTW_MSR_NETYPE_INFRA_OK, accept
3314689Sql147931  * broadcast/multicast packets whose 3rd address matches RTL8180's MAC.
3324689Sql147931  */
3334689Sql147931 #define	RTW_RCR_ADD3		BIT(21)
3344689Sql147931 #define	RTW_RCR_AMF		BIT(20)	/* accept management frames */
3354689Sql147931 #define	RTW_RCR_ACF		BIT(19)	/* accept control frames */
3364689Sql147931 #define	RTW_RCR_ADF		BIT(18)	/* accept data frames */
3374689Sql147931 /*
3384689Sql147931  * Rx FIFO Threshold: RTL8180 begins PCI transfer when this many data
3394689Sql147931  * bytes are received
3404689Sql147931  */
3414689Sql147931 #define	RTW_RCR_RXFTH_MASK	BITS(15, 13)
3424689Sql147931 #define	RTW_RCR_RXFTH_64	LSHIFT(2, RTW_RCR_RXFTH_MASK)
3434689Sql147931 #define	RTW_RCR_RXFTH_128	LSHIFT(3, RTW_RCR_RXFTH_MASK)
3444689Sql147931 #define	RTW_RCR_RXFTH_256	LSHIFT(4, RTW_RCR_RXFTH_MASK)
3454689Sql147931 #define	RTW_RCR_RXFTH_512	LSHIFT(5, RTW_RCR_RXFTH_MASK)
3464689Sql147931 #define	RTW_RCR_RXFTH_1024	LSHIFT(6, RTW_RCR_RXFTH_MASK)
3474689Sql147931 #define	RTW_RCR_RXFTH_WHOLE	LSHIFT(7, RTW_RCR_RXFTH_MASK)
3484689Sql147931 
3494689Sql147931 #define	RTW_RCR_AICV		BIT(12)	/* accept frames w/ ICV errors */
3504689Sql147931 
3514689Sql147931 /*
3524689Sql147931  * Max DMA Burst Size per Rx DMA Burst
3534689Sql147931  */
3544689Sql147931 #define	RTW_RCR_MXDMA_MASK	BITS(10, 8)
3554689Sql147931 #define	RTW_RCR_MXDMA_16	LSHIFT(0, RTW_RCR_MXDMA_MASK)
3564689Sql147931 #define	RTW_RCR_MXDMA_32	LSHIFT(1, RTW_RCR_MXDMA_MASK)
3574689Sql147931 #define	RTW_RCR_MXDMA_64	LSHIFT(2, RTW_RCR_MXDMA_MASK)
3584689Sql147931 #define	RTW_RCR_MXDMA_128	LSHIFT(3, RTW_RCR_MXDMA_MASK)
3594689Sql147931 #define	RTW_RCR_MXDMA_256	LSHIFT(4, RTW_RCR_MXDMA_MASK)
3604689Sql147931 #define	RTW_RCR_MXDMA_512	LSHIFT(5, RTW_RCR_MXDMA_MASK)
3614689Sql147931 #define	RTW_RCR_MXDMA_1024	LSHIFT(6, RTW_RCR_MXDMA_MASK)
3624689Sql147931 #define	RTW_RCR_MXDMA_UNLIMITED	LSHIFT(7, RTW_RCR_MXDMA_MASK)
3634689Sql147931 
3644689Sql147931 /*
3654689Sql147931  * EEPROM type, read-only. 1: EEPROM is 93c56, 0: 93c46
3664689Sql147931  */
3674689Sql147931 #define	RTW_RCR_9356SEL		BIT(6)
3684689Sql147931 
3694689Sql147931 #define	RTW_RCR_ACRC32		BIT(5)	/* accept frames w/ CRC32 errors */
3704689Sql147931 #define	RTW_RCR_AB		BIT(3)	/* accept broadcast frames */
3714689Sql147931 #define	RTW_RCR_AM		BIT(2)	/* accept multicast frames */
3724689Sql147931 /*
3734689Sql147931  * accept physical match frames. XXX means PLCP header ok?
3744689Sql147931  */
3754689Sql147931 #define	RTW_RCR_APM		BIT(1)
3764689Sql147931 #define	RTW_RCR_AAP		BIT(0)	/* accept frames w/ destination */
3774689Sql147931 
3784689Sql147931 /*
3794689Sql147931  * Additional bits to set in monitor mode.
3804689Sql147931  */
3814689Sql147931 #define	RTW_RCR_MONITOR (		\
3824689Sql147931     RTW_RCR_AAP |			\
3834689Sql147931     RTW_RCR_ACF |			\
3844689Sql147931     RTW_RCR_ACRC32 |			\
3854689Sql147931     RTW_RCR_AICV |			\
3864689Sql147931     0)
3874689Sql147931 
3884689Sql147931 /*
3894689Sql147931  * The packet filter bits.
3904689Sql147931  */
3914689Sql147931 #define	RTW_RCR_PKTFILTER_MASK (\
3924689Sql147931     RTW_RCR_ENCS1|RTW_RCR_ENCS2|\
3934689Sql147931     RTW_RCR_AAP |		\
3944689Sql147931     RTW_RCR_AB |		\
3954689Sql147931     RTW_RCR_ACF |		\
3964689Sql147931     RTW_RCR_ACRC32 |		\
3974689Sql147931     RTW_RCR_ADD3 |		\
3984689Sql147931     RTW_RCR_ADF |		\
3994689Sql147931     RTW_RCR_AICV |		\
4004689Sql147931     RTW_RCR_AM |		\
4014689Sql147931     RTW_RCR_AMF |		\
4024689Sql147931     RTW_RCR_APM |		\
4034689Sql147931     RTW_RCR_APWRMGT |		\
4044689Sql147931     0)
4054689Sql147931 
4064689Sql147931 /*
4074689Sql147931  * Receive power-management frames and mgmt/ctrl/data frames.
4084689Sql147931  */
4094689Sql147931 #define	RTW_RCR_PKTFILTER_DEFAULT	(	\
4104689Sql147931     RTW_RCR_ONLYERLPKT |			\
4114689Sql147931     RTW_RCR_ENCS1 |				\
4124689Sql147931     RTW_RCR_CBSSID |				\
4134689Sql147931     RTW_RCR_ADF |				\
4144689Sql147931     RTW_RCR_AMF |				\
4154689Sql147931     RTW_RCR_APM |				\
4164689Sql147931     RTW_RCR_AM |		\
4174689Sql147931     RTW_RCR_AB |		\
4184689Sql147931     0)
4194689Sql147931 #define	RTW_RCR_PROMIC (	\
4204689Sql147931     RTW_RCR_AAP |		\
4214689Sql147931     0)
4224689Sql147931 
4234689Sql147931 #define	RTW_TINT	0x48	/* Timer Interrupt Register, 32b */
4244689Sql147931 /*
4254689Sql147931  * Transmit Beacon Descriptor Start Address,
4264689Sql147931  *  32b, 256-byte alignment
4274689Sql147931  */
4284689Sql147931 #define	RTW_TBDA	0x4c
4294689Sql147931 #define	RTW_9346CR	0x50	/* 93c46/93c56 Command Register, 8b */
4304689Sql147931 #define	RTW_9346CR_EEM_MASK	BITS(7, 6)	/* Operating Mode */
4314689Sql147931 #define	RTW_9346CR_EEM_NORMAL	LSHIFT(0, RTW_9346CR_EEM_MASK)
4324689Sql147931 /*
4334689Sql147931  * Load the EEPROM. Reset registers to defaults.
4344689Sql147931  * Takes ~2ms. RTL8180 indicates completion with RTW_9346CR_EEM_NORMAL.
4354689Sql147931  * XXX RTL8180 only?
4364689Sql147931  */
4374689Sql147931 #define	RTW_9346CR_EEM_AUTOLOAD	LSHIFT(1, RTW_9346CR_EEM_MASK)
4384689Sql147931 /*
4394689Sql147931  * Disable network & bus-master operations and enable
4404689Sql147931  * _EECS, _EESK, _EEDI, _EEDO.
4414689Sql147931  * XXX RTL8180 only?
4424689Sql147931  */
4434689Sql147931 #define	RTW_9346CR_EEM_PROGRAM	LSHIFT(2, RTW_9346CR_EEM_MASK)
4444689Sql147931 /* Enable RTW_CONFIG[0123] registers. */
4454689Sql147931 #define	RTW_9346CR_EEM_CONFIG	LSHIFT(3, RTW_9346CR_EEM_MASK)
4464689Sql147931 /*
4474689Sql147931  * EEPROM pin status/control in _EEM_CONFIG, _EEM_AUTOLOAD modes.
4484689Sql147931  * XXX RTL8180 only?
4494689Sql147931  */
4504689Sql147931 #define	RTW_9346CR_EECS	BIT(3)
4514689Sql147931 #define	RTW_9346CR_EESK	BIT(2)
4524689Sql147931 #define	RTW_9346CR_EEDI	BIT(1)
4534689Sql147931 #define	RTW_9346CR_EEDO	BIT(0)	/* read-only */
4544689Sql147931 
4554689Sql147931 #define	RTW_CONFIG0	0x51	/* Configuration Register 0, 8b */
4564689Sql147931 /*
4574689Sql147931  * implements 40-bit WEP, XXX RTL8180 only?
4584689Sql147931  */
4594689Sql147931 #define	RTW_CONFIG0_WEP40	BIT(7)
4604689Sql147931 /*
4614689Sql147931  * implements 104-bit WEP, from EEPROM, read-only XXX RTL8180 only?
4624689Sql147931  */
4634689Sql147931 #define	RTW_CONFIG0_WEP104	BIT(6)
4644689Sql147931 /*
4654689Sql147931  * 1: RTW_PSR_LEDGPO[01] control LED[01] pins.
4664689Sql147931  * 0: LED behavior defined by RTW_CONFIG1_LEDS10_MASK
4674689Sql147931  * XXX RTL8180 only?
4684689Sql147931  */
4694689Sql147931 #define	RTW_CONFIG0_LEDGPOEN	BIT(4)
4704689Sql147931 /*
4714689Sql147931  * auxiliary power is present, read-only
4724689Sql147931  */
4734689Sql147931 #define	RTW_CONFIG0_AUXPWR	BIT(3)
4744689Sql147931 /*
4754689Sql147931  * Geographic Location, read-only
4764689Sql147931  */
4774689Sql147931 #define	RTW_CONFIG0_GL_MASK		BITS(1, 0)
4784689Sql147931 /*
4794689Sql147931  * _RTW_CONFIG0_GL_* is what the datasheet says, but RTW_CONFIG0_GL_*
4804689Sql147931  * work.
4814689Sql147931  */
4824689Sql147931 #define	_RTW_CONFIG0_GL_USA		LSHIFT(3, RTW_CONFIG0_GL_MASK)
4834689Sql147931 #define	RTW_CONFIG0_GL_EUROPE		LSHIFT(2, RTW_CONFIG0_GL_MASK)
4844689Sql147931 #define	RTW_CONFIG0_GL_JAPAN		LSHIFT(1, RTW_CONFIG0_GL_MASK)
4854689Sql147931 #define	RTW_CONFIG0_GL_USA		LSHIFT(0, RTW_CONFIG0_GL_MASK)
4864689Sql147931 /*
4874689Sql147931  * RTL8181 datasheet says RTW_CONFIG0_GL_JAPAN = 0.
4884689Sql147931  */
4894689Sql147931 
4904689Sql147931 #define	RTW_CONFIG1	0x52	/* Configuration Register 1, 8b */
4914689Sql147931 
4924689Sql147931 /*
4934689Sql147931  * LED configuration. From EEPROM. Read/write.
4944689Sql147931  *
4954689Sql147931  * Setting				LED0		LED1
4964689Sql147931  * -------				----		----
4974689Sql147931  * RTW_CONFIG1_LEDS_ACT_INFRA		Activity	Infrastructure
4984689Sql147931  * RTW_CONFIG1_LEDS_ACT_LINK		Activity	Link
4994689Sql147931  * RTW_CONFIG1_LEDS_TX_RX		Tx		Rx
5004689Sql147931  * RTW_CONFIG1_LEDS_LINKACT_INFRA	Link/Activity	Infrastructure
5014689Sql147931  */
5024689Sql147931 #define	RTW_CONFIG1_LEDS_MASK	BITS(7, 6)
5034689Sql147931 #define	RTW_CONFIG1_LEDS_ACT_INFRA	LSHIFT(0, RTW_CONFIG1_LEDS_MASK)
5044689Sql147931 #define	RTW_CONFIG1_LEDS_ACT_LINK	LSHIFT(1, RTW_CONFIG1_LEDS_MASK)
5054689Sql147931 #define	RTW_CONFIG1_LEDS_TX_RX		LSHIFT(2, RTW_CONFIG1_LEDS_MASK)
5064689Sql147931 #define	RTW_CONFIG1_LEDS_LINKACT_INFRA	LSHIFT(3, RTW_CONFIG1_LEDS_MASK)
5074689Sql147931 
5084689Sql147931 /*
5094689Sql147931  * LWAKE Output Signal. Only applicable to Cardbus. Pulse width is 150ms.
5104689Sql147931  *
5114689Sql147931  *                                   RTW_CONFIG1_LWACT
5124689Sql147931  *				0			1
5134689Sql147931  * RTW_CONFIG4_LWPTN	0	active high		active low
5144689Sql147931  *			1	positive pulse		negative pulse
5154689Sql147931  */
5164689Sql147931 #define	RTW_CONFIG1_LWACT	BIT(4)
5174689Sql147931 
5184689Sql147931 #define	RTW_CONFIG1_MEMMAP	BIT(3)	/* using PCI memory space, read-only */
5194689Sql147931 #define	RTW_CONFIG1_IOMAP	BIT(2)	/* using PCI I/O space, read-only */
5204689Sql147931 /*
5214689Sql147931  * if set, VPD from offsets 0x40-0x7f in EEPROM are at
5224689Sql147931  * registers 0x60-0x67 of PCI Configuration Space ( XXX huh? )
5234689Sql147931  */
5244689Sql147931 #define	RTW_CONFIG1_VPD		BIT(1)
5254689Sql147931 #define	RTW_CONFIG1_PMEN	BIT(0)	/* Power Management Enable: TBD */
5264689Sql147931 
5274689Sql147931 #define	RTW_CONFIG2	0x53	/* Configuration Register 2, 8b */
5284689Sql147931 /*
5294689Sql147931  * clocks are locked, read-only:
5304689Sql147931  * Tx frequency & symbol clocks are derived from the same OSC
5314689Sql147931  */
5324689Sql147931 #define	RTW_CONFIG2_LCK	BIT(7)
5334689Sql147931 #define	RTW_CONFIG2_ANT	BIT(6)	/* diversity enabled, read-only */
5344689Sql147931 /*
5354689Sql147931  * Descriptor Polling State: enable test mode.
5364689Sql147931  */
5374689Sql147931 #define	RTW_CONFIG2_DPS	BIT(3)
5384689Sql147931 #define	RTW_CONFIG2_PAPESIGN		BIT(2)		/* TBD, from EEPROM */
5394689Sql147931 #define	RTW_CONFIG2_PAPETIME_MASK	BITS(1, 0)	/* TBD, from EEPROM */
5404689Sql147931 
5414689Sql147931 #define	RTW_ANAPARM	0x54	/* Analog parameter, 32b */
5424689Sql147931 /*
5434689Sql147931  * undocumented bits which appear to control the power state of the RF
5444689Sql147931  * components
5454689Sql147931  */
5464689Sql147931 #define	RTW_ANAPARM_RFPOW0_MASK	BITS(30, 28)
5474689Sql147931 #define	RTW_ANAPARM_RFPOW_MASK	\
5484689Sql147931 	(RTW_ANAPARM_RFPOW0_MASK|RTW_ANAPARM_RFPOW1_MASK)
5494689Sql147931 
5504689Sql147931 /*
5514689Sql147931  * 1: disable Tx DAC,
5524689Sql147931  * 0: enable
5534689Sql147931  */
5544689Sql147931 #define	RTW_ANAPARM_TXDACOFF	BIT(27)
5554689Sql147931 /*
5564689Sql147931  * undocumented bits which appear to control the power state of the RF
5574689Sql147931  * components
5584689Sql147931  */
5594689Sql147931 #define	RTW_ANAPARM_RFPOW1_MASK	BITS(26, 20)
5604689Sql147931 
5614689Sql147931 /*
5624689Sql147931  * Maxim On/Sleep/Off control
5634689Sql147931  */
5644689Sql147931 #define	RTW_ANAPARM_RFPOW_MAXIM_ON	LSHIFT(0x8, RTW_ANAPARM_RFPOW1_MASK)
5654689Sql147931 
5664689Sql147931 /*
5674689Sql147931  * reg[RTW_ANAPARM] |= RTW_ANAPARM_TXDACOFF;
5684689Sql147931  */
5694689Sql147931 #define	RTW_ANAPARM_RFPOW_MAXIM_SLEEP	LSHIFT(0x378, RTW_ANAPARM_RFPOW1_MASK)
5704689Sql147931 
5714689Sql147931 /*
5724689Sql147931  * reg[RTW_ANAPARM] |= RTW_ANAPARM_TXDACOFF;
5734689Sql147931  */
5744689Sql147931 #define	RTW_ANAPARM_RFPOW_MAXIM_OFF	LSHIFT(0x379, RTW_ANAPARM_RFPOW1_MASK)
5754689Sql147931 
5764689Sql147931 /*
5774689Sql147931  * RFMD On/Sleep/Off control
5784689Sql147931  */
5794689Sql147931 #define	RTW_ANAPARM_RFPOW_RFMD_ON	LSHIFT(0x408, RTW_ANAPARM_RFPOW1_MASK)
5804689Sql147931 
5814689Sql147931 /*
5824689Sql147931  * reg[RTW_ANAPARM] |= RTW_ANAPARM_TXDACOFF;
5834689Sql147931  */
5844689Sql147931 #define	RTW_ANAPARM_RFPOW_RFMD_SLEEP	LSHIFT(0x378, RTW_ANAPARM_RFPOW1_MASK)
5854689Sql147931 
5864689Sql147931 /*
5874689Sql147931  * reg[RTW_ANAPARM] |= RTW_ANAPARM_TXDACOFF;
5884689Sql147931  */
5894689Sql147931 #define	RTW_ANAPARM_RFPOW_RFMD_OFF	LSHIFT(0x379, RTW_ANAPARM_RFPOW1_MASK)
5904689Sql147931 
5914689Sql147931 /*
5924689Sql147931  * Philips On/Sleep/Off control
5934689Sql147931  */
5944689Sql147931 #define	RTW_ANAPARM_RFPOW_ANA_PHILIPS_ON	\
5954689Sql147931     LSHIFT(0x328, RTW_ANAPARM_RFPOW1_MASK)
5964689Sql147931 #define	RTW_ANAPARM_RFPOW_DIG_PHILIPS_ON	\
5974689Sql147931     LSHIFT(0x008, RTW_ANAPARM_RFPOW1_MASK)
5984689Sql147931 
5994689Sql147931 /*
6004689Sql147931  * reg[RTW_ANAPARM] |= RTW_ANAPARM_TXDACOFF;
6014689Sql147931  */
6024689Sql147931 #define	RTW_ANAPARM_RFPOW_PHILIPS_SLEEP\
6034689Sql147931     LSHIFT(0x378, RTW_ANAPARM_RFPOW1_MASK)
6044689Sql147931 
6054689Sql147931 /*
6064689Sql147931  * reg[RTW_ANAPARM] |= RTW_ANAPARM_TXDACOFF;
6074689Sql147931  */
6084689Sql147931 #define	RTW_ANAPARM_RFPOW_PHILIPS_OFF\
6094689Sql147931     LSHIFT(0x379, RTW_ANAPARM_RFPOW1_MASK)
6104689Sql147931 
6114689Sql147931 #define	RTW_ANAPARM_RFPOW_PHILIPS_ON	LSHIFT(0x328, RTW_ANAPARM_RFPOW1_MASK)
6124689Sql147931 
6134689Sql147931 /*
6144689Sql147931  * undocumented card-specific bits from the EEPROM.
6154689Sql147931  */
6164689Sql147931 #define	RTW_ANAPARM_CARDSP_MASK	BITS(19, 0)
6174689Sql147931 
6184689Sql147931 #define	RTW_MSR		0x58	/* Media Status Register, 8b */
6194689Sql147931 /*
6204689Sql147931  * Network Type and Link Status
6214689Sql147931  */
6224689Sql147931 #define	RTW_MSR_NETYPE_MASK	BITS(3, 2)
6234689Sql147931 /*
6244689Sql147931  * AP, XXX RTL8181 only?
6254689Sql147931  */
6264689Sql147931 #define	RTW_MSR_NETYPE_AP_OK	LSHIFT(3, RTW_MSR_NETYPE_MASK)
6274689Sql147931 /*
6284689Sql147931  * infrastructure link ok
6294689Sql147931  */
6304689Sql147931 #define	RTW_MSR_NETYPE_INFRA_OK	LSHIFT(2, RTW_MSR_NETYPE_MASK)
6314689Sql147931 /*
6324689Sql147931  * ad-hoc link ok
6334689Sql147931  */
6344689Sql147931 #define	RTW_MSR_NETYPE_ADHOC_OK	LSHIFT(1, RTW_MSR_NETYPE_MASK)
6354689Sql147931 /*
6364689Sql147931  * no link
6374689Sql147931  */
6384689Sql147931 #define	RTW_MSR_NETYPE_NOLINK	LSHIFT(0, RTW_MSR_NETYPE_MASK)
6394689Sql147931 
6404689Sql147931 #define	RTW_CONFIG3	0x59	/* Configuration Register 3, 8b */
6414689Sql147931 #define	RTW_CONFIG3_GNTSEL	BIT(7)	/* Grant Select, read-only */
6424689Sql147931 /*
6434689Sql147931  * Set RTW_CONFIG3_PARMEN and RTW_9346CR_EEM_CONFIG to
6444689Sql147931  * allow RTW_ANAPARM writes.
6454689Sql147931  */
6464689Sql147931 #define	RTW_CONFIG3_PARMEN	BIT(6)
6474689Sql147931 /*
6484689Sql147931  * Valid when RTW_CONFIG1_PMEN is set. If set, RTL8180 wakes up
6494689Sql147931  * OS when Magic Packet is Rx'd.
6504689Sql147931  */
6514689Sql147931 #define	RTW_CONFIG3_MAGIC	BIT(5)
6524689Sql147931 /*
6534689Sql147931  * Cardbus-related registers and functions are enabled,
6544689Sql147931  * read-only. XXX RTL8180 only.
6554689Sql147931  */
6564689Sql147931 #define	RTW_CONFIG3_CARDBEN	BIT(3)
6574689Sql147931 /*
6584689Sql147931  * CLKRUN enabled, read-only. XXX RTL8180 only.
6594689Sql147931  */
6604689Sql147931 #define	RTW_CONFIG3_CLKRUNEN	BIT(2)
6614689Sql147931 /*
6624689Sql147931  * Function Registers Enabled, read-only. XXX RTL8180 only.
6634689Sql147931  */
6644689Sql147931 #define	RTW_CONFIG3_FUNCREGEN	BIT(1)
6654689Sql147931 /*
6664689Sql147931  * Fast back-to-back enabled, read-only.
6674689Sql147931  */
6684689Sql147931 #define	RTW_CONFIG3_FBTBEN	BIT(0)
6694689Sql147931 #define	RTW_CONFIG4	0x5A	/* Configuration Register 4, 8b */
6704689Sql147931 /*
6714689Sql147931  * VCO Power Down
6724689Sql147931  * 0: normal operation
6734689Sql147931  *    (power-on default)
6744689Sql147931  * 1: power-down VCO, RF front-end,
6754689Sql147931  *    and most RTL8180 components.
6764689Sql147931  */
6774689Sql147931 #define	RTW_CONFIG4_VCOPDN	BIT(7)
6784689Sql147931 /*
6794689Sql147931  * Power Off
6804689Sql147931  * 0: normal operation
6814689Sql147931  *    (power-on default)
6824689Sql147931  * 1: power-down RF front-end,
6834689Sql147931  *    and most RTL8180 components,
6844689Sql147931  *    but leave VCO on.
6854689Sql147931  *
6864689Sql147931  * XXX RFMD front-end only?
6874689Sql147931  */
6884689Sql147931 #define	RTW_CONFIG4_PWROFF	BIT(6)
6894689Sql147931 /*
6904689Sql147931  * Power Management
6914689Sql147931  * 0: normal operation
6924689Sql147931  *    (power-on default)
6934689Sql147931  * 1: set Tx packet's PWRMGMT bit.
6944689Sql147931  */
6954689Sql147931 #define	RTW_CONFIG4_PWRMGT	BIT(5)
6964689Sql147931 /*
6974689Sql147931  * LANWAKE vs. PMEB: Cardbus-only
6984689Sql147931  * 0: LWAKE & PMEB asserted
6994689Sql147931  *    simultaneously
7004689Sql147931  * 1: LWAKE asserted only if
7014689Sql147931  *    both PMEB is asserted and
7024689Sql147931  *    ISOLATEB is low.
7034689Sql147931  * XXX RTL8180 only.
7044689Sql147931  */
7054689Sql147931 #define	RTW_CONFIG4_LWPME	BIT(4)
7064689Sql147931 /*
7074689Sql147931  * see RTW_CONFIG1_LWACT XXX RTL8180 only.
7084689Sql147931  */
7094689Sql147931 #define	RTW_CONFIG4_LWPTN	BIT(2)
7104689Sql147931 /*
7114689Sql147931  * Radio Front-End Programming Method
7124689Sql147931  */
7134689Sql147931 #define	RTW_CONFIG4_RFTYPE_MASK	BITS(1, 0)
7144689Sql147931 #define	RTW_CONFIG4_RFTYPE_INTERSIL	LSHIFT(1, RTW_CONFIG4_RFTYPE_MASK)
7154689Sql147931 #define	RTW_CONFIG4_RFTYPE_RFMD		LSHIFT(2, RTW_CONFIG4_RFTYPE_MASK)
7164689Sql147931 #define	RTW_CONFIG4_RFTYPE_PHILIPS	LSHIFT(3, RTW_CONFIG4_RFTYPE_MASK)
7174689Sql147931 
7184689Sql147931 #define	RTW_TESTR	0x5B	/* TEST mode register, 8b */
7194689Sql147931 
7204689Sql147931 #define	RTW_PSR		0x5e	/* Page Select Register, 8b */
7214689Sql147931 #define	RTW_PSR_GPO	BIT(7)	/* Control/status of pin 52. */
7224689Sql147931 #define	RTW_PSR_GPI	BIT(6)	/* Status of pin 64. */
7234689Sql147931 /*
7244689Sql147931  * Status/control of LED1 pin if RTW_CONFIG0_LEDGPOEN is set.
7254689Sql147931  */
7264689Sql147931 #define	RTW_PSR_LEDGPO1	BIT(5)
7274689Sql147931 /*
7284689Sql147931  * Status/control of LED0 pin if RTW_CONFIG0_LEDGPOEN is set.
7294689Sql147931  */
7304689Sql147931 #define	RTW_PSR_LEDGPO0	BIT(4)
7314689Sql147931 #define	RTW_PSR_UWF	BIT(1)	/* Enable Unicast Wakeup Frame */
7324689Sql147931 #define	RTW_PSR_PSEN	BIT(0)	/* 1: page 1, 0: page 0 */
7334689Sql147931 
7344689Sql147931 #define	RTW_SCR		0x5f	/* Security Configuration Register, 8b */
7354689Sql147931 #define	RTW_SCR_KM_MASK	BITS(5, 4)	/* Key Mode */
7364689Sql147931 #define	RTW_SCR_KM_WEP104	LSHIFT(1, RTW_SCR_KM_MASK)
7374689Sql147931 #define	RTW_SCR_KM_WEP40	LSHIFT(0, RTW_SCR_KM_MASK)
7384689Sql147931 /*
7394689Sql147931  * Enable Tx WEP. Invalid if neither RTW_CONFIG0_WEP40 nor
7404689Sql147931  * RTW_CONFIG0_WEP104 is set.
7414689Sql147931  */
7424689Sql147931 #define	RTW_SCR_TXSECON		BIT(1)
7434689Sql147931 /*
7444689Sql147931  * Enable Rx WEP. Invalid if neither RTW_CONFIG0_WEP40 nor
7454689Sql147931  * RTW_CONFIG0_WEP104 is set.
7464689Sql147931  */
7474689Sql147931 #define	RTW_SCR_RXSECON		BIT(0)
7484689Sql147931 
7494689Sql147931 #define	RTW_BCNITV	0x70	/* Beacon Interval Register, 16b */
7504689Sql147931 /*
7514689Sql147931  * TU between TBTT, written by host.
7524689Sql147931  */
7534689Sql147931 #define	RTW_BCNITV_BCNITV_MASK	BITS(9, 0)
7544689Sql147931 #define	RTW_ATIMWND	0x72	/* ATIM Window Register, 16b */
7554689Sql147931 /*
7564689Sql147931  * ATIM Window length in TU, written by host.
7574689Sql147931  */
7584689Sql147931 #define	RTW_ATIMWND_ATIMWND	BITS(9, 0)
7594689Sql147931 
7604689Sql147931 #define	RTW_BINTRITV	0x74	/* Beacon Interrupt Interval Register, 16b */
7614689Sql147931 /*
7624689Sql147931  * RTL8180 wakes host with RTW_INTR_BCNINT at BINTRITV
7634689Sql147931  * microseconds before TBTT
7644689Sql147931  */
7654689Sql147931 #define	RTW_BINTRITV_BINTRITV	BITS(9, 0)
7664689Sql147931 #define	RTW_ATIMTRITV	0x76	/* ATIM Interrupt Interval Register, 16b */
7674689Sql147931 /*
7684689Sql147931  * RTL8180 wakes host with RTW_INTR_ATIMINT at ATIMTRITV
7694689Sql147931  * microseconds before end of ATIM Window
7704689Sql147931  */
7714689Sql147931 #define	RTW_ATIMTRITV_ATIMTRITV	BITS(9, 0)
7724689Sql147931 
7734689Sql147931 #define	RTW_PHYDELAY	0x78	/* PHY Delay Register, 8b */
7744689Sql147931 /*
7754689Sql147931  * Rev. C magic from reference  driver
7764689Sql147931  */
7774689Sql147931 #define	RTW_PHYDELAY_REVC_MAGIC	BIT(3)
7784689Sql147931 /*
7794689Sql147931  * microsecond Tx delay between MAC and RF front-end
7804689Sql147931  */
7814689Sql147931 #define	RTW_PHYDELAY_PHYDELAY	BITS(2, 0)
7824689Sql147931 #define	RTW_CRCOUNT	0x79	/* Carrier Sense Counter, 8b */
7834689Sql147931 #define	RTW_CRCOUNT_MAGIC	0x4c
7844689Sql147931 
7854689Sql147931 #define	RTW_CRC16ERR	0x7a	/* CRC16 error count, 16b, XXX RTL8181 only? */
7864689Sql147931 
7874689Sql147931 #define	RTW_BB	0x7c		/* Baseband interface, 32b */
7884689Sql147931 /*
7894689Sql147931  * used for writing RTL8180's integrated baseband processor
7904689Sql147931  */
7914689Sql147931 #define	RTW_BB_RD_MASK		BITS(23, 16)	/* data to read */
7924689Sql147931 #define	RTW_BB_WR_MASK		BITS(15, 8)	/* data to write */
7934689Sql147931 #define	RTW_BB_WREN		BIT(7)		/* write enable */
7944689Sql147931 #define	RTW_BB_ADDR_MASK	BITS(6, 0)	/* address */
7954689Sql147931 
7964689Sql147931 #define	RTW_PHYADDR	0x7c	/* Address register for PHY interface, 8b */
7974689Sql147931 #define	RTW_PHYDATAW	0x7d	/* Write data to PHY, 8b, write-only */
7984689Sql147931 #define	RTW_PHYDATAR	0x7e	/* Read data from PHY, 8b (?), read-only */
7994689Sql147931 
8004689Sql147931 #define	RTW_PHYCFG	0x80	/* PHY Configuration Register, 32b */
8014689Sql147931 /*
8024689Sql147931  * if !RTW_PHYCFG_HST, host sets. MAC clears after banging bits.
8034689Sql147931  */
8044689Sql147931 #define	RTW_PHYCFG_MAC_POLL	BIT(31)
8054689Sql147931 /*
8064689Sql147931  * 1: host bangs bits
8074689Sql147931  * 0: MAC bangs bits
8084689Sql147931  */
8094689Sql147931 #define	RTW_PHYCFG_HST		BIT(30)
8104689Sql147931 #define	RTW_PHYCFG_MAC_RFTYPE_MASK	BITS(29, 28)
8114689Sql147931 #define	RTW_PHYCFG_MAC_RFTYPE_INTERSIL	LSHIFT(0, RTW_PHYCFG_MAC_RFTYPE_MASK)
8124689Sql147931 #define	RTW_PHYCFG_MAC_RFTYPE_RFMD	LSHIFT(1, RTW_PHYCFG_MAC_RFTYPE_MASK)
8134689Sql147931 #define	RTW_PHYCFG_MAC_RFTYPE_GCT	RTW_PHYCFG_MAC_RFTYPE_RFMD
8144689Sql147931 #define	RTW_PHYCFG_MAC_RFTYPE_PHILIPS	LSHIFT(3, RTW_PHYCFG_MAC_RFTYPE_MASK)
8154689Sql147931 #define	RTW_PHYCFG_MAC_PHILIPS_ADDR_MASK	BITS(27, 24)
8164689Sql147931 #define	RTW_PHYCFG_MAC_PHILIPS_DATA_MASK	BITS(23, 0)
8174689Sql147931 #define	RTW_PHYCFG_MAC_MAXIM_LODATA_MASK	BITS(27, 24)
8184689Sql147931 #define	RTW_PHYCFG_MAC_MAXIM_ADDR_MASK		BITS(11, 8)
8194689Sql147931 #define	RTW_PHYCFG_MAC_MAXIM_HIDATA_MASK	BITS(7, 0)
8204689Sql147931 #define	RTW_PHYCFG_HST_EN		BIT(2)
8214689Sql147931 #define	RTW_PHYCFG_HST_CLK		BIT(1)
8224689Sql147931 #define	RTW_PHYCFG_HST_DATA		BIT(0)
8234689Sql147931 
8244689Sql147931 #define	RTW_MAXIM_HIDATA_MASK	BITS(11, 4)
8254689Sql147931 #define	RTW_MAXIM_LODATA_MASK	BITS(3, 0)
8264689Sql147931 
8274689Sql147931 /*
8284689Sql147931  * 0x84 - 0xD3, page 1, selected when RTW_PSR[PSEN] == 1.
8294689Sql147931  */
8304689Sql147931 
8314689Sql147931 #define	RTW_WAKEUP0L	0x84	/* Power Management Wakeup Frame */
8324689Sql147931 #define	RTW_WAKEUP0H	0x88	/* 32b */
8334689Sql147931 
8344689Sql147931 #define	RTW_WAKEUP1L	0x8c
8354689Sql147931 #define	RTW_WAKEUP1H	0x90
8364689Sql147931 
8374689Sql147931 #define	RTW_WAKEUP2LL	0x94
8384689Sql147931 #define	RTW_WAKEUP2LH	0x98
8394689Sql147931 
8404689Sql147931 #define	RTW_WAKEUP2HL	0x9c
8414689Sql147931 #define	RTW_WAKEUP2HH	0xa0
8424689Sql147931 
8434689Sql147931 #define	RTW_WAKEUP3LL	0xa4
8444689Sql147931 #define	RTW_WAKEUP3LH	0xa8
8454689Sql147931 
8464689Sql147931 #define	RTW_WAKEUP3HL	0xac
8474689Sql147931 #define	RTW_WAKEUP3HH	0xb0
8484689Sql147931 
8494689Sql147931 #define	RTW_WAKEUP4LL	0xb4
8504689Sql147931 #define	RTW_WAKEUP4LH	0xb8
8514689Sql147931 
8524689Sql147931 #define	RTW_WAKEUP4HL	0xbc
8534689Sql147931 #define	RTW_WAKEUP4HH	0xc0
8544689Sql147931 
8554689Sql147931 #define	RTW_CRC0	0xc4	/* CRC of wakeup frame 0, 16b */
8564689Sql147931 #define	RTW_CRC1	0xc6	/* CRC of wakeup frame 1, 16b */
8574689Sql147931 #define	RTW_CRC2	0xc8	/* CRC of wakeup frame 2, 16b */
8584689Sql147931 #define	RTW_CRC3	0xca	/* CRC of wakeup frame 3, 16b */
8594689Sql147931 #define	RTW_CRC4	0xcc	/* CRC of wakeup frame 4, 16b */
8604689Sql147931 
8614689Sql147931 /*
8624689Sql147931  * 0x84 - 0xD3, page 0, selected when RTW_PSR[PSEN] == 0.
8634689Sql147931  */
8644689Sql147931 
8654689Sql147931 /*
8664689Sql147931  * Default Key Registers, each 128b
8674689Sql147931  *
8684689Sql147931  * If RTW_SCR_KM_WEP104, 104 lsb are the key.
8694689Sql147931  * If RTW_SCR_KM_WEP40, 40 lsb are the key.
8704689Sql147931  */
8714689Sql147931 #define	RTW_DK0		0x90	/* Default Key 0 Register, 128b */
8724689Sql147931 #define	RTW_DK1		0xa0	/* Default Key 1 Register, 128b */
8734689Sql147931 #define	RTW_DK2		0xb0	/* Default Key 2 Register, 128b */
8744689Sql147931 #define	RTW_DK3		0xc0	/* Default Key 3 Register, 128b */
8754689Sql147931 
8764689Sql147931 #define	RTW_CONFIG5	0xd8	/* Configuration Register 5, 8b */
8774689Sql147931 #define	RTW_CONFIG5_TXFIFOOK	BIT(7)	/* Tx FIFO self-test pass, read-only */
8784689Sql147931 #define	RTW_CONFIG5_RXFIFOOK	BIT(6)	/* Rx FIFO self-test pass, read-only */
8794689Sql147931 /*
8804689Sql147931  * 1: start calibration cycle and raise AGCRESET pin.
8814689Sql147931  * 0: lower AGCRESET pin
8824689Sql147931  */
8834689Sql147931 #define	RTW_CONFIG5_CALON	BIT(5)
8844689Sql147931 #define	RTW_CONFIG5_EACPI	BIT(2)	/* Enable ACPI Wake up, default 0 */
8854689Sql147931 /*
8864689Sql147931  * Enable LAN Wake signal, from EEPROM
8874689Sql147931  */
8884689Sql147931 #define	RTW_CONFIG5_LANWAKE	BIT(1)
8894689Sql147931 /*
8904689Sql147931  * 1: both software & PCI Reset reset PME_Status
8914689Sql147931  * 0: only software resets PME_Status
8924689Sql147931  *
8934689Sql147931  * From EEPROM.
8944689Sql147931  */
8954689Sql147931 #define	RTW_CONFIG5_PMESTS	BIT(0)
8964689Sql147931 
8974689Sql147931 /*
8984689Sql147931  * Transmit Priority Polling Register, 8b, write-only.
8994689Sql147931  */
9004689Sql147931 #define	RTW_TPPOLL	0xd9
9014689Sql147931 /*
9024689Sql147931  * RTL8180 clears to notify host of a beacon
9034689Sql147931  * Tx. Host writes have no effect.
9044689Sql147931  */
9054689Sql147931 #define	RTW_TPPOLL_BQ	BIT(7)
9064689Sql147931 /*
9074689Sql147931  * Host writes 1 to notify RTL8180 of high-priority Tx packets, RTL8180 clears
9084689Sql147931  * to after high-priority Tx is complete.
9094689Sql147931  */
9104689Sql147931 #define	RTW_TPPOLL_HPQ	BIT(6)
9114689Sql147931 /*
9124689Sql147931  * If RTW_CONFIG2_DPS is set, host writes 1 to notify RTL8180 of
9134689Sql147931  * normal-priority Tx packets, RTL8180 clears
9144689Sql147931  * after normal-priority Tx is complete.
9154689Sql147931  *
9164689Sql147931  * If RTW_CONFIG2_DPS is clear, host writes have no effect. RTL8180 clears after
9174689Sql147931  * normal-priority Tx is complete.
9184689Sql147931  */
9194689Sql147931 #define	RTW_TPPOLL_NPQ	BIT(5)
9204689Sql147931 /*
9214689Sql147931  * Host writes 1 to notify RTL8180 of low-priority Tx packets, RTL8180 clears
9224689Sql147931  * after low-priority Tx is complete.
9234689Sql147931  */
9244689Sql147931 #define	RTW_TPPOLL_LPQ	BIT(4)
9254689Sql147931 /*
9264689Sql147931  * Host writes 1 to tell RTL8180 to stop beacon DMA. This bit is invalid
9274689Sql147931  * when RTW_CONFIG2_DPS is set.
9284689Sql147931  */
9294689Sql147931 #define	RTW_TPPOLL_SBQ	BIT(3)
9304689Sql147931 /*
9314689Sql147931  * Host writes 1 to tell RTL8180 to stop high-priority DMA.
9324689Sql147931  */
9334689Sql147931 #define	RTW_TPPOLL_SHPQ	BIT(2)
9344689Sql147931 /*
9354689Sql147931  * Host writes 1 to tell RTL8180 to stop normal-priority DMA.
9364689Sql147931  * This bit is invalid when RTW_CONFIG2_DPS is set.
9374689Sql147931  */
9384689Sql147931 #define	RTW_TPPOLL_SNPQ	BIT(1)
9394689Sql147931 /*
9404689Sql147931  * Host writes 1 to tell RTL8180 to stop low-priority DMA.
9414689Sql147931  */
9424689Sql147931 #define	RTW_TPPOLL_SLPQ	BIT(0)
9434689Sql147931 
9444689Sql147931 /* Start all queues. */
9454689Sql147931 #define	RTW_TPPOLL_ALL	(RTW_TPPOLL_BQ | RTW_TPPOLL_HPQ | \
9464689Sql147931 			RTW_TPPOLL_NPQ | RTW_TPPOLL_LPQ)
9474689Sql147931 
9484689Sql147931 /* Start queues solaris required. */
9494689Sql147931 #define	RTW_TPPOLL_LN	(RTW_TPPOLL_NPQ | RTW_TPPOLL_LPQ)
9504689Sql147931 
9514689Sql147931 /* Stop all queues. */
9524689Sql147931 #define	RTW_TPPOLL_SALL	(RTW_TPPOLL_SBQ | RTW_TPPOLL_SHPQ | \
9534689Sql147931 			RTW_TPPOLL_SNPQ | RTW_TPPOLL_SLPQ)
9544689Sql147931 
9554689Sql147931 #define	RTW_CWR		0xdc	/* Contention Window Register, 16b, read-only */
9564689Sql147931 /*
9574689Sql147931  * Contention Window: indicates number of contention windows before Tx
9584689Sql147931  */
9594689Sql147931 #define	RTW_CWR_CW	BITS(9, 0)
9604689Sql147931 
9614689Sql147931 /*
9624689Sql147931  * Retry Count Register, 16b, read-only
9634689Sql147931  */
9644689Sql147931 #define	RTW_RETRYCTR	0xde
9654689Sql147931 /*
9664689Sql147931  * Retry Count: indicates number of retries after Tx
9674689Sql147931  */
9684689Sql147931 #define	RTW_RETRYCTR_RETRYCT	BITS(7, 0)
9694689Sql147931 
9704689Sql147931 /*
9714689Sql147931  * Receive descriptor Start Address Register,
9724689Sql147931  * 32b, 256-byte alignment.
9734689Sql147931  */
9744689Sql147931 #define	RTW_RDSAR	0xe4
9754689Sql147931 /*
9764689Sql147931  * Function Event Register, 32b, Cardbus only. Only valid when
9774689Sql147931  * both RTW_CONFIG3_CARDBEN and RTW_CONFIG3_FUNCREGEN are set.
9784689Sql147931  */
9794689Sql147931 #define	RTW_FER		0xf0
9804689Sql147931 #define	RTW_FER_INTR	BIT(15)	/* set when RTW_FFER_INTR is set */
9814689Sql147931 #define	RTW_FER_GWAKE	BIT(4)	/* General Wakeup */
9824689Sql147931 /*
9834689Sql147931  * Function Event Mask Register, 32b, Cardbus only. Only valid when
9844689Sql147931  * both RTW_CONFIG3_CARDBEN and RTW_CONFIG3_FUNCREGEN are set.
9854689Sql147931  */
9864689Sql147931 #define	RTW_FEMR	0xf4
9874689Sql147931 #define	RTW_FEMR_INTR	BIT(15)	/* set when RTW_FFER_INTR is set */
9884689Sql147931 #define	RTW_FEMR_WKUP	BIT(14)	/* Wakeup Mask */
9894689Sql147931 #define	RTW_FEMR_GWAKE	BIT(4)	/* General Wakeup */
9904689Sql147931 /*
9914689Sql147931  * Function Present State Register, 32b, read-only, Cardbus only.
9924689Sql147931  * Only valid when both RTW_CONFIG3_CARDBEN and RTW_CONFIG3_FUNCREGEN
9934689Sql147931  * are set.
9944689Sql147931  */
9954689Sql147931 #define	RTW_FPSR	0xf8
9964689Sql147931 #define	RTW_FPSR_INTR	BIT(15)	/* TBD */
9974689Sql147931 #define	RTW_FPSR_GWAKE	BIT(4)	/* General Wakeup: TBD */
9984689Sql147931 /*
9994689Sql147931  * Function Force Event Register, 32b, write-only, Cardbus only.
10004689Sql147931  * Only valid when both RTW_CONFIG3_CARDBEN and RTW_CONFIG3_FUNCREGEN
10014689Sql147931  * are set.
10024689Sql147931  */
10034689Sql147931 #define	RTW_FFER	0xfc
10044689Sql147931 #define	RTW_FFER_INTR	BIT(15)	/* TBD */
10054689Sql147931 #define	RTW_FFER_GWAKE	BIT(4)	/* General Wakeup: TBD */
10064689Sql147931 
10074689Sql147931 /*
10084689Sql147931  * Serial EEPROM offsets
10094689Sql147931  */
10104689Sql147931 #define	RTW_SR_ID	0x00	/* 16b */
10114689Sql147931 #define	RTW_SR_VID	0x02	/* 16b */
10124689Sql147931 #define	RTW_SR_DID	0x04	/* 16b */
10134689Sql147931 #define	RTW_SR_SVID	0x06	/* 16b */
10144689Sql147931 #define	RTW_SR_SMID	0x08	/* 16b */
10154689Sql147931 #define	RTW_SR_MNGNT	0x0a
10164689Sql147931 #define	RTW_SR_MXLAT	0x0b
10174689Sql147931 #define	RTW_SR_RFCHIPID	0x0c
10184689Sql147931 #define	RTW_SR_CONFIG3	0x0d
10194689Sql147931 #define	RTW_SR_MAC	0x0e	/* 6 bytes */
10204689Sql147931 #define	RTW_SR_CONFIG0	0x14
10214689Sql147931 #define	RTW_SR_CONFIG1	0x15
10224689Sql147931 #define	RTW_SR_PMC	0x16	/* Power Management Capabilities, 16b */
10234689Sql147931 #define	RTW_SR_CONFIG2	0x18
10244689Sql147931 #define	RTW_SR_CONFIG4	0x19
10254689Sql147931 #define	RTW_SR_ANAPARM	0x1a	/* Analog Parameters, 32b */
10264689Sql147931 #define	RTW_SR_TESTR	0x1e
10274689Sql147931 #define	RTW_SR_CONFIG5	0x1f
10284689Sql147931 #define	RTW_SR_TXPOWER1		0x20
10294689Sql147931 #define	RTW_SR_TXPOWER2		0x21
10304689Sql147931 #define	RTW_SR_TXPOWER3		0x22
10314689Sql147931 #define	RTW_SR_TXPOWER4		0x23
10324689Sql147931 #define	RTW_SR_TXPOWER5		0x24
10334689Sql147931 #define	RTW_SR_TXPOWER6		0x25
10344689Sql147931 #define	RTW_SR_TXPOWER7		0x26
10354689Sql147931 #define	RTW_SR_TXPOWER8		0x27
10364689Sql147931 #define	RTW_SR_TXPOWER9		0x28
10374689Sql147931 #define	RTW_SR_TXPOWER10	0x29
10384689Sql147931 #define	RTW_SR_TXPOWER11	0x2a
10394689Sql147931 #define	RTW_SR_TXPOWER12	0x2b
10404689Sql147931 #define	RTW_SR_TXPOWER13	0x2c
10414689Sql147931 #define	RTW_SR_TXPOWER14	0x2d
10424689Sql147931 #define	RTW_SR_CHANNELPLAN	0x2e	/* bitmap of channels to scan */
10434689Sql147931 #define	RTW_SR_ENERGYDETTHR	0x2f	/* energy-detect threshold */
10444689Sql147931 #define	RTW_SR_ENERGYDETTHR_DEFAULT	0x0c	/* use this if old SROM */
10454689Sql147931 #define	RTW_SR_CISPOINTER	0x30	/* 16b */
10464689Sql147931 #define	RTW_SR_RFPARM		0x32	/* RF-specific parameter */
10474689Sql147931 #define	RTW_SR_RFPARM_DIGPHY	BIT(0)		/* 1: digital PHY */
10484689Sql147931 #define	RTW_SR_RFPARM_DFLANTB	BIT(1)		/* 1: antenna B is default */
10494689Sql147931 #define	RTW_SR_RFPARM_CS_MASK	BITS(2, 3)	/* carrier-sense type */
10504689Sql147931 #define	RTW_SR_VERSION		0x3c	/* EEPROM content version, 16b */
10514689Sql147931 #define	RTW_SR_CRC		0x3e	/* EEPROM content CRC, 16b */
10524689Sql147931 #define	RTW_SR_VPD		0x40	/* Vital Product Data, 64 bytes */
10534689Sql147931 #define	RTW_SR_CIS		0x80	/* CIS Data, 93c56 only, 128 bytes */
10544689Sql147931 
10554689Sql147931 /*
10564689Sql147931  * RTL8180 Transmit/Receive Descriptors
10574689Sql147931  */
10584689Sql147931 
10594689Sql147931 /*
10604689Sql147931  * the first descriptor in each ring must be on a 256-byte boundary
10614689Sql147931  */
10624689Sql147931 #define	RTW_DESC_ALIGNMENT 256
10634689Sql147931 
10644689Sql147931 /*
10654689Sql147931  * Tx descriptor
10664689Sql147931  */
10674689Sql147931 struct rtw_txdesc {
10684689Sql147931 	uint32_t	td_ctl0;
10694689Sql147931 	uint32_t	td_ctl1;
10704689Sql147931 	uint32_t	td_buf;
10714689Sql147931 	uint32_t	td_len;
10724689Sql147931 	uint32_t	td_next;
10734689Sql147931 	uint32_t	td_rsvd[3];
10744689Sql147931 };
10754689Sql147931 
10764689Sql147931 #define	td_stat td_ctl0
10774689Sql147931 
10784689Sql147931 #define	RTW_TXCTL0_OWN			BIT(31)		/* 1: ready to Tx */
10794689Sql147931 #define	RTW_TXCTL0_RSVD0		BIT(30)		/* reserved */
10804689Sql147931 #define	RTW_TXCTL0_FS			BIT(29)		/* first segment */
10814689Sql147931 #define	RTW_TXCTL0_LS			BIT(28)		/* last segment */
10824689Sql147931 
10834689Sql147931 #define	RTW_TXCTL0_RATE_MASK		BITS(27, 24)	/* Tx rate */
10844689Sql147931 #define	RTW_TXCTL0_RATE_1MBPS		LSHIFT(0, RTW_TXCTL0_RATE_MASK)
10854689Sql147931 #define	RTW_TXCTL0_RATE_2MBPS		LSHIFT(1, RTW_TXCTL0_RATE_MASK)
10864689Sql147931 #define	RTW_TXCTL0_RATE_5MBPS		LSHIFT(2, RTW_TXCTL0_RATE_MASK)
10874689Sql147931 #define	RTW_TXCTL0_RATE_11MBPS		LSHIFT(3, RTW_TXCTL0_RATE_MASK)
10884689Sql147931 
10894689Sql147931 #define	RTW_TXCTL0_RTSEN		BIT(23)		/* RTS Enable */
10904689Sql147931 
10914689Sql147931 #define	RTW_TXCTL0_RTSRATE_MASK		BITS(22, 19)	/* Tx rate */
10924689Sql147931 #define	RTW_TXCTL0_RTSRATE_1MBPS	LSHIFT(0, RTW_TXCTL0_RTSRATE_MASK)
10934689Sql147931 #define	RTW_TXCTL0_RTSRATE_2MBPS	LSHIFT(1, RTW_TXCTL0_RTSRATE_MASK)
10944689Sql147931 #define	RTW_TXCTL0_RTSRATE_5MBPS	LSHIFT(2, RTW_TXCTL0_RTSRATE_MASK)
10954689Sql147931 #define	RTW_TXCTL0_RTSRATE_11MBPS	LSHIFT(3, RTW_TXCTL0_RTSRATE_MASK)
10964689Sql147931 
10974689Sql147931 #define	RTW_TXCTL0_BEACON		BIT(18)	/* packet is a beacon */
10984689Sql147931 #define	RTW_TXCTL0_MOREFRAG		BIT(17)	/* another fragment follows */
10994689Sql147931 /*
11004689Sql147931  * add short PLCP preamble and header
11014689Sql147931  */
11024689Sql147931 #define	RTW_TXCTL0_SPLCP		BIT(16)
11034689Sql147931 #define	RTW_TXCTL0_KEYID_MASK		BITS(15, 14)	/* default key id */
11044689Sql147931 #define	RTW_TXCTL0_RSVD1_MASK		BITS(13, 12)	/* reserved */
11054689Sql147931 /*
11064689Sql147931  * Tx packet size in bytes
11074689Sql147931  */
11084689Sql147931 #define	RTW_TXCTL0_TPKTSIZE_MASK	BITS(11, 0)
11094689Sql147931 
11104689Sql147931 #define	RTW_TXSTAT_OWN		RTW_TXCTL0_OWN
11114689Sql147931 #define	RTW_TXSTAT_RSVD0	RTW_TXCTL0_RSVD0
11124689Sql147931 #define	RTW_TXSTAT_FS		RTW_TXCTL0_FS
11134689Sql147931 #define	RTW_TXSTAT_LS		RTW_TXCTL0_LS
11144689Sql147931 #define	RTW_TXSTAT_RSVD1_MASK	BITS(27, 16)
11154689Sql147931 #define	RTW_TXSTAT_TOK		BIT(15)
11164689Sql147931 #define	RTW_TXSTAT_RTSRETRY_MASK	BITS(14, 8)	/* RTS retry count */
11174689Sql147931 #define	RTW_TXSTAT_DRC_MASK		BITS(7, 0)	/* Data retry count */
11184689Sql147931 
11194689Sql147931 /*
11204689Sql147931  * supplements _LENGTH in packets sent 5.5Mb/s or faster
11214689Sql147931  */
11224689Sql147931 #define	RTW_TXCTL1_LENGEXT	BIT(31)
11234689Sql147931 #define	RTW_TXCTL1_LENGTH_MASK	BITS(30, 16)	/* PLCP length (microseconds) */
11244689Sql147931 /*
11254689Sql147931  * RTS Duration (microseconds)
11264689Sql147931  */
11274689Sql147931 #define	RTW_TXCTL1_RTSDUR_MASK	BITS(15, 0)
11284689Sql147931 
11294689Sql147931 #define	RTW_TXLEN_LENGTH_MASK	BITS(11, 0)	/* Tx buffer length in bytes */
11304689Sql147931 
11314689Sql147931 /*
11324689Sql147931  * Rx descriptor
11334689Sql147931  */
11344689Sql147931 struct rtw_rxdesc {
11354689Sql147931     uint32_t	rd_ctl;
11364689Sql147931     uint32_t	rd_rsvd0;
11374689Sql147931     uint32_t	rd_buf;
11384689Sql147931     uint32_t	rd_rsvd1;
11394689Sql147931 };
11404689Sql147931 
11414689Sql147931 #define	rd_stat rd_ctl
11424689Sql147931 #define	rd_rssi rd_rsvd0
11434689Sql147931 #define	rd_tsftl rd_buf		/* valid only when RTW_RXSTAT_LS is set */
11444689Sql147931 #define	rd_tsfth rd_rsvd1	/* valid only when RTW_RXSTAT_LS is set */
11454689Sql147931 
11464689Sql147931 #define	RTW_RXCTL_OWN		BIT(31)		/* 1: owned by NIC */
11474689Sql147931 #define	RTW_RXCTL_EOR		BIT(30)		/* end of ring */
11484689Sql147931 #define	RTW_RXCTL_FS		BIT(29)		/* first segment */
11494689Sql147931 #define	RTW_RXCTL_LS		BIT(28)		/* last segment */
11504689Sql147931 #define	RTW_RXCTL_RSVD0_MASK	BITS(29, 12)	/* reserved */
11514689Sql147931 #define	RTW_RXCTL_LENGTH_MASK	BITS(11, 0)	/* Rx buffer length */
11524689Sql147931 
11534689Sql147931 #define	RTW_RXSTAT_OWN		RTW_RXCTL_OWN
11544689Sql147931 #define	RTW_RXSTAT_EOR		RTW_RXCTL_EOR
11554689Sql147931 #define	RTW_RXSTAT_FS		RTW_RXCTL_FS	/* first segment */
11564689Sql147931 #define	RTW_RXSTAT_LS		RTW_RXCTL_LS	/* last segment */
11574689Sql147931 #define	RTW_RXSTAT_DMAFAIL	BIT(27)		/* DMA failure on this pkt */
11584689Sql147931 /*
11594689Sql147931  * buffer overflow XXX means FIFO exhausted?
11604689Sql147931  */
11614689Sql147931 #define	RTW_RXSTAT_BOVF		BIT(26)
11624689Sql147931 /*
11634689Sql147931  * Rx'd with short preamble and PLCP header
11644689Sql147931  */
11654689Sql147931 #define	RTW_RXSTAT_SPLCP	BIT(25)
11664689Sql147931 #define	RTW_RXSTAT_RSVD1	BIT(24)		/* reserved */
11674689Sql147931 #define	RTW_RXSTAT_RATE_MASK	BITS(23, 20)	/* Rx rate */
11684689Sql147931 #define	RTW_RXSTAT_RATE_1MBPS	LSHIFT(0, RTW_RXSTAT_RATE_MASK)
11694689Sql147931 #define	RTW_RXSTAT_RATE_2MBPS	LSHIFT(1, RTW_RXSTAT_RATE_MASK)
11704689Sql147931 #define	RTW_RXSTAT_RATE_5MBPS	LSHIFT(2, RTW_RXSTAT_RATE_MASK)
11714689Sql147931 #define	RTW_RXSTAT_RATE_11MBPS	LSHIFT(3, RTW_RXSTAT_RATE_MASK)
11724689Sql147931 #define	RTW_RXSTAT_MIC		BIT(19)		/* XXX from reference driver */
11734689Sql147931 #define	RTW_RXSTAT_MAR		BIT(18)		/* is multicast */
11744689Sql147931 #define	RTW_RXSTAT_PAR		BIT(17)		/* matches RTL8180's MAC */
11754689Sql147931 #define	RTW_RXSTAT_BAR		BIT(16)		/* is broadcast */
11764689Sql147931 /*
11774689Sql147931  * error summary. valid when RTW_RXSTAT_LS set. indicates
11784689Sql147931  * that either RTW_RXSTAT_CRC32 or RTW_RXSTAT_ICV is set.
11794689Sql147931  */
11804689Sql147931 #define	RTW_RXSTAT_RES		BIT(15)
11814689Sql147931 #define	RTW_RXSTAT_PWRMGT	BIT(14)		/* 802.11 PWRMGMT bit is set */
11824689Sql147931 /*
11834689Sql147931  * XXX CRC16 error, from reference driver
11844689Sql147931  */
11854689Sql147931 #define	RTW_RXSTAT_CRC16	BIT(14)
11864689Sql147931 #define	RTW_RXSTAT_CRC32	BIT(13)		/* CRC32 error */
11874689Sql147931 #define	RTW_RXSTAT_ICV		BIT(12)		/* ICV error */
11884689Sql147931 /*
11894689Sql147931  * frame length, including CRC32
11904689Sql147931  */
11914689Sql147931 #define	RTW_RXSTAT_LENGTH_MASK	BITS(11, 0)
11924689Sql147931 
11934689Sql147931 /*
11944689Sql147931  * Convenient status conjunction.
11954689Sql147931  */
11964689Sql147931 #define	RTW_RXSTAT_ONESEG	(RTW_RXSTAT_FS|RTW_RXSTAT_LS)
11974689Sql147931 /*
11984689Sql147931  * Convenient status disjunctions.
11994689Sql147931  */
12004689Sql147931 #define	RTW_RXSTAT_IOERROR	(RTW_RXSTAT_DMAFAIL|RTW_RXSTAT_BOVF)
12014689Sql147931 #define	RTW_RXSTAT_DEBUG	(RTW_RXSTAT_SPLCP|RTW_RXSTAT_MAR|\
12024689Sql147931 				RTW_RXSTAT_PAR|RTW_RXSTAT_BAR|\
12034689Sql147931 				RTW_RXSTAT_PWRMGT|RTW_RXSTAT_CRC32|\
12044689Sql147931 				RTW_RXSTAT_ICV)
12054689Sql147931 
12064689Sql147931 
12074689Sql147931 #define	RTW_RXRSSI_VLAN		BITS(32, 16)	/* XXX from reference driver */
12084689Sql147931 /*
12094689Sql147931  * for Philips RF front-ends
12104689Sql147931  */
12114689Sql147931 #define	RTW_RXRSSI_RSSI		BITS(15, 8)	/* RF energy at the PHY */
12124689Sql147931 /*
12134689Sql147931  * for RF front-ends by Intersil, Maxim, RFMD
12144689Sql147931  */
12154689Sql147931 #define	RTW_RXRSSI_IMR_RSSI	BITS(15, 9)	/* RF energy at the PHY */
12164689Sql147931 #define	RTW_RXRSSI_IMR_LNA	BIT(8)		/* 1: LNA activated */
12174689Sql147931 #define	RTW_RXRSSI_SQ		BITS(7, 0)	/* Barker code-lock quality */
12184689Sql147931 
12194689Sql147931 #define	RTW_READ8(regs, ofs)						\
12206890Sql147931 	ddi_get8((regs)->r_handle,					\
12216890Sql147931 	(uint8_t *)((regs)->r_base + (ofs)))
12224689Sql147931 
12234689Sql147931 #define	RTW_READ16(regs, ofs)						\
12246890Sql147931 	ddi_get16((regs)->r_handle,					\
12256890Sql147931 	(uint16_t *)((uintptr_t)(regs)->r_base + (ofs)))
12264689Sql147931 
12274689Sql147931 #define	RTW_READ(regs, ofs)						\
12286890Sql147931 	ddi_get32((regs)->r_handle,					\
12296890Sql147931 	(uint32_t *)((uintptr_t)(regs)->r_base + (ofs)))
12304689Sql147931 
12314689Sql147931 #define	RTW_WRITE8(regs, ofs, val)					\
12326890Sql147931 	ddi_put8((regs)->r_handle,					\
12336890Sql147931 	(uint8_t *)((regs)->r_base + (ofs)), val)
12344689Sql147931 
12354689Sql147931 #define	RTW_WRITE16(regs, ofs, val)					\
12366890Sql147931 	ddi_put16((regs)->r_handle,					\
12376890Sql147931 	(uint16_t *)((uintptr_t)(regs)->r_base + (ofs)), val)
12384689Sql147931 
12394689Sql147931 #define	RTW_WRITE(regs, ofs, val)					\
12406890Sql147931 	ddi_put32((regs)->r_handle,					\
12416890Sql147931 	(uint32_t *)((uintptr_t)(regs)->r_base + (ofs)), val)
12424689Sql147931 
12434689Sql147931 #define	RTW_ISSET(regs, reg, mask)					\
12444689Sql147931 	(RTW_READ((regs), (reg)) & (mask))
12454689Sql147931 
12464689Sql147931 #define	RTW_CLR(regs, reg, mask)					\
12474689Sql147931 	RTW_WRITE((regs), (reg), RTW_READ((regs), (reg)) & ~(mask))
12484689Sql147931 
12494689Sql147931 /*
12504689Sql147931  * bus_space(9) lied?
12514689Sql147931  */
12524689Sql147931 #ifndef	BUS_SPACE_BARRIER_SYNC
12534689Sql147931 #define	BUS_SPACE_BARRIER_SYNC (BUS_SPACE_BARRIER_READ|BUS_SPACE_BARRIER_WRITE)
12544689Sql147931 #endif
12554689Sql147931 
12564689Sql147931 #ifndef	BUS_SPACE_BARRIER_READ_BEFORE_READ
12574689Sql147931 #define	BUS_SPACE_BARRIER_READ_BEFORE_READ BUS_SPACE_BARRIER_READ
12584689Sql147931 #endif
12594689Sql147931 
12604689Sql147931 #ifndef	BUS_SPACE_BARRIER_READ_BEFORE_WRITE
12614689Sql147931 #define	BUS_SPACE_BARRIER_READ_BEFORE_WRITE BUS_SPACE_BARRIER_READ
12624689Sql147931 #endif
12634689Sql147931 
12644689Sql147931 #ifndef	BUS_SPACE_BARRIER_WRITE_BEFORE_READ
12654689Sql147931 #define	BUS_SPACE_BARRIER_WRITE_BEFORE_READ BUS_SPACE_BARRIER_WRITE
12664689Sql147931 #endif
12674689Sql147931 
12684689Sql147931 #ifndef	BUS_SPACE_BARRIER_WRITE_BEFORE_WRITE
12694689Sql147931 #define	BUS_SPACE_BARRIER_WRITE_BEFORE_WRITE BUS_SPACE_BARRIER_WRITE
12704689Sql147931 #endif
12714689Sql147931 
12724689Sql147931 /*
12734689Sql147931  * Bus barrier
12744689Sql147931  *
12754689Sql147931  * Complete outstanding read and/or write ops on [reg0, reg1]
12764689Sql147931  * ([reg1, reg0]) before starting new ops on the same region. See
12774689Sql147931  * acceptable bus_space_barrier(9) for the flag definitions.
12784689Sql147931  */
12794689Sql147931 #define	RTW_BARRIER(regs, reg0, reg1, flags)
12804689Sql147931 /*
12814689Sql147931  *	***just define a dummy macro here in solaris***
12824689Sql147931  *	bus_space_barrier((regs)->r_bh, (regs)->r_bt,		\
12834689Sql147931  *	    MIN(reg0, reg1), MAX(reg0, reg1) - MIN(reg0, reg1) + 4, flags)
12844689Sql147931  */
12854689Sql147931 /*
12864689Sql147931  * Barrier convenience macros.
12874689Sql147931  */
12884689Sql147931 /*
12894689Sql147931  * sync
12904689Sql147931  */
12914689Sql147931 #define	RTW_SYNC(regs, reg0, reg1)				\
12924689Sql147931 	RTW_BARRIER(regs, reg0, reg1, BUS_SPACE_BARRIER_SYNC)
12934689Sql147931 
12944689Sql147931 /*
12954689Sql147931  * write-before-write
12964689Sql147931  */
12974689Sql147931 #define	RTW_WBW(regs, reg0, reg1)				\
12984689Sql147931 	RTW_BARRIER(regs, reg0, reg1, BUS_SPACE_BARRIER_WRITE_BEFORE_WRITE)
12994689Sql147931 
13004689Sql147931 /*
13014689Sql147931  * write-before-read
13024689Sql147931  */
13034689Sql147931 #define	RTW_WBR(regs, reg0, reg1)				\
13044689Sql147931 	RTW_BARRIER(regs, reg0, reg1, BUS_SPACE_BARRIER_WRITE_BEFORE_READ)
13054689Sql147931 
13064689Sql147931 /*
13074689Sql147931  * read-before-read
13084689Sql147931  */
13094689Sql147931 #define	RTW_RBR(regs, reg0, reg1)				\
13104689Sql147931 	RTW_BARRIER(regs, reg0, reg1, BUS_SPACE_BARRIER_READ_BEFORE_READ)
13114689Sql147931 
13124689Sql147931 /*
13134689Sql147931  * read-before-read
13144689Sql147931  */
13154689Sql147931 #define	RTW_RBW(regs, reg0, reg1)				\
13164689Sql147931 	RTW_BARRIER(regs, reg0, reg1, BUS_SPACE_BARRIER_READ_BEFORE_WRITE)
13174689Sql147931 
13184689Sql147931 #define	RTW_WBRW(regs, reg0, reg1)				\
13194689Sql147931 		RTW_BARRIER(regs, reg0, reg1,			\
13204689Sql147931 		    BUS_SPACE_BARRIER_WRITE_BEFORE_READ |	\
13214689Sql147931 		    BUS_SPACE_BARRIER_WRITE_BEFORE_WRITE)
13224689Sql147931 
13234689Sql147931 /*
13244689Sql147931  * Registers for RTL8180L's built-in baseband modem.
13254689Sql147931  */
13264689Sql147931 #define	RTW_BBP_SYS1		0x00
13274689Sql147931 #define	RTW_BBP_TXAGC		0x03	/* guess: transmit auto gain control */
13284689Sql147931 /*
13294689Sql147931  * guess: low-noise amplifier activation threshold
13304689Sql147931  */
13314689Sql147931 #define	RTW_BBP_LNADET		0x04
13324689Sql147931 /*
13334689Sql147931  * guess: intermediate frequency (IF)
13344689Sql147931  * auto-gain control (AGC) initial value
13354689Sql147931  */
13364689Sql147931 #define	RTW_BBP_IFAGCINI	0x05
13374689Sql147931 #define	RTW_BBP_IFAGCLIMIT	0x06	/* guess: IF AGC maximum value */
13384689Sql147931 /*
13394689Sql147931  * guess: activation threshold for IF AGC loop
13404689Sql147931  */
13414689Sql147931 #define	RTW_BBP_IFAGCDET	0x07
13424689Sql147931 
13434689Sql147931 #define	RTW_BBP_ANTATTEN	0x10	/* guess: antenna & attenuation */
13444689Sql147931 #define	RTW_BBP_ANTATTEN_PHILIPS_MAGIC		0x91
13454689Sql147931 #define	RTW_BBP_ANTATTEN_INTERSIL_MAGIC		0x92
13464689Sql147931 #define	RTW_BBP_ANTATTEN_RFMD_MAGIC		0x93
13474689Sql147931 #define	RTW_BBP_ANTATTEN_MAXIM_MAGIC		0xb3
13484689Sql147931 #define	RTW_BBP_ANTATTEN_DFLANTB		0x40
13494689Sql147931 #define	RTW_BBP_ANTATTEN_CHAN14			0x0c
13504689Sql147931 
13514689Sql147931 /*
13524689Sql147931  * guess: transmit/receive switch latency
13534689Sql147931  */
13544689Sql147931 #define	RTW_BBP_TRL			0x11
13554689Sql147931 #define	RTW_BBP_SYS2			0x12
13564689Sql147931 #define	RTW_BBP_SYS2_ANTDIV		0x80	/* enable antenna diversity */
13574689Sql147931 /*
13584689Sql147931  * loopback rate?
13594689Sql147931  * 0: 1Mbps
13604689Sql147931  * 1: 2Mbps
13614689Sql147931  * 2: 5.5Mbps
13624689Sql147931  * 3: 11Mbps
13634689Sql147931  */
13644689Sql147931 #define	RTW_BBP_SYS2_RATE_MASK		BITS(5, 4)
13654689Sql147931 #define	RTW_BBP_SYS3			0x13
13664689Sql147931 /*
13674689Sql147931  * carrier-sense threshold
13684689Sql147931  */
13694689Sql147931 #define	RTW_BBP_SYS3_CSTHRESH_MASK	BITS(0, 3)
13704689Sql147931 /*
13714689Sql147931  * guess: channel energy-detect threshold
13724689Sql147931  */
13734689Sql147931 #define	RTW_BBP_CHESTLIM	0x19
13744689Sql147931 /*
13754689Sql147931  * guess: channel signal-quality threshold
13764689Sql147931  */
13774689Sql147931 #define	RTW_BBP_CHSQLIM		0x1a
13784689Sql147931 
13794689Sql147931 #define	RTW_EPROM_CMD_OPERATING_MODE_MASK	((1<<7)|(1<<6))
13804689Sql147931 #define	RTW_EPROM_CMD_OPERATING_MODE_SHIFT	6
13814689Sql147931 #define	RTW_EPROM_CS_SHIFT	3
13824689Sql147931 #define	RTW_EPROM_CK_SHIFT	2
13834689Sql147931 #define	RTW_EPROM_CMD_CONFIG	0x3
13844689Sql147931 #define	RTW_EPROM_CMD_NORMAL	0
13854689Sql147931 #define	RTW_EPROM_CMD_LOAD 1
13864689Sql147931 #define	RTW_TX_DMA_POLLING_HIPRIORITY_SHIFT 6
13874689Sql147931 #define	RTW_TX_DMA_POLLING_NORMPRIORITY_SHIFT 5
13884689Sql147931 #define	RTW_TX_DMA_POLLING_LOWPRIORITY_SHIFT 4
13894689Sql147931 #define	RTW_CONFIG2_DMA_POLLING_MODE_SHIFT 3
13904689Sql147931 
13914689Sql147931 #define	RTW_CMD_RST_SHIFT (4)
13924689Sql147931 #define	RTW_TX_DMA_STOP_BEACON_SHIFT 3
1393*10448SMikore.Li@Sun.COM #ifdef __cplusplus
1394*10448SMikore.Li@Sun.COM }
1395*10448SMikore.Li@Sun.COM #endif
13964689Sql147931 
13974689Sql147931 #endif /* _RTW_REG_H_ */
1398