]> git.ipfire.org Git - people/ms/u-boot.git/blobdiff - drivers/serial/serial_mxc.c
serial: mxc: Add debug uart support
[people/ms/u-boot.git] / drivers / serial / serial_mxc.c
index c8c36e5e19cf5167bc6d652768cc1b0fb9354302..cce80a8559e2527f15502cd9e4e07fbb0557403e 100644 (file)
@@ -357,3 +357,29 @@ U_BOOT_DRIVER(serial_mxc) = {
        .flags = DM_FLAG_PRE_RELOC,
 };
 #endif
        .flags = DM_FLAG_PRE_RELOC,
 };
 #endif
+
+#ifdef CONFIG_DEBUG_UART_MXC
+#include <debug_uart.h>
+
+static inline void _debug_uart_init(void)
+{
+       struct mxc_uart *base = (struct mxc_uart *)CONFIG_DEBUG_UART_BASE;
+
+       _mxc_serial_init(base);
+       _mxc_serial_setbrg(base, CONFIG_DEBUG_UART_CLOCK,
+                          CONFIG_BAUDRATE, false);
+}
+
+static inline void _debug_uart_putc(int ch)
+{
+       struct mxc_uart *base = (struct mxc_uart *)CONFIG_DEBUG_UART_BASE;
+
+       while (!(readl(&base->ts) & UTS_TXEMPTY))
+               WATCHDOG_RESET();
+
+       writel(ch, &base->txd);
+}
+
+DEBUG_UART_FUNCS
+
+#endif