cppi41 dma support for musb
the first patch implements a dma engine and a dma-driver for cpp41 & musb. The TX channel seems to work, there is still some work to be done. My current tree which I use for testing is also available at:
git://git.breakpoint.cc/bigeasy/linux.git am335x_usb
Sebastian
RFC 1/2 usb/musb dma: add cppi41 dma driver
This is a first shot of the cppi41 DMA driver. It is currently used by a new musb dma-engine implementation. I have to test it somehow.
The state of the cpp41 (and the using dmaengine) is in very early stage. I was able to send TX packets over DMA and enumerate an USB masstorage device.
Things that need to be taken care of:
- RX path
- cancel of transfers
- dynamic descriptor allocation
- re-think the current device tree nodes.
Currently a node looks like:
&cppi41dma X Y Z Q
that means:
- X: dma channel
- Y: RX/TX
- Z: start queue
- Q: complete queue
Each value number is hardwired with the USB endpoint it is using. The DMA channels are hardwired with USB endpoints and the start/complete is hardwired with the DMA channel.
I add each DMA channel twice: once for RX the other for TX (that is why I need the direction (Y) uppon lookup).
The RX/TX channel can be used simultaneously i.e. program & start RX, program & start TX and TX can complete before RX.
Currently I think that it would be best to remove the queue logic from the device and put it into the driver.
--- arch/arm/boot/dts/am33xx.dtsi | 50 +++ drivers/dma/Kconfig | 9 + drivers/dma/Makefile | 1 + drivers/dma/cppi41.c | 777 +++++++++++++++++++++++++++++++++++++++++ drivers/usb/musb/Kconfig | 4 + drivers/usb/musb/Makefile | 1 + drivers/usb/musb/musb_dma.h | 2 +- drivers/usb/musb/musb_dmaeng.c | 294 ++++++++++++++++ 8 files changed, 1137 insertions(+), 1 deletion(-) create mode 100644 drivers/dma/cppi41.c create mode 100644 drivers/usb/musb/musb_dmaeng.c
arch/arm/boot/dts/am33xx.dtsi +50 -0
@@ -349,6 +349,18 @@ status = "disabled"; }; + cppi41dma: dma@07402000 { + compatible = "ti,am3359-cppi41"; + reg = <0x47400000 0x1000 /* usbss */ + 0x47402000 0x1000 /* controller */ + 0x47403000 0x1000 /* scheduler */ + 0x47404000 0x4000>; /* queue manager */ + interrupts = <17>; + #dma-cells = <4>; + #dma-channels = <30>; + #dma-requests = <256>; + }; + musb: usb@47400000 { compatible = "ti,musb-am33xx"; reg = <0x47400000 0x1000>;
@@ -383,6 +395,44 @@ power = <250>; phys = <&musb1_phy>; status = "disabled"; + dmas = <&cppi41dma 15 0 16 141 + &cppi41dma 16 0 17 142 + &cppi41dma 17 0 18 143 + &cppi41dma 18 0 19 144 + &cppi41dma 19 0 20 145 + &cppi41dma 20 0 21 146 + &cppi41dma 21 0 22 147 + &cppi41dma 22 0 23 148 + &cppi41dma 23 0 24 149 + &cppi41dma 24 0 25 150 + &cppi41dma 25 0 26 151 + &cppi41dma 26 0 27 152 + &cppi41dma 27 0 28 153 + &cppi41dma 28 0 29 154 + &cppi41dma 29 0 30 155 + + &cppi41dma 15 1 62 125 + &cppi41dma 16 1 64 126 + &cppi41dma 17 1 66 127 + &cppi41dma 18 1 68 128 + &cppi41dma 19 1 70 129 + &cppi41dma 20 1 72 130 + &cppi41dma 21 1 74 131 + &cppi41dma 22 1 76 132 + &cppi41dma 23 1 78 133 + &cppi41dma 24 1 80 134 + &cppi41dma 25 1 82 135 + &cppi41dma 26 1 84 136 + &cppi41dma 27 1 86 137 + &cppi41dma 28 1 88 138 + &cppi41dma 29 1 90 139>; + dma-names = + "rx1", "rx2", "rx3", "rx4", "rx5", "rx6", "rx7", + "rx8", "rx9", "rx10", "rx11", "rx12", "rx13", + "rx14", "rx15", + "tx1", "tx2", "tx3", "tx4", "tx5", "tx6", "tx7", + "tx8", "tx9", "tx10", "tx11", "tx12", "tx13", + "tx14", "tx15"; }; };
drivers/dma/Kconfig +9 -0
@@ -305,6 +305,15 @@ config DMA_OMAP select DMA_ENGINE select DMA_VIRTUAL_CHANNELS +config TI_CPPI41 + tristate "AM33xx CPPI41 DMA support" + depends on ARCH_OMAP + select DMA_ENGINE + select DMA_VIRTUAL_CHANNELS + help + The Communications Port Programming Interface (CPPI) 4.1 DMA engine + is currently used by the MUSB driver on AM335x platforms. + config MMP_PDMA bool "MMP PDMA support" depends on (ARCH_MMP || ARCH_PXA)
drivers/dma/Makefile +1 -0
@@ -38,3 +38,4 @@ 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 +obj-$(CONFIG_TI_CPPI41) += cppi41.o
drivers/dma/cppi41.c new file +777 -0
777 lines not on this page · raw message
drivers/usb/musb/Kconfig +4 -0
@@ -125,6 +125,10 @@ config USB_TI_CPPI_DMA help Enable DMA transfers when TI CPPI DMA is available. +config USB_TI_CPPI41_DMA + bool 'TI CPPI 4.1 (AM335x)' + depends on ARCH_OMAP + config USB_TUSB_OMAP_DMA bool 'TUSB 6010' depends on USB_MUSB_TUSB6010
drivers/usb/musb/Makefile +1 -0
@@ -29,3 +29,4 @@ musb_hdrc-$(CONFIG_USB_INVENTRA_DMA) += musbhsdma.o musb_hdrc-$(CONFIG_USB_TI_CPPI_DMA) += cppi_dma.o musb_hdrc-$(CONFIG_USB_TUSB_OMAP_DMA) += tusb6010_omap.o musb_hdrc-$(CONFIG_USB_UX500_DMA) += ux500_dma.o +musb_hdrc-$(CONFIG_USB_TI_CPPI41_DMA) += musb_dmaeng.o
drivers/usb/musb/musb_dma.h +1 -1
@@ -71,7 +71,7 @@ struct musb_hw_ep;#ifdef CONFIG_USB_TI_CPPI_DMA #define is_cppi_enabled () 1#else -#define is_cppi_enabled () 0 +#define is_cppi_enabled () 1#endif #ifdef CONFIG_USB_TUSB_OMAP_DMA
drivers/usb/musb/musb_dmaeng.c new file +294 -0
294 lines not on this page · raw message
Signature · 1 line
1.8.3.2
Re: [RFC 1/2] usb/musb dma: add cppi41 dma driver
Hello.
Quoted 1 line · Sebastian Andrzej Siewior
This is a first shot of the cppi41 DMA driver.
Where have you been when I submitted my drivers back in 2009? :-)
Quoted 30 lines
It is currently used by
a new musb dma-engine implementation. I have to test it somehow.The state of the cpp41 (and the using dmaengine) is in very early stage. I was able to send TX packets over DMA and enumerate an USB masstorage device.
Things that need to be taken care of:
- RX path
- cancel of transfers
- dynamic descriptor allocation
- re-think the current device tree nodes.
Currently a node looks like:
&cppi41dma X Y Z Q
that means:
- X: dma channel
- Y: RX/TX
- Z: start queue
- Q: complete queue
Each value number is hardwired with the USB endpoint it is using. The DMA channels are hardwired with USB endpoints and the start/complete is hardwired with the DMA channel.I add each DMA channel twice: once for RX the other for TX (that is why I need the direction (Y) uppon lookup).
The RX/TX channel can be used simultaneously i.e. program & start RX, program & start TX and TX can complete before RX.
Currently I think that it would be best to remove the queue logic from the device and put it into the driver.Signed-off-by Sebastian Andrzej Siewior <[email protected]>
Quoted 9 lines
--- arch/arm/boot/dts/am33xx.dtsi | 50 +++ drivers/dma/Kconfig | 9 + drivers/dma/Makefile | 1 + drivers/dma/cppi41.c | 777 +++++++++++++++++++++++++++++++++++++++++ drivers/usb/musb/Kconfig | 4 + drivers/usb/musb/Makefile | 1 + drivers/usb/musb/musb_dma.h | 2 +- drivers/usb/musb/musb_dmaeng.c | 294 ++++++++++++++++
MUSB DMA engine support can't be generic unfortunately. There are
some non-generic DMA registers in each MUSB implementation that used CPPI 4.1.
arch/arm/boot/dts/am33xx.dtsi line 352
Quoted 13 lines
8 files changed, 1137 insertions(+), 1 deletion(-)create mode 100644
drivers/dma/cppi41.ccreate mode 100644drivers/usb/musb/musb_dmaeng.carch/arm/boot/dts/am33xx.dtsi +1
-0@@ -349,6 +349,18 @@ status = "disabled"; }; + cppi41dma: dma@07402000 {
@47402000? maybe?
arch/arm/boot/dts/am33xx.dtsi line 354
Quoted 2 lines
arch/arm/boot/dts/am33xx.dtsi +2
-0+ compatible = "ti,am3359-cppi41"; + reg = <0x47400000 0x1000 /* usbss */
USB register are not a part of CPPI 4.1 DMA. They are not generic
and are different on e.g. DA8xx/OMAP-L1x. Besides this range is conflicting with the next node.
Quoted 12 lines
arch/arm/boot/dts/am33xx.dtsi +9
-0+ 0x47402000 0x1000 /* controller */ + 0x47403000 0x1000 /* scheduler */ + 0x47404000 0x4000>; /* queue manager */ + interrupts = <17>; + #dma-cells = <4>; + #dma-channels = <30>; + #dma-requests = <256>; + }; + musb: usb@47400000 { compatible = "ti,musb-am33xx"; reg = <0x47400000 0x1000>;
[...]
drivers/dma/Kconfig config DMA_OMAP · line 309
Quoted 10 lines
drivers/dma/Kconfig +2
-0@@ -305,6 +305,15 @@ config DMA_OMAP select DMA_ENGINE select DMA_VIRTUAL_CHANNELS +config TI_CPPI41 + tristate "AM33xx CPPI41 DMA support"
It shouldn't be specific to AM33xx.
drivers/dma/Kconfig config DMA_OMAP · line 310
Quoted 1 line
drivers/dma/Kconfig +1
-0+ depends on ARCH_OMAP
And shouldn't depend on ARCH_OMAP only, also on ARCH_DAVINCI_DA8XX.
[...]
Quoted 20 lines
drivers/dma/cppi41.c new file +14
-0@@ -0,0 +1,777 @@ +#include <linux/dmaengine.h> +#include <linux/dma-mapping.h> +#include <linux/platform_device.h> +#include <linux/module.h> +#include <linux/of.h> +#include <linux/slab.h> +#include <linux/of_dma.h> +#include <linux/of_irq.h> +#include <linux/dmapool.h> +#include <linux/interrupt.h> +#include <linux/of_address.h> +#include "dmaengine.h" + +#define DESC_TYPE 27
drivers/dma/cppi41.c line 24
Quoted 10 lines
drivers/dma/cppi41.c new file +10
-0+#define DESC_TYPE_HOST 0x10 +#define DESC_TYPE_TEARD 0x13 + +#define TD_DESC_TX_RX 16 +#define TD_DESC_DMA_NUM 10 + +/* USB SS */ +#define USBSS_IRQ_STATUS (0x28) +#define USBSS_IRQ_ENABLER (0x2c) +#define USBSS_IRQ_CLEARR (0x30)
These shouldn't be here. Why enclose them in () BTW?
drivers/dma/cppi41.c line 35
Quoted 11 lines
drivers/dma/cppi41.c new file +11
-0+ +#define USBSS_IRQ_RX1 (1 << 11) +#define USBSS_IRQ_TX1 (1 << 10) +#define USBSS_IRQ_RX0 (1 << 9) +#define USBSS_IRQ_TX0 (1 << 8) +#define USBSS_IRQ_PD_COMP (1 << 2) + +#define USBSS_IRQ_RXTX1 (USBSS_IRQ_RX1 | USBSS_IRQ_TX1) +#define USBSS_IRQ_RXTX0 (USBSS_IRQ_RX0 | USBSS_IRQ_TX0) +#define USBSS_IRQ_RXTX01 (USBSS_IRQ_RXTX0 | USBSS_IRQ_RXTX1) +
Neither these shouldn't be here.
drivers/dma/cppi41.c line 60
Quoted 2 lines
drivers/dma/cppi41.c new file +2
-0+/* Queue manager */ +/* 4 KiB of memory for descriptors, 2 for each endpoint */
Endpoints shouldn't be mentioned. CPPI 4.1 is universal DMA engine,
not USB specific.
drivers/dma/cppi41.c line 118
Quoted 11 lines
drivers/dma/cppi41.c new file +11
-0+struct cppi41_dd { +struct dma_device ddev; + +void *qmgr_scratch; +dma_addr_t scratch_phys; + +struct cppi41_desc *cd; +dma_addr_t descs_phys; +struct cppi41_channel *chan_busy[ALLOC_DECS_NUM ]; + +void __iomem *usbss_mem;
Shouldn't be here.
drivers/dma/cppi41.c line 122
Quoted 4 lines
drivers/dma/cppi41.c new file +4
-0+void __iomem *ctrl_mem; +void __iomem *sched_mem; +void __iomem *qmgr_mem; +unsigned int irq;
Shouldn't be here either.
drivers/dma/cppi41.c line 152
Quoted 12 lines
drivers/dma/cppi41.c new file +12
-0+static struct cppi41_channel *desc_to_chan (struct cppi41_dd *cdd,u32 desc) +{ +struct cppi41_channel *c; +u32 descs_size; +u32 desc_num; + + descs_size =sizeof (struct cppi41_desc ) *ALLOC_DECS_NUM ; + +if (!((desc >= cdd->descs_phys) && + (desc < (cdd->descs_phys + descs_size)))) { +return NULL ; + }
checkpatch.pl would complain about single statement in {}.
drivers/dma/cppi41.c line 171
Quoted 11 lines
drivers/dma/cppi41.c new file +11
-0+static void cppi_writel (u32 val,void *__iomem *mem) +{ +writel (val, mem); +} + +static u32 cppi_readl (void *__iomem *mem) +{ +u32 val; + val =readl (mem); +return val; +}
I don't see much sense in these functions. Besides, they should
probably be using __raw_{read|write}().
drivers/dma/cppi41.c line 185
Quoted 10 lines
drivers/dma/cppi41.c new file +10
-0+static irqreturn_t cppi41_irq (int irq,void *data) +{ +struct cppi41_dd *cdd = data; +struct cppi41_channel *c; +u32 status; +int i; + + status =cppi_readl (cdd->usbss_mem +USBSS_IRQ_STATUS ); +if (!(status &USBSS_IRQ_PD_COMP )) +return IRQ_NONE ;
No, this can't be here.
Quoted 14 lines
drivers/dma/cppi41.c new file +14
-0+static u32 get_host_pd0 (u32 length) +{ +u32 reg; + + reg =DESC_TYPE_HOST <<DESC_TYPE ; + reg |= length; + +return reg; +} + +static u32 get_host_pd1 (struct cppi41_channel *c) +{ +u32 reg; +
drivers/dma/cppi41.c line 312
Quoted 10 lines
drivers/dma/cppi41.c new file +10
-0+ reg =0 ; + +return reg; +} + +static u32 get_host_pd2 (struct cppi41_channel *c) +{ +u32 reg; + + reg =5 <<26 ;/* USB TYPE */
The driver shouldn't be tied to USB at all.
Quoted 12 lines
drivers/dma/cppi41.c new file +12
-0+static int cppi41_dma_probe (struct platform_device *pdev) +{ +struct cppi41_dd *cdd; +int irq; +int ret; + + cdd =kzalloc (sizeof (*cdd),GFP_KERNEL ); +if (!cdd) +return -ENOMEM ; + +dma_cap_set (DMA_SLAVE , cdd->ddev.cap_mask); + cdd->ddev.device_alloc_chan_resources = cppi41_dma_alloc_chan_resources;
drivers/dma/cppi41.c line 680
Quoted 10 lines
drivers/dma/cppi41.c new file +10
-0+ cdd->ddev.device_free_chan_resources = cppi41_dma_free_chan_resources; + cdd->ddev.device_tx_status = cppi41_dma_tx_status; + cdd->ddev.device_issue_pending = cppi41_dma_issue_pending; + cdd->ddev.device_prep_slave_sg = cppi41_dma_prep_slave_sg; + cdd->ddev.device_control = cppi41_dma_control; + cdd->ddev.dev = &pdev->dev; +INIT_LIST_HEAD (&cdd->ddev.channels); + cpp41_dma_info.dma_cap = cdd->ddev.cap_mask; + + cdd->usbss_mem =of_iomap (pdev->dev.of_node,0 );
You should use the generic platform_get_resource()/devm_ioremap_resource() functions.
drivers/dma/cppi41.c line 703
Quoted 5 lines
drivers/dma/cppi41.c new file +5
-0+ irq =irq_of_parse_and_map (pdev->dev.of_node,0 ); +if (!irq) + goto err_irq; + +cppi_writel (USBSS_IRQ_PD_COMP , cdd->usbss_mem +USBSS_IRQ_ENABLER );
Shouldn't be here.
[...]
drivers/dma/cppi41.c line 761
Quoted 2 lines
drivers/dma/cppi41.c new file +2
-0+static const struct of_device_id cppi41_dma_ids[] = { + { .compatible ="ti,am3359-cppi41" , },
CPPI 4.1 driver should be generic, not SoC specific.
drivers/usb/musb/musb_dma.h struct musb_hw_ep; · line 74
Quoted 10 lines
drivers/usb/musb/musb_dma.h +1
-1@@ -71,7 +71,7 @@ struct musb_hw_ep;#ifdef CONFIG_USB_TI_CPPI_DMA #define is_cppi_enabled () 1#else -#define is_cppi_enabled () 0 +#define is_cppi_enabled () 1
What does that mean?
Quoted 6 lines
drivers/usb/musb/musb_dmaeng.c new file +0
-0@@ -0,0 +1,294 @@
[...]
Quoted 5 lines
drivers/usb/musb/musb_dmaeng.c new file +5
-0+static struct dma_channel *cppi41_dma_channel_allocate (struct dma_controller *c, +struct musb_hw_ep *hw_ep,u8 is_tx) +{ +struct cppi41_dma_controller *controller =container_of (c, + struct cppi41_dma_controller, controller);
drivers/usb/musb/musb_dmaeng.c line 94
Quoted 10 lines
drivers/usb/musb/musb_dmaeng.c new file +10
-0+struct cppi41_dma_channel *cppi41_channel =NULL ; +struct musb *musb = controller->musb; +u8 ch_num = hw_ep->epnum -1 ; + +if (ch_num >=MUSB_DMA_NUM_CHANNELS ) +return NULL ; + +if (!is_tx) +return NULL ; +if (is_tx)
You've just returned on '!is_tx'.
[...]
Quoted 8 lines
drivers/usb/musb/musb_dmaeng.c new file +8
-0+static void cppi41_release_all_dma_chans (struct cppi41_dma_controller *ctrl) +{ +struct dma_chan *dc; +int i; + +for (i =0 ; i <MUSB_DMA_NUM_CHANNELS ; i++) { + dc = ctrl->tx_channel[i].dc; +if (dc)
drivers/usb/musb/musb_dmaeng.c line 175
Quoted 10 lines
drivers/usb/musb/musb_dmaeng.c new file +10
-0+dma_release_channel (dc); + dc = ctrl->rx_channel[i].dc; +if (dc) +dma_release_channel (dc); + } +} + +static void cppi41_dma_controller_stop (struct cppi41_dma_controller *controller) +{ +cppi41_release_all_dma_chans (controller);
Why not just expand it inline?
Quoted 5 lines
drivers/usb/musb/musb_dmaeng.c new file +5
-0+} + +static int cppi41_dma_controller_start (struct cppi41_dma_controller *controller) +{ +struct musb *musb = controller->musb;
drivers/usb/musb/musb_dmaeng.c line 190
Quoted 10 lines
drivers/usb/musb/musb_dmaeng.c new file +10
-0+struct device *dev = musb->controller; +struct device_node *np = dev->of_node; +struct cppi41_dma_channel *cppi41_channel; +int count; +int i; +int ret; +dma_cap_mask_t mask; + +dma_cap_zero (mask); +dma_cap_set (DMA_SLAVE , mask);
You don't seem to use 'mask'.
[...]
drivers/usb/musb/musb_dmaeng.c line 232
Quoted 4 lines
drivers/usb/musb/musb_dmaeng.c new file +4
-0+ musb_dma = &cppi41_channel->channel; + musb_dma->private_data = cppi41_channel; + musb_dma->status =MUSB_DMA_STATUS_FREE ; + musb_dma->max_len =SZ_4M ;
Really?
WBR, Sergei
Re: [RFC 1/2] usb/musb dma: add cppi41 dma driver
Quoted 1 line · Sergei Shtylyov
Hello.
Hello Sergei,
Quoted 5 lines · Sebastian Andrzej Siewior
Quoted 2 lines
This is a first shot of the cppi41 DMA driver.
Where have you been when I submitted my drivers back in 2009? :-)
Not here it seems :) There is a driver I got which seem to work but it is not using the dma engine and is not really in shape so I'm doing this.
And the current musb's cppi dma engine (3.1, different logic etc.) is not using dmaengine and the network driver (cpsw) which is also using cppi 3.1 is having its own implementation of the cppi-dma part. So I think dma enggine implementation is a must here.
Quoted 3 lines
MUSB DMA engine support can't be generic unfortunately. There are
some non-generic DMA registers in each MUSB implementation that used CPPI 4.1.
I haven't got to it yet. The TX part seem generic enough so far. There seem to be two cases of how DMA is used:
- hard wired dma channel like cppi
- mostly free dma channel, the transfer requires the FIFO address
A big win is we move as much as possible of the dma code to drivers/dma so the driver can be used by other driver's like network. However if we manage to have better abstraction of the DMA interface within musb we maybe get even to a point where we can enable multiple engines.
Quoted 9 lines
Quoted 9 lines
arch/arm/boot/dts/am33xx.dtsi +0
-0@@ -349,6 +349,18 @@ status = "disabled"; };
Quoted 3 lines
arch/arm/boot/dts/am33xx.dtsi line 352
Quoted 1 line
arch/arm/boot/dts/am33xx.dtsi +1
-0+ cppi41dma: dma@07402000 {@47402000? maybe?
maybe, I will double check.
Quoted 6 lines
arch/arm/boot/dts/am33xx.dtsi line 354
Quoted 2 lines
arch/arm/boot/dts/am33xx.dtsi +2
-0+ compatible = "ti,am3359-cppi41"; + reg = <0x47400000 0x1000 /* usbss */USB register are not a part of CPPI 4.1 DMA. They are not generic and
are different on e.g. DA8xx/OMAP-L1x. Besides this range is conflicting with the next node.
I will shorten them for the range conflict. usbss is only used for interrupt mask on/off. If there are different, a different compatible string will carry the difference. I think I will also add the usb string to it since a possible network engine will look different in terms of the queue used (which I plan to move away from DT).
Quoted 8 lines
Quoted 8 lines
drivers/dma/Kconfig +0
-0@@ -305,6 +305,15 @@ config DMA_OMAP select DMA_ENGINE select DMA_VIRTUAL_CHANNELS
Quoted 4 lines
drivers/dma/Kconfig config DMA_OMAP · line 309
Quoted 2 lines
drivers/dma/Kconfig +2
-0+config TI_CPPI41 + tristate "AM33xx CPPI41 DMA support"It shouldn't be specific to AM33xx.
Okay.
Quoted 4 lines
drivers/dma/Kconfig config DMA_OMAP · line 310
Quoted 2 lines
drivers/dma/Kconfig +1
-0+ depends on ARCH_OMAPAnd shouldn't depend on
ARCH_OMAPonly, also onARCH_DAVINCI_DA8XX.
Okay
Quoted 14 lines
[...]
drivers/dma/cppi41.c line 4
Quoted 10 lines
drivers/dma/cppi41.c new file +4
-0@@ -0,0 +1,777 @@ +/* USB SS */ +#define USBSS_IRQ_STATUS (0x28) +#define USBSS_IRQ_ENABLER (0x2c) +#define USBSS_IRQ_CLEARR (0x30)These shouldn't be here. Why enclose them in () BTW?
The enclose is not on purpose and will be removed. I would keep them and distinguish different regs via compatible string once we have different implementations.
Quoted 4 lines
Quoted 4 lines
drivers/dma/cppi41.c new file +4
-0+#define USBSS_IRQ_RX1 (1 << 11) +#define USBSS_IRQ_TX1 (1 << 10) +#define USBSS_IRQ_RX0 (1 << 9) +#define USBSS_IRQ_TX0 (1 << 8)
Quoted 8 lines
drivers/dma/cppi41.c line 35
Quoted 6 lines
drivers/dma/cppi41.c new file +6
-0+#define USBSS_IRQ_PD_COMP (1 << 2) + +#define USBSS_IRQ_RXTX1 (USBSS_IRQ_RX1 | USBSS_IRQ_TX1) +#define USBSS_IRQ_RXTX0 (USBSS_IRQ_RX0 | USBSS_IRQ_TX0) +#define USBSS_IRQ_RXTX01 (USBSS_IRQ_RXTX0 | USBSS_IRQ_RXTX1) +Neither these shouldn't be here.
Se above.
Quoted 6 lines
drivers/dma/cppi41.c line 60
Quoted 3 lines
drivers/dma/cppi41.c new file +2
-0+/* Queue manager */ +/* 4 KiB of memory for descriptors, 2 for each endpoint */ Endpoints shouldn't be mentioned. CPPI 4.1 is universal DMA engine,
not USB specific.
Okay. My current plan is to keep 4kib of descriptors memory but add dynamic allocation.
Quoted 14 lines
drivers/dma/cppi41.c line 118
Quoted 11 lines
drivers/dma/cppi41.c new file +11
-0+struct cppi41_dd { +struct dma_device ddev; + +void *qmgr_scratch; +dma_addr_t scratch_phys; + +struct cppi41_desc *cd; +dma_addr_t descs_phys; +struct cppi41_channel *chan_busy[ALLOC_DECS_NUM ]; + +void __iomem *usbss_mem;Shouldn't be here.
Quoted 6 lines
drivers/dma/cppi41.c line 122
Quoted 4 lines
drivers/dma/cppi41.c new file +4
-0+void __iomem *ctrl_mem; +void __iomem *sched_mem; +void __iomem *qmgr_mem; +unsigned int irq;Shouldn't be here either.
What is wrong with the four mem pointer here?
Quoted 7 lines
Quoted 7 lines
drivers/dma/cppi41.c new file +1
-0+static struct cppi41_channel *desc_to_chan(struct cppi41_dd *cdd, u32desc)
drivers/dma/cppi41.c new file +5
-0+{ +struct cppi41_channel *c; +u32 descs_size; +u32 desc_num; +
Quoted 8 lines
drivers/dma/cppi41.c line 152
Quoted 6 lines
drivers/dma/cppi41.c new file +6
-0+ descs_size =sizeof (struct cppi41_desc ) *ALLOC_DECS_NUM ; + +if (!((desc >= cdd->descs_phys) && + (desc < (cdd->descs_phys + descs_size)))) { +return NULL ; + }checkpatch.pl would complain about single statement in {}.
It did not, but I agree.
Quoted 6 lines
Quoted 6 lines
drivers/dma/cppi41.c new file +6
-0+static void cppi_writel (u32 val,void *__iomem *mem) +{ +writel (val, mem); +} + +static u32 cppi_readl (void *__iomem *mem)
Quoted 8 lines
drivers/dma/cppi41.c line 171
Quoted 5 lines
drivers/dma/cppi41.c new file +5
-0+{ +u32 val; + val =readl (mem); +return val; +}I don't see much sense in these functions. Besides, they should
probably be using __raw_{read|write}().
I had printk() before posting for debugging. Using raw would require an explicit cache flush before triggering the engine, right?
Quoted 4 lines
Quoted 4 lines
drivers/dma/cppi41.c new file +4
-0+static irqreturn_t cppi41_irq (int irq,void *data) +{ +struct cppi41_dd *cdd = data; +struct cppi41_channel *c;
Quoted 8 lines
drivers/dma/cppi41.c line 185
Quoted 6 lines
drivers/dma/cppi41.c new file +6
-0+u32 status; +int i; + + status =cppi_readl (cdd->usbss_mem +USBSS_IRQ_STATUS ); +if (!(status &USBSS_IRQ_PD_COMP )) +return IRQ_NONE ;No, this can't be here.
again. Why not?
Quoted 18 lines
Quoted 18 lines
drivers/dma/cppi41.c new file +18
-0+static u32 get_host_pd0 (u32 length) +{ +u32 reg; + + reg =DESC_TYPE_HOST <<DESC_TYPE ; + reg |= length; + +return reg; +} + +static u32 get_host_pd1 (struct cppi41_channel *c) +{ +u32 reg; + + reg =0 ; + +return reg; +}
Quoted 8 lines
drivers/dma/cppi41.c line 312
Quoted 6 lines
drivers/dma/cppi41.c new file +6
-0+ +static u32 get_host_pd2 (struct cppi41_channel *c) +{ +u32 reg; + + reg =5 <<26 ;/* USB TYPE */ The driver shouldn't be tied to USB at all.
For now it is USB only. Once we git different types we will have different compatible strings for that. But that shift could by hidden behind a define so to comment could vanish as well.
Quoted 34 lines
Quoted 15 lines
drivers/dma/cppi41.c new file +12
-0+static int cppi41_dma_probe (struct platform_device *pdev) +{ +struct cppi41_dd *cdd; +int irq; +int ret; + + cdd =kzalloc (sizeof (*cdd),GFP_KERNEL ); +if (!cdd) +return -ENOMEM ; + +dma_cap_set (DMA_SLAVE , cdd->ddev.cap_mask); + cdd->ddev.device_alloc_chan_resources =
cppi41_dma_alloc_chan_resources;
+cdd->ddev.device_free_chan_resources=cppi41_dma_free_chan_resources;drivers/dma/cppi41.c line 680
Quoted 9 lines
drivers/dma/cppi41.c new file +9
-0+ cdd->ddev.device_tx_status = cppi41_dma_tx_status; + cdd->ddev.device_issue_pending = cppi41_dma_issue_pending; + cdd->ddev.device_prep_slave_sg = cppi41_dma_prep_slave_sg; + cdd->ddev.device_control = cppi41_dma_control; + cdd->ddev.dev = &pdev->dev; +INIT_LIST_HEAD (&cdd->ddev.channels); + cpp41_dma_info.dma_cap = cdd->ddev.cap_mask; + + cdd->usbss_mem =of_iomap (pdev->dev.of_node,0 );You should use the generic platform_get_resource()/
devm_ioremap_resource()functions.drivers/dma/cppi41.c line 703
Quoted 5 lines
drivers/dma/cppi41.c new file +5
-0+ irq =irq_of_parse_and_map (pdev->dev.of_node,0 ); +if (!irq) + goto err_irq; + +cppi_writel (USBSS_IRQ_PD_COMP , cdd->usbss_mem +USBSS_IRQ_ENABLER );
Quoted 7 lines
Shouldn't be here.
[...]
drivers/dma/cppi41.c line 761
Quoted 2 lines
drivers/dma/cppi41.c new file +2
-0+static const struct of_device_id cppi41_dma_ids[] = { + { .compatible ="ti,am3359-cppi41" , },CPPI 4.1 driver should be generic, not SoC specific.
So you want another driver around it to handle the SoC specific stuff?
Quoted 13 lines
drivers/usb/musb/musb_dma.h struct musb_hw_ep; · line 74
Quoted 11 lines
drivers/usb/musb/musb_dma.h +1
-1@@ -71,7 +71,7 @@ struct musb_hw_ep;#ifdef CONFIG_USB_TI_CPPI_DMA #define is_cppi_enabled () 1#else -#define is_cppi_enabled () 0 +#define is_cppi_enabled () 1What does that mean?
This isn't meant for final. It is just for me to easy hacking.
Quoted 19 lines
Quoted 8 lines
drivers/usb/musb/musb_dmaeng.c new file +0
-0@@ -0,0 +1,294 @@[...]
Quoted 10 lines
+static struct
dma_channel*cppi41_dma_channel_allocate(structdma_controller*c,drivers/usb/musb/musb_dmaeng.c new file +8
-0+ struct musb_hw_ep *hw_ep, u8 is_tx) +{ +struct cppi41_dma_controller *controller =container_of (c, + struct cppi41_dma_controller, controller); +struct cppi41_dma_channel *cppi41_channel =NULL ; +struct musb *musb = controller->musb; +u8 ch_num = hw_ep->epnum -1 ; +
Quoted 8 lines
drivers/usb/musb/musb_dmaeng.c line 94
Quoted 6 lines
drivers/usb/musb/musb_dmaeng.c new file +6
-0+if (ch_num >=MUSB_DMA_NUM_CHANNELS ) +return NULL ; + +if (!is_tx) +return NULL ; +if (is_tx)You've just returned on '!is_tx'.
As I said earlier, I have only TX completed so for RX channels there is nothing to do. If you want this to be removed wait for the next version which has RX also implemented :)
Quoted 15 lines
[...]
Quoted 14 lines
+static void
cppi41_release_all_dma_chans(struct cppi41_dma_controller *ctrl)drivers/usb/musb/musb_dmaeng.c new file +12
-0+{ +struct dma_chan *dc; +int i; + +for (i =0 ; i <MUSB_DMA_NUM_CHANNELS ; i++) { + dc = ctrl->tx_channel[i].dc; +if (dc) +dma_release_channel (dc); + dc = ctrl->rx_channel[i].dc; +if (dc) +dma_release_channel (dc); + }
Quoted 8 lines
drivers/usb/musb/musb_dmaeng.c line 175
Quoted 6 lines
drivers/usb/musb/musb_dmaeng.c new file +3
-0+} + +static void cppi41_dma_controller_stop(struct cppi41_dma_controller*controller)
drivers/usb/musb/musb_dmaeng.c new file +2
-0+{ +cppi41_release_all_dma_chans (controller);Why not just expand it inline?
Will do so once I'm done and sure that there is nothing else coming here.
Quoted 10 lines
Quoted 10 lines
drivers/usb/musb/musb_dmaeng.c new file +3
-0+} + +static int cppi41_dma_controller_start(struct cppi41_dma_controller*controller)
drivers/usb/musb/musb_dmaeng.c new file +6
-0+{ +struct musb *musb = controller->musb; +struct device *dev = musb->controller; +struct device_node *np = dev->of_node; +struct cppi41_dma_channel *cppi41_channel; +int count;
Quoted 8 lines
drivers/usb/musb/musb_dmaeng.c line 190
Quoted 6 lines
drivers/usb/musb/musb_dmaeng.c new file +6
-0+int i; +int ret; +dma_cap_mask_t mask; + +dma_cap_zero (mask); +dma_cap_set (DMA_SLAVE , mask);You don't seem to use 'mask'.
Strange. That is true but I assumed that I passed it somehow to the dma-engine code.
Quoted 7 lines
[...]
drivers/usb/musb/musb_dmaeng.c line 232
Quoted 4 lines
drivers/usb/musb/musb_dmaeng.c new file +4
-0+ musb_dma = &cppi41_channel->channel; + musb_dma->private_data = cppi41_channel; + musb_dma->status =MUSB_DMA_STATUS_FREE ; + musb_dma->max_len =SZ_4M ;Really?
The TRM says somewhere that it can handle a single transfer up to 4MiB.
Quoted 3 lines
WBR, Sergei
Sebastian
Re: [RFC 1/2] usb/musb dma: add cppi41 dma driver
Quoted 9 lines · Sebastian Andrzej Siewior
Quoted 1 line · Sergei Shtylyov
Hello.
Hello Sergei,
Quoted 4 lines · Sebastian Andrzej Siewior
Quoted 2 lines
This is a first shot of the cppi41 DMA driver.
Quoted 7 lines
Quoted 1 line
Where have you been when I submitted my drivers back in 2009? :-)
Not here it seems :) There is a driver I got which seem to work but it is not using the dma engine and is not really in shape so I'm doing this.
And the current musb's cppi dma engine (3.1, different logic etc.) is
3.0 I think.
Quoted 3 lines
not using dmaengine and the network driver (cpsw) which is also using cppi 3.1 is having its own implementation of the cppi-dma part. So I think dma enggine implementation is a must here.
Not at all. I'm not familiar with CPSW but DaVinci EMAC uses CPPI
3.0 too but it's completely regisyter incompatible with USB. CPPI 3.0 doesn't seem to be universal DMA engine, hence drivers/dma/ driver doesn't seem feasible.
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
arch/arm/boot/dts/am33xx.dtsi +0
-0@@ -349,6 +349,18 @@
[...]
Quoted 10 lines
Quoted 6 lines
arch/arm/boot/dts/am33xx.dtsi line 354
Quoted 2 lines
arch/arm/boot/dts/am33xx.dtsi +2
-0+ compatible = "ti,am3359-cppi41"; + reg = <0x47400000 0x1000 /* usbss */USB register are not a part of CPPI 4.1 DMA. They are not generic and
are different on e.g. DA8xx/OMAP-L1x. Besides this range is conflicting with the next node.I will shorten them for the range conflict. usbss is only used for interrupt mask on/off. If there are different, a different compatible string will carry the difference.
You don't quite understand. CPPI 4.1 specification as such (which I
guess you haven't seen) doesn't include any interrupt registers.
Quoted 3 lines
I think I will also add the usb
string to it since a possible network engine will look different in terms of the queue used (which I plan to move away from DT).
There are out of tree platform which uses CPPI 4.1 not only for USB
but e.g. for Ethernet.
Quoted 6 lines
Quoted 6 lines
drivers/dma/cppi41.c +0
-0Quoted 5 lines
new file mode 100644
index 0000000..80dcb56drivers/dma/cppi41.c new file +0
-0@@ -0,0 +1,777 @@
[...]
Quoted 14 lines
Quoted 13 lines
drivers/dma/cppi41.c line 118
Quoted 11 lines
drivers/dma/cppi41.c new file +11
-0+struct cppi41_dd { +struct dma_device ddev; + +void *qmgr_scratch; +dma_addr_t scratch_phys; + +struct cppi41_desc *cd; +dma_addr_t descs_phys; +struct cppi41_channel *chan_busy[ALLOC_DECS_NUM ]; + +void __iomem *usbss_mem;Shouldn't be here.
Quoted 8 lines
Quoted 6 lines
drivers/dma/cppi41.c line 122
Quoted 4 lines
drivers/dma/cppi41.c new file +4
-0+void __iomem *ctrl_mem; +void __iomem *sched_mem; +void __iomem *qmgr_mem; +unsigned int irq;Shouldn't be here either.
What is wrong with the four mem pointer here?
I meant only IRQ (interrupt registers are not part of CPPI 4.1 spec).
Quoted 15 lines
Quoted 6 lines
Quoted 6 lines
drivers/dma/cppi41.c new file +6
-0+static void cppi_writel (u32 val,void *__iomem *mem) +{ +writel (val, mem); +} + +static u32 cppi_readl (void *__iomem *mem)Quoted 8 lines
drivers/dma/cppi41.c line 171
Quoted 5 lines
drivers/dma/cppi41.c new file +5
-0+{ +u32 val; + val =readl (mem); +return val; +}I don't see much sense in these functions. Besides, they should
probably be using __raw_{read|write}().
Quoted 2 lines
I had
printk()before posting for debugging. Using raw would require an explicit cache flush before triggering the engine, right?
Don't think so -- I wasn't using it.
Quoted 13 lines
Quoted 4 lines
Quoted 4 lines
drivers/dma/cppi41.c new file +4
-0+static irqreturn_t cppi41_irq (int irq,void *data) +{ +struct cppi41_dd *cdd = data; +struct cppi41_channel *c;Quoted 8 lines
drivers/dma/cppi41.c line 185
Quoted 6 lines
drivers/dma/cppi41.c new file +6
-0+u32 status; +int i; + + status =cppi_readl (cdd->usbss_mem +USBSS_IRQ_STATUS ); +if (!(status &USBSS_IRQ_PD_COMP )) +return IRQ_NONE ;No, this can't be here.
Quoted 1 line
again. Why not?
This register is not part of CPPI 4.1 spec.
Quoted 27 lines
Quoted 18 lines
Quoted 18 lines
drivers/dma/cppi41.c new file +18
-0+static u32 get_host_pd0 (u32 length) +{ +u32 reg; + + reg =DESC_TYPE_HOST <<DESC_TYPE ; + reg |= length; + +return reg; +} + +static u32 get_host_pd1 (struct cppi41_channel *c) +{ +u32 reg; + + reg =0 ; + +return reg; +}Quoted 8 lines
drivers/dma/cppi41.c line 312
Quoted 6 lines
drivers/dma/cppi41.c new file +6
-0+ +static u32 get_host_pd2 (struct cppi41_channel *c) +{ +u32 reg; + + reg =5 <<26 ;/* USB TYPE */ The driver shouldn't be tied to USB at all.
Quoted 3 lines
For now it is USB only. Once we git different types we will have different compatible strings for that. But that shift could by hidden behind a define so to comment could vanish as well.
I repeat: CPPI 4.1 is universal DMA engine. It's a pity that it's
implemented as a part of USB peripheral on all in-tree platforms but it's implemented as an autonomous module on out-of-tree platforms.
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
drivers/dma/cppi41.c new file +2
-0+static int cppi41_dma_probe (struct platform_device *pdev) +{
[...]
Quoted 8 lines
Quoted 7 lines
drivers/dma/cppi41.c line 703
Quoted 5 lines
drivers/dma/cppi41.c new file +5
-0+ irq =irq_of_parse_and_map (pdev->dev.of_node,0 ); +if (!irq) + goto err_irq; + +cppi_writel (USBSS_IRQ_PD_COMP , cdd->usbss_mem +USBSS_IRQ_ENABLER );Shouldn't be here.
Quoted 7 lines
Quoted 5 lines
[...]
drivers/dma/cppi41.c line 761
Quoted 2 lines
drivers/dma/cppi41.c new file +2
-0+static const struct of_device_id cppi41_dma_ids[] = { + { .compatible ="ti,am3359-cppi41" , },CPPI 4.1 driver should be generic, not SoC specific.
So you want another driver around it to handle the SoC specific stuff?
This can be handled as part of MUSB DMA driver in our case.
Quoted 27 lines
Quoted 18 lines
Quoted 7 lines
drivers/usb/musb/musb_dmaeng.c new file +0
-0@@ -0,0 +1,294 @@[...]
Quoted 10 lines
+static struct
dma_channel*cppi41_dma_channel_allocate(structdma_controller*c,drivers/usb/musb/musb_dmaeng.c new file +8
-0+ struct musb_hw_ep *hw_ep, u8 is_tx) +{ +struct cppi41_dma_controller *controller =container_of (c, + struct cppi41_dma_controller, controller); +struct cppi41_dma_channel *cppi41_channel =NULL ; +struct musb *musb = controller->musb; +u8 ch_num = hw_ep->epnum -1 ; +Quoted 8 lines
drivers/usb/musb/musb_dmaeng.c line 94
Quoted 6 lines
drivers/usb/musb/musb_dmaeng.c new file +6
-0+if (ch_num >=MUSB_DMA_NUM_CHANNELS ) +return NULL ; + +if (!is_tx) +return NULL ; +if (is_tx)You've just returned on '!is_tx'.
Quoted 3 lines
As I said earlier, I have only TX completed so for RX channels there is nothing to do. If you want this to be removed wait for the next version which has RX also implemented :)
I don't see why this *if* (which couldn't happen) is in current
version exactly.
Quoted 9 lines
Quoted 7 lines
[...]
drivers/usb/musb/musb_dmaeng.c line 232
Quoted 4 lines
drivers/usb/musb/musb_dmaeng.c new file +4
-0+ musb_dma = &cppi41_channel->channel; + musb_dma->private_data = cppi41_channel; + musb_dma->status =MUSB_DMA_STATUS_FREE ; + musb_dma->max_len =SZ_4M ;Really?
The TRM says somewhere that it can handle a single transfer up to 4MiB.
Strange, my DA8xx driver didn't seem to include such limitation.
Quoted 1 line
Sebastian
PS: Are you aware that TI has written CPPI 4.2 DMA engine driver in their Arago project?
http://linux.davincidsp.com/pipermail/davinci-linux-open-source/2013-February/026345.html
WBR, Sergei
Re: [RFC 1/2] usb/musb dma: add cppi41 dma driver
Quoted 8 lines · Sergei Shtylyov
Quoted 3 lines
not using dmaengine and the network driver (cpsw) which is also using cppi 3.1 is having its own implementation of the cppi-dma part. So I think dma enggine implementation is a must here.
Not at all. I'm not familiar with CPSW but DaVinci EMAC uses CPPI 3.0
too but it's completely regisyter incompatible with USB. CPPI 3.0 doesn't seem to be universal DMA engine, hencedrivers/dma/driver doesn't seem feasible.
So you suggest to avoid drivers/dma and create drivers/usb /musb/cpp41-dma.c instead?
cpsw is using davinci_cpdma.c and you say it is completely different from what musb is using? I just browsed over the spec it looked very familiar.
Quoted 6 lines
Quoted 3 lines
I will shorten them for the range conflict. usbss is only used for interrupt mask on/off. If there are different, a different compatible string will carry the difference.
You don't quite understand. CPPI 4.1 specification as such (which I
guess you haven't seen) doesn't include any interrupt registers.
Yes but you do have them somewhere. So all its needs is just the SoC type which brings the register specification.
Quoted 6 lines
Quoted 3 lines
I think I will also add the usb
string to it since a possible network engine will look different in terms of the queue used (which I plan to move away from DT).There are out of tree platform which uses CPPI 4.1 not only for USB
but e.g. for Ethernet.
So what? The binding will be different, you get a different register for interrupt. I'm still not buying that part where you want skip the dmaengine framework and introduce custom callbacks for this kind of things.
Quoted 97 lines
Quoted 6 lines
Quoted 6 lines
drivers/dma/cppi41.c +0
-0Quoted 5 lines
new file mode 100644
index 0000000..80dcb56drivers/dma/cppi41.c new file +0
-0@@ -0,0 +1,777 @@[...]
Quoted 14 lines
Quoted 13 lines
drivers/dma/cppi41.c line 118
Quoted 11 lines
drivers/dma/cppi41.c new file +11
-0+struct cppi41_dd { +struct dma_device ddev; + +void *qmgr_scratch; +dma_addr_t scratch_phys; + +struct cppi41_desc *cd; +dma_addr_t descs_phys; +struct cppi41_channel *chan_busy[ALLOC_DECS_NUM ]; + +void __iomem *usbss_mem;Shouldn't be here.
Quoted 8 lines
Quoted 6 lines
drivers/dma/cppi41.c line 122
Quoted 4 lines
drivers/dma/cppi41.c new file +4
-0+void __iomem *ctrl_mem; +void __iomem *sched_mem; +void __iomem *qmgr_mem; +unsigned int irq;Shouldn't be here either.
What is wrong with the four mem pointer here?
I meant only IRQ (interrupt registers are not part of CPPI 4.1 spec).
Quoted 15 lines
Quoted 6 lines
Quoted 6 lines
drivers/dma/cppi41.c new file +6
-0+static void cppi_writel (u32 val,void *__iomem *mem) +{ +writel (val, mem); +} + +static u32 cppi_readl (void *__iomem *mem)Quoted 8 lines
drivers/dma/cppi41.c line 171
Quoted 5 lines
drivers/dma/cppi41.c new file +5
-0+{ +u32 val; + val =readl (mem); +return val; +}I don't see much sense in these functions. Besides, they should
probably be using __raw_{read|write}().Quoted 2 lines
I had
printk()before posting for debugging. Using raw would require an explicit cache flush before triggering the engine, right?Don't think so -- I wasn't using it.
Quoted 13 lines
Quoted 4 lines
Quoted 4 lines
drivers/dma/cppi41.c new file +4
-0+static irqreturn_t cppi41_irq (int irq,void *data) +{ +struct cppi41_dd *cdd = data; +struct cppi41_channel *c;Quoted 8 lines
drivers/dma/cppi41.c line 185
Quoted 6 lines
drivers/dma/cppi41.c new file +6
-0+u32 status; +int i; + + status =cppi_readl (cdd->usbss_mem +USBSS_IRQ_STATUS ); +if (!(status &USBSS_IRQ_PD_COMP )) +return IRQ_NONE ;No, this can't be here.
Quoted 1 line
again. Why not?
This register is not part of CPPI 4.1 spec.
Quoted 26 lines
Quoted 26 lines
Quoted 14 lines
drivers/dma/cppi41.c new file +14
-0+static u32 get_host_pd0 (u32 length) +{ +u32 reg; + + reg =DESC_TYPE_HOST <<DESC_TYPE ; + reg |= length; + +return reg; +} + +static u32 get_host_pd1 (struct cppi41_channel *c) +{ +u32 reg; +drivers/dma/cppi41.c line 312
Quoted 10 lines
drivers/dma/cppi41.c new file +10
-0+ reg =0 ; + +return reg; +} + +static u32 get_host_pd2 (struct cppi41_channel *c) +{ +u32 reg; + + reg =5 <<26 ;/* USB TYPE */ The driver shouldn't be tied to USB at all.
Quoted 7 lines
Quoted 3 lines
For now it is USB only. Once we git different types we will have different compatible strings for that. But that shift could by hidden behind a define so to comment could vanish as well.
I repeat: CPPI 4.1 is universal DMA engine. It's a pity that it's
implemented as a part of USB peripheral on all in-tree platforms but it's implemented as an autonomous module on out-of-tree platforms.
It can be still extended to use normal/generic memcpy() operation if this is supported somewhere. That one here tight to USB and can't do anything else. I do not start to include a bunch of function pointer if there is no need it for it. I didn't do anything that it made impossible to do so, right?
Quoted 13 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
drivers/dma/cppi41.c new file +2
-0+static int cppi41_dma_probe (struct platform_device *pdev) +{[...]
Quoted 10 lines
Quoted 10 lines
Quoted 6 lines
drivers/dma/cppi41.c new file +5
-0+ irq =irq_of_parse_and_map (pdev->dev.of_node,0 ); +if (!irq) + goto err_irq; + + cppi_writel(USBSS_IRQ_PD_COMP, cdd->usbss_mem +
USBSS_IRQ_ENABLER);Shouldn't be here.
[...]
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
drivers/dma/cppi41.c line 761
Quoted 2 lines
drivers/dma/cppi41.c new file +2
-0+static const struct of_device_id cppi41_dma_ids[] = { + { .compatible ="ti,am3359-cppi41" , },CPPI 4.1 driver should be generic, not SoC specific.
So you want another driver around it to handle the SoC specific stuff?
This can be handled as part of MUSB DMA driver in our case.
The glue layer you say. Okay. This does not look that bad. I will try to push it there. But then I need to pass pointers somehow between cppi41 which is behind dma-engine and this glue layer.
Quoted 6 lines
Quoted 3 lines
As I said earlier, I have only TX completed so for RX channels there is nothing to do. If you want this to be removed wait for the next version which has RX also implemented :)
I don't see why this *if* (which couldn't happen) is in current
version exactly.
Because RX path will be added. It won't stay like that for ever.
Quoted 6 lines
Quoted 1 line
Sebastian
PS: Are you aware that TI has written CPPI 4.2 DMA engine driver in their Arago project?
http://linux.davincidsp.com/pipermail/davinci-linux-open-source/2013-February/026345.html
No I wasn't. They could bring their code upstream…
Quoted 1 line
WBR, Sergei
Sebastian
Re: [RFC 1/2] usb/musb dma: add cppi41 dma driver
Hello.
Quoted 11 lines · Sebastian Andrzej Siewior
Quoted 8 lines
Quoted 3 lines
not using dmaengine and the network driver (cpsw) which is also using cppi 3.1 is having its own implementation of the cppi-dma part. So I think dma enggine implementation is a must here.
Not at all. I'm not familiar with CPSW but DaVinci EMAC uses CPPI 3.0
too but it's completely regisyter incompatible with USB. CPPI 3.0 doesn't seem to be universal DMA engine, hencedrivers/dma/driver doesn't seem feasible.So you suggest to avoid
drivers/dmaand createdrivers/usb/musb/cpp41-dma.c instead?
Where I was suggesting that? I was replying about CPPI 3.0 only.
Quoted 3 lines
cpsw is using
davinci_cpdma.cand you say it is completely different from what musb is using? I just browsed over the spec it looked very familiar.
Yes, the register interface is incompatible -- I too compared it
some time ago. The only things compatible are the DMA descriptors.
Quoted 9 lines
Quoted 6 lines
Quoted 3 lines
I will shorten them for the range conflict. usbss is only used for interrupt mask on/off. If there are different, a different compatible string will carry the difference.
You don't quite understand. CPPI 4.1 specification as such (which I
guess you haven't seen) doesn't include any interrupt registers.Yes but you do have them somewhere. So all its needs is just the SoC type which brings the register specification.
Well, it can be viewed this way...
Quoted 11 lines
Quoted 6 lines
Quoted 3 lines
I think I will also add the usb
string to it since a possible network engine will look different in terms of the queue used (which I plan to move away from DT).There are out of tree platform which uses CPPI 4.1 not only for USB
but e.g. for Ethernet.So what? The binding will be different, you get a different register for interrupt. I'm still not buying that part where you want skip the dmaengine framework and introduce custom callbacks for this kind of things.
I'm just not sure drivers/dma/ needs IRQs. To be honest, I'm not
very familiar with its APIs.
Quoted 20 lines
Quoted 19 lines
Quoted 6 lines
Quoted 6 lines
drivers/dma/cppi41.c +0
-0Quoted 5 lines
new file mode 100644
index 0000000..80dcb56drivers/dma/cppi41.c new file +0
-0@@ -0,0 +1,777 @@[...]
Quoted 11 lines
Quoted 7 lines
drivers/dma/cppi41.c line 312
Quoted 5 lines
drivers/dma/cppi41.c new file +5
-0+static u32 get_host_pd2 (struct cppi41_channel *c) +{ +u32 reg; + + reg =5 <<26 ;/* USB TYPE */ The driver shouldn't be tied to USB at all.
For now it is USB only. Once we git different types we will have different compatible strings for that. But that shift could by hidden behind a define so to comment could vanish as well.
Quoted 6 lines
Quoted 3 lines
I repeat: CPPI 4.1 is universal DMA engine. It's a pity that it's
implemented as a part of USB peripheral on all in-tree platforms but it's implemented as an autonomous module on out-of-tree platforms.It can be still extended to use normal/generic
memcpy()operation if this is supported somewhere.
No, it can't. CPPI 4.1 spec simply has no support for such thing.
It can't be implemented "somewhare" because then that hardware stops to be CPPI 4.1 compatible.
Quoted 4 lines
That one here tight to USB and can't do
anything else. I do not start to include a bunch of function pointer if there is no need it for it. I didn't do anything that it made impossible to do so, right?
I'd like to see universal driver in the end, not tied to USB in any
way.
Quoted 6 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
[...]
drivers/dma/cppi41.c line 761
Quoted 2 lines
drivers/dma/cppi41.c new file +2
-0+static const struct of_device_id cppi41_dma_ids[] = { + { .compatible ="ti,am3359-cppi41" , },CPPI 4.1 driver should be generic, not SoC specific.
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
So you want another driver around it to handle the SoC specific stuff?
This can be handled as part of MUSB DMA driver in our case.
The glue layer you say. Okay. This does not look that bad. I will try to push it there. But then I need to pass pointers somehow between cppi41 which is behind dma-engine and this glue layer.
I think that's enough to export a output queue polling function from
the DMA engine.
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
Sebastian
PS: Are you aware that TI has written CPPI 4.2 DMA engine driver in their Arago project?
They actually had plans to write CPPI 4.1 DMA engine support too but
that seems to have lead nowhere so far. They seem still content with what I wrote based on their CPPI 4.1 code back in 2008 (only moved it into drivers/usb/musb/).
Quoted 3 lines
Quoted 1 line
http://linux.davincidsp.com/pipermail/davinci-linux-open-source/2013-February/026345.html
No I wasn't. They could bring their code upstream…
Oh, they are usually in no hurry to do so. BTW, if you read the
mail, they weren't quite content with the DMA engine framework, and developed 2 alternate solutions as far as I could understand.
Quoted 1 line
Sebastian
WBR, Sergei
RFC 2/2 temporary disable first instance
In reply to Sebastian Andrzej Siewiorso testing is little easier.
--- arch/arm/boot/dts/am335x-evm.dts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/boot/dts/am335x-evm.dts +1 -1
@@ -183,7 +183,7 @@ status = "okay"; usb0@47401000 { - status = "okay"; + status = "no"; }; usb1@47401800 {
Signature · 1 line
1.8.3.2