public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Jeremy Linton" <jeremy.linton@arm.com>
To: devel@edk2.groups.io
Cc: pete@akeo.ie, ardb+tianocore@kernel.org, leif@nuviainc.com,
	awarkentin@vmware.com, Sunny.Wang@arm.com,
	samer.el-haj-mahmoud@arm.com, mariobalanica02@gmail.com,
	Jeremy Linton <jeremy.linton@arm.com>
Subject: [PATCH 2/9] Platform/RaspberryPi: Give the user control over the XHCI mailbox
Date: Thu,  2 Dec 2021 10:51:59 -0600	[thread overview]
Message-ID: <20211202165206.79615-3-jeremy.linton@arm.com> (raw)
In-Reply-To: <20211202165206.79615-1-jeremy.linton@arm.com>

Its a complete tossup whether removing the mailbox call after we have
set up the XHCI works for a given kernel+distro in DT mode. So lets
give users which want to try DT the option of flipping this on/off.

Users that don't want to have to deal with DT, can use ACPI.

Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
---
 Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c      | 10 ++++++++++
 Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf    |  1 +
 Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni |  5 +++++
 Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr | 15 +++++++++++++++
 Platform/RaspberryPi/Drivers/FdtDxe/FdtDxe.c            | 10 +++++++---
 Platform/RaspberryPi/Drivers/FdtDxe/FdtDxe.inf          |  1 +
 Platform/RaspberryPi/RPi3/RPi3.dsc                      |  6 ++++++
 Platform/RaspberryPi/RPi4/RPi4.dsc                      |  7 +++++++
 Platform/RaspberryPi/RaspberryPi.dec                    |  1 +
 9 files changed, 53 insertions(+), 3 deletions(-)

diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c
index 6b69934ef3..8979b3da4c 100644
--- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c
+++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c
@@ -297,6 +297,16 @@ SetupVariables (
         Status = PcdSet32S (PcdXhciPci, 1);
         ASSERT_EFI_ERROR (Status);
       }
