Data Structures | |
struct | IotSdioCardDetectParam_t |
input parameter type for eSDIOSetCardDetectParams ioctl request More... | |
struct | IoTSdioPowerOnOffCard_t |
input parameter type for eSDIOPowerOnOffCard ioctl request More... | |
struct | IotSdioFuncBlkSize_t |
input parameter type for eSDIOSetFuncBlockSize ioctl request More... | |
struct | IotSdioPerFuncEnable_t |
input parameter type for eSDIOEnableIOFunctionIrq ioctl request and for eSDIOEnableIo ioctl request More... | |
struct | IotSdioReadCis_t |
input parameter type for eSDIOReadCis ioctl request More... | |
Macros | |
#define | IOT_SDIO_SUCCESS ( 0 ) |
The return codes for the functions in SDIO. | |
#define | IOT_SDIO_IOCTL_FAIL ( 1 ) |
#define | IOT_SDIO_HOST_INIT_FAIL ( 2 ) |
#define | IOT_SDIO_INVALID_VALUE ( 3 ) |
#define | IOT_SDIO_TRANSFER_FAIL ( 4 ) |
#define | IOT_SDIO_SWITCH_HIGH_SPEED_FAIL ( 5 ) |
#define | IOT_SDIO_LOW_SPEED_CARD ( 6 ) |
#define | IOT_SDIO_SELECT_BUS_TIMING_FAIL ( 7 ) |
#define | IOT_SDIO_SET_CARD_BLOCK_SIZE_FAIL ( 8 ) |
#define | IOT_SDIO_SWITCH_VOLTAGE_FAIL ( 9 ) |
#define | IOT_SDIO_HOST_NOT_READY ( 10 ) |
#define | IOT_SDIO_INVALID_CARD ( 11 ) |
#define | IOT_SDIO_SEND_RELATIVE_ADDRESS_FAIL ( 12 ) |
#define | IOT_SDIO_SELECT_CARD_FAIL ( 13 ) |
#define | IOT_SDIO_READ_CIS_FAIL ( 14 ) |
#define | IOT_SDIO_SET_DATA_BUS_WIDTH_FAIL ( 15 ) |
#define | IOT_SDIO_ASYNC_INT_NOT_SUPPORTED ( 16 ) |
#define | IOT_SDIO_GET_CARD_CAPABILITY_FAIL ( 17 ) |
#define | IOT_SDIO_FUNCTION_NOT_SUPPORTED ( 18 ) |
#define | IOT_SDIO_BUS_1BIT ( 0 ) |
sdio io bus width | |
#define | IOT_SDIO_BUS_4BIT ( 2 ) |
#define | IOT_SDIO_BUS_8BIT ( 3 ) |
Typedefs | |
typedef struct IotSdioSlotDescriptor * | IotSdioSlotHandle_t |
IotSdioSlotHandle_t type is the SDIO slot handle returned by calling iot_sdio_open() | |
typedef void(* | IotSdioCallback_t) (IotSdioSlotHandle_t const pxSdioHandle, IotSdioEventType_t eSdioEvent, void *pvUserContext) |
The callback function for sdio event operation. This callback is passed to driver by using iot_sdio_set_callback API. It's called when one of the events (IotSdioEventType_t) happens. | |
typedef void(* | IotSdioIOFunctionCallback_t) (IotSdioSlotHandle_t const pxSdioHandle, IotSdioFunction_t eFunc, void *pvUserContext) |
SDIO I/O function callback type. User can call iot_sdio_set_io_function_callback() API to set one IOFunctionCallback per each standard SDIO function supported on a sdio card. | |
Functions | |
IotSdioSlotHandle_t | iot_sdio_open (uint8_t ucHostIdx, uint8_t ucSlotIdx) |
iot_sdio_open() is used to open a handle to a sdio card slot. | |
int32_t | iot_sdio_close (IotSdioSlotHandle_t const pxSdioHandle) |
iot_sdio_close() is used to close the sdio card slot handle. IO operation initiated through this handle before will not be aborted. Caller should call iot_sdio_abort_io() to abort IO operation. | |
int32_t | iot_sdio_card_connect (IotSdioSlotHandle_t const pxSdioHandle) |
iot_sdio_card_connect() is used to connect SDIO card. | |
int32_t | iot_sdio_card_disconnect (IotSdioSlotHandle_t const pxSdioHandle) |
iot_sdio_card_disconnect() is used to disconnect SDIO card. | |
int32_t | iot_sdio_card_reset (IotSdioSlotHandle_t const pxSdioHandle) |
iot_sdio_card_reset() is used to reset the sdio card in the target slot. This API should soft reset all I/O functions in sdio card. | |
int32_t | iot_sdio_io_write_direct (IotSdioSlotHandle_t const pxSdioHandle, IotSdioFunction_t eFunc, uint32_t ulRegAddr, uint8_t *pucData, bool bRaw) |
iot_sdio_io_write_direct() implements the write portion of CMD52. It is used to write 1 byte to a single register within the register space of a card I/O function. | |
int32_t | iot_sdio_io_read_direct (IotSdioSlotHandle_t const pxSdioHandle, IotSdioFunction_t eFunc, uint32_t ulRegAddr, uint8_t *pucData) |
iot_sdio_io_read_direct() implements the read portion of CMD52. It is used to read 1 byte from a single register within the register space of a card I/O function. | |
int32_t | iot_sdio_io_write_extended (IotSdioSlotHandle_t const pxSdioHandle, IotSdioFunction_t eFunc, bool bBlockMode, bool bOpcode, uint32_t ulRegAddr, uint8_t *pucBuf, uint32_t ulCount) |
iot_sdio_io_write_extended() implements the write portion of CMD53. It is used to write multiple bytes or blocks to a single address or incremental addresses within the register space in a I/O function. It provides highest transfer rate possible. | |
int32_t | iot_sdio_io_read_extended (IotSdioSlotHandle_t const pxSdioHandle, IotSdioFunction_t eFunc, bool bBlockMode, bool bOpcode, uint32_t ulRegAddr, uint8_t *pucBuf, uint32_t ulCount) |
iot_sdio_io_read_extended() implements the read portion of CMD53. It is used to read multiple bytes or blocks from a single address or incremental addresses within the register space in a I/O function. It provides highest transfer rate possible. | |
int32_t | iot_sdio_set_io_function_callback (IotSdioSlotHandle_t const pxSdioHandle, IotSdioFunction_t eFunc, IotSdioIOFunctionCallback_t xIOFunctionCallback, void *pvIOFunctionCallbackUserContext) |
iot_sdio_set_io_function_callback() is used to set IOFunctionCallback for each I/O function the card supports. | |
int32_t | iot_sdio_set_sdio_callback (IotSdioSlotHandle_t const pxSdioHandle, IotSdioCallback_t xSdioCallback, void *pvSdioCallbackUserContext) |
iot_sdio_set_sdio_callback() is used to set sdio card interrupt callback. | |
int32_t | iot_sdio_ioctl (IotSdioSlotHandle_t const pxSdioHandle, IotSdioIoctlRequest_t xSdioIoctlRequest, void *const pvBuffer) |
iot_sdio_ioctl() is Used for various sdio control function. | |
#define IOT_SDIO_SUCCESS ( 0 ) |
The return codes for the functions in SDIO.
SDIO operation completed successfully.
#define IOT_SDIO_IOCTL_FAIL ( 1 ) |
SDIO ioctl failed.
#define IOT_SDIO_HOST_INIT_FAIL ( 2 ) |
SDIO host controller initialization failed.
#define IOT_SDIO_INVALID_VALUE ( 3 ) |
At least one parameter is invalid.
#define IOT_SDIO_TRANSFER_FAIL ( 4 ) |
Sending command to or receive response from card failed.
#define IOT_SDIO_SWITCH_HIGH_SPEED_FAIL ( 5 ) |
If the card is initialized in 3.3V signaling, and card support high speed mode (SHS ==1), host can issue CMD52 in RAW mode, setting EHS bit in CCCR to one to switch to high speed mode. This error code indicates that the sdio card supports high speed mode but failed to switch to high speed mode. The bus clock rate remains unchanged in this case.
#define IOT_SDIO_LOW_SPEED_CARD ( 6 ) |
If the card is initialized in 3.3V signaling, and card support high speed mode (SHS ==1), host can issue CMD52 in RAW mode, setting EHS bit in CCCR to one to switch to high speed mode. This error code indicates that the sdio card does not supports high speed mode. The bus clock rate will be set to the default 25MHz in this case.
#define IOT_SDIO_SELECT_BUS_TIMING_FAIL ( 7 ) |
If the card is initialized in 1.8V signaling, and card support UHS-I, host will try to set card's bus timing mode to the highest mode the card supports using CMD52, and set the max clock frequency for that mode. This error code indicates a failure of such operation.
#define IOT_SDIO_SET_CARD_BLOCK_SIZE_FAIL ( 8 ) |
Setting block size for block transfer mode failed.
#define IOT_SDIO_SWITCH_VOLTAGE_FAIL ( 9 ) |
During card initialization, A host that supports UHS-I use CMD5 to probe if card also supports UHS-I and ready to switch from 3.3v to 1.8v. Once voltage switch request is accepted, host sends CMD11 to initiate voltage switch sequence. This error code indicates either card failed to respond to CMD11 or card responded to CMD11 but failed to switch voltage.
#define IOT_SDIO_HOST_NOT_READY ( 10 ) |
host controller not ready.
#define IOT_SDIO_INVALID_CARD ( 11 ) |
Not a valid SDIO card.
#define IOT_SDIO_SEND_RELATIVE_ADDRESS_FAIL ( 12 ) |
Send Relative Address (CMD3) failed.
#define IOT_SDIO_SELECT_CARD_FAIL ( 13 ) |
Select Card (CMD7) failed.
#define IOT_SDIO_READ_CIS_FAIL ( 14 ) |
Read (via CMD52) CIS (Card Information Structure failed.
#define IOT_SDIO_SET_DATA_BUS_WIDTH_FAIL ( 15 ) |
Set (via CMD52) data bus width failed.
#define IOT_SDIO_ASYNC_INT_NOT_SUPPORTED ( 16 ) |
Card does not support Asynchronous Interrupt.
#define IOT_SDIO_GET_CARD_CAPABILITY_FAIL ( 17 ) |
Reading CCCR (function 0) or FBR (function 1-7) failed.
#define IOT_SDIO_FUNCTION_NOT_SUPPORTED ( 18 ) |
API function is not supported by platform.
#define IOT_SDIO_BUS_1BIT ( 0 ) |
sdio io bus width
1 bit bus mode
#define IOT_SDIO_BUS_4BIT ( 2 ) |
4 bit bus mode
#define IOT_SDIO_BUS_8BIT ( 3 ) |
8 bit bus mode
typedef void(* IotSdioCallback_t) (IotSdioSlotHandle_t const pxSdioHandle, IotSdioEventType_t eSdioEvent, void *pvUserContext) |
The callback function for sdio event operation. This callback is passed to driver by using iot_sdio_set_callback API. It's called when one of the events (IotSdioEventType_t) happens.
[in] | pxSdioHandle | Handle to sdio card slot instance returned in iot_sdio_open(). |
[in] | eSdioEvent | sdio asynchronous event. |
[in] | pvUserContext | User Context passed when setting the callback. This is not used or modified by the driver. The context is provided by the caller when setting the callback, and is passed back to the caller in the callback. |
typedef void(* IotSdioIOFunctionCallback_t) (IotSdioSlotHandle_t const pxSdioHandle, IotSdioFunction_t eFunc, void *pvUserContext) |
SDIO I/O function callback type. User can call iot_sdio_set_io_function_callback() API to set one IOFunctionCallback per each standard SDIO function supported on a sdio card.
Since the I/O function number is parameter to IOFunctionCallback, user can implement one single IOFunctionCallback and set it for all I/O functions. Inside the IOFunctionCallback, different action can be taken according the I/O function number.
When there is a sdio card interrupt (eSdioCardInterruptEvent). The host should checks the interrupt pending status of each card I/O function and call that function's user defined IOFunctionCallback as needed.
The job of a IOFunctionCallback is to service the interrupt condition caused by the corresponding I/O function. It should read/write to the function unique area on the card to clear pending interrupt. The specific implementation for each IOFunctionCallback should be according to the specification of SDIO function it is written for.
[in] | pxSdioHandle | Handle to sdio card slot instance returned in iot_sdio_open(). |
[in] | eFunc | I/O Function number that are associated with IRQ. |
[in] | pvUserContext | User context passed when setting the callback This is not used by the driver, but just passed back to the user in the callback. |
enum IotSdioDirection_t |
enum IotSdioFunction_t |
SDIO I/O function number type Each SDIO card can support up to 7 I/O functions. Each I/O function can implement one of the following:
card detect type
enum IotSdioEventType_t |
common notify event types in sdio callback
IOCTL request types.
Enumerator | |
---|---|
eSDIOSetDriverStrength | Set driver strength type input: SDIO card driver strength. input data type IotSdioSdDriverStrength_t |
eSDIOSetCardInactive | put card in inactive state |
eSDIOSwitchToHighSpeed | switch to high speed mode if card supports it |
eSDIOSetDataBusWidth | set sdio card data bus width and change host setting to support it input: sdio bus width, input data type IotSdioBusWidth_t |
eSDIOGetCardCapabilities | request host to learn capabilities of specified card function input: I/O function number, of type IotSdioFunction_t |
eSDIOSetCardDetectParams | Set card detect parameters input: card detect parameters. input data type IotSdioCardDetectParam_t |
eSDIOSetFuncBlockSize | Set transfer block size for a function input: I/O function and block size. input data type IotSdioFuncBlkSize_t |
eSDIOEnableIOFunctionIrq | enable/disable irq for individual io functions input: I/O function number and enable or disable, input data type IotSdioPerFuncEnable |
eSDIOEnableAsyncIrqMode | enable/disable asynchronous interrupt mode input: boolean to indicate enable or disable |
eSDIOEnableIo | enable/disable an I/O function on card input: I/O function number and boolean to indicate enable or disable, input data type IotSdioPerFuncEnable_t |
eSDIOSelectIo | Select an I/O function for suspend/resume input: I/O function number, input data type IotSdioFunction_t |
eSDIOAbortIo | Abort an ongoing transfer initiated by the specified I/O function input: I/O function number. Input data type IotSdioFunction_t |
eSDIOReadCis | Host read list of tuples from card CIS input: I/O function number and tuple list to read, input data type IotSdioReadCis_t |
eSDIOPowerOnOffCard | Power on/off card input: boolean true for power on, false for power off boolean true to use board's default power method, false to use user defined power method via callback. input data type IoTSdioPowerOnOffCard_t |
eSDIOCheckCardPresence | check card presence output: boolean to indicate card present or not present |
enum IotSdioBusWidth_t |
SDIO card driver strength, input parameter type for eSDIOSetDriverStrength ioctl request.
IotSdioSlotHandle_t iot_sdio_open | ( | uint8_t | ucHostIdx, |
uint8_t | ucSlotIdx | ||
) |
iot_sdio_open() is used to open a handle to a sdio card slot.
This API must be called before using any other iot_sdio APIs. Upon successful return, the underline SDIO host controller should have been initialized properly.
[in] | ucHostIdx | SDIO host controller index. Must be 0 if only single host available. Range from 0 to n-1 if n hosts available. |
[in] | ucSlotIdx | Card slot index. Must be 0 if only single slot is supported. Range from 0 to n-1 if n card slots is supported. |
int32_t iot_sdio_close | ( | IotSdioSlotHandle_t const | pxSdioHandle | ) |
iot_sdio_close() is used to close the sdio card slot handle. IO operation initiated through this handle before will not be aborted. Caller should call iot_sdio_abort_io() to abort IO operation.
Up on a successful return of the API, the SDIO host controller should be regarded as uninitialized. All cards on this host should be regarded as disconnected.
[in] | pxSdioHandle | Handle to sdio card slot instance returned in iot_sdio_open() |
int32_t iot_sdio_card_connect | ( | IotSdioSlotHandle_t const | pxSdioHandle | ) |
iot_sdio_card_connect() is used to connect SDIO card.
This API should perform card connection sequence as specified in section 3.1.2 in "SD Specification Part E1 SDIO"
[in] | pxSdioHandle | Handle to sdio card slot instance returned in iot_sdio_open() |
int32_t iot_sdio_card_disconnect | ( | IotSdioSlotHandle_t const | pxSdioHandle | ) |
iot_sdio_card_disconnect() is used to disconnect SDIO card.
This API should soft reset all I/O functions in sdio card and de-select the the card. User is not required to call this api before trying to re-connect the card.
[in] | pxSdioHandle | Handle to sdio card slot instance returned in iot_sdio_open() |
int32_t iot_sdio_card_reset | ( | IotSdioSlotHandle_t const | pxSdioHandle | ) |
iot_sdio_card_reset() is used to reset the sdio card in the target slot. This API should soft reset all I/O functions in sdio card.
[in] | pxSdioHandle | Handle to sdio card slot instance returned in iot_sdio_open() |
int32_t iot_sdio_io_write_direct | ( | IotSdioSlotHandle_t const | pxSdioHandle, |
IotSdioFunction_t | eFunc, | ||
uint32_t | ulRegAddr, | ||
uint8_t * | pucData, | ||
bool | bRaw | ||
) |
iot_sdio_io_write_direct() implements the write portion of CMD52. It is used to write 1 byte to a single register within the register space of a card I/O function.
[in] | pxSdioHandle | Handle to sdio card slot instance returned in iot_sdio_open(). |
[in] | eFunc | IO function number range from eSdioFunction0 to eSdioFunction7. |
[in] | ulRegAddr | The address of the byte of data inside of the selected function to write. Range is 0 - 0x1ffff. |
[in,out] | pucData | In: data to be written to selected address Out: If bRaw (read after write) is == false, it is same as the input data. If bRaw (read after write) is == true, it contains value read from the same address after write. |
[in] | bRaw | The read after write flag. |
int32_t iot_sdio_io_read_direct | ( | IotSdioSlotHandle_t const | pxSdioHandle, |
IotSdioFunction_t | eFunc, | ||
uint32_t | ulRegAddr, | ||
uint8_t * | pucData | ||
) |
iot_sdio_io_read_direct() implements the read portion of CMD52. It is used to read 1 byte from a single register within the register space of a card I/O function.
[in] | pxSdioHandle | Handle to sdio card slot instance returned in iot_sdio_open(). |
[in] | eFunc | IO function number range from eSdioFunction0 to eSdioFunction7. |
[in] | ulRegAddr | The address of the byte of data inside of the selected function to read. Range is 0 - 0x1ffff. |
[out] | pucData | Contains data read when command succeeded. |
int32_t iot_sdio_io_write_extended | ( | IotSdioSlotHandle_t const | pxSdioHandle, |
IotSdioFunction_t | eFunc, | ||
bool | bBlockMode, | ||
bool | bOpcode, | ||
uint32_t | ulRegAddr, | ||
uint8_t * | pucBuf, | ||
uint32_t | ulCount | ||
) |
iot_sdio_io_write_extended() implements the write portion of CMD53. It is used to write multiple bytes or blocks to a single address or incremental addresses within the register space in a I/O function. It provides highest transfer rate possible.
[in] | pxSdioHandle | Handle to sdio card slot instance returned in iot_sdio_open(). |
[in] | eFunc | IO function number range from eSdioFunction0 to eSdioFunction7. |
[in] | bBlockMode | Set true to transfer on block basis. Set false to transfer on byte basis. |
[in] | bOpcode | Set true to write multiple bytes to incrementing addresses. Set false to write multiple bytes to a fixed address. |
[in] | ulRegAddr | Start Address of I/O register to write. Range is 0 - 0x1ffff. |
[in] | pucBuf | Buffer that contains data to write. |
[in] | ulCount | Number of bytes to write if bBlockMode is false. Number of blocks to write if bBlockMode is true. Range is 0 - 0x1ff When bBlockMode is false, a value of 0 shall cause 512 bytes to be written. When bBlockMode is true, a value of 0 shall cause infinite blocks to be written until iot_sdio_abort_io is called. |
int32_t iot_sdio_io_read_extended | ( | IotSdioSlotHandle_t const | pxSdioHandle, |
IotSdioFunction_t | eFunc, | ||
bool | bBlockMode, | ||
bool | bOpcode, | ||
uint32_t | ulRegAddr, | ||
uint8_t * | pucBuf, | ||
uint32_t | ulCount | ||
) |
iot_sdio_io_read_extended() implements the read portion of CMD53. It is used to read multiple bytes or blocks from a single address or incremental addresses within the register space in a I/O function. It provides highest transfer rate possible.
[in] | pxSdioHandle | Handle to sdio card slot instance returned in iot_sdio_open(). |
[in] | eFunc | IO function number range from eSdioFunction0 to eSdioFunction7. |
[in] | bBlockMode | Set true to transfer on block basis. Set false to transfer on byte basis. |
[in] | bOpcode | Set true to read multiple bytes from incrementing addresses. Set false to read multiple bytes from a fixed address. |
[in] | ulRegAddr | Start Address of I/O register to read. Range is 0 - 0x1ffff. |
[out] | pucBuf | Buffer to receive read data. |
[in] | ulCount | Number of bytes to read if bBlockMode is false. Number of blocks to read if bBlockMode is true. Range is 0 - 0x1ff When bBlockMode is false, a value of 0 shall cause 512 bytes to be read. When bBlockMode is true, a value of 0 shall cause infinite blocks to be read until iot_sdio_abort_io is called. |
int32_t iot_sdio_set_io_function_callback | ( | IotSdioSlotHandle_t const | pxSdioHandle, |
IotSdioFunction_t | eFunc, | ||
IotSdioIOFunctionCallback_t | xIOFunctionCallback, | ||
void * | pvIOFunctionCallbackUserContext | ||
) |
iot_sdio_set_io_function_callback() is used to set IOFunctionCallback for each I/O function the card supports.
IOFunctionCallback for an card I/O function is invoked when the corresponding I/O function pending interrupt bit is set in the Card's CCCR. Since the I/O function number is parameter to IOFunctionCallback, user can also implement one single IOFunctionCallback and set it for all I/O functions. Inside the IOFunctionCallback, different action can be taken according the I/O function number.
The job of a IOFunctionCallback is to service the interrupt condition caused by the corresponding I/O function. It should read/write to the function unique area on the card to clear pending interrupt. The specific implementation for each IOFunctionCallback should be according to the specification of SDIO function it is written for.
[in] | pxSdioHandle | Handle to sdio card slot instance returned in iot_sdio_open(). |
[in] | eFunc | IO function number range from eSdioFunction0 to eSdioFunction7. |
[in] | xIOFunctionCallback | IOFunctionCallback to be set for I/O function eFunc. |
[in] | pvIOFunctionCallbackUserContext | User context to be passed when IOFunctionCallback is invoked. |
int32_t iot_sdio_set_sdio_callback | ( | IotSdioSlotHandle_t const | pxSdioHandle, |
IotSdioCallback_t | xSdioCallback, | ||
void * | pvSdioCallbackUserContext | ||
) |
iot_sdio_set_sdio_callback() is used to set sdio card interrupt callback.
[in] | pxSdioHandle | Handle to sdio card slot instance returned in iot_sdio_open(). |
[in] | xSdioCallback | Callback function to be called from driver. |
[in] | pvSdioCallbackUserContext | User context to be passed when callback is called. |
int32_t iot_sdio_ioctl | ( | IotSdioSlotHandle_t const | pxSdioHandle, |
IotSdioIoctlRequest_t | xSdioIoctlRequest, | ||
void *const | pvBuffer | ||
) |
iot_sdio_ioctl() is Used for various sdio control function.
[in] | pxSdioHandle | Handle to sdio card slot instance returned in iot_sdio_open(). |
[in] | xSdioIoctlRequest | Should be one of IotSdioIoctlRequest_t. |
[in,out] | pvBuffer | The configuration values for the IOCTL request. |