public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [edk2-devel] [PATCH edk2-platforms WIP 0/5] Provide EHCI or XHCI USB controller
@ 2023-10-13 12:28 Marcin Juszkiewicz
  2023-10-13 12:28 ` [edk2-devel] [PATCH edk2-platforms WIP 1/5] SbsaQemu: introduce macro to compare platform version Marcin Juszkiewicz
                   ` (5 more replies)
  0 siblings, 6 replies; 9+ messages in thread
From: Marcin Juszkiewicz @ 2023-10-13 12:28 UTC (permalink / raw)
  To: devel; +Cc: Leif Lindholm, Ard Biesheuvel, Jeremy Linton

Platform version 0.3 introduced XHCI USB controller instead of EHCI one.
But we did it in a way that there is no in-EDK2 check for platform
version (XHCI is always given).

This behaviour works with Linux as it complains about being unable to
initialize EHCI and goes on. Free/Net/Open BSD systems hang in such
situation.

So two solutions came to my mind:

1. rewrite DSDT generation into C
2. provide EHCI/XHCI in SSDT table instead of DSDT

This changeset is my attempt for the second solution. Idea is to have
both EHCI and XHCI as ASL code and then use
LocateAndInstallAcpiFromFvConfitional() function to choose which one
should be provided (based on PlatformVersion being less than 0.3 for
EHCI).

This does not work as LocateAndInstallAcpiFromFvConfitional() only sees
DBG2 and FACP tables. There was one or two moments when it saw all
generated ones so I assume some kind of race condition.

Any ideas what I did wrong? All patches are work-in-progress.

---
Marcin Juszkiewicz (5):
      SbsaQemu: introduce macro to compare platform version
      WIP: SbsaQemu: rename USB controller variables to be generic
      SbsaQemu: move XHCI to SSDT
      SbsaQemu: add EHCI to SSDT
      WIP: try to enable/disable proper USB controller

 Silicon/Qemu/SbsaQemu/SbsaQemu.dec                  |   4 +-
 Platform/Qemu/SbsaQemu/SbsaQemu.dsc                 |   6 +-
 Silicon/Qemu/SbsaQemu/AcpiTables/AcpiTables.inf     |   6 +-
 .../Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.inf     |   3 +
 .../SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.inf     |   4 +-
 .../IndustryStandard/SbsaQemuPlatformVersion.h      |  25 ++++
 .../Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.c       |  62 +++++++++
 .../SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c       |   4 +-
 Silicon/Qemu/SbsaQemu/AcpiTables/Dsdt.asl           | 116 -----------------
 Silicon/Qemu/SbsaQemu/AcpiTables/Ehci.asl           | 132 ++++++++++++++++++++
 Silicon/Qemu/SbsaQemu/AcpiTables/Xhci.asl           | 132 ++++++++++++++++++++
 11 files changed, 368 insertions(+), 126 deletions(-)
---
base-commit: 06f6274d56422084281886fad447ab117fd0e487
change-id: 20231013-ehci-xhci-fix-c529356a7a8f

Best regards,
-- 
Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org>



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



^ permalink raw reply	[flat|nested] 9+ messages in thread

* [edk2-devel] [PATCH edk2-platforms WIP 1/5] SbsaQemu: introduce macro to compare platform version
  2023-10-13 12:28 [edk2-devel] [PATCH edk2-platforms WIP 0/5] Provide EHCI or XHCI USB controller Marcin Juszkiewicz
@ 2023-10-13 12:28 ` Marcin Juszkiewicz
  2023-10-13 12:28 ` [edk2-devel] [PATCH edk2-platforms WIP 2/5] WIP: SbsaQemu: rename USB controller variables to be generic Marcin Juszkiewicz
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: Marcin Juszkiewicz @ 2023-10-13 12:28 UTC (permalink / raw)
  To: devel; +Cc: Leif Lindholm, Ard Biesheuvel, Jeremy Linton

We want to check "if platver < 0.3" in an easy way.
---
 .../IndustryStandard/SbsaQemuPlatformVersion.h       | 25 ++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/Silicon/Qemu/SbsaQemu/Include/IndustryStandard/SbsaQemuPlatformVersion.h b/Silicon/Qemu/SbsaQemu/Include/IndustryStandard/SbsaQemuPlatformVersion.h
new file mode 100644
index 000000000000..dd2483787002
--- /dev/null
+++ b/Silicon/Qemu/SbsaQemu/Include/IndustryStandard/SbsaQemuPlatformVersion.h
@@ -0,0 +1,25 @@
+/** @file
+*
+*  Copyright (c) Linaro Limited. All rights reserved.
+*
+*  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#ifndef SBSAQEMUPLATFORM_VERSION_H
+#define SBSAQEMUPLATFORM_VERSION_H
+
+/*
+ * Compare PlatformVersion
+ *
+ */
+
+#define PLATFORM_VERSION_LESS_THAN(Major, Minor) (     \
+  (                                                    \
+    ( PcdGet32 (PcdPlatformVersionMajor) < Major)   || \
+    (                                                  \
+      ( PcdGet32 (PcdPlatformVersionMajor) == Major) && \
+      ( PcdGet32 (PcdPlatformVersionMinor) < Minor)    \
+    )                                                  \
+  )                                                    \
+)
+#endif

