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

login
register
mail settings
Submitter Simon Glass
Date March 19, 2012, 8:27 p.m.
Message ID <1332188824-5447-3-git-send-email-sjg@chromium.org>
Download mbox | patch
Permalink /patch/147619/
State New, archived
Headers show

Comments

Simon Glass - March 19, 2012, 8:27 p.m.
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@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(-)
Wolfgang Denk - March 21, 2012, 9:04 a.m.
Dear Simon Glass,

In message <1332188824-5447-3-git-send-email-sjg@chromium.org> you wrote:
> 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.

I dislike this.  This is broken by design.

Even if the could would work today, it would break as soon as we
switch to using a clean device model.

Don't do that, you are opening a can of worms that cannot be closed
easily, and you don't do yourself a favour with it.

Best regards,

Wolfgang Denk

Patch

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);