From 92d3e6e0ffcbb7224c83104f8d87b5b4bf39a38f Mon Sep 17 00:00:00 2001
From: Richard Retanubun <RichardRetanubun@RuggedCom.com>
Date: Fri, 23 Jan 2009 11:44:30 -0500
Subject: [PATCH] Coldfire: Applied baudrate formula of serial_init to
 serial_setbrg

Applied the patch for baudrate divider value truncation for
serial_init to serial_setbrg as well.

Signed-off-by: Richard Retanubun <RichardRetanubun@RuggedCom.com>
---
 drivers/serial/mcfuart.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/serial/mcfuart.c b/drivers/serial/mcfuart.c
index e04fc298d9..0b531402e4 100644
--- a/drivers/serial/mcfuart.c
+++ b/drivers/serial/mcfuart.c
@@ -115,8 +115,9 @@ void serial_setbrg(void)
 	volatile uart_t *uart = (volatile uart_t *)(CONFIG_SYS_UART_BASE);
 	u32 counter;
 
-	counter = ((gd->bus_clk / gd->baudrate)) >> 5;
-	counter++;
+	/* Setting up BaudRate */
+	counter = (u32) ((gd->bus_clk / 32) + (gd->baudrate / 2));
+	counter = counter / gd->baudrate;
 
 	/* write to CTUR: divide counter upper byte */
 	uart->ubg1 = ((counter & 0xff00) >> 8);
-- 
GitLab