[PATCH RFC 4/4] serial: esp32: Enable the UART clock during port registration

Vítor Hugo Silva vitorhg20080 at gmail.com
Fri Nov 27 08:55:52 PST 2026


uart_add_one_port() can invoke the modem control callbacks before
the console setup or startup callback enables the UART clock. Keep
the clock enabled across registration so those callbacks can
access the registers. Release the probe's clock reference after
registration, including when it fails.

Serial console registration and operation were tested on the
Waveshare ESP32-P4-Module-DEV-KIT.

Signed-off-by: Vítor Hugo Silva <vitorhg20080 at gmail.com>
---
 drivers/tty/serial/esp32_uart.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/tty/serial/esp32_uart.c b/drivers/tty/serial/esp32_uart.c
index 40acff7..cd68478 100644
--- a/drivers/tty/serial/esp32_uart.c
+++ b/drivers/tty/serial/esp32_uart.c
@@ -856,9 +856,15 @@ static int esp32_uart_probe(struct platform_device *pdev)
 	if (esp32_uart_ports[port->line])
 		return -EBUSY;
 
+	/* Serial core accesses modem control registers during registration. */
+	ret = clk_prepare_enable(sport->clk);
+	if (ret)
+		return ret;
+
 	/* Console setup can look up the port during registration. */
 	esp32_uart_ports[port->line] = sport;
 	ret = uart_add_one_port(&esp32_uart_reg, port);
+	clk_disable_unprepare(sport->clk);
 	if (ret) {
 		esp32_uart_ports[port->line] = NULL;
 		return ret;



More information about the linux-riscv mailing list