serial/serial_arc: Implement debug serial
[platform/kernel/u-boot.git] / drivers / serial / serial_arc.c
index da4a07a..925f0c2 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