Merge branch 'Makefile' of git://git.denx.de/u-boot-arm
[platform/kernel/u-boot.git] / drivers / serial / serial.c
index 4ccaee2..b361eef 100644 (file)
@@ -26,7 +26,7 @@
 #ifdef CFG_NS16550_SERIAL
 
 #include <ns16550.h>
-#ifdef CFG_NS87308
+#ifdef CONFIG_NS87308
 #include <ns87308.h>
 #endif
 
@@ -124,8 +124,6 @@ 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)) {
@@ -149,15 +147,11 @@ 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 (2/4).
+        * but we need to round that value by adding 0.5.
         * Rounding is especially important at high baud rates.
         */
-       clk_divisor = (((4 * CFG_NS16550_CLK) /
-                       (MODE_X_DIV * gd->baudrate)) + 2) / 4;
-
-       debug("NS16550 clock divisor = %d\n", clk_divisor);
-
-       return clk_divisor;
+       return (CFG_NS16550_CLK + (gd->baudrate * (MODE_X_DIV / 2))) /
+               (MODE_X_DIV * gd->baudrate);
 }
 
 #if !defined(CONFIG_SERIAL_MULTI)
@@ -165,7 +159,7 @@ int serial_init (void)
 {
        int clock_divisor;
 
-#ifdef CFG_NS87308
+#ifdef CONFIG_NS87308
        initialise_ns87308();
 #endif