* [PATCH v2] serial: 8250: omap: Provide ability to enable/disable UART as wakeup source
@ 2018-04-02 12:20 Vignesh R
2018-04-02 14:01 ` Andy Shevchenko
0 siblings, 1 reply; 3+ messages in thread
From: Vignesh R @ 2018-04-02 12:20 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Jiri Slaby, Tony Lindgren, Vignesh R, linux-serial, linux-kernel,
linux-omap
Enable/Clear module level UART wakeup in UART_OMAP_WER register based on
return value of device_may_wakeup() in .suspend(). This allows
userspace to use sysfs to control the ability of UART to wakeup the
system from deep sleep state. Register is restored back in .startup()
call that happens as part of resume sequence.
With this patch, userspace can control UART wakeup capability via sysfs:
To enable wakeup capability:
echo enabled > /sys/class/tty/ttyXX/device/power/wakeup
For disabling wakeup capability:
echo disabled > /sys/class/tty/ttyXX/device/power/wakeup
Note that the UART wakeup events configured in the 8250 hardware only
work for idle modes that do not cut off power for the UART. For deeper
idle states, dedicated padconf wakeirqs must be used. Or in some cases
the UART RX pin can be remuxed to GPIO input if the GPIO block stays
powered.
Signed-off-by: Vignesh R <vigneshr@ti.com>
Tested-by: Tony Lindgren <tony@atomide.com>
---
v2: update commit log.
drivers/tty/serial/8250/8250_omap.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/drivers/tty/serial/8250/8250_omap.c b/drivers/tty/serial/8250/8250_omap.c
index 624b501fd253..6aaa84355fd1 100644
--- a/drivers/tty/serial/8250/8250_omap.c
+++ b/drivers/tty/serial/8250/8250_omap.c
@@ -1310,8 +1310,17 @@ static void omap8250_complete(struct device *dev)
static int omap8250_suspend(struct device *dev)
{
struct omap8250_priv *priv = dev_get_drvdata(dev);
+ struct uart_8250_port *up = serial8250_get_port(priv->line);
serial8250_suspend_port(priv->line);
+
+ pm_runtime_get_sync(dev);
+ if (!device_may_wakeup(dev))
+ priv->wer = 0;
+ serial_out(up, UART_OMAP_WER, priv->wer);
+ pm_runtime_mark_last_busy(dev);
+ pm_runtime_put_autosuspend(dev);
+
flush_work(&priv->qos_work);
return 0;
}
@@ -1403,6 +1412,8 @@ static int omap8250_runtime_suspend(struct device *dev)
/* Restore to UART mode after reset (for wakeup) */
omap8250_update_mdr1(up, priv);
+ /* Restore wakeup enable register */
+ serial_out(up, UART_OMAP_WER, priv->wer);
}
if (up->dma && up->dma->rxchan)
--
2.16.2
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH v2] serial: 8250: omap: Provide ability to enable/disable UART as wakeup source
2018-04-02 12:20 [PATCH v2] serial: 8250: omap: Provide ability to enable/disable UART as wakeup source Vignesh R
@ 2018-04-02 14:01 ` Andy Shevchenko
2018-04-02 14:03 ` Andy Shevchenko
0 siblings, 1 reply; 3+ messages in thread
From: Andy Shevchenko @ 2018-04-02 14:01 UTC (permalink / raw)
To: Vignesh R
Cc: Greg Kroah-Hartman, Jiri Slaby, Tony Lindgren,
open list:SERIAL DRIVERS, Linux Kernel Mailing List,
Linux OMAP Mailing List
On Mon, Apr 2, 2018 at 3:20 PM, Vignesh R <vigneshr@ti.com> wrote:
> + pm_runtime_get_sync(dev);
> + if (!device_may_wakeup(dev))
> + priv->wer = 0;
Can it be
priv->wer = device_may_wakeup(dev);
?
> + serial_out(up, UART_OMAP_WER, priv->wer);
> + pm_runtime_mark_last_busy(dev);
> + pm_runtime_put_autosuspend(dev);
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] serial: 8250: omap: Provide ability to enable/disable UART as wakeup source
2018-04-02 14:01 ` Andy Shevchenko
@ 2018-04-02 14:03 ` Andy Shevchenko
0 siblings, 0 replies; 3+ messages in thread
From: Andy Shevchenko @ 2018-04-02 14:03 UTC (permalink / raw)
To: Vignesh R
Cc: Greg Kroah-Hartman, Jiri Slaby, Tony Lindgren,
open list:SERIAL DRIVERS, Linux Kernel Mailing List,
Linux OMAP Mailing List
On Mon, Apr 2, 2018 at 5:01 PM, Andy Shevchenko
<andy.shevchenko@gmail.com> wrote:
> On Mon, Apr 2, 2018 at 3:20 PM, Vignesh R <vigneshr@ti.com> wrote:
>> + if (!device_may_wakeup(dev))
>> + priv->wer = 0;
>
> Can it be
>
> priv->wer = device_may_wakeup(dev);
>
> ?
Answering to myself, missed that this value is used as actual one for the HW.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-04-02 14:03 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-04-02 12:20 [PATCH v2] serial: 8250: omap: Provide ability to enable/disable UART as wakeup source Vignesh R
2018-04-02 14:01 ` Andy Shevchenko
2018-04-02 14:03 ` Andy Shevchenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox