[PATCH V2] tty: serial: fsl_lpuart: Add missing wakeup event reporting

Sherry Sun posted 1 patch 1 week ago
drivers/tty/serial/fsl_lpuart.c | 8 ++++++++
1 file changed, 8 insertions(+)
[PATCH V2] tty: serial: fsl_lpuart: Add missing wakeup event reporting
Posted by Sherry Sun 1 week ago
Current lpuart wakeup event would not report itself as wakeup source
through sysfs. Add pm_wakeup_event() to support it.

Signed-off-by: Sherry Sun <sherry.sun@nxp.com>
---
Changes in V2:
1. Improve the commit message as Frank suggested.
2. Move wake_active above u32 stat.
3. Use (stat & (UARTSTAT_RDRF | UARTSTAT_RXEDGIF)) instead of (stat &
   UARTSTAT_RDRF || stat & UARTSTAT_RXEDGIF).
---
 drivers/tty/serial/fsl_lpuart.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c
index c9519e649e82..1bd7ec9c81ea 100644
--- a/drivers/tty/serial/fsl_lpuart.c
+++ b/drivers/tty/serial/fsl_lpuart.c
@@ -3087,6 +3087,8 @@ static int lpuart_suspend_noirq(struct device *dev)
 static int lpuart_resume_noirq(struct device *dev)
 {
 	struct lpuart_port *sport = dev_get_drvdata(dev);
+	struct tty_port *port = &sport->port.state->port;
+	bool wake_active;
 	u32 stat;
 
 	pinctrl_pm_select_default_state(dev);
@@ -3098,6 +3100,12 @@ static int lpuart_resume_noirq(struct device *dev)
 		if (lpuart_is_32(sport)) {
 			stat = lpuart32_read(&sport->port, UARTSTAT);
 			lpuart32_write(&sport->port, stat, UARTSTAT);
+
+			/* check whether lpuart wakeup was triggered */
+			wake_active = stat & (UARTSTAT_RDRF | UARTSTAT_RXEDGIF);
+
+			if (wake_active && irqd_is_wakeup_set(irq_get_irq_data(sport->port.irq)))
+				pm_wakeup_event(tty_port_tty_get(port)->dev, 0);
 		}
 	}
 
-- 
2.34.1
Re: [PATCH V2] tty: serial: fsl_lpuart: Add missing wakeup event reporting
Posted by Frank Li 1 week ago
On Wed, Sep 24, 2025 at 10:56:07AM +0800, Sherry Sun wrote:
> Current lpuart wakeup event would not report itself as wakeup source
> through sysfs. Add pm_wakeup_event() to support it.
>
> Signed-off-by: Sherry Sun <sherry.sun@nxp.com>
> ---

Reviewed-by: Frank Li <Frank.Li@nxp.com>

> Changes in V2:
> 1. Improve the commit message as Frank suggested.
> 2. Move wake_active above u32 stat.
> 3. Use (stat & (UARTSTAT_RDRF | UARTSTAT_RXEDGIF)) instead of (stat &
>    UARTSTAT_RDRF || stat & UARTSTAT_RXEDGIF).
> ---
>  drivers/tty/serial/fsl_lpuart.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
>
> diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c
> index c9519e649e82..1bd7ec9c81ea 100644
> --- a/drivers/tty/serial/fsl_lpuart.c
> +++ b/drivers/tty/serial/fsl_lpuart.c
> @@ -3087,6 +3087,8 @@ static int lpuart_suspend_noirq(struct device *dev)
>  static int lpuart_resume_noirq(struct device *dev)
>  {
>  	struct lpuart_port *sport = dev_get_drvdata(dev);
> +	struct tty_port *port = &sport->port.state->port;
> +	bool wake_active;
>  	u32 stat;
>
>  	pinctrl_pm_select_default_state(dev);
> @@ -3098,6 +3100,12 @@ static int lpuart_resume_noirq(struct device *dev)
>  		if (lpuart_is_32(sport)) {
>  			stat = lpuart32_read(&sport->port, UARTSTAT);
>  			lpuart32_write(&sport->port, stat, UARTSTAT);
> +
> +			/* check whether lpuart wakeup was triggered */
> +			wake_active = stat & (UARTSTAT_RDRF | UARTSTAT_RXEDGIF);
> +
> +			if (wake_active && irqd_is_wakeup_set(irq_get_irq_data(sport->port.irq)))
> +				pm_wakeup_event(tty_port_tty_get(port)->dev, 0);
>  		}
>  	}
>
> --
> 2.34.1
>