* [PATCH] serial: lpuart32: fix rx stall on FIFO overflow
@ 2024-02-28 10:21 Sascha Hauer
2024-02-29 8:09 ` Sascha Hauer
0 siblings, 1 reply; 2+ messages in thread
From: Sascha Hauer @ 2024-02-28 10:21 UTC (permalink / raw)
To: Barebox List
When the rx FIFO overruns then no new characters are received, even
when the FIFO is read from and space becomes available again.
Acknowledge the overrun in this case to let the UART continue to work.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/serial/serial_lpuart32.c | 21 ++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)
diff --git a/drivers/serial/serial_lpuart32.c b/drivers/serial/serial_lpuart32.c
index 0f3e7c7a04..09d4b620be 100644
--- a/drivers/serial/serial_lpuart32.c
+++ b/drivers/serial/serial_lpuart32.c
@@ -44,6 +44,17 @@ static void lpuart32_disable(struct lpuart32 *lpuart32)
writel(0, lpuart32->base + LPUART32_UARTCTRL);
}
+/* Test whether a character is in the RX buffer */
+static int lpuart32_serial_tstc(struct console_device *cdev)
+{
+ struct lpuart32 *lpuart32 = cdev_to_lpuart32(cdev);
+
+ if (readl(lpuart32->base + LPUART32_UARTSTAT) & LPUART32_UARTSTAT_OR)
+ writel(LPUART32_UARTSTAT_OR, lpuart32->base + LPUART32_UARTSTAT);
+
+ return readl(lpuart32->base + LPUART32_UARTSTAT) & LPUART32_UARTSTAT_RDRF;
+}
+
static int lpuart32_serial_setbaudrate(struct console_device *cdev,
int baudrate)
{
@@ -69,7 +80,7 @@ static int lpuart32_serial_getc(struct console_device *cdev)
{
struct lpuart32 *lpuart32 = cdev_to_lpuart32(cdev);
- while (!(readl(lpuart32->base + LPUART32_UARTSTAT) & LPUART32_UARTSTAT_RDRF));
+ while (!lpuart32_serial_tstc(cdev));
return readl(lpuart32->base + LPUART32_UARTDATA) & 0xff;
}
@@ -81,14 +92,6 @@ static void lpuart32_serial_putc(struct console_device *cdev, char c)
lpuart32_putc(lpuart32->base, c);
}
-/* Test whether a character is in the RX buffer */
-static int lpuart32_serial_tstc(struct console_device *cdev)
-{
- struct lpuart32 *lpuart32 = cdev_to_lpuart32(cdev);
-
- return readl(lpuart32->base + LPUART32_UARTSTAT) & LPUART32_UARTSTAT_RDRF;
-}
-
static void lpuart32_serial_flush(struct console_device *cdev)
{
}
--
2.39.2
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] serial: lpuart32: fix rx stall on FIFO overflow
2024-02-28 10:21 [PATCH] serial: lpuart32: fix rx stall on FIFO overflow Sascha Hauer
@ 2024-02-29 8:09 ` Sascha Hauer
0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2024-02-29 8:09 UTC (permalink / raw)
To: Barebox List, Sascha Hauer
On Wed, 28 Feb 2024 11:21:41 +0100, Sascha Hauer wrote:
> When the rx FIFO overruns then no new characters are received, even
> when the FIFO is read from and space becomes available again.
> Acknowledge the overrun in this case to let the UART continue to work.
>
>
Applied, thanks!
[1/1] serial: lpuart32: fix rx stall on FIFO overflow
https://git.pengutronix.de/cgit/barebox/commit/?id=4d6e5b641ceb (link may not be stable)
Best regards,
--
Sascha Hauer <s.hauer@pengutronix.de>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-02-29 8:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-28 10:21 [PATCH] serial: lpuart32: fix rx stall on FIFO overflow Sascha Hauer
2024-02-29 8:09 ` Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox