Staging: Add initial release of brcm80211 - Broadcom 802.11n wireless LAN driver.
[linux-2.6-block.git] / drivers / staging / brcm80211 / include / bcmsdh_sdmmc.h
1 /*
2  * Copyright (c) 2010 Broadcom Corporation
3  *
4  * Permission to use, copy, modify, and/or distribute this software for any
5  * purpose with or without fee is hereby granted, provided that the above
6  * copyright notice and this permission notice appear in all copies.
7  *
8  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
11  * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
13  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
14  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15  */
16
17 #ifndef __BCMSDH_SDMMC_H__
18 #define __BCMSDH_SDMMC_H__
19
20 #ifdef BCMDBG
21 #define sd_err(x)       do { if ((sd_msglevel & SDH_ERROR_VAL) && net_ratelimit()) printf x; } while (0)
22 #define sd_trace(x)     do { if ((sd_msglevel & SDH_TRACE_VAL) && net_ratelimit()) printf x; } while (0)
23 #define sd_info(x)      do { if ((sd_msglevel & SDH_INFO_VAL) && net_ratelimit()) printf x; } while (0)
24 #define sd_debug(x)     do { if ((sd_msglevel & SDH_DEBUG_VAL) && net_ratelimit()) printf x; } while (0)
25 #define sd_data(x)      do { if ((sd_msglevel & SDH_DATA_VAL) && net_ratelimit()) printf x; } while (0)
26 #define sd_ctrl(x)      do { if ((sd_msglevel & SDH_CTRL_VAL) && net_ratelimit()) printf x; } while (0)
27 #else
28 #define sd_err(x)
29 #define sd_trace(x)
30 #define sd_info(x)
31 #define sd_debug(x)
32 #define sd_data(x)
33 #define sd_ctrl(x)
34 #endif
35
36 /* Allocate/init/free per-OS private data */
37 extern int sdioh_sdmmc_osinit(sdioh_info_t * sd);
38 extern void sdioh_sdmmc_osfree(sdioh_info_t * sd);
39
40 #define BLOCK_SIZE_64 64
41 #define BLOCK_SIZE_512 512
42
43 /* internal return code */
44 #define SUCCESS 0
45 #define ERROR   1
46
47 /* private bus modes */
48 #define SDIOH_MODE_SD4          2
49 #define CLIENT_INTR             0x100   /* Get rid of this! */
50
51 struct sdioh_info {
52         osl_t *osh;             /* osh handler */
53         bool client_intr_enabled;       /* interrupt connnected flag */
54         bool intr_handler_valid;        /* client driver interrupt handler valid */
55         sdioh_cb_fn_t intr_handler;     /* registered interrupt handler */
56         void *intr_handler_arg; /* argument to call interrupt handler */
57         uint16 intmask;         /* Current active interrupts */
58         void *sdos_info;        /* Pointer to per-OS private data */
59
60         uint irq;               /* Client irq */
61         int intrcount;          /* Client interrupts */
62         bool sd_use_dma;        /* DMA on CMD53 */
63         bool sd_blockmode;      /* sd_blockmode == FALSE => 64 Byte Cmd 53s. */
64         /*  Must be on for sd_multiblock to be effective */
65         bool use_client_ints;   /* If this is false, make sure to restore */
66         int sd_mode;            /* SD1/SD4/SPI */
67         int client_block_size[SDIOD_MAX_IOFUNCS];       /* Blocksize */
68         uint8 num_funcs;        /* Supported funcs on client */
69         uint32 com_cis_ptr;
70         uint32 func_cis_ptr[SDIOD_MAX_IOFUNCS];
71         uint max_dma_len;
72         uint max_dma_descriptors;       /* DMA Descriptors supported by this controller. */
73         /*      SDDMA_DESCRIPTOR        SGList[32]; *//* Scatter/Gather DMA List */
74 };
75
76 /************************************************************
77  * Internal interfaces: per-port references into bcmsdh_sdmmc.c
78  */
79
80 /* Global message bits */
81 extern uint sd_msglevel;
82
83 /* OS-independent interrupt handler */
84 extern bool check_client_intr(sdioh_info_t * sd);
85
86 /* Core interrupt enable/disable of device interrupts */
87 extern void sdioh_sdmmc_devintr_on(sdioh_info_t * sd);
88 extern void sdioh_sdmmc_devintr_off(sdioh_info_t * sd);
89
90 /**************************************************************
91  * Internal interfaces: bcmsdh_sdmmc.c references to per-port code
92  */
93
94 /* Register mapping routines */
95 extern uint32 *sdioh_sdmmc_reg_map(osl_t * osh, int32 addr, int size);
96 extern void sdioh_sdmmc_reg_unmap(osl_t * osh, int32 addr, int size);
97
98 /* Interrupt (de)registration routines */
99 extern int sdioh_sdmmc_register_irq(sdioh_info_t * sd, uint irq);
100 extern void sdioh_sdmmc_free_irq(uint irq, sdioh_info_t * sd);
101
102 typedef struct _BCMSDH_SDMMC_INSTANCE {
103         sdioh_info_t *sd;
104         struct sdio_func *func[SDIOD_MAX_IOFUNCS];
105         uint32 host_claimed;
106 } BCMSDH_SDMMC_INSTANCE, *PBCMSDH_SDMMC_INSTANCE;
107
108 #endif                          /* __BCMSDH_SDMMC_H__ */