Dears ,
We use AM437x GPMC to FPGA Communication, need use DMA read data, but only can read 4 bytes(2* sizeof(u16) everytime.
DMA demon as below:
static int fpga_dma_init(struct fpga_dev * priv, int datatype)
{
dma_cap_mask_t mask;
int ret;
int i;
struct dma_slave_config conf;
dma_cap_zero(mask);
dma_cap_set(DMA_MEMCPY, mask);
/* Get control of DMA channel #0 */
priv->fpga_dma_chan = dma_request_channel(mask, NULL, NULL);
if (!priv->fpga_dma_chan) {
dev_err(priv->dev, "Unable to acquire DMA channel #0\n");
return -ENODEV;
}
priv->rbcout_addr = dma_alloc_coherent(priv->dev, SYS_DATA_DMA_SIZE*sizeof(u16), &priv->rbcout_dma_addr, GFP_DMA);
conf.direction = DMA_DEV_TO_MEM;
conf.dst_addr_width = DMA_SLAVE_BUSWIDTH_16_BYTES;
conf.src_addr_width = DMA_SLAVE_BUSWIDTH_16_BYTES;
dmaengine_slave_config(priv->fpga_dma_chan, &conf);
return 0;
}
static int fpga_dma_transfer(struct fpga_dev *priv, dma_addr_t dma_dst, size_t len)
{
struct dma_chan *chan = priv->fpga_dma_chan;
struct dma_device *dma_dev = chan->device;
enum dma_ctrl_flags flags = DMA_CTRL_ACK | DMA_PREP_INTERRUPT;
enum dma_status status;
struct dma_async_tx_descriptor *tx = NULL;
int ret=0,i;
dma_addr_t dma_src = priv->phys_addr + 2*FPGA_FIFO_RBC_ADDR;
len = 20;
tx = dma_dev->device_prep_dma_memcpy(chan, (unsigned long)dma_dst, (unsigned long)dma_src,
len, flags);
if (!tx) {
dev_err(priv->dev, "device_prep_dma_memcpy error\n");
ret = -EIO;
goto err;
}
tx->callback = fpga_sysdma_complete;
tx->callback_param = priv;
cookie = dmaengine_submit(tx);
dma_async_issue_pending(chan);
//ret = wait_for_completion_timeout(&sysinfo_wait, msecs_to_jiffies(50));
wait_for_completion(&sysinfo_wait);
printk("dma transfer success:sysbuf:");
for(i = 0; i < 20; i++){
printk(" 0x%x ",priv->rbcout_addr[i]);
}
printk("\n\n");
return 0'
}
everytime i read 20 bytes, but only : rbcout_addr[0], rbcout_addr[1], can read ok,and the fifo register also reduce 2 *(sizeof u16) bytes.
I change many dma read way,but it's also this issue. The issue is very urgent, Pls help me, thanks so much.