From patchwork Tue Jun 7 18:50:12 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 99318 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 42902B6FDA for ; Wed, 8 Jun 2011 04:54:52 +1000 (EST) Received: from localhost ([::1]:46354 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QU1QO-00043S-GQ for incoming@patchwork.ozlabs.org; Tue, 07 Jun 2011 14:54:48 -0400 Received: from eggs.gnu.org ([140.186.70.92]:37588) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QU1MA-0003oi-O9 for qemu-devel@nongnu.org; Tue, 07 Jun 2011 14:50:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QU1M7-0001cv-9U for qemu-devel@nongnu.org; Tue, 07 Jun 2011 14:50:26 -0400 Received: from mnementh.archaic.org.uk ([81.2.115.146]:48905) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QU1M6-0001Z0-Cb for qemu-devel@nongnu.org; Tue, 07 Jun 2011 14:50:22 -0400 Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.72) (envelope-from ) id 1QU1Lw-0006gg-VE; Tue, 07 Jun 2011 19:50:12 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Tue, 7 Jun 2011 19:50:12 +0100 Message-Id: <1307472612-25683-1-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.2.5 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 81.2.115.146 Cc: Gerd Hoffmann , patches@linaro.org Subject: [Qemu-devel] [PATCH] hw/usb-ohci.c: Implement remote wakeup X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Implement the wakeup callback in the OHCI USBPortOps, so that when a downstream device wakes up it correctly causes the OHCI controller to come out of suspend. Signed-off-by: Peter Maydell --- This patch fixes USB keyboard support on (the not-yet-upstream) OMAP3 for me -- without it Linux puts the port and then the OHCI controller into suspend, and usb-kbd can't get the controller out of reset when you press a key. It works for me and I think it's right, but I'm no USB expert and it could use review from somebody who is. hw/usb-ohci.c | 17 +++++++++++++++++ 1 files changed, 17 insertions(+), 0 deletions(-) diff --git a/hw/usb-ohci.c b/hw/usb-ohci.c index 8b966f7..347814e 100644 --- a/hw/usb-ohci.c +++ b/hw/usb-ohci.c @@ -367,6 +367,22 @@ static void ohci_detach(USBPort *port1) ohci_set_interrupt(s, OHCI_INTR_RHSC); } +static void ohci_wakeup(USBDevice *dev) +{ + USBBus *bus = usb_bus_from_device(dev); + OHCIState *s = container_of(bus, OHCIState, bus); + int portnum = dev->port->index; + OHCIPort *port = &s->rhport[portnum]; + if (port->ctrl & OHCI_PORT_PSS) { + DPRINTF("usb-ohci: port %d: wakeup\n", portnum); + port->ctrl |= OHCI_PORT_PSSC; + port->ctrl &= ~OHCI_PORT_PSS; + if ((s->ctl & OHCI_CTL_HCFS) == OHCI_USB_SUSPEND) { + ohci_set_interrupt(s, OHCI_INTR_RD); + } + } +} + /* Reset the controller */ static void ohci_reset(void *opaque) { @@ -1661,6 +1677,7 @@ static CPUWriteMemoryFunc * const ohci_writefn[3]={ static USBPortOps ohci_port_ops = { .attach = ohci_attach, .detach = ohci_detach, + .wakeup = ohci_wakeup, .complete = ohci_async_complete_packet, };