dma: Add timb-dma
PATCH 1/2 dma: Add timb-dma
Adds the support for the DMA engine withing the timberdale FPGA.
The DMA channels are strict device to host, or host to device and can not be used for generic memcpy.
---
drivers/dma/Kconfig +7 -0
@@ -149,6 +149,13 @@ config AMCC_PPC440SPE_ADMA help Enable support for the AMCC PPC440SPe RAID engines. +config TIMB_DMA + tristate "Timberdale FPGA DMA support" + depends on MFD_TIMBERDALE || HAS_IOMEM + select DMA_ENGINE + help + Enable support for the Timberdale FPGA DMA engine. + config ARCH_HAS_ASYNC_TX_FIND_CHANNEL bool
drivers/dma/Makefile +1 -0
@@ -20,3 +20,4 @@ obj-$(CONFIG_TXX9_DMAC) += txx9dmac.o obj-$(CONFIG_SH_DMAE) += shdma.o obj-$(CONFIG_COH901318) += coh901318.o coh901318_lli.o obj-$(CONFIG_AMCC_PPC440SPE_ADMA) += ppc4xx/ +obj-$(CONFIG_TIMB_DMA) += timb_dma.o
drivers/dma/timb_dma.c new file +853 -0
853 lines not on this page · raw message
include/linux/timb_dma.h new file +55 -0
55 lines not on this page · raw message
Quoted 6 lines · Richard Röjfors
Adds the support for the DMA engine withing the timberdale FPGA.
The DMA channels are strict device to host, or host to device and can not be used for generic memcpy.
Signed-off-by Richard Röjfors <[email protected]>
[..]
Quoted 4 lines
+struct
timb_dma_chan{
+ structdma_chanchan;
+ void__iomem*membase;
+spinlock_tlock; /* Used for mutual exclusion */
Please add some value to this comment. I can assume it protects all list manipulations, anything non-obvious worth noting?
[..]
Quoted 8 lines
drivers/dma/timb_dma.c new file +8
-0+ +static int td_fill_desc (struct timb_dma_chan *td_chan,u8 *dma_desc, + struct scatterlist *sg, bool last) +{ + if (sg_dma_len(sg) > USHORT_MAX) { + dev_err(chan2dev(&td_chan->chan), "Too big sg element\n"); + return -EINVAL; + }
drivers/dma/timb_dma.c line 200
Quoted 10 lines
drivers/dma/timb_dma.c new file +10
-0+ + /* length must be word aligned */ + if (sg_dma_len(sg) % sizeof(u32)) { + dev_err(chan2dev(&td_chan->chan), "Incorrect length: %d\n", + sg_dma_len(sg)); + return -EINVAL; + } + + dev_dbg(chan2dev(&td_chan->chan), "desc: %p, addr: %p\n", + dma_desc, (void *)(int)sg_dma_address(sg));
That (int) cast is not needed, causes a compiler warning, and can be dropped.
Nice simple driver. You can just send a follow up patch to fix up those minor issues. I've pushed it out to my 'next' branch [1].
--
Dan
git://git.kernel.org/pub/scm/linux/kernel/git/djbw/async_tx.git next