-- 
2.41.0



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



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [edk2-devel] [PATCH edk2-platforms WIP 2/5] WIP: SbsaQemu: rename USB controller variables to be generic
  2023-10-13 12:28 [edk2-devel] [PATCH edk2-platforms WIP 0/5] Provide EHCI or XHCI USB controller Marcin Juszkiewicz
  2023-10-13 12:28 ` [edk2-devel] [PATCH edk2-platforms WIP 1/5] SbsaQemu: introduce macro to compare platform version Marcin Juszkiewicz
@ 2023-10-13 12:28 ` Marcin Juszkiewicz
  2023-10-13 12:28 ` [edk2-devel] [PATCH edk2-platforms WIP 3/5] SbsaQemu: move XHCI to SSDT Marcin Juszkiewicz
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: Marcin Juszkiewicz @ 2023-10-13 12:28 UTC (permalink / raw)
  To: devel; +Cc: Leif Lindholm, Ard Biesheuvel, Jeremy Linton

If run on PlatformVersion <0.3 then we have EHCI controller (not
working) instead of XHCI one.

*BSD platforms hang with wrong combination.
---
 Silicon/Qemu/SbsaQemu/SbsaQemu.dec                                    | 4 ++--
 Platform/Qemu/SbsaQemu/SbsaQemu.dsc                                   | 4 ++--
 Silicon/Qemu/SbsaQemu/AcpiTables/AcpiTables.inf                       | 4 ++--
 .../Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.inf | 4 ++--
 .../Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c   | 4 ++--
 Silicon/Qemu/SbsaQemu/AcpiTables/Dsdt.asl                             | 4 ++--
 6 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/Silicon/Qemu/SbsaQemu/SbsaQemu.dec b/Silicon/Qemu/SbsaQemu/SbsaQemu.dec
index 913d1d75ef29..5e6578068fc8 100644
--- a/Silicon/Qemu/SbsaQemu/SbsaQemu.dec
+++ b/Silicon/Qemu/SbsaQemu/SbsaQemu.dec
@@ -32,8 +32,8 @@ [PcdsFixedAtBuild.common]
   # Non discoverable devices Pcds
   gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformAhciBase|0|UINT64|0x00000001
   gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformAhciSize|0x10000|UINT32|0x00000002
-  gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformXhciBase|0|UINT64|0x00000003
-  gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformXhciSize|0x10000|UINT32|0x00000004
+  gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformUsbBase|0|UINT64|0x00000003
+  gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformUsbSize|0x10000|UINT32|0x00000004
   gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdDeviceTreeBaseAddress|0x10000000000|UINT64|0x00000005
 
   # PCDs complementing PCIe layout pulled into ACPI tables
diff --git a/Platform/Qemu/SbsaQemu/SbsaQemu.dsc b/Platform/Qemu/SbsaQemu/SbsaQemu.dsc
index 36723e21d7b5..3900fed0c7dc 100644
--- a/Platform/Qemu/SbsaQemu/SbsaQemu.dsc
+++ b/Platform/Qemu/SbsaQemu/SbsaQemu.dsc
@@ -432,8 +432,8 @@ [PcdsFixedAtBuild.common]
   # Non discoverable devices (AHCI,XHCI)
   gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformAhciBase|0x60100000
   gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformAhciSize|0x00010000
-  gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformXhciBase|0x60110000
-  gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformXhciSize|0x00010000
+  gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformUsbBase|0x60110000
+  gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformUsbSize|0x00010000
 
   # PL011 - Serial Terminal
   gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterBase|0x60000000
diff --git a/Silicon/Qemu/SbsaQemu/AcpiTables/AcpiTables.inf b/Silicon/Qemu/SbsaQemu/AcpiTables/AcpiTables.inf
index 8d4905362edc..42cc203eeb7b 100644
--- a/Silicon/Qemu/SbsaQemu/AcpiTables/AcpiTables.inf
+++ b/Silicon/Qemu/SbsaQemu/AcpiTables/AcpiTables.inf
@@ -68,8 +68,8 @@ [FixedPcd]
 
   gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformAhciBase
   gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformAhciSize
-  gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformXhciBase
-  gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformXhciSize
+  gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformUsbBase
+  gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformUsbSize
 
 [Pcd]
   gArmTokenSpaceGuid.PcdGicDistributorBase
diff --git a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.inf b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.inf
index 19534b7a274a..4cda4eae0f7b 100644
--- a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.inf
+++ b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.inf
@@ -37,8 +37,8 @@ [LibraryClasses]
 [Pcd]
   gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformAhciBase
   gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformAhciSize
-  gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformXhciBase
-  gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformXhciSize
+  gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformUsbBase
+  gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformUsbSize
 
   gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformVersionMajor
   gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformVersionMinor
diff --git a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c
index 36ada4270bbf..9aca789b5673 100644
--- a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c
+++ b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c
@@ -57,9 +57,9 @@ InitializeSbsaQemuPlatformDxe (
     return Status;
   }
 
-  Base = (VOID*)(UINTN)PcdGet64 (PcdPlatformXhciBase);
+  Base = (VOID*)(UINTN)PcdGet64 (PcdPlatformUsbBase);
   ASSERT (Base != NULL);
-  Size = (UINTN)PcdGet32 (PcdPlatformXhciSize);
+  Size = (UINTN)PcdGet32 (PcdPlatformUsbSize);
   ASSERT (Size != 0);
 
   DEBUG ((DEBUG_INFO, "%a: Got platform XHCI %llx %u\n",
diff --git a/Silicon/Qemu/SbsaQemu/AcpiTables/Dsdt.asl b/Silicon/Qemu/SbsaQemu/AcpiTables/Dsdt.asl
index 543b5782580a..4ff267e00802 100644
--- a/Silicon/Qemu/SbsaQemu/AcpiTables/Dsdt.asl
+++ b/Silicon/Qemu/SbsaQemu/AcpiTables/Dsdt.asl
@@ -79,8 +79,8 @@ DefinitionBlock ("DsdtTable.aml", "DSDT",
         Method (_CRS, 0x0, Serialized) {
             Name (RBUF, ResourceTemplate() {
                 Memory32Fixed (ReadWrite,
-                               FixedPcdGet32 (PcdPlatformXhciBase),
-                               FixedPcdGet32 (PcdPlatformXhciSize))
+                               FixedPcdGet32 (PcdPlatformUsbBase),
+                               FixedPcdGet32 (PcdPlatformUsbSize))
                 Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 43 }
             })
             Return (RBUF)

-- 
2.41.0



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



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [edk2-devel] [PATCH edk2-platforms WIP 3/5] SbsaQemu: move XHCI to SSDT
  2023-10-13 12:28 [edk2-devel] [PATCH edk2-platforms WIP 0/5] Provide EHCI or XHCI USB controller Marcin Juszkiewicz
  2023-10-13 12:28 ` [edk2-devel] [PATCH edk2-platforms WIP 1/5] SbsaQemu: introduce macro to compare platform version Marcin Juszkiewicz
  2023-10-13 12:28 ` [edk2-devel] [PATCH edk2-platforms WIP 2/5] WIP: SbsaQemu: rename USB controller variables to be generic Marcin Juszkiewicz
@ 2023-10-13 12:28 ` Marcin Juszkiewicz
  2023-10-13 12:28 ` [edk2-devel] [PATCH edk2-platforms WIP 4/5] SbsaQemu: add EHCI " Marcin Juszkiewicz
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: Marcin Juszkiewicz @ 2023-10-13 12:28 UTC (permalink / raw)
  To: devel; +Cc: Leif Lindholm, Ard Biesheuvel, Jeremy Linton

I want to add EHCI/XHCI switching so platforms older than 0.3
would not complain about missing XHCI.
---
 Silicon/Qemu/SbsaQemu/AcpiTables/AcpiTables.inf |   1 +
 Silicon/Qemu/SbsaQemu/AcpiTables/Dsdt.asl       | 116 -----------------
 Silicon/Qemu/SbsaQemu/AcpiTables/Xhci.asl       | 132 ++++++++++++++++++++
 3 files changed, 133 insertions(+), 116 deletions(-)

diff --git a/Silicon/Qemu/SbsaQemu/AcpiTables/AcpiTables.inf b/Silicon/Qemu/SbsaQemu/AcpiTables/AcpiTables.inf
index 42cc203eeb7b..cd89ab346aa7 100644
--- a/Silicon/Qemu/SbsaQemu/AcpiTables/AcpiTables.inf
+++ b/Silicon/Qemu/SbsaQemu/AcpiTables/AcpiTables.inf
@@ -21,6 +21,7 @@ [Sources]
   Fadt.aslc
   Mcfg.aslc
   Spcr.aslc
+  Xhci.asl
 
 [Packages]
   ArmPlatformPkg/ArmPlatformPkg.dec
diff --git a/Silicon/Qemu/SbsaQemu/AcpiTables/Dsdt.asl b/Silicon/Qemu/SbsaQemu/AcpiTables/Dsdt.asl
index 4ff267e00802..714636b518a5 100644
--- a/Silicon/Qemu/SbsaQemu/AcpiTables/Dsdt.asl
+++ b/Silicon/Qemu/SbsaQemu/AcpiTables/Dsdt.asl
@@ -68,122 +68,6 @@ DefinitionBlock ("DsdtTable.aml", "DSDT",
       }
     }
 
-    // USB XHCI Host Controller
-    Device (USB0) {
-        Name (_HID, "PNP0D10")      // _HID: Hardware ID
-        Name (_UID, 0x00)            // _UID: Unique ID
-        Name (_CCA, 0x01)            // _CCA: Cache Coherency Attribute
-        Method (_STA) {
-          Return (0xF)
-        }
-        Method (_CRS, 0x0, Serialized) {
-            Name (RBUF, ResourceTemplate() {
-                Memory32Fixed (ReadWrite,
-                               FixedPcdGet32 (PcdPlatformUsbBase),
-                               FixedPcdGet32 (PcdPlatformUsbSize))
-                Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 43 }
-            })
-            Return (RBUF)
-        }
-
-        // Root Hub
-        Device (RHUB) {
-            Name (_ADR, 0x00000000)  // Address of Root Hub should be 0 as per ACPI 5.0 spec
-            Method (_STA) {
-              Return (0xF)
-            }
-
-            // Ports connected to Root Hub
-            Device (HUB1) {
-                Name (_ADR, 0x00000001)
-                Name (_UPC, Package() {
-                    0x00,       // Port is NOT connectable
-                    0xFF,       // Don't care
-                    0x00000000, // Reserved 0 must be zero
-                    0x00000000  // Reserved 1 must be zero
-                })
-                Method (_STA) {
-                  Return (0xF)
-                }
-
-                Device (PRT1) {
-                    Name (_ADR, 0x00000001)
-                    Name (_UPC, Package() {
-                        0xFF,        // Port is connectable
-                        0x00,        // Port connector is A
-                        0x00000000,
-                        0x00000000
-                    })
-                    Name (_PLD, Package() {
-                        Buffer(0x10) {
-                            0x81, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-                            0x31, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
-                        }
-                    })
-                    Method (_STA) {
-                      Return (0xF)
-                    }
-                } // USB0_RHUB_HUB1_PRT1
-                Device (PRT2) {
-                    Name (_ADR, 0x00000002)
-                    Name (_UPC, Package() {
-                        0xFF,        // Port is connectable
-                        0x00,        // Port connector is A
-                        0x00000000,
-                        0x00000000
-                    })
-                    Name (_PLD, Package() {
-                        Buffer(0x10) {
-                            0x81, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-                            0x31, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
-                        }
-                    })
-                    Method (_STA) {
-                      Return (0xF)
-                    }
-                } // USB0_RHUB_HUB1_PRT2
-
-                Device (PRT3) {
-                    Name (_ADR, 0x00000003)
-                    Name (_UPC, Package() {
-                        0xFF,        // Port is connectable
-                        0x09,        // Type C connector - USB2 and SS with Switch
-                        0x00000000,
-                        0x00000000
-                    })
-                    Name (_PLD, Package() {
-                        Buffer (0x10) {
-                            0x81, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-                            0x31, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
-                        }
-                    })
-                    Method (_STA) {
-                      Return (0xF)
-                    }
-                } // USB0_RHUB_HUB1_PRT3
-
-                Device (PRT4) {
-                    Name (_ADR, 0x00000004)
-                    Name (_UPC, Package() {
-                        0xFF,        // Port is connectable
-                        0x09,        // Type C connector - USB2 and SS with Switch
-                        0x00000000,
-                        0x00000000
-                    })
-                    Name (_PLD, Package() {
-                        Buffer (0x10){
-                            0x81, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-                            0x31, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
-                        }
-                    })
-                    Method (_STA) {
-                      Return (0xF)
-                    }
-                } // USB0_RHUB_HUB1_PRT4
-            } // USB0_RHUB_HUB1
-        } // USB0_RHUB
-    } // USB0
-
     Device (PCI0)
     {
       Name (_HID, EISAID ("PNP0A08")) // PCI Express Root Bridge
diff --git a/Silicon/Qemu/SbsaQemu/AcpiTables/Xhci.asl b/Silicon/Qemu/SbsaQemu/AcpiTables/Xhci.asl
new file mode 100644
index 000000000000..bfdcb09b28f0
--- /dev/null
+++ b/Silicon/Qemu/SbsaQemu/AcpiTables/Xhci.asl
@@ -0,0 +1,132 @@
+/** @file
+*  [DSDT] XHCI Usb Host controller
+*
+*  Copyright (c) 2023, Linaro Ltd. All rights reserved.
+*
+*  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#include <IndustryStandard/Acpi60.h>
+#include <IndustryStandard/SbsaQemuAcpi.h>
+
+DefinitionBlock (__FILE__, "SSDT", 2, "LINARO", "SBSAXHCI", 2)
+{
+  Scope (\_SB_)
+  {
+    // USB XHCI Host Controller
+    Device (USB3) {
+    Name (_HID, "PNP0D10")      // _HID: Hardware ID
+    Name (_UID, 0x00)            // _UID: Unique ID
+    Name (_CCA, 0x01)            // _CCA: Cache Coherency Attribute
+    Method (_STA) {
+    Return (0xF)
+    }
+    Method (_CRS, 0x0, Serialized) {
+        Name (RBUF, ResourceTemplate() {
+        Memory32Fixed (ReadWrite,
+                        FixedPcdGet32 (PcdPlatformUsbBase),
+                        FixedPcdGet32 (PcdPlatformUsbSize))
+        Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 43 }
+        })
+        Return (RBUF)
+    }
+
+    // Root Hub
+    Device (RHUB) {
+        Name (_ADR, 0x00000000)  // Address of Root Hub should be 0 as per ACPI 5.0 spec
+        Method (_STA) {
+        Return (0xF)
+        }
+
+        // Ports connected to Root Hub
+        Device (HUB1) {
+        Name (_ADR, 0x00000001)
+        Name (_UPC, Package() {
+                0x00,       // Port is NOT connectable
+                0xFF,       // Don't care
+                0x00000000, // Reserved 0 must be zero
+                0x00000000  // Reserved 1 must be zero
+        })
+        Method (_STA) {
+        Return (0xF)
+        }
+
+        Device (PRT1) {
+                Name (_ADR, 0x00000001)
+                Name (_UPC, Package() {
+                0xFF,        // Port is connectable
+                0x00,        // Port connector is A
+                0x00000000,
+                0x00000000
+                })
+                Name (_PLD, Package() {
+                Buffer(0x10) {
+                        0x81, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                        0x31, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+                }
+                })
+                Method (_STA) {
+                Return (0xF)
+                }
+        } // USB0_RHUB_HUB1_PRT1
+        Device (PRT2) {
+                Name (_ADR, 0x00000002)
+                Name (_UPC, Package() {
+                0xFF,        // Port is connectable
+                0x00,        // Port connector is A
+                0x00000000,
+                0x00000000
+                })
+                Name (_PLD, Package() {
+                Buffer(0x10) {
+                        0x81, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                        0x31, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+                }
+                })
+                Method (_STA) {
+                Return (0xF)
+                }
+        } // USB0_RHUB_HUB1_PRT2
+
+        Device (PRT3) {
+                Name (_ADR, 0x00000003)
+                Name (_UPC, Package() {
+                0xFF,        // Port is connectable
+                0x09,        // Type C connector - USB2 and SS with Switch
+                0x00000000,
+                0x00000000
+                })
+                Name (_PLD, Package() {
+                Buffer (0x10) {
+                        0x81, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                        0x31, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+                }
+                })
+                Method (_STA) {
+                Return (0xF)
+                }
+        } // USB0_RHUB_HUB1_PRT3
+
+        Device (PRT4) {
+                Name (_ADR, 0x00000004)
+                Name (_UPC, Package() {
+                0xFF,        // Port is connectable
+                0x09,        // Type C connector - USB2 and SS with Switch
+                0x00000000,
+                0x00000000
+                })
+                Name (_PLD, Package() {
+                Buffer (0x10){
+                        0x81, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                        0x31, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+                }
+                })
+                Method (_STA) {
+                Return (0xF)
+                }
+        } // USB0_RHUB_HUB1_PRT4
+        } // USB0_RHUB_HUB1
+    } // USB0_RHUB
+    } // USB0
+  } //\SB
+}

-- 
2.41.0



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



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [edk2-devel] [PATCH edk2-platforms WIP 4/5] SbsaQemu: add EHCI to SSDT
  2023-10-13 12:28 [edk2-devel] [PATCH edk2-platforms WIP 0/5] Provide EHCI or XHCI USB controller Marcin Juszkiewicz
                   ` (2 preceding siblings ...)
  2023-10-13 12:28 ` [edk2-devel] [PATCH edk2-platforms WIP 3/5] SbsaQemu: move XHCI to SSDT Marcin Juszkiewicz
@ 2023-10-13 12:28 ` Marcin Juszkiewicz
  2023-10-13 12:28 ` [edk2-devel] [PATCH edk2-platforms WIP 5/5] WIP: try to enable/disable proper USB controller Marcin Juszkiewicz
  2023-10-13 13:24 ` [edk2-devel] [PATCH edk2-platforms WIP 0/5] Provide EHCI or XHCI " Gerd Hoffmann
  5 siblings, 0 replies; 9+ messages in thread
