rtwreg.h revision 1.5 1 /* $NetBSD: rtwreg.h,v 1.5 2004/12/27 08:59:16 mycroft 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. Neither the name of the author nor the names of any co-contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY David Young AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL David Young
25 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
31 * THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34 /* Macros for bit twiddling. */
35 /* TBD factor w/ dev/ic/atwreg.h. */
36
37 #ifndef _BIT_TWIDDLE
38 #define _BIT_TWIDDLE
39 /* nth bit, BIT(0) == 0x1. */
40 #define BIT(n) (((n) == 32) ? 0 : ((u_int32_t)1 << (n)))
41
42 /* bits m through n, m < n. */
43 #define BITS(m, n) ((BIT(MAX((m), (n)) + 1) - 1) ^ (BIT(MIN((m), (n))) - 1))
44
45 /* find least significant bit that is set */
46 #define LOWEST_SET_BIT(x) ((((x) - 1) & (x)) ^ (x))
47
48 /* for x a power of two and p a non-negative integer, is x a greater
49 * power than 2**p?
50 */
51 #define GTEQ_POWER(x, p) (((u_long)(x) >> (p)) != 0)
52
53 #define MASK_TO_SHIFT2(m) (GTEQ_POWER(LOWEST_SET_BIT((m)), 1) ? 1 : 0)
54
55 #define MASK_TO_SHIFT4(m) \
56 (GTEQ_POWER(LOWEST_SET_BIT((m)), 2) \
57 ? 2 + MASK_TO_SHIFT2((m) >> 2) \
58 : MASK_TO_SHIFT2((m)))
59
60 #define MASK_TO_SHIFT8(m) \
61 (GTEQ_POWER(LOWEST_SET_BIT((m)), 4) \
62 ? 4 + MASK_TO_SHIFT4((m) >> 4) \
63 : MASK_TO_SHIFT4((m)))
64
65 #define MASK_TO_SHIFT16(m) \
66 (GTEQ_POWER(LOWEST_SET_BIT((m)), 8) \
67 ? 8 + MASK_TO_SHIFT8((m) >> 8) \
68 : MASK_TO_SHIFT8((m)))
69
70 #define MASK_TO_SHIFT(m) \
71 (GTEQ_POWER(LOWEST_SET_BIT((m)), 16) \
72 ? 16 + MASK_TO_SHIFT16((m) >> 16) \
73 : MASK_TO_SHIFT16((m)))
74
75 #define MASK_AND_RSHIFT(x, mask) (((x) & (mask)) >> MASK_TO_SHIFT(mask))
76 #define LSHIFT(x, mask) ((x) << MASK_TO_SHIFT(mask))
77 #define MASK_AND_REPLACE(reg, val, mask) ((reg & ~mask) | LSHIFT(val, mask))
78 #define PRESHIFT(m) MASK_AND_RSHIFT((m), (m))
79
80 #endif /* _BIT_TWIDDLE */
81
82 /* RTL8180L Host Control and Status Registers */
83
84 #define RTW_IDR0 0x00 /* ID Register: MAC addr, 6 bytes.
85 * Auto-loaded from EEPROM. Read by byte,
86 * by word, or by double word, but write
87 * only by double word.
88 */
89 #define RTW_IDR1 0x04
90
91 #define RTW_MAR0 0x08 /* Multicast filter, 64b. */
92 #define RTW_MAR1 0x0c
93
94 #define RTW_TSFTRL 0x18 /* Timing Synchronization Function Timer
95 * Register, low word, 32b, read-only.
96 */
97 #define RTW_TSFTRH 0x1c /* High word, 32b, read-only. */
98 #define RTW_TLPDA 0x20 /* Transmit Low Priority Descriptors Start
99 * Address, 32b, 256-byte alignment.
100 */
101 #define RTW_TNPDA 0x24 /* Transmit Normal Priority Descriptors Start
102 * Address, 32b, 256-byte alignment.
103 */
104 #define RTW_THPDA 0x28 /* Transmit High Priority Descriptors Start
105 * Address, 32b, 256-byte alignment.
106 */
107
108 #define RTW_BRSR 0x2c /* Basic Rate Set Register, 16b */
109 #define RTW_BRSR_BPLCP BIT(8) /* 1: use short PLCP header for CTS/ACK packet,
110 * 0: use long PLCP header
111 */
112 #define RTW_BRSR_MBR8180_MASK BITS(1,0) /* Maximum Basic Service Rate */
113 #define RTW_BRSR_MBR8180_1MBPS LSHIFT(0, RTW_BRSR_MBR8180_MASK)
114 #define RTW_BRSR_MBR8180_2MBPS LSHIFT(1, RTW_BRSR_MBR8180_MASK)
115 #define RTW_BRSR_MBR8180_5MBPS LSHIFT(2, RTW_BRSR_MBR8180_MASK)
116 #define RTW_BRSR_MBR8180_11MBPS LSHIFT(3, RTW_BRSR_MBR8180_MASK)
117
118 /* 8181 and 8180 docs conflict! */
119 #define RTW_BRSR_MBR8181_1MBPS BIT(0)
120 #define RTW_BRSR_MBR8181_2MBPS BIT(1)
121 #define RTW_BRSR_MBR8181_5MBPS BIT(2)
122 #define RTW_BRSR_MBR8181_11MBPS BIT(3)
123
124 #define RTW_BSSID 0x2e
125 /* BSSID, 6 bytes */
126 #define RTW_BSSID16 0x2e /* first two bytes */
127 #define RTW_BSSID32 (0x2e + 4) /* remaining four bytes */
128 #define RTW_BSSID0 RTW_BSSID16 /* BSSID[0], 8b */
129 #define RTW_BSSID1 (RTW_BSSID0 + 1) /* BSSID[1], 8b */
130 #define RTW_BSSID2 (RTW_BSSID1 + 1) /* BSSID[2], 8b */
131 #define RTW_BSSID3 (RTW_BSSID2 + 1) /* BSSID[3], 8b */
132 #define RTW_BSSID4 (RTW_BSSID3 + 1) /* BSSID[4], 8b */
133 #define RTW_BSSID5 (RTW_BSSID4 + 1) /* BSSID[5], 8b */
134
135 #define RTW_CR 0x37 /* Command Register, 8b */
136 #define RTW_CR_RST BIT(4) /* Reset: host sets to 1 to disable
137 * transmitter & receiver, reinitialize FIFO.
138 * RTL8180L sets to 0 to signal completion.
139 */
140 #define RTW_CR_RE BIT(3) /* Receiver Enable: host enables receiver
141 * by writing 1. RTL8180L indicates receiver
142 * is active with 1. After power-up, host
143 * must wait for reset before writing.
144 */
145 #define RTW_CR_TE BIT(2) /* Transmitter Enable: host enables transmitter
146 * by writing 1. RTL8180L indicates transmitter
147 * is active with 1. After power-up, host
148 * must wait for reset before writing.
149 */
150 #define RTW_CR_MULRW BIT(0) /* PCI Multiple Read/Write enable: 1 enables,
151 * 0 disables. XXX RTL8180, only?
152 */
153
154 #define RTW_IMR 0x3c /* Interrupt Mask Register, 16b */
155 #define RTW_ISR 0x3e /* Interrupt status register, 16b */
156
157 #define RTW_INTR_TXFOVW BIT(15) /* Tx FIFO Overflow */
158 #define RTW_INTR_TIMEOUT BIT(14) /* Time Out: 1 indicates
159 * RTW_TSFTR[0:31] = RTW_TINT
160 */
161 #define RTW_INTR_BCNINT BIT(13) /* Beacon Time Out: time for host to
162 * prepare beacon:
163 * RTW_TSFTR % (RTW_BCNITV_BCNITV * TU) =
164 * (RTW_BCNITV_BCNITV * TU - RTW_BINTRITV)
165 */
166 #define RTW_INTR_ATIMINT BIT(12)
167 /* ATIM Time Out: ATIM interval will pass,
168 * RTW_TSFTR % (RTW_BCNITV_BCNITV * TU) =
169 * (RTW_ATIMWND_ATIMWND * TU - RTW_ATIMTRITV)
170 */
171 #define RTW_INTR_TBDER BIT(11) /* Tx Beacon Descriptor Error:
172 * beacon transmission aborted because
173 * frame Rx'd
174 */
175 #define RTW_INTR_TBDOK BIT(10) /* Tx Beacon Descriptor OK */
176 #define RTW_INTR_THPDER BIT(9) /* Tx High Priority Descriptor Error:
177 * reached short/long retry limit
178 */
179 #define RTW_INTR_THPDOK BIT(8) /* Tx High Priority Descriptor OK */
180 #define RTW_INTR_TNPDER BIT(7) /* Tx Normal Priority Descriptor Error:
181 * reached short/long retry limit
182 */
183 #define RTW_INTR_TNPDOK BIT(6) /* Tx Normal Priority Descriptor OK */
184 #define RTW_INTR_RXFOVW BIT(5) /* Rx FIFO Overflow: either RDU (see below)
185 * or PCI bus too slow/busy
186 */
187 #define RTW_INTR_RDU BIT(4) /* Rx Descriptor Unavailable */
188 #define RTW_INTR_TLPDER BIT(3) /* Tx Normal Priority Descriptor Error
189 * reached short/long retry limit
190 */
191 #define RTW_INTR_TLPDOK BIT(2) /* Tx Normal Priority Descriptor OK */
192 #define RTW_INTR_RER BIT(1) /* Rx Error: CRC32 or ICV error */
193 #define RTW_INTR_ROK BIT(0) /* Rx OK */
194
195 /* Convenient interrupt conjunctions. */
196 #define RTW_INTR_RX (RTW_INTR_RER|RTW_INTR_ROK)
197 #define RTW_INTR_TX (RTW_INTR_TLPDER|RTW_INTR_TLPDOK|RTW_INTR_THPDER|\
198 RTW_INTR_THPDOK|RTW_INTR_TNPDER|RTW_INTR_TNPDOK)
199 #define RTW_INTR_BEACON (RTW_INTR_TBDER|RTW_INTR_TBDOK|RTW_INTR_BCNINT)
200 #define RTW_INTR_IOERROR (RTW_INTR_TXFOVW|RTW_INTR_RXFOVW|RTW_INTR_RDU)
201
202 #define RTW_TCR 0x40 /* Transmit Configuration Register, 32b */
203 #define RTW_TCR_CWMIN BIT(31) /* 1: CWmin = 8, 0: CWmin = 32. */
204 #define RTW_TCR_SWSEQ BIT(30) /* 1: host assigns 802.11 sequence number,
205 * 0: hardware assigns sequence number
206 */
207 /* Hardware version ID, read-only */
208 #define RTW_TCR_HWVERID_MASK BITS(29, 25)
209 #define RTW_TCR_HWVERID_D LSHIFT(26, RTW_TCR_HWVERID_MASK)
210 #define RTW_TCR_HWVERID_F LSHIFT(27, RTW_TCR_HWVERID_MASK)
211 #define RTW_TCR_HWVERID_RTL8180 RTW_TCR_HWVERID_F
212
213 /* Set ACK/CTS Timeout (EIFS).
214 * 1: ACK rate = max(RTW_BRSR_MBR, Rx rate) (XXX not min? typo in datasheet?)
215 * 0: ACK rate = 1Mbps
216 */
217 #define RTW_TCR_SAT BIT(24)
218 /* Max DMA Burst Size per Tx DMA Burst */
219 #define RTW_TCR_MXDMA_MASK BITS(23,21)
220 #define RTW_TCR_MXDMA_16 LSHIFT(0, RTW_TCR_MXDMA_MASK)
221 #define RTW_TCR_MXDMA_32 LSHIFT(1, RTW_TCR_MXDMA_MASK)
222 #define RTW_TCR_MXDMA_64 LSHIFT(2, RTW_TCR_MXDMA_MASK)
223 #define RTW_TCR_MXDMA_128 LSHIFT(3, RTW_TCR_MXDMA_MASK)
224 #define RTW_TCR_MXDMA_256 LSHIFT(4, RTW_TCR_MXDMA_MASK)
225 #define RTW_TCR_MXDMA_512 LSHIFT(5, RTW_TCR_MXDMA_MASK)
226 #define RTW_TCR_MXDMA_1024 LSHIFT(6, RTW_TCR_MXDMA_MASK)
227 #define RTW_TCR_MXDMA_2048 LSHIFT(7, RTW_TCR_MXDMA_MASK)
228
229 #define RTW_TCR_DISCW BIT(20) /* disable 802.11 random backoff */
230
231 #define RTW_TCR_ICV BIT(19) /* host lets RTL8180 append ICV to
232 * WEP packets
233 */
234
235 /* Loopback Test: disables TXI/TXQ outputs. */
236 #define RTW_TCR_LBK_MASK BITS(18,17)
237 #define RTW_TCR_LBK_NORMAL LSHIFT(0, RTW_TCR_LBK_MASK) /* normal ops */
238 #define RTW_TCR_LBK_MAC LSHIFT(1, RTW_TCR_LBK_MASK) /* MAC loopback */
239 #define RTW_TCR_LBK_BBP LSHIFT(2, RTW_TCR_LBK_MASK) /* baseband loop. */
240 #define RTW_TCR_LBK_CONT LSHIFT(3, RTW_TCR_LBK_MASK) /* continuous Tx */
241
242 #define RTW_TCR_CRC BIT(16) /* 0: RTL8180 appends CRC32
243 * 1: host appends CRC32
244 *
245 * (I *think* this is right.
246 * The docs have a mysterious
247 * description in the
248 * passive voice.)
249 */
250 #define RTW_TCR_SRL_MASK BITS(15,8) /* Short Retry Limit */
251 #define RTW_TCR_LRL_MASK BITS(7,0) /* Long Retry Limit */
252
253 #define RTW_RCR 0x44 /* Receive Configuration Register, 32b */
254 #define RTW_RCR_ONLYERLPKT BIT(31) /* only do Early Rx on packets
255 * longer than 1536 bytes
256 */
257 #define RTW_RCR_ENCS2 BIT(30) /* enable carrier sense method 2 */
258 #define RTW_RCR_ENCS1 BIT(29) /* enable carrier sense method 1 */
259 #define RTW_RCR_ENMARP BIT(28) /* enable MAC auto-reset PHY */
260 #define RTW_RCR_CBSSID BIT(23) /* Check BSSID/ToDS/FromDS: set
261 * "Link On" when received BSSID
262 * matches RTW_BSSID and received
263 * ToDS/FromDS are appropriate
264 * according to RTW_MSR_NETYPE.
265 */
266 #define RTW_RCR_APWRMGT BIT(22) /* accept packets w/ PWRMGMT bit set */
267 #define RTW_RCR_ADD3 BIT(21) /* when RTW_MSR_NETYPE ==
268 * RTW_MSR_NETYPE_INFRA_OK, accept
269 * broadcast/multicast packets whose
270 * 3rd address matches RTL8180's MAC.
271 */
272 #define RTW_RCR_AMF BIT(20) /* accept management frames */
273 #define RTW_RCR_ACF BIT(19) /* accept control frames */
274 #define RTW_RCR_ADF BIT(18) /* accept data frames */
275 /* Rx FIFO Threshold: RTL8180 begins PCI transfer when this many data
276 * bytes are received
277 */
278 #define RTW_RCR_RXFTH_MASK BITS(15,13)
279 #define RTW_RCR_RXFTH_64 LSHIFT(2, RTW_RCR_RXFTH_MASK)
280 #define RTW_RCR_RXFTH_128 LSHIFT(3, RTW_RCR_RXFTH_MASK)
281 #define RTW_RCR_RXFTH_256 LSHIFT(4, RTW_RCR_RXFTH_MASK)
282 #define RTW_RCR_RXFTH_512 LSHIFT(5, RTW_RCR_RXFTH_MASK)
283 #define RTW_RCR_RXFTH_1024 LSHIFT(6, RTW_RCR_RXFTH_MASK)
284 #define RTW_RCR_RXFTH_WHOLE LSHIFT(7, RTW_RCR_RXFTH_MASK)
285
286 #define RTW_RCR_AICV BIT(12) /* accept frames w/ ICV errors */
287
288 /* Max DMA Burst Size per Rx DMA Burst */
289 #define RTW_RCR_MXDMA_MASK BITS(10,8)
290 #define RTW_RCR_MXDMA_16 LSHIFT(0, RTW_RCR_MXDMA_MASK)
291 #define RTW_RCR_MXDMA_32 LSHIFT(1, RTW_RCR_MXDMA_MASK)
292 #define RTW_RCR_MXDMA_64 LSHIFT(2, RTW_RCR_MXDMA_MASK)
293 #define RTW_RCR_MXDMA_128 LSHIFT(3, RTW_RCR_MXDMA_MASK)
294 #define RTW_RCR_MXDMA_256 LSHIFT(4, RTW_RCR_MXDMA_MASK)
295 #define RTW_RCR_MXDMA_512 LSHIFT(5, RTW_RCR_MXDMA_MASK)
296 #define RTW_RCR_MXDMA_1024 LSHIFT(6, RTW_RCR_MXDMA_MASK)
297 #define RTW_RCR_MXDMA_UNLIMITED LSHIFT(7, RTW_RCR_MXDMA_MASK)
298
299 /* EEPROM type, read-only. 1: EEPROM is 93c56, 0: 93c46 */
300 #define RTW_RCR_9356SEL BIT(6)
301
302 #define RTW_RCR_ACRC32 BIT(5) /* accept frames w/ CRC32 errors */
303 #define RTW_RCR_AB BIT(3) /* accept broadcast frames */
304 #define RTW_RCR_AM BIT(2) /* accept multicast frames */
305 /* accept physical match frames. XXX means PLCP header ok? */
306 #define RTW_RCR_APM BIT(1)
307 #define RTW_RCR_AAP BIT(0) /* accept frames w/ destination */
308
309 #define RTW_TINT 0x48 /* Timer Interrupt Register, 32b */
310 #define RTW_TBDA 0x4c /* Transmit Beacon Descriptor Start Address,
311 * 32b, 256-byte alignment
312 */
313 #define RTW_9346CR 0x50 /* 93c46/93c56 Command Register, 8b */
314 #define RTW_9346CR_EEM_MASK BITS(7,6) /* Operating Mode */
315 #define RTW_9346CR_EEM_NORMAL LSHIFT(0, RTW_9346CR_EEM_MASK)
316 /* Load the EEPROM. Reset registers to defaults.
317 * Takes ~2ms. RTL8180 indicates completion with RTW_9346CR_EEM_NORMAL.
318 * XXX RTL8180 only?
319 */
320 #define RTW_9346CR_EEM_AUTOLOAD LSHIFT(1, RTW_9346CR_EEM_MASK)
321 /* Disable network & bus-master operations and enable
322 * _EECS, _EESK, _EEDI, _EEDO.
323 * XXX RTL8180 only?
324 */
325 #define RTW_9346CR_EEM_PROGRAM LSHIFT(2, RTW_9346CR_EEM_MASK)
326 /* Enable RTW_CONFIG[0123] registers. */
327 #define RTW_9346CR_EEM_CONFIG LSHIFT(3, RTW_9346CR_EEM_MASK)
328 /* EEPROM pin status/control in _EEM_CONFIG, _EEM_AUTOLOAD modes.
329 * XXX RTL8180 only?
330 */
331 #define RTW_9346CR_EECS BIT(3)
332 #define RTW_9346CR_EESK BIT(2)
333 #define RTW_9346CR_EEDI BIT(1)
334 #define RTW_9346CR_EEDO BIT(0) /* read-only */
335
336 #define RTW_CONFIG0 0x51 /* Configuration Register 0, 8b */
337 #define RTW_CONFIG0_WEP40 BIT(7) /* implements 40-bit WEP,
338 * XXX RTL8180 only?
339 */
340 #define RTW_CONFIG0_WEP104 BIT(6) /* implements 104-bit WEP,
341 * from EEPROM, read-only
342 * XXX RTL8180 only?
343 */
344 #define RTW_CONFIG0_LEDGPOEN BIT(4) /* 1: RTW_PSR_LEDGPO[01] control
345 * LED[01] pins.
346 * 0: LED behavior defined by
347 * RTW_CONFIG1_LEDS10_MASK
348 * XXX RTL8180 only?
349 */
350 /* auxiliary power is present, read-only */
351 #define RTW_CONFIG0_AUXPWR BIT(3)
352 /* Geographic Location, read-only */
353 #define RTW_CONFIG0_GL_MASK BITS(1,0)
354 /* _RTW_CONFIG0_GL_* is what the datasheet says, but RTW_CONFIG0_GL_*
355 * work.
356 */
357 #define _RTW_CONFIG0_GL_USA LSHIFT(3, RTW_CONFIG0_GL_MASK)
358 #define RTW_CONFIG0_GL_EUROPE LSHIFT(2, RTW_CONFIG0_GL_MASK)
359 #define RTW_CONFIG0_GL_JAPAN LSHIFT(1, RTW_CONFIG0_GL_MASK)
360 #define RTW_CONFIG0_GL_USA LSHIFT(0, RTW_CONFIG0_GL_MASK)
361 /* RTL8181 datasheet says RTW_CONFIG0_GL_JAPAN = 0. */
362
363 #define RTW_CONFIG1 0x52 /* Configuration Register 1, 8b */
364
365 /* LED configuration. From EEPROM. Read/write.
366 *
367 * Setting LED0 LED1
368 * ------- ---- ----
369 * RTW_CONFIG1_LEDS_ACT_INFRA Activity Infrastructure
370 * RTW_CONFIG1_LEDS_ACT_LINK Activity Link
371 * RTW_CONFIG1_LEDS_TX_RX Tx Rx
372 * RTW_CONFIG1_LEDS_LINKACT_INFRA Link/Activity Infrastructure
373 */
374 #define RTW_CONFIG1_LEDS_MASK BITS(7,6)
375 #define RTW_CONFIG1_LEDS_ACT_INFRA LSHIFT(0, RTW_CONFIG1_LEDS_MASK)
376 #define RTW_CONFIG1_LEDS_ACT_LINK LSHIFT(1, RTW_CONFIG1_LEDS_MASK)
377 #define RTW_CONFIG1_LEDS_TX_RX LSHIFT(2, RTW_CONFIG1_LEDS_MASK)
378 #define RTW_CONFIG1_LEDS_LINKACT_INFRA LSHIFT(3, RTW_CONFIG1_LEDS_MASK)
379
380 /* LWAKE Output Signal. Only applicable to Cardbus. Pulse width is 150ms.
381 *
382 * RTW_CONFIG1_LWACT
383 * 0 1
384 * RTW_CONFIG4_LWPTN 0 active high active low
385 * 1 positive pulse negative pulse
386 */
387 #define RTW_CONFIG1_LWACT BIT(4)
388
389 #define RTW_CONFIG1_MEMMAP BIT(3) /* using PCI memory space, read-only */
390 #define RTW_CONFIG1_IOMAP BIT(2) /* using PCI I/O space, read-only */
391 #define RTW_CONFIG1_VPD BIT(1) /* if set, VPD from offsets
392 * 0x40-0x7f in EEPROM are at
393 * registers 0x60-0x67 of PCI
394 * Configuration Space (XXX huh?)
395 */
396 #define RTW_CONFIG1_PMEN BIT(0) /* Power Management Enable: TBD */
397
398 #define RTW_CONFIG2 0x53 /* Configuration Register 2, 8b */
399 #define RTW_CONFIG2_LCK BIT(7) /* clocks are locked, read-only:
400 * Tx frequency & symbol clocks
401 * are derived from the same OSC
402 */
403 #define RTW_CONFIG2_ANT BIT(6) /* diversity enabled, read-only */
404 #define RTW_CONFIG2_DPS BIT(3) /* Descriptor Polling State: enable
405 * test mode.
406 */
407 #define RTW_CONFIG2_PAPESIGN BIT(2) /* TBD, from EEPROM */
408 #define RTW_CONFIG2_PAPETIME_MASK BITS(1,0) /* TBD, from EEPROM */
409
410 #define RTW_ANAPARM 0x54 /* Analog parameter, 32b */
411 #define RTW_ANAPARM_RFPOW0_MASK BITS(30,28) /* undocumented bits
412 * which appear to
413 * control the power
414 * state of the RF
415 * components
416 */
417 #define RTW_ANAPARM_RFPOW_MASK \
418 (RTW_ANAPARM_RFPOW0_MASK|RTW_ANAPARM_RFPOW1_MASK)
419
420 #define RTW_ANAPARM_TXDACOFF BIT(27) /* 1: disable Tx DAC,
421 * 0: enable
422 */
423 #define RTW_ANAPARM_RFPOW1_MASK BITS(26,20) /* undocumented bits
424 * which appear to
425 * control the power
426 * state of the RF
427 * components
428 */
429
430 /*
431 * Maxim On/Sleep/Off control
432 */
433 #define RTW_ANAPARM_RFPOW_MAXIM_ON LSHIFT(0x8, RTW_ANAPARM_RFPOW1_MASK)
434
435 /* reg[RTW_ANAPARM] |= RTW_ANAPARM_TXDACOFF; */
436 #define RTW_ANAPARM_RFPOW_MAXIM_SLEEP LSHIFT(0x378, RTW_ANAPARM_RFPOW1_MASK)
437
438 /* reg[RTW_ANAPARM] |= RTW_ANAPARM_TXDACOFF; */
439 #define RTW_ANAPARM_RFPOW_MAXIM_OFF LSHIFT(0x379, RTW_ANAPARM_RFPOW1_MASK)
440
441 /*
442 * RFMD On/Sleep/Off control
443 */
444 #define RTW_ANAPARM_RFPOW_RFMD_ON LSHIFT(0x408, RTW_ANAPARM_RFPOW1_MASK)
445
446 /* reg[RTW_ANAPARM] |= RTW_ANAPARM_TXDACOFF; */
447 #define RTW_ANAPARM_RFPOW_RFMD_SLEEP LSHIFT(0x378, RTW_ANAPARM_RFPOW1_MASK)
448
449 /* reg[RTW_ANAPARM] |= RTW_ANAPARM_TXDACOFF; */
450 #define RTW_ANAPARM_RFPOW_RFMD_OFF LSHIFT(0x379, RTW_ANAPARM_RFPOW1_MASK)
451
452 /*
453 * Philips On/Sleep/Off control
454 */
455 #define RTW_ANAPARM_RFPOW_ANA_PHILIPS_ON \
456 LSHIFT(0x328, RTW_ANAPARM_RFPOW1_MASK)
457 #define RTW_ANAPARM_RFPOW_DIG_PHILIPS_ON \
458 LSHIFT(0x008, RTW_ANAPARM_RFPOW1_MASK)
459
460 /* reg[RTW_ANAPARM] |= RTW_ANAPARM_TXDACOFF; */
461 #define RTW_ANAPARM_RFPOW_PHILIPS_SLEEP\
462 LSHIFT(0x378, RTW_ANAPARM_RFPOW1_MASK)
463
464 /* reg[RTW_ANAPARM] |= RTW_ANAPARM_TXDACOFF; */
465 #define RTW_ANAPARM_RFPOW_PHILIPS_OFF\
466 LSHIFT(0x379, RTW_ANAPARM_RFPOW1_MASK)
467
468 #define RTW_ANAPARM_RFPOW_PHILIPS_ON LSHIFT(0x328, RTW_ANAPARM_RFPOW1_MASK)
469
470 #define RTW_ANAPARM_CARDSP_MASK BITS(19,0) /* undocumented
471 * card-specific
472 * bits from the
473 * EEPROM.
474 */
475
476 #define RTW_MSR 0x58 /* Media Status Register, 8b */
477 /* Network Type and Link Status */
478 #define RTW_MSR_NETYPE_MASK BITS(3,2)
479 /* AP, XXX RTL8181 only? */
480 #define RTW_MSR_NETYPE_AP_OK LSHIFT(3, RTW_MSR_NETYPE_MASK)
481 /* infrastructure link ok */
482 #define RTW_MSR_NETYPE_INFRA_OK LSHIFT(2, RTW_MSR_NETYPE_MASK)
483 /* ad-hoc link ok */
484 #define RTW_MSR_NETYPE_ADHOC_OK LSHIFT(1, RTW_MSR_NETYPE_MASK)
485 /* no link */
486 #define RTW_MSR_NETYPE_NOLINK LSHIFT(0, RTW_MSR_NETYPE_MASK)
487
488 #define RTW_CONFIG3 0x59 /* Configuration Register 3, 8b */
489 #define RTW_CONFIG3_GNTSEL BIT(7) /* Grant Select, read-only */
490 #define RTW_CONFIG3_PARMEN BIT(6) /* Set RTW_CONFIG3_PARMEN and
491 * RTW_9346CR_EEM_CONFIG to
492 * allow RTW_ANAPARM writes.
493 */
494 #define RTW_CONFIG3_MAGIC BIT(5) /* Valid when RTW_CONFIG1_PMEN is
495 * set. If set, RTL8180 wakes up
496 * OS when Magic Packet is Rx'd.
497 */
498 #define RTW_CONFIG3_CARDBEN BIT(3) /* Cardbus-related registers
499 * and functions are enabled,
500 * read-only. XXX RTL8180 only.
501 */
502 #define RTW_CONFIG3_CLKRUNEN BIT(2) /* CLKRUN enabled, read-only.
503 * XXX RTL8180 only.
504 */
505 #define RTW_CONFIG3_FUNCREGEN BIT(1) /* Function Registers Enabled,
506 * read-only. XXX RTL8180 only.
507 */
508 #define RTW_CONFIG3_FBTBEN BIT(0) /* Fast back-to-back enabled,
509 * read-only.
510 */
511 #define RTW_CONFIG4 0x5A /* Configuration Register 4, 8b */
512 #define RTW_CONFIG4_VCOPDN BIT(7) /* VCO Power Down
513 * 0: normal operation
514 * (power-on default)
515 * 1: power-down VCO, RF front-end,
516 * and most RTL8180 components.
517 */
518 #define RTW_CONFIG4_PWROFF BIT(6) /* Power Off
519 * 0: normal operation
520 * (power-on default)
521 * 1: power-down RF front-end,
522 * and most RTL8180 components,
523 * but leave VCO on.
524 *
525 * XXX RFMD front-end only?
526 */
527 #define RTW_CONFIG4_PWRMGT BIT(5) /* Power Management
528 * 0: normal operation
529 * (power-on default)
530 * 1: set Tx packet's PWRMGMT bit.
531 */
532 #define RTW_CONFIG4_LWPME BIT(4) /* LANWAKE vs. PMEB: Cardbus-only
533 * 0: LWAKE & PMEB asserted
534 * simultaneously
535 * 1: LWAKE asserted only if
536 * both PMEB is asserted and
537 * ISOLATEB is low.
538 * XXX RTL8180 only.
539 */
540 #define RTW_CONFIG4_LWPTN BIT(2) /* see RTW_CONFIG1_LWACT
541 * XXX RTL8180 only.
542 */
543 /* Radio Front-End Programming Method */
544 #define RTW_CONFIG4_RFTYPE_MASK BITS(1,0)
545 #define RTW_CONFIG4_RFTYPE_INTERSIL LSHIFT(1, RTW_CONFIG4_RFTYPE_MASK)
546 #define RTW_CONFIG4_RFTYPE_RFMD LSHIFT(2, RTW_CONFIG4_RFTYPE_MASK)
547 #define RTW_CONFIG4_RFTYPE_PHILIPS LSHIFT(3, RTW_CONFIG4_RFTYPE_MASK)
548
549 #define RTW_TESTR 0x5B /* TEST mode register, 8b */
550
551 #define RTW_PSR 0x5e /* Page Select Register, 8b */
552 #define RTW_PSR_GPO BIT(7) /* Control/status of pin 52. */
553 #define RTW_PSR_GPI BIT(6) /* Status of pin 64. */
554 #define RTW_PSR_LEDGPO1 BIT(5) /* Status/control of LED1 pin if
555 * RTW_CONFIG0_LEDGPOEN is set.
556 */
557 #define RTW_PSR_LEDGPO0 BIT(4) /* Status/control of LED0 pin if
558 * RTW_CONFIG0_LEDGPOEN is set.
559 */
560 #define RTW_PSR_UWF BIT(1) /* Enable Unicast Wakeup Frame */
561 #define RTW_PSR_PSEN BIT(0) /* 1: page 1, 0: page 0 */
562
563 #define RTW_SCR 0x5f /* Security Configuration Register, 8b */
564 #define RTW_SCR_KM_MASK BITS(5,4) /* Key Mode */
565 #define RTW_SCR_KM_WEP104 LSHIFT(1, RTW_SCR_KM_MASK)
566 #define RTW_SCR_KM_WEP40 LSHIFT(0, RTW_SCR_KM_MASK)
567 #define RTW_SCR_TXSECON BIT(1) /* Enable Tx WEP. Invalid if
568 * neither RTW_CONFIG0_WEP40 nor
569 * RTW_CONFIG0_WEP104 is set.
570 */
571 #define RTW_SCR_RXSECON BIT(0) /* Enable Rx WEP. Invalid if
572 * neither RTW_CONFIG0_WEP40 nor
573 * RTW_CONFIG0_WEP104 is set.
574 */
575
576 #define RTW_BCNITV 0x70 /* Beacon Interval Register, 16b */
577 #define RTW_BCNITV_BCNITV_MASK BITS(9,0) /* TU between TBTT, written
578 * by host.
579 */
580 #define RTW_ATIMWND 0x72 /* ATIM Window Register, 16b */
581 #define RTW_ATIMWND_ATIMWND BITS(9,0) /* ATIM Window length in TU,
582 * written by host.
583 */
584
585 #define RTW_BINTRITV 0x74 /* Beacon Interrupt Interval Register, 16b */
586 #define RTW_BINTRITV_BINTRITV BITS(9,0) /* RTL8180 wakes host with
587 * RTW_INTR_BCNINT at BINTRITV
588 * microseconds before TBTT
589 */
590 #define RTW_ATIMTRITV 0x76 /* ATIM Interrupt Interval Register, 16b */
591 #define RTW_ATIMTRITV_ATIMTRITV BITS(9,0) /* RTL8180 wakes host with
592 * RTW_INTR_ATIMINT at ATIMTRITV
593 * microseconds before end of
594 * ATIM Window
595 */
596
597 #define RTW_PHYDELAY 0x78 /* PHY Delay Register, 8b */
598 #define RTW_PHYDELAY_REVC_MAGIC BIT(3) /* Rev. C magic from reference
599 * driver
600 */
601 #define RTW_PHYDELAY_PHYDELAY BITS(2,0) /* microsecond Tx delay between
602 * MAC and RF front-end
603 */
604 #define RTW_CRCOUNT 0x79 /* Carrier Sense Counter, 8b */
605 #define RTW_CRCOUNT_MAGIC 0x4c
606
607 #define RTW_CRC16ERR 0x7a /* CRC16 error count, 16b, XXX RTL8181 only? */
608
609 #define RTW_BB 0x7c /* Baseband interface, 32b */
610 /* used for writing RTL8180's integrated baseband processor */
611 #define RTW_BB_RD_MASK BITS(23,16) /* data to read */
612 #define RTW_BB_WR_MASK BITS(15,8) /* data to write */
613 #define RTW_BB_WREN BIT(7) /* write enable */
614 #define RTW_BB_ADDR_MASK BITS(6,0) /* address */
615
616 #define RTW_PHYADDR 0x7c /* Address register for PHY interface, 8b */
617 #define RTW_PHYDATAW 0x7d /* Write data to PHY, 8b, write-only */
618 #define RTW_PHYDATAR 0x7e /* Read data from PHY, 8b (?), read-only */
619
620 #define RTW_PHYCFG 0x80 /* PHY Configuration Register, 32b */
621 #define RTW_PHYCFG_MAC_POLL BIT(31) /* if !RTW_PHYCFG_HST,
622 * host sets. MAC clears
623 * after banging bits.
624 */
625 #define RTW_PHYCFG_HST BIT(30) /* 1: host bangs bits
626 * 0: MAC bangs bits
627 */
628 #define RTW_PHYCFG_MAC_RFTYPE_MASK BITS(29,28)
629 #define RTW_PHYCFG_MAC_RFTYPE_INTERSIL LSHIFT(0, RTW_PHYCFG_MAC_RFTYPE_MASK)
630 #define RTW_PHYCFG_MAC_RFTYPE_RFMD LSHIFT(1, RTW_PHYCFG_MAC_RFTYPE_MASK)
631 #define RTW_PHYCFG_MAC_RFTYPE_GCT RTW_PHYCFG_MAC_RFTYPE_RFMD
632 #define RTW_PHYCFG_MAC_RFTYPE_PHILIPS LSHIFT(3, RTW_PHYCFG_MAC_RFTYPE_MASK)
633 #define RTW_PHYCFG_MAC_PHILIPS_ADDR_MASK BITS(27,24)
634 #define RTW_PHYCFG_MAC_PHILIPS_DATA_MASK BITS(23,0)
635 #define RTW_PHYCFG_MAC_MAXIM_LODATA_MASK BITS(27,24)
636 #define RTW_PHYCFG_MAC_MAXIM_ADDR_MASK BITS(11,8)
637 #define RTW_PHYCFG_MAC_MAXIM_HIDATA_MASK BITS(7,0)
638 #define RTW_PHYCFG_HST_EN BIT(2)
639 #define RTW_PHYCFG_HST_CLK BIT(1)
640 #define RTW_PHYCFG_HST_DATA BIT(0)
641
642 #define RTW_MAXIM_HIDATA_MASK BITS(11,4)
643 #define RTW_MAXIM_LODATA_MASK BITS(3,0)
644
645 /**
646 ** 0x84 - 0xD3, page 1, selected when RTW_PSR[PSEN] == 1.
647 **/
648
649 #define RTW_WAKEUP0L 0x84 /* Power Management Wakeup Frame */
650 #define RTW_WAKEUP0H 0x88 /* 32b */
651
652 #define RTW_WAKEUP1L 0x8c
653 #define RTW_WAKEUP1H 0x90
654
655 #define RTW_WAKEUP2LL 0x94
656 #define RTW_WAKEUP2LH 0x98
657
658 #define RTW_WAKEUP2HL 0x9c
659 #define RTW_WAKEUP2HH 0xa0
660
661 #define RTW_WAKEUP3LL 0xa4
662 #define RTW_WAKEUP3LH 0xa8
663
664 #define RTW_WAKEUP3HL 0xac
665 #define RTW_WAKEUP3HH 0xb0
666
667 #define RTW_WAKEUP4LL 0xb4
668 #define RTW_WAKEUP4LH 0xb8
669
670 #define RTW_WAKEUP4HL 0xbc
671 #define RTW_WAKEUP4HH 0xc0
672
673 #define RTW_CRC0 0xc4 /* CRC of wakeup frame 0, 16b */
674 #define RTW_CRC1 0xc6 /* CRC of wakeup frame 1, 16b */
675 #define RTW_CRC2 0xc8 /* CRC of wakeup frame 2, 16b */
676 #define RTW_CRC3 0xca /* CRC of wakeup frame 3, 16b */
677 #define RTW_CRC4 0xcc /* CRC of wakeup frame 4, 16b */
678
679 /**
680 ** 0x84 - 0xD3, page 0, selected when RTW_PSR[PSEN] == 0.
681 **/
682
683 /* Default Key Registers, each 128b
684 *
685 * If RTW_SCR_KM_WEP104, 104 lsb are the key.
686 * If RTW_SCR_KM_WEP40, 40 lsb are the key.
687 */
688 #define RTW_DK0 0x90 /* Default Key 0 Register, 128b */
689 #define RTW_DK1 0xa0 /* Default Key 1 Register, 128b */
690 #define RTW_DK2 0xb0 /* Default Key 2 Register, 128b */
691 #define RTW_DK3 0xc0 /* Default Key 3 Register, 128b */
692
693 #define RTW_CONFIG5 0xd8 /* Configuration Register 5, 8b */
694 #define RTW_CONFIG5_TXFIFOOK BIT(7) /* Tx FIFO self-test pass, read-only */
695 #define RTW_CONFIG5_RXFIFOOK BIT(6) /* Rx FIFO self-test pass, read-only */
696 #define RTW_CONFIG5_CALON BIT(5) /* 1: start calibration cycle
697 * and raise AGCRESET pin.
698 * 0: lower AGCRESET pin
699 */
700 #define RTW_CONFIG5_EACPI BIT(2) /* Enable ACPI Wake up, default 0 */
701 #define RTW_CONFIG5_LANWAKE BIT(1) /* Enable LAN Wake signal,
702 * from EEPROM
703 */
704 #define RTW_CONFIG5_PMESTS BIT(0) /* 1: both software & PCI Reset
705 * reset PME_Status
706 * 0: only software resets PME_Status
707 *
708 * From EEPROM.
709 */
710
711 #define RTW_TPPOLL 0xd9 /* Transmit Priority Polling Register, 8b,
712 * write-only.
713 */
714 #define RTW_TPPOLL_BQ BIT(7) /* RTL8180 clears to notify host of a beacon
715 * Tx. Host writes have no effect.
716 */
717 #define RTW_TPPOLL_HPQ BIT(6) /* Host writes 1 to notify RTL8180 of
718 * high-priority Tx packets, RTL8180 clears
719 * to after high-priority Tx is complete.
720 */
721 #define RTW_TPPOLL_NPQ BIT(5) /* If RTW_CONFIG2_DPS is set,
722 * host writes 1 to notify RTL8180 of
723 * normal-priority Tx packets, RTL8180 clears
724 * after normal-priority Tx is complete.
725 *
726 * If RTW_CONFIG2_DPS is clear, host writes
727 * have no effect. RTL8180 clears after
728 * normal-priority Tx is complete.
729 */
730 #define RTW_TPPOLL_LPQ BIT(4) /* Host writes 1 to notify RTL8180 of
731 * low-priority Tx packets, RTL8180 clears
732 * after low-priority Tx is complete.
733 */
734 #define RTW_TPPOLL_SBQ BIT(3) /* Host writes 1 to tell RTL8180 to
735 * stop beacon DMA. This bit is invalid
736 * when RTW_CONFIG2_DPS is set.
737 */
738 #define RTW_TPPOLL_SHPQ BIT(2) /* Host writes 1 to tell RTL8180 to
739 * stop high-priority DMA.
740 */
741 #define RTW_TPPOLL_SNPQ BIT(2) /* Host writes 1 to tell RTL8180 to
742 * stop normal-priority DMA. This bit is invalid
743 * when RTW_CONFIG2_DPS is set.
744 */
745 #define RTW_TPPOLL_SLPQ BIT(2) /* Host writes 1 to tell RTL8180 to
746 * stop low-priority DMA.
747 */
748 #define RTW_TPPOLL_FSWINT BIT(0) /* Force software interrupt. From
749 * reference driver.
750 */
751
752
753 #define RTW_CWR 0xdc /* Contention Window Register, 16b, read-only */
754 /* Contention Window: indicates number of contention windows before Tx
755 */
756 #define RTW_CWR_CW BITS(9,0)
757
758 /* Retry Count Register, 16b, read-only */
759 #define RTW_RETRYCTR 0xde
760 /* Retry Count: indicates number of retries after Tx */
761 #define RTW_RETRYCTR_RETRYCT BITS(7,0)
762
763 #define RTW_RDSAR 0xe4 /* Receive descriptor Start Address Register,
764 * 32b, 256-byte alignment.
765 */
766 /* Function Event Register, 32b, Cardbus only. Only valid when
767 * both RTW_CONFIG3_CARDBEN and RTW_CONFIG3_FUNCREGEN are set.
768 */
769 #define RTW_FER 0xf0
770 #define RTW_FER_INTR BIT(15) /* set when RTW_FFER_INTR is set */
771 #define RTW_FER_GWAKE BIT(4) /* General Wakeup */
772 /* Function Event Mask Register, 32b, Cardbus only. Only valid when
773 * both RTW_CONFIG3_CARDBEN and RTW_CONFIG3_FUNCREGEN are set.
774 */
775 #define RTW_FEMR 0xf4
776 #define RTW_FEMR_INTR BIT(15) /* set when RTW_FFER_INTR is set */
777 #define RTW_FEMR_WKUP BIT(14) /* Wakeup Mask */
778 #define RTW_FEMR_GWAKE BIT(4) /* General Wakeup */
779 /* Function Present State Register, 32b, read-only, Cardbus only.
780 * Only valid when both RTW_CONFIG3_CARDBEN and RTW_CONFIG3_FUNCREGEN
781 * are set.
782 */
783 #define RTW_FPSR 0xf8
784 #define RTW_FPSR_INTR BIT(15) /* TBD */
785 #define RTW_FPSR_GWAKE BIT(4) /* General Wakeup: TBD */
786 /* Function Force Event Register, 32b, write-only, Cardbus only.
787 * Only valid when both RTW_CONFIG3_CARDBEN and RTW_CONFIG3_FUNCREGEN
788 * are set.
789 */
790 #define RTW_FFER 0xfc
791 #define RTW_FFER_INTR BIT(15) /* TBD */
792 #define RTW_FFER_GWAKE BIT(4) /* General Wakeup: TBD */
793
794 /* Serial EEPROM offsets */
795 #define RTW_SR_ID 0x00 /* 16b */
796 #define RTW_SR_VID 0x02 /* 16b */
797 #define RTW_SR_DID 0x04 /* 16b */
798 #define RTW_SR_SVID 0x06 /* 16b */
799 #define RTW_SR_SMID 0x08 /* 16b */
800 #define RTW_SR_MNGNT 0x0a
801 #define RTW_SR_MXLAT 0x0b
802 #define RTW_SR_RFCHIPID 0x0c
803 #define RTW_SR_CONFIG3 0x0d
804 #define RTW_SR_MAC 0x0e /* 6 bytes */
805 #define RTW_SR_CONFIG0 0x14
806 #define RTW_SR_CONFIG1 0x15
807 #define RTW_SR_PMC 0x16 /* Power Management Capabilities, 16b */
808 #define RTW_SR_CONFIG2 0x18
809 #define RTW_SR_CONFIG4 0x19
810 #define RTW_SR_ANAPARM 0x1a /* Analog Parameters, 32b */
811 #define RTW_SR_TESTR 0x1e
812 #define RTW_SR_CONFIG5 0x1f
813 #define RTW_SR_TXPOWER1 0x20
814 #define RTW_SR_TXPOWER2 0x21
815 #define RTW_SR_TXPOWER3 0x22
816 #define RTW_SR_TXPOWER4 0x23
817 #define RTW_SR_TXPOWER5 0x24
818 #define RTW_SR_TXPOWER6 0x25
819 #define RTW_SR_TXPOWER7 0x26
820 #define RTW_SR_TXPOWER8 0x27
821 #define RTW_SR_TXPOWER9 0x28
822 #define RTW_SR_TXPOWER10 0x29
823 #define RTW_SR_TXPOWER11 0x2a
824 #define RTW_SR_TXPOWER12 0x2b
825 #define RTW_SR_TXPOWER13 0x2c
826 #define RTW_SR_TXPOWER14 0x2d
827 #define RTW_SR_CHANNELPLAN 0x2e /* bitmap of channels to scan */
828 #define RTW_SR_ENERGYDETTHR 0x2f /* energy-detect threshold */
829 #define RTW_SR_ENERGYDETTHR_DEFAULT 0x0c /* use this if old SROM */
830 #define RTW_SR_CISPOINTER 0x30 /* 16b */
831 #define RTW_SR_RFPARM 0x32 /* RF-specific parameter */
832 #define RTW_SR_RFPARM_DIGPHY BIT(0) /* 1: digital PHY */
833 #define RTW_SR_RFPARM_DFLANTB BIT(1) /* 1: antenna B is default */
834 #define RTW_SR_RFPARM_CS_MASK BITS(2,3) /* carrier-sense type */
835 #define RTW_SR_VERSION 0x3c /* EEPROM content version, 16b */
836 #define RTW_SR_CRC 0x3e /* EEPROM content CRC, 16b */
837 #define RTW_SR_VPD 0x40 /* Vital Product Data, 64 bytes */
838 #define RTW_SR_CIS 0x80 /* CIS Data, 93c56 only, 128 bytes*/
839
840 /*
841 * RTL8180 Transmit/Receive Descriptors
842 */
843
844 /* the first descriptor in each ring must be on a 256-byte boundary */
845 #define RTW_DESC_ALIGNMENT 256
846
847 /* Tx descriptor */
848 struct rtw_txdesc {
849 u_int32_t htx_ctl0;
850 u_int32_t htx_ctl1;
851 u_int32_t htx_buf;
852 u_int32_t htx_len;
853 u_int32_t htx_next;
854 u_int32_t htx_rsvd[3];
855 };
856
857 #define htx_stat htx_ctl0
858
859 #define RTW_TXCTL0_OWN BIT(31) /* 1: ready to Tx */
860 #define RTW_TXCTL0_RSVD0 BIT(30) /* reserved */
861 #define RTW_TXCTL0_FS BIT(29) /* first segment */
862 #define RTW_TXCTL0_LS BIT(28) /* last segment */
863
864 #define RTW_TXCTL0_RATE_MASK BITS(27,24) /* Tx rate */
865 #define RTW_TXCTL0_RATE_1MBPS LSHIFT(0, RTW_TXCTL0_RATE_MASK)
866 #define RTW_TXCTL0_RATE_2MBPS LSHIFT(1, RTW_TXCTL0_RATE_MASK)
867 #define RTW_TXCTL0_RATE_5MBPS LSHIFT(2, RTW_TXCTL0_RATE_MASK)
868 #define RTW_TXCTL0_RATE_11MBPS LSHIFT(3, RTW_TXCTL0_RATE_MASK)
869
870 #define RTW_TXCTL0_RTSEN BIT(23) /* RTS Enable */
871
872 #define RTW_TXCTL0_RTSRATE_MASK BITS(22,19) /* Tx rate */
873 #define RTW_TXCTL0_RTSRATE_1MBPS LSHIFT(0, RTW_TXCTL0_RTSRATE_MASK)
874 #define RTW_TXCTL0_RTSRATE_2MBPS LSHIFT(1, RTW_TXCTL0_RTSRATE_MASK)
875 #define RTW_TXCTL0_RTSRATE_5MBPS LSHIFT(2, RTW_TXCTL0_RTSRATE_MASK)
876 #define RTW_TXCTL0_RTSRATE_11MBPS LSHIFT(3, RTW_TXCTL0_RTSRATE_MASK)
877
878 #define RTW_TXCTL0_BEACON BIT(18) /* packet is a beacon */
879 #define RTW_TXCTL0_MOREFRAG BIT(17) /* another fragment follows */
880 #define RTW_TXCTL0_SPLCP BIT(16) /* add short PLCP preamble
881 * and header
882 */
883 #define RTW_TXCTL0_KEYID_MASK BITS(15,14) /* default key id */
884 #define RTW_TXCTL0_RSVD1_MASK BITS(13,12) /* reserved */
885 #define RTW_TXCTL0_TPKTSIZE_MASK BITS(11,0) /* Tx packet size
886 * in bytes
887 */
888
889 #define RTW_TXSTAT_OWN RTW_TXCTL0_OWN
890 #define RTW_TXSTAT_RSVD0 RTW_TXCTL0_RSVD0
891 #define RTW_TXSTAT_FS RTW_TXCTL0_FS
892 #define RTW_TXSTAT_LS RTW_TXCTL0_LS
893 #define RTW_TXSTAT_RSVD1_MASK BITS(27,16)
894 #define RTW_TXSTAT_TOK BIT(15)
895 #define RTW_TXSTAT_RTSRETRY_MASK BITS(14,8) /* RTS retry count */
896 #define RTW_TXSTAT_DRC_MASK BITS(7,0) /* Data retry count */
897
898 #define RTW_TXCTL1_LENGEXT BIT(31) /* supplements _LENGTH
899 * in packets sent 5.5Mb/s or
900 * faster
901 */
902 #define RTW_TXCTL1_LENGTH_MASK BITS(30,16) /* PLCP length (microseconds) */
903 #define RTW_TXCTL1_RTSDUR_MASK BITS(15,0) /* RTS Duration
904 * (microseconds)
905 */
906
907 #define RTW_TXLEN_LENGTH_MASK BITS(11,0) /* Tx buffer length in bytes */
908
909 /* Rx descriptor */
910 struct rtw_rxdesc {
911 u_int32_t hrx_ctl;
912 u_int32_t hrx_rsvd0;
913 u_int32_t hrx_buf;
914 u_int32_t hrx_rsvd1;
915 };
916
917 #define hrx_stat hrx_ctl
918 #define hrx_rssi hrx_rsvd0
919 #define hrx_tsftl hrx_buf /* valid only when RTW_RXSTAT_LS is set */
920 #define hrx_tsfth hrx_rsvd1 /* valid only when RTW_RXSTAT_LS is set */
921
922 #define RTW_RXCTL_OWN BIT(31) /* 1: owned by NIC */
923 #define RTW_RXCTL_EOR BIT(30) /* end of ring */
924 #define RTW_RXCTL_FS BIT(29) /* first segment */
925 #define RTW_RXCTL_LS BIT(28) /* last segment */
926 #define RTW_RXCTL_RSVD0_MASK BITS(29,12) /* reserved */
927 #define RTW_RXCTL_LENGTH_MASK BITS(11,0) /* Rx buffer length */
928
929 #define RTW_RXSTAT_OWN RTW_RXCTL_OWN
930 #define RTW_RXSTAT_EOR RTW_RXCTL_EOR
931 #define RTW_RXSTAT_FS RTW_RXCTL_FS /* first segment */
932 #define RTW_RXSTAT_LS RTW_RXCTL_LS /* last segment */
933 #define RTW_RXSTAT_DMAFAIL BIT(27) /* DMA failure on this pkt */
934 #define RTW_RXSTAT_BOVF BIT(26) /* buffer overflow XXX means
935 * FIFO exhausted?
936 */
937 #define RTW_RXSTAT_SPLCP BIT(25) /* Rx'd with short preamble
938 * and PLCP header
939 */
940 #define RTW_RXSTAT_RSVD1 BIT(24) /* reserved */
941 #define RTW_RXSTAT_RATE_MASK BITS(23,20) /* Rx rate */
942 #define RTW_RXSTAT_RATE_1MBPS LSHIFT(0, RTW_RXSTAT_RATE_MASK)
943 #define RTW_RXSTAT_RATE_2MBPS LSHIFT(1, RTW_RXSTAT_RATE_MASK)
944 #define RTW_RXSTAT_RATE_5MBPS LSHIFT(2, RTW_RXSTAT_RATE_MASK)
945 #define RTW_RXSTAT_RATE_11MBPS LSHIFT(3, RTW_RXSTAT_RATE_MASK)
946 #define RTW_RXSTAT_MIC BIT(19) /* XXX from reference driver */
947 #define RTW_RXSTAT_MAR BIT(18) /* is multicast */
948 #define RTW_RXSTAT_PAR BIT(17) /* matches RTL8180's MAC */
949 #define RTW_RXSTAT_BAR BIT(16) /* is broadcast */
950 #define RTW_RXSTAT_RES BIT(15) /* error summary. valid when
951 * RTW_RXSTAT_LS set. indicates
952 * that either RTW_RXSTAT_CRC32
953 * or RTW_RXSTAT_ICV is set.
954 */
955 #define RTW_RXSTAT_PWRMGT BIT(14) /* 802.11 PWRMGMT bit is set */
956 #define RTW_RXSTAT_CRC16 BIT(14) /* XXX CRC16 error, from
957 * reference driver
958 */
959 #define RTW_RXSTAT_CRC32 BIT(13) /* CRC32 error */
960 #define RTW_RXSTAT_ICV BIT(12) /* ICV error */
961 #define RTW_RXSTAT_LENGTH_MASK BITS(11,0) /* frame length, including
962 * CRC32
963 */
964
965 /* Convenient status conjunction. */
966 #define RTW_RXSTAT_ONESEG (RTW_RXSTAT_FS|RTW_RXSTAT_LS)
967 /* Convenient status disjunctions. */
968 #define RTW_RXSTAT_IOERROR (RTW_RXSTAT_DMAFAIL|RTW_RXSTAT_BOVF)
969 #define RTW_RXSTAT_DEBUG (RTW_RXSTAT_SPLCP|RTW_RXSTAT_MAR|\
970 RTW_RXSTAT_PAR|RTW_RXSTAT_BAR|\
971 RTW_RXSTAT_PWRMGT|RTW_RXSTAT_CRC32|\
972 RTW_RXSTAT_ICV)
973
974
975 #define RTW_RXRSSI_VLAN BITS(32,16) /* XXX from reference driver */
976 /* for Philips RF front-ends */
977 #define RTW_RXRSSI_RSSI BITS(15,8) /* RF energy at the PHY */
978 /* for RF front-ends by Intersil, Maxim, RFMD */
979 #define RTW_RXRSSI_IMR_RSSI BITS(15,9) /* RF energy at the PHY */
980 #define RTW_RXRSSI_IMR_LNA BIT(8) /* 1: LNA activated */
981 #define RTW_RXRSSI_SQ BITS(7,0) /* Barker code-lock quality */
982
983 #define RTW_READ8(regs, ofs) \
984 bus_space_read_1((regs)->r_bt, (regs)->r_bh, (ofs))
985
986 #define RTW_READ16(regs, ofs) \
987 bus_space_read_2((regs)->r_bt, (regs)->r_bh, (ofs))
988
989 #define RTW_READ(regs, ofs) \
990 bus_space_read_4((regs)->r_bt, (regs)->r_bh, (ofs))
991
992 #define RTW_WRITE8(regs, ofs, val) \
993 bus_space_write_1((regs)->r_bt, (regs)->r_bh, (ofs), (val))
994
995 #define RTW_WRITE16(regs, ofs, val) \
996 bus_space_write_2((regs)->r_bt, (regs)->r_bh, (ofs), (val))
997
998 #define RTW_WRITE(regs, ofs, val) \
999 bus_space_write_4((regs)->r_bt, (regs)->r_bh, (ofs), (val))
1000
1001 #define RTW_ISSET(regs, reg, mask) \
1002 (RTW_READ((regs), (reg)) & (mask))
1003
1004 #define RTW_CLR(regs, reg, mask) \
1005 RTW_WRITE((regs), (reg), RTW_READ((regs), (reg)) & ~(mask))
1006
1007 /* bus_space(9) lied? */
1008 #ifndef BUS_SPACE_BARRIER_SYNC
1009 #define BUS_SPACE_BARRIER_SYNC (BUS_SPACE_BARRIER_READ|BUS_SPACE_BARRIER_WRITE)
1010 #endif
1011
1012 #ifndef BUS_SPACE_BARRIER_READ_BEFORE_READ
1013 #define BUS_SPACE_BARRIER_READ_BEFORE_READ BUS_SPACE_BARRIER_READ
1014 #endif
1015
1016 #ifndef BUS_SPACE_BARRIER_READ_BEFORE_WRITE
1017 #define BUS_SPACE_BARRIER_READ_BEFORE_WRITE BUS_SPACE_BARRIER_READ
1018 #endif
1019
1020 #ifndef BUS_SPACE_BARRIER_WRITE_BEFORE_READ
1021 #define BUS_SPACE_BARRIER_WRITE_BEFORE_READ BUS_SPACE_BARRIER_WRITE
1022 #endif
1023
1024 #ifndef BUS_SPACE_BARRIER_WRITE_BEFORE_WRITE
1025 #define BUS_SPACE_BARRIER_WRITE_BEFORE_WRITE BUS_SPACE_BARRIER_WRITE
1026 #endif
1027
1028 /*
1029 * Bus barrier
1030 *
1031 * Complete outstanding read and/or write ops on [reg0, reg1]
1032 * ([reg1, reg0]) before starting new ops on the same region. See
1033 * acceptable bus_space_barrier(9) for the flag definitions.
1034 */
1035 #define RTW_BARRIER(regs, reg0, reg1, flags) \
1036 bus_space_barrier((regs)->r_bh, (regs)->r_bt, \
1037 MIN(reg0, reg1), MAX(reg0, reg1) - MIN(reg0, reg1) + 4, flags)
1038
1039 /*
1040 * Barrier convenience macros.
1041 */
1042 /* sync */
1043 #define RTW_SYNC(regs, reg0, reg1) \
1044 RTW_BARRIER(regs, reg0, reg1, BUS_SPACE_BARRIER_SYNC)
1045
1046 /* write-before-write */
1047 #define RTW_WBW(regs, reg0, reg1) \
1048 RTW_BARRIER(regs, reg0, reg1, BUS_SPACE_BARRIER_WRITE_BEFORE_WRITE)
1049
1050 /* write-before-read */
1051 #define RTW_WBR(regs, reg0, reg1) \
1052 RTW_BARRIER(regs, reg0, reg1, BUS_SPACE_BARRIER_WRITE_BEFORE_READ)
1053
1054 /* read-before-read */
1055 #define RTW_RBR(regs, reg0, reg1) \
1056 RTW_BARRIER(regs, reg0, reg1, BUS_SPACE_BARRIER_READ_BEFORE_READ)
1057
1058 /* read-before-read */
1059 #define RTW_RBW(regs, reg0, reg1) \
1060 RTW_BARRIER(regs, reg0, reg1, BUS_SPACE_BARRIER_READ_BEFORE_WRITE)
1061
1062 #define RTW_WBRW(regs, reg0, reg1) \
1063 RTW_BARRIER(regs, reg0, reg1, \
1064 BUS_SPACE_BARRIER_WRITE_BEFORE_READ | \
1065 BUS_SPACE_BARRIER_WRITE_BEFORE_WRITE)
1066
1067 /*
1068 * Registers for RTL8180L's built-in baseband modem.
1069 */
1070 #define RTW_BBP_SYS1 0x00
1071 #define RTW_BBP_TXAGC 0x03
1072 #define RTW_BBP_LNADET 0x04
1073 #define RTW_BBP_IFAGCINI 0x05
1074 #define RTW_BBP_IFAGCLIMIT 0x06
1075 #define RTW_BBP_IFAGCDET 0x07
1076
1077 #define RTW_BBP_ANTATTEN 0x10
1078 #define RTW_BBP_ANTATTEN_PHILIPS_MAGIC 0x91
1079 #define RTW_BBP_ANTATTEN_INTERSIL_MAGIC 0x92
1080 #define RTW_BBP_ANTATTEN_RFMD_MAGIC 0x93
1081 #define RTW_BBP_ANTATTEN_MAXIM_MAGIC 0xb3
1082 #define RTW_BBP_ANTATTEN_DFLANTB 0x40
1083 #define RTW_BBP_ANTATTEN_CHAN14 0x0c
1084
1085 #define RTW_BBP_TRL 0x11
1086 #define RTW_BBP_SYS2 0x12
1087 #define RTW_BBP_SYS2_ANTDIV 0x80 /* enable antenna diversity */
1088 #define RTW_BBP_SYS2_RATE_MASK BITS(5,4) /* loopback rate?
1089 * 0: 1Mbps
1090 * 1: 2Mbps
1091 * 2: 5.5Mbps
1092 * 3: 11Mbps
1093 */
1094 #define RTW_BBP_SYS3 0x13
1095 /* carrier-sense threshold */
1096 #define RTW_BBP_SYS3_CSTHRESH_MASK BITS(0,3)
1097 #define RTW_BBP_CHESTLIM 0x19
1098 #define RTW_BBP_CHSQLIM 0x1a
1099
1100