@@ -1001,6 +1001,7 @@ int serial8250_register_8250_port(struct uart_8250_port *up)
uart->port.membase = up->port.membase;
uart->port.irq = up->port.irq;
uart->port.irqflags = up->port.irqflags;
+ uart->port.wakeup_irq = up->port.wakeup_irq;
uart->port.uartclk = up->port.uartclk;
uart->port.fifosize = up->port.fifosize;
uart->port.regshift = up->port.regshift;
@@ -2165,12 +2165,13 @@ int uart_suspend_port(struct uart_driver *drv, struct uart_port *uport)
struct tty_port *port = &state->port;
struct device *tty_dev;
struct uart_match match = {uport, drv};
+ int irq = uport->wakeup_irq > 0 ? uport->wakeup_irq : uport->irq;
mutex_lock(&port->mutex);
tty_dev = device_find_child(uport->dev, &match, serial_match_port);
if (tty_dev && device_may_wakeup(tty_dev)) {
- enable_irq_wake(uport->irq);
+ enable_irq_wake(irq);
put_device(tty_dev);
mutex_unlock(&port->mutex);
return 0;
@@ -2228,13 +2229,14 @@ int uart_resume_port(struct uart_driver *drv, struct uart_port *uport)
struct device *tty_dev;
struct uart_match match = {uport, drv};
struct ktermios termios;
+ int irq = uport->wakeup_irq > 0 ? uport->wakeup_irq : uport->irq;
mutex_lock(&port->mutex);
tty_dev = device_find_child(uport->dev, &match, serial_match_port);
if (!uport->suspended && device_may_wakeup(tty_dev)) {
- if (irqd_is_wakeup_set(irq_get_irq_data((uport->irq))))
- disable_irq_wake(uport->irq);
+ if (irqd_is_wakeup_set(irq_get_irq_data((irq))))
+ disable_irq_wake(irq);
put_device(tty_dev);
mutex_unlock(&port->mutex);
return 0;
@@ -136,6 +136,7 @@ struct uart_port {
struct serial_iso7816 *iso7816);
unsigned int irq; /* irq number */
unsigned long irqflags; /* irq flags */
+ unsigned int wakeup_irq; /* wakeup irq number */
unsigned int uartclk; /* base uart clock */
unsigned int fifosize; /* tx fifo size */
unsigned char x_char; /* xon/xoff char */
Since some uart controllers may be off in S3, we won't be able to use the normal in-band wakeup. Take 8250_mtk.c as an example. The driver needs to allocate an edge sensitive interrupt as the wakeup_irq and use an addtional pinctrl to reconfigure Rx pin to normal GPIO in sleep state. Once host detects Rx falling, an interrupt is triggered, and the system leaves sleep state. Add the wakeup_irq logic in core to simplify and make the code more generic. Also, we can align with the original wakeup behavior and power/wakeup node. Signed-off-by: Claire Chang <tientzu@chromium.org> --- drivers/tty/serial/8250/8250_core.c | 1 + drivers/tty/serial/serial_core.c | 8 +++++--- include/linux/serial_core.h | 1 + 3 files changed, 7 insertions(+), 3 deletions(-)