From: Marcin Juszkiewicz @ 2023-10-13 12:28 UTC (permalink / raw)
  To: devel; +Cc: Leif Lindholm, Ard Biesheuvel, Jeremy Linton

I want to add EHCI/XHCI switching so platforms older than 0.3
would not complain about missing XHCI.
---
 Silicon/Qemu/SbsaQemu/AcpiTables/AcpiTables.inf |   1 +
 Silicon/Qemu/SbsaQemu/AcpiTables/Ehci.asl       | 132 ++++++++++++++++++++
 2 files changed, 133 insertions(+)

diff --git a/Silicon/Qemu/SbsaQemu/AcpiTables/AcpiTables.inf b/Silicon/Qemu/SbsaQemu/AcpiTables/AcpiTables.inf
index cd89ab346aa7..b58a2137ec03 100644
--- a/Silicon/Qemu/SbsaQemu/AcpiTables/AcpiTables.inf
+++ b/Silicon/Qemu/SbsaQemu/AcpiTables/AcpiTables.inf
@@ -22,6 +22,7 @@ [Sources]
   Mcfg.aslc
   Spcr.aslc
   Xhci.asl
+  Ehci.asl
 
 [Packages]
   ArmPlatformPkg/ArmPlatformPkg.dec
diff --git a/Silicon/Qemu/SbsaQemu/AcpiTables/Ehci.asl b/Silicon/Qemu/SbsaQemu/AcpiTables/Ehci.asl
new file mode 100644
index 000000000000..186f28363d95
--- /dev/null
+++ b/Silicon/Qemu/SbsaQemu/AcpiTables/Ehci.asl
@@ -0,0 +1,132 @@
+/** @file
+*  [DSDT] XHCI Usb Host controller
+*
+*  Copyright (c) 2023, Linaro Ltd. All rights reserved.
+*
+*  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#include <IndustryStandard/Acpi60.h>
+#include <IndustryStandard/SbsaQemuAcpi.h>
+
+DefinitionBlock (__FILE__, "SSDT", 1, "LINARO", "SBSAEHCI", 1)
+{
+  Scope (\_SB_)
+  {
+    // USB EHCI Host Controller
+    Device (USB2) {
+    Name (_HID, "PNP0D20")      // _HID: Hardware ID
+    Name (_UID, 0x00)            // _UID: Unique ID
+    Name (_CCA, 0x01)            // _CCA: Cache Coherency Attribute
+    Method (_STA) {
+    Return (0xF)
+    }
+    Method (_CRS, 0x0, Serialized) {
+        Name (RBUF, ResourceTemplate() {
+        Memory32Fixed (ReadWrite,
+                        FixedPcdGet32 (PcdPlatformUsbBase),
+                        FixedPcdGet32 (PcdPlatformUsbSize))
+        Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 43 }
+        })
+        Return (RBUF)
+    }
+
+    // Root Hub
+    Device (RHUB) {
+        Name (_ADR, 0x00000000)  // Address of Root Hub should be 0 as per ACPI 5.0 spec
+        Method (_STA) {
+        Return (0xF)
+        }
+
+        // Ports connected to Root Hub
+        Device (HUB1) {
+        Name (_ADR, 0x00000001)
+        Name (_UPC, Package() {
+                0x00,       // Port is NOT connectable
+                0xFF,       // Don't care
+                0x00000000, // Reserved 0 must be zero
+                0x00000000  // Reserved 1 must be zero
+        })
+        Method (_STA) {
+        Return (0xF)
+        }
+
+        Device (PRT1) {
+                Name (_ADR, 0x00000001)
+                Name (_UPC, Package() {
+                0xFF,        // Port is connectable
+                0x00,        // Port connector is A
+                0x00000000,
+                0x00000000
+                })
+                Name (_PLD, Package() {
+                Buffer(0x10) {
+                        0x81, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                        0x31, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+                }
+                })
+                Method (_STA) {
+                Return (0xF)
+                }
+        } // USB0_RHUB_HUB1_PRT1
+        Device (PRT2) {
+                Name (_ADR, 0x00000002)
+                Name (_UPC, Package() {
+                0xFF,        // Port is connectable
+                0x00,        // Port connector is A
+                0x00000000,
+                0x00000000
+                })
+                Name (_PLD, Package() {
+                Buffer(0x10) {
+                        0x81, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                        0x31, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+                }
+                })
+                Method (_STA) {
+                Return (0xF)
+                }
+        } // USB0_RHUB_HUB1_PRT2
+
+        Device (PRT3) {
+                Name (_ADR, 0x00000003)
+                Name (_UPC, Package() {
+                0xFF,        // Port is connectable
+                0x00,        // Port connector is A
+                0x00000000,
+                0x00000000
+                })
+                Name (_PLD, Package() {
+                Buffer (0x10) {
+                        0x81, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                        0x31, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+                }
+                })
+                Method (_STA) {
+                Return (0xF)
+                }
+        } // USB0_RHUB_HUB1_PRT3
+
+        Device (PRT4) {
+                Name (_ADR, 0x00000004)
+                Name (_UPC, Package() {
+                0xFF,        // Port is connectable
+                0x00,        // Port connector is A
+                0x00000000,
+                0x00000000
+                })
+                Name (_PLD, Package() {
+                Buffer (0x10){
+                        0x81, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                        0x31, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+                }
+                })
+                Method (_STA) {
+                Return (0xF)
+                }
+        } // USB0_RHUB_HUB1_PRT4
+        } // USB0_RHUB_HUB1
+    } // USB0_RHUB
+    } // USB0
+  } //\SB
+}

-- 
2.41.0



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



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [edk2-devel] [PATCH edk2-platforms WIP 5/5] WIP: try to enable/disable proper USB controller
  2023-10-13 12:28 [edk2-devel] [PATCH edk2-platforms WIP 0/5] Provide EHCI or XHCI USB controller Marcin Juszkiewicz
                   ` (3 preceding siblings ...)
  2023-10-13 12:28 ` [edk2-devel] [PATCH edk2-platforms WIP 4/5] SbsaQemu: add EHCI " Marcin Juszkiewicz
@ 2023-10-13 12:28 ` Marcin Juszkiewicz
  2023-10-13 13:24 ` [edk2-devel] [PATCH edk2-platforms WIP 0/5] Provide EHCI or XHCI " Gerd Hoffmann
  5 siblings, 0 replies; 9+ messages in thread
From: Marcin Juszkiewicz @ 2023-10-13 12:28 UTC (permalink / raw)
  To: devel; +Cc: Leif Lindholm, Ard Biesheuvel, Jeremy Linton

If platform version < 0.3 then we want EHCI. Otherwise XHCI needs to be
present.

The problem:

LocateAndInstallAcpiFromFvConditional() gets only DBG2 and FACP tables.
Looks like synchronization issue as there were moments when it got all
present tables.

Anyway even if all goes well then SSDT nodes for both XHCI and EHCI were
present in resulting system.
---
 Platform/Qemu/SbsaQemu/SbsaQemu.dsc                  |  2 +
 .../Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.inf      |  3 +
 .../Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.c        | 62 ++++++++++++++++++++
 3 files changed, 67 insertions(+)

diff --git a/Platform/Qemu/SbsaQemu/SbsaQemu.dsc b/Platform/Qemu/SbsaQemu/SbsaQemu.dsc
index 3900fed0c7dc..80ea4ed2edd2 100644
--- a/Platform/Qemu/SbsaQemu/SbsaQemu.dsc
+++ b/Platform/Qemu/SbsaQemu/SbsaQemu.dsc
@@ -172,6 +172,8 @@ [LibraryClasses.common]
 
   ReportStatusCodeLib|MdePkg/Library/BaseReportStatusCodeLibNull/BaseReportStatusCodeLibNull.inf
 
+  AcpiLib|EmbeddedPkg/Library/AcpiLib/AcpiLib.inf
+
   ArmLib|ArmPkg/Library/ArmLib/ArmBaseLib.inf
   ArmMmuLib|ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf
 
diff --git a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.inf b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.inf
index 7c7e08e0fd3a..c67f9a92fd4c 100644
--- a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.inf
+++ b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.inf
@@ -29,6 +29,7 @@ [Packages]
   Silicon/Qemu/SbsaQemu/SbsaQemu.dec
 
 [LibraryClasses]
+  AcpiLib
   ArmLib
   BaseMemoryLib
   BaseLib
@@ -50,6 +51,8 @@ [Pcd]
   gArmTokenSpaceGuid.PcdGicRedistributorsBase
   gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdGicItsBase
   gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdSmmuBase
+  gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformVersionMajor
+  gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformVersionMinor
 
 [Depex]
   gEfiAcpiTableProtocolGuid                       ## CONSUMES
diff --git a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.c b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.c
index fd849ca1594b..b103111606e3 100644
--- a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.c
+++ b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.c
@@ -10,6 +10,7 @@
 #include <IndustryStandard/AcpiAml.h>
 #include <IndustryStandard/IoRemappingTable.h>
 #include <IndustryStandard/SbsaQemuAcpi.h>
+#include <IndustryStandard/SbsaQemuPlatformVersion.h>
 #include <Library/AcpiLib.h>
 #include <Library/ArmLib.h>
 #include <Library/BaseMemoryLib.h>
@@ -26,6 +27,14 @@
 
 #pragma pack(1)
 
+/*
+ * The GUID inside Silicon/Qemu/SbsaQemu/AcpiTables/AcpiTables.inf _must_ match
+ * below.
+ */
+STATIC CONST EFI_GUID mAcpiTableFile = {
+  0x7E374E25, 0x8E01, 0x4FEE, { 0x87, 0xf2, 0x39, 0x0C, 0x23, 0xC6, 0x06, 0xCD }
+  //7E374E25-8E01-4FEE-87F2-390C23C606CD
+};
 
 static UINTN GicItsBase;
 
