dmaengine: add support mmp-pdma
Subsystems (2)
v5 cover dmaengine: add support mmp-pdma
v4->v5
Split mmp-dma.txt
Based on linux.git Sep 1
v3->v4
Set DMA_MEM_TO_MEM as default setting for memcpy, Suggested by Russell. "By default, any channel being asked to do memcpy
should deal with the channel configuration itself and not require it to be set"
v2->v3
Use "#dma-channels", instead of "dma-channels", suggested by Arnd
v1->v2
Sync with Arnd and Haojoan, change compatible name to "marvell,pdma-1.0" Used platfroms: pxa25x, pxa27x, pxa3xx, pxa93x, pxa168, pxa910, pxa688. Use IP name rather than platform name
Also change "marvell,mmp-adma" to "marvell,adma-1.0"
v0->v1
Update dt member and desc according to Arnd's suggestion
Use dma_slave_config.slave_id to transfer drcmr followed Vinod's suggestion
mmp-pdma is added under dmaengine framework. The final purpose is replacing arch/arm/plat-pxa/dma.c
Test on pxa910 with pxa3xx-nand and dmatest.ko
Zhangfei Gao (3):
dmaengine: mmp-pdma support
dmaengine: mmp_tdma: add dt support
ARM: dt: mmp-dma: add binding file
Documentation/devicetree/bindings/dma/mmp-dma.txt | 75 ++ drivers/dma/Kconfig | 7 + drivers/dma/Makefile | 1 + drivers/dma/mmp_pdma.c | 875 +++++++++++++++++++++ drivers/dma/mmp_tdma.c | 51 +- include/linux/platform_data/mmp_dma.h | 19 + 6 files changed, 1008 insertions(+), 20 deletions(-) create mode 100644 Documentation/devicetree/bindings/dma/mmp-dma.txt create mode 100644 drivers/dma/mmp_pdma.c create mode 100644 include/linux/platform_data/mmp_dma.h
PATCH v5 1/3 dmaengine: mmp-pdma support
1. virtual channel vs. physical channel
Virtual channel is managed by dmaengine
Physical channel handling resource, such as irq
Physical channel is alloced dynamically as descending priority, freed immediately when irq done.
The availble highest priority physically channel will alwayes be alloced
Issue pending list -> alloc highest dma physically channel available -> dma done -> free physically channel
2. list: running list & pending list
submit: desc list -> pending listissue_pending_list: if (IDLE) pending list -> running list; free pending list (RUN)
irq: free running list (IDLE)
check pendlist -> pending list -> running list; free pending list (RUN)
3. irq:
Each list generate one irq, calling callback
One list may contain several desc chain, in such case, make sure only the last desc list generate irq.
4. async
Submit will add desc chain to pending list, which can be multi-called If multi desc chain is submitted, only the last desc would generate irq -> call back If IDLE, issue_pending_list start pending_list, transforming pendlist to running list If RUN, irq will start pending list
5. test
5.1 pxa3xx_nand on pxa910
5.2 insmod dmatest.ko (threads_per_chan=y)
By default drivers/dma/dmatest.c test every channel and test memcpy with 1 threads per channel
--- drivers/dma/Kconfig | 7 + drivers/dma/Makefile | 1 + drivers/dma/mmp_pdma.c | 875 +++++++++++++++++++++++++++++++++ include/linux/platform_data/mmp_dma.h | 19 + 4 files changed, 902 insertions(+), 0 deletions(-) create mode 100644 drivers/dma/mmp_pdma.c create mode 100644 include/linux/platform_data/mmp_dma.h
drivers/dma/Kconfig +7 -0
@@ -292,6 +292,13 @@ config DMA_OMAP select DMA_ENGINE select DMA_VIRTUAL_CHANNELS +config MMP_PDMA + bool "MMP PDMA support" + depends on (ARCH_MMP || ARCH_PXA) + select DMA_ENGINE + help + Support the MMP PDMA engine for PXA and MMP platfrom. + config DMA_ENGINE bool
drivers/dma/Makefile +1 -0
@@ -32,3 +32,4 @@ obj-$(CONFIG_EP93XX_DMA) += ep93xx_dma.o obj-$(CONFIG_DMA_SA11X0) += sa11x0-dma.o obj-$(CONFIG_MMP_TDMA) += mmp_tdma.o obj-$(CONFIG_DMA_OMAP) += omap-dma.o +obj-$(CONFIG_MMP_PDMA) += mmp_pdma.o
drivers/dma/mmp_pdma.c new file +875 -0
875 lines not on this page · raw message
include/linux/platform_data/mmp_dma.h new file +19 -0
@@ -0,0 +1,19 @@ +/* +* MMP Platform DMA Management +* +* Copyright (c) 2011 Marvell Semiconductors Inc. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +* +*/ + +#ifndef MMP_DMA_H +#define MMP_DMA_H + +struct mmp_dma_platdata { +int dma_channels; +}; + +#endif /* MMP_DMA_H */
Signature · 1 line
1.7.1
PATCH v5 1/3 dmaengine: mmp-pdma support
Quoted 25 lines · Zhangfei Gao
1. virtual channel vs. physical channel
Virtual channel is managed by dmaengine
Physical channel handling resource, such as irq
Physical channel is alloced dynamically as descending priority, freed immediately when irq done.
The availble highest priority physically channel will alwayes be allocedIssue pending list -> alloc highest dma physically channel available -> dma done -> free physically channel
2. list: running list & pending list
submit: desc list -> pending listissue_pending_list: if (IDLE) pending list -> running list; free pending list (RUN)
irq: free running list (IDLE)check pendlist -> pending list -> running list; free pending list (RUN)3. irq:
Each list generate one irq, calling callback
One list may contain several desc chain, in such case, make sure only the last desc list generate irq.4. async
Submit will add desc chain to pending list, which can be multi-called If multi desc chain is submitted, only the last desc would generate irq -> call back If IDLE,issue_pending_liststartpending_list, transforming pendlist to running list If RUN, irq will start pending list
Quoted 7 lines
5. test
5.1pxa3xx_nandon pxa910
5.2 insmod dmatest.ko (threads_per_chan=y)
By defaultdrivers/dma/dmatest.ctest every channel and test memcpy with 1 threads per channelSigned-off-by Zhangfei Gao <[email protected]>Acked-by Arnd Bergmann <[email protected]>
Applied thanks
Signature · 1 line
~Vinod
PATCH v5 2/3 dmaengine: mmp_tdma: add dt support
In reply to Zhangfei Gao--- drivers/dma/mmp_tdma.c | 51 +++++++++++++++++++++++++++++------------------ 1 files changed, 31 insertions(+), 20 deletions(-)
drivers/dma/mmp_tdma.c +31 -20
@@ -20,6 +20,7 @@#include <linux/device.h> #include <mach/regs-icu.h> #include <mach/sram.h> +#include <linux/of_device.h> #include "dmaengine.h"
@@ -127,7 +128,6 @@ struct mmp_tdma_device {void __iomem *base;struct dma_device device;struct mmp_tdma_chan *tdmac[TDMA_CHANNEL_NUM ]; -int irq; };#define to_mmp_tdma_chan (dchan) container_of(dchan, struct mmp_tdma_chan, chan)
@@ -492,7 +492,7 @@ static int __devinit mmp_tdma_chan_init(struct mmp_tdma_device *tdev,return -ENOMEM ; }if (irq) - tdmac->irq = irq + idx; + tdmac->irq = irq; tdmac->dev = tdev->dev; tdmac->chan.device = &tdev->device; tdmac->idx = idx;
@@ -505,34 +505,43 @@ static int __devinit mmp_tdma_chan_init(struct mmp_tdma_device *tdev,/* add the channel to tdma_chan list */ list_add_tail (&tdmac->chan.device_node, &tdev->device.channels); -return 0 ; } +static struct of_device_id mmp_tdma_dt_ids[] = { + { .compatible ="marvell,adma-1.0" , .data = (void *)MMP_AUD_TDMA }, + { .compatible ="marvell,pxa910-squ" , .data = (void *)PXA910_SQU }, + {} +}; +MODULE_DEVICE_TABLE (of, mmp_tdma_dt_ids); +static int __devinit mmp_tdma_probe (struct platform_device *pdev) { -const struct platform_device_id *id =platform_get_device_id (pdev); -enum mmp_tdma_type type = id->driver_data; +enum mmp_tdma_type type; +const struct of_device_id *of_id;struct mmp_tdma_device *tdev;struct resource *iores;int i, ret; -int irq =0 ; +int irq =0 , irq_num =0 ;int chan_num =TDMA_CHANNEL_NUM ; + of_id =of_match_device (mmp_tdma_dt_ids, &pdev->dev); +if (of_id) + type = (enum mmp_tdma_type ) of_id->data; +else + type =platform_get_device_id (pdev)->driver_data; +/* always have couple channels */ tdev =devm_kzalloc (&pdev->dev,sizeof (*tdev),GFP_KERNEL );if (!tdev)return -ENOMEM ; tdev->dev = &pdev->dev; - iores =platform_get_resource (pdev,IORESOURCE_IRQ ,0 ); -if (!iores) -return -EINVAL ; -if (resource_size (iores) != chan_num) - tdev->irq = iores->start; -else - irq = iores->start; +for (i =0 ; i < chan_num; i++) { +if (platform_get_irq (pdev, i) >0 ) + irq_num++; + } iores =platform_get_resource (pdev,IORESOURCE_MEM ,0 );if (!iores)
@@ -542,25 +551,26 @@ static int __devinit mmp_tdma_probe(struct platform_device *pdev)if (!tdev->base)return -EADDRNOTAVAIL ; -if (tdev->irq) { - ret =devm_request_irq (&pdev->dev, tdev->irq, +INIT_LIST_HEAD (&tdev->device.channels); + +if (irq_num != chan_num) { + irq =platform_get_irq (pdev,0 ); + ret =devm_request_irq (&pdev->dev, irq, mmp_tdma_int_handler,IRQF_DISABLED ,"tdma" , tdev);if (ret)return ret; } -dma_cap_set (DMA_SLAVE , tdev->device.cap_mask); -dma_cap_set (DMA_CYCLIC , tdev->device.cap_mask); - -INIT_LIST_HEAD (&tdev->device.channels); -/* initialize channel parameters */ for (i =0 ; i < chan_num; i++) { + irq = (irq_num != chan_num) ?0 :platform_get_irq (pdev, i); ret =mmp_tdma_chan_init (tdev, i, irq, type);if (ret)return ret; } +dma_cap_set (DMA_SLAVE , tdev->device.cap_mask); +dma_cap_set (DMA_CYCLIC , tdev->device.cap_mask); tdev->device.dev = &pdev->dev; tdev->device.device_alloc_chan_resources = mmp_tdma_alloc_chan_resources;
@@ -595,6 +605,7 @@ static struct platform_driver mmp_tdma_driver = { .driver = { .name = "mmp-tdma", .owner = THIS_MODULE, + .of_match_table = mmp_tdma_dt_ids, }, .id_table = mmp_tdma_id_table, .probe = mmp_tdma_probe,
Signature · 1 line
1.7.1
PATCH v5 2/3 dmaengine: mmp_tdma: add dt support
Quoted 2 lines · Zhangfei Gao
Signed-off-by Zhangfei Gao <[email protected]>Acked-by Arnd Bergmann <[email protected]>
Applied thanks
PATCH v5 3/3 ARM: dt: mmp-dma: add binding file
In reply to Zhangfei Gao--- Documentation/devicetree/bindings/dma/mmp-dma.txt | 75 +++++++++++++++++++++ 1 files changed, 75 insertions(+), 0 deletions(-) create mode 100644 Documentation/devicetree/bindings/dma/mmp-dma.txt
Documentation/devicetree/bindings/dma/mmp-dma.txt new file +75 -0
@@ -0,0 +1,75 @@ +* MARVELL MMP DMA controller + +Marvell Peripheral DMA Controller +Used platfroms: pxa688, pxa910, pxa3xx, etc + +Required properties: +- compatible: Should be "marvell,pdma-1.0" +- reg: Should contain DMA registers location and length. +- interrupts: Either contain all of the per-channel DMA interrupts + or one irq for pdma device +- #dma-channels: Number of DMA channels supported by the controller. + +"marvell,pdma-1.0" +Used platfroms: pxa25x, pxa27x, pxa3xx, pxa93x, pxa168, pxa910, pxa688. + +Examples: + +/* + * Each channel has specific irq + * ICU parse out irq channel from ICU register, + * while DMA controller may not able to distinguish the irq channel + * Using this method, interrupt-parent is required as demuxer + * For example, pxa688 icu register 0x128, bit 0~15 is PDMA channel irq, + * 18~21 is ADMA irq + */ +pdma: dma-controller at d4000000 { + compatible = "marvell,pdma-1.0"; + reg = <0xd4000000 0x10000>; + interrupts = <0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15>; + interrupt-parent = <&intcmux32>; + #dma-channels = <16>; + }; + +/* + * One irq for all channels + * Dmaengine driver (DMA controller) distinguish irq channel via + * parsing internal register + */ +pdma: dma-controller at d4000000 { + compatible = "marvell,pdma-1.0"; + reg = <0xd4000000 0x10000>; + interrupts = <47>; + #dma-channels = <16>; + }; + + +Marvell Two Channel DMA Controller used specifically for audio +Used platfroms: pxa688, pxa910 + +Required properties: +- compatible: Should be "marvell,adma-1.0" or "marvell,pxa910-squ" +- reg: Should contain DMA registers location and length. +- interrupts: Either contain all of the per-channel DMA interrupts + or one irq for dma device + +"marvell,adma-1.0" used on pxa688 +"marvell,pxa910-squ" used on pxa910 + +Examples: + +/* each channel has specific irq */ +adma0: dma-controller at d42a0800 { + compatible = "marvell,adma-1.0"; + reg = <0xd42a0800 0x100>; + interrupts = <18 19>; + interrupt-parent = <&intcmux32>; + }; + +/* One irq for all channels */ +squ: dma-controller at d42a0800 { + compatible = "marvell,pxa910-squ"; + reg = <0xd42a0800 0x100>; + interrupts = <46>; + }; +
Signature · 1 line
1.7.1
PATCH v5 3/3 ARM: dt: mmp-dma: add binding file
Quoted 2 lines · Zhangfei Gao
Signed-off-by Zhangfei Gao <[email protected]>Acked-by Arnd Bergmann <[email protected]>
I think this patch should be merged in tree having this file, possibly arm tree?
Quoted 86 lines
--- Documentation/devicetree/bindings/dma/mmp-dma.txt | 75 +++++++++++++++++++++ 1 files changed, 75 insertions(+), 0 deletions(-) create mode 100644 Documentation/devicetree/bindings/dma/mmp-dma.txtDocumentation/devicetree/bindings/dma/mmp-dma.txt new file +75
-0@@ -0,0 +1,75 @@ +* MARVELL MMP DMA controller + +Marvell Peripheral DMA Controller +Used platfroms: pxa688, pxa910, pxa3xx, etc + +Required properties: +- compatible: Should be "marvell,pdma-1.0" +- reg: Should contain DMA registers location and length. +- interrupts: Either contain all of the per-channel DMA interrupts + or one irq for pdma device +- #dma-channels: Number of DMA channels supported by the controller. + +"marvell,pdma-1.0" +Used platfroms: pxa25x, pxa27x, pxa3xx, pxa93x, pxa168, pxa910, pxa688. + +Examples: + +/* + * Each channel has specific irq + * ICU parse out irq channel from ICU register, + * while DMA controller may not able to distinguish the irq channel + * Using this method, interrupt-parent is required as demuxer + * For example, pxa688 icu register 0x128, bit 0~15 is PDMA channel irq, + * 18~21 is ADMA irq + */ +pdma: dma-controller at d4000000 { + compatible = "marvell,pdma-1.0"; + reg = <0xd4000000 0x10000>; + interrupts = <0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15>; + interrupt-parent = <&intcmux32>; + #dma-channels = <16>; + }; + +/* + * One irq for all channels + * Dmaengine driver (DMA controller) distinguish irq channel via + * parsing internal register + */ +pdma: dma-controller at d4000000 { + compatible = "marvell,pdma-1.0"; + reg = <0xd4000000 0x10000>; + interrupts = <47>; + #dma-channels = <16>; + }; + + +Marvell Two Channel DMA Controller used specifically for audio +Used platfroms: pxa688, pxa910 + +Required properties: +- compatible: Should be "marvell,adma-1.0" or "marvell,pxa910-squ" +- reg: Should contain DMA registers location and length. +- interrupts: Either contain all of the per-channel DMA interrupts + or one irq for dma device + +"marvell,adma-1.0" used on pxa688 +"marvell,pxa910-squ" used on pxa910 + +Examples: + +/* each channel has specific irq */ +adma0: dma-controller at d42a0800 { + compatible = "marvell,adma-1.0"; + reg = <0xd42a0800 0x100>; + interrupts = <18 19>; + interrupt-parent = <&intcmux32>; + }; + +/* One irq for all channels */ +squ: dma-controller at d42a0800 { + compatible = "marvell,pxa910-squ"; + reg = <0xd42a0800 0x100>; + interrupts = <46>; + }; +
Signature · 1 line
~Vinod
PATCH v5 3/3 ARM: dt: mmp-dma: add binding file
Quoted 8 lines · Vinod Koul
Quoted 2 lines · Zhangfei Gao
Signed-off-by Zhangfei Gao <[email protected]>Acked-by Arnd Bergmann <[email protected]>Acked-by Vinod Koul <[email protected]>I think this patch should be merged in tree having this file, possibly arm tree?
You can merge this patch into your tree since it only appends a new file.
Regards
Haojian
Quoted 5 lines
Quoted 5 lines
--- Documentation/devicetree/bindings/dma/mmp-dma.txt | 75 +++++++++++++++++++++ 1 files changed, 75 insertions(+), 0 deletions(-) create mode 100644 Documentation/devicetree/bindings/dma/mmp-dma.txt
PATCH v5 3/3 ARM: dt: mmp-dma: add binding file
Quoted 11 lines · Haojian Zhuang
Quoted 8 lines · Vinod Koul
Quoted 2 lines · Zhangfei Gao
Signed-off-by Zhangfei Gao <[email protected]>Acked-by Arnd Bergmann <[email protected]>Acked-by Vinod Koul <[email protected]>I think this patch should be merged in tree having this file, possibly arm tree?
You can merge this patch into your tree since it only appends a new file.
And as I have said previously my tree or linus's tree doesn't have this file. SO this needs to go to a tree where thsi file exists
Quoted 10 lines
Acked-by Haojian Zhuang <[email protected]>Regards
HaojianQuoted 5 lines
Quoted 5 lines
--- Documentation/devicetree/bindings/dma/mmp-dma.txt | 75 +++++++++++++++++++++ 1 files changed, 75 insertions(+), 0 deletions(-) create mode 100644 Documentation/devicetree/bindings/dma/mmp-dma.txt
Signature · 1 line
~Vinod
PATCH v5 3/3 ARM: dt: mmp-dma: add binding file
Quoted 7 lines · Vinod Koul
Quoted 6 lines · Haojian Zhuang
Quoted 5 lines · Vinod Koul
Quoted 2 lines · Zhangfei Gao
Signed-off-by Zhangfei Gao <[email protected]>Acked-by Arnd Bergmann <[email protected]>Acked-by Vinod Koul <[email protected]>
Quoted 16 lines
Quoted 5 lines
Quoted 3 lines
I think this patch should be merged in tree having this file, possibly arm tree?
You can merge this patch into your tree since it only appends a new file.
And as I have said previously my tree or linus's tree doesn't have this file. SO this needs to go to a tree where thsi file exists
Quoted 6 lines
Acked-by Haojian Zhuang <[email protected]>Quoted 4 lines
Quoted 4 lines
Documentation/devicetree/bindings/dma/mmp-dma.txt | 75 +++++++++++++++++++++ 1 files changed, 75 insertions(+), 0 deletions(-) create mode 100644 Documentation/devicetree/bindings/dma/mmp-dma.txt
Thanks Vinod for the BIG help.
Arnd
Which tree you think is suitable to take this new file? Documentation/devicetree/bindings/dma/mmp-dma.txt
Thanks
Haojian Zhuang
AppliedPATCH v5 3/3 ARM: dt: mmp-dma: add binding file
Quoted 24 lines · Zhangfei Gao
Quoted 7 lines · Vinod Koul
Quoted 6 lines · Haojian Zhuang
Quoted 5 lines · Vinod Koul
Quoted 2 lines · Zhangfei Gao
Signed-off-by Zhangfei Gao <[email protected]>Acked-by Arnd Bergmann <[email protected]>Acked-by Vinod Koul <[email protected]>Quoted 16 lines
Quoted 5 lines
Quoted 3 lines
I think this patch should be merged in tree having this file, possibly arm tree?
You can merge this patch into your tree since it only appends a new file.
And as I have said previously my tree or linus's tree doesn't have this file. SO this needs to go to a tree where thsi file exists
Quoted 6 lines
Acked-by Haojian Zhuang <[email protected]>Quoted 4 lines
Quoted 4 lines
Documentation/devicetree/bindings/dma/mmp-dma.txt | 75 +++++++++++++++++++++ 1 files changed, 75 insertions(+), 0 deletions(-) create mode 100644 Documentation/devicetree/bindings/dma/mmp-dma.txt
Quoted 9 lines
Thanks Vinod for the BIG help.
Arnd
Which tree you think is suitable to take this new file?
Documentation/devicetree/bindings/dma/mmp-dma.txtThanks
Applied in arch-pxa tree.