Commit eb578848032f6abc2d1f78c5e5c72be5e235bffd

Authored by Alexandre Belloni
Committed by Greg Kroah-Hartman
1 parent c9715888bf

tty/serial: atmel: fix hardware handshake selection

commit 5be605ac9af979265d7b64c160ad9928088a78be upstream.

Commit 1cf6e8fc8341 ("tty/serial: at91: fix RTS line management when
hardware handshake is enabled") actually allowed to enable hardware
handshaking.
Before, the CRTSCTS flags was silently ignored.

As the DMA controller can't drive RTS (as explain in the commit message).
Ensure that hardware flow control stays disabled when DMA is used and FIFOs
are not available.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Fixes: 1cf6e8fc8341 ("tty/serial: at91: fix RTS line management when hardware handshake is enabled")
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Showing 1 changed file with 13 additions and 1 deletions Side-by-side Diff

drivers/tty/serial/atmel_serial.c
... ... @@ -277,6 +277,13 @@
277 277 return atmel_port->use_dma_rx;
278 278 }
279 279  
  280 +static bool atmel_use_fifo(struct uart_port *port)
  281 +{
  282 + struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
  283 +
  284 + return atmel_port->fifo_size;
  285 +}
  286 +
280 287 static unsigned int atmel_get_lines_status(struct uart_port *port)
281 288 {
282 289 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
... ... @@ -2169,7 +2176,12 @@
2169 2176 mode |= ATMEL_US_USMODE_RS485;
2170 2177 } else if (termios->c_cflag & CRTSCTS) {
2171 2178 /* RS232 with hardware handshake (RTS/CTS) */
2172   - mode |= ATMEL_US_USMODE_HWHS;
  2179 + if (atmel_use_dma_rx(port) && !atmel_use_fifo(port)) {
  2180 + dev_info(port->dev, "not enabling hardware flow control because DMA is used");
  2181 + termios->c_cflag &= ~CRTSCTS;
  2182 + } else {
  2183 + mode |= ATMEL_US_USMODE_HWHS;
  2184 + }
2173 2185 } else {
2174 2186 /* RS232 without hadware handshake */
2175 2187 mode |= ATMEL_US_USMODE_NORMAL;