summaryrefslogtreecommitdiff
path: root/drivers/serial/atmel_usart.c
diff options
context:
space:
mode:
authorWenyou Yang <wenyou.yang@atmel.com>2016-10-17 09:49:55 +0800
committerAndreas Bießmann <andreas@biessmann.org>2016-10-28 18:37:15 +0200
commit998cf3c2becb933a87d001c24193911e64dc8b6a (patch)
tree92ac79c427d420545cf731d77f122924092259c6 /drivers/serial/atmel_usart.c
parent6ec739aa525bb238acdd428042a11183ce4be3c4 (diff)
downloadu-boot-998cf3c2becb933a87d001c24193911e64dc8b6a.tar.gz
serial: atmel_usart: Support enable an early debug UART
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>
Diffstat (limited to 'drivers/serial/atmel_usart.c')
-rw-r--r--drivers/serial/atmel_usart.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/drivers/serial/atmel_usart.c b/drivers/serial/atmel_usart.c
index e450135c75..7674f97e8d 100644
--- a/drivers/serial/atmel_usart.c
+++ b/drivers/serial/atmel_usart.c
@@ -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