]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
dm: serial: bcm6345: fix baud rate clock calculation
authorÁlvaro Fernández Rojas <noltari@gmail.com>
Mon, 22 May 2017 18:01:46 +0000 (20:01 +0200)
committerDaniel Schwierzeck <daniel.schwierzeck@gmail.com>
Wed, 31 May 2017 12:55:20 +0000 (14:55 +0200)
It's currently bugged and doesn't work for even cases.
Right shift bits instead of dividing and fix even cases.

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
drivers/serial/serial_bcm6345.c

index 14c1bf26c12bf824aca60f9d9a3771e698e3529c..0843b48bea11c8f4e2712aeea3c6b7e8f0f4f6f1 100644 (file)
@@ -157,11 +157,11 @@ static int bcm6345_serial_init(void __iomem *base, ulong clk, u32 baudrate)
                        UART_FIFO_CFG_TX_4);
 
        /* set baud rate */
-       val = (clk / baudrate) / 16;
+       val = ((clk / baudrate) >> 4);
        if (val & 0x1)
-               val = val;
+               val = (val >> 1);
        else
-               val = val / 2 - 1;
+               val = (val >> 1) - 1;
        writel_be(val, base + UART_BAUD_REG);
 
        /* clear interrupts */
@@ -243,7 +243,7 @@ static int bcm6345_serial_probe(struct udevice *dev)
        ret = clk_get_by_index(dev, 0, &clk);
        if (ret < 0)
                return ret;
-       priv->uartclk = clk_get_rate(&clk) / 2;
+       priv->uartclk = clk_get_rate(&clk);
        clk_free(&clk);
 
        /* initialize serial */