public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH v2 0/4] RPi: SD/Wifi Acpi updates
@ 2021-02-01 22:53 Jeremy Linton
  2021-02-01 22:53 ` [PATCH v2 1/4] Platform/RaspberryPi: Add Negative table check Jeremy Linton
                   ` (4 more replies)
  0 siblings, 5 replies; 15+ messages in thread
From: Jeremy Linton @ 2021-02-01 22:53 UTC (permalink / raw)
  To: devel
  Cc: pete, awarkentin, samer.el-haj-mahmoud, leif, ardb+tianocore,
	Jeremy Linton

The existing RPi3 acpi entries for the Arasan
and sdhci controllers needs updating to work
with the RPi4. This is done by adding a caps
override for the legacy Arasan controller and
then adding an entirely new entry for the newer
eMMC2 controller.

Then we flip the default routing to make the eMMC2
the default for the SD card, so that the wifi can
start working on the Arasan.

Additional we add a menu item to enable the SDMA/ADMA2
modes on the controller.

v1->v2: Add option for user to enable/disable eMMC DMA
        Only enable the emmc2 table on rpi4 & 
            !Arasan routing
        Move emmc2 into its own SSDT and drop 
            second _DMA entry

Jeremy Linton (4):
  Platform/RaspberryPi: Add Negative table check
  Platform/RaspberryPi/Acpitables: Add eMMC2 device and tweak Arasan
  Platform/RaspberryPi: User control of eMMC2 DMA
  Platform/RaspberryPi: Invert default Arasan, Emmc2 routing

 Platform/RaspberryPi/AcpiTables/AcpiTables.inf     |   1 +
 Platform/RaspberryPi/AcpiTables/Emmc.asl           | 130 +++++++++++++++++++++
 Platform/RaspberryPi/AcpiTables/Sdhc.asl           |  18 ++-
 Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c |  26 +++++
 .../RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf    |   1 +
 .../RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni |   5 +
 .../RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr |  17 +++
 Platform/RaspberryPi/Include/ConfigVars.h          |   8 ++
 Platform/RaspberryPi/RPi3/RPi3.dsc                 |   1 +
 Platform/RaspberryPi/RPi4/RPi4.dsc                 |   3 +-
 Platform/RaspberryPi/RPi4/Readme.md                |   2 +-
 Platform/RaspberryPi/RaspberryPi.dec               |   1 +
 12 files changed, 208 insertions(+), 5 deletions(-)
 create mode 100644 Platform/RaspberryPi/AcpiTables/Emmc.asl

-- 
2.13.7


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

* [PATCH v2 1/4] Platform/RaspberryPi: Add Negative table check
  2021-02-01 22:53 [PATCH v2 0/4] RPi: SD/Wifi Acpi updates Jeremy Linton
@ 2021-02-01 22:53 ` Jeremy Linton
  2021-02-08 17:08   ` Pete Batard
  2021-02-01 22:53 ` [PATCH] Platform/RaspberryPi/Acpitables: Add eMMC2 device and tweak Arasan Jeremy Linton
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 15+ messages in thread
From: Jeremy Linton @ 2021-02-01 22:53 UTC (permalink / raw)
  To: devel
  Cc: pete, awarkentin, samer.el-haj-mahmoud, leif, ardb+tianocore,
	Jeremy Linton

Turns out its helpful to have a !PcdToken flag
that enables a DSDT/SSDT. That simplifies
both the emmc2 SSDT (it only installs when
!SdIsArasan) and later for the XHCI/PCIe switch
where we want to install one of two tables
depending on whether a single Pcd is set.

Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
---
 Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c
index 9581bc41e1..ca7533cbee 100644
--- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c
+++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c
@@ -616,6 +616,7 @@ typedef struct {
 typedef struct {
   UINT64                      OemTableId;
   UINTN                       PcdToken;
+  UINTN                       PcdTokenNot;
   CONST AML_NAME_OP_REPLACE   *SdtNameOpReplace;
 } NAMESPACE_TABLES;
 
@@ -713,6 +714,9 @@ VerifyUpdateTable (
   if (SdtTable->PcdToken && !LibPcdGet32 (SdtTable->PcdToken)) {
     Result = FALSE;
   }
+  if (SdtTable->PcdTokenNot && LibPcdGet32 (SdtTable->PcdTokenNot)) {
+    Result = FALSE;
+  }
   if (Result && SdtTable->SdtNameOpReplace) {
     UpdateSdtNameOps (AcpiHeader, SdtTable->SdtNameOpReplace);
   }
@@ -730,11 +734,13 @@ STATIC CONST NAMESPACE_TABLES SdtTables[] = {
   {
     SIGNATURE_64 ('R', 'P', 'I', 'T', 'H', 'F', 'A', 'N'),
     PcdToken(PcdFanOnGpio),
+    0,
     SsdtNameOpReplace
   },
   {
     SIGNATURE_64 ('R', 'P', 'I', 0, 0, 0, 0, 0),
     0,
+    0,
     NULL
   },
   { }
-- 
2.13.7


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

* [PATCH] Platform/RaspberryPi/Acpitables: Add eMMC2 device and tweak Arasan
  2021-02-01 22:53 [PATCH v2 0/4] RPi: SD/Wifi Acpi updates Jeremy Linton
  2021-02-01 22:53 ` [PATCH v2 1/4] Platform/RaspberryPi: Add Negative table check Jeremy Linton
