[edk2-devel] [PATCH edk2-platforms v6 3/4] SbsaQemu: initialize XHCI only if it exists

Marcin Juszkiewicz marcin.juszkiewicz at linaro.org
Thu Oct 26 17:33:51 UTC 2023


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 at 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 (#110136): https://edk2.groups.io/g/devel/message/110136
Mute This Topic: https://groups.io/mt/102205082/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-




More information about the edk2-devel-archive mailing list