@@ -682,6 +691,55 @@ AddGtdtTable (
   return Status;
 }
 
+//
+// Monitor the ACPI tables being installed and when
+// a DSDT/SSDT is detected check do we want to enable
+// EHCI or XHCI USB controller
+//
+STATIC
+BOOLEAN
+HandleDynamicNamespace (
+  IN  EFI_ACPI_DESCRIPTION_HEADER   *AcpiHeader
+  )
+{
+  switch (AcpiHeader->Signature) {
+  case SIGNATURE_32 ('D', 'S', 'D', 'T'):
+  case SIGNATURE_32 ('S', 'S', 'D', 'T'):
+    if (AcpiHeader->OemTableId == SIGNATURE_64 ('S', 'B', 'S', 'A', 'X', 'H', 'C', 'I'))
+    {
+      DEBUG ((DEBUG_ERROR, "HRW: XHCI\n"));
+      if (! PLATFORM_VERSION_LESS_THAN(0, 3) )
+      {
+
+      DEBUG ((DEBUG_ERROR, "HRW: XHCI enabled\n"));
+        return TRUE;
+      }
+      else
+      {
+        DEBUG ((DEBUG_ERROR, "HRW: XHCI disabled\n"));
+        return FALSE;
+      }
+    }
+    if (AcpiHeader->OemTableId == SIGNATURE_64 ('S', 'B', 'S', 'A', 'E', 'H', 'C', 'I'))
+    {
+      DEBUG ((DEBUG_ERROR, "HRW: EHCI\n"));
+      if ( PLATFORM_VERSION_LESS_THAN(0, 3) )
+      {
+
+      DEBUG ((DEBUG_ERROR, "HRW: EHCI enabled\n"));
+        return TRUE;
+      }
+      else
+      {
+        DEBUG ((DEBUG_ERROR, "HRW: EHCI disabled\n"));
+        return FALSE;
+      }
+    }
+  }
+
+  return TRUE;
+}
+
 EFI_STATUS
 EFIAPI
 InitializeSbsaQemuAcpiDxe (
@@ -738,5 +796,9 @@ InitializeSbsaQemuAcpiDxe (
     DEBUG ((DEBUG_ERROR, "Failed to add GTDT table\n"));
   }
 
+  Status = LocateAndInstallAcpiFromFvConditional (&mAcpiTableFile,
+                                                  &HandleDynamicNamespace);
+  ASSERT_EFI_ERROR (Status);
+
   return EFI_SUCCESS;
 }

