qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Gerd Hoffmann <kraxel@redhat.com>
Subject: [Qemu-devel] [PATCH 18/30] usb: uhci: remote wakeup support.
Date: Fri, 17 Dec 2010 12:26:34 +0100	[thread overview]
Message-ID: <1292585206-24862-19-git-send-email-kraxel@redhat.com> (raw)
In-Reply-To: <1292585206-24862-1-git-send-email-kraxel@redhat.com>

Add support for remote wakeup to the UHCI adapter.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 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)
-- 
1.7.1

  parent reply	other threads:[~2010-12-17 11:27 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-17 11:26 [Qemu-devel] [PATCH 00/30] usb descriptor overhaul + more Gerd Hoffmann
2010-12-17 11:26 ` [Qemu-devel] [PATCH 01/30] usb: update MAINTAINERS Gerd Hoffmann
2010-12-17 11:26 ` [Qemu-devel] [PATCH 02/30] usb: data structs and helpers for usb descriptors Gerd Hoffmann
2010-12-17 11:26 ` [Qemu-devel] [PATCH 03/30] usb hid: use new descriptor infrastructure Gerd Hoffmann
2010-12-17 11:26 ` [Qemu-devel] [PATCH 04/30] usb serial: " Gerd Hoffmann
2010-12-17 11:26 ` [Qemu-devel] [PATCH 05/30] usb storage: " Gerd Hoffmann
2010-12-17 11:26 ` [Qemu-devel] [PATCH 06/30] usb wacom: " Gerd Hoffmann
2010-12-17 11:26 ` [Qemu-devel] [PATCH 07/30] usb bluetooth: " Gerd Hoffmann
2010-12-17 11:26 ` [Qemu-devel] [PATCH 08/30] usb hub: " Gerd Hoffmann
2010-12-17 11:26 ` [Qemu-devel] [PATCH 09/30] usb descriptors: add settable strings Gerd Hoffmann
2010-12-17 11:26 ` [Qemu-devel] [PATCH 10/30] usb storage: serial number support Gerd Hoffmann
2010-12-17 11:26 ` [Qemu-devel] [PATCH 11/30] usb network: use new descriptor infrastructure Gerd Hoffmann
2010-12-17 11:26 ` [Qemu-devel] [PATCH 12/30] usb: move USB_REQ_SET_ADDRESS handling to common code Gerd Hoffmann
2010-12-17 11:26 ` [Qemu-devel] [PATCH 13/30] usb: move USB_REQ_{GET, SET}_CONFIGURATION " Gerd Hoffmann
2010-12-17 11:26 ` [Qemu-devel] [PATCH 14/30] usb: move remote wakeup " Gerd Hoffmann
2010-12-17 11:26 ` [Qemu-devel] [PATCH 15/30] usb: create USBPortOps, move attach there Gerd Hoffmann
2010-12-17 11:26 ` [Qemu-devel] [PATCH 16/30] usb: rework attach/detach workflow Gerd Hoffmann
2010-12-17 11:26 ` [Qemu-devel] [PATCH 17/30] usb: add usb_wakeup() + wakeup callback to port ops Gerd Hoffmann
2010-12-17 11:26 ` Gerd Hoffmann [this message]
2010-12-17 11:26 ` [Qemu-devel] [PATCH 19/30] usb: hub: remote wakeup support Gerd Hoffmann
2010-12-17 11:26 ` [Qemu-devel] [PATCH 20/30] usb: hid: " Gerd Hoffmann
2010-12-17 11:26 ` [Qemu-devel] [PATCH 21/30] usb: hid: change serial number to "42" Gerd Hoffmann
2010-12-17 11:26 ` [Qemu-devel] [PATCH 22/30] usb: add speed mask to ports Gerd Hoffmann
2010-12-17 11:26 ` [Qemu-devel] [PATCH 23/30] usb: add attach callback Gerd Hoffmann
2010-12-17 11:26 ` [Qemu-devel] [PATCH 24/30] usb: add usb_desc_attach Gerd Hoffmann
2010-12-17 11:26 ` [Qemu-devel] [PATCH 25/30] usb: add device qualifier support Gerd Hoffmann
2010-12-17 11:26 ` [Qemu-devel] [PATCH 26/30] usb storage: high speed support Gerd Hoffmann
2010-12-17 11:26 ` [Qemu-devel] [PATCH 27/30] usb storage: fix status reporting Gerd Hoffmann
2010-12-17 11:26 ` [Qemu-devel] [PATCH 28/30] usb storage: handle long responses Gerd Hoffmann
2010-12-17 11:26 ` [Qemu-devel] [PATCH 29/30] usb: keep track of physical port address Gerd Hoffmann
2010-12-17 11:26 ` [Qemu-devel] [PATCH 30/30] usb: add port property Gerd Hoffmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1292585206-24862-19-git-send-email-kraxel@redhat.com \
    --to=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).