From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f66.google.com (mail-wm1-f66.google.com [209.85.128.66]) by mx.groups.io with SMTP id smtpd.web09.9309.1581424703046939875 for ; Tue, 11 Feb 2020 04:38:23 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@nuviainc-com.20150623.gappssmtp.com header.s=20150623 header.b=AxBO7W7Y; spf=pass (domain: nuviainc.com, ip: 209.85.128.66, mailfrom: leif@nuviainc.com) Received: by mail-wm1-f66.google.com with SMTP id b17so3386913wmb.0 for ; Tue, 11 Feb 2020 04:38:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuviainc-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=WLURpKN4kqXuESoU2hwHqXiLLPS4tfODB3IfWCb0ENU=; b=AxBO7W7YIoCoGrpi2bz6e7HG3B9g4RYNtsXFRLJyLPVjl9T7/hTPNrZtwDMI/18Usy UyptGfC1V8CdeXZQHANj0xSSktsvIylRjy35/v1Ldx6W1WTxq9nNZACNP/MsBgmRsrFE 65i9F7yklo/j2PvxYJrtpC7BHMEqwYUwp/mAd5CrCoqon2Zq+rmGHX+I32qiAUqkuVF5 Oq16CZjGtupAwo2iIanWGD24Cr9vDJzgyXyGXMsr6QxxBirtrQbseSGgp5FFP8nSnE/D HBIMpZzH0hvfsgVnJOm+M1isUec50k0BwnPNgFWR2Jc+Rl4sTfuhy5mMB9mAoKO8qEOG TKlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=WLURpKN4kqXuESoU2hwHqXiLLPS4tfODB3IfWCb0ENU=; b=pHLVSEtzQGP8+5z0sGy4ZFKppMg0X8idp5EdojvVCSw+Sja+wnROkf3Jj0WrTkdl1D hiqo5Z+np72Epv9a60OciJQQN4HJUl4Zl0pnEku38LsLtdNbyGL8IT34HiYSnp6HyDT6 /wvQLBJj/tmi4uD3yjmSb4cGUO+WiMzvK3VTrIsBc5ELPSWzOaCoHFbzxJ43nWDewPrZ txv8mCGxrHWeLJ+kw8a8x1y5fksKSaa5W3boafz0Hel1bHFr/aAn0GTR0FOsdzLi0Txl vK3EctJOnalJasxuMSNFet0gMmSJAeOGGLl6BGnl3pCoOeW8rxe7VlVJT7k1+3eutl7c jU/Q== X-Gm-Message-State: APjAAAX6pSBZl/4XYYkuAeL7wiXTvjA3SfAoVkE0gFQzOIqVFDBIxh9e TRZtfzYFm7Gd+gOpEBUxQ1RUUQ== X-Google-Smtp-Source: APXvYqyDd2xo7n3F6rc3O178m8mpkHsodB0tfdd2ohmfBW9QBbplbEHUAF9xBC49cIZ/NSWT4W+9yg== X-Received: by 2002:a1c:1bcd:: with SMTP id b196mr5513789wmb.54.1581424701381; Tue, 11 Feb 2020 04:38:21 -0800 (PST) Return-Path: Received: from bivouac.eciton.net (bivouac.eciton.net. [2a00:1098:0:86:1000:23:0:2]) by smtp.gmail.com with ESMTPSA id g7sm5157064wrq.21.2020.02.11.04.38.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Feb 2020 04:38:20 -0800 (PST) Date: Tue, 11 Feb 2020 12:38:19 +0000 From: "Leif Lindholm" To: Pankaj Bansal Cc: Meenakshi Aggarwal , Michael D Kinney , Varun Sethi , devel@edk2.groups.io Subject: Re: [PATCH 12/19] Silicon/NXP/LS1043A: Add SocLib Message-ID: <20200211123819.GV23627@bivouac.eciton.net> References: <20200207124328.8723-1-pankaj.bansal@nxp.com> <20200207124328.8723-13-pankaj.bansal@nxp.com> MIME-Version: 1.0 In-Reply-To: <20200207124328.8723-13-pankaj.bansal@nxp.com> User-Agent: Mutt/1.10.1 (2018-07-13) Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Fri, Feb 07, 2020 at 18:13:21 +0530, Pankaj Bansal wrote: > Add SocLib for LS1043A as per new directory structure OK, now I'm confused again. Separating the Chassis library from the SoC library seemed sensible. But now we're merging them together again, only the other way around? Can you explain why? > Signed-off-by: Pankaj Bansal > --- > Silicon/NXP/Chassis2/LS1043A/Include/Soc.h | 56 +++++++++++++ > Silicon/NXP/Chassis2/LS1043A/LS1043A.dec | 23 ++++++ > Silicon/NXP/Chassis2/LS1043A/LS1043A.dsc.inc | 30 +++++++ > .../Chassis2/LS1043A/Library/SocLib/SocLib.c | 73 +++++++++++++++++ > .../LS1043A/Library/SocLib/SocLib.inf | 32 ++++++++ > Silicon/NXP/Include/Library/SocLib.h | 81 +++++++++++++++++++ > Silicon/NXP/Include/Ppi/NxpPlatformGetClock.h | 47 +++++++++++ > Silicon/NXP/NxpQoriqLs.dec | 3 + > 8 files changed, 345 insertions(+) > create mode 100644 Silicon/NXP/Chassis2/LS1043A/Include/Soc.h > create mode 100644 Silicon/NXP/Chassis2/LS1043A/LS1043A.dec > create mode 100644 Silicon/NXP/Chassis2/LS1043A/LS1043A.dsc.inc > create mode 100644 Silicon/NXP/Chassis2/LS1043A/Library/SocLib/SocLib.c > create mode 100644 Silicon/NXP/Chassis2/LS1043A/Library/SocLib/SocLib.inf > create mode 100644 Silicon/NXP/Include/Library/SocLib.h > create mode 100644 Silicon/NXP/Include/Ppi/NxpPlatformGetClock.h > > diff --git a/Silicon/NXP/Chassis2/LS1043A/Include/Soc.h b/Silicon/NXP/Chassis2/LS1043A/Include/Soc.h > new file mode 100644 > index 0000000000..3b11b2b126 > --- /dev/null > +++ b/Silicon/NXP/Chassis2/LS1043A/Include/Soc.h > @@ -0,0 +1,56 @@ > +/** @file > + > + Copyright 2020 NXP > + > + SPDX-License-Identifier: BSD-2-Clause-Patent > + > +**/ > +#ifndef __SOC_H__ > +#define __SOC_H__ Please drop leading __ from include guards. > + > +#include > + > +/** > + Soc Memory Map > +**/ > +#define LS1043A_DRAM0_PHYS_ADDRESS 0x80000000 > +#define LS1043A_DRAM0_SIZE SIZE_2GB > +#define LS1043A_DRAM1_PHYS_ADDRESS 0x880000000 > +#define LS1043A_DRAM1_SIZE 0x780000000 // 30 GB > + > +#define LS1043A_CCSR_PHYS_ADDRESS 0x1000000 > +#define LS1043A_CCSR_SIZE 0xF000000 > + > +#define LS1043A_IFC0_PHYS_ADDRESS 0x60000000 > +#define LS1043A_IFC0_SIZE SIZE_512MB > +#define LS1043A_IFC1_PHYS_ADDRESS 0x620000000 > +#define LS1043A_IFC1_SIZE 0xE0000000 // 3.5 GB > + > +#define LS1043A_QSPI_PHYS_ADDRESS 0x40000000 > +#define LS1043A_QSPI_SIZE SIZE_512MB > + > +#define LS1043A_QMAN_SW_PORTAL_PHYS_ADDRESS 0x500000000 > +#define LS1043A_QMAN_SW_PORTAL_SIZE SIZE_128MB > +#define LS1043A_BMAN_SW_PORTAL_PHYS_ADDRESS 0x508000000 > +#define LS1043A_BMAN_SW_PORTAL_SIZE SIZE_128MB > + > +#define LS1043A_PCI0_PHYS_ADDRESS 0x4000000000 > +#define LS1043A_PCI1_PHYS_ADDRESS 0x4800000000 > +#define LS1043A_PCI2_PHYS_ADDRESS 0x5000000000 > +#define LS1043A_PCI_SIZE SIZE_32GB > + > +#define LS1043A_I2C0_PHYS_ADDRESS 0x2180000 > +#define LS1043A_I2C_SIZE 0x10000 > +#define LS1043A_I2C_NUM_CONTROLLERS 4 > + > +#define LS1043A_DCFG_ADDRESS NXP_LAYERSCAPE_CHASSIS2_DCFG_ADDRESS > + > +/** > + Reset Control Word (RCW) Bits > +**/ > +#define SYS_PLL_RAT(x) (((x) & 0x7c) >> 2) // Bits 2-6 RAT is an unknown term, what is it short for? > + > +typedef NXP_LAYERSCAPE_CHASSIS2_DEVICE_CONFIG LS1043A_DEVICE_CONFIG; > + > +#endif > + > diff --git a/Silicon/NXP/Chassis2/LS1043A/LS1043A.dec b/Silicon/NXP/Chassis2/LS1043A/LS1043A.dec > new file mode 100644 > index 0000000000..106b118188 > --- /dev/null > +++ b/Silicon/NXP/Chassis2/LS1043A/LS1043A.dec > @@ -0,0 +1,23 @@ > +#/** @file > +# NXP Layerscape processor package. > +# > +# Copyright 2020 NXP > +# > +# SPDX-License-Identifier: BSD-2-Clause-Patent > +# > +#**/ > + > +[Defines] > + DEC_SPECIFICATION = 1.27 > + PACKAGE_VERSION = 0.1 > + > +################################################################################ > +# > +# Include Section - list of Include Paths that are provided by this package. > +# Comments are used for Keywords and Module Types. > +# > +# > +################################################################################ > +[Includes.common] > + Include # Root include for the package *If* we are merging Soc and Chassis again - why do we need separate include paths? > + > diff --git a/Silicon/NXP/Chassis2/LS1043A/LS1043A.dsc.inc b/Silicon/NXP/Chassis2/LS1043A/LS1043A.dsc.inc > new file mode 100644 > index 0000000000..4511203443 > --- /dev/null > +++ b/Silicon/NXP/Chassis2/LS1043A/LS1043A.dsc.inc > @@ -0,0 +1,30 @@ > +# @file > +# > +# Copyright 2020 NXP > +# > +# SPDX-License-Identifier: BSD-2-Clause-Patent > +# > +# > + > +[LibraryClasses.common] > + SocLib|Silicon/NXP/Chassis2/LS1043A/Library/SocLib/SocLib.inf > + > +################################################################################ > +# > +# Pcd Section - list of all EDK II PCD Entries defined by this Platform > +# > +################################################################################ > +[PcdsFeatureFlag.common] > + gNxpQoriqLsTokenSpaceGuid.PcdDcfgBigEndian|TRUE > + > +[PcdsFixedAtBuild.common] > +## ns16550 Serial Terminal > + gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterBase|0x21c0500 > + gArmPlatformTokenSpaceGuid.PcdCoreCount|4 > + > +[PcdsDynamicDefault.common] > + # > + # ARM General Interrupt Controller > + gArmTokenSpaceGuid.PcdGicDistributorBase|0x1401000 > + gArmTokenSpaceGuid.PcdGicInterruptInterfaceBase|0x1402000 > + > diff --git a/Silicon/NXP/Chassis2/LS1043A/Library/SocLib/SocLib.c b/Silicon/NXP/Chassis2/LS1043A/Library/SocLib/SocLib.c > new file mode 100644 > index 0000000000..2a08ad87db > --- /dev/null > +++ b/Silicon/NXP/Chassis2/LS1043A/Library/SocLib/SocLib.c > @@ -0,0 +1,73 @@ > +/** @file > + > + Copyright 2017-2020 NXP > + > + SPDX-License-Identifier: BSD-2-Clause-Patent > + **/ > +#include > +#include > + > +/** > + Return the input clock frequency to an IP Module. > + This function reads the RCW bits and calculates the PLL multipler/divider values to be applied > + to various IP modules. > + If a module is disabled or doesn't exist on platform, then return zero. > + > + @param[in] BaseClock Base clock to which PLL multipler/divider values is to be applied. > + @param[in] ClockType IP modules whose clock value is to be retrieved > + @param[in] Args Variable Args lists that is parsed based on the ClockType > + e.g. if there are multiple modules of same type then this value tells the > + instance of module for which clock is to be retrieved. > + (e.g. if there are four i2c controllers in SOC, then this value can be 1, 2, 3, 4) > + for IP modules which have only single instance in SOC (e.g. one QSPI controller) > + this value can be null (i.e. no arg) Please wrap long lines (throughout). > + > + @return > 0 Return the input clock frequency to an IP Module > + 0 either IP module doesn't exist in SOC > + or IP module instance doesn't exist in SOC > + or IP module instance is disabled. i.e. no input clock is provided to IP module instance. > +**/ > +UINT64 > +SocGetClock ( > + IN UINT64 BaseClock, > + IN UINT32 ClockType, > + IN VA_LIST Args > + ) > +{ > + LS1043A_DEVICE_CONFIG *Dcfg; > + UINT32 RcwSr; > + UINT64 ReturnValue; > + > + ReturnValue = 0; > + Dcfg = (LS1043A_DEVICE_CONFIG *)LS1043A_DCFG_ADDRESS; Extra space in cast. > + > + switch (ClockType) { > + case NXP_UART_CLOCK: > + case NXP_I2C_CLOCK: > + RcwSr = DcfgRead32 ((UINTN)&Dcfg->RcwSr[0]); > + ReturnValue = BaseClock * SYS_PLL_RAT (RcwSr); > + break; > + default: > + break; > + } > + > + return ReturnValue; > +} > + > +/** > + Function to initialize SoC specific constructs > + CPU Info > + SoC Personality > + Board Personality > + RCW prints > + **/ > +VOID > +SocInit ( > + VOID > + ) > +{ > + ChassisInit (); > + > + return; > +} > + > diff --git a/Silicon/NXP/Chassis2/LS1043A/Library/SocLib/SocLib.inf b/Silicon/NXP/Chassis2/LS1043A/Library/SocLib/SocLib.inf > new file mode 100644 > index 0000000000..c9a4fbc01f > --- /dev/null > +++ b/Silicon/NXP/Chassis2/LS1043A/Library/SocLib/SocLib.inf > @@ -0,0 +1,32 @@ > +#@file > +# > +# Component description file for SocLib module > +# > +# Copyright 2017-2020 NXP > +# > +# SPDX-License-Identifier: BSD-2-Clause-Patent > +# > + > + > +[Defines] > + INF_VERSION = 0x0001000A > + BASE_NAME = SocLib > + FILE_GUID = 9b046753-2b4f-42d8-bfb3-468892fe17d4 > + MODULE_TYPE = BASE > + VERSION_STRING = 1.0 > + LIBRARY_CLASS = SocLib > + > +[Sources.common] > + SocLib.c > + > +[Packages] > + MdePkg/MdePkg.dec > + ArmPkg/ArmPkg.dec > + ArmPlatformPkg/ArmPlatformPkg.dec > + Silicon/NXP/NxpQoriqLs.dec > + Silicon/NXP/Chassis2/Chassis2.dec > + Silicon/NXP/Chassis2/LS1043A/LS1043A.dec Please sort packages alphabetically. > + > +[LibraryClasses] > + ChassisLib > + > diff --git a/Silicon/NXP/Include/Library/SocLib.h b/Silicon/NXP/Include/Library/SocLib.h > new file mode 100644 > index 0000000000..3def396171 > --- /dev/null > +++ b/Silicon/NXP/Include/Library/SocLib.h > @@ -0,0 +1,81 @@ > +/** @file > + > + Copyright 2020 NXP > + SPDX-License-Identifier: BSD-2-Clause-Patent > + > +**/ > + > +#ifndef __SOC_LIB_H__ > +#define __SOC_LIB_H__ Please drop leading __ from header guards. > + > +#include > +#include > +#include > +#include > + > +/** > + Return the number of cores present in SOC > + > + This function returns the number of cores present in SOC. > + and also their position (cluster number and core number) in the form of ARM_CORE_INFO array > + and NxpCoreTable array. > + NxpCoreTable array can be used to find out the type of core. it's values are of type > + TP_ITYPE_VERSION_*. > + The number of cores present in SOC can vary depending on which flavour of SOC is being used. > + This function doesn't allocte any memory and must be provided memory for array of ARM_CORE_INFO > + and NxpCoreTable for maximum number of cores the SOC can have. > + > + @param[out] NxpCoreTable array of UINT8 for maximum number of cores the SOC can have. > + @param[out] ArmCoreTable array of ARM_CORE_INFO for maximum number of cores the SOC can have. > + @param[in] ArmCoreTableSize Size of ArmCoreTable > + > + @return Actual number of cores present in SOC. After calling this function only the returned value number of > + entries in ArmCoreTable are valid entries. > +**/ > +UINTN > +SocGetMpCoreInfo ( > + OUT UINT8 *NxpCoreTable, > + OUT ARM_CORE_INFO *ArmCoreTable, > + IN UINTN ArmCoreTableSize > + ); > + > +/** > + Return the input clock frequency to an IP Module. > + This function reads the RCW bits and calculates the PLL multipler/divider values to be applied > + to various IP modules. > + If a module is disabled or doesn't exist on platform, then return zero. > + > + @param[in] BaseClock Base clock to which PLL multipler/divider values is to be applied. > + @param[in] ClockType IP modules whose clock value is to be retrieved > + @param[in] Args Variable Args lists that is parsed based on the ClockType > + e.g. if there are multiple modules of same type then this value tells the > + instance of module for which clock is to be retrieved. > + (e.g. if there are four i2c controllers in SOC, then this value can be 1, 2, 3, 4) > + for IP modules which have only single instance in SOC (e.g. one QSPI controller) > + this value can be null (i.e. no arg) > + > + @return > 0 Return the input clock frequency to an IP Module > + 0 either IP module doesn't exist in SOC > + or IP module instance doesn't exist in SOC > + or IP module instance is disabled. i.e. no input clock is provided to IP module instance. > +**/ > +UINT64 > +SocGetClock ( > + IN UINT64 BaseClock, > + IN UINT32 ClockType, > + IN VA_LIST Args > + ); > + > +/** > + Function to initialize SoC specific constructs > + CPU Info > + SoC Personality > + Board Personality > + RCW prints > + **/ > +VOID > +SocInit ( > + VOID > + ); > + > +#endif // __SOC_LIB_H__ > diff --git a/Silicon/NXP/Include/Ppi/NxpPlatformGetClock.h b/Silicon/NXP/Include/Ppi/NxpPlatformGetClock.h > new file mode 100644 > index 0000000000..2c8c97987d > --- /dev/null > +++ b/Silicon/NXP/Include/Ppi/NxpPlatformGetClock.h > @@ -0,0 +1,47 @@ > +/** @file > +* > +* Copyright 2020 NXP > +* > +* SPDX-License-Identifier: BSD-2-Clause-Patent > +* > +**/ > + > +#ifndef __NXP_PLATFORM_PPI_H__ > +#define __NXP_PLATFORM_PPI_H__ Please drop leading __ from header guards. > + > +#include > + > +#define NXP_PLATFORM_GET_CLOCK_PPI_GUID \ > + { 0x6847cc74, 0xe9ec, 0x4f8f, {0xa2, 0x9d, 0xab, 0x44, 0xe7, 0x54, 0xa8, 0xfc} } > + > +typedef enum _NXP_IP_CLOCK { > + NXP_SYSTEM_CLOCK, > + NXP_UART_CLOCK, > + NXP_I2C_CLOCK > +} NXP_IP_CLOCK; > + > +/** > + Get the clocks supplied by Platform(Board) to NXP Layerscape SOC > + > + The core can be of type ARM or PowerPC or Hardware Accelerator. > + If the core is enabled and of type ARM EFI_SUCCESS is returned and a code for type of ARM core is returned > + > + @param[in] ClockType Type of clock > + @param[in] ... Variable argument list which is parsed based on ClockType > + > + @return Actual Clock Frequency. return value 0 should be interpreted as clock not provided by Board. Funky alignment of argument/return descriptions. / Leif > +**/ > +typedef > +UINT64 > +(EFIAPI * NXP_PLATFORM_GET_CLOCK)( > + IN UINT32 ClockType, > + ... > + ); > + > +typedef struct { > + NXP_PLATFORM_GET_CLOCK PlatformGetClock; > +} NXP_PLATFORM_GET_CLOCK_PPI; > + > +extern EFI_GUID gNxpPlatformGetClockPpiGuid; > + > +#endif > diff --git a/Silicon/NXP/NxpQoriqLs.dec b/Silicon/NXP/NxpQoriqLs.dec > index d8989657e6..4f14cc9848 100644 > --- a/Silicon/NXP/NxpQoriqLs.dec > +++ b/Silicon/NXP/NxpQoriqLs.dec > @@ -14,6 +14,9 @@ > Include > > [LibraryClasses] > + ## @libraryclass Provides Soc specific functions to other modules > + SocLib|Include/Library/SocLib.h > + > ## @libraryclass Provides Chassis specific functions to other modules > ChassisLib|Include/Library/ChassisLib.h > > -- > 2.17.1 >