~ubuntu-branches/ubuntu/precise/linux-ti-omap4/precise

« back to all changes in this revision

Viewing changes to drivers/staging/rt2860/chip/mac_pci.h

  • Committer: Bazaar Package Importer
  • Author(s): Paolo Pisati
  • Date: 2011-06-29 15:23:51 UTC
  • mfrom: (26.1.1 natty-proposed)
  • Revision ID: james.westby@ubuntu.com-20110629152351-xs96tm303d95rpbk
Tags: 3.0.0-1200.2
* Rebased against 3.0.0-6.7
* BSP from TI based on 3.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
 
        mac_pci.h
29
 
 
30
 
    Abstract:
31
 
 
32
 
    Revision History:
33
 
    Who                 When            What
34
 
    Justin P. Mattock   11/07/2010      Fix some typos
35
 
    ---------    ----------    ----------------------------------------------
36
 
 */
37
 
 
38
 
#ifndef __MAC_PCI_H__
39
 
#define __MAC_PCI_H__
40
 
 
41
 
#include "../rtmp_type.h"
42
 
#include "rtmp_mac.h"
43
 
#include "rtmp_phy.h"
44
 
#include "../rtmp_iface.h"
45
 
#include "../rtmp_dot11.h"
46
 
 
47
 
/* */
48
 
/* Device ID & Vendor ID related definitions, */
49
 
/* NOTE: you should not add the new VendorID/DeviceID here unless you know for sure what chip it belongs too. */
50
 
/* */
51
 
#define NIC_PCI_VENDOR_ID               0x1814
52
 
#define PCIBUS_INTEL_VENDOR     0x8086
53
 
 
54
 
#if !defined(PCI_CAP_ID_EXP)
55
 
#define PCI_CAP_ID_EXP                      0x10
56
 
#endif
57
 
#if !defined(PCI_EXP_LNKCTL)
58
 
#define PCI_EXP_LNKCTL                      0x10
59
 
#endif
60
 
#if !defined(PCI_CLASS_BRIDGE_PCI)
61
 
#define PCI_CLASS_BRIDGE_PCI            0x0604
62
 
#endif
63
 
 
64
 
#define TXINFO_SIZE                                             0
65
 
#define RTMP_PKT_TAIL_PADDING                   0
66
 
#define fRTMP_ADAPTER_NEED_STOP_TX      0
67
 
 
68
 
#define AUX_CTRL           0x10c
69
 
 
70
 
/* */
71
 
/* TX descriptor format, Tx     ring, Mgmt Ring */
72
 
/* */
73
 
struct PACKED rt_txd {
74
 
        /* Word 0 */
75
 
        u32 SDPtr0;
76
 
        /* Word 1 */
77
 
        u32 SDLen1:14;
78
 
        u32 LastSec1:1;
79
 
        u32 Burst:1;
80
 
        u32 SDLen0:14;
81
 
        u32 LastSec0:1;
82
 
        u32 DMADONE:1;
83
 
        /*Word2 */
84
 
        u32 SDPtr1;
85
 
        /*Word3 */
86
 
        u32 rsv2:24;
87
 
        u32 WIV:1;              /* Wireless Info Valid. 1 if Driver already fill WI,  o if DMA needs to copy WI to correct position */
88
 
        u32 QSEL:2;             /* select on-chip FIFO ID for 2nd-stage output scheduler.0:MGMT, 1:HCCA 2:EDCA */
89
 
        u32 rsv:2;
90
 
        u32 TCO:1;              /* */
91
 
        u32 UCO:1;              /* */
92
 
        u32 ICO:1;              /* */
93
 
};
94
 
 
95
 
/* */
96
 
/* Rx descriptor format, Rx Ring */
97
 
/* */
98
 