-- 
2.41.0



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



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [edk2-devel] [PATCH edk2-platforms WIP 0/5] Provide EHCI or XHCI USB controller
  2023-10-13 12:28 [edk2-devel] [PATCH edk2-platforms WIP 0/5] Provide EHCI or XHCI USB controller Marcin Juszkiewicz
                   ` (4 preceding siblings ...)
  2023-10-13 12:28 ` [edk2-devel] [PATCH edk2-platforms WIP 5/5] WIP: try to enable/disable proper USB controller Marcin Juszkiewicz
@ 2023-10-13 13:24 ` Gerd Hoffmann
  2023-10-13 13:31   ` Marcin Juszkiewicz
       [not found]   ` <178DADF696DC483E.8679@groups.io>
  5 siblings, 2 replies; 9+ messages in thread
From: Gerd Hoffmann @ 2023-10-13 13:24 UTC (permalink / raw)
  To: devel, marcin.juszkiewicz; +Cc: Leif Lindholm, Ard Biesheuvel, Jeremy Linton

  Hi,

> So two solutions came to my mind:
> 
> 1. rewrite DSDT generation into C

You might want have a look at DynamicTablesPkg/ for that


> 2. provide EHCI/XHCI in SSDT table instead of DSDT

Should work, except that I'd suggest to worry about xhci only.
ehci never actually worked anyway, so why advertise it to the OS in the
first place?


3. Add a _STA AML function to the XHCI DSDT description, which is able
to figure whenever XHCI is present.

We had that in qemu years ago, before switching to full DSDT generation,
where the _STA functions checked some bit in PCI config space of the ISA
bridge to figure whenever specific isa devices (floppy, serial/parallel
port) are present or not.


HTH & take care,
  Gerd



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



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [edk2-devel] [PATCH edk2-platforms WIP 0/5] Provide EHCI or XHCI USB controller
  2023-10-13 13:24 ` [edk2-devel] [PATCH edk2-platforms WIP 0/5] Provide EHCI or XHCI " Gerd Hoffmann
@ 2023-10-13 13:31   ` Marcin Juszkiewicz
       [not found]   ` <178DADF696DC483E.8679@groups.io>
  1 sibling, 0 replies; 9+ messages in thread
From: Marcin Juszkiewicz @ 2023-10-13 13:31 UTC (permalink / raw)
  To: Gerd Hoffmann, devel; +Cc: Leif Lindholm, Ard Biesheuvel, Jeremy Linton

W dniu 13.10.2023 o 15:24, Gerd Hoffmann pisze:

>> So two solutions came to my mind:
>>
>> 1. rewrite DSDT generation into C
> 
> You might want have a look at DynamicTablesPkg/ for that

Wasn't is involving using ConfigurationManager? Or maybe I just had 
wrong assumption after reading code.
>> 2. provide EHCI/XHCI in SSDT table instead of DSDT
> 
> Should work, except that I'd suggest to worry about xhci only.
> ehci never actually worked anyway, so why advertise it to the OS in the
> first place?

Good point.

> 3. Add a _STA AML function to the XHCI DSDT description, which is able
> to figure whenever XHCI is present.
> 
> We had that in qemu years ago, before switching to full DSDT generation,
> where the _STA functions checked some bit in PCI config space of the ISA
> bridge to figure whenever specific isa devices (floppy, serial/parallel
> port) are present or not.
Will look.

Thanks.


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



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [edk2-devel] [PATCH edk2-platforms WIP 0/5] Provide EHCI or XHCI USB controller
       [not found]   ` <178DADF696DC483E.8679@groups.io>
@ 2023-10-13 17:29     ` Marcin Juszkiewicz
  0 siblings, 0 replies; 9+ messages in thread
From: Marcin Juszkiewicz @ 2023-10-13 17:29 UTC (permalink / raw)
  To: devel, Gerd Hoffmann; +Cc: Leif Lindholm, Ard Biesheuvel, Jeremy Linton

W dniu 13.10.2023 o 15:31, Marcin Juszkiewicz via groups.io pisze:
> W dniu 13.10.2023 o 15:24, Gerd Hoffmann pisze:
> 
>>> So two solutions came to my mind:
>>>
>>> 1. rewrite DSDT generation into C
>>
>> You might want have a look at DynamicTablesPkg/ for that
> 
> Wasn't is involving using ConfigurationManager? Or maybe I just had 
> wrong assumption after reading code.

>>> 2. provide EHCI/XHCI in SSDT table instead of DSDT
>>
>> Should work, except that I'd suggest to worry about xhci only.
>> ehci never actually worked anyway, so why advertise it to the OS in the
>> first place?
> 
> Good point.

