summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2013-09-06 15:56:48 -0700
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2013-12-05 16:59:15 +0000
commitc7837fc4526992f2c976dc8ec74285a3cbf6f228 (patch)
tree93078dd7b6e0fb8ce4c7281e483954ffbc6a4b76
parentaa8c8578070127acaffdcd299f64107619f7b7e1 (diff)
downloadchrome-ec-c7837fc4526992f2c976dc8ec74285a3cbf6f228.tar.gz
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 <rspangler@chromium.org> Previous-Reviewed-on: https://chromium-review.googlesource.com/168810 (cherry picked from commit e6401d2e83939a63cbd156fa193f9768063d9325) Reviewed-on: https://chromium-review.googlesource.com/178823 Reviewed-by: Doug Anderson <dianders@chromium.org> Tested-by: Doug Anderson <dianders@chromium.org> Commit-Queue: Doug Anderson <dianders@chromium.org>
-rw-r--r--chip/stm32/config_chip.h3
-rw-r--r--chip/stm32/dma.c3
-rw-r--r--common/main.c6
-rw-r--r--include/config.h3
-rw-r--r--include/dma.h10
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 9a5a75f1cd..d326c2504a 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"
@@ -83,6 +84,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 7c66cbf4c0..77f3b15f7e 100644
--- a/include/config.h
+++ b/include/config.h
@@ -237,6 +237,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