From: TsiChung Liew Date: Thu, 29 May 2008 17:21:54 +0000 (-0500) Subject: ColdFire: Fix UART baudrate formula X-Git-Tag: v1.3.4-rc1~40^2^2~12 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=81cc32322acb1b3225ee45606ced48e2a14824dc;p=u-boot ColdFire: Fix UART baudrate formula The formula "counter = (u32) (gd->bus_clk / gd->baudrate) / 32" can generate the wrong divisor due to integer division truncation. Round the calculated divisor value by adding 1/2 the baudrate before dividing by the baudrate. Signed-off-by: TsiChung Liew Acked-by: Gerald Van Baren --- diff --git a/drivers/serial/mcfuart.c b/drivers/serial/mcfuart.c index 88f3eb10ab..5eb4f458f8 100644 --- a/drivers/serial/mcfuart.c +++ b/drivers/serial/mcfuart.c @@ -63,8 +63,8 @@ int serial_init(void) uart->umr = UART_UMR_SB_STOP_BITS_1; /* Setting up BaudRate */ - counter = (u32) (gd->bus_clk / (gd->baudrate)); - counter >>= 5; + counter = (u32) ((gd->bus_clk / 32) + (gd->baudrate / 2)); + counter = counter / gd->baudrate; /* write to CTUR: divide counter upper byte */ uart->ubg1 = (u8) ((counter & 0xff00) >> 8);