From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by mx.groups.io with SMTP id smtpd.web12.6835.1575024430122445862 for ; Fri, 29 Nov 2019 02:47:10 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@linaro.org header.s=google header.b=PeAjHlSP; spf=pass (domain: linaro.org, ip: 209.85.221.68, mailfrom: ard.biesheuvel@linaro.org) Received: by mail-wr1-f68.google.com with SMTP id z7so31114383wrl.13 for ; Fri, 29 Nov 2019 02:47:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=gDepIyBGkCmuEv3XHohLNFUSky12ekZFdEf679VW83A=; b=PeAjHlSP5LFZ4daQMZMJ4E5rpgru2ds1/9FLD4aUtGUa3P5KNtdJs+AUPZlUSaAijg LmeVIeFd3Ie2b+jzJbGJBsZJ3pNtkq4QpQtzhSU2277gJtsFzR7iXJm0l9BHJo7X7E16 5Qzd0qlRirj7uG2SIF3MsQV2XbsgfihsyA4jvNiHXYUtAelSjKoulHeqE3l8o9vYCOS7 sz+nWUi9RILrXV6ufVZrHdoz7lRWUjs8pan0R3/dFkeSD1WrTf/BLVlM0DW1mzpDXmCJ Eq25qzeRyhmx2h0s1kppU4HhMy2OvXM4yDwhQIrx91EXeHCZPjPvNYppq+FAczrxW7er fNDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=gDepIyBGkCmuEv3XHohLNFUSky12ekZFdEf679VW83A=; b=RHGiiUzOzR0rsHKsnRcNkjk4CzHtMWH4kW3X+zYJUWTUgOSV3Hsc9Lt/9FOXL/T8T8 TcX0eoNCrKJV61ukiZ6u9AjcowcW+YW+6vNmtof3pAOjmyyinQKrnwp0zws9NLMtjcst 0IKxWyK7NJZ8s/Eb7TexkG0D7Jeb+8/gLNjkNmncY4A1wHdHd+KF87If9Pq4NKIpBOpC O1nz1Hh+aqZ8vYctTmQ3g4qVVIkQ/RsFQOq1mMAo3iDAz/YkSVDGW+qEBaXWU0hrQWgT 2Hm6U0dz9wtSbrKfqgTViqYyp7vj1ghTaeXuAuxJqkRkhj3El6m5PkeIXrOMLyKTPCP8 +1lQ== X-Gm-Message-State: APjAAAVytZWPFXfjsMF1868RRdpm+PiQ+y09XubCAZHGLtSXS6hoIG1u d07YtVzD3cKcOibhP8W2vsyakNeJgRJHAA== X-Google-Smtp-Source: APXvYqwgZtEV6jSd06kzbp03NM1powEeJ6kUXhUO6g0BxWw08tKGUdNOkC+MNtqpOumhlO04CSozqA== X-Received: by 2002:a5d:6748:: with SMTP id l8mr9031950wrw.188.1575024428359; Fri, 29 Nov 2019 02:47:08 -0800 (PST) Return-Path: Received: from e123331-lin.home (amontpellier-657-1-18-247.w109-210.abo.wanadoo.fr. [109.210.65.247]) by smtp.gmail.com with ESMTPSA id 60sm27186170wrn.86.2019.11.29.02.47.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Nov 2019 02:47:07 -0800 (PST) From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: leif.lindholm@linaro.org, Ard Biesheuvel Subject: [PATCH edk2-platforms 1/2] Silicon/SynQuacer/PlatformDxe: move EMMC SSDT handling to core routine Date: Fri, 29 Nov 2019 11:47:15 +0100 Message-Id: <20191129104716.819-2-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191129104716.819-1-ard.biesheuvel@linaro.org> References: <20191129104716.819-1-ard.biesheuvel@linaro.org> In preparation of adding support for describing the presence of OP-TEE via a SSDT ACPI table, refactor the existing code so we will be able to reuse it more easily. Signed-off-by: Ard Biesheuvel --- Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/Emmc.c | 55 ----------------- Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.c | 65 ++++++++++++++++++++ 2 files changed, 65 insertions(+), 55 deletions(-) diff --git a/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/Emmc.c b/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/Emmc.c index 0d0e5edad901..90b67152c768 100644 --- a/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/Emmc.c +++ b/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/Emmc.c @@ -53,10 +53,6 @@ STATIC EFI_HANDLE mSdMmcControllerHandle; -STATIC EFI_ACPI_DESCRIPTION_HEADER *mSsdt; -STATIC UINTN mSsdtSize; -STATIC VOID *mEventRegistration; - /** Override function for SDHCI capability bits @@ -185,31 +181,6 @@ 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 ( @@ -218,32 +189,6 @@ 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.c b/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.c index 73cc560fa8d8..c9cc37dd2478 100644 --- a/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.c +++ b/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.c @@ -113,6 +113,11 @@ STATIC EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR mI2c1Desc[] = { } }; +STATIC EFI_ACPI_DESCRIPTION_HEADER *mEmmcSsdt; +STATIC UINTN mEmmcSsdtSize; + +STATIC VOID *mAcpiTableEventRegistration; + STATIC EFI_STATUS RegisterDevice ( @@ -256,6 +261,32 @@ EnableSettingsForm ( return InstallHiiPages (); } +STATIC +VOID +EFIAPI +InstallAcpiTables ( + 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, mEmmcSsdt, mEmmcSsdtSize, + &TableKey); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_WARN, "%a: failed to install SSDT table for eMMC - %r\n", + __FUNCTION__, Status)); + } +} + EFI_STATUS EFIAPI PlatformDxeEntryPoint ( @@ -267,6 +298,9 @@ PlatformDxeEntryPoint ( VOID *Dtb; UINTN DtbSize; EFI_HANDLE Handle; + EFI_ACPI_DESCRIPTION_HEADER *Ssdt; + UINTN SsdtSize; + UINTN Index; mHiiSettingsVal = PcdGet64 (PcdPlatformSettings); mHiiSettings = (SYNQUACER_PLATFORM_VARSTORE_DATA *)&mHiiSettingsVal; @@ -344,5 +378,36 @@ PlatformDxeEntryPoint ( ASSERT_EFI_ERROR (Status); } + if (mHiiSettings->AcpiPref == ACPIPREF_ACPI) { + // + // Load the SSDT tables from a raw section in this FFS file. + // + for (Index = 0;; Index++) { + Status = GetSectionFromFv (&gEfiCallerIdGuid, EFI_SECTION_RAW, Index, + (VOID **)&Ssdt, &SsdtSize); + if (EFI_ERROR (Status)) { + break; + } + + switch (Ssdt->OemTableId) { + case EMMC_TABLE_ID: + if (mHiiSettings->EnableEmmc != EMMC_ENABLED) { + break; + } + mEmmcSsdt = Ssdt; + mEmmcSsdtSize = SsdtSize; + break; + } + } + + if (mEmmcSsdtSize > 0) { + // + // Register for the ACPI table protocol if we found any SSDTs to install + // + EfiCreateProtocolNotifyEvent (&gEfiAcpiTableProtocolGuid, TPL_CALLBACK, + InstallAcpiTables, NULL, &mAcpiTableEventRegistration); + } + } + return EFI_SUCCESS; } -- 2.17.1