Userspace SDIO library (libsdio)

libsdio is a Linux C library for accessing SDIO cards. More...

Typedefs

typedef struct sdio_uif * sdio_uif_t
typedef void(LIBSDIOAPI * sdio_int_handler_t )(sdio_uif_t uif, void *arg)
typedef void(LIBSDIOAPI * sdio_io_callback_t )(sdio_uif_t uif, void *arg, int status)

Enumerations

enum  sdio_status {
  SDIO_SUCCESS = 0,
  SDIO_EAGAIN = -1,
  SDIO_EINVAL = -2,
  SDIO_EIO = -3,
  SDIO_ENODEV = -4,
  SDIO_ENOMEM = -5,
  SDIO_ENOTSUPP = -6,
  SDIO_ENXIO = -7,
  SDIO_ETIMEDOUT = -8
}

Functions

sdio_uif_t LIBSDIOAPI sdio_open (const char *dev_filename, sdio_int_handler_t int_handler, void *arg)
void LIBSDIOAPI sdio_interrupt_mask (sdio_uif_t uif)
void LIBSDIOAPI sdio_interrupt_unmask (sdio_uif_t uif)
void LIBSDIOAPI sdio_close (sdio_uif_t uif)
int LIBSDIOAPI sdio_num_functions (sdio_uif_t uif)
int LIBSDIOAPI sdio_set_bus_width (sdio_uif_t uif, int bus_width)
void LIBSDIOAPI sdio_set_max_bus_freq (sdio_uif_t uif, int max_freq)
uint16_t LIBSDIOAPI sdio_manf_id (sdio_uif_t uif)
uint16_t LIBSDIOAPI sdio_card_id (sdio_uif_t uif)
uint8_t LIBSDIOAPI sdio_std_if (sdio_uif_t uif, int func)
int LIBSDIOAPI sdio_max_block_size (sdio_uif_t uif, int func)
int LIBSDIOAPI sdio_block_size (sdio_uif_t uif, int func)
int LIBSDIOAPI sdio_set_block_size (sdio_uif_t uif, int func, int blksz)
int LIBSDIOAPI sdio_read8 (sdio_uif_t uif, int func, uint32_t addr, uint8_t *data)
int LIBSDIOAPI sdio_write8 (sdio_uif_t uif, int func, uint32_t addr, uint8_t data)
int LIBSDIOAPI sdio_read (sdio_uif_t uif, int func, uint32_t addr, uint8_t *data, size_t len, int block_size)
int LIBSDIOAPI sdio_write (sdio_uif_t uif, int func, uint32_t addr, const uint8_t *data, size_t len, int block_size)
int LIBSDIOAPI sdio_read8_async (sdio_uif_t uif, int func, uint32_t addr, uint8_t *data, sdio_io_callback_t callback, void *arg)
int LIBSDIOAPI sdio_write8_async (sdio_uif_t uif, int func, uint32_t addr, uint8_t data, sdio_io_callback_t callback, void *arg)
int LIBSDIOAPI sdio_read_async (sdio_uif_t uif, int func, uint32_t addr, uint8_t *data, size_t len, int block_size, sdio_io_callback_t callback, void *arg)
int LIBSDIOAPI sdio_write_async (sdio_uif_t uif, int func, uint32_t addr, const uint8_t *data, size_t len, int block_size, sdio_io_callback_t callback, void *arg)
int LIBSDIOAPI sdio_reinsert_card (sdio_uif_t uif)

Detailed Description

libsdio is a Linux C library for accessing SDIO cards.

Use of this library requires several sdioemb kernel modules to be loaded:


Typedef Documentation

typedef void(LIBSDIOAPI * sdio_int_handler_t)(sdio_uif_t uif, void *arg)

Card interrupt handler function.

Parameters:
uif handle to the interrupting device.
arg data supplied by the caller of sdio_open().

typedef void(LIBSDIOAPI * sdio_io_callback_t)(sdio_uif_t uif, void *arg, int status)

Asynchronous IO completion callback function.

Parameters:
uif handle to the device that completed the IO operation.
arg data supplied by the caller of the asynchronous IO operation.
status status of the IO operation. 0 is success; -EIO, -EINVAL, -ETIMEDOUT etc. on an error.

typedef struct sdio_uif* sdio_uif_t

Handle to an opened SDIO Userspace Interface device.


Function Documentation

int LIBSDIOAPI sdio_block_size ( sdio_uif_t  uif,
int  func 
)

