X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=drivers%2Fserial%2Fserial_arc.c;h=04063fbe39976001ff02edd134bea74a779bb989;hb=4e05c167a756cbfb0a51ef09e52c8b5c7c4d6514;hp=6292eb136b0d86590d7508d6b26260afe41bfbca;hpb=4d339a9e8a758889de5da16b562aff5601bb3d8d;p=platform%2Fkernel%2Fu-boot.git diff --git a/drivers/serial/serial_arc.c b/drivers/serial/serial_arc.c index 6292eb1..04063fb 100644 --- a/drivers/serial/serial_arc.c +++ b/drivers/serial/serial_arc.c @@ -42,23 +42,7 @@ static int arc_serial_setbrg(struct udevice *dev, int baudrate) int arc_console_baud = gd->cpu_clk / (baudrate * 4) - 1; writeb(arc_console_baud & 0xff, ®s->baudl); - -#ifdef CONFIG_ARC - /* - * UART ISS(Instruction Set simulator) emulation has a subtle bug: - * A existing value of Baudh = 0 is used as a indication to startup - * it's internal state machine. - * Thus if baudh is set to 0, 2 times, it chokes. - * This happens with BAUD=115200 and the formaula above - * Until that is fixed, when running on ISS, we will set baudh to !0 - */ - if (gd->arch.running_on_hw) - writeb((arc_console_baud & 0xff00) >> 8, ®s->baudh); - else - writeb(1, ®s->baudh); -#else writeb((arc_console_baud & 0xff00) >> 8, ®s->baudh); -#endif return 0; } @@ -130,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 = dev_read_addr_ptr(dev); + plat->uartclk = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "clock-frequency", 0); return 0; @@ -142,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