typedef struct PACKED rt_rxd {
99
 
        /* Word 0 */
100
 
        u32 SDP0;
101
 
        /* Word 1 */
102
 
        u32 SDL1:14;
103
 
        u32 Rsv:2;
104
 
        u32 SDL0:14;
105
 
        u32 LS0:1;
106
 
        u32 DDONE:1;
107
 
        /* Word 2 */
108
 
        u32 SDP1;
109
 
        /* Word 3 */
110
 
        u32 BA:1;
111
 
        u32 DATA:1;
112
 
        u32 NULLDATA:1;
113
 
        u32 FRAG:1;
114
 
        u32 U2M:1;              /* 1: this RX frame is unicast to me */
115
 
        u32 Mcast:1;            /* 1: this is a multicast frame */
116
 
        u32 Bcast:1;            /* 1: this is a broadcast frame */
117
 
        u32 MyBss:1;            /* 1: this frame belongs to the same BSSID */
118
 
        u32 Crc:1;              /* 1: CRC error */
119
 
        u32 CipherErr:2;        /* 0: decryption okay, 1:ICV error, 2:MIC error, 3:KEY not valid */
120
 
        u32 AMSDU:1;            /* rx with 802.3 header, not 802.11 header. */
121
 
        u32 HTC:1;
122
 
        u32 RSSI:1;
123
 
        u32 L2PAD:1;
124
 
        u32 AMPDU:1;
125
 
        u32 Decrypted:1;        /* this frame is being decrypted. */
126
 
        u32 PlcpSignal:1;       /* To be moved */
127
 
        u32 PlcpRssil:1;        /* To be moved */
128
 
        u32 Rsv1:13;
129
 
} RT28XX_RXD_STRUC, *PRT28XX_RXD_STRUC;
130
 
 
131
 
typedef union _TX_ATTENUATION_CTRL_STRUC {
132
 
        struct {
133
 
                unsigned long RF_ISOLATION_ENABLE:1;
134
 
                unsigned long Reserve2:7;
135
 
                unsigned long PCIE_PHY_TX_ATTEN_VALUE:3;
136
 
                unsigned long PCIE_PHY_TX_ATTEN_EN:1;
137
 
                unsigned long Reserve1:20;
138
 
        } field;
139
 
 
140
 
        unsigned long word;
141
 
} TX_ATTENUATION_CTRL_STRUC, *PTX_ATTENUATION_CTRL_STRUC;
142
 
 
143
 
/* ----------------- EEPROM Related MACRO ----------------- */
144
 
 
145
 
/* 8051 firmware image for RT2860 - base address = 0x4000 */
146
 
#define FIRMWARE_IMAGE_BASE     0x2000
147
 
#define MAX_FIRMWARE_IMAGE_SIZE 0x2000  /* 8kbyte */
148
 
 
149
 
/* ----------------- Frimware Related MACRO ----------------- */
150
 
#define RTMP_WRITE_FIRMWARE(_pAd, _pFwImage, _FwLen)                    \
151
 
        do {                                                            \
152
 
                unsigned long   _i, _firm;                                      \
153
 
                RTMP_IO_WRITE32(_pAd, PBF_SYS_CTRL, 0x10000);           \
154
 
                                                                        \
155
 
                for (_i = 0; _i < _FwLen; _i += 4) {                            \
156
 
                                _firm = _pFwImage[_i] +                         \
157
 
                           (_pFwImage[_i+3] << 24) +                    \
158
 
                           (_pFwImage[_i+2] << 16) +                    \
159
 
                           (_pFwImage[_i+1] << 8);                      \
160
 
                        RTMP_IO_WRITE32(_pAd, FIRMWARE_IMAGE_BASE + _i, _firm); \
161
 
                }                                                       \
162
 
                RTMP_IO_WRITE32(_pAd, PBF_SYS_CTRL, 0x00000);           \
163
 
                RTMP_IO_WRITE32(_pAd, PBF_SYS_CTRL, 0x00001);           \
164
 
                                                                        \
165
 
                /* initialize BBP R/W access agent */                   \
166
 
                RTMP_IO_WRITE32(_pAd, H2M_BBP_AGENT, 0);                \
167
 
                RTMP_IO_WRITE32(_pAd, H2M_MAILBOX_CSR, 0);              \
168
 
        } while (0)
169
 
 
170
 
/* ----------------- TX Related MACRO ----------------- */
171
 
#define RTMP_START_DEQUEUE(pAd, QueIdx, irqFlags)               do {} while (0)
172
 
#define RTMP_STOP_DEQUEUE(pAd, QueIdx, irqFlags)                do {} while (0)
173
 
 
174
 
#define RTMP_HAS_ENOUGH_FREE_DESC(pAd, pTxBlk, freeNum, pPacket) \
175
 
                ((freeNum) >= (unsigned long)(pTxBlk->TotalFragNum + RTMP_GET_PACKET_FRAGMENTS(pPacket) + 3))   /* rough estimate we will use 3 more descriptor. */
176
 
