public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH v2] serial: mxc: Keep the original FIFO empty check
@ 2022-10-25 22:56 Fabio Estevam
  2022-10-25 23:23 ` Tim Harvey
  0 siblings, 1 reply; 4+ messages in thread
From: Fabio Estevam @ 2022-10-25 22:56 UTC (permalink / raw)
  To: sbabic
  Cc: uboot-imx, johannes.schneider, u-boot, pali, Fabio Estevam,
	Tim Harvey

From: Fabio Estevam <festevam@denx.de>

Tim Harvey reported that since commit c7878a0483c5 ("serial: mxc:
have putc use the TXFIFO"), console messages put inside board_init()
are no longer printed correctly.

This change added a check to handle the UART FIFO full condition and
removed the UART FIFO empty check, which causes the problem.

To avoid console corruption, add back the original UART FIFO empty
check so that when the FIFO is empty, mxc_serial_putc() returns -EAGAIN
to the core serial-uclass.c.

This way the serial core can properly handle the UART empty condition 
by not doing character transmission when -EAGAIN is returned.

Fixes: c7878a0483c5 ("serial: mxc: have putc use the TXFIFO")
Reported-by: Tim Harvey <tharvey@gateworks.com>
Signed-off-by: Fabio Estevam <festevam@denx.de>
---
Changes since v1:
- Add the check for FIFO full and FIFO empty.

 drivers/serial/serial_mxc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/serial/serial_mxc.c b/drivers/serial/serial_mxc.c
index 4cf79c1ca24f..d3fbe76065ec 100644
--- a/drivers/serial/serial_mxc.c
+++ b/drivers/serial/serial_mxc.c
@@ -311,7 +311,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_TXFULL)
+	if ((readl(&uart->ts) & UTS_TXFULL) || !(readl(&uart->ts) & UTS_TXEMPTY))
 		return -EAGAIN;
 
 	writel(ch, &uart->txd);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-10-26  6:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-25 22:56 [PATCH v2] serial: mxc: Keep the original FIFO empty check Fabio Estevam
2022-10-25 23:23 ` Tim Harvey
2022-10-26  0:17   ` Fabio Estevam
2022-10-26  6:15     ` Michael Nazzareno Trimarchi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox