diff options
author | Jakub Luzny <jakub.luzny@codasip.com> | 2022-01-21 16:06:14 +0100 |
---|---|---|
committer | Anup Patel <anup@brainfault.org> | 2022-02-04 11:16:29 +0530 |
commit | ce4c0188d96b2c20c2e08d24646a5e517fe15a4b (patch) | |
tree | b657f4238d17392180be0c1410eb94c312fd8182 | |
parent | 6ad8917b7e27e5e80fb9268492b9111b17ed2024 (diff) | |
download | opensbi-ce4c0188d96b2c20c2e08d24646a5e517fe15a4b.zip opensbi-ce4c0188d96b2c20c2e08d24646a5e517fe15a4b.tar.gz opensbi-ce4c0188d96b2c20c2e08d24646a5e517fe15a4b.tar.bz2 |
lib: utils/serial: Round UART8250 baud rate divisor to nearest integer
Previously, it was rounded down and that gives suboptimal results when
non-standard clock sources or baud rates are used.
Signed-off-by: Jakub Luzny <jakub.luzny@codasip.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
-rw-r--r-- | lib/utils/serial/uart8250.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/utils/serial/uart8250.c b/lib/utils/serial/uart8250.c index 142f8dc..141bd45 100644 --- a/lib/utils/serial/uart8250.c +++ b/lib/utils/serial/uart8250.c @@ -101,7 +101,7 @@ int uart8250_init(unsigned long base, u32 in_freq, u32 baudrate, u32 reg_shift, uart8250_in_freq = in_freq; uart8250_baudrate = baudrate; - bdiv = uart8250_in_freq / (16 * uart8250_baudrate); + bdiv = (uart8250_in_freq + 8 * uart8250_baudrate) / (16 * uart8250_baudrate); /* Disable all interrupts */ set_reg(UART_IER_OFFSET, 0x00); |