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, awarkentin@vmware.com,
	samer.el-haj-mahmoud@arm.com, leif@nuviainc.com,
	ardb+tianocore@kernel.org, Jeremy Linton <jeremy.linton@arm.com>
Subject: [PATCH] Platform/RaspberryPi/Acpitables: Add eMMC2 device and tweak Arasan
Date: Mon,  1 Feb 2021 16:53:41 -0600	[thread overview]
Message-ID: <20210201225343.2001835-3-jeremy.linton@arm.com> (raw)
In-Reply-To: <20210201225343.2001835-1-jeremy.linton@arm.com>

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


  parent reply	other threads:[~2021-02-01 22:53 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` Jeremy Linton [this message]
2021-02-08 17:08   ` [PATCH] Platform/RaspberryPi/Acpitables: Add eMMC2 device and tweak Arasan 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

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=20210201225343.2001835-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