Root/drivers/staging/csr/csr_sdio.h

1#ifndef CSR_SDIO_H__
2#define CSR_SDIO_H__
3/*****************************************************************************
4
5            (c) Cambridge Silicon Radio Limited 2010
6            All rights reserved and confidential information of CSR
7
8            Refer to LICENSE.txt included with this source for details
9            on the license terms.
10
11*****************************************************************************/
12
13#include "csr_result.h"
14
15#ifdef __cplusplus
16extern "C" {
17#endif
18
19/* Result Codes */
20#define CSR_SDIO_RESULT_INVALID_VALUE ((CsrResult) 1) /* Invalid argument value */
21#define CSR_SDIO_RESULT_NO_DEVICE ((CsrResult) 2) /* The specified device is no longer present */
22#define CSR_SDIO_RESULT_CRC_ERROR ((CsrResult) 3) /* The transmitted/received data or command response contained a CRC error */
23#define CSR_SDIO_RESULT_TIMEOUT ((CsrResult) 4) /* No command response or data received from device, or function enable/disable did not succeed within timeout period */
24#define CSR_SDIO_RESULT_NOT_RESET ((CsrResult) 5) /* The device was not reset */
25
26/* Features (for use in features member of CsrSdioFunction) */
27#define CSR_SDIO_FEATURE_BYTE_MODE 0x00000001 /* Transfer sizes do not have to be a multiple of block size */
28#define CSR_SDIO_FEATURE_DMA_CAPABLE_MEM_REQUIRED 0x00000002 /* Bulk operations require DMA friendly memory */
29
30/* CsrSdioFunctionId wildcards (for use in CsrSdioFunctionId members) */
31#define CSR_SDIO_ANY_MANF_ID 0xFFFF
32#define CSR_SDIO_ANY_CARD_ID 0xFFFF
33#define CSR_SDIO_ANY_SDIO_FUNCTION 0xFF
34#define CSR_SDIO_ANY_SDIO_INTERFACE 0xFF
35
36/*----------------------------------------------------------------------------*
37 * NAME
38 * CsrSdioFunctionId
39 *
40 * DESCRIPTION
41 * This structure describes one or more functions of a device, based on
42 * four qualitative measures. The CsrSdioFunctionId wildcard defines can be
43 * used for making the CsrSdioFunctionId match more than one function.
44 *
45 * MEMBERS
46 * manfId - Vendor ID (or CSR_SDIO_ANY_MANF_ID).
47 * cardId - Device ID (or CSR_SDIO_ANY_CARD_ID).
48 * sdioFunction - SDIO Function number (or CSR_SDIO_ANY_SDIO_FUNCTION).
49 * sdioInterface - SDIO Standard Interface Code (or CSR_SDIO_ANY_SDIO_INTERFACE)
50 *
51 *----------------------------------------------------------------------------*/
52typedef struct
53{
54    u16 manfId; /* Vendor ID to match or CSR_SDIO_ANY_MANF_ID */
55    u16 cardId; /* Device ID to match or CSR_SDIO_ANY_CARD_ID */
56    u8 sdioFunction; /* SDIO Function number to match or CSR_SDIO_ANY_SDIO_FUNCTION */
57    u8 sdioInterface; /* SDIO Standard Interface Code to match or CSR_SDIO_ANY_SDIO_INTERFACE */
58} CsrSdioFunctionId;
59
60/*----------------------------------------------------------------------------*
61 * NAME
62 * CsrSdioFunction
63 *
64 * DESCRIPTION
65 * This structure represents a single function on a device.
66 *
67 * MEMBERS
68 * sdioId - A CsrSdioFunctionId describing this particular function. The
69 * subfield shall not contain any CsrSdioFunctionId wildcards. The
70 * subfields shall describe the specific single function
71 * represented by this structure.
72 * blockSize - Actual configured block size, or 0 if unconfigured.
73 * features - Bit mask with any of CSR_SDIO_FEATURE_* set.
74 * device - Handle of device containing the function. If two functions have
75 * the same device handle, they reside on the same device.
76 * driverData - For use by the Function Driver. The SDIO Driver shall not
77 * attempt to dereference the pointer.
78 * priv - For use by the SDIO Driver. The Function Driver shall not attempt
79 * to dereference the pointer.
80 *
81 *
82 *----------------------------------------------------------------------------*/
83typedef struct
84{
85    CsrSdioFunctionId sdioId;
86    u16 blockSize; /* Actual configured block size, or 0 if unconfigured */
87    u32 features; /* Bit mask with any of CSR_SDIO_FEATURE_* set */
88    void *device; /* Handle of device containing the function */
89    void *driverData; /* For use by the Function Driver */
90    void *priv; /* For use by the SDIO Driver */
91} CsrSdioFunction;
92
93/*----------------------------------------------------------------------------*
94 * NAME
95 * CsrSdioInsertedCallback, CsrSdioRemovedCallback
96 *
97 * DESCRIPTION
98 * CsrSdioInsertedCallback is called when a function becomes available to
99 * a registered Function Driver that supports the function.
100 * CsrSdioRemovedCallback is called when a function is no longer available
101 * to a Function Driver, either because the device has been removed, or the
102 * Function Driver has been unregistered.
103 *
104 * NOTE: These functions are implemented by the Function Driver, and are
105 * passed as function pointers in the CsrSdioFunctionDriver struct.
106 *
107 * PARAMETERS
108 * function - Pointer to struct representing the function.
109 *
110 *----------------------------------------------------------------------------*/
111typedef void (*CsrSdioInsertedCallback)(CsrSdioFunction *function);
112typedef void (*CsrSdioRemovedCallback)(CsrSdioFunction *function);
113
114/*----------------------------------------------------------------------------*
115 * NAME
116 * CsrSdioInterruptDsrCallback, CsrSdioInterruptCallback
117 *
118 * DESCRIPTION
119 * CsrSdioInterruptCallback is called when an interrupt occurs on the
120 * the device associated with the specified function.
121 *
122 * NOTE: These functions are implemented by the Function Driver, and are
123 * passed as function pointers in the CsrSdioFunctionDriver struct.
124 *
125 * PARAMETERS
126 * function - Pointer to struct representing the function.
127 *
128 * RETURNS (only CsrSdioInterruptCallback)
129 * A pointer to a CsrSdioInterruptDsrCallback function.
130 *
131 *----------------------------------------------------------------------------*/
132typedef void (*CsrSdioInterruptDsrCallback)(CsrSdioFunction *function);
133typedef CsrSdioInterruptDsrCallback (*CsrSdioInterruptCallback)(CsrSdioFunction *function);
134
135/*----------------------------------------------------------------------------*
136 * NAME
137 * CsrSdioSuspendCallback, CsrSdioResumeCallback
138 *
139 * DESCRIPTION
140 * CsrSdioSuspendCallback is called when the system is preparing to go
141 * into a suspended state. CsrSdioResumeCallback is called when the system
142 * has entered an active state again.
143 *
144 * NOTE: These functions are implemented by the Function Driver, and are
145 * passed as function pointers in the CsrSdioFunctionDriver struct.
146 *
147 * PARAMETERS
148 * function - Pointer to struct representing the function.
149 *
150 *----------------------------------------------------------------------------*/
151typedef void (*CsrSdioSuspendCallback)(CsrSdioFunction *function);
152typedef void (*CsrSdioResumeCallback)(CsrSdioFunction *function);
153
154/*----------------------------------------------------------------------------*
155 * NAME
156 * CsrSdioAsyncCallback, CsrSdioAsyncDsrCallback
157 *
158 * DESCRIPTION
159 * CsrSdioAsyncCallback is called when an asynchronous operation completes.
160 *
161 * NOTE: These functions are implemented by the Function Driver, and are
162 * passed as function pointers in the function calls that initiate
163 * the operation.
164 *
165 * PARAMETERS
166 * function - Pointer to struct representing the function.
167 * result - The result of the operation that completed. See the description
168 * of the initiating function for possible result values.
169 *
170 * RETURNS (only CsrSdioAsyncCallback)
171 * A pointer to a CsrSdioAsyncDsrCallback function.
172 *
173 *----------------------------------------------------------------------------*/
174typedef void (*CsrSdioAsyncDsrCallback)(CsrSdioFunction *function, CsrResult result);
175typedef CsrSdioAsyncDsrCallback (*CsrSdioAsyncCallback)(CsrSdioFunction *function, CsrResult result);
176
177/*----------------------------------------------------------------------------*
178 * NAME
179 * CsrSdioFunctionDriver
180 *
181 * DESCRIPTION
182 * Structure representing a Function Driver.
183 *
184 * MEMBERS
185 * inserted - Callback, see description of CsrSdioInsertedCallback.
186 * removed - Callback, see description of CsrSdioRemovedCallback.
187 * intr - Callback, see description of CsrSdioInterruptCallback.
188 * suspend - Callback, see description of CsrSdioSuspendCallback.
189 * resume - Callback, see description of CsrSdioResumeCallback.
190 * ids - Array of CsrSdioFunctionId describing one or more functions that
191 * are supported by the Function Driver.
192 * idsCount - Length of the ids array.
193 * priv - For use by the SDIO Driver. The Function Driver may initialise
194 * it to NULL, but shall otherwise not access the pointer or attempt
195 * to dereference it.
196 *
197 *----------------------------------------------------------------------------*/
198typedef struct
199{
200    CsrSdioInsertedCallback inserted;
201    CsrSdioRemovedCallback removed;
202    CsrSdioInterruptCallback intr;
203    CsrSdioSuspendCallback suspend;
204    CsrSdioResumeCallback resume;
205    CsrSdioFunctionId *ids;
206    u8 idsCount;
207    void *priv; /* For use by the SDIO Driver */
208} CsrSdioFunctionDriver;
209
210/*----------------------------------------------------------------------------*
211 * NAME
212 * CsrSdioFunctionDriverRegister
213 *
214 * DESCRIPTION
215 * Register a Function Driver.
216 *
217 * PARAMETERS
218 * functionDriver - Pointer to struct describing the Function Driver.
219 *
220 * RETURNS
221 * CSR_RESULT_SUCCESS - The Function Driver was successfully
222 * registered.
223 * CSR_RESULT_FAILURE - Unable to register the function driver,
224 * because of an unspecified/unknown error. The
225 * Function Driver has not been registered.
226 * CSR_SDIO_RESULT_INVALID_VALUE - The specified Function Driver pointer
227 * does not point at a valid Function
228 * Driver structure, or some of the members
229 * contain invalid entries.
230 *
231 *----------------------------------------------------------------------------*/
232CsrResult CsrSdioFunctionDriverRegister(CsrSdioFunctionDriver *functionDriver);
233
234/*----------------------------------------------------------------------------*
235 * NAME
236 * CsrSdioFunctionDriverUnregister
237 *
238 * DESCRIPTION
239 * Unregister a previously registered Function Driver.
240 *
241 * PARAMETERS
242 * functionDriver - pointer to struct describing the Function Driver.
243 *
244 *----------------------------------------------------------------------------*/
245void CsrSdioFunctionDriverUnregister(CsrSdioFunctionDriver *functionDriver);
246
247/*----------------------------------------------------------------------------*
248 * NAME
249 * CsrSdioFunctionEnable, CsrSdioFunctionDisable
250 *
251 * DESCRIPTION
252 * Enable/disable the specified function by setting/clearing the
253 * corresponding bit in the I/O Enable register in function 0, and then
254 * periodically reading the related bit in the I/O Ready register until it
255 * is set/clear, limited by an implementation defined timeout.
256 *
257 * PARAMETERS
258 * function - Pointer to struct representing the function.
259 *
260 * RETURNS
261 * CSR_RESULT_SUCCESS - The specified function was enabled/disabled.
262 * CSR_RESULT_FAILURE - Unspecified/unknown error.
263 * CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore.
264 * CSR_SDIO_RESULT_CRC_ERROR - A CRC error occured. The state of the
265 * related bit in the I/O Enable register is
266 * undefined.
267 * CSR_SDIO_RESULT_TIMEOUT - No response from the device, or the related
268 * bit in the I/O ready register was not
269 * set/cleared within the timeout period.
270 *
271 * NOTE: If the SDIO R5 response is available, and either of the
272 * FUNCTION_NUMBER or OUT_OF_RANGE bits are set,
273 * CSR_SDIO_RESULT_INVALID_VALUE shall be returned. If the ERROR bit
274 * is set (but none of FUNCTION_NUMBER or OUT_OF_RANGE),
275 * CSR_RESULT_FAILURE shall be returned. The ILLEGAL_COMMAND and
276 * COM_CRC_ERROR bits shall be ignored.
277 *
278 * If the CSPI response is available, and any of the
279 * FUNCTION_DISABLED or CLOCK_DISABLED bits are set,
280 * CSR_SDIO_RESULT_INVALID_VALUE will be returned.
281 *
282 *----------------------------------------------------------------------------*/
283CsrResult CsrSdioFunctionEnable(CsrSdioFunction *function);
284CsrResult CsrSdioFunctionDisable(CsrSdioFunction *function);
285
286/*----------------------------------------------------------------------------*
287 * NAME
288 * CsrSdioInterruptEnable, CsrSdioInterruptDisable
289 *
290 * DESCRIPTION
291 * Enable/disable the interrupt for the specified function by
292 * setting/clearing the corresponding bit in the INT Enable register in
293 * function 0.
294 *
295 * PARAMETERS
296 * function - Pointer to struct representing the function.
297 *
298 * RETURNS
299 * CSR_RESULT_SUCCESS - The specified function was enabled/disabled.
300 * CSR_RESULT_FAILURE - Unspecified/unknown error.
301 * CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore.
302 * CSR_SDIO_RESULT_CRC_ERROR - A CRC error occured. The state of the
303 * related bit in the INT Enable register is
304 * unchanged.
305 * CSR_SDIO_RESULT_INVALID_VALUE - The specified function cannot be
306 * enabled/disabled, because it either
307 * does not exist or it is not possible to
308 * individually enable/disable functions.
309 * CSR_SDIO_RESULT_TIMEOUT - No response from the device.
310 *
311 * NOTE: If the SDIO R5 response is available, and either of the
312 * FUNCTION_NUMBER or OUT_OF_RANGE bits are set,
313 * CSR_SDIO_RESULT_INVALID_VALUE shall be returned. If the ERROR bit
314 * is set (but none of FUNCTION_NUMBER or OUT_OF_RANGE),
315 * CSR_RESULT_FAILURE shall be returned. The ILLEGAL_COMMAND and
316 * COM_CRC_ERROR bits shall be ignored.
317 *
318 * If the CSPI response is available, and any of the
319 * FUNCTION_DISABLED or CLOCK_DISABLED bits are set,
320 * CSR_SDIO_RESULT_INVALID_VALUE will be returned.
321 *
322 *----------------------------------------------------------------------------*/
323CsrResult CsrSdioInterruptEnable(CsrSdioFunction *function);
324CsrResult CsrSdioInterruptDisable(CsrSdioFunction *function);
325
326/*----------------------------------------------------------------------------*
327 * NAME
328 * CsrSdioInterruptAcknowledge
329 *
330 * DESCRIPTION
331 * Acknowledge that a signalled interrupt has been handled. Shall only
332 * be called once, and exactly once for each signalled interrupt to the
333 * corresponding function.
334 *
335 * PARAMETERS
336 * function - Pointer to struct representing the function to which the
337 * event was signalled.
338 *
339 *----------------------------------------------------------------------------*/
340void CsrSdioInterruptAcknowledge(CsrSdioFunction *function);
341
342/*----------------------------------------------------------------------------*
343 * NAME
344 * CsrSdioInsertedAcknowledge, CsrSdioRemovedAcknowledge
345 *
346 * DESCRIPTION
347 * Acknowledge that a signalled inserted/removed event has been handled.
348 * Shall only be called once, and exactly once for each signalled event to
349 * the corresponding function.
350 *
351 * PARAMETERS
352 * function - Pointer to struct representing the function to which the
353 * inserted was signalled.
354 * result (CsrSdioInsertedAcknowledge only)
355 * CSR_RESULT_SUCCESS - The Function Driver has accepted the
356 * function, and the function is attached to
357 * the Function Driver until the
358 * CsrSdioRemovedCallback is called and
359 * acknowledged.
360 * CSR_RESULT_FAILURE - Unable to accept the function. The
361 * function is not attached to the Function
362 * Driver, and it may be passed to another
363 * Function Driver which supports the
364 * function.
365 *
366 *----------------------------------------------------------------------------*/
367void CsrSdioInsertedAcknowledge(CsrSdioFunction *function, CsrResult result);
368void CsrSdioRemovedAcknowledge(CsrSdioFunction *function);
369
370/*----------------------------------------------------------------------------*
371 * NAME
372 * CsrSdioSuspendAcknowledge, CsrSdioResumeAcknowledge
373 *
374 * DESCRIPTION
375 * Acknowledge that a signalled suspend event has been handled. Shall only
376 * be called once, and exactly once for each signalled event to the
377 * corresponding function.
378 *
379 * PARAMETERS
380 * function - Pointer to struct representing the function to which the
381 * event was signalled.
382 * result
383 * CSR_RESULT_SUCCESS - Successfully suspended/resumed.
384 * CSR_RESULT_FAILURE - Unspecified/unknown error.
385 *
386 *----------------------------------------------------------------------------*/
387void CsrSdioSuspendAcknowledge(CsrSdioFunction *function, CsrResult result);
388void CsrSdioResumeAcknowledge(CsrSdioFunction *function, CsrResult result);
389
390/*----------------------------------------------------------------------------*
391 * NAME
392 * CsrSdioBlockSizeSet
393 *
394 * DESCRIPTION
395 * Set the block size to use for the function. The actual configured block
396 * size shall be the minimum of:
397 * 1) Maximum block size supported by the function.
398 * 2) Maximum block size supported by the host controller.
399 * 3) The block size specified by the blockSize argument.
400 *
401 * When this function returns, the actual configured block size is
402 * available in the blockSize member of the function struct.
403 *
404 * PARAMETERS
405 * function - Pointer to struct representing the function.
406 * blockSize - Block size to use for the function. Valid range is 1 to
407 * 2048.
408 *
409 * RETURNS
410 * CSR_RESULT_SUCCESS - The block size register on the chip
411 * was updated.
412 * CSR_RESULT_FAILURE - Unspecified/unknown error.
413 * CSR_SDIO_RESULT_INVALID_VALUE - One or more arguments were invalid.
414 * CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore.
415 * CSR_SDIO_RESULT_CRC_ERROR - A CRC error occured. The configured block
416 * size is undefined.
417 * CSR_SDIO_RESULT_TIMEOUT - No response from the device.
418 *
419 * NOTE: If the SDIO R5 response is available, and the FUNCTION_NUMBER
420 * bits is set, CSR_SDIO_RESULT_INVALID_VALUE shall be returned.
421 * If the ERROR bit is set (but not FUNCTION_NUMBER),
422 * CSR_RESULT_FAILURE shall be returned. The ILLEGAL_COMMAND and
423 * COM_CRC_ERROR bits shall be ignored.
424 *
425 * If the CSPI response is available, and any of the
426 * FUNCTION_DISABLED or CLOCK_DISABLED bits are set,
427 * CSR_SDIO_RESULT_INVALID_VALUE will be returned.
428 *
429 * NOTE: Setting the block size requires two individual operations. The
430 * implementation shall ignore the OUT_OF_RANGE bit of the SDIO R5
431 * response for the first operation, as the partially configured
432 * block size may be out of range, even if the final block size
433 * (after the second operation) is in the valid range.
434 *
435 *----------------------------------------------------------------------------*/
436CsrResult CsrSdioBlockSizeSet(CsrSdioFunction *function, u16 blockSize);
437
438/*----------------------------------------------------------------------------*
439 * NAME
440 * CsrSdioMaxBusClockFrequencySet
441 *
442 * DESCRIPTION
443 * Set the maximum clock frequency to use for the device associated with
444 * the specified function. The actual configured clock frequency for the
445 * device shall be the minimum of:
446 * 1) Maximum clock frequency supported by the device.
447 * 2) Maximum clock frequency supported by the host controller.
448 * 3) Maximum clock frequency specified for any function on the same
449 * device.
450 *
451 * If the clock frequency exceeds 25MHz, it is the responsibility of the
452 * SDIO driver to enable high speed mode on the device, using the standard
453 * defined procedure, before increasing the frequency beyond the limit.
454 *
455 * Note that the clock frequency configured affects all functions on the
456 * same device.
457 *
458 * PARAMETERS
459 * function - Pointer to struct representing the function.
460 * maxFrequency - The maximum clock frequency for the function in Hertz.
461 *
462 * RETURNS
463 * CSR_RESULT_SUCCESS - The maximum clock frequency was succesfully
464 * set for the function.
465 * CSR_RESULT_FAILURE - Unspecified/unknown error.
466 * CSR_SDIO_RESULT_INVALID_VALUE - One or more arguments were invalid.
467 * CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore.
468 *
469 * NOTE: If the SDIO R5 response is available, and the FUNCTION_NUMBER
470 * bits is set, CSR_SDIO_RESULT_INVALID_VALUE shall be returned.
471 * If the ERROR bit is set (but not FUNCTION_NUMBER),
472 * CSR_RESULT_FAILURE shall be returned. The ILLEGAL_COMMAND and
473 * COM_CRC_ERROR bits shall be ignored.
474 *
475 * If the CSPI response is available, and any of the
476 * FUNCTION_DISABLED or CLOCK_DISABLED bits are set,
477 * CSR_SDIO_RESULT_INVALID_VALUE will be returned.
478 *
479 *
480 *----------------------------------------------------------------------------*/
481CsrResult CsrSdioMaxBusClockFrequencySet(CsrSdioFunction *function, u32 maxFrequency);
482
483/*----------------------------------------------------------------------------*
484 * NAME
485 * CsrSdioRead8, CsrSdioWrite8, CsrSdioRead8Async, CsrSdioWrite8Async
486 *
487 * DESCRIPTION
488 * Read/write an 8bit value from/to the specified register address.
489 *
490 * PARAMETERS
491 * function - Pointer to struct representing the function.
492 * address - Register address within the function.
493 * data - The data to read/write.
494 * callback - The function to call on operation completion.
495 *
496 * RETURNS
497 * CSR_RESULT_SUCCESS - The data was successfully read/written.
498 * CSR_RESULT_FAILURE - Unspecified/unknown error.
499 * CSR_SDIO_RESULT_INVALID_VALUE - One or more arguments were invalid.
500 * CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore.
501 * CSR_SDIO_RESULT_CRC_ERROR - A CRC error occured. No data read/written.
502 * CSR_SDIO_RESULT_TIMEOUT - No response from the device.
503 *
504 * NOTE: If the SDIO R5 response is available, and either of the
505 * FUNCTION_NUMBER or OUT_OF_RANGE bits are set,
506 * CSR_SDIO_RESULT_INVALID_VALUE shall be returned. If the ERROR bit
507 * is set (but none of FUNCTION_NUMBER or OUT_OF_RANGE),
508 * CSR_RESULT_FAILURE shall be returned. The ILLEGAL_COMMAND and
509 * COM_CRC_ERROR bits shall be ignored.
510 *
511 * If the CSPI response is available, and any of the
512 * FUNCTION_DISABLED or CLOCK_DISABLED bits are set,
513 * CSR_SDIO_RESULT_INVALID_VALUE will be returned.
514 *
515 * NOTE: The CsrSdioRead8Async and CsrSdioWrite8Async functions return
516 * immediately, and the supplied callback function is called when the
517 * operation is complete. The result value is given as an argument to
518 * the callback function.
519 *
520 *----------------------------------------------------------------------------*/
521CsrResult CsrSdioRead8(CsrSdioFunction *function, u32 address, u8 *data);
522CsrResult CsrSdioWrite8(CsrSdioFunction *function, u32 address, u8 data);
523void CsrSdioRead8Async(CsrSdioFunction *function, u32 address, u8 *data, CsrSdioAsyncCallback callback);
524void CsrSdioWrite8Async(CsrSdioFunction *function, u32 address, u8 data, CsrSdioAsyncCallback callback);
525
526/*----------------------------------------------------------------------------*
527 * NAME
528 * CsrSdioRead16, CsrSdioWrite16, CsrSdioRead16Async, CsrSdioWrite16Async
529 *
530 * DESCRIPTION
531 * Read/write a 16bit value from/to the specified register address.
532 *
533 * PARAMETERS
534 * function - Pointer to struct representing the function.
535 * address - Register address within the function.
536 * data - The data to read/write.
537 * callback - The function to call on operation completion.
538 *
539 * RETURNS
540 * CSR_RESULT_SUCCESS - The data was successfully read/written.
541 * CSR_RESULT_FAILURE - Unspecified/unknown error.
542 * CSR_SDIO_RESULT_INVALID_VALUE - One or more arguments were invalid.
543 * CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore.
544 * CSR_SDIO_RESULT_CRC_ERROR - A CRC error occured. Data may have been
545 * partially read/written.
546 * CSR_SDIO_RESULT_TIMEOUT - No response from the device.
547 *
548 * NOTE: If the SDIO R5 response is available, and either of the
549 * FUNCTION_NUMBER or OUT_OF_RANGE bits are set,
550 * CSR_SDIO_RESULT_INVALID_VALUE shall be returned. If the ERROR bit
551 * is set (but none of FUNCTION_NUMBER or OUT_OF_RANGE),
552 * CSR_RESULT_FAILURE shall be returned. The ILLEGAL_COMMAND and
553 * COM_CRC_ERROR bits shall be ignored.
554 *
555 * If the CSPI response is available, and any of the
556 * FUNCTION_DISABLED or CLOCK_DISABLED bits are set,
557 * CSR_SDIO_RESULT_INVALID_VALUE will be returned.
558 *
559 * NOTE: The CsrSdioRead16Async and CsrSdioWrite16Async functions return
560 * immediately, and the supplied callback function is called when the
561 * operation is complete. The result value is given as an argument to
562 * the callback function.
563 *
564 *----------------------------------------------------------------------------*/
565CsrResult CsrSdioRead16(CsrSdioFunction *function, u32 address, u16 *data);
566CsrResult CsrSdioWrite16(CsrSdioFunction *function, u32 address, u16 data);
567void CsrSdioRead16Async(CsrSdioFunction *function, u32 address, u16 *data, CsrSdioAsyncCallback callback);
568void CsrSdioWrite16Async(CsrSdioFunction *function, u32 address, u16 data, CsrSdioAsyncCallback callback);
569
570/*----------------------------------------------------------------------------*
571 * NAME
572 * CsrSdioF0Read8, CsrSdioF0Write8, CsrSdioF0Read8Async,
573 * CsrSdioF0Write8Async
574 *
575 * DESCRIPTION
576 * Read/write an 8bit value from/to the specified register address in
577 * function 0.
578 *
579 * PARAMETERS
580 * function - Pointer to struct representing the function.
581 * address - Register address within the function.
582 * data - The data to read/write.
583 * callback - The function to call on operation completion.
584 *
585 * RETURNS
586 * CSR_RESULT_SUCCESS - The data was successfully read/written.
587 * CSR_RESULT_FAILURE - Unspecified/unknown error.
588 * CSR_SDIO_RESULT_INVALID_VALUE - One or more arguments were invalid.
589 * CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore.
590 * CSR_SDIO_RESULT_CRC_ERROR - A CRC error occured. No data read/written.
591 * CSR_SDIO_RESULT_TIMEOUT - No response from the device.
592 *
593 * NOTE: If the SDIO R5 response is available, and either of the
594 * FUNCTION_NUMBER or OUT_OF_RANGE bits are set,
595 * CSR_SDIO_RESULT_INVALID_VALUE shall be returned. If the ERROR bit
596 * is set (but none of FUNCTION_NUMBER or OUT_OF_RANGE),
597 * CSR_RESULT_FAILURE shall be returned. The ILLEGAL_COMMAND and
598 * COM_CRC_ERROR bits shall be ignored.
599 *
600 * If the CSPI response is available, and any of the
601 * FUNCTION_DISABLED or CLOCK_DISABLED bits are set,
602 * CSR_SDIO_RESULT_INVALID_VALUE will be returned.
603 *
604 * NOTE: The CsrSdioF0Read8Async and CsrSdioF0Write8Async functions return
605 * immediately, and the supplied callback function is called when the
606 * operation is complete. The result value is given as an argument to
607 * the callback function.
608 *
609 *----------------------------------------------------------------------------*/
610CsrResult CsrSdioF0Read8(CsrSdioFunction *function, u32 address, u8 *data);
611CsrResult CsrSdioF0Write8(CsrSdioFunction *function, u32 address, u8 data);
612void CsrSdioF0Read8Async(CsrSdioFunction *function, u32 address, u8 *data, CsrSdioAsyncCallback callback);
613void CsrSdioF0Write8Async(CsrSdioFunction *function, u32 address, u8 data, CsrSdioAsyncCallback callback);
614
615/*----------------------------------------------------------------------------*
616 * NAME
617 * CsrSdioRead, CsrSdioWrite, CsrSdioReadAsync, CsrSdioWriteAsync
618 *
619 * DESCRIPTION
620 * Read/write a specified number of bytes from/to the specified register
621 * address.
622 *
623 * PARAMETERS
624 * function - Pointer to struct representing the function.
625 * address - Register address within the function.
626 * data - The data to read/write.
627 * length - Number of byte to read/write.
628 * callback - The function to call on operation completion.
629 *
630 * RETURNS
631 * CSR_RESULT_SUCCESS - The data was successfully read/written.
632 * CSR_RESULT_FAILURE - Unspecified/unknown error.
633 * CSR_SDIO_RESULT_INVALID_VALUE - One or more arguments were invalid.
634 * CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore.
635 * CSR_SDIO_RESULT_CRC_ERROR - A CRC error occured. Data may have been
636 * partially read/written.
637 * CSR_SDIO_RESULT_TIMEOUT - No response from the device.
638 *
639 * NOTE: If the SDIO R5 response is available, and either of the
640 * FUNCTION_NUMBER or OUT_OF_RANGE bits are set,
641 * CSR_SDIO_RESULT_INVALID_VALUE shall be returned. If the ERROR bit
642 * is set (but none of FUNCTION_NUMBER or OUT_OF_RANGE),
643 * CSR_RESULT_FAILURE shall be returned. The ILLEGAL_COMMAND and
644 * COM_CRC_ERROR bits shall be ignored.
645 *
646 * If the CSPI response is available, and any of the
647 * FUNCTION_DISABLED or CLOCK_DISABLED bits are set,
648 * CSR_SDIO_RESULT_INVALID_VALUE will be returned.
649 *
650 * NOTE: The CsrSdioF0Read8Async and CsrSdioF0Write8Async functions return
651 * immediately, and the supplied callback function is called when the
652 * operation is complete. The result value is given as an argument to
653 * the callback function.
654 *
655 *----------------------------------------------------------------------------*/
656CsrResult CsrSdioRead(CsrSdioFunction *function, u32 address, void *data, u32 length);
657CsrResult CsrSdioWrite(CsrSdioFunction *function, u32 address, const void *data, u32 length);
658void CsrSdioReadAsync(CsrSdioFunction *function, u32 address, void *data, u32 length, CsrSdioAsyncCallback callback);
659void CsrSdioWriteAsync(CsrSdioFunction *function, u32 address, const void *data, u32 length, CsrSdioAsyncCallback callback);
660
661/*----------------------------------------------------------------------------*
662 * NAME
663 * CsrSdioPowerOn, CsrSdioPowerOff
664 *
665 * DESCRIPTION
666 * Power on/off the device.
667 *
668 * PARAMETERS
669 * function - Pointer to struct representing the function that resides on
670 * the device to power on/off.
671 *
672 * RETURNS (only CsrSdioPowerOn)
673 * CSR_RESULT_SUCCESS - Power was succesfully reapplied and the device
674 * has been reinitialised.
675 * CSR_RESULT_FAILURE - Unspecified/unknown error.
676 * CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore.
677 * CSR_SDIO_RESULT_CRC_ERROR - A CRC error occured during reinitialisation.
678 * CSR_SDIO_RESULT_TIMEOUT - No response from the device during
679 * reinitialisation.
680 * CSR_SDIO_RESULT_NOT_RESET - The power was not removed by the
681 * CsrSdioPowerOff call. The state of the
682 * device is unchanged.
683 *
684 *----------------------------------------------------------------------------*/
685CsrResult CsrSdioPowerOn(CsrSdioFunction *function);
686void CsrSdioPowerOff(CsrSdioFunction *function);
687
688/*----------------------------------------------------------------------------*
689 * NAME
690 * CsrSdioHardReset
691 *
692 * DESCRIPTION
693 * Perform a hardware reset of the device.
694 *
695 * PARAMETERS
696 * function - Pointer to struct representing the function that resides on
697 * the device to hard reset.
698 *
699 * RETURNS
700 * CSR_RESULT_SUCCESS - Reset was succesfully performed and the device
701 * has been reinitialised.
702 * CSR_RESULT_FAILURE - Unspecified/unknown error.
703 * CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore.
704 * CSR_SDIO_RESULT_CRC_ERROR - A CRC error occured during reinitialisation.
705 * CSR_SDIO_RESULT_TIMEOUT - No response from the device during
706 * reinitialisation.
707 * CSR_SDIO_RESULT_NOT_RESET - The reset was not applied because it is not
708 * supported. The state of the device is
709 * unchanged.
710 *
711 *----------------------------------------------------------------------------*/
712CsrResult CsrSdioHardReset(CsrSdioFunction *function);
713
714/*----------------------------------------------------------------------------*
715 * NAME
716 * CsrSdioFunctionActive, CsrSdioFunctionIdle
717 *
718 * DESCRIPTION
719 *
720 * PARAMETERS
721 * function - Pointer to struct representing the function.
722 *
723 *----------------------------------------------------------------------------*/
724void CsrSdioFunctionActive(CsrSdioFunction *function);
725void CsrSdioFunctionIdle(CsrSdioFunction *function);
726
727#ifdef __cplusplus
728}
729#endif
730
731#endif
732

Archive Download this file



interactive