From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C97AAC43334 for ; Thu, 23 Jun 2022 12:14:11 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 018488425A; Thu, 23 Jun 2022 14:14:08 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="acf9VDjd"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 38B6F84334; Thu, 23 Jun 2022 14:14:07 +0200 (CEST) Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id BDC278425A for ; Thu, 23 Jun 2022 14:14:04 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=pali@kernel.org Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 48BA6B82327; Thu, 23 Jun 2022 12:14:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C9098C3411B; Thu, 23 Jun 2022 12:14:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1655986443; bh=eySXlZFRt5Pv1un5kI9ZmZyGZHoTazSIMMbaNL4z1QE=; h=From:To:Cc:Subject:Date:From; b=acf9VDjd3DTJ8Ir6qIlQ93v4H23RKisM4FrgbvB6KPT8IWMP9+ckauB6P5cNFEiP1 opimhd1FMdM1BOX9t9DzqzxYtkTHgulFAXp+PGEZd3xphD/4i8KM8vDQkgB+xc9yZv +TLorMR1lzbOPydU5Wruj6W5oyM0x7IHggPE6oRXLwYQN174/bHJ+1TRTz/CbbwGug o+c6cy9LWH9eHHrh+ivQDzngROwSAUvLekFX+5Ljfy0SUEhoUFzhp5wK7ZKWxSARl5 c3FwwY4Uu03zO6mP6s3MZqJmOYAuXFat7G7zkoTikYlIXSu6OhmWuX83uZ2G1eja4r QahPTvbxSnEnw== Received: by pali.im (Postfix) id B53B579F; Thu, 23 Jun 2022 14:13:59 +0200 (CEST) From: =?UTF-8?q?Pali=20Roh=C3=A1r?= To: Stefan Roese , Simon Glass Cc: u-boot@lists.denx.de, =?UTF-8?q?Marek=20Beh=C3=BAn?= Subject: [PATCH] serial: ns16550: Wait in debug_uart_init until tx buffer is empty Date: Thu, 23 Jun 2022 14:13:56 +0200 Message-Id: <20220623121356.4149-1-pali@kernel.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean Commit d293759d55cc ("serial: ns16550: Add support for SPL_DEBUG_UART_BASE") fixed support for setting correct early debug UART base address in SPL. But after this commit, output from Marvell A385 BootROM is truncated or lost and not fully present on serial console. Debugging this issue showed that BootROM just put bytes into UART HW output buffer and does not wait until UART HW transmit all characters. U-Boot ns16550 early debug is initialized very early and during its initialization is resetting UART HW and flushing remaining transmit buffer (which still contains BootROM output). Fix this issue by waiting in init function prior resetting UART HW until TxEmpty bit in UART Line Status Register is set. TxEmpty is set when all remaining bytes from HW buffer are transmitted. Signed-off-by: Pali Rohár --- drivers/serial/ns16550.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/serial/ns16550.c b/drivers/serial/ns16550.c index 78bfe6281ce3..13418004e2b0 100644 --- a/drivers/serial/ns16550.c +++ b/drivers/serial/ns16550.c @@ -328,6 +328,8 @@ static inline void _debug_uart_init(void) struct ns16550 *com_port = (struct ns16550 *)CONFIG_VAL(DEBUG_UART_BASE); int baud_divisor; + while (!(serial_din(&com_port->lsr) & UART_LSR_TEMT)); + /* * We copy the code from above because it is already horribly messy. * Trying to refactor to nicely remove the duplication doesn't seem -- 2.20.1