summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorCrescent Hsieh <crescentcy.hsieh@moxa.com>2026-07-31 15:48:10 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2026-08-03 16:51:57 +0200
commit55edf8511f4728a79757ab64ae9126e2ea59e310 (patch)
treeb8d55c66e366fe41152ce5a9b049aaff3a06e633 /drivers
parent0a53c72969e72041476a5ae3fe8381fc7e2c13dd (diff)
downloadlinux-55edf8511f4728a79757ab64ae9126e2ea59e310.tar.gz
linux-55edf8511f4728a79757ab64ae9126e2ea59e310.zip
serial: 8250_mxpcie: enable automatic RTS/CTS flow control
The MUEx50 UART supports automatic RTS/CTS flow control via the enhanced feature register. Implement a mxpcie-specific set_termios() callback that enables MUEx50 auto-RTS/auto-CTS when CRTSCTS is requested and disables it otherwise. Keep the 8250 port status flags in sync with the hardware configuration. Signed-off-by: Crescent Hsieh <crescentcy.hsieh@moxa.com> Link: https://patch.msgid.link/20260731074820.735619-5-crescentcy.hsieh@moxa.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/tty/serial/8250/8250_mxpcie.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/drivers/tty/serial/8250/8250_mxpcie.c b/drivers/tty/serial/8250/8250_mxpcie.c
index e1d607b607e8..25ca43225e7a 100644
--- a/drivers/tty/serial/8250/8250_mxpcie.c
+++ b/drivers/tty/serial/8250/8250_mxpcie.c
@@ -58,6 +58,10 @@
/* Enhanced Function Register (EFR) */
#define MOXA_PUART_EFR 0x0A
#define MOXA_PUART_EFR_ENHANCED BIT(4)
+#define MOXA_PUART_EFR_AUTO_RTS BIT(6)
+#define MOXA_PUART_EFR_AUTO_CTS BIT(7)
+#define MOXA_PUART_EFR_RX_FLOW_MASK GENMASK(1, 0)
+#define MOXA_PUART_EFR_TX_FLOW_MASK GENMASK(3, 2)
#define MOXA_PUART_TTL 0x10 /* Tx Interrupt Trigger Level */
#define MOXA_PUART_RTL 0x11 /* Rx Interrupt Trigger Level */
@@ -148,6 +152,29 @@ static void mxpcie8250_set_interface(struct mxpcie8250 *priv,
iowrite8(cval, uir_addr);
}
+static void mxpcie8250_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;
+ u8 efr;
+
+ serial8250_do_set_termios(port, new, old);
+
+ up->port.status &= ~(UPSTAT_AUTORTS | UPSTAT_AUTOCTS);
+
+ efr = serial_in(up, MOXA_PUART_EFR);
+ efr &= ~(MOXA_PUART_EFR_AUTO_RTS | MOXA_PUART_EFR_AUTO_CTS);
+
+ if (cflag & CRTSCTS) {
+ efr |= (MOXA_PUART_EFR_AUTO_RTS | MOXA_PUART_EFR_AUTO_CTS);
+ up->port.status |= (UPSTAT_AUTORTS | UPSTAT_AUTOCTS);
+ }
+ serial_out(up, MOXA_PUART_EFR, efr);
+}
+
static int mxpcie8250_startup(struct uart_port *port)
{
struct uart_8250_port *up = up_to_u8250p(port);
@@ -285,6 +312,7 @@ static int mxpcie8250_probe(struct pci_dev *pdev, const struct pci_device_id *id
up.port.iobase = 0;
up.port.regshift = 0;
+ up.port.set_termios = mxpcie8250_set_termios;
up.port.startup = mxpcie8250_startup;
up.port.shutdown = mxpcie8250_shutdown;