aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>2017-03-20 05:05:38 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-04-08 03:30:34 -0400
commit5289f1ce39a798e46f31db8efc2e3f99eebf73df (patch)
tree35f6a19f7f9fc33482949c0128aa6029aa37b832
parent67e41b1368b146ff6508a4efe5552400412d2f32 (diff)
serial: mxs-auart: Fix baudrate calculation
commit a6040bc610554c66088fda3608ae5d6307c548e4 upstream. The reference manual for the i.MX28 recommends to calculate the divisor as divisor = (UARTCLK * 32) / baud rate, rounded to the nearest integer , so let's do this. For a typical setup of UARTCLK = 24 MHz and baud rate = 115200 this changes the divisor from 6666 to 6667 and so the actual baud rate improves from 115211.521 Bd (error ≅ 0.01 %) to 115194.240 Bd (error ≅ 0.005 %). Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/tty/serial/mxs-auart.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/tty/serial/mxs-auart.c b/drivers/tty/serial/mxs-auart.c
index 770454e0dfa3..07390f8c3681 100644
--- a/drivers/tty/serial/mxs-auart.c
+++ b/drivers/tty/serial/mxs-auart.c
@@ -1085,7 +1085,7 @@ static void mxs_auart_settermios(struct uart_port *u,
1085 AUART_LINECTRL_BAUD_DIV_MAX); 1085 AUART_LINECTRL_BAUD_DIV_MAX);
1086 baud_max = u->uartclk * 32 / AUART_LINECTRL_BAUD_DIV_MIN; 1086 baud_max = u->uartclk * 32 / AUART_LINECTRL_BAUD_DIV_MIN;
1087 baud = uart_get_baud_rate(u, termios, old, baud_min, baud_max); 1087 baud = uart_get_baud_rate(u, termios, old, baud_min, baud_max);
1088 div = u->uartclk * 32 / baud; 1088 div = DIV_ROUND_CLOSEST(u->uartclk * 32, baud);
1089 } 1089 }
1090 1090
1091 ctrl |= AUART_LINECTRL_BAUD_DIVFRAC(div & 0x3F); 1091 ctrl |= AUART_LINECTRL_BAUD_DIVFRAC(div & 0x3F);