Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/audio/dai.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,9 @@ static struct comp_dev *dai_new(struct sof_ipc_comp *comp)
}

/* request GP LP DMA with shared access privilege */
/* TODO: hda: retrieve req'ed caps from the dai,
* dmas are not cross-compatible.
*/
dir = DMA_DIR_MEM_TO_DEV | DMA_DIR_DEV_TO_MEM;
caps = DMA_CAP_GP_LP | DMA_CAP_GP_HP;
dma_dev = DMA_DEV_SSP | DMA_DEV_DMIC;
Expand Down
2 changes: 1 addition & 1 deletion src/audio/host.c
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ static struct comp_dev *host_new(struct sof_ipc_comp *comp)
dir = DMA_DIR_LMEM_TO_HMEM;

caps = 0;
dma_dev = DMA_DEV_HDA;
dma_dev = DMA_DEV_HOST;
hd->dma = dma_get(dir, caps, dma_dev, DMA_ACCESS_SHARED);
if (hd->dma == NULL) {
trace_host_error("eDM");
Expand Down
40 changes: 40 additions & 0 deletions src/include/sof/bit.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright (c) 2018, Intel Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the Intel Corporation nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
*/

#ifndef __INCLUDE_BIT__
#define __INCLUDE_BIT__

#define BIT(b) (1 << (b))
#define MASK(b_hi, b_lo) ((1 << ((b_hi) - (b_lo) + 1)) - 1)
#define SET_BIT(b, x) (((x) & 1) << (b))
#define SET_BITS(b_hi, b_lo, x) \
(((x) & ((1 << ((b_hi) - (b_lo) + 1)) - 1)) << (b_lo))

#endif
30 changes: 17 additions & 13 deletions src/include/sof/dma.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#include <sof/lock.h>
#include <sof/sof.h>
#include <sof/wait.h>
#include <sof/bit.h>
#include <arch/atomic.h>

/** \addtogroup sof_dma_drivers DMA Drivers
Expand All @@ -52,29 +53,32 @@
*/

/* 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 */
#define DMA_DIR_MEM_TO_MEM BIT(0) /**< local memory copy */
#define DMA_DIR_HMEM_TO_LMEM BIT(1) /**< host memory to local mem copy */
#define DMA_DIR_LMEM_TO_HMEM BIT(2) /**< local mem to host mem copy */
#define DMA_DIR_MEM_TO_DEV BIT(3) /**< local mem to dev copy */
#define DMA_DIR_DEV_TO_MEM BIT(4) /**< dev to local mem copy */
#define DMA_DIR_DEV_TO_DEV BIT(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)
#define DMA_CAP_HDA BIT(0) /**< HDA DMA */
#define DMA_CAP_GP_LP BIT(1) /**< GP LP DMA */
#define DMA_CAP_GP_HP BIT(2) /**< GP HP DMA */

/* 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)

#define DMA_DEV_HOST BIT(0) /**< connectable to host */
#define DMA_DEV_HDA BIT(1) /**< connectable to HD/A link */
#define DMA_DEV_SSP BIT(2) /**< connectable to SSP fifo */
#define DMA_DEV_DMIC BIT(3) /**< connectable to DMIC fifo */

/* DMA access privilege flag */
#define DMA_ACCESS_EXCLUSIVE 1
#define DMA_ACCESS_SHARED 0

/* DMA IRQ types */
#define DMA_IRQ_TYPE_BLOCK (1 << 0)
#define DMA_IRQ_TYPE_LLIST (1 << 1)
#define DMA_IRQ_TYPE_BLOCK BIT(0)
#define DMA_IRQ_TYPE_LLIST BIT(1)


/* We will use this macro in cb handler to inform dma that
Expand Down
8 changes: 1 addition & 7 deletions src/include/sof/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,7 @@
#define __INCLUDE_IO__

#include <stdint.h>

/* Macros for register bits access */
#define BIT(b) (1 << (b))
#define MASK(b_hi, b_lo) ((1 << ((b_hi) - (b_lo) + 1)) - 1)
#define SET_BIT(b, x) (((x) & 1) << (b))
#define SET_BITS(b_hi, b_lo, x) \
(((x) & ((1 << ((b_hi) - (b_lo) + 1)) - 1)) << (b_lo))
#include <sof/bit.h>

static inline uint32_t io_reg_read(uint32_t reg)
{
Expand Down
4 changes: 2 additions & 2 deletions src/ipc/apl-ipc.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,10 @@ int platform_ipc_init(struct ipc *ipc)
if (iipc->page_table)
bzero(iipc->page_table, HOST_PAGE_SIZE);

/* request GP DMA with shared access privilege */
/* request HDA DMA with shared access privilege */
caps = 0;
dir = DMA_DIR_HMEM_TO_LMEM;
dev = DMA_DEV_HDA;
dev = DMA_DEV_HOST;
iipc->dmac = dma_get(dir, caps, dev, DMA_ACCESS_SHARED);

/* PM */
Expand Down
2 changes: 1 addition & 1 deletion src/ipc/byt-ipc.c
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ int platform_ipc_init(struct ipc *ipc)
/* request HDA DMA with shared access privilege */
caps = 0;
dir = DMA_DIR_HMEM_TO_LMEM;
dev = DMA_DEV_HDA;
dev = DMA_DEV_HOST;
iipc->dmac = dma_get(dir, caps, dev, DMA_ACCESS_SHARED);

/* PM */
Expand Down
4 changes: 2 additions & 2 deletions src/ipc/cnl-ipc.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,10 @@ int platform_ipc_init(struct ipc *ipc)
if (iipc->page_table)
bzero(iipc->page_table, HOST_PAGE_SIZE);

/* request GP DMA with shared access privilege */
/* request HDA DMA with shared access privilege */
caps = 0;
dir = DMA_DIR_HMEM_TO_LMEM;
dev = DMA_DEV_HDA;
dev = DMA_DEV_HOST;
iipc->dmac = dma_get(dir, caps, dev, DMA_ACCESS_SHARED);

/* PM */
Expand Down
2 changes: 1 addition & 1 deletion src/ipc/dma-copy.c
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ int dma_copy_new(struct dma_copy *dc)

/* request HDA DMA in the dir LMEM->HMEM with shared access */
dir = DMA_DIR_LMEM_TO_HMEM;
dev = DMA_DEV_HDA;
dev = DMA_DEV_HOST;
cap = 0;
dc->dmac = dma_get(dir, cap, dev, DMA_ACCESS_SHARED);
if (dc->dmac == NULL) {
Expand Down
2 changes: 1 addition & 1 deletion src/ipc/hsw-ipc.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ int platform_ipc_init(struct ipc *ipc)
/* request GP DMA with shared access privilege */
caps = 0;
dir = DMA_DIR_HMEM_TO_LMEM;
dev = DMA_DEV_HDA;
dev = DMA_DEV_HOST;
iipc->dmac = dma_get(dir, caps, dev, DMA_ACCESS_SHARED);

/* PM */
Expand Down
16 changes: 8 additions & 8 deletions src/platform/apollolake/dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ struct dma dma[PLATFORM_NUM_DMACS] = {
.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,
.caps = DMA_CAP_GP_LP,
.devs = DMA_DEV_SSP | DMA_DEV_DMIC,
.base = LP_GP_DMA_BASE(0),
.channels = 8,
Expand All @@ -128,7 +128,7 @@ struct dma dma[PLATFORM_NUM_DMACS] = {
.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,
.caps = DMA_CAP_GP_LP,
.devs = DMA_DEV_SSP | DMA_DEV_DMIC,
.base = LP_GP_DMA_BASE(1),
.channels = 8,
Expand All @@ -141,8 +141,8 @@ struct dma dma[PLATFORM_NUM_DMACS] = {
.plat_data = {
.id = DMA_HOST_IN_DMAC,
.dir = DMA_DIR_LMEM_TO_HMEM,
.caps = 0,
.devs = DMA_DEV_HDA,
.caps = DMA_CAP_HDA,
.devs = DMA_DEV_HOST,
.base = GTW_HOST_IN_STREAM_BASE(0),
.channels = 7,
.irq = IRQ_EXT_HOST_DMA_IN_LVL3(0, 0),
Expand All @@ -154,8 +154,8 @@ struct dma dma[PLATFORM_NUM_DMACS] = {
.plat_data = {
.id = DMA_HOST_OUT_DMAC,
.dir = DMA_DIR_HMEM_TO_LMEM,
.caps = 0,
.devs = DMA_DEV_HDA,
.caps = DMA_CAP_HDA,
.devs = DMA_DEV_HOST,
.base = GTW_HOST_OUT_STREAM_BASE(0),
.channels = 6,
.irq = IRQ_EXT_HOST_DMA_OUT_LVL3(0, 0),
Expand All @@ -167,7 +167,7 @@ struct dma dma[PLATFORM_NUM_DMACS] = {
.plat_data = {
.id = DMA_LINK_IN_DMAC,
.dir = DMA_DIR_MEM_TO_DEV,
.caps = 0,
.caps = DMA_CAP_HDA,
.devs = DMA_DEV_HDA,
.base = GTW_LINK_IN_STREAM_BASE(0),
.channels = 8,
Expand All @@ -180,7 +180,7 @@ struct dma dma[PLATFORM_NUM_DMACS] = {
.plat_data = {
.id = DMA_LINK_OUT_DMAC,
.dir = DMA_DIR_DEV_TO_MEM,
.caps = 0,
.caps = DMA_CAP_HDA,
.devs = DMA_DEV_HDA,
.base = GTW_LINK_OUT_STREAM_BASE(0),
.channels = 8,
Expand Down
6 changes: 3 additions & 3 deletions src/platform/baytrail/dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ struct dma dma[PLATFORM_NUM_DMACS] = {
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,
.devs = DMA_DEV_SSP | DMA_DEV_DMIC | DMA_DEV_HOST,
.base = DMA0_BASE,
.irq = IRQ_NUM_EXT_DMAC0,
.drv_plat_data = &dmac0,
Expand All @@ -165,7 +165,7 @@ struct dma dma[PLATFORM_NUM_DMACS] = {
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,
.devs = DMA_DEV_SSP | DMA_DEV_DMIC | DMA_DEV_HOST,
.base = DMA1_BASE,
.irq = IRQ_NUM_EXT_DMAC1,
.drv_plat_data = &dmac1,
Expand All @@ -180,7 +180,7 @@ struct dma dma[PLATFORM_NUM_DMACS] = {
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,
.devs = DMA_DEV_SSP | DMA_DEV_DMIC | DMA_DEV_HOST,
.base = DMA2_BASE,
.irq = IRQ_NUM_EXT_DMAC2,
.drv_plat_data = &dmac2,
Expand Down
16 changes: 8 additions & 8 deletions src/platform/cannonlake/dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ struct dma dma[PLATFORM_NUM_DMACS] = {
.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,
.caps = DMA_CAP_GP_LP,
.devs = DMA_DEV_SSP | DMA_DEV_DMIC,
.base = LP_GP_DMA_BASE(0),
.channels = 8,
Expand All @@ -129,7 +129,7 @@ struct dma dma[PLATFORM_NUM_DMACS] = {
.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,
.caps = DMA_CAP_GP_LP,
.devs = DMA_DEV_SSP | DMA_DEV_DMIC,
.base = LP_GP_DMA_BASE(1),
.channels = 8,
Expand All @@ -142,8 +142,8 @@ struct dma dma[PLATFORM_NUM_DMACS] = {
.plat_data = {
.id = DMA_HOST_IN_DMAC,
.dir = DMA_DIR_LMEM_TO_HMEM,
.caps = 0,
.devs = DMA_DEV_HDA,
.caps = DMA_CAP_HDA,
.devs = DMA_DEV_HOST,
.base = GTW_HOST_IN_STREAM_BASE(0),
.channels = 7,
.irq = IRQ_EXT_HOST_DMA_IN_LVL3(0, 0),
Expand All @@ -155,8 +155,8 @@ struct dma dma[PLATFORM_NUM_DMACS] = {
.plat_data = {
.id = DMA_HOST_OUT_DMAC,
.dir = DMA_DIR_HMEM_TO_LMEM,
.caps = 0,
.devs = DMA_DEV_HDA,
.caps = DMA_CAP_HDA,
.devs = DMA_DEV_HOST,
.base = GTW_HOST_OUT_STREAM_BASE(0),
.channels = 9,
.irq = IRQ_EXT_HOST_DMA_OUT_LVL3(0, 0),
Expand All @@ -168,7 +168,7 @@ struct dma dma[PLATFORM_NUM_DMACS] = {
.plat_data = {
.id = DMA_LINK_IN_DMAC,
.dir = DMA_DIR_MEM_TO_DEV,
.caps = 0,
.caps = DMA_CAP_HDA,
.devs = DMA_DEV_HDA,
.base = GTW_LINK_IN_STREAM_BASE(0),
.channels = 9,
Expand All @@ -181,7 +181,7 @@ struct dma dma[PLATFORM_NUM_DMACS] = {
.plat_data = {
.id = DMA_LINK_OUT_DMAC,
.dir = DMA_DIR_DEV_TO_MEM,
.caps = 0,
.caps = DMA_CAP_HDA,
.devs = DMA_DEV_HDA,
.base = GTW_LINK_OUT_STREAM_BASE(0),
.channels = 7,
Expand Down
4 changes: 2 additions & 2 deletions src/platform/haswell/dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ struct dma dma[PLATFORM_NUM_DMACS] = {
.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,
.devs = DMA_DEV_SSP | DMA_DEV_DMIC | DMA_DEV_HOST,
.irq = IRQ_NUM_EXT_DMAC0,
.drv_plat_data = &dmac0,
},
Expand All @@ -125,7 +125,7 @@ struct dma dma[PLATFORM_NUM_DMACS] = {
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,
.devs = DMA_DEV_SSP | DMA_DEV_DMIC | DMA_DEV_HOST,
.irq = IRQ_NUM_EXT_DMAC1,
.drv_plat_data = &dmac1,
},
Expand Down