staging: brcm80211: remove usage of printf (macro) from driver
[deliverable/linux.git] / drivers / staging / brcm80211 / include / bcmsdh.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_h_
18 #define _bcmsdh_h_
19
20 #include <linux/skbuff.h>
21 #define BCMSDH_ERROR_VAL 0x0001 /* Error */
22 #define BCMSDH_INFO_VAL 0x0002 /* Info */
23 extern const uint bcmsdh_msglevel;
24
25 #ifdef BCMDBG
26 #define BCMSDH_ERROR(x) \
27 do { \
28 if ((bcmsdh_msglevel & BCMSDH_ERROR_VAL) && net_ratelimit()) \
29 printk x; \
30 } while (0)
31 #define BCMSDH_INFO(x) \
32 do { \
33 if ((bcmsdh_msglevel & BCMSDH_INFO_VAL) && net_ratelimit()) \
34 printk x; \
35 } while (0)
36 #else /* BCMDBG */
37 #define BCMSDH_ERROR(x)
38 #define BCMSDH_INFO(x)
39 #endif /* BCMDBG */
40
41 /* forward declarations */
42 typedef struct bcmsdh_info bcmsdh_info_t;
43 typedef void (*bcmsdh_cb_fn_t) (void *);
44
45 /* Attach and build an interface to the underlying SD host driver.
46 * - Allocates resources (structs, arrays, mem, OS handles, etc) needed by bcmsdh.
47 * - Returns the bcmsdh handle and virtual address base for register access.
48 * The returned handle should be used in all subsequent calls, but the bcmsh
49 * implementation may maintain a single "default" handle (e.g. the first or
50 * most recent one) to enable single-instance implementations to pass NULL.
51 */
52 extern bcmsdh_info_t *bcmsdh_attach(struct osl_info *osh, void *cfghdl,
53 void **regsva, uint irq);
54
55 /* Detach - freeup resources allocated in attach */
56 extern int bcmsdh_detach(struct osl_info *osh, void *sdh);
57
58 /* Query if SD device interrupts are enabled */
59 extern bool bcmsdh_intr_query(void *sdh);
60
61 /* Enable/disable SD interrupt */
62 extern int bcmsdh_intr_enable(void *sdh);
63 extern int bcmsdh_intr_disable(void *sdh);
64
65 /* Register/deregister device interrupt handler. */
66 extern int bcmsdh_intr_reg(void *sdh, bcmsdh_cb_fn_t fn, void *argh);
67 extern int bcmsdh_intr_dereg(void *sdh);
68
69 #if defined(DHD_DEBUG)
70 /* Query pending interrupt status from the host controller */
71 extern bool bcmsdh_intr_pending(void *sdh);
72 #endif
73 extern int bcmsdh_claim_host_and_lock(void *sdh);
74 extern int bcmsdh_release_host_and_unlock(void *sdh);
75
76 /* Register a callback to be called if and when bcmsdh detects
77 * device removal. No-op in the case of non-removable/hardwired devices.
78 */
79 extern int bcmsdh_devremove_reg(void *sdh, bcmsdh_cb_fn_t fn, void *argh);
80
81 /* Access SDIO address space (e.g. CCCR) using CMD52 (single-byte interface).
82 * fn: function number
83 * addr: unmodified SDIO-space address
84 * data: data byte to write
85 * err: pointer to error code (or NULL)
86 */
87 extern u8 bcmsdh_cfg_read(void *sdh, uint func, u32 addr, int *err);
88 extern void bcmsdh_cfg_write(void *sdh, uint func, u32 addr, u8 data,
89 int *err);
90
91 /* Read/Write 4bytes from/to cfg space */
92 extern u32 bcmsdh_cfg_read_word(void *sdh, uint fnc_num, u32 addr,
93 int *err);
94 extern void bcmsdh_cfg_write_word(void *sdh, uint fnc_num, u32 addr,
95 u32 data, int *err);
96
97 /* Read CIS content for specified function.
98 * fn: function whose CIS is being requested (0 is common CIS)
99 * cis: pointer to memory location to place results
100 * length: number of bytes to read
101 * Internally, this routine uses the values from the cis base regs (0x9-0xB)
102 * to form an SDIO-space address to read the data from.
103 */
104 extern int bcmsdh_cis_read(void *sdh, uint func, u8 *cis, uint length);
105
106 /* Synchronous access to device (client) core registers via CMD53 to F1.
107 * addr: backplane address (i.e. >= regsva from attach)
108 * size: register width in bytes (2 or 4)
109 * data: data for register write
110 */
111 extern u32 bcmsdh_reg_read(void *sdh, u32 addr, uint size);
112 extern u32 bcmsdh_reg_write(void *sdh, u32 addr, uint size, u32 data);
113
114 /* Indicate if last reg read/write failed */
115 extern bool bcmsdh_regfail(void *sdh);
116
117 /* Buffer transfer to/from device (client) core via cmd53.
118 * fn: function number
119 * addr: backplane address (i.e. >= regsva from attach)
120 * flags: backplane width, address increment, sync/async
121 * buf: pointer to memory data buffer
122 * nbytes: number of bytes to transfer to/from buf
123 * pkt: pointer to packet associated with buf (if any)
124 * complete: callback function for command completion (async only)
125 * handle: handle for completion callback (first arg in callback)
126 * Returns 0 or error code.
127 * NOTE: Async operation is not currently supported.
128 */
129 typedef void (*bcmsdh_cmplt_fn_t) (void *handle, int status, bool sync_waiting);
130 extern int bcmsdh_send_buf(void *sdh, u32 addr, uint fn, uint flags,
131 u8 *buf, uint nbytes, void *pkt,
132 bcmsdh_cmplt_fn_t complete, void *handle);
133 extern int bcmsdh_recv_buf(void *sdh, u32 addr, uint fn, uint flags,
134 u8 *buf, uint nbytes, struct sk_buff *pkt,
135 bcmsdh_cmplt_fn_t complete, void *handle);
136
137 /* Flags bits */
138 #define SDIO_REQ_4BYTE 0x1 /* Four-byte target (backplane) width (vs. two-byte) */
139 #define SDIO_REQ_FIXED 0x2 /* Fixed address (FIFO) (vs. incrementing address) */
140 #define SDIO_REQ_ASYNC 0x4 /* Async request (vs. sync request) */
141
142 /* Pending (non-error) return code */
143 #define BCME_PENDING 1
144
145 /* Read/write to memory block (F1, no FIFO) via CMD53 (sync only).
146 * rw: read or write (0/1)
147 * addr: direct SDIO address
148 * buf: pointer to memory data buffer
149 * nbytes: number of bytes to transfer to/from buf
150 * Returns 0 or error code.
151 */
152 extern int bcmsdh_rwdata(void *sdh, uint rw, u32 addr, u8 *buf,
153 uint nbytes);
154
155 /* Issue an abort to the specified function */
156 extern int bcmsdh_abort(void *sdh, uint fn);
157
158 /* Start SDIO Host Controller communication */
159 extern int bcmsdh_start(void *sdh, int stage);
160
161 /* Stop SDIO Host Controller communication */
162 extern int bcmsdh_stop(void *sdh);
163
164 /* Returns the "Device ID" of target device on the SDIO bus. */
165 extern int bcmsdh_query_device(void *sdh);
166
167 /* Returns the number of IO functions reported by the device */
168 extern uint bcmsdh_query_iofnum(void *sdh);
169
170 /* Miscellaneous knob tweaker. */
171 extern int bcmsdh_iovar_op(void *sdh, const char *name,
172 void *params, int plen, void *arg, int len,
173 bool set);
174
175 /* Reset and reinitialize the device */
176 extern int bcmsdh_reset(bcmsdh_info_t *sdh);
177
178 /* helper functions */
179
180 extern void *bcmsdh_get_sdioh(bcmsdh_info_t *sdh);
181
182 /* callback functions */
183 typedef struct {
184 /* attach to device */
185 void *(*attach) (u16 vend_id, u16 dev_id, u16 bus, u16 slot,
186 u16 func, uint bustype, void *regsva,
187 struct osl_info *osh, void *param);
188 /* detach from device */
189 void (*detach) (void *ch);
190 } bcmsdh_driver_t;
191
192 /* platform specific/high level functions */
193 extern int bcmsdh_register(bcmsdh_driver_t *driver);
194 extern void bcmsdh_unregister(void);
195 extern bool bcmsdh_chipmatch(u16 vendor, u16 device);
196 extern void bcmsdh_device_remove(void *sdh);
197
198 /* Function to pass device-status bits to DHD. */
199 extern u32 bcmsdh_get_dstatus(void *sdh);
200
201 /* Function to return current window addr */
202 extern u32 bcmsdh_cur_sbwad(void *sdh);
203
204 /* Function to pass chipid and rev to lower layers for controlling pr's */
205 extern void bcmsdh_chipinfo(void *sdh, u32 chip, u32 chiprev);
206
207 #endif /* _bcmsdh_h_ */
This page took 0.036822 seconds and 5 git commands to generate.