Implement a custom set_termios() to configure RTS/CTS hardware flow
control. When CRTSCTS is enabled in termios, the UART_MCR[5] AFE (Auto
Flow Control Enable) bit is set to allow automatic RTS/CTS signaling.
Signed-off-by: Crescent Hsieh <crescentcy.hsieh@moxa.com>
---
drivers/tty/serial/8250/8250_mxupci.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/drivers/tty/serial/8250/8250_mxupci.c b/drivers/tty/serial/8250/8250_mxupci.c
index c4fa52de8962..54e50cd3f472 100644
--- a/drivers/tty/serial/8250/8250_mxupci.c
+++ b/drivers/tty/serial/8250/8250_mxupci.c
@@ -78,6 +78,26 @@ static unsigned short mxupci8250_get_nports(unsigned short device)
return FIELD_GET(0x00F0, device);
}
+static void mxupci8250_set_termios(struct uart_port *port, struct ktermios *new,
+ const struct ktermios *old)
+{
+ struct uart_8250_port *up = up_to_u8250p(port);
+ struct tty_struct *tty = port->state->port.tty;
+ unsigned int cflag = tty->termios.c_cflag;
+
+ serial8250_do_set_termios(port, new, old);
+
+ up->port.status &= ~(UPSTAT_AUTORTS | UPSTAT_AUTOCTS);
+
+ up->mcr &= ~UART_MCR_AFE;
+
+ if (cflag & CRTSCTS) {
+ up->mcr |= (UART_MCR_AFE | UART_MCR_RTS);
+ up->port.status |= (UPSTAT_AUTORTS | UPSTAT_AUTOCTS);
+ }
+ serial_out(up, UART_MCR, up->mcr);
+}
+
static int mxupci8250_startup(struct uart_port *port)
{
struct uart_8250_port *up = up_to_u8250p(port);
@@ -152,6 +172,7 @@ static int mxupci8250_probe(struct pci_dev *pdev, const struct pci_device_id *id
up.port.flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF | UPF_SHARE_IRQ | UPF_FIXED_TYPE;
up.port.type = PORT_MU860;
+ up.port.set_termios = mxupci8250_set_termios;
up.port.startup = mxupci8250_startup;
up.port.shutdown = mxupci8250_shutdown;
--
2.45.2