serial/serial_arc: Implement debug serial
authorAlexey Brodkin <abrodkin@synopsys.com>
Mon, 21 May 2018 13:42:07 +0000 (16:42 +0300)
committerAlexey Brodkin <abrodkin@synopsys.com>
Thu, 24 May 2018 12:59:17 +0000 (15:59 +0300)
Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
drivers/serial/Kconfig
drivers/serial/serial_arc.c

index 1aab0320f676527c018be439dbfefedf2bcdce4f..87779098608102e5d7bab8bfe3791fe2e7d21350 100644 (file)
@@ -197,6 +197,15 @@ config DEBUG_UART_AR933X
          driver will be available until the real driver model serial is
          running.
 
+config DEBUG_ARC_SERIAL
+       bool "ARC UART"
+       depends on ARC_SERIAL
+       help
+         Select this to enable a debug UART using the ARC UART 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_ATMEL
        bool "Atmel USART"
        help
index da4a07ab2f668b57da7f9d0b1fbc752af374b4e8..925f0c2555446021ff24fca47f685273e2764acf 100644 (file)
@@ -130,3 +130,29 @@ U_BOOT_DRIVER(serial_arc) = {
        .ops    = &arc_serial_ops,
        .flags = DM_FLAG_PRE_RELOC,
 };
+
+#ifdef CONFIG_DEBUG_ARC_SERIAL
+#include <debug_uart.h>
+
+static inline void _debug_uart_init(void)
+{
+       struct arc_serial_regs *regs = (struct arc_serial_regs *)CONFIG_DEBUG_UART_BASE;
+       int arc_console_baud = CONFIG_DEBUG_UART_CLOCK / (CONFIG_BAUDRATE * 4) - 1;
+
+       writeb(arc_console_baud & 0xff, &regs->baudl);
+       writeb((arc_console_baud & 0xff00) >> 8, &regs->baudh);
+}
+
+static inline void _debug_uart_putc(int c)
+{
+       struct arc_serial_regs *regs = (struct arc_serial_regs *)CONFIG_DEBUG_UART_BASE;
+
+       while (!(readb(&regs->status) & UART_TXEMPTY))
+               ;
+
+       writeb(c, &regs->data);
+}
+
+DEBUG_UART_FUNCS
+
+#endif