From e6401d2e83939a63cbd156fa193f9768063d9325 Mon Sep 17 00:00:00 2001 From: Randall Spangler Date: Fri, 6 Sep 2013 15:56:48 -0700 Subject: Initalize DMA before UART This is in preparation for enabling DMA-based UART transfers, to improve UART performance on STM32. BUG=chrome-os-partner:20485 BRANCH=none TEST=Boot pit. Host commands should still be received; this verifies DMA is still operational. Change-Id: Ibc3b2e2cd187547eb61b85e4a086704accd7f2fb Signed-off-by: Randall Spangler Reviewed-on: https://chromium-review.googlesource.com/168810 --- chip/stm32/config_chip.h | 3 +++ chip/stm32/dma.c | 3 +-- common/main.c | 6 ++++++ include/config.h | 3 +++ include/dma.h | 10 +++++++++- 5 files changed, 22 insertions(+), 3 deletions(-) diff --git a/chip/stm32/config_chip.h b/chip/stm32/config_chip.h index 40de499fd5..fa839287e0 100644 --- a/chip/stm32/config_chip.h +++ b/chip/stm32/config_chip.h @@ -47,6 +47,9 @@ */ #define CONFIG_WATCHDOG_HELP +/* Use DMA */ +#define CONFIG_DMA + /* Flash protection applies to the next boot, not the current one */ #define CONFIG_FLASH_PROTECT_NEXT_BOOT diff --git a/chip/stm32/dma.c b/chip/stm32/dma.c index c4eb08d4ec..06da15e1b6 100644 --- a/chip/stm32/dma.c +++ b/chip/stm32/dma.c @@ -182,7 +182,7 @@ void dma_test(void) } #endif /* CONFIG_DMA_HELP */ -static void dma_init(void) +void dma_init(void) { int i; @@ -193,7 +193,6 @@ static void dma_init(void) for (i = 0; i < STM32_DMAC_COUNT; i++) id[i] = TASK_ID_INVALID; } -DECLARE_HOOK(HOOK_INIT, dma_init, HOOK_PRIO_INIT_DMA); int dma_wait(enum dma_channel channel) { diff --git a/common/main.c b/common/main.c index ec4bc2b48c..12d9f9ec5b 100644 --- a/common/main.c +++ b/common/main.c @@ -10,6 +10,7 @@ #include "common.h" #include "console.h" #include "cpu.h" +#include "dma.h" #include "eeprom.h" #include "eoption.h" #include "flash.h" @@ -90,6 +91,11 @@ test_mockable int main(void) /* Main initialization stage. Modules may enable interrupts here. */ cpu_init(); +#ifdef CONFIG_DMA + /* Initialize DMA. Must be before UART. */ + dma_init(); +#endif + /* Initialize UART. Console output functions may now be used. */ uart_init(); diff --git a/include/config.h b/include/config.h index d46ae943f2..8b5e2a9214 100644 --- a/include/config.h +++ b/include/config.h @@ -280,6 +280,9 @@ /*****************************************************************************/ +/* Compile support for the DMA module */ +#undef CONFIG_DMA + /* Compile extra debugging and tests for the DMA module */ #undef CONFIG_DMA_HELP diff --git a/include/dma.h b/include/dma.h index 1b03795b36..04c1be2bf9 100644 --- a/include/dma.h +++ b/include/dma.h @@ -2,12 +2,14 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. * - * Register map and API for STM32 processor dma registers + * DMA interface */ #ifndef __CROS_EC_DMA_H #define __CROS_EC_DMA_H +#ifdef CONFIG_DMA + #include "common.h" #include "registers.h" @@ -134,4 +136,10 @@ void dma_disable_tc_interrupt(enum dma_channel channel); */ int dma_wait(enum dma_channel channel); +/** + * Initialize the DMA module. + */ +void dma_init(void); + +#endif /* CONFIG_DMA */ #endif -- cgit v1.2.1