aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/layerscape/patches-5.4/806-dma-0008-MLK-15330-3-dma-fsl-edma-v3-add-dual-fifo-support.patch
blob: 36222efcb25ebae33a39a2ae31e25cebb15ee38b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
From 6c753f83ffc3fede13582f667a15e7f6e97f972c Mon Sep 17 00:00:00 2001
From: Robin Gong <yibin.gong@nxp.com>
Date: Tue, 4 Jul 2017 16:04:36 +0800
Subject: [PATCH] MLK-15330-3 dma: fsl-edma-v3: add dual fifo support

There is Audio dual fifo cause that fill fifo one by one and
loop back after every minor loop:
  -- fill the first 32bit width fifo
  -- fill the next 32bit width fifo
  -- +MLOFF signed offset after the above two FIFOs filled
  -- loop back to the first step to handle the next minor loop.

Signed-off-by: Robin Gong <yibin.gong@nxp.com>
(cherry picked from commit 5aa5e9663bb3a834444b75ea086bef8c37ecb636)
---
 .../devicetree/bindings/dma/fsl-edma-v3.txt        |  2 ++
 drivers/dma/fsl-edma-v3.c                          | 29 ++++++++++++++++++++--
 2 files changed, 29 insertions(+), 2 deletions(-)

--- a/Documentation/devicetree/bindings/dma/fsl-edma-v3.txt
+++ b/Documentation/devicetree/bindings/dma/fsl-edma-v3.txt
@@ -22,6 +22,8 @@ Required properties:
 		0: transmit, 1: receive.
 	BIT(1): local or remote access:
 		0: local, 1: remote.
+	BIT(2): dualfifo case or not(only in Audio cyclic now):
+		0: not dual fifo case, 1: dualfifo case.
 	See the SoC's reference manual for all the supported request sources.
 - dma-channels : Number of channels supported by the controller
 
--- a/drivers/dma/fsl-edma-v3.c
+++ b/drivers/dma/fsl-edma-v3.c
@@ -78,6 +78,9 @@
 
 #define EDMA_TCD_SOFF_SOFF(x)		(x)
 #define EDMA_TCD_NBYTES_NBYTES(x)	(x)
+#define EDMA_TCD_NBYTES_MLOFF(x)	(x << 10)
+#define EDMA_TCD_NBYTES_DMLOE		(1 << 30)
+#define EDMA_TCD_NBYTES_SMLOE		(1 << 31)
 #define EDMA_TCD_SLAST_SLAST(x)		(x)
 #define EDMA_TCD_DADDR_DADDR(x)		(x)
 #define EDMA_TCD_CITER_CITER(x)		((x) & 0x7FFF)
@@ -102,6 +105,7 @@
 
 #define ARGS_RX				BIT(0)
 #define ARGS_REMOTE			BIT(1)
