CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
orangepi-xunlong

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

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