Maximilian Brune has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/79951?usp=email )
Change subject: drivers/uart/sifive.c: Fix divisor calculation ......................................................................
drivers/uart/sifive.c: Fix divisor calculation
The divisor is calculated using the following formula: div = (frequency / baudrate) - 1;
The current implementation however essentially cacluates: div = (frequency / baudrate);
Signed-off-by: Maximilian Brune maximilian.brune@9elements.com Change-Id: I8a0898ce9016a70c0f91dc8a99fc1cf9e46d20c4 --- M src/drivers/uart/sifive.c 1 file changed, 8 insertions(+), 3 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/51/79951/1
diff --git a/src/drivers/uart/sifive.c b/src/drivers/uart/sifive.c index d1b89dc..68759c8 100644 --- a/src/drivers/uart/sifive.c +++ b/src/drivers/uart/sifive.c @@ -47,9 +47,14 @@
void uart_init(unsigned int idx) { - unsigned int div; - div = uart_baudrate_divisor(get_uart_baudrate(), - uart_platform_refclk(), uart_input_clock_divider()); + // according to FU740 manual: + // f_baud = f_in / (div + 1) + // <=> + // div = (f_in / f_baud) - 1 + unsigned int div = uart_baudrate_divisor(get_uart_baudrate(), uart_platform_refclk(), + uart_input_clock_divider()); + div -= 1; + sifive_uart_init(uart_platform_baseptr(idx), div); }