Staging: rt2870: add eFuse support
[safe/jmp/linux-2.6] / drivers / staging / rt2870 / rt2870.h
index c05998b..131f332 100644 (file)
@@ -62,6 +62,7 @@
 #define        fRTUSB_BULK_OUT_DATA_NORMAL_2                   0x00020000
 #define        fRTUSB_BULK_OUT_DATA_NORMAL_3                   0x00040000
 #define        fRTUSB_BULK_OUT_DATA_NORMAL_4                   0x00080000
+#define        fRTUSB_BULK_OUT_DATA_NORMAL_5                   0x00100000
 
 #define        fRTUSB_BULK_OUT_PSPOLL                                  0x00000020
 #define        fRTUSB_BULK_OUT_DATA_FRAG                               0x00000040
 #define        fRTUSB_BULK_OUT_DATA_FRAG_3                             0x00000100
 #define        fRTUSB_BULK_OUT_DATA_FRAG_4                             0x00000200
 
-#ifdef RALINK_ATE
-#define        fRTUSB_BULK_OUT_DATA_ATE                                0x00100000
-#endif // RALINK_ATE //
-
-#define RT2870_USB_DEVICES     \
-{      \
-       {USB_DEVICE(0x148F,0x2770)}, /* Ralink */               \
-       {USB_DEVICE(0x1737,0x0071)}, /* Linksys WUSB600N */     \
-       {USB_DEVICE(0x148F,0x2870)}, /* Ralink */               \
-       {USB_DEVICE(0x148F,0x3070)}, /* Ralink */               \
-       {USB_DEVICE(0x0B05,0x1731)}, /* Asus */                 \
-       {USB_DEVICE(0x0B05,0x1732)}, /* Asus */                 \
-       {USB_DEVICE(0x0B05,0x1742)}, /* Asus */                 \
-       {USB_DEVICE(0x0DF6,0x0017)}, /* Sitecom */              \
-       {USB_DEVICE(0x0DF6,0x002B)}, /* Sitecom */              \
-       {USB_DEVICE(0x0DF6,0x002C)}, /* Sitecom */              \
-       {USB_DEVICE(0x0DF6,0x002D)}, /* Sitecom */              \
-       {USB_DEVICE(0x0DF6,0x0039)}, /* Sitecom */              \
-       {USB_DEVICE(0x14B2,0x3C06)}, /* Conceptronic */         \
-       {USB_DEVICE(0x14B2,0x3C28)}, /* Conceptronic */         \
-       {USB_DEVICE(0x2019,0xED06)}, /* Planex Communications, Inc. */          \
-       {USB_DEVICE(0x2019,0xAB25)}, /* Planex Communications, Inc. RT3070 */           \
-       {USB_DEVICE(0x07D1,0x3C09)}, /* D-Link */               \
-       {USB_DEVICE(0x07D1,0x3C11)}, /* D-Link */               \
-       {USB_DEVICE(0x14B2,0x3C07)}, /* AL */                   \
-       {USB_DEVICE(0x14B2,0x3C12)}, /* AL */           \
-       {USB_DEVICE(0x050D,0x8053)}, /* Belkin */               \
-       {USB_DEVICE(0x14B2,0x3C23)}, /* Airlink */              \
-       {USB_DEVICE(0x14B2,0x3C27)}, /* Airlink */              \
-       {USB_DEVICE(0x07AA,0x002F)}, /* Corega */               \
-       {USB_DEVICE(0x07AA,0x003C)}, /* Corega */               \
-       {USB_DEVICE(0x07AA,0x003F)}, /* Corega */               \
-       {USB_DEVICE(0x18C5,0x0012)}, /* Corega */               \
-       {USB_DEVICE(0x1044,0x800B)}, /* Gigabyte */             \
-       {USB_DEVICE(0x15A9,0x0006)}, /* Sparklan */             \
-       {USB_DEVICE(0x083A,0xB522)}, /* SMC */                  \
-       {USB_DEVICE(0x083A,0xA618)}, /* SMC */                  \
-       {USB_DEVICE(0x083A,0x7522)}, /* Arcadyan */             \
-       {USB_DEVICE(0x0CDE,0x0022)}, /* ZCOM */                 \
-       {USB_DEVICE(0x0586,0x3416)}, /* Zyxel */                \
-       {USB_DEVICE(0x0CDE,0x0025)}, /* Zyxel */                \
-       {USB_DEVICE(0x1740,0x9701)}, /* EnGenius */             \
-       {USB_DEVICE(0x1740,0x9702)}, /* EnGenius */             \
-       {USB_DEVICE(0x0471,0x200f)}, /* Philips */              \
-       {USB_DEVICE(0x14B2,0x3C25)}, /* Draytek */              \
-       {USB_DEVICE(0x13D3,0x3247)}, /* AzureWave */    \
-       {USB_DEVICE(0x083A,0x6618)}, /* Accton */               \
-       {USB_DEVICE(0x15c5,0x0008)}, /* Amit */                 \
-       {USB_DEVICE(0x0E66,0x0001)}, /* Hawking */              \
-       {USB_DEVICE(0x0E66,0x0003)}, /* Hawking */              \
-       {USB_DEVICE(0x129B,0x1828)}, /* Siemens */              \
-       {USB_DEVICE(0x157E,0x300E)},    /* U-Media */   \
-       {USB_DEVICE(0x050d,0x805c)},                                    \
-       {USB_DEVICE(0x1482,0x3C09)}, /* Abocom*/                \
-       {USB_DEVICE(0x14B2,0x3C09)}, /* Alpha */                \
-       {USB_DEVICE(0x04E8,0x2018)}, /* samsung */      \
-       {USB_DEVICE(0x07B8,0x3070)}, /* AboCom */               \
-       {USB_DEVICE(0x07B8,0x3071)}, /* AboCom */               \
-       {USB_DEVICE(0x07B8,0x2870)}, /* AboCom */               \
-       {USB_DEVICE(0x07B8,0x2770)}, /* AboCom */               \
-       {USB_DEVICE(0x7392,0x7711)}, /* Edimax */               \
-       {USB_DEVICE(0x5A57,0x0280)}, /* Zinwell */              \
-       {USB_DEVICE(0x5A57,0x0282)}, /* Zinwell */              \
-       {USB_DEVICE(0x0789,0x0162)}, /* Logitec */              \
-       {USB_DEVICE(0x0789,0x0163)}, /* Logitec */              \
-       {USB_DEVICE(0x0789,0x0164)}, /* Logitec */              \
-       {USB_DEVICE(0x7392,0x7717)}, /* Edimax */               \
-       { }/* Terminating entry */                      \
-}
-
 #define        FREE_HTTX_RING(_p, _b, _t)                      \
 {                                                                              \
        if ((_t)->ENextBulkOutPosition == (_t)->CurWritePosition)                               \
 //
 // RXINFO appends at the end of each rx packet.
 //
-#ifdef RT_BIG_ENDIAN
-typedef        struct  PACKED _RXINFO_STRUC {
-       UINT32          PlcpSignal:12;
-       UINT32          LastAMSDU:1;
-       UINT32          CipherAlg:1;
-       UINT32          PlcpRssil:1;
-       UINT32          Decrypted:1;
-       UINT32          AMPDU:1;                // To be moved
-       UINT32          L2PAD:1;
-       UINT32          RSSI:1;
-       UINT32          HTC:1;
-       UINT32          AMSDU:1;                // rx with 802.3 header, not 802.11 header.
-       UINT32          CipherErr:2;        // 0: decryption okay, 1:ICV error, 2:MIC error, 3:KEY not valid
-       UINT32          Crc:1;              // 1: CRC error
-       UINT32          MyBss:1;        // 1: this frame belongs to the same BSSID
-       UINT32          Bcast:1;            // 1: this is a broadcast frame
-       UINT32          Mcast:1;            // 1: this is a multicast frame
-       UINT32          U2M:1;              // 1: this RX frame is unicast to me
-       UINT32          FRAG:1;
-       UINT32          NULLDATA:1;
-       UINT32          DATA:1;
-       UINT32          BA:1;
-}      RXINFO_STRUC, *PRXINFO_STRUC, RT28XX_RXD_STRUC, *PRT28XX_RXD_STRUC;
-#else
 typedef        struct  PACKED _RXINFO_STRUC {
        UINT32          BA:1;
        UINT32          DATA:1;
@@ -197,25 +104,10 @@ typedef   struct  PACKED _RXINFO_STRUC {
        UINT32          LastAMSDU:1;
        UINT32          PlcpSignal:12;
 }      RXINFO_STRUC, *PRXINFO_STRUC, RT28XX_RXD_STRUC, *PRT28XX_RXD_STRUC;
-#endif
-
 
 //
 // TXINFO
 //
-#ifdef RT_BIG_ENDIAN
-typedef        struct  _TXINFO_STRUC {
-       // Word 0
-       UINT32          USBDMATxburst:1;//used ONLY in USB bulk Aggre. Force USB DMA transmit frame from current selected endpoint
-       UINT32          USBDMANextVLD:1;        //used ONLY in USB bulk Aggregation, NextValid
-       UINT32          rsv2:2;  // Software use.
-       UINT32          SwUseLastRound:1; // Software use.
-       UINT32          QSEL:2; // select on-chip FIFO ID for 2nd-stage output scheduler.0:MGMT, 1:HCCA 2:EDCA
-       UINT32          WIV:1;  // Wireless Info Valid. 1 if Driver already fill WI,  o if DMA needs to copy WI to correctposition
-       UINT32          rsv:8;
-       UINT32          USBDMATxPktLen:16;      //used ONLY in USB bulk Aggregation,  Total byte counts of all sub-frame.
-}      TXINFO_STRUC, *PTXINFO_STRUC;
-#else
 typedef        struct  _TXINFO_STRUC {
        // Word 0
        UINT32          USBDMATxPktLen:16;      //used ONLY in USB bulk Aggregation,  Total byte counts of all sub-frame.
@@ -227,7 +119,6 @@ typedef     struct  _TXINFO_STRUC {
        UINT32          USBDMANextVLD:1;        //used ONLY in USB bulk Aggregation, NextValid
        UINT32          USBDMATxburst:1;//used ONLY in USB bulk Aggre. Force USB DMA transmit frame from current selected endpoint
 }      TXINFO_STRUC, *PTXINFO_STRUC;
-#endif
 
 #define TXINFO_SIZE                            4
 #define RXINFO_SIZE                            4
@@ -247,12 +138,14 @@ typedef   struct  _MGMT_STRUC     {
 #define RT28xx_EEPROM_READ16(pAd, offset, var)                                 \
        do {                                                                                                            \
                RTUSBReadEEPROM(pAd, offset, (PUCHAR)&(var), 2);                \
+               if(!pAd->bUseEfuse)                                                                             \
                var = le2cpu16(var);                                                                    \
        }while(0)
 
 #define RT28xx_EEPROM_WRITE16(pAd, offset, var)                                        \
        do{                                                                                                                     \
-               USHORT _tmpVar;                                                                                 \
+               USHORT _tmpVar=var;                                                                             \
+               if(!pAd->bUseEfuse)                                                                     \
                _tmpVar = cpu2le16(var);                                                                \
                RTUSBWriteEEPROM(pAd, offset, (PUCHAR)&(_tmpVar), 2);   \
        }while(0)
@@ -263,19 +156,8 @@ typedef    struct  _MGMT_STRUC     {
 
 
 /* ----------------- Frimware Related MACRO ----------------- */
-#if 0
-#define RT28XX_FIRMUD_INIT(pAd)                \
-       {       UINT32  MacReg;                         \
-               RTUSBReadMACRegister(pAd, MAC_CSR0, &MacReg); }
-
-#define RT28XX_FIRMUD_END(pAd) \
-       RTUSBWriteMACRegister(pAd, 0x7014, 0xffffffff); \
-       RTUSBWriteMACRegister(pAd, 0x701c, 0xffffffff); \
-       RTUSBFirmwareRun(pAd);
-#else
 #define RT28XX_WRITE_FIRMWARE(_pAd, _pFwImage, _FwLen)         \
        RTUSBFirmwareWrite(_pAd, _pFwImage, _FwLen)
-#endif
 
 /* ----------------- TX Related MACRO ----------------- */
 #define RT28XX_START_DEQUEUE(pAd, QueIdx, irqFlags)                            \
@@ -360,13 +242,6 @@ extern UCHAR EpToQueue[6];
 /* ----------------- RX Related MACRO ----------------- */
 //#define RT28XX_RX_ERROR_CHECK                                RTMPCheckRxWI
 
-#if 0
-#define RT28XX_RCV_INIT(pAd)                                   \
-       pAd->TransferBufferLength = 0;                          \
-       pAd->ReadPosition = 0;                                          \
-       pAd->pCurrRxContext = NULL;
-#endif
-
 #define RT28XX_RV_ALL_BUF_END(bBulkReceive)            \
        /* We return STATUS_MORE_PROCESSING_REQUIRED so that the completion */  \
        /* routine (IofCompleteRequest) will stop working on the irp. */                \
@@ -374,27 +249,6 @@ extern UCHAR EpToQueue[6];
 
 
 /* ----------------- ASIC Related MACRO ----------------- */
-#if 0
-#define RT28XX_DMA_WRITE_INIT(GloCfg)                  \
-       {       GloCfg.field.EnTXWriteBackDDONE = 1;    \
-               GloCfg.field.EnableRxDMA = 1;                   \
-               GloCfg.field.EnableTxDMA = 1; }
-
-#define RT28XX_DMA_POST_WRITE(_pAd)                            \
-       do{     USB_DMA_CFG_STRUC       UsbCfg;                         \
-               UsbCfg.word = 0;                                                \
-               /* for last packet, PBF might use more than limited, so minus 2 to prevent from error */ \
-               UsbCfg.field.RxBulkAggLmt = (MAX_RXBULK_SIZE /1024)-3;  \
-               UsbCfg.field.phyclear = 0;                                                              \
-               /* usb version is 1.1,do not use bulk in aggregation */ \
-               if (_pAd->BulkInMaxPacketSize == 512)                                   \
-                       UsbCfg.field.RxBulkAggEn = 1;                                           \
-               UsbCfg.field.RxBulkEn = 1;                                                              \
-               UsbCfg.field.TxBulkEn = 1;                                                              \
-               UsbCfg.field.RxBulkAggTOut = 0x80; /* 2006-10-18 */             \
-               RTUSBWriteMACRegister(_pAd, USB_DMA_CFG, UsbCfg.word);  \
-       }while(0)
-#endif
 
 // reset MAC of a station entry to 0xFFFFFFFFFFFF
 #define RT28XX_STA_ENTRY_MAC_RESET(pAd, Wcid)                                  \
@@ -495,7 +349,11 @@ extern UCHAR EpToQueue[6];
        {       RTUSB_SET_BULK_FLAG(pAd, fRTUSB_BULK_OUT_PSPOLL);       \
                RTUSBKickBulkOut(pAd); }
 
+#ifdef RT30xx
+#define RT28xx_CHIP_NAME            "RT3070"
+#else
 #define RT28xx_CHIP_NAME            "RT2870"
+#endif
 #define USB_CYC_CFG                 0x02a4
 #define STATUS_SUCCESS                         0x00
 #define STATUS_UNSUCCESSFUL            0x01
@@ -523,7 +381,6 @@ extern UCHAR EpToQueue[6];
 //#undef MlmeAllocateMemory
 //#undef MlmeFreeMemory
 
-typedef int                            NTSTATUS;
 typedef struct usb_device      * PUSB_DEV;
 
 /* MACRO for linux usb */
@@ -551,24 +408,20 @@ VOID RTUSBBulkOutRTSFrameComplete(purbb_t pUrb, struct pt_regs *pt_regs);
 VOID RTUSBBulkOutPsPollComplete(purbb_t pUrb, struct pt_regs *pt_regs);
 VOID RTUSBBulkRxComplete(purbb_t pUrb, struct pt_regs *pt_regs);
 
-
 #define RTUSBMlmeUp(pAd)               \
 {                                                                  \
        POS_COOKIE pObj = (POS_COOKIE) pAd->OS_Cookie;  \
-       BUG_ON(pObj->MLMEThr_task == NULL);                 \
-       CHECK_PID_LEGALITY(task_pid(pObj->MLMEThr_task))                    \
+       if (pid_nr(pObj->MLMEThr_pid) > 0) \
         up(&(pAd->mlme_semaphore)); \
 }
 
 #define RTUSBCMDUp(pAd)                        \
 {                                                                          \
        POS_COOKIE pObj = (POS_COOKIE) pAd->OS_Cookie;  \
-       BUG_ON(pObj->RTUSBCmdThr_task == NULL);     \
-       CHECK_PID_LEGALITY(task_pid(pObj->RTUSBCmdThr_task))        \
+       if (pid_nr(pObj->RTUSBCmdThr_pid) > 0) \
            up(&(pAd->RTUSBCmd_semaphore)); \
 }
 
-
 static inline NDIS_STATUS RTMPAllocateMemory(
        OUT PVOID *ptr,
        IN size_t size)
@@ -609,7 +462,9 @@ typedef struct   _RT_SET_ASIC_WCID {
        ULONG WCID;          // mechanism for rekeying: 0:disable, 1: time-based, 2: packet-based
        ULONG SetTid;        // time-based: seconds, packet-based: kilo-packets
        ULONG DeleteTid;        // time-based: seconds, packet-based: kilo-packets
+#ifndef RT30xx
        UCHAR Addr[MAC_ADDR_LEN];       // avoid in interrupt when write key
+#endif
 } RT_SET_ASIC_WCID,*PRT_SET_ASIC_WCID;
 
 typedef struct   _RT_SET_ASIC_WCID_ATTRI {
@@ -652,13 +507,6 @@ typedef    struct  _CmdQ   {
        UINT32          CmdQState;
 }CmdQ, *PCmdQ;
 
-//
-// For WPA SUPPLICANT: WIRELESS EXT support wireless events: v14 or newer
-//
-#if WIRELESS_EXT >= 14
-//#define WPA_SUPPLICANT_SUPPORT  1
-#endif
-
 /* oid.h */
 // Cipher suite type for mixed mode group cipher, P802.11i-2004
 typedef enum _RT_802_11_CIPHER_SUITE_TYPE {
@@ -709,15 +557,13 @@ typedef   struct  _CMDHandler_TLV {
 #define CMDTHREAD_SET_ASIC_WCID                     0x0D730226 // cmd
 #define CMDTHREAD_SET_ASIC_WCID_CIPHER              0x0D730227 // cmd
 #define CMDTHREAD_QKERIODIC_EXECUT                  0x0D73023D // cmd
-#define RT_CMD_SET_KEY_TABLE                        0x0D730228  // cmd
-#define RT_CMD_SET_RX_WCID_TABLE                    0x0D730229  // cmd
 #define CMDTHREAD_SET_CLIENT_MAC_ENTRY              0x0D73023E // cmd
 #define CMDTHREAD_802_11_QUERY_HARDWARE_REGISTER    0x0D710105 // cmd
 #define CMDTHREAD_802_11_SET_PHY_MODE               0x0D79010C // cmd
 #define CMDTHREAD_802_11_SET_STA_CONFIG             0x0D790111 // cmd
 #define CMDTHREAD_802_11_SET_PREAMBLE               0x0D790101 // cmd
 #define CMDTHREAD_802_11_COUNTER_MEASURE                       0x0D790102      // cmd
-
+#define CMDTHREAD_UPDATE_PROTECT                                       0x0D790103      // cmd
 
 #define WPA1AKMBIT         0x01
 #define WPA2AKMBIT         0x02