serial: ns16550: implement ops->clear callback

Thus, the flushc() can work normally.

Change-Id: I544ed0ffcbc5564913bf89bf1a83c6d540ae6b6a
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
This commit is contained in:
Joseph Chen 2019-05-05 12:55:55 +08:00
parent c1e72b20c9
commit 7c86130655
1 changed files with 19 additions and 14 deletions

View File

@ -363,20 +363,6 @@ static int ns16550_serial_putc(struct udevice *dev, const char ch)
if (ch == '\n')
WATCHDOG_RESET();
#ifdef CONFIG_ARCH_ROCKCHIP
/*
* Wait fifo flush.
*
* UART_USR: bit2 trans_fifo_empty:
* 0 = Transmit FIFO is not empty
* 1 = Transmit FIFO is empty
*/
if (gd->flags & GD_FLG_OS_RUN) {
while (!(serial_in(&com_port->rbr + 0x1f) & 0x04))
;
}
#endif
return 0;
}
@ -413,6 +399,24 @@ static int ns16550_serial_setbrg(struct udevice *dev, int baudrate)
return 0;
}
static int ns16550_serial_clear(struct udevice *dev)
{
#ifdef CONFIG_ARCH_ROCKCHIP
struct NS16550 *const com_port = dev_get_priv(dev);
/*
* Wait fifo flush.
*
* UART_USR: bit2 trans_fifo_empty:
* 0 = Transmit FIFO is not empty
* 1 = Transmit FIFO is empty
*/
while (!(serial_in(&com_port->rbr + 0x1f) & 0x04))
;
#endif
return 0;
}
int ns16550_serial_probe(struct udevice *dev)
{
struct NS16550 *const com_port = dev_get_priv(dev);
@ -521,6 +525,7 @@ const struct dm_serial_ops ns16550_serial_ops = {
.pending = ns16550_serial_pending,
.getc = ns16550_serial_getc,
.setbrg = ns16550_serial_setbrg,
.clear = ns16550_serial_clear,
};
#if CONFIG_IS_ENABLED(SERIAL_PRESENT)