@ 2021-02-01 22:53 ` Jeremy Linton
  2021-02-08 17:08   ` Pete Batard
  2021-02-08 17:25   ` Andrei Warkentin
  2021-02-01 22:53 ` [PATCH v2 3/4] Platform/RaspberryPi: User control of eMMC2 DMA Jeremy Linton
                   ` (2 subsequent siblings)
  4 siblings, 2 replies; 15+ messages in thread
From: Jeremy Linton @ 2021-02-01 22:53 UTC (permalink / raw)
  To: devel
  Cc: pete, awarkentin, samer.el-haj-mahmoud, leif, ardb+tianocore,
	Jeremy Linton

The primarly problem with the rpi Arasan controller working
with a default SDHCI driver is the lack of a meaningful
capabilities register. As such if we add a _DSD entry
to provide that information, we can then bind it to
the linux sdhci_iproc driver which already
hardcodes the remaining controller bugs.

Further we have gotten BRCME88C approved as the HID
for the newer eMMC2 controller. So lets define an
ACPI object to describe it.

Of course both devices are sharing an interrupt so
we should also indicate that in the table as well.

Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
---
 Platform/RaspberryPi/AcpiTables/AcpiTables.inf     |   1 +
 Platform/RaspberryPi/AcpiTables/Emmc.asl           | 131 +++++++++++++++++++++
 Platform/RaspberryPi/AcpiTables/Sdhc.asl           |  18 ++-
 Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c |   6 +
 4 files changed, 153 insertions(+), 3 deletions(-)
 create mode 100644 Platform/RaspberryPi/AcpiTables/Emmc.asl

diff --git a/Platform/RaspberryPi/AcpiTables/AcpiTables.inf b/Platform/RaspberryPi/AcpiTables/AcpiTables.inf
index d2cce074e5..743261afcf 100644
--- a/Platform/RaspberryPi/AcpiTables/AcpiTables.inf
+++ b/Platform/RaspberryPi/AcpiTables/AcpiTables.inf
@@ -35,6 +35,7 @@
   Spcr.aslc
   Pptt.aslc
   SsdtThermal.asl
+  Emmc.asl
 
 [Packages]
   ArmPkg/ArmPkg.dec
diff --git a/Platform/RaspberryPi/AcpiTables/Emmc.asl b/Platform/RaspberryPi/AcpiTables/Emmc.asl
new file mode 100644
index 0000000000..f089068556
--- /dev/null
+++ b/Platform/RaspberryPi/AcpiTables/Emmc.asl
@@ -0,0 +1,131 @@
+/** @file
+ *
+ *  Copyright (c) 2021 Arm. All rights reserved.
+ *
+ *  SPDX-License-Identifier: BSD-2-Clause-Patent
+ *
+ **/
+
+#include <IndustryStandard/Bcm2836SdHost.h>
+#include <IndustryStandard/Bcm2836Sdio.h>
+
+#include "AcpiTables.h"
+
+DefinitionBlock (__FILE__, "SSDT", 5, "RPIFDN", "RPI4EMMC", 2)
+{
+  Scope (\_SB_)
+  {
+#if (RPI_MODEL == 4)
+    Device (GDV1) {
+      Name (_HID, "ACPI0004")
+      Name (_UID, 0x0)
+      Name (_CCA, 0x0)
+
+      Name (RBUF, ResourceTemplate ()
+      {
+          MEMORY32FIXED (ReadWrite, 0, MMCHS2_LENGTH, RMEM)
+      })
+      Method (_CRS, 0x0, Serialized)
+      {
+        MEMORY32SETBASE (RBUF, RMEM, RBAS, MMCHS2_OFFSET)
+        Return (^RBUF)
+      }
+
+      Name (_DMA, ResourceTemplate() {
+        /*
+         * XHC0 is limited to DMA to first 3GB. Note this
+         * only applies to PCIe, not GENET or other devices
+         * next to the A72.
+         */
+        QWordMemory (ResourceConsumer,
+            ,
+            MinFixed,
+            MaxFixed,
+            NonCacheable,
+            ReadWrite,
+            0x0,
+            0x00000000C0000000, // MIN
+            0x00000000FFFFFFFF, // MAX
+            0xFFFFFFFF40000000, // TRA
+            0x0000000040000000, // LEN
+            ,
+            ,
+            )
+      })
+      
+      // emmc2 Host Controller. (brcm,bcm2711-emmc2)
+      Device (SDC3)
+      {
+        Name (_HID, "BRCME88C")
+        Name (_UID, 0x1)
+	Name (_CCA, 0x0)
+	Name (_S1D, 0x1)
+	Name (_S2D, 0x1)
+	Name (_S3D, 0x1)
+	Name (_S4D, 0x1)
+	Name (SDMA, 0x2)
+	Method (_STA)
+	{
+	  Return(0xf)
+	}
+	Name (RBUF, ResourceTemplate ()
+	{
+	  MEMORY32FIXED (ReadWrite, 0, MMCHS2_LENGTH, RMEM)
+	  Interrupt (ResourceConsumer, Level, ActiveHigh, Shared) { BCM2836_MMCHS1_INTERRUPT }
+	})
+	Method (_CRS, 0x0, Serialized)
+	{
+	  MEMORY32SETBASE (RBUF, RMEM, RBAS, MMCHS2_OFFSET)
+	  Return (^RBUF)
+	}
+
+        // Unfortunatly this controller doesn't honor the
+        // standard sdhci voltage control registers
+        // (or at least linux's standard code can't 
+        // lower the voltage) So, UHS mode is disabled with caps
+        Name (DSD1, Package () {
+            ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
+            Package () {
+               Package () { "sdhci-caps-mask", 0x0000000500080000 },
+	    }
+        })
+	// We also disable both SDMA and ADMA2 until the linux
+	// _DMA() mask/translate works properly
+        Name (DSD2, Package () {
+            ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
+            Package () {
+               Package () { "sdhci-caps-mask", 0x0000000504480000 },
+	    }
+        })
+	Method (_DSD, 0x0, Serialized)
+        {
+          if (SDMA == 0) 
+          {
+            return (^DSD2)
+          } 
+          else 
+          {
+            return (^DSD1)
+          }
+        }
+
+        //
+        // A child device that represents the
+        // sd card, which is marked as non-removable.
+        //
+        Device (SDMM)
+        {
+          Method (_ADR)
+          {
+            Return (0)
+          }
+          Method (_RMV) // Is removable
+          {
+            Return (0) // 0 - fixed
+          }
+        }
+      } //SDC3
+    } //GDV1
+#endif
+  } //\SB
+}
diff --git a/Platform/RaspberryPi/AcpiTables/Sdhc.asl b/Platform/RaspberryPi/AcpiTables/Sdhc.asl
index 0ab1ba27f2..0430ab7d2d 100644
--- a/Platform/RaspberryPi/AcpiTables/Sdhc.asl
+++ b/Platform/RaspberryPi/AcpiTables/Sdhc.asl
@@ -19,7 +19,7 @@
 // Note: UEFI can use either SDHost or Arasan. We expose both to the OS.
 //
 
-// ArasanSD 3.0 SD Host Controller.
+// ArasanSD 3.0 SD Host Controller. (brcm,bcm2835-sdhci)
 Device (SDC1)
 {
   Name (_HID, "BCM2847")
@@ -37,7 +37,7 @@ Device (SDC1)
   Name (RBUF, ResourceTemplate ()
   {
     MEMORY32FIXED (ReadWrite, 0, MMCHS1_LENGTH, RMEM)
-    Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { BCM2836_MMCHS1_INTERRUPT }
+    Interrupt (ResourceConsumer, Level, ActiveHigh, Shared) { BCM2836_MMCHS1_INTERRUPT }
   })
   Method (_CRS, 0x0, Serialized)
   {
@@ -45,6 +45,17 @@ Device (SDC1)
     Return (^RBUF)
   }
 
+  // The standard CAPs registers on this controller
+  // appear to be 0, lets set some minimal defaults
+  // Since this cap doesn't indicate DMA capability
+  // we don't need a _DMA()
+  Name (_DSD, Package () {
+    ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
+    Package () {
+      Package () { "sdhci-caps", 0x0100fa81 },
+    }
+  })
+
   //
   // A child device that represents the
   // sd card, which is marked as non-removable.
@@ -62,7 +73,7 @@ Device (SDC1)
   }
 }
 
-
+#if (RPI_MODEL < 4)
 // Broadcom SDHost 2.0 SD Host Controller
 Device (SDC2)
 {
@@ -105,3 +116,4 @@ Device (SDC2)
     }
   }
 }
+#endif // !RPI4
diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c
index ca7533cbee..7f26f7b4be 100644
--- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c
+++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c
@@ -738,6 +738,12 @@ STATIC CONST NAMESPACE_TABLES SdtTables[] = {
     SsdtNameOpReplace
   },
   {
+    SIGNATURE_64 ('R', 'P', 'I', '4', 'E', 'M', 'M', 'C'),
+    0,
+    PcdToken(PcdSdIsArasan),
+    NULL
+  },
+  {
     SIGNATURE_64 ('R', 'P', 'I', 0, 0, 0, 0, 0),
     0,
     0,
-- 
2.13.7


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

* [PATCH v2 3/4] Platform/RaspberryPi: User control of eMMC2 DMA
  2021-02-01 22:53 [PATCH v2 0/4] RPi: SD/Wifi Acpi updates Jeremy Linton
  2021-02-01 22:53 ` [PATCH v2 1/4] Platform/RaspberryPi: Add Negative table check Jeremy Linton
  2021-02-01 22:53 ` [PATCH] Platform/RaspberryPi/Acpitables: Add eMMC2 device and tweak Arasan Jeremy Linton
@ 2021-02-01 22:53 ` Jeremy Linton
  2021-02-08 17:08   ` Pete Batard
  2021-02-01 22:53 ` [PATCH v2 4/4] Platform/RaspberryPi: Invert default Arasan, Emmc2 routing Jeremy Linton
  2021-02-11  8:07 ` [PATCH v2 0/4] RPi: SD/Wifi Acpi updates Ard Biesheuvel
  4 siblings, 1 reply; 15+ messages in thread
From: Jeremy Linton @ 2021-02-01 22:53 UTC (permalink / raw)
  To: devel
  Cc: pete, awarkentin, samer.el-haj-mahmoud, leif, ardb+tianocore,
	Jeremy Linton

DMA translation on the eMMC2 vary based on SOC, and
this is made worse by the poor _DMA support in linux.

For now the "safe" option is to simply run the eMMC2
controller in PIO mode. More advanced users or !linux
operating systems may choose to enable this to gain
a perf boost.

Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
---
 Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c      | 16 +++++++++++++++-
 Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf    |  1 +
 Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni |  5 +++++
 Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr | 17 +++++++++++++++++
 Platform/RaspberryPi/Include/ConfigVars.h               |  8 ++++++++
 Platform/RaspberryPi/RPi3/RPi3.dsc                      |  1 +
 Platform/RaspberryPi/RPi4/RPi4.dsc                      |  1 +
 Platform/RaspberryPi/RaspberryPi.dec                    |  1 +
 8 files changed, 49 insertions(+), 1 deletion(-)

diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c
index 7f26f7b4be..1b8b360ddc 100644
--- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c
+++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c
@@ -346,6 +346,15 @@ SetupVariables (
   }
 
   Size = sizeof (UINT32);
+  Status = gRT->GetVariable (L"MmcEnableDma",
+                  &gConfigDxeFormSetGuid,
+                  NULL, &Size, &Var32);
+  if (EFI_ERROR (Status)) {
+    Status = PcdSet32S (PcdMmcEnableDma, PcdGet32 (PcdMmcEnableDma));
+    ASSERT_EFI_ERROR (Status);
+  }
+
+  Size = sizeof (UINT32);
   Status = gRT->GetVariable (L"DebugEnableJTAG",
                   &gConfigDxeFormSetGuid,
                   NULL, &Size, &Var32);
@@ -730,6 +739,11 @@ STATIC CONST AML_NAME_OP_REPLACE SsdtNameOpReplace[] = {
   { }
 };
 
+STATIC CONST AML_NAME_OP_REPLACE SsdtEmmcNameOpReplace[] = {
+  { "SDMA", PcdToken (PcdMmcEnableDma) },
+  { }
+};
+
 STATIC CONST NAMESPACE_TABLES SdtTables[] = {
   {
     SIGNATURE_64 ('R', 'P', 'I', 'T', 'H', 'F', 'A', 'N'),
@@ -741,7 +755,7 @@ STATIC CONST NAMESPACE_TABLES SdtTables[] = {
     SIGNATURE_64 ('R', 'P', 'I', '4', 'E', 'M', 'M', 'C'),
     0,
     PcdToken(PcdSdIsArasan),
-    NULL
+    SsdtEmmcNameOpReplace
   },
   {
     SIGNATURE_64 ('R', 'P', 'I', 0, 0, 0, 0, 0),
diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf
index 544e3b3e10..d51e54e010 100644
--- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf
+++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf
@@ -84,6 +84,7 @@
   gRaspberryPiTokenSpaceGuid.PcdMmcSdDefaultSpeedMHz
   gRaspberryPiTokenSpaceGuid.PcdMmcSdHighSpeedMHz
   gRaspberryPiTokenSpaceGuid.PcdMmcDisableMulti
+  gRaspberryPiTokenSpaceGuid.PcdMmcEnableDma
   gRaspberryPiTokenSpaceGuid.PcdDebugEnableJTAG
   gRaspberryPiTokenSpaceGuid.PcdDisplayEnableScaledVModes
   gRaspberryPiTokenSpaceGuid.PcdDisplayEnableSShot
diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni
index 2afe8f32ae..6abccc1fdb 100644
--- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni
+++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni
@@ -94,6 +94,11 @@
 #string STR_MMC_SD_HS_PROMPT     #language en-US "SD High Speed (MHz)"
 #string STR_MMC_SD_HS_HELP       #language en-US "Override default 50Mhz"
 
+#string STR_MMC_EMMC_PROMPT      #language en-US "Enable eMMC DMA modes"
+#string STR_MMC_EMMC_PIO         #language en-US "PIO"
+#string STR_MMC_EMMC_DMA         #language en-US "SDMA/ADMA2"
+#string STR_MMC_EMMC_HELP        #language en-US "Enable eMMC DMA modes for OS's that support ACPI _DMA() translations"
+
 
 /*
  * Display settings.
diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr
index de5e43471a..cc7a09cfb7 100644
--- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr
+++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr
@@ -96,6 +96,11 @@ formset
       name  = MmcSdHighSpeedMHz,
       guid  = CONFIGDXE_FORM_SET_GUID;
 
+    efivarstore MMC_EMMC_DMA_VARSTORE_DATA,
+      attribute = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
+      name  = MmcEnableDma,
+      guid  = CONFIGDXE_FORM_SET_GUID;
+
     efivarstore DEBUG_ENABLE_JTAG_VARSTORE_DATA,
       attribute = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
       name  = DebugEnableJTAG,
@@ -275,6 +280,18 @@ formset
              maximum = 100,
              default = 50,
         endnumeric;
+#if (RPI_MODEL == 4)
+        grayoutif ideqval SdIsArasan.Routing == 1;
+        oneof varid = MmcEnableDma.EnableDma,
+            prompt      = STRING_TOKEN(STR_MMC_EMMC_PROMPT),
+            help        = STRING_TOKEN(STR_MMC_EMMC_HELP),
+            flags       = NUMERIC_SIZE_4 | INTERACTIVE | RESET_REQUIRED,
+            option text = STRING_TOKEN(STR_MMC_EMMC_PIO), value = 0, flags = DEFAULT;
+            option text = STRING_TOKEN(STR_MMC_EMMC_DMA), value = 1, flags = 0;
+        endoneof;
+        endif;
+#endif
+
     endform;
 
     form formid = 0x1004,
diff --git a/Platform/RaspberryPi/Include/ConfigVars.h b/Platform/RaspberryPi/Include/ConfigVars.h
index c185bfe28b..142317985a 100644
--- a/Platform/RaspberryPi/Include/ConfigVars.h
+++ b/Platform/RaspberryPi/Include/ConfigVars.h
@@ -135,4 +135,12 @@ typedef struct {
   UINT32 MHz;
 } MMC_SD_HS_MHZ_VARSTORE_DATA;
 
+typedef struct {
+  /*
+   * 0 - eMMC PIO mode
+   * 1 - eMMC DMA mode
+   */
+  UINT32 EnableDma;
+} MMC_EMMC_DMA_VARSTORE_DATA;
+
 #endif /* CONFIG_VARS_H */
diff --git a/Platform/RaspberryPi/RPi3/RPi3.dsc b/Platform/RaspberryPi/RPi3/RPi3.dsc
index 530b42796a..107cbda297 100644
--- a/Platform/RaspberryPi/RPi3/RPi3.dsc
+++ b/Platform/RaspberryPi/RPi3/RPi3.dsc
@@ -470,6 +470,7 @@
   gRaspberryPiTokenSpaceGuid.PcdMmcSdDefaultSpeedMHz|L"MmcSdDefaultSpeedMHz"|gConfigDxeFormSetGuid|0x0|25
   gRaspberryPiTokenSpaceGuid.PcdMmcSdHighSpeedMHz|L"MmcSdHighSpeedMHz"|gConfigDxeFormSetGuid|0x0|50
   gRaspberryPiTokenSpaceGuid.PcdMmcDisableMulti|L"MmcDisableMulti"|gConfigDxeFormSetGuid|0x0|0
+  gRaspberryPiTokenSpaceGuid.PcdMmcEnableDma|L"MmcEnableDma"|gConfigDxeFormSetGuid|0x0|0
 
   #
   # Debug-related.
diff --git a/Platform/RaspberryPi/RPi4/RPi4.dsc b/Platform/RaspberryPi/RPi4/RPi4.dsc
index 5f8452aa0b..9962df0076 100644
--- a/Platform/RaspberryPi/RPi4/RPi4.dsc
+++ b/Platform/RaspberryPi/RPi4/RPi4.dsc
@@ -481,6 +481,7 @@
   gRaspberryPiTokenSpaceGuid.PcdMmcSdDefaultSpeedMHz|L"MmcSdDefaultSpeedMHz"|gConfigDxeFormSetGuid|0x0|25
   gRaspberryPiTokenSpaceGuid.PcdMmcSdHighSpeedMHz|L"MmcSdHighSpeedMHz"|gConfigDxeFormSetGuid|0x0|50
   gRaspberryPiTokenSpaceGuid.PcdMmcDisableMulti|L"MmcDisableMulti"|gConfigDxeFormSetGuid|0x0|0
+  gRaspberryPiTokenSpaceGuid.PcdMmcEnableDma|L"MmcEnableDma"|gConfigDxeFormSetGuid|0x0|0
 
   #
   # Debug-related.
diff --git a/Platform/RaspberryPi/RaspberryPi.dec b/Platform/RaspberryPi/RaspberryPi.dec
index 10723036aa..08135717ed 100644
--- a/Platform/RaspberryPi/RaspberryPi.dec
+++ b/Platform/RaspberryPi/RaspberryPi.dec
@@ -69,3 +69,4 @@
   gRaspberryPiTokenSpaceGuid.PcdFanOnGpio|0|UINT32|0x0000001C
   gRaspberryPiTokenSpaceGuid.PcdFanTemp|0|UINT32|0x0000001D
   gRaspberryPiTokenSpaceGuid.PcdPlatformResetDelay|0|UINT32|0x0000001E
+  gRaspberryPiTokenSpaceGuid.PcdMmcEnableDma|0|UINT32|0x0000001F
-- 
2.13.7


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

* [PATCH v2 4/4] Platform/RaspberryPi: Invert default Arasan, Emmc2 routing
  2021-02-01 22:53 [PATCH v2 0/4] RPi: SD/Wifi Acpi updates Jeremy Linton
                   ` (2 preceding siblings ...)
  2021-02-01 22:53 ` [PATCH v2 3/4] Platform/RaspberryPi: User control of eMMC2 DMA Jeremy Linton
@ 2021-02-01 22:53 ` Jeremy Linton
  2021-02-08 17:09   ` Pete Batard
  2021-02-08 17:26   ` Andrei Warkentin
  2021-02-11  8:07 ` [PATCH v2 0/4] RPi: SD/Wifi Acpi updates Ard Biesheuvel
  4 siblings, 2 replies; 15+ messages in thread
From: Jeremy Linton @ 2021-02-01 22:53 UTC (permalink / raw)
  To: devel
  Cc: pete, awarkentin, samer.el-haj-mahmoud, leif, ardb+tianocore,
	Jeremy Linton

In order for the wifi to work, and the SD to run at full
speed we need to bind the sd slot to the eMMC2 controller.

Since we now have a driver for the eMMC2 controller
there isn't any reason to leave the SD card bound
to the older Arasan controller.

Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
---
 Platform/RaspberryPi/RPi4/RPi4.dsc  | 2 +-
 Platform/RaspberryPi/RPi4/Readme.md | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/Platform/RaspberryPi/RPi4/RPi4.dsc b/Platform/RaspberryPi/RPi4/RPi4.dsc
index 9962df0076..e0fad6f744 100644
--- a/Platform/RaspberryPi/RPi4/RPi4.dsc
+++ b/Platform/RaspberryPi/RPi4/RPi4.dsc
@@ -475,7 +475,7 @@
   # SD-related.
   #
 
-  gRaspberryPiTokenSpaceGuid.PcdSdIsArasan|L"SdIsArasan"|gConfigDxeFormSetGuid|0x0|1
+  gRaspberryPiTokenSpaceGuid.PcdSdIsArasan|L"SdIsArasan"|gConfigDxeFormSetGuid|0x0|0
   gRaspberryPiTokenSpaceGuid.PcdMmcForce1Bit|L"MmcForce1Bit"|gConfigDxeFormSetGuid|0x0|0
   gRaspberryPiTokenSpaceGuid.PcdMmcForceDefaultSpeed|L"MmcForceDefaultSpeed"|gConfigDxeFormSetGuid|0x0|0
   gRaspberryPiTokenSpaceGuid.PcdMmcSdDefaultSpeedMHz|L"MmcSdDefaultSpeedMHz"|gConfigDxeFormSetGuid|0x0|25
diff --git a/Platform/RaspberryPi/RPi4/Readme.md b/Platform/RaspberryPi/RPi4/Readme.md
index 3b2ed44e3c..80899f4ca4 100644
--- a/Platform/RaspberryPi/RPi4/Readme.md
+++ b/Platform/RaspberryPi/RPi4/Readme.md
@@ -181,7 +181,7 @@ Limit RAM to 3 GB            | `RamLimitTo3GB` | Disable = `0x00000000` <br> Ena
 System Table Selection       | `SystemTableMode`| ACPI = `0x00000000` (default)<br> ACPI + Devicetree = `0x00000001` <br> Devicetree = `0x00000002`
 Asset Tag                    | `AssetTag` | String, 32 characters or less (e.g. `L"ABCD123"`)<br> (default `L""`)
 **SD/MMC Configuration**     |
-uSD/eMMC Routing             | `SdIsArasan` | Arasan SDHC = `0x00000001` (default) <br> eMMC2 SDHCI = `0x00000000`
+uSD/eMMC Routing             | `SdIsArasan` | Arasan SDHC = `0x00000001` <br> eMMC2 SDHCI = `0x00000000` (default)
 Multi-Block Support          | `MmcDisableMulti` | Multi-block transfers = `0x00000000` (default)<br> Single block transfers = `0x00000001`
 uSD Max Bus Width            | `MmcForce1Bit` | 4-bit Mode = `0x00000000`  (default)<br> 1-bit Mode = `0x00000001`
 uSD Force Default Speed      | `MmcForceDefaultSpeed` | Allow High Speed = `0x00000000` (default)<br> Force Default Speed = `0x00000001`
-- 
2.13.7


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

* Re: [PATCH v2 1/4] Platform/RaspberryPi: Add Negative table check
  2021-02-01 22:53 ` [PATCH v2 1/4] Platform/RaspberryPi: Add Negative table check Jeremy Linton
