tty: serial: meson: Add support for XTAL clock input
authorAndreas Färber <afaerber@suse.de>
Mon, 8 Feb 2016 12:49:42 +0000 (13:49 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 15 Feb 2016 01:39:36 +0000 (17:39 -0800)
Fix the baudrate calculation for 24 MHz XTAL clock found on gxbb platforms.

Signed-off-by: Andreas Färber <afaerber@suse.de>
Acked-by: Carlo Caione <carlo@endlessm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/meson_uart.c

index b12a37bd37b630fddb6613c79992a6ec7cc8b58a..024445aa0521b36c3a75695a87065f631c301b0a 100644 (file)
@@ -78,6 +78,7 @@
 /* AML_UART_REG5 bits */
 #define AML_UART_BAUD_MASK             0x7fffff
 #define AML_UART_BAUD_USE              BIT(23)
+#define AML_UART_BAUD_XTAL             BIT(24)
 
 #define AML_UART_PORT_NUM              6
 #define AML_UART_DEV_NAME              "ttyAML"
@@ -299,7 +300,12 @@ static void meson_uart_change_speed(struct uart_port *port, unsigned long baud)
 
        val = readl(port->membase + AML_UART_REG5);
        val &= ~AML_UART_BAUD_MASK;
-       val = ((port->uartclk * 10 / (baud * 4) + 5) / 10) - 1;
+       if (port->uartclk == 24000000) {
+               val = ((port->uartclk / 3) / baud) - 1;
+               val |= AML_UART_BAUD_XTAL;
+       } else {
+               val = ((port->uartclk * 10 / (baud * 4) + 5) / 10) - 1;
+       }
        val |= AML_UART_BAUD_USE;
        writel(val, port->membase + AML_UART_REG5);
 }