From 83b181fb3210fb09a3e4a5c9ef3d3b755fd1b85e Mon Sep 17 00:00:00 2001 From: Serhii Voloshynov Date: Tue, 11 Jan 2022 14:30:05 +0200 Subject: Disable CRTSCTS when setting RS485 half duplex to match Vizzini driver - adaptation for 5.4 kernel --- .../mtcdt/linux-5.4-rs485-atmel-crtscts.patch | 23 ++++++++++++++++++++++ recipes-kernel/linux/linux-at91_5.4.81.bb | 1 + 2 files changed, 24 insertions(+) create mode 100644 recipes-kernel/linux/linux-at91-5.4.81/mtcdt/linux-5.4-rs485-atmel-crtscts.patch diff --git a/recipes-kernel/linux/linux-at91-5.4.81/mtcdt/linux-5.4-rs485-atmel-crtscts.patch b/recipes-kernel/linux/linux-at91-5.4.81/mtcdt/linux-5.4-rs485-atmel-crtscts.patch new file mode 100644 index 0000000..d17ed37 --- /dev/null +++ b/recipes-kernel/linux/linux-at91-5.4.81/mtcdt/linux-5.4-rs485-atmel-crtscts.patch @@ -0,0 +1,23 @@ +This patch allows RS485 Half Duplex (ATMEL_US_USMODE_RS485 is half duplex) to +work even if handshaking is turned on. This mimics the behavior of the EXAR +USB/Serial driver known as Vizzini. It is impossible to use handshaking when +using ATMEL_US_USMODE_RS485. This provides compatibility between MTCDT-0.1 and +MTCDT-0.2. +======================================================================================= +diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c +index 28d4a92c0d63..2d17558a807d 100644 +--- a/drivers/tty/serial/atmel_serial.c ++++ b/drivers/tty/serial/atmel_serial.c +@@ -2250,6 +2250,9 @@ static void atmel_set_termios(struct uart_port *port, struct ktermios *termios, + atmel_uart_writel(port, ATMEL_US_TTGR, + port->rs485.delay_rts_after_send); + mode |= ATMEL_US_USMODE_RS485; ++ /* CRTSCTS is impossible in RS485 mode, and breaks the driver ++ * so we cannot do a send. */ ++ termios->c_cflag &= ~CRTSCTS; + } else if (port->iso7816.flags & SER_ISO7816_ENABLED) { + atmel_uart_writel(port, ATMEL_US_TTGR, port->iso7816.tg); + /* select mck clock, and output */ +-- +2.25.1 + diff --git a/recipes-kernel/linux/linux-at91_5.4.81.bb b/recipes-kernel/linux/linux-at91_5.4.81.bb index f57d418..9a427d2 100644 --- a/recipes-kernel/linux/linux-at91_5.4.81.bb +++ b/recipes-kernel/linux/linux-at91_5.4.81.bb @@ -45,6 +45,7 @@ COMMON_PATCHES = " \ file://linux-5.4-OF-DT-Overlay-configfs-interface.patch \ file://linux-5.4-revert-net-macb-Properly-handle-phylink-on-at91rm9200.patch \ file://linux-5.4-bring-back-PAE-bit-and-fix-NCFGR-values-applicable-f.patch \ + file://linux-5.4-rs485-atmel-crtscts.patch \ file://mt-at91.h \ " -- cgit v1.2.3