X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=drivers%2Fserial%2Fserial_arc.c;h=70dbc6d6b53f50eaaceba28d47e528fa95363fac;hb=29e9363504d6e2aef0bd11a08de59cf635e285bc;hp=326a536a26ad47801b40eee9b44a7f04ce084641;hpb=814013253fd4cf932d0fb32f7043f09a2a748d9a;p=oweals%2Fu-boot.git diff --git a/drivers/serial/serial_arc.c b/drivers/serial/serial_arc.c index 326a536a26..70dbc6d6b5 100644 --- a/drivers/serial/serial_arc.c +++ b/drivers/serial/serial_arc.c @@ -114,8 +114,8 @@ 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->uartclk = fdtdec_get_int(gd->fdt_blob, dev->of_offset, + 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); return 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 + +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, ®s->baudl); + writeb((arc_console_baud & 0xff00) >> 8, ®s->baudh); +} + +static inline void _debug_uart_putc(int c) +{ + struct arc_serial_regs *regs = (struct arc_serial_regs *)CONFIG_DEBUG_UART_BASE; + + while (!(readb(®s->status) & UART_TXEMPTY)) + ; + + writeb(c, ®s->data); +} + +DEBUG_UART_FUNCS + +#endif