mirror of
https://github.com/riscv-software-src/opensbi.git
synced 2025-08-24 07:21:22 +01:00
lib: utils/serial: Clear LSR status and check RBR status
On some platforms, read RBR when it is empty may result in an error. Signed-off-by: Yi Pei <neopimail@gmail.com> Reviewed-by: Anup Patel <anup@brainfault.org> Link: https://lore.kernel.org/r/CAFPVDjQZ1gpf8-u--RBbAL1Y0FfDN2vZ3g=wBw+Bp-8ppuz3HA@mail.gmail.com Signed-off-by: Anup Patel <anup@brainfault.org>
This commit is contained in:
@@ -133,10 +133,9 @@ int uart8250_init(unsigned long base, u32 in_freq, u32 baudrate, u32 reg_shift,
|
||||
set_reg(UART_FCR_OFFSET, 0x01);
|
||||
/* No modem control DTR RTS */
|
||||
set_reg(UART_MCR_OFFSET, 0x00);
|
||||
/* Clear line status */
|
||||
get_reg(UART_LSR_OFFSET);
|
||||
/* Read receive buffer */
|
||||
get_reg(UART_RBR_OFFSET);
|
||||
/* Clear line status and read receive buffer */
|
||||
if (get_reg(UART_LSR_OFFSET) & UART_LSR_DR)
|
||||
get_reg(UART_RBR_OFFSET);
|
||||
/* Set scratchpad */
|
||||
set_reg(UART_SCR_OFFSET, 0x00);
|
||||
|
||||
|
Reference in New Issue
Block a user