From patchwork Fri Dec 17 11:26:34 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 75879 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id BB160B6EEB for ; Fri, 17 Dec 2010 23:10:28 +1100 (EST) Received: from localhost ([127.0.0.1]:46460 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PTZ8j-0000LT-5n for incoming@patchwork.ozlabs.org; Fri, 17 Dec 2010 07:10:25 -0500 Received: from [140.186.70.92] (port=39265 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PTYTH-0008Du-8F for qemu-devel@nongnu.org; Fri, 17 Dec 2010 06:27:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PTYT4-0007Vt-FN for qemu-devel@nongnu.org; Fri, 17 Dec 2010 06:27:23 -0500 Received: from mx1.redhat.com ([209.132.183.28]:59525) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PTYT3-0007VV-P8 for qemu-devel@nongnu.org; Fri, 17 Dec 2010 06:27:22 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id oBHBRK73029550 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 17 Dec 2010 06:27:21 -0500 Received: from rincewind.home.kraxel.org (vpn2-10-81.ams2.redhat.com [10.36.10.81]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id oBHBRHP4004991; Fri, 17 Dec 2010 06:27:19 -0500 Received: by rincewind.home.kraxel.org (Postfix, from userid 500) id 076EF41327; Fri, 17 Dec 2010 12:26:48 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Fri, 17 Dec 2010 12:26:34 +0100 Message-Id: <1292585206-24862-19-git-send-email-kraxel@redhat.com> In-Reply-To: <1292585206-24862-1-git-send-email-kraxel@redhat.com> References: <1292585206-24862-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: Gerd Hoffmann Subject: [Qemu-devel] [PATCH 18/30] usb: uhci: remote wakeup support. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Add support for remote wakeup to the UHCI adapter. Signed-off-by: Gerd Hoffmann --- hw/usb-uhci.c | 23 +++++++++++++++++++++-- 1 files changed, 21 insertions(+), 2 deletions(-) diff --git a/hw/usb-uhci.c b/hw/usb-uhci.c index debf7f7..60d5d57 100644 --- a/hw/usb-uhci.c +++ b/hw/usb-uhci.c @@ -57,13 +57,18 @@ #define TD_CTRL_NAK (1 << 19) #define TD_CTRL_TIMEOUT (1 << 18) +#define UHCI_PORT_SUSPEND (1 << 12) #define UHCI_PORT_RESET (1 << 9) #define UHCI_PORT_LSDA (1 << 8) +#define UHCI_PORT_RD (1 << 6) #define UHCI_PORT_ENC (1 << 3) #define UHCI_PORT_EN (1 << 2) #define UHCI_PORT_CSC (1 << 1) #define UHCI_PORT_CCS (1 << 0) +#define UHCI_PORT_READ_ONLY (0x1bb) +#define UHCI_PORT_WRITE_CLEAR (UHCI_PORT_CSC | UHCI_PORT_ENC) + #define FRAME_TIMER_FREQ 1000 #define FRAME_MAX_LOOPS 100 @@ -497,9 +502,10 @@ static void uhci_ioport_writew(void *opaque, uint32_t addr, uint32_t val) usb_send_msg(dev, USB_MSG_RESET); } } - port->ctrl = (port->ctrl & 0x01fb) | (val & ~0x01fb); + port->ctrl &= UHCI_PORT_READ_ONLY; + port->ctrl |= (val & ~UHCI_PORT_READ_ONLY); /* some bits are reset when a '1' is written to them */ - port->ctrl &= ~(val & 0x000a); + port->ctrl &= ~(val & UHCI_PORT_WRITE_CLEAR); } break; } @@ -629,6 +635,18 @@ static void uhci_detach(USBPort *port1) uhci_resume(s); } +static void uhci_wakeup(USBDevice *dev) +{ + USBBus *bus = usb_bus_from_device(dev); + UHCIState *s = container_of(bus, UHCIState, bus); + UHCIPort *port = s->ports + dev->port->index; + + if (port->ctrl & UHCI_PORT_SUSPEND && !(port->ctrl & UHCI_PORT_RD)) { + port->ctrl |= UHCI_PORT_RD; + uhci_resume(s); + } +} + static int uhci_broadcast_packet(UHCIState *s, USBPacket *p) { int i, ret; @@ -1094,6 +1112,7 @@ static void uhci_map(PCIDevice *pci_dev, int region_num, static USBPortOps uhci_port_ops = { .attach = uhci_attach, .detach = uhci_detach, + .wakeup = uhci_wakeup, }; static int usb_uhci_common_initfn(UHCIState *s)