#define RTMP_RELEASE_DESC_RESOURCE(pAd, QueIdx)                 do {} while (0)
177
 
 
178
 
#define NEED_QUEUE_BACK_FOR_AGG(pAd, QueIdx, freeNum, _TxFrameType) \
179
 
                (((freeNum != (TX_RING_SIZE-1)) && \
180
 
                (pAd->TxSwQueue[QueIdx].Number == 0)) || (freeNum < 3))
181
 
 
182
 
#define HAL_KickOutMgmtTx(_pAd, _QueIdx, _pPacket, _pSrcBufVA, _SrcBufLen)      \
183
 
                        RtmpPCIMgmtKickOut(_pAd, _QueIdx, _pPacket, _pSrcBufVA, _SrcBufLen)
184
 
 
185
 
#define HAL_WriteSubTxResource(pAd, pTxBlk, bIsLast, pFreeNumber)       \
186
 
                                /* RtmpPCI_WriteSubTxResource(pAd, pTxBlk, bIsLast, pFreeNumber) */
187
 
 
188
 
#define HAL_WriteTxResource(pAd, pTxBlk, bIsLast, pFreeNumber)  \
189
 
                        RtmpPCI_WriteSingleTxResource(pAd, pTxBlk, bIsLast, pFreeNumber)
190
 
 
191
 
#define HAL_WriteFragTxResource(pAd, pTxBlk, fragNum, pFreeNumber) \
192
 
                        RtmpPCI_WriteFragTxResource(pAd, pTxBlk, fragNum, pFreeNumber)
193
 
 
194
 
#define HAL_WriteMultiTxResource(pAd, pTxBlk, frameNum, pFreeNumber) \
195
 
                        RtmpPCI_WriteMultiTxResource(pAd, pTxBlk, frameNum, pFreeNumber)
196
 
 
197
 
#define HAL_FinalWriteTxResource(_pAd, _pTxBlk, _TotalMPDUSize, _FirstTxIdx)    \
198
 
                        RtmpPCI_FinalWriteTxResource(_pAd, _pTxBlk, _TotalMPDUSize, _FirstTxIdx)
199
 
 
200
 
#define HAL_LastTxIdx(_pAd, _QueIdx, _LastTxIdx) \
201
 
                                /*RtmpPCIDataLastTxIdx(_pAd, _QueIdx,_LastTxIdx) */
202
 
 
203
 
#define HAL_KickOutTx(_pAd, _pTxBlk, _QueIdx)   \
204
 
                        RTMP_IO_WRITE32((_pAd), TX_CTX_IDX0+((_QueIdx)*0x10), (_pAd)->TxRing[(_QueIdx)].TxCpuIdx)
205
 
/*                      RtmpPCIDataKickOut(_pAd, _pTxBlk, _QueIdx)*/
206
 
 
207
 
#define HAL_KickOutNullFrameTx(_pAd, _QueIdx, _pNullFrame, _frameLen)   \
208
 
                        MiniportMMRequest(_pAd, _QueIdx, _pNullFrame, _frameLen)
209
 
 
210
 
#define GET_TXRING_FREENO(_pAd, _QueIdx) \
211
 
        (_pAd->TxRing[_QueIdx].TxSwFreeIdx > _pAd->TxRing[_QueIdx].TxCpuIdx)    ? \
212
 
                        (_pAd->TxRing[_QueIdx].TxSwFreeIdx - _pAd->TxRing[_QueIdx].TxCpuIdx - 1) \
213
 
                         :      \
214
 
                        (_pAd->TxRing[_QueIdx].TxSwFreeIdx + TX_RING_SIZE - _pAd->TxRing[_QueIdx].TxCpuIdx - 1);
215
 
 
216
 
#define GET_MGMTRING_FREENO(_pAd) \
217
 
        (_pAd->MgmtRing.TxSwFreeIdx > _pAd->MgmtRing.TxCpuIdx)  ? \
218
 
                        (_pAd->MgmtRing.TxSwFreeIdx - _pAd->MgmtRing.TxCpuIdx - 1) \
219
 
                         :      \
220
 
                        (_pAd->MgmtRing.TxSwFreeIdx + MGMT_RING_SIZE - _pAd->MgmtRing.TxCpuIdx - 1);
221
 
 
222
 
/* ----------------- RX Related MACRO ----------------- */
223
 
 
224
 
/* ----------------- ASIC Related MACRO ----------------- */
225
 
