Add DMA engine driver for Freescale MPC85xx processors.
Subsystems (2)
PATCH v2 1/1 Add DMA engine driver for Freescale MPC85xx processors.
The driver implements DMA engine API for Freescale MPC85xx DMA controller, which could be used by devices in the silicon. The driver supports the Basic mode of Freescale MPC85xx DMA controller. The MPC85xx processors supported include MPC8540/60, MPC8555, MPC8548, MPC8641 and so on.
The MPC83xx(MPC8349, MPC8360) are also supported.
--- MAINTAINERS | 7 + drivers/dma/Kconfig | 19 +- drivers/dma/Makefile | 1 + drivers/dma/fsldma.c | 1089 ++++++++++++++++++++++++++++++++++++++++++++++++++ drivers/dma/fsldma.h | 189 +++++++++ 5 files changed, 1304 insertions(+), 1 deletions(-) create mode 100644 drivers/dma/fsldma.c create mode 100644 drivers/dma/fsldma.h
MAINTAINERS +7 -0
@@ -1532,6 +1532,13 @@ L: [email protected] (subscribers-only) W: http://linux-fbdev.sourceforge.net/ S: Maintained +FREESCALE DMA DRIVER +P; Zhang Wei +M: [email protected] +L: [email protected] +L: [email protected] +S: Maintained + FREESCALE SOC FS_ENET DRIVER P: Pantelis Antoniou M: [email protected]
drivers/dma/Kconfig +18 -1
@@ -4,7 +4,7 @@ menuconfig DMADEVICES bool "DMA Offload Engine support" - depends on (PCI && X86) || ARCH_IOP32X || ARCH_IOP33X || ARCH_IOP13XX + depends on (PCI && X86) || ARCH_IOP32X || ARCH_IOP33X || ARCH_IOP13XX || PPC help Intel(R) offload engines enable offloading memory copies in the network stack and RAID operations in the MD driver.
@@ -34,6 +34,23 @@ config INTEL_IOP_ADMA help Enable support for the Intel(R) IOP Series RAID engines. +config FSL_DMA + bool "Freescale MPC85xx/MPC83xx DMA support" + depends on PPC + select DMA_ENGINE + ---help--- + Enable support for the Freescale DMA engine. Now, it support + MPC8560/40, MPC8555, MPC8548 and MPC8641 processors. + The MPC8349, MPC8360 is also supported. + +config FSL_DMA_SELFTEST + bool "Enable the self test for each DMA channel" + depends on FSL_DMA + default y + ---help--- + Enable the self test for each DMA channel. A self test will be + performed after the channel probed to ensure the DMA works well. + config DMA_ENGINE bool
drivers/dma/Makefile +1 -0
@@ -3,3 +3,4 @@ obj-$(CONFIG_NET_DMA) += iovlock.o obj-$(CONFIG_INTEL_IOATDMA) += ioatdma.o ioatdma-objs := ioat.o ioat_dma.o ioat_dca.o obj-$(CONFIG_INTEL_IOP_ADMA) += iop-adma.o +obj-$(CONFIG_FSL_DMA) += fsldma.o
drivers/dma/fsldma.c new file +1089 -0
1,089 lines not on this page · raw message
drivers/dma/fsldma.h new file +189 -0
189 lines not on this page · raw message
Signature · 1 line
1.5.2
Quoted 9 lines · Zhang Wei
The driver implements DMA engine API for Freescale MPC85xx DMA controller, which could be used by devices in the silicon. The driver supports the Basic mode of Freescale MPC85xx DMA controller.
The MPC85xx processors supported include MPC8540/60, MPC8555, MPC8548,
MPC8641 and so on.
TheMPC83xx(MPC8349, MPC8360)are also supported.
Quoted 3 lines
Signed-off-by Zhang Wei <[email protected]>Signed-off-by Ebony Zhu <[email protected]>---
Hello Wei,
Since the fixups were straightforward I went ahead and pulled this patch out of -mm and rebased it on my async-tx patch queue for 2.6.25. Could you double check the result, I have only compile tested it?
git pull git://lost.foo-projects.org/~dwillia2/git/iop md-for-linus
I also came across two more review items:
1/ Is there any issue with getting rid of CONFIG_FSL_DMA_SELFTEST? It is always on in iop-adma and ioatdma.
2/ I get the following compile warning:drivers/dma/fsldma.c:731: warning: 'fsl_dma_callback_test' defined but not used
For reference the changes I made when I rebased are appended below.
Thanks,
Dan
fsldma.c | 66 +++++++++++++++++++-------------------------------------------- 1 file changed, 20 insertions(+), 46 deletions(-)
drivers/dma/fsldma.c +20 -46
@@ -302,30 +302,6 @@ static void fsl_chan_toggle_ext_start(struct fsl_dma_chan *fsl_chan, int enable) fsl_chan->feature &= ~FSL_DMA_CHAN_START_EXT ; } -static void fsl_dma_set_src (dma_addr_t addr, -struct dma_async_tx_descriptor *tx,int index) -{ -struct fsl_desc_sw *desc_node, *desc =tx_to_fsl_desc (tx); -struct fsl_dma_chan *fsl_chan =to_fsl_chan (tx->chan); - -list_for_each_entry (desc_node, &desc->async_tx.tx_list, node) { -set_desc_src (fsl_chan, &desc_node->hw, addr); - addr +=FSL_DMA_BCR_MAX_CNT ; - } -} - -static void fsl_dma_set_dest (dma_addr_t addr, -struct dma_async_tx_descriptor *tx,int index) -{ -struct fsl_desc_sw *desc_node, *desc =tx_to_fsl_desc (tx); -struct fsl_dma_chan *fsl_chan =to_fsl_chan (tx->chan); - -list_for_each_entry (desc_node, &desc->async_tx.tx_list, node) { -set_desc_dest (fsl_chan, &desc_node->hw, addr); - addr +=FSL_DMA_BCR_MAX_CNT ; - } -} -static dma_cookie_t fsl_dma_tx_submit (struct dma_async_tx_descriptor *tx) {struct fsl_desc_sw *desc =tx_to_fsl_desc (tx);
@@ -368,8 +344,6 @@ static struct fsl_desc_sw *fsl_dma_alloc_descriptor(memset (desc_sw,0 ,sizeof (struct fsl_desc_sw ));dma_async_tx_descriptor_init (&desc_sw->async_tx, &fsl_chan->common); - desc_sw->async_tx.tx_set_src = fsl_dma_set_src; - desc_sw->async_tx.tx_set_dest = fsl_dma_set_dest; desc_sw->async_tx.tx_submit = fsl_dma_tx_submit;INIT_LIST_HEAD (&desc_sw->async_tx.tx_list); desc_sw->async_tx.phys = pdesc;
@@ -433,7 +407,8 @@ static void fsl_dma_free_chan_resources(struct dma_chan *chan) }static struct dma_async_tx_descriptor *fsl_dma_prep_memcpy ( -struct dma_chan *chan,size_t len,int int_en) +struct dma_chan *chan,dma_addr_t dma_dest,dma_addr_t dma_src, +size_t len,unsigned long flags) {struct fsl_dma_chan *fsl_chan;struct fsl_desc_sw *first =NULL , *prev =NULL , *new;
@@ -464,6 +439,8 @@ static struct dma_async_tx_descriptor *fsl_dma_prep_memcpy( copy =min (len,FSL_DMA_BCR_MAX_CNT );set_desc_cnt (fsl_chan, &new->hw, copy); +set_desc_src (fsl_chan, &new->hw, dma_src); +set_desc_dest (fsl_chan, &new->hw, dma_dest);if (!first) first = new;
@@ -475,6 +452,8 @@ static struct dma_async_tx_descriptor *fsl_dma_prep_memcpy( prev = new; len -= copy; + dma_src += copy; + dma_dest += copy;/* Insert the link descriptor to the LD ring */ list_add_tail (&new->node, &first->async_tx.tx_list);
@@ -758,7 +737,7 @@ static int fsl_dma_self_test(struct fsl_dma_chan *fsl_chan) {struct dma_chan *chan;int err =0 ; -dma_addr_t addr; +dma_addr_t dma_dest, dma_src;dma_cookie_t cookie;u8 *src, *dest;int i;
@@ -790,13 +769,12 @@ static int fsl_dma_self_test(struct fsl_dma_chan *fsl_chan) }/* TX 1 */ - tx1 =fsl_dma_prep_memcpy (chan, test_size /2 ,0 ); + dma_src =dma_map_single (fsl_chan->dev, src, test_size /2 , +DMA_TO_DEVICE ); + dma_dest =dma_map_single (fsl_chan->dev, dest, test_size /2 , +DMA_FROM_DEVICE ); + tx1 =fsl_dma_prep_memcpy (chan, dma_dest, dma_src, test_size /2 ,0 );async_tx_ack (tx1); - addr =dma_map_single (fsl_chan->dev, src, test_size /2 ,DMA_TO_DEVICE ); -fsl_dma_set_src (addr, tx1,0 ); - addr =dma_map_single (fsl_chan->dev, dest, test_size /2 , -DMA_FROM_DEVICE ); -fsl_dma_set_dest (addr, tx1,0 ); cookie =fsl_dma_tx_submit (tx1);fsl_dma_memcpy_issue_pending (chan);
@@ -821,24 +799,20 @@ static int fsl_dma_self_test(struct fsl_dma_chan *fsl_chan)/* Continue to test * TX 2 */ - tx2 =fsl_dma_prep_memcpy (chan, test_size /4 ,0 ); -async_tx_ack (tx2); - addr =dma_map_single (fsl_chan->dev, src + test_size /2 , + dma_src =dma_map_single (fsl_chan->dev, src + test_size /2 , test_size /4 ,DMA_TO_DEVICE ); -fsl_dma_set_src (addr, tx2,0 ); - addr =dma_map_single (fsl_chan->dev, dest + test_size /2 , + dma_dest =dma_map_single (fsl_chan->dev, dest + test_size /2 , test_size /4 ,DMA_FROM_DEVICE ); -fsl_dma_set_dest (addr, tx2,0 ); + tx2 =fsl_dma_prep_memcpy (chan, dma_dest, dma_src, test_size /4 ,0 ); +async_tx_ack (tx2);/* TX 3 */ - tx3 =fsl_dma_prep_memcpy (chan, test_size /4 ,0 ); -async_tx_ack (tx3); - addr =dma_map_single (fsl_chan->dev, src + test_size *3 /4 , + dma_src =dma_map_single (fsl_chan->dev, src + test_size *3 /4 , test_size /4 ,DMA_TO_DEVICE ); -fsl_dma_set_src (addr, tx3,0 ); - addr =dma_map_single (fsl_chan->dev, dest + test_size *3 /4 , + dma_dest =dma_map_single (fsl_chan->dev, dest + test_size *3 /4 , test_size /4 ,DMA_FROM_DEVICE ); -fsl_dma_set_dest (addr, tx3,0 ); + tx3 =fsl_dma_prep_memcpy (chan, dma_dest, dma_src, test_size /4 ,0 ); +async_tx_ack (tx3);/* Test exchanging the prepared tx sort */ cookie =fsl_dma_tx_submit (tx3);
RE: [PATCH v2] Add DMA engine driver for Freescale MPC85xxprocessors.
Hi, Dan,
Thanks so much for your help!
Quoted 6 lines
Since the fixups were straightforward I went ahead and pulled this patch
out of -mm and rebased it on my async-tx patch queue for 2.6.25. Could
you double check the result, I have only compile tested it?
Quoted 6 lines
git pull
git://lost.foo-projects.org/~dwillia2/git/iop
md-for-linusI also came across two more review items:
1/ Is there any issue with getting rid ofCONFIG_FSL_DMA_SELFTEST? It is always on in iop-adma and ioatdma.
I think it's no problem to remove CONFIG_FSL_DMA_SELFTEST.
Quoted 5 lines
2/ I get the following compile warning:
drivers/dma/fsldma.c:731: warning: 'fsl_dma_callback_test' defined but not used
I should add #ifdef FSL_DMA_CALLBACKTEST before fsl_dma_callback_test() function to get rid of the warning.
I think your patch is good. What should I do next?
Cheers!
Wei.
Quoted 163 lines
For reference the changes I made when I rebased are appended below.
Thanks,
Danfsldma.c | 66 +++++++++++++++++++-------------------------------------------- 1 file changed, 20 insertions(+), 46 deletions(-)drivers/dma/fsldma.c +0
-24@@ -302,30 +302,6 @@ static void fsl_chan_toggle_ext_start(struct fsl_dma_chan *fsl_chan, int enable) fsl_chan->feature &= ~FSL_DMA_CHAN_START_EXT; } -static void fsl_dma_set_src (dma_addr_t addr, -struct dma_async_tx_descriptor *tx, int index) -{ -struct fsl_desc_sw *desc_node, *desc =tx_to_fsl_desc (tx); -struct fsl_dma_chan *fsl_chan =to_fsl_chan (tx->chan); - -list_for_each_entry (desc_node, &desc->async_tx.tx_list, node) { -set_desc_src (fsl_chan, &desc_node->hw, addr); - addr +=FSL_DMA_BCR_MAX_CNT ; - } -} - -static void fsl_dma_set_dest (dma_addr_t addr, -struct dma_async_tx_descriptor *tx, int index) -{ -struct fsl_desc_sw *desc_node, *desc =tx_to_fsl_desc (tx); -struct fsl_dma_chan *fsl_chan =to_fsl_chan (tx->chan); - -list_for_each_entry (desc_node, &desc->async_tx.tx_list, node) { -set_desc_dest (fsl_chan, &desc_node->hw, addr); - addr +=FSL_DMA_BCR_MAX_CNT ; - } -} -static
dma_cookie_tfsl_dma_tx_submit(structdma_async_tx_descriptor*tx)
{drivers/dma/fsldma.c +0
-2struct fsl_desc_sw *desc =tx_to_fsl_desc (tx);@@ -368,8 +344,6 @@ static struct fsl_desc_sw *fsl_dma_alloc_descriptor ( memset(desc_sw, 0, sizeof(struct fsl_desc_sw));dma_async_tx_descriptor_init (&desc_sw->async_tx, &fsl_chan->common); - desc_sw->async_tx.tx_set_src = fsl_dma_set_src; - desc_sw->async_tx.tx_set_dest = fsl_dma_set_dest; desc_sw->async_tx.tx_submit = fsl_dma_tx_submit;INIT_LIST_HEAD (&desc_sw->async_tx.tx_list);drivers/dma/fsldma.c +2
-1desc_sw->async_tx.phys = pdesc;@@ -433,7 +407,8 @@ static void fsl_dma_free_chan_resources(struct dma_chan *chan) }static struct dma_async_tx_descriptor *fsl_dma_prep_memcpy ( -struct dma_chan *chan,size_t len ,int int_en) + struct dma_chan *chan, dma_addr_t dma_dest, dma_addr_t dma_src, + size_t len, unsigned long flags) {drivers/dma/fsldma.c +2
-0struct fsl_dma_chan *fsl_chan;struct fsl_desc_sw *first =NULL , *prev =NULL , *new;@@ -464,6 +439,8 @@ static struct dma_async_tx_descriptor *fsl_dma_prep_memcpy ( copy = min(len, FSL_DMA_BCR_MAX_CNT);set_desc_cnt (fsl_chan, &new->hw, copy); +set_desc_src (fsl_chan, &new->hw, dma_src); +set_desc_dest (fsl_chan, &new->hw, dma_dest);if (!first)drivers/dma/fsldma.c +2
-0first = new;@@ -475,6 +452,8 @@ static struct dma_async_tx_descriptor *fsl_dma_prep_memcpy ( prev = new; len -= copy; + dma_src += copy; + dma_dest += copy;/* Insert the link descriptor to the LD ring */ drivers/dma/fsldma.c +1
-1list_add_tail (&new->node, &first->async_tx.tx_list);@@ -758,7 +737,7 @@ static int fsl_dma_self_test(struct fsl_dma_chan *fsl_chan) {struct dma_chan *chan;int err =0 ; -dma_addr_t addr; +dma_addr_t dma_dest, dma_src;dma_cookie_t cookie;u8 *src, *dest;drivers/dma/fsldma.c +5
-5int i;@@ -790,13 +769,12 @@ static int fsl_dma_self_test(struct fsl_dma_chan *fsl_chan) }/* TX 1 */ - tx1 =fsl_dma_prep_memcpy (chan, test_size /2 ,0 ); + dma_src =dma_map_single (fsl_chan->dev, src, test_size /2 , +DMA_TO_DEVICE ); + dma_dest =dma_map_single (fsl_chan->dev, dest, test_size /2 , +DMA_FROM_DEVICE ); + tx1 =fsl_dma_prep_memcpy (chan, dma_dest, dma_src, test_size /2 ,0 );async_tx_ack (tx1); - addr =dma_map_single (fsl_chan->dev, src, test_size / 2, DMA_TO_DEVICE); -fsl_dma_set_src (addr, tx1,0 ); - addr = dma_map_single(fsl_chan->dev, dest, test_size / 2, -
DMA_FROM_DEVICE);drivers/dma/fsldma.c +7
-13-fsl_dma_set_dest (addr, tx1,0 ); cookie =fsl_dma_tx_submit (tx1);fsl_dma_memcpy_issue_pending (chan);@@ -821,24 +799,20 @@ static int fsl_dma_self_test(struct fsl_dma_chan *fsl_chan)/* Continue to test * TX 2 */ - tx2 =fsl_dma_prep_memcpy (chan, test_size /4 ,0 ); -async_tx_ack (tx2); - addr =dma_map_single (fsl_chan->dev, src + test_size /2 , + dma_src =dma_map_single (fsl_chan->dev, src + test_size /2 , test_size /4 ,DMA_TO_DEVICE ); -fsl_dma_set_src (addr, tx2,0 ); - addr =dma_map_single (fsl_chan->dev, dest + test_size /2 , + dma_dest =dma_map_single (fsl_chan->dev, dest + test_size /2 , test_size /4 ,DMA_FROM_DEVICE ); -fsl_dma_set_dest (addr, tx2,0 ); + tx2 =fsl_dma_prep_memcpy (chan, dma_dest, dma_src, test_size /4 ,0 ); +async_tx_ack (tx2);/* TX 3 */ - tx3 =fsl_dma_prep_memcpy (chan, test_size /4 ,0 ); -async_tx_ack (tx3); - addr =dma_map_single (fsl_chan->dev, src + test_size *3 /4 , + dma_src =dma_map_single (fsl_chan->dev, src + test_size *3 /4 , test_size /4 ,DMA_TO_DEVICE ); -fsl_dma_set_src (addr, tx3,0 ); - addr =dma_map_single (fsl_chan->dev, dest + test_size *3 /4 , + dma_dest =dma_map_single (fsl_chan->dev, dest + test_size *3 /4 , test_size /4 ,DMA_FROM_DEVICE ); -fsl_dma_set_dest (addr, tx3,0 ); + tx3 = fsl_dma_prep_memcpy(chan, dma_dest, dma_src,
test_size/ 4, 0);drivers/dma/fsldma.c +1
-0+async_tx_ack (tx3);/* Test exchanging the prepared tx sort */ cookie =fsl_dma_tx_submit (tx3);