[PATCH 3/3] uart: mediatek: move the in-band wakeup logic to core

From: Claire Chang
Date: Wed May 06 2020 - 03:23:44 EST


Move the in-band wakeup logic to core so that we can control the wakeup
behavior by serdev controller's power/wakeup node and align with other
serial drivers.

Signed-off-by: Claire Chang <tientzu@xxxxxxxxxxxx>
---
drivers/tty/serial/8250/8250_mtk.c | 24 +++---------------------
1 file changed, 3 insertions(+), 21 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_mtk.c b/drivers/tty/serial/8250/8250_mtk.c
index f839380c2f4c1..52cb41e4e493d 100644
--- a/drivers/tty/serial/8250/8250_mtk.c
+++ b/drivers/tty/serial/8250/8250_mtk.c
@@ -71,7 +71,6 @@ struct mtk8250_data {
#ifdef CONFIG_SERIAL_8250_DMA
enum dma_rx_status rx_status;
#endif
- int rx_wakeup_irq;
};

/* flow control mode */
@@ -496,6 +495,8 @@ static int mtk8250_probe(struct platform_device *pdev)
struct uart_8250_port uart = {};
struct resource *regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
struct resource *irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
+ struct resource *wakeup_irq =
+ platform_get_resource(pdev, IORESOURCE_IRQ, 1);
struct mtk8250_data *data;
int err;

@@ -525,6 +526,7 @@ static int mtk8250_probe(struct platform_device *pdev)
spin_lock_init(&uart.port.lock);
uart.port.mapbase = regs->start;
uart.port.irq = irq->start;
+ uart.port.wakeup_irq = wakeup_irq ? wakeup_irq->start : -ENXIO;
uart.port.pm = mtk8250_do_pm;
uart.port.type = PORT_16550;
uart.port.flags = UPF_BOOT_AUTOCONF | UPF_FIXED_PORT;
@@ -556,8 +558,6 @@ static int mtk8250_probe(struct platform_device *pdev)
if (data->line < 0)
return data->line;

- data->rx_wakeup_irq = platform_get_irq_optional(pdev, 1);
-
return 0;
}

@@ -581,23 +581,9 @@ static int mtk8250_remove(struct platform_device *pdev)
static int __maybe_unused mtk8250_suspend(struct device *dev)
{
struct mtk8250_data *data = dev_get_drvdata(dev);
- int irq = data->rx_wakeup_irq;
- int err;

serial8250_suspend_port(data->line);
-
pinctrl_pm_select_sleep_state(dev);
- if (irq >= 0) {
- err = enable_irq_wake(irq);
- if (err) {
- dev_err(dev,
- "failed to enable irq wake on IRQ %d: %d\n",
- irq, err);
- pinctrl_pm_select_default_state(dev);
- serial8250_resume_port(data->line);
- return err;
- }
- }

return 0;
}
@@ -605,12 +591,8 @@ static int __maybe_unused mtk8250_suspend(struct device *dev)
static int __maybe_unused mtk8250_resume(struct device *dev)
{
struct mtk8250_data *data = dev_get_drvdata(dev);
- int irq = data->rx_wakeup_irq;

- if (irq >= 0)
- disable_irq_wake(irq);
pinctrl_pm_select_default_state(dev);
-
serial8250_resume_port(data->line);

return 0;
--
2.26.2.526.g744177e7f7-goog