* [PATCH] 8250: Allow platform to register PM hook
@ 2008-11-27 0:25 Kevin Hilman
2008-11-27 0:25 ` [PATCH] 8250: when waking, PM hook should be called before accessing port Kevin Hilman
0 siblings, 1 reply; 2+ messages in thread
From: Kevin Hilman @ 2008-11-27 0:25 UTC (permalink / raw)
To: linux-serial; +Cc: linux-omap
Allow platform code to register a PM hook with the 8250 driver. This
enables platform specific code to be run for suspend/resume events.
Since the per-port PM hook is local to the 8250 driver ('struct
uart_port' doesn't have a PM hook) I pass the pm hook from the
platform probe via serial8250_register_port().
Signed-off-by: Kevin Hilman <khilman@deeprootsystems.com>
---
drivers/serial/8250.c | 7 +++++--
include/linux/serial_8250.h | 7 ++++++-
2 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c
index 5f383d8..993a242 100644
--- a/drivers/serial/8250.c
+++ b/drivers/serial/8250.c
@@ -2842,7 +2842,7 @@ static int __devinit serial8250_probe(struct platform_device *dev)
port.dev = &dev->dev;
if (share_irqs)
port.flags |= UPF_SHARE_IRQ;
- ret = serial8250_register_port(&port);
+ ret = serial8250_register_port(&port, p->pm);
if (ret < 0) {
dev_err(&dev->dev, "unable to register port at index %d "
"(IO%lx MEM%llx IRQ%d): %d\n", i,
@@ -2966,7 +2966,9 @@ static struct uart_8250_port *serial8250_find_match_or_unused(struct uart_port *
*
* On success the port is ready to use and the line number is returned.
*/
-int serial8250_register_port(struct uart_port *port)
+int serial8250_register_port(struct uart_port *port,
+ void (*pm)(struct uart_port *, unsigned int state,
+ unsigned int oldstate))
{
struct uart_8250_port *uart;
int ret = -ENOSPC;
@@ -2990,6 +2992,7 @@ int serial8250_register_port(struct uart_port *port)
uart->port.flags = port->flags | UPF_BOOT_AUTOCONF;
uart->port.mapbase = port->mapbase;
uart->port.private_data = port->private_data;
+ uart->pm = pm;
if (port->dev)
uart->port.dev = port->dev;
diff --git a/include/linux/serial_8250.h b/include/linux/serial_8250.h
index 3d37c94..97723c5 100644
--- a/include/linux/serial_8250.h
+++ b/include/linux/serial_8250.h
@@ -28,6 +28,9 @@ struct plat_serial8250_port {
unsigned char iotype; /* UPIO_* */
unsigned char hub6;
upf_t flags; /* UPF_* flags */
+
+ void (*pm)(struct uart_port *, unsigned int state,
+ unsigned int oldstate);
};
/*
@@ -57,7 +60,9 @@ enum {
*/
struct uart_port;
-int serial8250_register_port(struct uart_port *);
+int serial8250_register_port(struct uart_port *,
+ void (*pm)(struct uart_port *, unsigned int state,
+ unsigned int oldstate));
void serial8250_unregister_port(int line);
void serial8250_suspend_port(int line);
void serial8250_resume_port(int line);
--
1.6.0.3
^ permalink raw reply related [flat|nested] 2+ messages in thread* [PATCH] 8250: when waking, PM hook should be called before accessing port
2008-11-27 0:25 [PATCH] 8250: Allow platform to register PM hook Kevin Hilman
@ 2008-11-27 0:25 ` Kevin Hilman
0 siblings, 0 replies; 2+ messages in thread
From: Kevin Hilman @ 2008-11-27 0:25 UTC (permalink / raw)
To: linux-serial; +Cc: linux-omap
The UART suspend hook may have disabled the UART clocks such that
accesses to the port may fail. So before accessing the port
call the PM hook so it has a chance to enable clocks.
Signed-off-by: Kevin Hilman <khilman@deeprootsystems.com>
---
drivers/serial/8250.c | 12 ++++++++++--
1 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c
index 993a242..a181667 100644
--- a/drivers/serial/8250.c
+++ b/drivers/serial/8250.c
@@ -2334,10 +2334,18 @@ serial8250_pm(struct uart_port *port, unsigned int state,
unsigned int oldstate)
{
struct uart_8250_port *p = (struct uart_8250_port *)port;
+ int sleep = state != 0;
- serial8250_set_sleep(p, state != 0);
+ /* If we're waking up, call the PM hook before waking up
+ * so port can be properly activated/enabled if necessary */
+ if (p->pm && !sleep)
+ p->pm(port, state, oldstate);
+
+ serial8250_set_sleep(p, sleep);
- if (p->pm)
+ /* If we're going to sleep, PM hook should be called after
+ * to deactivate/disable port */
+ if (p->pm && sleep)
p->pm(port, state, oldstate);
}
--
1.6.0.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-11-27 0:25 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-27 0:25 [PATCH] 8250: Allow platform to register PM hook Kevin Hilman
2008-11-27 0:25 ` [PATCH] 8250: when waking, PM hook should be called before accessing port Kevin Hilman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox