blob: 89e5ed24e4f7906a95ae0feaacc992e022840e34 [file] [log] [blame]
Ivo van Doorn95ea3622007-09-25 17:57:13 -07001/*
Ivo van Doorn811aa9c2008-02-03 15:42:53 +01002 Copyright (C) 2004 - 2008 rt2x00 SourceForge Project
Ivo van Doorn95ea3622007-09-25 17:57:13 -07003 <http://rt2x00.serialmonkey.com>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the
17 Free Software Foundation, Inc.,
18 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 */
20
21/*
22 Module: rt2500usb
23 Abstract: Data structures and registers for the rt2500usb module.
24 Supported chipsets: RT2570.
25 */
26
27#ifndef RT2500USB_H
28#define RT2500USB_H
29
30/*
31 * RF chip defines.
32 */
33#define RF2522 0x0000
34#define RF2523 0x0001
35#define RF2524 0x0002
36#define RF2525 0x0003
37#define RF2525E 0x0005
38#define RF5222 0x0010
39
40/*
41 * RT2570 version
42 */
43#define RT2570_VERSION_B 2
44#define RT2570_VERSION_C 3
45#define RT2570_VERSION_D 4
46
47/*
48 * Signal information.
49 * Defaul offset is required for RSSI <-> dBm conversion.
50 */
Ivo van Doorn95ea3622007-09-25 17:57:13 -070051#define DEFAULT_RSSI_OFFSET 120
52
53/*
54 * Register layout information.
55 */
56#define CSR_REG_BASE 0x0400
57#define CSR_REG_SIZE 0x0100
58#define EEPROM_BASE 0x0000
59#define EEPROM_SIZE 0x006a
60#define BBP_SIZE 0x0060
61#define RF_SIZE 0x0014
62
63/*
Gertjan van Wingerde61448f82008-05-10 13:43:33 +020064 * Number of TX queues.
65 */
66#define NUM_TX_QUEUES 2
67
68/*
Ivo van Doorn95ea3622007-09-25 17:57:13 -070069 * Control/Status Registers(CSR).
70 * Some values are set in TU, whereas 1 TU == 1024 us.
71 */
72
73/*
74 * MAC_CSR0: ASIC revision number.
75 */
76#define MAC_CSR0 0x0400
77
78/*
79 * MAC_CSR1: System control.
80 * SOFT_RESET: Software reset, 1: reset, 0: normal.
81 * BBP_RESET: Hardware reset, 1: reset, 0, release.
82 * HOST_READY: Host ready after initialization.
83 */
84#define MAC_CSR1 0x0402
85#define MAC_CSR1_SOFT_RESET FIELD16(0x00000001)
86#define MAC_CSR1_BBP_RESET FIELD16(0x00000002)
87#define MAC_CSR1_HOST_READY FIELD16(0x00000004)
88
89/*
90 * MAC_CSR2: STA MAC register 0.
91 */
92#define MAC_CSR2 0x0404
93#define MAC_CSR2_BYTE0 FIELD16(0x00ff)
94#define MAC_CSR2_BYTE1 FIELD16(0xff00)
95
96/*
97 * MAC_CSR3: STA MAC register 1.
98 */
99#define MAC_CSR3 0x0406
100#define MAC_CSR3_BYTE2 FIELD16(0x00ff)
101#define MAC_CSR3_BYTE3 FIELD16(0xff00)
102
103/*
104 * MAC_CSR4: STA MAC register 2.
105 */
106#define MAC_CSR4 0X0408
107#define MAC_CSR4_BYTE4 FIELD16(0x00ff)
108#define MAC_CSR4_BYTE5 FIELD16(0xff00)
109
110/*
111 * MAC_CSR5: BSSID register 0.
112 */
113#define MAC_CSR5 0x040a
114#define MAC_CSR5_BYTE0 FIELD16(0x00ff)
115#define MAC_CSR5_BYTE1 FIELD16(0xff00)
116
117/*
118 * MAC_CSR6: BSSID register 1.
119 */
120#define MAC_CSR6 0x040c
121#define MAC_CSR6_BYTE2 FIELD16(0x00ff)
122#define MAC_CSR6_BYTE3 FIELD16(0xff00)
123
124/*
125 * MAC_CSR7: BSSID register 2.
126 */
127#define MAC_CSR7 0x040e
128#define MAC_CSR7_BYTE4 FIELD16(0x00ff)
129#define MAC_CSR7_BYTE5 FIELD16(0xff00)
130
131/*
132 * MAC_CSR8: Max frame length.
133 */
134#define MAC_CSR8 0x0410
135#define MAC_CSR8_MAX_FRAME_UNIT FIELD16(0x0fff)
136
137/*
138 * Misc MAC_CSR registers.
139 * MAC_CSR9: Timer control.
140 * MAC_CSR10: Slot time.
Ivo van Doornf5507ce2008-02-03 15:51:13 +0100141 * MAC_CSR11: SIFS.
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700142 * MAC_CSR12: EIFS.
143 * MAC_CSR13: Power mode0.
144 * MAC_CSR14: Power mode1.
145 * MAC_CSR15: Power saving transition0
146 * MAC_CSR16: Power saving transition1
147 */
148#define MAC_CSR9 0x0412
149#define MAC_CSR10 0x0414
150#define MAC_CSR11 0x0416
151#define MAC_CSR12 0x0418
152#define MAC_CSR13 0x041a
153#define MAC_CSR14 0x041c
154#define MAC_CSR15 0x041e
155#define MAC_CSR16 0x0420
156
157/*
158 * MAC_CSR17: Manual power control / status register.
159 * Allowed state: 0 deep_sleep, 1: sleep, 2: standby, 3: awake.
160 * SET_STATE: Set state. Write 1 to trigger, self cleared.
161 * BBP_DESIRE_STATE: BBP desired state.
162 * RF_DESIRE_STATE: RF desired state.
163 * BBP_CURRENT_STATE: BBP current state.
164 * RF_CURRENT_STATE: RF current state.
165 * PUT_TO_SLEEP: Put to sleep. Write 1 to trigger, self cleared.
166 */
167#define MAC_CSR17 0x0422
168#define MAC_CSR17_SET_STATE FIELD16(0x0001)
169#define MAC_CSR17_BBP_DESIRE_STATE FIELD16(0x0006)
170#define MAC_CSR17_RF_DESIRE_STATE FIELD16(0x0018)
171#define MAC_CSR17_BBP_CURR_STATE FIELD16(0x0060)
172#define MAC_CSR17_RF_CURR_STATE FIELD16(0x0180)
173#define MAC_CSR17_PUT_TO_SLEEP FIELD16(0x0200)
174
175/*
176 * MAC_CSR18: Wakeup timer register.
177 * DELAY_AFTER_BEACON: Delay after Tbcn expired in units of 1/16 TU.
178 * BEACONS_BEFORE_WAKEUP: Number of beacon before wakeup.
179 * AUTO_WAKE: Enable auto wakeup / sleep mechanism.
180 */
181#define MAC_CSR18 0x0424
182#define MAC_CSR18_DELAY_AFTER_BEACON FIELD16(0x00ff)
183#define MAC_CSR18_BEACONS_BEFORE_WAKEUP FIELD16(0x7f00)
184#define MAC_CSR18_AUTO_WAKE FIELD16(0x8000)
185
186/*
187 * MAC_CSR19: GPIO control register.
188 */
189#define MAC_CSR19 0x0426
190
191/*
192 * MAC_CSR20: LED control register.
193 * ACTIVITY: 0: idle, 1: active.
194 * LINK: 0: linkoff, 1: linkup.
195 * ACTIVITY_POLARITY: 0: active low, 1: active high.
196 */
197#define MAC_CSR20 0x0428
198#define MAC_CSR20_ACTIVITY FIELD16(0x0001)
199#define MAC_CSR20_LINK FIELD16(0x0002)
200#define MAC_CSR20_ACTIVITY_POLARITY FIELD16(0x0004)
201
202/*
203 * MAC_CSR21: LED control register.
204 * ON_PERIOD: On period, default 70ms.
205 * OFF_PERIOD: Off period, default 30ms.
206 */
207#define MAC_CSR21 0x042a
208#define MAC_CSR21_ON_PERIOD FIELD16(0x00ff)
209#define MAC_CSR21_OFF_PERIOD FIELD16(0xff00)
210
211/*
Ivo van Doorn84263b02008-07-06 17:09:48 +0200212 * MAC_CSR22: Collision window control register.
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700213 */
214#define MAC_CSR22 0x042c
215
216/*
217 * Transmit related CSRs.
218 * Some values are set in TU, whereas 1 TU == 1024 us.
219 */
220
221/*
222 * TXRX_CSR0: Security control register.
223 */
224#define TXRX_CSR0 0x0440
225#define TXRX_CSR0_ALGORITHM FIELD16(0x0007)
226#define TXRX_CSR0_IV_OFFSET FIELD16(0x01f8)
227#define TXRX_CSR0_KEY_ID FIELD16(0x1e00)
228
229/*
230 * TXRX_CSR1: TX configuration.
231 * ACK_TIMEOUT: ACK Timeout in unit of 1-us.
232 * TSF_OFFSET: TSF offset in MAC header.
233 * AUTO_SEQUENCE: Let ASIC control frame sequence number.
234 */
235#define TXRX_CSR1 0x0442
236#define TXRX_CSR1_ACK_TIMEOUT FIELD16(0x00ff)
237#define TXRX_CSR1_TSF_OFFSET FIELD16(0x7f00)
238#define TXRX_CSR1_AUTO_SEQUENCE FIELD16(0x8000)
239
240/*
241 * TXRX_CSR2: RX control.
242 * DISABLE_RX: Disable rx engine.
243 * DROP_CRC: Drop crc error.
244 * DROP_PHYSICAL: Drop physical error.
245 * DROP_CONTROL: Drop control frame.
246 * DROP_NOT_TO_ME: Drop not to me unicast frame.
247 * DROP_TODS: Drop frame tods bit is true.
248 * DROP_VERSION_ERROR: Drop version error frame.
249 * DROP_MCAST: Drop multicast frames.
250 * DROP_BCAST: Drop broadcast frames.
251 */
252#define TXRX_CSR2 0x0444
253#define TXRX_CSR2_DISABLE_RX FIELD16(0x0001)
254#define TXRX_CSR2_DROP_CRC FIELD16(0x0002)
255#define TXRX_CSR2_DROP_PHYSICAL FIELD16(0x0004)
256#define TXRX_CSR2_DROP_CONTROL FIELD16(0x0008)
257#define TXRX_CSR2_DROP_NOT_TO_ME FIELD16(0x0010)
258#define TXRX_CSR2_DROP_TODS FIELD16(0x0020)
259#define TXRX_CSR2_DROP_VERSION_ERROR FIELD16(0x0040)
260#define TXRX_CSR2_DROP_MULTICAST FIELD16(0x0200)
261#define TXRX_CSR2_DROP_BROADCAST FIELD16(0x0400)
262
263/*
264 * RX BBP ID registers
265 * TXRX_CSR3: CCK RX BBP ID.
266 * TXRX_CSR4: OFDM RX BBP ID.
267 */
268#define TXRX_CSR3 0x0446
269#define TXRX_CSR4 0x0448
270
271/*
272 * TXRX_CSR5: CCK TX BBP ID0.
273 */
274#define TXRX_CSR5 0x044a
275#define TXRX_CSR5_BBP_ID0 FIELD16(0x007f)
276#define TXRX_CSR5_BBP_ID0_VALID FIELD16(0x0080)
277#define TXRX_CSR5_BBP_ID1 FIELD16(0x7f00)
278#define TXRX_CSR5_BBP_ID1_VALID FIELD16(0x8000)
279
280/*
281 * TXRX_CSR6: CCK TX BBP ID1.
282 */
283#define TXRX_CSR6 0x044c
284#define TXRX_CSR6_BBP_ID0 FIELD16(0x007f)
285#define TXRX_CSR6_BBP_ID0_VALID FIELD16(0x0080)
286#define TXRX_CSR6_BBP_ID1 FIELD16(0x7f00)
287#define TXRX_CSR6_BBP_ID1_VALID FIELD16(0x8000)
288
289/*
290 * TXRX_CSR7: OFDM TX BBP ID0.
291 */
292#define TXRX_CSR7 0x044e
293#define TXRX_CSR7_BBP_ID0 FIELD16(0x007f)
294#define TXRX_CSR7_BBP_ID0_VALID FIELD16(0x0080)
295#define TXRX_CSR7_BBP_ID1 FIELD16(0x7f00)
296#define TXRX_CSR7_BBP_ID1_VALID FIELD16(0x8000)
297
298/*
Ivo van Doorn84263b02008-07-06 17:09:48 +0200299 * TXRX_CSR8: OFDM TX BBP ID1.
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700300 */
301#define TXRX_CSR8 0x0450
302#define TXRX_CSR8_BBP_ID0 FIELD16(0x007f)
303#define TXRX_CSR8_BBP_ID0_VALID FIELD16(0x0080)
304#define TXRX_CSR8_BBP_ID1 FIELD16(0x7f00)
305#define TXRX_CSR8_BBP_ID1_VALID FIELD16(0x8000)
306
307/*
308 * TXRX_CSR9: TX ACK time-out.
309 */
310#define TXRX_CSR9 0x0452
311
312/*
313 * TXRX_CSR10: Auto responder control.
314 */
315#define TXRX_CSR10 0x0454
316#define TXRX_CSR10_AUTORESPOND_PREAMBLE FIELD16(0x0004)
317
318/*
319 * TXRX_CSR11: Auto responder basic rate.
320 */
321#define TXRX_CSR11 0x0456
322
323/*
324 * ACK/CTS time registers.
325 */
326#define TXRX_CSR12 0x0458
327#define TXRX_CSR13 0x045a
328#define TXRX_CSR14 0x045c
329#define TXRX_CSR15 0x045e
330#define TXRX_CSR16 0x0460
331#define TXRX_CSR17 0x0462
332
333/*
334 * TXRX_CSR18: Synchronization control register.
335 */
336#define TXRX_CSR18 0x0464
337#define TXRX_CSR18_OFFSET FIELD16(0x000f)
338#define TXRX_CSR18_INTERVAL FIELD16(0xfff0)
339
340/*
341 * TXRX_CSR19: Synchronization control register.
342 * TSF_COUNT: Enable TSF auto counting.
343 * TSF_SYNC: Tsf sync, 0: disable, 1: infra, 2: ad-hoc/master mode.
344 * TBCN: Enable Tbcn with reload value.
345 * BEACON_GEN: Enable beacon generator.
346 */
347#define TXRX_CSR19 0x0466
348#define TXRX_CSR19_TSF_COUNT FIELD16(0x0001)
349#define TXRX_CSR19_TSF_SYNC FIELD16(0x0006)
350#define TXRX_CSR19_TBCN FIELD16(0x0008)
351#define TXRX_CSR19_BEACON_GEN FIELD16(0x0010)
352
353/*
354 * TXRX_CSR20: Tx BEACON offset time control register.
355 * OFFSET: In units of usec.
356 * BCN_EXPECT_WINDOW: Default: 2^CWmin
357 */
358#define TXRX_CSR20 0x0468
359#define TXRX_CSR20_OFFSET FIELD16(0x1fff)
360#define TXRX_CSR20_BCN_EXPECT_WINDOW FIELD16(0xe000)
361
362/*
363 * TXRX_CSR21
364 */
365#define TXRX_CSR21 0x046a
366
367/*
368 * Encryption related CSRs.
369 *
370 */
371
372/*
Ivo van Doorn84263b02008-07-06 17:09:48 +0200373 * SEC_CSR0: Shared key 0, word 0
374 * SEC_CSR1: Shared key 0, word 1
375 * SEC_CSR2: Shared key 0, word 2
376 * SEC_CSR3: Shared key 0, word 3
377 * SEC_CSR4: Shared key 0, word 4
378 * SEC_CSR5: Shared key 0, word 5
379 * SEC_CSR6: Shared key 0, word 6
380 * SEC_CSR7: Shared key 0, word 7
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700381 */
382#define SEC_CSR0 0x0480
383#define SEC_CSR1 0x0482
384#define SEC_CSR2 0x0484
385#define SEC_CSR3 0x0486
386#define SEC_CSR4 0x0488
387#define SEC_CSR5 0x048a
388#define SEC_CSR6 0x048c
389#define SEC_CSR7 0x048e
390
391/*
Ivo van Doorn84263b02008-07-06 17:09:48 +0200392 * SEC_CSR8: Shared key 1, word 0
393 * SEC_CSR9: Shared key 1, word 1
394 * SEC_CSR10: Shared key 1, word 2
395 * SEC_CSR11: Shared key 1, word 3
396 * SEC_CSR12: Shared key 1, word 4
397 * SEC_CSR13: Shared key 1, word 5
398 * SEC_CSR14: Shared key 1, word 6
399 * SEC_CSR15: Shared key 1, word 7
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700400 */
401#define SEC_CSR8 0x0490
402#define SEC_CSR9 0x0492
403#define SEC_CSR10 0x0494
404#define SEC_CSR11 0x0496
405#define SEC_CSR12 0x0498
406#define SEC_CSR13 0x049a
407#define SEC_CSR14 0x049c
408#define SEC_CSR15 0x049e
409
410/*
Ivo van Doorn84263b02008-07-06 17:09:48 +0200411 * SEC_CSR16: Shared key 2, word 0
412 * SEC_CSR17: Shared key 2, word 1
413 * SEC_CSR18: Shared key 2, word 2
414 * SEC_CSR19: Shared key 2, word 3
415 * SEC_CSR20: Shared key 2, word 4
416 * SEC_CSR21: Shared key 2, word 5
417 * SEC_CSR22: Shared key 2, word 6
418 * SEC_CSR23: Shared key 2, word 7
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700419 */
420#define SEC_CSR16 0x04a0
421#define SEC_CSR17 0x04a2
422#define SEC_CSR18 0X04A4
423#define SEC_CSR19 0x04a6
424#define SEC_CSR20 0x04a8
425#define SEC_CSR21 0x04aa
426#define SEC_CSR22 0x04ac
427#define SEC_CSR23 0x04ae
428
429/*
Ivo van Doorn84263b02008-07-06 17:09:48 +0200430 * SEC_CSR24: Shared key 3, word 0
431 * SEC_CSR25: Shared key 3, word 1
432 * SEC_CSR26: Shared key 3, word 2
433 * SEC_CSR27: Shared key 3, word 3
434 * SEC_CSR28: Shared key 3, word 4
435 * SEC_CSR29: Shared key 3, word 5
436 * SEC_CSR30: Shared key 3, word 6
437 * SEC_CSR31: Shared key 3, word 7
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700438 */
439#define SEC_CSR24 0x04b0
440#define SEC_CSR25 0x04b2
441#define SEC_CSR26 0x04b4
442#define SEC_CSR27 0x04b6
443#define SEC_CSR28 0x04b8
444#define SEC_CSR29 0x04ba
445#define SEC_CSR30 0x04bc
446#define SEC_CSR31 0x04be
447
448/*
449 * PHY control registers.
450 */
451
452/*
453 * PHY_CSR0: RF switching timing control.
454 */
455#define PHY_CSR0 0x04c0
456
457/*
458 * PHY_CSR1: TX PA configuration.
459 */
460#define PHY_CSR1 0x04c2
461
462/*
463 * MAC configuration registers.
Ivo van Doornddc827f2007-10-13 16:26:42 +0200464 */
465
466/*
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700467 * PHY_CSR2: TX MAC configuration.
Ivo van Doornddc827f2007-10-13 16:26:42 +0200468 * NOTE: Both register fields are complete dummy,
469 * documentation and legacy drivers are unclear un
470 * what this register means or what fields exists.
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700471 */
472#define PHY_CSR2 0x04c4
Ivo van Doornddc827f2007-10-13 16:26:42 +0200473#define PHY_CSR2_LNA FIELD16(0x0002)
474#define PHY_CSR2_LNA_MODE FIELD16(0x3000)
475
476/*
477 * PHY_CSR3: RX MAC configuration.
478 */
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700479#define PHY_CSR3 0x04c6
480
481/*
482 * PHY_CSR4: Interface configuration.
483 */
484#define PHY_CSR4 0x04c8
485#define PHY_CSR4_LOW_RF_LE FIELD16(0x0001)
486
487/*
488 * BBP pre-TX registers.
489 * PHY_CSR5: BBP pre-TX CCK.
490 */
491#define PHY_CSR5 0x04ca
492#define PHY_CSR5_CCK FIELD16(0x0003)
493#define PHY_CSR5_CCK_FLIP FIELD16(0x0004)
494
495/*
496 * BBP pre-TX registers.
497 * PHY_CSR6: BBP pre-TX OFDM.
498 */
499#define PHY_CSR6 0x04cc
500#define PHY_CSR6_OFDM FIELD16(0x0003)
501#define PHY_CSR6_OFDM_FLIP FIELD16(0x0004)
502
503/*
504 * PHY_CSR7: BBP access register 0.
505 * BBP_DATA: BBP data.
506 * BBP_REG_ID: BBP register ID.
507 * BBP_READ_CONTROL: 0: write, 1: read.
508 */
509#define PHY_CSR7 0x04ce
510#define PHY_CSR7_DATA FIELD16(0x00ff)
511#define PHY_CSR7_REG_ID FIELD16(0x7f00)
512#define PHY_CSR7_READ_CONTROL FIELD16(0x8000)
513
514/*
515 * PHY_CSR8: BBP access register 1.
516 * BBP_BUSY: ASIC is busy execute BBP programming.
517 */
518#define PHY_CSR8 0x04d0
519#define PHY_CSR8_BUSY FIELD16(0x0001)
520
521/*
522 * PHY_CSR9: RF access register.
523 * RF_VALUE: Register value + id to program into rf/if.
524 */
525#define PHY_CSR9 0x04d2
526#define PHY_CSR9_RF_VALUE FIELD16(0xffff)
527
528/*
529 * PHY_CSR10: RF access register.
530 * RF_VALUE: Register value + id to program into rf/if.
531 * RF_NUMBER_OF_BITS: Number of bits used in value (i:20, rfmd:22).
532 * RF_IF_SELECT: Chip to program: 0: rf, 1: if.
533 * RF_PLL_LD: Rf pll_ld status.
534 * RF_BUSY: 1: asic is busy execute rf programming.
535 */
536#define PHY_CSR10 0x04d4
537#define PHY_CSR10_RF_VALUE FIELD16(0x00ff)
538#define PHY_CSR10_RF_NUMBER_OF_BITS FIELD16(0x1f00)
539#define PHY_CSR10_RF_IF_SELECT FIELD16(0x2000)
540#define PHY_CSR10_RF_PLL_LD FIELD16(0x4000)
541#define PHY_CSR10_RF_BUSY FIELD16(0x8000)
542
543/*
544 * STA_CSR0: FCS error count.
545 * FCS_ERROR: FCS error count, cleared when read.
546 */
547#define STA_CSR0 0x04e0
548#define STA_CSR0_FCS_ERROR FIELD16(0xffff)
549
550/*
551 * STA_CSR1: PLCP error count.
552 */
553#define STA_CSR1 0x04e2
554
555/*
556 * STA_CSR2: LONG error count.
557 */
558#define STA_CSR2 0x04e4
559
560/*
561 * STA_CSR3: CCA false alarm.
562 * FALSE_CCA_ERROR: False CCA error count, cleared when read.
563 */
564#define STA_CSR3 0x04e6
565#define STA_CSR3_FALSE_CCA_ERROR FIELD16(0xffff)
566
567/*
568 * STA_CSR4: RX FIFO overflow.
569 */
570#define STA_CSR4 0x04e8
571
572/*
573 * STA_CSR5: Beacon sent counter.
574 */
575#define STA_CSR5 0x04ea
576
577/*
578 * Statistics registers
579 */
580#define STA_CSR6 0x04ec
581#define STA_CSR7 0x04ee
582#define STA_CSR8 0x04f0
583#define STA_CSR9 0x04f2
584#define STA_CSR10 0x04f4
585
586/*
587 * BBP registers.
588 * The wordsize of the BBP is 8 bits.
589 */
590
591/*
592 * R2: TX antenna control
593 */
594#define BBP_R2_TX_ANTENNA FIELD8(0x03)
595#define BBP_R2_TX_IQ_FLIP FIELD8(0x04)
596
597/*
598 * R14: RX antenna control
599 */
600#define BBP_R14_RX_ANTENNA FIELD8(0x03)
601#define BBP_R14_RX_IQ_FLIP FIELD8(0x04)
602
603/*
604 * RF registers.
605 */
606
607/*
608 * RF 1
609 */
610#define RF1_TUNER FIELD32(0x00020000)
611
612/*
613 * RF 3
614 */
615#define RF3_TUNER FIELD32(0x00000100)
616#define RF3_TXPOWER FIELD32(0x00003e00)
617
618/*
619 * EEPROM contents.
620 */
621
622/*
623 * HW MAC address.
624 */
625#define EEPROM_MAC_ADDR_0 0x0002
626#define EEPROM_MAC_ADDR_BYTE0 FIELD16(0x00ff)
627#define EEPROM_MAC_ADDR_BYTE1 FIELD16(0xff00)
628#define EEPROM_MAC_ADDR1 0x0003
629#define EEPROM_MAC_ADDR_BYTE2 FIELD16(0x00ff)
630#define EEPROM_MAC_ADDR_BYTE3 FIELD16(0xff00)
631#define EEPROM_MAC_ADDR_2 0x0004
632#define EEPROM_MAC_ADDR_BYTE4 FIELD16(0x00ff)
633#define EEPROM_MAC_ADDR_BYTE5 FIELD16(0xff00)
634
635/*
636 * EEPROM antenna.
637 * ANTENNA_NUM: Number of antenna's.
638 * TX_DEFAULT: Default antenna 0: diversity, 1: A, 2: B.
639 * RX_DEFAULT: Default antenna 0: diversity, 1: A, 2: B.
640 * LED_MODE: 0: default, 1: TX/RX activity, 2: Single (ignore link), 3: rsvd.
641 * DYN_TXAGC: Dynamic TX AGC control.
642 * HARDWARE_RADIO: 1: Hardware controlled radio. Read GPIO0.
643 * RF_TYPE: Rf_type of this adapter.
644 */
645#define EEPROM_ANTENNA 0x000b
646#define EEPROM_ANTENNA_NUM FIELD16(0x0003)
647#define EEPROM_ANTENNA_TX_DEFAULT FIELD16(0x000c)
648#define EEPROM_ANTENNA_RX_DEFAULT FIELD16(0x0030)
649#define EEPROM_ANTENNA_LED_MODE FIELD16(0x01c0)
650#define EEPROM_ANTENNA_DYN_TXAGC FIELD16(0x0200)
651#define EEPROM_ANTENNA_HARDWARE_RADIO FIELD16(0x0400)
652#define EEPROM_ANTENNA_RF_TYPE FIELD16(0xf800)
653
654/*
655 * EEPROM NIC config.
656 * CARDBUS_ACCEL: 0: enable, 1: disable.
657 * DYN_BBP_TUNE: 0: enable, 1: disable.
658 * CCK_TX_POWER: CCK TX power compensation.
659 */
660#define EEPROM_NIC 0x000c
661#define EEPROM_NIC_CARDBUS_ACCEL FIELD16(0x0001)
662#define EEPROM_NIC_DYN_BBP_TUNE FIELD16(0x0002)
663#define EEPROM_NIC_CCK_TX_POWER FIELD16(0x000c)
664
665/*
666 * EEPROM geography.
667 * GEO: Default geography setting for device.
668 */
669#define EEPROM_GEOGRAPHY 0x000d
670#define EEPROM_GEOGRAPHY_GEO FIELD16(0x0f00)
671
672/*
673 * EEPROM BBP.
674 */
675#define EEPROM_BBP_START 0x000e
676#define EEPROM_BBP_SIZE 16
677#define EEPROM_BBP_VALUE FIELD16(0x00ff)
678#define EEPROM_BBP_REG_ID FIELD16(0xff00)
679
680/*
681 * EEPROM TXPOWER
682 */
683#define EEPROM_TXPOWER_START 0x001e
684#define EEPROM_TXPOWER_SIZE 7
685#define EEPROM_TXPOWER_1 FIELD16(0x00ff)
686#define EEPROM_TXPOWER_2 FIELD16(0xff00)
687
688/*
689 * EEPROM Tuning threshold
690 */
691#define EEPROM_BBPTUNE 0x0030
692#define EEPROM_BBPTUNE_THRESHOLD FIELD16(0x00ff)
693
694/*
695 * EEPROM BBP R24 Tuning.
696 */
697#define EEPROM_BBPTUNE_R24 0x0031
698#define EEPROM_BBPTUNE_R24_LOW FIELD16(0x00ff)
699#define EEPROM_BBPTUNE_R24_HIGH FIELD16(0xff00)
700
701/*
702 * EEPROM BBP R25 Tuning.
703 */
704#define EEPROM_BBPTUNE_R25 0x0032
705#define EEPROM_BBPTUNE_R25_LOW FIELD16(0x00ff)
706#define EEPROM_BBPTUNE_R25_HIGH FIELD16(0xff00)
707
708/*
709 * EEPROM BBP R24 Tuning.
710 */
711#define EEPROM_BBPTUNE_R61 0x0033
712#define EEPROM_BBPTUNE_R61_LOW FIELD16(0x00ff)
713#define EEPROM_BBPTUNE_R61_HIGH FIELD16(0xff00)
714
715/*
716 * EEPROM BBP VGC Tuning.
717 */
718#define EEPROM_BBPTUNE_VGC 0x0034
719#define EEPROM_BBPTUNE_VGCUPPER FIELD16(0x00ff)
Ivo van Doorn6bb40dd2008-02-03 15:49:59 +0100720#define EEPROM_BBPTUNE_VGCLOWER FIELD16(0xff00)
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700721
722/*
723 * EEPROM BBP R17 Tuning.
724 */
725#define EEPROM_BBPTUNE_R17 0x0035
726#define EEPROM_BBPTUNE_R17_LOW FIELD16(0x00ff)
727#define EEPROM_BBPTUNE_R17_HIGH FIELD16(0xff00)
728
729/*
730 * RSSI <-> dBm offset calibration
731 */
732#define EEPROM_CALIBRATE_OFFSET 0x0036
733#define EEPROM_CALIBRATE_OFFSET_RSSI FIELD16(0x00ff)
734
735/*
736 * DMA descriptor defines.
737 */
Ivo van Doorn4bd7c452008-01-24 00:48:03 -0800738#define TXD_DESC_SIZE ( 5 * sizeof(__le32) )
739#define RXD_DESC_SIZE ( 4 * sizeof(__le32) )
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700740
741/*
742 * TX descriptor format for TX, PRIO, ATIM and Beacon Ring.
743 */
744
745/*
746 * Word0
747 */
748#define TXD_W0_PACKET_ID FIELD32(0x0000000f)
749#define TXD_W0_RETRY_LIMIT FIELD32(0x000000f0)
750#define TXD_W0_MORE_FRAG FIELD32(0x00000100)
751#define TXD_W0_ACK FIELD32(0x00000200)
752#define TXD_W0_TIMESTAMP FIELD32(0x00000400)
753#define TXD_W0_OFDM FIELD32(0x00000800)
754#define TXD_W0_NEW_SEQ FIELD32(0x00001000)
755#define TXD_W0_IFS FIELD32(0x00006000)
756#define TXD_W0_DATABYTE_COUNT FIELD32(0x0fff0000)
757#define TXD_W0_CIPHER FIELD32(0x20000000)
758#define TXD_W0_KEY_ID FIELD32(0xc0000000)
759
760/*
761 * Word1
762 */
763#define TXD_W1_IV_OFFSET FIELD32(0x0000003f)
764#define TXD_W1_AIFS FIELD32(0x000000c0)
765#define TXD_W1_CWMIN FIELD32(0x00000f00)
766#define TXD_W1_CWMAX FIELD32(0x0000f000)
767
768/*
769 * Word2: PLCP information
770 */
771#define TXD_W2_PLCP_SIGNAL FIELD32(0x000000ff)
772#define TXD_W2_PLCP_SERVICE FIELD32(0x0000ff00)
773#define TXD_W2_PLCP_LENGTH_LOW FIELD32(0x00ff0000)
774#define TXD_W2_PLCP_LENGTH_HIGH FIELD32(0xff000000)
775
776/*
777 * Word3
778 */
779#define TXD_W3_IV FIELD32(0xffffffff)
780
781/*
782 * Word4
783 */
784#define TXD_W4_EIV FIELD32(0xffffffff)
785
786/*
787 * RX descriptor format for RX Ring.
788 */
789
790/*
791 * Word0
792 */
793#define RXD_W0_UNICAST_TO_ME FIELD32(0x00000002)
794#define RXD_W0_MULTICAST FIELD32(0x00000004)
795#define RXD_W0_BROADCAST FIELD32(0x00000008)
796#define RXD_W0_MY_BSS FIELD32(0x00000010)
797#define RXD_W0_CRC_ERROR FIELD32(0x00000020)
798#define RXD_W0_OFDM FIELD32(0x00000040)
799#define RXD_W0_PHYSICAL_ERROR FIELD32(0x00000080)
800#define RXD_W0_CIPHER FIELD32(0x00000100)
801#define RXD_W0_CIPHER_ERROR FIELD32(0x00000200)
802#define RXD_W0_DATABYTE_COUNT FIELD32(0x0fff0000)
803
804/*
805 * Word1
806 */
807#define RXD_W1_RSSI FIELD32(0x000000ff)
808#define RXD_W1_SIGNAL FIELD32(0x0000ff00)
809
810/*
811 * Word2
812 */
813#define RXD_W2_IV FIELD32(0xffffffff)
814
815/*
816 * Word3
817 */
818#define RXD_W3_EIV FIELD32(0xffffffff)
819
820/*
Ivo van Doornde99ff82008-02-17 17:34:26 +0100821 * Macro's for converting txpower from EEPROM to mac80211 value
822 * and from mac80211 value to register value.
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700823 */
824#define MIN_TXPOWER 0
825#define MAX_TXPOWER 31
826#define DEFAULT_TXPOWER 24
827
Ivo van Doorn8c5e7a52008-08-04 16:38:47 +0200828#define TXPOWER_FROM_DEV(__txpower) \
829 (((u8)(__txpower)) > MAX_TXPOWER) ? DEFAULT_TXPOWER : (__txpower)
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700830
Ivo van Doorn8c5e7a52008-08-04 16:38:47 +0200831#define TXPOWER_TO_DEV(__txpower) \
832 clamp_t(char, __txpower, MIN_TXPOWER, MAX_TXPOWER)
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700833
834#endif /* RT2500USB_H */