[Sound-open-firmware] [PATCH v4 2/5] dma: update platform DMAC definitions with the supported dev types, dir and capabilities

Ranjani Sridharan ranjani.sridharan at linux.intel.com
Tue Jun 12 05:37:12 CEST 2018


This patch updates the platform DMAC definitions to include information
about the supported dev types, copy directions and capabilities.

It also replaces the copy_dir enum with a bitmask and adds
the copy capabilities and dev type bitmasks.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan at linux.intel.com>
---
 src/audio/host.c                              |  1 +
 src/drivers/dw-dma.c                          |  2 +-
 src/drivers/hda-dma.c                         |  2 +-
 src/include/sof/dma.h                         | 30 ++++++++++++-------
 src/platform/apollolake/dma.c                 | 22 +++++++++++++-
 .../apollolake/include/platform/dma.h         |  5 ++++
 src/platform/baytrail/dma.c                   | 17 ++++++++++-
 src/platform/baytrail/include/platform/dma.h  |  9 ++++++
 src/platform/cannonlake/dma.c                 | 22 +++++++++++++-
 .../cannonlake/include/platform/dma.h         |  6 ++++
 src/platform/haswell/dma.c                    | 10 ++++++-
 src/platform/haswell/include/platform/dma.h   |  5 ++++
 12 files changed, 115 insertions(+), 16 deletions(-)

diff --git a/src/audio/host.c b/src/audio/host.c
index c0f4e1b..0285e4a 100644
--- a/src/audio/host.c
+++ b/src/audio/host.c
@@ -537,6 +537,7 @@ static struct comp_dev *host_new(struct sof_ipc_comp *comp)
 	else
 		hd->dma = dma_get(DMA_HOST_IN_DMAC);
 #endif
