Lines Matching defs:dma
18 #include <linux/dma-mapping.h>
134 struct at91_twi_dma *dma = &dev->dma;
138 if (dma->xfer_in_progress) {
139 if (dma->direction == DMA_FROM_DEVICE)
140 dmaengine_terminate_sync(dma->chan_rx);
142 dmaengine_terminate_sync(dma->chan_tx);
143 dma->xfer_in_progress = false;
145 if (dma->buf_mapped) {
146 dma_unmap_single(dev->dev, sg_dma_address(&dma->sg[0]),
147 dev->buf_len, dma->direction);
148 dma->buf_mapped = false;
178 dma_unmap_single(dev->dev, sg_dma_address(&dev->dma.sg[0]),
197 struct at91_twi_dma *dma = &dev->dma;
198 struct dma_chan *chan_tx = dma->chan_tx;
204 dma->direction = DMA_TO_DEVICE;
210 dev_err(dev->dev, "dma map failed\n");
213 dma->buf_mapped = true;
225 sg = &dma->sg[sg_len++];
232 sg = &dma->sg[sg_len++];
246 sg_dma_len(&dma->sg[0]) = dev->buf_len;
247 sg_dma_address(&dma->sg[0]) = dma_addr;
250 txdesc = dmaengine_prep_slave_sg(chan_tx, dma->sg, sg_len,
254 dev_err(dev->dev, "dma prep slave sg failed\n");
261 dma->xfer_in_progress = true;
320 dma_unmap_single(dev->dev, sg_dma_address(&dev->dma.sg[0]),
324 /* The last two bytes have to be read without using dma */
336 struct at91_twi_dma *dma = &dev->dma;
337 struct dma_chan *chan_rx = dma->chan_rx;
341 dma->direction = DMA_FROM_DEVICE;
343 /* Keep in mind that we won't use dma to read the last two bytes */
347 dev_err(dev->dev, "dma map failed\n");
350 dma->buf_mapped = true;
366 sg_dma_len(&dma->sg[0]) = buf_len;
367 sg_dma_address(&dma->sg[0]) = dma_addr;
369 rxdesc = dmaengine_prep_slave_sg(chan_rx, dma->sg, 1, DMA_DEV_TO_MEM,
372 dev_err(dev->dev, "dma prep slave sg failed\n");
379 dma->xfer_in_progress = true;
381 dma_async_issue_pending(dma->chan_rx);
561 * When using dma without alternative command mode, the last
564 * In practice, there are some issues if you use the dma to
566 * Reading n-2 bytes with dma and the two last ones manually
750 struct at91_twi_dma *dma = &dev->dma;
780 dma->chan_tx = dma_request_chan(dev->dev, "tx");
781 if (IS_ERR(dma->chan_tx)) {
782 ret = PTR_ERR(dma->chan_tx);
783 dma->chan_tx = NULL;
787 dma->chan_rx = dma_request_chan(dev->dev, "rx");
788 if (IS_ERR(dma->chan_rx)) {
789 ret = PTR_ERR(dma->chan_rx);
790 dma->chan_rx = NULL;
795 if (dmaengine_slave_config(dma->chan_tx, &slave_config)) {
802 if (dmaengine_slave_config(dma->chan_rx, &slave_config)) {
808 sg_init_table(dma->sg, 2);
809 dma->buf_mapped = false;
810 dma->xfer_in_progress = false;
814 dma_chan_name(dma->chan_tx), dma_chan_name(dma->chan_rx));
821 if (dma->chan_rx)
822 dma_release_channel(dma->chan_rx);
823 if (dma->chan_tx)
824 dma_release_channel(dma->chan_tx);