Got rid of EHCI at all. On >= 0.3 XHCI is created, otherwise there is no 
USB controller in DSDT.

>> 3. Add a _STA AML function to the XHCI DSDT description, which is able
>> to figure whenever XHCI is present.
>>
>> We had that in qemu years ago, before switching to full DSDT generation,
>> where the _STA functions checked some bit in PCI config space of the ISA
>> bridge to figure whenever specific isa devices (floppy, serial/parallel
>> port) are present or not.

> Will look.

Our XHCI is on sysbus so checking PCI_config is not an option.


4. Add variable in ASL + check in _STA for it. And alter that variable 
from C code once DSDT is done. Kind of what Ampere does in 
JadePkg/**/AcpiDsdt.c file.


I am also thinking of going back to 2nd version and handle it on 
ExitBootServicesEvent event (again: Ampere/JadePkg). All ACPI tables 
should be ready at that moment...



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



^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2023-10-13 17:29 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-13 12:28 [edk2-devel] [PATCH edk2-platforms WIP 0/5] Provide EHCI or XHCI USB controller Marcin Juszkiewicz
2023-10-13 12:28 ` [edk2-devel] [PATCH edk2-platforms WIP 1/5] SbsaQemu: introduce macro to compare platform version Marcin Juszkiewicz
2023-10-13 12:28 ` [edk2-devel] [PATCH edk2-platforms WIP 2/5] WIP: SbsaQemu: rename USB controller variables to be generic Marcin Juszkiewicz
2023-10-13 12:28 ` [edk2-devel] [PATCH edk2-platforms WIP 3/5] SbsaQemu: move XHCI to SSDT Marcin Juszkiewicz
2023-10-13 12:28 ` [edk2-devel] [PATCH edk2-platforms WIP 4/5] SbsaQemu: add EHCI " Marcin Juszkiewicz
2023-10-13 12:28 ` [edk2-devel] [PATCH edk2-platforms WIP 5/5] WIP: try to enable/disable proper USB controller Marcin Juszkiewicz
2023-10-13 13:24 ` [edk2-devel] [PATCH edk2-platforms WIP 0/5] Provide EHCI or XHCI " Gerd Hoffmann
2023-10-13 13:31   ` Marcin Juszkiewicz
     [not found]   ` <178DADF696DC483E.8679@groups.io>
2023-10-13 17:29     ` Marcin Juszkiewicz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox