From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-f170.google.com (mail-pg1-f170.google.com [209.85.215.170]) by mx.groups.io with SMTP id smtpd.web09.5135.1613552635247582311 for ; Wed, 17 Feb 2021 01:03:55 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@puresoftware.com header.s=google header.b=kVWt9cFV; spf=pass (domain: puresoftware.com, ip: 209.85.215.170, mailfrom: vikas.singh@puresoftware.com) Received: by mail-pg1-f170.google.com with SMTP id 75so4698792pgf.13 for ; Wed, 17 Feb 2021 01:03:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=puresoftware.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=BIpFHuQ8HvKiLe7RzCXczV6EuQJS8i25MzwK8K3vk8o=; b=kVWt9cFVhcfua3CNxuuPWcMxbmJtUr7ZZVbd3R16k7+UzgR0g26Vctl0yUWEgCOeJa G1fdUQTH1hNxZjMESzpKl3UdvzaOAnHeQnFlgiMfrWkCDGwu7ZkSZe+fvJsQihTgYinD e0yWG/ZavOrJQQapjvr2g5miaVu6DErGuggro= 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=BIpFHuQ8HvKiLe7RzCXczV6EuQJS8i25MzwK8K3vk8o=; b=GO0aPFmEJ8MAhYEylEs4682kxLQJNZAUU7j2lSKCKDO2nTup5vPADwG05wsVncpkwd XbTNY6901kHUojhF/dZ/IrCux+XWRdm6tPqrj4GOubUbqgYWSfr5XgrZJjaTGW1YuWs5 fAH3DaXeM5eychgwaLehJhe92rPqIBwSEtBEBxFbX7Xppb6qqFWHfJZgXSHh9g19PSoe jVSsi6vadFGQG9+VBNkxha47WNvb5Ld80+oW3wZ21QxVx78t1BrjAMEMIQlCXvA1B7IP 7fmFgfmo5J0uKRqYISkyEhP/MTU8B9ONlNLGjh+kzxydz0v4WiJo86HdnYEDXJIdN3xP qL/w== X-Gm-Message-State: AOAM533Z9wU742sHpmWCbcXZ1lvrz0jhaJbFkUfEj7nlLprzTvy/jYa0 2M2XoEjveSfibeKe+RRYCW/n5jdYa1IA05Ev X-Google-Smtp-Source: ABdhPJyrT+Vli6yBWIc4hrjWV/YxCS7/dcK70qKJET+gX/zWWJV5xQT60zYZ7rbGszVr7UqLVNUKBw== X-Received: by 2002:a63:4521:: with SMTP id s33mr23090125pga.16.1613552634346; Wed, 17 Feb 2021 01:03:54 -0800 (PST) Return-Path: Received: from embedded-PC.puresoft.int ([125.63.92.170]) by smtp.gmail.com with ESMTPSA id v9sm1493418pju.33.2021.02.17.01.03.50 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Feb 2021 01:03:54 -0800 (PST) From: "Vikas Singh" To: devel@edk2.groups.io Cc: sami.mujawar@arm.com, leif@nuviainc.com, meenakshi.aggarwal@nxp.com, paul.yang@arm.com, augustine.philips@arm.com, samer.el-haj-mahmoud@arm.com, v.sethi@nxp.com, arokia.samy@puresoftware.com, kuldip.dwivedi@puresoftware.com, ard.biesheuvel@arm.com, vikas.singh@nxp.com Subject: [PATCH v3 2/2] Platform/NXP: Add OEM specific DSDT generator Date: Wed, 17 Feb 2021 14:33:32 +0530 Message-Id: <1613552612-15642-3-git-send-email-vikas.singh@puresoftware.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1613552612-15642-1-git-send-email-vikas.singh@puresoftware.com> References: <1613552612-15642-1-git-send-email-vikas.singh@puresoftware.com> These changes add platform specific DSDT generator and Clk dsdt properties for LX2160ARDB. Signed-off-by: Vikas Singh --- Platform/NXP/ConfigurationManagerPkg/ConfigurationManagerDxe/ConfigurationManager.c | 9 ++ Platform/NXP/ConfigurationManagerPkg/ConfigurationManagerDxe/ConfigurationManager.h | 4 +- Platform/NXP/ConfigurationManagerPkg/ConfigurationManagerDxe/ConfigurationManagerDxe.inf | 1 + Platform/NXP/ConfigurationManagerPkg/ConfigurationManagerPkg.dec | 23 +++ Platform/NXP/ConfigurationManagerPkg/Include/PlatformAcpiTableGenerator.h | 20 +++ Platform/NXP/LX2160aRdbPkg/AcpiTablesInclude/Dsdt/Clk.asl | 40 ++++++ Platform/NXP/LX2160aRdbPkg/AcpiTablesInclude/Dsdt/Dsdt.asl | 15 ++ Platform/NXP/LX2160aRdbPkg/AcpiTablesInclude/PlatformAcpiDsdtLib.inf | 39 ++++++ Platform/NXP/LX2160aRdbPkg/AcpiTablesInclude/PlatformAcpiDsdtLib/RawDsdtGenerator.c | 146 ++++++++++++++++++++ Platform/NXP/LX2160aRdbPkg/AcpiTablesInclude/PlatformAcpiLib.h | 23 +++ Platform/NXP/LX2160aRdbPkg/Include/Platform.h | 6 + Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.dsc | 1 + 12 files changed, 326 insertions(+), 1 deletion(-) diff --git a/Platform/NXP/ConfigurationManagerPkg/ConfigurationManagerDxe/ConfigurationManager.c b/Platform/NXP/ConfigurationManagerPkg/ConfigurationManagerDxe/ConfigurationManager.c index bec9131..80ce841 100644 --- a/Platform/NXP/ConfigurationManagerPkg/ConfigurationManagerDxe/ConfigurationManager.c +++ b/Platform/NXP/ConfigurationManagerPkg/ConfigurationManagerDxe/ConfigurationManager.c @@ -78,6 +78,15 @@ FSL_PLATFORM_REPOSITORY_INFO FslPlatformRepositoryInfo = { CREATE_STD_ACPI_TABLE_GEN_ID (EStdAcpiTableIdSpcr), NULL, CFG_MGR_TABLE_ID + }, + + // DSDT (OEM) Table + { + EFI_ACPI_6_2_DIFFERENTIATED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE, + 0, + CREATE_OEM_ACPI_TABLE_GEN_ID (PlatAcpiTableIdDsdt), + NULL, + CFG_MGR_TABLE_ID } }, diff --git a/Platform/NXP/ConfigurationManagerPkg/ConfigurationManagerDxe/ConfigurationManager.h b/Platform/NXP/ConfigurationManagerPkg/ConfigurationManagerDxe/ConfigurationManager.h index ab320e5..0c7dd41 100644 --- a/Platform/NXP/ConfigurationManagerPkg/ConfigurationManagerDxe/ConfigurationManager.h +++ b/Platform/NXP/ConfigurationManagerPkg/ConfigurationManagerDxe/ConfigurationManager.h @@ -15,6 +15,7 @@ #define CONFIGURATION_MANAGER_H #include +#include /** The configuration manager version */ @@ -62,7 +63,8 @@ typedef EFI_STATUS (*CM_OBJECT_HANDLER_PROC) ( /** The number of ACPI tables to install */ -#define PLAT_ACPI_TABLE_COUNT 5 +#define CM_MANDATORY_ACPI_TABLES 5 +#define PLAT_ACPI_TABLE_COUNT (CM_MANDATORY_ACPI_TABLES + OEM_ACPI_TABLES) /** A structure describing the platform configuration manager repository information diff --git a/Platform/NXP/ConfigurationManagerPkg/ConfigurationManagerDxe/ConfigurationManagerDxe.inf b/Platform/NXP/ConfigurationManagerPkg/ConfigurationManagerDxe/ConfigurationManagerDxe.inf index 496c8bf..7c082cb 100644 --- a/Platform/NXP/ConfigurationManagerPkg/ConfigurationManagerDxe/ConfigurationManagerDxe.inf +++ b/Platform/NXP/ConfigurationManagerPkg/ConfigurationManagerDxe/ConfigurationManagerDxe.inf @@ -31,6 +31,7 @@ EmbeddedPkg/EmbeddedPkg.dec MdeModulePkg/MdeModulePkg.dec MdePkg/MdePkg.dec + Platform/NXP/ConfigurationManagerPkg/ConfigurationManagerPkg.dec Silicon/NXP/NxpQoriqLs.dec [LibraryClasses] diff --git a/Platform/NXP/ConfigurationManagerPkg/ConfigurationManagerPkg.dec b/Platform/NXP/ConfigurationManagerPkg/ConfigurationManagerPkg.dec new file mode 100644 index 0000000..e4af8e4 --- /dev/null +++ b/Platform/NXP/ConfigurationManagerPkg/ConfigurationManagerPkg.dec @@ -0,0 +1,23 @@ +# ConfigurationManager.dec +# +# Copyright 2020 NXP +# Copyright 2020 Puresoftware Ltd +# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# + +[Defines] + PACKAGE_NAME = ConfigurationManagerPkg + PACKAGE_GUID = 0222b1b1-247f-404e-bdc3-baab65f2ddd3 + +################################################################################ +# +# Include Section - list of Include Paths that are provided by this package. +# Comments are used for Keywords and Module Types. +# +# Supported Module Types: +# BASE SEC PEI_CORE PEIM DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SMM_DRIVER DXE_SAL_DRIVER UEFI_DRIVER UEFI_APPLICATION +# +################################################################################ +[Includes] + Include diff --git a/Platform/NXP/ConfigurationManagerPkg/Include/PlatformAcpiTableGenerator.h b/Platform/NXP/ConfigurationManagerPkg/Include/PlatformAcpiTableGenerator.h new file mode 100644 index 0000000..c1ec114 --- /dev/null +++ b/Platform/NXP/ConfigurationManagerPkg/Include/PlatformAcpiTableGenerator.h @@ -0,0 +1,20 @@ +/** @file + Acpi Table generator headers + + Copyright 2020 NXP + Copyright 2020 Puresoftware Ltd + + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef PLATFORM_ACPI_TABLE_GENERATOR_H +#define PLATFORM_ACPI_TABLE_GENERATOR_H + +typedef enum PlatAcpiTableId { + PlatAcpiTableIdReserved = 0x0000, ///< Reserved + PlatAcpiTableIdDsdt, + PlatAcpiTableIdMax +} PLAT_ACPI_TABLE_ID; + +#endif // PLATFORM_ACPI_TABLE_GENERATOR_H diff --git a/Platform/NXP/LX2160aRdbPkg/AcpiTablesInclude/Dsdt/Clk.asl b/Platform/NXP/LX2160aRdbPkg/AcpiTablesInclude/Dsdt/Clk.asl new file mode 100644 index 0000000..1008476 --- /dev/null +++ b/Platform/NXP/LX2160aRdbPkg/AcpiTablesInclude/Dsdt/Clk.asl @@ -0,0 +1,40 @@ +/** @file + Differentiated System Description Table Fields (DSDT) + + Copyright 2020 NXP + Copyright 2020 Puresoftware Ltd + + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +Scope(_SB) +{ + Device(PCLK) { + Name(_HID, "NXP0017") + Name(CLK, 0) + Name(AVBL, 0) + OperationRegion(RCWS, SystemMemory, DCFG_BASE, DCFG_LEN) + Method(_REG,2) { + if (Arg0 == "RCWS") { + Store(Arg1, AVBL) + } + } + Field (RCWS, ByteAcc, NoLock, Preserve) { + offset(0x100), + PCFG, 2, + PRAT, 6, + offset(0x124), + RESV, 4, + SFRQ, 10 + } + + Method(_INI, 0, NotSerialized) { + Store(SFRQ, Local0) + Multiply(Local0, 500000, Local0) + Multiply(Local0, PRAT, Local0) + Divide(Local0, 6, , Local0) + Store(Local0, CLK) + } + } +} // end of device PCLK diff --git a/Platform/NXP/LX2160aRdbPkg/AcpiTablesInclude/Dsdt/Dsdt.asl b/Platform/NXP/LX2160aRdbPkg/AcpiTablesInclude/Dsdt/Dsdt.asl new file mode 100644 index 0000000..e4f04ce --- /dev/null +++ b/Platform/NXP/LX2160aRdbPkg/AcpiTablesInclude/Dsdt/Dsdt.asl @@ -0,0 +1,15 @@ +/** @file + Differentiated System Description Table Fields (DSDT) + + Copyright 2020 NXP + Copyright 2020 Puresoftware Ltd. + + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include "Platform.h" + +DefinitionBlock("DsdtTable.aml", "DSDT", 2, "NXP ", "LX2160 ", EFI_ACPI_ARM_OEM_REVISION) { + include ("Clk.asl") +} diff --git a/Platform/NXP/LX2160aRdbPkg/AcpiTablesInclude/PlatformAcpiDsdtLib.inf b/Platform/NXP/LX2160aRdbPkg/AcpiTablesInclude/PlatformAcpiDsdtLib.inf new file mode 100644 index 0000000..b7e34f4 --- /dev/null +++ b/Platform/NXP/LX2160aRdbPkg/AcpiTablesInclude/PlatformAcpiDsdtLib.inf @@ -0,0 +1,39 @@ +## @file +# Raw Table Generator +# +# Copyright 2020 NXP +# Copyright 2020 Puresoftware Ltd +# +# SPDX-License-Identifier: BSD-2-Clause-Patent +## + +[Defines] + INF_VERSION = 0x00010019 + BASE_NAME = PlatformAcpiDsdtLib + FILE_GUID = 0b1768cf-13fa-4ecf-b640-338a636d1abb + VERSION_STRING = 1.0 + MODULE_TYPE = DXE_DRIVER + LIBRARY_CLASS = NULL|DXE_DRIVER + CONSTRUCTOR = AcpiDsdtLibConstructor + DESTRUCTOR = AcpiDsdtLibDestructor + +[Sources] + PlatformAcpiDsdtLib/RawDsdtGenerator.c + Dsdt/Dsdt.asl + +[Packages] + DynamicTablesPkg/DynamicTablesPkg.dec + EmbeddedPkg/EmbeddedPkg.dec + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.dec + Platform/NXP/ConfigurationManagerPkg/ConfigurationManagerPkg.dec + +[LibraryClasses] + BaseLib + +[Pcd] + +[Protocols] + +[Guids] diff --git a/Platform/NXP/LX2160aRdbPkg/AcpiTablesInclude/PlatformAcpiDsdtLib/RawDsdtGenerator.c b/Platform/NXP/LX2160aRdbPkg/AcpiTablesInclude/PlatformAcpiDsdtLib/RawDsdtGenerator.c new file mode 100644 index 0000000..375598c --- /dev/null +++ b/Platform/NXP/LX2160aRdbPkg/AcpiTablesInclude/PlatformAcpiDsdtLib/RawDsdtGenerator.c @@ -0,0 +1,146 @@ +/** @file + Raw DSDT Table Generator + + Copyright 2020 NXP + Copyright 2020 Puresoftware Ltd. + + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include + +// Module specific include files. +#include +#include +#include +#include +#include + +#include "PlatformAcpiLib.h" + +/** Construct the ACPI table using the ACPI table data provided. + + This function invokes the Configuration Manager protocol interface + to get the required hardware information for generating the ACPI + table. + + If this function allocates any resources then they must be freed + in the FreeXXXXTableResources function. + + @param [in] This Pointer to the table generator. + @param [in] AcpiTableInfo Pointer to the ACPI Table Info. + @param [in] CfgMgrProtocol Pointer to the Configuration Manager + Protocol Interface. + @param [out] Table Pointer to the constructed ACPI Table. + + @retval EFI_SUCCESS Table generated successfully. + @retval EFI_INVALID_PARAMETER A parameter is invalid. +**/ +STATIC +EFI_STATUS +EFIAPI +BuildRawDsdtTable ( + IN CONST ACPI_TABLE_GENERATOR * CONST This, + IN CONST CM_STD_OBJ_ACPI_TABLE_INFO * CONST AcpiTableInfo, + IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProtocol, + OUT EFI_ACPI_DESCRIPTION_HEADER ** CONST Table + ) +{ + ASSERT (This != NULL); + ASSERT (AcpiTableInfo != NULL); + ASSERT (CfgMgrProtocol != NULL); + ASSERT (Table != NULL); + ASSERT (AcpiTableInfo->TableGeneratorId == This->GeneratorID); + + if (AcpiTableInfo->AcpiTableData == NULL) { + // Add the dsdt aml code here, Currently NULL place holder. + *Table = (EFI_ACPI_DESCRIPTION_HEADER *)&dsdt_aml_code; + } + + return EFI_SUCCESS; +} + +/** This macro defines the Raw Generator revision. +*/ +#define DSDT_GENERATOR_REVISION CREATE_REVISION (1, 0) + +/** The interface for the Raw Table Generator. +*/ +STATIC +CONST +ACPI_TABLE_GENERATOR RawDsdtGenerator = { + // Generator ID + CREATE_OEM_ACPI_TABLE_GEN_ID (PlatAcpiTableIdDsdt), + // Generator Description + L"ACPI.OEM.RAW.DSDT.GENERATOR", + // ACPI Table Signature - Unused + 0, + // ACPI Table Revision - Unused + 0, + // Minimum ACPI Table Revision - Unused + 0, + // Creator ID + TABLE_GENERATOR_CREATOR_ID_ARM, + // Creator Revision + DSDT_GENERATOR_REVISION, + // Build Table function + BuildRawDsdtTable, + // No additional resources are allocated by the generator. + // Hence the Free Resource function is not required. + NULL, + // Extended build function not needed + NULL, + // Extended build function not implemented by the generator. + // Hence extended free resource function is not required. + NULL +}; + +/** Register the Generator with the ACPI Table Factory. + + @param [in] ImageHandle The handle to the image. + @param [in] SystemTable Pointer to the System Table. + + @retval EFI_SUCCESS The Generator is registered. + @retval EFI_INVALID_PARAMETER A parameter is invalid. + @retval EFI_ALREADY_STARTED The Generator for the Table ID + is already registered. +**/ +EFI_STATUS +EFIAPI +AcpiDsdtLibConstructor ( + IN CONST EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE * CONST SystemTable + ) +{ + EFI_STATUS Status; + Status = RegisterAcpiTableGenerator (&RawDsdtGenerator); + DEBUG ((DEBUG_INFO, "OEM: Register DSDT Generator. Status = %r\n", Status)); + ASSERT_EFI_ERROR (Status); + return Status; +} + +/** Deregister the Generator from the ACPI Table Factory. + + @param [in] ImageHandle The handle to the image. + @param [in] SystemTable Pointer to the System Table. + + @retval EFI_SUCCESS The Generator is deregistered. + @retval EFI_INVALID_PARAMETER A parameter is invalid. + @retval EFI_NOT_FOUND The Generator is not registered. +**/ +EFI_STATUS +EFIAPI +AcpiDsdtLibDestructor ( + IN CONST EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE * CONST SystemTable + ) +{ + EFI_STATUS Status; + Status = DeregisterAcpiTableGenerator (&RawDsdtGenerator); + DEBUG ((DEBUG_INFO, "OEM: Deregister DSDT Generator. Status = %r\n", Status)); + ASSERT_EFI_ERROR (Status); + return Status; +} diff --git a/Platform/NXP/LX2160aRdbPkg/AcpiTablesInclude/PlatformAcpiLib.h b/Platform/NXP/LX2160aRdbPkg/AcpiTablesInclude/PlatformAcpiLib.h new file mode 100644 index 0000000..058061e --- /dev/null +++ b/Platform/NXP/LX2160aRdbPkg/AcpiTablesInclude/PlatformAcpiLib.h @@ -0,0 +1,23 @@ +/** @file + * Acpi lib headers + * + * Copyright 2020 NXP + * Copyright 2020 Puresoftware Ltd + * + * SPDX-License-Identifier: BSD-2-Clause-Patent + * +**/ + + +#ifndef LX2160ARDB_PLATFORM_ACPI_LIB_H +#define LX2160ARDB_PLATFORM_ACPI_LIB_H + +#include + +/** C array containing the compiled AML template. + These symbols are defined in the auto generated C file + containing the AML bytecode array. +*/ +extern CHAR8 dsdt_aml_code[]; + +#endif diff --git a/Platform/NXP/LX2160aRdbPkg/Include/Platform.h b/Platform/NXP/LX2160aRdbPkg/Include/Platform.h index e11ac37..76a41d4 100644 --- a/Platform/NXP/LX2160aRdbPkg/Include/Platform.h +++ b/Platform/NXP/LX2160aRdbPkg/Include/Platform.h @@ -21,6 +21,10 @@ #define SVR_LX2160A 0x873600 +// PCLK +#define DCFG_BASE 0x1E00000 +#define DCFG_LEN 0x1FFFF + // Gic #define GIC_VERSION 3 #define GICD_BASE 0x6000000 @@ -80,6 +84,8 @@ // Platform specific info needed by Configuration Manager +#define OEM_ACPI_TABLES 1 // OEM defined DSDT + #define CFG_MGR_TABLE_ID SIGNATURE_64 ('L','X','2','1','6','0',' ',' ') #define PLAT_PCI_SEG0_CONFIG_BASE LX2160A_PCI_SEG0_CONFIG_BASE diff --git a/Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.dsc b/Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.dsc index 6ba429d..9d898f2 100644 --- a/Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.dsc +++ b/Platform/NXP/LX2160aRdbPkg/LX2160aRdbPkg.dsc @@ -82,6 +82,7 @@ NULL|DynamicTablesPkg/Library/Acpi/Arm/AcpiMadtLibArm/AcpiMadtLibArm.inf NULL|DynamicTablesPkg/Library/Acpi/Arm/AcpiMcfgLibArm/AcpiMcfgLibArm.inf NULL|DynamicTablesPkg/Library/Acpi/Arm/AcpiSpcrLibArm/AcpiSpcrLibArm.inf + NULL|Platform/NXP/LX2160aRdbPkg/AcpiTablesInclude/PlatformAcpiDsdtLib.inf } !endif -- 2.7.4