staging: brcm80211: removed last typedefs from fullmac
[deliverable/linux.git] / drivers / staging / brcm80211 / brcmfmac / bcmsdbus.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 _sdio_api_h_
18 #define _sdio_api_h_
19
20 #include "sdio_host.h"
21
22 #define SDIOH_READ 0 /* Read request */
23 #define SDIOH_WRITE 1 /* Write request */
24
25 #define SDIOH_DATA_FIX 0 /* Fixed addressing */
26 #define SDIOH_DATA_INC 1 /* Incremental addressing */
27
28 #define SDIOH_CMD_TYPE_NORMAL 0 /* Normal command */
29 #define SDIOH_CMD_TYPE_APPEND 1 /* Append command */
30 #define SDIOH_CMD_TYPE_CUTTHRU 2 /* Cut-through command */
31
32 #define SDIOH_DATA_PIO 0 /* PIO mode */
33 #define SDIOH_DATA_DMA 1 /* DMA mode */
34
35 /* internal return code */
36 #define SUCCESS 0
37 #define ERROR 1
38
39 /* Common msglevel constants */
40 #define SDH_ERROR_VAL 0x0001 /* Error */
41 #define SDH_TRACE_VAL 0x0002 /* Trace */
42 #define SDH_INFO_VAL 0x0004 /* Info */
43 #define SDH_DEBUG_VAL 0x0008 /* Debug */
44 #define SDH_DATA_VAL 0x0010 /* Data */
45 #define SDH_CTRL_VAL 0x0020 /* Control Regs */
46 #define SDH_LOG_VAL 0x0040 /* Enable bcmlog */
47 #define SDH_DMA_VAL 0x0080 /* DMA */
48
49 #ifdef BCMDBG
50 #define sd_err(x) \
51 do { \
52 if ((sd_msglevel & SDH_ERROR_VAL) && net_ratelimit()) \
53 printk x; \
54 } while (0)
55 #define sd_trace(x) \
56 do { \
57 if ((sd_msglevel & SDH_TRACE_VAL) && net_ratelimit()) \
58 printk x; \
59 } while (0)
60 #define sd_info(x) \
61 do { \
62 if ((sd_msglevel & SDH_INFO_VAL) && net_ratelimit()) \
63 printk x; \
64 } while (0)
65 #define sd_debug(x) \
66 do { \
67 if ((sd_msglevel & SDH_DEBUG_VAL) && net_ratelimit()) \
68 printk x; \
69 } while (0)
70 #define sd_data(x) \
71 do { \
72 if ((sd_msglevel & SDH_DATA_VAL) && net_ratelimit()) \
73 printk x; \
74 } while (0)
75 #define sd_ctrl(x) \
76 do { \
77 if ((sd_msglevel & SDH_CTRL_VAL) && net_ratelimit()) \
78 printk x; \
79 } while (0)
80 #else
81 #define sd_err(x)
82 #define sd_trace(x)
83 #define sd_info(x)
84 #define sd_debug(x)
85 #define sd_data(x)
86 #define sd_ctrl(x)
87 #endif
88
89 struct brcmf_sdreg {
90 int func;
91 int offset;
92 int value;
93 };
94
95 struct sdioh_info {
96 struct osl_info *osh; /* osh handler */
97 bool client_intr_enabled; /* interrupt connnected flag */
98 bool intr_handler_valid; /* client driver interrupt handler valid */
99 void (*intr_handler)(void *); /* registered interrupt handler */
100 void *intr_handler_arg; /* argument to call interrupt handler */
101 u16 intmask; /* Current active interrupts */
102 void *sdos_info; /* Pointer to per-OS private data */
103
104 uint irq; /* Client irq */
105 int intrcount; /* Client interrupts */
106 bool sd_blockmode; /* sd_blockmode == false => 64 Byte Cmd 53s. */
107 /* Must be on for sd_multiblock to be effective */
108 bool use_client_ints; /* If this is false, make sure to restore */
109 int client_block_size[SDIOD_MAX_IOFUNCS]; /* Blocksize */
110 u8 num_funcs; /* Supported funcs on client */
111 u32 com_cis_ptr;
112 u32 func_cis_ptr[SDIOD_MAX_IOFUNCS];
113 uint max_dma_len;
114 uint max_dma_descriptors; /* DMA Descriptors supported by this controller. */
115 /* SDDMA_DESCRIPTOR SGList[32]; *//* Scatter/Gather DMA List */
116 };
117
118 struct brcmf_sdmmc_instance {
119 struct sdioh_info *sd;
120 struct sdio_func *func[SDIOD_MAX_IOFUNCS];
121 u32 host_claimed;
122 };
123
124 /* Allocate/init/free per-OS private data */
125 extern int brcmf_sdioh_osinit(struct sdioh_info *sd);
126 extern void brcmf_sdioh_osfree(struct sdioh_info *sd);
127
128 /* OS-independent interrupt handler */
129 extern bool brcmf_sdioh_check_client_intr(struct sdioh_info *sd);
130
131 /* Core interrupt enable/disable of device interrupts */
132 extern void brcmf_sdioh_dev_intr_on(struct sdioh_info *sd);
133 extern void brcmf_sdioh_dev_intr_off(struct sdioh_info *sd);
134
135 /* Register mapping routines */
136 extern u32 *brcmf_sdioh_reg_map(s32 addr, int size);
137 extern void brcmf_sdioh_reg_unmap(s32 addr, int size);
138
139 /* Interrupt (de)registration routines */
140 extern int brcmf_sdioh_register_irq(struct sdioh_info *sd, uint irq);
141 extern void brcmf_sdioh_free_irq(uint irq, struct sdioh_info *sd);
142
143 /* attach, return handler on success, NULL if failed.
144 * The handler shall be provided by all subsequent calls. No local cache
145 * cfghdl points to the starting address of pci device mapped memory
146 */
147 extern struct sdioh_info *brcmf_sdioh_attach(void *cfghdl, uint irq);
148 extern int brcmf_sdioh_detach(struct sdioh_info *si);
149
150 extern int
151 brcmf_sdioh_interrupt_register(struct sdioh_info *si,
152 void (*sdioh_cb_fn)(void *), void *argh);
153
154 extern int brcmf_sdioh_interrupt_deregister(struct sdioh_info *si);
155
156 /* query whether SD interrupt is enabled or not */
157 extern int
158 brcmf_sdioh_interrupt_query(struct sdioh_info *si, bool *onoff);
159
160 /* enable or disable SD interrupt */
161 extern int
162 brcmf_sdioh_interrupt_set(struct sdioh_info *si, bool enable_disable);
163
164 /* read or write one byte using cmd52 */
165 extern int
166 brcmf_sdioh_request_byte(struct sdioh_info *si, uint rw, uint fnc, uint addr,
167 u8 *byte);
168
169 /* read or write 2/4 bytes using cmd53 */
170 extern int
171 brcmf_sdioh_request_word(struct sdioh_info *si, uint cmd_type,
172 uint rw, uint fnc, uint addr,
173 u32 *word, uint nbyte);
174
175 /* read or write any buffer using cmd53 */
176 extern int
177 brcmf_sdioh_request_buffer(struct sdioh_info *si, uint pio_dma,
178 uint fix_inc, uint rw, uint fnc_num,
179 u32 addr, uint regwidth,
180 u32 buflen, u8 *buffer, struct sk_buff *pkt);
181
182 /* get cis data */
183 extern int
184 brcmf_sdioh_cis_read(struct sdioh_info *si, uint fuc, u8 *cis, u32 length);
185
186 extern int
187 brcmf_sdioh_cfg_read(struct sdioh_info *si, uint fuc, u32 addr, u8 *data);
188 extern int
189 brcmf_sdioh_cfg_write(struct sdioh_info *si, uint fuc, u32 addr, u8 *data);
190
191 /* query number of io functions */
192 extern uint brcmf_sdioh_query_iofnum(struct sdioh_info *si);
193
194 /* handle iovars */
195 extern int brcmf_sdioh_iovar_op(struct sdioh_info *si, const char *name,
196 void *params, int plen, void *arg, int len, bool set);
197
198 /* Issue abort to the specified function and clear controller as needed */
199 extern int brcmf_sdioh_abort(struct sdioh_info *si, uint fnc);
200
201 /* Helper function */
202 void *brcmf_sdcard_get_sdioh(struct brcmf_sdio_card *card);
203
204 /* Watchdog timer interface for pm ops */
205 extern void brcmf_sdio_wdtmr_enable(bool enable);
206
207 extern uint sd_msglevel; /* Debug message level */
208
209 extern struct brcmf_sdmmc_instance *gInstance;
210
211 #endif /* _sdio_api_h_ */
This page took 0.037582 seconds and 5 git commands to generate.