From: "Vítor Hugo Silva" <vitorhg20080@gmail.com>
To: linux-serial@vger.kernel.org
Cc: gregkh@linuxfoundation.org, jirislaby@kernel.org,
linux-riscv@lists.infradead.org, sashiko-reviews@lists.linux.dev,
"Vítor Hugo Silva" <vitorhg20080@gmail.com>
Subject: [PATCH RFC 2/2] serial: esp32: Report active-low CTS correctly on ESP32-S3 and ESP32-P4
Date: Fri, 27 Nov 2026 19:25:11 +0000 [thread overview]
Message-ID: <20261127192514.174468-2-vitorhg20080@gmail.com> (raw)
In-Reply-To: <20261127192514.174468-1-vitorhg20080@gmail.com>
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@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
WARNING: multiple messages have this Message-ID (diff)
From: "Vítor Hugo Silva" <vitorhg20080@gmail.com>
To: linux-serial@vger.kernel.org
Cc: gregkh@linuxfoundation.org, jirislaby@kernel.org,
linux-riscv@lists.infradead.org, sashiko-reviews@lists.linux.dev,
"Vítor Hugo Silva" <vitorhg20080@gmail.com>
Subject: [PATCH RFC 2/2] serial: esp32: Report active-low CTS correctly on ESP32-S3 and ESP32-P4
Date: Fri, 27 Nov 2026 19:25:11 +0000 [thread overview]
Message-ID: <20261127192514.174468-2-vitorhg20080@gmail.com> (raw)
In-Reply-To: <20261127192514.174468-1-vitorhg20080@gmail.com>
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@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
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
next prev parent reply other threads:[~2026-11-27 19:25 UTC|newest]
Thread overview: 72+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 23:30 [PATCH RFC 00/19] riscv: Add initial support for Espressif ESP32-P4 Vítor Hugo Silva
2026-11-25 23:30 ` Vítor Hugo Silva
2026-11-25 23:30 ` [PATCH RFC 01/19] riscv: Prepare ESP32-P4 early CLIC trap vectors Vítor Hugo Silva
2026-11-25 23:30 ` Vítor Hugo Silva
2026-11-25 23:30 ` [PATCH RFC 02/19] riscv: Handle ESP32-P4 CLIC trap context Vítor Hugo Silva
2026-11-25 23:30 ` Vítor Hugo Silva
2026-11-25 23:30 ` [PATCH RFC 03/19] dt-bindings: interrupt-controller: Add Espressif ESP32-P4 CLIC Vítor Hugo Silva
2026-11-25 23:30 ` Vítor Hugo Silva
2026-11-25 23:30 ` [PATCH RFC 04/19] irqchip: Add Espressif ESP32-P4 CLIC support Vítor Hugo Silva
2026-11-25 23:30 ` Vítor Hugo Silva
2026-11-25 23:30 ` [PATCH RFC 05/19] dt-bindings: interrupt-controller: Add Espressif ESP32-P4 interrupt matrix Vítor Hugo Silva
2026-11-25 23:30 ` Vítor Hugo Silva
2026-11-25 23:30 ` [PATCH RFC 06/19] irqchip: Add Espressif ESP32-P4 interrupt matrix support Vítor Hugo Silva
2026-11-25 23:30 ` Vítor Hugo Silva
2026-11-25 23:30 ` [PATCH RFC 07/19] dt-bindings: timer: Add Espressif ESP32-P4 CLINT Vítor Hugo Silva
2026-11-25 23:30 ` Vítor Hugo Silva
2026-11-25 23:30 ` [PATCH RFC 08/19] clocksource/drivers/timer-clint: Add Espressif ESP32-P4 support Vítor Hugo Silva
2026-11-25 23:30 ` Vítor Hugo Silva
2026-11-26 23:32 ` sashiko-bot
2026-11-27 16:18 ` [PATCH RFC v2] " Vítor Hugo Silva
2026-11-27 16:18 ` Vítor Hugo Silva
2026-11-25 23:30 ` [PATCH RFC 09/19] dt-bindings: serial: Add Espressif ESP32-P4 UART Vítor Hugo Silva
2026-11-25 23:30 ` Vítor Hugo Silva
2026-11-25 23:30 ` [PATCH RFC 10/19] serial: esp32: Restore the ESP32 UART driver Vítor Hugo Silva
2026-11-25 23:30 ` Vítor Hugo Silva
2026-11-26 23:32 ` sashiko-bot
2026-11-27 16:55 ` [PATCH RFC 1/4] serial: esp32: Validate the baud rate before programming the UART Vítor Hugo Silva
2026-11-27 16:55 ` Vítor Hugo Silva
2026-11-27 16:55 ` [PATCH RFC 2/4] serial: esp32: Fix ESP32-S3 baud rate prescaler calculation Vítor Hugo Silva
2026-11-27 16:55 ` Vítor Hugo Silva
2026-11-27 16:55 ` [PATCH RFC 3/4] serial: esp32: Deliver and mask receive break interrupts Vítor Hugo Silva
2026-11-27 16:55 ` Vítor Hugo Silva
2026-11-27 16:55 ` [PATCH RFC 4/4] serial: esp32: Enable the UART clock during port registration Vítor Hugo Silva
2026-11-27 16:55 ` Vítor Hugo Silva
2026-11-27 19:25 ` [PATCH RFC 1/2] serial: esp32: Enable hardware RTS/CTS flow control Vítor Hugo Silva
2026-11-27 19:25 ` Vítor Hugo Silva
2026-11-27 19:25 ` Vítor Hugo Silva [this message]
2026-11-27 19:25 ` [PATCH RFC 2/2] serial: esp32: Report active-low CTS correctly on ESP32-S3 and ESP32-P4 Vítor Hugo Silva
2026-11-25 23:30 ` [PATCH RFC 11/19] serial: esp32: Add support for the ESP32-P4 UART Vítor Hugo Silva
2026-11-25 23:30 ` Vítor Hugo Silva
2026-11-26 23:32 ` sashiko-bot
2026-11-27 19:39 ` [PATCH RFC v2] " Vítor Hugo Silva
2026-11-27 19:39 ` Vítor Hugo Silva
2026-11-25 23:30 ` [PATCH RFC 12/19] serial: esp32: Rearm TX interrupts when the FIFO is full Vítor Hugo Silva
2026-11-25 23:30 ` Vítor Hugo Silva
2026-11-26 23:32 ` sashiko-bot
2026-11-27 15:40 ` Vítor Hugo Silva
2026-11-27 15:56 ` [PATCH RFC v2] " Vítor Hugo Silva
2026-11-27 15:56 ` Vítor Hugo Silva
2026-11-25 23:30 ` [PATCH RFC 13/19] serial: esp32: Add early console support for ESP32-P4 Vítor Hugo Silva
2026-11-25 23:30 ` Vítor Hugo Silva
2026-11-25 23:30 ` [PATCH RFC 14/19] riscv: Synchronize instructions written to ESP32-P4 PSRAM Vítor Hugo Silva
2026-11-25 23:30 ` Vítor Hugo Silva
2026-11-26 23:32 ` sashiko-bot
2026-11-27 22:13 ` [PATCH RFC v2] " Vítor Hugo Silva
2026-11-27 22:13 ` Vítor Hugo Silva
2026-11-28 22:16 ` sashiko-bot
2026-11-30 10:31 ` Vítor Hugo Silva
2026-11-30 12:23 ` [PATCH RFC v3] " Vítor Hugo Silva
2026-11-30 12:23 ` Vítor Hugo Silva
2026-12-01 12:24 ` sashiko-bot
2026-11-25 23:30 ` [PATCH RFC 15/19] riscv: Align init data to the ESP32-P4 PMP granularity Vítor Hugo Silva
2026-11-25 23:30 ` Vítor Hugo Silva
2026-11-25 23:30 ` [PATCH RFC 16/19] dt-bindings: riscv: Add Waveshare ESP32-P4-Module-DEV-KIT Vítor Hugo Silva
2026-11-25 23:30 ` Vítor Hugo Silva
2026-11-25 23:30 ` [PATCH RFC 17/19] dt-bindings: riscv: cpus: Document Espressif ESP32-P4 HP harts Vítor Hugo Silva
2026-11-25 23:30 ` Vítor Hugo Silva
2026-11-25 23:30 ` [PATCH RFC 18/19] riscv: dts: Add Waveshare ESP32-P4-Module-DEV-KIT Vítor Hugo Silva
2026-11-25 23:30 ` Vítor Hugo Silva
2026-11-25 23:30 ` [PATCH RFC 19/19] MAINTAINERS: Add the Espressif ESP32-P4 platform Vítor Hugo Silva
2026-11-25 23:30 ` Vítor Hugo Silva
2026-11-26 23:32 ` [PATCH RFC 00/19] riscv: Add initial support for Espressif ESP32-P4 sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261127192514.174468-2-vitorhg20080@gmail.com \
--to=vitorhg20080@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=jirislaby@kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=linux-serial@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.