All of lore.kernel.org
 help / color / mirror / Atom feed
* wake up from a serial port
@ 2007-08-25 22:38 Budhee Jamaich
  2007-08-27  7:06 ` Tony Lindgren
  0 siblings, 1 reply; 8+ messages in thread
From: Budhee Jamaich @ 2007-08-25 22:38 UTC (permalink / raw)
  To: linux-omap-open-source

hello list,

i am working on 2430 and I need to enable
wakeup from a serial port.

a patch which does this very thing has just been posted on lkml:
http://article.gmane.org/gmane.linux.kernel/574545

is it relevant to me ?

or is there already a way to do that ?

thank you very much
budhee

^ permalink raw reply	[flat|nested] 8+ messages in thread
* + wake-up-from-a-serial-port.patch added to -mm tree
@ 2007-09-10  8:31 akpm
       [not found] ` <20070910132703.2dd92485@the-village.bc.nu>
  0 siblings, 1 reply; 8+ messages in thread
From: akpm @ 2007-09-10  8:31 UTC (permalink / raw)
  To: mm-commits; +Cc: g.liakhovetski, alan, greg, pavel, rjw, rmk


The patch titled
     wake up from a serial port
has been added to the -mm tree.  Its filename is
     wake-up-from-a-serial-port.patch

*** Remember to use Documentation/SubmitChecklist when testing your code ***

See http://www.zip.com.au/~akpm/linux/patches/stuff/added-to-mm.txt to find
out what to do about this

------------------------------------------------------
Subject: wake up from a serial port
From: Guennadi Liakhovetski <g.liakhovetski@gmx.de>

Enable wakeup from serial ports, make it run-time configurable over sysfs,
e.g.,

echo enabled > /sys/devices/platform/serial8250.0/tty/ttyS0/power/wakeup

Requires

# CONFIG_SYSFS_DEPRECATED is not set

Linkstation / kurobox systems from Buffalo Tech.  have an AVR controller
connected to host's UART.  The AVR controls power, buttons, fan, LEDs,
sensors...  So, practically the only way to wake the system up is to press a
button, which sends a byte from the AVR to the CPU.

Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: "Rafael J. Wysocki" <rjw@sisk.pl>
Cc: Greg KH <greg@kroah.com>
Cc: Russell King <rmk@arm.linux.org.uk>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 drivers/serial/8250.c        |   30 ++++++++++++++++++++++++++----
 drivers/serial/serial_core.c |    9 ++++++++-
 2 files changed, 34 insertions(+), 5 deletions(-)

diff -puN drivers/serial/8250.c~wake-up-from-a-serial-port drivers/serial/8250.c
--- a/drivers/serial/8250.c~wake-up-from-a-serial-port
+++ a/drivers/serial/8250.c
@@ -129,6 +129,7 @@ struct uart_8250_port {
 	unsigned char		mcr;
 	unsigned char		mcr_mask;	/* mask of user bits */
 	unsigned char		mcr_force;	/* mask of forced bits */
+	char			suspended;
 
 	/*
 	 * Some bits in registers are cleared on a read, so they must
@@ -2701,6 +2702,14 @@ static int __devexit serial8250_remove(s
 	return 0;
 }
 
+static int serial8250_match_port(struct device *dev, void *data)
+{
+	struct uart_port *port = data;
+	dev_t devt = MKDEV(serial8250_reg.major, serial8250_reg.minor) + port->line;
+
+	return dev->devt == devt; /* Actually, only one tty per port */
+}
+
 static int serial8250_suspend(struct platform_device *dev, pm_message_t state)
 {
 	int i;
@@ -2708,8 +2717,16 @@ static int serial8250_suspend(struct pla
 	for (i = 0; i < UART_NR; i++) {
 		struct uart_8250_port *up = &serial8250_ports[i];
 
-		if (up->port.type != PORT_UNKNOWN && up->port.dev == &dev->dev)
-			uart_suspend_port(&serial8250_reg, &up->port);
+		if (up->port.type != PORT_UNKNOWN && up->port.dev == &dev->dev) {
+			struct device *tty_dev = device_find_child(up->port.dev, &up->port,
+								   serial8250_match_port);
+			if (device_may_wakeup(tty_dev))
+				enable_irq_wake(up->port.irq);
+			else {
+				uart_suspend_port(&serial8250_reg, &up->port);
+				up->suspended = 1;
+			}
+		}
 	}
 
 	return 0;
@@ -2722,8 +2739,13 @@ static int serial8250_resume(struct plat
 	for (i = 0; i < UART_NR; i++) {
 		struct uart_8250_port *up = &serial8250_ports[i];
 
-		if (up->port.type != PORT_UNKNOWN && up->port.dev == &dev->dev)
-			serial8250_resume_port(i);
+		if (up->port.type != PORT_UNKNOWN && up->port.dev == &dev->dev) {
+			if (up->suspended) {
+				serial8250_resume_port(i);
+				up->suspended = 0;
+			} else
+				disable_irq_wake(up->port.irq);
+		}
 	}
 
 	return 0;
diff -puN drivers/serial/serial_core.c~wake-up-from-a-serial-port drivers/serial/serial_core.c
--- a/drivers/serial/serial_core.c~wake-up-from-a-serial-port
+++ a/drivers/serial/serial_core.c
@@ -2271,6 +2271,7 @@ int uart_add_one_port(struct uart_driver
 {
 	struct uart_state *state;
 	int ret = 0;
+	struct device *tty_dev;
 
 	BUG_ON(in_interrupt());
 
@@ -2306,7 +2307,13 @@ int uart_add_one_port(struct uart_driver
 	 * Register the port whether it's detected or not.  This allows
 	 * setserial to be used to alter this ports parameters.
 	 */
-	tty_register_device(drv->tty_driver, port->line, port->dev);
+	tty_dev = tty_register_device(drv->tty_driver, port->line, port->dev);
+	if (likely(!IS_ERR(tty_dev))) {
+		device_can_wakeup(tty_dev) = 1;
+		device_set_wakeup_enable(tty_dev, 0);
+	} else
+		printk(KERN_ERR "Cannot register tty device on line %d\n",
+		       port->line);
 
 	/*
 	 * If this driver supports console, and it hasn't been
_

Patches currently in -mm which might be from g.liakhovetski@gmx.de are

git-powerpc.patch
wake-up-from-a-serial-port.patch

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2007-09-13 20:29 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-25 22:38 wake up from a serial port Budhee Jamaich
2007-08-27  7:06 ` Tony Lindgren
2007-08-27  8:38   ` Budhee Jamaich
2007-08-27 11:14     ` Tony Lindgren
2007-08-27 12:21       ` Woodruff, Richard
2007-08-31 17:40         ` Tony Lindgren
  -- strict thread matches above, loose matches on Subject: below --
2007-09-10  8:31 + wake-up-from-a-serial-port.patch added to -mm tree akpm
     [not found] ` <20070910132703.2dd92485@the-village.bc.nu>
     [not found]   ` <Pine.LNX.4.60.0709102251250.5200@poirot.grange>
     [not found]     ` <20070911081220.GA20847@flint.arm.linux.org.uk>
     [not found]       ` <Pine.LNX.4.60.0709111217470.19259@poirot.grange>
     [not found]         ` <20070911121057.34b9e066@the-village.bc.nu>
2007-09-12 18:50           ` [PATCH] wake up from a serial port Guennadi Liakhovetski
2007-09-12 21:06             ` Michael Mauch
2007-09-13 20:29               ` Guennadi Liakhovetski

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.