From: Masahiro Yamada Date: Tue, 16 Dec 2014 13:39:03 +0900 Subject: [U-Boot] [PATCH 18/19] serial: ns16550: Support debug UART In-Reply-To: <1418653194-16873-19-git-send-email-sjg@chromium.org> References: <1418653194-16873-1-git-send-email-sjg@chromium.org> <1418653194-16873-19-git-send-email-sjg@chromium.org> Message-ID: <20141216133901.0546.AA925319@jp.panasonic.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hi Simon, On Mon, 15 Dec 2014 07:19:53 -0700 Simon Glass 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