From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web10.67.1610735227181618743 for ; Fri, 15 Jan 2021 10:27:07 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: arm.com, ip: 217.140.110.172, mailfrom: pranav.madhu@arm.com) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D99AAED1; Fri, 15 Jan 2021 10:27:06 -0800 (PST) Received: from usa.arm.com (a074742.blr.arm.com [10.162.16.32]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id AB3F73F719; Fri, 15 Jan 2021 10:27:05 -0800 (PST) From: "Pranav Madhu" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Leif Lindholm Subject: [edk2-platforms][PATCH V1 02/11] Platform/ARM/SgiPkg: Add GetProductId API for SGI/RD Platforms Date: Fri, 15 Jan 2021 23:56:39 +0530 Message-Id: <20210115182648.20938-3-pranav.madhu@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210115182648.20938-1-pranav.madhu@arm.com> References: <20210115182648.20938-1-pranav.madhu@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Add GetProductId API for SGI/RD Platform. The API returns a product id in integer format based on the platform description data. The product id is required for other drivers such as SMBIOS. Signed-off-by: Pranav Madhu --- Platform/ARM/SgiPkg/Include/SgiPlatform.h | 21 +++++ Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLib.c | 83 +++++++++++++= ++++++- 2 files changed, 103 insertions(+), 1 deletion(-) diff --git a/Platform/ARM/SgiPkg/Include/SgiPlatform.h b/Platform/ARM/Sgi= Pkg/Include/SgiPlatform.h index e0bb0b4bbe07..dfcc616fb08b 100644 --- a/Platform/ARM/SgiPkg/Include/SgiPlatform.h +++ b/Platform/ARM/SgiPkg/Include/SgiPlatform.h @@ -72,4 +72,25 @@ typedef struct { UINTN MultiChipMode; } SGI_PLATFORM_DESCRIPTOR; =20 +// Arm SGI/RD Product IDs +enum ARM_RD_PRODUCT_ID { + UnknownId =3D 0, + Sgi575, + RdN1Edge, + RdN1EdgeX2, + RdE1Edge, + RdV1, + RdV1Mc, + RdN2 +}; + +// Arm ProductId look-up table +typedef struct { + UINTN ProductId; + UINTN PlatformId; + UINTN ConfigId; + UINTN MultiChipMode; +} SGI_PRODUCT_ID_LOOKUP; + +UINT8 SgiGetProductId ( VOID ); #endif // __SGI_PLATFORM_H__ diff --git a/Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLib.c b/Plat= form/ARM/SgiPkg/Library/PlatformLib/PlatformLib.c index 9731d7cccede..f2accb7dd098 100644 --- a/Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLib.c +++ b/Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLib.c @@ -1,6 +1,6 @@ /** @file * -* Copyright (c) 2018, ARM Limited. All rights reserved. +* Copyright (c) 2018-2021, ARM Limited. All rights reserved. * * SPDX-License-Identifier: BSD-2-Clause-Patent * @@ -8,9 +8,12 @@ =20 #include #include +#include #include #include =20 +#include "SgiPlatform.h" + UINT64 NtFwConfigDtBlob; STATIC SGI_NT_FW_CONFIG_INFO_PPI mNtFwConfigDtInfoPpi; =20 @@ -21,6 +24,51 @@ STATIC ARM_CORE_INFO mCoreInfoTable[] =3D { }, }; =20 +STATIC SGI_PRODUCT_ID_LOOKUP SgiProductIdLookup[] =3D { + { + Sgi575, + SGI575_PART_NUM, + SGI575_CONF_NUM, + 0 + }, + { + RdN1Edge, + RD_N1E1_EDGE_PART_NUM, + RD_N1_EDGE_CONF_ID, + 0 + }, + { + RdN1EdgeX2, + RD_N1E1_EDGE_PART_NUM, + RD_N1_EDGE_CONF_ID, + 1 + }, + { + RdE1Edge, + RD_N1E1_EDGE_PART_NUM, + RD_E1_EDGE_CONF_ID, + 0 + }, + { + RdV1, + RD_V1_PART_NUM, + RD_V1_CONF_ID, + 0 + }, + { + RdV1Mc, + RD_V1_PART_NUM, + RD_V1_CONF_ID, + 1 + }, + { + RdN2, + RD_N2_PART_NUM, + RD_N2_CONF_ID, + 0 + } +}; + EFI_BOOT_MODE ArmPlatformGetBootMode ( VOID @@ -75,3 +123,36 @@ ArmPlatformGetPlatformPpiList ( *PpiListSize =3D sizeof (gPlatformPpiTable); *PpiList =3D gPlatformPpiTable; } + +/** + Update the product Id by reading platform id descriptor + + @retval Zero Failed identify platform + @retval Others Platform identified, and return ARM_PRODUCT_ID +**/ +UINT8 +SgiGetProductId ( + VOID + ) +{ + VOID *SystemIdHob; + UINT8 Idx; + SGI_PLATFORM_DESCRIPTOR *HobData; + + SystemIdHob =3D GetFirstGuidHob (&gArmSgiPlatformIdDescriptorGuid); + if (SystemIdHob =3D=3D NULL) { + return UnknownId; + } + + HobData =3D (SGI_PLATFORM_DESCRIPTOR *)GET_GUID_HOB_DATA (SystemIdHob)= ; + + for (Idx =3D 0; Idx < ARRAY_SIZE (SgiProductIdLookup); Idx++) { + if ((HobData->PlatformId =3D=3D SgiProductIdLookup[Idx].PlatformId) = && + (HobData->ConfigId =3D=3D SgiProductIdLookup[Idx].ConfigId) && + (HobData->MultiChipMode =3D=3D SgiProductIdLookup[Idx].MultiChip= Mode)) { + return SgiProductIdLookup[Idx].ProductId; + } + } + + return UnknownId; +} --=20 2.17.1