[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251130104222.63077-13-crescentcy.hsieh@moxa.com>
Date: Sun, 30 Nov 2025 18:42:03 +0800
From: Crescent Hsieh <crescentcy.hsieh@...a.com>
To: gregkh@...uxfoundation.org,
jirislaby@...nel.org,
ilpo.jarvinen@...ux.intel.com,
andy.shevchenko@...il.com
Cc: linux-kernel@...r.kernel.org,
linux-serial@...r.kernel.org,
crescentcy.hsieh@...a.com
Subject: [PATCH v1 12/31] serial: 8250_mxpcie: enable auto RTS/CTS flow control
Implement a custom set_termios() to configure RTS/CTS hardware flow
control using the Enhanced Feature Register (EFR). This enables support
for automatic RTS/CTS signaling when CRTSCTS is enabled in termios.
Signed-off-by: Crescent Hsieh <crescentcy.hsieh@...a.com>
---
drivers/tty/serial/8250/8250_mxpcie.c | 28 +++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/drivers/tty/serial/8250/8250_mxpcie.c b/drivers/tty/serial/8250/8250_mxpcie.c
index 39a178dc0519..197d016354c9 100644
--- a/drivers/tty/serial/8250/8250_mxpcie.c
+++ b/drivers/tty/serial/8250/8250_mxpcie.c
@@ -43,6 +43,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 */
@@ -137,6 +141,29 @@ static int mxpcie8250_set_interface(struct mxpcie8250 *priv,
return 0;
}
+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);
@@ -254,6 +281,7 @@ static int mxpcie8250_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_MUEX50;
+ up.port.set_termios = mxpcie8250_set_termios;
up.port.startup = mxpcie8250_startup;
up.port.shutdown = mxpcie8250_shutdown;
--
2.45.2
Powered by blists - more mailing lists