Merge branch 'for-linus' of git://git.kernel.dk/linux-block
[pandora-kernel.git] / drivers / staging / brcm80211 / brcmfmac / dhd_sdio.c
index 077cb49..7fa95b6 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/printk.h>
 #include <linux/pci_ids.h>
 #include <linux/netdevice.h>
+#include <linux/interrupt.h>
 #include <linux/sched.h>
 #include <linux/mmc/sdio.h>
 #include <linux/mmc/sdio_func.h>
@@ -32,7 +33,6 @@
 #include <brcm_hw_ids.h>
 #include <soc.h>
 #include "sdio_host.h"
-#include "bcmsdbus.h"
 
 /* register access macros */
 #ifndef __BIG_ENDIAN
@@ -150,9 +150,6 @@ struct rte_console {
 #endif                         /* BCMDBG */
 #include <chipcommon.h>
 
-#include "sbsdio.h"
-
-#include "dngl_stats.h"
 #include "dhd.h"
 #include "dhd_bus.h"
 #include "dhd_proto.h"
@@ -182,10 +179,107 @@ struct rte_console {
 #ifndef BRCMF_FIRSTREAD
 #define BRCMF_FIRSTREAD        32
 #endif
+
 #if !ISPOWEROF2(BRCMF_FIRSTREAD)
 #error BRCMF_FIRSTREAD is not a power of 2!
 #endif
 
+/* SBSDIO_DEVICE_CTL */
+#define SBSDIO_DEVCTL_SETBUSY          0x01    /* 1: device will assert busy signal when
+                                                * receiving CMD53
+                                                */
+#define SBSDIO_DEVCTL_SPI_INTR_SYNC    0x02    /* 1: assertion of sdio interrupt is
+                                                * synchronous to the sdio clock
+                                                */
+#define SBSDIO_DEVCTL_CA_INT_ONLY      0x04    /* 1: mask all interrupts to host
+                                                * except the chipActive (rev 8)
+                                                */
+#define SBSDIO_DEVCTL_PADS_ISO         0x08    /* 1: isolate internal sdio signals, put
+                                                * external pads in tri-state; requires
+                                                * sdio bus power cycle to clear (rev 9)
+                                                */
+#define SBSDIO_DEVCTL_SB_RST_CTL       0x30    /* Force SD->SB reset mapping (rev 11) */
+#define SBSDIO_DEVCTL_RST_CORECTL      0x00    /*   Determined by CoreControl bit */
+#define SBSDIO_DEVCTL_RST_BPRESET      0x10    /*   Force backplane reset */
+#define SBSDIO_DEVCTL_RST_NOBPRESET    0x20    /*   Force no backplane reset */
+
+/* SBSDIO_FUNC1_CHIPCLKCSR */
+#define SBSDIO_FORCE_ALP               0x01    /* Force ALP request to backplane */
+#define SBSDIO_FORCE_HT                        0x02    /* Force HT request to backplane */
+#define SBSDIO_FORCE_ILP               0x04    /* Force ILP request to backplane */
+#define SBSDIO_ALP_AVAIL_REQ           0x08    /* Make ALP ready (power up xtal) */
+#define SBSDIO_HT_AVAIL_REQ            0x10    /* Make HT ready (power up PLL) */
+#define SBSDIO_FORCE_HW_CLKREQ_OFF     0x20    /* Squelch clock requests from HW */
+#define SBSDIO_ALP_AVAIL               0x40    /* Status: ALP is ready */
+#define SBSDIO_HT_AVAIL                        0x80    /* Status: HT is ready */
+
+#define SBSDIO_AVBITS                  (SBSDIO_HT_AVAIL | SBSDIO_ALP_AVAIL)
+#define SBSDIO_ALPAV(regval)           ((regval) & SBSDIO_AVBITS)
+#define SBSDIO_HTAV(regval)            (((regval) & SBSDIO_AVBITS) == SBSDIO_AVBITS)
+#define SBSDIO_ALPONLY(regval)         (SBSDIO_ALPAV(regval) && !SBSDIO_HTAV(regval))
+#define SBSDIO_CLKAV(regval, alponly)  (SBSDIO_ALPAV(regval) && \
+                                       (alponly ? 1 : SBSDIO_HTAV(regval)))
+/* direct(mapped) cis space */
+#define SBSDIO_CIS_BASE_COMMON         0x1000  /* MAPPED common CIS address */
+#define SBSDIO_CIS_SIZE_LIMIT          0x200   /* maximum bytes in one CIS */
+#define SBSDIO_CIS_OFT_ADDR_MASK       0x1FFFF /* cis offset addr is < 17 bits */
+
+#define SBSDIO_CIS_MANFID_TUPLE_LEN    6       /* manfid tuple length, include tuple,
+                                                * link bytes
+                                                */
+
+/* intstatus */
+#define I_SMB_SW0      (1 << 0)        /* To SB Mail S/W interrupt 0 */
+#define I_SMB_SW1      (1 << 1)        /* To SB Mail S/W interrupt 1 */
+#define I_SMB_SW2      (1 << 2)        /* To SB Mail S/W interrupt 2 */
+#define I_SMB_SW3      (1 << 3)        /* To SB Mail S/W interrupt 3 */
+#define I_SMB_SW_MASK  0x0000000f      /* To SB Mail S/W interrupts mask */
+#define I_SMB_SW_SHIFT 0       /* To SB Mail S/W interrupts shift */
+#define I_HMB_SW0      (1 << 4)        /* To Host Mail S/W interrupt 0 */
+#define I_HMB_SW1      (1 << 5)        /* To Host Mail S/W interrupt 1 */
+#define I_HMB_SW2      (1 << 6)        /* To Host Mail S/W interrupt 2 */
+#define I_HMB_SW3      (1 << 7)        /* To Host Mail S/W interrupt 3 */
+#define I_HMB_SW_MASK  0x000000f0      /* To Host Mail S/W interrupts mask */
+#define I_HMB_SW_SHIFT 4       /* To Host Mail S/W interrupts shift */
+#define I_WR_OOSYNC    (1 << 8)        /* Write Frame Out Of Sync */
+#define I_RD_OOSYNC    (1 << 9)        /* Read Frame Out Of Sync */
+#define        I_PC            (1 << 10)       /* descriptor error */
+#define        I_PD            (1 << 11)       /* data error */
+#define        I_DE            (1 << 12)       /* Descriptor protocol Error */
+#define        I_RU            (1 << 13)       /* Receive descriptor Underflow */
+#define        I_RO            (1 << 14)       /* Receive fifo Overflow */
+#define        I_XU            (1 << 15)       /* Transmit fifo Underflow */
+#define        I_RI            (1 << 16)       /* Receive Interrupt */
+#define I_BUSPWR       (1 << 17)       /* SDIO Bus Power Change (rev 9) */
+#define I_XMTDATA_AVAIL (1 << 23)      /* bits in fifo */
+#define        I_XI            (1 << 24)       /* Transmit Interrupt */
+#define I_RF_TERM      (1 << 25)       /* Read Frame Terminate */
+#define I_WF_TERM      (1 << 26)       /* Write Frame Terminate */
+#define I_PCMCIA_XU    (1 << 27)       /* PCMCIA Transmit FIFO Underflow */
+#define I_SBINT                (1 << 28)       /* sbintstatus Interrupt */
+#define I_CHIPACTIVE   (1 << 29)       /* chip from doze to active state */
+#define I_SRESET       (1 << 30)       /* CCCR RES interrupt */
+#define I_IOE2         (1U << 31)      /* CCCR IOE2 Bit Changed */
+#define        I_ERRORS        (I_PC | I_PD | I_DE | I_RU | I_RO | I_XU)
+#define I_DMA          (I_RI | I_XI | I_ERRORS)
+
+/* corecontrol */
+#define CC_CISRDY              (1 << 0)        /* CIS Ready */
+#define CC_BPRESEN             (1 << 1)        /* CCCR RES signal */
+#define CC_F2RDY               (1 << 2)        /* set CCCR IOR2 bit */
+#define CC_CLRPADSISO          (1 << 3)        /* clear SDIO pads isolation */
+#define CC_XMTDATAAVAIL_MODE   (1 << 4)
+#define CC_XMTDATAAVAIL_CTRL   (1 << 5)
+
+/* SDA_FRAMECTRL */
+#define SFC_RF_TERM    (1 << 0)        /* Read Frame Terminate */
+#define SFC_WF_TERM    (1 << 1)        /* Write Frame Terminate */
+#define SFC_CRC4WOOS   (1 << 2)        /* CRC error for write out of sync */
+#define SFC_ABORTALL   (1 << 3)        /* Abort all in-progress frames */
+
+/* HW frame tag */
+#define SDPCM_FRAMETAG_LEN     4       /* 2 bytes len, 2 bytes check val */
+
 /* Total length of frame header for dongle protocol */
 #define SDPCM_HDRLEN   (SDPCM_FRAMETAG_LEN + SDPCM_SWHEADER_LEN)
 #ifdef SDTEST