diff options
| author | TsiChung Liew <[email protected]> | 2008-05-29 12:21:54 -0500 |
|---|---|---|
| committer | John Rigby <[email protected]> | 2008-07-11 10:45:56 -0600 |
| commit | 81cc32322acb1b3225ee45606ced48e2a14824dc (patch) | |
| tree | 27484e115603a42a3f470d0ac471157ff8329e79 /drivers | |
| parent | 9b55a2536919f4de1bb1044e6eb8262c2f53bc96 (diff) | |
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 <[email protected]>
Acked-by: Gerald Van Baren <[email protected]>
Diffstat (limited to 'drivers')
| -rw-r--r-- | drivers/serial/mcfuart.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/serial/mcfuart.c b/drivers/serial/mcfuart.c index 88f3eb10abf..5eb4f458f81 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); |
