public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Pranav Madhu" <pranav.madhu@arm.com>
To: devel@edk2.groups.io
Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>,
	Leif Lindholm <leif@nuviainc.com>
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	[thread overview]
Message-ID: <20210115182648.20938-3-pranav.madhu@arm.com> (raw)
In-Reply-To: <20210115182648.20938-1-pranav.madhu@arm.com>

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 <pranav.madhu@arm.com>
---
 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/SgiPkg/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;
 
+// Arm SGI/RD Product IDs
+enum ARM_RD_PRODUCT_ID {
+  UnknownId = 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/Platform/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 @@
 
 #include <Library/ArmPlatformLib.h>
 #include <Library/BaseLib.h>
+#include <Library/HobLib.h>
 #include <Ppi/ArmMpCoreInfo.h>
 #include <Ppi/SgiPlatformId.h>
 
+#include "SgiPlatform.h"
+
 UINT64 NtFwConfigDtBlob;
 STATIC SGI_NT_FW_CONFIG_INFO_PPI mNtFwConfigDtInfoPpi;
 
@@ -21,6 +24,51 @@ STATIC ARM_CORE_INFO mCoreInfoTable[] = {
   },
 };
 
+STATIC SGI_PRODUCT_ID_LOOKUP SgiProductIdLookup[] = {
+  {
+    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 = sizeof (gPlatformPpiTable);
   *PpiList = 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 = GetFirstGuidHob (&gArmSgiPlatformIdDescriptorGuid);
+  if (SystemIdHob == NULL) {
+    return UnknownId;
+  }
+
+  HobData = (SGI_PLATFORM_DESCRIPTOR *)GET_GUID_HOB_DATA (SystemIdHob);
+
+  for (Idx = 0; Idx < ARRAY_SIZE (SgiProductIdLookup); Idx++) {
+    if ((HobData->PlatformId == SgiProductIdLookup[Idx].PlatformId) &&
+        (HobData->ConfigId == SgiProductIdLookup[Idx].ConfigId) &&
+        (HobData->MultiChipMode == SgiProductIdLookup[Idx].MultiChipMode)) {
+      return SgiProductIdLookup[Idx].ProductId;
+    }
+  }
+
+  return UnknownId;
+}
-- 
2.17.1


  parent reply	other threads:[~2021-01-15 18:27 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-15 18:26 [edk2-platforms][PATCH V1 00/11] Add SMBIOS tables for SGI/RD platforms Pranav Madhu
2021-01-15 18:26 ` [edk2-platforms][PATCH V1 01/11] Platform/ARM/SgiPkg: Define RD-N2 platform id values Pranav Madhu
2021-01-15 18:26 ` Pranav Madhu [this message]
2021-01-15 18:26 ` [edk2-platforms][PATCH V1 03/11] Platform/ARM/SgiPkg: Add Initial SMBIOS support Pranav Madhu
2021-01-15 18:26 ` [edk2-platforms][PATCH V1 04/11] Platform/ARM/SgiPkg: Add SMBIOS Type1 Table Pranav Madhu
2021-01-15 18:26 ` [edk2-platforms][PATCH V1 05/11] Platform/ARM/SgiPkg: Add SMBIOS Type3 Table Pranav Madhu
2021-01-15 18:26 ` [edk2-platforms][PATCH V1 06/11] Platform/ARM/SgiPkg: Add SMBIOS Type4 Table Pranav Madhu
2021-01-15 18:26 ` [edk2-platforms][PATCH V1 07/11] Platform/ARM/SgiPkg: Add SMBIOS Type7 Table Pranav Madhu
2021-01-15 18:26 ` [edk2-platforms][PATCH V1 08/11] Platform/ARM/SgiPkg: Add SMBIOS Type16 Table Pranav Madhu
2021-01-15 18:26 ` [edk2-platforms][PATCH V1 09/11] Platform/ARM/SgiPkg: Add SMBIOS Type17 Table Pranav Madhu
2021-01-15 18:26 ` [edk2-platforms][PATCH V1 10/11] Platform/ARM/SgiPkg: Add SMBIOS Type19 Table Pranav Madhu
2021-01-15 18:26 ` [edk2-platforms][PATCH V1 11/11] Platform/ARM/SgiPkg: Add SMBIOS Type32 Table Pranav Madhu
2021-01-26 14:33 ` [edk2-devel] [edk2-platforms][PATCH V1 00/11] Add SMBIOS tables for SGI/RD platforms Thomas Abraham
2021-01-29  6:29   ` Pranav Madhu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210115182648.20938-3-pranav.madhu@arm.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox