3 /*****************************************************************************
5 (c) Cambridge Silicon Radio Limited 2010
6 All rights reserved and confidential information of CSR
8 Refer to LICENSE.txt included with this source for details
11 *****************************************************************************/
13 #include "csr_result.h"
16 #define CSR_SDIO_RESULT_INVALID_VALUE ((CsrResult) 1) /* Invalid argument value */
17 #define CSR_SDIO_RESULT_NO_DEVICE ((CsrResult) 2) /* The specified device is no longer present */
18 #define CSR_SDIO_RESULT_CRC_ERROR ((CsrResult) 3) /* The transmitted/received data or command response contained a CRC error */
19 #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 */
20 #define CSR_SDIO_RESULT_NOT_RESET ((CsrResult) 5) /* The device was not reset */
22 /* Features (for use in features member of CsrSdioFunction) */
23 #define CSR_SDIO_FEATURE_BYTE_MODE 0x00000001 /* Transfer sizes do not have to be a multiple of block size */
24 #define CSR_SDIO_FEATURE_DMA_CAPABLE_MEM_REQUIRED 0x00000002 /* Bulk operations require DMA friendly memory */
26 /* CsrSdioFunctionId wildcards (for use in CsrSdioFunctionId members) */
27 #define CSR_SDIO_ANY_MANF_ID 0xFFFF
28 #define CSR_SDIO_ANY_CARD_ID 0xFFFF
29 #define CSR_SDIO_ANY_SDIO_FUNCTION 0xFF
30 #define CSR_SDIO_ANY_SDIO_INTERFACE 0xFF
32 /*----------------------------------------------------------------------------*
37 * This structure describes one or more functions of a device, based on
38 * four qualitative measures. The CsrSdioFunctionId wildcard defines can be
39 * used for making the CsrSdioFunctionId match more than one function.
42 * manfId - Vendor ID (or CSR_SDIO_ANY_MANF_ID).
43 * cardId - Device ID (or CSR_SDIO_ANY_CARD_ID).
44 * sdioFunction - SDIO Function number (or CSR_SDIO_ANY_SDIO_FUNCTION).
45 * sdioInterface - SDIO Standard Interface Code (or CSR_SDIO_ANY_SDIO_INTERFACE)
47 *----------------------------------------------------------------------------*/
50 u16 manfId; /* Vendor ID to match or CSR_SDIO_ANY_MANF_ID */
51 u16 cardId; /* Device ID to match or CSR_SDIO_ANY_CARD_ID */
52 u8 sdioFunction; /* SDIO Function number to match or CSR_SDIO_ANY_SDIO_FUNCTION */
53 u8 sdioInterface; /* SDIO Standard Interface Code to match or CSR_SDIO_ANY_SDIO_INTERFACE */
56 /*----------------------------------------------------------------------------*
61 * This structure represents a single function on a device.
64 * sdioId - A CsrSdioFunctionId describing this particular function. The
65 * subfield shall not contain any CsrSdioFunctionId wildcards. The
66 * subfields shall describe the specific single function
67 * represented by this structure.
68 * blockSize - Actual configured block size, or 0 if unconfigured.
69 * features - Bit mask with any of CSR_SDIO_FEATURE_* set.
70 * device - Handle of device containing the function. If two functions have
71 * the same device handle, they reside on the same device.
72 * driverData - For use by the Function Driver. The SDIO Driver shall not
73 * attempt to dereference the pointer.
74 * priv - For use by the SDIO Driver. The Function Driver shall not attempt
75 * to dereference the pointer.
78 *----------------------------------------------------------------------------*/
81 CsrSdioFunctionId sdioId;
82 u16 blockSize; /* Actual configured block size, or 0 if unconfigured */
83 u32 features; /* Bit mask with any of CSR_SDIO_FEATURE_* set */
84 void *device; /* Handle of device containing the function */
85 void *driverData; /* For use by the Function Driver */
86 void *priv; /* For use by the SDIO Driver */
89 /*----------------------------------------------------------------------------*
91 * CsrSdioInsertedCallback, CsrSdioRemovedCallback
94 * CsrSdioInsertedCallback is called when a function becomes available to
95 * a registered Function Driver that supports the function.
96 * CsrSdioRemovedCallback is called when a function is no longer available
97 * to a Function Driver, either because the device has been removed, or the
98 * Function Driver has been unregistered.
100 * NOTE: These functions are implemented by the Function Driver, and are
101 * passed as function pointers in the CsrSdioFunctionDriver struct.
104 * function - Pointer to struct representing the function.
106 *----------------------------------------------------------------------------*/
107 typedef void (*CsrSdioInsertedCallback)(CsrSdioFunction *function);
108 typedef void (*CsrSdioRemovedCallback)(CsrSdioFunction *function);
110 /*----------------------------------------------------------------------------*
112 * CsrSdioInterruptDsrCallback, CsrSdioInterruptCallback
115 * CsrSdioInterruptCallback is called when an interrupt occurs on the
116 * the device associated with the specified function.
118 * NOTE: These functions are implemented by the Function Driver, and are
119 * passed as function pointers in the CsrSdioFunctionDriver struct.
122 * function - Pointer to struct representing the function.
124 * RETURNS (only CsrSdioInterruptCallback)
125 * A pointer to a CsrSdioInterruptDsrCallback function.
127 *----------------------------------------------------------------------------*/
128 typedef void (*CsrSdioInterruptDsrCallback)(CsrSdioFunction *function);
129 typedef CsrSdioInterruptDsrCallback (*CsrSdioInterruptCallback)(CsrSdioFunction *function);
131 /*----------------------------------------------------------------------------*
133 * CsrSdioSuspendCallback, CsrSdioResumeCallback
136 * CsrSdioSuspendCallback is called when the system is preparing to go
137 * into a suspended state. CsrSdioResumeCallback is called when the system
138 * has entered an active state again.
140 * NOTE: These functions are implemented by the Function Driver, and are
141 * passed as function pointers in the CsrSdioFunctionDriver struct.
144 * function - Pointer to struct representing the function.
146 *----------------------------------------------------------------------------*/
147 typedef void (*CsrSdioSuspendCallback)(CsrSdioFunction *function);
148 typedef void (*CsrSdioResumeCallback)(CsrSdioFunction *function);
150 /*----------------------------------------------------------------------------*
152 * CsrSdioAsyncCallback, CsrSdioAsyncDsrCallback
155 * CsrSdioAsyncCallback is called when an asynchronous operation completes.
157 * NOTE: These functions are implemented by the Function Driver, and are
158 * passed as function pointers in the function calls that initiate
162 * function - Pointer to struct representing the function.
163 * result - The result of the operation that completed. See the description
164 * of the initiating function for possible result values.
166 * RETURNS (only CsrSdioAsyncCallback)
167 * A pointer to a CsrSdioAsyncDsrCallback function.
169 *----------------------------------------------------------------------------*/
170 typedef void (*CsrSdioAsyncDsrCallback)(CsrSdioFunction *function, CsrResult result);
171 typedef CsrSdioAsyncDsrCallback (*CsrSdioAsyncCallback)(CsrSdioFunction *function, CsrResult result);
173 /*----------------------------------------------------------------------------*
175 * CsrSdioFunctionDriver
178 * Structure representing a Function Driver.
181 * inserted - Callback, see description of CsrSdioInsertedCallback.
182 * removed - Callback, see description of CsrSdioRemovedCallback.
183 * intr - Callback, see description of CsrSdioInterruptCallback.
184 * suspend - Callback, see description of CsrSdioSuspendCallback.
185 * resume - Callback, see description of CsrSdioResumeCallback.
186 * ids - Array of CsrSdioFunctionId describing one or more functions that
187 * are supported by the Function Driver.
188 * idsCount - Length of the ids array.
189 * priv - For use by the SDIO Driver. The Function Driver may initialise
190 * it to NULL, but shall otherwise not access the pointer or attempt
193 *----------------------------------------------------------------------------*/
196 CsrSdioInsertedCallback inserted;
197 CsrSdioRemovedCallback removed;
198 CsrSdioInterruptCallback intr;
199 CsrSdioSuspendCallback suspend;
200 CsrSdioResumeCallback resume;
201 CsrSdioFunctionId *ids;
203 void *priv; /* For use by the SDIO Driver */
204 } CsrSdioFunctionDriver;
206 /*----------------------------------------------------------------------------*
208 * CsrSdioFunctionDriverRegister
211 * Register a Function Driver.
214 * functionDriver - Pointer to struct describing the Function Driver.
217 * CSR_RESULT_SUCCESS - The Function Driver was successfully
219 * CSR_RESULT_FAILURE - Unable to register the function driver,
220 * because of an unspecified/unknown error. The
221 * Function Driver has not been registered.
222 * CSR_SDIO_RESULT_INVALID_VALUE - The specified Function Driver pointer
223 * does not point at a valid Function
224 * Driver structure, or some of the members
225 * contain invalid entries.
227 *----------------------------------------------------------------------------*/
228 CsrResult CsrSdioFunctionDriverRegister(CsrSdioFunctionDriver *functionDriver);
230 /*----------------------------------------------------------------------------*
232 * CsrSdioFunctionDriverUnregister
235 * Unregister a previously registered Function Driver.
238 * functionDriver - pointer to struct describing the Function Driver.
240 *----------------------------------------------------------------------------*/
241 void CsrSdioFunctionDriverUnregister(CsrSdioFunctionDriver *functionDriver);
243 /*----------------------------------------------------------------------------*
245 * CsrSdioFunctionEnable, CsrSdioFunctionDisable
248 * Enable/disable the specified function by setting/clearing the
249 * corresponding bit in the I/O Enable register in function 0, and then
250 * periodically reading the related bit in the I/O Ready register until it
251 * is set/clear, limited by an implementation defined timeout.
254 * function - Pointer to struct representing the function.
257 * CSR_RESULT_SUCCESS - The specified function was enabled/disabled.
258 * CSR_RESULT_FAILURE - Unspecified/unknown error.
259 * CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore.
260 * CSR_SDIO_RESULT_CRC_ERROR - A CRC error occured. The state of the
261 * related bit in the I/O Enable register is
263 * CSR_SDIO_RESULT_TIMEOUT - No response from the device, or the related
264 * bit in the I/O ready register was not
265 * set/cleared within the timeout period.
267 * NOTE: If the SDIO R5 response is available, and either of the
268 * FUNCTION_NUMBER or OUT_OF_RANGE bits are set,
269 * CSR_SDIO_RESULT_INVALID_VALUE shall be returned. If the ERROR bit
270 * is set (but none of FUNCTION_NUMBER or OUT_OF_RANGE),
271 * CSR_RESULT_FAILURE shall be returned. The ILLEGAL_COMMAND and
272 * COM_CRC_ERROR bits shall be ignored.
274 * If the CSPI response is available, and any of the
275 * FUNCTION_DISABLED or CLOCK_DISABLED bits are set,
276 * CSR_SDIO_RESULT_INVALID_VALUE will be returned.
278 *----------------------------------------------------------------------------*/
279 CsrResult CsrSdioFunctionEnable(CsrSdioFunction *function);
280 CsrResult CsrSdioFunctionDisable(CsrSdioFunction *function);
282 /*----------------------------------------------------------------------------*
284 * CsrSdioInterruptEnable, CsrSdioInterruptDisable
287 * Enable/disable the interrupt for the specified function by
288 * setting/clearing the corresponding bit in the INT Enable register in
292 * function - Pointer to struct representing the function.
295 * CSR_RESULT_SUCCESS - The specified function was enabled/disabled.
296 * CSR_RESULT_FAILURE - Unspecified/unknown error.
297 * CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore.
298 * CSR_SDIO_RESULT_CRC_ERROR - A CRC error occured. The state of the
299 * related bit in the INT Enable register is
301 * CSR_SDIO_RESULT_INVALID_VALUE - The specified function cannot be
302 * enabled/disabled, because it either
303 * does not exist or it is not possible to
304 * individually enable/disable functions.
305 * CSR_SDIO_RESULT_TIMEOUT - No response from the device.
307 * NOTE: If the SDIO R5 response is available, and either of the
308 * FUNCTION_NUMBER or OUT_OF_RANGE bits are set,
309 * CSR_SDIO_RESULT_INVALID_VALUE shall be returned. If the ERROR bit
310 * is set (but none of FUNCTION_NUMBER or OUT_OF_RANGE),
311 * CSR_RESULT_FAILURE shall be returned. The ILLEGAL_COMMAND and
312 * COM_CRC_ERROR bits shall be ignored.
314 * If the CSPI response is available, and any of the
315 * FUNCTION_DISABLED or CLOCK_DISABLED bits are set,
316 * CSR_SDIO_RESULT_INVALID_VALUE will be returned.
318 *----------------------------------------------------------------------------*/
319 CsrResult CsrSdioInterruptEnable(CsrSdioFunction *function);
320 CsrResult CsrSdioInterruptDisable(CsrSdioFunction *function);
322 /*----------------------------------------------------------------------------*
324 * CsrSdioInterruptAcknowledge
327 * Acknowledge that a signalled interrupt has been handled. Shall only
328 * be called once, and exactly once for each signalled interrupt to the
329 * corresponding function.
332 * function - Pointer to struct representing the function to which the
333 * event was signalled.
335 *----------------------------------------------------------------------------*/
336 void CsrSdioInterruptAcknowledge(CsrSdioFunction *function);
338 /*----------------------------------------------------------------------------*
340 * CsrSdioInsertedAcknowledge, CsrSdioRemovedAcknowledge
343 * Acknowledge that a signalled inserted/removed event has been handled.
344 * Shall only be called once, and exactly once for each signalled event to
345 * the corresponding function.
348 * function - Pointer to struct representing the function to which the
349 * inserted was signalled.
350 * result (CsrSdioInsertedAcknowledge only)
351 * CSR_RESULT_SUCCESS - The Function Driver has accepted the
352 * function, and the function is attached to
353 * the Function Driver until the
354 * CsrSdioRemovedCallback is called and
356 * CSR_RESULT_FAILURE - Unable to accept the function. The
357 * function is not attached to the Function
358 * Driver, and it may be passed to another
359 * Function Driver which supports the
362 *----------------------------------------------------------------------------*/
363 void CsrSdioInsertedAcknowledge(CsrSdioFunction *function, CsrResult result);
364 void CsrSdioRemovedAcknowledge(CsrSdioFunction *function);
366 /*----------------------------------------------------------------------------*
368 * CsrSdioSuspendAcknowledge, CsrSdioResumeAcknowledge
371 * Acknowledge that a signalled suspend event has been handled. Shall only
372 * be called once, and exactly once for each signalled event to the
373 * corresponding function.
376 * function - Pointer to struct representing the function to which the
377 * event was signalled.
379 * CSR_RESULT_SUCCESS - Successfully suspended/resumed.
380 * CSR_RESULT_FAILURE - Unspecified/unknown error.
382 *----------------------------------------------------------------------------*/
383 void CsrSdioSuspendAcknowledge(CsrSdioFunction *function, CsrResult result);
384 void CsrSdioResumeAcknowledge(CsrSdioFunction *function, CsrResult result);
386 /*----------------------------------------------------------------------------*
388 * CsrSdioBlockSizeSet
391 * Set the block size to use for the function. The actual configured block
392 * size shall be the minimum of:
393 * 1) Maximum block size supported by the function.
394 * 2) Maximum block size supported by the host controller.
395 * 3) The block size specified by the blockSize argument.
397 * When this function returns, the actual configured block size is
398 * available in the blockSize member of the function struct.
401 * function - Pointer to struct representing the function.
402 * blockSize - Block size to use for the function. Valid range is 1 to
406 * CSR_RESULT_SUCCESS - The block size register on the chip
408 * CSR_RESULT_FAILURE - Unspecified/unknown error.
409 * CSR_SDIO_RESULT_INVALID_VALUE - One or more arguments were invalid.
410 * CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore.
411 * CSR_SDIO_RESULT_CRC_ERROR - A CRC error occured. The configured block
413 * CSR_SDIO_RESULT_TIMEOUT - No response from the device.
415 * NOTE: If the SDIO R5 response is available, and the FUNCTION_NUMBER
416 * bits is set, CSR_SDIO_RESULT_INVALID_VALUE shall be returned.
417 * If the ERROR bit is set (but not FUNCTION_NUMBER),
418 * CSR_RESULT_FAILURE shall be returned. The ILLEGAL_COMMAND and
419 * COM_CRC_ERROR bits shall be ignored.
421 * If the CSPI response is available, and any of the
422 * FUNCTION_DISABLED or CLOCK_DISABLED bits are set,
423 * CSR_SDIO_RESULT_INVALID_VALUE will be returned.
425 * NOTE: Setting the block size requires two individual operations. The
426 * implementation shall ignore the OUT_OF_RANGE bit of the SDIO R5
427 * response for the first operation, as the partially configured
428 * block size may be out of range, even if the final block size
429 * (after the second operation) is in the valid range.
431 *----------------------------------------------------------------------------*/
432 CsrResult CsrSdioBlockSizeSet(CsrSdioFunction *function, u16 blockSize);
434 /*----------------------------------------------------------------------------*
436 * CsrSdioMaxBusClockFrequencySet
439 * Set the maximum clock frequency to use for the device associated with
440 * the specified function. The actual configured clock frequency for the
441 * device shall be the minimum of:
442 * 1) Maximum clock frequency supported by the device.
443 * 2) Maximum clock frequency supported by the host controller.
444 * 3) Maximum clock frequency specified for any function on the same
447 * If the clock frequency exceeds 25MHz, it is the responsibility of the
448 * SDIO driver to enable high speed mode on the device, using the standard
449 * defined procedure, before increasing the frequency beyond the limit.
451 * Note that the clock frequency configured affects all functions on the
455 * function - Pointer to struct representing the function.
456 * maxFrequency - The maximum clock frequency for the function in Hertz.
459 * CSR_RESULT_SUCCESS - The maximum clock frequency was succesfully
460 * set for the function.
461 * CSR_RESULT_FAILURE - Unspecified/unknown error.
462 * CSR_SDIO_RESULT_INVALID_VALUE - One or more arguments were invalid.
463 * CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore.
465 * NOTE: If the SDIO R5 response is available, and the FUNCTION_NUMBER
466 * bits is set, CSR_SDIO_RESULT_INVALID_VALUE shall be returned.
467 * If the ERROR bit is set (but not FUNCTION_NUMBER),
468 * CSR_RESULT_FAILURE shall be returned. The ILLEGAL_COMMAND and
469 * COM_CRC_ERROR bits shall be ignored.
471 * If the CSPI response is available, and any of the
472 * FUNCTION_DISABLED or CLOCK_DISABLED bits are set,
473 * CSR_SDIO_RESULT_INVALID_VALUE will be returned.
476 *----------------------------------------------------------------------------*/
477 CsrResult CsrSdioMaxBusClockFrequencySet(CsrSdioFunction *function, u32 maxFrequency);
479 /*----------------------------------------------------------------------------*
481 * CsrSdioRead8, CsrSdioWrite8, CsrSdioRead8Async, CsrSdioWrite8Async
484 * Read/write an 8bit value from/to the specified register address.
487 * function - Pointer to struct representing the function.
488 * address - Register address within the function.
489 * data - The data to read/write.
490 * callback - The function to call on operation completion.
493 * CSR_RESULT_SUCCESS - The data was successfully read/written.
494 * CSR_RESULT_FAILURE - Unspecified/unknown error.
495 * CSR_SDIO_RESULT_INVALID_VALUE - One or more arguments were invalid.
496 * CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore.
497 * CSR_SDIO_RESULT_CRC_ERROR - A CRC error occured. No data read/written.
498 * CSR_SDIO_RESULT_TIMEOUT - No response from the device.
500 * NOTE: If the SDIO R5 response is available, and either of the
501 * FUNCTION_NUMBER or OUT_OF_RANGE bits are set,
502 * CSR_SDIO_RESULT_INVALID_VALUE shall be returned. If the ERROR bit
503 * is set (but none of FUNCTION_NUMBER or OUT_OF_RANGE),
504 * CSR_RESULT_FAILURE shall be returned. The ILLEGAL_COMMAND and
505 * COM_CRC_ERROR bits shall be ignored.
507 * If the CSPI response is available, and any of the
508 * FUNCTION_DISABLED or CLOCK_DISABLED bits are set,
509 * CSR_SDIO_RESULT_INVALID_VALUE will be returned.
511 * NOTE: The CsrSdioRead8Async and CsrSdioWrite8Async functions return
512 * immediately, and the supplied callback function is called when the
513 * operation is complete. The result value is given as an argument to
514 * the callback function.
516 *----------------------------------------------------------------------------*/
517 CsrResult CsrSdioRead8(CsrSdioFunction *function, u32 address, u8 *data);
518 CsrResult CsrSdioWrite8(CsrSdioFunction *function, u32 address, u8 data);
519 void CsrSdioRead8Async(CsrSdioFunction *function, u32 address, u8 *data, CsrSdioAsyncCallback callback);
520 void CsrSdioWrite8Async(CsrSdioFunction *function, u32 address, u8 data, CsrSdioAsyncCallback callback);
522 /*----------------------------------------------------------------------------*
524 * CsrSdioRead16, CsrSdioWrite16, CsrSdioRead16Async, CsrSdioWrite16Async
527 * Read/write a 16bit value from/to the specified register address.
530 * function - Pointer to struct representing the function.
531 * address - Register address within the function.
532 * data - The data to read/write.
533 * callback - The function to call on operation completion.
536 * CSR_RESULT_SUCCESS - The data was successfully read/written.
537 * CSR_RESULT_FAILURE - Unspecified/unknown error.
538 * CSR_SDIO_RESULT_INVALID_VALUE - One or more arguments were invalid.
539 * CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore.
540 * CSR_SDIO_RESULT_CRC_ERROR - A CRC error occured. Data may have been
541 * partially read/written.
542 * CSR_SDIO_RESULT_TIMEOUT - No response from the device.
544 * NOTE: If the SDIO R5 response is available, and either of the
545 * FUNCTION_NUMBER or OUT_OF_RANGE bits are set,
546 * CSR_SDIO_RESULT_INVALID_VALUE shall be returned. If the ERROR bit
547 * is set (but none of FUNCTION_NUMBER or OUT_OF_RANGE),
548 * CSR_RESULT_FAILURE shall be returned. The ILLEGAL_COMMAND and
549 * COM_CRC_ERROR bits shall be ignored.
551 * If the CSPI response is available, and any of the
552 * FUNCTION_DISABLED or CLOCK_DISABLED bits are set,
553 * CSR_SDIO_RESULT_INVALID_VALUE will be returned.
555 * NOTE: The CsrSdioRead16Async and CsrSdioWrite16Async functions return
556 * immediately, and the supplied callback function is called when the
557 * operation is complete. The result value is given as an argument to
558 * the callback function.
560 *----------------------------------------------------------------------------*/
561 CsrResult CsrSdioRead16(CsrSdioFunction *function, u32 address, u16 *data);
562 CsrResult CsrSdioWrite16(CsrSdioFunction *function, u32 address, u16 data);
563 void CsrSdioRead16Async(CsrSdioFunction *function, u32 address, u16 *data, CsrSdioAsyncCallback callback);
564 void CsrSdioWrite16Async(CsrSdioFunction *function, u32 address, u16 data, CsrSdioAsyncCallback callback);
566 /*----------------------------------------------------------------------------*
568 * CsrSdioF0Read8, CsrSdioF0Write8, CsrSdioF0Read8Async,
569 * CsrSdioF0Write8Async
572 * Read/write an 8bit value from/to the specified register address in
576 * function - Pointer to struct representing the function.
577 * address - Register address within the function.
578 * data - The data to read/write.
579 * callback - The function to call on operation completion.
582 * CSR_RESULT_SUCCESS - The data was successfully read/written.
583 * CSR_RESULT_FAILURE - Unspecified/unknown error.
584 * CSR_SDIO_RESULT_INVALID_VALUE - One or more arguments were invalid.
585 * CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore.
586 * CSR_SDIO_RESULT_CRC_ERROR - A CRC error occured. No data read/written.
587 * CSR_SDIO_RESULT_TIMEOUT - No response from the device.
589 * NOTE: If the SDIO R5 response is available, and either of the
590 * FUNCTION_NUMBER or OUT_OF_RANGE bits are set,
591 * CSR_SDIO_RESULT_INVALID_VALUE shall be returned. If the ERROR bit
592 * is set (but none of FUNCTION_NUMBER or OUT_OF_RANGE),
593 * CSR_RESULT_FAILURE shall be returned. The ILLEGAL_COMMAND and
594 * COM_CRC_ERROR bits shall be ignored.
596 * If the CSPI response is available, and any of the
597 * FUNCTION_DISABLED or CLOCK_DISABLED bits are set,
598 * CSR_SDIO_RESULT_INVALID_VALUE will be returned.
600 * NOTE: The CsrSdioF0Read8Async and CsrSdioF0Write8Async functions return
601 * immediately, and the supplied callback function is called when the
602 * operation is complete. The result value is given as an argument to
603 * the callback function.
605 *----------------------------------------------------------------------------*/
606 CsrResult CsrSdioF0Read8(CsrSdioFunction *function, u32 address, u8 *data);
607 CsrResult CsrSdioF0Write8(CsrSdioFunction *function, u32 address, u8 data);
608 void CsrSdioF0Read8Async(CsrSdioFunction *function, u32 address, u8 *data, CsrSdioAsyncCallback callback);
609 void CsrSdioF0Write8Async(CsrSdioFunction *function, u32 address, u8 data, CsrSdioAsyncCallback callback);
611 /*----------------------------------------------------------------------------*
613 * CsrSdioRead, CsrSdioWrite, CsrSdioReadAsync, CsrSdioWriteAsync
616 * Read/write a specified number of bytes from/to the specified register
620 * function - Pointer to struct representing the function.
621 * address - Register address within the function.
622 * data - The data to read/write.
623 * length - Number of byte to read/write.
624 * callback - The function to call on operation completion.
627 * CSR_RESULT_SUCCESS - The data was successfully read/written.
628 * CSR_RESULT_FAILURE - Unspecified/unknown error.
629 * CSR_SDIO_RESULT_INVALID_VALUE - One or more arguments were invalid.
630 * CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore.
631 * CSR_SDIO_RESULT_CRC_ERROR - A CRC error occured. Data may have been
632 * partially read/written.
633 * CSR_SDIO_RESULT_TIMEOUT - No response from the device.
635 * NOTE: If the SDIO R5 response is available, and either of the
636 * FUNCTION_NUMBER or OUT_OF_RANGE bits are set,
637 * CSR_SDIO_RESULT_INVALID_VALUE shall be returned. If the ERROR bit
638 * is set (but none of FUNCTION_NUMBER or OUT_OF_RANGE),
639 * CSR_RESULT_FAILURE shall be returned. The ILLEGAL_COMMAND and
640 * COM_CRC_ERROR bits shall be ignored.
642 * If the CSPI response is available, and any of the
643 * FUNCTION_DISABLED or CLOCK_DISABLED bits are set,
644 * CSR_SDIO_RESULT_INVALID_VALUE will be returned.
646 * NOTE: The CsrSdioF0Read8Async and CsrSdioF0Write8Async functions return
647 * immediately, and the supplied callback function is called when the
648 * operation is complete. The result value is given as an argument to
649 * the callback function.
651 *----------------------------------------------------------------------------*/
652 CsrResult CsrSdioRead(CsrSdioFunction *function, u32 address, void *data, u32 length);
653 CsrResult CsrSdioWrite(CsrSdioFunction *function, u32 address, const void *data, u32 length);
654 void CsrSdioReadAsync(CsrSdioFunction *function, u32 address, void *data, u32 length, CsrSdioAsyncCallback callback);
655 void CsrSdioWriteAsync(CsrSdioFunction *function, u32 address, const void *data, u32 length, CsrSdioAsyncCallback callback);
657 /*----------------------------------------------------------------------------*
659 * CsrSdioPowerOn, CsrSdioPowerOff
662 * Power on/off the device.
665 * function - Pointer to struct representing the function that resides on
666 * the device to power on/off.
668 * RETURNS (only CsrSdioPowerOn)
669 * CSR_RESULT_SUCCESS - Power was succesfully reapplied and the device
670 * has been reinitialised.
671 * CSR_RESULT_FAILURE - Unspecified/unknown error.
672 * CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore.
673 * CSR_SDIO_RESULT_CRC_ERROR - A CRC error occured during reinitialisation.
674 * CSR_SDIO_RESULT_TIMEOUT - No response from the device during
676 * CSR_SDIO_RESULT_NOT_RESET - The power was not removed by the
677 * CsrSdioPowerOff call. The state of the
678 * device is unchanged.
680 *----------------------------------------------------------------------------*/
681 CsrResult CsrSdioPowerOn(CsrSdioFunction *function);
682 void CsrSdioPowerOff(CsrSdioFunction *function);
684 /*----------------------------------------------------------------------------*
689 * Perform a hardware reset of the device.
692 * function - Pointer to struct representing the function that resides on
693 * the device to hard reset.
696 * CSR_RESULT_SUCCESS - Reset was succesfully performed and the device
697 * has been reinitialised.
698 * CSR_RESULT_FAILURE - Unspecified/unknown error.
699 * CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore.
700 * CSR_SDIO_RESULT_CRC_ERROR - A CRC error occured during reinitialisation.
701 * CSR_SDIO_RESULT_TIMEOUT - No response from the device during
703 * CSR_SDIO_RESULT_NOT_RESET - The reset was not applied because it is not
704 * supported. The state of the device is
707 *----------------------------------------------------------------------------*/
708 CsrResult CsrSdioHardReset(CsrSdioFunction *function);
710 /*----------------------------------------------------------------------------*
712 * CsrSdioFunctionActive, CsrSdioFunctionIdle
717 * function - Pointer to struct representing the function.
719 *----------------------------------------------------------------------------*/
720 void CsrSdioFunctionActive(CsrSdioFunction *function);
721 void CsrSdioFunctionIdle(CsrSdioFunction *function);