]> bbs.cooldavid.org Git - net-next-2.6.git/blob - drivers/staging/rt2860/chip/rtmp_mac.h
Staging: rt28x0: updates from vendor's V2.1.0.0 drivers
[net-next-2.6.git] / drivers / staging / rt2860 / chip / rtmp_mac.h
1 /*
2  *************************************************************************
3  * Ralink Tech Inc.
4  * 5F., No.36, Taiyuan St., Jhubei City,
5  * Hsinchu County 302,
6  * Taiwan, R.O.C.
7  *
8  * (c) Copyright 2002-2007, Ralink Technology, Inc.
9  *
10  * This program is free software; you can redistribute it and/or modify  *
11  * it under the terms of the GNU General Public License as published by  *
12  * the Free Software Foundation; either version 2 of the License, or     *
13  * (at your option) any later version.                                   *
14  *                                                                       *
15  * This program is distributed in the hope that it will be useful,       *
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
18  * GNU General Public License for more details.                          *
19  *                                                                       *
20  * You should have received a copy of the GNU General Public License     *
21  * along with this program; if not, write to the                         *
22  * Free Software Foundation, Inc.,                                       *
23  * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
24  *                                                                       *
25  *************************************************************************
26
27         Module Name:
28         rtmp_mac.h
29
30         Abstract:
31         Ralink Wireless Chip MAC related definition & structures
32
33         Revision History:
34         Who                     When              What
35         --------        ----------        ----------------------------------------------
36 */
37
38 #ifndef __RTMP_MAC_H__
39 #define __RTMP_MAC_H__
40
41
42
43 // =================================================================================
44 // TX / RX ring descriptor format
45 // =================================================================================
46
47 // the first 24-byte in TXD is called TXINFO and will be DMAed to MAC block through TXFIFO.
48 // MAC block use this TXINFO to control the transmission behavior of this frame.
49 #define FIFO_MGMT                 0
50 #define FIFO_HCCA                 1
51 #define FIFO_EDCA                 2
52
53
54 //
55 // TXD Wireless Information format for Tx ring and Mgmt Ring
56 //
57 //txop : for txop mode
58 // 0:txop for the MPDU frame will be handles by ASIC by register
59 // 1/2/3:the MPDU frame is send after PIFS/backoff/SIFS
60 typedef struct  PACKED _TXWI_STRUC {
61         // Word 0
62         // ex: 00 03 00 40 means txop = 3, PHYMODE = 1
63         UINT32          FRAG:1;         // 1 to inform TKIP engine this is a fragment.
64         UINT32          MIMOps:1;       // the remote peer is in dynamic MIMO-PS mode
65         UINT32          CFACK:1;
66         UINT32          TS:1;
67
68         UINT32          AMPDU:1;
69         UINT32          MpduDensity:3;
70         UINT32          txop:2; //FOR "THIS" frame. 0:HT TXOP rule , 1:PIFS TX ,2:Backoff, 3:sifs only when previous frame exchange is successful.
71         UINT32          rsv:6;
72
73         UINT32          MCS:7;
74         UINT32          BW:1;   //channel bandwidth 20MHz or 40 MHz
75         UINT32          ShortGI:1;
76         UINT32          STBC:2; // 1: STBC support MCS =0-7,   2,3 : RESERVE
77         UINT32          Ifs:1;  //
78 //      UINT32          rsv2:2; //channel bandwidth 20MHz or 40 MHz
79         UINT32          rsv2:1;
80         UINT32          TxBF:1; // 3*3
81         UINT32          PHYMODE:2;
82         // Word1
83         // ex:  1c ff 38 00 means ACK=0, BAWinSize=7, MPDUtotalByteCount = 0x38
84         UINT32          ACK:1;
85         UINT32          NSEQ:1;
86         UINT32          BAWinSize:6;
87         UINT32          WirelessCliID:8;
88         UINT32          MPDUtotalByteCount:12;
89         UINT32          PacketId:4;
90         //Word2
91         UINT32          IV;
92         //Word3
93         UINT32          EIV;
94 }       TXWI_STRUC, *PTXWI_STRUC;
95
96
97 //
98 // RXWI wireless information format, in PBF. invisible in driver.
99 //
100 typedef struct  PACKED _RXWI_STRUC {
101         // Word 0
102         UINT32          WirelessCliID:8;
103         UINT32          KeyIndex:2;
104         UINT32          BSSID:3;
105         UINT32          UDF:3;
106         UINT32          MPDUtotalByteCount:12;
107         UINT32          TID:4;
108         // Word 1
109         UINT32          FRAG:4;
110         UINT32          SEQUENCE:12;
111         UINT32          MCS:7;
112         UINT32          BW:1;
113         UINT32          ShortGI:1;
114         UINT32          STBC:2;
115         UINT32          rsv:3;
116         UINT32          PHYMODE:2;              // 1: this RX frame is unicast to me
117         //Word2
118         UINT32          RSSI0:8;
119         UINT32          RSSI1:8;
120         UINT32          RSSI2:8;
121         UINT32          rsv1:8;
122         //Word3
123         UINT32          SNR0:8;
124         UINT32          SNR1:8;
125         UINT32          FOFFSET:8;      // RT35xx
126         UINT32          rsv2:8;
127         /*UINT32                rsv2:16;*/
128 }       RXWI_STRUC, *PRXWI_STRUC;
129
130
131 // =================================================================================
132 // Register format
133 // =================================================================================
134
135
136 //
137 // SCH/DMA registers - base address 0x0200
138 //
139 // INT_SOURCE_CSR: Interrupt source register. Write one to clear corresponding bit
140 //
141 #define DMA_CSR0                0x200
142 #define INT_SOURCE_CSR          0x200
143 typedef union   _INT_SOURCE_CSR_STRUC   {
144         struct  {
145                 UINT32          RxDelayINT:1;
146                 UINT32          TxDelayINT:1;
147                 UINT32          RxDone:1;
148                 UINT32          Ac0DmaDone:1;//4
149                 UINT32          Ac1DmaDone:1;
150                 UINT32          Ac2DmaDone:1;
151                 UINT32          Ac3DmaDone:1;
152                 UINT32          HccaDmaDone:1; // bit7
153                 UINT32          MgmtDmaDone:1;
154                 UINT32          MCUCommandINT:1;//bit 9
155                 UINT32          RxTxCoherent:1;
156                 UINT32          TBTTInt:1;
157                 UINT32          PreTBTT:1;
158                 UINT32          TXFifoStatusInt:1;//FIFO Statistics is full, sw should read 0x171c
159                 UINT32          AutoWakeup:1;//bit14
160                 UINT32          GPTimer:1;
161                 UINT32          RxCoherent:1;//bit16
162                 UINT32          TxCoherent:1;
163                 UINT32          :14;
164         }       field;
165         UINT32                  word;
166 } INT_SOURCE_CSR_STRUC, *PINT_SOURCE_CSR_STRUC;
167
168 //
169 // INT_MASK_CSR:   Interrupt MASK register.   1: the interrupt is mask OFF
170 //
171 #define INT_MASK_CSR        0x204
172 typedef union   _INT_MASK_CSR_STRUC     {
173         struct  {
174                 UINT32          RXDelay_INT_MSK:1;
175                 UINT32          TxDelay:1;
176                 UINT32          RxDone:1;
177                 UINT32          Ac0DmaDone:1;
178                 UINT32          Ac1DmaDone:1;
179                 UINT32          Ac2DmaDone:1;
180                 UINT32          Ac3DmaDone:1;
181                 UINT32          HccaDmaDone:1;
182                 UINT32          MgmtDmaDone:1;
183                 UINT32          MCUCommandINT:1;
184                 UINT32          :20;
185                 UINT32          RxCoherent:1;
186                 UINT32          TxCoherent:1;
187         }       field;
188         UINT32                  word;
189 } INT_MASK_CSR_STRUC, *PINT_MASK_CSR_STRUC;
190
191 #define WPDMA_GLO_CFG   0x208
192 typedef union   _WPDMA_GLO_CFG_STRUC    {
193         struct  {
194                 UINT32          EnableTxDMA:1;
195                 UINT32          TxDMABusy:1;
196                 UINT32          EnableRxDMA:1;
197                 UINT32          RxDMABusy:1;
198                 UINT32          WPDMABurstSIZE:2;
199                 UINT32          EnTXWriteBackDDONE:1;
200                 UINT32          BigEndian:1;
201                 UINT32          RXHdrScater:8;
202                 UINT32          HDR_SEG_LEN:16;
203         }       field;
204         UINT32                  word;
205 } WPDMA_GLO_CFG_STRUC, *PWPDMA_GLO_CFG_STRUC;
206
207 #define WPDMA_RST_IDX   0x20c
208 typedef union   _WPDMA_RST_IDX_STRUC    {
209         struct  {
210                 UINT32          RST_DTX_IDX0:1;
211                 UINT32          RST_DTX_IDX1:1;
212                 UINT32          RST_DTX_IDX2:1;
213                 UINT32          RST_DTX_IDX3:1;
214                 UINT32          RST_DTX_IDX4:1;
215                 UINT32          RST_DTX_IDX5:1;
216                 UINT32          rsv:10;
217                 UINT32          RST_DRX_IDX0:1;
218                 UINT32          :15;
219         }       field;
220         UINT32                  word;
221 } WPDMA_RST_IDX_STRUC, *PWPDMA_RST_IDX_STRUC;
222 #define DELAY_INT_CFG  0x0210
223 typedef union   _DELAY_INT_CFG_STRUC    {
224         struct  {
225                 UINT32          RXMAX_PTIME:8;
226                 UINT32          RXMAX_PINT:7;
227                 UINT32          RXDLY_INT_EN:1;
228                 UINT32          TXMAX_PTIME:8;
229                 UINT32          TXMAX_PINT:7;
230                 UINT32          TXDLY_INT_EN:1;
231         }       field;
232         UINT32                  word;
233 } DELAY_INT_CFG_STRUC, *PDELAY_INT_CFG_STRUC;
234 #define WMM_AIFSN_CFG   0x0214
235 typedef union   _AIFSN_CSR_STRUC        {
236         struct  {
237             UINT32   Aifsn0:4;       // for AC_BE
238             UINT32   Aifsn1:4;       // for AC_BK
239             UINT32   Aifsn2:4;       // for AC_VI
240             UINT32   Aifsn3:4;       // for AC_VO
241             UINT32   Rsv:16;
242         }       field;
243         UINT32                  word;
244 }       AIFSN_CSR_STRUC, *PAIFSN_CSR_STRUC;
245 //
246 // CWMIN_CSR: CWmin for each EDCA AC
247 //
248 #define WMM_CWMIN_CFG   0x0218
249 typedef union   _CWMIN_CSR_STRUC        {
250         struct  {
251             UINT32   Cwmin0:4;       // for AC_BE
252             UINT32   Cwmin1:4;       // for AC_BK
253             UINT32   Cwmin2:4;       // for AC_VI
254             UINT32   Cwmin3:4;       // for AC_VO
255             UINT32   Rsv:16;
256         }       field;
257         UINT32                  word;
258 }       CWMIN_CSR_STRUC, *PCWMIN_CSR_STRUC;
259
260 //
261 // CWMAX_CSR: CWmin for each EDCA AC
262 //
263 #define WMM_CWMAX_CFG   0x021c
264 typedef union   _CWMAX_CSR_STRUC        {
265         struct  {
266             UINT32   Cwmax0:4;       // for AC_BE
267             UINT32   Cwmax1:4;       // for AC_BK
268             UINT32   Cwmax2:4;       // for AC_VI
269             UINT32   Cwmax3:4;       // for AC_VO
270             UINT32   Rsv:16;
271         }       field;
272         UINT32                  word;
273 }       CWMAX_CSR_STRUC, *PCWMAX_CSR_STRUC;
274
275
276 //
277 // AC_TXOP_CSR0: AC_BK/AC_BE TXOP register
278 //
279 #define WMM_TXOP0_CFG    0x0220
280 typedef union   _AC_TXOP_CSR0_STRUC     {
281         struct  {
282             USHORT  Ac0Txop;        // for AC_BK, in unit of 32us
283             USHORT  Ac1Txop;        // for AC_BE, in unit of 32us
284         }       field;
285         UINT32                  word;
286 }       AC_TXOP_CSR0_STRUC, *PAC_TXOP_CSR0_STRUC;
287
288 //
289 // AC_TXOP_CSR1: AC_VO/AC_VI TXOP register
290 //
291 #define WMM_TXOP1_CFG    0x0224
292 typedef union   _AC_TXOP_CSR1_STRUC     {
293         struct  {
294             USHORT  Ac2Txop;        // for AC_VI, in unit of 32us
295             USHORT  Ac3Txop;        // for AC_VO, in unit of 32us
296         }       field;
297         UINT32                  word;
298 }       AC_TXOP_CSR1_STRUC, *PAC_TXOP_CSR1_STRUC;
299
300
301 #define RINGREG_DIFF                    0x10
302 #define GPIO_CTRL_CFG    0x0228 //MAC_CSR13
303 #define MCU_CMD_CFG    0x022c
304 #define TX_BASE_PTR0     0x0230 //AC_BK base address
305 #define TX_MAX_CNT0      0x0234
306 #define TX_CTX_IDX0       0x0238
307 #define TX_DTX_IDX0      0x023c
308 #define TX_BASE_PTR1     0x0240         //AC_BE base address
309 #define TX_MAX_CNT1      0x0244
310 #define TX_CTX_IDX1       0x0248
311 #define TX_DTX_IDX1      0x024c
312 #define TX_BASE_PTR2     0x0250         //AC_VI base address
313 #define TX_MAX_CNT2      0x0254
314 #define TX_CTX_IDX2       0x0258
315 #define TX_DTX_IDX2      0x025c
316 #define TX_BASE_PTR3     0x0260         //AC_VO base address
317 #define TX_MAX_CNT3      0x0264
318 #define TX_CTX_IDX3       0x0268
319 #define TX_DTX_IDX3      0x026c
320 #define TX_BASE_PTR4     0x0270         //HCCA base address
321 #define TX_MAX_CNT4      0x0274
322 #define TX_CTX_IDX4       0x0278
323 #define TX_DTX_IDX4      0x027c
324 #define TX_BASE_PTR5     0x0280         //MGMT base address
325 #define  TX_MAX_CNT5     0x0284
326 #define TX_CTX_IDX5       0x0288
327 #define TX_DTX_IDX5      0x028c
328 #define TX_MGMTMAX_CNT      TX_MAX_CNT5
329 #define TX_MGMTCTX_IDX       TX_CTX_IDX5
330 #define TX_MGMTDTX_IDX      TX_DTX_IDX5
331 #define RX_BASE_PTR     0x0290  //RX base address
332 #define RX_MAX_CNT      0x0294
333 #define RX_CRX_IDX       0x0298
334 #define RX_DRX_IDX      0x029c
335
336
337 #define USB_DMA_CFG      0x02a0
338 typedef union   _USB_DMA_CFG_STRUC      {
339         struct  {
340             UINT32  RxBulkAggTOut:8;        //Rx Bulk Aggregation TimeOut  in unit of 33ns
341             UINT32  RxBulkAggLmt:8;        //Rx Bulk Aggregation Limit  in unit of 256 bytes
342             UINT32  phyclear:1;                 //phy watch dog enable. write 1
343             UINT32  rsv:2;
344             UINT32  TxClear:1;        //Clear USB DMA TX path
345             UINT32  TxopHalt:1;        //Halt TXOP count down when TX buffer is full.
346             UINT32  RxBulkAggEn:1;        //Enable Rx Bulk Aggregation
347             UINT32  RxBulkEn:1;        //Enable USB DMA Rx
348             UINT32  TxBulkEn:1;        //Enable USB DMA Tx
349             UINT32  EpoutValid:6;        //OUT endpoint data valid
350             UINT32  RxBusy:1;        //USB DMA RX FSM busy
351             UINT32  TxBusy:1;           //USB DMA TX FSM busy
352         }       field;
353         UINT32                  word;
354 }       USB_DMA_CFG_STRUC, *PUSB_DMA_CFG_STRUC;
355
356
357 //
358 //  3  PBF  registers
359 //
360 //
361 // Most are for debug. Driver doesn't touch PBF register.
362 #define PBF_SYS_CTRL     0x0400
363 #define PBF_CFG                 0x0408
364 #define PBF_MAX_PCNT     0x040C
365 #define PBF_CTRL                0x0410
366 #define PBF_INT_STA      0x0414
367 #define PBF_INT_ENA      0x0418
368 #define TXRXQ_PCNT       0x0438
369 #define PBF_DBG                  0x043c
370 #define PBF_CAP_CTRL     0x0440
371
372 #ifdef RT30xx
373 #ifdef RTMP_EFUSE_SUPPORT
374 // eFuse registers
375 #define EFUSE_CTRL                              0x0580
376 #define EFUSE_DATA0                             0x0590
377 #define EFUSE_DATA1                             0x0594
378 #define EFUSE_DATA2                             0x0598
379 #define EFUSE_DATA3                             0x059c
380 #endif // RTMP_EFUSE_SUPPORT //
381 #endif // RT30xx //
382
383 #define OSC_CTRL                0x5a4
384 #define PCIE_PHY_TX_ATTENUATION_CTRL    0x05C8
385 #define LDO_CFG0                                0x05d4
386 #define GPIO_SWITCH                             0x05dc
387
388
389 //
390 //  4  MAC  registers
391 //
392 //
393 //  4.1 MAC SYSTEM  configuration registers (offset:0x1000)
394 //
395 #define MAC_CSR0            0x1000
396 typedef union   _ASIC_VER_ID_STRUC      {
397         struct  {
398             USHORT  ASICRev;        // reversion  : 0
399             USHORT  ASICVer;        // version : 2860
400         }       field;
401         UINT32                  word;
402 }       ASIC_VER_ID_STRUC, *PASIC_VER_ID_STRUC;
403 #define MAC_SYS_CTRL            0x1004          //MAC_CSR1
404 #define MAC_ADDR_DW0                            0x1008          // MAC ADDR DW0
405 #define MAC_ADDR_DW1                     0x100c         // MAC ADDR DW1
406 //
407 // MAC_CSR2: STA MAC register 0
408 //
409 typedef union   _MAC_DW0_STRUC  {
410         struct  {
411                 UCHAR           Byte0;          // MAC address byte 0
412                 UCHAR           Byte1;          // MAC address byte 1
413                 UCHAR           Byte2;          // MAC address byte 2
414                 UCHAR           Byte3;          // MAC address byte 3
415         }       field;
416         UINT32                  word;
417 }       MAC_DW0_STRUC, *PMAC_DW0_STRUC;
418
419 //
420 // MAC_CSR3: STA MAC register 1
421 //
422 typedef union   _MAC_DW1_STRUC  {
423         struct  {
424                 UCHAR           Byte4;          // MAC address byte 4
425                 UCHAR           Byte5;          // MAC address byte 5
426                 UCHAR           U2MeMask;
427                 UCHAR           Rsvd1;
428         }       field;
429         UINT32                  word;
430 }       MAC_DW1_STRUC, *PMAC_DW1_STRUC;
431
432 #define MAC_BSSID_DW0                           0x1010          // MAC BSSID DW0
433 #define MAC_BSSID_DW1                           0x1014          // MAC BSSID DW1
434
435 //
436 // MAC_CSR5: BSSID register 1
437 //
438 typedef union   _MAC_CSR5_STRUC {
439         struct  {
440                 UCHAR           Byte4;           // BSSID byte 4
441                 UCHAR           Byte5;           // BSSID byte 5
442                 USHORT          BssIdMask:2; // 0: one BSSID, 10: 4 BSSID,  01: 2 BSSID , 11: 8BSSID
443                 USHORT          MBssBcnNum:3;
444                 USHORT          Rsvd:11;
445         }       field;
446         UINT32                  word;
447 }       MAC_CSR5_STRUC, *PMAC_CSR5_STRUC;
448
449 #define MAX_LEN_CFG              0x1018         // rt2860b max 16k bytes. bit12:13 Maximum PSDU length (power factor) 0:2^13, 1:2^14, 2:2^15, 3:2^16
450 #define BBP_CSR_CFG                     0x101c          //
451 //
452 // BBP_CSR_CFG: BBP serial control register
453 //
454 typedef union   _BBP_CSR_CFG_STRUC      {
455         struct  {
456                 UINT32          Value:8;                        // Register     value to program into BBP
457                 UINT32          RegNum:8;                       // Selected     BBP     register
458                 UINT32          fRead:1;                    // 0: Write BBP, 1: Read BBP
459                 UINT32          Busy:1;                         // 1: ASIC is busy execute BBP programming.
460                 UINT32          BBP_PAR_DUR:1;               // 0: 4 MAC clock cycles  1: 8 MAC clock cycles
461                 UINT32          BBP_RW_MODE:1;          // 0: use serial mode  1:parallel
462                 UINT32          :12;
463         }       field;
464         UINT32                  word;
465 }       BBP_CSR_CFG_STRUC, *PBBP_CSR_CFG_STRUC;
466 #define RF_CSR_CFG0                     0x1020
467 //
468 // RF_CSR_CFG: RF control register
469 //
470 typedef union   _RF_CSR_CFG0_STRUC      {
471         struct  {
472                 UINT32          RegIdAndContent:24;                     // Register     value to program into BBP
473                 UINT32          bitwidth:5;                     // Selected     BBP     register
474                 UINT32          StandbyMode:1;              // 0: high when stand by 1: low when standby
475                 UINT32          Sel:1;                          // 0:RF_LE0 activate  1:RF_LE1 activate
476                 UINT32          Busy:1;             // 0: idle 1: 8busy
477         }       field;
478         UINT32                  word;
479 }       RF_CSR_CFG0_STRUC, *PRF_CSR_CFG0_STRUC;
480 #define RF_CSR_CFG1                     0x1024
481 typedef union   _RF_CSR_CFG1_STRUC      {
482         struct  {
483                 UINT32          RegIdAndContent:24;                     // Register     value to program into BBP
484                 UINT32          RFGap:5;                        // Gap between BB_CONTROL_RF and RF_LE. 0: 3 system clock cycle (37.5usec) 1: 5 system clock cycle (62.5usec)
485                 UINT32          rsv:7;              // 0: idle 1: 8busy
486         }       field;
487         UINT32                  word;
488 }       RF_CSR_CFG1_STRUC, *PRF_CSR_CFG1_STRUC;
489 #define RF_CSR_CFG2                     0x1028          //
490 typedef union   _RF_CSR_CFG2_STRUC      {
491         struct  {
492                 UINT32          RegIdAndContent:24;                     // Register     value to program into BBP
493                 UINT32          rsv:8;              // 0: idle 1: 8busy
494         }       field;
495         UINT32                  word;
496 }       RF_CSR_CFG2_STRUC, *PRF_CSR_CFG2_STRUC;
497 #define LED_CFG                         0x102c          //  MAC_CSR14
498 typedef union   _LED_CFG_STRUC  {
499         struct  {
500                 UINT32          OnPeriod:8;                     // blinking on period unit 1ms
501                 UINT32          OffPeriod:8;                    // blinking off period unit 1ms
502                 UINT32          SlowBlinkPeriod:6;                      // slow blinking period. unit:1ms
503                 UINT32          rsv:2;
504                 UINT32          RLedMode:2;                     // red Led Mode    0: off1: blinking upon TX2: periodic slow blinking3: always on
505                 UINT32          GLedMode:2;                     // green Led Mode
506                 UINT32          YLedMode:2;                     // yellow Led Mode
507                 UINT32          LedPolar:1;                     // Led Polarity.  0: active low1: active high
508                 UINT32          :1;
509         }       field;
510         UINT32                  word;
511 }       LED_CFG_STRUC, *PLED_CFG_STRUC;
512 //
513 //  4.2 MAC TIMING  configuration registers (offset:0x1100)
514 //
515 #define XIFS_TIME_CFG             0x1100                 // MAC_CSR8  MAC_CSR9
516 typedef union   _IFS_SLOT_CFG_STRUC     {
517         struct  {
518             UINT32  CckmSifsTime:8;        //  unit 1us. Applied after CCK RX/TX
519             UINT32  OfdmSifsTime:8;        //  unit 1us. Applied after OFDM RX/TX
520             UINT32  OfdmXifsTime:4;        //OFDM SIFS. unit 1us. Applied after OFDM RX when MAC doesn't reference BBP signal BBRXEND
521             UINT32  EIFS:9;        //  unit 1us
522             UINT32  BBRxendEnable:1;        //  reference RXEND signal to begin XIFS defer
523             UINT32  rsv:2;
524         }       field;
525         UINT32                  word;
526 }       IFS_SLOT_CFG_STRUC, *PIFS_SLOT_CFG_STRUC;
527
528 #define BKOFF_SLOT_CFG             0x1104                //  mac_csr9 last 8 bits
529 #define NAV_TIME_CFG             0x1108          // NAV  (MAC_CSR15)
530 #define CH_TIME_CFG             0x110C                  // Count as channel busy
531 #define PBF_LIFE_TIMER             0x1110                //TX/RX MPDU timestamp timer (free run)Unit: 1us
532 #define BCN_TIME_CFG             0x1114          // TXRX_CSR9
533
534 #define BCN_OFFSET0                             0x042C
535 #define BCN_OFFSET1                             0x0430
536
537 //
538 // BCN_TIME_CFG : Synchronization control register
539 //
540 typedef union   _BCN_TIME_CFG_STRUC     {
541         struct  {
542                 UINT32       BeaconInterval:16;  // in unit of 1/16 TU
543                 UINT32          bTsfTicking:1;          // Enable TSF auto counting
544                 UINT32          TsfSyncMode:2;          // Enable TSF sync, 00: disable, 01: infra mode, 10: ad-hoc mode
545         UINT32       bTBTTEnable:1;
546                 UINT32          bBeaconGen:1;           // Enable beacon generator
547         UINT32       :3;
548                 UINT32          TxTimestampCompensate:8;
549         }       field;
550         UINT32                  word;
551 }       BCN_TIME_CFG_STRUC, *PBCN_TIME_CFG_STRUC;
552 #define TBTT_SYNC_CFG            0x1118                 // txrx_csr10
553 #define TSF_TIMER_DW0             0x111C                // Local TSF timer lsb 32 bits. Read-only
554 #define TSF_TIMER_DW1             0x1120                // msb 32 bits. Read-only.
555 #define TBTT_TIMER              0x1124                  // TImer remains till next TBTT. Read-only.  TXRX_CSR14
556 #define INT_TIMER_CFG                   0x1128                  //
557 #define INT_TIMER_EN                    0x112c                  //  GP-timer and pre-tbtt Int enable
558 #define CH_IDLE_STA                     0x1130                  //  channel idle time
559 #define CH_BUSY_STA                     0x1134                  //  channle busy time
560 //
561 //  4.2 MAC POWER  configuration registers (offset:0x1200)
562 //
563 #define MAC_STATUS_CFG             0x1200                // old MAC_CSR12
564 #define PWR_PIN_CFG             0x1204           // old MAC_CSR12
565 #define AUTO_WAKEUP_CFG             0x1208               // old MAC_CSR10
566 //
567 // AUTO_WAKEUP_CFG: Manual power control / status register
568 //
569 typedef union   _AUTO_WAKEUP_STRUC      {
570         struct  {
571                 UINT32       AutoLeadTime:8;
572                 UINT32       NumofSleepingTbtt:7;          // ForceWake has high privilege than PutToSleep when both set
573                 UINT32          EnableAutoWakeup:1;     // 0:sleep, 1:awake
574                 UINT32          :16;
575         }       field;
576         UINT32                  word;
577 }       AUTO_WAKEUP_STRUC, *PAUTO_WAKEUP_STRUC;
578 //
579 //  4.3 MAC TX  configuration registers (offset:0x1300)
580 //
581
582 #define EDCA_AC0_CFG    0x1300          //AC_TXOP_CSR0 0x3474
583 #define EDCA_AC1_CFG    0x1304
584 #define EDCA_AC2_CFG    0x1308
585 #define EDCA_AC3_CFG    0x130c
586 typedef union   _EDCA_AC_CFG_STRUC      {
587         struct  {
588             UINT32  AcTxop:8;        //  in unit of 32us
589             UINT32  Aifsn:4;        // # of slot time
590             UINT32  Cwmin:4;        //
591             UINT32  Cwmax:4;        //unit power of 2
592             UINT32  :12;       //
593         }       field;
594         UINT32                  word;
595 }       EDCA_AC_CFG_STRUC, *PEDCA_AC_CFG_STRUC;
596
597 #define EDCA_TID_AC_MAP 0x1310
598 #define TX_PWR_CFG_0    0x1314
599 #define TX_PWR_CFG_1    0x1318
600 #define TX_PWR_CFG_2    0x131C
601 #define TX_PWR_CFG_3    0x1320
602 #define TX_PWR_CFG_4    0x1324
603 #define TX_PIN_CFG              0x1328
604 #define TX_BAND_CFG     0x132c          // 0x1 use upper 20MHz. 0 juse lower 20MHz
605 #define TX_SW_CFG0              0x1330
606 #define TX_SW_CFG1              0x1334
607 #define TX_SW_CFG2              0x1338
608 #define TXOP_THRES_CFG          0x133c
609 #define TXOP_CTRL_CFG           0x1340
610 #define TX_RTS_CFG              0x1344
611
612 typedef union   _TX_RTS_CFG_STRUC       {
613         struct  {
614             UINT32       AutoRtsRetryLimit:8;
615             UINT32       RtsThres:16;    // unit:byte
616             UINT32       RtsFbkEn:1;    // enable rts rate fallback
617             UINT32       rsv:7;     // 1: HT non-STBC control frame enable
618         }       field;
619         UINT32                  word;
620 }       TX_RTS_CFG_STRUC, *PTX_RTS_CFG_STRUC;
621 #define TX_TIMEOUT_CFG  0x1348
622 typedef union   _TX_TIMEOUT_CFG_STRUC   {
623         struct  {
624             UINT32       rsv:4;
625             UINT32       MpduLifeTime:4;    //  expiration time = 2^(9+MPDU LIFE TIME)  us
626             UINT32       RxAckTimeout:8;        // unit:slot. Used for TX precedure
627             UINT32       TxopTimeout:8; //TXOP timeout value for TXOP truncation.  It is recommended that (SLOT_TIME) > (TX_OP_TIMEOUT) > (RX_ACK_TIMEOUT)
628             UINT32       rsv2:8;     // 1: HT non-STBC control frame enable
629         }       field;
630         UINT32                  word;
631 }       TX_TIMEOUT_CFG_STRUC, *PTX_TIMEOUT_CFG_STRUC;
632 #define TX_RTY_CFG      0x134c
633 typedef union PACKED _TX_RTY_CFG_STRUC  {
634         struct  {
635             UINT32       ShortRtyLimit:8;       //  short retry limit
636             UINT32       LongRtyLimit:8;        //long retry limit
637             UINT32       LongRtyThre:12;        // Long retry threshoold
638             UINT32       NonAggRtyMode:1;       // Non-Aggregate MPDU retry mode.  0:expired by retry limit, 1: expired by mpdu life timer
639             UINT32       AggRtyMode:1;  // Aggregate MPDU retry mode.  0:expired by retry limit, 1: expired by mpdu life timer
640             UINT32       TxautoFBEnable:1;    // Tx retry PHY rate auto fallback enable
641             UINT32       rsv:1;     // 1: HT non-STBC control frame enable
642         }       field;
643         UINT32                  word;
644 }       TX_RTY_CFG_STRUC, *PTX_RTY_CFG_STRUC;
645 #define TX_LINK_CFG     0x1350
646 typedef union   PACKED _TX_LINK_CFG_STRUC       {
647         struct PACKED {
648             UINT32       RemoteMFBLifeTime:8;   //remote MFB life time. unit : 32us
649             UINT32       MFBEnable:1;   //  TX apply remote MFB 1:enable
650             UINT32       RemoteUMFSEnable:1;    //  remote unsolicit  MFB enable.  0: not apply remote remote unsolicit (MFS=7)
651             UINT32       TxMRQEn:1;     //  MCS request TX enable
652             UINT32       TxRDGEn:1;     // RDG TX enable
653             UINT32       TxCFAckEn:1;   //   Piggyback CF-ACK enable
654             UINT32       rsv:3; //
655             UINT32       RemotMFB:8;    //  remote MCS feedback
656             UINT32       RemotMFS:8;    //remote MCS feedback sequence number
657         }       field;
658         UINT32                  word;
659 }       TX_LINK_CFG_STRUC, *PTX_LINK_CFG_STRUC;
660 #define HT_FBK_CFG0     0x1354
661 typedef union PACKED _HT_FBK_CFG0_STRUC {
662         struct  {
663             UINT32       HTMCS0FBK:4;
664             UINT32       HTMCS1FBK:4;
665             UINT32       HTMCS2FBK:4;
666             UINT32       HTMCS3FBK:4;
667             UINT32       HTMCS4FBK:4;
668             UINT32       HTMCS5FBK:4;
669             UINT32       HTMCS6FBK:4;
670             UINT32       HTMCS7FBK:4;
671         }       field;
672         UINT32                  word;
673 }       HT_FBK_CFG0_STRUC, *PHT_FBK_CFG0_STRUC;
674 #define HT_FBK_CFG1     0x1358
675 typedef union   _HT_FBK_CFG1_STRUC      {
676         struct  {
677             UINT32       HTMCS8FBK:4;
678             UINT32       HTMCS9FBK:4;
679             UINT32       HTMCS10FBK:4;
680             UINT32       HTMCS11FBK:4;
681             UINT32       HTMCS12FBK:4;
682             UINT32       HTMCS13FBK:4;
683             UINT32       HTMCS14FBK:4;
684             UINT32       HTMCS15FBK:4;
685         }       field;
686         UINT32                  word;
687 }       HT_FBK_CFG1_STRUC, *PHT_FBK_CFG1_STRUC;
688 #define LG_FBK_CFG0     0x135c
689 typedef union   _LG_FBK_CFG0_STRUC      {
690         struct  {
691             UINT32       OFDMMCS0FBK:4; //initial value is 0
692             UINT32       OFDMMCS1FBK:4; //initial value is 0
693             UINT32       OFDMMCS2FBK:4; //initial value is 1
694             UINT32       OFDMMCS3FBK:4; //initial value is 2
695             UINT32       OFDMMCS4FBK:4; //initial value is 3
696             UINT32       OFDMMCS5FBK:4; //initial value is 4
697             UINT32       OFDMMCS6FBK:4; //initial value is 5
698             UINT32       OFDMMCS7FBK:4; //initial value is 6
699         }       field;
700         UINT32                  word;
701 }       LG_FBK_CFG0_STRUC, *PLG_FBK_CFG0_STRUC;
702 #define LG_FBK_CFG1             0x1360
703 typedef union   _LG_FBK_CFG1_STRUC      {
704         struct  {
705             UINT32       CCKMCS0FBK:4;  //initial value is 0
706             UINT32       CCKMCS1FBK:4;  //initial value is 0
707             UINT32       CCKMCS2FBK:4;  //initial value is 1
708             UINT32       CCKMCS3FBK:4;  //initial value is 2
709             UINT32       rsv:16;
710         }       field;
711         UINT32                  word;
712 }       LG_FBK_CFG1_STRUC, *PLG_FBK_CFG1_STRUC;
713
714
715 //=======================================================
716 //================ Protection Paramater================================
717 //=======================================================
718 #define CCK_PROT_CFG    0x1364          //CCK Protection
719 #define ASIC_SHORTNAV           1
720 #define ASIC_LONGNAV            2
721 #define ASIC_RTS                1
722 #define ASIC_CTS                2
723 typedef union   _PROT_CFG_STRUC {
724         struct  {
725             UINT32       ProtectRate:16;        //Protection control frame rate for CCK TX(RTS/CTS/CFEnd).
726             UINT32       ProtectCtrl:2; //Protection control frame type for CCK TX. 1:RTS/CTS, 2:CTS-to-self, 0:None, 3:rsv
727             UINT32       ProtectNav:2;  //TXOP protection type for CCK TX. 0:None, 1:ShortNAVprotect,  2:LongNAVProtect, 3:rsv
728             UINT32       TxopAllowCck:1;        //CCK TXOP allowance.0:disallow.
729             UINT32       TxopAllowOfdm:1;       //CCK TXOP allowance.0:disallow.
730             UINT32       TxopAllowMM20:1;       //CCK TXOP allowance. 0:disallow.
731             UINT32       TxopAllowMM40:1;       //CCK TXOP allowance.0:disallow.
732             UINT32       TxopAllowGF20:1;       //CCK TXOP allowance.0:disallow.
733             UINT32       TxopAllowGF40:1;       //CCK TXOP allowance.0:disallow.
734             UINT32       RTSThEn:1;     //RTS threshold enable on CCK TX
735             UINT32       rsv:5;
736         }       field;
737         UINT32                  word;
738 }       PROT_CFG_STRUC, *PPROT_CFG_STRUC;
739
740 #define OFDM_PROT_CFG   0x1368          //OFDM Protection
741 #define MM20_PROT_CFG   0x136C          //MM20 Protection
742 #define MM40_PROT_CFG   0x1370          //MM40 Protection
743 #define GF20_PROT_CFG   0x1374          //GF20 Protection
744 #define GF40_PROT_CFG   0x1378          //GR40 Protection
745 #define EXP_CTS_TIME    0x137C          //
746 #define EXP_ACK_TIME    0x1380          //
747
748 //
749 //  4.4 MAC RX configuration registers (offset:0x1400)
750 //
751 #define RX_FILTR_CFG    0x1400                  //TXRX_CSR0
752 #define AUTO_RSP_CFG    0x1404                  //TXRX_CSR4
753 //
754 // TXRX_CSR4: Auto-Responder/
755 //
756 typedef union _AUTO_RSP_CFG_STRUC {
757  struct {
758      UINT32       AutoResponderEnable:1;
759      UINT32       BACAckPolicyEnable:1;    // 0:long, 1:short preamble
760      UINT32       CTS40MMode:1;  // Response CTS 40MHz duplicate mode
761      UINT32       CTS40MRef:1;  // Response CTS 40MHz duplicate mode
762      UINT32       AutoResponderPreamble:1;    // 0:long, 1:short preamble
763      UINT32       rsv:1;   // Power bit value in conrtrol frame
764      UINT32       DualCTSEn:1;   // Power bit value in conrtrol frame
765      UINT32       AckCtsPsmBit:1;   // Power bit value in conrtrol frame
766      UINT32        :24;
767  } field;
768  UINT32   word;
769 } AUTO_RSP_CFG_STRUC, *PAUTO_RSP_CFG_STRUC;
770
771 #define LEGACY_BASIC_RATE       0x1408  //  TXRX_CSR5           0x3054
772 #define HT_BASIC_RATE           0x140c
773 #define HT_CTRL_CFG             0x1410
774 #define SIFS_COST_CFG           0x1414
775 #define RX_PARSER_CFG           0x1418  //Set NAV for all received frames
776
777 //
778 //  4.5 MAC Security configuration (offset:0x1500)
779 //
780 #define TX_SEC_CNT0             0x1500          //
781 #define RX_SEC_CNT0             0x1504          //
782 #define CCMP_FC_MUTE            0x1508          //
783 //
784 //  4.6 HCCA/PSMP (offset:0x1600)
785 //
786 #define TXOP_HLDR_ADDR0         0x1600
787 #define TXOP_HLDR_ADDR1         0x1604
788 #define TXOP_HLDR_ET            0x1608
789 #define QOS_CFPOLL_RA_DW0               0x160c
790 #define QOS_CFPOLL_A1_DW1               0x1610
791 #define QOS_CFPOLL_QC           0x1614
792 //
793 //  4.7 MAC Statistis registers (offset:0x1700)
794 //
795 #define RX_STA_CNT0             0x1700          //
796 #define RX_STA_CNT1             0x1704          //
797 #define RX_STA_CNT2             0x1708          //
798
799 //
800 // RX_STA_CNT0_STRUC: RX PLCP error count & RX CRC error count
801 //
802 typedef union   _RX_STA_CNT0_STRUC      {
803         struct  {
804             USHORT  CrcErr;
805             USHORT  PhyErr;
806         }       field;
807         UINT32                  word;
808 }       RX_STA_CNT0_STRUC, *PRX_STA_CNT0_STRUC;
809
810 //
811 // RX_STA_CNT1_STRUC: RX False CCA count & RX LONG frame count
812 //
813 typedef union   _RX_STA_CNT1_STRUC      {
814         struct  {
815             USHORT  FalseCca;
816             USHORT  PlcpErr;
817         }       field;
818         UINT32                  word;
819 }       RX_STA_CNT1_STRUC, *PRX_STA_CNT1_STRUC;
820
821 //
822 // RX_STA_CNT2_STRUC:
823 //
824 typedef union   _RX_STA_CNT2_STRUC      {
825         struct  {
826             USHORT  RxDupliCount;
827             USHORT  RxFifoOverflowCount;
828         }       field;
829         UINT32                  word;
830 }       RX_STA_CNT2_STRUC, *PRX_STA_CNT2_STRUC;
831 #define TX_STA_CNT0             0x170C          //
832 //
833 // STA_CSR3: TX Beacon count
834 //
835 typedef union   _TX_STA_CNT0_STRUC      {
836         struct  {
837             USHORT  TxFailCount;
838             USHORT  TxBeaconCount;
839         }       field;
840         UINT32                  word;
841 }       TX_STA_CNT0_STRUC, *PTX_STA_CNT0_STRUC;
842 #define TX_STA_CNT1             0x1710          //
843 //
844 // TX_STA_CNT1: TX tx count
845 //
846 typedef union   _TX_STA_CNT1_STRUC      {
847         struct  {
848             USHORT  TxSuccess;
849             USHORT  TxRetransmit;
850         }       field;
851         UINT32                  word;
852 }       TX_STA_CNT1_STRUC, *PTX_STA_CNT1_STRUC;
853 #define TX_STA_CNT2             0x1714          //
854 //
855 // TX_STA_CNT2: TX tx count
856 //
857 typedef union   _TX_STA_CNT2_STRUC      {
858         struct  {
859             USHORT  TxZeroLenCount;
860             USHORT  TxUnderFlowCount;
861         }       field;
862         UINT32                  word;
863 }       TX_STA_CNT2_STRUC, *PTX_STA_CNT2_STRUC;
864 #define TX_STA_FIFO             0x1718          //
865 //
866 // TX_STA_FIFO_STRUC: TX Result for specific PID status fifo register
867 //
868 typedef union PACKED _TX_STA_FIFO_STRUC {
869         struct  {
870                 UINT32          bValid:1;   // 1:This register contains a valid TX result
871                 UINT32          PidType:4;
872                 UINT32          TxSuccess:1;   // Tx No retry success
873                 UINT32          TxAggre:1;    // Tx Retry Success
874                 UINT32          TxAckRequired:1;    // Tx fail
875                 UINT32          wcid:8;         //wireless client index
876 //              UINT32          SuccessRate:16; //include MCS, mode ,shortGI, BW settingSame format as TXWI Word 0 Bit 31-16.
877                 UINT32          SuccessRate:13; //include MCS, mode ,shortGI, BW settingSame format as TXWI Word 0 Bit 31-16.
878                 UINT32          TxBF:1;
879                 UINT32          Reserve:2;
880         }       field;
881         UINT32                  word;
882 }       TX_STA_FIFO_STRUC, *PTX_STA_FIFO_STRUC;
883 // Debug counter
884 #define TX_AGG_CNT      0x171c
885 typedef union   _TX_AGG_CNT_STRUC       {
886         struct  {
887             USHORT  NonAggTxCount;
888             USHORT  AggTxCount;
889         }       field;
890         UINT32                  word;
891 }       TX_AGG_CNT_STRUC, *PTX_AGG_CNT_STRUC;
892 // Debug counter
893 #define TX_AGG_CNT0     0x1720
894 typedef union   _TX_AGG_CNT0_STRUC      {
895         struct  {
896             USHORT  AggSize1Count;
897             USHORT  AggSize2Count;
898         }       field;
899         UINT32                  word;
900 }       TX_AGG_CNT0_STRUC, *PTX_AGG_CNT0_STRUC;
901 // Debug counter
902 #define TX_AGG_CNT1     0x1724
903 typedef union   _TX_AGG_CNT1_STRUC      {
904         struct  {
905             USHORT  AggSize3Count;
906             USHORT  AggSize4Count;
907         }       field;
908         UINT32                  word;
909 }       TX_AGG_CNT1_STRUC, *PTX_AGG_CNT1_STRUC;
910 #define TX_AGG_CNT2     0x1728
911 typedef union   _TX_AGG_CNT2_STRUC      {
912         struct  {
913             USHORT  AggSize5Count;
914             USHORT  AggSize6Count;
915         }       field;
916         UINT32                  word;
917 }       TX_AGG_CNT2_STRUC, *PTX_AGG_CNT2_STRUC;
918 // Debug counter
919 #define TX_AGG_CNT3     0x172c
920 typedef union   _TX_AGG_CNT3_STRUC      {
921         struct  {
922             USHORT  AggSize7Count;
923             USHORT  AggSize8Count;
924         }       field;
925         UINT32                  word;
926 }       TX_AGG_CNT3_STRUC, *PTX_AGG_CNT3_STRUC;
927 // Debug counter
928 #define TX_AGG_CNT4     0x1730
929 typedef union   _TX_AGG_CNT4_STRUC      {
930         struct  {
931             USHORT  AggSize9Count;
932             USHORT  AggSize10Count;
933         }       field;
934         UINT32                  word;
935 }       TX_AGG_CNT4_STRUC, *PTX_AGG_CNT4_STRUC;
936 #define TX_AGG_CNT5     0x1734
937 typedef union   _TX_AGG_CNT5_STRUC      {
938         struct  {
939             USHORT  AggSize11Count;
940             USHORT  AggSize12Count;
941         }       field;
942         UINT32                  word;
943 }       TX_AGG_CNT5_STRUC, *PTX_AGG_CNT5_STRUC;
944 #define TX_AGG_CNT6             0x1738
945 typedef union   _TX_AGG_CNT6_STRUC      {
946         struct  {
947             USHORT  AggSize13Count;
948             USHORT  AggSize14Count;
949         }       field;
950         UINT32                  word;
951 }       TX_AGG_CNT6_STRUC, *PTX_AGG_CNT6_STRUC;
952 #define TX_AGG_CNT7             0x173c
953 typedef union   _TX_AGG_CNT7_STRUC      {
954         struct  {
955             USHORT  AggSize15Count;
956             USHORT  AggSize16Count;
957         }       field;
958         UINT32                  word;
959 }       TX_AGG_CNT7_STRUC, *PTX_AGG_CNT7_STRUC;
960 #define MPDU_DENSITY_CNT                0x1740
961 typedef union   _MPDU_DEN_CNT_STRUC     {
962         struct  {
963             USHORT  TXZeroDelCount;     //TX zero length delimiter count
964             USHORT  RXZeroDelCount;     //RX zero length delimiter count
965         }       field;
966         UINT32                  word;
967 }       MPDU_DEN_CNT_STRUC, *PMPDU_DEN_CNT_STRUC;
968 //
969 // TXRX control registers - base address 0x3000
970 //
971 // rt2860b  UNKNOWN reg use R/O Reg Addr 0x77d0 first..
972 #define TXRX_CSR1           0x77d0
973
974 //
975 // Security key table memory, base address = 0x1000
976 //
977 #define MAC_WCID_BASE           0x1800 //8-bytes(use only 6-bytes) * 256 entry =
978 #define HW_WCID_ENTRY_SIZE   8
979 #define PAIRWISE_KEY_TABLE_BASE     0x4000      // 32-byte * 256-entry =  -byte
980 #define HW_KEY_ENTRY_SIZE           0x20
981 #define PAIRWISE_IVEIV_TABLE_BASE     0x6000      // 8-byte * 256-entry =  -byte
982 #define MAC_IVEIV_TABLE_BASE     0x6000      // 8-byte * 256-entry =  -byte
983 #define HW_IVEIV_ENTRY_SIZE   8
984 #define MAC_WCID_ATTRIBUTE_BASE     0x6800      // 4-byte * 256-entry =  -byte
985 #define HW_WCID_ATTRI_SIZE   4
986 #define WCID_RESERVED                   0x6bfc
987 #define SHARED_KEY_TABLE_BASE       0x6c00      // 32-byte * 16-entry = 512-byte
988 #define SHARED_KEY_MODE_BASE       0x7000      // 32-byte * 16-entry = 512-byte
989 #define HW_SHARED_KEY_MODE_SIZE   4
990 #define SHAREDKEYTABLE                  0
991 #define PAIRWISEKEYTABLE                        1
992
993
994 typedef union   _SHAREDKEY_MODE_STRUC   {
995         struct  {
996                 UINT32       Bss0Key0CipherAlg:3;
997                 UINT32       :1;
998                 UINT32       Bss0Key1CipherAlg:3;
999                 UINT32       :1;
1000                 UINT32       Bss0Key2CipherAlg:3;
1001                 UINT32       :1;
1002                 UINT32       Bss0Key3CipherAlg:3;
1003                 UINT32       :1;
1004                 UINT32       Bss1Key0CipherAlg:3;
1005                 UINT32       :1;
1006                 UINT32       Bss1Key1CipherAlg:3;
1007                 UINT32       :1;
1008                 UINT32       Bss1Key2CipherAlg:3;
1009                 UINT32       :1;
1010                 UINT32       Bss1Key3CipherAlg:3;
1011                 UINT32       :1;
1012         }       field;
1013         UINT32                  word;
1014 }       SHAREDKEY_MODE_STRUC, *PSHAREDKEY_MODE_STRUC;
1015 // 64-entry for pairwise key table
1016 typedef struct _HW_WCID_ENTRY {  // 8-byte per entry
1017     UCHAR   Address[6];
1018     UCHAR   Rsv[2];
1019 } HW_WCID_ENTRY, PHW_WCID_ENTRY;
1020
1021
1022 // =================================================================================
1023 // WCID  format
1024 // =================================================================================
1025 //7.1   WCID  ENTRY  format  : 8bytes
1026 typedef struct  _WCID_ENTRY_STRUC {
1027         UCHAR           RXBABitmap7;    // bit0 for TID8, bit7 for TID 15
1028         UCHAR           RXBABitmap0;    // bit0 for TID0, bit7 for TID 7
1029         UCHAR           MAC[6]; // 0 for shared key table.  1 for pairwise key table
1030 }       WCID_ENTRY_STRUC, *PWCID_ENTRY_STRUC;
1031
1032 //8.1.1 SECURITY  KEY  format  : 8DW
1033 // 32-byte per entry, total 16-entry for shared key table, 64-entry for pairwise key table
1034 typedef struct _HW_KEY_ENTRY {          // 32-byte per entry
1035     UCHAR   Key[16];
1036     UCHAR   TxMic[8];
1037     UCHAR   RxMic[8];
1038 } HW_KEY_ENTRY, *PHW_KEY_ENTRY;
1039
1040 //8.1.2 IV/EIV  format  : 2DW
1041
1042 //8.1.3 RX attribute entry format  : 1DW
1043 typedef struct  _MAC_ATTRIBUTE_STRUC {
1044         UINT32          KeyTab:1;       // 0 for shared key table.  1 for pairwise key table
1045         UINT32          PairKeyMode:3;
1046         UINT32          BSSIDIdx:3; //multipleBSS index for the WCID
1047         UINT32          RXWIUDF:3;
1048         UINT32          rsv:22;
1049 }       MAC_ATTRIBUTE_STRUC, *PMAC_ATTRIBUTE_STRUC;
1050
1051
1052 // =================================================================================
1053 // HOST-MCU communication data structure
1054 // =================================================================================
1055
1056 //
1057 // H2M_MAILBOX_CSR: Host-to-MCU Mailbox
1058 //
1059 typedef union  _H2M_MAILBOX_STRUC {
1060     struct {
1061         UINT32       LowByte:8;
1062         UINT32       HighByte:8;
1063         UINT32       CmdToken:8;
1064         UINT32       Owner:8;
1065     }   field;
1066     UINT32           word;
1067 } H2M_MAILBOX_STRUC, *PH2M_MAILBOX_STRUC;
1068
1069 //
1070 // M2H_CMD_DONE_CSR: MCU-to-Host command complete indication
1071 //
1072 typedef union _M2H_CMD_DONE_STRUC {
1073     struct  {
1074         UINT32       CmdToken0;
1075         UINT32       CmdToken1;
1076         UINT32       CmdToken2;
1077         UINT32       CmdToken3;
1078     } field;
1079     UINT32           word;
1080 } M2H_CMD_DONE_STRUC, *PM2H_CMD_DONE_STRUC;
1081
1082
1083 //NAV_TIME_CFG :NAV
1084 typedef union   _NAV_TIME_CFG_STRUC     {
1085         struct  {
1086                 UCHAR           Sifs;               // in unit of 1-us
1087                 UCHAR       SlotTime;    // in unit of 1-us
1088                 USHORT          Eifs:9;               // in unit of 1-us
1089                 USHORT          ZeroSifs:1;               // Applied zero SIFS timer after OFDM RX 0: disable
1090                 USHORT          rsv:6;
1091         }       field;
1092         UINT32                  word;
1093 }       NAV_TIME_CFG_STRUC, *PNAV_TIME_CFG_STRUC;
1094
1095
1096 //
1097 // RX_FILTR_CFG:  /RX configuration register
1098 //
1099 typedef union   _RX_FILTR_CFG_STRUC     {
1100         struct  {
1101                 UINT32          DropCRCErr:1;           // Drop CRC error
1102                 UINT32          DropPhyErr:1;           // Drop physical error
1103                 UINT32          DropNotToMe:1;          // Drop not to me unicast frame
1104                 UINT32          DropNotMyBSSID:1;                       // Drop fram ToDs bit is true
1105
1106                 UINT32          DropVerErr:1;       // Drop version error frame
1107                 UINT32          DropMcast:1;            // Drop multicast frames
1108                 UINT32          DropBcast:1;            // Drop broadcast frames
1109                 UINT32          DropDuplicate:1;                // Drop duplicate frame
1110
1111                 UINT32          DropCFEndAck:1;         // Drop Ps-Poll
1112                 UINT32          DropCFEnd:1;            // Drop Ps-Poll
1113                 UINT32          DropAck:1;              // Drop Ps-Poll
1114                 UINT32          DropCts:1;              // Drop Ps-Poll
1115
1116                 UINT32          DropRts:1;              // Drop Ps-Poll
1117                 UINT32          DropPsPoll:1;           // Drop Ps-Poll
1118                 UINT32          DropBA:1;               //
1119                 UINT32          DropBAR:1;       //
1120
1121                 UINT32          DropRsvCntlType:1;
1122                 UINT32          :15;
1123         }       field;
1124         UINT32                  word;
1125 }       RX_FILTR_CFG_STRUC, *PRX_FILTR_CFG_STRUC;
1126
1127
1128
1129
1130 //
1131 // PHY_CSR4: RF serial control register
1132 //
1133 typedef union   _PHY_CSR4_STRUC {
1134         struct  {
1135                 UINT32          RFRegValue:24;          // Register     value (include register id)     serial out to RF/IF     chip.
1136                 UINT32          NumberOfBits:5;         // Number of bits used in RFRegValue (I:20,     RFMD:22)
1137                 UINT32          IFSelect:1;                     // 1: select IF to program,     0: select RF to program
1138                 UINT32          PLL_LD:1;                       // RF PLL_LD status
1139                 UINT32          Busy:1;                         // 1: ASIC is busy execute RF programming.
1140         }       field;
1141         UINT32                  word;
1142 }       PHY_CSR4_STRUC, *PPHY_CSR4_STRUC;
1143
1144
1145 //
1146 // SEC_CSR5: shared key table security mode register
1147 //
1148 typedef union   _SEC_CSR5_STRUC {
1149         struct  {
1150         UINT32       Bss2Key0CipherAlg:3;
1151         UINT32       :1;
1152         UINT32       Bss2Key1CipherAlg:3;
1153         UINT32       :1;
1154         UINT32       Bss2Key2CipherAlg:3;
1155         UINT32       :1;
1156         UINT32       Bss2Key3CipherAlg:3;
1157         UINT32       :1;
1158         UINT32       Bss3Key0CipherAlg:3;
1159         UINT32       :1;
1160         UINT32       Bss3Key1CipherAlg:3;
1161         UINT32       :1;
1162         UINT32       Bss3Key2CipherAlg:3;
1163         UINT32       :1;
1164         UINT32       Bss3Key3CipherAlg:3;
1165         UINT32       :1;
1166         }       field;
1167         UINT32                  word;
1168 }       SEC_CSR5_STRUC, *PSEC_CSR5_STRUC;
1169
1170
1171 //
1172 // HOST_CMD_CSR: For HOST to interrupt embedded processor
1173 //
1174 typedef union   _HOST_CMD_CSR_STRUC     {
1175         struct  {
1176             UINT32   HostCommand:8;
1177             UINT32   Rsv:24;
1178         }       field;
1179         UINT32                  word;
1180 }       HOST_CMD_CSR_STRUC, *PHOST_CMD_CSR_STRUC;
1181
1182
1183 //
1184 // AIFSN_CSR: AIFSN for each EDCA AC
1185 //
1186
1187
1188
1189 //
1190 // E2PROM_CSR: EEPROM control register
1191 //
1192 typedef union   _E2PROM_CSR_STRUC       {
1193         struct  {
1194                 UINT32          Reload:1;               // Reload EEPROM content, write one to reload, self-cleared.
1195                 UINT32          EepromSK:1;
1196                 UINT32          EepromCS:1;
1197                 UINT32          EepromDI:1;
1198                 UINT32          EepromDO:1;
1199                 UINT32          Type:1;                 // 1: 93C46, 0:93C66
1200                 UINT32       LoadStatus:1;   // 1:loading, 0:done
1201                 UINT32          Rsvd:25;
1202         }       field;
1203         UINT32                  word;
1204 }       E2PROM_CSR_STRUC, *PE2PROM_CSR_STRUC;
1205
1206 //
1207 // QOS_CSR0: TXOP holder address0 register
1208 //
1209 typedef union   _QOS_CSR0_STRUC {
1210         struct  {
1211                 UCHAR           Byte0;          // MAC address byte 0
1212                 UCHAR           Byte1;          // MAC address byte 1
1213                 UCHAR           Byte2;          // MAC address byte 2
1214                 UCHAR           Byte3;          // MAC address byte 3
1215         }       field;
1216         UINT32                  word;
1217 }       QOS_CSR0_STRUC, *PQOS_CSR0_STRUC;
1218
1219 //
1220 // QOS_CSR1: TXOP holder address1 register
1221 //
1222 typedef union   _QOS_CSR1_STRUC {
1223         struct  {
1224                 UCHAR           Byte4;          // MAC address byte 4
1225                 UCHAR           Byte5;          // MAC address byte 5
1226                 UCHAR           Rsvd0;
1227                 UCHAR           Rsvd1;
1228         }       field;
1229         UINT32                  word;
1230 }       QOS_CSR1_STRUC, *PQOS_CSR1_STRUC;
1231
1232 #define RF_CSR_CFG      0x500
1233 typedef union   _RF_CSR_CFG_STRUC       {
1234         struct  {
1235                 UINT    RF_CSR_DATA:8;                  // DATA
1236                 UINT    TESTCSR_RFACC_REGNUM:5; // RF register ID
1237                 UINT    Rsvd2:3;                                // Reserved
1238                 UINT    RF_CSR_WR:1;                    // 0: read  1: write
1239                 UINT    RF_CSR_KICK:1;                  // kick RF register read/write
1240                 UINT    Rsvd1:14;                               // Reserved
1241         }       field;
1242         UINT    word;
1243 }       RF_CSR_CFG_STRUC, *PRF_CSR_CFG_STRUC;
1244
1245
1246 //
1247 // Other on-chip shared memory space, base = 0x2000
1248 //
1249
1250 // CIS space - base address = 0x2000
1251 #define HW_CIS_BASE             0x2000
1252
1253 // Carrier-sense CTS frame base address. It's where mac stores carrier-sense frame for carrier-sense function.
1254 #define HW_CS_CTS_BASE                  0x7700
1255 // DFS CTS frame base address. It's where mac stores CTS frame for DFS.
1256 #define HW_DFS_CTS_BASE                 0x7780
1257 #define HW_CTS_FRAME_SIZE               0x80
1258
1259 // 2004-11-08 john - since NULL frame won't be that long (256 byte). We steal 16 tail bytes
1260 // to save debugging settings
1261 #define HW_DEBUG_SETTING_BASE   0x77f0  // 0x77f0~0x77ff total 16 bytes
1262 #define HW_DEBUG_SETTING_BASE2   0x7770  // 0x77f0~0x77ff total 16 bytes
1263
1264 // In order to support maximum 8 MBSS and its maximum length is 512 for each beacon
1265 // Three section discontinue memory segments will be used.
1266 // 1. The original region for BCN 0~3
1267 // 2. Extract memory from FCE table for BCN 4~5
1268 // 3. Extract memory from Pair-wise key table for BCN 6~7
1269 //        It occupied those memory of wcid 238~253 for BCN 6
1270 //                                                    and wcid 222~237 for BCN 7
1271 #define HW_BEACON_MAX_SIZE      0x1000 /* unit: byte */
1272 #define HW_BEACON_BASE0         0x7800
1273 #define HW_BEACON_BASE1         0x7A00
1274 #define HW_BEACON_BASE2         0x7C00
1275 #define HW_BEACON_BASE3         0x7E00
1276 #define HW_BEACON_BASE4         0x7200
1277 #define HW_BEACON_BASE5         0x7400
1278 #define HW_BEACON_BASE6         0x5DC0
1279 #define HW_BEACON_BASE7         0x5BC0
1280
1281 #define HW_BEACON_MAX_COUNT     8
1282 #define HW_BEACON_OFFSET                0x0200
1283 #define HW_BEACON_CONTENT_LEN   (HW_BEACON_OFFSET - TXWI_SIZE)
1284
1285 // HOST-MCU shared memory - base address = 0x2100
1286 #define HOST_CMD_CSR            0x404
1287 #define H2M_MAILBOX_CSR         0x7010
1288 #define H2M_MAILBOX_CID         0x7014
1289 #define H2M_MAILBOX_STATUS      0x701c
1290 #define H2M_INT_SRC             0x7024
1291 #define H2M_BBP_AGENT           0x7028
1292 #define M2H_CMD_DONE_CSR        0x000c
1293 #define MCU_TXOP_ARRAY_BASE     0x000c   // TODO: to be provided by Albert
1294 #define MCU_TXOP_ENTRY_SIZE     32       // TODO: to be provided by Albert
1295 #define MAX_NUM_OF_TXOP_ENTRY   16       // TODO: must be same with 8051 firmware
1296 #define MCU_MBOX_VERSION        0x01     // TODO: to be confirmed by Albert
1297 #define MCU_MBOX_VERSION_OFFSET 5        // TODO: to be provided by Albert
1298
1299 //
1300 // Host DMA registers - base address 0x200 .  TX0-3=EDCAQid0-3, TX4=HCCA, TX5=MGMT,
1301 //
1302 //
1303 //  DMA RING DESCRIPTOR
1304 //
1305 #define E2PROM_CSR          0x0004
1306 #define IO_CNTL_CSR         0x77d0
1307
1308
1309
1310 // ================================================================
1311 // Tx / Rx / Mgmt ring descriptor definition
1312 // ================================================================
1313
1314 // the following PID values are used to mark outgoing frame type in TXD->PID so that
1315 // proper TX statistics can be collected based on these categories
1316 // b3-2 of PID field -
1317 #define PID_MGMT                        0x05
1318 #define PID_BEACON                      0x0c
1319 #define PID_DATA_NORMALUCAST            0x02
1320 #define PID_DATA_AMPDU          0x04
1321 #define PID_DATA_NO_ACK         0x08
1322 #define PID_DATA_NOT_NORM_ACK           0x03
1323 // value domain of pTxD->HostQId (4-bit: 0~15)
1324 #define QID_AC_BK               1   // meet ACI definition in 802.11e
1325 #define QID_AC_BE               0   // meet ACI definition in 802.11e
1326 #define QID_AC_VI               2
1327 #define QID_AC_VO               3
1328 #define QID_HCCA                4
1329 #define NUM_OF_TX_RING          4
1330 #define QID_MGMT                13
1331 #define QID_RX                  14
1332 #define QID_OTHER               15
1333
1334 #endif // __RTMP_MAC_H__ //