From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.49 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795649493; b=QyMcwL8M54qWhXz2pt5pEXITgH31g0U17oI9x0azsdu/T3Es9dKttnsSliodNwAIILRf sLqYvMLroPmfqXXCSP7+os3JWHAmi1nd65aw2mfxQnYxJJT3bEc15dGNDWzrOWhokRcju dRQd5VIPlHPhxqACCPmTPFK/94Q+XE79TnIukL+KeVWwFcKbXde4IYjr4ry3zhKZcCHze 3TEUpyVdVV8EOXJH1ntfuME+ViqHHjjYlc38EyvULs5As2uyFZqV+JCMZAUI46nazixnI t63dNq0zS3LmzTD/ONo1vAE00CeuxtCuLfShRKTg9iD7/yLUvOFvmuyYThMfCo+Bw7A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795649493; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: MIME-Version:Content-Type:Content-Transfer-Encoding; bh=Cf6MiC9aLyREtPGRrWON9xR4Ztcj11+KcwsAovolrF4=; b=dkgO5krqIPc7juUs/nR9iXE4gwXBbe3x4gMQHesDb72dWD2xVr43nieEIVwyOI7rQhom CuBrFuyf2yJELzcW0dgLKFWedVXEN6NPCgchzAFwUP5LPOeuku8TcHts1sQwK6dv9SRHu hBFwnnek8fcskFUwCDXv/XrzVxfSBg0Z/vesaxbs8nZE05nMZC0dBchtZZY0i9rBlw2HJ bjZNnPG8RP2y8MKX1uMK8mUblWxFAAnTWsJN2I7DDvV+lVdYae40vizsWmVlAGkmSPU0x kgMbtGYD7FT9WUlhE74eu0V82nSz1LzT2MVpj/T0TyGB58lmuDNwRPeJ5DkUDJmcgew== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=C+vnIwqv; arc=none smtp.remote-ip=209.85.128.49 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E5747606A681 for ; Wed, 25 Nov 2026 23:31:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org E5747606A681 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=C+vnIwqv Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-4b79502c27aso63511605e9.1 for ; Wed, 25 Nov 2026 15:31:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1795649491; x=1796254291; darn=vger.kernel.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=Cf6MiC9aLyREtPGRrWON9xR4Ztcj11+KcwsAovolrF4=; b=C+vnIwqvpAaoW/uXMhp8CY0+imCU6UwOUhGFZYFg442ZvilS4WqYNnZiTKq5FyemRD bq/MfOUMDdo/cL7nlm4wBHO8XVIpxrgg1LiIol1lMm24V/zUElaT+BDyWwFATjIH+wjf PIJNQADzUk0O3+21jna9dhKOQaZGs/soErqSYaaNoC9wzTwjwbiJL9FSlA/rVHoihlbp YI7bTndzjHrRAJuxN+t2hgSVV8ghhRJ16eoHauZob198fVGLGO/HJTa4OdicdmcS9/CP bAHFcobo+Z/b0Wr1o60pOa4orUZTyhOvy19WZyotvVCcCxoMxWTvFBBQyuZJ0md4FjoK ci9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795649491; x=1796254291; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=Cf6MiC9aLyREtPGRrWON9xR4Ztcj11+KcwsAovolrF4=; b=lEPTb7sWsVAmvtJUqKCTq0DVbVH+Q+yObuUtyj7WPJb99MKegxdLFrbd5PJg70Tlmu iNlL107l98fL5UPFzPlo5jepmPHC4tVFtyb58KlXS3kSpL+vUegUaQemhbB8bckL8Gmm mgU4pXTC6q6KSDWUb+B0vlw/zkGXtKFJEBo2QsrEJ3rssEW7OGTzq4Mzj0a5Lwdc7/OC gU9CWDRCxfN2zw/xn+C99LmkMJN/rHg9dh08AFhkoQkmLYstLT5VWNJ2mnb1SchZ3LIw JL3QCyPahlLzLDdM+GAlEWFW9UbN+zMlpUDEIyWXLdr/IxFaDR34HNcklq7hDWfPV/dm H3Gg== X-Forwarded-Encrypted: i=1; AL+hErFksglT1MgpGQ7YZ7L9vAoOMWuso5quYkRDgY8kCkVRfUTyeoXtv6hNm5fFDax5W/iyDbJy2Fbs3Y0cftw=@vger.kernel.org X-Gm-Message-State: APuU4Z8E1iknEzn1I+cajc5M1qujiJSDNg1sSzf0NUFbVrgmKB2Ek7hL 0ATTnzwc9GTmExsV51SOgPLUfSS8+FWwpXHpjzka/sDHvgPVWBzKvkNW X-Gm-Gg: AZFdTZeF+/6lbTi2MeiubhsF1D1cMeUZBF+lA3WSPeAEcD80X5vTnGbK8NAJE+RW+x6 Cml2J2x9/kAVWBW6AtO86TikQizdRwC+6FfvmyGJad2l8ju2k2+rIZg8UgkOMazqUq3Dwh1rjdA C2GIdpWbmk3JmESsmSICewPu8x0awyY9YRDYVq6TPbEUjD9sKyFiePPJmew4chRSC5vWKQg1LGZ 4fr2VDg5Eq60Z0HAdXM+UpPJNJnj7OTDYmgLRQ6cQiJQZY4a4J2pNv43YKJZOXDC32J3yXE6+eP eKWVFiJ83DCSEmnYdZBERslWQItPHf3dDbaFvpTTVo04zr5qjEIXtLwCXFAQR6HMmEPE9cCzikE uQY51D5NF7VNbZ2tQdBXoG2UPphcvnNnmC1Y1OHYwVw5TFd7C+TcaXsh+VQYhxxBCwXn+EcRjmw Gl18fw95utLT+EX03d2kas+CiKjppx9fX8UAAg0C0LC2sEc42OSV+2173WtFxfErSc4PVuLechS jJuaNkYnxs1TELPOWusJrd2RaoHpSM0MAUb8OPNHH7XrO41prFd4AuQ3bZaep9wJ5Qmu64XrN/c iGw7P2OFNgzAmStWM8ZvSdPtz893m6/ddaX3L+ndsLvfMoDDoo6KobAzAlBoziXRqGVaF9uTN6Z FgUpI1HTum4NwcaTuDFjq22+tMapWiLw= X-Received: by 2002:a05:600c:3b83:b0:4b7:6b96:e431 with SMTP id 5b1f17b1804b1-4bb88822242mr450476545e9.28.1795649491157; Wed, 25 Nov 2026 15:31:31 -0800 (PST) Received: from localhost (bl20-90-91.dsl.telepac.pt. [2.81.90.91]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bb853a9687sm618034375e9.10.2026.11.25.15.31.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Nov 2026 15:31:30 -0800 (PST) From: =?UTF-8?q?V=C3=ADtor=20Hugo=20Silva?= To: linux-riscv@lists.infradead.org Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Rob Herring , Krzysztof Kozlowski , Conor Dooley , Greg Kroah-Hartman , Jiri Slaby , linux-serial@vger.kernel.org Subject: [PATCH RFC 11/19] serial: esp32: Add support for the ESP32-P4 UART Date: Wed, 25 Nov 2026 23:30:12 +0000 Message-ID: <20261125233020.1380594-12-vitorhg20080@gmail.com> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261125233020.1380594-1-vitorhg20080@gmail.com> References: <20261125233020.1380594-1-vitorhg20080@gmail.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Enable the ESP32 UART driver on ESP32-P4 and describe the SoC's register layout in the variant data. Synchronize configuration writes to the UART clock domain and keep baud rate requests within the limits of the ESP32-P4 divider. Propagate IRQ lookup errors, including deferred probe. Serialize UART port registration and removal, and clear the port table entry when registration fails or the port is removed. Keep the console setup callback available for probes after init memory is freed. Tested on a Waveshare ESP32-P4-Module-DEV-KIT with the transmit interrupt fix applied. Verified UART receive interrupts and serial console operation. AI assisted with driver development. Signed-off-by: VĂ­tor Hugo Silva --- drivers/tty/serial/Kconfig | 6 +- drivers/tty/serial/esp32_uart.c | 167 ++++++++++++++++++++++++++++---- 2 files changed, 151 insertions(+), 22 deletions(-) diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig index 83a37922fb07..6d3d3a342101 100644 --- a/drivers/tty/serial/Kconfig +++ b/drivers/tty/serial/Kconfig @@ -99,12 +99,14 @@ config SERIAL_EARLYCON_RISCV_SBI config SERIAL_ESP32 tristate "Espressif ESP32 UART support" - depends on COMPILE_TEST && OF && HAS_IOMEM + depends on OF && HAS_IOMEM + depends on RISCV_ESP32P4_CLIC || COMPILE_TEST select SERIAL_CORE select SERIAL_CORE_CONSOLE select SERIAL_EARLYCON help - Driver for the UART controllers of the Espressif ESP32xx SoCs. + Driver for the UART controllers of the Espressif ESP32xx SoCs, + including the ESP32-P4. When earlycon option is enabled the following kernel command line snippets may be used: earlycon=esp32s3uart,mmio32,0x60000000,115200n8,40000000 diff --git a/drivers/tty/serial/esp32_uart.c b/drivers/tty/serial/esp32_uart.c index 8f257cf0d290..304e1345518b 100644 --- a/drivers/tty/serial/esp32_uart.c +++ b/drivers/tty/serial/esp32_uart.c @@ -6,10 +6,13 @@ #include #include #include +#include #include #include +#include #include #include +#include #include #include #include @@ -89,6 +92,22 @@ ESP32S3_UART_SCLK_EN | \ FIELD_PREP(ESP32S3_UART_SCLK_SEL, XTAL_CLK)) +#define ESP32P4_UART_CLKDIV GENMASK(11, 0) +#define ESP32P4_UART_RXFIFO_CNT GENMASK(7, 0) +#define ESP32P4_UART_TXFIFO_CNT GENMASK(23, 16) +#define ESP32P4_UART_TXFIFO_EMPTY_THRHD_SHIFT 8 + +/* ESP32-P4 uses a dedicated register for RX flow control. */ +#define ESP32P4_UART_HWFC_CONF_REG 0x2c +#define ESP32P4_UART_RX_FLOW_EN BIT(8) +#define ESP32P4_UART_REG_UPDATE_REG 0x98 +#define ESP32P4_UART_REG_UPDATE BIT(0) +#define ESP32P4_UART_LOOPBACK BIT(12) +#define ESP32P4_UART_SW_RTS BIT(21) +#define ESP32P4_UART_SW_DTR BIT(20) +#define ESP32P4_UART_RTS_INV BIT(18) +#define ESP32P4_UART_DTR_INV BIT(19) + struct esp32_port { struct uart_port port; struct clk *clk; @@ -99,9 +118,16 @@ struct esp32_uart_variant { u32 rxfifo_cnt_mask; u32 txfifo_cnt_mask; u32 txfifo_empty_thrhd_shift; + u32 rx_flow_reg; u32 rx_flow_en; + u32 loopback_mask; + u32 sw_rts_mask; + u32 sw_dtr_reg; + u32 sw_dtr_mask; + u32 mctrl_inv_mask; const char *type; bool has_clkconf; + bool needs_reg_update; }; static const struct esp32_uart_variant esp32_variant = { @@ -109,8 +135,14 @@ static const struct esp32_uart_variant esp32_variant = { .rxfifo_cnt_mask = ESP32_UART_RXFIFO_CNT, .txfifo_cnt_mask = ESP32_UART_TXFIFO_CNT, .txfifo_empty_thrhd_shift = ESP32_UART_TXFIFO_EMPTY_THRHD_SHIFT, + .rx_flow_reg = UART_CONF1_REG, .rx_flow_en = ESP32_UART_RX_FLOW_EN, .type = "ESP32 UART", + .loopback_mask = UART_LOOPBACK, + .sw_rts_mask = UART_SW_RTS, + .sw_dtr_reg = UART_CONF0_REG, + .sw_dtr_mask = UART_SW_DTR, + .mctrl_inv_mask = UART_RTS_INV | UART_DTR_INV, }; static const struct esp32_uart_variant esp32s3_variant = { @@ -118,9 +150,31 @@ static const struct esp32_uart_variant esp32s3_variant = { .rxfifo_cnt_mask = ESP32S3_UART_RXFIFO_CNT, .txfifo_cnt_mask = ESP32S3_UART_TXFIFO_CNT, .txfifo_empty_thrhd_shift = ESP32S3_UART_TXFIFO_EMPTY_THRHD_SHIFT, + .rx_flow_reg = UART_CONF1_REG, .rx_flow_en = ESP32S3_UART_RX_FLOW_EN, .type = "ESP32S3 UART", .has_clkconf = true, + .loopback_mask = UART_LOOPBACK, + .sw_rts_mask = UART_SW_RTS, + .sw_dtr_reg = UART_CONF0_REG, + .sw_dtr_mask = UART_SW_DTR, + .mctrl_inv_mask = UART_RTS_INV | UART_DTR_INV, +}; + +static const struct esp32_uart_variant esp32p4_variant = { + .clkdiv_mask = ESP32P4_UART_CLKDIV, + .rxfifo_cnt_mask = ESP32P4_UART_RXFIFO_CNT, + .txfifo_cnt_mask = ESP32P4_UART_TXFIFO_CNT, + .txfifo_empty_thrhd_shift = ESP32P4_UART_TXFIFO_EMPTY_THRHD_SHIFT, + .rx_flow_reg = ESP32P4_UART_HWFC_CONF_REG, + .rx_flow_en = ESP32P4_UART_RX_FLOW_EN, + .type = "ESP32-P4 UART", + .needs_reg_update = true, + .loopback_mask = ESP32P4_UART_LOOPBACK, + .sw_rts_mask = ESP32P4_UART_SW_RTS, + .sw_dtr_reg = UART_CONF1_REG, + .sw_dtr_mask = ESP32P4_UART_SW_DTR, + .mctrl_inv_mask = ESP32P4_UART_RTS_INV | ESP32P4_UART_DTR_INV, }; static const struct of_device_id esp32_uart_dt_ids[] = { @@ -130,10 +184,14 @@ static const struct of_device_id esp32_uart_dt_ids[] = { }, { .compatible = "esp,esp32s3-uart", .data = &esp32s3_variant, + }, { + .compatible = "esp,esp32p4-uart", + .data = &esp32p4_variant, }, { /* sentinel */ } }; MODULE_DEVICE_TABLE(of, esp32_uart_dt_ids); +static DEFINE_MUTEX(esp32_uart_ports_lock); static struct esp32_port *esp32_uart_ports[UART_NR]; static const struct esp32_uart_variant *port_variant(struct uart_port *port) @@ -143,7 +201,24 @@ static const struct esp32_uart_variant *port_variant(struct uart_port *port) static void esp32_uart_write(struct uart_port *port, unsigned long reg, u32 v) { + void __iomem *update = port->membase + ESP32P4_UART_REG_UPDATE_REG; + u32 status; + writel(v, port->membase + reg); + + if (reg != UART_CLKDIV_REG && reg != UART_CONF0_REG && + reg != ESP32P4_UART_HWFC_CONF_REG) + return; + + if (!port_variant(port)->needs_reg_update) + return; + + /* Commit configuration to UART core clock domain. */ + writel(ESP32P4_UART_REG_UPDATE, update); + if (readl_poll_timeout_atomic(update, status, + !(status & ESP32P4_UART_REG_UPDATE), + 1, 100)) + printk_deferred_once(DRIVER_NAME ": UART register update timed out\n"); } static u32 esp32_uart_read(struct uart_port *port, unsigned long reg) @@ -173,18 +248,29 @@ static unsigned int esp32_uart_tx_empty(struct uart_port *port) static void esp32_uart_set_mctrl(struct uart_port *port, unsigned int mctrl) { - u32 conf0 = esp32_uart_read(port, UART_CONF0_REG); + const struct esp32_uart_variant *variant = port_variant(port); + bool dtr_in_conf0 = variant->sw_dtr_reg == UART_CONF0_REG; + u32 conf0, dtr_conf; - conf0 &= ~(UART_LOOPBACK | - UART_SW_RTS | UART_RTS_INV | - UART_SW_DTR | UART_DTR_INV); + conf0 = esp32_uart_read(port, UART_CONF0_REG); + conf0 &= ~(variant->loopback_mask | variant->sw_rts_mask); if (mctrl & TIOCM_RTS) - conf0 |= UART_SW_RTS; - if (mctrl & TIOCM_DTR) - conf0 |= UART_SW_DTR; + conf0 |= variant->sw_rts_mask; if (mctrl & TIOCM_LOOP) - conf0 |= UART_LOOPBACK; + conf0 |= variant->loopback_mask; + + /* Software DTR and RTS/DTR inversion share a register. */ + dtr_conf = dtr_in_conf0 ? conf0 : esp32_uart_read(port, variant->sw_dtr_reg); + dtr_conf &= ~(variant->sw_dtr_mask | variant->mctrl_inv_mask); + + if (mctrl & TIOCM_DTR) + dtr_conf |= variant->sw_dtr_mask; + + if (dtr_in_conf0) + conf0 = dtr_conf; + else + esp32_uart_write(port, variant->sw_dtr_reg, dtr_conf); esp32_uart_write(port, UART_CONF0_REG, conf0); } @@ -387,13 +473,37 @@ static bool esp32_uart_set_baud(struct uart_port *port, u32 baud) return false; } +static void esp32p4_uart_limit_baud_rate(struct ktermios *termios, + const struct ktermios *old, + u32 min_baud, u32 max_baud) +{ + u32 baud = tty_termios_baud_rate(termios); + + if (!baud || (baud >= min_baud && baud <= max_baud)) + return; + + if (old) { + u32 old_baud = tty_termios_baud_rate(old); + + if (old_baud && old_baud >= min_baud && old_baud <= max_baud) + baud = old_baud; + } + + baud = clamp(baud, min_baud, max_baud); + /* Keep the fallback exact near a standard rate outside the range. */ + termios->c_cflag &= ~(CBAUD | (CBAUD << IBSHIFT)); + termios->c_cflag |= BOTHER; + tty_termios_encode_baud_rate(termios, baud, baud); +} + static void esp32_uart_set_termios(struct uart_port *port, struct ktermios *termios, const struct ktermios *old) { unsigned long flags; - u32 conf0, conf1; - u32 baud; + u32 conf0, flow; + u32 baud, min_baud, max_baud; + const u32 rx_flow_reg = port_variant(port)->rx_flow_reg; const u32 rx_flow_en = port_variant(port)->rx_flow_en; u32 max_div = port_variant(port)->clkdiv_mask; @@ -402,17 +512,19 @@ static void esp32_uart_set_termios(struct uart_port *port, if (port_variant(port)->has_clkconf) max_div *= FIELD_MAX(ESP32S3_UART_SCLK_DIV_NUM); - baud = uart_get_baud_rate(port, termios, old, - port->uartclk / max_div, - port->uartclk / 16); + min_baud = port->uartclk / max_div; + max_baud = port->uartclk / 16; + if (port_variant(port) == &esp32p4_variant) + esp32p4_uart_limit_baud_rate(termios, old, min_baud, max_baud); + baud = uart_get_baud_rate(port, termios, old, min_baud, max_baud); spin_lock_irqsave(&port->lock, flags); conf0 = esp32_uart_read(port, UART_CONF0_REG); conf0 &= ~(UART_PARITY_EN | UART_PARITY | UART_BIT_NUM | UART_STOP_BIT_NUM); - conf1 = esp32_uart_read(port, UART_CONF1_REG); - conf1 &= ~rx_flow_en; + flow = esp32_uart_read(port, rx_flow_reg); + flow &= ~rx_flow_en; if (termios->c_cflag & PARENB) { conf0 |= UART_PARITY_EN; @@ -441,10 +553,10 @@ static void esp32_uart_set_termios(struct uart_port *port, conf0 |= FIELD_PREP(UART_STOP_BIT_NUM, UART_STOP_BIT_NUM_1); if (termios->c_cflag & CRTSCTS) - conf1 |= rx_flow_en; + flow |= rx_flow_en; esp32_uart_write(port, UART_CONF0_REG, conf0); - esp32_uart_write(port, UART_CONF1_REG, conf1); + esp32_uart_write(port, rx_flow_reg, flow); if (baud) { esp32_uart_set_baud(port, baud); @@ -715,29 +827,44 @@ static int esp32_uart_probe(struct platform_device *pdev) if (IS_ERR(sport->clk)) return PTR_ERR(sport->clk); + ret = platform_get_irq(pdev, 0); + if (ret < 0) + return ret; + port->uartclk = clk_get_rate(sport->clk); port->dev = &pdev->dev; port->type = PORT_GENERIC; port->iotype = UPIO_MEM; - port->irq = platform_get_irq(pdev, 0); + port->irq = ret; port->ops = &esp32_uart_pops; port->flags = UPF_BOOT_AUTOCONF; port->has_sysrq = 1; port->fifosize = ESP32_UART_TX_FIFO_SIZE; port->private_data = (void *)device_get_match_data(&pdev->dev); + guard(mutex)(&esp32_uart_ports_lock); + if (esp32_uart_ports[port->line]) + return -EBUSY; + + /* Console setup can look up the port during registration. */ esp32_uart_ports[port->line] = sport; + ret = uart_add_one_port(&esp32_uart_reg, port); + if (ret) { + esp32_uart_ports[port->line] = NULL; + return ret; + } platform_set_drvdata(pdev, port); - - return uart_add_one_port(&esp32_uart_reg, port); + return 0; } static void esp32_uart_remove(struct platform_device *pdev) { struct uart_port *port = platform_get_drvdata(pdev); + guard(mutex)(&esp32_uart_ports_lock); uart_remove_one_port(&esp32_uart_reg, port); + esp32_uart_ports[port->line] = NULL; } -- 2.56.1