fsl_lpuart: improve Idle Line Interrupt and registers handle in .shutdown()
v3 cover 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(-)
Signature · 1 line
2.17.1
PATCH v3 1/3 tty: serial: fsl_lpuart: only enable Idle Line Interrupt for non-dma case
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.
--- drivers/tty/serial/fsl_lpuart.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
drivers/tty/serial/fsl_lpuart.c +8 -5
@@ -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 );
Signature · 1 line
2.17.1
PATCH v3 2/3 tty: serial: fsl_lpuart: disable Rx/Tx DMA in lpuart32_shutdown()
In reply to Sherry SunUARTBAUD_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().
--- drivers/tty/serial/fsl_lpuart.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/tty/serial/fsl_lpuart.c +5 -0
@@ -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 |
Signature · 1 line
2.17.1
PATCH v3 3/3 tty: serial: fsl_lpuart: clear LPUART Status Register in lpuart32_shutdown()
In reply to Sherry SunThe LPUART Status Register needs to be cleared when closing the uart port to get a clean environment when reopening the uart.
--- drivers/tty/serial/fsl_lpuart.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/tty/serial/fsl_lpuart.c +4 -0
@@ -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 );
Signature · 1 line
2.17.1
Gentle ping for this patch set...
Best Regards
Sherry
Quoted 35 lines
-----Original Message-----
From: Sherry Sun
Sent: 2022年11月25日 18:24
To: [email protected]; [email protected]
Cc: [email protected]; [email protected]; dl-linux-imx <[email protected]>; [email protected]; [email protected]
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 andFIELD_PREPto 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 inlpuart32_shutdown()
tty: serial:fsl_lpuart: clear LPUART Status Register inlpuart32_shutdown()drivers/tty/serial/fsl_lpuart.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-)--
2.17.1
[email protected]
maintainerQuoted 1 line · Sherry Sun
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
Quoted 12 lines
-----Original Message-----
From: [email protected] <[email protected]>
Sent: 2022年12月14日 16:26
To: Sherry Sun <[email protected]>
Cc: [email protected]; [email protected]; linux- [email protected]; dl-linux-imx <[email protected]>; [email protected]; [email protected]
Subject: Re: [PATCH V3 0/3]fsl_lpuart: improve Idle Line Interrupt and registers handle in .shutdown()
Quoted 6 lines
Quoted 1 line · Sherry Sun
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
Quoted 3 lines
thanks,
greg k-h