From patchwork Sun Oct 19 07:23:01 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 625 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1760858622; bh=dE/WtxhirVUr7Kyel6xOz9FG7ZlFV7mtz4p+ZgvdCY0=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=gtTEiDJANHvXb7n/xBfCBzFT6u2b69H9LXEXigL2xKoA9p0IaWunyno/RReot49Ok xn4t+GxVTSL4q8q3Z1XLfqSJ6fardXerOSZPSXEMrumERchA1vasMNpIkY7pOQx9z5 4Co9H5cWDPTn2gRC+02INt9EB5kkJIfJNM+AizTqakB0Lr0n0nucz9U2WqKhGoP6Sm edIiKRFEz8EzJN3onvsjX5cD6qnKenn+2H6Tkxf3sr/e4FuwT0z+2DB7SFhgd+Ro4I Y4mY96gEH+KijXLT6x6ebpwhPgvakHF5jpp+tHF8Y0URQDBxrvUlewcM4eyB4ROXsU Yo6Gq/kbV3iEA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id EEDAA681AD for ; Sun, 19 Oct 2025 01:23:42 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id r-Iw9jRB81Od for ; Sun, 19 Oct 2025 01:23:42 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1760858622; bh=dE/WtxhirVUr7Kyel6xOz9FG7ZlFV7mtz4p+ZgvdCY0=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=gtTEiDJANHvXb7n/xBfCBzFT6u2b69H9LXEXigL2xKoA9p0IaWunyno/RReot49Ok xn4t+GxVTSL4q8q3Z1XLfqSJ6fardXerOSZPSXEMrumERchA1vasMNpIkY7pOQx9z5 4Co9H5cWDPTn2gRC+02INt9EB5kkJIfJNM+AizTqakB0Lr0n0nucz9U2WqKhGoP6Sm edIiKRFEz8EzJN3onvsjX5cD6qnKenn+2H6Tkxf3sr/e4FuwT0z+2DB7SFhgd+Ro4I Y4mY96gEH+KijXLT6x6ebpwhPgvakHF5jpp+tHF8Y0URQDBxrvUlewcM4eyB4ROXsU Yo6Gq/kbV3iEA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id DD92068105 for ; Sun, 19 Oct 2025 01:23:42 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1760858620; bh=kbTIM8HH+1rrReKPEEpgUIQoT+0aRq75yfLCK1JD8VI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tsXTOEIGtVPutBOWd9PSQqcFwxc08Y2PlM9GgPoRwcWON8sLPokV1a90dUW5/EULj 7T0JVlkb0gRP6zDsTP/NYI7O0r4zO23b9SYQxSUeRj9L3NCeHrW4REZbPxAUMIkMVn /rgj0YhYl0KWUhY4nuiuyk6iLSNL2sb1W4u2FO5Bb2GuDyUbQVSdKHcHUixf6GN8y6 +R91V2g8CIP+LgFg32w2TB/bBxW0LQi6QRAqEAFx3VRJhYcqbQA4qn0P/alem+Cp4O HFs7YN219j9WsOQGe3ycOye2d0O4O7HvN5ozPhBq4kJKj21P9t9nGTnz7e0nvWL/MX mHNLMKhIiCgLA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 91ADE5E435; Sun, 19 Oct 2025 01:23:40 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id MVyeeNLxbdxJ; Sun, 19 Oct 2025 01:23:40 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1760858616; bh=LH9nXvkMXlFYLEueUce752hM6Oq29yquDV8dq1Ia5IQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wg/k/mw92Q5m+BYkf5LmwlFDX/QVqNOraM++5juAzLT6F/u5u78g+JvGRc1vZPlH0 VIFI9HplXwqnfddkp0YLRwO43rw1ODYI2glv1PEflrxwH61caXSsN+32MkGGTt9y6d LSX59w7eIfil+t/DKZk/3ryEExbw/zgfmYzZOEE96Fs3PTcPsEeMuI8/J8pm7w8tKg 5gWUBq64lAfwgh6CkFyv9l6El6uzPPLTYI4BhH7eMz7wN4Cq+tNKtJvSNk+vLbte27 pGf2fSR55OfsLtiM1+bKAyKNxDbH0h01KyTK8drwE3gvvVO7I3BXnjZyOMx8k5aAOK Qzz+eG/VFNiTA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 42CED68170; Sun, 19 Oct 2025 01:23:36 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Sun, 19 Oct 2025 01:23:01 -0600 Message-ID: <20251019072313.3235339-2-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251019072313.3235339-1-sjg@u-boot.org> References: <20251019072313.3235339-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: PAZQNSGUSUQ4XQCL72KBVOIE36GCCPZV X-Message-ID-Hash: PAZQNSGUSUQ4XQCL72KBVOIE36GCCPZV X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass , Claude X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 1/8] serial: ns16550: Add skip-init devicetree property List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Add support for a 'skip-init' property in the device tree that preserves UART settings from a previous boot phase. This is useful when the UART is already configured by firmware (e.g., EFI firmware on x86 platforms) and changing the settings would disrupt console output or cause communication issues. Co-developed-by: Claude Signed-off-by: Simon Glass --- drivers/serial/ns16550.c | 12 +++++++++++- include/ns16550.h | 2 ++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/drivers/serial/ns16550.c b/drivers/serial/ns16550.c index 5126cf8bc1a..1f0d1c894cb 100644 --- a/drivers/serial/ns16550.c +++ b/drivers/serial/ns16550.c @@ -426,6 +426,9 @@ static int ns16550_serial_setbrg(struct udevice *dev, int baudrate) struct ns16550_plat *plat = com_port->plat; int clock_divisor; + if (plat->skip_init) + return 0; + clock_divisor = ns16550_calc_divisor(com_port, plat->clock, baudrate); ns16550_setbrg(com_port, clock_divisor); @@ -436,11 +439,15 @@ static int ns16550_serial_setbrg(struct udevice *dev, int baudrate) static int ns16550_serial_setconfig(struct udevice *dev, uint serial_config) { struct ns16550 *const com_port = dev_get_priv(dev); + struct ns16550_plat *plat = com_port->plat; int lcr_val = UART_LCR_WLS_8; uint parity = SERIAL_GET_PARITY(serial_config); uint bits = SERIAL_GET_BITS(serial_config); uint stop = SERIAL_GET_STOP(serial_config); + if (plat->skip_init) + return 0; + /* * only parity config is implemented, check if other serial settings * are the default one. @@ -533,7 +540,8 @@ int ns16550_serial_probe(struct udevice *dev) reset_deassert_bulk(&reset_bulk); com_port->plat = dev_get_plat(dev); - ns16550_init(com_port, -1); + if (!plat->skip_init) + ns16550_init(com_port, -1); return 0; } @@ -589,6 +597,8 @@ int ns16550_serial_of_to_plat(struct udevice *dev) if (port_type == PORT_JZ4780) plat->fcr |= UART_FCR_UME; + plat->skip_init = dev_read_bool(dev, "skip-init"); + return 0; } #endif diff --git a/include/ns16550.h b/include/ns16550.h index 7f481300083..787680853c7 100644 --- a/include/ns16550.h +++ b/include/ns16550.h @@ -66,6 +66,7 @@ enum ns16550_flags { * @fcr: Offset of FCR register (normally UART_FCR_DEFVAL) * @flags: A few flags (enum ns16550_flags) * @bdf: PCI slot/function (pci_dev_t) + * @skip_init: Skip UART initialization (preserve existing settings) */ struct ns16550_plat { ulong base; @@ -79,6 +80,7 @@ struct ns16550_plat { #if defined(CONFIG_PCI) && defined(CONFIG_SPL) int bdf; #endif + bool skip_init; }; struct udevice;