* [PATCH] modify pl011 driver to work as wakeup source
@ 2015-08-14 10:24 Zhaoyang Huang
2015-08-14 10:58 ` Daniel Lezcano
0 siblings, 1 reply; 7+ messages in thread
From: Zhaoyang Huang @ 2015-08-14 10:24 UTC (permalink / raw)
To: linux-pm; +Cc: amit.kucheria
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(-)
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
--
1.7.9.5
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] modify pl011 driver to work as wakeup source
2015-08-14 10:24 [PATCH] modify pl011 driver to work as wakeup source Zhaoyang Huang
@ 2015-08-14 10:58 ` Daniel Lezcano
[not found] ` <CAN2waFv+8KM_TCw=iy1BOn-KmYuZRVmr5jKAniJwCaxBjqXvNQ@mail.gmail.com>
0 siblings, 1 reply; 7+ messages in thread
From: Daniel Lezcano @ 2015-08-14 10:58 UTC (permalink / raw)
To: Zhaoyang Huang, linux-pm; +Cc: amit.kucheria
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 ?
--
<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> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] modify pl011 driver to work as wakeup source
[not found] ` <CAN2waFv+8KM_TCw=iy1BOn-KmYuZRVmr5jKAniJwCaxBjqXvNQ@mail.gmail.com>
@ 2015-08-26 13:46 ` Amit Kucheria
2015-08-26 14:00 ` Daniel Lezcano
1 sibling, 0 replies; 7+ messages in thread
From: Amit Kucheria @ 2015-08-26 13:46 UTC (permalink / raw)
To: Zhaoyang Huang; +Cc: Daniel Lezcano, Linux PM list
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 ?
>>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] modify pl011 driver to work as wakeup source
[not found] ` <CAN2waFv+8KM_TCw=iy1BOn-KmYuZRVmr5jKAniJwCaxBjqXvNQ@mail.gmail.com>
2015-08-26 13:46 ` Amit Kucheria
@ 2015-08-26 14:00 ` Daniel Lezcano
2015-08-26 15:36 ` Sudeep Holla
1 sibling, 1 reply; 7+ messages in thread
From: Daniel Lezcano @ 2015-08-26 14:00 UTC (permalink / raw)
To: Zhaoyang Huang; +Cc: linux-pm, Amit Kucheria, Sudeep Holla
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
>
>
--
<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> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] modify pl011 driver to work as wakeup source
2015-08-26 14:00 ` Daniel Lezcano
@ 2015-08-26 15:36 ` Sudeep Holla
[not found] ` <CAN2waFtcVHoSX6QGZQFzJJ2fkYVk1mUsgMn1HYGGd-+TT-XMjw@mail.gmail.com>
0 siblings, 1 reply; 7+ messages in thread
From: Sudeep Holla @ 2015-08-26 15:36 UTC (permalink / raw)
To: Zhaoyang Huang
Cc: Daniel Lezcano, Sudeep Holla, linux-pm@vger.kernel.org,
Amit Kucheria
On 26/08/15 15:00, Daniel Lezcano wrote:
> 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);
I did a quick hack in pl011 driver and it works fine to me, though I am
not sure if that feature is an upstream material as intended by your
patch. I don't this PL011 especially when used as a console needs to be
configured as wakeup(may be when used for bluetooth ?)
>
> 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 had tested those APIs with RTC a while ago, it work just fine.
> 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.
>
Thanks Daniel for the add.
Regards,
Sudeep
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] modify pl011 driver to work as wakeup source
[not found] ` <CAN2waFtcVHoSX6QGZQFzJJ2fkYVk1mUsgMn1HYGGd-+TT-XMjw@mail.gmail.com>
@ 2015-08-27 10:51 ` Sudeep Holla
[not found] ` <CAN2waFsMVEYHy4rb7qJX8Tgxs1d+EuAOXPpbn2SVEoQuXkt9DA@mail.gmail.com>
0 siblings, 1 reply; 7+ messages in thread
From: Sudeep Holla @ 2015-08-27 10:51 UTC (permalink / raw)
To: Zhaoyang Huang
Cc: Sudeep Holla, Daniel Lezcano, linux-pm@vger.kernel.org,
Amit Kucheria
On 27/08/15 09:25, Zhaoyang Huang wrote:
> Sudeep,
> Have you check if the pl011 can wakeup the system. I notice that the
> calling of dev_pm_set_wake_irq can set the node of <device>/power/wakeup
> to be enabled but can not wakeup the system.
>
Yes I did, and it does wakeup the system.
> By basic debugging, I find that when calling of dev_pm_set_wake_irq
> within pl011_probe, the real device which we operate is the
> /sys/devices/platform/7ff80000.uart instead of the ttyAMA0.
>
No, if you are expecting the wakeup by sending some character on the
console, then it's ttyAMA0 which uses the pl011 UART. May be you can
also generate wakeup by toggling RTS/CTS hardware flow signals.
> By checking the sysfs, I find that the value of
> "sys/devices/platform/7ff80000.uart/power/wakeup" is "enabled", which
> can also prove above information. However, the value of
> "dev.power.wakeup->wakeirq->irq" for uart is 24 which is the same with
> ttyAMA0.
Ah, you need to use /sys/class/tty/ttyAMA0/power/wakeup
Regards,
Sudeep
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] modify pl011 driver to work as wakeup source
[not found] ` <CAN2waFuNChUJcTbwM-yZPqzptQmRFW2Mhg1fA0VPEKRyT+9kFg@mail.gmail.com>
@ 2015-08-28 13:14 ` Sudeep Holla
0 siblings, 0 replies; 7+ messages in thread
From: Sudeep Holla @ 2015-08-28 13:14 UTC (permalink / raw)
To: Zhaoyang Huang, tony@atomide.com
Cc: Sudeep Holla, Daniel Lezcano, Amit Kucheria, Serge Broslavsky,
linux-pm@vger.kernel.org
On 28/08/15 10:43, Zhaoyang Huang wrote:
> I would like loop Tony for more discussion.
>
> Hi Tony,
> I met a problem when using your latest API for setting wakeup source.
> The basic phenomenon is the ttyAMA0 can not wakeup the whole system even
> if the wakeup node of its </power/wakeup> has been set to be enabled. By
> doing some basic debug, I find that the corresponding isr was set to
> suspend even with above setting have been take effect.
>
I don't quite understand the issue you are facing, but for sure
IRQF_NO_SUSPEND is not the right way to fix this. Please read the
document, it clearly states ".. but does not guarantee that the
interrupt will wake the system from a suspended state, for such cases
it is necessary to use enable_irq_wake()".
dev_pm_set_wake_irq is just new alternative for enable_irq_wake.
I have tried this API with RTC and it works fine, so I don't see any
issue unless you are exploring something new in the code path you are
using this API. I even tried with UART though it was a hack.
So this patch is wrong and you also fails to explain why you need a
console as a wake up source, for just testing ?
Regards,
Sudeep
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2015-08-28 13:14 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-14 10:24 [PATCH] modify pl011 driver to work as wakeup source Zhaoyang Huang
2015-08-14 10:58 ` Daniel Lezcano
[not found] ` <CAN2waFv+8KM_TCw=iy1BOn-KmYuZRVmr5jKAniJwCaxBjqXvNQ@mail.gmail.com>
2015-08-26 13:46 ` Amit Kucheria
2015-08-26 14:00 ` Daniel Lezcano
2015-08-26 15:36 ` Sudeep Holla
[not found] ` <CAN2waFtcVHoSX6QGZQFzJJ2fkYVk1mUsgMn1HYGGd-+TT-XMjw@mail.gmail.com>
2015-08-27 10:51 ` Sudeep Holla
[not found] ` <CAN2waFsMVEYHy4rb7qJX8Tgxs1d+EuAOXPpbn2SVEoQuXkt9DA@mail.gmail.com>
[not found] ` <CAN2waFuNChUJcTbwM-yZPqzptQmRFW2Mhg1fA0VPEKRyT+9kFg@mail.gmail.com>
2015-08-28 13:14 ` Sudeep Holla
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).