diff options
author | Ye Li <ye.li@nxp.com> | 2019-01-02 19:34:45 -0800 |
---|---|---|
committer | Ye Li <ye.li@nxp.com> | 2019-01-03 01:21:20 -0800 |
commit | 81385a5b0735dd4522c61659ab7b11b4384b518f (patch) | |
tree | 08ee50889e3915b0c7f2bffb70a3f357235838d5 | |
parent | 9f1a11bdc3fef58bc41bebec858ccab0cd9050e4 (diff) |
MLK-20669 lpuart: Fix tstc issue in Non-DM driver
The tstc function in Non-DM driver does not check the LPUART_FLAG_REGMAP_32BIT_REG
flag, it always use 8 bits register version and cause issue in 8QM/QXP SPL.
Signed-off-by: Ye Li <ye.li@nxp.com>
Acked-by: Peng Fan <peng.fan@nxp.com>
-rw-r--r-- | drivers/serial/serial_lpuart.c | 57 |
1 files changed, 28 insertions, 29 deletions
diff --git a/drivers/serial/serial_lpuart.c b/drivers/serial/serial_lpuart.c index 23f8fb8f975..a8177806e19 100644 --- a/drivers/serial/serial_lpuart.c +++ b/drivers/serial/serial_lpuart.c @@ -137,6 +137,17 @@ static void _lpuart_serial_putc(struct lpuart_serial_platdata *plat, __raw_writeb(c, &base->ud); } +/* Test whether a character is in the RX buffer */ +static int _lpuart_serial_tstc(struct lpuart_serial_platdata *plat) +{ + struct lpuart_fsl *base = plat->reg; + + if (__raw_readb(&base->urcfifo) == 0) + return 0; + + return 1; +} + /* * Initialise the serial port with the given baudrate. The settings * are always 8 data bits, no parity, 1 stop bit, no start bits. @@ -282,6 +293,20 @@ static void _lpuart32_serial_putc(struct lpuart_serial_platdata *plat, lpuart_write32(plat->flags, &base->data, c); } +/* Test whether a character is in the RX buffer */ +static int _lpuart32_serial_tstc(struct lpuart_serial_platdata *plat) +{ + struct lpuart_fsl_reg32 *base = plat->reg; + u32 water; + + lpuart_read32(plat->flags, &base->water, &water); + + if ((water >> 24) == 0) + return 0; + + return 1; +} + /* * Initialise the serial port with the given baudrate. The settings * are always 8 data bits, no parity, 1 stop bit, no start bits. @@ -387,12 +412,11 @@ static void serial_lpuart_putc(const char c) static int serial_lpuart_tstc(void) { struct lpuart_serial_platdata *plat = &lpuart_serial_data; - struct lpuart_fsl *base = plat->reg; - if (__raw_readb(&base->urcfifo) == 0) - return 0; + if (plat->flags & LPUART_FLAG_REGMAP_32BIT_REG) + return _lpuart32_serial_tstc(plat); - return 1; + return _lpuart_serial_tstc(plat); } static struct serial_device serial_lpuart_drv = { @@ -425,31 +449,6 @@ static bool is_lpuart32(struct udevice *dev) return plat->flags & LPUART_FLAG_REGMAP_32BIT_REG; } -/* Test whether a character is in the RX buffer */ -static int _lpuart_serial_tstc(struct lpuart_serial_platdata *plat) -{ - struct lpuart_fsl *base = plat->reg; - - if (__raw_readb(&base->urcfifo) == 0) - return 0; - - return 1; -} - -/* Test whether a character is in the RX buffer */ -static int _lpuart32_serial_tstc(struct lpuart_serial_platdata *plat) -{ - struct lpuart_fsl_reg32 *base = plat->reg; - u32 water; - - lpuart_read32(plat->flags, &base->water, &water); - - if ((water >> 24) == 0) - return 0; - - return 1; -} - static int lpuart_serial_setbrg(struct udevice *dev, int baudrate) { struct lpuart_serial_platdata *plat = dev->platdata; |