]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
tty: serial: fsl_lpuart: flush RX and TX FIFO when lpuart shutdown
authorSherry Sun <sherry.sun@nxp.com>
Tue, 7 Jan 2025 07:48:34 +0000 (15:48 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 7 Jan 2025 10:50:05 +0000 (11:50 +0100)
Need to flush UART RX and TX FIFO when lpuart is shutting down to make
sure restore a clean data transfer environment.

Signed-off-by: Sherry Sun <sherry.sun@nxp.com>
Link: https://lore.kernel.org/r/20250107074834.3115230-1-sherry.sun@nxp.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/fsl_lpuart.c

index 7cb1e36fdaab78f3f536067e925e1f78a17b2942..c91b9d9818cd832ea7bb6f1de9f0d4fbdfbfff42 100644 (file)
@@ -1965,6 +1965,11 @@ static void lpuart32_shutdown(struct uart_port *port)
                        UARTCTRL_TIE | UARTCTRL_TCIE | UARTCTRL_RIE | UARTCTRL_SBK);
        lpuart32_write(port, temp, UARTCTRL);
 
+       /* flush Rx/Tx FIFO */
+       temp = lpuart32_read(port, UARTFIFO);
+       temp |= UARTFIFO_TXFLUSH | UARTFIFO_RXFLUSH;
+       lpuart32_write(port, temp, UARTFIFO);
+
        uart_port_unlock_irqrestore(port, flags);
 
        lpuart_dma_shutdown(sport);