+
 	if (hd->dma == NULL) {
 		trace_host_error("eDM");
 		goto error;
diff --git a/src/drivers/dw-dma.c b/src/drivers/dw-dma.c
index c064330..70ddb96 100644
--- a/src/drivers/dw-dma.c
+++ b/src/drivers/dw-dma.c
@@ -249,7 +249,7 @@
 /* data for each DMA channel */
 struct dma_chan_data {
 	uint32_t status;
-	enum dma_copy_dir direction;
+	uint32_t direction;
 	struct dw_lli2 *lli;
 	struct dw_lli2 *lli_current;
 	uint32_t desc_count;
diff --git a/src/drivers/hda-dma.c b/src/drivers/hda-dma.c
index 97ea0ef..bef0b17 100644
--- a/src/drivers/hda-dma.c
+++ b/src/drivers/hda-dma.c
@@ -84,7 +84,7 @@ struct hda_chan_data {
 	uint32_t status;
 	uint32_t desc_count;
 	uint32_t desc_avail;
-	enum dma_copy_dir direction;
+	uint32_t direction;
 };
 
 struct dma_pdata {
diff --git a/src/include/sof/dma.h b/src/include/sof/dma.h
index af15d14..fd0024f 100644
--- a/src/include/sof/dma.h
+++ b/src/include/sof/dma.h
@@ -38,15 +38,22 @@
 #include <sof/sof.h>
 #include <sof/wait.h>
 
-/* types of DMA directions */
-enum dma_copy_dir {
-	DMA_DIR_MEM_TO_MEM = 0,	/* local memcpy */
-	DMA_DIR_HMEM_TO_LMEM,	/* host to local memcpy */
-	DMA_DIR_LMEM_TO_HMEM,	/* local to host memcpy */
-	DMA_DIR_MEM_TO_DEV,
-	DMA_DIR_DEV_TO_MEM,
-	DMA_DIR_DEV_TO_DEV,
-};
+/* DMA direction bitmasks used to define DMA copy direction */
+#define DMA_DIR_MEM_TO_MEM	(1 << 0) /* local memory copy */
+#define DMA_DIR_HMEM_TO_LMEM	(1 << 1) /* host memory to local mem copy */
+#define DMA_DIR_LMEM_TO_HMEM	(1 << 2) /* local mem to host mem copy */
+#define DMA_DIR_MEM_TO_DEV	(1 << 3) /* local mem to dev copy */
+#define DMA_DIR_DEV_TO_MEM	(1 << 4) /* dev to local mem copy */
+#define DMA_DIR_DEV_TO_DEV	(1 << 5) /* dev to dev copy */
+
+/* DMA capabilities bitmasks used to define the type of DMA */
+#define DMA_CAP_GP_LP		(1 << 0)
+#define DMA_CAP_GP_HP		(1 << 1)
+
+/* DMA dev type bitmasks used to define the type of DMA */
+#define DMA_DEV_HDA		(1 << 0)
+#define DMA_DEV_SSP		(1 << 1)
+#define DMA_DEV_DMIC		(1 << 2)
 
 /* DMA IRQ types */
 #define DMA_IRQ_TYPE_BLOCK	(1 << 0)
@@ -73,7 +80,7 @@ struct dma_sg_config {
 	uint32_t src_width;	/* in bytes */
 	uint32_t dest_width;	/* in bytes */
 	uint32_t burst_elems;
-	enum dma_copy_dir direction;
+	uint32_t direction;
 	uint32_t src_dev;
 	uint32_t dest_dev;
 	uint32_t cyclic;		/* circular buffer */
@@ -118,6 +125,9 @@ struct dma_ops {
 /* DMA platform data */
 struct dma_plat_data {
 	uint32_t id;
+	uint32_t dir; /* bitmask of supported copy directions */
+	uint32_t caps; /* bitmask of supported capabilities */
+	uint32_t devs; /* bitmask of supported devs */
 	uint32_t base;
 	uint32_t channels;
 	uint32_t irq;
diff --git a/src/platform/apollolake/dma.c b/src/platform/apollolake/dma.c
index 00d19d5..b014259 100644
--- a/src/platform/apollolake/dma.c
+++ b/src/platform/apollolake/dma.c
@@ -108,10 +108,14 @@ static struct dw_drv_plat_data dmac1 = {
 	},
 };
 
-static struct dma dma[] = {
+struct dma dma[PLATFORM_NUM_DMACS] = {
 {	/* Low Power GP DMAC 0 */
 	.plat_data = {
 		.id		= DMA_GP_LP_DMAC0,
+		.dir		= DMA_DIR_MEM_TO_MEM | DMA_DIR_MEM_TO_DEV |
+				  DMA_DIR_DEV_TO_MEM | DMA_DIR_DEV_TO_DEV,
+		.caps		= DMA_CAP_GP_LP | DMA_CAP_GP_HP,
+		.devs		= DMA_DEV_SSP | DMA_DEV_DMIC,
 		.base		= LP_GP_DMA_BASE(0),
 		.channels	= 8,
 		.irq		= IRQ_EXT_LP_GPDMA0_LVL5(0, 0),
@@ -122,6 +126,10 @@ static struct dma dma[] = {
 {	/* Low Power GP DMAC 1 */
 	.plat_data = {
 		.id		= DMA_GP_LP_DMAC1,
+		.dir		= DMA_DIR_MEM_TO_MEM | DMA_DIR_MEM_TO_DEV |
+				  DMA_DIR_DEV_TO_MEM | DMA_DIR_DEV_TO_DEV,
+		.caps		= DMA_CAP_GP_LP | DMA_CAP_GP_HP,
+		.devs		= DMA_DEV_SSP | DMA_DEV_DMIC,
 		.base		= LP_GP_DMA_BASE(1),
 		.channels	= 8,
 		.irq		= IRQ_EXT_LP_GPDMA1_LVL5(0, 0),
@@ -132,6 +140,9 @@ static struct dma dma[] = {
 {	/* Host In DMAC */
 	.plat_data = {
 		.id		= DMA_HOST_IN_DMAC,
+		.dir		= DMA_DIR_LMEM_TO_HMEM,
+		.caps		= 0,
+		.devs		= DMA_DEV_HDA,
 		.base		= GTW_HOST_IN_STREAM_BASE(0),
 		.channels	= 7,
 		.irq		= IRQ_EXT_HOST_DMA_IN_LVL3(0, 0),
@@ -142,6 +153,9 @@ static struct dma dma[] = {
 {	/* Host out DMAC */
 	.plat_data = {
 		.id		= DMA_HOST_OUT_DMAC,
+		.dir		= DMA_DIR_HMEM_TO_LMEM,
+		.caps		= 0,
+		.devs		= DMA_DEV_HDA,
 		.base		= GTW_HOST_OUT_STREAM_BASE(0),
 		.channels	= 6,
 		.irq		= IRQ_EXT_HOST_DMA_OUT_LVL3(0, 0),
@@ -152,6 +166,9 @@ static struct dma dma[] = {
 {	/* Link In DMAC */
 	.plat_data = {
 		.id		= DMA_LINK_IN_DMAC,
+		.dir		= DMA_DIR_MEM_TO_DEV,
+		.caps		= 0,
+		.devs		= DMA_DEV_HDA,
 		.base		= GTW_LINK_IN_STREAM_BASE(0),
 		.channels	= 8,
 		.irq		= IRQ_EXT_LINK_DMA_IN_LVL4(0, 0),
@@ -162,6 +179,9 @@ static struct dma dma[] = {
 {	/* Link out DMAC */
 	.plat_data = {
 		.id		= DMA_LINK_OUT_DMAC,
+		.dir		= DMA_DIR_DEV_TO_MEM,
+		.caps		= 0,
+		.devs		= DMA_DEV_HDA,
 		.base		= GTW_LINK_OUT_STREAM_BASE(0),
 		.channels	= 8,
 		.irq		= IRQ_EXT_LINK_DMA_OUT_LVL4(0, 0),
diff --git a/src/platform/apollolake/include/platform/dma.h b/src/platform/apollolake/include/platform/dma.h
index 916a455..7243c03 100644
--- a/src/platform/apollolake/include/platform/dma.h
+++ b/src/platform/apollolake/include/platform/dma.h
@@ -35,6 +35,9 @@
 #include <stdint.h>
 #include <sof/io.h>
 #include <arch/cache.h>
+#include <sof/dma.h>
+
+#define PLATFORM_NUM_DMACS	6
 
 /* available DMACs */
 #define DMA_GP_LP_DMAC0		0
@@ -72,4 +75,6 @@
 #define DMA_HANDSHAKE_SSP5_TX	12
 #define DMA_HANDSHAKE_SSP5_RX	13
 
+extern struct dma dma[PLATFORM_NUM_DMACS];
+
 #endif
diff --git a/src/platform/baytrail/dma.c b/src/platform/baytrail/dma.c
index 78fbf14..f82cc55 100644
--- a/src/platform/baytrail/dma.c
+++ b/src/platform/baytrail/dma.c
@@ -143,10 +143,15 @@ static struct dw_drv_plat_data dmac2 = {
 };
 #endif
 
-static struct dma dma[] = {
+struct dma dma[PLATFORM_NUM_DMACS] = {
 {
 	.plat_data = {
 		.id		= DMA_ID_DMAC0,
+		.dir		= DMA_DIR_MEM_TO_MEM | DMA_DIR_MEM_TO_DEV |
+				  DMA_DIR_DEV_TO_MEM | DMA_DIR_DEV_TO_DEV |
+				  DMA_DIR_HMEM_TO_LMEM | DMA_DIR_LMEM_TO_HMEM,
+		.caps		= DMA_CAP_GP_HP,
+		.devs		= DMA_DEV_SSP | DMA_DEV_DMIC | DMA_DEV_HDA,
 		.base		= DMA0_BASE,
 		.irq		= IRQ_NUM_EXT_DMAC0,
 		.drv_plat_data	= &dmac0,
@@ -156,6 +161,11 @@ static struct dma dma[] = {
 {
 	.plat_data = {
 		.id		= DMA_ID_DMAC1,
+		.dir		= DMA_DIR_MEM_TO_MEM | DMA_DIR_MEM_TO_DEV |
+				  DMA_DIR_DEV_TO_MEM | DMA_DIR_DEV_TO_DEV |
+				  DMA_DIR_HMEM_TO_LMEM | DMA_DIR_LMEM_TO_HMEM,
+		.caps		= DMA_CAP_GP_HP,
+		.devs		= DMA_DEV_SSP | DMA_DEV_DMIC | DMA_DEV_HDA,
 		.base		= DMA1_BASE,
 		.irq		= IRQ_NUM_EXT_DMAC1,
 		.drv_plat_data	= &dmac1,
@@ -166,6 +176,11 @@ static struct dma dma[] = {
 {
 	.plat_data = {
 		.id		= DMA_ID_DMAC2,
+		.dir		= DMA_DIR_MEM_TO_MEM | DMA_DIR_MEM_TO_DEV |
+				  DMA_DIR_DEV_TO_MEM | DMA_DIR_DEV_TO_DEV |
+				  DMA_DIR_HMEM_TO_LMEM | DMA_DIR_LMEM_TO_HMEM,
+		.caps		= DMA_CAP_GP_HP,
+		.devs		= DMA_DEV_SSP | DMA_DEV_DMIC | DMA_DEV_HDA,
 		.base		= DMA2_BASE,
 		.irq		= IRQ_NUM_EXT_DMAC2,
 		.drv_plat_data	= &dmac2,
diff --git a/src/platform/baytrail/include/platform/dma.h b/src/platform/baytrail/include/platform/dma.h
index eec501a..5084dad 100644
--- a/src/platform/baytrail/include/platform/dma.h
+++ b/src/platform/baytrail/include/platform/dma.h
@@ -33,6 +33,13 @@
 #define __PLATFORM_DMA_H__
 
 #include <stdint.h>
+#include <sof/dma.h>
+
+#if defined CONFIG_CHERRYTRAIL
+#define PLATFORM_NUM_DMACS	3
+#else
+#define PLATFORM_NUM_DMACS	2
+#endif
 
 #define DMA_ID_DMAC0	0
 #define DMA_ID_DMAC1	1
@@ -53,4 +60,6 @@
 #define DMA_HANDSHAKE_SSP6_RX	12
 #define DMA_HANDSHAKE_SSP6_TX	13
 
+extern struct dma dma[PLATFORM_NUM_DMACS];
+
 #endif
diff --git a/src/platform/cannonlake/dma.c b/src/platform/cannonlake/dma.c
index c560b86..e46ff07 100644
--- a/src/platform/cannonlake/dma.c
+++ b/src/platform/cannonlake/dma.c
@@ -109,10 +109,14 @@ static struct dw_drv_plat_data dmac1 = {
 	},
 };
 
-static struct dma dma[] = {
+struct dma dma[PLATFORM_NUM_DMACS] = {
 {	/* Low Power GP DMAC 0 */
 	.plat_data = {
 		.id		= DMA_GP_LP_DMAC0,
+		.dir		= DMA_DIR_MEM_TO_MEM | DMA_DIR_MEM_TO_DEV |
+				  DMA_DIR_DEV_TO_MEM | DMA_DIR_DEV_TO_DEV,
+		.caps		= DMA_CAP_GP_LP | DMA_CAP_GP_HP,
+		.devs		= DMA_DEV_SSP | DMA_DEV_DMIC,
 		.base		= LP_GP_DMA_BASE(0),
 		.channels	= 8,
 		.irq = IRQ_EXT_LP_GPDMA0_LVL5(0, 0),
@@ -123,6 +127,10 @@ static struct dma dma[] = {
 {	/* Low Power GP DMAC 1 */
 	.plat_data = {
 		.id		= DMA_GP_LP_DMAC1,
+		.dir		= DMA_DIR_MEM_TO_MEM | DMA_DIR_MEM_TO_DEV |
+				  DMA_DIR_DEV_TO_MEM | DMA_DIR_DEV_TO_DEV,
+		.caps		= DMA_CAP_GP_LP | DMA_CAP_GP_HP,
+		.devs		= DMA_DEV_SSP | DMA_DEV_DMIC,
 		.base		= LP_GP_DMA_BASE(1),
 		.channels	= 8,
 		.irq = IRQ_EXT_LP_GPDMA1_LVL5(0, 0),
@@ -133,6 +141,9 @@ static struct dma dma[] = {
 {	/* Host In DMAC */
 	.plat_data = {
 		.id		= DMA_HOST_IN_DMAC,
+		.dir		= DMA_DIR_LMEM_TO_HMEM,
+		.caps		= 0,
+		.devs		= DMA_DEV_HDA,
 		.base		= GTW_HOST_IN_STREAM_BASE(0),
 		.channels	= 7,
 		.irq = IRQ_EXT_HOST_DMA_IN_LVL3(0, 0),
@@ -143,6 +154,9 @@ static struct dma dma[] = {
 {	/* Host out DMAC */
 	.plat_data = {
 		.id		= DMA_HOST_OUT_DMAC,
+		.dir		= DMA_DIR_HMEM_TO_LMEM,
+		.caps		= 0,
+		.devs		= DMA_DEV_HDA,
 		.base		= GTW_HOST_OUT_STREAM_BASE(0),
 		.channels	= 9,
 		.irq = IRQ_EXT_HOST_DMA_OUT_LVL3(0, 0),
@@ -153,6 +167,9 @@ static struct dma dma[] = {
 {	/* Link In DMAC */
 	.plat_data = {
 		.id		= DMA_LINK_IN_DMAC,
+		.dir		= DMA_DIR_MEM_TO_DEV,
+		.caps		= 0,
+		.devs		= DMA_DEV_HDA,
 		.base		= GTW_LINK_IN_STREAM_BASE(0),
 		.channels	= 9,
 		.irq = IRQ_EXT_LINK_DMA_IN_LVL4(0, 0),
@@ -163,6 +180,9 @@ static struct dma dma[] = {
 {	/* Link out DMAC */
 	.plat_data = {
 		.id		= DMA_LINK_OUT_DMAC,
+		.dir		= DMA_DIR_DEV_TO_MEM,
+		.caps		= 0,
+		.devs		= DMA_DEV_HDA,
 		.base		= GTW_LINK_OUT_STREAM_BASE(0),
 		.channels	= 7,
 		.irq = IRQ_EXT_LINK_DMA_OUT_LVL4(0, 0),
diff --git a/src/platform/cannonlake/include/platform/dma.h b/src/platform/cannonlake/include/platform/dma.h
index 00dcda8..b6366a0 100644
--- a/src/platform/cannonlake/include/platform/dma.h
+++ b/src/platform/cannonlake/include/platform/dma.h
@@ -33,6 +33,10 @@
 #ifndef __PLATFORM_DMA_H__
 #define __PLATFORM_DMA_H__
 
+#include <sof/dma.h>
+
+#define PLATFORM_NUM_DMACS	6
+
 /* available DMACs */
 #define DMA_GP_LP_DMAC0		0
 #define DMA_GP_LP_DMAC1		1
@@ -69,4 +73,6 @@
 #define DMA_HANDSHAKE_SSP5_TX	12
 #define DMA_HANDSHAKE_SSP5_RX	13
 
+extern struct dma dma[PLATFORM_NUM_DMACS];
+
 #endif
diff --git a/src/platform/haswell/dma.c b/src/platform/haswell/dma.c
index 0ae935d..90c834c 100644
--- a/src/platform/haswell/dma.c
+++ b/src/platform/haswell/dma.c
@@ -106,10 +106,13 @@ static struct dw_drv_plat_data dmac1 = {
 	},
 };
 
-static struct dma dma[] = {
+struct dma dma[PLATFORM_NUM_DMACS] = {
 {
 	.plat_data = {
 		.base		= DMA0_BASE,
+		.dir		= DMA_DIR_MEM_TO_MEM,
+		.caps		= DMA_CAP_GP_HP | DMA_CAP_GP_LP,
+		.devs		= DMA_DEV_SSP | DMA_DEV_DMIC | DMA_DEV_HDA,
 		.irq		= IRQ_NUM_EXT_DMAC0,
 		.drv_plat_data	= &dmac0,
 	},
@@ -118,6 +121,11 @@ static struct dma dma[] = {
 {
 	.plat_data = {
 		.base		= DMA1_BASE,
+		.dir		= DMA_DIR_MEM_TO_MEM | DMA_DIR_MEM_TO_DEV |
+				  DMA_DIR_DEV_TO_MEM | DMA_DIR_DEV_TO_DEV |
+				  DMA_DIR_HMEM_TO_LMEM | DMA_DIR_LMEM_TO_HMEM,
+		.caps		= DMA_CAP_GP_HP | DMA_CAP_GP_LP,
+		.devs		= DMA_DEV_SSP | DMA_DEV_DMIC | DMA_DEV_HDA,
 		.irq		= IRQ_NUM_EXT_DMAC1,
 		.drv_plat_data	= &dmac1,
 	},
diff --git a/src/platform/haswell/include/platform/dma.h b/src/platform/haswell/include/platform/dma.h
index 4780f92..c926672 100644
--- a/src/platform/haswell/include/platform/dma.h
+++ b/src/platform/haswell/include/platform/dma.h
@@ -32,6 +32,9 @@
 #define __PLATFORM_DMA_H__
 
 #include <stdint.h>
+#include <sof/dma.h>
+
+#define PLATFORM_NUM_DMACS	2
 
 #define DMA_ID_DMAC0			0
 #define DMA_ID_DMAC1			1
@@ -53,4 +56,6 @@
 #define DMA_HANDSHAKE_OBFF_10		14
 #define DMA_HANDSHAKE_OBFF_11		15
 
+extern struct dma dma[PLATFORM_NUM_DMACS];
+
 #endif
-- 
2.17.1



More information about the Sound-open-firmware mailing list