public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Marcin Juszkiewicz" <marcin.juszkiewicz@linaro.org>
To: devel@edk2.groups.io
Cc: Leif Lindholm <quic_llindhol@quicinc.com>,
	 Ard Biesheuvel <ardb+tianocore@kernel.org>,
	 Jeremy Linton <jeremy.linton@arm.com>,
	 Nhi Pham <nhi@os.amperecomputing.com>,
	 Chuong Tran <chuong@os.amperecomputing.com>,
	 Rebecca Cran <rebecca@os.amperecomputing.com>,
	 Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org>
Subject: [edk2-devel] [PATCH edk2-platforms v5 3/4] SbsaQemu: initialize XHCI only if it exists
Date: Wed, 18 Oct 2023 13:55:40 +0200	[thread overview]
Message-ID: <20231018-ehci-xhci-fix-v5-3-f42995a3dfd9@linaro.org> (raw)
In-Reply-To: <20231018-ehci-xhci-fix-v5-0-f42995a3dfd9@linaro.org>

We need platform version to be at least 0.3 to have XHCI
in virtual hardware. On older platforms there is non-working
EHCI which we ignore.

Signed-off-by: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org>
---
 .../SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c        | 49 +++++++++++---------
 1 file changed, 27 insertions(+), 22 deletions(-)

diff --git a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c
index 36ada4270bbf..4ebbe7c93a19 100644
--- a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c
+++ b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c
@@ -15,6 +15,7 @@
 #include <Library/UefiBootServicesTableLib.h>
 #include <Library/UefiDriverEntryPoint.h>
 #include <IndustryStandard/SbsaQemuSmc.h>
+#include <IndustryStandard/SbsaQemuPlatformVersion.h>
 
 #include <Protocol/FdtClient.h>
 
@@ -57,28 +58,6 @@ InitializeSbsaQemuPlatformDxe (
     return Status;
   }
 
-  Base = (VOID*)(UINTN)PcdGet64 (PcdPlatformXhciBase);
-  ASSERT (Base != NULL);
-  Size = (UINTN)PcdGet32 (PcdPlatformXhciSize);
-  ASSERT (Size != 0);
-
-  DEBUG ((DEBUG_INFO, "%a: Got platform XHCI %llx %u\n",
-          __FUNCTION__, Base, Size));
-
-  Status = RegisterNonDiscoverableMmioDevice (
-                   NonDiscoverableDeviceTypeXhci,
-                   NonDiscoverableDeviceDmaTypeCoherent,
-                   NULL,
-                   NULL,
-                   1,
-                   Base, Size);
-
-  if (EFI_ERROR(Status)) {
-    DEBUG ((DEBUG_ERROR, "%a: NonDiscoverable: Cannot install XHCI device @%p (Staus == %r)\n",
-            __FUNCTION__, Base, Status));
-    return Status;
-  }
-
   SmcResult = ArmCallSmc0 (SIP_SVC_VERSION, &Arg0, &Arg1, NULL);
   if (SmcResult == SMC_ARCH_CALL_SUCCESS) {
     Result = PcdSet32S (PcdPlatformVersionMajor, Arg0);
@@ -118,5 +97,31 @@ InitializeSbsaQemuPlatformDxe (
 
   DEBUG ((DEBUG_INFO, "GICI base: 0x%x\n", Arg0));
 
+  if (!PLATFORM_VERSION_LESS_THAN (0, 3)) {
+    Base = (VOID *)(UINTN)PcdGet64 (PcdPlatformXhciBase);
+    ASSERT (Base != NULL);
+    Size = (UINTN)PcdGet32 (PcdPlatformXhciSize);
+    ASSERT (Size != 0);
+
+    DEBUG ((DEBUG_INFO, "%a: Got platform XHCI %llx %u\n",
+            __FUNCTION__, Base, Size));
+
+    Status = RegisterNonDiscoverableMmioDevice (
+                                                NonDiscoverableDeviceTypeXhci,
+                                                NonDiscoverableDeviceDmaTypeCoherent,
+                                                NULL,
+                                                NULL,
+                                                1,
+                                                Base,
+                                                Size
+                                                );
+
+    if (EFI_ERROR (Status)) {
+      DEBUG ((DEBUG_ERROR, "%a: NonDiscoverable: Cannot install XHCI device @%p (Status == %r)\n",
+              __FUNCTION__, Base, Status));
+      return Status;
+    }
+  }
+
   return EFI_SUCCESS;
 }

-- 
2.41.0



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#109738): https://edk2.groups.io/g/devel/message/109738
Mute This Topic: https://groups.io/mt/102037245/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



  parent reply	other threads:[~2023-10-18 11:55 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-18 11:55 [edk2-devel] [PATCH edk2-platforms v5 0/4] Provide XHCI USB controller only for newer hardware Marcin Juszkiewicz
2023-10-18 11:55 ` [edk2-devel] [PATCH edk2-platforms v5 1/4] SbsaQemu: introduce macro to compare platform version Marcin Juszkiewicz
2023-10-18 11:55 ` [edk2-devel] [PATCH edk2-platforms v5 2/4] SbsaQemu: add AcpiLib Marcin Juszkiewicz
2023-10-18 11:55 ` Marcin Juszkiewicz [this message]
2023-10-18 11:55 ` [edk2-devel] [PATCH edk2-platforms v5 4/4] SbsaQemu: disable XHCI in DSDT if not present Marcin Juszkiewicz
2023-10-26 16:56   ` Leif Lindholm

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-list 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=20231018-ehci-xhci-fix-v5-3-f42995a3dfd9@linaro.org \
    --to=devel@edk2.groups.io \
    /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