All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH V3 0/3] fsl_lpuart: improve Idle Line Interrupt and registers handle in .shutdown()
@ 2022-11-25 10:19 Sherry Sun
  2022-11-25 10:19 ` [PATCH V3 1/3] tty: serial: fsl_lpuart: only enable Idle Line Interrupt for non-dma case Sherry Sun
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Sherry Sun @ 2022-11-25 10:19 UTC (permalink / raw)
  To: gregkh, jirislaby
  Cc: linux-serial, linux-kernel, linux-imx, atsushi.nemoto, tomonori.sakita

---
Changes in V3:
1. Add the corresponding head files for GENMASK and FIELD_PREP to
avoid build break.
2. Remove the patch 2 and patch 3 in the original patch set, as the
loopback and RTS/CTS flags may not need to be cleared in .shutdown().
---

The patchset improve the Idle Line Interrupt for lpuart driver, also handle
the registers correctly for lpuart32 when closing the uart port.

Patches have been tested on imx8ulp-evk platform.

Sherry Sun (3):
  tty: serial: fsl_lpuart: only enable Idle Line Interrupt for non-dma
    case
  tty: serial: fsl_lpuart: disable Rx/Tx DMA in lpuart32_shutdown()
  tty: serial: fsl_lpuart: clear LPUART Status Register in
    lpuart32_shutdown()

 drivers/tty/serial/fsl_lpuart.c | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

-- 
2.17.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH V3 1/3] tty: serial: fsl_lpuart: only enable Idle Line Interrupt for non-dma case
  2022-11-25 10:19 [PATCH V3 0/3] fsl_lpuart: improve Idle Line Interrupt and registers handle in .shutdown() Sherry Sun
@ 2022-11-25 10:19 ` Sherry Sun
  2022-11-25 10:19 ` [PATCH V3 2/3] tty: serial: fsl_lpuart: disable Rx/Tx DMA in lpuart32_shutdown() Sherry Sun
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Sherry Sun @ 2022-11-25 10:19 UTC (permalink / raw)
  To: gregkh, jirislaby
  Cc: linux-serial, linux-kernel, linux-imx, atsushi.nemoto, tomonori.sakita

For the lpuart driver, the Idle Line Interrupt Enable now is only needed
for the CPU mode, so enable the UARTCTRL_ILIE at the correct place, and
clear it when shutdown.

Also need to configure the suitable UARTCTRL_IDLECFG, now the value is
0x7, represent 128 idle characters will trigger the Idle Line Interrupt.

Signed-off-by: Sherry Sun <sherry.sun@nxp.com>
---
 drivers/tty/serial/fsl_lpuart.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c
index 5e69fb73f570..9b8d32262f1e 100644
--- a/drivers/tty/serial/fsl_lpuart.c
+++ b/drivers/tty/serial/fsl_lpuart.c
@@ -5,6 +5,8 @@
  *  Copyright 2012-2014 Freescale Semiconductor, Inc.
  */
 
+#include <linux/bitfield.h>
+#include <linux/bits.h>
 #include <linux/clk.h>
 #include <linux/console.h>
 #include <linux/delay.h>
@@ -181,7 +183,7 @@
 #define UARTCTRL_SBK		0x00010000
 #define UARTCTRL_MA1IE		0x00008000
 #define UARTCTRL_MA2IE		0x00004000
-#define UARTCTRL_IDLECFG	0x00000100
+#define UARTCTRL_IDLECFG	GENMASK(10, 8)
 #define UARTCTRL_LOOPS		0x00000080
 #define UARTCTRL_DOZEEN		0x00000040
 #define UARTCTRL_RSRC		0x00000020
@@ -1523,7 +1525,7 @@ static void lpuart32_setup_watermark(struct lpuart_port *sport)
 	ctrl = lpuart32_read(&sport->port, UARTCTRL);
 	ctrl_saved = ctrl;
 	ctrl &= ~(UARTCTRL_TIE | UARTCTRL_TCIE | UARTCTRL_TE |
-			UARTCTRL_RIE | UARTCTRL_RE);
+			UARTCTRL_RIE | UARTCTRL_RE | UARTCTRL_ILIE);
 	lpuart32_write(&sport->port, ctrl, UARTCTRL);
 
 	/* enable FIFO mode */
@@ -1547,7 +1549,8 @@ static void lpuart32_setup_watermark_enable(struct lpuart_port *sport)
 	lpuart32_setup_watermark(sport);
 
 	temp = lpuart32_read(&sport->port, UARTCTRL);
-	temp |= UARTCTRL_RE | UARTCTRL_TE | UARTCTRL_ILIE;
+	temp |= UARTCTRL_RE | UARTCTRL_TE;
+	temp |= FIELD_PREP(UARTCTRL_IDLECFG, 0x7);
 	lpuart32_write(&sport->port, temp, UARTCTRL);
 }
 
@@ -1691,7 +1694,7 @@ static void lpuart32_configure(struct lpuart_port *sport)
 	}
 	temp = lpuart32_read(&sport->port, UARTCTRL);
 	if (!sport->lpuart_dma_rx_use)
-		temp |= UARTCTRL_RIE;
+		temp |= UARTCTRL_RIE | UARTCTRL_ILIE;
 	if (!sport->lpuart_dma_tx_use)
 		temp |= UARTCTRL_TIE;
 	lpuart32_write(&sport->port, temp, UARTCTRL);
@@ -1798,7 +1801,7 @@ static void lpuart32_shutdown(struct uart_port *port)
 
 	/* disable Rx/Tx and interrupts */
 	temp = lpuart32_read(port, UARTCTRL);
-	temp &= ~(UARTCTRL_TE | UARTCTRL_RE |
+	temp &= ~(UARTCTRL_TE | UARTCTRL_RE | UARTCTRL_ILIE |
 			UARTCTRL_TIE | UARTCTRL_TCIE | UARTCTRL_RIE);
 	lpuart32_write(port, temp, UARTCTRL);
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH V3 2/3] tty: serial: fsl_lpuart: disable Rx/Tx DMA in lpuart32_shutdown()
  2022-11-25 10:19 [PATCH V3 0/3] fsl_lpuart: improve Idle Line Interrupt and registers handle in .shutdown() Sherry Sun
  2022-11-25 10:19 ` [PATCH V3 1/3] tty: serial: fsl_lpuart: only enable Idle Line Interrupt for non-dma case Sherry Sun
