public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Nate DeSimone" <nathaniel.l.desimone@intel.com>
To: devel@edk2.groups.io
Cc: Chasel Chiu <chasel.chiu@intel.com>,
	Sai Chaganty <rangasai.v.chaganty@intel.com>,
	Isaac Oram <isaac.w.oram@intel.com>,
	Benjamin Doron <benjamin.doron00@gmail.com>,
	Michael Kubacki <michael.kubacki@microsoft.com>,
	Jeremy Soller <jeremy@system76.com>
Subject: [edk2-platforms] [PATCH V3 1/6] KabylakeOpenBoardPkg: Add HdmiDebugPchDetectionLib
Date: Thu,  8 Sep 2022 18:06:59 -0700	[thread overview]
Message-ID: <20220909010704.7186-2-nathaniel.l.desimone@intel.com> (raw)
In-Reply-To: <20220909010704.7186-1-nathaniel.l.desimone@intel.com>

This library detects the type of PCH present on
the system to the granualarity level needed to
determine which GMBUS pins to use to access the
HDMI DDC I2C bus.

Cc: Chasel Chiu <chasel.chiu@intel.com>
Cc: Sai Chaganty <rangasai.v.chaganty@intel.com>
Cc: Isaac Oram <isaac.w.oram@intel.com>
Cc: Benjamin Doron <benjamin.doron00@gmail.com>
Cc: Michael Kubacki <michael.kubacki@microsoft.com>
Cc: Jeremy Soller <jeremy@system76.com>
Signed-off-by: Nate DeSimone <nathaniel.l.desimone@intel.com>
---
 .../AspireVn7Dash572G/OpenBoardPkg.dsc        |  1 +
 .../GalagoPro3/OpenBoardPkg.dsc               |  1 +
 .../Library/HdmiDebugPchDetectionLib.h        | 34 ++++++++++
 .../KabylakeRvp3/OpenBoardPkg.dsc             |  1 +
 .../HdmiDebugPchDetectionLib.c                | 67 +++++++++++++++++++
 .../HdmiDebugPchDetectionLib.inf              | 38 +++++++++++
 6 files changed, 142 insertions(+)
 create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Include/Library/HdmiDebugPchDetectionLib.h
 create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/HdmiDebugPchDetectionLib/HdmiDebugPchDetectionLib.c
 create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/HdmiDebugPchDetectionLib/HdmiDebugPchDetectionLib.inf

diff --git a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/OpenBoardPkg.dsc b/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/OpenBoardPkg.dsc
index 29aa8d9111..5e9ed615cf 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/OpenBoardPkg.dsc
+++ b/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/OpenBoardPkg.dsc
@@ -184,6 +184,7 @@
   GpioExpanderLib|$(PLATFORM_BOARD_PACKAGE)/Library/BaseGpioExpanderLib/BaseGpioExpanderLib.inf
   I2cAccessLib|$(PLATFORM_BOARD_PACKAGE)/Library/PeiI2cAccessLib/PeiI2cAccessLib.inf
   PlatformSecLib|$(PLATFORM_PACKAGE)/FspWrapper/Library/SecFspWrapperPlatformSecLib/SecFspWrapperPlatformSecLib.inf
+  HdmiDebugPchDetectionLib|$(PLATFORM_BOARD_PACKAGE)/Library/HdmiDebugPchDetectionLib/HdmiDebugPchDetectionLib.inf
 
   # Thunderbolt
 !if gKabylakeOpenBoardPkgTokenSpaceGuid.PcdTbtEnable == TRUE
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc
index 93cf93942b..59d361b472 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc
+++ b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc
@@ -128,6 +128,7 @@
   GpioExpanderLib|$(PLATFORM_BOARD_PACKAGE)/Library/BaseGpioExpanderLib/BaseGpioExpanderLib.inf
   I2cAccessLib|$(PLATFORM_BOARD_PACKAGE)/Library/PeiI2cAccessLib/PeiI2cAccessLib.inf
   PlatformSecLib|$(PLATFORM_PACKAGE)/FspWrapper/Library/SecFspWrapperPlatformSecLib/SecFspWrapperPlatformSecLib.inf
+  HdmiDebugPchDetectionLib|$(PLATFORM_BOARD_PACKAGE)/Library/HdmiDebugPchDetectionLib/HdmiDebugPchDetectionLib.inf
 
   # Thunderbolt
 !if gKabylakeOpenBoardPkgTokenSpaceGuid.PcdTbtEnable == TRUE
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/Include/Library/HdmiDebugPchDetectionLib.h b/Platform/Intel/KabylakeOpenBoardPkg/Include/Library/HdmiDebugPchDetectionLib.h
new file mode 100644
index 0000000000..af5e6059f5
--- /dev/null
+++ b/Platform/Intel/KabylakeOpenBoardPkg/Include/Library/HdmiDebugPchDetectionLib.h
@@ -0,0 +1,34 @@
+/** @file
+  PCH Detection for the HDMI I2C Debug Port
+
+Copyright (c) 2022, Intel Corporation. All rights reserved.<BR>
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef HDMI_DEBUG_PCH_DETECTION_LIB_H_
+#define HDMI_DEBUG_PCH_DETECTION_LIB_H_
+
+#include <Uefi/UefiBaseType.h>
+
+typedef enum {
+  PchTypeUnknown = 0,
+  PchTypeSptLp,
+  PchTypeSptH,
+  PchTypeKbpH,
+  PchTypeCnlLp,
+  PchTypeCnlH,
+  PchTypeMax
+} PCH_TYPE;
+
+/**
+  Returns the type of PCH on the system
+
+  @retval   The PCH type.
+**/
+PCH_TYPE
+GetPchTypeInternal (
+  VOID
+  );
+
+#endif
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkg.dsc b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkg.dsc
index a46d36b056..3085a80ca2 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkg.dsc
+++ b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkg.dsc
@@ -171,6 +171,7 @@
   GpioExpanderLib|$(PLATFORM_BOARD_PACKAGE)/Library/BaseGpioExpanderLib/BaseGpioExpanderLib.inf
   I2cAccessLib|$(PLATFORM_BOARD_PACKAGE)/Library/PeiI2cAccessLib/PeiI2cAccessLib.inf
   PlatformSecLib|$(PLATFORM_PACKAGE)/FspWrapper/Library/SecFspWrapperPlatformSecLib/SecFspWrapperPlatformSecLib.inf
+  HdmiDebugPchDetectionLib|$(PLATFORM_BOARD_PACKAGE)/Library/HdmiDebugPchDetectionLib/HdmiDebugPchDetectionLib.inf
 
   # Thunderbolt
 !if gKabylakeOpenBoardPkgTokenSpaceGuid.PcdTbtEnable == TRUE
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/Library/HdmiDebugPchDetectionLib/HdmiDebugPchDetectionLib.c b/Platform/Intel/KabylakeOpenBoardPkg/Library/HdmiDebugPchDetectionLib/HdmiDebugPchDetectionLib.c
new file mode 100644
index 0000000000..596976dd1b
--- /dev/null
+++ b/Platform/Intel/KabylakeOpenBoardPkg/Library/HdmiDebugPchDetectionLib/HdmiDebugPchDetectionLib.c
@@ -0,0 +1,67 @@
+/** @file
+  PCH Detection for the HDMI I2C Debug Port
+
+Copyright (c) 2022, Intel Corporation. All rights reserved.<BR>
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Uefi/UefiBaseType.h>
+#include <Library/PciLib.h>
+#include <Library/HdmiDebugPchDetectionLib.h>
+
+
+//
+// PCH Detection Registers
+//
+#define PCH_PCI_BUS                                       0
+#define PCH_LPC_PCI_DEV                                   31
+#define PCH_LPC_PCI_FUN                                   0
+#define R_PCH_LPC_DID                                     0x02
+
+#define V_SPT_LP_PCH_START_DEVICE_ID                      0x9D40
+#define V_SPT_LP_PCH_END_DEVICE_ID                        0x9D5F
+#define V_SPT_H_PCH_START_DEVICE_ID                       0xA140
+#define V_SPT_H_PCH_END_DEVICE_ID                         0xA15F
+#define V_KBP_H_PCH_START_DEVICE_ID                       0xA2C0
+#define V_KBP_H_PCH_END_DEVICE_ID                         0xA2DF
+#define V_CNL_LP_PCH_START_DEVICE_ID                      0x9D80
+#define V_CNL_LP_PCH_END_DEVICE_ID                        0x9D9F
+#define V_CNL_H_PCH_START_DEVICE_ID                       0xA300
+#define V_CNL_H_PCH_END_DEVICE_ID                         0xA31F
+
+#define V_KBP_H_PCH_DEVICE_ID_ES                          0xA2C0        ///< This is SKL-PCH-H in KBL-PCH-H package
+#define V_KBP_H_PCH_DEVICE_ID_SVR_ES                      0xA2D0        ///< This is SKL-PCH-H in KBL-PCH-H package
+
+/**
+  Returns the type of PCH on the system
+
+  @retval   The PCH type.
+**/
+PCH_TYPE
+GetPchTypeInternal (
+  VOID
+  )
+{
+  PCH_TYPE  PchType;
+  UINT16    DeviceId;
+
+  PchType   = PchTypeUnknown;
+  DeviceId  = PciRead16 (PCI_LIB_ADDRESS (PCH_PCI_BUS, PCH_LPC_PCI_DEV, PCH_LPC_PCI_FUN, R_PCH_LPC_DID));
+  if ((DeviceId >= V_SPT_LP_PCH_START_DEVICE_ID) && (DeviceId <= V_SPT_LP_PCH_END_DEVICE_ID)) {
+    PchType = PchTypeSptLp;
+  } else if ((DeviceId >= V_SPT_H_PCH_START_DEVICE_ID) && (DeviceId <= V_SPT_H_PCH_END_DEVICE_ID )) {
+    PchType = PchTypeSptH;
+  } else if ((DeviceId >= V_KBP_H_PCH_START_DEVICE_ID) && (DeviceId <= V_KBP_H_PCH_END_DEVICE_ID)) {
+    PchType = PchTypeKbpH;
+    if ((DeviceId == V_KBP_H_PCH_DEVICE_ID_ES) || (DeviceId == V_KBP_H_PCH_DEVICE_ID_SVR_ES)) {
+      PchType = PchTypeSptH;
+    }
+  } else if ((DeviceId >= V_CNL_LP_PCH_START_DEVICE_ID) && (DeviceId <= V_CNL_LP_PCH_END_DEVICE_ID)) {
+    PchType = PchTypeCnlLp;
+  } else if ((DeviceId >= V_CNL_H_PCH_START_DEVICE_ID) && (DeviceId <= V_CNL_H_PCH_END_DEVICE_ID)) {
+    PchType = PchTypeCnlH;
+  }
+
+  return PchType;
+}
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/Library/HdmiDebugPchDetectionLib/HdmiDebugPchDetectionLib.inf b/Platform/Intel/KabylakeOpenBoardPkg/Library/HdmiDebugPchDetectionLib/HdmiDebugPchDetectionLib.inf
new file mode 100644
index 0000000000..897f60fbb9
--- /dev/null
+++ b/Platform/Intel/KabylakeOpenBoardPkg/Library/HdmiDebugPchDetectionLib/HdmiDebugPchDetectionLib.inf
@@ -0,0 +1,38 @@
+### @file
+# Component description file for the HDMI I2C Debug Port PCH Detection library
+#
+# Copyright (c) 2022, Intel Corporation. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+  INF_VERSION                    = 0x00010005
+  BASE_NAME                      = BaseHdmiDebugPchDetectionLib
+  FILE_GUID                      = EA098B52-45DF-4367-A32D-F36ACF91A0A9
+  VERSION_STRING                 = 1.0
+  MODULE_TYPE                    = BASE
+  LIBRARY_CLASS                  = HdmiDebugPchDetectionLib
+#
+# The following information is for reference only and not required by the build tools.
+#
+# VALID_ARCHITECTURES = IA32 X64
+#
+
+[LibraryClasses]
+  BaseLib
+  PciLib
+
+[Packages]
+  MdePkg/MdePkg.dec
+  KabylakeOpenBoardPkg/OpenBoardPkg.dec
+
+[Sources]
+  HdmiDebugPchDetectionLib.c
+
+[Ppis]
+
+[Guids]
+
+[Pcd]
-- 
2.27.0.windows.1


  reply	other threads:[~2022-09-09  1:07 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-09  1:06 [edk2-platforms] [PATCH V3 0/6] KabylakeOpenBoardPkg: HDMI DDC I2C Bus Debugging Nate DeSimone
2022-09-09  1:06 ` Nate DeSimone [this message]
2022-09-09  1:07 ` [edk2-platforms] [PATCH V3 2/6] KabylakeOpenBoardPkg: Add I2cHdmiDebugSerialPortLib Nate DeSimone
2022-09-09  1:07 ` [edk2-platforms] [PATCH V3 3/6] KabylakeOpenBoardPkg: Add HdmiDebugGpioInitLib Nate DeSimone
2022-09-09  1:07 ` [edk2-platforms] [PATCH V3 4/6] KabylakeOpenBoardPkg: Add SecBoardInitLib Nate DeSimone
2022-09-09  1:07 ` [edk2-platforms] [PATCH V3 5/6] MinPlatformPkg: Add PcdDefaultTerminalType support to SerialPortTerminalLib Nate DeSimone
2022-09-09  1:07 ` [edk2-platforms] [PATCH V3 6/6] KabylakeOpenBoardPkg/GalagoPro3: Enable HDMI DDC Debug Port Nate DeSimone

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=20220909010704.7186-2-nathaniel.l.desimone@intel.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