diff mbox

[U-Boot,v3,11/54] dm: Allow debug UART to support an early console

Message ID 1435095556-15924-12-git-send-email-sjg@chromium.org
State Accepted
Delegated to: Simon Glass
Headers show

Commit Message

Simon Glass June 23, 2015, 9:38 p.m. UTC
When there is no console ready, allow the debug UART to be used for output.
This makes debugging of early code considerably easier.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

Changes in v3: None
Changes in v2: None

 common/console.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

Comments

Simon Glass July 17, 2015, 11:56 p.m. UTC | #1
On 23 June 2015 at 15:38, Simon Glass <sjg@chromium.org> wrote:
> When there is no console ready, allow the debug UART to be used for output.
> This makes debugging of early code considerably easier.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
> Changes in v3: None
> Changes in v2: None
>
>  common/console.c | 19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)

Applied to u-boot-dm.
diff mbox

Patch

diff --git a/common/console.c b/common/console.c
index 0058222..acad8bd 100644
--- a/common/console.c
+++ b/common/console.c
@@ -6,6 +6,7 @@ 
  */
 
 #include <common.h>
+#include <debug_uart.h>
 #include <stdarg.h>
 #include <iomux.h>
 #include <malloc.h>
@@ -460,6 +461,13 @@  void putc(const char c)
 		return;
 	}
 #endif
+#ifdef CONFIG_DEBUG_UART
+	/* if we don't have a console yet, use the debug UART */
+	if (!gd || !(gd->flags & GD_FLG_SERIAL_READY)) {
+		printch(c);
+		return;
+	}
+#endif
 #ifdef CONFIG_SILENT_CONSOLE
 	if (gd->flags & GD_FLG_SILENT)
 		return;
@@ -491,7 +499,18 @@  void puts(const char *s)
 		return;
 	}
 #endif
+#ifdef CONFIG_DEBUG_UART
+	if (!gd || !(gd->flags & GD_FLG_SERIAL_READY)) {
+		while (*s) {
+			int ch = *s++;
 
+			printch(ch);
+			if (ch == '\n')
+				printch('\r');
+		}
+		return;
+	}
+#endif
 #ifdef CONFIG_SILENT_CONSOLE
 	if (gd->flags & GD_FLG_SILENT)
 		return;