qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: qemu-devel@nongnu.org
Cc: qemu-ppc@nongnu.org, "BALATON Zoltan" <balaton@eik.bme.hu>,
	"Gerd Hoffmann" <kraxel@redhat.com>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>
Subject: [PULL 17/20] hw/usb/ohci: Implement resume on connection status change
Date: Wed,  8 Mar 2023 00:47:08 +0100	[thread overview]
Message-ID: <20230307234711.55375-18-philmd@linaro.org> (raw)
In-Reply-To: <20230307234711.55375-1-philmd@linaro.org>

From: BALATON Zoltan <balaton@eik.bme.hu>

If certain bit is set remote wake up should change state from
suspended to resume and generate interrupt. There was a todo comment
for this, implement that by moving existing resume logic to a function
and call that.

Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Message-Id: <35c4d4ccf2f73e6a87cdbd28fb6a1b33de72ed74.1676916640.git.balaton@eik.bme.hu>
[PMD: Have ohci_resume() return a boolean]
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/usb/hcd-ohci.c | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)

diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c
index 6f8b543243..88d2b4b13c 100644
--- a/hw/usb/hcd-ohci.c
+++ b/hw/usb/hcd-ohci.c
@@ -1410,6 +1410,18 @@ static void ohci_set_hub_status(OHCIState *ohci, uint32_t val)
     }
 }
 
+/* This is the one state transition the controller can do by itself */
+static bool ohci_resume(OHCIState *s)
+{
+    if ((s->ctl & OHCI_CTL_HCFS) == OHCI_USB_SUSPEND) {
+        trace_usb_ohci_remote_wakeup(s->name);
+        s->ctl &= ~OHCI_CTL_HCFS;
+        s->ctl |= OHCI_USB_RESUME;
+        return true;
+    }
+    return false;
+}
+
 /*
  * Sets a flag in a port status reg but only set it if the port is connected.
  * If not set ConnectStatusChange flag. If flag is enabled return 1.
@@ -1426,7 +1438,10 @@ static int ohci_port_set_if_connected(OHCIState *ohci, int i, uint32_t val)
     if (!(ohci->rhport[i].ctrl & OHCI_PORT_CCS)) {
         ohci->rhport[i].ctrl |= OHCI_PORT_CSC;
         if (ohci->rhstatus & OHCI_RHS_DRWE) {
-            /* TODO: CSC is a wakeup event */
+            /* CSC is a wakeup event */
+            if (ohci_resume(ohci)) {
+                ohci_set_interrupt(ohci, OHCI_INTR_RD);
+            }
         }
         return 0;
     }
@@ -1828,11 +1843,7 @@ static void ohci_wakeup(USBPort *port1)
         intr = OHCI_INTR_RHSC;
     }
     /* Note that the controller can be suspended even if this port is not */
-    if ((s->ctl & OHCI_CTL_HCFS) == OHCI_USB_SUSPEND) {
-        trace_usb_ohci_remote_wakeup(s->name);
-        /* This is the one state transition the controller can do by itself */
-        s->ctl &= ~OHCI_CTL_HCFS;
-        s->ctl |= OHCI_USB_RESUME;
+    if (ohci_resume(s)) {
         /*
          * In suspend mode only ResumeDetected is possible, not RHSC:
          * see the OHCI spec 5.1.2.3.
-- 
2.38.1



  parent reply	other threads:[~2023-03-07 23:50 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-07 23:46 [PULL 00/20] MIPS patches for 2023-03-07 Philippe Mathieu-Daudé
2023-03-07 23:46 ` [PULL 01/20] docs/system: Remove "mips" board from target-mips.rst Philippe Mathieu-Daudé
2023-03-07 23:46 ` [PULL 02/20] target/mips: Replace [g_]assert(0) -> g_assert_not_reached() Philippe Mathieu-Daudé
2023-03-07 23:46 ` [PULL 03/20] target/mips: Fix JALS32/J32 instruction handling for microMIPS Philippe Mathieu-Daudé
2023-03-07 23:46 ` [PULL 04/20] target/mips: Fix SWM32 " Philippe Mathieu-Daudé
2023-03-07 23:46 ` [PULL 05/20] target/mips: Implement CP0.Config7.WII bit support Philippe Mathieu-Daudé
2023-03-07 23:46 ` [PULL 06/20] target/mips: Set correct CP0.Config[4, 5] values for M14K(c) Philippe Mathieu-Daudé
2023-03-07 23:46 ` [PULL 07/20] hw/mips: Declare all length properties as unsigned Philippe Mathieu-Daudé
2023-03-07 23:46 ` [PULL 08/20] hw/mips/itu: Pass SAAR using QOM link property Philippe Mathieu-Daudé
2023-03-07 23:47 ` [PULL 09/20] Revert "hw/isa/i82378: Remove intermediate IRQ forwarder" Philippe Mathieu-Daudé
2023-03-07 23:47 ` [PULL 10/20] Revert "hw/isa/vt82c686: " Philippe Mathieu-Daudé
2023-03-07 23:47 ` [PULL 11/20] hw/display/sm501: Add debug property to control pixman usage Philippe Mathieu-Daudé
2023-03-07 23:47 ` [PULL 12/20] hw/intc/i8259: Implement legacy LTIM Edge/Level Bank Select Philippe Mathieu-Daudé
2023-03-07 23:47 ` [PULL 13/20] hw/isa/vt82c686: Implement PCI IRQ routing Philippe Mathieu-Daudé
2023-03-07 23:47 ` [PULL 14/20] hw/ppc/pegasos2: Fix PCI interrupt routing Philippe Mathieu-Daudé
2023-03-08 13:54   ` Philippe Mathieu-Daudé
2023-03-08 14:46     ` BALATON Zoltan
2023-03-08 18:51       ` BALATON Zoltan
2023-03-07 23:47 ` [PULL 15/20] hw/usb/vt82c686-uhci-pci: Use PCI IRQ routing Philippe Mathieu-Daudé
2023-03-07 23:47 ` [PULL 16/20] hw/audio/via-ac97: Basic implementation of audio playback Philippe Mathieu-Daudé
2023-03-07 23:47 ` Philippe Mathieu-Daudé [this message]
2023-03-07 23:47 ` [PULL 18/20] ui/cocoa: Override windowDidResignKey Philippe Mathieu-Daudé
2023-03-07 23:47 ` [PULL 19/20] memory: Dump HPA and access type of ramblocks Philippe Mathieu-Daudé
2023-03-07 23:47 ` [PULL 20/20] log: Remove unneeded new line Philippe Mathieu-Daudé
2023-03-09 13:13 ` [PULL 00/20] MIPS patches for 2023-03-07 Peter Maydell

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=20230307234711.55375-18-philmd@linaro.org \
    --to=philmd@linaro.org \
    --cc=balaton@eik.bme.hu \
    --cc=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@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).