@ 2022-11-25 10:19 ` Sherry Sun
  2022-11-25 10:19 ` [PATCH V3 3/3] tty: serial: fsl_lpuart: clear LPUART Status Register " Sherry Sun
  2022-12-14  2:43 ` [PATCH V3 0/3] fsl_lpuart: improve Idle Line Interrupt and registers handle in .shutdown() Sherry Sun
  3 siblings, 0 replies; 7+ messages in thread
From: Sherry Sun @ 2022-11-25 10:19 UTC (permalink / raw)
  To: gregkh, jirislaby
  Cc: linux-serial, linux-kernel, linux-imx, atsushi.nemoto, tomonori.sakita

UARTBAUD_RDMAE and UARTBAUD_TDMAE are enabled in lpuart32_startup(), but
lpuart32_shutdown() not disable them, only free the dma ring buffer and
release the dma channels, so here disable the Rx/Tx DMA first in
lpuart32_shutdown().

Fixes: 42b68768e51b ("serial: fsl_lpuart: DMA support for 32-bit variant")
Signed-off-by: Sherry Sun <sherry.sun@nxp.com>
---
 drivers/tty/serial/fsl_lpuart.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c
index 9b8d32262f1e..88697ddcd8c4 100644
--- a/drivers/tty/serial/fsl_lpuart.c
+++ b/drivers/tty/serial/fsl_lpuart.c
@@ -1799,6 +1799,11 @@ static void lpuart32_shutdown(struct uart_port *port)
 
 	spin_lock_irqsave(&port->lock, flags);
 
+	/* disable Rx/Tx DMA */
+	temp = lpuart32_read(port, UARTBAUD);
+	temp &= ~(UARTBAUD_TDMAE | UARTBAUD_RDMAE);
+	lpuart32_write(port, temp, UARTBAUD);
+
 	/* disable Rx/Tx and interrupts */
 	temp = lpuart32_read(port, UARTCTRL);
 	temp &= ~(UARTCTRL_TE | UARTCTRL_RE | UARTCTRL_ILIE |
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH V3 3/3] tty: serial: fsl_lpuart: clear LPUART Status Register in lpuart32_shutdown()
  2022-11-25 10:19 [PATCH V3 0/3] fsl_lpuart: improve Idle Line Interrupt and registers handle in .shutdown() Sherry Sun
  2022-11-25 10:19 ` [PATCH V3 1/3] tty: serial: fsl_lpuart: only enable Idle Line Interrupt for non-dma case Sherry Sun
  2022-11-25 10:19 ` [PATCH V3 2/3] tty: serial: fsl_lpuart: disable Rx/Tx DMA in lpuart32_shutdown() Sherry Sun
@ 2022-11-25 10:19 ` Sherry Sun
  2022-12-14  2:43 ` [PATCH V3 0/3] fsl_lpuart: improve Idle Line Interrupt and registers handle in .shutdown() Sherry Sun
  3 siblings, 0 replies; 7+ messages in thread
From: Sherry Sun @ 2022-11-25 10:19 UTC (permalink / raw)
  To: gregkh, jirislaby
  Cc: linux-serial, linux-kernel, linux-imx, atsushi.nemoto, tomonori.sakita

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>
---
 drivers/tty/serial/fsl_lpuart.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c
index 88697ddcd8c4..8918e08bb19e 100644
--- a/drivers/tty/serial/fsl_lpuart.c
+++ b/drivers/tty/serial/fsl_lpuart.c
@@ -1799,6 +1799,10 @@ static void lpuart32_shutdown(struct uart_port *port)
 
 	spin_lock_irqsave(&port->lock, flags);
 
+	/* clear status */
+	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);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* RE: [PATCH V3 0/3] fsl_lpuart: improve Idle Line Interrupt and registers handle in .shutdown()
  2022-11-25 10:19 [PATCH V3 0/3] fsl_lpuart: improve Idle Line Interrupt and registers handle in .shutdown() Sherry Sun
                   ` (2 preceding siblings ...)
  2022-11-25 10:19 ` [PATCH V3 3/3] tty: serial: fsl_lpuart: clear LPUART Status Register " Sherry Sun
@ 2022-12-14  2:43 ` Sherry Sun
  2022-12-14  8:26   ` gregkh
  3 siblings, 1 reply; 7+ messages in thread
From: Sherry Sun @ 2022-12-14  2:43 UTC (permalink / raw)
  To: gregkh, jirislaby
  Cc: linux-serial, linux-kernel, dl-linux-imx, atsushi.nemoto,
	tomonori.sakita

Gentle ping for this patch set...

Best Regards
Sherry

> -----Original Message-----
> From: Sherry Sun
> Sent: 2022年11月25日 18:24
> To: gregkh@linuxfoundation.org; jirislaby@kernel.org
> Cc: linux-serial@vger.kernel.org; linux-kernel@vger.kernel.org; dl-linux-imx
> <linux-imx@nxp.com>; atsushi.nemoto@sord.co.jp;
> tomonori.sakita@sord.co.jp
> Subject: [PATCH V3 0/3] fsl_lpuart: improve Idle Line Interrupt and registers
> handle in .shutdown()
> 
> ---
> Changes in V3:
> 1. Add the corresponding head files for GENMASK and FIELD_PREP to avoid
> build break.
> 2. Remove the patch 2 and patch 3 in the original patch set, as the loopback
> and RTS/CTS flags may not need to be cleared in .shutdown().
> ---
> 
> The patchset improve the Idle Line Interrupt for lpuart driver, also handle the
> registers correctly for lpuart32 when closing the uart port.
> 
> Patches have been tested on imx8ulp-evk platform.
> 
> Sherry Sun (3):
>   tty: serial: fsl_lpuart: only enable Idle Line Interrupt for non-dma
>     case
>   tty: serial: fsl_lpuart: disable Rx/Tx DMA in lpuart32_shutdown()
>   tty: serial: fsl_lpuart: clear LPUART Status Register in
>     lpuart32_shutdown()
> 
>  drivers/tty/serial/fsl_lpuart.c | 22 +++++++++++++++++-----
>  1 file changed, 17 insertions(+), 5 deletions(-)
> 
> --
> 2.17.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH V3 0/3] fsl_lpuart: improve Idle Line Interrupt and registers handle in .shutdown()
  2022-12-14  2:43 ` [PATCH V3 0/3] fsl_lpuart: improve Idle Line Interrupt and registers handle in .shutdown() Sherry Sun
