diff mbox

[U-Boot,2/2] ARM: tegra: Implement early console support

Message ID 1426851034-29393-2-git-send-email-thierry.reding@gmail.com
State Deferred
Delegated to: Tom Rini
Headers show

Commit Message

Thierry Reding March 20, 2015, 11:30 a.m. UTC
From: Thierry Reding <treding@nvidia.com>

Use the physical address of the debug serial port from the configuration
to provide an early_putc() implementation that can be used with the new
early console support.

Cc: Tom Warren <twarren@nvidia.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 board/nvidia/common/board.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
diff mbox

Patch

diff --git a/board/nvidia/common/board.c b/board/nvidia/common/board.c
index c3d77893ded3..d945de456ea2 100644
--- a/board/nvidia/common/board.c
+++ b/board/nvidia/common/board.c
@@ -155,6 +155,28 @@  int board_init(void)
 	return 0;
 }
 
+#ifdef CONFIG_EARLY_CONSOLE
+#define UART_THR 0x00
+#define UART_LSR 0x14
+
+void early_putc(char ch)
+{
+	uint32_t mask = UART_LSR_TEMT | UART_LSR_THRE, value;
+	unsigned long base = CONFIG_SYS_NS16550_COM1;
+
+	if (ch == '\n')
+		early_putc('\r');
+
+	writel(ch, base + UART_THR);
+
+	while (true) {
+		value = readl(base + UART_LSR);
+		if ((value & mask) == mask)
+			break;
+	}
+}
+#endif
+
 #ifdef CONFIG_BOARD_EARLY_INIT_F
 static void __gpio_early_init(void)
 {