From patchwork Thu Jan 12 17:19:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Loic Poulain X-Patchwork-Id: 641659 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp3922596pvb; Thu, 12 Jan 2023 09:20:07 -0800 (PST) X-Google-Smtp-Source: AMrXdXseHYUjH2aeHYseTLVgUrZ0v0s6pgtiokkQg/etkRVy1q78hHAKID74SHvs/ud9njDsLXhA X-Received: by 2002:a05:6871:714:b0:14e:ab8c:8735 with SMTP id f20-20020a056871071400b0014eab8c8735mr42359140oap.57.1673544007360; Thu, 12 Jan 2023 09:20:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673544007; cv=none; d=google.com; s=arc-20160816; b=qLO1Z9PiGeYWwkEkhjcwSz+/CmZOmQTxu+FUad46aGhEGP0Xcbi7q/uHl205RSOmOv xVapTjJognOuBCgwOzPdX9lVrFgAGiDSZILt6fqvmjc6y6wZPADk91nMNfvuqna4A7hc 979xmJ4AIw5smo8M7f9+OgJdIkUjaRuNoXbmWY1G78OwBjhPbNXbYZPWxIiQwE0ohOaD /PPNuENSz65dgm2UOgHmBh9VxJ34eH1H6cHJnIYCl2w4/Lc8MgnosMDvaNBKmCdFB7/1 SiEPyFyteljgMOe0hOnuNXEv89IlR79WV8Ir5b11xqVXt6OelOHfl4IfRAUs9Gg5HmRd PaxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=s7Hoqt1yXp4PA0KllLzPGORud1CasT7A1SWxValNQxY=; b=VJqaJQbKOneqd2sZkskXFPpafbGPGsaiIUGa357Er2RI9+ucFKCwfsRXqZUOKKdIUt D0RCl/hCPG6aobANVqQAn1DgPhPrBuCMdHslhr2ft5kbwj4XPxF3Gt0ZBl1SLKMXD+qX MmP4K25nIYbcGqaqo3OBjKwc9dTPxf0f/l1uMu4vKyzvFo5/64zQCuYS/qkZ6P4Ca9BM SKQwUciQUR1QXgECEseiR/Kj87gbajj9RAJf/mJMHVXhpMImLC6JS5tTzh33HrSAxBfL gn1EB8papxOG1fwKmA6lyOmEoGUzYO77xqWDxNRFMora0Q8qnpYriKVZOO5GM/Gd2sPZ x1Tw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=l4rTNINE; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id i15-20020a056870a68f00b00131f4c4abf5si16310096oam.58.2023.01.12.09.20.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Jan 2023 09:20:07 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=l4rTNINE; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id BF0AD852B6; Thu, 12 Jan 2023 18:20:00 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.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=linaro.org header.i=@linaro.org header.b="l4rTNINE"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8A5DD85368; Thu, 12 Jan 2023 18:19:59 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id C46FA85023 for ; Thu, 12 Jan 2023 18:19:56 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=loic.poulain@linaro.org Received: by mail-wm1-x32d.google.com with SMTP id j34-20020a05600c1c2200b003da1b054057so1379022wms.5 for ; Thu, 12 Jan 2023 09:19:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=s7Hoqt1yXp4PA0KllLzPGORud1CasT7A1SWxValNQxY=; b=l4rTNINEUaGRgAMmEO2B8oMlOYOkoWYCWX+/es4nYmEAbM/GaZQ+zsFIS8C2oz60zj KgpG5vKmWr/hJRLvwr8aZzkIwdJypzpik8jopNTrsiLSrW03Ae+4ErmOTlb17j5EJR9C h0o7rnAYfe0NgRV3t1VqR/8sNuoH7HkboEW7Ev73QlTrfRMmvPX8ogXUzBESJmWBYsHn kvgnSpXi50hKyTOG6VgyQcvpoHj1P+QFLI0XhbbvV0cejlf5hSOJIcdSMt2PVn/0PBb+ YF6TET+o7D29NtgaqGfdSH/yHdwxH8bDV5VUFjNVxZelH5Z/963CA6pMQUG9wcUOnaZ1 W+Ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=s7Hoqt1yXp4PA0KllLzPGORud1CasT7A1SWxValNQxY=; b=SD7NzMavR32aygYIUWIXxRvAvjlXsZ8xr9F3bZQ5lGBLdY1ucGYpfhB8C30ix51Q7w SwpXlVudWFArIYMKOoZzlfZKmXJg9bOzdBVBL7WoJj7YEg7RVADE2H7tTu/fEhHtsEpI H+V9mZY4b8MWqzkxf5lIQDuEQByxajdJpeqlb3civZENCDIkZHlzrqg8xen9vcRtCG60 8XTz0msks3Mj9ahcNx+BbPVuOd3UofkJfKA2aAA+Nd/sgPBCoEIZlTdrKXgnU+1FrH// aZsLLw87tGt8/Ub3GWsOgTJUaUi+HLLQjUsUcM6KMOdejpkdqgscxC+WSn3w/id02tKx ni/A== X-Gm-Message-State: AFqh2kraPSkJP1d1rUw6+PNaOf4PJpePkA2NbzIF5bYOnAZpiNyZBddf 7dza6USEUuwtGpTgRkNEMjt7tA== X-Received: by 2002:a05:600c:3550:b0:3d9:ed30:6a73 with SMTP id i16-20020a05600c355000b003d9ed306a73mr13144345wmq.9.1673543996199; Thu, 12 Jan 2023 09:19:56 -0800 (PST) Received: from loic-ThinkPad-T470p.. ([2a01:e0a:82c:5f0:1fa1:5990:937b:e8c8]) by smtp.gmail.com with ESMTPSA id o15-20020a5d62cf000000b002bbedd60a9asm11231267wrv.77.2023.01.12.09.19.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Jan 2023 09:19:55 -0800 (PST) From: Loic Poulain To: sbabic@denx.de, festevam@gmail.com Cc: uboot-imx@nxp.com, u-boot@lists.denx.de, LW@karo-electronics.de, pali@kernel.org, Loic Poulain , =?utf-8?q?Lothar_W?= =?utf-8?q?a=C3=9Fmann?= Subject: [PATCH v4 1/2] serial: mxc: Wait for TX completion before reset Date: Thu, 12 Jan 2023 18:19:50 +0100 Message-Id: <20230112171951.2082899-1-loic.poulain@linaro.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 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 The u-boot console may show some corrupted characters when printing in board_init() due to reset or baudrate change of the UART (probe) before the TX FIFO has been completely drained. To fix this issue, and in case UART is still running, we now try to flush the FIFO before proceeding to UART reinitialization. For this we're waiting for Transmitter Complete bit, indicating that the FIFO and the shift register are empty. flushing has a 4ms timeout guard, which is normally more than enough to consume the FIFO @ low baudrate (9600bps). Signed-off-by: Loic Poulain Tested-by: Lothar Waßmann Acked-by: Pali Rohár Reviewed-by: Fabio Estevam ---  v2: Add this commit to the series v3: Fix typo & reordering commits for good bisectabilit v4: Wait for transfer completion before baudrate change as well drivers/serial/serial_mxc.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/drivers/serial/serial_mxc.c b/drivers/serial/serial_mxc.c index 82c0d84628..9e5b987994 100644 --- a/drivers/serial/serial_mxc.c +++ b/drivers/serial/serial_mxc.c @@ -13,6 +13,7 @@ #include #include #include +#include /* UART Control Register Bit Fields.*/ #define URXD_CHARRDY (1<<15) @@ -144,8 +145,22 @@ struct mxc_uart { u32 ts; }; +static void _mxc_serial_flush(struct mxc_uart *base) +{ + unsigned int timeout = 4000; + + if (!(readl(&base->cr1) & UCR1_UARTEN) || + !(readl(&base->cr2) & UCR2_TXEN)) + return; + + while (!(readl(&base->sr2) & USR2_TXDC) && --timeout) + udelay(1); +} + static void _mxc_serial_init(struct mxc_uart *base, int use_dte) { + _mxc_serial_flush(base); + writel(0, &base->cr1); writel(0, &base->cr2); @@ -169,6 +184,8 @@ static void _mxc_serial_setbrg(struct mxc_uart *base, unsigned long clk, { u32 tmp; + _mxc_serial_flush(base); + tmp = RFDIV << UFCR_RFDIV_SHF; if (use_dte) tmp |= UFCR_DCEDTE; @@ -252,10 +269,17 @@ static int mxc_serial_init(void) return 0; } +static int mxc_serial_stop(void) +{ + _mxc_serial_flush(mxc_base); + + return 0; +} + static struct serial_device mxc_serial_drv = { .name = "mxc_serial", .start = mxc_serial_init, - .stop = NULL, + .stop = mxc_serial_stop, .setbrg = mxc_serial_setbrg, .putc = mxc_serial_putc, .puts = default_serial_puts, From patchwork Thu Jan 12 17:19:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Loic Poulain X-Patchwork-Id: 641660 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp3922844pvb; Thu, 12 Jan 2023 09:20:35 -0800 (PST) X-Google-Smtp-Source: AMrXdXvMS85l9usZ3qYq/hg9UmNsKFzEdV99Vp9lIKW65ZEvL+55CEzr/XwXsvFHU4fnx7c0ihHH X-Received: by 2002:a05:6870:e285:b0:15e:cfce:fcb9 with SMTP id v5-20020a056870e28500b0015ecfcefcb9mr641437oad.34.1673544035706; Thu, 12 Jan 2023 09:20:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673544035; cv=none; d=google.com; s=arc-20160816; b=wOBmNL3f3vaTt/PE3SGCQvUMyMEbGXXWjmRTjAeFP2gdLQSoRJjAQCCh1Hnlzau8gQ W4Y5T0tVy4IEYUQMZscfFQSHnGSLGvawlafgW7L+8Jl9hnjP1bFGy277b17vnBKUWkcN BD9YV5VrQYSdctT5XxjoW40XhKboCIafr3syvRpnv5s3O2u1WQLZwp7RE74MMY+7H9Kp CjGLzoAzXL6ghm5hzFxDw0eyUcHntJP3yAniblJ7f5pVRs3Q1wKFY3tMk77g3u8zM+zb 11UBpd4F6DPs4MUhC56fy76IyXHxrtIEn9nHpd6vbSu95+16jjVIjw5rdyNfYeZTYKg7 Byyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=jJZkP2bW7gM15V8Jc7Vwfcb7IM3EYogwbvmj37hGnI0=; b=NfS0Rt/keb8qyKbbCtEdD/K8yLCQVokgm5Fuqc0Q9EW0bvwh5Nkqvt1i1sIPjoGOnN FaKQytP6JKQ50yslcryOWDRbnUI6Kc8P8u75+TYPFrBCsw9ZQYp3szaYoFrTX1T32aQW +81dhYUs6gw1HSCltn1SH1JboMS97LhbcII5wgyF+E2+mOeLmwpbtlBBYRyOoAl5gSpE JLVJPl6y/dFpTjiIANF2+ANJs/bv3whKiphWKaeizl2a/9Twgplz4Dc1kumgmlC03Hhw Wf2YPwyuJLDxLJ9jTFe3O4u4Kv9YCAvtjgGDqIWSw11p1bXu8qu/QAWo05LEnR4mVWvX CZ+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZfJnsx5s; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id j30-20020a056870169e00b0015ea0c8960csi5034008oae.38.2023.01.12.09.20.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Jan 2023 09:20:35 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZfJnsx5s; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id F2C3B852E9; Thu, 12 Jan 2023 18:20:13 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.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=linaro.org header.i=@linaro.org header.b="ZfJnsx5s"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2BB8285408; Thu, 12 Jan 2023 18:20:04 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 5EEBF852E9 for ; Thu, 12 Jan 2023 18:19:58 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=loic.poulain@linaro.org Received: by mail-wm1-x32c.google.com with SMTP id j16-20020a05600c1c1000b003d9ef8c274bso11308672wms.0 for ; Thu, 12 Jan 2023 09:19:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=jJZkP2bW7gM15V8Jc7Vwfcb7IM3EYogwbvmj37hGnI0=; b=ZfJnsx5sB/zwjZevkhrj2cjCjDB0W/SlCJBZVwl1n0D8hKK40g2hvn/XAcW6MKNnu6 nOrCxp3qxYenV04fRZpgbK6SlY1suK+ZK90AXJoucqPfN3EgskPaNwrn7c6Q0zqNfGAg VzfLiK7+BrjWIM7PYab1v7n2C4fePyaRIFMakASusEPdy1DR+klrnxjBYppvqNUmqXJ6 wKK8irkN/U7z6kM10mBWvwcB0+uGAGmnRppsueqg5OcXrQYEj+cYzA+RUhla6y7ZNmH/ N+0FG8T2PYWcXYps3q4ZCGH1GlwxIF3tJqVppANym4LN37oIKrMdepMnY+QviYI4Ha5h airQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jJZkP2bW7gM15V8Jc7Vwfcb7IM3EYogwbvmj37hGnI0=; b=RN0JFuBsaOfNZQ1vfOwj3bz6RJzyUOndTrFiswNIszyRkZHY9963znuL67knKfKwQm H8XU9GPvdCtXziScsXUPAnurTUWdR9goRl77L9ec86RzETnVT0tv7NhnmKWbNXJYWXNo n5lpfIZqYkk5DMzBNl7HtLhaYvaFhj/DQk/87qxoBRs5j6Wn7+CRwmIrMe4iuEwcUMWi FfpVyEBcxZH8vyezPIvcFWbdC6frrhVGSDjmZSsSmmmQFqxy/JzIMvJOeofwyVrq0gmD dGglYOTXL8PsgXCXyG6SSB6zzFCn/uV4Pk1tY8lQIgxYpu0KBgqfhkdRZe9opzKgDP1U Re2Q== X-Gm-Message-State: AFqh2ko6Ln4C1cXLstQiOkiRBkwADTHjzskW6v7JHBxLVkB59lEgqY7T Kqlsy23VmXnioxbePbRVsEVNag== X-Received: by 2002:a1c:770b:0:b0:3cf:a18d:399c with SMTP id t11-20020a1c770b000000b003cfa18d399cmr58316804wmi.1.1673543997881; Thu, 12 Jan 2023 09:19:57 -0800 (PST) Received: from loic-ThinkPad-T470p.. ([2a01:e0a:82c:5f0:1fa1:5990:937b:e8c8]) by smtp.gmail.com with ESMTPSA id o15-20020a5d62cf000000b002bbedd60a9asm11231267wrv.77.2023.01.12.09.19.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Jan 2023 09:19:57 -0800 (PST) From: Loic Poulain To: sbabic@denx.de, festevam@gmail.com Cc: uboot-imx@nxp.com, u-boot@lists.denx.de, LW@karo-electronics.de, pali@kernel.org, Loic Poulain , =?utf-8?q?Lothar_W?= =?utf-8?q?a=C3=9Fmann?= Subject: [PATCH v4 2/2] serial: mxc: Speed-up character transmission Date: Thu, 12 Jan 2023 18:19:51 +0100 Message-Id: <20230112171951.2082899-2-loic.poulain@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230112171951.2082899-1-loic.poulain@linaro.org> References: <20230112171951.2082899-1-loic.poulain@linaro.org> MIME-Version: 1.0 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 Instead of waiting for empty FIFO condition before writing a character, wait for non-full FIFO condition. This helps in saving several tens of milliseconds during boot (depending verbosity). Signed-off-by: Loic Poulain Tested-by: Lothar Waßmann Acked-by: Pali Rohár Reviewed-by: Fabio Estevam Tested-by: Fabio Estevam --- v2: fixing transfert abort & char corruption commit v3: Reordering commits for good bisectability v4: no code change drivers/serial/serial_mxc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/serial/serial_mxc.c b/drivers/serial/serial_mxc.c index 9e5b987994..cac1922354 100644 --- a/drivers/serial/serial_mxc.c +++ b/drivers/serial/serial_mxc.c @@ -240,11 +240,11 @@ static void mxc_serial_putc(const char c) if (c == '\n') serial_putc('\r'); - writel(c, &mxc_base->txd); - /* wait for transmitter to be ready */ - while (!(readl(&mxc_base->ts) & UTS_TXEMPTY)) + while (readl(&mxc_base->ts) & UTS_TXFULL) schedule(); + + writel(c, &mxc_base->txd); } /* Test whether a character is in the RX buffer */ @@ -335,7 +335,7 @@ static int mxc_serial_putc(struct udevice *dev, const char ch) struct mxc_serial_plat *plat = dev_get_plat(dev); struct mxc_uart *const uart = plat->reg; - if (!(readl(&uart->ts) & UTS_TXEMPTY)) + if (readl(&uart->ts) & UTS_TXFULL) return -EAGAIN; writel(ch, &uart->txd);