+
+      Size = sizeof (UINT32);
+      Status = gRT->GetVariable (L"XhciReload",
+                                 &gConfigDxeFormSetGuid,
+                                 NULL, &Size, &Var32);
+      if (EFI_ERROR (Status)) {
+        Status = PcdSet32S (PcdXhciReload, PcdGet32 (PcdXhciReload));
+        ASSERT_EFI_ERROR (Status);
+      }
+
     }
   } else {
     /*
diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf
index e6e22ad82e..ff182e831d 100644
--- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf
+++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf
@@ -95,6 +95,7 @@
   gRaspberryPiTokenSpaceGuid.PcdFanTemp
   gRaspberryPiTokenSpaceGuid.PcdUartInUse
   gRaspberryPiTokenSpaceGuid.PcdXhciPci
+  gRaspberryPiTokenSpaceGuid.PcdXhciReload
 
 [Depex]
   gPcdProtocolGuid AND gRaspberryPiFirmwareProtocolGuid
diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni
index e25bb83cd3..e40b0914f8 100644
--- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni
+++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni
@@ -63,6 +63,11 @@
 #string STR_ADVANCED_XHCIPCI_XHCI     #language en-US "XHCI"
 #string STR_ADVANCED_XHCIPCI_PCIE     #language en-US "PCIe"
 
+#string STR_ADVANCED_XHCIRELOAD_PROMPT  #language en-US "DT Reload XHCI firmware"
+#string STR_ADVANCED_XHCIRELOAD_HELP    #language en-US "OS should reload XHCI firmware on reset"
+#string STR_ADVANCED_XHCIRELOAD_DISABLE #language en-US "Disabled"
+#string STR_ADVANCED_XHCIRELOAD_RELOAD  #language en-US "Reload"
+
 #string STR_ADVANCED_ASSET_TAG_PROMPT #language en-US "Asset Tag"
 #string STR_ADVANCED_ASSET_TAG_HELP   #language en-US "Set the system Asset Tag"
 
diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr
index 830c72eac6..61171cf658 100644
--- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr
+++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr
@@ -61,6 +61,11 @@ formset
       name  = XhciPci,
       guid  = CONFIGDXE_FORM_SET_GUID;
 
+    efivarstore ADVANCED_XHCIPCI_VARSTORE_DATA,
+      attribute = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
+      name  = XhciReload,
+      guid  = CONFIGDXE_FORM_SET_GUID;
+
     efivarstore SYSTEM_TABLE_MODE_VARSTORE_DATA,
       attribute = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
       name  = SystemTableMode,
@@ -229,6 +234,16 @@ formset
               option text = STRING_TOKEN(STR_ADVANCED_XHCIPCI_PCIE), value = 1, flags = 0;
             endoneof;
           endif;
+
+          grayoutif ideqval SystemTableMode.Mode == SYSTEM_TABLE_MODE_ACPI;
+            oneof varid = XhciReload.Value,
+              prompt      = STRING_TOKEN(STR_ADVANCED_XHCIRELOAD_PROMPT),
+              help        = STRING_TOKEN(STR_ADVANCED_XHCIRELOAD_HELP),
+              flags       = NUMERIC_SIZE_4 | INTERACTIVE | RESET_REQUIRED,
+              option text = STRING_TOKEN(STR_ADVANCED_XHCIRELOAD_DISABLE), value = 0, flags = DEFAULT;
+              option text = STRING_TOKEN(STR_ADVANCED_XHCIRELOAD_RELOAD), value = 1, flags = 0;
+            endoneof;
+          endif;
         endif;
 #endif
         string varid = AssetTag.AssetTag,
diff --git a/Platform/RaspberryPi/Drivers/FdtDxe/FdtDxe.c b/Platform/RaspberryPi/Drivers/FdtDxe/FdtDxe.c
index a4816d4295..a808b1bf8c 100644
--- a/Platform/RaspberryPi/Drivers/FdtDxe/FdtDxe.c
+++ b/Platform/RaspberryPi/Drivers/FdtDxe/FdtDxe.c
@@ -352,8 +352,8 @@ SyncPcie (
   }
 
   // non translated 32-bit DMA window with a limit of 0xc0000000
-  DmaRanges[0] = cpu_to_fdt32 (0x02000000); 
-  DmaRanges[1] = cpu_to_fdt32 (0x00000000); 
+  DmaRanges[0] = cpu_to_fdt32 (0x02000000);
+  DmaRanges[1] = cpu_to_fdt32 (0x00000000);
   DmaRanges[2] = cpu_to_fdt32 (0x00000000);
   DmaRanges[3] = cpu_to_fdt32 (0x00000000);
   DmaRanges[4] = cpu_to_fdt32 (0x00000000);
@@ -362,7 +362,7 @@ SyncPcie (
 
   DEBUG ((DEBUG_INFO, "%a: Updating PCIe dma-ranges\n",  __FUNCTION__));
 
-  /* 
+  /*
    * Match dma-ranges with the EDK2+ACPI setup we are using.  This works
    * around a failure in Linux and OpenBSD to reset the PCIe/XHCI correctly
    * when in DT mode.
@@ -375,6 +375,10 @@ SyncPcie (
     return EFI_NOT_FOUND;
   }
 
+  if (PcdGet32 (PcdXhciReload) != 1) {
+    return EFI_SUCCESS;
+  }
+
   /*
    * Now that we are always running without DMA translation, and with a 3G
    * limit, there shouldn't be a need to reset/reload the XHCI. The
diff --git a/Platform/RaspberryPi/Drivers/FdtDxe/FdtDxe.inf b/Platform/RaspberryPi/Drivers/FdtDxe/FdtDxe.inf
index 26f84e5940..d9fb6ee480 100644
--- a/Platform/RaspberryPi/Drivers/FdtDxe/FdtDxe.inf
+++ b/Platform/RaspberryPi/Drivers/FdtDxe/FdtDxe.inf
@@ -47,3 +47,4 @@
 
 [Pcd]
   gRaspberryPiTokenSpaceGuid.PcdSystemTableMode
+  gRaspberryPiTokenSpaceGuid.PcdXhciReload
diff --git a/Platform/RaspberryPi/RPi3/RPi3.dsc b/Platform/RaspberryPi/RPi3/RPi3.dsc
index 6ab5d1ae6d..9b00327002 100644
--- a/Platform/RaspberryPi/RPi3/RPi3.dsc
+++ b/Platform/RaspberryPi/RPi3/RPi3.dsc
@@ -526,6 +526,12 @@
   #
   gRaspberryPiTokenSpaceGuid.PcdXhciPci|L"XhciPci"|gConfigDxeFormSetGuid|0x0|0
 
+  # DT contains XHCI quirk node (not valid on rpi3)
+  #
+  # 0  - DISABLED
+  #
+  gRaspberryPiTokenSpaceGuid.PcdXhciReload|L"XhciReload"|gConfigDxeFormSetGuid|0x0|0
+
   #
   # Common UEFI ones.
   #
diff --git a/Platform/RaspberryPi/RPi4/RPi4.dsc b/Platform/RaspberryPi/RPi4/RPi4.dsc
index 44ed60ab2f..6de4407749 100644
--- a/Platform/RaspberryPi/RPi4/RPi4.dsc
+++ b/Platform/RaspberryPi/RPi4/RPi4.dsc
@@ -544,6 +544,13 @@
   #
   gRaspberryPiTokenSpaceGuid.PcdXhciPci|L"XhciPci"|gConfigDxeFormSetGuid|0x0|0
 
+  # DT contains XHCI quirk node
+  #
+  # 0  - No reload
+  # 1  - Yes, DT has Reload
+  #
+  gRaspberryPiTokenSpaceGuid.PcdXhciReload|L"XhciReload"|gConfigDxeFormSetGuid|0x0|0
+
   #
   # Common UEFI ones.
   #
diff --git a/Platform/RaspberryPi/RaspberryPi.dec b/Platform/RaspberryPi/RaspberryPi.dec
index 797be59274..c50ebdcf77 100644
--- a/Platform/RaspberryPi/RaspberryPi.dec
+++ b/Platform/RaspberryPi/RaspberryPi.dec
@@ -72,3 +72,4 @@
   gRaspberryPiTokenSpaceGuid.PcdMmcEnableDma|0|UINT32|0x0000001F
   gRaspberryPiTokenSpaceGuid.PcdUartInUse|1|UINT32|0x00000021
   gRaspberryPiTokenSpaceGuid.PcdXhciPci|0|UINT32|0x00000022
+  gRaspberryPiTokenSpaceGuid.PcdXhciReload|0|UINT32|0x00000023
-- 
2.13.7


  parent reply	other threads:[~2021-12-02 16:52 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-02 16:51 [PATCH 0/9] Platform/RaspberryPi: Utilize SPI flash for EFI variables Jeremy Linton
2021-12-02 16:51 ` [PATCH 1/9] Platform/RaspberryPi: Cleanup menu visibility Jeremy Linton
2021-12-02 16:51 ` Jeremy Linton [this message]
2021-12-02 16:52 ` [PATCH 3/9] Platform/RaspberryPi: Move GPIO/SPI/I2C to SSDT Jeremy Linton
2021-12-02 16:52 ` [PATCH 4/9] Platform/RaspberryPi: Add menu item to enable/disable GPIO Jeremy Linton
2021-12-02 16:52 ` [PATCH 5/9] Platform/RaspberryPi: Add constants for controlling SPI Jeremy Linton
2021-12-02 16:52 ` [PATCH 6/9] Platform/RaspberryPi: Add mailbox cmd to control audio amp Jeremy Linton
2021-12-02 16:52 ` [PATCH 7/9] Platform/RaspberryPi: Add SPI/GPIO to memory map Jeremy Linton
2021-12-02 16:52 ` [PATCH 8/9] Platform/RaspberryPi: Allow pin function selection at runtime Jeremy Linton
2021-12-02 17:03 ` [edk2-devel] [PATCH 0/9] Platform/RaspberryPi: Utilize SPI flash for EFI variables Ard Biesheuvel
2021-12-02 17:09   ` Ard Biesheuvel
2021-12-02 17:29     ` Jeremy Linton
2021-12-02 17:55     ` Jeremy Linton
2021-12-03 18:12       ` Ard Biesheuvel
2021-12-03 19:31         ` Jeremy Linton
  -- strict thread matches above, loose matches on Subject: below --
2021-12-02 17:53 [PATCH 2/9] Platform/RaspberryPi: Give the user control over the XHCI mailbox Jeremy Linton

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=20211202165206.79615-3-jeremy.linton@arm.com \
    --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