aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Wahren <stefan.wahren@i2se.com>2015-08-11 07:46:01 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2015-08-14 20:08:48 -0400
commitdf57cf6a879502cd6e5559c1f2d6db12128e074f (patch)
treee4988c9a2c427a351a33d7a4435803c5f60c1db7
parent17dc72cf3d8c6284cc34f29627f891268af07a55 (diff)
serial: mxs-auart: fix baud rate range
Currently mxs-auart doesn't care correctly about the baud rate divisor. According to reference manual the baud rate divisor must be between 0x000000EC and 0x003FFFC0. So calculate the possible baud rate range and use it for uart_get_baud_rate(). Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com> Reviewed-by: Fabio Estevam <fabio.estevam@freescale.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/tty/serial/mxs-auart.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/tty/serial/mxs-auart.c b/drivers/tty/serial/mxs-auart.c
index 8d1cd158ca24..7c7f30809849 100644
--- a/drivers/tty/serial/mxs-auart.c
+++ b/drivers/tty/serial/mxs-auart.c
@@ -100,6 +100,8 @@
100#define AUART_CTRL2_TXE (1 << 8) 100#define AUART_CTRL2_TXE (1 << 8)
101#define AUART_CTRL2_UARTEN (1 << 0) 101#define AUART_CTRL2_UARTEN (1 << 0)
102 102
103#define AUART_LINECTRL_BAUD_DIV_MAX 0x003fffc0
104#define AUART_LINECTRL_BAUD_DIV_MIN 0x000000ec
103#define AUART_LINECTRL_BAUD_DIVINT_SHIFT 16 105#define AUART_LINECTRL_BAUD_DIVINT_SHIFT 16
104#define AUART_LINECTRL_BAUD_DIVINT_MASK 0xffff0000 106#define AUART_LINECTRL_BAUD_DIVINT_MASK 0xffff0000
105#define AUART_LINECTRL_BAUD_DIVINT(v) (((v) & 0xffff) << 16) 107#define AUART_LINECTRL_BAUD_DIVINT(v) (((v) & 0xffff) << 16)
@@ -659,7 +661,7 @@ static void mxs_auart_settermios(struct uart_port *u,
659{ 661{
660 struct mxs_auart_port *s = to_auart_port(u); 662 struct mxs_auart_port *s = to_auart_port(u);
661 u32 bm, ctrl, ctrl2, div; 663 u32 bm, ctrl, ctrl2, div;
662 unsigned int cflag, baud; 664 unsigned int cflag, baud, baud_min, baud_max;
663 665
664 cflag = termios->c_cflag; 666 cflag = termios->c_cflag;
665 667
@@ -752,7 +754,9 @@ static void mxs_auart_settermios(struct uart_port *u,
752 } 754 }
753 755
754 /* set baud rate */ 756 /* set baud rate */
755 baud = uart_get_baud_rate(u, termios, old, 0, u->uartclk); 757 baud_min = DIV_ROUND_UP(u->uartclk * 32, AUART_LINECTRL_BAUD_DIV_MAX);
758 baud_max = u->uartclk * 32 / AUART_LINECTRL_BAUD_DIV_MIN;
759 baud = uart_get_baud_rate(u, termios, old, baud_min, baud_max);
756 div = u->uartclk * 32 / baud; 760 div = u->uartclk * 32 / baud;
757 ctrl |= AUART_LINECTRL_BAUD_DIVFRAC(div & 0x3F); 761 ctrl |= AUART_LINECTRL_BAUD_DIVFRAC(div & 0x3F);
758 ctrl |= AUART_LINECTRL_BAUD_DIVINT(div >> 6); 762 ctrl |= AUART_LINECTRL_BAUD_DIVINT(div >> 6);