[U-Boot] [PATCH 3/5] tegra: Export the UART setup function for use by boards

Simon Glass sjg at chromium.org
Mon Mar 19 21:27:02 CET 2012


Allow boards to call the tegra_setup_uarts() function so that they
can set up UARTs on demand. The UART selection enum is moved into the
board.h header file so that boards can use this for pre-console panic.

Signed-off-by: Simon Glass <sjg at chromium.org>
---
 arch/arm/cpu/armv7/tegra2/board.c        |   26 +++++++-------------------
 arch/arm/include/asm/arch-tegra2/board.h |   17 +++++++++++++++++
 2 files changed, 24 insertions(+), 19 deletions(-)

diff --git a/arch/arm/cpu/armv7/tegra2/board.c b/arch/arm/cpu/armv7/tegra2/board.c
index 77a627d..c9a7520 100644
--- a/arch/arm/cpu/armv7/tegra2/board.c
+++ b/arch/arm/cpu/armv7/tegra2/board.c
@@ -24,6 +24,7 @@
 #include <common.h>
 #include <asm/io.h>
 #include "ap20.h"
+#include <asm/arch/board.h>
 #include <asm/arch/clock.h>
 #include <asm/arch/funcmux.h>
 #include <asm/arch/sys_proto.h>
@@ -32,14 +33,6 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-enum {
-	/* UARTs which we can enable */
-	UARTA	= 1 << 0,
-	UARTB	= 1 << 1,
-	UARTD	= 1 << 3,
-	UART_COUNT = 4,
-};
-
 /*
  * Boot ROM initializes the odmdata in APBDEV_PMC_SCRATCH20_0,
  * so we are using this value to identify memory size.
@@ -101,12 +94,7 @@ int arch_cpu_init(void)
 }
 #endif
 
-/**
- * Set up the specified uarts
- *
- * @param uarts_ids	Mask containing UARTs to init (UARTx)
- */
-static void setup_uarts(int uart_ids)
+void tegra_setup_uarts(int uart_ids)
 {
 	static enum periph_id id_for_uart[] = {
 		PERIPH_ID_UART1,
@@ -116,7 +104,7 @@ static void setup_uarts(int uart_ids)
 	};
 	size_t i;
 
-	for (i = 0; i < UART_COUNT; i++) {
+	for (i = 0; i < TEGRA_UART_COUNT; i++) {
 		if (uart_ids & (1 << i)) {
 			enum periph_id id = id_for_uart[i];
 
@@ -131,15 +119,15 @@ void board_init_uart_f(void)
 	int uart_ids = 0;	/* bit mask of which UART ids to enable */
 
 #ifdef CONFIG_TEGRA2_ENABLE_UARTA
-	uart_ids |= UARTA;
+	uart_ids |= TEGRA_UARTA;
 #endif
 #ifdef CONFIG_TEGRA2_ENABLE_UARTB
-	uart_ids |= UARTB;
+	uart_ids |= TEGRA_UARTB;
 #endif
 #ifdef CONFIG_TEGRA2_ENABLE_UARTD
-	uart_ids |= UARTD;
+	uart_ids |= TEGRA_UARTD;
 #endif
-	setup_uarts(uart_ids);
+	tegra_setup_uarts(uart_ids);
 }
 
 #ifndef CONFIG_SYS_DCACHE_OFF
diff --git a/arch/arm/include/asm/arch-tegra2/board.h b/arch/arm/include/asm/arch-tegra2/board.h
index a90d36c..fb88517 100644
--- a/arch/arm/include/asm/arch-tegra2/board.h
+++ b/arch/arm/include/asm/arch-tegra2/board.h
@@ -24,6 +24,23 @@
 #ifndef _TEGRA_BOARD_H_
 #define _TEGRA_BOARD_H_
 
+enum {
+	/* UARTs which we can enable */
+	TEGRA_UARTA	= 1 << 0,
+	TEGRA_UARTB	= 1 << 1,
+	TEGRA_UARTD	= 1 << 3,
+	TEGRA_UART_ALL	= 0xf,
+
+	TEGRA_UART_COUNT = 4,
+};
+
+/**
+ * Set up the specified UARTs (pinmux and clocks)
+ *
+ * @param uarts_ids	Mask containing UARTs to init (see TEGRA_UARTx)
+ */
+void tegra_setup_uarts(int uart_ids);
+
 /* Setup UARTs for the board according to the selected config */
 void board_init_uart_f(void);
 
-- 
1.7.7.3



More information about the U-Boot mailing list