From 87df4399094a9bc59cb39e77dbb49f263d157bc5 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sun, 20 May 2018 10:34:27 -0600 Subject: [PATCH] arch/arm/src/imxrt: Add eDMA initialization logic. --- arch/arm/src/imxrt/Kconfig | 26 ++++++++++++++++++++++++++ arch/arm/src/imxrt/imxrt_edma.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/arch/arm/src/imxrt/Kconfig b/arch/arm/src/imxrt/Kconfig index 35fa03aa96f..f87cb577698 100644 --- a/arch/arm/src/imxrt/Kconfig +++ b/arch/arm/src/imxrt/Kconfig @@ -73,6 +73,7 @@ menu "LPUART Peripherals" config IMXRT_EDMA bool "eDMA" default n + select ARCH_DMA depends on EXPERIMENTAL config IMXRT_LPUART1 @@ -332,4 +333,29 @@ config IMXRT_SRAM_HEAPOFFSET endmenu # i.MX6 Primary RAM endmenu # Memory Configuration + +menu "eDMA Configuration" + depends on IMXRT_EDMA + +config IMXRT_EDMA_ERCA + bool "Round Robin Channel Arbitration" + default n + +config IMXRT_EDMA_HOE + bool "Halt On Error" + default y + +config IMXRT_EDMA_CLM + bool "Continuous Link Mode" + default n + +config IMXRT_EDMA_EMLIM + bool "Minor Loop Mapping" + default n + +config IMXRT_EDMA_EDBG + bool "Enable Debug" + default n + +endmenu # eDMA Global Configuration endif # ARCH_CHIP_IMXRT diff --git a/arch/arm/src/imxrt/imxrt_edma.c b/arch/arm/src/imxrt/imxrt_edma.c index 8db84067eb5..be960633cd0 100644 --- a/arch/arm/src/imxrt/imxrt_edma.c +++ b/arch/arm/src/imxrt/imxrt_edma.c @@ -355,6 +355,7 @@ static int imxrt_edma_interrupt(int irq, void *context, FAR void *arg) void weak_function up_dmainitialize(void) { + uint32_t regval; int i; dmainfo("Initialize eDMA\n"); @@ -363,6 +364,30 @@ void weak_function up_dmainitialize(void) imxrt_clockrun_dma(); + /* Configure the eDMA controller */ + + regval = getreg32(IMXRT_EDMA_CR); + regval &= ~(EDMA_CR_EDBG | EDMA_CR_ERCA | EDMA_CR_HOE | EDMA_CR_CLM | + EDMA_CR_EMLM); + +#ifdef CONFIG_IMXRT_EDMA_EDBG + regval |= EDMA_CR_EDBG; /* Enable Debug */ +#endif +#ifdef CONFIG_IMXRT_EDMA_ERCA + regval |= EDMA_CR_ERCA; /* Enable Round Robin Channel Arbitration */ +#endif +#ifdef CONFIG_IMXRT_EDMA_HOE + regval |= EDMA_CR_HOE; /* Halt On Error */ +#endif +#ifdef CONFIG_IMXRT_EDMA_CLM + regval |= EDMA_CR_CLM; /* Continuous Link Mode */ +#endif +#ifdef CONFIG_IMXRT_EDMA_EMLIM + regval |= EDMA_CR_EMLM; /* Enable Minor Loop Mapping */ +#endif + + putreg32(regval, IMXRT_EDMA_CR); + /* Initialize data structures */ memset(&g_edma, 0, sizeof()); @@ -560,6 +585,9 @@ int imxrt_dmasetup(DMA_HANDLE handle, uint32_t saddr, uint32_t daddr, size_t nby /* To initialize the eDMA: * * 1. Write to the CR if a configuration other than the default is desired. + * + * We always use the global default setup by up_dmainitialize() + * * 2. Write the channel priority levels to the DCHPRIn registers if a * configuration other than the default is desired. * 3. Enable error interrupts in the EEI register if so desired.