From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
To: edk2-devel@lists.01.org
Cc: leif.lindholm@linaro.org, graeme.gregory@linaro.org,
masahisa.kojima@linaro.org,
Ard Biesheuvel <ard.biesheuvel@linaro.org>
Subject: [PATCH edk2-platforms v2 5/7] Silicon/SynQuacer/PlatformDxe: add ACPI description of eMMC
Date: Wed, 28 Feb 2018 19:24:19 +0000 [thread overview]
Message-ID: <20180228192421.17684-6-ard.biesheuvel@linaro.org> (raw)
In-Reply-To: <20180228192421.17684-1-ard.biesheuvel@linaro.org>
Expose a separate ACPI description of the SynQuacer eMMC controller
when both ACPI and eMMC support have been enabled in the HII menu.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
Platform/Socionext/DeveloperBox/DeveloperBox.fdf | 1 +
Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.fdf | 1 +
Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/Emmc.asl | 41 +++++++++++++++
Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/Emmc.c | 55 ++++++++++++++++++++
Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.h | 4 ++
Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.inf | 4 ++
6 files changed, 106 insertions(+)
diff --git a/Platform/Socionext/DeveloperBox/DeveloperBox.fdf b/Platform/Socionext/DeveloperBox/DeveloperBox.fdf
index 50e385b519d0..7f8708d3a7a9 100644
--- a/Platform/Socionext/DeveloperBox/DeveloperBox.fdf
+++ b/Platform/Socionext/DeveloperBox/DeveloperBox.fdf
@@ -450,6 +450,7 @@ [Rule.Common.DXE_DRIVER]
PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi
UI STRING="$(MODULE_NAME)" Optional
RAW BIN Optional |.dtb
+ RAW ASL Optional |.aml
}
[Rule.Common.DXE_RUNTIME_DRIVER]
diff --git a/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.fdf b/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.fdf
index 20d19120d1b7..3f47781fe979 100644
--- a/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.fdf
+++ b/Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.fdf
@@ -419,6 +419,7 @@ [Rule.Common.DXE_DRIVER]
DXE_DEPEX DXE_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME).depex
PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi
UI STRING="$(MODULE_NAME)" Optional
+ RAW ASL Optional |.aml
}
[Rule.Common.DXE_RUNTIME_DRIVER]
diff --git a/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/Emmc.asl b/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/Emmc.asl
new file mode 100644
index 000000000000..4e371befc7b5
--- /dev/null
+++ b/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/Emmc.asl
@@ -0,0 +1,41 @@
+/** @file
+ SSDT describing the SynQuacer eMMC controller
+
+ Copyright (c) 2018, Linaro Ltd. All rights reserved.<BR>
+
+ This program and the accompanying materials are licensed and made available
+ under the terms and conditions of the BSD License which accompanies this
+ distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include <Platform/MemoryMap.h>
+
+DefinitionBlock ("SsdtEmmc.aml", "SSDT", 1, "SNI", "SynQeMMC",
+ FixedPcdGet32 (PcdAcpiDefaultOemRevision)) {
+ Scope (_SB) {
+ Device (MMC0) {
+ Name (_HID, "SCX0002")
+ Name (_UID, Zero)
+ Name (_CCA, 1)
+ Name (_CRS, ResourceTemplate () {
+ Memory32Fixed (ReadWrite, SYNQUACER_EMMC_BASE, SYNQUACER_EMMC_BASE_SZ)
+ Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 184 }
+ })
+
+ Name (_DSD, Package () // _DSD: Device-Specific Data
+ {
+ ToUUID ("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
+ Package () {
+ Package (2) { "bus-width", 8 },
+ Package (2) { "cap-mmc-highspeed", 0x1 },
+ Package (2) { "fujitsu,cmd-dat-delay-select", 0x1 },
+ }
+ })
+ }
+ } // Scope (_SB)
+}
diff --git a/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/Emmc.c b/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/Emmc.c
index 7284ea6a7cee..e0987c954c74 100644
--- a/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/Emmc.c
+++ b/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/Emmc.c
@@ -59,6 +59,10 @@
STATIC EFI_HANDLE mSdMmcControllerHandle;
+STATIC EFI_ACPI_DESCRIPTION_HEADER *mSsdt;
+STATIC UINTN mSsdtSize;
+STATIC VOID *mEventRegistration;
+
/**
Override function for SDHCI capability bits
@@ -182,6 +186,31 @@ STATIC EDKII_SD_MMC_OVERRIDE mSdMmcOverride = {
SynQuacerSdMmcNotifyPhase,
};
+STATIC
+VOID
+EFIAPI
+InstallAcpiTable (
+ IN EFI_EVENT Event,
+ IN VOID* Context
+ )
+{
+ UINTN TableKey;
+ EFI_STATUS Status;
+ EFI_ACPI_TABLE_PROTOCOL *AcpiTable;
+
+ Status = gBS->LocateProtocol (&gEfiAcpiTableProtocolGuid, NULL,
+ (VOID **)&AcpiTable);
+ if (EFI_ERROR (Status)) {
+ return;
+ }
+
+ Status = AcpiTable->InstallAcpiTable (AcpiTable, mSsdt, mSsdtSize, &TableKey);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_WARN, "%a: failed to install SSDT table for eMMC - %r\n",
+ __FUNCTION__, Status));
+ }
+}
+
EFI_STATUS
EFIAPI
RegisterEmmc (
@@ -190,6 +219,32 @@ RegisterEmmc (
{
EFI_STATUS Status;
EFI_HANDLE Handle;
+ UINTN Index;
+
+ if (mHiiSettings->AcpiPref == ACPIPREF_ACPI) {
+ //
+ // Load the SSDT table from a raw section in this FFS file.
+ //
+ for (Index = 0;; Index++) {
+ Status = GetSectionFromFv (&gEfiCallerIdGuid, EFI_SECTION_RAW, Index,
+ (VOID **)&mSsdt, &mSsdtSize);
+ if (EFI_ERROR (Status)) {
+ break;
+ }
+
+ if (mSsdt->OemTableId != EMMC_TABLE_ID) {
+ continue;
+ }
+
+ //
+ // Register for the ACPI table protocol
+ //
+ EfiCreateProtocolNotifyEvent (&gEfiAcpiTableProtocolGuid, TPL_CALLBACK,
+ InstallAcpiTable, NULL, &mEventRegistration);
+
+ break;
+ }
+ }
Status = RegisterNonDiscoverableMmioDevice (
NonDiscoverableDeviceTypeSdhci,
diff --git a/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.h b/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.h
index a391d2f67c29..c25b7f168a37 100644
--- a/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.h
+++ b/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.h
@@ -24,6 +24,7 @@
#include <Library/DebugLib.h>
#include <Library/DevicePathLib.h>
#include <Library/DtPlatformDtbLoaderLib.h>
+#include <Library/DxeServicesLib.h>
#include <Library/HiiLib.h>
#include <Library/IoLib.h>
#include <Library/MemoryAllocationLib.h>
@@ -35,10 +36,13 @@
#include <Platform/MemoryMap.h>
#include <Platform/Pcie.h>
#include <Platform/VarStore.h>
+#include <Protocol/AcpiTable.h>
#include <Protocol/NonDiscoverableDevice.h>
#include <Protocol/PciIo.h>
#include <Protocol/SdMmcOverride.h>
+#define EMMC_TABLE_ID SIGNATURE_64('S','y','n','Q','e','M','M','C')
+
extern UINT8 PlatformDxeHiiBin[];
extern UINT8 PlatformDxeStrings[];
diff --git a/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.inf b/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.inf
index bef7feccd8b8..8df3073bf24b 100644
--- a/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.inf
+++ b/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.inf
@@ -23,6 +23,7 @@ [Defines]
ENTRY_POINT = PlatformDxeEntryPoint
[Sources]
+ Emmc.asl
Emmc.c
Pci.c
PlatformDxe.c
@@ -46,6 +47,7 @@ [LibraryClasses]
DebugLib
DevicePathLib
DtPlatformDtbLoaderLib
+ DxeServicesLib
HiiLib
IoLib
MemoryAllocationLib
@@ -69,10 +71,12 @@ [Guids]
[Protocols]
gEdkiiNonDiscoverableDeviceProtocolGuid ## PRODUCES
gEdkiiSdMmcOverrideProtocolGuid ## PRODUCES
+ gEfiAcpiTableProtocolGuid ## CONSUMES
gEfiPciIoProtocolGuid ## CONSUMES
gPcf8563RealTimeClockLibI2cMasterProtocolGuid ## PRODUCES
[FixedPcd]
+ gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultOemRevision
gSynQuacerTokenSpaceGuid.PcdNetsecEepromBase
gSynQuacerTokenSpaceGuid.PcdNetsecPhyAddress
--
2.11.0
next prev parent reply other threads:[~2018-02-28 19:18 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-28 19:24 [PATCH edk2-platforms v2 0/7] SynQuacer ACPI support Ard Biesheuvel
2018-02-28 19:24 ` [PATCH edk2-platforms v2 1/7] Platform/Socionext/DeveloperBox: fix PCIe slot to B/D/F mapping Ard Biesheuvel
2018-02-28 19:24 ` [PATCH edk2-platforms v2 2/7] Silicon/SynQuacer: tweak PCI I/O windows for ACPI/Linux support Ard Biesheuvel
2018-02-28 19:24 ` [PATCH edk2-platforms v2 3/7] Silicon/SynQuacer: add ACPI drivers and tables Ard Biesheuvel
2018-02-28 19:24 ` [PATCH edk2-platforms v2 4/7] Silicon/SynQuacer/PlatformDxe: add option to enable ACPI mode Ard Biesheuvel
2018-02-28 19:24 ` Ard Biesheuvel [this message]
2018-02-28 19:24 ` [PATCH edk2-platforms v2 6/7] Silicon/SynQuacer/AcpiTables: disable PCI RCs if ECAM ghosts are detected Ard Biesheuvel
2018-02-28 19:24 ` [PATCH edk2-platforms v2 7/7] Silicon/SynQuacer/AcpiTables: take presence detect of PCI0 into account Ard Biesheuvel
2018-02-28 20:21 ` [PATCH edk2-platforms v2 0/7] SynQuacer ACPI support Leif Lindholm
2018-03-01 11:23 ` Graeme Gregory (Linaro)
2018-03-01 11:24 ` Ard Biesheuvel
2018-03-15 16:06 ` Ard Biesheuvel
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=20180228192421.17684-6-ard.biesheuvel@linaro.org \
--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