lib: utils/serial: Skip baudrate config if input frequency is zero

We should skip baudrate config for UART8250 and SiFive UART when
input frequency is zero.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
This commit is contained in:
Anup Patel
2020-04-25 11:11:49 +05:30
committed by Anup Patel
parent 5bdf022d07
commit e6c1345f89
2 changed files with 10 additions and 5 deletions

View File

@@ -89,6 +89,7 @@ int sifive_uart_init(unsigned long base, u32 in_freq, u32 baudrate)
uart_baudrate = baudrate; uart_baudrate = baudrate;
/* Configure baudrate */ /* Configure baudrate */
if (in_freq)
set_reg(UART_REG_DIV, uart_min_clk_divisor(in_freq, baudrate)); set_reg(UART_REG_DIV, uart_min_clk_divisor(in_freq, baudrate));
/* Disable interrupts */ /* Disable interrupts */
set_reg(UART_REG_IE, 0); set_reg(UART_REG_IE, 0);

View File

@@ -100,10 +100,14 @@ int uart8250_init(unsigned long base, u32 in_freq, u32 baudrate, u32 reg_shift,
set_reg(UART_IER_OFFSET, 0x00); set_reg(UART_IER_OFFSET, 0x00);
/* Enable DLAB */ /* Enable DLAB */
set_reg(UART_LCR_OFFSET, 0x80); set_reg(UART_LCR_OFFSET, 0x80);
if (bdiv) {
/* Set divisor low byte */ /* Set divisor low byte */
set_reg(UART_DLL_OFFSET, bdiv & 0xff); set_reg(UART_DLL_OFFSET, bdiv & 0xff);
/* Set divisor high byte */ /* Set divisor high byte */
set_reg(UART_DLM_OFFSET, (bdiv >> 8) & 0xff); set_reg(UART_DLM_OFFSET, (bdiv >> 8) & 0xff);
}
/* 8 bits, no parity, one stop bit */ /* 8 bits, no parity, one stop bit */
set_reg(UART_LCR_OFFSET, 0x03); set_reg(UART_LCR_OFFSET, 0x03);
/* Enable FIFO */ /* Enable FIFO */