[V2,5/5] tty: serial: fsl_lpuart: clear LPUART Status Register in lpuart32_shutdown()

Message ID 20221110081728.10172-6-sherry.sun@nxp.com
State New
Headers
Series fsl_lpuart: improve Idle Line Interrupt and registers handle in .shutdown() |

Commit Message

Sherry Sun Nov. 10, 2022, 8:17 a.m. UTC
  The LPUART Status Register needs to be cleared when closing the uart
port to get a clean environment when reopening the uart.

Fixes: 380c966c093e ("tty: serial: fsl_lpuart: add 32-bit register interface support")
Signed-off-by: Sherry Sun <sherry.sun@nxp.com>
---
Changes in V2:
1. Split one patch into four smaller patches to improve the commit
messages and add Fixes tag as suggested by Ilpo.
---
 drivers/tty/serial/fsl_lpuart.c | 4 ++++
 1 file changed, 4 insertions(+)
  

Comments

Michael Walle Nov. 23, 2022, 10:36 a.m. UTC | #1
Am 2022-11-10 09:17, schrieb Sherry Sun:
> The LPUART Status Register needs to be cleared when closing the uart
> port to get a clean environment when reopening the uart.

Shouldn't it be cleared on startup instead? What if there was some
kind of event between shutdown and startup?

-michael
  
Sherry Sun Nov. 23, 2022, 11:34 a.m. UTC | #2
> -----Original Message-----
> From: Michael Walle <michael@walle.cc>
> Sent: 2022年11月23日 18:36
> To: Sherry Sun <sherry.sun@nxp.com>
> Cc: gregkh@linuxfoundation.org; jirislaby@kernel.org;
> jingchang.lu@freescale.com; tomonori.sakita@sord.co.jp;
> atsushi.nemoto@sord.co.jp; linux-serial@vger.kernel.org; linux-
> kernel@vger.kernel.org; dl-linux-imx <linux-imx@nxp.com>
> Subject: Re: [PATCH V2 5/5] tty: serial: fsl_lpuart: clear LPUART Status
> Register in lpuart32_shutdown()
> 
> Am 2022-11-10 09:17, schrieb Sherry Sun:
> > The LPUART Status Register needs to be cleared when closing the uart
> > port to get a clean environment when reopening the uart.
> 
> Shouldn't it be cleared on startup instead? What if there was some kind of
> event between shutdown and startup?
> 

Hi Michael, same as what we discussed under another patch, unfortunately the .startup() won’t clear the status of the uart port.

Best Regards
Sherry
  

Patch

diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c
index c297be11422a..75162c4784dd 100644
--- a/drivers/tty/serial/fsl_lpuart.c
+++ b/drivers/tty/serial/fsl_lpuart.c
@@ -1769,6 +1769,10 @@  static void lpuart32_shutdown(struct uart_port *port)
 
 	spin_lock_irqsave(&port->lock, flags);
 
+	/* clear statue */
+	temp = lpuart32_read(&sport->port, UARTSTAT);
+	lpuart32_write(&sport->port, temp, UARTSTAT);
+
 	/* disable Rx/Tx DMA */
 	temp = lpuart32_read(port, UARTBAUD);
 	temp &= ~(UARTBAUD_TDMAE | UARTBAUD_RDMAE);