[PATCH v2 2/2] serial: mxc: Wait for TX completion before reset
loic.poulain at linaro.org
Wed Jan 11 09:06:23 CET 2023
On Wed, 11 Jan 2023 at 01:15, Simon Glass <sjg at chromium.org> wrote:
> On Tue, 10 Jan 2023 at 05:42, Loic Poulain <loic.poulain at linaro.org> wrote:
> > The u-boot console may show some corrupted characters when
> > printing in board_init() due to reset 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 proceding 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 <loic.poulain at linaro.org>
> > ---
> > v2: Add this commit to the series
> > drivers/serial/serial_mxc.c | 24 +++++++++++++++++++++++-
> > 1 file changed, 23 insertions(+), 1 deletion(-)
> Can you just use serial_flush()? It is generic and should work with any device.
Not directly, except that serial_flush is specific to DM and
it's also not exactly what we're doing here, as we want to check if
the UART was running
before (re)initialization, and to limit the waiting loop in case the
TX/UART is in bad state or
stuck due to flow control.
More information about the U-Boot