Return a function's current block size.

Note:
This returns the driver's view of the block size and not the value in the function's block size register.
Parameters:
uif device handle.
func card function to query.
Returns:
the current block size.

uint16_t LIBSDIOAPI sdio_card_id ( sdio_uif_t  uif  ) 

Return the card's card (device) ID.

Parameters:
uif device handle.
Returns:
card ID.

void LIBSDIOAPI sdio_close ( sdio_uif_t  uif  ) 

Close an opened SDIO Userspace Interface device, freeing all associated resources.

Parameters:
uif handle to the device.

void LIBSDIOAPI sdio_interrupt_mask ( sdio_uif_t  uif  ) 

Mask the SDIO interrupt.

Call this in an interrupt handler to allow the processing of interrupts to be deferred until after the interrupt handler has returned.

Note:
Must only be called from within the interrupt handler registered with sdio_open().
Parameters:
uif device handle.

void LIBSDIOAPI sdio_interrupt_unmask ( sdio_uif_t  uif  ) 

Unmask the SDIO interrupt.

Unmasks the SDIO interrupt if it had previously been masked with sdio_interrupt_mask().

Parameters:
uif device handle.

uint16_t LIBSDIOAPI sdio_manf_id ( sdio_uif_t  uif  ) 

Return the card's manufacturer (vendor) ID.

Parameters:
uif device handle.
Returns:
manufacturer ID.

int LIBSDIOAPI sdio_max_block_size ( sdio_uif_t  uif,
int  func 
)

Return a function's maximum supported block size.

Parameters:
uif device handle.
func card function to query.
Returns:
maximum block size.

int LIBSDIOAPI sdio_num_functions ( sdio_uif_t  uif  ) 

Return the number of functions the card has.

Parameters:
uif device handle.
Returns:
number of card functions.

sdio_uif_t LIBSDIOAPI sdio_open ( const char *  dev_filename,
sdio_int_handler_t  int_handler,
void *  arg 
)

Open a SDIO Userspace Interface device and (optionally) register a card interrupt handler and enable card interrupts.

Card interrupts are masked before calling int_handler and are unmasked when int_handler returns (unless sdio_interrupt_mask() is called).

Parameters:
dev_filename filename of the device to open.
int_handler card interrupt handler; or NULL if no interrupt handler is required.
arg argument to be passed to the interrupt handler.
Returns:
handle to the opened device; or NULL on error with errno set.

int LIBSDIOAPI sdio_read ( sdio_uif_t  uif,
int  func,
uint32_t  addr,
uint8_t *  data,
size_t  len,
int  block_size 
)

Read a buffer from a 8 bit wide register/FIFO.

The buffer read uses a fixed (not incrementing) address.

block_size must be set to the value writted into func's I/O block size FBR register.

If len % block_size == 0, a block mode transfer is used; a byte mode transfer is used if len < block_size.

Parameters:
uif device handle.
func card function.
addr register/FIFO address.
data buffer to store the data read.
len length of data to read.
block_size block size to use for this transfer.
Returns:
0 on success; or -ve on error with errno set.

int LIBSDIOAPI sdio_read8 ( sdio_uif_t  uif,
int  func,
uint32_t  addr,
uint8_t *  data 
)

Read an 8 bit register.

Parameters:
uif device handle.
func card function.
addr register address.
data the data read.
Returns:
0 on success; or -ve on error with errno set.

int LIBSDIOAPI sdio_read8_async ( sdio_uif_t  uif,
int  func,
uint32_t  addr,
uint8_t *  data,
sdio_io_callback_t  callback,
void *  arg 
)

Read an 8 bit register, without waiting for completion.

Parameters:
uif device handle.
func card function.
addr register address.
data the data read.
callback function to be called when the read completes.
arg argument to be passed to callback.
Returns:
0 on success; or -ve on error with errno set.

int LIBSDIOAPI sdio_read_async ( sdio_uif_t  uif,
int  func,
uint32_t  addr,
uint8_t *  data,
size_t  len,
int  block_size,
sdio_io_callback_t  callback,
void *  arg 
)

Read a buffer from a 8 bit wide register/FIFO, without waiting for completion.

The buffer read uses a fixed (not incrementing) address.

block_size must be set to the value writted into func's I/O block size FBR register.

If len % block_size == 0, a block mode transfer is used; a byte mode transfer is used if len < block_size.

