serial: atmel_usart: Support enable an early debug UART
authorWenyou Yang <wenyou.yang@atmel.com>
Mon, 17 Oct 2016 01:49:55 +0000 (09:49 +0800)
committerAndreas Bießmann <andreas@biessmann.org>
Fri, 28 Oct 2016 16:37:15 +0000 (18:37 +0200)
Add support to enable an early debug UART for debugging.

Signed-off-by: Wenyou Yang <wenyou.yang@atmel.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Andreas Bießmann <andreas@biessmann.org>
drivers/serial/Kconfig
drivers/serial/atmel_usart.c

index 9e48902446105dee95aebf4332d38d8ee0cda1c9..507a27da03911effdf56ea29d0c81dc6348a1f8f 100644 (file)
@@ -98,6 +98,13 @@ config DEBUG_UART_AR933X
          driver will be available until the real driver model serial is
          running.
 
+config DEBUG_UART_ATMEL
+       bool "Atmel USART"
+       help
+         Select this to enable a debug UART using the atmel usart driver. You
+         will need to provide parameters to make this work. The driver will
+         be available until the real driver-model serial is running.
+
 config DEBUG_UART_NS16550
        bool "ns16550"
        help
index e450135c75745e7231fd83bf5f35bd4d98bb7591..7674f97e8dde04dbf5bf4112874cdb91847d7e4d 100644 (file)
@@ -11,6 +11,7 @@
 #include <errno.h>
 #include <watchdog.h>
 #include <serial.h>
+#include <debug_uart.h>
 #include <linux/compiler.h>
 
 #include <asm/io.h>
@@ -226,3 +227,24 @@ U_BOOT_DRIVER(serial_atmel) = {
        .priv_auto_alloc_size   = sizeof(struct atmel_serial_priv),
 };
 #endif
+
+#ifdef CONFIG_DEBUG_UART_ATMEL
+static inline void _debug_uart_init(void)
+{
+       atmel_usart3_t *usart = (atmel_usart3_t *)CONFIG_DEBUG_UART_BASE;
+
+       atmel_serial_setbrg_internal(usart, 0, CONFIG_BAUDRATE);
+}
+
+static inline void _debug_uart_putc(int ch)
+{
+       atmel_usart3_t *usart = (atmel_usart3_t *)CONFIG_DEBUG_UART_BASE;
+
+       while (!(readl(&usart->csr) & USART3_BIT(TXRDY)))
+               ;
+
+       writel(ch, &usart->thr);
+}
+
+DEBUG_UART_FUNCS
+#endif