00001 /* 00002 * Synergy compatible API -- SDIO. 00003 * 00004 * Copyright (C) 2010 Cambridge Silicon Radio Ltd. 00005 * 00006 * Refer to LICENSE.txt included with this source code for details on 00007 * the license terms. 00008 */ 00009 #ifndef CSR_SDIO_H__ 00010 #define CSR_SDIO_H__ 00011 00012 #include "csr_types.h" 00013 #include "csr_result.h" 00014 00015 #ifdef __cplusplus 00016 extern "C" { 00017 #endif 00018 00019 /* Result Codes */ 00020 #define CSR_SDIO_RESULT_INVALID_VALUE ((CsrResult) 1) /* Invalid argument value */ 00021 #define CSR_SDIO_RESULT_NO_DEVICE ((CsrResult) 2) /* The specified device is no longer present */ 00022 #define CSR_SDIO_RESULT_CRC_ERROR ((CsrResult) 3) /* The transmitted/received data or command response contained a CRC error */ 00023 #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 */ 00024 #define CSR_SDIO_RESULT_NOT_RESET ((CsrResult) 5) /* The device was not reset */ 00025 00026 /* Features (for use in features member of CsrSdioFunction) */ 00027 #define CSR_SDIO_FEATURE_BYTE_MODE 0x00000001 /* Transfer sizes do not have to be a multiple of block size */ 00028 #define CSR_SDIO_FEATURE_DMA_CAPABLE_MEM_REQUIRED 0x00000002 /* Bulk operations require DMA friendly memory */ 00029 00030 /* CsrSdioFunctionId wildcards (for use in CsrSdioFunctionId members) */ 00031 #define CSR_SDIO_ANY_MANF_ID 0xFFFF 00032 #define CSR_SDIO_ANY_CARD_ID 0xFFFF 00033 #define CSR_SDIO_ANY_SDIO_FUNCTION 0xFF 00034 #define CSR_SDIO_ANY_SDIO_INTERFACE 0xFF 00035 00036 /*----------------------------------------------------------------------------* 00037 * NAME 00038 * CsrSdioFunctionId 00039 * 00040 * DESCRIPTION 00041 * This structure describes one or more functions of a device, based on 00042 * four qualitative measures. The CsrSdioFunctionId wildcard defines can be 00043 * used for making the CsrSdioFunctionId match more than one function. 00044 * 00045 * MEMBERS 00046 * manfId - Vendor ID (or CSR_SDIO_ANY_MANF_ID). 00047 * cardId - Device ID (or CSR_SDIO_ANY_CARD_ID). 00048 * sdioFunction - SDIO Function number (or CSR_SDIO_ANY_SDIO_FUNCTION). 00049 * sdioInterface - SDIO Standard Interface Code (or CSR_SDIO_ANY_SDIO_INTERFACE) 00050 * 00051 *----------------------------------------------------------------------------*/ 00052 typedef struct 00053 { 00054 CsrUint16 manfId; /* Vendor ID to match or CSR_SDIO_ANY_MANF_ID */ 00055 CsrUint16 cardId; /* Device ID to match or CSR_SDIO_ANY_CARD_ID */ 00056 CsrUint8 sdioFunction; /* SDIO Function number to match or CSR_SDIO_ANY_SDIO_FUNCTION */ 00057 CsrUint8 sdioInterface; /* SDIO Standard Interface Code to match or CSR_SDIO_ANY_SDIO_INTERFACE */ 00058 } CsrSdioFunctionId; 00059 00060 /*----------------------------------------------------------------------------* 00061 * NAME 00062 * CsrSdioFunction 00063 * 00064 * DESCRIPTION 00065 * This structure represents a single function on a device. 00066 * 00067 * MEMBERS 00068 * sdioId - A CsrSdioFunctionId describing this particular function. The 00069 * subfield shall not contain any CsrSdioFunctionId wildcards. The 00070 * subfields shall describe the specific single function 00071 * represented by this structure. 00072 * blockSize - Actual configured block size, or 0 if unconfigured. 00073 * features - Bit mask with any of CSR_SDIO_FEATURE_* set. 00074 * driverData - For use by the Function Driver. The SDIO Driver shall not 00075 * attempt to dereference the pointer. 00076 * priv - For use by the SDIO Driver. The Function Driver shall not attempt 00077 * to dereference the pointer. 00078 * 00079 *----------------------------------------------------------------------------*/ 00080 typedef struct 00081 { 00082 CsrSdioFunctionId sdioId; 00083 CsrUint16 blockSize; /* Actual configured block size, or 0 if unconfigured */ 00084 CsrUint32 features; /* Bit mask with any of CSR_SDIO_FEATURE_* set */ 00085 void *cardHandle; /* An opaque handle for this function's card. */ 00086 void *osDevice; 00087 void *driverData; /* For use by the Function Driver */ 00088 void *priv; /* For use by the SDIO Driver */ 00089 } CsrSdioFunction; 00090 00091 /*----------------------------------------------------------------------------* 00092 * NAME 00093 * CsrSdioInsertedCallback, CsrSdioRemovedCallback 00094 * 00095 * DESCRIPTION 00096 * CsrSdioInsertedCallback is called when a function becomes available to 00097 * a registered Function Driver that supports the function. 00098 * CsrSdioRemovedCallback is called when a function is no longer available 00099 * to a Function Driver, either because the device has been removed, or the 00100 * Function Driver has been unregistered. 00101 * 00102 * NOTE: These functions are implemented by the Function Driver, and are 00103 * passed as function pointers in the CsrSdioFunctionDriver struct. 00104 * 00105 * PARAMETERS 00106 * function - Pointer to struct representing the function. 00107 * 00108 *----------------------------------------------------------------------------*/ 00109 typedef void (*CsrSdioInsertedCallback)(CsrSdioFunction *function); 00110 typedef void (*CsrSdioRemovedCallback)(CsrSdioFunction *function); 00111 00112 /*----------------------------------------------------------------------------* 00113 * NAME 00114 * CsrSdioInterruptDsrCallback, CsrSdioInterruptCallback 00115 * 00116 * DESCRIPTION 00117 * CsrSdioInterruptCallback is called when an interrupt occurs on the 00118 * the device associated with the specified function. 00119 * 00120 * NOTE: These functions are implemented by the Function Driver, and are 00121 * passed as function pointers in the CsrSdioFunctionDriver struct. 00122 * 00123 * PARAMETERS 00124 * function - Pointer to struct representing the function. 00125 * 00126 * RETURNS (only CsrSdioInterruptCallback) 00127 * A pointer to a CsrSdioInterruptDsrCallback function. 00128 * 00129 *----------------------------------------------------------------------------*/ 00130 typedef void (*CsrSdioInterruptDsrCallback)(CsrSdioFunction *function); 00131 typedef CsrSdioInterruptDsrCallback (*CsrSdioInterruptCallback)(CsrSdioFunction *function); 00132 00133 /*----------------------------------------------------------------------------* 00134 * NAME 00135 * CsrSdioSuspendCallback, CsrSdioResumeCallback 00136 * 00137 * DESCRIPTION 00138 * CsrSdioSuspendCallback is called when the system is preparing to go 00139 * into a suspended state. CsrSdioResumeCallback is called when the system 00140 * has entered an active state again. 00141 * 00142 * NOTE: These functions are implemented by the Function Driver, and are 00143 * passed as function pointers in the CsrSdioFunctionDriver struct. 00144 * 00145 * PARAMETERS 00146 * function - Pointer to struct representing the function. 00147 * 00148 *----------------------------------------------------------------------------*/ 00149 typedef void (*CsrSdioSuspendCallback)(CsrSdioFunction *function); 00150 typedef void (*CsrSdioResumeCallback)(CsrSdioFunction *function); 00151 00152 /*----------------------------------------------------------------------------* 00153 * NAME 00154 * CsrSdioAsyncCallback, CsrSdioAsyncDsrCallback 00155 * 00156 * DESCRIPTION 00157 * CsrSdioAsyncCallback is called when an asynchronous operation completes. 00158 * 00159 * NOTE: These functions are implemented by the Function Driver, and are 00160 * passed as function pointers in the function calls that initiate 00161 * the operation. 00162 * 00163 * PARAMETERS 00164 * function - Pointer to struct representing the function. 00165 * result - The result of the operation that completed. See the description 00166 * of the initiating function for possible result values. 00167 * 00168 * RETURNS (only CsrSdioAsyncCallback) 00169 * A pointer to a CsrSdioAsyncDsrCallback function. 00170 * 00171 *----------------------------------------------------------------------------*/ 00172 typedef void (*CsrSdioAsyncDsrCallback)(CsrSdioFunction *function, CsrResult result); 00173 typedef CsrSdioAsyncDsrCallback (*CsrSdioAsyncCallback)(CsrSdioFunction *function, CsrResult result); 00174 00175 typedef struct 00176 { 00177 CsrSdioInsertedCallback inserted; 00178 CsrSdioRemovedCallback removed; 00179 CsrSdioInterruptCallback intr; 00180 CsrSdioSuspendCallback suspend; 00181 CsrSdioResumeCallback resume; 00182 CsrSdioFunctionId *ids; 00183 CsrUint8 idsCount; 00184 void *priv; 00185 } CsrSdioFunctionDriver; 00186 00187 /*----------------------------------------------------------------------------* 00188 * NAME 00189 * CsrSdioFunctionDriverRegister 00190 * 00191 * DESCRIPTION 00192 * Register a Function Driver. 00193 * 00194 * PARAMETERS 00195 * functionDriver - Pointer to struct describing the Function Driver. 00196 * 00197 * RETURNS 00198 * CSR_RESULT_SUCCESS - The Function Driver was successfully 00199 * registered. 00200 * CSR_RESULT_FAILURE - Unable to register the function driver, 00201 * because of an unspecified/unknown error. The 00202 * Function Driver has not been registered. 00203 * CSR_SDIO_RESULT_INVALID_VALUE - The specified Function Driver pointer 00204 * does not point at a valid Function 00205 * Driver structure, or some of the members 00206 * contain invalid entries. 00207 * 00208 *----------------------------------------------------------------------------*/ 00209 CsrResult CsrSdioFunctionDriverRegister(CsrSdioFunctionDriver *functionDriver); 00210 00211 /*----------------------------------------------------------------------------* 00212 * NAME 00213 * CsrSdioFunctionDriverUnregister 00214 * 00215 * DESCRIPTION 00216 * Unregister a previously registered Function Driver. 00217 * 00218 * PARAMETERS 00219 * functionDriver - pointer to struct describing the Function Driver. 00220 * 00221 *----------------------------------------------------------------------------*/ 00222 void CsrSdioFunctionDriverUnregister(CsrSdioFunctionDriver *functionDriver); 00223 00224 /*----------------------------------------------------------------------------* 00225 * NAME 00226 * CsrSdioFunctionEnable, CsrSdioFunctionDisable 00227 * 00228 * DESCRIPTION 00229 * Enable/disable the specified function by setting/clearing the 00230 * corresponding bit in the I/O Enable register in function 0, and then 00231 * periodically reading the related bit in the I/O Ready register until it 00232 * is set/clear, limited by an implementation defined timeout. 00233 * 00234 * PARAMETERS 00235 * function - Pointer to struct representing the function. 00236 * 00237 * RETURNS 00238 * CSR_RESULT_SUCCESS - The specified function was enabled/disabled. 00239 * CSR_RESULT_FAILURE - Unspecified/unknown error. 00240 * CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore. 00241 * CSR_SDIO_RESULT_CRC_ERROR - A CRC error occured. The state of the 00242 * related bit in the I/O Enable register is 00243 * undefined. 00244 * CSR_SDIO_RESULT_TIMEOUT - No response from the device, or the related 00245 * bit in the I/O ready register was not 00246 * set/cleared within the timeout period. 00247 * 00248 * NOTE: If the SDIO R5 response is available, and either of the 00249 * FUNCTION_NUMBER or OUT_OF_RANGE bits are set, 00250 * CSR_SDIO_RESULT_INVALID_VALUE shall be returned. If the ERROR bit 00251 * is set (but none of FUNCTION_NUMBER or OUT_OF_RANGE), 00252 * CSR_RESULT_FAILURE shall be returned. The ILLEGAL_COMMAND and 00253 * COM_CRC_ERROR bits shall be ignored. 00254 * 00255 * If the CSPI response is available, and any of the 00256 * FUNCTION_DISABLED or CLOCK_DISABLED bits are set, 00257 * CSR_SDIO_RESULT_INVALID_VALUE will be returned. 00258 * 00259 *----------------------------------------------------------------------------*/ 00260 CsrResult CsrSdioFunctionEnable(CsrSdioFunction *function); 00261 CsrResult CsrSdioFunctionDisable(CsrSdioFunction *function); 00262 00263 /*----------------------------------------------------------------------------* 00264 * NAME 00265 * CsrSdioInterruptEnable, CsrSdioInterruptDisable 00266 * 00267 * DESCRIPTION 00268 * Enable/disable the interrupt for the specified function by 00269 * setting/clearing the corresponding bit in the INT Enable register in 00270 * function 0. 00271 * 00272 * PARAMETERS 00273 * function - Pointer to struct representing the function. 00274 * 00275 * RETURNS 00276 * CSR_RESULT_SUCCESS - The specified function was enabled/disabled. 00277 * CSR_RESULT_FAILURE - Unspecified/unknown error. 00278 * CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore. 00279 * CSR_SDIO_RESULT_CRC_ERROR - A CRC error occured. The state of the 00280 * related bit in the INT Enable register is 00281 * unchanged. 00282 * CSR_SDIO_RESULT_INVALID_VALUE - The specified function cannot be 00283 * enabled/disabled, because it either 00284 * does not exist or it is not possible to 00285 * individually enable/disable functions. 00286 * CSR_SDIO_RESULT_TIMEOUT - No response from the device. 00287 * 00288 * NOTE: If the SDIO R5 response is available, and either of the 00289 * FUNCTION_NUMBER or OUT_OF_RANGE bits are set, 00290 * CSR_SDIO_RESULT_INVALID_VALUE shall be returned. If the ERROR bit 00291 * is set (but none of FUNCTION_NUMBER or OUT_OF_RANGE), 00292 * CSR_RESULT_FAILURE shall be returned. The ILLEGAL_COMMAND and 00293 * COM_CRC_ERROR bits shall be ignored. 00294 * 00295 * If the CSPI response is available, and any of the 00296 * FUNCTION_DISABLED or CLOCK_DISABLED bits are set, 00297 * CSR_SDIO_RESULT_INVALID_VALUE will be returned. 00298 * 00299 *----------------------------------------------------------------------------*/ 00300 CsrResult CsrSdioInterruptEnable(CsrSdioFunction *function); 00301 CsrResult CsrSdioInterruptDisable(CsrSdioFunction *function); 00302 00303 /*----------------------------------------------------------------------------* 00304 * NAME 00305 * CsrSdioInterruptAcknowledge 00306 * 00307 * DESCRIPTION 00308 * Acknowledge that a signalled interrupt has been handled. Shall only 00309 * be called once, and exactly once for each signalled interrupt to the 00310 * corresponding function. 00311 * 00312 * PARAMETERS 00313 * function - Pointer to struct representing the function to which the 00314 * event was signalled. 00315 * 00316 *----------------------------------------------------------------------------*/ 00317 void CsrSdioInterruptAcknowledge(CsrSdioFunction *function); 00318 00319 /*----------------------------------------------------------------------------* 00320 * NAME 00321 * CsrSdioInsertedAcknowledge, CsrSdioRemovedAcknowledge 00322 * 00323 * DESCRIPTION 00324 * Acknowledge that a signalled inserted/removed event has been handled. 00325 * Shall only be called once, and exactly once for each signalled event to 00326 * the corresponding function. 00327 * 00328 * PARAMETERS 00329 * function - Pointer to struct representing the function to which the 00330 * inserted was signalled. 00331 * result (CsrSdioInsertedAcknowledge only) 00332 * CSR_RESULT_SUCCESS - The Function Driver has accepted the 00333 * function, and the function is attached to 00334 * the Function Driver until the 00335 * CsrSdioRemovedCallback is called and 00336 * acknowledged. 00337 * CSR_RESULT_FAILURE - Unable to accept the function. The 00338 * function is not attached to the Function 00339 * Driver, and it may be passed to another 00340 * Function Driver which supports the 00341 * function. 00342 * 00343 *----------------------------------------------------------------------------*/ 00344 void CsrSdioInsertedAcknowledge(CsrSdioFunction *function, CsrResult result); 00345 void CsrSdioRemovedAcknowledge(CsrSdioFunction *function); 00346 00347 /*----------------------------------------------------------------------------* 00348 * NAME 00349 * CsrSdioSuspendAcknowledge, CsrSdioResumeAcknowledge 00350 * 00351 * DESCRIPTION 00352 * Acknowledge that a signalled suspend event has been handled. Shall only 00353 * be called once, and exactly once for each signalled event to the 00354 * corresponding function. 00355 * 00356 * PARAMETERS 00357 * function - Pointer to struct representing the function to which the 00358 * event was signalled. 00359 * result 00360 * CSR_RESULT_SUCCESS - Successfully suspended/resumed. 00361 * CSR_RESULT_FAILURE - Unspecified/unknown error. 00362 * 00363 *----------------------------------------------------------------------------*/ 00364 void CsrSdioSuspendAcknowledge(CsrSdioFunction *function, CsrResult result); 00365 void CsrSdioResumeAcknowledge(CsrSdioFunction *function, CsrResult result); 00366 00367 /*----------------------------------------------------------------------------* 00368 * NAME 00369 * CsrSdioBlockSizeSet 00370 * 00371 * DESCRIPTION 00372 * Set the block size to use for the function. The actual configured block 00373 * size shall be the minimum of: 00374 * 1) Maximum block size supported by the function. 00375 * 2) Maximum block size supported by the host controller. 00376 * 3) The block size specified by the blockSize argument. 00377 * 00378 * When this function returns, the actual configured block size is 00379 * available in the blockSize member of the function struct. 00380 * 00381 * PARAMETERS 00382 * function - Pointer to struct representing the function. 00383 * blockSize - Block size to use for the function. Valid range is 1 to 00384 * 2048. 00385 * 00386 * RETURNS 00387 * CSR_RESULT_SUCCESS - The block size register on the chip 00388 * was updated. 00389 * CSR_RESULT_FAILURE - Unspecified/unknown error. 00390 * CSR_SDIO_RESULT_INVALID_VALUE - One or more arguments were invalid. 00391 * CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore. 00392 * CSR_SDIO_RESULT_CRC_ERROR - A CRC error occured. The configured block 00393 * size is undefined. 00394 * CSR_SDIO_RESULT_TIMEOUT - No response from the device. 00395 * 00396 * NOTE: If the SDIO R5 response is available, and the FUNCTION_NUMBER 00397 * bits is set, CSR_SDIO_RESULT_INVALID_VALUE shall be returned. 00398 * If the ERROR bit is set (but not FUNCTION_NUMBER), 00399 * CSR_RESULT_FAILURE shall be returned. The ILLEGAL_COMMAND and 00400 * COM_CRC_ERROR bits shall be ignored. 00401 * 00402 * If the CSPI response is available, and any of the 00403 * FUNCTION_DISABLED or CLOCK_DISABLED bits are set, 00404 * CSR_SDIO_RESULT_INVALID_VALUE will be returned. 00405 * 00406 * NOTE: Setting the block size requires two individual operations. The 00407 * implementation shall ignore the OUT_OF_RANGE bit of the SDIO R5 00408 * response for the first operation, as the partially configured 00409 * block size may be out of range, even if the final block size 00410 * (after the second operation) is in the valid range. 00411 * 00412 *----------------------------------------------------------------------------*/ 00413 CsrResult CsrSdioBlockSizeSet(CsrSdioFunction *function, CsrUint16 blockSize); 00414 00415 /*----------------------------------------------------------------------------* 00416 * NAME 00417 * CsrSdioMaxBusClockFrequencySet 00418 * 00419 * DESCRIPTION 00420 * Set the maximum clock frequency to use for the device associated with 00421 * the specified function. The actual configured clock frequency for the 00422 * device shall be the minimum of: 00423 * 1) Maximum clock frequency supported by the device. 00424 * 2) Maximum clock frequency supported by the host controller. 00425 * 3) Maximum clock frequency specified for any function on the same 00426 * device. 00427 * 00428 * If the clock frequency exceeds 25MHz, it is the responsibility of the 00429 * SDIO driver to enable high speed mode on the device, using the standard 00430 * defined procedure, before increasing the frequency beyond the limit. 00431 * 00432 * Note that the clock frequency configured affects all functions on the 00433 * same device. 00434 * 00435 * PARAMETERS 00436 * function - Pointer to struct representing the function. 00437 * maxFrequency - The maximum clock frequency for the function in Hertz. 00438 * 00439 * RETURNS 00440 * CSR_RESULT_SUCCESS - The maximum clock frequency was succesfully 00441 * set for the function. 00442 * CSR_RESULT_FAILURE - Unspecified/unknown error. 00443 * CSR_SDIO_RESULT_INVALID_VALUE - One or more arguments were invalid. 00444 * CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore. 00445 * 00446 * NOTE: If the SDIO R5 response is available, and the FUNCTION_NUMBER 00447 * bits is set, CSR_SDIO_RESULT_INVALID_VALUE shall be returned. 00448 * If the ERROR bit is set (but not FUNCTION_NUMBER), 00449 * CSR_RESULT_FAILURE shall be returned. The ILLEGAL_COMMAND and 00450 * COM_CRC_ERROR bits shall be ignored. 00451 * 00452 * If the CSPI response is available, and any of the 00453 * FUNCTION_DISABLED or CLOCK_DISABLED bits are set, 00454 * CSR_SDIO_RESULT_INVALID_VALUE will be returned. 00455 * 00456 * 00457 *----------------------------------------------------------------------------*/ 00458 CsrResult CsrSdioMaxBusClockFrequencySet(CsrSdioFunction *function, CsrUint32 maxFrequency); 00459 00460 /*----------------------------------------------------------------------------* 00461 * NAME 00462 * CsrSdioRead8, CsrSdioWrite8, CsrSdioRead8Async, CsrSdioWrite8Async 00463 * 00464 * DESCRIPTION 00465 * Read/write an 8bit value from/to the specified register address. 00466 * 00467 * PARAMETERS 00468 * function - Pointer to struct representing the function. 00469 * address - Register address within the function. 00470 * data - The data to read/write. 00471 * callback - The function to call on operation completion. 00472 * 00473 * RETURNS 00474 * CSR_RESULT_SUCCESS - The data was successfully read/written. 00475 * CSR_RESULT_FAILURE - Unspecified/unknown error. 00476 * CSR_SDIO_RESULT_INVALID_VALUE - One or more arguments were invalid. 00477 * CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore. 00478 * CSR_SDIO_RESULT_CRC_ERROR - A CRC error occured. No data read/written. 00479 * CSR_SDIO_RESULT_TIMEOUT - No response from the device. 00480 * 00481 * NOTE: If the SDIO R5 response is available, and either of the 00482 * FUNCTION_NUMBER or OUT_OF_RANGE bits are set, 00483 * CSR_SDIO_RESULT_INVALID_VALUE shall be returned. If the ERROR bit 00484 * is set (but none of FUNCTION_NUMBER or OUT_OF_RANGE), 00485 * CSR_RESULT_FAILURE shall be returned. The ILLEGAL_COMMAND and 00486 * COM_CRC_ERROR bits shall be ignored. 00487 * 00488 * If the CSPI response is available, and any of the 00489 * FUNCTION_DISABLED or CLOCK_DISABLED bits are set, 00490 * CSR_SDIO_RESULT_INVALID_VALUE will be returned. 00491 * 00492 * NOTE: The CsrSdioRead8Async and CsrSdioWrite8Async functions return 00493 * immediately, and the supplied callback function is called when the 00494 * operation is complete. The result value is given as an argument to 00495 * the callback function. 00496 * 00497 *----------------------------------------------------------------------------*/ 00498 CsrResult CsrSdioRead8(CsrSdioFunction *function, CsrUint32 address, CsrUint8 *data); 00499 CsrResult CsrSdioWrite8(CsrSdioFunction *function, CsrUint32 address, CsrUint8 data); 00500 void CsrSdioRead8Async(CsrSdioFunction *function, CsrUint32 address, CsrUint8 *data, CsrSdioAsyncCallback callback); 00501 void CsrSdioWrite8Async(CsrSdioFunction *function, CsrUint32 address, CsrUint8 data, CsrSdioAsyncCallback callback); 00502 00503 /*----------------------------------------------------------------------------* 00504 * NAME 00505 * CsrSdioRead16, CsrSdioWrite16, CsrSdioRead16Async, CsrSdioWrite16Async 00506 * 00507 * DESCRIPTION 00508 * Read/write a 16bit value from/to the specified register address. 00509 * 00510 * PARAMETERS 00511 * function - Pointer to struct representing the function. 00512 * address - Register address within the function. 00513 * data - The data to read/write. 00514 * callback - The function to call on operation completion. 00515 * 00516 * RETURNS 00517 * CSR_RESULT_SUCCESS - The data was successfully read/written. 00518 * CSR_RESULT_FAILURE - Unspecified/unknown error. 00519 * CSR_SDIO_RESULT_INVALID_VALUE - One or more arguments were invalid. 00520 * CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore. 00521 * CSR_SDIO_RESULT_CRC_ERROR - A CRC error occured. Data may have been 00522 * partially read/written. 00523 * CSR_SDIO_RESULT_TIMEOUT - No response from the device. 00524 * 00525 * NOTE: If the SDIO R5 response is available, and either of the 00526 * FUNCTION_NUMBER or OUT_OF_RANGE bits are set, 00527 * CSR_SDIO_RESULT_INVALID_VALUE shall be returned. If the ERROR bit 00528 * is set (but none of FUNCTION_NUMBER or OUT_OF_RANGE), 00529 * CSR_RESULT_FAILURE shall be returned. The ILLEGAL_COMMAND and 00530 * COM_CRC_ERROR bits shall be ignored. 00531 * 00532 * If the CSPI response is available, and any of the 00533 * FUNCTION_DISABLED or CLOCK_DISABLED bits are set, 00534 * CSR_SDIO_RESULT_INVALID_VALUE will be returned. 00535 * 00536 * NOTE: The CsrSdioRead16Async and CsrSdioWrite16Async functions return 00537 * immediately, and the supplied callback function is called when the 00538 * operation is complete. The result value is given as an argument to 00539 * the callback function. 00540 * 00541 *----------------------------------------------------------------------------*/ 00542 CsrResult CsrSdioRead16(CsrSdioFunction *function, CsrUint32 address, CsrUint16 *data); 00543 CsrResult CsrSdioWrite16(CsrSdioFunction *function, CsrUint32 address, CsrUint16 data); 00544 void CsrSdioRead16Async(CsrSdioFunction *function, CsrUint32 address, CsrUint16 *data, CsrSdioAsyncCallback callback); 00545 void CsrSdioWrite16Async(CsrSdioFunction *function, CsrUint32 address, CsrUint16 data, CsrSdioAsyncCallback callback); 00546 00547 /*----------------------------------------------------------------------------* 00548 * NAME 00549 * CsrSdioF0Read8, CsrSdioF0Write8, CsrSdioF0Read8Async, 00550 * CsrSdioF0Write8Async 00551 * 00552 * DESCRIPTION 00553 * Read/write an 8bit value from/to the specified register address in 00554 * function 0. 00555 * 00556 * PARAMETERS 00557 * function - Pointer to struct representing the function. 00558 * address - Register address within the function. 00559 * data - The data to read/write. 00560 * callback - The function to call on operation completion. 00561 * 00562 * RETURNS 00563 * CSR_RESULT_SUCCESS - The data was successfully read/written. 00564 * CSR_RESULT_FAILURE - Unspecified/unknown error. 00565 * CSR_SDIO_RESULT_INVALID_VALUE - One or more arguments were invalid. 00566 * CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore. 00567 * CSR_SDIO_RESULT_CRC_ERROR - A CRC error occured. No data read/written. 00568 * CSR_SDIO_RESULT_TIMEOUT - No response from the device. 00569 * 00570 * NOTE: If the SDIO R5 response is available, and either of the 00571 * FUNCTION_NUMBER or OUT_OF_RANGE bits are set, 00572 * CSR_SDIO_RESULT_INVALID_VALUE shall be returned. If the ERROR bit 00573 * is set (but none of FUNCTION_NUMBER or OUT_OF_RANGE), 00574 * CSR_RESULT_FAILURE shall be returned. The ILLEGAL_COMMAND and 00575 * COM_CRC_ERROR bits shall be ignored. 00576 * 00577 * If the CSPI response is available, and any of the 00578 * FUNCTION_DISABLED or CLOCK_DISABLED bits are set, 00579 * CSR_SDIO_RESULT_INVALID_VALUE will be returned. 00580 * 00581 * NOTE: The CsrSdioF0Read8Async and CsrSdioF0Write8Async functions return 00582 * immediately, and the supplied callback function is called when the 00583 * operation is complete. The result value is given as an argument to 00584 * the callback function. 00585 * 00586 *----------------------------------------------------------------------------*/ 00587 CsrResult CsrSdioF0Read8(CsrSdioFunction *function, CsrUint32 address, CsrUint8 *data); 00588 CsrResult CsrSdioF0Write8(CsrSdioFunction *function, CsrUint32 address, CsrUint8 data); 00589 void CsrSdioF0Read8Async(CsrSdioFunction *function, CsrUint32 address, CsrUint8 *data, CsrSdioAsyncCallback callback); 00590 void CsrSdioF0Write8Async(CsrSdioFunction *function, CsrUint32 address, CsrUint8 data, CsrSdioAsyncCallback callback); 00591 00592 /*----------------------------------------------------------------------------* 00593 * NAME 00594 * CsrSdioRead, CsrSdioWrite, CsrSdioReadAsync, CsrSdioWriteAsync 00595 * 00596 * DESCRIPTION 00597 * Read/write a specified number of bytes from/to the specified register 00598 * address. 00599 * 00600 * PARAMETERS 00601 * function - Pointer to struct representing the function. 00602 * address - Register address within the function. 00603 * data - The data to read/write. 00604 * length - Number of byte to read/write. 00605 * callback - The function to call on operation completion. 00606 * 00607 * RETURNS 00608 * CSR_RESULT_SUCCESS - The data was successfully read/written. 00609 * CSR_RESULT_FAILURE - Unspecified/unknown error. 00610 * CSR_SDIO_RESULT_INVALID_VALUE - One or more arguments were invalid. 00611 * CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore. 00612 * CSR_SDIO_RESULT_CRC_ERROR - A CRC error occured. Data may have been 00613 * partially read/written. 00614 * CSR_SDIO_RESULT_TIMEOUT - No response from the device. 00615 * 00616 * NOTE: If the SDIO R5 response is available, and either of the 00617 * FUNCTION_NUMBER or OUT_OF_RANGE bits are set, 00618 * CSR_SDIO_RESULT_INVALID_VALUE shall be returned. If the ERROR bit 00619 * is set (but none of FUNCTION_NUMBER or OUT_OF_RANGE), 00620 * CSR_RESULT_FAILURE shall be returned. The ILLEGAL_COMMAND and 00621 * COM_CRC_ERROR bits shall be ignored. 00622 * 00623 * If the CSPI response is available, and any of the 00624 * FUNCTION_DISABLED or CLOCK_DISABLED bits are set, 00625 * CSR_SDIO_RESULT_INVALID_VALUE will be returned. 00626 * 00627 * NOTE: The CsrSdioF0Read8Async and CsrSdioF0Write8Async functions return 00628 * immediately, and the supplied callback function is called when the 00629 * operation is complete. The result value is given as an argument to 00630 * the callback function. 00631 * 00632 *----------------------------------------------------------------------------*/ 00633 CsrResult CsrSdioRead(CsrSdioFunction *function, CsrUint32 address, void *data, CsrUint32 length); 00634 CsrResult CsrSdioWrite(CsrSdioFunction *function, CsrUint32 address, const void *data, CsrUint32 length); 00635 void CsrSdioReadAsync(CsrSdioFunction *function, CsrUint32 address, void *data, CsrUint32 length, CsrSdioAsyncCallback callback); 00636 void CsrSdioWriteAsync(CsrSdioFunction *function, CsrUint32 address, const void *data, CsrUint32 length, CsrSdioAsyncCallback callback); 00637 00638 /*----------------------------------------------------------------------------* 00639 * NAME 00640 * CsrSdioPowerOn, CsrSdioPowerOff 00641 * 00642 * DESCRIPTION 00643 * Power on/off the device. 00644 * 00645 * PARAMETERS 00646 * function - Pointer to struct representing the function that resides on 00647 * the device to power on/off. 00648 * 00649 * RETURNS (only CsrSdioPowerOn) 00650 * CSR_RESULT_SUCCESS - Power was succesfully reapplied and the device 00651 * has been reinitialised. 00652 * CSR_RESULT_FAILURE - Unspecified/unknown error. 00653 * CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore. 00654 * CSR_SDIO_RESULT_CRC_ERROR - A CRC error occured during reinitialisation. 00655 * CSR_SDIO_RESULT_TIMEOUT - No response from the device during 00656 * reinitialisation. 00657 * CSR_SDIO_RESULT_NOT_RESET - The power was not removed by the 00658 * CsrSdioPowerOff call. The state of the 00659 * device is unchanged. 00660 * 00661 *----------------------------------------------------------------------------*/ 00662 CsrResult CsrSdioPowerOn(CsrSdioFunction *function); 00663 void CsrSdioPowerOff(CsrSdioFunction *function); 00664 00665 /*----------------------------------------------------------------------------* 00666 * NAME 00667 * CsrSdioHardReset 00668 * 00669 * DESCRIPTION 00670 * Perform a hardware reset of the device. 00671 * 00672 * PARAMETERS 00673 * function - Pointer to struct representing the function that resides on 00674 * the device to hard reset. 00675 * 00676 * RETURNS 00677 * CSR_RESULT_SUCCESS - Reset was succesfully performed and the device 00678 * has been reinitialised. 00679 * CSR_RESULT_FAILURE - Unspecified/unknown error. 00680 * CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore. 00681 * CSR_SDIO_RESULT_CRC_ERROR - A CRC error occured during reinitialisation. 00682 * CSR_SDIO_RESULT_TIMEOUT - No response from the device during 00683 * reinitialisation. 00684 * CSR_SDIO_RESULT_NOT_RESET - The reset was not applied because it is not 00685 * supported. The state of the device is 00686 * unchanged. 00687 * 00688 *----------------------------------------------------------------------------*/ 00689 CsrResult CsrSdioHardReset(CsrSdioFunction *function); 00690 00691 /*----------------------------------------------------------------------------* 00692 * NAME 00693 * CsrSdioFunctionActive, CsrSdioFunctionIdle 00694 * 00695 * DESCRIPTION 00696 * 00697 * PARAMETERS 00698 * function - Pointer to struct representing the function. 00699 * 00700 *----------------------------------------------------------------------------*/ 00701 void CsrSdioFunctionActive(CsrSdioFunction *function); 00702 void CsrSdioFunctionIdle(CsrSdioFunction *function); 00703 00704 void CsrSdioCallbackInhibitEnter(CsrSdioFunction *function); 00705 void CsrSdioCallbackInhibitLeave(CsrSdioFunction *function); 00706 00707 #ifdef __cplusplus 00708 } 00709 #endif 00710 00711 #endif