Parameters:
uif device handle.
func card function.
addr register/FIFO address.
data buffer to store the data read.
len length of data to read.
block_size block size to use for this transfer.
callback function to be called when the read completes.
arg argument to be passed to callback.
Returns:
0 on success; or -ve on error with errno set.

int LIBSDIOAPI sdio_reinsert_card ( sdio_uif_t  uif  ) 

Force a card removal and reinsertion.

This will power cycle the card if the slot hardware supports power control.

Note:
The device handle will no longer be valid.
Parameters:
uif device handle.
Returns:
0 on success; or -ve on error with errno set.

int LIBSDIOAPI sdio_set_block_size ( sdio_uif_t  uif,
int  func,
int  blksz 
)

Set a function's block size.

The function's block size registers will be written if necessary.

Parameters:
uif device handle.
func function to modify.
blksz the new block size; or 0 for the default size.
Returns:
0 on success; or -ve on error with errno set.

int LIBSDIOAPI sdio_set_bus_width ( sdio_uif_t  uif,
int  bus_width 
)

Set an SDIO bus to 1 bit or 4 bit wide mode.

The CCCR bus interface control register will be read and rewritten with the new bus width.

Parameters:
uif device handle.
bus_width bus width (1 or 4).
Returns:
0 on success; -ve on error with errno set.
Note:
The card capabilities are not checked. The user should ensure 4 bit mode is not enabled on a card that does not support it.

void LIBSDIOAPI sdio_set_max_bus_freq ( sdio_uif_t  uif,
int  max_freq 
)

Limit the frequency of (or stop) the SD bus clock.

The frequency cannot be set greater than that supported by the card or the controller.

Note:
Stopping the bus clock while other device drivers are executing commands may result in those commands not completing until the bus clock is restarted.
Parameters:
uif device handle.
max_freq maximum frequency (Hz) or 0 to stop the bus clock until the start of the next command.

uint8_t LIBSDIOAPI sdio_std_if ( sdio_uif_t  uif,
int  func 
)

Return the standard interface code for a function.

Parameters:
uif device handle.
func card function to query.
Returns:
the standard interface.

int LIBSDIOAPI sdio_write ( sdio_uif_t  uif,
int  func,
uint32_t  addr,
const uint8_t *  data,
size_t  len,
int  block_size 
)

Write a buffer to an 8 bit wide register/FIFO.

The buffer write uses a fixed (not incrementing) address.

block_size must be set to the value writted into func's I/O block size FBR register.

If len % block_size == 0, a block mode transfer is used; a byte mode transfer is used if len < block_size.

Parameters:
uif device handle.
func card function.
addr register/FIFO address.
data buffer of data to write.
len length of the data to write.
block_size block size to use for this transfer.
Returns:
0 on success; or -ve on error with errno set.

int LIBSDIOAPI sdio_write8 ( sdio_uif_t  uif,
int  func,
uint32_t  addr,
uint8_t  data 
)

Write an 8 bit register.

Parameters:
uif device handle.
func card function.
addr register address.
data the data to write.
Returns:
0 on success; or -ve on error with errno set.

int LIBSDIOAPI sdio_write8_async ( sdio_uif_t  uif,
int  func,
uint32_t  addr,
uint8_t  data,
sdio_io_callback_t  callback,
void *  arg 
)

Write an 8 bit register, without waiting for completion.

Parameters:
uif device handle.
func card function.
addr register address.
data the data to write.
callback function to be called when the write completes.
arg argument to be passed to callback.
Returns:
0 on success; or -ve on error with errno set.

int LIBSDIOAPI sdio_write_async ( sdio_uif_t  uif,
int  func,
uint32_t  addr,
const uint8_t *  data,
size_t  len,
int  block_size,
sdio_io_callback_t  callback,
void *  arg 
)

Write a buffer to an 8 bit wide register/FIFO, without waiting for completion.

The buffer write uses a fixed (not incrementing) address.

block_size must be set to the value writted into func's I/O block size FBR register.

If len % block_size == 0, a block mode transfer is used; a byte mode transfer is used if len < block_size.

Parameters:
uif device handle.
func card function.
addr register/FIFO address.
data buffer of data to write.
len length of the data to write.
block_size block size to use for this transfer.
callback function to be called when the write completes.
arg argument to be passed to callback.
Returns:
0 on success; or -ve on error with errno set.


Generated on Wed Oct 27 15:18:12 2010 for sdioemb by  doxygen 1.5.5