[PATCH RFC 2/2] serial: esp32: Report active-low CTS correctly on ESP32-S3 and ESP32-P4
Vítor Hugo Silva
vitorhg20080 at gmail.com
Fri Nov 27 11:25:11 PST 2026
The ESP32-S3 and ESP32-P4 UARTs permit transmission when CTS is low.
The driver currently reports the raw CTS level as TIOCM_CTS, so
TIOCMGET reports CTS asserted while transmission is blocked.
Record the CTS polarity per variant and report the logical CTS state.
Use the existing polarity for the original ESP32.
On the Waveshare ESP32-P4-Module-DEV-KIT, UART1 internal loopback
verified that TIOCMGET reports CTS deasserted while transmission is
blocked and asserted when transmission resumes.
ESP32-S3 hardware testing is pending.
AI assisted with driver development and the loopback test.
Signed-off-by: Vítor Hugo Silva <vitorhg20080 at gmail.com>
---
drivers/tty/serial/esp32_uart.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/tty/serial/esp32_uart.c b/drivers/tty/serial/esp32_uart.c
index 7d58a41..ab0f739 100644
--- a/drivers/tty/serial/esp32_uart.c
+++ b/drivers/tty/serial/esp32_uart.c
@@ -140,6 +140,7 @@ struct esp32_uart_variant {
const char *type;
bool has_clkconf;
bool needs_reg_update;
+ bool cts_active_low;
};
static const struct esp32_uart_variant esp32_variant = {
@@ -172,6 +173,7 @@ static const struct esp32_uart_variant esp32s3_variant = {
.rx_flow_thresh_mask = ESP32S3_UART_RX_FLOW_THRHD,
.type = "ESP32S3 UART",
.has_clkconf = true,
+ .cts_active_low = true,
.loopback_mask = UART_LOOPBACK,
.sw_rts_mask = UART_SW_RTS,
.sw_dtr_reg = UART_CONF0_REG,
@@ -191,6 +193,7 @@ static const struct esp32_uart_variant esp32p4_variant = {
.rx_flow_thresh_mask = ESP32P4_UART_RX_FLOW_THRHD,
.type = "ESP32-P4 UART",
.needs_reg_update = true,
+ .cts_active_low = true,
.loopback_mask = ESP32P4_UART_LOOPBACK,
.sw_rts_mask = ESP32P4_UART_SW_RTS,
.sw_dtr_reg = UART_CONF1_REG,
@@ -332,12 +335,14 @@ static void esp32_uart_set_mctrl(struct uart_port *port, unsigned int mctrl)
static unsigned int esp32_uart_get_mctrl(struct uart_port *port)
{
+ const struct esp32_uart_variant *variant = port_variant(port);
u32 status = esp32_uart_read(port, UART_STATUS_REG);
+ bool ctsn = status & UART_CTSN;
unsigned int ret = TIOCM_CAR;
if (status & UART_DSRN)
ret |= TIOCM_DSR;
- if (status & UART_CTSN)
+ if (ctsn != variant->cts_active_low)
ret |= TIOCM_CTS;
return ret;
--
2.56.1
More information about the linux-riscv
mailing list