From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oi1-f177.google.com (mail-oi1-f177.google.com [209.85.167.177]) by mx.groups.io with SMTP id smtpd.web11.8996.1624028245788322856 for ; Fri, 18 Jun 2021 07:57:25 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@puresoftware.com header.s=google header.b=OxBm78Lv; spf=pass (domain: puresoftware.com, ip: 209.85.167.177, mailfrom: vikas.singh@puresoftware.com) Received: by mail-oi1-f177.google.com with SMTP id t40so10826040oiw.8 for ; Fri, 18 Jun 2021 07:57:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=puresoftware.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=pTJlx0mNs5wt3NR3161ofwtAYc21YN0gk9UczsTvGO0=; b=OxBm78LvAaXQvci70Trh8L6M13Sow4XcbFRfRq68pS18mRdwRfUL+yG68R6azkxe30 /FM3EKUf6E9u8hGEp7qY49sAK940/dk1rUHG5WUKpzDKrbTtlWrHx0Rt0QqMm/KY2gIi 29vLtoAGJQ2RA37mN253THYJCkOSWA/2/JAd0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=pTJlx0mNs5wt3NR3161ofwtAYc21YN0gk9UczsTvGO0=; b=VrAjfkEf9sbOJPTEYf0m6ohriJnWD+k4Fjy+pBLN/vAE1Fh9Mv9OlAuslxEe0P+MiO NgpzeW9huAm5ud5G7z1XDi4RE4H+OeZNGUGuWBRvxcwYiwqI5EwSjpksP4r/AJ5fBg+N wtWL8QTvT56AKbx3DzLziBnwkQuEptzeleiWF4YleI4BBstvjYvljFa+zCTZn1iZJemg gtgvbJIhWMAwrbGwpOlOAQytuBWw/xJc8rcIeKu40jUrRmN8R9TeSzli2OiuZ4XUn0K8 gVQ/2/g0+yQmd3yQlmLLLNDYjK6xINzcixYy9ERs71OpP0YCMfXj8PNNfNL187AjZBWG X/DQ== X-Gm-Message-State: AOAM531MJ1fAWfg4b+xA3+bgozga27tqfto7SXUhvZa7XljfIYp10NAr tCq5YhueIMzgGfjmwbJilmBePpVvKHHLUG/nTINUXA== X-Google-Smtp-Source: ABdhPJz5W2MPc2bHrz0oJ+ukWqqKkHfSTsePvUiq3vvBF+k2Jug3jXavFn5uJMofiG9Q4HTJjcaykpVXa4mfx9niAvg= X-Received: by 2002:aca:4c10:: with SMTP id z16mr14598076oia.123.1624028245076; Fri, 18 Jun 2021 07:57:25 -0700 (PDT) MIME-Version: 1.0 References: <20210611155200.15535-1-vikas.singh@puresoftware.com> <20210611155200.15535-5-vikas.singh@puresoftware.com> <20210614213747.dw7c6yt2yrukctiw@leviathan> In-Reply-To: <20210614213747.dw7c6yt2yrukctiw@leviathan> From: "Vikas Singh" Date: Fri, 18 Jun 2021 20:26:58 +0530 Message-ID: Subject: Re: [PATCH V1 4/4] Platform/NXP/LS1046aFrwyPkg: Add OEM specific DSDT generator To: Leif Lindholm Cc: devel@edk2.groups.io, Sami Mujawar , meenakshi.aggarwal@nxp.com, Samer El-Haj-Mahmoud , Varun Sethi , Arokia Samy , Kuldip Dwivedi , ard.biesheuvel@arm.com, Vikas Singh , Sunny Wang Content-Type: text/plain; charset="UTF-8" On Tue, Jun 15, 2021 at 3:07 AM Leif Lindholm wrote: > > On Fri, Jun 11, 2021 at 21:22:00 +0530, Vikas Singh wrote: > > This patch adds platform specific DSDT generator > > and Clk dsdt properties for LS1046AFRWY platform. > > > > Signed-off-by: Vikas Singh > > --- > > Platform/NXP/LS1046aFrwyPkg/AcpiTablesInclude/Dsdt/Clk.asl | 60 +++++++++ > > Platform/NXP/LS1046aFrwyPkg/AcpiTablesInclude/Dsdt/Dsdt.asl | 15 +++ > > Platform/NXP/LS1046aFrwyPkg/AcpiTablesInclude/PlatformAcpiDsdtLib.inf | 39 ++++++ > > Platform/NXP/LS1046aFrwyPkg/AcpiTablesInclude/PlatformAcpiDsdtLib/RawDsdtGenerator.c | 138 ++++++++++++++++++++ > > Platform/NXP/LS1046aFrwyPkg/AcpiTablesInclude/PlatformAcpiLib.h | 23 ++++ > > Platform/NXP/LS1046aFrwyPkg/Include/Platform.h | 6 +- > > Platform/NXP/LS1046aFrwyPkg/LS1046aFrwyPkg.dsc | 1 + > > 7 files changed, 281 insertions(+), 1 deletion(-) > > > > diff --git a/Platform/NXP/LS1046aFrwyPkg/AcpiTablesInclude/Dsdt/Clk.asl b/Platform/NXP/LS1046aFrwyPkg/AcpiTablesInclude/Dsdt/Clk.asl > > new file mode 100644 > > index 0000000000..58541c3019 > > --- /dev/null > > +++ b/Platform/NXP/LS1046aFrwyPkg/AcpiTablesInclude/Dsdt/Clk.asl > > @@ -0,0 +1,60 @@ > > +/** @file > > +* DSDT : Dynamic Clock ACPI Information > > +* > > +* Copyright 2021 NXP > > +* Copyright 2021 Puresoftware Ltd. > > +* > > +* SPDX-License-Identifier: BSD-2-Clause-Patent > > +* > > +**/ > > + > > +Scope(_SB) > > +{ > > + Device(PCLK) { > > + Name(_HID, "NXP0017") > > + Name(CLK, 0) // Maximum Platform Clock (Hz) > > + Name(CCLK, 0) // Maximum CPU Core Clock (MHz) > > + Name(AVBL, 0) > > + OperationRegion(RCWS, SystemMemory, DCFG_BASE, DCFG_LEN) > > + Method(_REG,2) { > > + if (Arg0 == "RCWS") { > > + Store(Arg1, AVBL) > > + } > > + } > > + Field (RCWS, ByteAcc, NoLock, Preserve) { > > + /* The below table provides the func of diff bits in 512 bits RCW data: > > + SYS_PLL_CFG : 0-1 bits > > + SYS_PLL_RAT : 2-6 bits > > + SYSCLK_FREQ : 472-481 bits etc. > > + Refer LS1046ARM for more info. > > + For LS1046 RCWSRs are read as RCW[0:31] . > > + */ > > + offset(0x100), > > + RESV, 1, > > + PRAT, 5, > > + PCFG, 2, > > + offset(0x103), > > + CPRT, 6, // Cluster Group PLL Multiplier ratio > > + offset(0x13B), > > + HFRQ, 8, // Higher 8 bits of SYSCLK_FREQ > > + RESX, 6, > > + LFRQ, 2 // Lower bits of SYSCLK_FREQ > > + } > > + > > + Method(_INI, 0, NotSerialized) { > > + /* Calculating Platform Clock */ > > + Local0 = (HFRQ<<2 | LFRQ) // Concatinating LFRQ at end of HFRQ > > + Multiply(Local0, 500000, Local0) > > + Multiply(Local0, PRAT, Local0) > > + Divide(Local0, 3, , Local0) > > + Store(Local0, CLK) > > + > > + /* Calculating Maximum Core Clock */ > > + Local0 = (HFRQ<<2 | LFRQ) // Concatinating LFRQ at end of HFRQ > > + Multiply(Local0, 500000, Local0) > > + Divide(Local0, 3, , Local0) > > + Divide(Local0, 1000000, , Local0) //Just the MHz part of SYSCLK. > > + Multiply(Local0, CPRT, CCLK) // PLL_Ratio * SYSCLK, Max freq of cluster > > + } > > + } // end of device PCLK > > +} > > diff --git a/Platform/NXP/LS1046aFrwyPkg/AcpiTablesInclude/Dsdt/Dsdt.asl b/Platform/NXP/LS1046aFrwyPkg/AcpiTablesInclude/Dsdt/Dsdt.asl > > new file mode 100644 > > index 0000000000..19f3f1c0e8 > > --- /dev/null > > +++ b/Platform/NXP/LS1046aFrwyPkg/AcpiTablesInclude/Dsdt/Dsdt.asl > > @@ -0,0 +1,15 @@ > > +/** @file > > + Differentiated System Description Table Fields (DSDT) > > + > > + Copyright 2021 NXP > > + Copyright 2021 Puresoftware Ltd. > > + > > + SPDX-License-Identifier: BSD-2-Clause-Patent > > + > > +**/ > > + > > +#include "Platform.h" > > + > > +DefinitionBlock("DsdtTable.aml", "DSDT", 2, "NXP ", "LS1046 ", EFI_ACPI_ARM_OEM_REVISION) { > > + include ("Clk.asl") > > +} > > diff --git a/Platform/NXP/LS1046aFrwyPkg/AcpiTablesInclude/PlatformAcpiDsdtLib.inf b/Platform/NXP/LS1046aFrwyPkg/AcpiTablesInclude/PlatformAcpiDsdtLib.inf > > new file mode 100644 > > index 0000000000..ed5f9dd442 > > --- /dev/null > > +++ b/Platform/NXP/LS1046aFrwyPkg/AcpiTablesInclude/PlatformAcpiDsdtLib.inf > > @@ -0,0 +1,39 @@ > > +## @file > > +# Raw Table Generator > > +# > > +# Copyright 2021 NXP > > +# Copyright 2021 Puresoftware Ltd > > +# > > +# SPDX-License-Identifier: BSD-2-Clause-Patent > > +## > > + > > +[Defines] > > + INF_VERSION = 0x00010019 > > + BASE_NAME = PlatformAcpiDsdtLib > > + FILE_GUID = A97F70AC-3BB4-4596-B4D2-9F948EC12D17 > > + 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/LS1046aFrwyPkg/LS1046aFrwyPkg.dec > > + Platform/NXP/ConfigurationManagerPkg/ConfigurationManagerPkg.dec > > + > > +[LibraryClasses] > > + BaseLib > > + > > +[Pcd] > > + > > +[Protocols] > > + > > +[Guids] > > diff --git a/Platform/NXP/LS1046aFrwyPkg/AcpiTablesInclude/PlatformAcpiDsdtLib/RawDsdtGenerator.c b/Platform/NXP/LS1046aFrwyPkg/AcpiTablesInclude/PlatformAcpiDsdtLib/RawDsdtGenerator.c > > new file mode 100644 > > index 0000000000..7d886396ca > > --- /dev/null > > +++ b/Platform/NXP/LS1046aFrwyPkg/AcpiTablesInclude/PlatformAcpiDsdtLib/RawDsdtGenerator.c > > @@ -0,0 +1,138 @@ > > +/** @file > > + Raw DSDT Table Generator > > + > > + Copyright 2021 NXP > > + Copyright 2021 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. > > + *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/LS1046aFrwyPkg/AcpiTablesInclude/PlatformAcpiLib.h b/Platform/NXP/LS1046aFrwyPkg/AcpiTablesInclude/PlatformAcpiLib.h > > new file mode 100644 > > index 0000000000..e5f907a7d4 > > --- /dev/null > > +++ b/Platform/NXP/LS1046aFrwyPkg/AcpiTablesInclude/PlatformAcpiLib.h > > @@ -0,0 +1,23 @@ > > +/** @file > > + * Acpi lib headers > > + * > > + * Copyright 2021 NXP > > + * Copyright 2021 Puresoftware Ltd > > + * > > + * SPDX-License-Identifier: BSD-2-Clause-Patent > > + * > > +**/ > > + > > + > > +#ifndef LS1046AFRWY_PLATFORM_ACPI_LIB_H > > +#define LS1046AFRWY_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/LS1046aFrwyPkg/Include/Platform.h b/Platform/NXP/LS1046aFrwyPkg/Include/Platform.h > > index 19e879ec6d..b21e875f20 100644 > > --- a/Platform/NXP/LS1046aFrwyPkg/Include/Platform.h > > +++ b/Platform/NXP/LS1046aFrwyPkg/Include/Platform.h > > @@ -20,6 +20,10 @@ > > #define SVR_MAJOR(svr) (((svr) >> 4) & 0xf) > > #define SVR_MINOR(svr) (((svr) >> 0) & 0xf) > > > > +// PCLK : Dynamic Clock > > +#define DCFG_BASE 0x1EE0000 /* Device configuration data Base Address */ > > +#define DCFG_LEN 0xFFF /* Device configuration data length */ > > + > > > > // Gic > > #define GIC_VERSION 2 > > #define GICD_BASE 0x1410000 > > @@ -62,7 +66,7 @@ > > #define CFG_MGR_TABLE_ID SIGNATURE_64 ('L','S','1','0','4','6',' ',' ') > > > > // Specify the OEM defined tables > > -#define OEM_ACPI_TABLES 0 > > +#define OEM_ACPI_TABLES 1 // Added DSDT > > Drop the comment. > With that: > Reviewed-by: Leif Lindholm > Ok, I will add "Reviewed-by: Leif Lindholm " as part of the commit body. > > > > > #define PLAT_PCI_SEG0 LS1046A_PCI_SEG0 > > #define PLAT_PCI_SEG1_CONFIG_BASE LS1046A_PCI_SEG1_CONFIG_BASE > > diff --git a/Platform/NXP/LS1046aFrwyPkg/LS1046aFrwyPkg.dsc b/Platform/NXP/LS1046aFrwyPkg/LS1046aFrwyPkg.dsc > > index 20111e6037..7041d15da5 100755 > > --- a/Platform/NXP/LS1046aFrwyPkg/LS1046aFrwyPkg.dsc > > +++ b/Platform/NXP/LS1046aFrwyPkg/LS1046aFrwyPkg.dsc > > @@ -65,6 +65,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/LS1046aFrwyPkg/AcpiTablesInclude/PlatformAcpiDsdtLib.inf > > } > > !endif > > > > -- > > 2.25.1 > >