@ 2022-12-14  8:26   ` gregkh
  2022-12-14  8:29     ` Sherry Sun
  0 siblings, 1 reply; 7+ messages in thread
From: gregkh @ 2022-12-14  8:26 UTC (permalink / raw)
  To: Sherry Sun
  Cc: jirislaby, linux-serial, linux-kernel, dl-linux-imx,
	atsushi.nemoto, tomonori.sakita

On Wed, Dec 14, 2022 at 02:43:16AM +0000, Sherry Sun wrote:
> Gentle ping for this patch set...

It's the middle of the merge window and we can not do anything until
6.2-rc1 is released, sorry.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: [PATCH V3 0/3] fsl_lpuart: improve Idle Line Interrupt and registers handle in .shutdown()
  2022-12-14  8:26   ` gregkh
@ 2022-12-14  8:29     ` Sherry Sun
  0 siblings, 0 replies; 7+ messages in thread
From: Sherry Sun @ 2022-12-14  8:29 UTC (permalink / raw)
  To: gregkh
  Cc: jirislaby, linux-serial, linux-kernel, dl-linux-imx,
	atsushi.nemoto, tomonori.sakita



> -----Original Message-----
> From: gregkh@linuxfoundation.org <gregkh@linuxfoundation.org>
> Sent: 2022年12月14日 16:26
> To: Sherry Sun <sherry.sun@nxp.com>
> Cc: jirislaby@kernel.org; linux-serial@vger.kernel.org; linux-
> kernel@vger.kernel.org; dl-linux-imx <linux-imx@nxp.com>;
> atsushi.nemoto@sord.co.jp; tomonori.sakita@sord.co.jp
> Subject: Re: [PATCH V3 0/3] fsl_lpuart: improve Idle Line Interrupt and
> registers handle in .shutdown()
> 
> On Wed, Dec 14, 2022 at 02:43:16AM +0000, Sherry Sun wrote:
> > Gentle ping for this patch set...
> 
> It's the middle of the merge window and we can not do anything until
> 6.2-rc1 is released, sorry.
> 

Oh... okay, thanks for the info, sorry for the inconvenience.

Best Regards
Sherry


> thanks,
> 
> greg k-h

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-12-14  8:29 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-25 10:19 [PATCH V3 0/3] fsl_lpuart: improve Idle Line Interrupt and registers handle in .shutdown() Sherry Sun
2022-11-25 10:19 ` [PATCH V3 1/3] tty: serial: fsl_lpuart: only enable Idle Line Interrupt for non-dma case Sherry Sun
2022-11-25 10:19 ` [PATCH V3 2/3] tty: serial: fsl_lpuart: disable Rx/Tx DMA in lpuart32_shutdown() Sherry Sun
2022-11-25 10:19 ` [PATCH V3 3/3] tty: serial: fsl_lpuart: clear LPUART Status Register " Sherry Sun
2022-12-14  2:43 ` [PATCH V3 0/3] fsl_lpuart: improve Idle Line Interrupt and registers handle in .shutdown() Sherry Sun
2022-12-14  8:26   ` gregkh
2022-12-14  8:29     ` Sherry Sun

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.