@ 2021-02-08 17:08   ` Pete Batard
  2021-02-08 17:24     ` Andrei Warkentin
  0 siblings, 1 reply; 15+ messages in thread
From: Pete Batard @ 2021-02-08 17:08 UTC (permalink / raw)
  To: Jeremy Linton, devel
  Cc: awarkentin, samer.el-haj-mahmoud, leif, ardb+tianocore

Looks good to me.

On 2021.02.01 22:53, Jeremy Linton wrote:
> Turns out its helpful to have a !PcdToken flag
> that enables a DSDT/SSDT. That simplifies
> both the emmc2 SSDT (it only installs when
> !SdIsArasan) and later for the XHCI/PCIe switch
> where we want to install one of two tables
> depending on whether a single Pcd is set.
> 
> Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
> ---
>   Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c | 6 ++++++
>   1 file changed, 6 insertions(+)
> 
> diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c
> index 9581bc41e1..ca7533cbee 100644
> --- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c
> +++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c
> @@ -616,6 +616,7 @@ typedef struct {
>   typedef struct {
> 
>     UINT64                      OemTableId;
> 
>     UINTN                       PcdToken;
> 
> +  UINTN                       PcdTokenNot;
> 
>     CONST AML_NAME_OP_REPLACE   *SdtNameOpReplace;
> 
>   } NAMESPACE_TABLES;
> 
>   
> 
> @@ -713,6 +714,9 @@ VerifyUpdateTable (
>     if (SdtTable->PcdToken && !LibPcdGet32 (SdtTable->PcdToken)) {
> 
>       Result = FALSE;
> 
>     }
> 
> +  if (SdtTable->PcdTokenNot && LibPcdGet32 (SdtTable->PcdTokenNot)) {
> 
> +    Result = FALSE;
> 
> +  }
> 
>     if (Result && SdtTable->SdtNameOpReplace) {
> 
>       UpdateSdtNameOps (AcpiHeader, SdtTable->SdtNameOpReplace);
> 
>     }
> 
> @@ -730,11 +734,13 @@ STATIC CONST NAMESPACE_TABLES SdtTables[] = {
>     {
> 
>       SIGNATURE_64 ('R', 'P', 'I', 'T', 'H', 'F', 'A', 'N'),
> 
>       PcdToken(PcdFanOnGpio),
> 
> +    0,
> 
>       SsdtNameOpReplace
> 
>     },
> 
>     {
> 
>       SIGNATURE_64 ('R', 'P', 'I', 0, 0, 0, 0, 0),
> 
>       0,
> 
> +    0,
> 
>       NULL
> 
>     },
> 
>     { }
> 

Reviewed-by: Pete Batard <pete@akeo.ie>

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

* Re: [PATCH] Platform/RaspberryPi/Acpitables: Add eMMC2 device and tweak Arasan
  2021-02-01 22:53 ` [PATCH] Platform/RaspberryPi/Acpitables: Add eMMC2 device and tweak Arasan Jeremy Linton
@ 2021-02-08 17:08   ` Pete Batard
  2021-02-08 17:25   ` Andrei Warkentin
  1 sibling, 0 replies; 15+ messages in thread
From: Pete Batard @ 2021-02-08 17:08 UTC (permalink / raw)
  To: Jeremy Linton, devel
  Cc: awarkentin, samer.el-haj-mahmoud, leif, ardb+tianocore

On 2021.02.01 22:53, Jeremy Linton wrote:
> The primarly problem with the rpi Arasan controller working

Small typo: primarly -> primary

> with a default SDHCI driver is the lack of a meaningful
> capabilities register. As such if we add a _DSD entry
> to provide that information, we can then bind it to
> the linux sdhci_iproc driver which already
> hardcodes the remaining controller bugs.
> 
> Further we have gotten BRCME88C approved as the HID
> for the newer eMMC2 controller. So lets define an
> ACPI object to describe it.
> 
> Of course both devices are sharing an interrupt so
> we should also indicate that in the table as well.
> 
> Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
> ---
>   Platform/RaspberryPi/AcpiTables/AcpiTables.inf     |   1 +
>   Platform/RaspberryPi/AcpiTables/Emmc.asl           | 131 +++++++++++++++++++++
>   Platform/RaspberryPi/AcpiTables/Sdhc.asl           |  18 ++-
>   Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c |   6 +
>   4 files changed, 153 insertions(+), 3 deletions(-)
>   create mode 100644 Platform/RaspberryPi/AcpiTables/Emmc.asl
> 
> diff --git a/Platform/RaspberryPi/AcpiTables/AcpiTables.inf b/Platform/RaspberryPi/AcpiTables/AcpiTables.inf
> index d2cce074e5..743261afcf 100644
> --- a/Platform/RaspberryPi/AcpiTables/AcpiTables.inf
> +++ b/Platform/RaspberryPi/AcpiTables/AcpiTables.inf
> @@ -35,6 +35,7 @@
>     Spcr.aslc
> 
>     Pptt.aslc
> 
>     SsdtThermal.asl
> 
> +  Emmc.asl
> 
>   
> 
>   [Packages]
> 
>     ArmPkg/ArmPkg.dec
> 
> diff --git a/Platform/RaspberryPi/AcpiTables/Emmc.asl b/Platform/RaspberryPi/AcpiTables/Emmc.asl
> new file mode 100644
> index 0000000000..f089068556
> --- /dev/null
> +++ b/Platform/RaspberryPi/AcpiTables/Emmc.asl
> @@ -0,0 +1,131 @@
> +/** @file
> + *
> + *  Copyright (c) 2021 Arm. All rights reserved.
> + *
> + *  SPDX-License-Identifier: BSD-2-Clause-Patent
> + *
> + **/
> +
> +#include <IndustryStandard/Bcm2836SdHost.h>
> +#include <IndustryStandard/Bcm2836Sdio.h>
> +
> +#include "AcpiTables.h"
> +
> +DefinitionBlock (__FILE__, "SSDT", 5, "RPIFDN", "RPI4EMMC", 2)
> +{
> +  Scope (\_SB_)
> +  {
> +#if (RPI_MODEL == 4)
> +    Device (GDV1) {
> +      Name (_HID, "ACPI0004")
> +      Name (_UID, 0x0)
> +      Name (_CCA, 0x0)
> +
> +      Name (RBUF, ResourceTemplate ()
> +      {
> +          MEMORY32FIXED (ReadWrite, 0, MMCHS2_LENGTH, RMEM)
> +      })
> +      Method (_CRS, 0x0, Serialized)
> +      {
> +        MEMORY32SETBASE (RBUF, RMEM, RBAS, MMCHS2_OFFSET)
> +        Return (^RBUF)
> +      }
> +
> +      Name (_DMA, ResourceTemplate() {
> +        /*
> +         * XHC0 is limited to DMA to first 3GB. Note this
> +         * only applies to PCIe, not GENET or other devices
> +         * next to the A72.
> +         */

I don't think this comment, that appears to have been lifted from a 
copy/paste of 
https://github.com/tianocore/edk2-platforms/blob/master/Platform/RaspberryPi/AcpiTables/Xhci.asl#L62-L82, 
applies here, since you are no longer describing a [0x00000000, 
0xbfffffff] range here (or dealing with the XHC0 ACPI device) but 
applying a translation.

I would either remove the comment or make it explain why the translation 
is needed.

> +        QWordMemory (ResourceConsumer,
> +            ,
> +            MinFixed,
> +            MaxFixed,
> +            NonCacheable,
> +            ReadWrite,
> +            0x0,
> +            0x00000000C0000000, // MIN
> +            0x00000000FFFFFFFF, // MAX
> +            0xFFFFFFFF40000000, // TRA
> +            0x0000000040000000, // LEN
> +            ,
> +            ,
> +            )
> +      })
> +
> +      // emmc2 Host Controller. (brcm,bcm2711-emmc2)
> +      Device (SDC3)
> +      {
> +        Name (_HID, "BRCME88C")
> +        Name (_UID, 0x1)

vvvvvvvvvvvv

> +	Name (_CCA, 0x0)
> +	Name (_S1D, 0x1)
> +	Name (_S2D, 0x1)
> +	Name (_S3D, 0x1)
> +	Name (_S4D, 0x1)
> +	Name (SDMA, 0x2)
> +	Method (_STA)
> +	{
> +	  Return(0xf)
> +	}
> +	Name (RBUF, ResourceTemplate ()
> +	{
> +	  MEMORY32FIXED (ReadWrite, 0, MMCHS2_LENGTH, RMEM)
> +	  Interrupt (ResourceConsumer, Level, ActiveHigh, Shared) { BCM2836_MMCHS1_INTERRUPT }
> +	})
> +	Method (_CRS, 0x0, Serialized)
> +	{
> +	  MEMORY32SETBASE (RBUF, RMEM, RBAS, MMCHS2_OFFSET)
> +	  Return (^RBUF)
> +	}

^^^^^^^^^^^^^
Section above uses tabs instead of spaces.
I believe edk2/BaseTools/Scripts/PatchCheck.py, when run, should warn 
you about this.

> +
> +        // Unfortunatly this controller doesn't honor the

Small typo: Unfortunatly -> Unfortunately

> +        // standard sdhci voltage control registers
> +        // (or at least linux's standard code can't
> +        // lower the voltage) So, UHS mode is disabled with caps
> +        Name (DSD1, Package () {
> +            ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
> +            Package () {
> +               Package () { "sdhci-caps-mask", 0x0000000500080000 },
> +	    }
> +        })

vvvvvvvvvvvv

> +	// We also disable both SDMA and ADMA2 until the linux
> +	// _DMA() mask/translate works properly

^^^^^^^^^^^^^
Another tabbed section

Also, the "also" above seems to imply that DSD1 applies on top of DSD2, 
whereas, per the code further down, we only apply one of DSD1 or DSD2 
according to SDMA. Maybe, for clarity, this should be mentioned more 
explicitly in the comments above?

> +        Name (DSD2, Package () {
> +            ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
> +            Package () {
> +               Package () { "sdhci-caps-mask", 0x0000000504480000 },
> +	    }

^^^^^^^^^^^^^
Another tabbed line

> +        })
> +	Method (_DSD, 0x0, Serialized)

^^^^^^^^^^^^^
Another tabbed line

> +        {
> +          if (SDMA == 0)
> +          {
> +            return (^DSD2)
> +          }
> +          else
> +          {
> +            return (^DSD1)
> +          }
> +        }
> +
> +        //
> +        // A child device that represents the
> +        // sd card, which is marked as non-removable.
> +        //
> +        Device (SDMM)
> +        {
> +          Method (_ADR)
> +          {
> +            Return (0)
> +          }
> +          Method (_RMV) // Is removable
> +          {
> +            Return (0) // 0 - fixed
> +          }
> +        }
> +      } //SDC3
> +    } //GDV1
> +#endif
> +  } //\SB
> +}
> diff --git a/Platform/RaspberryPi/AcpiTables/Sdhc.asl b/Platform/RaspberryPi/AcpiTables/Sdhc.asl
> index 0ab1ba27f2..0430ab7d2d 100644
> --- a/Platform/RaspberryPi/AcpiTables/Sdhc.asl
> +++ b/Platform/RaspberryPi/AcpiTables/Sdhc.asl
> @@ -19,7 +19,7 @@
>   // Note: UEFI can use either SDHost or Arasan. We expose both to the OS.
> 
>   //
> 
>   
> 
> -// ArasanSD 3.0 SD Host Controller.
> 
> +// ArasanSD 3.0 SD Host Controller. (brcm,bcm2835-sdhci)
> 
>   Device (SDC1)
> 
>   {
> 
>     Name (_HID, "BCM2847")
> 
> @@ -37,7 +37,7 @@ Device (SDC1)
>     Name (RBUF, ResourceTemplate ()
> 
>     {
> 
>       MEMORY32FIXED (ReadWrite, 0, MMCHS1_LENGTH, RMEM)
> 
> -    Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { BCM2836_MMCHS1_INTERRUPT }
> 
> +    Interrupt (ResourceConsumer, Level, ActiveHigh, Shared) { BCM2836_MMCHS1_INTERRUPT }
> 
>     })
> 
>     Method (_CRS, 0x0, Serialized)
> 
>     {
> 
> @@ -45,6 +45,17 @@ Device (SDC1)
>       Return (^RBUF)
> 
>     }
> 
>   
> 
> +  // The standard CAPs registers on this controller
> 
> +  // appear to be 0, lets set some minimal defaults
> 
> +  // Since this cap doesn't indicate DMA capability
> 
> +  // we don't need a _DMA()
> 
> +  Name (_DSD, Package () {
> 
> +    ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
> 
> +    Package () {
> 
> +      Package () { "sdhci-caps", 0x0100fa81 },
> 
> +    }
> 
> +  })
> 
> +
> 
>     //
> 
>     // A child device that represents the
> 
>     // sd card, which is marked as non-removable.
> 
> @@ -62,7 +73,7 @@ Device (SDC1)
>     }
> 
>   }
> 
>   
> 
> -
> 
> +#if (RPI_MODEL < 4)
> 
>   // Broadcom SDHost 2.0 SD Host Controller
> 
>   Device (SDC2)
> 
>   {
> 
> @@ -105,3 +116,4 @@ Device (SDC2)
>       }
> 
>     }
> 
>   }
> 
> +#endif // !RPI4
> 
> diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c
> index ca7533cbee..7f26f7b4be 100644
> --- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c
> +++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c
> @@ -738,6 +738,12 @@ STATIC CONST NAMESPACE_TABLES SdtTables[] = {
>       SsdtNameOpReplace
> 
>     },
> 
>     {
> 
> +    SIGNATURE_64 ('R', 'P', 'I', '4', 'E', 'M', 'M', 'C'),
> 
> +    0,
> 
> +    PcdToken(PcdSdIsArasan),
> 
> +    NULL
> 
> +  },
> 
> +  {
> 
>       SIGNATURE_64 ('R', 'P', 'I', 0, 0, 0, 0, 0),
> 
>       0,
> 
>       0,
> 

With all of the above being formatting/comment/typos issues:
Reviewed-by: Pete Batard <pete@akeo.ie>


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

* Re: [PATCH v2 3/4] Platform/RaspberryPi: User control of eMMC2 DMA
  2021-02-01 22:53 ` [PATCH v2 3/4] Platform/RaspberryPi: User control of eMMC2 DMA Jeremy Linton
@ 2021-02-08 17:08   ` Pete Batard
  2021-02-08 17:26     ` Andrei Warkentin
  0 siblings, 1 reply; 15+ messages in thread
From: Pete Batard @ 2021-02-08 17:08 UTC (permalink / raw)
  To: Jeremy Linton, devel
  Cc: awarkentin, samer.el-haj-mahmoud, leif, ardb+tianocore

On 2021.02.01 22:53, Jeremy Linton wrote:
> DMA translation on the eMMC2 vary based on SOC, and
> this is made worse by the poor _DMA support in linux.
> 
> For now the "safe" option is to simply run the eMMC2
> controller in PIO mode. More advanced users or !linux
> operating systems may choose to enable this to gain
> a perf boost.
> 
> Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
> ---
>   Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c      | 16 +++++++++++++++-
>   Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf    |  1 +
>   Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni |  5 +++++
>   Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr | 17 +++++++++++++++++
>   Platform/RaspberryPi/Include/ConfigVars.h               |  8 ++++++++
>   Platform/RaspberryPi/RPi3/RPi3.dsc                      |  1 +
>   Platform/RaspberryPi/RPi4/RPi4.dsc                      |  1 +
>   Platform/RaspberryPi/RaspberryPi.dec                    |  1 +
>   8 files changed, 49 insertions(+), 1 deletion(-)
> 
> diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c
> index 7f26f7b4be..1b8b360ddc 100644
> --- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c
> +++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c
> @@ -346,6 +346,15 @@ SetupVariables (
>     }
> 
>   
> 
>     Size = sizeof (UINT32);
> 
> +  Status = gRT->GetVariable (L"MmcEnableDma",
> 
> +                  &gConfigDxeFormSetGuid,
> 
> +                  NULL, &Size, &Var32);
> 
> +  if (EFI_ERROR (Status)) {
> 
> +    Status = PcdSet32S (PcdMmcEnableDma, PcdGet32 (PcdMmcEnableDma));
> 
> +    ASSERT_EFI_ERROR (Status);
> 
> +  }
> 
> +
> 
> +  Size = sizeof (UINT32);
> 
>     Status = gRT->GetVariable (L"DebugEnableJTAG",
> 
>                     &gConfigDxeFormSetGuid,
> 
>                     NULL, &Size, &Var32);
> 
> @@ -730,6 +739,11 @@ STATIC CONST AML_NAME_OP_REPLACE SsdtNameOpReplace[] = {
>     { }
> 
>   };
> 
>   
> 
> +STATIC CONST AML_NAME_OP_REPLACE SsdtEmmcNameOpReplace[] = {
> 
> +  { "SDMA", PcdToken (PcdMmcEnableDma) },
> 
> +  { }
> 
> +};
> 
> +
> 
>   STATIC CONST NAMESPACE_TABLES SdtTables[] = {
> 
>     {
> 
>       SIGNATURE_64 ('R', 'P', 'I', 'T', 'H', 'F', 'A', 'N'),
> 
> @@ -741,7 +755,7 @@ STATIC CONST NAMESPACE_TABLES SdtTables[] = {
>       SIGNATURE_64 ('R', 'P', 'I', '4', 'E', 'M', 'M', 'C'),
> 
>       0,
> 
>       PcdToken(PcdSdIsArasan),
> 
> -    NULL
> 
> +    SsdtEmmcNameOpReplace
> 
>     },
> 
>     {
> 
>       SIGNATURE_64 ('R', 'P', 'I', 0, 0, 0, 0, 0),
> 
> diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf
> index 544e3b3e10..d51e54e010 100644
> --- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf
> +++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf
> @@ -84,6 +84,7 @@
>     gRaspberryPiTokenSpaceGuid.PcdMmcSdDefaultSpeedMHz
> 
>     gRaspberryPiTokenSpaceGuid.PcdMmcSdHighSpeedMHz
> 
>     gRaspberryPiTokenSpaceGuid.PcdMmcDisableMulti
> 
> +  gRaspberryPiTokenSpaceGuid.PcdMmcEnableDma
> 
>     gRaspberryPiTokenSpaceGuid.PcdDebugEnableJTAG
> 
>     gRaspberryPiTokenSpaceGuid.PcdDisplayEnableScaledVModes
> 
>     gRaspberryPiTokenSpaceGuid.PcdDisplayEnableSShot
> 
> diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni
> index 2afe8f32ae..6abccc1fdb 100644
> --- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni
> +++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni
> @@ -94,6 +94,11 @@
>   #string STR_MMC_SD_HS_PROMPT     #language en-US "SD High Speed (MHz)"
> 
>   #string STR_MMC_SD_HS_HELP       #language en-US "Override default 50Mhz"
> 
>   
> 
> +#string STR_MMC_EMMC_PROMPT      #language en-US "Enable eMMC DMA modes"
> 
> +#string STR_MMC_EMMC_PIO         #language en-US "PIO"
> 
> +#string STR_MMC_EMMC_DMA         #language en-US "SDMA/ADMA2"
> 
> +#string STR_MMC_EMMC_HELP        #language en-US "Enable eMMC DMA modes for OS's that support ACPI _DMA() translations"

For consistency, since that's what we already use for other UI strings, 
the plural of OS should be "OSes" rather than "OS's"

> 
> +

(very minor) Extra line added here.

> 
>   
> 
>   /*
> 
>    * Display settings.
> 
> diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr
> index de5e43471a..cc7a09cfb7 100644
> --- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr
> +++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr
> @@ -96,6 +96,11 @@ formset
>         name  = MmcSdHighSpeedMHz,
> 
>         guid  = CONFIGDXE_FORM_SET_GUID;
> 
>   
> 
> +    efivarstore MMC_EMMC_DMA_VARSTORE_DATA,
> 
> +      attribute = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
> 
> +      name  = MmcEnableDma,
> 
> +      guid  = CONFIGDXE_FORM_SET_GUID;
> 
> +
> 
>       efivarstore DEBUG_ENABLE_JTAG_VARSTORE_DATA,
> 
>         attribute = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
> 
>         name  = DebugEnableJTAG,
> 
> @@ -275,6 +280,18 @@ formset
>                maximum = 100,
> 
>                default = 50,
> 
>           endnumeric;
> 
> +#if (RPI_MODEL == 4)
> 
> +        grayoutif ideqval SdIsArasan.Routing == 1;
> 
> +        oneof varid = MmcEnableDma.EnableDma,
> 
> +            prompt      = STRING_TOKEN(STR_MMC_EMMC_PROMPT),
> 
> +            help        = STRING_TOKEN(STR_MMC_EMMC_HELP),
> 
> +            flags       = NUMERIC_SIZE_4 | INTERACTIVE | RESET_REQUIRED,
> 
> +            option text = STRING_TOKEN(STR_MMC_EMMC_PIO), value = 0, flags = DEFAULT;
> 
> +            option text = STRING_TOKEN(STR_MMC_EMMC_DMA), value = 1, flags = 0;
> 
> +        endoneof;
> 
> +        endif;
> 
> +#endif
> 
> +
> 
>       endform;
> 
>   
> 
>       form formid = 0x1004,
> 
> diff --git a/Platform/RaspberryPi/Include/ConfigVars.h b/Platform/RaspberryPi/Include/ConfigVars.h
> index c185bfe28b..142317985a 100644
> --- a/Platform/RaspberryPi/Include/ConfigVars.h
> +++ b/Platform/RaspberryPi/Include/ConfigVars.h
> @@ -135,4 +135,12 @@ typedef struct {
>     UINT32 MHz;
> 
>   } MMC_SD_HS_MHZ_VARSTORE_DATA;
> 
>   
> 
> +typedef struct {
> 
> +  /*
> 
> +   * 0 - eMMC PIO mode
> 
> +   * 1 - eMMC DMA mode
> 
> +   */
> 
> +  UINT32 EnableDma;
> 
> +} MMC_EMMC_DMA_VARSTORE_DATA;
> 
> +
> 
>   #endif /* CONFIG_VARS_H */
> 
> diff --git a/Platform/RaspberryPi/RPi3/RPi3.dsc b/Platform/RaspberryPi/RPi3/RPi3.dsc
> index 530b42796a..107cbda297 100644
> --- a/Platform/RaspberryPi/RPi3/RPi3.dsc
> +++ b/Platform/RaspberryPi/RPi3/RPi3.dsc
> @@ -470,6 +470,7 @@
>     gRaspberryPiTokenSpaceGuid.PcdMmcSdDefaultSpeedMHz|L"MmcSdDefaultSpeedMHz"|gConfigDxeFormSetGuid|0x0|25
> 
>     gRaspberryPiTokenSpaceGuid.PcdMmcSdHighSpeedMHz|L"MmcSdHighSpeedMHz"|gConfigDxeFormSetGuid|0x0|50
> 
>     gRaspberryPiTokenSpaceGuid.PcdMmcDisableMulti|L"MmcDisableMulti"|gConfigDxeFormSetGuid|0x0|0
> 
> +  gRaspberryPiTokenSpaceGuid.PcdMmcEnableDma|L"MmcEnableDma"|gConfigDxeFormSetGuid|0x0|0
> 
>   
> 
>     #
> 
>     # Debug-related.
> 
> diff --git a/Platform/RaspberryPi/RPi4/RPi4.dsc b/Platform/RaspberryPi/RPi4/RPi4.dsc
> index 5f8452aa0b..9962df0076 100644
> --- a/Platform/RaspberryPi/RPi4/RPi4.dsc
> +++ b/Platform/RaspberryPi/RPi4/RPi4.dsc
> @@ -481,6 +481,7 @@
>     gRaspberryPiTokenSpaceGuid.PcdMmcSdDefaultSpeedMHz|L"MmcSdDefaultSpeedMHz"|gConfigDxeFormSetGuid|0x0|25
> 
>     gRaspberryPiTokenSpaceGuid.PcdMmcSdHighSpeedMHz|L"MmcSdHighSpeedMHz"|gConfigDxeFormSetGuid|0x0|50
> 
>     gRaspberryPiTokenSpaceGuid.PcdMmcDisableMulti|L"MmcDisableMulti"|gConfigDxeFormSetGuid|0x0|0
> 
> +  gRaspberryPiTokenSpaceGuid.PcdMmcEnableDma|L"MmcEnableDma"|gConfigDxeFormSetGuid|0x0|0
> 
>   
> 
>     #
> 
>     # Debug-related.
> 
> diff --git a/Platform/RaspberryPi/RaspberryPi.dec b/Platform/RaspberryPi/RaspberryPi.dec
> index 10723036aa..08135717ed 100644
> --- a/Platform/RaspberryPi/RaspberryPi.dec
> +++ b/Platform/RaspberryPi/RaspberryPi.dec
> @@ -69,3 +69,4 @@
>     gRaspberryPiTokenSpaceGuid.PcdFanOnGpio|0|UINT32|0x0000001C
> 
>     gRaspberryPiTokenSpaceGuid.PcdFanTemp|0|UINT32|0x0000001D
> 
>     gRaspberryPiTokenSpaceGuid.PcdPlatformResetDelay|0|UINT32|0x0000001E
> 
> +  gRaspberryPiTokenSpaceGuid.PcdMmcEnableDma|0|UINT32|0x0000001F
> 

Reviewed-by: Pete Batard <pete@akeo.ie>

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

* Re: [PATCH v2 4/4] Platform/RaspberryPi: Invert default Arasan, Emmc2 routing
  2021-02-01 22:53 ` [PATCH v2 4/4] Platform/RaspberryPi: Invert default Arasan, Emmc2 routing Jeremy Linton
@ 2021-02-08 17:09   ` Pete Batard
  2021-02-08 17:26   ` Andrei Warkentin
  1 sibling, 0 replies; 15+ messages in thread
From: Pete Batard @ 2021-02-08 17:09 UTC (permalink / raw)
  To: Jeremy Linton, devel
  Cc: awarkentin, samer.el-haj-mahmoud, leif, ardb+tianocore

On 2021.02.01 22:53, Jeremy Linton wrote:
> In order for the wifi to work, and the SD to run at full
> speed we need to bind the sd slot to the eMMC2 controller.

For consistency, you might want to capitalize SD here, since it's 
capitalized before and after.

> Since we now have a driver for the eMMC2 controller
> there isn't any reason to leave the SD card bound
> to the older Arasan controller.
> 
> Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
> ---
>   Platform/RaspberryPi/RPi4/RPi4.dsc  | 2 +-
>   Platform/RaspberryPi/RPi4/Readme.md | 2 +-
>   2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/Platform/RaspberryPi/RPi4/RPi4.dsc b/Platform/RaspberryPi/RPi4/RPi4.dsc
> index 9962df0076..e0fad6f744 100644
> --- a/Platform/RaspberryPi/RPi4/RPi4.dsc
> +++ b/Platform/RaspberryPi/RPi4/RPi4.dsc
> @@ -475,7 +475,7 @@
>     # SD-related.
> 
>     #
> 
>   
> 
> -  gRaspberryPiTokenSpaceGuid.PcdSdIsArasan|L"SdIsArasan"|gConfigDxeFormSetGuid|0x0|1
> 
> +  gRaspberryPiTokenSpaceGuid.PcdSdIsArasan|L"SdIsArasan"|gConfigDxeFormSetGuid|0x0|0
> 
>     gRaspberryPiTokenSpaceGuid.PcdMmcForce1Bit|L"MmcForce1Bit"|gConfigDxeFormSetGuid|0x0|0
> 
>     gRaspberryPiTokenSpaceGuid.PcdMmcForceDefaultSpeed|L"MmcForceDefaultSpeed"|gConfigDxeFormSetGuid|0x0|0
> 
>     gRaspberryPiTokenSpaceGuid.PcdMmcSdDefaultSpeedMHz|L"MmcSdDefaultSpeedMHz"|gConfigDxeFormSetGuid|0x0|25
> 
> diff --git a/Platform/RaspberryPi/RPi4/Readme.md b/Platform/RaspberryPi/RPi4/Readme.md
> index 3b2ed44e3c..80899f4ca4 100644
> --- a/Platform/RaspberryPi/RPi4/Readme.md
> +++ b/Platform/RaspberryPi/RPi4/Readme.md
> @@ -181,7 +181,7 @@ Limit RAM to 3 GB            | `RamLimitTo3GB` | Disable = `0x00000000` <br> Ena
>   System Table Selection       | `SystemTableMode`| ACPI = `0x00000000` (default)<br> ACPI + Devicetree = `0x00000001` <br> Devicetree = `0x00000002`
> 
>   Asset Tag                    | `AssetTag` | String, 32 characters or less (e.g. `L"ABCD123"`)<br> (default `L""`)
> 
>   **SD/MMC Configuration**     |
> 
> -uSD/eMMC Routing             | `SdIsArasan` | Arasan SDHC = `0x00000001` (default) <br> eMMC2 SDHCI = `0x00000000`
> 
> +uSD/eMMC Routing             | `SdIsArasan` | Arasan SDHC = `0x00000001` <br> eMMC2 SDHCI = `0x00000000` (default)
> 
>   Multi-Block Support          | `MmcDisableMulti` | Multi-block transfers = `0x00000000` (default)<br> Single block transfers = `0x00000001`
> 
>   uSD Max Bus Width            | `MmcForce1Bit` | 4-bit Mode = `0x00000000`  (default)<br> 1-bit Mode = `0x00000001`
> 
>   uSD Force Default Speed      | `MmcForceDefaultSpeed` | Allow High Speed = `0x00000000` (default)<br> Force Default Speed = `0x00000001`
> 

Reviewed-by: Pete Batard <pete@akeo.ie>

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

* Re: [PATCH v2 1/4] Platform/RaspberryPi: Add Negative table check
  2021-02-08 17:08   ` Pete Batard
@ 2021-02-08 17:24     ` Andrei Warkentin
  0 siblings, 0 replies; 15+ messages in thread
From: Andrei Warkentin @ 2021-02-08 17:24 UTC (permalink / raw)
  To: Pete Batard, Jeremy Linton, devel@edk2.groups.io
  Cc: samer.el-haj-mahmoud@arm.com, leif@nuviainc.com,
	ardb+tianocore@kernel.org

[-- Attachment #1: Type: text/plain, Size: 2470 bytes --]

Reviewed-by: Andrei Warkentin <awarkentin@vmware.com>
________________________________
From: Pete Batard <pete@akeo.ie>
Sent: Monday, February 8, 2021 11:08 AM
To: Jeremy Linton <jeremy.linton@arm.com>; devel@edk2.groups.io <devel@edk2.groups.io>
Cc: Andrei Warkentin <awarkentin@vmware.com>; samer.el-haj-mahmoud@arm.com <samer.el-haj-mahmoud@arm.com>; leif@nuviainc.com <leif@nuviainc.com>; ardb+tianocore@kernel.org <ardb+tianocore@kernel.org>
Subject: Re: [PATCH v2 1/4] Platform/RaspberryPi: Add Negative table check

Looks good to me.

On 2021.02.01 22:53, Jeremy Linton wrote:
> Turns out its helpful to have a !PcdToken flag
> that enables a DSDT/SSDT. That simplifies
> both the emmc2 SSDT (it only installs when
> !SdIsArasan) and later for the XHCI/PCIe switch
> where we want to install one of two tables
> depending on whether a single Pcd is set.
>
> Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
> ---
>   Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c | 6 ++++++
>   1 file changed, 6 insertions(+)
>
> diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c
> index 9581bc41e1..ca7533cbee 100644
> --- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c
> +++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c
> @@ -616,6 +616,7 @@ typedef struct {
>   typedef struct {
>
>     UINT64                      OemTableId;
>
>     UINTN                       PcdToken;
>
> +  UINTN                       PcdTokenNot;
>
>     CONST AML_NAME_OP_REPLACE   *SdtNameOpReplace;
>
>   } NAMESPACE_TABLES;
>
>
>
> @@ -713,6 +714,9 @@ VerifyUpdateTable (
>     if (SdtTable->PcdToken && !LibPcdGet32 (SdtTable->PcdToken)) {
>
>       Result = FALSE;
>
>     }
>
> +  if (SdtTable->PcdTokenNot && LibPcdGet32 (SdtTable->PcdTokenNot)) {
>
> +    Result = FALSE;
>
> +  }
>
>     if (Result && SdtTable->SdtNameOpReplace) {
>
>       UpdateSdtNameOps (AcpiHeader, SdtTable->SdtNameOpReplace);
>
>     }
>
> @@ -730,11 +734,13 @@ STATIC CONST NAMESPACE_TABLES SdtTables[] = {
>     {
>
>       SIGNATURE_64 ('R', 'P', 'I', 'T', 'H', 'F', 'A', 'N'),
>
>       PcdToken(PcdFanOnGpio),
>
> +    0,
>
>       SsdtNameOpReplace
>
>     },
>
>     {
>
>       SIGNATURE_64 ('R', 'P', 'I', 0, 0, 0, 0, 0),
>
>       0,
>
> +    0,
>
>       NULL
>
>     },
>
>     { }
>

Reviewed-by: Pete Batard <pete@akeo.ie>

[-- Attachment #2: Type: text/html, Size: 4786 bytes --]

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

* Re: [PATCH] Platform/RaspberryPi/Acpitables: Add eMMC2 device and tweak Arasan
  2021-02-01 22:53 ` [PATCH] Platform/RaspberryPi/Acpitables: Add eMMC2 device and tweak Arasan Jeremy Linton
  2021-02-08 17:08   ` Pete Batard
@ 2021-02-08 17:25   ` Andrei Warkentin
  1 sibling, 0 replies; 15+ messages in thread
From: Andrei Warkentin @ 2021-02-08 17:25 UTC (permalink / raw)
  To: Jeremy Linton, devel@edk2.groups.io
  Cc: pete@akeo.ie, samer.el-haj-mahmoud@arm.com, leif@nuviainc.com,
	ardb+tianocore@kernel.org

[-- Attachment #1: Type: text/plain, Size: 8056 bytes --]

[with all of Pete's comments]

Reviewed-by: Andrei Warkentin <awarkentin@vmware.com>
________________________________
From: Jeremy Linton <jeremy.linton@arm.com>
Sent: Monday, February 1, 2021 4:53 PM
To: devel@edk2.groups.io <devel@edk2.groups.io>
Cc: pete@akeo.ie <pete@akeo.ie>; Andrei Warkentin <awarkentin@vmware.com>; samer.el-haj-mahmoud@arm.com <samer.el-haj-mahmoud@arm.com>; leif@nuviainc.com <leif@nuviainc.com>; ardb+tianocore@kernel.org <ardb+tianocore@kernel.org>; Jeremy Linton <jeremy.linton@arm.com>
Subject: [PATCH] Platform/RaspberryPi/Acpitables: Add eMMC2 device and tweak Arasan

The primarly problem with the rpi Arasan controller working
with a default SDHCI driver is the lack of a meaningful
capabilities register. As such if we add a _DSD entry
to provide that information, we can then bind it to
the linux sdhci_iproc driver which already
hardcodes the remaining controller bugs.

Further we have gotten BRCME88C approved as the HID
for the newer eMMC2 controller. So lets define an
ACPI object to describe it.

Of course both devices are sharing an interrupt so
we should also indicate that in the table as well.

Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
---
 Platform/RaspberryPi/AcpiTables/AcpiTables.inf     |   1 +
 Platform/RaspberryPi/AcpiTables/Emmc.asl           | 131 +++++++++++++++++++++
 Platform/RaspberryPi/AcpiTables/Sdhc.asl           |  18 ++-
 Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c |   6 +
 4 files changed, 153 insertions(+), 3 deletions(-)
 create mode 100644 Platform/RaspberryPi/AcpiTables/Emmc.asl

diff --git a/Platform/RaspberryPi/AcpiTables/AcpiTables.inf b/Platform/RaspberryPi/AcpiTables/AcpiTables.inf
index d2cce074e5..743261afcf 100644
--- a/Platform/RaspberryPi/AcpiTables/AcpiTables.inf
+++ b/Platform/RaspberryPi/AcpiTables/AcpiTables.inf
@@ -35,6 +35,7 @@
   Spcr.aslc

   Pptt.aslc

   SsdtThermal.asl

+  Emmc.asl



 [Packages]

   ArmPkg/ArmPkg.dec

diff --git a/Platform/RaspberryPi/AcpiTables/Emmc.asl b/Platform/RaspberryPi/AcpiTables/Emmc.asl
new file mode 100644
index 0000000000..f089068556
--- /dev/null
+++ b/Platform/RaspberryPi/AcpiTables/Emmc.asl
@@ -0,0 +1,131 @@
+/** @file
+ *
+ *  Copyright (c) 2021 Arm. All rights reserved.
+ *
+ *  SPDX-License-Identifier: BSD-2-Clause-Patent
+ *
+ **/
+
+#include <IndustryStandard/Bcm2836SdHost.h>
+#include <IndustryStandard/Bcm2836Sdio.h>
+
+#include "AcpiTables.h"
+
+DefinitionBlock (__FILE__, "SSDT", 5, "RPIFDN", "RPI4EMMC", 2)
+{
+  Scope (\_SB_)
+  {
+#if (RPI_MODEL == 4)
+    Device (GDV1) {
+      Name (_HID, "ACPI0004")
+      Name (_UID, 0x0)
+      Name (_CCA, 0x0)
+
+      Name (RBUF, ResourceTemplate ()
+      {
+          MEMORY32FIXED (ReadWrite, 0, MMCHS2_LENGTH, RMEM)
+      })
+      Method (_CRS, 0x0, Serialized)
+      {
+        MEMORY32SETBASE (RBUF, RMEM, RBAS, MMCHS2_OFFSET)
+        Return (^RBUF)
+      }
+
+      Name (_DMA, ResourceTemplate() {
+        /*
+         * XHC0 is limited to DMA to first 3GB. Note this
+         * only applies to PCIe, not GENET or other devices
+         * next to the A72.
+         */
+        QWordMemory (ResourceConsumer,
+            ,
+            MinFixed,
+            MaxFixed,
+            NonCacheable,
+            ReadWrite,
+            0x0,
+            0x00000000C0000000, // MIN
+            0x00000000FFFFFFFF, // MAX
+            0xFFFFFFFF40000000, // TRA
+            0x0000000040000000, // LEN
+            ,
+            ,
+            )
+      })
+
+      // emmc2 Host Controller. (brcm,bcm2711-emmc2)
+      Device (SDC3)
+      {
+        Name (_HID, "BRCME88C")
+        Name (_UID, 0x1)
+       Name (_CCA, 0x0)
+       Name (_S1D, 0x1)
+       Name (_S2D, 0x1)
+       Name (_S3D, 0x1)
+       Name (_S4D, 0x1)
+       Name (SDMA, 0x2)
+       Method (_STA)
+       {
+         Return(0xf)
+       }
+       Name (RBUF, ResourceTemplate ()
+       {
+         MEMORY32FIXED (ReadWrite, 0, MMCHS2_LENGTH, RMEM)
+         Interrupt (ResourceConsumer, Level, ActiveHigh, Shared) { BCM2836_MMCHS1_INTERRUPT }
+       })
+       Method (_CRS, 0x0, Serialized)
+       {
+         MEMORY32SETBASE (RBUF, RMEM, RBAS, MMCHS2_OFFSET)
+         Return (^RBUF)
+       }
+
+        // Unfortunatly this controller doesn't honor the
+        // standard sdhci voltage control registers
+        // (or at least linux's standard code can't
+        // lower the voltage) So, UHS mode is disabled with caps
+        Name (DSD1, Package () {
+            ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
+            Package () {
+               Package () { "sdhci-caps-mask", 0x0000000500080000 },
+           }
+        })
+       // We also disable both SDMA and ADMA2 until the linux
+       // _DMA() mask/translate works properly
+        Name (DSD2, Package () {
+            ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
+            Package () {
+               Package () { "sdhci-caps-mask", 0x0000000504480000 },
+           }
+        })
+       Method (_DSD, 0x0, Serialized)
+        {
+          if (SDMA == 0)
+          {
+            return (^DSD2)
+          }
+          else
+          {
+            return (^DSD1)
+          }
+        }
+
+        //
+        // A child device that represents the
+        // sd card, which is marked as non-removable.
+        //
+        Device (SDMM)
+        {
+          Method (_ADR)
+          {
+            Return (0)
+          }
+          Method (_RMV) // Is removable
+          {
+            Return (0) // 0 - fixed
+          }
+        }
+      } //SDC3
+    } //GDV1
+#endif
+  } //\SB
+}
diff --git a/Platform/RaspberryPi/AcpiTables/Sdhc.asl b/Platform/RaspberryPi/AcpiTables/Sdhc.asl
index 0ab1ba27f2..0430ab7d2d 100644
--- a/Platform/RaspberryPi/AcpiTables/Sdhc.asl
+++ b/Platform/RaspberryPi/AcpiTables/Sdhc.asl
@@ -19,7 +19,7 @@
 // Note: UEFI can use either SDHost or Arasan. We expose both to the OS.

 //



-// ArasanSD 3.0 SD Host Controller.

+// ArasanSD 3.0 SD Host Controller. (brcm,bcm2835-sdhci)

 Device (SDC1)

 {

   Name (_HID, "BCM2847")

@@ -37,7 +37,7 @@ Device (SDC1)
   Name (RBUF, ResourceTemplate ()

   {

     MEMORY32FIXED (ReadWrite, 0, MMCHS1_LENGTH, RMEM)

-    Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { BCM2836_MMCHS1_INTERRUPT }

+    Interrupt (ResourceConsumer, Level, ActiveHigh, Shared) { BCM2836_MMCHS1_INTERRUPT }

   })

   Method (_CRS, 0x0, Serialized)

   {

@@ -45,6 +45,17 @@ Device (SDC1)
     Return (^RBUF)

   }



+  // The standard CAPs registers on this controller

+  // appear to be 0, lets set some minimal defaults

+  // Since this cap doesn't indicate DMA capability

+  // we don't need a _DMA()

+  Name (_DSD, Package () {

+    ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),

+    Package () {

+      Package () { "sdhci-caps", 0x0100fa81 },

+    }

+  })

+

   //

   // A child device that represents the

   // sd card, which is marked as non-removable.

@@ -62,7 +73,7 @@ Device (SDC1)
   }

 }



-

+#if (RPI_MODEL < 4)

 // Broadcom SDHost 2.0 SD Host Controller

 Device (SDC2)

 {

@@ -105,3 +116,4 @@ Device (SDC2)
     }

   }

 }

+#endif // !RPI4

diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c
index ca7533cbee..7f26f7b4be 100644
--- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c
+++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c
@@ -738,6 +738,12 @@ STATIC CONST NAMESPACE_TABLES SdtTables[] = {
     SsdtNameOpReplace

   },

   {

+    SIGNATURE_64 ('R', 'P', 'I', '4', 'E', 'M', 'M', 'C'),

+    0,

+    PcdToken(PcdSdIsArasan),

+    NULL

+  },

+  {

     SIGNATURE_64 ('R', 'P', 'I', 0, 0, 0, 0, 0),

     0,

     0,

--
2.13.7


[-- Attachment #2: Type: text/html, Size: 15587 bytes --]

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

* Re: [PATCH v2 3/4] Platform/RaspberryPi: User control of eMMC2 DMA
  2021-02-08 17:08   ` Pete Batard
@ 2021-02-08 17:26     ` Andrei Warkentin
  0 siblings, 0 replies; 15+ messages in thread
From: Andrei Warkentin @ 2021-02-08 17:26 UTC (permalink / raw)
  To: Pete Batard, Jeremy Linton, devel@edk2.groups.io
  Cc: samer.el-haj-mahmoud@arm.com, leif@nuviainc.com,
	ardb+tianocore@kernel.org

[-- Attachment #1: Type: text/plain, Size: 9179 bytes --]

Reviewed-by: Andrei Warkentin <awarkentin@vmware.com>
________________________________
From: Pete Batard <pete@akeo.ie>
Sent: Monday, February 8, 2021 11:08 AM
To: Jeremy Linton <jeremy.linton@arm.com>; devel@edk2.groups.io <devel@edk2.groups.io>
Cc: Andrei Warkentin <awarkentin@vmware.com>; samer.el-haj-mahmoud@arm.com <samer.el-haj-mahmoud@arm.com>; leif@nuviainc.com <leif@nuviainc.com>; ardb+tianocore@kernel.org <ardb+tianocore@kernel.org>
Subject: Re: [PATCH v2 3/4] Platform/RaspberryPi: User control of eMMC2 DMA

On 2021.02.01 22:53, Jeremy Linton wrote:
> DMA translation on the eMMC2 vary based on SOC, and
> this is made worse by the poor _DMA support in linux.
>
> For now the "safe" option is to simply run the eMMC2
> controller in PIO mode. More advanced users or !linux
> operating systems may choose to enable this to gain
> a perf boost.
>
> Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
> ---
>   Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c      | 16 +++++++++++++++-
>   Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf    |  1 +
>   Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni |  5 +++++
>   Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr | 17 +++++++++++++++++
>   Platform/RaspberryPi/Include/ConfigVars.h               |  8 ++++++++
>   Platform/RaspberryPi/RPi3/RPi3.dsc                      |  1 +
>   Platform/RaspberryPi/RPi4/RPi4.dsc                      |  1 +
>   Platform/RaspberryPi/RaspberryPi.dec                    |  1 +
>   8 files changed, 49 insertions(+), 1 deletion(-)
>
> diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c
> index 7f26f7b4be..1b8b360ddc 100644
> --- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c
> +++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c
> @@ -346,6 +346,15 @@ SetupVariables (
>     }
>
>
>
>     Size = sizeof (UINT32);
>
> +  Status = gRT->GetVariable (L"MmcEnableDma",
>
> +                  &gConfigDxeFormSetGuid,
>
> +                  NULL, &Size, &Var32);
>
> +  if (EFI_ERROR (Status)) {
>
> +    Status = PcdSet32S (PcdMmcEnableDma, PcdGet32 (PcdMmcEnableDma));
>
> +    ASSERT_EFI_ERROR (Status);
>
> +  }
>
> +
>
> +  Size = sizeof (UINT32);
>
>     Status = gRT->GetVariable (L"DebugEnableJTAG",
>
>                     &gConfigDxeFormSetGuid,
>
>                     NULL, &Size, &Var32);
>
> @@ -730,6 +739,11 @@ STATIC CONST AML_NAME_OP_REPLACE SsdtNameOpReplace[] = {
>     { }
>
>   };
>
>
>
> +STATIC CONST AML_NAME_OP_REPLACE SsdtEmmcNameOpReplace[] = {
>
> +  { "SDMA", PcdToken (PcdMmcEnableDma) },
>
> +  { }
>
> +};
>
> +
>
>   STATIC CONST NAMESPACE_TABLES SdtTables[] = {
>
>     {
>
>       SIGNATURE_64 ('R', 'P', 'I', 'T', 'H', 'F', 'A', 'N'),
>
> @@ -741,7 +755,7 @@ STATIC CONST NAMESPACE_TABLES SdtTables[] = {
>       SIGNATURE_64 ('R', 'P', 'I', '4', 'E', 'M', 'M', 'C'),
>
>       0,
>
>       PcdToken(PcdSdIsArasan),
>
> -    NULL
>
> +    SsdtEmmcNameOpReplace
>
>     },
>
>     {
>
>       SIGNATURE_64 ('R', 'P', 'I', 0, 0, 0, 0, 0),
>
> diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf
> index 544e3b3e10..d51e54e010 100644
> --- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf
> +++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf
> @@ -84,6 +84,7 @@
>     gRaspberryPiTokenSpaceGuid.PcdMmcSdDefaultSpeedMHz
>
>     gRaspberryPiTokenSpaceGuid.PcdMmcSdHighSpeedMHz
>
>     gRaspberryPiTokenSpaceGuid.PcdMmcDisableMulti
>
> +  gRaspberryPiTokenSpaceGuid.PcdMmcEnableDma
>
>     gRaspberryPiTokenSpaceGuid.PcdDebugEnableJTAG
>
>     gRaspberryPiTokenSpaceGuid.PcdDisplayEnableScaledVModes
>
>     gRaspberryPiTokenSpaceGuid.PcdDisplayEnableSShot
>
> diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni
> index 2afe8f32ae..6abccc1fdb 100644
> --- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni
> +++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni
> @@ -94,6 +94,11 @@
>   #string STR_MMC_SD_HS_PROMPT     #language en-US "SD High Speed (MHz)"
>
>   #string STR_MMC_SD_HS_HELP       #language en-US "Override default 50Mhz"
>
>
>
> +#string STR_MMC_EMMC_PROMPT      #language en-US "Enable eMMC DMA modes"
>
> +#string STR_MMC_EMMC_PIO         #language en-US "PIO"
>
> +#string STR_MMC_EMMC_DMA         #language en-US "SDMA/ADMA2"
>
> +#string STR_MMC_EMMC_HELP        #language en-US "Enable eMMC DMA modes for OS's that support ACPI _DMA() translations"

For consistency, since that's what we already use for other UI strings,
the plural of OS should be "OSes" rather than "OS's"

>
> +

(very minor) Extra line added here.

>
>
>
>   /*
>
>    * Display settings.
>
> diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr
> index de5e43471a..cc7a09cfb7 100644
> --- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr
> +++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr
> @@ -96,6 +96,11 @@ formset
>         name  = MmcSdHighSpeedMHz,
>
>         guid  = CONFIGDXE_FORM_SET_GUID;
>
>
>
> +    efivarstore MMC_EMMC_DMA_VARSTORE_DATA,
>
> +      attribute = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
>
> +      name  = MmcEnableDma,
>
> +      guid  = CONFIGDXE_FORM_SET_GUID;
>
> +
>
>       efivarstore DEBUG_ENABLE_JTAG_VARSTORE_DATA,
>
>         attribute = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
>
>         name  = DebugEnableJTAG,
>
> @@ -275,6 +280,18 @@ formset
>                maximum = 100,
>
>                default = 50,
>
>           endnumeric;
>
> +#if (RPI_MODEL == 4)
>
> +        grayoutif ideqval SdIsArasan.Routing == 1;
>
> +        oneof varid = MmcEnableDma.EnableDma,
>
> +            prompt      = STRING_TOKEN(STR_MMC_EMMC_PROMPT),
>
> +            help        = STRING_TOKEN(STR_MMC_EMMC_HELP),
>
> +            flags       = NUMERIC_SIZE_4 | INTERACTIVE | RESET_REQUIRED,
>
> +            option text = STRING_TOKEN(STR_MMC_EMMC_PIO), value = 0, flags = DEFAULT;
>
> +            option text = STRING_TOKEN(STR_MMC_EMMC_DMA), value = 1, flags = 0;
>
> +        endoneof;
>
> +        endif;
>
> +#endif
>
> +
>
>       endform;
>
>
>
>       form formid = 0x1004,
>
> diff --git a/Platform/RaspberryPi/Include/ConfigVars.h b/Platform/RaspberryPi/Include/ConfigVars.h
> index c185bfe28b..142317985a 100644
> --- a/Platform/RaspberryPi/Include/ConfigVars.h
> +++ b/Platform/RaspberryPi/Include/ConfigVars.h
> @@ -135,4 +135,12 @@ typedef struct {
>     UINT32 MHz;
>
>   } MMC_SD_HS_MHZ_VARSTORE_DATA;
>
>
>
> +typedef struct {
>
> +  /*
>
> +   * 0 - eMMC PIO mode
>
> +   * 1 - eMMC DMA mode
>
> +   */
>
> +  UINT32 EnableDma;
>
> +} MMC_EMMC_DMA_VARSTORE_DATA;
>
> +
>
>   #endif /* CONFIG_VARS_H */
>
> diff --git a/Platform/RaspberryPi/RPi3/RPi3.dsc b/Platform/RaspberryPi/RPi3/RPi3.dsc
> index 530b42796a..107cbda297 100644
> --- a/Platform/RaspberryPi/RPi3/RPi3.dsc
> +++ b/Platform/RaspberryPi/RPi3/RPi3.dsc
> @@ -470,6 +470,7 @@
>     gRaspberryPiTokenSpaceGuid.PcdMmcSdDefaultSpeedMHz|L"MmcSdDefaultSpeedMHz"|gConfigDxeFormSetGuid|0x0|25
>
>     gRaspberryPiTokenSpaceGuid.PcdMmcSdHighSpeedMHz|L"MmcSdHighSpeedMHz"|gConfigDxeFormSetGuid|0x0|50
>
>     gRaspberryPiTokenSpaceGuid.PcdMmcDisableMulti|L"MmcDisableMulti"|gConfigDxeFormSetGuid|0x0|0
>
> +  gRaspberryPiTokenSpaceGuid.PcdMmcEnableDma|L"MmcEnableDma"|gConfigDxeFormSetGuid|0x0|0
>
>
>
>     #
>
>     # Debug-related.
>
> diff --git a/Platform/RaspberryPi/RPi4/RPi4.dsc b/Platform/RaspberryPi/RPi4/RPi4.dsc
> index 5f8452aa0b..9962df0076 100644
> --- a/Platform/RaspberryPi/RPi4/RPi4.dsc
> +++ b/Platform/RaspberryPi/RPi4/RPi4.dsc
> @@ -481,6 +481,7 @@
>     gRaspberryPiTokenSpaceGuid.PcdMmcSdDefaultSpeedMHz|L"MmcSdDefaultSpeedMHz"|gConfigDxeFormSetGuid|0x0|25
>
>     gRaspberryPiTokenSpaceGuid.PcdMmcSdHighSpeedMHz|L"MmcSdHighSpeedMHz"|gConfigDxeFormSetGuid|0x0|50
>
>     gRaspberryPiTokenSpaceGuid.PcdMmcDisableMulti|L"MmcDisableMulti"|gConfigDxeFormSetGuid|0x0|0
>
> +  gRaspberryPiTokenSpaceGuid.PcdMmcEnableDma|L"MmcEnableDma"|gConfigDxeFormSetGuid|0x0|0
>
>
>
>     #
>
>     # Debug-related.
>
> diff --git a/Platform/RaspberryPi/RaspberryPi.dec b/Platform/RaspberryPi/RaspberryPi.dec
> index 10723036aa..08135717ed 100644
> --- a/Platform/RaspberryPi/RaspberryPi.dec
> +++ b/Platform/RaspberryPi/RaspberryPi.dec
> @@ -69,3 +69,4 @@
>     gRaspberryPiTokenSpaceGuid.PcdFanOnGpio|0|UINT32|0x0000001C
>
>     gRaspberryPiTokenSpaceGuid.PcdFanTemp|0|UINT32|0x0000001D
>
>     gRaspberryPiTokenSpaceGuid.PcdPlatformResetDelay|0|UINT32|0x0000001E
>
> +  gRaspberryPiTokenSpaceGuid.PcdMmcEnableDma|0|UINT32|0x0000001F
>

Reviewed-by: Pete Batard <pete@akeo.ie>

[-- Attachment #2: Type: text/html, Size: 15611 bytes --]

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

* Re: [PATCH v2 4/4] Platform/RaspberryPi: Invert default Arasan, Emmc2 routing
  2021-02-01 22:53 ` [PATCH v2 4/4] Platform/RaspberryPi: Invert default Arasan, Emmc2 routing Jeremy Linton
  2021-02-08 17:09   ` Pete Batard
@ 2021-02-08 17:26   ` Andrei Warkentin
  1 sibling, 0 replies; 15+ messages in thread
From: Andrei Warkentin @ 2021-02-08 17:26 UTC (permalink / raw)
  To: Jeremy Linton, devel@edk2.groups.io
  Cc: pete@akeo.ie, samer.el-haj-mahmoud@arm.com, leif@nuviainc.com,
	ardb+tianocore@kernel.org

[-- Attachment #1: Type: text/plain, Size: 3063 bytes --]

Reviewed-by: Andrei Warkentin <awarkentin@vmware.com>
________________________________
From: Jeremy Linton <jeremy.linton@arm.com>
Sent: Monday, February 1, 2021 4:53 PM
To: devel@edk2.groups.io <devel@edk2.groups.io>
Cc: pete@akeo.ie <pete@akeo.ie>; Andrei Warkentin <awarkentin@vmware.com>; samer.el-haj-mahmoud@arm.com <samer.el-haj-mahmoud@arm.com>; leif@nuviainc.com <leif@nuviainc.com>; ardb+tianocore@kernel.org <ardb+tianocore@kernel.org>; Jeremy Linton <jeremy.linton@arm.com>
Subject: [PATCH v2 4/4] Platform/RaspberryPi: Invert default Arasan, Emmc2 routing

In order for the wifi to work, and the SD to run at full
speed we need to bind the sd slot to the eMMC2 controller.

Since we now have a driver for the eMMC2 controller
there isn't any reason to leave the SD card bound
to the older Arasan controller.

Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
---
 Platform/RaspberryPi/RPi4/RPi4.dsc  | 2 +-
 Platform/RaspberryPi/RPi4/Readme.md | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/Platform/RaspberryPi/RPi4/RPi4.dsc b/Platform/RaspberryPi/RPi4/RPi4.dsc
index 9962df0076..e0fad6f744 100644
--- a/Platform/RaspberryPi/RPi4/RPi4.dsc
+++ b/Platform/RaspberryPi/RPi4/RPi4.dsc
@@ -475,7 +475,7 @@
   # SD-related.

   #



-  gRaspberryPiTokenSpaceGuid.PcdSdIsArasan|L"SdIsArasan"|gConfigDxeFormSetGuid|0x0|1

+  gRaspberryPiTokenSpaceGuid.PcdSdIsArasan|L"SdIsArasan"|gConfigDxeFormSetGuid|0x0|0

   gRaspberryPiTokenSpaceGuid.PcdMmcForce1Bit|L"MmcForce1Bit"|gConfigDxeFormSetGuid|0x0|0

   gRaspberryPiTokenSpaceGuid.PcdMmcForceDefaultSpeed|L"MmcForceDefaultSpeed"|gConfigDxeFormSetGuid|0x0|0

   gRaspberryPiTokenSpaceGuid.PcdMmcSdDefaultSpeedMHz|L"MmcSdDefaultSpeedMHz"|gConfigDxeFormSetGuid|0x0|25

diff --git a/Platform/RaspberryPi/RPi4/Readme.md b/Platform/RaspberryPi/RPi4/Readme.md
index 3b2ed44e3c..80899f4ca4 100644
--- a/Platform/RaspberryPi/RPi4/Readme.md
+++ b/Platform/RaspberryPi/RPi4/Readme.md
@@ -181,7 +181,7 @@ Limit RAM to 3 GB            | `RamLimitTo3GB` | Disable = `0x00000000` <br> Ena
 System Table Selection       | `SystemTableMode`| ACPI = `0x00000000` (default)<br> ACPI + Devicetree = `0x00000001` <br> Devicetree = `0x00000002`

 Asset Tag                    | `AssetTag` | String, 32 characters or less (e.g. `L"ABCD123"`)<br> (default `L""`)

 **SD/MMC Configuration**     |

-uSD/eMMC Routing             | `SdIsArasan` | Arasan SDHC = `0x00000001` (default) <br> eMMC2 SDHCI = `0x00000000`

+uSD/eMMC Routing             | `SdIsArasan` | Arasan SDHC = `0x00000001` <br> eMMC2 SDHCI = `0x00000000` (default)

 Multi-Block Support          | `MmcDisableMulti` | Multi-block transfers = `0x00000000` (default)<br> Single block transfers = `0x00000001`

 uSD Max Bus Width            | `MmcForce1Bit` | 4-bit Mode = `0x00000000`  (default)<br> 1-bit Mode = `0x00000001`

 uSD Force Default Speed      | `MmcForceDefaultSpeed` | Allow High Speed = `0x00000000` (default)<br> Force Default Speed = `0x00000001`

--
2.13.7


[-- Attachment #2: Type: text/html, Size: 4831 bytes --]

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

* Re: [PATCH v2 0/4] RPi: SD/Wifi Acpi updates
  2021-02-01 22:53 [PATCH v2 0/4] RPi: SD/Wifi Acpi updates Jeremy Linton
                   ` (3 preceding siblings ...)
  2021-02-01 22:53 ` [PATCH v2 4/4] Platform/RaspberryPi: Invert default Arasan, Emmc2 routing Jeremy Linton
@ 2021-02-11  8:07 ` Ard Biesheuvel
  2021-02-16 23:23   ` [edk2-devel] " Jeremy Linton
  4 siblings, 1 reply; 15+ messages in thread
From: Ard Biesheuvel @ 2021-02-11  8:07 UTC (permalink / raw)
  To: Jeremy Linton
  Cc: devel, Peter Batard, Andrei Warkentin, Samer El-Haj-Mahmoud,
	Leif Lindholm, Ard Biesheuvel

On Mon, 1 Feb 2021 at 23:53, Jeremy Linton <jeremy.linton@arm.com> wrote:
>
> The existing RPi3 acpi entries for the Arasan
> and sdhci controllers needs updating to work
> with the RPi4. This is done by adding a caps
> override for the legacy Arasan controller and
> then adding an entirely new entry for the newer
> eMMC2 controller.
>
> Then we flip the default routing to make the eMMC2
> the default for the SD card, so that the wifi can
> start working on the Arasan.
>
> Additional we add a menu item to enable the SDMA/ADMA2
> modes on the controller.
>
> v1->v2: Add option for user to enable/disable eMMC DMA
>         Only enable the emmc2 table on rpi4 &
>             !Arasan routing
>         Move emmc2 into its own SSDT and drop
>             second _DMA entry
>
> Jeremy Linton (4):
>   Platform/RaspberryPi: Add Negative table check
>   Platform/RaspberryPi/Acpitables: Add eMMC2 device and tweak Arasan
>   Platform/RaspberryPi: User control of eMMC2 DMA
>   Platform/RaspberryPi: Invert default Arasan, Emmc2 routing
>

Hi Jeremy,

I don't see v2 2/4 in my mailbox or in the ML archive. Can you resend please?

Also, what is the status of this work on the Linux side?


>  Platform/RaspberryPi/AcpiTables/AcpiTables.inf     |   1 +
>  Platform/RaspberryPi/AcpiTables/Emmc.asl           | 130 +++++++++++++++++++++
>  Platform/RaspberryPi/AcpiTables/Sdhc.asl           |  18 ++-
>  Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c |  26 +++++
>  .../RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf    |   1 +
>  .../RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni |   5 +
>  .../RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr |  17 +++
>  Platform/RaspberryPi/Include/ConfigVars.h          |   8 ++
>  Platform/RaspberryPi/RPi3/RPi3.dsc                 |   1 +
>  Platform/RaspberryPi/RPi4/RPi4.dsc                 |   3 +-
>  Platform/RaspberryPi/RPi4/Readme.md                |   2 +-
>  Platform/RaspberryPi/RaspberryPi.dec               |   1 +
>  12 files changed, 208 insertions(+), 5 deletions(-)
>  create mode 100644 Platform/RaspberryPi/AcpiTables/Emmc.asl
>
> --
> 2.13.7
>

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

* Re: [edk2-devel] [PATCH v2 0/4] RPi: SD/Wifi Acpi updates
  2021-02-11  8:07 ` [PATCH v2 0/4] RPi: SD/Wifi Acpi updates Ard Biesheuvel
@ 2021-02-16 23:23   ` Jeremy Linton
  0 siblings, 0 replies; 15+ messages in thread
From: Jeremy Linton @ 2021-02-16 23:23 UTC (permalink / raw)
  To: devel, ardb
  Cc: Peter Batard, Andrei Warkentin, Samer El-Haj-Mahmoud,
	Leif Lindholm, Ard Biesheuvel

Hi,

On 2/11/21 2:07 AM, Ard Biesheuvel via groups.io wrote:
> On Mon, 1 Feb 2021 at 23:53, Jeremy Linton <jeremy.linton@arm.com> wrote:
>>
>> The existing RPi3 acpi entries for the Arasan
>> and sdhci controllers needs updating to work
>> with the RPi4. This is done by adding a caps
>> override for the legacy Arasan controller and
>> then adding an entirely new entry for the newer
>> eMMC2 controller.
>>
>> Then we flip the default routing to make the eMMC2
>> the default for the SD card, so that the wifi can
>> start working on the Arasan.
>>
>> Additional we add a menu item to enable the SDMA/ADMA2
>> modes on the controller.
>>
>> v1->v2: Add option for user to enable/disable eMMC DMA
>>          Only enable the emmc2 table on rpi4 &
>>              !Arasan routing
>>          Move emmc2 into its own SSDT and drop
>>              second _DMA entry
>>
>> Jeremy Linton (4):
>>    Platform/RaspberryPi: Add Negative table check
>>    Platform/RaspberryPi/Acpitables: Add eMMC2 device and tweak Arasan
>>    Platform/RaspberryPi: User control of eMMC2 DMA
>>    Platform/RaspberryPi: Invert default Arasan, Emmc2 routing
>>
> 
> Hi Jeremy,
> 
> I don't see v2 2/4 in my mailbox or in the ML archive. Can you resend please?

Sorry about the delay here. I noticed this as I was doing a final pass 
on the review comments before reposing.

I'm guessing you didn't see it because because I messed up the patch 
numbering?

> 
> Also, what is the status of this work on the Linux side?

It should all be merged(ing), there was a patch in 5.11 to handle the 
sdhci-caps[-mask] fields, and the ACPI ID's patch should be getting 
merged to 5.12. The linux-firmware patch was merged a month or so ago 
too, which enables wifi. This is the last piece of the puzzle.


> 
> 
>>   Platform/RaspberryPi/AcpiTables/AcpiTables.inf     |   1 +
>>   Platform/RaspberryPi/AcpiTables/Emmc.asl           | 130 +++++++++++++++++++++
>>   Platform/RaspberryPi/AcpiTables/Sdhc.asl           |  18 ++-
>>   Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c |  26 +++++
>>   .../RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf    |   1 +
>>   .../RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni |   5 +
>>   .../RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr |  17 +++
>>   Platform/RaspberryPi/Include/ConfigVars.h          |   8 ++
>>   Platform/RaspberryPi/RPi3/RPi3.dsc                 |   1 +
>>   Platform/RaspberryPi/RPi4/RPi4.dsc                 |   3 +-
>>   Platform/RaspberryPi/RPi4/Readme.md                |   2 +-
>>   Platform/RaspberryPi/RaspberryPi.dec               |   1 +
>>   12 files changed, 208 insertions(+), 5 deletions(-)
>>   create mode 100644 Platform/RaspberryPi/AcpiTables/Emmc.asl
>>
>> --
>> 2.13.7
>>
> 
> 
> 
> 
> 


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

end of thread, other threads:[~2021-02-16 23:23 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-02-01 22:53 [PATCH v2 0/4] RPi: SD/Wifi Acpi updates Jeremy Linton
2021-02-01 22:53 ` [PATCH v2 1/4] Platform/RaspberryPi: Add Negative table check Jeremy Linton
2021-02-08 17:08   ` Pete Batard
2021-02-08 17:24     ` Andrei Warkentin
2021-02-01 22:53 ` [PATCH] Platform/RaspberryPi/Acpitables: Add eMMC2 device and tweak Arasan Jeremy Linton
2021-02-08 17:08   ` Pete Batard
2021-02-08 17:25   ` Andrei Warkentin
2021-02-01 22:53 ` [PATCH v2 3/4] Platform/RaspberryPi: User control of eMMC2 DMA Jeremy Linton
2021-02-08 17:08   ` Pete Batard
2021-02-08 17:26     ` Andrei Warkentin
2021-02-01 22:53 ` [PATCH v2 4/4] Platform/RaspberryPi: Invert default Arasan, Emmc2 routing Jeremy Linton
2021-02-08 17:09   ` Pete Batard
2021-02-08 17:26   ` Andrei Warkentin
2021-02-11  8:07 ` [PATCH v2 0/4] RPi: SD/Wifi Acpi updates Ard Biesheuvel
2021-02-16 23:23   ` [edk2-devel] " Jeremy Linton

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