Commit 751d0017 authored by David Engraf's avatar David Engraf Committed by Greg Kroah-Hartman

tty/serial: atmel: fix out of range clock divider handling

Use MCK_DIV8 when the clock divider is > 65535. Unfortunately the mode
register was already written thus the clock selection is ignored.

Fix by writing the mode register after calculating the baudrate.
Signed-off-by: default avatarDavid Engraf <david.engraf@sysgo.com>
Link: https://lore.kernel.org/r/20191211162954.8393-1-david.engraf@sysgo.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 2301ec36
...@@ -2270,9 +2270,6 @@ static void atmel_set_termios(struct uart_port *port, struct ktermios *termios, ...@@ -2270,9 +2270,6 @@ static void atmel_set_termios(struct uart_port *port, struct ktermios *termios,
mode |= ATMEL_US_USMODE_NORMAL; mode |= ATMEL_US_USMODE_NORMAL;
} }
/* set the mode, clock divisor, parity, stop bits and data size */
atmel_uart_writel(port, ATMEL_US_MR, mode);
/* /*
* when switching the mode, set the RTS line state according to the * when switching the mode, set the RTS line state according to the
* new mode, otherwise keep the former state * new mode, otherwise keep the former state
...@@ -2315,6 +2312,9 @@ static void atmel_set_termios(struct uart_port *port, struct ktermios *termios, ...@@ -2315,6 +2312,9 @@ static void atmel_set_termios(struct uart_port *port, struct ktermios *termios,
} }
quot = cd | fp << ATMEL_US_FP_OFFSET; quot = cd | fp << ATMEL_US_FP_OFFSET;
/* set the mode, clock divisor, parity, stop bits and data size */
atmel_uart_writel(port, ATMEL_US_MR, mode);
if (!(port->iso7816.flags & SER_ISO7816_ENABLED)) if (!(port->iso7816.flags & SER_ISO7816_ENABLED))
atmel_uart_writel(port, ATMEL_US_BRGR, quot); atmel_uart_writel(port, ATMEL_US_BRGR, quot);
atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_RSTSTA | ATMEL_US_RSTRX); atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_RSTSTA | ATMEL_US_RSTRX);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment