public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Nhi Pham via groups.io" <nhi=os.amperecomputing.com@groups.io>
To: devel@edk2.groups.io
Cc: quic_llindhol@quicinc.com, chuong@os.amperecomputing.com,
	rebecca@os.amperecomputing.com, nhi@os.amperecomputing.com
Subject: [edk2-devel] [edk2-platforms][PATCH 4/5] JadePkg: Add PlatformBmcReadyLib to support BMC ready check
Date: Thu,  1 Aug 2024 16:36:17 +0700	[thread overview]
Message-ID: <20240801093618.191274-5-nhi@os.amperecomputing.com> (raw)
In-Reply-To: <20240801093618.191274-1-nhi@os.amperecomputing.com>

This adds the PlatformBmcReadyLib library instance, which provides a
function to check whether the BMC is ready for transaction or not. The
function checks the GPIO pin specified by the PcdBmcReadyGpio PCD and
returns TRUE if the pin is set to a logic high level, indicating that
the BMC is ready.

Signed-off-by: Nhi Pham <nhi@os.amperecomputing.com>
---
 Platform/Ampere/JadePkg/Library/PlatformBmcReadyLib/PlatformBmcReadyLib.inf | 29 +++++++++++++++++++
 Platform/Ampere/JadePkg/Library/PlatformBmcReadyLib/PlatformBmcReadyLib.c   | 30 ++++++++++++++++++++
 2 files changed, 59 insertions(+)

diff --git a/Platform/Ampere/JadePkg/Library/PlatformBmcReadyLib/PlatformBmcReadyLib.inf b/Platform/Ampere/JadePkg/Library/PlatformBmcReadyLib/PlatformBmcReadyLib.inf
new file mode 100755
index 000000000000..493178c3fc5e
--- /dev/null
+++ b/Platform/Ampere/JadePkg/Library/PlatformBmcReadyLib/PlatformBmcReadyLib.inf
@@ -0,0 +1,29 @@
+## @file
+#
+# Copyright (c) 2024, Ampere Computing LLC. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+  INF_VERSION                    = 0x0001001B
+  BASE_NAME                      = PlatformBmcReadyLib
+  FILE_GUID                      = D7D58480-96D5-4820-AC2D-472F4E0B9903
+  MODULE_TYPE                    = BASE
+  VERSION_STRING                 = 1.0
+  LIBRARY_CLASS                  = PlatformBmcReadyLib
+
+[Sources]
+  PlatformBmcReadyLib.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  Silicon/Ampere/AmpereSiliconPkg/AmpereSiliconPkg.dec
+  Silicon/Ampere/AmpereAltraPkg/AmpereAltraPkg.dec
+
+[LibraryClasses]
+  GpioLib
+
+[Pcd]
+  gAmpereTokenSpaceGuid.PcdBmcReadyGpio
diff --git a/Platform/Ampere/JadePkg/Library/PlatformBmcReadyLib/PlatformBmcReadyLib.c b/Platform/Ampere/JadePkg/Library/PlatformBmcReadyLib/PlatformBmcReadyLib.c
new file mode 100644
index 000000000000..b1712ff393c8
--- /dev/null
+++ b/Platform/Ampere/JadePkg/Library/PlatformBmcReadyLib/PlatformBmcReadyLib.c
@@ -0,0 +1,30 @@
+/** @file
+
+  Copyright (c) 2024, Ampere Computing LLC. All rights reserved.<BR>
+
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Uefi.h>
+#include <Library/GpioLib.h>
+#include <Library/PcdLib.h>
+
+/**
+  This function checks whether BMC is ready for transaction or not.
+
+  @retval TRUE   The BMC is ready.
+  @retval FALSE  The BMC is not ready.
+
+**/
+BOOLEAN
+EFIAPI
+PlatformBmcReady (
+  VOID
+  )
+{
+  //
+  // The BMC is considered ready if its GPIO pin is set to a logic high level.
+  //
+  return GpioReadBit (FixedPcdGet8 (PcdBmcReadyGpio)) == 0x1;
+}
-- 
2.25.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#120166): https://edk2.groups.io/g/devel/message/120166
Mute This Topic: https://groups.io/mt/107662240/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



  parent reply	other threads:[~2024-08-01  9:40 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-01  9:36 [edk2-devel] [edk2-platforms][PATCH 0/5] Add IPMI SSIF support Nhi Pham via groups.io
2024-08-01  9:36 ` [edk2-devel] [edk2-platforms][PATCH 1/5] AmpereAltraPkg/DwI2cLib: Add SmbusRead() function Nhi Pham via groups.io
2024-08-01 15:14   ` Leif Lindholm
2024-08-05  3:44     ` Nhi Pham via groups.io
2024-08-01 15:18   ` Leif Lindholm
2024-08-05  3:46     ` Nhi Pham via groups.io
2024-08-01  9:36 ` [edk2-devel] [edk2-platforms][PATCH 2/5] AmpereSiliconPkg: Define PCDs for SMBUS and BMC Nhi Pham via groups.io
2024-08-01 15:02   ` Leif Lindholm
2024-08-05  3:18     ` Nhi Pham via groups.io
2024-08-01  9:36 ` [edk2-devel] [edk2-platforms][PATCH 3/5] AmpereAltraPkg: Add SmbusHc PEI and DXE drivers Nhi Pham via groups.io
2024-08-01  9:36 ` Nhi Pham via groups.io [this message]
2024-08-01  9:36 ` [edk2-devel] [edk2-platforms][PATCH 5/5] Ampere/Jade: Enable IPMI SSIF Nhi Pham via groups.io

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=20240801093618.191274-5-nhi@os.amperecomputing.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