serial: sh-sci: suspend/resume wakeup support
Subsystems (2)
PATCH 1/1 serial: sh-sci: suspend/resume wakeup support
From: Magnus Damm <[email protected]>
This patch adds wakeup support to the sh-sci driver. As usual, device_init_wakeup() and enable_irq_wake()/disable_irq_wake() are used to determine if the port should be suspended/resumed as usual or if it should be enabled to act as a wakeup source.
---
drivers/tty/serial/sh-sci.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-)
drivers/tty/serial/sh-sci.c +17 -5
@@ -1962,7 +1962,11 @@ static int __devinit sci_probe_single(stif (ret)return ret; -return uart_add_one_port (&sci_uart_driver, &sciport->port); + ret =uart_add_one_port (&sci_uart_driver, &sciport->port); +if (!ret) +device_init_wakeup (&dev->dev,1 ); + +return ret; }static int __devinit sci_probe (struct platform_device *dev)
@@ -2007,8 +2011,12 @@ static int sci_suspend(struct device *de {struct sci_port *sport =dev_get_drvdata (dev); -if (sport) -uart_suspend_port (&sci_uart_driver, &sport->port); +if (sport) { +if (device_may_wakeup (dev)) +enable_irq_wake (sport->cfg->irqs[SCIx_RXI_IRQ]); +else +uart_suspend_port (&sci_uart_driver, &sport->port); + }return 0 ; }
@@ -2017,8 +2025,12 @@ static int sci_resume(struct device *dev {struct sci_port *sport =dev_get_drvdata (dev); -if (sport) -uart_resume_port (&sci_uart_driver, &sport->port); +if (sport) { +if (device_may_wakeup (dev)) +disable_irq_wake (sport->cfg->irqs[SCIx_RXI_IRQ]); +else +uart_resume_port (&sci_uart_driver, &sport->port); + }return 0 ; }
Quoted 8 lines · Magnus Damm
From: Magnus Damm <[email protected]>
This patch adds wakeup support to the sh-sci driver. As usual,
device_init_wakeup()and enable_irq_wake()/disable_irq_wake() are used to determine if the port should be suspended/resumed as usual or if it should be enabled to act as a wakeup source.Signed-off-by Magnus Damm <[email protected]>
The serial core already does all of this, so I'm not sure I see the point. If you've stumbled upon something the generic infrastructure doesn't handle properly, then fix that up instead of reinventing it and sidestepping the rest of the suspend/resume port ops.
Quoted 8 lines · Paul Mundt
Quoted 7 lines · Magnus Damm
From: Magnus Damm <[email protected]>
This patch adds wakeup support to the sh-sci driver. As usual,
device_init_wakeup()and enable_irq_wake()/disable_irq_wake() are used to determine if the port should be suspended/resumed as usual or if it should be enabled to act as a wakeup source.
Quoted 6 lines
Quoted 1 line
Signed-off-by Magnus Damm <[email protected]>The serial core already does all of this, so I'm not sure I see the point. If you've stumbled upon something the generic infrastructure doesn't handle properly, then fix that up instead of reinventing it and sidestepping the rest of the suspend/resume port ops.
Sure, I overlooked that. Have a look at V2.
PATCH 1/1 serial: sh-sci: suspend/resume wakeup support V2
In reply to Magnus DammFrom: Magnus Damm <[email protected]>
This patch adds wakeup support to the sh-sci driver. The serial core deals with all details but defaults to wakeup disabled. So to make use of this feature enable wakeup in sysfs:
echo enabled > /sys/class/tty/ttySC0/power/wakeup
---
Changes since V1:
- drop device_init_wakeup() and enable/disable_irq_wake() bits
- let port->irq point out receive IRQ
drivers/tty/serial/sh-sci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/serial/sh-sci.c +1 -1
@@ -1777,7 +1777,7 @@ static int __devinit sci_init_single(str* * For the muxed case there's nothing more to do. */ - port->irq = p->irqs[SCIx_TXI_IRQ]; + port->irq = p->irqs[SCIx_RXI_IRQ];if (p->dma_dev) dev_dbg(port->dev, "DMA device %p, tx %d, rx %d\n",