Current imx uart 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>
---
drivers/tty/serial/imx.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
index 90e2ea1e8afe..c488e5d372ff 100644
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -30,7 +30,7 @@
#include <linux/iopoll.h>
#include <linux/dma-mapping.h>
-#include <asm/irq.h>
+#include <linux/irq.h>
#include <linux/dma/imx-dma.h>
#include "serial_mctrl_gpio.h"
@@ -2699,8 +2699,8 @@ static void imx_uart_enable_wakeup(struct imx_port *sport, bool on)
{
struct tty_port *port = &sport->port.state->port;
struct device *tty_dev;
- bool may_wake = false;
- u32 ucr3;
+ bool may_wake = false, wake_active = false;
+ u32 ucr3, usr1;
scoped_guard(tty_port_tty, port) {
struct tty_struct *tty = scoped_tty();
@@ -2715,12 +2715,14 @@ static void imx_uart_enable_wakeup(struct imx_port *sport, bool on)
uart_port_lock_irq(&sport->port);
+ usr1 = imx_uart_readl(sport, USR1);
ucr3 = imx_uart_readl(sport, UCR3);
if (on) {
imx_uart_writel(sport, USR1_AWAKE, USR1);
ucr3 |= UCR3_AWAKEN;
} else {
ucr3 &= ~UCR3_AWAKEN;
+ wake_active = usr1 & USR1_AWAKE;
}
imx_uart_writel(sport, ucr3, UCR3);
@@ -2731,10 +2733,14 @@ static void imx_uart_enable_wakeup(struct imx_port *sport, bool on)
ucr1 |= UCR1_RTSDEN;
} else {
ucr1 &= ~UCR1_RTSDEN;
+ wake_active = wake_active || (usr1 & USR1_RTSD);
}
imx_uart_writel(sport, ucr1, UCR1);
}
+ if (wake_active && irqd_is_wakeup_set(irq_get_irq_data(sport->port.irq)))
+ pm_wakeup_event(tty_port_tty_get(port)->dev, 0);
+
uart_port_unlock_irq(&sport->port);
}
--
2.34.1
On Thu, Oct 02, 2025 at 12:52:59PM +0800, Sherry Sun wrote:
> Current imx uart 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>
> drivers/tty/serial/imx.c | 12 +++++++++---
> 1 file changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
> index 90e2ea1e8afe..c488e5d372ff 100644
> --- a/drivers/tty/serial/imx.c
> +++ b/drivers/tty/serial/imx.c
> @@ -30,7 +30,7 @@
> #include <linux/iopoll.h>
> #include <linux/dma-mapping.h>
>
> -#include <asm/irq.h>
> +#include <linux/irq.h>
> #include <linux/dma/imx-dma.h>
>
> #include "serial_mctrl_gpio.h"
> @@ -2699,8 +2699,8 @@ static void imx_uart_enable_wakeup(struct imx_port *sport, bool on)
> {
> struct tty_port *port = &sport->port.state->port;
> struct device *tty_dev;
> - bool may_wake = false;
> - u32 ucr3;
> + bool may_wake = false, wake_active = false;
> + u32 ucr3, usr1;
>
> scoped_guard(tty_port_tty, port) {
> struct tty_struct *tty = scoped_tty();
> @@ -2715,12 +2715,14 @@ static void imx_uart_enable_wakeup(struct imx_port *sport, bool on)
>
> uart_port_lock_irq(&sport->port);
>
> + usr1 = imx_uart_readl(sport, USR1);
> ucr3 = imx_uart_readl(sport, UCR3);
> if (on) {
> imx_uart_writel(sport, USR1_AWAKE, USR1);
> ucr3 |= UCR3_AWAKEN;
> } else {
> ucr3 &= ~UCR3_AWAKEN;
> + wake_active = usr1 & USR1_AWAKE;
> }
> imx_uart_writel(sport, ucr3, UCR3);
>
> @@ -2731,10 +2733,14 @@ static void imx_uart_enable_wakeup(struct imx_port *sport, bool on)
> ucr1 |= UCR1_RTSDEN;
> } else {
> ucr1 &= ~UCR1_RTSDEN;
> + wake_active = wake_active || (usr1 & USR1_RTSD);
> }
> imx_uart_writel(sport, ucr1, UCR1);
> }
>
> + if (wake_active && irqd_is_wakeup_set(irq_get_irq_data(sport->port.irq)))
> + pm_wakeup_event(tty_port_tty_get(port)->dev, 0);
> +
> uart_port_unlock_irq(&sport->port);
> }
>
> --
> 2.34.1
>
© 2016 - 2025 Red Hat, Inc.