public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Thierry Reding <thierry.reding@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 2/2] ARM: tegra: Implement early console support
Date: Fri, 20 Mar 2015 12:30:34 +0100	[thread overview]
Message-ID: <1426851034-29393-2-git-send-email-thierry.reding@gmail.com> (raw)
In-Reply-To: <1426851034-29393-1-git-send-email-thierry.reding@gmail.com>

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 --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)
 {
-- 
2.3.2

  reply	other threads:[~2015-03-20 11:30 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-20 11:30 [U-Boot] [PATCH 1/2] console: Support board-specific early console Thierry Reding
2015-03-20 11:30 ` Thierry Reding [this message]
2015-03-20 15:24 ` Tom Rini
2015-03-20 16:55 ` Wolfgang Denk
2015-03-23 23:38   ` Simon Glass

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1426851034-29393-2-git-send-email-thierry.reding@gmail.com \
    --to=thierry.reding@gmail.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox