From ccf967ed7a8c592655c80eb7f315fcf57d2e41e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20B=C4=83l=C4=83nic=C4=83?= Date: Thu, 8 Feb 2024 15:18:09 +0200 Subject: [PATCH] ACPI: Expose EHCI unconditionally MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit But detect the OS booted and hide the PNP0D20 ID for Windows, so we don't end up binding to the inbox driver package and crashing. The fixed driver package[^1] will bind to the custom RKCP0D20 _HID instead. [^1]: https://github.com/worproject/Rockchip-Windows-Drivers/tree/master/drivers/usb/usbehci_noncoherent Signed-off-by: Mario Bălănică --- .../IndiedroidNova/AcpiTables/AcpiTables.inf | 1 - .../IndiedroidNova/AcpiTables/Dsdt.asl | 2 +- .../ITX-3588J/AcpiTables/AcpiTables.inf | 1 - .../Firefly/ITX-3588J/AcpiTables/Dsdt.asl | 2 +- .../ROC-RK3588S-PC/AcpiTables/AcpiTables.inf | 1 - .../ROC-RK3588S-PC/AcpiTables/Dsdt.asl | 2 +- .../NanoPC-T6/AcpiTables/AcpiTables.inf | 1 - .../NanoPC-T6/AcpiTables/Dsdt.asl | 2 +- .../NanoPi-R6C/AcpiTables/AcpiTables.inf | 1 - .../NanoPi-R6C/AcpiTables/Dsdt.asl | 2 +- .../NanoPi-R6S/AcpiTables/AcpiTables.inf | 1 - .../NanoPi-R6S/AcpiTables/Dsdt.asl | 2 +- .../Hinlink/H88K/AcpiTables/AcpiTables.inf | 1 - .../Platform/Hinlink/H88K/AcpiTables/Dsdt.asl | 2 +- .../Khadas/Edge2/AcpiTables/AcpiTables.inf | 1 - .../Platform/Khadas/Edge2/AcpiTables/Dsdt.asl | 2 +- .../R58-Mini/AcpiTables/AcpiTables.inf | 1 - .../Mekotronics/R58-Mini/AcpiTables/Dsdt.asl | 2 +- .../R58X/AcpiTables/AcpiTables.inf | 1 - .../Mekotronics/R58X/AcpiTables/Dsdt.asl | 2 +- .../Mixtile/Blade3/AcpiTables/AcpiTables.inf | 1 - .../Mixtile/Blade3/AcpiTables/Dsdt.asl | 2 +- .../OrangePi5/AcpiTables/AcpiTables.inf | 1 - .../OrangePi/OrangePi5/AcpiTables/Dsdt.asl | 2 +- .../OrangePi5Plus/AcpiTables/AcpiTables.inf | 1 - .../OrangePi5Plus/AcpiTables/Dsdt.asl | 2 +- .../Radxa/ROCK5A/AcpiTables/AcpiTables.inf | 1 - .../Platform/Radxa/ROCK5A/AcpiTables/Dsdt.asl | 2 +- .../Radxa/ROCK5B/AcpiTables/AcpiTables.inf | 1 - .../Platform/Radxa/ROCK5B/AcpiTables/Dsdt.asl | 2 +- .../Rockchip/RK3588/AcpiTables/Usb1Host.asl | 108 ------- .../Rockchip/RK3588/AcpiTables/Usb2Host.asl | 250 ++++++++++----- .../Drivers/AcpiPlatformDxe/AcpiPlatformDxe.c | 285 +++++++++++++----- .../AcpiPlatformDxe/AcpiPlatformDxe.inf | 4 +- .../RK3588/Drivers/RK3588Dxe/ConfigTable.c | 9 - .../RK3588/Drivers/RK3588Dxe/RK3588Dxe.inf | 2 - .../RK3588/Drivers/RK3588Dxe/RK3588DxeHii.uni | 3 - .../RK3588/Drivers/RK3588Dxe/RK3588DxeHii.vfr | 16 +- .../Rockchip/RK3588/Include/VarStoreData.h | 6 - .../Silicon/Rockchip/RK3588/RK3588.dec | 3 - .../Rockchip/RK3588/RK3588Base.dsc.inc | 6 - 41 files changed, 397 insertions(+), 340 deletions(-) delete mode 100644 edk2-rockchip/Silicon/Rockchip/RK3588/AcpiTables/Usb1Host.asl diff --git a/edk2-rockchip/Platform/Ameridroid/IndiedroidNova/AcpiTables/AcpiTables.inf b/edk2-rockchip/Platform/Ameridroid/IndiedroidNova/AcpiTables/AcpiTables.inf index c33251956..e262848a2 100644 --- a/edk2-rockchip/Platform/Ameridroid/IndiedroidNova/AcpiTables/AcpiTables.inf +++ b/edk2-rockchip/Platform/Ameridroid/IndiedroidNova/AcpiTables/AcpiTables.inf @@ -40,7 +40,6 @@ $(RK_COMMON_ACPI_DIR)/Sata0.asl $(RK_COMMON_ACPI_DIR)/Sata1.asl $(RK_COMMON_ACPI_DIR)/Sata2.asl - $(RK_COMMON_ACPI_DIR)/Usb2Host.asl [Packages] ArmPkg/ArmPkg.dec diff --git a/edk2-rockchip/Platform/Ameridroid/IndiedroidNova/AcpiTables/Dsdt.asl b/edk2-rockchip/Platform/Ameridroid/IndiedroidNova/AcpiTables/Dsdt.asl index ee9831b76..4c6e57df7 100644 --- a/edk2-rockchip/Platform/Ameridroid/IndiedroidNova/AcpiTables/Dsdt.asl +++ b/edk2-rockchip/Platform/Ameridroid/IndiedroidNova/AcpiTables/Dsdt.asl @@ -38,7 +38,7 @@ DefinitionBlock ("Dsdt.aml", "DSDT", 2, "RKCP ", "RK3588 ", 2) include ("I2s.asl") - include ("Usb1Host.asl") + include ("Usb2Host.asl") include ("Usb3Host0.asl") include ("Usb3Host2.asl") diff --git a/edk2-rockchip/Platform/Firefly/ITX-3588J/AcpiTables/AcpiTables.inf b/edk2-rockchip/Platform/Firefly/ITX-3588J/AcpiTables/AcpiTables.inf index 6aed97287..5ac5e196a 100644 --- a/edk2-rockchip/Platform/Firefly/ITX-3588J/AcpiTables/AcpiTables.inf +++ b/edk2-rockchip/Platform/Firefly/ITX-3588J/AcpiTables/AcpiTables.inf @@ -40,7 +40,6 @@ $(RK_COMMON_ACPI_DIR)/Sata0.asl $(RK_COMMON_ACPI_DIR)/Sata1.asl $(RK_COMMON_ACPI_DIR)/Sata2.asl - $(RK_COMMON_ACPI_DIR)/Usb2Host.asl [Packages] ArmPkg/ArmPkg.dec diff --git a/edk2-rockchip/Platform/Firefly/ITX-3588J/AcpiTables/Dsdt.asl b/edk2-rockchip/Platform/Firefly/ITX-3588J/AcpiTables/Dsdt.asl index fd9f529a1..60f61eb95 100644 --- a/edk2-rockchip/Platform/Firefly/ITX-3588J/AcpiTables/Dsdt.asl +++ b/edk2-rockchip/Platform/Firefly/ITX-3588J/AcpiTables/Dsdt.asl @@ -29,7 +29,7 @@ DefinitionBlock ("Dsdt.aml", "DSDT", 2, "RKCP ", "RK3588 ", 2) include ("Uart.asl") // include ("Spi.asl") - include ("Usb1Host.asl") + include ("Usb2Host.asl") include ("Usb3Host0.asl") include ("Usb3Host1.asl") include ("Usb3Host2.asl") diff --git a/edk2-rockchip/Platform/Firefly/ROC-RK3588S-PC/AcpiTables/AcpiTables.inf b/edk2-rockchip/Platform/Firefly/ROC-RK3588S-PC/AcpiTables/AcpiTables.inf index c33251956..e262848a2 100644 --- a/edk2-rockchip/Platform/Firefly/ROC-RK3588S-PC/AcpiTables/AcpiTables.inf +++ b/edk2-rockchip/Platform/Firefly/ROC-RK3588S-PC/AcpiTables/AcpiTables.inf @@ -40,7 +40,6 @@ $(RK_COMMON_ACPI_DIR)/Sata0.asl $(RK_COMMON_ACPI_DIR)/Sata1.asl $(RK_COMMON_ACPI_DIR)/Sata2.asl - $(RK_COMMON_ACPI_DIR)/Usb2Host.asl [Packages] ArmPkg/ArmPkg.dec diff --git a/edk2-rockchip/Platform/Firefly/ROC-RK3588S-PC/AcpiTables/Dsdt.asl b/edk2-rockchip/Platform/Firefly/ROC-RK3588S-PC/AcpiTables/Dsdt.asl index a0228a5c0..ebd74ec02 100644 --- a/edk2-rockchip/Platform/Firefly/ROC-RK3588S-PC/AcpiTables/Dsdt.asl +++ b/edk2-rockchip/Platform/Firefly/ROC-RK3588S-PC/AcpiTables/Dsdt.asl @@ -38,7 +38,7 @@ DefinitionBlock ("Dsdt.aml", "DSDT", 2, "RKCP ", "RK3588 ", 2) include ("I2s.asl") - include ("Usb1Host.asl") + include ("Usb2Host.asl") include ("Usb3Host0.asl") include ("Usb3Host2.asl") diff --git a/edk2-rockchip/Platform/FriendlyElec/NanoPC-T6/AcpiTables/AcpiTables.inf b/edk2-rockchip/Platform/FriendlyElec/NanoPC-T6/AcpiTables/AcpiTables.inf index c33251956..e262848a2 100644 --- a/edk2-rockchip/Platform/FriendlyElec/NanoPC-T6/AcpiTables/AcpiTables.inf +++ b/edk2-rockchip/Platform/FriendlyElec/NanoPC-T6/AcpiTables/AcpiTables.inf @@ -40,7 +40,6 @@ $(RK_COMMON_ACPI_DIR)/Sata0.asl $(RK_COMMON_ACPI_DIR)/Sata1.asl $(RK_COMMON_ACPI_DIR)/Sata2.asl - $(RK_COMMON_ACPI_DIR)/Usb2Host.asl [Packages] ArmPkg/ArmPkg.dec diff --git a/edk2-rockchip/Platform/FriendlyElec/NanoPC-T6/AcpiTables/Dsdt.asl b/edk2-rockchip/Platform/FriendlyElec/NanoPC-T6/AcpiTables/Dsdt.asl index 6789498fc..7acff974c 100755 --- a/edk2-rockchip/Platform/FriendlyElec/NanoPC-T6/AcpiTables/Dsdt.asl +++ b/edk2-rockchip/Platform/FriendlyElec/NanoPC-T6/AcpiTables/Dsdt.asl @@ -32,7 +32,7 @@ DefinitionBlock ("Dsdt.aml", "DSDT", 2, "RKCP ", "RK3588 ", 2) include ("I2s.asl") - include ("Usb1Host.asl") + include ("Usb2Host.asl") include ("Usb3Host0.asl") include ("Usb3Host1.asl") // include ("Usb3Host2.asl") diff --git a/edk2-rockchip/Platform/FriendlyElec/NanoPi-R6C/AcpiTables/AcpiTables.inf b/edk2-rockchip/Platform/FriendlyElec/NanoPi-R6C/AcpiTables/AcpiTables.inf index c33251956..e262848a2 100644 --- a/edk2-rockchip/Platform/FriendlyElec/NanoPi-R6C/AcpiTables/AcpiTables.inf +++ b/edk2-rockchip/Platform/FriendlyElec/NanoPi-R6C/AcpiTables/AcpiTables.inf @@ -40,7 +40,6 @@ $(RK_COMMON_ACPI_DIR)/Sata0.asl $(RK_COMMON_ACPI_DIR)/Sata1.asl $(RK_COMMON_ACPI_DIR)/Sata2.asl - $(RK_COMMON_ACPI_DIR)/Usb2Host.asl [Packages] ArmPkg/ArmPkg.dec diff --git a/edk2-rockchip/Platform/FriendlyElec/NanoPi-R6C/AcpiTables/Dsdt.asl b/edk2-rockchip/Platform/FriendlyElec/NanoPi-R6C/AcpiTables/Dsdt.asl index 66cad83dc..ba2376e52 100644 --- a/edk2-rockchip/Platform/FriendlyElec/NanoPi-R6C/AcpiTables/Dsdt.asl +++ b/edk2-rockchip/Platform/FriendlyElec/NanoPi-R6C/AcpiTables/Dsdt.asl @@ -28,7 +28,7 @@ DefinitionBlock ("Dsdt.aml", "DSDT", 2, "RKCP ", "RK3588S", 2) include ("Uart.asl") //include ("Spi.asl") - include ("Usb1Host.asl") + include ("Usb2Host.asl") include ("Usb3Host0.asl") include ("Usb3Host1.asl") } diff --git a/edk2-rockchip/Platform/FriendlyElec/NanoPi-R6S/AcpiTables/AcpiTables.inf b/edk2-rockchip/Platform/FriendlyElec/NanoPi-R6S/AcpiTables/AcpiTables.inf index c33251956..e262848a2 100644 --- a/edk2-rockchip/Platform/FriendlyElec/NanoPi-R6S/AcpiTables/AcpiTables.inf +++ b/edk2-rockchip/Platform/FriendlyElec/NanoPi-R6S/AcpiTables/AcpiTables.inf @@ -40,7 +40,6 @@ $(RK_COMMON_ACPI_DIR)/Sata0.asl $(RK_COMMON_ACPI_DIR)/Sata1.asl $(RK_COMMON_ACPI_DIR)/Sata2.asl - $(RK_COMMON_ACPI_DIR)/Usb2Host.asl [Packages] ArmPkg/ArmPkg.dec diff --git a/edk2-rockchip/Platform/FriendlyElec/NanoPi-R6S/AcpiTables/Dsdt.asl b/edk2-rockchip/Platform/FriendlyElec/NanoPi-R6S/AcpiTables/Dsdt.asl index d0d6d2087..9487e7be1 100755 --- a/edk2-rockchip/Platform/FriendlyElec/NanoPi-R6S/AcpiTables/Dsdt.asl +++ b/edk2-rockchip/Platform/FriendlyElec/NanoPi-R6S/AcpiTables/Dsdt.asl @@ -28,7 +28,7 @@ DefinitionBlock ("Dsdt.aml", "DSDT", 2, "RKCP ", "RK3588 ", 2) include ("Uart.asl") // include ("Spi.asl") - include ("Usb1Host.asl") + include ("Usb2Host.asl") include ("Usb3Host0.asl") include ("Usb3Host2.asl") } diff --git a/edk2-rockchip/Platform/Hinlink/H88K/AcpiTables/AcpiTables.inf b/edk2-rockchip/Platform/Hinlink/H88K/AcpiTables/AcpiTables.inf index c33251956..e262848a2 100644 --- a/edk2-rockchip/Platform/Hinlink/H88K/AcpiTables/AcpiTables.inf +++ b/edk2-rockchip/Platform/Hinlink/H88K/AcpiTables/AcpiTables.inf @@ -40,7 +40,6 @@ $(RK_COMMON_ACPI_DIR)/Sata0.asl $(RK_COMMON_ACPI_DIR)/Sata1.asl $(RK_COMMON_ACPI_DIR)/Sata2.asl - $(RK_COMMON_ACPI_DIR)/Usb2Host.asl [Packages] ArmPkg/ArmPkg.dec diff --git a/edk2-rockchip/Platform/Hinlink/H88K/AcpiTables/Dsdt.asl b/edk2-rockchip/Platform/Hinlink/H88K/AcpiTables/Dsdt.asl index 01e88a417..c6b57a891 100755 --- a/edk2-rockchip/Platform/Hinlink/H88K/AcpiTables/Dsdt.asl +++ b/edk2-rockchip/Platform/Hinlink/H88K/AcpiTables/Dsdt.asl @@ -38,7 +38,7 @@ DefinitionBlock ("Dsdt.aml", "DSDT", 2, "RKCP ", "RK3588 ", 2) include ("I2s.asl") - include ("Usb1Host.asl") + include ("Usb2Host.asl") include ("Usb3Host0.asl") include ("Usb3Host1.asl") include ("Usb3Host2.asl") diff --git a/edk2-rockchip/Platform/Khadas/Edge2/AcpiTables/AcpiTables.inf b/edk2-rockchip/Platform/Khadas/Edge2/AcpiTables/AcpiTables.inf index c33251956..e262848a2 100644 --- a/edk2-rockchip/Platform/Khadas/Edge2/AcpiTables/AcpiTables.inf +++ b/edk2-rockchip/Platform/Khadas/Edge2/AcpiTables/AcpiTables.inf @@ -40,7 +40,6 @@ $(RK_COMMON_ACPI_DIR)/Sata0.asl $(RK_COMMON_ACPI_DIR)/Sata1.asl $(RK_COMMON_ACPI_DIR)/Sata2.asl - $(RK_COMMON_ACPI_DIR)/Usb2Host.asl [Packages] ArmPkg/ArmPkg.dec diff --git a/edk2-rockchip/Platform/Khadas/Edge2/AcpiTables/Dsdt.asl b/edk2-rockchip/Platform/Khadas/Edge2/AcpiTables/Dsdt.asl index 6900027bc..0ee6ea63a 100644 --- a/edk2-rockchip/Platform/Khadas/Edge2/AcpiTables/Dsdt.asl +++ b/edk2-rockchip/Platform/Khadas/Edge2/AcpiTables/Dsdt.asl @@ -38,7 +38,7 @@ DefinitionBlock ("Dsdt.aml", "DSDT", 2, "RKCP ", "RK3588 ", 2) include ("I2s.asl") - include ("Usb1Host.asl") + include ("Usb2Host.asl") include ("Usb3Host0.asl") include ("Usb3Host2.asl") diff --git a/edk2-rockchip/Platform/Mekotronics/R58-Mini/AcpiTables/AcpiTables.inf b/edk2-rockchip/Platform/Mekotronics/R58-Mini/AcpiTables/AcpiTables.inf index c33251956..e262848a2 100644 --- a/edk2-rockchip/Platform/Mekotronics/R58-Mini/AcpiTables/AcpiTables.inf +++ b/edk2-rockchip/Platform/Mekotronics/R58-Mini/AcpiTables/AcpiTables.inf @@ -40,7 +40,6 @@ $(RK_COMMON_ACPI_DIR)/Sata0.asl $(RK_COMMON_ACPI_DIR)/Sata1.asl $(RK_COMMON_ACPI_DIR)/Sata2.asl - $(RK_COMMON_ACPI_DIR)/Usb2Host.asl [Packages] ArmPkg/ArmPkg.dec diff --git a/edk2-rockchip/Platform/Mekotronics/R58-Mini/AcpiTables/Dsdt.asl b/edk2-rockchip/Platform/Mekotronics/R58-Mini/AcpiTables/Dsdt.asl index a409b7cda..d6d8c9446 100644 --- a/edk2-rockchip/Platform/Mekotronics/R58-Mini/AcpiTables/Dsdt.asl +++ b/edk2-rockchip/Platform/Mekotronics/R58-Mini/AcpiTables/Dsdt.asl @@ -28,7 +28,7 @@ DefinitionBlock ("Dsdt.aml", "DSDT", 2, "RKCP ", "RK3588 ", 2) include ("Uart.asl") // include ("Spi.asl") - include ("Usb1Host.asl") + include ("Usb2Host.asl") include ("Usb3Host0.asl") include ("Usb3Host1.asl") include ("Usb3Host2.asl") diff --git a/edk2-rockchip/Platform/Mekotronics/R58X/AcpiTables/AcpiTables.inf b/edk2-rockchip/Platform/Mekotronics/R58X/AcpiTables/AcpiTables.inf index c33251956..e262848a2 100644 --- a/edk2-rockchip/Platform/Mekotronics/R58X/AcpiTables/AcpiTables.inf +++ b/edk2-rockchip/Platform/Mekotronics/R58X/AcpiTables/AcpiTables.inf @@ -40,7 +40,6 @@ $(RK_COMMON_ACPI_DIR)/Sata0.asl $(RK_COMMON_ACPI_DIR)/Sata1.asl $(RK_COMMON_ACPI_DIR)/Sata2.asl - $(RK_COMMON_ACPI_DIR)/Usb2Host.asl [Packages] ArmPkg/ArmPkg.dec diff --git a/edk2-rockchip/Platform/Mekotronics/R58X/AcpiTables/Dsdt.asl b/edk2-rockchip/Platform/Mekotronics/R58X/AcpiTables/Dsdt.asl index a19e0c754..5883e91f8 100644 --- a/edk2-rockchip/Platform/Mekotronics/R58X/AcpiTables/Dsdt.asl +++ b/edk2-rockchip/Platform/Mekotronics/R58X/AcpiTables/Dsdt.asl @@ -39,7 +39,7 @@ DefinitionBlock ("Dsdt.aml", "DSDT", 2, "RKCP ", "RK3588 ", 2) include ("I2s.asl") - include ("Usb1Host.asl") + include ("Usb2Host.asl") include ("Usb3Host0.asl") include ("Usb3Host1.asl") include ("Usb3Host2.asl") diff --git a/edk2-rockchip/Platform/Mixtile/Blade3/AcpiTables/AcpiTables.inf b/edk2-rockchip/Platform/Mixtile/Blade3/AcpiTables/AcpiTables.inf index c33251956..e262848a2 100644 --- a/edk2-rockchip/Platform/Mixtile/Blade3/AcpiTables/AcpiTables.inf +++ b/edk2-rockchip/Platform/Mixtile/Blade3/AcpiTables/AcpiTables.inf @@ -40,7 +40,6 @@ $(RK_COMMON_ACPI_DIR)/Sata0.asl $(RK_COMMON_ACPI_DIR)/Sata1.asl $(RK_COMMON_ACPI_DIR)/Sata2.asl - $(RK_COMMON_ACPI_DIR)/Usb2Host.asl [Packages] ArmPkg/ArmPkg.dec diff --git a/edk2-rockchip/Platform/Mixtile/Blade3/AcpiTables/Dsdt.asl b/edk2-rockchip/Platform/Mixtile/Blade3/AcpiTables/Dsdt.asl index 3ac4dbb1d..8d4a6aef2 100644 --- a/edk2-rockchip/Platform/Mixtile/Blade3/AcpiTables/Dsdt.asl +++ b/edk2-rockchip/Platform/Mixtile/Blade3/AcpiTables/Dsdt.asl @@ -28,7 +28,7 @@ DefinitionBlock ("Dsdt.aml", "DSDT", 2, "RKCP ", "RK3588 ", 2) include ("Uart.asl") // include ("Spi.asl") - include ("Usb1Host.asl") + include ("Usb2Host.asl") include ("Usb3Host0.asl") include ("Usb3Host1.asl") include ("Usb3Host2.asl") diff --git a/edk2-rockchip/Platform/OrangePi/OrangePi5/AcpiTables/AcpiTables.inf b/edk2-rockchip/Platform/OrangePi/OrangePi5/AcpiTables/AcpiTables.inf index c33251956..e262848a2 100644 --- a/edk2-rockchip/Platform/OrangePi/OrangePi5/AcpiTables/AcpiTables.inf +++ b/edk2-rockchip/Platform/OrangePi/OrangePi5/AcpiTables/AcpiTables.inf @@ -40,7 +40,6 @@ $(RK_COMMON_ACPI_DIR)/Sata0.asl $(RK_COMMON_ACPI_DIR)/Sata1.asl $(RK_COMMON_ACPI_DIR)/Sata2.asl - $(RK_COMMON_ACPI_DIR)/Usb2Host.asl [Packages] ArmPkg/ArmPkg.dec diff --git a/edk2-rockchip/Platform/OrangePi/OrangePi5/AcpiTables/Dsdt.asl b/edk2-rockchip/Platform/OrangePi/OrangePi5/AcpiTables/Dsdt.asl index 74222bac7..366aca3c4 100755 --- a/edk2-rockchip/Platform/OrangePi/OrangePi5/AcpiTables/Dsdt.asl +++ b/edk2-rockchip/Platform/OrangePi/OrangePi5/AcpiTables/Dsdt.asl @@ -38,7 +38,7 @@ DefinitionBlock ("Dsdt.aml", "DSDT", 2, "RKCP ", "RK3588 ", 2) include ("I2s.asl") - include ("Usb1Host.asl") + include ("Usb2Host.asl") include ("Usb3Host0.asl") include ("Usb3Host2.asl") diff --git a/edk2-rockchip/Platform/OrangePi/OrangePi5Plus/AcpiTables/AcpiTables.inf b/edk2-rockchip/Platform/OrangePi/OrangePi5Plus/AcpiTables/AcpiTables.inf index c33251956..e262848a2 100644 --- a/edk2-rockchip/Platform/OrangePi/OrangePi5Plus/AcpiTables/AcpiTables.inf +++ b/edk2-rockchip/Platform/OrangePi/OrangePi5Plus/AcpiTables/AcpiTables.inf @@ -40,7 +40,6 @@ $(RK_COMMON_ACPI_DIR)/Sata0.asl $(RK_COMMON_ACPI_DIR)/Sata1.asl $(RK_COMMON_ACPI_DIR)/Sata2.asl - $(RK_COMMON_ACPI_DIR)/Usb2Host.asl [Packages] ArmPkg/ArmPkg.dec diff --git a/edk2-rockchip/Platform/OrangePi/OrangePi5Plus/AcpiTables/Dsdt.asl b/edk2-rockchip/Platform/OrangePi/OrangePi5Plus/AcpiTables/Dsdt.asl index 08ff398b8..a691a731b 100644 --- a/edk2-rockchip/Platform/OrangePi/OrangePi5Plus/AcpiTables/Dsdt.asl +++ b/edk2-rockchip/Platform/OrangePi/OrangePi5Plus/AcpiTables/Dsdt.asl @@ -38,7 +38,7 @@ DefinitionBlock ("Dsdt.aml", "DSDT", 2, "RKCP ", "RK3588 ", 2) include ("I2s.asl") - include ("Usb1Host.asl") + include ("Usb2Host.asl") include ("Usb3Host0.asl") include ("Usb3Host1.asl") diff --git a/edk2-rockchip/Platform/Radxa/ROCK5A/AcpiTables/AcpiTables.inf b/edk2-rockchip/Platform/Radxa/ROCK5A/AcpiTables/AcpiTables.inf index c33251956..e262848a2 100644 --- a/edk2-rockchip/Platform/Radxa/ROCK5A/AcpiTables/AcpiTables.inf +++ b/edk2-rockchip/Platform/Radxa/ROCK5A/AcpiTables/AcpiTables.inf @@ -40,7 +40,6 @@ $(RK_COMMON_ACPI_DIR)/Sata0.asl $(RK_COMMON_ACPI_DIR)/Sata1.asl $(RK_COMMON_ACPI_DIR)/Sata2.asl - $(RK_COMMON_ACPI_DIR)/Usb2Host.asl [Packages] ArmPkg/ArmPkg.dec diff --git a/edk2-rockchip/Platform/Radxa/ROCK5A/AcpiTables/Dsdt.asl b/edk2-rockchip/Platform/Radxa/ROCK5A/AcpiTables/Dsdt.asl index c5683d818..346a8deed 100755 --- a/edk2-rockchip/Platform/Radxa/ROCK5A/AcpiTables/Dsdt.asl +++ b/edk2-rockchip/Platform/Radxa/ROCK5A/AcpiTables/Dsdt.asl @@ -38,7 +38,7 @@ DefinitionBlock ("Dsdt.aml", "DSDT", 2, "RKCP ", "RK3588 ", 2) include ("I2s.asl") - include ("Usb1Host.asl") + include ("Usb2Host.asl") include ("Usb3Host0.asl") include ("Usb3Host2.asl") diff --git a/edk2-rockchip/Platform/Radxa/ROCK5B/AcpiTables/AcpiTables.inf b/edk2-rockchip/Platform/Radxa/ROCK5B/AcpiTables/AcpiTables.inf index c33251956..e262848a2 100644 --- a/edk2-rockchip/Platform/Radxa/ROCK5B/AcpiTables/AcpiTables.inf +++ b/edk2-rockchip/Platform/Radxa/ROCK5B/AcpiTables/AcpiTables.inf @@ -40,7 +40,6 @@ $(RK_COMMON_ACPI_DIR)/Sata0.asl $(RK_COMMON_ACPI_DIR)/Sata1.asl $(RK_COMMON_ACPI_DIR)/Sata2.asl - $(RK_COMMON_ACPI_DIR)/Usb2Host.asl [Packages] ArmPkg/ArmPkg.dec diff --git a/edk2-rockchip/Platform/Radxa/ROCK5B/AcpiTables/Dsdt.asl b/edk2-rockchip/Platform/Radxa/ROCK5B/AcpiTables/Dsdt.asl index 9f43a0224..76550c6f3 100755 --- a/edk2-rockchip/Platform/Radxa/ROCK5B/AcpiTables/Dsdt.asl +++ b/edk2-rockchip/Platform/Radxa/ROCK5B/AcpiTables/Dsdt.asl @@ -38,7 +38,7 @@ DefinitionBlock ("Dsdt.aml", "DSDT", 2, "RKCP ", "RK3588 ", 2) include ("I2s.asl") - include ("Usb1Host.asl") + include ("Usb2Host.asl") include ("Usb3Host0.asl") include ("Usb3Host1.asl") include ("Usb3Host2.asl") diff --git a/edk2-rockchip/Silicon/Rockchip/RK3588/AcpiTables/Usb1Host.asl b/edk2-rockchip/Silicon/Rockchip/RK3588/AcpiTables/Usb1Host.asl deleted file mode 100644 index 1166be078..000000000 --- a/edk2-rockchip/Silicon/Rockchip/RK3588/AcpiTables/Usb1Host.asl +++ /dev/null @@ -1,108 +0,0 @@ -/** @file - * - * USB 1.1 (OHCI) controllers. - * - * Copyright (c) 2022, Rockchip Electronics Co., Ltd - * Copyright (c) 2023, Mario Bălănică - * - * SPDX-License-Identifier: BSD-2-Clause-Patent - * - **/ - -#include "AcpiTables.h" - -Device (OHC0) { - Name (_HID, "PRP0001") - Name (_CLS, Package() { 0x0c, 0x03, 0x10 }) - Name (_UID, Zero) - Name (_CCA, Zero) - - Name (_DSD, Package () { - ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"), - Package () { - Package () { "compatible", "generic-ohci" }, - } - }) - - Method (_CRS, 0x0, Serialized) { - Name (RBUF, ResourceTemplate() { - Memory32Fixed (ReadWrite, 0xFC840000, 0x40000) - Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 248 } - }) - Return (RBUF) - } - - Device (RHUB) { - Name (_ADR, 0) - Device (PRT1) { - Name (_ADR, 1) - Name (_UPC, Package() { - 0xFF, // Port is connectable - 0x00, // Connector type - Type 'A' - 0x00000000, // Reserved, must be zero - 0x00000000 // Reserved, must be zero - }) - Name (_PLD, Package (0x01) { - ToPLD ( - PLD_Revision = 0x2, - PLD_IgnoreColor = 0x1, - PLD_UserVisible = 0x1, - PLD_Panel = "UNKNOWN", - PLD_VerticalPosition = "UPPER", - PLD_HorizontalPosition = "LEFT", - PLD_Shape = "HORIZONTALRECTANGLE", - PLD_Ejectable = 0x1, - PLD_EjectRequired = 0x1, - ) - }) - } - } -} - -Device (OHC1) { - Name (_HID, "PRP0001") - Name (_CLS, Package() { 0x0c, 0x03, 0x10 }) - Name (_UID, One) - Name (_CCA, Zero) - - Name (_DSD, Package () { - ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"), - Package () { - Package () { "compatible", "generic-ohci" }, - } - }) - - Method (_CRS, 0x0, Serialized) { - Name (RBUF, ResourceTemplate() { - Memory32Fixed (ReadWrite, 0xFC8C0000, 0x40000) - Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 251 } - }) - Return (RBUF) - } - - Device (RHUB) { - Name (_ADR, 0) - Device (PRT1) { - Name (_ADR, 1) - Name (_UPC, Package() { - 0xFF, // Port is connectable - 0x00, // Connector type - Type 'A' - 0x00000000, // Reserved, must be zero - 0x00000000 // Reserved, must be zero - }) - Name (_PLD, Package (0x01) { - ToPLD ( - PLD_Revision = 0x2, - PLD_IgnoreColor = 0x1, - PLD_UserVisible = 0x1, - PLD_Panel = "UNKNOWN", - PLD_VerticalPosition = "LOWER", - PLD_HorizontalPosition = "LEFT", - PLD_Shape = "HORIZONTALRECTANGLE", - PLD_Ejectable = 0x1, - PLD_EjectRequired = 0x1, - ) - }) - } - } -} diff --git a/edk2-rockchip/Silicon/Rockchip/RK3588/AcpiTables/Usb2Host.asl b/edk2-rockchip/Silicon/Rockchip/RK3588/AcpiTables/Usb2Host.asl index de93e89c9..40a6df9f4 100644 --- a/edk2-rockchip/Silicon/Rockchip/RK3588/AcpiTables/Usb2Host.asl +++ b/edk2-rockchip/Silicon/Rockchip/RK3588/AcpiTables/Usb2Host.asl @@ -1,9 +1,9 @@ /** @file * - * USB 2.0 (EHCI) controllers. + * USB 2.0 (EHCI + OHCI) controllers. * * Copyright (c) 2022, Rockchip Electronics Co., Ltd - * Copyright (c) 2023, Mario Bălănică + * Copyright (c) 2024, Mario Bălănică * * SPDX-License-Identifier: BSD-2-Clause-Patent * @@ -11,88 +11,188 @@ #include "AcpiTables.h" -DefinitionBlock (__FILE__, "SSDT", 5, "RKCP ", "USB2HOST", 2) -{ - Scope (\_SB_) - { - Device (EHC0) { - Name (_HID, "PNP0D20") - Name (_UID, Zero) - Name (_CCA, Zero) - - Method (_CRS, 0x0, Serialized) { - Name (RBUF, ResourceTemplate() { - Memory32Fixed (ReadWrite, 0xFC800000, 0x40000) - Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 247 } +Scope (\_SB_) { + Name (EHID, 1) // Expose EHCI PNP _CID + + Device (EHC0) { + Name (_HID, "RKCP0D20") + If (EHID == 1) { + Name (_CID, "PNP0D20") + } + Name (_UID, Zero) + Name (_CCA, Zero) + + Method (_CRS, 0x0, Serialized) { + Name (RBUF, ResourceTemplate() { + Memory32Fixed (ReadWrite, 0xFC800000, 0x40000) + Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 247 } + }) + Return (RBUF) + } + + Device (RHUB) { + Name (_ADR, 0) + Device (PRT1) { + Name (_ADR, 1) + Name (_UPC, Package() { + 0xFF, // Port is connectable + 0x00, // Connector type - Type 'A' + 0x00000000, // Reserved, must be zero + 0x00000000 // Reserved, must be zero + }) + Name (_PLD, Package (0x01) { + ToPLD ( + PLD_Revision = 0x2, + PLD_IgnoreColor = 0x1, + PLD_UserVisible = 0x1, + PLD_Panel = "UNKNOWN", + PLD_VerticalPosition = "UPPER", + PLD_HorizontalPosition = "LEFT", + PLD_Shape = "HORIZONTALRECTANGLE", + PLD_Ejectable = 0x1, + PLD_EjectRequired = 0x1, + ) }) - Return (RBUF) } + } + } - Device (RHUB) { - Name (_ADR, 0) - Device (PRT1) { - Name (_ADR, 1) - Name (_UPC, Package() { - 0xFF, // Port is connectable - 0x00, // Connector type - Type 'A' - 0x00000000, // Reserved, must be zero - 0x00000000 // Reserved, must be zero - }) - Name (_PLD, Package (0x01) { - ToPLD ( - PLD_Revision = 0x2, - PLD_IgnoreColor = 0x1, - PLD_UserVisible = 0x1, - PLD_Panel = "UNKNOWN", - PLD_VerticalPosition = "UPPER", - PLD_HorizontalPosition = "LEFT", - PLD_Shape = "HORIZONTALRECTANGLE", - PLD_Ejectable = 0x1, - PLD_EjectRequired = 0x1, - ) - }) - } + Device (EHC1) { + Name (_HID, "RKCP0D20") + If (EHID == 1) { + Name (_CID, "PNP0D20") + } + Name (_UID, One) + Name (_CCA, Zero) + + Method (_CRS, 0x0, Serialized) { + Name (RBUF, ResourceTemplate() { + Memory32Fixed (ReadWrite, 0xFC880000, 0x40000) + Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 250 } + }) + Return (RBUF) + } + + Device (RHUB) { + Name (_ADR, 0) + Device (PRT1) { + Name (_ADR, 1) + Name (_UPC, Package() { + 0xFF, // Port is connectable + 0x00, // Connector type - Type 'A' + 0x00000000, // Reserved, must be zero + 0x00000000 // Reserved, must be zero + }) + Name (_PLD, Package (0x01) { + ToPLD ( + PLD_Revision = 0x2, + PLD_IgnoreColor = 0x1, + PLD_UserVisible = 0x1, + PLD_Panel = "UNKNOWN", + PLD_VerticalPosition = "LOWER", + PLD_HorizontalPosition = "LEFT", + PLD_Shape = "HORIZONTALRECTANGLE", + PLD_Ejectable = 0x1, + PLD_EjectRequired = 0x1, + ) + }) } } + } - Device (EHC1) { - Name (_HID, "PNP0D20") - Name (_UID, One) - Name (_CCA, Zero) + Device (OHC0) { + Name (_HID, "PRP0001") + Name (_CLS, Package() { 0x0c, 0x03, 0x10 }) + Name (_UID, Zero) + Name (_CCA, Zero) - Method (_CRS, 0x0, Serialized) { - Name (RBUF, ResourceTemplate() { - Memory32Fixed (ReadWrite, 0xFC880000, 0x40000) - Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 250 } + Name (_DSD, Package () { + ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"), + Package () { + Package () { "compatible", "generic-ohci" }, + } + }) + + Method (_CRS, 0x0, Serialized) { + Name (RBUF, ResourceTemplate() { + Memory32Fixed (ReadWrite, 0xFC840000, 0x40000) + Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 248 } + }) + Return (RBUF) + } + + Device (RHUB) { + Name (_ADR, 0) + Device (PRT1) { + Name (_ADR, 1) + Name (_UPC, Package() { + 0xFF, // Port is connectable + 0x00, // Connector type - Type 'A' + 0x00000000, // Reserved, must be zero + 0x00000000 // Reserved, must be zero + }) + Name (_PLD, Package (0x01) { + ToPLD ( + PLD_Revision = 0x2, + PLD_IgnoreColor = 0x1, + PLD_UserVisible = 0x1, + PLD_Panel = "UNKNOWN", + PLD_VerticalPosition = "UPPER", + PLD_HorizontalPosition = "LEFT", + PLD_Shape = "HORIZONTALRECTANGLE", + PLD_Ejectable = 0x1, + PLD_EjectRequired = 0x1, + ) }) - Return (RBUF) } + } + } + + Device (OHC1) { + Name (_HID, "PRP0001") + Name (_CLS, Package() { 0x0c, 0x03, 0x10 }) + Name (_UID, One) + Name (_CCA, Zero) - Device (RHUB) { - Name (_ADR, 0) - Device (PRT1) { - Name (_ADR, 1) - Name (_UPC, Package() { - 0xFF, // Port is connectable - 0x00, // Connector type - Type 'A' - 0x00000000, // Reserved, must be zero - 0x00000000 // Reserved, must be zero - }) - Name (_PLD, Package (0x01) { - ToPLD ( - PLD_Revision = 0x2, - PLD_IgnoreColor = 0x1, - PLD_UserVisible = 0x1, - PLD_Panel = "UNKNOWN", - PLD_VerticalPosition = "LOWER", - PLD_HorizontalPosition = "LEFT", - PLD_Shape = "HORIZONTALRECTANGLE", - PLD_Ejectable = 0x1, - PLD_EjectRequired = 0x1, - ) - }) - } + Name (_DSD, Package () { + ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"), + Package () { + Package () { "compatible", "generic-ohci" }, + } + }) + + Method (_CRS, 0x0, Serialized) { + Name (RBUF, ResourceTemplate() { + Memory32Fixed (ReadWrite, 0xFC8C0000, 0x40000) + Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 251 } + }) + Return (RBUF) + } + + Device (RHUB) { + Name (_ADR, 0) + Device (PRT1) { + Name (_ADR, 1) + Name (_UPC, Package() { + 0xFF, // Port is connectable + 0x00, // Connector type - Type 'A' + 0x00000000, // Reserved, must be zero + 0x00000000 // Reserved, must be zero + }) + Name (_PLD, Package (0x01) { + ToPLD ( + PLD_Revision = 0x2, + PLD_IgnoreColor = 0x1, + PLD_UserVisible = 0x1, + PLD_Panel = "UNKNOWN", + PLD_VerticalPosition = "LOWER", + PLD_HorizontalPosition = "LEFT", + PLD_Shape = "HORIZONTALRECTANGLE", + PLD_Ejectable = 0x1, + PLD_EjectRequired = 0x1, + ) + }) } } - } // Scope (\_SB_) -} // DefinitionBlock + } +} diff --git a/edk2-rockchip/Silicon/Rockchip/RK3588/Drivers/AcpiPlatformDxe/AcpiPlatformDxe.c b/edk2-rockchip/Silicon/Rockchip/RK3588/Drivers/AcpiPlatformDxe/AcpiPlatformDxe.c index 7382e6b86..e18609059 100644 --- a/edk2-rockchip/Silicon/Rockchip/RK3588/Drivers/AcpiPlatformDxe/AcpiPlatformDxe.c +++ b/edk2-rockchip/Silicon/Rockchip/RK3588/Drivers/AcpiPlatformDxe/AcpiPlatformDxe.c @@ -3,15 +3,19 @@ * ACPI platform driver * * Copyright (c) 2020, Jeremy Linton - * Copyright (c) 2023, Mario Bălănică + * Copyright (c) 2024, Mario Bălănică * * SPDX-License-Identifier: BSD-2-Clause-Patent * **/ +#include +#include #include +#include #include #include +#include #include #include #include @@ -20,89 +24,77 @@ STATIC CONST EFI_GUID mAcpiTableFile = { 0x7E374E25, 0x8E01, 0x4FEE, { 0x87, 0xf2, 0x39, 0x0C, 0x23, 0xC6, 0x06, 0xCD } }; -typedef struct { - CHAR8 Name[4]; - UINTN PcdToken; -} AML_NAME_OP_REPLACE; +STATIC EFI_EXIT_BOOT_SERVICES mOriginalExitBootServices; + +STATIC EFI_ACPI_SDT_PROTOCOL *mAcpiSdtProtocol; + +typedef enum { + AcpiOsUnknown = 0, + AcpiOsWindows, +} ACPI_OS_BOOT_TYPE; + +#define SDT_PATTERN_LEN (AML_NAME_SEG_SIZE + 1) -#define SSDT_PATTERN_LEN 5 -#define AML_NAMEOP_8 0x0A -#define AML_NAMEOP_16 0x0B -#define AML_NAMEOP_32 0x0C -#define AML_NAMEOP_STR 0x0D -// -// Scan the given namespace table (DSDT/SSDT) for AML NameOps -// listed in the NameOpReplace structure. If one is found then -// update the value in the table from the specified Pcd // -// This allows us to have conditionals in AML controlled -// by options in the BDS or detected during firmware bootstrap. -// We could extend this concept for strings/etc but due to len -// variations its probably easier to encode the strings -// in the ASL and pick the correct one based off a variable. +// Simple NameOp integer patcher. +// Does not allocate memory and can be safely used at ExitBootServices. // STATIC -VOID -AcpiUpdateSdtNameOps ( - EFI_ACPI_DESCRIPTION_HEADER *AcpiTable, - CONST AML_NAME_OP_REPLACE *NameOpReplace +EFI_STATUS +AcpiUpdateSdtNameInteger ( + IN EFI_ACPI_DESCRIPTION_HEADER *AcpiTable, + IN CHAR8 Name[AML_NAME_SEG_SIZE], + IN UINTN Value ) { - UINTN Idx; - UINTN Index; - CHAR8 Pattern[SSDT_PATTERN_LEN]; - UINTN PcdVal; - UINT8 *SdtPtr; - UINT32 SdtSize; - - SdtSize = AcpiTable->Length; - - if (SdtSize > 0) { - SdtPtr = (UINT8 *)AcpiTable; - - for (Idx = 0; NameOpReplace && NameOpReplace[Idx].PcdToken; Idx++) { - // - // Do a single NameOp variable replacement these are of the - // form 08 XXXX SIZE VAL, where SIZE is 0A=byte, 0B=word, 0C=dword - // and XXXX is the name and VAL is the value - // - Pattern[0] = 0x08; - Pattern[1] = NameOpReplace[Idx].Name[0]; - Pattern[2] = NameOpReplace[Idx].Name[1]; - Pattern[3] = NameOpReplace[Idx].Name[2]; - Pattern[4] = NameOpReplace[Idx].Name[3]; - - for (Index = 0; Index < (SdtSize - SSDT_PATTERN_LEN); Index++) { - if (CompareMem (SdtPtr + Index, Pattern, SSDT_PATTERN_LEN) == 0) { - PcdVal = LibPcdGet32 (NameOpReplace[Idx].PcdToken); - switch (SdtPtr[Index + SSDT_PATTERN_LEN]) { - case AML_NAMEOP_32: - SdtPtr[Index + SSDT_PATTERN_LEN + 4] = (PcdVal >> 24) & 0xFF; - SdtPtr[Index + SSDT_PATTERN_LEN + 3] = (PcdVal >> 16) & 0xFF; - // Fallthrough - case AML_NAMEOP_16: - SdtPtr[Index + SSDT_PATTERN_LEN + 2] = (PcdVal >> 8) & 0xFF; - // Fallthrough - case AML_NAMEOP_8: - SdtPtr[Index + SSDT_PATTERN_LEN + 1] = PcdVal & 0xFF; - break; - case 0: - case 1: - SdtPtr[Index + SSDT_PATTERN_LEN + 1] = !!PcdVal; - break; - case AML_NAMEOP_STR: - // - // If the string val is added to the NameOpReplace, we can - // dynamically update things like _HID too as long as the - // string length matches. - // - break; - } + UINTN Index; + CHAR8 Pattern[SDT_PATTERN_LEN]; + UINT8 *SdtPtr; + UINT32 DataSize; + UINT32 ValueOffset; + + if (AcpiTable->Length <= SDT_PATTERN_LEN) { + return EFI_INVALID_PARAMETER; + } + + SdtPtr = (UINT8 *)AcpiTable; + // + // Do a single NameOp variable replacement. These are of the + // form "08 XXXX SIZE VAL", where SIZE is: 0A=byte, 0B=word, 0C=dword, + // XXXX is the name and VAL is the value. + // + Pattern[0] = AML_NAME_OP; + CopyMem (Pattern + 1, Name, AML_NAME_SEG_SIZE); + + ValueOffset = SDT_PATTERN_LEN + 1; + + for (Index = 0; Index < (AcpiTable->Length - SDT_PATTERN_LEN); Index++) { + if (CompareMem (SdtPtr + Index, Pattern, SDT_PATTERN_LEN) == 0) { + switch (SdtPtr[Index + SDT_PATTERN_LEN]) { + case AML_QWORD_PREFIX: + DataSize = sizeof (UINT64); + break; + case AML_DWORD_PREFIX: + DataSize = sizeof (UINT32); + break; + case AML_WORD_PREFIX: + DataSize = sizeof (UINT16); + break; + case AML_ONE_OP: + case AML_ZERO_OP: + ValueOffset--; + // Fallthrough + case AML_BYTE_PREFIX: + DataSize = sizeof (UINT8); break; - } + default: + return EFI_UNSUPPORTED; } + CopyMem (SdtPtr + Index + ValueOffset, &Value, DataSize); + return EFI_SUCCESS; } } + return EFI_NOT_FOUND; } STATIC @@ -112,10 +104,8 @@ AcpiVerifyUpdateTable ( ) { BOOLEAN Result; - AML_NAME_OP_REPLACE *NameOpReplace; Result = TRUE; - NameOpReplace = NULL; switch (AcpiHeader->OemTableId) { case SIGNATURE_64 ('P', 'C', 'I', 'E', '3', '4', 'L', '0'): @@ -143,13 +133,6 @@ AcpiVerifyUpdateTable ( case SIGNATURE_64 ('A', 'H', 'C', 'S', 'A', 'T', 'A', '2'): Result = PcdGet32 (PcdComboPhy2Mode) == COMBO_PHY_MODE_SATA; break; - case SIGNATURE_64 ('U', 'S', 'B', '2', 'H', 'O', 'S', 'T'): - Result = PcdGet32 (PcdAcpiUsb2State) == ACPI_USB2_STATE_ENABLED; - break; - } - - if (Result && NameOpReplace) { - AcpiUpdateSdtNameOps (AcpiHeader, NameOpReplace); } return Result; @@ -202,6 +185,15 @@ NotifyEndOfDxeEvent ( { EFI_STATUS Status; + Status = gBS->LocateProtocol ( + &gEfiAcpiSdtProtocolGuid, + NULL, + (VOID **)&mAcpiSdtProtocol); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "AcpiPlatform: Couldn't locate gEfiAcpiSdtProtocolGuid! Status=%r\n", Status)); + return; + } + Status = LocateAndInstallAcpiFromFvConditional (&mAcpiTableFile, &AcpiHandleDynamicNamespace); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_WARN, "AcpiPlatform: Failed to install firmware ACPI as config table. Status=%r\n", @@ -209,6 +201,130 @@ NotifyEndOfDxeEvent ( } } +STATIC +VOID +EFIAPI +AcpiPlatformOsBootHandler ( + IN ACPI_OS_BOOT_TYPE OsType + ) +{ + EFI_STATUS Status; + EFI_ACPI_DESCRIPTION_HEADER *Table; + UINTN TableKey; + UINTN TableIndex; + + if (mAcpiSdtProtocol == NULL) { + return; + } + + TableIndex = 0; + Status = AcpiLocateTableBySignature ( + mAcpiSdtProtocol, + EFI_ACPI_6_3_DIFFERENTIATED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE, + &TableIndex, + &Table, + &TableKey); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: Couldn't locate ACPI DSDT table! Status=%r\n", + __func__, Status)); + return; + } + + // + // Hide EHCI PNP ID for Windows to avoid binding to the inbox driver, + // which by default uses atomics on uncached memory and would crash + // the system. + // + if (OsType == AcpiOsWindows) { + AcpiUpdateSdtNameInteger (Table, "EHID", 0); + } + + AcpiUpdateChecksum ((UINT8 *)Table, Table->Length); +} + +STATIC +UINTN +EFIAPI +FindPeImageBase ( + EFI_PHYSICAL_ADDRESS Base + ) +{ + EFI_IMAGE_DOS_HEADER *DosHdr; + EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr; + + Base &= ~(EFI_PAGE_SIZE - 1); + + while (Base != 0) { + DosHdr = (EFI_IMAGE_DOS_HEADER *)Base; + if (DosHdr->e_magic == EFI_IMAGE_DOS_SIGNATURE) { + Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)(Base + DosHdr->e_lfanew); + if (Hdr.Pe32->Signature == EFI_IMAGE_NT_SIGNATURE) { + break; + } + } + + Base -= EFI_PAGE_SIZE; + } + + return Base; +} + +STATIC CHAR8 mWinLoadNameStr[] = "winload"; +#define PDB_NAME_MAX_LENGTH 256 + +STATIC +BOOLEAN +IsPeImageWinLoader ( + IN VOID *PeImage + ) +{ + CHAR8 *PdbStr; + UINTN Index; + + PdbStr = (CHAR8 *)PeCoffLoaderGetPdbPointer (PeImage); + if (PdbStr == NULL) { + return FALSE; + } + + for (Index = 0; Index < PDB_NAME_MAX_LENGTH && PdbStr[Index] != '\0'; Index++) { + if (AsciiStrnCmp (PdbStr + Index, mWinLoadNameStr, sizeof (mWinLoadNameStr) - sizeof (CHAR8)) == 0) { + return TRUE; + } + } + + return FALSE; +} + +STATIC +EFI_STATUS +EFIAPI +AcpiPlatformExitBootServicesHook ( + IN EFI_HANDLE ImageHandle, + IN UINTN MapKey + ) +{ + UINTN ReturnAddress; + UINTN OsLoaderAddress; + ACPI_OS_BOOT_TYPE OsType; + + ReturnAddress = (UINTN)RETURN_ADDRESS (0); + + gBS->ExitBootServices = mOriginalExitBootServices; + + OsType = AcpiOsUnknown; + + OsLoaderAddress = FindPeImageBase (ReturnAddress); + if (OsLoaderAddress > 0) { + if (IsPeImageWinLoader ((VOID *)OsLoaderAddress)) { + OsType = AcpiOsWindows; + } + } + + AcpiPlatformOsBootHandler (OsType); + + return gBS->ExitBootServices (ImageHandle, MapKey); +} + EFI_STATUS EFIAPI AcpiPlatformDxeInitialize ( @@ -234,5 +350,8 @@ AcpiPlatformDxeInitialize ( ); ASSERT_EFI_ERROR (Status); + mOriginalExitBootServices = gBS->ExitBootServices; + gBS->ExitBootServices = AcpiPlatformExitBootServicesHook; + return EFI_SUCCESS; } diff --git a/edk2-rockchip/Silicon/Rockchip/RK3588/Drivers/AcpiPlatformDxe/AcpiPlatformDxe.inf b/edk2-rockchip/Silicon/Rockchip/RK3588/Drivers/AcpiPlatformDxe/AcpiPlatformDxe.inf index 9e22052e8..6416de46f 100644 --- a/edk2-rockchip/Silicon/Rockchip/RK3588/Drivers/AcpiPlatformDxe/AcpiPlatformDxe.inf +++ b/edk2-rockchip/Silicon/Rockchip/RK3588/Drivers/AcpiPlatformDxe/AcpiPlatformDxe.inf @@ -28,8 +28,10 @@ [LibraryClasses] AcpiLib + BaseLib BaseMemoryLib DebugLib + PeCoffGetEntryPointLib UefiBootServicesTableLib UefiDriverEntryPoint @@ -37,10 +39,10 @@ gEfiEndOfDxeEventGroupGuid [Protocols] + gEfiAcpiSdtProtocolGuid [Pcd] gRK3588TokenSpaceGuid.PcdConfigTableMode - gRK3588TokenSpaceGuid.PcdAcpiUsb2State gRK3588TokenSpaceGuid.PcdComboPhy0Mode gRK3588TokenSpaceGuid.PcdComboPhy1Mode gRK3588TokenSpaceGuid.PcdComboPhy2Mode diff --git a/edk2-rockchip/Silicon/Rockchip/RK3588/Drivers/RK3588Dxe/ConfigTable.c b/edk2-rockchip/Silicon/Rockchip/RK3588/Drivers/RK3588Dxe/ConfigTable.c index a6df625b1..0a08b29f1 100644 --- a/edk2-rockchip/Silicon/Rockchip/RK3588/Drivers/RK3588Dxe/ConfigTable.c +++ b/edk2-rockchip/Silicon/Rockchip/RK3588/Drivers/RK3588Dxe/ConfigTable.c @@ -43,15 +43,6 @@ SetupConfigTableVariables ( ASSERT_EFI_ERROR (Status); } - Size = sizeof (UINT32); - Status = gRT->GetVariable (L"AcpiUsb2State", - &gRK3588DxeFormSetGuid, - NULL, &Size, &Var32); - if (EFI_ERROR (Status)) { - Status = PcdSet32S (PcdAcpiUsb2State, FixedPcdGet32 (PcdAcpiUsb2StateDefault)); - ASSERT_EFI_ERROR (Status); - } - Size = sizeof (UINT8); Status = gRT->GetVariable (L"FdtSupportOverrides", &gRK3588DxeFormSetGuid, diff --git a/edk2-rockchip/Silicon/Rockchip/RK3588/Drivers/RK3588Dxe/RK3588Dxe.inf b/edk2-rockchip/Silicon/Rockchip/RK3588/Drivers/RK3588Dxe/RK3588Dxe.inf index 55a2e8154..9942afce5 100644 --- a/edk2-rockchip/Silicon/Rockchip/RK3588/Drivers/RK3588Dxe/RK3588Dxe.inf +++ b/edk2-rockchip/Silicon/Rockchip/RK3588/Drivers/RK3588Dxe/RK3588Dxe.inf @@ -93,8 +93,6 @@ gRK3588TokenSpaceGuid.PcdPcie30State gRK3588TokenSpaceGuid.PcdConfigTableMode - gRK3588TokenSpaceGuid.PcdAcpiUsb2StateDefault - gRK3588TokenSpaceGuid.PcdAcpiUsb2State gRK3588TokenSpaceGuid.PcdFdtSupportOverrides gRK3588TokenSpaceGuid.PcdHasOnBoardFanOutput diff --git a/edk2-rockchip/Silicon/Rockchip/RK3588/Drivers/RK3588Dxe/RK3588DxeHii.uni b/edk2-rockchip/Silicon/Rockchip/RK3588/Drivers/RK3588Dxe/RK3588DxeHii.uni index 54cb4cc49..37f801c70 100644 --- a/edk2-rockchip/Silicon/Rockchip/RK3588/Drivers/RK3588Dxe/RK3588DxeHii.uni +++ b/edk2-rockchip/Silicon/Rockchip/RK3588/Drivers/RK3588Dxe/RK3588DxeHii.uni @@ -136,9 +136,6 @@ #string STR_CONFIG_TABLE_ACPI_SUBTITLE #language en-US "ACPI Configuration" -#string STR_ACPI_USB2_STATE_PROMPT #language en-US "USB 2.0 Support" -#string STR_ACPI_USB2_STATE_HELP #language en-US "Enable or disable the USB 2.0 (EHCI) controllers.\n\nThis option is disabled by default due to compatibility issues with Windows, but it can be enabled for other OSes." - #string STR_CONFIG_TABLE_FDT_SUBTITLE #language en-US "Device Tree Configuration" #string STR_FDT_SUPPORT_OVERRIDES_PROMPT #language en-US "Support DTB override & overlays" #string STR_FDT_SUPPORT_OVERRIDES_HELP #language en-US "Enable or disable support for overriding the firmware-provided DTB and installing overlays.\n\nCheck firmware documentation for more details." diff --git a/edk2-rockchip/Silicon/Rockchip/RK3588/Drivers/RK3588Dxe/RK3588DxeHii.vfr b/edk2-rockchip/Silicon/Rockchip/RK3588/Drivers/RK3588Dxe/RK3588DxeHii.vfr index 848c16722..bf22bf35a 100644 --- a/edk2-rockchip/Silicon/Rockchip/RK3588/Drivers/RK3588Dxe/RK3588DxeHii.vfr +++ b/edk2-rockchip/Silicon/Rockchip/RK3588/Drivers/RK3588Dxe/RK3588DxeHii.vfr @@ -127,11 +127,6 @@ formset name = ConfigTableMode, guid = RK3588DXE_FORMSET_GUID; - efivarstore ACPI_USB2_STATE_VARSTORE_DATA, - attribute = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE, - name = AcpiUsb2State, - guid = RK3588DXE_FORMSET_GUID; - efivarstore FDT_SUPPORT_OVERRIDES_VARSTORE_DATA, attribute = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE, name = FdtSupportOverrides, @@ -479,19 +474,12 @@ formset option text = STRING_TOKEN(STR_CONFIG_TABLE_MODE_ACPI_FDT), value = CONFIG_TABLE_MODE_ACPI_FDT, flags = 0; endoneof; +#if 0 suppressif (get(ConfigTableMode.Mode) & CONFIG_TABLE_MODE_ACPI) == 0; subtitle text = STRING_TOKEN(STR_NULL_STRING); subtitle text = STRING_TOKEN(STR_CONFIG_TABLE_ACPI_SUBTITLE); - - oneof varid = AcpiUsb2State.State, - prompt = STRING_TOKEN(STR_ACPI_USB2_STATE_PROMPT), - help = STRING_TOKEN(STR_ACPI_USB2_STATE_HELP), - flags = NUMERIC_SIZE_4 | INTERACTIVE | RESET_REQUIRED, - default = FixedPcdGet32 (PcdAcpiUsb2StateDefault), - option text = STRING_TOKEN(STR_DISABLED), value = ACPI_USB2_STATE_DISABLED, flags = 0; - option text = STRING_TOKEN(STR_ENABLED), value = ACPI_USB2_STATE_ENABLED, flags = 0; - endoneof; endif; +#endif suppressif (get(ConfigTableMode.Mode) & CONFIG_TABLE_MODE_FDT) == 0; subtitle text = STRING_TOKEN(STR_NULL_STRING); diff --git a/edk2-rockchip/Silicon/Rockchip/RK3588/Include/VarStoreData.h b/edk2-rockchip/Silicon/Rockchip/RK3588/Include/VarStoreData.h index 3c74b1d16..dc280701b 100644 --- a/edk2-rockchip/Silicon/Rockchip/RK3588/Include/VarStoreData.h +++ b/edk2-rockchip/Silicon/Rockchip/RK3588/Include/VarStoreData.h @@ -52,12 +52,6 @@ typedef struct { UINT32 Mode; } CONFIG_TABLE_MODE_VARSTORE_DATA; -#define ACPI_USB2_STATE_DISABLED 0 -#define ACPI_USB2_STATE_ENABLED 1 -typedef struct { - UINT32 State; -} ACPI_USB2_STATE_VARSTORE_DATA; - typedef struct { UINT8 State; } FDT_SUPPORT_OVERRIDES_VARSTORE_DATA; diff --git a/edk2-rockchip/Silicon/Rockchip/RK3588/RK3588.dec b/edk2-rockchip/Silicon/Rockchip/RK3588/RK3588.dec index 140af6932..27ee5eb93 100644 --- a/edk2-rockchip/Silicon/Rockchip/RK3588/RK3588.dec +++ b/edk2-rockchip/Silicon/Rockchip/RK3588/RK3588.dec @@ -43,8 +43,6 @@ gRK3588TokenSpaceGuid.PcdPcie30Supported|FALSE|BOOLEAN|0x00010201 - gRK3588TokenSpaceGuid.PcdAcpiUsb2StateDefault|0|UINT32|0x00010301 - gRK3588TokenSpaceGuid.PcdHasOnBoardFanOutput|FALSE|BOOLEAN|0x10401 gRK3588TokenSpaceGuid.PcdUsbDpPhy0Supported|FALSE|BOOLEAN|0x00010501 @@ -83,7 +81,6 @@ gRK3588TokenSpaceGuid.PcdPcie30State|0|UINT32|0x00000201 gRK3588TokenSpaceGuid.PcdConfigTableMode|0|UINT32|0x00000300 - gRK3588TokenSpaceGuid.PcdAcpiUsb2State|0|UINT32|0x00000301 gRK3588TokenSpaceGuid.PcdFdtSupportOverrides|0|UINT8|0x00000351 gRK3588TokenSpaceGuid.PcdCoolingFanState|0|UINT32|0x00000401 diff --git a/edk2-rockchip/Silicon/Rockchip/RK3588/RK3588Base.dsc.inc b/edk2-rockchip/Silicon/Rockchip/RK3588/RK3588Base.dsc.inc index 167f477fe..8c235ff79 100644 --- a/edk2-rockchip/Silicon/Rockchip/RK3588/RK3588Base.dsc.inc +++ b/edk2-rockchip/Silicon/Rockchip/RK3588/RK3588Base.dsc.inc @@ -35,9 +35,6 @@ DEFINE COMBO_PHY_MODE_SATA = 2 DEFINE COMBO_PHY_MODE_USB3 = 3 - DEFINE ACPI_USB2_STATE_DISABLED = 0 - DEFINE ACPI_USB2_STATE_ENABLED = 1 - DEFINE COOLING_FAN_STATE_DISABLED = 0 DEFINE COOLING_FAN_STATE_ENABLED = 1 @@ -255,8 +252,6 @@ # # ACPI support flags and default values # - # EHCI disabled by default since it crashes Windows. - gRK3588TokenSpaceGuid.PcdAcpiUsb2StateDefault|$(ACPI_USB2_STATE_DISABLED) [PcdsPatchableInModule] gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate|1500000 @@ -303,7 +298,6 @@ # ACPI / Device Tree # gRK3588TokenSpaceGuid.PcdConfigTableMode|L"ConfigTableMode"|gRK3588DxeFormSetGuid|0x0|$(CONFIG_TABLE_MODE_ACPI) - gRK3588TokenSpaceGuid.PcdAcpiUsb2State|L"AcpiUsb2State"|gRK3588DxeFormSetGuid|0x0|gRK3588TokenSpaceGuid.PcdAcpiUsb2StateDefault gRK3588TokenSpaceGuid.PcdFdtSupportOverrides|L"FdtSupportOverrides"|gRK3588DxeFormSetGuid|0x0|FALSE #