[U-Boot] [PATCH 18/19] serial: ns16550: Support debug UART

Masahiro Yamada yamada.m at jp.panasonic.com
Tue Dec 16 05:39:03 CET 2014


Hi Simon,


On Mon, 15 Dec 2014 07:19:53 -0700
Simon Glass <sjg at chromium.org> wrote:

> +#ifdef CONFIG_DEBUG_UART_NS16550
> +void debug_uart_init(void)
> +{
> +	struct NS16550 *com_port = (struct NS16550 *)CONFIG_DEBUG_UART_BASE;
> +	int baud_divisor;
> +
> +	baud_divisor = calc_divisor(com_port, CONFIG_DEBUG_UART_CLOCK,
> +				    CONFIG_BAUDRATE);
> +
> +	writeb(CONFIG_SYS_NS16550_IER, &com_port->ier);
> +	writeb(UART_MCRVAL, &com_port->mcr);
> +	writeb(UART_FCRVAL, &com_port->fcr);
> +
> +	writeb(UART_LCR_BKSE | UART_LCRVAL, &com_port->lcr);
> +	writeb(baud_divisor & 0xff, &com_port->dll);
> +	writeb((baud_divisor >> 8) & 0xff, &com_port->dlm);
> +	writeb(UART_LCRVAL, &com_port->lcr);
> +}

This function is duplicating NS16550_init() and NS16550_setbrg().



> +static inline void _debug_uart_putc(int ch)
> +{
> +	struct NS16550 *com_port = (struct NS16550 *)CONFIG_DEBUG_UART_BASE;
> +
> +	while (!(readb(&com_port->lsr) & UART_LSR_THRE))
> +		;
> +	writeb(ch, &com_port->thr);
> +}

This is duplicating ns16550_serial_putc().



What does this patch save?

It looks like the driver code is just getting dirtier.




Best Regards
Masahiro Yamada



More information about the U-Boot mailing list