diff mbox

modify pl011 driver to work as wakeup source

Message ID 1439547886-5093-1-git-send-email-zhaoyang.huang@linaro.org
State New
Headers show

Commit Message

Zhaoyang Huang Aug. 14, 2015, 10:24 a.m. UTC
add IRQF_NO_SUSPEND flag when requiring irq line and call
the pm_system_wakeup when RX interrupt happens

Signed-off-by: Zhaoyang Huang <zhaoyang.huang@linaro.org>
---
 drivers/tty/serial/amba-pl011.c |   24 +++++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)

Comments

Daniel Lezcano Aug. 14, 2015, 10:58 a.m. UTC | #1
On 08/14/2015 12:24 PM, Zhaoyang Huang wrote:
> add IRQF_NO_SUSPEND flag when requiring irq line and call
> the pm_system_wakeup when RX interrupt happens
>
> Signed-off-by: Zhaoyang Huang <zhaoyang.huang@linaro.org>

Did you look at the 'dev_pm_set_wake_irq' function ?
Amit Kucheria Aug. 26, 2015, 1:46 p.m. UTC | #2
On Wed, Aug 26, 2015 at 6:32 PM, Zhaoyang Huang
<zhaoyang.huang@linaro.org> wrote:
> The following functions don't work on pl011 for setting it as wakeup irq.
> device_init_wakeup(dev, true); dev_pm_set_wake_irq(dev, irq);

Can you elaborate how it doesn't work?

>
> On 14 August 2015 at 18:58, Daniel Lezcano <daniel.lezcano@linaro.org>
> wrote:
>>
>> On 08/14/2015 12:24 PM, Zhaoyang Huang wrote:
>>>
>>> add IRQF_NO_SUSPEND flag when requiring irq line and call
>>> the pm_system_wakeup when RX interrupt happens
>>>
>>> Signed-off-by: Zhaoyang Huang <zhaoyang.huang@linaro.org>
>>
>>
>> Did you look at the 'dev_pm_set_wake_irq' function ?
>>
--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Daniel Lezcano Aug. 26, 2015, 2 p.m. UTC | #3
On 08/26/2015 03:02 PM, Zhaoyang Huang wrote:
> The following functions don't work on pl011 for setting it as wakeup irq.
> device_init_wakeup(dev, true);	dev_pm_set_wake_irq(dev, irq);

Hi Zhaoyang,

if I understood correctly, dev_pm_set_wake_irq is the new API to set a 
wake up device up. You are the first one using it, so perhaps there is 
something missing.

I recommend you have a look at the slides [1] showed at the LPC2015.

I added Sudeep so he can give more informations about that.

   -- Daniel

[1] 
https://linuxplumbersconf.org/2015/ocw//system/presentations/3051/original/wakeup_config.pdf

>
> On 14 August 2015 at 18:58, Daniel Lezcano <daniel.lezcano@linaro.org
> <mailto:daniel.lezcano@linaro.org>> wrote:
>
>     On 08/14/2015 12:24 PM, Zhaoyang Huang wrote:
>
>         add IRQF_NO_SUSPEND flag when requiring irq line and call
>         the pm_system_wakeup when RX interrupt happens
>
>         Signed-off-by: Zhaoyang Huang <zhaoyang.huang@linaro.org
>         <mailto:zhaoyang.huang@linaro.org>>
>
>
>     Did you look at the 'dev_pm_set_wake_irq' function ?
>
>
>
>     --
>       <http://www.linaro.org/> Linaro.org │ Open source software for ARM
>     SoCs
>
>     Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
>     <http://twitter.com/#!/linaroorg
>     <http://twitter.com/#%21/linaroorg>> Twitter |
>     <http://www.linaro.org/linaro-blog/> Blog
>
>
diff mbox

Patch

diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c
index 50cf5b1..6285819 100644
--- a/drivers/tty/serial/amba-pl011.c
+++ b/drivers/tty/serial/amba-pl011.c
@@ -59,6 +59,7 @@ 
 #include <linux/sizes.h>
 #include <linux/io.h>
 #include <linux/acpi.h>
+#include <linux/suspend.h>
 
 #define UART_NR			14
 
@@ -127,6 +128,7 @@  static struct vendor_data vendor_st = {
 	.get_fifosize		= get_fifosize_st,
 };
 
+static int is_suspended = 0;
 /* Deals with DMA transactions */
 
 struct pl011_sgbuf {
@@ -1376,6 +1378,10 @@  static irqreturn_t pl011_int(int irq, void *dev_id)
 					pl011_dma_rx_irq(uap);
 				else
 					pl011_rx_chars(uap);
+
+				if(is_suspended)
+					pm_system_wakeup();
+
 			}
 			if (status & (UART011_DSRMIS|UART011_DCDMIS|
 				      UART011_CTSMIS|UART011_RIMIS))
@@ -1585,7 +1591,7 @@  static int pl011_allocate_irq(struct uart_amba_port *uap)
 {
 	writew(uap->im, uap->port.membase + UART011_IMSC);
 
-	return request_irq(uap->port.irq, pl011_int, 0, "uart-pl011", uap);
+	return request_irq(uap->port.irq, pl011_int, IRQF_NO_SUSPEND, "uart-pl011", uap);
 }
 
 /*
@@ -2403,21 +2409,33 @@  static int pl011_remove(struct amba_device *dev)
 static int pl011_suspend(struct device *dev)
 {
 	struct uart_amba_port *uap = dev_get_drvdata(dev);
+	int ret = 0;
 
 	if (!uap)
 		return -EINVAL;
 
-	return uart_suspend_port(&amba_reg, &uap->port);
+	ret =uart_suspend_port(&amba_reg, &uap->port);
+
+	if(!ret)
+		is_suspended = 1;
+
+	return ret;
 }
 
 static int pl011_resume(struct device *dev)
 {
 	struct uart_amba_port *uap = dev_get_drvdata(dev);
+	int ret = 0;
 
 	if (!uap)
 		return -EINVAL;
 
-	return uart_resume_port(&amba_reg, &uap->port);
+	ret = uart_resume_port(&amba_reg, &uap->port);
+
+	if(!ret)
+		is_suspended = 0;
+
+	return ret;
 }
 #endif