1
0
Fork 0
alistair23-linux/drivers/tty
Richard Genoud 9bcffe7575 tty/serial: at91: fix hardware handshake on Atmel platforms
After commit 1cf6e8fc83 ("tty/serial: at91: fix RTS line management
when hardware handshake is enabled"), the hardware handshake wasn't
functional anymore on Atmel platforms (beside SAMA5D2).

To understand why, one has to understand the flag ATMEL_US_USMODE_HWHS
first:
Before commit 1cf6e8fc83 ("tty/serial: at91: fix RTS line management
when hardware handshake is enabled"), this flag was never set.
Thus, the CTS/RTS where only handled by serial_core (and everything
worked just fine).

This commit introduced the use of the ATMEL_US_USMODE_HWHS flag,
enabling it for all boards when the user space enables flow control.

When the ATMEL_US_USMODE_HWHS is set, the Atmel USART controller
handles a part of the flow control job:
- disable the transmitter when the CTS pin gets high.
- drive the RTS pin high when the DMA buffer transfer is completed or
  PDC RX buffer full or RX FIFO is beyond threshold. (depending on the
  controller version).

NB: This feature is *not* mandatory for the flow control to work.
(Nevertheless, it's very useful if low latencies are needed.)

Now, the specifics of the ATMEL_US_USMODE_HWHS flag:

- For platforms with DMAC and no FIFOs (sam9x25, sam9x35, sama5D3,
sama5D4, sam9g15, sam9g25, sam9g35)* this feature simply doesn't work.
( source: https://lkml.org/lkml/2016/9/7/598 )
Tested it on sam9g35, the RTS pins always stays up, even when RXEN=1
or a new DMA transfer descriptor is set.
=> ATMEL_US_USMODE_HWHS must not be used for those platforms

- For platforms with a PDC (sam926{0,1,3}, sam9g10, sam9g20, sam9g45,
sam9g46)*, there's another kind of problem. Once the flag
ATMEL_US_USMODE_HWHS is set, the RTS pin can't be driven anymore via
RTSEN/RTSDIS in USART Control Register. The RTS pin can only be driven
by enabling/disabling the receiver or setting RCR=RNCR=0 in the PDC
(Receive (Next) Counter Register).
=> Doing this is beyond the scope of this patch and could add other
bugs, so the original (and working) behaviour should be set for those
platforms (meaning ATMEL_US_USMODE_HWHS flag should be unset).

- For platforms with a FIFO (sama5d2)*, the RTS pin is driven according
to the RX FIFO thresholds, and can be also driven by RTSEN/RTSDIS in
USART Control Register. No problem here.
(This was the use case of commit 1cf6e8fc83 ("tty/serial: at91: fix
RTS line management when hardware handshake is enabled"))
NB: If the CTS pin declared as a GPIO in the DTS, (for instance
cts-gpios = <&pioA PIN_PB31 GPIO_ACTIVE_LOW>), the transmitter will be
disabled.
=> ATMEL_US_USMODE_HWHS flag can be set for this platform ONLY IF the
CTS pin is not a GPIO.

So, the only case when ATMEL_US_USMODE_HWHS can be enabled is when
(atmel_use_fifo(port) &&
 !mctrl_gpio_to_gpiod(atmel_port->gpios, UART_GPIO_CTS))

Tested on all Atmel USART controller flavours:
AT91SAM9G35-CM (DMAC flavour), AT91SAM9G20-EK (PDC flavour),
SAMA5D2xplained (FIFO flavour).

* the list may not be exhaustive

Cc: <stable@vger.kernel.org> #4.4+ (beware, missing atmel_port variable)
Fixes: 1cf6e8fc83 ("tty/serial: at91: fix RTS line management when hardware handshake is enabled")
Signed-off-by: Richard Genoud <richard.genoud@gmail.com>
Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Acked-by: Cyrille Pitchen <cyrille.pitchen@atmel.com>
Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-10-28 08:10:48 -04:00
..
hvc tty/hvc: Use opal irqchip interface if available 2016-07-27 12:38:20 +10:00
ipwireless tty: ipwireless, cleanup TIOCGSERIAL 2016-06-25 08:56:30 -07:00
serial tty/serial: at91: fix hardware handshake on Atmel platforms 2016-10-28 08:10:48 -04:00
vt vt: clear selection before resizing 2016-10-27 17:19:35 +02:00
Kconfig devpts: Make each mount of devpts an independent filesystem. 2016-06-05 10:36:01 -07:00
Makefile TTY: Add MIPS EJTAG Fast Debug Channel TTY driver 2015-03-31 12:04:12 +02:00
amiserial.c tty: Replace ASYNC_INITIALIZED bit and update atomically 2016-04-30 09:26:55 -07:00
bfin_jtag_comm.c TTY: bfin_jtag_comm: remove incorrect wait_until_sent operation 2015-03-07 03:44:14 +01:00
cyclades.c tty: stop defining STD_COM_FLAGS in drivers 2016-06-25 08:56:30 -07:00
ehv_bytechan.c drivers/tty: make ehv_bytechan.c explicitly non-modular 2016-02-06 23:26:43 -08:00
goldfish.c tty: goldfish: support platform_device with id -1 2016-03-07 16:11:14 -08:00
isicom.c tty: Replace ASYNC_INITIALIZED bit and update atomically 2016-04-30 09:26:55 -07:00
metag_da.c timers, drivers/tty/metag_da: Initialize the poll timer as pinned 2016-07-07 10:25:14 +02:00
mips_ejtag_fdc.c timers, drivers/tty/mips_ejtag: Initialize the poll timer as pinned 2016-07-07 10:34:59 +02:00
moxa.c tty: Replace ASYNC_INITIALIZED bit and update atomically 2016-04-30 09:26:55 -07:00
moxa.h
mxser.c tty: cyclades+mxser, do not initialize to zero 2016-06-25 08:56:30 -07:00
mxser.h
n_gsm.c TTY and Serial driver update for 4.7-rc1 2016-05-20 20:57:27 -07:00
n_hdlc.c Fix OpenSSH pty regression on close 2016-05-01 13:22:54 -07:00
n_r3964.c tty: r3964: Replace/remove bogus tty lock use 2015-10-17 21:11:29 -07:00
n_tracerouter.c n_tracerouter: stop including <asm-generic/bug> 2015-10-15 00:21:10 +02:00
n_tracesink.c n_tracesink: stop including <asm-generic/bug> 2015-10-15 00:21:11 +02:00
n_tracesink.h
n_tty.c Fix OpenSSH pty regression on close 2016-05-01 13:22:54 -07:00
nozomi.c tty: Replace TTY_THROTTLED bit tests with tty_throttled() 2016-04-30 09:26:55 -07:00
pty.c pty: make ptmx file ops read-only after init 2016-09-15 12:47:03 +02:00
rocket.c TTY: add __init attribute 2016-04-30 09:26:55 -07:00
rocket.h tty: rocket: fix comment of ROCKET_SPD_HI 2015-05-24 12:49:16 -07:00
rocket_int.h tty: rocket: Remove private close_wait 2016-01-28 14:13:44 -08:00
synclink.c TTY and Serial driver update for 4.7-rc1 2016-05-20 20:57:27 -07:00
synclink_gt.c TTY and Serial driver update for 4.7-rc1 2016-05-20 20:57:27 -07:00
synclinkmp.c TTY and Serial driver update for 4.7-rc1 2016-05-20 20:57:27 -07:00
sysrq.c Revert "drivers/tty: Explicitly pass current to show_stack" 2016-09-28 08:12:27 +02:00
tty_audit.c tty: audit: remove unused variable 2016-03-07 16:11:14 -08:00
tty_buffer.c Fix OpenSSH pty regression on close 2016-05-01 13:22:54 -07:00
tty_io.c Merge 4.6-rc7 into tty-next 2016-05-09 09:39:13 +02:00
tty_ioctl.c tty: Replace TTY_THROTTLED bit tests with tty_throttled() 2016-04-30 09:26:55 -07:00
tty_ldisc.c tty: Eliminate global symbol tty_ldisc_N_TTY 2016-01-27 15:13:28 -08:00
tty_ldsem.c tty: Deinline __ldsem_down_write_nested, save 128 bytes 2015-12-13 19:59:48 -08:00
tty_mutex.c Merge 4.5-rc4 into tty-next 2016-02-14 14:36:04 -08:00
tty_port.c tty: Replace ASYNC_INITIALIZED bit and update atomically 2016-04-30 09:26:55 -07:00