/* reset MAC of a station entry to 0x000000000000 */
226
 
#define RTMP_STA_ENTRY_MAC_RESET(pAd, Wcid)     \
227
 
        AsicDelWcidTab(pAd, Wcid);
228
 
 
229
 
/* add this entry into ASIC RX WCID search table */
230
 
#define RTMP_STA_ENTRY_ADD(pAd, pEntry)         \
231
 
        AsicUpdateRxWCIDTable(pAd, pEntry->Aid, pEntry->Addr);
232
 
 
233
 
/* add by johnli, fix "in_interrupt" error when call "MacTableDeleteEntry" in Rx tasklet */
234
 
/* Set MAC register value according operation mode */
235
 
#define RTMP_UPDATE_PROTECT(pAd)        \
236
 
        AsicUpdateProtect(pAd, 0, (ALLN_SETPROTECT), TRUE, 0);
237
 
/* end johnli */
238
 
 
239
 
/* remove Pair-wise key material from ASIC */
240
 
#define RTMP_STA_ENTRY_KEY_DEL(pAd, BssIdx, Wcid)       \
241
 
        AsicRemovePairwiseKeyEntry(pAd, BssIdx, (u8)Wcid);
242
 
 
243
 
/* add Client security information into ASIC WCID table and IVEIV table */
244
 
#define RTMP_STA_SECURITY_INFO_ADD(pAd, apidx, KeyID, pEntry)           \
245
 
        RTMPAddWcidAttributeEntry(pAd, apidx, KeyID,                    \
246
 
                                                        pAd->SharedKey[apidx][KeyID].CipherAlg, pEntry);
247
 
 
248
 
#define RTMP_SECURITY_KEY_ADD(pAd, apidx, KeyID, pEntry)                \
249
 
        {       /* update pairwise key information to ASIC Shared Key Table */  \
250
 
                AsicAddSharedKeyEntry(pAd, apidx, KeyID,                                        \
251
 
                                                  pAd->SharedKey[apidx][KeyID].CipherAlg,               \
252
 
                                                  pAd->SharedKey[apidx][KeyID].Key,                             \
253
 
                                                  pAd->SharedKey[apidx][KeyID].TxMic,                   \
254
 
                                                  pAd->SharedKey[apidx][KeyID].RxMic);                  \
255
 
                /* update ASIC WCID attribute table and IVEIV table */                  \
256
 
                RTMPAddWcidAttributeEntry(pAd, apidx, KeyID,                                    \
257
 
                                                  pAd->SharedKey[apidx][KeyID].CipherAlg,               \
258
 
                                                  pEntry); }
259
 
 
260
 
/* Insert the BA bitmap to ASIC for the Wcid entry */
261
 
#define RTMP_ADD_BA_SESSION_TO_ASIC(_pAd, _Aid, _TID)   \
262
 
                do {                                    \
263
 
                        u32 _Value = 0, _Offset;                                        \
264
 
                        _Offset = MAC_WCID_BASE + (_Aid) * HW_WCID_ENTRY_SIZE + 4;      \
265
 
                        RTMP_IO_READ32((_pAd), _Offset, &_Value);\
266
 
                        _Value |= (0x10000<<(_TID));    \
267
 
                        RTMP_IO_WRITE32((_pAd), _Offset, _Value);\
268
 
                } while (0)
269
 
 
270
 
/* Remove the BA bitmap from ASIC for the Wcid entry */
271
 
/*              bitmap field starts at 0x10000 in ASIC WCID table */
272
 
#define RTMP_DEL_BA_SESSION_FROM_ASIC(_pAd, _Wcid, _TID)                                \
273
 
                do {                                                            \
274
 
                        u32 _Value = 0, _Offset;                                \
275
 
                        _Offset = MAC_WCID_BASE + (_Wcid) * HW_WCID_ENTRY_SIZE + 4;     \
276
 
                        RTMP_IO_READ32((_pAd), _Offset, &_Value);                       \
277
 
                        _Value &= (~(0x10000 << (_TID)));                               \
278
 
                        RTMP_IO_WRITE32((_pAd), _Offset, _Value);                       \
279
 
                } while (0)
280
 
 
281
 
/* ----------------- Interface Related MACRO ----------------- */
282
 
 
283
 
/* */
284
 
/* Enable & Disable NIC interrupt via writing interrupt mask register */
285
 
/* Since it use ADAPTER structure, it have to be put after structure definition. */
286
 
