aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/bcmdhd/include/bcmsdh.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/bcmdhd/include/bcmsdh.h')
-rw-r--r--drivers/net/wireless/bcmdhd/include/bcmsdh.h211
1 files changed, 211 insertions, 0 deletions
diff --git a/drivers/net/wireless/bcmdhd/include/bcmsdh.h b/drivers/net/wireless/bcmdhd/include/bcmsdh.h
new file mode 100644
index 00000000000..4e3affde6b0
--- /dev/null
+++ b/drivers/net/wireless/bcmdhd/include/bcmsdh.h
@@ -0,0 +1,211 @@
1/*
2 * SDIO host client driver interface of Broadcom HNBU
3 * export functions to client drivers
4 * abstract OS and BUS specific details of SDIO
5 *
6 * Copyright (C) 1999-2011, Broadcom Corporation
7 *
8 * Unless you and Broadcom execute a separate written software license
9 * agreement governing use of this software, this software is licensed to you
10 * under the terms of the GNU General Public License version 2 (the "GPL"),
11 * available at http://www.broadcom.com/licenses/GPLv2.php, with the
12 * following added to such license:
13 *
14 * As a special exception, the copyright holders of this software give you
15 * permission to link this software with independent modules, and to copy and
16 * distribute the resulting executable under terms of your choice, provided that
17 * you also meet, for each linked independent module, the terms and conditions of
18 * the license of that module. An independent module is a module which is not
19 * derived from this software. The special exception does not apply to any
20 * modifications of the software.
21 *
22 * Notwithstanding the above, under no circumstances may you combine this
23 * software in any way with any other Broadcom software provided under a license
24 * other than the GPL, without Broadcom's express prior written consent.
25 *
26 * $Id: bcmsdh.h,v 13.46.52.3 2010-10-19 00:41:44 Exp $
27 */
28
29#ifndef _bcmsdh_h_
30#define _bcmsdh_h_
31
32#define BCMSDH_ERROR_VAL 0x0001 /* Error */
33#define BCMSDH_INFO_VAL 0x0002 /* Info */
34extern const uint bcmsdh_msglevel;
35
36#define BCMSDH_ERROR(x)
37#define BCMSDH_INFO(x)
38
39/* forward declarations */
40typedef struct bcmsdh_info bcmsdh_info_t;
41typedef void (*bcmsdh_cb_fn_t)(void *);
42
43/* Attach and build an interface to the underlying SD host driver.
44 * - Allocates resources (structs, arrays, mem, OS handles, etc) needed by bcmsdh.
45 * - Returns the bcmsdh handle and virtual address base for register access.
46 * The returned handle should be used in all subsequent calls, but the bcmsh
47 * implementation may maintain a single "default" handle (e.g. the first or
48 * most recent one) to enable single-instance implementations to pass NULL.
49 */
50extern bcmsdh_info_t *bcmsdh_attach(osl_t *osh, void *cfghdl, void **regsva, uint irq);
51
52/* Detach - freeup resources allocated in attach */
53extern int bcmsdh_detach(osl_t *osh, void *sdh);
54
55/* Query if SD device interrupts are enabled */
56extern bool bcmsdh_intr_query(void *sdh);
57
58/* Enable/disable SD interrupt */
59extern int bcmsdh_intr_enable(void *sdh);
60extern int bcmsdh_intr_disable(void *sdh);
61
62/* Register/deregister device interrupt handler. */
63extern int bcmsdh_intr_reg(void *sdh, bcmsdh_cb_fn_t fn, void *argh);
64extern int bcmsdh_intr_dereg(void *sdh);
65
66#if defined(DHD_DEBUG)
67/* Query pending interrupt status from the host controller */
68extern bool bcmsdh_intr_pending(void *sdh);
69#endif
70
71#ifdef BCMLXSDMMC
72extern int bcmsdh_claim_host_and_lock(void *sdh);
73extern int bcmsdh_release_host_and_unlock(void *sdh);
74#endif /* BCMLXSDMMC */
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 */
79extern 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 */
87extern uint8 bcmsdh_cfg_read(void *sdh, uint func, uint32 addr, int *err);
88extern void bcmsdh_cfg_write(void *sdh, uint func, uint32 addr, uint8 data, int *err);
89
90/* Read/Write 4bytes from/to cfg space */
91extern uint32 bcmsdh_cfg_read_word(void *sdh, uint fnc_num, uint32 addr, int *err);
92extern void bcmsdh_cfg_write_word(void *sdh, uint fnc_num, uint32 addr, uint32 data, int *err);
93
94/* Read CIS content for specified function.
95 * fn: function whose CIS is being requested (0 is common CIS)
96 * cis: pointer to memory location to place results
97 * length: number of bytes to read
98 * Internally, this routine uses the values from the cis base regs (0x9-0xB)
99 * to form an SDIO-space address to read the data from.
100 */
101extern int bcmsdh_cis_read(void *sdh, uint func, uint8 *cis, uint length);
102
103/* Synchronous access to device (client) core registers via CMD53 to F1.
104 * addr: backplane address (i.e. >= regsva from attach)
105 * size: register width in bytes (2 or 4)
106 * data: data for register write
107 */
108extern uint32 bcmsdh_reg_read(void *sdh, uint32 addr, uint size);
109extern uint32 bcmsdh_reg_write(void *sdh, uint32 addr, uint size, uint32 data);
110
111/* Indicate if last reg read/write failed */
112extern bool bcmsdh_regfail(void *sdh);
113
114/* Buffer transfer to/from device (client) core via cmd53.
115 * fn: function number
116 * addr: backplane address (i.e. >= regsva from attach)
117 * flags: backplane width, address increment, sync/async
118 * buf: pointer to memory data buffer
119 * nbytes: number of bytes to transfer to/from buf
120 * pkt: pointer to packet associated with buf (if any)
121 * complete: callback function for command completion (async only)
122 * handle: handle for completion callback (first arg in callback)
123 * Returns 0 or error code.
124 * NOTE: Async operation is not currently supported.
125 */
126typedef void (*bcmsdh_cmplt_fn_t)(void *handle, int status, bool sync_waiting);
127extern int bcmsdh_send_buf(void *sdh, uint32 addr, uint fn, uint flags,
128 uint8 *buf, uint nbytes, void *pkt,
129 bcmsdh_cmplt_fn_t complete, void *handle);
130extern int bcmsdh_recv_buf(void *sdh, uint32 addr, uint fn, uint flags,
131 uint8 *buf, uint nbytes, void *pkt,
132 bcmsdh_cmplt_fn_t complete, void *handle);
133
134/* Flags bits */
135#define SDIO_REQ_4BYTE 0x1 /* Four-byte target (backplane) width (vs. two-byte) */
136#define SDIO_REQ_FIXED 0x2 /* Fixed address (FIFO) (vs. incrementing address) */
137#define SDIO_REQ_ASYNC 0x4 /* Async request (vs. sync request) */
138
139/* Pending (non-error) return code */
140#define BCME_PENDING 1
141
142/* Read/write to memory block (F1, no FIFO) via CMD53 (sync only).
143 * rw: read or write (0/1)
144 * addr: direct SDIO address
145 * buf: pointer to memory data buffer
146 * nbytes: number of bytes to transfer to/from buf
147 * Returns 0 or error code.
148 */
149extern int bcmsdh_rwdata(void *sdh, uint rw, uint32 addr, uint8 *buf, uint nbytes);
150
151/* Issue an abort to the specified function */
152extern int bcmsdh_abort(void *sdh, uint fn);
153
154/* Start SDIO Host Controller communication */
155extern int bcmsdh_start(void *sdh, int stage);
156
157/* Stop SDIO Host Controller communication */
158extern int bcmsdh_stop(void *sdh);
159
160/* Wait system lock free */
161extern int bcmsdh_waitlockfree(void *sdh);
162
163/* Returns the "Device ID" of target device on the SDIO bus. */
164extern int bcmsdh_query_device(void *sdh);
165
166/* Returns the number of IO functions reported by the device */
167extern uint bcmsdh_query_iofnum(void *sdh);
168
169/* Miscellaneous knob tweaker. */
170extern int bcmsdh_iovar_op(void *sdh, const char *name,
171 void *params, int plen, void *arg, int len, bool set);
172
173/* Reset and reinitialize the device */
174extern int bcmsdh_reset(bcmsdh_info_t *sdh);
175
176/* helper functions */
177
178extern void *bcmsdh_get_sdioh(bcmsdh_info_t *sdh);
179
180/* callback functions */
181typedef struct {
182 /* attach to device */
183 void *(*attach)(uint16 vend_id, uint16 dev_id, uint16 bus, uint16 slot,
184 uint16 func, uint bustype, void * regsva, osl_t * osh,
185 void * param, void *dev);
186 /* detach from device */
187 void (*detach)(void *ch);
188} bcmsdh_driver_t;
189
190/* platform specific/high level functions */
191extern int bcmsdh_register(bcmsdh_driver_t *driver);
192extern void bcmsdh_unregister(void);
193extern bool bcmsdh_chipmatch(uint16 vendor, uint16 device);
194extern void bcmsdh_device_remove(void * sdh);
195
196#if defined(OOB_INTR_ONLY)
197extern int bcmsdh_register_oob_intr(void * dhdp);
198extern void bcmsdh_unregister_oob_intr(void);
199extern void bcmsdh_oob_intr_set(bool enable);
200#endif /* defined(OOB_INTR_ONLY) */
201/* Function to pass device-status bits to DHD. */
202extern uint32 bcmsdh_get_dstatus(void *sdh);
203
204/* Function to return current window addr */
205extern uint32 bcmsdh_cur_sbwad(void *sdh);
206
207/* Function to pass chipid and rev to lower layers for controlling pr's */
208extern void bcmsdh_chipinfo(void *sdh, uint32 chip, uint32 chiprev);
209
210
211#endif /* _bcmsdh_h_ */