aboutsummaryrefslogtreecommitdiff
path: root/lib/utils/serial/uart8250.c
diff options
context:
space:
mode:
authorAnup Patel <anup.patel@wdc.com>2020-04-25 11:11:49 +0530
committerAnup Patel <anup@brainfault.org>2020-05-01 09:36:13 +0530
commite6c1345f89f0c2fa5d8b0dde733eb80366056632 (patch)
tree24f543cd02b83be807671b5a0915b39e11648639 /lib/utils/serial/uart8250.c
parent5bdf022d07f1efcf8bc1647c78a294ab2baf4c9b (diff)
downloadopensbi-e6c1345f89f0c2fa5d8b0dde733eb80366056632.zip
opensbi-e6c1345f89f0c2fa5d8b0dde733eb80366056632.tar.gz
opensbi-e6c1345f89f0c2fa5d8b0dde733eb80366056632.tar.bz2
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>
Diffstat (limited to 'lib/utils/serial/uart8250.c')
-rw-r--r--lib/utils/serial/uart8250.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/utils/serial/uart8250.c b/lib/utils/serial/uart8250.c
index 42f1881..9635ba8 100644
--- a/lib/utils/serial/uart8250.c
+++ b/lib/utils/serial/uart8250.c
@@ -100,10 +100,14 @@ int uart8250_init(unsigned long base, u32 in_freq, u32 baudrate, u32 reg_shift,
set_reg(UART_IER_OFFSET, 0x00);
/* Enable DLAB */
set_reg(UART_LCR_OFFSET, 0x80);
- /* Set divisor low byte */
- set_reg(UART_DLL_OFFSET, bdiv & 0xff);
- /* Set divisor high byte */
- set_reg(UART_DLM_OFFSET, (bdiv >> 8) & 0xff);
+
+ if (bdiv) {
+ /* Set divisor low byte */
+ set_reg(UART_DLL_OFFSET, bdiv & 0xff);
+ /* Set divisor high byte */
+ set_reg(UART_DLM_OFFSET, (bdiv >> 8) & 0xff);
+ }
+
/* 8 bits, no parity, one stop bit */
set_reg(UART_LCR_OFFSET, 0x03);
/* Enable FIFO */