Logo Search packages:      
Sourcecode: linux-fsl-imx51 version File versions  Download package

int mxc_dma_sg_config ( int  channel_num,
struct scatterlist *  sg,
int  num_buf,
int  num_of_bytes,
mxc_dma_mode_t  mode 

This function would just configure the scatterlist specified by the user into dma channel. This is a slight variation of mxc_dma_config(), it is provided for the convenience of drivers that have a scatterlist passed into them. It is the calling driver's responsibility to have the correct physical address filled in the "dma_address" field of the scatterlist.

channel_num the channel number returned at request time. This would be used by the DMA driver to identify the calling driver and do the necessary cleanup on the channel associated with the particular peripheral
sg a scatterlist of buffers. The caller must guarantee the dma_buf is available until the transfer is completed.
num_buf number of buffers in the array
num_of_bytes total number of bytes to transfer. If set to 0, this would imply to use the length field of the scatterlist for each DMA transfer. Else it would calculate the size for each DMA transfer.
mode specifies whether this is READ or WRITE operation
This function returns a negative number on error if buffer could not be added with DMA for transfer. On Success, it returns 0

Definition at line 944 of file dma_mx2.c.

References mx2_dma_priv_s::dma_chaining, fill_dma_bd_by_sg(), mxc_dma_channel::lock, mxc_dma_channel::mode, and mxc_dma_channel::private.

Referenced by mxcmci_setup_data().

      mxc_dma_channel_t *dma;
      mx2_dma_priv_t *dma_private;

      if ((sg == NULL) || (num_buf < 1) || (num_of_bytes < 0)) {
            return -EINVAL;

      if ((channel_num >= MAX_DMA_CHANNELS) || (channel_num < 0)) {
            return -EINVAL;

      dma = g_dma_channels + channel_num;
      dma_private = (mx2_dma_priv_t *) dma->private;
      if (dma_private == NULL) {
                   "config_sg dma %d which is not completed initialization \n",
            return -EFAULT;

      if (dma->lock == 0) {
            return -ENODEV;

      /*TODO: dma chainning can not support on bi-dir channel */
      if (dma_private->dma_chaining && (dma->mode != mode)) {
            return -EINVAL;

      /*TODO: fill dma buffer into driver .
       * If driver is no enought buffer to save them , it will return -EBUSY
      if (fill_dma_bd_by_sg(dma, sg, num_buf, num_of_bytes, mode)) {
            return -EBUSY;
      return 0;

Generated by  Doxygen 1.6.0   Back to index