From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web12.4138.1613542706911021984 for ; Tue, 16 Feb 2021 22:18:27 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=softfail (domain: gmail.com, ip: 217.140.110.172, mailfrom: lintonrjeremy@gmail.com) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 895C3106F; Tue, 16 Feb 2021 22:18:26 -0800 (PST) Received: from u200856.usa.arm.com (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 3BA5D3F73B; Tue, 16 Feb 2021 22:18:26 -0800 (PST) From: jlinton 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 Subject: [PATCH v3 2/4] Platform/RaspberryPi/Acpitables: Add eMMC2 device and tweak Arasan Date: Wed, 17 Feb 2021 00:18:07 -0600 Message-Id: <20210217061809.307479-3-lintonrjeremy@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210217061809.307479-1-lintonrjeremy@gmail.com> References: <20210217061809.307479-1-lintonrjeremy@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Jeremy Linton The primary problem with the RPi's Arasan controller is the lack of a meaningful capabilities register. With just a sdhci-caps _DSD entry we can provide that information. It can then be bound 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 Reviewed-by: Pete Batard Reviewed-by: Andrei Warkentin --- Platform/RaspberryPi/AcpiTables/AcpiTables.inf | 1 + Platform/RaspberryPi/AcpiTables/Emmc.asl | 129 +++++++++++++++++= ++++ Platform/RaspberryPi/AcpiTables/Sdhc.asl | 18 ++- Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c | 6 + 4 files changed, 151 insertions(+), 3 deletions(-) create mode 100644 Platform/RaspberryPi/AcpiTables/Emmc.asl diff --git a/Platform/RaspberryPi/AcpiTables/AcpiTables.inf b/Platform/Rasp= berryPi/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=0D Pptt.aslc=0D SsdtThermal.asl=0D + Emmc.asl=0D =0D [Packages]=0D ArmPkg/ArmPkg.dec=0D diff --git a/Platform/RaspberryPi/AcpiTables/Emmc.asl b/Platform/RaspberryP= i/AcpiTables/Emmc.asl new file mode 100644 index 0000000000..3cb5289d36 --- /dev/null +++ b/Platform/RaspberryPi/AcpiTables/Emmc.asl @@ -0,0 +1,129 @@ +/** @file + * + * Copyright (c) 2021 Arm. All rights reserved. + * + * SPDX-License-Identifier: BSD-2-Clause-Patent + * + **/ + +#include +#include + +#include "AcpiTables.h" + +DefinitionBlock (__FILE__, "SSDT", 5, "RPIFDN", "RPI4EMMC", 2) +{ + Scope (\_SB_) + { +#if (RPI_MODEL =3D=3D 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() { + QWordMemory (ResourceConsumer, + , + MinFixed, + MaxFixed, + NonCacheable, + ReadWrite, + 0x0, + 0x00000000C0000000, // MIN + 0x00000000FFFFFFFF, // MAX + 0xFFFFFFFF40000000, // TRA + 0x0000000040000000, // LEN + , + , + ) + }) +=20=20=20=20=20=20 + // 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) { BCM283= 6_MMCHS1_INTERRUPT } + }) + Method (_CRS, 0x0, Serialized) + { + MEMORY32SETBASE (RBUF, RMEM, RBAS, MMCHS2_OFFSET) + Return (^RBUF) + } + + // Unfortunately this controller doesn't honor the + // standard SDHCI voltage control registers + // (or at least Linux's standard code can't=20 + // 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 }, + } + }) + // Along with disabling UHS, here both SDMA and ADMA2 + // are also disabled 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) + { + // Select one of the sdhci-caps-mask definitions + // depending on whether we also want to disable DMA + if (SDMA =3D=3D 0)=20 + { + return (^DSD2) + }=20 + else=20 + { + 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/RaspberryP= i/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.=0D //=0D =0D -// ArasanSD 3.0 SD Host Controller.=0D +// ArasanSD 3.0 SD Host Controller. (brcm,bcm2835-sdhci)=0D Device (SDC1)=0D {=0D Name (_HID, "BCM2847")=0D @@ -37,7 +37,7 @@ Device (SDC1) Name (RBUF, ResourceTemplate ()=0D {=0D MEMORY32FIXED (ReadWrite, 0, MMCHS1_LENGTH, RMEM)=0D - Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { BCM2836_M= MCHS1_INTERRUPT }=0D + Interrupt (ResourceConsumer, Level, ActiveHigh, Shared) { BCM2836_MMCH= S1_INTERRUPT }=0D })=0D Method (_CRS, 0x0, Serialized)=0D {=0D @@ -45,6 +45,17 @@ Device (SDC1) Return (^RBUF)=0D }=0D =0D + // The standard CAPs registers on this controller=0D + // appear to be 0, lets set some minimal defaults=0D + // Since this cap doesn't indicate DMA capability=0D + // we don't need a _DMA()=0D + Name (_DSD, Package () {=0D + ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),=0D + Package () {=0D + Package () { "sdhci-caps", 0x0100fa81 },=0D + }=0D + })=0D +=0D //=0D // A child device that represents the=0D // sd card, which is marked as non-removable.=0D @@ -62,7 +73,7 @@ Device (SDC1) }=0D }=0D =0D -=0D +#if (RPI_MODEL < 4)=0D // Broadcom SDHost 2.0 SD Host Controller=0D Device (SDC2)=0D {=0D @@ -105,3 +116,4 @@ Device (SDC2) }=0D }=0D }=0D +#endif // !RPI4=0D diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c b/Platform/= RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c index fc1b5f3420..402a2996b3 100644 --- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c +++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c @@ -728,6 +728,12 @@ STATIC CONST NAMESPACE_TABLES SdtTables[] =3D { SsdtNameOpReplace=0D },=0D {=0D + SIGNATURE_64 ('R', 'P', 'I', '4', 'E', 'M', 'M', 'C'),=0D + 0,=0D + PcdToken(PcdSdIsArasan),=0D + NULL=0D + },=0D + {=0D SIGNATURE_64 ('R', 'P', 'I', 0, 0, 0, 0, 0),=0D 0,=0D 0,=0D --=20 2.13.7