]> git.baikalelectronics.ru Git - uboot.git/commitdiff
serial: mxc: Speed-up character transmission
authorLoic Poulain <loic.poulain@linaro.org>
Thu, 12 Jan 2023 17:19:51 +0000 (18:19 +0100)
committerStefano Babic <sbabic@denx.de>
Mon, 30 Jan 2023 22:23:02 +0000 (23:23 +0100)
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 <loic.poulain@linaro.org>
Tested-by: Lothar Waßmann <LW@KARO-electronics.de>
Acked-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Fabio Estevam <festevam@denx.de>
Tested-by: Fabio Estevam <festevam@denx.de>
drivers/serial/serial_mxc.c

index e4ffa9c3f6b2682470f1e6b1925142a8952e8496..cc85a502726ecc46463b33ea2c3fade80dd419ce 100644 (file)
@@ -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);