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"
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 */
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 */
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
36 /*----------------------------------------------------------------------------*
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.
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)
51 *----------------------------------------------------------------------------*/
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 */
60 /*----------------------------------------------------------------------------*
65 * This structure represents a single function on a device.
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.
82 *----------------------------------------------------------------------------*/
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 */
93 /*----------------------------------------------------------------------------*
95 * CsrSdioInsertedCallback, CsrSdioRemovedCallback
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.
104 * NOTE: These functions are implemented by the Function Driver, and are
105 * passed as function pointers in the CsrSdioFunctionDriver struct.
108 * function - Pointer to struct representing the function.
110 *----------------------------------------------------------------------------*/
111 typedef void (*CsrSdioInsertedCallback)(CsrSdioFunction *function);
112 typedef void (*CsrSdioRemovedCallback)(CsrSdioFunction *function);
114 /*----------------------------------------------------------------------------*
116 * CsrSdioInterruptDsrCallback, CsrSdioInterruptCallback
119 * CsrSdioInterruptCallback is called when an interrupt occurs on the
120 * the device associated with the specified function.
122 * NOTE: These functions are implemented by the Function Driver, and are
123 * passed as function pointers in the CsrSdioFunctionDriver struct.
126 * function - Pointer to struct representing the function.
128 * RETURNS (only CsrSdioInterruptCallback)
129 * A pointer to a CsrSdioInterruptDsrCallback function.
131 *----------------------------------------------------------------------------*/
132 typedef void (*CsrSdioInterruptDsrCallback)(CsrSdioFunction *function);
133 typedef CsrSdioInterruptDsrCallback (*CsrSdioInterruptCallback)(CsrSdioFunction *function);
135 /*----------------------------------------------------------------------------*
137 * CsrSdioSuspendCallback, CsrSdioResumeCallback
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.
144 * NOTE: These functions are implemented by the Function Driver, and are
145 * passed as function pointers in the CsrSdioFunctionDriver struct.
148 * function - Pointer to struct representing the function.
150 *----------------------------------------------------------------------------*/
151 typedef void (*CsrSdioSuspendCallback)(CsrSdioFunction *function);
152 typedef void (*CsrSdioResumeCallback)(CsrSdioFunction *function);
154 /*----------------------------------------------------------------------------*
156 * CsrSdioAsyncCallback, CsrSdioAsyncDsrCallback
159 * CsrSdioAsyncCallback is called when an asynchronous operation completes.
161 * NOTE: These functions are implemented by the Function Driver, and are
162 * passed as function pointers in the function calls that initiate
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.
170 * RETURNS (only CsrSdioAsyncCallback)
171 * A pointer to a CsrSdioAsyncDsrCallback function.
173 *----------------------------------------------------------------------------*/
174 typedef void (*CsrSdioAsyncDsrCallback)(CsrSdioFunction *function, CsrResult result);
175 typedef CsrSdioAsyncDsrCallback (*CsrSdioAsyncCallback)(CsrSdioFunction *function, CsrResult result);
177 /*----------------------------------------------------------------------------*
179 * CsrSdioFunctionDriver
182 * Structure representing a Function Driver.
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
197 *----------------------------------------------------------------------------*/
200 CsrSdioInsertedCallback inserted;
201 CsrSdioRemovedCallback removed;
202 CsrSdioInterruptCallback intr;
203 CsrSdioSuspendCallback suspend;
204 CsrSdioResumeCallback resume;
205 CsrSdioFunctionId *ids;
207 void *priv; /* For use by the SDIO Driver */
208 } CsrSdioFunctionDriver;
210 /*----------------------------------------------------------------------------*
212 * CsrSdioFunctionDriverRegister
215 * Register a Function Driver.
218 * functionDriver - Pointer to struct describing the Function Driver.
221 * CSR_RESULT_SUCCESS - The Function Driver was successfully
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.
231 *----------------------------------------------------------------------------*/
232 CsrResult CsrSdioFunctionDriverRegister(CsrSdioFunctionDriver *functionDriver);
234 /*----------------------------------------------------------------------------*
236 * CsrSdioFunctionDriverUnregister
239 * Unregister a previously registered Function Driver.
242 * functionDriver - pointer to struct describing the Function Driver.
244 *----------------------------------------------------------------------------*/
245 void CsrSdioFunctionDriverUnregister(CsrSdioFunctionDriver *functionDriver);
247 /*----------------------------------------------------------------------------*
249 * CsrSdioFunctionEnable, CsrSdioFunctionDisable
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.
258 * function - Pointer to struct representing the function.
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
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.
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.
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.
282 *----------------------------------------------------------------------------*/
283 CsrResult CsrSdioFunctionEnable(CsrSdioFunction *function);
284 CsrResult CsrSdioFunctionDisable(CsrSdioFunction *function);
286 /*----------------------------------------------------------------------------*
288 * CsrSdioInterruptEnable, CsrSdioInterruptDisable
291 * Enable/disable the interrupt for the specified function by
292 * setting/clearing the corresponding bit in the INT Enable register in
296 * function - Pointer to struct representing the function.
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
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.
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.
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.
322 *----------------------------------------------------------------------------*/
323 CsrResult CsrSdioInterruptEnable(CsrSdioFunction *function);
324 CsrResult CsrSdioInterruptDisable(CsrSdioFunction *function);
326 /*----------------------------------------------------------------------------*
328 * CsrSdioInterruptAcknowledge
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.
336 * function - Pointer to struct representing the function to which the
337 * event was signalled.
339 *----------------------------------------------------------------------------*/
340 void CsrSdioInterruptAcknowledge(CsrSdioFunction *function);
342 /*----------------------------------------------------------------------------*
344 * CsrSdioInsertedAcknowledge, CsrSdioRemovedAcknowledge
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.
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
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
366 *----------------------------------------------------------------------------*/
367 void CsrSdioInsertedAcknowledge(CsrSdioFunction *function, CsrResult result);
368 void CsrSdioRemovedAcknowledge(CsrSdioFunction *function);
370 /*----------------------------------------------------------------------------*
372 * CsrSdioSuspendAcknowledge, CsrSdioResumeAcknowledge
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.
380 * function - Pointer to struct representing the function to which the
381 * event was signalled.
383 * CSR_RESULT_SUCCESS - Successfully suspended/resumed.
384 * CSR_RESULT_FAILURE - Unspecified/unknown error.
386 *----------------------------------------------------------------------------*/
387 void CsrSdioSuspendAcknowledge(CsrSdioFunction *function, CsrResult result);
388 void CsrSdioResumeAcknowledge(CsrSdioFunction *function, CsrResult result);
390 /*----------------------------------------------------------------------------*
392 * CsrSdioBlockSizeSet
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.
401 * When this function returns, the actual configured block size is
402 * available in the blockSize member of the function struct.
405 * function - Pointer to struct representing the function.
406 * blockSize - Block size to use for the function. Valid range is 1 to
410 * CSR_RESULT_SUCCESS - The block size register on the chip
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
417 * CSR_SDIO_RESULT_TIMEOUT - No response from the device.
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.
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.
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.
435 *----------------------------------------------------------------------------*/
436 CsrResult CsrSdioBlockSizeSet(CsrSdioFunction *function, u16 blockSize);
438 /*----------------------------------------------------------------------------*
440 * CsrSdioMaxBusClockFrequencySet
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
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.
455 * Note that the clock frequency configured affects all functions on the
459 * function - Pointer to struct representing the function.
460 * maxFrequency - The maximum clock frequency for the function in Hertz.
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.
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.
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.
480 *----------------------------------------------------------------------------*/
481 CsrResult CsrSdioMaxBusClockFrequencySet(CsrSdioFunction *function, u32 maxFrequency);
483 /*----------------------------------------------------------------------------*
485 * CsrSdioRead8, CsrSdioWrite8, CsrSdioRead8Async, CsrSdioWrite8Async
488 * Read/write an 8bit value from/to the specified register address.
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.
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.
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.
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.
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.
520 *----------------------------------------------------------------------------*/
521 CsrResult CsrSdioRead8(CsrSdioFunction *function, u32 address, u8 *data);
522 CsrResult CsrSdioWrite8(CsrSdioFunction *function, u32 address, u8 data);
523 void CsrSdioRead8Async(CsrSdioFunction *function, u32 address, u8 *data, CsrSdioAsyncCallback callback);
524 void CsrSdioWrite8Async(CsrSdioFunction *function, u32 address, u8 data, CsrSdioAsyncCallback callback);
526 /*----------------------------------------------------------------------------*
528 * CsrSdioRead16, CsrSdioWrite16, CsrSdioRead16Async, CsrSdioWrite16Async
531 * Read/write a 16bit value from/to the specified register address.
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.
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.
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.
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.
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.
564 *----------------------------------------------------------------------------*/
565 CsrResult CsrSdioRead16(CsrSdioFunction *function, u32 address, u16 *data);
566 CsrResult CsrSdioWrite16(CsrSdioFunction *function, u32 address, u16 data);
567 void CsrSdioRead16Async(CsrSdioFunction *function, u32 address, u16 *data, CsrSdioAsyncCallback callback);
568 void CsrSdioWrite16Async(CsrSdioFunction *function, u32 address, u16 data, CsrSdioAsyncCallback callback);
570 /*----------------------------------------------------------------------------*
572 * CsrSdioF0Read8, CsrSdioF0Write8, CsrSdioF0Read8Async,
573 * CsrSdioF0Write8Async
576 * Read/write an 8bit value from/to the specified register address in
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.
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.
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.
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.
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.
609 *----------------------------------------------------------------------------*/
610 CsrResult CsrSdioF0Read8(CsrSdioFunction *function, u32 address, u8 *data);
611 CsrResult CsrSdioF0Write8(CsrSdioFunction *function, u32 address, u8 data);
612 void CsrSdioF0Read8Async(CsrSdioFunction *function, u32 address, u8 *data, CsrSdioAsyncCallback callback);
613 void CsrSdioF0Write8Async(CsrSdioFunction *function, u32 address, u8 data, CsrSdioAsyncCallback callback);
615 /*----------------------------------------------------------------------------*
617 * CsrSdioRead, CsrSdioWrite, CsrSdioReadAsync, CsrSdioWriteAsync
620 * Read/write a specified number of bytes from/to the specified register
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.
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.
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.
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.
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.
655 *----------------------------------------------------------------------------*/
656 CsrResult CsrSdioRead(CsrSdioFunction *function, u32 address, void *data, u32 length);
657 CsrResult CsrSdioWrite(CsrSdioFunction *function, u32 address, const void *data, u32 length);
658 void CsrSdioReadAsync(CsrSdioFunction *function, u32 address, void *data, u32 length, CsrSdioAsyncCallback callback);
659 void CsrSdioWriteAsync(CsrSdioFunction *function, u32 address, const void *data, u32 length, CsrSdioAsyncCallback callback);
661 /*----------------------------------------------------------------------------*
663 * CsrSdioPowerOn, CsrSdioPowerOff
666 * Power on/off the device.
669 * function - Pointer to struct representing the function that resides on
670 * the device to power on/off.
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
680 * CSR_SDIO_RESULT_NOT_RESET - The power was not removed by the
681 * CsrSdioPowerOff call. The state of the
682 * device is unchanged.
684 *----------------------------------------------------------------------------*/
685 CsrResult CsrSdioPowerOn(CsrSdioFunction *function);
686 void CsrSdioPowerOff(CsrSdioFunction *function);
688 /*----------------------------------------------------------------------------*
693 * Perform a hardware reset of the device.
696 * function - Pointer to struct representing the function that resides on
697 * the device to hard reset.
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
707 * CSR_SDIO_RESULT_NOT_RESET - The reset was not applied because it is not
708 * supported. The state of the device is
711 *----------------------------------------------------------------------------*/
712 CsrResult CsrSdioHardReset(CsrSdioFunction *function);
714 /*----------------------------------------------------------------------------*
716 * CsrSdioFunctionActive, CsrSdioFunctionIdle
721 * function - Pointer to struct representing the function.
723 *----------------------------------------------------------------------------*/
724 void CsrSdioFunctionActive(CsrSdioFunction *function);
725 void CsrSdioFunctionIdle(CsrSdioFunction *function);