/* */
287
 
#define RTMP_ASIC_INTERRUPT_DISABLE(_pAd)               \
288
 
        do {                    \
289
 
                RTMP_IO_WRITE32((_pAd), INT_MASK_CSR, 0x0);     /* 0: disable */        \
290
 
                RTMP_CLEAR_FLAG((_pAd), fRTMP_ADAPTER_INTERRUPT_ACTIVE);                \
291
 
        } while (0)
292
 
 
293
 
#define RTMP_ASIC_INTERRUPT_ENABLE(_pAd)\
294
 
        do {                            \
295
 
                RTMP_IO_WRITE32((_pAd), INT_MASK_CSR, (_pAd)->int_enable_reg /*DELAYINTMASK*/);     /* 1:enable */      \
296
 
                RTMP_SET_FLAG((_pAd), fRTMP_ADAPTER_INTERRUPT_ACTIVE);  \
297
 
        } while (0)
298
 
 
299
 
#define RTMP_IRQ_INIT(pAd)      \
300
 
        {       pAd->int_enable_reg = ((DELAYINTMASK) |         \
301
 
                                        (RxINT|TxDataInt|TxMgmtInt)) & ~(0x03); \
302
 
                pAd->int_disable_mask = 0;                                              \
303
 
                pAd->int_pending = 0; }
304
 
 
305
 
#define RTMP_IRQ_ENABLE(pAd)                                    \
306
 
        {       /* clear garbage ints */                        \
307
 
                RTMP_IO_WRITE32(pAd, INT_SOURCE_CSR, 0xffffffff);\
308
 
                RTMP_ASIC_INTERRUPT_ENABLE(pAd); }
309
 
 
310
 
/* ----------------- MLME Related MACRO ----------------- */
311
 
#define RTMP_MLME_HANDLER(pAd)                  MlmeHandler(pAd)
312
 
 
313
 
#define RTMP_MLME_PRE_SANITY_CHECK(pAd)
314
 
 
315
 
#define RTMP_MLME_STA_QUICK_RSP_WAKE_UP(pAd)    \
316
 
                RTMPSetTimer(&pAd->StaCfg.StaQuickResponeForRateUpTimer, 100);
317
 
 
318
 
#define RTMP_MLME_RESET_STATE_MACHINE(pAd)      \
319
 
                MlmeRestartStateMachine(pAd)
320
 
 
321
 
#define RTMP_HANDLE_COUNTER_MEASURE(_pAd, _pEntry)\
322
 
                HandleCounterMeasure(_pAd, _pEntry)
323
 
 
324
 
/* ----------------- Power Save Related MACRO ----------------- */
325
 
#define RTMP_PS_POLL_ENQUEUE(pAd)                               EnqueuePsPoll(pAd)
326
 
 
327
 
/* For RTMPPCIePowerLinkCtrlRestore () function */
328
 
#define RESTORE_HALT            1
329
 
#define RESTORE_WAKEUP          2
330
 
#define RESTORE_CLOSE           3
331
 
 
332
 
#define PowerSafeCID            1
333
 
#define PowerRadioOffCID        2
334
 
#define PowerWakeCID            3
335
 
#define CID0MASK                0x000000ff
336
 
#define CID1MASK                0x0000ff00
337
 
#define CID2MASK                0x00ff0000
338
 
#define CID3MASK                0xff000000
339
 
 
340
 
#define RTMP_STA_FORCE_WAKEUP(pAd, bFromTx) \
341
 
    RT28xxPciStaAsicForceWakeup(pAd, bFromTx);
342
 
 
343
 
#define RTMP_STA_SLEEP_THEN_AUTO_WAKEUP(pAd, TbttNumToNextWakeUp) \
344
 
    RT28xxPciStaAsicSleepThenAutoWakeup(pAd, TbttNumToNextWakeUp);
345
 
 
346
 
#define RTMP_SET_PSM_BIT(_pAd, _val) \
347
 
        MlmeSetPsmBit(_pAd, _val);
348
 
 
349
 
#define RTMP_MLME_RADIO_ON(pAd) \
350
 
    RT28xxPciMlmeRadioOn(pAd);
351
 
 
352
 
#define RTMP_MLME_RADIO_OFF(pAd) \
353
 
    RT28xxPciMlmeRadioOFF(pAd);
354
 
 
355
 
#endif /*__MAC_PCI_H__ // */