+#define ARGS_DFIFO			BIT(2)
 
 struct fsl_edma3_hw_tcd {
 	__le32	saddr;
@@ -143,6 +147,7 @@ struct fsl_edma3_chan {
 	int				priority;
 	int				is_rxchan;
 	int				is_remote;
+	int				is_dfifo;
 	struct dma_pool			*tcd_pool;
 	u32				chn_real_count;
 	char				txirq_name[32];
@@ -454,6 +459,19 @@ void fsl_edma3_fill_tcd(struct fsl_edma3
 
 	tcd->soff = cpu_to_le16(EDMA_TCD_SOFF_SOFF(soff));
 
+	if (fsl_chan->is_dfifo) {
+		/* set mloff as -8 */
+		nbytes |= EDMA_TCD_NBYTES_MLOFF(-8);
+		/* enable DMLOE/SMLOE */
+		if (fsl_chan->fsc.dir == DMA_MEM_TO_DEV) {
+			nbytes |= EDMA_TCD_NBYTES_DMLOE;
+			nbytes &= ~EDMA_TCD_NBYTES_SMLOE;
+		} else {
+			nbytes |= EDMA_TCD_NBYTES_SMLOE;
+			nbytes &= ~EDMA_TCD_NBYTES_DMLOE;
+		}
+	}
+
 	tcd->nbytes = cpu_to_le32(EDMA_TCD_NBYTES_NBYTES(nbytes));
 	tcd->slast = cpu_to_le32(EDMA_TCD_SLAST_SLAST(slast));
 
@@ -540,11 +558,17 @@ static struct dma_async_tx_descriptor *f
 			src_addr = dma_buf_next;
 			dst_addr = fsl_chan->fsc.dev_addr;
 			soff = fsl_chan->fsc.addr_width;
-			doff = 0;
+			if (fsl_chan->is_dfifo)
+				doff = 4;
+			else
+				doff = 0;
 		} else if (fsl_chan->fsc.dir == DMA_DEV_TO_MEM) {
 			src_addr = fsl_chan->fsc.dev_addr;
 			dst_addr = dma_buf_next;
-			soff = 0;
+			if (fsl_chan->is_dfifo)
+				soff = 4;
+			else
+				soff = 0;
 			doff = fsl_chan->fsc.addr_width;
 		} else {
 			/* DMA_DEV_TO_DEV */
@@ -715,6 +739,7 @@ static struct dma_chan *fsl_edma3_xlate(
 			fsl_chan->priority = dma_spec->args[1];
 			fsl_chan->is_rxchan = dma_spec->args[2] & ARGS_RX;
 			fsl_chan->is_remote = dma_spec->args[2] & ARGS_REMOTE;
+			fsl_chan->is_dfifo = dma_spec->args[2] & ARGS_DFIFO;
 			mutex_unlock(&fsl_edma3->fsl_edma3_mutex);
 			return chan;
 		}
(INSTALL_PROG) tools/check/chk tools/check/check_* $(DISTDIR)/check xen: $(MAKE) -C xen install tools: $(MAKE) -C tools install kernels: for i in $(XKERNELS) ; do $(MAKE) $$i-build || exit 1; done docs: sh ./docs/check_pkgs && $(MAKE) -C docs install || true # Build all the various kernels and modules kbuild: kernels # Delete the kernel build trees entirely kdelete: for i in $(XKERNELS) ; do $(MAKE) $$i-delete ; done # Clean the kernel build trees kclean: for i in $(XKERNELS) ; do $(MAKE) $$i-clean ; done # Make patches from kernel sparse trees mkpatches: for i in $(ALLSPARSETREES) ; do $(MAKE) $$i-xen.patch; done # build xen, the tools, and a domain 0 plus unprivileged linux-xen images, # and place them in the install directory. 'make install' should then # copy them to the normal system directories world: $(MAKE) clean $(MAKE) kdelete $(MAKE) dist # clean doesn't do a kclean clean:: $(MAKE) -C xen clean $(MAKE) -C tools clean $(MAKE) -C docs clean # clean, but blow away kernel build tree plus tar balls mrproper: clean rm -rf dist patches/tmp for i in $(ALLKERNELS) ; do $(MAKE) $$i-delete ; done for i in $(ALLSPARSETREES) ; do $(MAKE) $$i-mrproper ; done install-twisted: wget http://www.twistedmatrix.com/products/get-current.epy tar -zxf Twisted-*.tar.gz cd Twisted-* && python setup.py install install-logging: LOGGING=logging-0.4.9.2 install-logging: [ -f $(LOGGING).tar.gz ] || wget http://www.red-dove.com/$(LOGGING).tar.gz tar -zxf $(LOGGING).tar.gz cd $(LOGGING) && python setup.py install # handy target to upgrade iptables (use rpm or apt-get in preference) install-iptables: wget http://www.netfilter.org/files/iptables-1.2.11.tar.bz2 tar -jxf iptables-1.2.11.tar.bz2 $(MAKE) -C iptables-1.2.11 PREFIX= KERNEL_DIR=../linux-$(LINUX_VER)-xen0 install install-%: DESTDIR= install-%: % @: # do nothing help: @echo 'Installation targets:' @echo ' install - build and install everything' @echo ' install-xen - build and install the Xen hypervisor' @echo ' install-tools - build and install the control tools' @echo ' install-kernels - build and install guest kernels' @echo ' install-docs - build and install documentation' @echo '' @echo 'Building targets:' @echo ' dist - build and install everything into local dist directory' @echo ' world - clean everything, delete guest kernel build' @echo ' trees then make dist' @echo ' xen - build and install Xen hypervisor' @echo ' tools - build and install tools' @echo ' kernels - build and install guest kernels' @echo ' kbuild - synonym for make kernels' @echo ' docs - build and install docs' @echo '' @echo 'Cleaning targets:' @echo ' clean - clean the Xen, tools and docs (but not' @echo ' guest kernel) trees' @echo ' mrproper - clean plus delete kernel tarballs and kernel' @echo ' build trees' @echo ' kdelete - delete guest kernel build trees' @echo ' kclean - clean guest kernel build trees' @echo '' @echo 'Dependency installation targets:' @echo ' install-twisted - install the Twisted Matrix Framework' @echo ' install-logging - install the Python Logging package' @echo ' install-iptables - install iptables tools' @echo '' @echo 'Miscellaneous targets:' @echo ' mkpatches - make patches against vanilla kernels from' @echo ' sparse trees' @echo ' uninstall - attempt to remove installed Xen tools (use' @echo ' with extreme care!)' # Use this target with extreme care! uninstall: DESTDIR= uninstall: D=$(DESTDIR) uninstall: [ -d $(D)/etc/xen ] && mv -f $(D)/etc/xen $(D)/etc/xen.old-$(date +%s) rm -rf $(D)/etc/init.d/xend* rm -rf $(D)/usr/$(LIBDIR)/libxc* $(D)/usr/$(LIBDIR)/libxutil* rm -rf $(D)/usr/lib/python/xen $(D)/usr/include/xen rm -rf $(D)/usr/include/xcs_proto.h $(D)/usr/include/xc.h rm -rf $(D)/usr/sbin/xcs $(D)/usr/sbin/xcsdump $(D)/usr/sbin/xen* rm -rf $(D)/usr/sbin/netfix rm -rf $(D)/usr/sbin/xfrd $(D)/usr/sbin/xm $(D)/var/lib/xen rm -rf $(D)/usr/share/doc/xen $(D)/usr/man/man*/xentrace* rm -rf $(D)/usr/bin/xen* $(D)/usr/bin/miniterm rm -rf $(D)/boot/*xen* rm -rf $(D)/lib/modules/*xen* # Legacy targets for compatibility linux24: $(MAKE) linux-2.4-xen0-build $(MAKE) linux-2.4-xenU-build linux26: $(MAKE) linux-2.6-xen0-build $(MAKE) linux-2.6-xenU-build netbsd20: $(MAKE) netbsd-2.0-xenU-build