• Stefan Agner's avatar
    tty: serial: fsl_lpuart: clear receive flag on FIFO flush · 63d7ff22
    Stefan Agner authored
    commit 8e4934c6 upstream.
    
    When the receiver was enabled during startup, a character could
    have been in the FIFO when the UART get initially used. The
    driver configures the (receive) watermark level, and flushes the
    FIFO. However, the receive flag (RDRF) could still be set at that
    stage (as mentioned in the register description of UARTx_RWFIFO).
    This leads to an interrupt which won't be handled properly in
    interrupt mode: The receive interrupt function lpuart_rxint checks
    the FIFO count, which is 0 at that point (due to the flush
    during initialization). The problem does not manifest when using
    DMA to receive characters.
    
    Fix this situation by explicitly read the status register, which
    leads to clearing of the RDRF flag. Due to the flush just after
    the status flag read, a explicit data read is not to required.
    Signed-off-by: default avatarStefan Agner <stefan@agner.ch>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    63d7ff22
fsl_lpuart.c 49.1 KB