summaryrefslogtreecommitdiff
path: root/drivers/serial/serial.c
diff options
context:
space:
mode:
authorStefan Roese <sr@denx.de>2008-07-14 10:45:47 +0200
committerStefan Roese <sr@denx.de>2008-07-14 10:45:47 +0200
commit4b326101d6cfaeab8250988bc4c7f51e6c92d719 (patch)
treed04632af08591263f5cd6fc8a5c6ba8ac3d6d246 /drivers/serial/serial.c
parent69e2c6d0d13d7c8cf1612ac090bdc4c59ba6858e (diff)
parentd5996dd555edf52721b7691a4c59de016251ed39 (diff)
downloadu-boot-imx-4b326101d6cfaeab8250988bc4c7f51e6c92d719.zip
u-boot-imx-4b326101d6cfaeab8250988bc4c7f51e6c92d719.tar.gz
u-boot-imx-4b326101d6cfaeab8250988bc4c7f51e6c92d719.tar.bz2
Merge branch 'master' of /home/stefan/git/u-boot/u-boot into next
Diffstat (limited to 'drivers/serial/serial.c')
-rw-r--r--drivers/serial/serial.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/drivers/serial/serial.c b/drivers/serial/serial.c
index 182ca2d..4ccaee2 100644
--- a/drivers/serial/serial.c
+++ b/drivers/serial/serial.c
@@ -124,6 +124,8 @@ static NS16550_t serial_ports[4] = {
static int calc_divisor (NS16550_t port)
{
+ uint32_t clk_divisor;
+
#ifdef CONFIG_OMAP1510
/* If can't cleanly clock 115200 set div to 1 */
if ((CFG_NS16550_CLK == 12000000) && (gd->baudrate == 115200)) {
@@ -147,10 +149,15 @@ static int calc_divisor (NS16550_t port)
/* Compute divisor value. Normally, we should simply return:
* CFG_NS16550_CLK) / MODE_X_DIV / gd->baudrate
- * but we need to round that value by adding 0.5 or 8/16.
+ * but we need to round that value by adding 0.5 (2/4).
* Rounding is especially important at high baud rates.
*/
- return (((16 * CFG_NS16550_CLK) / MODE_X_DIV / gd->baudrate) + 8) / 16;
+ clk_divisor = (((4 * CFG_NS16550_CLK) /
+ (MODE_X_DIV * gd->baudrate)) + 2) / 4;
+
+ debug("NS16550 clock divisor = %d\n", clk_divisor);
+
+ return clk_divisor;
}
#if !defined(CONFIG_SERIAL_MULTI)