Merge tag 'video-for-2019.07' of https://gitlab.denx.de/u-boot/custodians/u-boot...
[oweals/u-boot.git] / drivers / serial / serial_arc.c
index fc91977b4c8aa358aa1c5dbe5b426166202ae260..70dbc6d6b53f50eaaceba28d47e528fa95363fac 100644 (file)
@@ -114,7 +114,7 @@ static int arc_serial_ofdata_to_platdata(struct udevice *dev)
        struct arc_serial_platdata *plat = dev_get_platdata(dev);
        DECLARE_GLOBAL_DATA_PTR;
 
-       plat->reg = (struct arc_serial_regs *)dev_get_addr(dev);
+       plat->reg = (struct arc_serial_regs *)devfdt_get_addr(dev);
        plat->uartclk = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
                                       "clock-frequency", 0);
 
@@ -126,7 +126,33 @@ U_BOOT_DRIVER(serial_arc) = {
        .id     = UCLASS_SERIAL,
        .of_match = arc_serial_ids,
        .ofdata_to_platdata = arc_serial_ofdata_to_platdata,
+       .platdata_auto_alloc_size = sizeof(struct arc_serial_platdata),
        .probe = arc_serial_probe,
        .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