public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [edk2-platforms] [PATCH V2 0/5] KabylakeOpenBoardPkg: HDMI DDC I2C Bus Debugging
@ 2022-09-07  6:27 Nate DeSimone
  2022-09-07  6:27 ` [edk2-platforms] [PATCH V2 1/5] KabylakeOpenBoardPkg: Add I2cHdmiDebugSerialPortLib Nate DeSimone
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Nate DeSimone @ 2022-09-07  6:27 UTC (permalink / raw)
  To: devel
  Cc: Chasel Chiu, Sai Chaganty, Isaac Oram, Eric Dong, Liming Gao,
	Benjamin Doron, Michael Kubacki, Jeremy Soller

Changes in V2:
 - Use SerialPortTerminalLib from MinPlatformPkg.
 - Override SerialPortLib on StatusCodeHandlerSmm not
   StatusCodeRouter.

Normally the HDMI DDC I2C bus is used to read the EDID
data from the monitor. An unintended but useful property
of this interface is that is does not require DMA to
perform I/O. This means that this interface can be used
to perform I/O before DRAM is initialized.

HDMI video output is a common feature of many laptops.
This makes the HDMI DDC bus the only I/O interface
that is often exposed outside of the laptop chassis
while simultaneously capable of being used in Pre-Memory.
Oddly... this makes it an ideal and novel way to perform
closed chassis debug.

This patch series adds a implementation of using the HDMI
DDC I2C Bus as a "poor man's" UART. This is accomplished
using the GMBUS that is part of the Intel HD Graphics
device. Accordingly, this implementation will only work
on systems with the HDMI port routed to the Intel
graphics device, and will not work on systems with HDMI
routed to a discrete GPU.

In order to use this implementation, one will also need
a BusPirate programmed with Nate's Custom Bus Pirate FW
for I2C Serial Debug. This firmware is available from:

https://github.com/nate-desimone/Bus_Pirate

This firmware interfaces with the I2C Bus and forwards
traffic from it to the FTDI USB Serial Adapter that is
integrated with the BusPirate. In combination, this
results in the HDMI port appearing to function as a
regular UART to the user.

If you would like to see this in action, I made a short
YouTube video:

https://www.youtube.com/watch?v=xe7cFhRsr80

Cc: Chasel Chiu <chasel.chiu@intel.com>
Cc: Sai Chaganty <rangasai.v.chaganty@intel.com>
Cc: Isaac Oram <isaac.w.oram@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
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>

Nate DeSimone (5):
  KabylakeOpenBoardPkg: Add I2cHdmiDebugSerialPortLib
  KabylakeOpenBoardPkg: Add HdmiDebugGpioInitLib
  KabylakeOpenBoardPkg: Add SecBoardInitLib
  MinPlatformPkg: Add PcdDefaultTerminalType support to
    SerialPortTerminalLib
  KabylakeOpenBoardPkg/GalagoPro3: Enable HDMI DDC Debug Port

 .../PeiAspireVn7Dash572GInitPreMemLib.c       |   3 +-
 .../AspireVn7Dash572G/OpenBoardPkg.dsc        |  11 +-
 .../AspireVn7Dash572G/OpenBoardPkgPcd.dsc     |   9 +
 .../BoardInitLib/PeiGalagoPro3InitPreMemLib.c |  13 +-
 .../GalagoPro3/OpenBoardPkg.dsc               |  84 +-
 .../GalagoPro3/OpenBoardPkgPcd.dsc            |  40 +
 .../Include/Library/HdmiDebugGpioInitLib.h    |  26 +
 .../PeiKabylakeRvp3InitPreMemLib.c            |  13 +-
 .../KabylakeRvp3/OpenBoardPkg.dsc             |  11 +-
 .../KabylakeRvp3/OpenBoardPkgPcd.dsc          |   9 +
 .../HdmiDebugGpioInitLib.c                    | 221 +++++
 .../HdmiDebugGpioInitLib.inf                  |  42 +
 .../DxeI2cHdmiDebugSerialPortLib.inf          |  51 ++
 .../DxeSmmI2cHdmiDebugSerialPortLib.c         | 161 ++++
 .../Library/I2cHdmiDebugSerialPortLib/Gmbus.c | 826 ++++++++++++++++++
 .../Library/I2cHdmiDebugSerialPortLib/Gmbus.h | 324 +++++++
 .../I2cDebugPortProtocol.c                    | 194 ++++
 .../I2cDebugPortProtocol.h                    |  77 ++
 .../I2cDebugPortTplDxe.c                      |  44 +
 .../I2cDebugPortTplNull.c                     |  36 +
 .../I2cHdmiDebugSerialPortLib.c               | 201 +++++
 .../I2cHdmiDebugSerialPortLib/IgfxI2c.c       | 112 +++
 .../I2cHdmiDebugSerialPortLib/IgfxI2c.h       | 146 ++++
 .../PeiI2cHdmiDebugSerialPortLib.c            | 237 +++++
 .../PeiI2cHdmiDebugSerialPortLib.inf          |  52 ++
 .../SecI2cHdmiDebugSerialPortLib.c            | 134 +++
 .../SecI2cHdmiDebugSerialPortLib.inf          |  51 ++
 .../SmmI2cHdmiDebugSerialPortLib.inf          |  51 ++
 .../SecBoardInitLib/Ia32/SecBoardInit.nasm    |  18 +
 .../Library/SecBoardInitLib/SecBoardInitLib.c |  35 +
 .../SecBoardInitLib/SecBoardInitLib.inf       |  39 +
 .../KabylakeOpenBoardPkg/OpenBoardPkg.dec     |  33 +-
 .../SerialPortTerminalLib.c                   |  66 +-
 .../SerialPortTerminalLib.h                   |  11 +-
 .../SerialPortTerminalLib.inf                 |  17 +-
 35 files changed, 3343 insertions(+), 55 deletions(-)
 create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Include/Library/HdmiDebugGpioInitLib.h
 create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/HdmiDebugGpioInitLib/HdmiDebugGpioInitLib.c
 create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/HdmiDebugGpioInitLib/HdmiDebugGpioInitLib.inf
 create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/DxeI2cHdmiDebugSerialPortLib.inf
 create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/DxeSmmI2cHdmiDebugSerialPortLib.c
 create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/Gmbus.c
 create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/Gmbus.h
 create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/I2cDebugPortProtocol.c
 create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/I2cDebugPortProtocol.h
 create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/I2cDebugPortTplDxe.c
 create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/I2cDebugPortTplNull.c
 create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/I2cHdmiDebugSerialPortLib.c
 create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/IgfxI2c.c
 create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/IgfxI2c.h
 create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/PeiI2cHdmiDebugSerialPortLib.c
 create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/PeiI2cHdmiDebugSerialPortLib.inf
 create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/SecI2cHdmiDebugSerialPortLib.c
 create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/SecI2cHdmiDebugSerialPortLib.inf
 create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/SmmI2cHdmiDebugSerialPortLib.inf
 create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/SecBoardInitLib/Ia32/SecBoardInit.nasm
 create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/SecBoardInitLib/SecBoardInitLib.c
 create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/SecBoardInitLib/SecBoardInitLib.inf

-- 
2.27.0.windows.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [edk2-platforms] [PATCH V2 1/5] KabylakeOpenBoardPkg: Add I2cHdmiDebugSerialPortLib
  2022-09-07  6:27 [edk2-platforms] [PATCH V2 0/5] KabylakeOpenBoardPkg: HDMI DDC I2C Bus Debugging Nate DeSimone
@ 2022-09-07  6:27 ` Nate DeSimone
  2022-09-07  6:27 ` [edk2-platforms] [PATCH V2 2/5] KabylakeOpenBoardPkg: Add HdmiDebugGpioInitLib Nate DeSimone
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Nate DeSimone @ 2022-09-07  6:27 UTC (permalink / raw)
  To: devel
  Cc: Chasel Chiu, Sai Chaganty, Isaac Oram, Benjamin Doron,
	Michael Kubacki, Jeremy Soller

Add new SerialPortLib implementation that routes log
messages over the I2C bus included in the integrated
graphics HDMI port. Normally this I2C bus is used to
read the EDID data from the monitor. An unintended
but useful property of this interface is that is does
not require DMA to perform I/O. This means that this
interface can be used to perform I/O before DRAM is
initialized.

HDMI video output is a common feature of many laptops.
This makes the HDMI DDC bus the only I/O interface
that is often exposed outside of the laptop chassis
while simultaneously capable of being used in Pre-Memory.
Oddly, this makes it ideal for closed chassis debug.

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/OpenBoardPkgPcd.dsc     |   9 +
 .../GalagoPro3/OpenBoardPkgPcd.dsc            |   9 +
 .../KabylakeRvp3/OpenBoardPkgPcd.dsc          |   9 +
 .../DxeI2cHdmiDebugSerialPortLib.inf          |  51 ++
 .../DxeSmmI2cHdmiDebugSerialPortLib.c         | 161 ++++
 .../Library/I2cHdmiDebugSerialPortLib/Gmbus.c | 826 ++++++++++++++++++
 .../Library/I2cHdmiDebugSerialPortLib/Gmbus.h | 324 +++++++
 .../I2cDebugPortProtocol.c                    | 194 ++++
 .../I2cDebugPortProtocol.h                    |  77 ++
 .../I2cDebugPortTplDxe.c                      |  44 +
 .../I2cDebugPortTplNull.c                     |  36 +
 .../I2cHdmiDebugSerialPortLib.c               | 201 +++++
 .../I2cHdmiDebugSerialPortLib/IgfxI2c.c       | 112 +++
 .../I2cHdmiDebugSerialPortLib/IgfxI2c.h       | 146 ++++
 .../PeiI2cHdmiDebugSerialPortLib.c            | 237 +++++
 .../PeiI2cHdmiDebugSerialPortLib.inf          |  52 ++
 .../SecI2cHdmiDebugSerialPortLib.c            | 134 +++
 .../SecI2cHdmiDebugSerialPortLib.inf          |  51 ++
 .../SmmI2cHdmiDebugSerialPortLib.inf          |  51 ++
 .../KabylakeOpenBoardPkg/OpenBoardPkg.dec     |  15 +-
 20 files changed, 2737 insertions(+), 2 deletions(-)
 create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/DxeI2cHdmiDebugSerialPortLib.inf
 create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/DxeSmmI2cHdmiDebugSerialPortLib.c
 create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/Gmbus.c
 create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/Gmbus.h
 create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/I2cDebugPortProtocol.c
 create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/I2cDebugPortProtocol.h
 create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/I2cDebugPortTplDxe.c
 create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/I2cDebugPortTplNull.c
 create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/I2cHdmiDebugSerialPortLib.c
 create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/IgfxI2c.c
 create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/IgfxI2c.h
 create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/PeiI2cHdmiDebugSerialPortLib.c
 create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/PeiI2cHdmiDebugSerialPortLib.inf
 create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/SecI2cHdmiDebugSerialPortLib.c
 create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/SecI2cHdmiDebugSerialPortLib.inf
 create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/SmmI2cHdmiDebugSerialPortLib.inf

diff --git a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/OpenBoardPkgPcd.dsc b/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/OpenBoardPkgPcd.dsc
index da8f9a075c..a9d531a269 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/OpenBoardPkgPcd.dsc
+++ b/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/OpenBoardPkgPcd.dsc
@@ -399,6 +399,15 @@
   ######################################
   gBoardModulePkgTokenSpaceGuid.PcdPs2KbMsEnable|1
   gBoardModulePkgTokenSpaceGuid.PcdSuperIoPciIsaBridgeDevice|{0x00, 0x00, 0x1F, 0x00}
+  gKabylakeOpenBoardPkgTokenSpaceGuid.PcdGttMmAddress|0xDF000000
+
+  ## Specifies the DDC I2C channel to claim as the HDMI debug port
+  #  The value is defined as below.
+  #  2: DDC channel B
+  #  3: DDC channel C
+  #  4: DDC channel D
+  # @Prompt DDC I2C channel to claim as the HDMI debug port
+  gKabylakeOpenBoardPkgTokenSpaceGuid.PcdI2cHdmiDebugPortDdcI2cChannel|0x00  #@todo - Set to correct value for VN7-572G
 
 [PcdsFixedAtBuild.IA32]
   ######################################
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkgPcd.dsc b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkgPcd.dsc
index 2b9fbe81c0..207c1de06d 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkgPcd.dsc
+++ b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkgPcd.dsc
@@ -332,6 +332,15 @@
   ######################################
   gBoardModulePkgTokenSpaceGuid.PcdPs2KbMsEnable|1
   gBoardModulePkgTokenSpaceGuid.PcdSuperIoPciIsaBridgeDevice|{0x00, 0x00, 0x1F, 0x00}
+  gKabylakeOpenBoardPkgTokenSpaceGuid.PcdGttMmAddress|0xDF000000
+
+  ## Specifies the DDC I2C channel to claim as the HDMI debug port
+  #  The value is defined as below.
+  #  2: DDC channel B
+  #  3: DDC channel C
+  #  4: DDC channel D
+  # @Prompt DDC I2C channel to claim as the HDMI debug port
+  gKabylakeOpenBoardPkgTokenSpaceGuid.PcdI2cHdmiDebugPortDdcI2cChannel|0x03
 
 [PcdsFixedAtBuild.IA32]
   ######################################
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkgPcd.dsc b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkgPcd.dsc
index 360b99e0cf..2f7765e58a 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkgPcd.dsc
+++ b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkgPcd.dsc
@@ -332,6 +332,15 @@
   ######################################
   gBoardModulePkgTokenSpaceGuid.PcdPs2KbMsEnable|1
   gBoardModulePkgTokenSpaceGuid.PcdSuperIoPciIsaBridgeDevice|{0x00, 0x00, 0x1F, 0x00}
+  gKabylakeOpenBoardPkgTokenSpaceGuid.PcdGttMmAddress|0xDF000000
+
+  ## Specifies the DDC I2C channel to claim as the HDMI debug port
+  #  The value is defined as below.
+  #  2: DDC channel B
+  #  3: DDC channel C
+  #  4: DDC channel D
+  # @Prompt DDC I2C channel to claim as the HDMI debug port
+  gKabylakeOpenBoardPkgTokenSpaceGuid.PcdI2cHdmiDebugPortDdcI2cChannel|0x00
 
 [PcdsFixedAtBuild.IA32]
   ######################################
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/DxeI2cHdmiDebugSerialPortLib.inf b/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/DxeI2cHdmiDebugSerialPortLib.inf
new file mode 100644
index 0000000000..5403d8ae0f
--- /dev/null
+++ b/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/DxeI2cHdmiDebugSerialPortLib.inf
@@ -0,0 +1,51 @@
+### @file
+# Component description file for Serial I/O Port library for the HDMI I2C Debug Port
+#
+# Copyright (c) 2022, Intel Corporation. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+  INF_VERSION                    = 0x00010005
+  BASE_NAME                      = DxeI2cHdmiDebugSerialPortLib
+  FILE_GUID                      = 53A31F61-7B95-4AD0-8F02-B03BCE6FC781
+  VERSION_STRING                 = 1.0
+  MODULE_TYPE                    = DXE_DRIVER
+  LIBRARY_CLASS                  = SerialPortLib|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER SMM_CORE
+#
+# The following information is for reference only and not required by the build tools.
+#
+# VALID_ARCHITECTURES = IA32 X64
+#
+
+[LibraryClasses]
+  BaseLib
+  BaseMemoryLib
+  PcdLib
+  TimerLib
+  PciLib
+
+[Packages]
+  MdePkg/MdePkg.dec
+  KabylakeOpenBoardPkg/OpenBoardPkg.dec
+
+[Sources]
+  DxeSmmI2cHdmiDebugSerialPortLib.c
+  Gmbus.c
+  Gmbus.h
+  I2cDebugPortProtocol.c
+  I2cDebugPortProtocol.h
+  I2cDebugPortTplDxe.c
+  I2cHdmiDebugSerialPortLib.c
+  IgfxI2c.c
+  IgfxI2c.h
+
+[Ppis]
+
+[Guids]
+
+[Pcd]
+  gKabylakeOpenBoardPkgTokenSpaceGuid.PcdI2cHdmiDebugPortDdcI2cChannel    ## CONSUMES
+  gKabylakeOpenBoardPkgTokenSpaceGuid.PcdGttMmAddress                     ## CONSUMES
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/DxeSmmI2cHdmiDebugSerialPortLib.c b/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/DxeSmmI2cHdmiDebugSerialPortLib.c
new file mode 100644
index 0000000000..5556e09a74
--- /dev/null
+++ b/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/DxeSmmI2cHdmiDebugSerialPortLib.c
@@ -0,0 +1,161 @@
+/** @file
+  Serial I/O Port library implementation for the HDMI I2C Debug Port
+  DXE/SMM Library implementation
+
+Copyright (c) 2022, Intel Corporation. All rights reserved.<BR>
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Base.h>
+#include <Library/BaseLib.h>
+#include <Library/SerialPortLib.h>
+#include <Library/PcdLib.h>
+#include <Library/TimerLib.h>
+
+#include <IgfxI2c.h>
+#include <I2cDebugPortProtocol.h>
+
+//Once we reach DXE phase we can start assuming global variables are writeable.
+STATIC PCH_TYPE mPchType = PchTypeUnknown;
+STATIC UINT32   mControlBits = 0;
+STATIC UINT8    mI2cHdmiDebugDdcBusPinPair = 0;
+STATIC BOOLEAN  mIgdBusMasterReset = FALSE;
+
+/**
+  Sets the control bits on a serial device.
+
+  @param Control                Sets the bits of Control that are settable.
+
+  @retval RETURN_SUCCESS        The new control bits were set on the serial device.
+  @retval RETURN_UNSUPPORTED    The serial device does not support this operation.
+  @retval RETURN_DEVICE_ERROR   The serial device is not functioning correctly.
+
+**/
+RETURN_STATUS
+EFIAPI
+SerialPortSetControl (
+  IN UINT32 Control
+  )
+{
+  //
+  // check for invalid control parameters
+  //
+  if ((Control & (~(EFI_SERIAL_REQUEST_TO_SEND          |
+                    EFI_SERIAL_DATA_TERMINAL_READY      |
+                    EFI_SERIAL_HARDWARE_LOOPBACK_ENABLE |
+                    EFI_SERIAL_SOFTWARE_LOOPBACK_ENABLE |
+                    EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE))) != 0 ) {
+    return EFI_UNSUPPORTED;
+  }
+  Control &= (UINT32) ~(EFI_SERIAL_INPUT_BUFFER_EMPTY);
+  mControlBits = Control;
+  return EFI_SUCCESS;
+}
+
+/**
+  Retrieve the status of the control bits on a serial device.
+
+  @param Control                A pointer to return the current control signals from the serial device.
+
+  @retval RETURN_SUCCESS        The control bits were read from the serial device.
+  @retval RETURN_UNSUPPORTED    The serial device does not support this operation.
+  @retval RETURN_DEVICE_ERROR   The serial device is not functioning correctly.
+
+**/
+RETURN_STATUS
+EFIAPI
+SerialPortGetControl (
+  OUT UINT32 *Control
+  )
+{
+  EFI_STATUS  Status;
+  UINT8       NumberOfBytesInFifoBuffer;
+
+  Status = I2cDebugPortReadyToRead (&NumberOfBytesInFifoBuffer);
+  if (EFI_ERROR (Status)) {
+    return Status;
+  }
+  *Control = (EFI_SERIAL_CLEAR_TO_SEND | EFI_SERIAL_DATA_SET_READY |
+              EFI_SERIAL_CARRIER_DETECT | EFI_SERIAL_OUTPUT_BUFFER_EMPTY);
+  if (NumberOfBytesInFifoBuffer <= 0) {
+    *Control |= EFI_SERIAL_INPUT_BUFFER_EMPTY;
+  }
+  *Control |= mControlBits;
+  return Status;
+}
+
+/**
+  Returns the type of PCH on the system
+
+  @retval   The PCH type.
+**/
+PCH_TYPE
+GetPchType (
+  VOID
+  )
+{
+  if (mPchType == PchTypeUnknown) {
+    mPchType = GetPchTypeInternal ();
+  }
+  return mPchType;
+}
+
+/**
+  Returns the GPIO pin pair to use for the I2C HDMI debug port
+
+  @param[out] DdcBusPinPair               - The GPIO pin pair for the I2C HDMI debug port.
+
+  @retval  EFI_SUCCESS                    - The GPIO pin pair was successfully determined
+  @retval  EFI_INVALID_PARAMETER          - The given DDC I2C channel does not exist.
+  @retval  EFI_UNSUPPORTED                - The platform is using a PCH that is not supported yet.
+**/
+EFI_STATUS
+GetGmbusBusPinPairForI2cDebugPort (
+  OUT UINT8             *DdcBusPinPair
+  )
+{
+  EFI_STATUS  Status;
+
+  if (mI2cHdmiDebugDdcBusPinPair == 0) {
+    Status  = GetGmbusBusPinPair (
+                (IGFX_I2C_CHANNEL) PcdGet32 (PcdI2cHdmiDebugPortDdcI2cChannel),
+                &mI2cHdmiDebugDdcBusPinPair
+                );
+    if (EFI_ERROR (Status)) {
+      mI2cHdmiDebugDdcBusPinPair = 0;
+      return Status;
+    }
+  }
+  *DdcBusPinPair = mI2cHdmiDebugDdcBusPinPair;
+  return EFI_SUCCESS;
+}
+
+/**
+  Returns a flag indicating whether the IGD device bus master enable needs to
+  be disabled at the end of the current transaction
+
+  @retval  TRUE                           - IGD Bus Master Enable needs to be reset
+  @retval  FALSE                          - IGD Bus Master Enable does not need to be reset
+**/
+BOOLEAN
+GetIgdBusMasterReset (
+  VOID
+  )
+{
+  return mIgdBusMasterReset;
+}
+
+/**
+  Sets a flag indicating whether the IGD device bus master enable needs to
+  be disabled at the end of the current transaction
+
+  @param[in]  IgdBusMasterReset           - IGD device bus master enable flag
+**/
+VOID
+SetIgdBusMasterReset (
+  BOOLEAN IgdBusMasterReset
+  )
+{
+  mIgdBusMasterReset = IgdBusMasterReset;
+}
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/Gmbus.c b/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/Gmbus.c
new file mode 100644
index 0000000000..c04bcd2850
--- /dev/null
+++ b/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/Gmbus.c
@@ -0,0 +1,826 @@
+/** @file
+  GMBUS I/O Implementation
+
+  Copyright (c) 2022, Intel Corporation. All rights reserved.<BR>
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Uefi.h>
+#include <Library/BaseLib.h>
+#include <Library/DebugLib.h>
+#include <Library/PcdLib.h>
+#include <Library/IoLib.h>
+#include <Library/PciLib.h>
+
+#include <IgfxI2c.h>
+#include <Gmbus.h>
+
+/**
+  Gets the GttMmAdr BAR value
+
+  @retval  The current value of the GTTMMADR BAR
+**/
+UINTN
+GmbusGetGttMmAdr (
+  VOID
+  )
+{
+  UINTN                   GttMmPciAddress;
+  UINT32                  GttMmAdr;
+
+  //
+  // Check if GTT Memory Mapped BAR has been already assigned, initialize if not
+  //
+  GttMmPciAddress = PCI_LIB_ADDRESS (SA_IGD_BUS, SA_IGD_DEV, SA_IGD_FUN_0, R_SA_IGD_GTTMMADR);
+  GttMmAdr = PciRead32 (GttMmPciAddress) & 0xFFFFFFF0;
+  //DEBUG ((DEBUG_INFO, "GttMmPciAddress = %x\n", (UINTN) GttMmPciAddress)); //@TODO
+  //DEBUG ((DEBUG_INFO, "GttMmAdr = %x\n", (UINTN) GttMmAdr)); //@TODO
+  //DEBUG ((DEBUG_INFO, "GMBUS2 = %x\n", (UINTN) MmioRead32 (GttMmAdr + R_SA_GTTMMADR_GMBUS2_STATUS))); //@TODO
+  //DEBUG ((DEBUG_INFO, "IGD CMD = %x\n", (UINTN) PciRead16 (PCI_LIB_ADDRESS (SA_IGD_BUS, SA_IGD_DEV, SA_IGD_FUN_0, R_SA_IGD_CMD)))); //@TODO
+  if (GttMmAdr == 0) {
+    //DEBUG ((DEBUG_INFO, "Programming GTT MMIO\n"));//@TODO
+    GttMmAdr = (UINT32) FixedPcdGet32 (PcdGttMmAddress);
+    if (GttMmAdr == 0) {
+      return 0;
+    }
+    //DEBUG ((DEBUG_INFO, "GMBUS2 Before = %x\n", (UINTN) MmioRead32 (GttMmAdr + R_SA_GTTMMADR_GMBUS2_STATUS))); //@TODO
+    //
+    // Program and read back GTT Memory Mapped BAR
+    //
+    PciWrite32 (GttMmPciAddress, (UINT32) (GttMmAdr & 0xFF000000));
+    GttMmAdr = PciRead32 (GttMmPciAddress) & 0xFFFFFFF0;
+    //DEBUG ((DEBUG_INFO, "GttMmAdr = %x\n", (UINTN) GttMmAdr));//@TODO
+    //DEBUG ((DEBUG_INFO, "GMBUS2 After = %x\n", (UINTN) MmioRead32 (GttMmAdr + R_SA_GTTMMADR_GMBUS2_STATUS))); //@TODO
+  }
+  //
+  // Check if Bus Master and Memory access on 0:2:0 is enabled, enable it if not
+  //
+  if ((PciRead16 (
+        PCI_LIB_ADDRESS (SA_IGD_BUS, SA_IGD_DEV, SA_IGD_FUN_0, R_SA_IGD_CMD)
+        )
+      & (BIT2 | BIT1)) != (BIT2 | BIT1)) {
+    //
+    // Enable Bus Master and Memory access on 0:2:0
+    //
+    PciOr16 (PCI_LIB_ADDRESS (SA_IGD_BUS, SA_IGD_DEV, SA_IGD_FUN_0, R_SA_IGD_CMD), (BIT2 | BIT1));
+    //
+    // Set the Reset Bus Master flag so that it will be disabled when the current transaction is done
+    //
+    SetIgdBusMasterReset (TRUE);
+  }
+
+  return GttMmAdr;
+}
+
+/**
+  Reset Bus Master and Memory access on the IGD device to the initial state at
+  the start of the current transaction.
+**/
+VOID
+GmbusResetBusMaster (
+  VOID
+  )
+{
+  if (GetIgdBusMasterReset ()) {
+    //
+    // Check if Bus Master and Memory access on 0:2:0 is enabled, disable it if so
+    //
+    if ((PciRead16 (
+          PCI_LIB_ADDRESS (SA_IGD_BUS, SA_IGD_DEV, SA_IGD_FUN_0, R_SA_IGD_CMD)
+          )
+        & (BIT2 | BIT1)) != 0) {
+      //
+      // Disable Bus Master and Memory access on 0:2:0
+      //
+      PciAnd16 (PCI_LIB_ADDRESS (SA_IGD_BUS, SA_IGD_DEV, SA_IGD_FUN_0, R_SA_IGD_CMD), (UINT16) ~(BIT2 | BIT1));
+    }
+    //
+    // Clear the Reset Bus Master flag
+    //
+    SetIgdBusMasterReset (FALSE);
+  }
+}
+
+/**
+  Writes to the GMBUS0 register (Clock/Port Select)
+
+  @param[in]  GmbusClkPrtSel              - The value to write to GMBUS0
+
+  @retval  EFI_SUCCESS                    - GMBUS0 was successfully written.
+  @retval  EFI_DEVICE_ERROR               - An error occurred while writting to GMBUS0
+**/
+EFI_STATUS
+SetGmbus0ClockPortSelect (
+  IN  UINT32             GmbusClkPrtSel
+  )
+{
+  UINTN                   GttMmAdr;
+
+  GttMmAdr = GmbusGetGttMmAdr ();
+  MmioWrite32 (GttMmAdr + R_SA_GTTMMADR_GMBUS0_CLKPRTSEL, GmbusClkPrtSel);
+  return EFI_SUCCESS;
+}
+
+/**
+  Writes to the GMBUS1 register (Command/Status)
+
+  @param[in]  GmbusCmdSts                 - The value to write to GMBUS1
+
+  @retval  EFI_SUCCESS                    - GMBUS1 was successfully written.
+  @retval  EFI_DEVICE_ERROR               - An error occurred while writting to GMBUS1
+**/
+EFI_STATUS
+SetGmbus1Command (
+  IN  UINT32             GmbusCmdSts
+  )
+{
+  UINTN                   GttMmAdr;
+
+  GttMmAdr = GmbusGetGttMmAdr ();
+  MmioWrite32 (GttMmAdr + R_SA_GTTMMADR_GMBUS1_CMDSTS, GmbusCmdSts);
+  return EFI_SUCCESS;
+}
+
+/**
+  Reads from the GMBUS2 register (GMBUS Status)
+
+  @param[out]  GmbusStatus                - The value read from GMBUS2
+
+  @retval  EFI_SUCCESS                    - GMBUS2 was successfully read.
+  @retval  EFI_DEVICE_ERROR               - An error occurred while reading from GMBUS2
+**/
+EFI_STATUS
+GetGmbus2Status (
+  OUT  UINT32             *GmbusStatus
+  )
+{
+  UINTN                   GttMmAdr;
+
+  GttMmAdr = GmbusGetGttMmAdr ();
+  if (GttMmAdr == 0) {
+    return EFI_UNSUPPORTED;
+  }
+  *GmbusStatus = MmioRead32 (GttMmAdr + R_SA_GTTMMADR_GMBUS2_STATUS);
+  return EFI_SUCCESS;
+}
+
+/**
+  Writes to the GMBUS2 register (GMBUS Status)
+
+  @param[in]  GmbusStatus                 - The value to write to GMBUS2
+
+  @retval  EFI_SUCCESS                    - GMBUS2 was successfully written.
+  @retval  EFI_DEVICE_ERROR               - An error occurred while writting to GMBUS2
+**/
+EFI_STATUS
+SetGmbus2Status (
+  IN  UINT32             GmbusStatus
+  )
+{
+  UINTN                   GttMmAdr;
+
+  GttMmAdr = GmbusGetGttMmAdr ();
+  if (GttMmAdr == 0) {
+    return EFI_UNSUPPORTED;
+  }
+  MmioWrite32 (GttMmAdr + R_SA_GTTMMADR_GMBUS2_STATUS, GmbusStatus);
+  return EFI_SUCCESS;
+}
+
+/**
+  Reads from the GMBUS3 register (GMBUS Data Buffer)
+
+  @param[out]  GmbusData                  - The value read from GMBUS3
+
+  @retval  EFI_SUCCESS                    - GMBUS2 was successfully read.
+  @retval  EFI_DEVICE_ERROR               - An error occurred while reading from GMBUS2
+**/
+EFI_STATUS
+GetGmbus3Data (
+  OUT  UINT32             *GmbusData
+  )
+{
+  UINTN                   GttMmAdr;
+
+  GttMmAdr = GmbusGetGttMmAdr ();
+  if (GttMmAdr == 0) {
+    return EFI_UNSUPPORTED;
+  }
+  *GmbusData = MmioRead32 (GttMmAdr + R_SA_GTTMMADR_GMBUS3_DATA);
+  return EFI_SUCCESS;
+}
+
+/**
+  Writes to the GMBUS3 register (GMBUS Data Buffer)
+
+  @param[in]  GmbusData                   - The value to write to GMBUS3
+
+  @retval  EFI_SUCCESS                    - GMBUS3 was successfully written.
+  @retval  EFI_DEVICE_ERROR               - An error occurred while writting to GMBUS3
+**/
+EFI_STATUS
+SetGmbus3Data (
+  IN  UINT32             GmbusData
+  )
+{
+  UINTN                   GttMmAdr;
+
+  GttMmAdr = GmbusGetGttMmAdr ();
+  if (GttMmAdr == 0) {
+    return EFI_UNSUPPORTED;
+  }
+  MmioWrite32 (GttMmAdr + R_SA_GTTMMADR_GMBUS3_DATA, GmbusData);
+  return EFI_SUCCESS;
+}
+
+/**
+  Set and clear the software clear interrupt bit. This causes a local reset on the GMBUS controller.
+
+  @retval  EFI_SUCCESS                    - The GMBUS error was successfully cleared.
+  @retval  EFI_TIMEOUT                    - The GMBUS I2C controller did not respond within the required timeout period.
+  @retval  EFI_DEVICE_ERROR               - An error occurred while accessing the GMBUS I2C controller.
+**/
+EFI_STATUS
+GmbusRecoverError (
+  VOID
+  )
+{
+  EFI_STATUS              Status;
+
+  //
+  // Setting B_SA_GTTMMADR_GMBUS1_SW_CLR_INT
+  // causes a local reset on the GMBUS controller
+  //
+  Status = SetGmbus1Command ((UINT32) B_SA_GTTMMADR_GMBUS1_SW_CLR_INT);
+  if (EFI_ERROR (Status)) {
+    //DEBUG ((DEBUG_INFO, "Error: %a() - SetGmbus1Command() failed - %r\n", __FUNCTION__, Status));
+    return Status;
+  }
+  Status = SetGmbus1Command (0);
+  if (EFI_ERROR (Status)) {
+    //DEBUG ((DEBUG_INFO, "Error: %a() - SetGmbus1Command() failed - %r\n", __FUNCTION__, Status));
+    return Status;
+  }
+  //
+  // Wait for reset to complete
+  //
+  Status = GmbusWaitForReady (B_SA_GTTMMADR_GMBUS2_BUS_ACTIVE, FALSE);
+  if (EFI_ERROR (Status)) {
+    //DEBUG ((DEBUG_INFO, "Error: %a() - GmbusWaitForReady() failed - %r\n", __FUNCTION__, Status));
+    return Status;
+  }
+
+  return Status;
+}
+
+/**
+  Wait for a given bitmask of status bits to de-assert to zero.
+
+  @param[in]  StatusBitMask               - A bitmask of status bits to be compared to the present value of GMBUS2
+  @param[in]  WaitForAssertion            - If TRUE, the Status Bit indicated must be 1, otherwise it must be 0.
+
+  @retval  EFI_SUCCESS                    - The GMBUS controller has cleared all of the bits in the bitmask.
+  @retval  EFI_TIMEOUT                    - The GMBUS controller did not clear all of the bits in the bitmask
+                                            within the required timeout period.
+  @retval  EFI_DEVICE_ERROR               - An error occurred while accessing the GMBUS I2C controller.
+**/
+EFI_STATUS
+GmbusWaitForReady (
+  IN  UINT32              StatusBitMask,
+  IN  BOOLEAN             WaitForAssertion
+  )
+{
+  EFI_STATUS              Status;
+  EFI_STATUS              Status2;
+  UINTN                   Index;
+  UINT32                  GmbusStatus;
+
+  //DEBUG ((DEBUG_INFO, "%a() - Enter\n", __FUNCTION__)); //@todo
+  Status = EFI_TIMEOUT;
+  for (Index = 0; Index < GMBUS_TIMEOUT; Index++) {
+    Status2 = GetGmbus2Status (&GmbusStatus);
+    if (EFI_ERROR (Status2)) {
+      //DEBUG ((DEBUG_INFO, "Error: %a() - GetGmbus2Status() failed - %r\n", __FUNCTION__, Status2));
+      return Status2;
+    }
+    if (WaitForAssertion) {
+      if (GmbusStatus & StatusBitMask) {
+        Status = EFI_SUCCESS;
+        break;
+      }
+    } else {
+      if (!(GmbusStatus & StatusBitMask)) {
+        Status = EFI_SUCCESS;
+        break;
+      }
+    }
+  }
+  if (EFI_ERROR (Status)) {
+    //DEBUG ((DEBUG_INFO, "GmbusStatus = %x\n", (UINTN) GmbusStatus));//@TODO
+  }
+  if (Status == EFI_TIMEOUT) {
+    if (WaitForAssertion) {
+      //DEBUG ((DEBUG_INFO, "Error: %a() - Gmbus assertion did not occur within timeout period.\n", __FUNCTION__));
+    } else {
+      //DEBUG ((DEBUG_INFO, "Error: %a() - Gmbus de-assertion did not occur within timeout period.\n", __FUNCTION__));
+    }
+  }
+  return Status;
+}
+
+/**
+  Initialize the GMBUS to use a given GPIO pin pair and clock speed in preparation
+  for sending a I2C command to the GMBUS controller.
+
+  @param[in]  BusSpeed                    - The clock rate for the I2C bus.
+  @param[in]  DdcBusPinPair               - The GPIO pin pair the GMBUS controller should use.
+
+  @retval  EFI_SUCCESS                    - The GMBUS has been initialized successfully.
+  @retval  EFI_INVALID_PARAMETER          - The given BusSpeed does not match a valid clock rate value.
+  @retval  EFI_TIMEOUT                    - The GMBUS I2C controller did not respond within the required timeout period.
+  @retval  EFI_DEVICE_ERROR               - An error occurred while accessing the GMBUS I2C controller.
+**/
+EFI_STATUS
+GmbusPrepare (
+  IN  UINT8             BusSpeed,
+  IN  UINT8             DdcBusPinPair
+  )
+{
+  EFI_STATUS              Status;
+  UINT32                  GmbusClkPrtSel;
+  UINT32                  GmbusStatus;
+
+  //
+  // Check that the user provided a valid bus speed
+  //
+  //DEBUG ((DEBUG_INFO, "%a() - Enter\n", __FUNCTION__)); //@todo
+  if ((BusSpeed != GMBUS_CLOCK_RATE_100K) && (BusSpeed != GMBUS_CLOCK_RATE_50K) &&
+      (BusSpeed != GMBUS_CLOCK_RATE_400K) && (BusSpeed != GMBUS_CLOCK_RATE_1M)) {
+    return EFI_INVALID_PARAMETER;
+  }
+  //
+  // Wait for GMBUS to complete any pending commands
+  //
+  Status = GmbusWaitForReady (B_SA_GTTMMADR_GMBUS2_INUSE, FALSE);
+  if (EFI_ERROR (Status)) {
+    //DEBUG ((DEBUG_INFO, "Error: %a() - GmbusWaitForReady() failed - %r\n", __FUNCTION__, Status));
+    return Status;
+  }
+  //DEBUG ((DEBUG_INFO, "%a() - INUSE De-asserted\n", __FUNCTION__)); //@todo
+  //
+  // Program the GMBUS Port and Clock
+  //
+  GmbusClkPrtSel = (BusSpeed << 8) | DdcBusPinPair;
+  Status = SetGmbus0ClockPortSelect (GmbusClkPrtSel);
+  if (EFI_ERROR (Status)) {
+    //DEBUG ((DEBUG_INFO, "Error: %a() - SetGmbus0ClockPortSelect() failed - %r\n", __FUNCTION__, Status));
+    return Status;
+  }
+
+  //
+  // Check for a NACK that has not been cleared yet. Clear it if found.
+  //
+  Status = GetGmbus2Status (&GmbusStatus);
+  if (EFI_ERROR (Status)) {
+    //DEBUG ((DEBUG_INFO, "Error: %a() - GetGmbus2Status() failed - %r\n", __FUNCTION__, Status));
+    return Status;
+  }
+  if (GmbusStatus & B_SA_GTTMMADR_GMBUS2_NACK_INDICATOR) {
+    Status = GmbusRecoverError ();
+    if (EFI_ERROR (Status)) {
+      //DEBUG ((DEBUG_INFO, "Error: %a() - GmbusRecoverError() failed - %r\n", __FUNCTION__, Status));
+      return Status;
+    }
+  }
+
+  return Status;
+}
+
+/**
+  Release the GMBUS controller
+
+  @retval  EFI_SUCCESS                    - The GMBUS has been released successfully.
+  @retval  EFI_DEVICE_ERROR               - An error occurred while accessing the GMBUS I2C controller.
+**/
+EFI_STATUS
+GmbusRelease (
+  VOID
+  )
+{
+  EFI_STATUS              Status;
+
+  //
+  // Clear the GMBUS Port and Clock
+  //
+  Status = SetGmbus0ClockPortSelect (0);
+  if (EFI_ERROR (Status)) {
+    //DEBUG ((DEBUG_INFO, "Error: %a() - SetGmbus0ClockPortSelect() failed - %r\n", __FUNCTION__, Status));
+    return Status;
+  }
+
+  //
+  // Setting the INUSE bit to 1 indicates that software has released the GMBUS resource.
+  // The GMBUS controller will then reset the INUSE bit to 0.
+  //
+  Status = SetGmbus2Status (B_SA_GTTMMADR_GMBUS2_INUSE);
+  if (EFI_ERROR (Status)) {
+    //DEBUG ((DEBUG_INFO, "Error: %a() - SetGmbus0ClockPortSelect() failed - %r\n", __FUNCTION__, Status));
+  }
+
+  return Status;
+}
+
+/**
+  Reads data from the I2C bus using the GMBUS I2C controller
+
+  @param[in]  DdcBusPinPair               - The GPIO pin pair to use for the read operation
+  @param[in]  SlaveAddress                - The I2C device address to read data from
+  @param[in]  SendStopCondition           - TRUE:  After the read is complete, send a STOP condition to the I2C bus
+                                            FALSE: Don't send a STOP after the read is complete, this allows one to
+                                                   immediately send a repeated START condition to the I2C bus after
+                                                   GmbusRead() exits by calling either GmbusRead() or GmbusWrite()
+                                                   immediately after this function returns.
+  @param[in]  SendIndexBeforeRead         - TRUE:  Before executing the read on the I2C bus, first send a WRITE to the
+                                                   I2C bus using the same SlaveAddress (but with BIT0 set to 0 because
+                                                   the operation is a write) the write will contain a single byte, that
+                                                   byte is the data given in the IndexData parameter.
+                                            FALSE: Just send a read to the I2C bus, the IndexData parameter is ignored.
+  @param[in]  IndexData                   - If SendIndexBeforeRead is TRUE, this byte of data will be written to the I2C
+                                            bus before the I2C bus is read. If SendIndexBeforeRead is FALSE, this
+                                            parameter is ignored.
+  @param[in, out]  ByteCount              - The number of bytes to read from the I2C bus. On output, the number of bytes
+                                            actually read.
+  @param[out] ReadBuffer                  - The memory buffer to return the read data.
+
+  @retval  EFI_SUCCESS                    - The data was successfully read.
+  @retval  EFI_INVALID_PARAMETER          - One of the following conditions:
+                                            * ByteCount is 0 or >GMBUS_MAX_BYTES.
+                                            * ReadBuffer is NULL
+                                            * SlaveAddress does not have BIT0 set (required for reads.)
+  @retval  EFI_TIMEOUT                    - The GMBUS I2C controller did not respond within the required timeout period.
+  @retval  EFI_DEVICE_ERROR               - An error occurred while accessing the GMBUS I2C controller.
+**/
+EFI_STATUS
+GmbusRead (
+  IN      UINT8         DdcBusPinPair,
+  IN      UINT8         SlaveAddress,
+  IN      BOOLEAN       SendStopCondition,
+  IN      BOOLEAN       SendIndexBeforeRead,
+  IN      UINT8         IndexData,
+  IN OUT  UINT32        *ByteCount,
+  OUT     UINT8         *ReadBuffer
+  )
+{
+  EFI_STATUS              Status;
+  EFI_STATUS              Status2;
+  UINT32                  Index;
+  UINT32                  GmbusCmdSts;
+  UINT32                  GmbusStatus;
+  UINT32                  GmbusData;
+  UINT32                  BytesRead;
+
+  Status      = EFI_SUCCESS;
+  BytesRead   = 0;
+  GmbusStatus = 0;
+
+  //
+  // Input Validation
+  //
+  if ((*ByteCount) <= 0) {
+    DEBUG ((DEBUG_INFO, "Error: %a() - ByteCount is 0, no bytes to read.\n", __FUNCTION__));
+    return EFI_INVALID_PARAMETER;
+  }
+  if ((*ByteCount) > GMBUS_MAX_BYTES) {
+    DEBUG ((DEBUG_INFO, "Error: %a() - ByteCount is greater than GMBUS_MAX_BYTES[%d].\n", __FUNCTION__, GMBUS_MAX_BYTES));
+    return EFI_INVALID_PARAMETER;
+  }
+  if (ReadBuffer == NULL) {
+    DEBUG ((DEBUG_INFO, "Error: %a() - ReadBuffer is NULL.\n", __FUNCTION__));
+    return EFI_INVALID_PARAMETER;
+  }
+  if ((SlaveAddress & BIT0) != BIT0) {
+    DEBUG ((DEBUG_INFO, "Error: %a() - BIT0 of SlaveAddress should be set for an I2C read.\n", __FUNCTION__));
+    return EFI_INVALID_PARAMETER;
+  }
+
+  //
+  // Configure Gmbus port and clock speed
+  //
+  Status = GmbusPrepare (GMBUS_CLOCK_RATE_50K, (DdcBusPinPair & B_SA_GTTMMADR_GMBUS0_PIN_PAIR_MASK));
+  if (EFI_ERROR (Status)) {
+    DEBUG ((DEBUG_INFO, "Error: %a() - GmbusPrepare() failed - %r\n", __FUNCTION__, Status));
+    goto Done;
+  }
+
+  //
+  // Construct the command for the GMBUS controller
+  //
+  GmbusCmdSts     = ((UINT32) SlaveAddress)                   |
+                    B_SA_GTTMMADR_GMBUS1_BUS_CYCLE_SEL_START  |
+                    B_SA_GTTMMADR_GMBUS1_SW_RDY               |
+                    B_SA_GTTMMADR_GMBUS1_EN_TIMEOUT;
+  GmbusCmdSts    |= (((*ByteCount) << N_SA_GTTMMADR_GMBUS1_TOTAL_BYTE_COUNT) & B_SA_GTTMMADR_GMBUS1_TOTAL_BYTE_COUNT_MASK);
+  if (SendStopCondition) {
+    GmbusCmdSts  |= B_SA_GTTMMADR_GMBUS1_BUS_CYCLE_SEL_STOP;
+  }
+  if (SendIndexBeforeRead) {
+    GmbusCmdSts  |= B_SA_GTTMMADR_GMBUS1_BUS_CYCLE_SEL_INDEX;
+    GmbusCmdSts  |= ((IndexData << N_SA_GTTMMADR_GMBUS1_INDEX) & B_SA_GTTMMADR_GMBUS1_INDEX_MASK);
+  }
+
+  //
+  // Send the command to the GMBUS controller, this will cause the I2C transaction to begin immediately
+  //
+  Status = SetGmbus1Command (GmbusCmdSts);
+  if (EFI_ERROR (Status)) {
+    DEBUG ((DEBUG_INFO, "Error: %a() - SetGmbus1Command() failed - %r\n", __FUNCTION__, Status));
+    goto Done;
+  }
+
+  //
+  // Read the data from the GMBUS controller as it arrives
+  //
+  while (BytesRead < (*ByteCount)) {
+    //
+    // Wait for the GMBUS controller to set the HW_RDY bit to 1
+    //
+    // The HW_RDY bit is set under the following conditions:
+    //
+    // * After a reset
+    // * When a transaction is aborted by the setting the SW_CLR_INT bit in the GMBUS1 register
+    // * When an active GMBUS cycle has terminated with a STOP condition
+    // * During a GMBUS write transaction, when the data register can accept another four bytes of data
+    // * During a GMBUS read transaction, when the data register has four bytes of new data or when the read
+    //   transaction DATA phase is complete and the data register contains all remaining data.
+    //
+    Status = GmbusWaitForReady (B_SA_GTTMMADR_GMBUS2_HW_RDY, TRUE);
+    if (EFI_ERROR (Status)) {
+      DEBUG ((DEBUG_INFO, "Error: %a() - GmbusWaitForReady() failed - %r\n", __FUNCTION__, Status));
+    }
+    //
+    // Check the GMBUS2 register for error conditions (NACK or Slave Stall Timeout)
+    //
+    Status2 = GetGmbus2Status (&GmbusStatus);
+    if (EFI_ERROR (Status2)) {
+      Status = Status2;
+      DEBUG ((DEBUG_INFO, "Error: %a() - GetGmbus2Status() failed - %r\n", __FUNCTION__, Status));
+      goto Done;
+    }
+    if (EFI_ERROR (Status) && ((GmbusStatus & B_SA_GTTMMADR_GMBUS2_NACK_INDICATOR) == 0)) {
+      DEBUG ((DEBUG_INFO, "Error: %a() - Unexpected behavior detected!\n", __FUNCTION__));
+      DEBUG ((DEBUG_INFO, "The GMBUS controller did not encounter a NACK and it did not set the HW_RDY bit.\n"));
+      DEBUG ((DEBUG_INFO, "Status = %r\n", Status));
+      Status = EFI_DEVICE_ERROR;
+      goto Done;
+    }
+    if (((GmbusStatus & B_SA_GTTMMADR_GMBUS2_NACK_INDICATOR) != 0) ||
+        ((GmbusStatus & B_SA_GTTMMADR_GMBUS2_SLAVE_STALL_TIMEOUT_ERROR) != 0)) {
+      //
+      // If a NACK or Slave Stall Timeout occurs, then a bus error has occurred.
+      // In the event of a bus error, one must reset the GMBUS controller to resume normal operation.
+      //
+      DEBUG ((DEBUG_INFO, "Error: %a() - NACK occurred during read operation.\n", __FUNCTION__));
+      Status = GmbusRecoverError ();
+      if (EFI_ERROR (Status)) {
+        DEBUG ((DEBUG_INFO, "Error: %a() - GmbusRecoverError() failed - %r\n", __FUNCTION__, Status));
+        goto Done;
+      }
+      Status = EFI_DEVICE_ERROR;
+      goto Done;
+    }
+    //
+    // No error conditions were encountered, read the data and write it to the data buffer
+    //
+    Status = GetGmbus3Data (&GmbusData);
+    if (EFI_ERROR (Status)) {
+      DEBUG ((DEBUG_INFO, "Error: %a() - GetGmbus3Data() failed - %r\n", __FUNCTION__, Status));
+      goto Done;
+    }
+    for (Index = 0; (Index < sizeof (UINT32)) && (BytesRead < (*ByteCount)); Index++) {
+      ReadBuffer[BytesRead] = (GmbusData >> (Index * 8)) & 0xFF;
+      BytesRead++;
+    }
+  }
+
+  //
+  // Wait for the GMBUS controller to enter the IDLE state
+  //
+  Status = GmbusWaitForReady (B_SA_GTTMMADR_GMBUS2_BUS_ACTIVE, FALSE);
+  if (EFI_ERROR (Status)) {
+    DEBUG ((DEBUG_INFO, "Error: %a() - GmbusWaitForReady() failed - %r\n", __FUNCTION__, Status));
+    return Status;
+  }
+
+Done:
+  Status2 = GmbusRelease ();
+  if (EFI_ERROR (Status2)) {
+    Status = Status2;
+    DEBUG ((DEBUG_INFO, "Error: %a() - GmbusRelease() failed - %r\n", __FUNCTION__, Status));
+  }
+  GmbusResetBusMaster ();
+
+  (*ByteCount) = BytesRead;
+  return Status;
+}
+
+/**
+  Writes data to the I2C bus using the GMBUS I2C controller
+
+  @param[in]  DdcBusPinPair               - The GPIO pin pair to use for the write operation
+  @param[in]  SlaveAddress                - The I2C device address to write data to
+  @param[in]  SendStopCondition           - TRUE:  After the write is complete, send a STOP condition to the I2C bus
+                                            FALSE: Don't send a STOP after the write is complete, this allows one to
+                                                   immediately send a repeated START condition to the I2C bus after
+                                                   GmbusRead() exits by calling either GmbusRead() or GmbusWrite()
+                                                   immediately after this function returns.
+  @param[in]  ByteCount                   - The number of bytes to write to the I2C bus.
+  @param[in]  WriteBuffer                 - The data to be written to the I2C bus.
+
+  @retval  EFI_SUCCESS                    - The data was successfully written.
+  @retval  EFI_INVALID_PARAMETER          - One of the following conditions:
+                                            * ByteCount is 0 or >GMBUS_MAX_BYTES.
+                                            * WriteBuffer is NULL
+                                            * SlaveAddress does not have BIT0 cleared (required for writes.)
+  @retval  EFI_TIMEOUT                    - The GMBUS I2C controller did not respond within the required timeout period.
+  @retval  EFI_DEVICE_ERROR               - An error occurred while accessing the GMBUS I2C controller.
+**/
+EFI_STATUS
+GmbusWrite (
+  IN  UINT8             DdcBusPinPair,
+  IN  UINT8             SlaveAddress,
+  IN  BOOLEAN           SendStopCondition,
+  IN  UINT32            ByteCount,
+  IN  UINT8             *WriteBuffer
+  )
+{
+  EFI_STATUS              Status;
+  EFI_STATUS              Status2;
+  UINT32                  Index;
+  UINT32                  GmbusCmdSts;
+  UINT32                  GmbusStatus;
+  UINT32                  GmbusData;
+  UINT32                  BytesWritten;
+  BOOLEAN                 FirstLoop;
+
+  Status        = EFI_SUCCESS;
+  BytesWritten  = 0;
+  GmbusStatus   = 0;
+  FirstLoop     = TRUE;
+
+  //DEBUG ((DEBUG_INFO, "%a() - Enter\n", __FUNCTION__)); //@todo
+  //
+  // Input Validation
+  //
+  if (ByteCount <= 0) {
+    //DEBUG ((DEBUG_INFO, "Error: %a() - ByteCount is 0, no bytes to write.\n", __FUNCTION__));
+    return EFI_INVALID_PARAMETER;
+  }
+  if (ByteCount > GMBUS_MAX_BYTES) {
+    //DEBUG ((DEBUG_INFO, "Error: %a() - ByteCount is greater than GMBUS_MAX_BYTES[%d].\n", __FUNCTION__, GMBUS_MAX_BYTES));
+    return EFI_INVALID_PARAMETER;
+  }
+  if (WriteBuffer == NULL) {
+    //DEBUG ((DEBUG_INFO, "Error: %a() - ReadBuffer is NULL.\n", __FUNCTION__));
+    return EFI_INVALID_PARAMETER;
+  }
+  if ((SlaveAddress & BIT0) != 0) {
+    //DEBUG ((DEBUG_INFO, "Error: %a() - BIT0 of SlaveAddress should be cleared for an I2C write.\n", __FUNCTION__));
+    return EFI_INVALID_PARAMETER;
+  }
+
+  //
+  // Configure Gmbus port and clock speed
+  //GMBUS_CLOCK_RATE_100K @todo
+  Status = GmbusPrepare (GMBUS_CLOCK_RATE_50K, (DdcBusPinPair & B_SA_GTTMMADR_GMBUS0_PIN_PAIR_MASK));
+  if (EFI_ERROR (Status)) {
+    //DEBUG ((DEBUG_INFO, "Error: %a() - GmbusPrepare() failed - %r\n", __FUNCTION__, Status));
+    goto Done;
+  }
+
+  //
+  // Construct the command for the GMBUS controller
+  //
+  GmbusCmdSts     = ((UINT32) SlaveAddress)                   |
+                    B_SA_GTTMMADR_GMBUS1_BUS_CYCLE_SEL_START  |
+                    B_SA_GTTMMADR_GMBUS1_SW_RDY               |
+                    B_SA_GTTMMADR_GMBUS1_EN_TIMEOUT;
+  GmbusCmdSts    |= ((ByteCount << N_SA_GTTMMADR_GMBUS1_TOTAL_BYTE_COUNT) & B_SA_GTTMMADR_GMBUS1_TOTAL_BYTE_COUNT_MASK);
+  if (SendStopCondition) {
+    GmbusCmdSts  |= B_SA_GTTMMADR_GMBUS1_BUS_CYCLE_SEL_STOP;
+  }
+
+  //
+  // Preload the first 4 bytes of data so that when we send the command to the GMBUS
+  // controller the first 4 bytes of data are ready for transmission. The GMBUS controller requires this.
+  //
+  GmbusData = 0;
+  for (Index = 0; (Index < sizeof (UINT32)) && (BytesWritten < ByteCount); Index++) {
+    GmbusData |= (WriteBuffer[BytesWritten] << (Index * 8));
+    BytesWritten++;
+  }
+  Status = SetGmbus3Data (GmbusData);
+  if (EFI_ERROR (Status)) {
+    //DEBUG ((DEBUG_INFO, "Error: %a() - SetGmbus3Data() failed - %r\n", __FUNCTION__, Status));
+    goto Done;
+  }
+
+  //
+  // Send the command to the GMBUS controller, this will cause the I2C transaction to begin immediately
+  //
+  Status = SetGmbus1Command (GmbusCmdSts);
+  if (EFI_ERROR (Status)) {
+    //DEBUG ((DEBUG_INFO, "Error: %a() - SetGmbus1Command() failed - %r\n", __FUNCTION__, Status));
+    goto Done;
+  }
+
+  while ((BytesWritten < ByteCount) || FirstLoop) {
+    //DEBUG ((DEBUG_INFO, "BytesWritten: %d\n", (UINTN) BytesWritten));
+    //DEBUG ((DEBUG_INFO, "ByteCount: %d\n", (UINTN) ByteCount));
+    //
+    // If this is not the first loop, load the next 4 bytes of data into the
+    // GMBUS controller's data buffer.
+    //
+    if(!FirstLoop) {
+      GmbusData = 0;
+      for (Index = 0; (Index < sizeof (UINT32)) && (BytesWritten < ByteCount); Index++) {
+        GmbusData |= (WriteBuffer[BytesWritten] << (Index * 8));
+        BytesWritten++;
+      }
+      Status = SetGmbus3Data (GmbusData);
+      if (EFI_ERROR (Status)) {
+        //DEBUG ((DEBUG_INFO, "Error: %a() - SetGmbus3Data() failed - %r\n", __FUNCTION__, Status));
+        goto Done;
+      }
+    }
+    FirstLoop = FALSE;
+    //DEBUG ((DEBUG_INFO, "Sending: %x\n", (UINTN) GmbusData));
+
+    //
+    // Wait for the GMBUS controller to set the HW_RDY bit to 1
+    //
+    // The HW_RDY bit is set under the following conditions:
+    //
+    // * After a reset
+    // * When a transaction is aborted by the setting the SW_CLR_INT bit in the GMBUS1 register
+    // * When an active GMBUS cycle has terminated with a STOP condition
+    // * During a GMBUS write transaction, when the data register can accept another four bytes of data
+    // * During a GMBUS read transaction, when the data register has four bytes of new data or when the read
+    //   transaction DATA phase is complete and the data register contains all remaining data.
+    //
+    Status = GmbusWaitForReady (B_SA_GTTMMADR_GMBUS2_HW_RDY, TRUE);
+    if (EFI_ERROR (Status)) {
+      //DEBUG ((DEBUG_INFO, "Error: %a() - GmbusWaitForReady() failed - %r\n", __FUNCTION__, Status));
+    }
+    //
+    // Check the GMBUS2 register for error conditions (NACK or Slave Stall Timeout)
+    //
+    Status2 = GetGmbus2Status (&GmbusStatus);
+    if (EFI_ERROR (Status2)) {
+      Status = Status2;
+      //DEBUG ((DEBUG_INFO, "Error: %a() - GetGmbus2Status() failed - %r\n", __FUNCTION__, Status));
+      goto Done;
+    }
+    if (EFI_ERROR (Status) && ((GmbusStatus & B_SA_GTTMMADR_GMBUS2_NACK_INDICATOR) == 0)) {
+      //DEBUG ((DEBUG_INFO, "Error: %a() - Unexpected behavior detected!\n", __FUNCTION__));
+      //DEBUG ((DEBUG_INFO, "The GMBUS controller did not encounter a NACK and it did not set the HW_RDY bit.\n"));
+      //DEBUG ((DEBUG_INFO, "Status = %r\n", Status));
+      Status = EFI_DEVICE_ERROR;
+      goto Done;
+    }
+    if (((GmbusStatus & B_SA_GTTMMADR_GMBUS2_NACK_INDICATOR) != 0) ||
+        ((GmbusStatus & B_SA_GTTMMADR_GMBUS2_SLAVE_STALL_TIMEOUT_ERROR) != 0)) {
+      //
+      // If a NACK or Slave Stall Timeout occurs, then a bus error has occurred.
+      // In the event of a bus error, one must reset the GMBUS controller to resume normal operation.
+      //
+      //DEBUG ((DEBUG_INFO, "Error: %a() - NACK occurred during write operation.\n", __FUNCTION__));
+      Status = GmbusRecoverError ();
+      if (EFI_ERROR (Status)) {
+        //DEBUG ((DEBUG_INFO, "Error: %a() - GmbusRecoverError() failed - %r\n", __FUNCTION__, Status));
+        goto Done;
+      }
+      Status = EFI_DEVICE_ERROR;
+      goto Done;
+    }
+  }
+
+  //
+  // Wait for the GMBUS controller to enter the IDLE state
+  //
+  Status = GmbusWaitForReady (B_SA_GTTMMADR_GMBUS2_BUS_ACTIVE, FALSE);
+  if (EFI_ERROR (Status)) {
+    //DEBUG ((DEBUG_INFO, "Error: %a() - GmbusWaitForReady() failed - %r\n", __FUNCTION__, Status));
+    return Status;
+  }
+
+Done:
+  Status2 = GmbusRelease ();
+  if (EFI_ERROR (Status2)) {
+    Status = Status2;
+    //DEBUG ((DEBUG_INFO, "Error: %a() - GmbusRelease() failed - %r\n", __FUNCTION__, Status));
+  }
+  GmbusResetBusMaster ();
+
+  return Status;
+}
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/Gmbus.h b/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/Gmbus.h
new file mode 100644
index 0000000000..6c376968d2
--- /dev/null
+++ b/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/Gmbus.h
@@ -0,0 +1,324 @@
+/** @file
+  GMBUS I/O Registers and Functions
+
+  Copyright (c) 2022, Intel Corporation. All rights reserved.<BR>
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+  <b>Conventions</b>:
+  - Prefixes:
+    - Definitions beginning with "R_" are registers
+    - Definitions beginning with "B_" are bits within registers
+    - Definitions beginning with "V_" are meaningful values of bits within the registers
+    - Definitions beginning with "S_" are register sizes
+    - Definitions beginning with "N_" are the bit position
+  - In general, SA registers are denoted by "_SA_" in register names
+  - Registers / bits that are different between SA generations are denoted by
+    "_SA_[generation_name]_" in register/bit names. e.g., "_SA_HSW_"
+  - Registers / bits that are different between SKUs are denoted by "_[SKU_name]"
+    at the end of the register/bit names
+  - Registers / bits of new devices introduced in a SA generation will be just named
+    as "_SA_" without [generation_name] inserted.
+**/
+
+#include <Uefi.h>
+
+//@todo: Consolidate with CoffeeLakeSiliconPkg
+#define SA_SEG_NUM                                        0x0000000
+#define SA_IGD_BUS                                        0x0000000
+#define SA_IGD_DEV                                        0x0000002
+#define SA_IGD_FUN_0                                      0x0000000
+#define R_SA_IGD_CMD                                      0x0000004
+#define R_SA_IGD_GTTMMADR                                 0x0000010
+#define R_SA_GTTMMADR_GMBUS0_CLKPRTSEL                    0x00C5100
+#define B_SA_GTTMMADR_GMBUS0_PIN_PAIR_MASK                0x0000007
+#define R_SA_GTTMMADR_GMBUS1_CMDSTS                       0x00C5104
+#define B_SA_GTTMMADR_GMBUS1_SW_CLR_INT                   BIT31
+#define B_SA_GTTMMADR_GMBUS1_SW_RDY                       BIT30
+#define B_SA_GTTMMADR_GMBUS1_EN_TIMEOUT                   BIT29
+#define B_SA_GTTMMADR_GMBUS1_BUS_CYCLE_SEL_MASK           (BIT27 | BIT26 | BIT25)
+/*
+BUS_CYCLE_SEL Decoder Table
+===========================
+Value | Name                    | Description
+------+-------------------------+------------------------------------------------------------------------------------
+000b  | No cycle                | No GMBUS cycle is generated
+001b  | No Index, No Stop, Wait | GMBUS cycle is generated without an INDEX, with no STOP, and ends with a WAIT
+010b  | Reserved                | Reserved
+011b  | Index, No Stop, Wait    | GMBUS cycle is generated with an INDEX, with no STOP, and ends with a WAIT
+100b  | Gen Stop                | Generates a STOP if currently in a WAIT or after the completion of the current byte
+101b  | No Index, Stop          | GMBUS cycle is generated without an INDEX and with a STOP
+110b  | Reserved                | Reserved
+111b  | Index, Stop             | GMBUS cycle is generated with an INDEX and with a STOP All
+*/
+#define B_SA_GTTMMADR_GMBUS1_BUS_CYCLE_SEL_STOP           BIT27
+#define B_SA_GTTMMADR_GMBUS1_BUS_CYCLE_SEL_INDEX          BIT26
+#define B_SA_GTTMMADR_GMBUS1_BUS_CYCLE_SEL_START          BIT25
+#define B_SA_GTTMMADR_GMBUS1_TOTAL_BYTE_COUNT_MASK        0x1FF0000
+#define N_SA_GTTMMADR_GMBUS1_TOTAL_BYTE_COUNT             16
+#define B_SA_GTTMMADR_GMBUS1_INDEX_MASK                   0x000FF00
+#define N_SA_GTTMMADR_GMBUS1_INDEX                        8
+#define R_SA_GTTMMADR_GMBUS2_STATUS                       0x00C5108
+#define B_SA_GTTMMADR_GMBUS2_INUSE                        BIT15
+#define B_SA_GTTMMADR_GMBUS2_SLAVE_STALL_TIMEOUT_ERROR    BIT13
+#define B_SA_GTTMMADR_GMBUS2_HW_RDY                       BIT11
+#define B_SA_GTTMMADR_GMBUS2_NACK_INDICATOR               BIT10
+#define B_SA_GTTMMADR_GMBUS2_BUS_ACTIVE                   BIT9
+#define R_SA_GTTMMADR_GMBUS3_DATA                         0x00C510C
+
+#define GMBUS_MAX_BYTES                                   (0x1FF - 0x8)   //9-bits minus 8 bytes
+
+#define GMBUS_CLOCK_RATE_100K                             0x0000000
+#define GMBUS_CLOCK_RATE_50K                              0x0000001
+#define GMBUS_CLOCK_RATE_400K                             0x0000002
+#define GMBUS_CLOCK_RATE_1M                               0x0000003
+
+#define GMBUS_TIMEOUT                                     0x00249F0
+
+/**
+  Gets the GttMmAdr BAR value
+
+  @retval  The current value of the GTTMMADR BAR
+**/
+UINTN
+GmbusGetGttMmAdr (
+  VOID
+  );
+
+/**
+  Reset Bus Master and Memory access on the IGD device to the initial state at
+  the start of the current transaction.
+**/
+VOID
+GmbusResetBusMaster (
+  VOID
+  );
+
+/**
+  Returns a flag indicating whether the IGD device bus master enable needs to
+  be disabled at the end of the current transaction
+
+  @retval  TRUE                           - IGD Bus Master Enable needs to be reset
+  @retval  FALSE                          - IGD Bus Master Enable does not need to be reset
+**/
+BOOLEAN
+GetIgdBusMasterReset (
+  VOID
+  );
+
+/**
+  Sets a flag indicating whether the IGD device bus master enable needs to
+  be disabled at the end of the current transaction
+
+  @param[in]  IgdBusMasterReset           - IGD device bus master enable flag
+**/
+VOID
+SetIgdBusMasterReset (
+  BOOLEAN IgdBusMasterReset
+  );
+
+/**
+  Writes to the GMBUS0 register (Clock/Port Select)
+
+  @param[in]  GmbusClkPrtSel              - The value to write to GMBUS0
+
+  @retval  EFI_SUCCESS                    - GMBUS0 was successfully written.
+  @retval  EFI_DEVICE_ERROR               - An error occurred while writting to GMBUS0
+**/
+EFI_STATUS
+SetGmbus0ClockPortSelect (
+  IN  UINT32             GmbusClkPrtSel
+  );
+
+/**
+  Writes to the GMBUS1 register (Command/Status)
+
+  @param[in]  GmbusCmdSts                 - The value to write to GMBUS1
+
+  @retval  EFI_SUCCESS                    - GMBUS1 was successfully written.
+  @retval  EFI_DEVICE_ERROR               - An error occurred while writting to GMBUS1
+**/
+EFI_STATUS
+SetGmbus1Command (
+  IN  UINT32             GmbusCmdSts
+  );
+
+/**
+  Reads from the GMBUS2 register (GMBUS Status)
+
+  @param[out]  GmbusStatus                - The value read from GMBUS2
+
+  @retval  EFI_SUCCESS                    - GMBUS2 was successfully read.
+  @retval  EFI_DEVICE_ERROR               - An error occurred while reading from GMBUS2
+**/
+EFI_STATUS
+GetGmbus2Status (
+  OUT  UINT32             *GmbusStatus
+  );
+
+/**
+  Writes to the GMBUS2 register (GMBUS Status)
+
+  @param[in]  GmbusStatus                 - The value to write to GMBUS2
+
+  @retval  EFI_SUCCESS                    - GMBUS2 was successfully written.
+  @retval  EFI_DEVICE_ERROR               - An error occurred while writting to GMBUS2
+**/
+EFI_STATUS
+SetGmbus2Status (
+  IN  UINT32             GmbusStatus
+  );
+
+/**
+  Reads from the GMBUS3 register (GMBUS Data Buffer)
+
+  @param[out]  GmbusData                  - The value read from GMBUS3
+
+  @retval  EFI_SUCCESS                    - GMBUS2 was successfully read.
+  @retval  EFI_DEVICE_ERROR               - An error occurred while reading from GMBUS2
+**/
+EFI_STATUS
+GetGmbus3Data (
+  OUT  UINT32             *GmbusData
+  );
+
+/**
+  Writes to the GMBUS3 register (GMBUS Data Buffer)
+
+  @param[in]  GmbusData                   - The value to write to GMBUS3
+
+  @retval  EFI_SUCCESS                    - GMBUS3 was successfully written.
+  @retval  EFI_DEVICE_ERROR               - An error occurred while writting to GMBUS3
+**/
+EFI_STATUS
+SetGmbus3Data (
+  IN  UINT32             GmbusData
+  );
+
+/**
+  Set and clear the software clear interrupt bit. This causes a local reset on the GMBUS controller.
+
+  @retval  EFI_SUCCESS                    - The GMBUS error was successfully cleared.
+  @retval  EFI_TIMEOUT                    - The GMBUS I2C controller did not respond within the required timeout period.
+  @retval  EFI_DEVICE_ERROR               - An error occurred while accessing the GMBUS I2C controller.
+**/
+EFI_STATUS
+GmbusRecoverError (
+  VOID
+  );
+
+/**
+  Wait for a given bitmask of status bits to de-assert to zero.
+
+  @param[in]  StatusBitMask               - A bitmask of status bits to be compared to the present value of GMBUS2
+  @param[in]  WaitForAssertion            - If TRUE, the Status Bit indicated must be 1, otherwise it must be 0.
+
+  @retval  EFI_SUCCESS                    - The GMBUS controller has cleared all of the bits in the bitmask.
+  @retval  EFI_TIMEOUT                    - The GMBUS controller did not clear all of the bits in the bitmask
+                                            within the required timeout period.
+  @retval  EFI_DEVICE_ERROR               - An error occurred while accessing the GMBUS I2C controller.
+**/
+EFI_STATUS
+GmbusWaitForReady (
+  IN  UINT32              StatusBitMask,
+  IN  BOOLEAN             WaitForAssertion
+  );
+
+/**
+  Initialize the GMBUS to use a given GPIO pin pair and clock speed in preparation
+  for sending a I2C command to the GMBUS controller.
+
+  @param[in]  BusSpeed                    - The clock rate for the I2C bus.
+  @param[in]  DdcBusPinPair               - The GPIO pin pair the GMBUS controller should use.
+
+  @retval  EFI_SUCCESS                    - The GMBUS has been initialized successfully.
+  @retval  EFI_INVALID_PARAMETER          - The given BusSpeed does not match a valid clock rate value.
+  @retval  EFI_TIMEOUT                    - The GMBUS I2C controller did not respond within the required timeout period.
+  @retval  EFI_DEVICE_ERROR               - An error occurred while accessing the GMBUS I2C controller.
+**/
+EFI_STATUS
+GmbusPrepare (
+  IN  UINT8             BusSpeed,
+  IN  UINT8             DdcBusPinPair
+  );
+
+/**
+  Release the GMBUS controller
+
+  @retval  EFI_SUCCESS                    - The GMBUS has been released successfully.
+  @retval  EFI_DEVICE_ERROR               - An error occurred while accessing the GMBUS I2C controller.
+**/
+EFI_STATUS
+GmbusRelease (
+  VOID
+  );
+
+/**
+  Reads data from the I2C bus using the GMBUS I2C controller
+
+  @param[in]  DdcBusPinPair               - The GPIO pin pair to use for the read operation
+  @param[in]  SlaveAddress                - The I2C device address to read data from
+  @param[in]  SendStopCondition           - TRUE:  After the read is complete, send a STOP condition to the I2C bus
+                                            FALSE: Don't send a STOP after the read is complete, this allows one to
+                                                   immediately send a repeated START condition to the I2C bus after
+                                                   GmbusRead() exits by calling either GmbusRead() or GmbusWrite()
+                                                   immediately after this function returns.
+  @param[in]  SendIndexBeforeRead         - TRUE:  Before executing the read on the I2C bus, first send a WRITE to the
+                                                   I2C bus using the same SlaveAddress (but with BIT0 set to 0 because
+                                                   the operation is a write) the write will contain a single byte, that
+                                                   byte is the data given in the IndexData parameter.
+                                            FALSE: Just send a read to the I2C bus, the IndexData parameter is ignored.
+  @param[in]  IndexData                   - If SendIndexBeforeRead is TRUE, this byte of data will be written to the I2C
+                                            bus before the I2C bus is read. If SendIndexBeforeRead is FALSE, this
+                                            parameter is ignored.
+  @param[in, out]  ByteCount              - The number of bytes to read from the I2C bus. On output, the number of bytes
+                                            actually read.
+  @param[out] ReadBuffer                  - The memory buffer to return the read data.
+
+  @retval  EFI_SUCCESS                    - The data was successfully read.
+  @retval  EFI_INVALID_PARAMETER          - One of the following conditions:
+                                            * ByteCount is 0 or >GMBUS_MAX_BYTES.
+                                            * ReadBuffer is NULL
+                                            * SlaveAddress does not have BIT0 set (required for reads.)
+  @retval  EFI_TIMEOUT                    - The GMBUS I2C controller did not respond within the required timeout period.
+  @retval  EFI_DEVICE_ERROR               - An error occurred while accessing the GMBUS I2C controller.
+**/
+EFI_STATUS
+GmbusRead (
+  IN      UINT8         DdcBusPinPair,
+  IN      UINT8         SlaveAddress,
+  IN      BOOLEAN       SendStopCondition,
+  IN      BOOLEAN       SendIndexBeforeRead,
+  IN      UINT8         IndexData,
+  IN OUT  UINT32        *ByteCount,
+  OUT     UINT8         *ReadBuffer
+  );
+
+/**
+  Writes data to the I2C bus using the GMBUS I2C controller
+
+  @param[in]  DdcBusPinPair               - The GPIO pin pair to use for the write operation
+  @param[in]  SlaveAddress                - The I2C device address to write data to
+  @param[in]  SendStopCondition           - TRUE:  After the write is complete, send a STOP condition to the I2C bus
+                                            FALSE: Don't send a STOP after the write is complete, this allows one to
+                                                   immediately send a repeated START condition to the I2C bus after
+                                                   GmbusRead() exits by calling either GmbusRead() or GmbusWrite()
+                                                   immediately after this function returns.
+  @param[in]  ByteCount                   - The number of bytes to write to the I2C bus.
+  @param[in]  WriteBuffer                 - The data to be written to the I2C bus.
+
+  @retval  EFI_SUCCESS                    - The data was successfully written.
+  @retval  EFI_INVALID_PARAMETER          - One of the following conditions:
+                                            * ByteCount is 0 or >GMBUS_MAX_BYTES.
+                                            * WriteBuffer is NULL
+                                            * SlaveAddress does not have BIT0 cleared (required for writes.)
+  @retval  EFI_TIMEOUT                    - The GMBUS I2C controller did not respond within the required timeout period.
+  @retval  EFI_DEVICE_ERROR               - An error occurred while accessing the GMBUS I2C controller.
+**/
+EFI_STATUS
+GmbusWrite (
+  IN  UINT8             DdcBusPinPair,
+  IN  UINT8             SlaveAddress,
+  IN  BOOLEAN           SendStopCondition,
+  IN  UINT32            ByteCount,
+  IN  UINT8             *WriteBuffer
+  );
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/I2cDebugPortProtocol.c b/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/I2cDebugPortProtocol.c
new file mode 100644
index 0000000000..1a31c98347
--- /dev/null
+++ b/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/I2cDebugPortProtocol.c
@@ -0,0 +1,194 @@
+/** @file
+  I2C Debug Port Protocol Implementation
+
+  Copyright (c) 2022, Intel Corporation. All rights reserved.<BR>
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Base.h>
+#include <Library/BaseLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/PcdLib.h>
+#include <Library/TimerLib.h>
+
+#include <IgfxI2c.h>
+#include <Gmbus.h>
+#include <I2cDebugPortProtocol.h>
+
+/**
+  Writes data to the I2C debug port
+
+  @param[in]  Buffer                      - The data to be written to the I2C debug port.
+  @param[in]  Count                       - The number of bytes to write to the I2C debug port.
+
+  @retval  EFI_SUCCESS                    - The data was successfully written.
+  @retval  EFI_INVALID_PARAMETER          - One of the following conditions:
+                                            * ByteCount is 0
+                                            * Buffer is NULL
+  @retval  EFI_TIMEOUT                    - The I2C controller did not respond within the required timeout period.
+  @retval  EFI_DEVICE_ERROR               - An error occurred while accessing the I2C controller.
+**/
+EFI_STATUS
+I2cDebugPortWrite (
+  IN  UINT8             *Buffer,
+  IN  UINT32            Count
+  )
+{
+  UINT8       WriteBuffer[I2C_DEBUG_PORT_MAX_DATA_SIZE + 1];
+  EFI_STATUS  Status;
+  UINT32      Index;
+  UINT8       CurrentSize;
+  UINT8       DdcBusPinPair;
+
+  //DEBUG ((DEBUG_INFO, "I2cDebugPortWrite() - Enter\n"));
+  if (Count <= 0) {
+    return EFI_INVALID_PARAMETER;
+  }
+  if (Buffer == NULL) {
+    return EFI_INVALID_PARAMETER;
+  }
+  Status = GetGmbusBusPinPairForI2cDebugPort (&DdcBusPinPair);
+  if (EFI_ERROR (Status)) {
+    return Status;
+  }
+  RaiseTplForI2cDebugPortAccess ();
+  for (Index = 0; Index < Count; Index += I2C_DEBUG_PORT_MAX_DATA_SIZE) {
+    MicroSecondDelay (3000);  //3ms stall to let the BusPirate catch up
+    if ((Index + I2C_DEBUG_PORT_MAX_DATA_SIZE) >= Count) {
+      CurrentSize = (UINT8) (Count - Index);
+    } else {
+      CurrentSize = I2C_DEBUG_PORT_MAX_DATA_SIZE;
+    }
+    WriteBuffer[0]  = (I2C_DEBUG_PORT_WRITE_COMMAND << I2C_DEBUG_PORT_COMMAND_BIT_POSITION) |
+                      (CurrentSize & I2C_DEBUG_PORT_DATA_SIZE_BIT_MASK);
+    CopyMem (&(WriteBuffer[1]), &(Buffer[Index]), CurrentSize);
+    Status = GmbusWrite (DdcBusPinPair, I2C_DEBUG_PORT_WRITE_DEVICE_ADDRESS, TRUE, CurrentSize + 1, &(WriteBuffer[0]));
+    if (EFI_ERROR (Status)) {
+      break;
+    }
+  }
+  RestoreTplAfterI2cDebugPortAccess ();
+  //DEBUG ((DEBUG_INFO, "I2cDebugPortWrite() - Exit\n"));
+  return Status;
+}
+
+/**
+  Reads data from the I2C debug port
+
+  @param[out]     Buffer                  - The memory buffer to return the read data.
+  @param[in, out] Count                   - The number of bytes to read from the I2C debug port.
+                                            On output, the number of bytes actually read.
+
+  @retval  EFI_SUCCESS                    - The data was successfully read.
+  @retval  EFI_INVALID_PARAMETER          - One of the following conditions:
+                                            * ByteCount is 0
+                                            * Buffer is NULL
+  @retval  EFI_TIMEOUT                    - The I2C controller did not respond within the required timeout period.
+  @retval  EFI_DEVICE_ERROR               - An error occurred while accessing the I2C controller.
+**/
+EFI_STATUS
+I2cDebugPortRead (
+  OUT     UINT8         *Buffer,
+  IN OUT  UINT32        *Count
+  )
+{
+  EFI_STATUS  Status;
+  UINT32      Index;
+  UINT32      BytesRead;
+  UINT32      CurrentSize;
+  UINT8       DdcBusPinPair;
+  UINT8       GmbusIndexData;
+
+  //DEBUG ((DEBUG_INFO, "I2cDebugPortRead() - Enter\n"));
+  BytesRead = 0;
+  if ((*Count) <= 0) {
+    return EFI_INVALID_PARAMETER;
+  }
+  if (Buffer == NULL) {
+    return EFI_INVALID_PARAMETER;
+  }
+  Status = GetGmbusBusPinPairForI2cDebugPort (&DdcBusPinPair);
+  if (EFI_ERROR (Status)) {
+    return Status;
+  }
+  RaiseTplForI2cDebugPortAccess ();
+  for (Index = 0; Index < (*Count); Index += I2C_DEBUG_PORT_MAX_DATA_SIZE) {
+    MicroSecondDelay (3000);  //3ms stall to let the BusPirate catch up
+    if ((Index + I2C_DEBUG_PORT_MAX_DATA_SIZE) >= (*Count)) {
+      CurrentSize = (*Count) - Index;
+    } else {
+      CurrentSize = I2C_DEBUG_PORT_MAX_DATA_SIZE;
+    }
+    GmbusIndexData  = (I2C_DEBUG_PORT_READ_COMMAND << I2C_DEBUG_PORT_COMMAND_BIT_POSITION) |
+                      (CurrentSize & I2C_DEBUG_PORT_DATA_SIZE_BIT_MASK);
+    Status  = GmbusRead (
+                DdcBusPinPair,
+                I2C_DEBUG_PORT_READ_DEVICE_ADDRESS,
+                TRUE,
+                TRUE,
+                GmbusIndexData,
+                &CurrentSize,
+                &(Buffer[Index])
+                );
+    if (EFI_ERROR (Status)) {
+      break;
+    }
+    BytesRead += CurrentSize;
+    if (((Index + I2C_DEBUG_PORT_MAX_DATA_SIZE) < (*Count)) && (CurrentSize < I2C_DEBUG_PORT_MAX_DATA_SIZE)) {
+      break;
+    }
+  }
+  RestoreTplAfterI2cDebugPortAccess ();
+
+  (*Count) = BytesRead;
+  //DEBUG ((DEBUG_INFO, "I2cDebugPortRead() - Exit\n"));
+  return Status;
+}
+
+/**
+  Queries the I2C debug port to see if there are any data waiting to be read
+
+  @param[out] NumberOfBytesInFifoBuffer   - The number of bytes sitting in the I2C debug port's
+                                            FIFO buffer waiting to be read
+
+  @retval  EFI_SUCCESS                    - The I2C debug port was successfully queried
+  @retval  EFI_INVALID_PARAMETER          - One of the following conditions:
+                                            * NumberOfBytesInFifoBuffer is NULL
+  @retval  EFI_TIMEOUT                    - The I2C controller did not respond within the required timeout period.
+  @retval  EFI_DEVICE_ERROR               - An error occurred while accessing the I2C controller.
+**/
+EFI_STATUS
+I2cDebugPortReadyToRead (
+  OUT     UINT8         *NumberOfBytesInFifoBuffer
+  )
+{
+  EFI_STATUS  Status;
+  UINT32      BytesRead;
+  UINT8       DdcBusPinPair;
+  UINT8       GmbusIndexData;
+
+  //DEBUG ((DEBUG_INFO, "I2cDebugPortReadyToRead() - Enter\n"));
+  BytesRead = 1;
+  if (NumberOfBytesInFifoBuffer == NULL) {
+    return EFI_INVALID_PARAMETER;
+  }
+  Status = GetGmbusBusPinPairForI2cDebugPort (&DdcBusPinPair);
+  if (EFI_ERROR (Status)) {
+    return Status;
+  }
+  MicroSecondDelay (3000);  //3ms stall to let the BusPirate catch up
+  GmbusIndexData  = (I2C_DEBUG_PORT_READY_TO_READ_COMMAND << I2C_DEBUG_PORT_COMMAND_BIT_POSITION) |
+                    (1 & I2C_DEBUG_PORT_DATA_SIZE_BIT_MASK); //READY_TO_READ always returns 1 byte
+  RaiseTplForI2cDebugPortAccess ();
+  Status = GmbusRead (DdcBusPinPair, I2C_DEBUG_PORT_READ_DEVICE_ADDRESS, TRUE, TRUE, GmbusIndexData, &BytesRead, NumberOfBytesInFifoBuffer);
+  if (EFI_ERROR (Status)) {
+    return Status;
+  }
+  RestoreTplAfterI2cDebugPortAccess ();
+  if (BytesRead != 1) {
+    Status = EFI_DEVICE_ERROR;
+  }
+  //DEBUG ((DEBUG_INFO, "I2cDebugPortReadyToRead() - Exit\n"));
+  return Status;
+}
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/I2cDebugPortProtocol.h b/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/I2cDebugPortProtocol.h
new file mode 100644
index 0000000000..caf195469a
--- /dev/null
+++ b/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/I2cDebugPortProtocol.h
@@ -0,0 +1,77 @@
+/** @file
+  I2C Debug Port Protocol Implementation
+
+  Copyright (c) 2022, Intel Corporation. All rights reserved.<BR>
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Uefi/UefiBaseType.h>
+
+#define I2C_DEBUG_PORT_WRITE_DEVICE_ADDRESS 0xDE
+#define I2C_DEBUG_PORT_READ_DEVICE_ADDRESS 0xDF
+
+#define I2C_DEBUG_PORT_WRITE_COMMAND 0x00
+#define I2C_DEBUG_PORT_READ_COMMAND 0x01
+#define I2C_DEBUG_PORT_READY_TO_READ_COMMAND 0x02
+
+#define I2C_DEBUG_PORT_COMMAND_BIT_POSITION 5
+#define I2C_DEBUG_PORT_COMMAND_BIT_MASK 0x7
+#define I2C_DEBUG_PORT_DATA_SIZE_BIT_MASK 0x1F
+#define I2C_DEBUG_PORT_MAX_DATA_SIZE  I2C_DEBUG_PORT_DATA_SIZE_BIT_MASK
+
+/**
+  Writes data to the I2C debug port
+
+  @param[in]  Buffer                      - The data to be written to the I2C debug port.
+  @param[in]  Count                       - The number of bytes to write to the I2C debug port.
+
+  @retval  EFI_SUCCESS                    - The data was successfully written.
+  @retval  EFI_INVALID_PARAMETER          - One of the following conditions:
+                                            * ByteCount is 0
+                                            * Buffer is NULL
+  @retval  EFI_TIMEOUT                    - The I2C controller did not respond within the required timeout period.
+  @retval  EFI_DEVICE_ERROR               - An error occurred while accessing the I2C controller.
+**/
+EFI_STATUS
+I2cDebugPortWrite (
+  IN  UINT8             *Buffer,
+  IN  UINT32            Count
+  );
+
+/**
+  Reads data from the I2C debug port
+
+  @param[out]     Buffer                  - The memory buffer to return the read data.
+  @param[in, out] Count                   - The number of bytes to read from the I2C debug port.
+                                            On output, the number of bytes actually read.
+
+  @retval  EFI_SUCCESS                    - The data was successfully read.
+  @retval  EFI_INVALID_PARAMETER          - One of the following conditions:
+                                            * ByteCount is 0
+                                            * Buffer is NULL
+  @retval  EFI_TIMEOUT                    - The I2C controller did not respond within the required timeout period.
+  @retval  EFI_DEVICE_ERROR               - An error occurred while accessing the I2C controller.
+**/
+EFI_STATUS
+I2cDebugPortRead (
+  OUT     UINT8         *Buffer,
+  IN OUT  UINT32        *Count
+  );
+
+/**
+  Queries the I2C debug port to see if there are any data waiting to be read
+
+  @param[out] NumberOfBytesInFifoBuffer   - The number of bytes sitting in the I2C debug port's
+                                            FIFO buffer waiting to be read
+
+  @retval  EFI_SUCCESS                    - The I2C debug port was successfully queried
+  @retval  EFI_INVALID_PARAMETER          - One of the following conditions:
+                                            * NumberOfBytesInFifoBuffer is NULL
+  @retval  EFI_TIMEOUT                    - The I2C controller did not respond within the required timeout period.
+  @retval  EFI_DEVICE_ERROR               - An error occurred while accessing the I2C controller.
+**/
+EFI_STATUS
+I2cDebugPortReadyToRead (
+  OUT     UINT8         *NumberOfBytesInFifoBuffer
+  );
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/I2cDebugPortTplDxe.c b/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/I2cDebugPortTplDxe.c
new file mode 100644
index 0000000000..9d69c03657
--- /dev/null
+++ b/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/I2cDebugPortTplDxe.c
@@ -0,0 +1,44 @@
+/** @file
+  Serial I/O Port library implementation for the HDMI I2C Debug Port
+  DXE Library implementation
+
+Copyright (c) 2022, Intel Corporation. All rights reserved.<BR>
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Uefi.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/UefiLib.h>
+
+STATIC EFI_TPL  mPreviousTpl  = 0;
+
+/**
+  For boot phases that utilize task priority levels (TPLs), this function raises
+  the TPL to the appriopriate level needed to execute I/O to the I2C Debug Port
+**/
+VOID
+RaiseTplForI2cDebugPortAccess (
+  VOID
+  )
+{
+  if (EfiGetCurrentTpl () < TPL_NOTIFY) {
+    mPreviousTpl = gBS->RaiseTPL (TPL_NOTIFY);
+  }
+}
+
+/**
+  For boot phases that utilize task priority levels (TPLs), this function
+  restores the TPL to the previous level after I/O to the I2C Debug Port is
+  complete
+**/
+VOID
+RestoreTplAfterI2cDebugPortAccess (
+  VOID
+  )
+{
+  if (mPreviousTpl > 0) {
+    gBS->RestoreTPL (mPreviousTpl);
+    mPreviousTpl = 0;
+  }
+}
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/I2cDebugPortTplNull.c b/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/I2cDebugPortTplNull.c
new file mode 100644
index 0000000000..791465a0eb
--- /dev/null
+++ b/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/I2cDebugPortTplNull.c
@@ -0,0 +1,36 @@
+/** @file
+  Serial I/O Port library implementation for the HDMI I2C Debug Port
+  Null implementation of Task Priority Level functions.
+  This implementation is used by SEC, PEI, & SMM
+
+Copyright (c) 2022, Intel Corporation. All rights reserved.<BR>
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Uefi/UefiBaseType.h>
+
+/**
+  For boot phases that utilize task priority levels (TPLs), this function raises
+  the TPL to the appriopriate level needed to execute I/O to the I2C Debug Port
+**/
+VOID
+RaiseTplForI2cDebugPortAccess (
+  VOID
+  )
+{
+  return;
+}
+
+/**
+  For boot phases that utilize task priority levels (TPLs), this function
+  restores the TPL to the previous level after I/O to the I2C Debug Port is
+  complete
+**/
+VOID
+RestoreTplAfterI2cDebugPortAccess (
+  VOID
+  )
+{
+  return;
+}
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/I2cHdmiDebugSerialPortLib.c b/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/I2cHdmiDebugSerialPortLib.c
new file mode 100644
index 0000000000..89a01b868d
--- /dev/null
+++ b/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/I2cHdmiDebugSerialPortLib.c
@@ -0,0 +1,201 @@
+/** @file
+  Serial I/O Port library implementation for the HDMI I2C Debug Port
+
+Copyright (c) 2022, Intel Corporation. All rights reserved.<BR>
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Base.h>
+#include <Library/BaseLib.h>
+#include <Library/SerialPortLib.h>
+#include <Library/PcdLib.h>
+#include <Library/TimerLib.h>
+
+#include <IgfxI2c.h>
+#include <I2cDebugPortProtocol.h>
+
+/**
+  Initialize the serial device hardware.
+
+  If no initialization is required, then return RETURN_SUCCESS.
+  If the serial device was successfully initialized, then return RETURN_SUCCESS.
+  If the serial device could not be initialized, then return RETURN_DEVICE_ERROR.
+
+  @retval RETURN_SUCCESS        The serial device was initialized.
+  @retval RETURN_DEVICE_ERROR   The serial device could not be initialized.
+
+**/
+RETURN_STATUS
+EFIAPI
+SerialPortInitialize (
+  VOID
+  )
+{
+  return RETURN_SUCCESS;
+}
+
+/**
+  Write data from buffer to serial device.
+
+  Writes NumberOfBytes data bytes from Buffer to the serial device.
+  The number of bytes actually written to the serial device is returned.
+  If the return value is less than NumberOfBytes, then the write operation failed.
+  If Buffer is NULL, then ASSERT().
+  If NumberOfBytes is zero, then return 0.
+
+  @param  Buffer           Pointer to the data buffer to be written.
+  @param  NumberOfBytes    Number of bytes to written to the serial device.
+
+  @retval 0                NumberOfBytes is 0.
+  @retval >0               The number of bytes written to the serial device.
+                           If this value is less than NumberOfBytes, then the write operation failed.
+
+**/
+UINTN
+EFIAPI
+SerialPortWrite (
+  IN UINT8     *Buffer,
+  IN UINTN     NumberOfBytes
+  )
+{
+  EFI_STATUS  Status;
+  /******************************************************/
+  /* WARNING: The GPIOs Need to be programmed first.    */
+  /*          Make sure HdmiDebugGpioInit() runs before */
+  /*          this function is called!!!                */
+  /******************************************************/
+  //DEBUG ((DEBUG_INFO, "SerialPortWrite() - Enter\n"));
+  if (Buffer == NULL) {
+    return 0;
+  }
+  if (NumberOfBytes == 0) {
+    return 0;
+  }
+  Status = I2cDebugPortWrite (Buffer, (UINT32) NumberOfBytes);
+  //DEBUG ((DEBUG_INFO, "Status = %r\n", Status));
+  //DEBUG ((DEBUG_INFO, "SerialPortWrite() - Exit\n"));
+  if (EFI_ERROR (Status)) {
+    return 0;
+  } else {
+    return NumberOfBytes;
+  }
+}
+
+/**
+  Read data from serial device and save the datas in buffer.
+
+  Reads NumberOfBytes data bytes from a serial device into the buffer
+  specified by Buffer. The number of bytes actually read is returned.
+  If the return value is less than NumberOfBytes, then the rest operation failed.
+  If Buffer is NULL, then ASSERT().
+  If NumberOfBytes is zero, then return 0.
+
+  @param  Buffer           Pointer to the data buffer to store the data read from the serial device.
+  @param  NumberOfBytes    Number of bytes which will be read.
+
+  @retval 0                Read data failed, no data is to be read.
+  @retval >0               Actual number of bytes read from serial device.
+
+**/
+UINTN
+EFIAPI
+SerialPortRead (
+  OUT UINT8     *Buffer,
+  IN  UINTN     NumberOfBytes
+  )
+{
+  EFI_STATUS  Status;
+  UINT32      BytesRead;
+
+  if (Buffer == NULL) {
+    return 0;
+  }
+  if (NumberOfBytes == 0) {
+    return 0;
+  }
+  BytesRead = (UINT32) NumberOfBytes;
+  Status = I2cDebugPortRead (Buffer, &BytesRead);
+  if (EFI_ERROR (Status)) {
+    return 0;
+  } else {
+    return (UINTN) BytesRead;
+  }
+}
+
+/**
+  Polls a serial device to see if there is any data waiting to be read.
+
+  Polls a serial device to see if there is any data waiting to be read.
+  If there is data waiting to be read from the serial device, then TRUE is returned.
+  If there is no data waiting to be read from the serial device, then FALSE is returned.
+
+  @retval TRUE             Data is waiting to be read from the serial device.
+  @retval FALSE            There is no data waiting to be read from the serial device.
+
+**/
+BOOLEAN
+EFIAPI
+SerialPortPoll (
+  VOID
+  )
+{
+  EFI_STATUS  Status;
+  UINT8       NumberOfBytesInFifoBuffer;
+
+  Status = I2cDebugPortReadyToRead (&NumberOfBytesInFifoBuffer);
+  if (EFI_ERROR (Status)) {
+    return FALSE;
+  }
+  if (NumberOfBytesInFifoBuffer <= 0) {
+    return FALSE;
+  }
+  return TRUE;
+}
+
+/**
+  Sets the baud rate, receive FIFO depth, transmit/receice time out, parity,
+  data bits, and stop bits on a serial device.
+
+  @param BaudRate           The requested baud rate. A BaudRate value of 0 will use the
+                            device's default interface speed.
+                            On output, the value actually set.
+  @param ReveiveFifoDepth   The requested depth of the FIFO on the receive side of the
+                            serial interface. A ReceiveFifoDepth value of 0 will use
+                            the device's default FIFO depth.
+                            On output, the value actually set.
+  @param Timeout            The requested time out for a single character in microseconds.
+                            This timeout applies to both the transmit and receive side of the
+                            interface. A Timeout value of 0 will use the device's default time
+                            out value.
+                            On output, the value actually set.
+  @param Parity             The type of parity to use on this serial device. A Parity value of
+                            DefaultParity will use the device's default parity value.
+                            On output, the value actually set.
+  @param DataBits           The number of data bits to use on the serial device. A DataBits
+                            vaule of 0 will use the device's default data bit setting.
+                            On output, the value actually set.
+  @param StopBits           The number of stop bits to use on this serial device. A StopBits
+                            value of DefaultStopBits will use the device's default number of
+                            stop bits.
+                            On output, the value actually set.
+
+  @retval RETURN_SUCCESS            The new attributes were set on the serial device.
+  @retval RETURN_UNSUPPORTED        The serial device does not support this operation.
+  @retval RETURN_INVALID_PARAMETER  One or more of the attributes has an unsupported value.
+  @retval RETURN_DEVICE_ERROR       The serial device is not functioning correctly.
+
+**/
+RETURN_STATUS
+EFIAPI
+SerialPortSetAttributes (
+  IN OUT UINT64             *BaudRate,
+  IN OUT UINT32             *ReceiveFifoDepth,
+  IN OUT UINT32             *Timeout,
+  IN OUT EFI_PARITY_TYPE    *Parity,
+  IN OUT UINT8              *DataBits,
+  IN OUT EFI_STOP_BITS_TYPE *StopBits
+  )
+{
+  return EFI_UNSUPPORTED;
+}
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/IgfxI2c.c b/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/IgfxI2c.c
new file mode 100644
index 0000000000..b1273c7a5d
--- /dev/null
+++ b/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/IgfxI2c.c
@@ -0,0 +1,112 @@
+/** @file
+  Intel Graphics I2C Bus I/O
+
+  Copyright (c) 2022, Intel Corporation. All rights reserved.<BR>
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Uefi.h>
+#include <Library/BaseLib.h>
+#include <Library/IoLib.h>
+#include <Library/PciLib.h>
+#include <IgfxI2c.h>
+
+/**
+  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;
+}
+
+/**
+  Returns the GPIO pin pair to use for the given DDC channel
+
+  @param[in]  Channel                     - The DDC I2C channel.
+  @param[out] DdcBusPinPair               - The GPIO pin pair for the given DDC channel.
+
+  @retval  EFI_SUCCESS                    - The GPIO pin pair was successfully determined
+  @retval  EFI_INVALID_PARAMETER          - The given DDC I2C channel does not exist.
+  @retval  EFI_UNSUPPORTED                - The platform is using a PCH that is not supported yet.
+**/
+EFI_STATUS
+GetGmbusBusPinPair (
+  IN  IGFX_I2C_CHANNEL  Channel,
+  OUT UINT8             *DdcBusPinPair
+  )
+{
+  PCH_TYPE  PchType;
+  *DdcBusPinPair = 0;
+
+  PchType = GetPchType ();
+  switch (PchType) {
+    // The PCH design lineage from SkyLake, KabyLake, AmberLake, & early CoffeeLake
+    case PchTypeSptLp:
+    case PchTypeSptH:
+    case PchTypeKbpH:
+      switch (Channel) {
+        case EnumDdcB:
+          *DdcBusPinPair = V_KBL_PCH_HDMI_DDC_B_PIN_PAIR;
+          return EFI_SUCCESS;
+        case EnumDdcC:
+          *DdcBusPinPair = V_KBL_PCH_HDMI_DDC_C_PIN_PAIR;
+          return EFI_SUCCESS;
+        case EnumDdcD:
+          *DdcBusPinPair = V_KBL_PCH_HDMI_DDC_D_PIN_PAIR;
+          return EFI_SUCCESS;
+
+        default:
+          return EFI_INVALID_PARAMETER;
+      }
+      break;
+    // The PCH design lineage from newer CoffeeLake & WhiskeyLake
+    case PchTypeCnlLp:
+    case PchTypeCnlH:
+      switch (Channel) {
+        case EnumDdcB:
+          *DdcBusPinPair = V_CNL_PCH_HDMI_DDC_B_PIN_PAIR;
+          return EFI_SUCCESS;
+        case EnumDdcC:
+          *DdcBusPinPair = V_CNL_PCH_HDMI_DDC_C_PIN_PAIR;
+          return EFI_SUCCESS;
+        case EnumDdcD:
+          *DdcBusPinPair = V_CNL_PCH_HDMI_DDC_D_PIN_PAIR;
+          return EFI_SUCCESS;
+        case EnumDdcF:
+          *DdcBusPinPair = V_CNL_PCH_HDMI_DDC_F_PIN_PAIR;
+          return EFI_SUCCESS;
+
+        default:
+          return EFI_INVALID_PARAMETER;
+      }
+      break;
+  }
+
+  return EFI_UNSUPPORTED;
+}
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/IgfxI2c.h b/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/IgfxI2c.h
new file mode 100644
index 0000000000..0c69b1db19
--- /dev/null
+++ b/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/IgfxI2c.h
@@ -0,0 +1,146 @@
+/** @file
+  Intel Graphics I2C Bus I/O
+
+  Copyright (c) 2022, Intel Corporation. All rights reserved.<BR>
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+  <b>Conventions</b>:
+  - Prefixes:
+    - Definitions beginning with "R_" are registers
+    - Definitions beginning with "B_" are bits within registers
+    - Definitions beginning with "V_" are meaningful values of bits within the registers
+    - Definitions beginning with "S_" are register sizes
+    - Definitions beginning with "N_" are the bit position
+**/
+
+#include <Uefi/UefiBaseType.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
+
+//
+// HDMI DDC Pin Pairs
+//
+#define V_CNL_PCH_HDMI_DDC_B_PIN_PAIR                     0x01
+#define V_CNL_PCH_HDMI_DDC_C_PIN_PAIR                     0x02
+#define V_CNL_PCH_HDMI_DDC_D_PIN_PAIR                     0x04
+#define V_CNL_PCH_HDMI_DDC_F_PIN_PAIR                     0x03
+
+#define V_KBL_PCH_HDMI_DDC_B_PIN_PAIR                     0x05
+#define V_KBL_PCH_HDMI_DDC_C_PIN_PAIR                     0x04
+#define V_KBL_PCH_HDMI_DDC_D_PIN_PAIR                     0x06
+
+typedef enum {
+  PchTypeUnknown = 0,
+  PchTypeSptLp,
+  PchTypeSptH,
+  PchTypeKbpH,
+  PchTypeCnlLp,
+  PchTypeCnlH,
+  PchTypeMax
+} PCH_TYPE;
+
+typedef enum {
+  PchH           = 1,
+  PchLp,
+  PchUnknownSeries
+} PCH_SERIES;
+
+typedef enum {
+  EnumDdcUnknown = 0,
+  EnumDdcA,
+  EnumDdcB,
+  EnumDdcC,
+  EnumDdcD,
+  EnumDdcE,
+  EnumDdcF,
+  EnumI2cChannelMax
+} IGFX_I2C_CHANNEL;
+
+/**
+  Returns the type of PCH on the system
+
+  @retval   The PCH type.
+**/
+PCH_TYPE
+GetPchType (
+  VOID
+  );
+
+/**
+  Returns the type of PCH on the system
+
+  @retval   The PCH type.
+**/
+PCH_TYPE
+GetPchTypeInternal (
+  VOID
+  );
+
+/**
+  Returns the GPIO pin pair to use for the given DDC channel
+
+  @param[in]  Channel                     - The DDC I2C channel.
+  @param[out] DdcBusPinPair               - The GPIO pin pair for the given DDC channel.
+
+  @retval  EFI_SUCCESS                    - The GPIO pin pair was successfully determined
+  @retval  EFI_INVALID_PARAMETER          - The given DDC I2C channel does not exist.
+  @retval  EFI_UNSUPPORTED                - The platform is using a PCH that is not supported yet.
+**/
+EFI_STATUS
+GetGmbusBusPinPair (
+  IN  IGFX_I2C_CHANNEL  Channel,
+  OUT UINT8             *DdcBusPinPair
+  );
+
+/**
+  Returns the GPIO pin pair to use for the I2C HDMI debug port
+
+  @param[out] DdcBusPinPair               - The GPIO pin pair for the I2C HDMI debug port.
+
+  @retval  EFI_SUCCESS                    - The GPIO pin pair was successfully determined
+  @retval  EFI_INVALID_PARAMETER          - The given DDC I2C channel does not exist.
+  @retval  EFI_UNSUPPORTED                - The platform is using a PCH that is not supported yet.
+**/
+EFI_STATUS
+GetGmbusBusPinPairForI2cDebugPort (
+  OUT UINT8             *DdcBusPinPair
+  );
+
+/**
+  For boot phases that utilize task priority levels (TPLs), this function raises
+  the TPL to the appriopriate level needed to execute I/O to the I2C Debug Port
+**/
+VOID
+RaiseTplForI2cDebugPortAccess (
+  VOID
+  );
+
+/**
+  For boot phases that utilize task priority levels (TPLs), this function
+  restores the TPL to the previous level after I/O to the I2C Debug Port is
+  complete
+**/
+VOID
+RestoreTplAfterI2cDebugPortAccess (
+  VOID
+  );
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/PeiI2cHdmiDebugSerialPortLib.c b/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/PeiI2cHdmiDebugSerialPortLib.c
new file mode 100644
index 0000000000..c998213673
--- /dev/null
+++ b/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/PeiI2cHdmiDebugSerialPortLib.c
@@ -0,0 +1,237 @@
+/** @file
+  Serial I/O Port library implementation for the HDMI I2C Debug Port
+  PEI Library implementation
+
+Copyright (c) 2022, Intel Corporation. All rights reserved.<BR>
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Base.h>
+#include <PiPei.h>
+
+#include <Library/BaseLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/SerialPortLib.h>
+#include <Library/HobLib.h>
+#include <Library/PcdLib.h>
+
+#include <IgfxI2c.h>
+#include <I2cDebugPortProtocol.h>
+
+extern EFI_GUID gI2cHdmiDebugHobGuid;
+
+typedef struct {
+  PCH_TYPE              PchType;
+  UINT32                ControlBits;
+  UINT8                 I2cHdmiDebugDdcBusPinPair;
+  BOOLEAN               IgdBusMasterReset;
+} I2C_HDMI_DEBUG_PORT_CONTEXT;
+
+I2C_HDMI_DEBUG_PORT_CONTEXT*
+GetI2cHdmiDebugPortContext (
+  VOID
+  )
+{
+  EFI_STATUS                    Status;
+  EFI_HOB_GUID_TYPE             *GuidHob;
+  I2C_HDMI_DEBUG_PORT_CONTEXT   *Context;
+  UINT8                         I2cHdmiDebugDdcBusPinPair;
+
+  //DEBUG ((DEBUG_INFO, "GetI2cHdmiDebugPortContext() - Enter\n"));
+  I2cHdmiDebugDdcBusPinPair = 0;
+  GuidHob = GetFirstGuidHob (&gI2cHdmiDebugHobGuid);
+  if (GuidHob == NULL) {
+    //DEBUG ((DEBUG_INFO, "HOB Not Found, Creating HOB\n"));
+    Context = (I2C_HDMI_DEBUG_PORT_CONTEXT *) BuildGuidHob (&gI2cHdmiDebugHobGuid, sizeof (I2C_HDMI_DEBUG_PORT_CONTEXT));
+    if (Context == NULL) {
+      return NULL;
+    }
+    ZeroMem ((VOID *) Context, sizeof (I2C_HDMI_DEBUG_PORT_CONTEXT));
+    Context->PchType = GetPchTypeInternal ();
+    //DEBUG ((DEBUG_INFO, "PchType = %d\n", (UINTN) Context->PchType));
+    Status  = GetGmbusBusPinPair (
+                (IGFX_I2C_CHANNEL) PcdGet32 (PcdI2cHdmiDebugPortDdcI2cChannel),
+                &I2cHdmiDebugDdcBusPinPair
+                );
+    if (EFI_ERROR (Status)) {
+      I2cHdmiDebugDdcBusPinPair = 0;
+    }
+    Context->I2cHdmiDebugDdcBusPinPair  = I2cHdmiDebugDdcBusPinPair;
+    //DEBUG ((DEBUG_INFO, "I2cHdmiDebugDdcBusPinPair = %d\n", (UINTN) I2cHdmiDebugDdcBusPinPair));
+    //DEBUG ((DEBUG_INFO, "GetI2cHdmiDebugPortContext() - Exit\n"));
+    return Context;
+  } else {
+    //DEBUG ((DEBUG_INFO, "HOB Found\n"));
+    //DEBUG ((DEBUG_INFO, "GetI2cHdmiDebugPortContext() - Exit\n"));
+    return GET_GUID_HOB_DATA (GuidHob);
+  }
+}
+
+/**
+  Sets the control bits on a serial device.
+
+  @param Control                Sets the bits of Control that are settable.
+
+  @retval RETURN_SUCCESS        The new control bits were set on the serial device.
+  @retval RETURN_UNSUPPORTED    The serial device does not support this operation.
+  @retval RETURN_DEVICE_ERROR   The serial device is not functioning correctly.
+
+**/
+RETURN_STATUS
+EFIAPI
+SerialPortSetControl (
+  IN UINT32 Control
+  )
+{
+  I2C_HDMI_DEBUG_PORT_CONTEXT   *Context;
+
+  //
+  // check for invalid control parameters
+  //
+  if ((Control & (~(EFI_SERIAL_REQUEST_TO_SEND          |
+                    EFI_SERIAL_DATA_TERMINAL_READY      |
+                    EFI_SERIAL_HARDWARE_LOOPBACK_ENABLE |
+                    EFI_SERIAL_SOFTWARE_LOOPBACK_ENABLE |
+                    EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE))) != 0 ) {
+    return EFI_UNSUPPORTED;
+  }
+
+  Context = GetI2cHdmiDebugPortContext ();
+  if (Context == NULL) {
+    return EFI_UNSUPPORTED;
+  }
+  Control &= (UINT32) ~(EFI_SERIAL_INPUT_BUFFER_EMPTY);
+  Context->ControlBits = Control;
+  return EFI_SUCCESS;
+}
+
+/**
+  Retrieve the status of the control bits on a serial device.
+
+  @param Control                A pointer to return the current control signals from the serial device.
+
+  @retval RETURN_SUCCESS        The control bits were read from the serial device.
+  @retval RETURN_UNSUPPORTED    The serial device does not support this operation.
+  @retval RETURN_DEVICE_ERROR   The serial device is not functioning correctly.
+
+**/
+RETURN_STATUS
+EFIAPI
+SerialPortGetControl (
+  OUT UINT32 *Control
+  )
+{
+  EFI_STATUS                    Status;
+  I2C_HDMI_DEBUG_PORT_CONTEXT   *Context;
+  UINT8                         NumberOfBytesInFifoBuffer;
+
+  Context = GetI2cHdmiDebugPortContext ();
+  if (Context == NULL) {
+    return EFI_UNSUPPORTED;
+  }
+  Status = I2cDebugPortReadyToRead (&NumberOfBytesInFifoBuffer);
+  if (EFI_ERROR (Status)) {
+    return Status;
+  }
+  *Control = (EFI_SERIAL_CLEAR_TO_SEND | EFI_SERIAL_DATA_SET_READY |
+              EFI_SERIAL_CARRIER_DETECT | EFI_SERIAL_OUTPUT_BUFFER_EMPTY);
+  if (NumberOfBytesInFifoBuffer <= 0) {
+    *Control |= EFI_SERIAL_INPUT_BUFFER_EMPTY;
+  }
+  *Control |= Context->ControlBits;
+  return Status;
+}
+
+/**
+  Returns the type of PCH on the system
+
+  @retval   The PCH type.
+**/
+PCH_TYPE
+GetPchType (
+  VOID
+  )
+{
+  I2C_HDMI_DEBUG_PORT_CONTEXT   *Context;
+
+  //DEBUG ((DEBUG_INFO, "%a() - Enter\n", __FUNCTION__));
+  Context = GetI2cHdmiDebugPortContext ();
+  if (Context == NULL) {
+    return PchTypeUnknown;
+  }
+  //DEBUG ((DEBUG_INFO, "PchType = %d\n", (UINTN) Context->PchType));
+  //DEBUG ((DEBUG_INFO, "%a() - Exit\n", __FUNCTION__));
+  return Context->PchType;
+}
+
+/**
+  Returns the GPIO pin pair to use for the I2C HDMI debug port
+
+  @param[out] DdcBusPinPair               - The GPIO pin pair for the I2C HDMI debug port.
+
+  @retval  EFI_SUCCESS                    - The GPIO pin pair was successfully determined
+  @retval  EFI_INVALID_PARAMETER          - The given DDC I2C channel does not exist.
+  @retval  EFI_UNSUPPORTED                - The platform is using a PCH that is not supported yet.
+**/
+EFI_STATUS
+GetGmbusBusPinPairForI2cDebugPort (
+  OUT UINT8             *DdcBusPinPair
+  )
+{
+  I2C_HDMI_DEBUG_PORT_CONTEXT   *Context;
+
+  //DEBUG ((DEBUG_INFO, "%a() - Enter\n", __FUNCTION__));
+  Context = GetI2cHdmiDebugPortContext ();
+  if (Context == NULL) {
+    return EFI_UNSUPPORTED;
+  }
+
+  *DdcBusPinPair = Context->I2cHdmiDebugDdcBusPinPair;
+  //DEBUG ((DEBUG_INFO, "I2cHdmiDebugDdcBusPinPair = %d\n", (UINTN) Context->I2cHdmiDebugDdcBusPinPair));
+  //DEBUG ((DEBUG_INFO, "%a() - Exit\n", __FUNCTION__));
+  return EFI_SUCCESS;
+}
+
+/**
+  Returns a flag indicating whether the IGD device bus master enable needs to
+  be disabled at the end of the current transaction
+
+  @retval  TRUE                           - IGD Bus Master Enable needs to be reset
+  @retval  FALSE                          - IGD Bus Master Enable does not need to be reset
+**/
+BOOLEAN
+GetIgdBusMasterReset (
+  VOID
+  )
+{
+  I2C_HDMI_DEBUG_PORT_CONTEXT   *Context;
+
+  Context = GetI2cHdmiDebugPortContext ();
+  if (Context == NULL) {
+    return TRUE;
+  }
+
+  return Context->IgdBusMasterReset;
+}
+
+/**
+  Sets a flag indicating whether the IGD device bus master enable needs to
+  be disabled at the end of the current transaction
+
+  @param[in]  IgdBusMasterReset           - IGD device bus master enable flag
+**/
+VOID
+SetIgdBusMasterReset (
+  BOOLEAN IgdBusMasterReset
+  )
+{
+  I2C_HDMI_DEBUG_PORT_CONTEXT   *Context;
+
+  Context = GetI2cHdmiDebugPortContext ();
+  if (Context == NULL) {
+    return;
+  }
+
+  Context->IgdBusMasterReset = IgdBusMasterReset;
+}
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/PeiI2cHdmiDebugSerialPortLib.inf b/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/PeiI2cHdmiDebugSerialPortLib.inf
new file mode 100644
index 0000000000..62b3cd3e1e
--- /dev/null
+++ b/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/PeiI2cHdmiDebugSerialPortLib.inf
@@ -0,0 +1,52 @@
+### @file
+# Component description file for Serial I/O Port library for the HDMI I2C Debug Port
+#
+# Copyright (c) 2022, Intel Corporation. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+  INF_VERSION                    = 0x00010005
+  BASE_NAME                      = PeiI2cHdmiDebugSerialPortLib
+  FILE_GUID                      = 9B537D5A-BD66-4FD5-A3F2-F3377840492E
+  VERSION_STRING                 = 1.0
+  MODULE_TYPE                    = BASE
+  LIBRARY_CLASS                  = SerialPortLib|PEI_CORE PEIM
+#
+# The following information is for reference only and not required by the build tools.
+#
+# VALID_ARCHITECTURES = IA32 X64
+#
+
+[LibraryClasses]
+  BaseLib
+  BaseMemoryLib
+  PcdLib
+  TimerLib
+  PciLib
+
+[Packages]
+  MdePkg/MdePkg.dec
+  KabylakeOpenBoardPkg/OpenBoardPkg.dec
+
+[Sources]
+  PeiI2cHdmiDebugSerialPortLib.c
+  Gmbus.c
+  Gmbus.h
+  I2cDebugPortProtocol.c
+  I2cDebugPortProtocol.h
+  I2cDebugPortTplNull.c
+  I2cHdmiDebugSerialPortLib.c
+  IgfxI2c.c
+  IgfxI2c.h
+
+[Ppis]
+
+[Guids]
+  gI2cHdmiDebugHobGuid
+
+[Pcd]
+  gKabylakeOpenBoardPkgTokenSpaceGuid.PcdI2cHdmiDebugPortDdcI2cChannel    ## CONSUMES
+  gKabylakeOpenBoardPkgTokenSpaceGuid.PcdGttMmAddress                     ## CONSUMES
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/SecI2cHdmiDebugSerialPortLib.c b/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/SecI2cHdmiDebugSerialPortLib.c
new file mode 100644
index 0000000000..416114d436
--- /dev/null
+++ b/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/SecI2cHdmiDebugSerialPortLib.c
@@ -0,0 +1,134 @@
+/** @file
+  Serial I/O Port library implementation for the HDMI I2C Debug Port
+  Generic Base Library implementation
+
+Copyright (c) 2022, Intel Corporation. All rights reserved.<BR>
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Base.h>
+#include <Library/BaseLib.h>
+#include <Library/SerialPortLib.h>
+#include <Library/PcdLib.h>
+
+#include <IgfxI2c.h>
+#include <I2cDebugPortProtocol.h>
+
+/**
+  Sets the control bits on a serial device.
+
+  @param Control                Sets the bits of Control that are settable.
+
+  @retval RETURN_SUCCESS        The new control bits were set on the serial device.
+  @retval RETURN_UNSUPPORTED    The serial device does not support this operation.
+  @retval RETURN_DEVICE_ERROR   The serial device is not functioning correctly.
+
+**/
+RETURN_STATUS
+EFIAPI
+SerialPortSetControl (
+  IN UINT32 Control
+  )
+{
+  //
+  // check for invalid control parameters
+  //
+  if ((Control & (~(EFI_SERIAL_REQUEST_TO_SEND          |
+                    EFI_SERIAL_DATA_TERMINAL_READY      |
+                    EFI_SERIAL_HARDWARE_LOOPBACK_ENABLE |
+                    EFI_SERIAL_SOFTWARE_LOOPBACK_ENABLE |
+                    EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE))) != 0 ) {
+    return EFI_UNSUPPORTED;
+  }
+  return EFI_SUCCESS;
+}
+
+/**
+  Retrieve the status of the control bits on a serial device.
+
+  @param Control                A pointer to return the current control signals from the serial device.
+
+  @retval RETURN_SUCCESS        The control bits were read from the serial device.
+  @retval RETURN_UNSUPPORTED    The serial device does not support this operation.
+  @retval RETURN_DEVICE_ERROR   The serial device is not functioning correctly.
+
+**/
+RETURN_STATUS
+EFIAPI
+SerialPortGetControl (
+  OUT UINT32 *Control
+  )
+{
+  EFI_STATUS  Status;
+  UINT8       NumberOfBytesInFifoBuffer;
+
+  Status = I2cDebugPortReadyToRead (&NumberOfBytesInFifoBuffer);
+  if (EFI_ERROR (Status)) {
+    return Status;
+  }
+  *Control = (EFI_SERIAL_CLEAR_TO_SEND | EFI_SERIAL_DATA_SET_READY |
+              EFI_SERIAL_CARRIER_DETECT | EFI_SERIAL_OUTPUT_BUFFER_EMPTY);
+  if (NumberOfBytesInFifoBuffer <= 0) {
+    *Control |= EFI_SERIAL_INPUT_BUFFER_EMPTY;
+  }
+  return Status;
+}
+
+/**
+  Returns the type of PCH on the system
+
+  @retval   The PCH type.
+**/
+PCH_TYPE
+GetPchType (
+  VOID
+  )
+{
+  return GetPchTypeInternal ();
+}
+
+/**
+  Returns the GPIO pin pair to use for the I2C HDMI debug port
+
+  @param[out] DdcBusPinPair               - The GPIO pin pair for the I2C HDMI debug port.
+
+  @retval  EFI_SUCCESS                    - The GPIO pin pair was successfully determined
+  @retval  EFI_INVALID_PARAMETER          - The given DDC I2C channel does not exist.
+  @retval  EFI_UNSUPPORTED                - The platform is using a PCH that is not supported yet.
+**/
+EFI_STATUS
+GetGmbusBusPinPairForI2cDebugPort (
+  OUT UINT8             *DdcBusPinPair
+  )
+{
+  return GetGmbusBusPinPair ((IGFX_I2C_CHANNEL) FixedPcdGet32 (PcdI2cHdmiDebugPortDdcI2cChannel), DdcBusPinPair);
+}
+
+/**
+  Returns a flag indicating whether the IGD device bus master enable needs to
+  be disabled at the end of the current transaction
+
+  @retval  TRUE                           - IGD Bus Master Enable needs to be reset
+  @retval  FALSE                          - IGD Bus Master Enable does not need to be reset
+**/
+BOOLEAN
+GetIgdBusMasterReset (
+  VOID
+  )
+{
+  return TRUE;
+}
+
+/**
+  Sets a flag indicating whether the IGD device bus master enable needs to
+  be disabled at the end of the current transaction
+
+  @param[in]  IgdBusMasterReset           - IGD device bus master enable flag
+**/
+VOID
+SetIgdBusMasterReset (
+  BOOLEAN IgdBusMasterReset
+  )
+{
+}
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/SecI2cHdmiDebugSerialPortLib.inf b/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/SecI2cHdmiDebugSerialPortLib.inf
new file mode 100644
index 0000000000..3ae724926f
--- /dev/null
+++ b/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/SecI2cHdmiDebugSerialPortLib.inf
@@ -0,0 +1,51 @@
+### @file
+# Component description file for Serial I/O Port library for the HDMI I2C Debug Port
+#
+# Copyright (c) 2022, Intel Corporation. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+  INF_VERSION                    = 0x00010005
+  BASE_NAME                      = BaseI2cHdmiDebugSerialPortLib
+  FILE_GUID                      = 4B838C3E-0D23-4CCE-9069-E0E3D2B9CB49
+  VERSION_STRING                 = 1.0
+  MODULE_TYPE                    = SEC
+  LIBRARY_CLASS                  = SerialPortLib
+#
+# The following information is for reference only and not required by the build tools.
+#
+# VALID_ARCHITECTURES = IA32 X64
+#
+
+[LibraryClasses]
+  BaseLib
+  BaseMemoryLib
+  PcdLib
+  TimerLib
+  PciLib
+
+[Packages]
+  MdePkg/MdePkg.dec
+  KabylakeOpenBoardPkg/OpenBoardPkg.dec
+
+[Sources]
+  Gmbus.c
+  Gmbus.h
+  I2cDebugPortProtocol.c
+  I2cDebugPortProtocol.h
+  I2cDebugPortTplNull.c
+  I2cHdmiDebugSerialPortLib.c
+  IgfxI2c.c
+  IgfxI2c.h
+  SecI2cHdmiDebugSerialPortLib.c
+
+[Ppis]
+
+[Guids]
+
+[Pcd]
+  gKabylakeOpenBoardPkgTokenSpaceGuid.PcdI2cHdmiDebugPortDdcI2cChannel    ## CONSUMES
+  gKabylakeOpenBoardPkgTokenSpaceGuid.PcdGttMmAddress                     ## CONSUMES
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/SmmI2cHdmiDebugSerialPortLib.inf b/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/SmmI2cHdmiDebugSerialPortLib.inf
new file mode 100644
index 0000000000..dcbf43b886
--- /dev/null
+++ b/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/SmmI2cHdmiDebugSerialPortLib.inf
@@ -0,0 +1,51 @@
+### @file
+# Component description file for Serial I/O Port library for the HDMI I2C Debug Port
+#
+# Copyright (c) 2022, Intel Corporation. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+  INF_VERSION                    = 0x00010005
+  BASE_NAME                      = SmmI2cHdmiDebugSerialPortLib
+  FILE_GUID                      = 14B7E774-CF36-4CEC-AD5E-42FF37363F21
+  VERSION_STRING                 = 1.0
+  MODULE_TYPE                    = DXE_SMM_DRIVER
+  LIBRARY_CLASS                  = SerialPortLib|DXE_SMM_DRIVER SMM_CORE
+#
+# The following information is for reference only and not required by the build tools.
+#
+# VALID_ARCHITECTURES = IA32 X64
+#
+
+[LibraryClasses]
+  BaseLib
+  BaseMemoryLib
+  PcdLib
+  TimerLib
+  PciLib
+
+[Packages]
+  MdePkg/MdePkg.dec
+  KabylakeOpenBoardPkg/OpenBoardPkg.dec
+
+[Sources]
+  DxeSmmI2cHdmiDebugSerialPortLib.c
+  Gmbus.c
+  Gmbus.h
+  I2cDebugPortProtocol.c
+  I2cDebugPortProtocol.h
+  I2cDebugPortTplNull.c
+  I2cHdmiDebugSerialPortLib.c
+  IgfxI2c.c
+  IgfxI2c.h
+
+[Ppis]
+
+[Guids]
+
+[Pcd]
+  gKabylakeOpenBoardPkgTokenSpaceGuid.PcdI2cHdmiDebugPortDdcI2cChannel    ## CONSUMES
+  gKabylakeOpenBoardPkgTokenSpaceGuid.PcdGttMmAddress                     ## CONSUMES
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/OpenBoardPkg.dec b/Platform/Intel/KabylakeOpenBoardPkg/OpenBoardPkg.dec
index ac87fe486c..c89715766b 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/OpenBoardPkg.dec
+++ b/Platform/Intel/KabylakeOpenBoardPkg/OpenBoardPkg.dec
@@ -5,7 +5,7 @@
 # INF files to generate AutoGen.c and AutoGen.h files
 # for the build infrastructure.
 #
-# Copyright (c) 2017 - 2019, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2017 - 2022, Intel Corporation. All rights reserved.<BR>
 #
 # SPDX-License-Identifier: BSD-2-Clause-Patent
 #
@@ -35,7 +35,7 @@ gSpiFlashDebugHobGuid                 =  {0xcaaaf418, 0x38a5, 0x4d49, {0xbe, 0x7
 
 gTbtInfoHobGuid                       =  {0x74a81eaa, 0x033c, 0x4783, {0xbe, 0x2b, 0x84, 0x85, 0x74, 0xa6, 0x97, 0xb7}}
 
-gPlatformModuleTokenSpaceGuid         =  {0x69d13bf0, 0xaf91, 0x4d96, {0xaa, 0x9f, 0x21, 0x84, 0xc5, 0xce, 0x3b, 0xc0}}
+gI2cHdmiDebugHobGuid                  =  {0x93a54938, 0x3a3e, 0x48cf, {0x9f, 0x0a, 0xaf, 0x6e, 0x0a, 0xa7, 0xc6, 0x44}}
 
 
 [Protocols]
@@ -52,9 +52,12 @@ gPeiTbtPolicyBoardInitDonePpiGuid     =  {0x970f9c60, 0x8547, 0x49d7, { 0xa4, 0x
 
 [PcdsFixedAtBuild]
 
+gKabylakeOpenBoardPkgTokenSpaceGuid.PcdGttMmAddress|0x00000000|UINT32|0x9000000F
+
 gKabylakeOpenBoardPkgTokenSpaceGuid.PcdLpcIoDecodeRange|0x0010|UINT16|0x10001004
 gKabylakeOpenBoardPkgTokenSpaceGuid.PchLpcIoEnableDecoding|0x3c03|UINT16|0x10001005
 
+
 gKabylakeOpenBoardPkgTokenSpaceGuid.PcdLpcSioIndexPort|0x4e|UINT16|0x90000018
 gKabylakeOpenBoardPkgTokenSpaceGuid.PcdLpcSioDataPort|0x4f|UINT16|0x9000001F
 
@@ -73,6 +76,14 @@ gKabylakeOpenBoardPkgTokenSpaceGuid.PcdFlashNvDebugMessageBase|0x00000000|UINT32
 gKabylakeOpenBoardPkgTokenSpaceGuid.PcdFlashNvDebugMessageSize|0x00000000|UINT32|0x90000031
 gKabylakeOpenBoardPkgTokenSpaceGuid.PcdFlashNvDebugMessageOffset|0x00000000|UINT32|0x90000032
 
+## Specifies the DDC I2C channel to claim as the HDMI debug port
+#  The value is defined as below.
+#  2: DDC channel B
+#  3: DDC channel C
+#  4: DDC channel D
+# @Prompt DDC I2C channel to claim as the HDMI debug port
+gKabylakeOpenBoardPkgTokenSpaceGuid.PcdI2cHdmiDebugPortDdcI2cChannel|0x00000000|UINT32|0x90000035
+
 [PcdsDynamic]
 
 # Board GPIO Table
-- 
2.27.0.windows.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [edk2-platforms] [PATCH V2 2/5] KabylakeOpenBoardPkg: Add HdmiDebugGpioInitLib
  2022-09-07  6:27 [edk2-platforms] [PATCH V2 0/5] KabylakeOpenBoardPkg: HDMI DDC I2C Bus Debugging Nate DeSimone
  2022-09-07  6:27 ` [edk2-platforms] [PATCH V2 1/5] KabylakeOpenBoardPkg: Add I2cHdmiDebugSerialPortLib Nate DeSimone
@ 2022-09-07  6:27 ` Nate DeSimone
  2022-09-07  6:27 ` [edk2-platforms] [PATCH V2 3/5] KabylakeOpenBoardPkg: Add SecBoardInitLib Nate DeSimone
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Nate DeSimone @ 2022-09-07  6:27 UTC (permalink / raw)
  To: devel
  Cc: Chasel Chiu, Sai Chaganty, Isaac Oram, Benjamin Doron,
	Michael Kubacki, Jeremy Soller

This library initializes any GPIOs nessesary for
the HDMI DDC bus to operate. This can be called
very early (SEC phase) to enable closed chassis
debug through 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        |   3 +-
 .../GalagoPro3/OpenBoardPkg.dsc               |   3 +-
 .../Include/Library/HdmiDebugGpioInitLib.h    |  26 +++
 .../KabylakeRvp3/OpenBoardPkg.dsc             |   3 +-
 .../HdmiDebugGpioInitLib.c                    | 221 ++++++++++++++++++
 .../HdmiDebugGpioInitLib.inf                  |  42 ++++
 6 files changed, 295 insertions(+), 3 deletions(-)
 create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Include/Library/HdmiDebugGpioInitLib.h
 create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/HdmiDebugGpioInitLib/HdmiDebugGpioInitLib.c
 create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/HdmiDebugGpioInitLib/HdmiDebugGpioInitLib.inf

diff --git a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/OpenBoardPkg.dsc b/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/OpenBoardPkg.dsc
index 29aa8d9111..ec5591e00f 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/OpenBoardPkg.dsc
+++ b/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/OpenBoardPkg.dsc
@@ -1,7 +1,7 @@
 ## @file
 #  The main build description file for the Aspire VN7-572G board.
 #
-# Copyright (c) 2017 - 2021, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2017 - 2022, Intel Corporation. All rights reserved.<BR>
 #
 # SPDX-License-Identifier: BSD-2-Clause-Patent
 #
@@ -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
+  HdmiDebugGpioInitLib|$(PLATFORM_BOARD_PACKAGE)/Library/HdmiDebugGpioInitLib/HdmiDebugGpioInitLib.inf
 
   # Thunderbolt
 !if gKabylakeOpenBoardPkgTokenSpaceGuid.PcdTbtEnable == TRUE
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc
index 93cf93942b..1df3cf13a3 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc
+++ b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc
@@ -1,7 +1,7 @@
 ## @file
 #  The main build description file for the GalagoPro3 board.
 #
-# Copyright (c) 2019 - 2021, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2019 - 2022, Intel Corporation. All rights reserved.<BR>
 #
 # SPDX-License-Identifier: BSD-2-Clause-Patent
 #
@@ -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
+  HdmiDebugGpioInitLib|$(PLATFORM_BOARD_PACKAGE)/Library/HdmiDebugGpioInitLib/HdmiDebugGpioInitLib.inf
 
   # Thunderbolt
 !if gKabylakeOpenBoardPkgTokenSpaceGuid.PcdTbtEnable == TRUE
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/Include/Library/HdmiDebugGpioInitLib.h b/Platform/Intel/KabylakeOpenBoardPkg/Include/Library/HdmiDebugGpioInitLib.h
new file mode 100644
index 0000000000..33bdeb74fc
--- /dev/null
+++ b/Platform/Intel/KabylakeOpenBoardPkg/Include/Library/HdmiDebugGpioInitLib.h
@@ -0,0 +1,26 @@
+/** @file
+  GPIO initialization 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_GPIO_INIT_LIB_H_
+#define HDMI_DEBUG_GPIO_INIT_LIB_H_
+
+#include <Uefi.h>
+
+/**
+  Configures GPIOs to enable usage of the HDMI DDC I2C Bus
+
+  @retval EFI_SUCCESS        The function completed successfully
+  @retval EFI_UNSUPPORTED    The platform is using a PCH that is not supported yet.
+
+**/
+EFI_STATUS
+HdmiDebugGpioInit (
+  VOID
+  );
+
+#endif
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkg.dsc b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkg.dsc
index a46d36b056..1f2950be72 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkg.dsc
+++ b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkg.dsc
@@ -1,7 +1,7 @@
 ## @file
 #  The main build description file for the KabylakeRvp3 board.
 #
-# Copyright (c) 2017 - 2021, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2017 - 2022, Intel Corporation. All rights reserved.<BR>
 #
 # SPDX-License-Identifier: BSD-2-Clause-Patent
 #
@@ -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
+  HdmiDebugGpioInitLib|$(PLATFORM_BOARD_PACKAGE)/Library/HdmiDebugGpioInitLib/HdmiDebugGpioInitLib.inf
 
   # Thunderbolt
 !if gKabylakeOpenBoardPkgTokenSpaceGuid.PcdTbtEnable == TRUE
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/Library/HdmiDebugGpioInitLib/HdmiDebugGpioInitLib.c b/Platform/Intel/KabylakeOpenBoardPkg/Library/HdmiDebugGpioInitLib/HdmiDebugGpioInitLib.c
new file mode 100644
index 0000000000..3d9e37f34a
--- /dev/null
+++ b/Platform/Intel/KabylakeOpenBoardPkg/Library/HdmiDebugGpioInitLib/HdmiDebugGpioInitLib.c
@@ -0,0 +1,221 @@
+/** @file
+  GPIO initialization for the HDMI I2C Debug Port
+
+Copyright (c) 2022, Intel Corporation. All rights reserved.<BR>
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Uefi.h>
+#include <Library/PcdLib.h>
+#include <Library/PciLib.h>
+
+#include <Library/GpioLib.h>
+#include <GpioPinsSklLp.h>
+#include <GpioPinsSklH.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_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
+
+//GPIO Table Terminator
+#define END_OF_GPIO_TABLE 0xFFFFFFFF
+
+typedef enum {
+  PchTypeUnknown = 0,
+  PchTypeSptLp,
+  PchTypeSptH,
+  PchTypeKbpH,
+  PchTypeCnlLp,
+  PchTypeCnlH,
+  PchTypeMax
+} PCH_TYPE;
+
+typedef enum {
+  PchH           = 1,
+  PchLp,
+  PchUnknownSeries
+} PCH_SERIES;
+
+typedef enum {
+  EnumDdcUnknown = 0,
+  EnumDdcA,
+  EnumDdcB,
+  EnumDdcC,
+  EnumDdcD,
+  EnumDdcE,
+  EnumDdcF,
+  EnumI2cChannelMax
+} IGFX_I2C_CHANNEL;
+
+/*** SKL-LP ***/
+
+// HDMI-B DDC GPIO Pins
+GPIO_INIT_CONFIG mDebugGpioTableSklLpDdpB[] =
+{
+  {GPIO_SKL_LP_GPP_E18, {GpioPadModeNative1, GpioHostOwnDefault, GpioDirNone,    GpioOutDefault, GpioIntDis, GpioHostDeepReset, GpioTermNone}}, //DDPB_CTRLCLK
+  {GPIO_SKL_LP_GPP_E19, {GpioPadModeNative1, GpioHostOwnDefault, GpioDirNone,    GpioOutDefault, GpioIntDis, GpioHostDeepReset, GpioTermNone}}, //DDPB_CTRLDATA
+  {END_OF_GPIO_TABLE,   {GpioPadModeGpio,    GpioHostOwnGpio,    GpioDirNone,    GpioOutDefault, GpioIntDis, GpioDswReset,  GpioTermNone}},//Marking End of Table
+};
+UINT16 mDebugGpioTableSklLpDdpBSize = sizeof (mDebugGpioTableSklLpDdpB) / sizeof (GPIO_INIT_CONFIG) - 1;
+
+// HDMI-C DDC GPIO Pins
+GPIO_INIT_CONFIG mDebugGpioTableSklLpDdpC[] =
+{
+  {GPIO_SKL_LP_GPP_E20, {GpioPadModeNative1, GpioHostOwnDefault, GpioDirNone,    GpioOutDefault, GpioIntDis, GpioHostDeepReset, GpioTermNone}}, //DDPC_CTRLCLK
+  {GPIO_SKL_LP_GPP_E21, {GpioPadModeNative1, GpioHostOwnDefault, GpioDirNone,    GpioOutDefault, GpioIntDis, GpioHostDeepReset, GpioTermNone}}, //DDPC_CTRLDATA
+  {END_OF_GPIO_TABLE,   {GpioPadModeGpio,    GpioHostOwnGpio,    GpioDirNone,    GpioOutDefault, GpioIntDis, GpioDswReset,  GpioTermNone}},//Marking End of Table
+};
+UINT16 mDebugGpioTableSklLpDdpCSize = sizeof (mDebugGpioTableSklLpDdpC) / sizeof (GPIO_INIT_CONFIG) - 1;
+
+// HDMI-D DDC GPIO Pins
+GPIO_INIT_CONFIG mDebugGpioTableSklLpDdpD[] =
+{
+  {GPIO_SKL_LP_GPP_E22, {GpioPadModeNative1, GpioHostOwnDefault, GpioDirNone,    GpioOutDefault, GpioIntDis, GpioHostDeepReset, GpioTermNone}}, //DDPD_CTRLCLK
+  {GPIO_SKL_LP_GPP_E23, {GpioPadModeNative1, GpioHostOwnDefault, GpioDirNone,    GpioOutDefault, GpioIntDis, GpioHostDeepReset, GpioTermNone}}, //DDPD_CTRLDATA
+  {END_OF_GPIO_TABLE,   {GpioPadModeGpio,    GpioHostOwnGpio,    GpioDirNone,    GpioOutDefault, GpioIntDis, GpioDswReset,  GpioTermNone}},//Marking End of Table
+};
+UINT16 mDebugGpioTableSklLpDdpDSize = sizeof (mDebugGpioTableSklLpDdpD) / sizeof (GPIO_INIT_CONFIG) - 1;
+
+/*** SKL-H ***/
+
+// HDMI-B DDC GPIO Pins
+GPIO_INIT_CONFIG mDebugGpioTableSklHDdpB[] =
+{
+  {GPIO_SKL_H_GPP_I5,   {GpioPadModeNative1, GpioHostOwnDefault, GpioDirNone,    GpioOutDefault, GpioIntDis, GpioHostDeepReset, GpioTermNone}}, //DDPB_CTRLCLK
+  {GPIO_SKL_H_GPP_I6,   {GpioPadModeNative1, GpioHostOwnDefault, GpioDirNone,    GpioOutDefault, GpioIntDis, GpioHostDeepReset, GpioTermNone}}, //DDPB_CTRLDATA
+  {END_OF_GPIO_TABLE,   {GpioPadModeGpio,    GpioHostOwnGpio,    GpioDirNone,    GpioOutDefault, GpioIntDis, GpioDswReset,  GpioTermNone}},//Marking End of Table
+};
+UINT16 mDebugGpioTableSklHDdpBSize = sizeof (mDebugGpioTableSklHDdpB) / sizeof (GPIO_INIT_CONFIG) - 1;
+
+// HDMI-C DDC GPIO Pins
+GPIO_INIT_CONFIG mDebugGpioTableSklHDdpC[] =
+{
+  {GPIO_SKL_H_GPP_I7,   {GpioPadModeNative1, GpioHostOwnDefault, GpioDirNone,    GpioOutDefault, GpioIntDis, GpioHostDeepReset, GpioTermNone}}, //DDPC_CTRLCLK
+  {GPIO_SKL_H_GPP_I8,   {GpioPadModeNative1, GpioHostOwnDefault, GpioDirNone,    GpioOutDefault, GpioIntDis, GpioHostDeepReset, GpioTermNone}}, //DDPC_CTRLDATA
+  {END_OF_GPIO_TABLE,   {GpioPadModeGpio,    GpioHostOwnGpio,    GpioDirNone,    GpioOutDefault, GpioIntDis, GpioDswReset,  GpioTermNone}},//Marking End of Table
+};
+UINT16 mDebugGpioTableSklHDdpCSize = sizeof (mDebugGpioTableSklHDdpC) / sizeof (GPIO_INIT_CONFIG) - 1;
+
+// HDMI-D DDC GPIO Pins
+GPIO_INIT_CONFIG mDebugGpioTableSklHDdpD[] =
+{
+  {GPIO_SKL_H_GPP_I9,   {GpioPadModeNative1, GpioHostOwnDefault, GpioDirNone,    GpioOutDefault, GpioIntDis, GpioHostDeepReset, GpioTermNone}}, //DDPD_CTRLCLK
+  {GPIO_SKL_H_GPP_I10,  {GpioPadModeNative1, GpioHostOwnDefault, GpioDirNone,    GpioOutDefault, GpioIntDis, GpioHostDeepReset, GpioTermNone}}, //DDPD_CTRLDATA
+  {END_OF_GPIO_TABLE,   {GpioPadModeGpio,    GpioHostOwnGpio,    GpioDirNone,    GpioOutDefault, GpioIntDis, GpioDswReset,  GpioTermNone}},//Marking End of Table
+};
+UINT16 mDebugGpioTableSklHDdpDSize = sizeof (mDebugGpioTableSklHDdpD) / sizeof (GPIO_INIT_CONFIG) - 1;
+
+/**
+  Configures GPIO
+
+  @param[in]  GpioTable       Point to Platform Gpio table
+  @param[in]  GpioTableCount  Number of Gpio table entries
+
+**/
+VOID
+HdmiDebugConfigureGpio (
+  IN GPIO_INIT_CONFIG                 *GpioDefinition,
+  IN UINT16                           GpioTableCount
+  )
+{
+  EFI_STATUS          Status;
+
+  Status = GpioConfigurePads (GpioTableCount, GpioDefinition);
+
+}
+
+
+PCH_TYPE
+HdmiGpioInitGetPchType (
+  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;
+    }
+  }
+
+  return PchType;
+}
+
+/**
+  Configures GPIOs to enable usage of the HDMI DDC I2C Bus
+
+  @retval EFI_SUCCESS        The function completed successfully
+  @retval EFI_UNSUPPORTED    The platform is using a PCH that is not supported yet.
+
+**/
+EFI_STATUS
+HdmiDebugGpioInit (
+  VOID
+  )
+{
+  IGFX_I2C_CHANNEL  Channel;
+  PCH_TYPE  PchType;
+
+  PchType = HdmiGpioInitGetPchType ();
+  Channel = (IGFX_I2C_CHANNEL) PcdGet32 (PcdI2cHdmiDebugPortDdcI2cChannel);
+  switch (PchType) {
+    case PchTypeSptLp:
+      switch (Channel) {
+        case EnumDdcB:
+          HdmiDebugConfigureGpio (mDebugGpioTableSklLpDdpB, mDebugGpioTableSklLpDdpBSize);
+          return EFI_SUCCESS;
+        case EnumDdcC:
+          HdmiDebugConfigureGpio (mDebugGpioTableSklLpDdpC, mDebugGpioTableSklLpDdpCSize);
+          return EFI_SUCCESS;
+        case EnumDdcD:
+          HdmiDebugConfigureGpio (mDebugGpioTableSklLpDdpD, mDebugGpioTableSklLpDdpDSize);
+          return EFI_SUCCESS;
+
+        default:
+          return EFI_UNSUPPORTED;
+      }
+      break;
+    case PchTypeSptH:
+    case PchTypeKbpH:
+      switch (Channel) {
+        case EnumDdcB:
+          HdmiDebugConfigureGpio (mDebugGpioTableSklHDdpB, mDebugGpioTableSklHDdpBSize);
+          return EFI_SUCCESS;
+        case EnumDdcC:
+          HdmiDebugConfigureGpio (mDebugGpioTableSklHDdpC, mDebugGpioTableSklHDdpCSize);
+          return EFI_SUCCESS;
+        case EnumDdcD:
+          HdmiDebugConfigureGpio (mDebugGpioTableSklHDdpD, mDebugGpioTableSklHDdpDSize);
+          return EFI_SUCCESS;
+
+        default:
+          return EFI_UNSUPPORTED;
+      }
+      break;
+    default:
+      return EFI_UNSUPPORTED;
+  }
+}
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/Library/HdmiDebugGpioInitLib/HdmiDebugGpioInitLib.inf b/Platform/Intel/KabylakeOpenBoardPkg/Library/HdmiDebugGpioInitLib/HdmiDebugGpioInitLib.inf
new file mode 100644
index 0000000000..3c83f68774
--- /dev/null
+++ b/Platform/Intel/KabylakeOpenBoardPkg/Library/HdmiDebugGpioInitLib/HdmiDebugGpioInitLib.inf
@@ -0,0 +1,42 @@
+### @file
+# Component description file for the HDMI I2C Debug Port GPIO initialization library
+#
+# Copyright (c) 2022, Intel Corporation. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+  INF_VERSION                    = 0x00010005
+  BASE_NAME                      = BaseHdmiDebugGpioInitLib
+  FILE_GUID                      = 4CC9D17A-B6D4-4FE2-AB82-27D539A8D8A9
+  VERSION_STRING                 = 1.0
+  MODULE_TYPE                    = BASE
+  LIBRARY_CLASS                  = HdmiDebugGpioInitLib
+#
+# The following information is for reference only and not required by the build tools.
+#
+# VALID_ARCHITECTURES = IA32 X64
+#
+
+[LibraryClasses]
+  BaseLib
+  PcdLib
+  PciLib
+  GpioLib
+
+[Packages]
+  MdePkg/MdePkg.dec
+  KabylakeOpenBoardPkg/OpenBoardPkg.dec
+  KabylakeSiliconPkg/SiPkg.dec
+
+[Sources]
+  HdmiDebugGpioInitLib.c
+
+[Ppis]
+
+[Guids]
+
+[Pcd]
+  gKabylakeOpenBoardPkgTokenSpaceGuid.PcdI2cHdmiDebugPortDdcI2cChannel    ## CONSUMES
-- 
2.27.0.windows.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [edk2-platforms] [PATCH V2 3/5] KabylakeOpenBoardPkg: Add SecBoardInitLib
  2022-09-07  6:27 [edk2-platforms] [PATCH V2 0/5] KabylakeOpenBoardPkg: HDMI DDC I2C Bus Debugging Nate DeSimone
  2022-09-07  6:27 ` [edk2-platforms] [PATCH V2 1/5] KabylakeOpenBoardPkg: Add I2cHdmiDebugSerialPortLib Nate DeSimone
  2022-09-07  6:27 ` [edk2-platforms] [PATCH V2 2/5] KabylakeOpenBoardPkg: Add HdmiDebugGpioInitLib Nate DeSimone
@ 2022-09-07  6:27 ` Nate DeSimone
  2022-09-07  6:27 ` [edk2-platforms] [PATCH V2 4/5] MinPlatformPkg: Add PcdDefaultTerminalType support to SerialPortTerminalLib Nate DeSimone
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Nate DeSimone @ 2022-09-07  6:27 UTC (permalink / raw)
  To: devel
  Cc: Chasel Chiu, Sai Chaganty, Isaac Oram, Benjamin Doron,
	Michael Kubacki, Jeremy Soller

Adds a board-specific implementation of SecBoardInitLib.
This implementation will invoke the GPIO initialization
routine for the HDMI DDC Bus if the HDMI DDC Bus is being
used for debug log output. Adds PCDs for enable/disable
of using HDMI DDC I2C Bus as a Serial Port.

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>
---
 .../PeiAspireVn7Dash572GInitPreMemLib.c       |  3 +-
 .../AspireVn7Dash572G/OpenBoardPkg.dsc        |  8 +++-
 .../BoardInitLib/PeiGalagoPro3InitPreMemLib.c | 13 ++-----
 .../GalagoPro3/OpenBoardPkg.dsc               |  7 +++-
 .../PeiKabylakeRvp3InitPreMemLib.c            | 13 ++-----
 .../KabylakeRvp3/OpenBoardPkg.dsc             |  8 +++-
 .../SecBoardInitLib/Ia32/SecBoardInit.nasm    | 18 +++++++++
 .../Library/SecBoardInitLib/SecBoardInitLib.c | 35 +++++++++++++++++
 .../SecBoardInitLib/SecBoardInitLib.inf       | 39 +++++++++++++++++++
 .../KabylakeOpenBoardPkg/OpenBoardPkg.dec     | 18 +++++++++
 10 files changed, 137 insertions(+), 25 deletions(-)
 create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/SecBoardInitLib/Ia32/SecBoardInit.nasm
 create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/SecBoardInitLib/SecBoardInitLib.c
 create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/SecBoardInitLib/SecBoardInitLib.inf

diff --git a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Library/BoardInitLib/PeiAspireVn7Dash572GInitPreMemLib.c b/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Library/BoardInitLib/PeiAspireVn7Dash572GInitPreMemLib.c
index d17685be82..1c9a65399b 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Library/BoardInitLib/PeiAspireVn7Dash572GInitPreMemLib.c
+++ b/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Library/BoardInitLib/PeiAspireVn7Dash572GInitPreMemLib.c
@@ -1,6 +1,6 @@
 /** @file
 
-Copyright (c) 2017 - 2021, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2017 - 2022, Intel Corporation. All rights reserved.<BR>
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -251,7 +251,6 @@ AspireVn7Dash572GBoardDebugInit (
   ///
   /// Do Early PCH init
   ///
-  EarlySiliconInit ();
   LpcInit ();
 
   // NB: MinPlatform specification defines platform initialisation flow.
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/OpenBoardPkg.dsc b/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/OpenBoardPkg.dsc
index ec5591e00f..261f141056 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/OpenBoardPkg.dsc
+++ b/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/OpenBoardPkg.dsc
@@ -209,8 +209,12 @@
   # Platform Package
   #######################################
   TestPointCheckLib|$(PLATFORM_PACKAGE)/Test/Library/TestPointCheckLib/SecTestPointCheckLib.inf
-  SecBoardInitLib|$(PLATFORM_PACKAGE)/PlatformInit/Library/SecBoardInitLibNull/SecBoardInitLibNull.inf
-  SiliconPolicyUpdateLib|MinPlatformPkg/PlatformInit/Library/SiliconPolicyUpdateLibNull/SiliconPolicyUpdateLibNull.inf
+  SiliconPolicyUpdateLib|$(PLATFORM_PACKAGE)/PlatformInit/Library/SiliconPolicyUpdateLibNull/SiliconPolicyUpdateLibNull.inf
+
+  #######################################
+  # Board-specific
+  #######################################
+  SecBoardInitLib|$(PLATFORM_BOARD_PACKAGE)/Library/SecBoardInitLib/SecBoardInitLib.inf
 
 [LibraryClasses.common.PEI_CORE]
   #######################################
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/BoardInitLib/PeiGalagoPro3InitPreMemLib.c b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/BoardInitLib/PeiGalagoPro3InitPreMemLib.c
index f4833149f3..051dac0b20 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/BoardInitLib/PeiGalagoPro3InitPreMemLib.c
+++ b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/BoardInitLib/PeiGalagoPro3InitPreMemLib.c
@@ -1,7 +1,7 @@
 /** @file
   System 76 GalagoPro3 board pre-memory initialization.
 
-Copyright (c) 2019 - 2021, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2019 - 2022, Intel Corporation. All rights reserved.<BR>
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -167,9 +167,9 @@ SioInit (
 }
 
 /**
-  Configues the IC2 Controller on which GPIO Expander Communicates.
-  This Function is to enable the I2CGPIOExapanderLib to programm the Gpios
-  Complete intilization will be done in later Stage
+  Configures the IC2 Controller on which GPIO Expander Communicates.
+  This Function is to enable the I2CGPIOExapanderLib to program the Gpios
+  Complete initialization will be done in later Stage
 
 **/
 VOID
@@ -227,10 +227,6 @@ GalagoPro3BoardDebugInit (
   VOID
   )
 {
-  ///
-  /// Do Early PCH init
-  ///
-  EarlySiliconInit ();
   return EFI_SUCCESS;
 }
 
@@ -242,4 +238,3 @@ GalagoPro3BoardBootModeDetect (
 {
   return BOOT_WITH_FULL_CONFIGURATION;
 }
-
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc
index 1df3cf13a3..5cf2d424ff 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc
+++ b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc
@@ -152,8 +152,13 @@
   #######################################
   # Platform Package
   #######################################
-  SecBoardInitLib|$(PLATFORM_PACKAGE)/PlatformInit/Library/SecBoardInitLibNull/SecBoardInitLibNull.inf
   TestPointCheckLib|$(PLATFORM_PACKAGE)/Test/Library/TestPointCheckLib/SecTestPointCheckLib.inf
+  SiliconPolicyUpdateLib|$(PLATFORM_PACKAGE)/PlatformInit/Library/SiliconPolicyUpdateLibNull/SiliconPolicyUpdateLibNull.inf
+
+  #######################################
+  # Board-specific
+  #######################################
+  SecBoardInitLib|$(PLATFORM_BOARD_PACKAGE)/Library/SecBoardInitLib/SecBoardInitLib.inf
 
 [LibraryClasses.common.PEIM]
   #######################################
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/Library/BoardInitLib/PeiKabylakeRvp3InitPreMemLib.c b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/Library/BoardInitLib/PeiKabylakeRvp3InitPreMemLib.c
index d34b0be3c7..87ae3b531e 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/Library/BoardInitLib/PeiKabylakeRvp3InitPreMemLib.c
+++ b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/Library/BoardInitLib/PeiKabylakeRvp3InitPreMemLib.c
@@ -1,6 +1,6 @@
 /** @file
 
-Copyright (c) 2017 - 2021, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2017 - 2022, Intel Corporation. All rights reserved.<BR>
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -257,9 +257,9 @@ SioInit (
 }
 
 /**
-  Configues the IC2 Controller on which GPIO Expander Communicates.
-  This Function is to enable the I2CGPIOExapanderLib to programm the Gpios
-  Complete intilization will be done in later Stage
+  Configures the IC2 Controller on which GPIO Expander Communicates.
+  This Function is to enable the I2CGPIOExapanderLib to program the Gpios
+  Complete initialization will be done in later Stage
 
 **/
 VOID
@@ -321,10 +321,6 @@ KabylakeRvp3BoardDebugInit (
   VOID
   )
 {
-  ///
-  /// Do Early PCH init
-  ///
-  EarlySiliconInit ();
   return EFI_SUCCESS;
 }
 
@@ -336,4 +332,3 @@ KabylakeRvp3BoardBootModeDetect (
 {
   return BOOT_WITH_FULL_CONFIGURATION;
 }
-
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkg.dsc b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkg.dsc
index 1f2950be72..26a54b0dc7 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkg.dsc
+++ b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkg.dsc
@@ -189,8 +189,12 @@
   # Platform Package
   #######################################
   TestPointCheckLib|$(PLATFORM_PACKAGE)/Test/Library/TestPointCheckLib/SecTestPointCheckLib.inf
-  SecBoardInitLib|$(PLATFORM_PACKAGE)/PlatformInit/Library/SecBoardInitLibNull/SecBoardInitLibNull.inf
-  SiliconPolicyUpdateLib|MinPlatformPkg/PlatformInit/Library/SiliconPolicyUpdateLibNull/SiliconPolicyUpdateLibNull.inf
+  SiliconPolicyUpdateLib|$(PLATFORM_PACKAGE)/PlatformInit/Library/SiliconPolicyUpdateLibNull/SiliconPolicyUpdateLibNull.inf
+
+  #######################################
+  # Board-specific
+  #######################################
+  SecBoardInitLib|$(PLATFORM_BOARD_PACKAGE)/Library/SecBoardInitLib/SecBoardInitLib.inf
 
 [LibraryClasses.common.PEIM]
   #######################################
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/Library/SecBoardInitLib/Ia32/SecBoardInit.nasm b/Platform/Intel/KabylakeOpenBoardPkg/Library/SecBoardInitLib/Ia32/SecBoardInit.nasm
new file mode 100644
index 0000000000..c9cfa236ea
--- /dev/null
+++ b/Platform/Intel/KabylakeOpenBoardPkg/Library/SecBoardInitLib/Ia32/SecBoardInit.nasm
@@ -0,0 +1,18 @@
+;; @file
+; Kaby Lake board SEC initialization.
+;
+; Copyright (c) 2022, Intel Corporation. All rights reserved.<BR>
+; SPDX-License-Identifier: BSD-2-Clause-Patent
+;
+;;
+
+SECTION .text
+
+global  ASM_PFX(BoardBeforeTempRamInit)
+ASM_PFX(BoardBeforeTempRamInit):
+        ;
+        ; This hook is called before FSP TempRamInit API call
+        ; ESI, EDI need to be preserved
+        ; ESP contains return address
+        ;
+        jmp     esp
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/Library/SecBoardInitLib/SecBoardInitLib.c b/Platform/Intel/KabylakeOpenBoardPkg/Library/SecBoardInitLib/SecBoardInitLib.c
new file mode 100644
index 0000000000..22712d12db
--- /dev/null
+++ b/Platform/Intel/KabylakeOpenBoardPkg/Library/SecBoardInitLib/SecBoardInitLib.c
@@ -0,0 +1,35 @@
+/** @file
+  Kaby Lake board SEC initialization.
+
+Copyright (c) 2022, Intel Corporation. All rights reserved.<BR>
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <PiDxe.h>
+#include <Library/BoardInitLib.h>
+#include <Library/PcdLib.h>
+#include <Library/SiliconInitLib.h>
+#include <Library/HdmiDebugGpioInitLib.h>
+
+EFI_STATUS
+EFIAPI
+BoardAfterTempRamInit (
+  VOID
+  )
+{
+  ///
+  /// Do Early PCH init
+  ///
+  EarlySiliconInit ();
+
+  ///
+  /// Initialize HDMI DDC GPIOs if HDMI I2C Debug Port is Enabled
+  ///
+  if (PcdGetBool (PcdI2cHdmiDebugPortEnable) ||
+      PcdGetBool (PcdI2cHdmiDebugPortSerialTerminalEnable)) {
+    HdmiDebugGpioInit ();
+  }
+
+  return EFI_SUCCESS;
+}
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/Library/SecBoardInitLib/SecBoardInitLib.inf b/Platform/Intel/KabylakeOpenBoardPkg/Library/SecBoardInitLib/SecBoardInitLib.inf
new file mode 100644
index 0000000000..192a78865f
--- /dev/null
+++ b/Platform/Intel/KabylakeOpenBoardPkg/Library/SecBoardInitLib/SecBoardInitLib.inf
@@ -0,0 +1,39 @@
+## @file
+# Component information file for Kaby Lake SEC Board Init Library
+#
+# Copyright (c) 2022, Intel Corporation. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+  INF_VERSION                    = 0x00010005
+  BASE_NAME                      = SecKabyLakeBoardInitLib
+  FILE_GUID                      = B9DC6910-67E0-4FCE-A1A4-675115E71455
+  MODULE_TYPE                    = SEC
+  VERSION_STRING                 = 1.0
+  LIBRARY_CLASS                  = SecBoardInitLib
+
+[Sources.IA32]
+  Ia32/SecBoardInit.nasm
+
+[Sources]
+  SecBoardInitLib.c
+
+[Packages]
+  MinPlatformPkg/MinPlatformPkg.dec
+  MdePkg/MdePkg.dec
+  KabylakeSiliconPkg/SiPkg.dec
+  KabylakeOpenBoardPkg/OpenBoardPkg.dec
+
+[LibraryClasses]
+  BaseLib
+  SiliconInitLib
+  HdmiDebugGpioInitLib
+
+[Guids]
+
+[Pcd]
+  gKabylakeOpenBoardPkgTokenSpaceGuid.PcdI2cHdmiDebugPortEnable               ## CONSUMES
+  gKabylakeOpenBoardPkgTokenSpaceGuid.PcdI2cHdmiDebugPortSerialTerminalEnable ## CONSUMES
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/OpenBoardPkg.dec b/Platform/Intel/KabylakeOpenBoardPkg/OpenBoardPkg.dec
index c89715766b..448eafacbf 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/OpenBoardPkg.dec
+++ b/Platform/Intel/KabylakeOpenBoardPkg/OpenBoardPkg.dec
@@ -76,6 +76,24 @@ gKabylakeOpenBoardPkgTokenSpaceGuid.PcdFlashNvDebugMessageBase|0x00000000|UINT32
 gKabylakeOpenBoardPkgTokenSpaceGuid.PcdFlashNvDebugMessageSize|0x00000000|UINT32|0x90000031
 gKabylakeOpenBoardPkgTokenSpaceGuid.PcdFlashNvDebugMessageOffset|0x00000000|UINT32|0x90000032
 
+## Enable usage the HDMI DDC channel as a debug port - Causes the BIOS debug log
+#  to be written to the HDMI DDC channel.
+#  The value is defined as below.
+#  FALSE: Do NOT use the HDMI DDC channel as a debug port
+#  TRUE:  Use the HDMI DDC channel as a debug port
+# @Prompt Enable usage the HDMI DDC channel as a debug port
+gKabylakeOpenBoardPkgTokenSpaceGuid.PcdI2cHdmiDebugPortEnable|FALSE|BOOLEAN|0x90000033
+
+## Enable usage the HDMI DDC channel as a serial terminal - Enables usage of the
+#  HDMI DDC channel to display BIOS Setup, UEFI Shell, etc. using a terminal
+#  emulator. Useful for cases where video is not operating correctly.
+#
+#  The value is defined as below.
+#  FALSE: Do NOT use the HDMI DDC channel as a debug port
+#  TRUE:  Use the HDMI DDC channel as a debug port
+# @Prompt Enable usage the HDMI DDC channel as a debug port
+gKabylakeOpenBoardPkgTokenSpaceGuid.PcdI2cHdmiDebugPortSerialTerminalEnable|FALSE|BOOLEAN|0x90000034
+
 ## Specifies the DDC I2C channel to claim as the HDMI debug port
 #  The value is defined as below.
 #  2: DDC channel B
-- 
2.27.0.windows.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [edk2-platforms] [PATCH V2 4/5] MinPlatformPkg: Add PcdDefaultTerminalType support to SerialPortTerminalLib
  2022-09-07  6:27 [edk2-platforms] [PATCH V2 0/5] KabylakeOpenBoardPkg: HDMI DDC I2C Bus Debugging Nate DeSimone
                   ` (2 preceding siblings ...)
  2022-09-07  6:27 ` [edk2-platforms] [PATCH V2 3/5] KabylakeOpenBoardPkg: Add SecBoardInitLib Nate DeSimone
@ 2022-09-07  6:27 ` Nate DeSimone
  2022-09-07  6:27 ` [edk2-platforms] [PATCH V2 5/5] KabylakeOpenBoardPkg/GalagoPro3: Enable HDMI DDC Debug Port Nate DeSimone
  2022-09-08 22:59 ` [edk2-platforms] [PATCH V2 0/5] KabylakeOpenBoardPkg: HDMI DDC I2C Bus Debugging Isaac Oram
  5 siblings, 0 replies; 7+ messages in thread
From: Nate DeSimone @ 2022-09-07  6:27 UTC (permalink / raw)
  To: devel
  Cc: Chasel Chiu, Sai Chaganty, Isaac Oram, Eric Dong, Liming Gao,
	Benjamin Doron, Michael Kubacki, Jeremy Soller

 - Sets the terminal type GUID for ConIn, ConOut, and ConErr to the terminal
   type indicated by PcdDefaultTerminalType.
 - Some improvements to the comments in SerialPortTerminalLib

Cc: Chasel Chiu <chasel.chiu@intel.com>
Cc: Sai Chaganty <rangasai.v.chaganty@intel.com>
Cc: Isaac Oram <isaac.w.oram@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
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>
---
 .../SerialPortTerminalLib.c                   | 66 ++++++++++++++-----
 .../SerialPortTerminalLib.h                   | 11 +++-
 .../SerialPortTerminalLib.inf                 | 17 ++++-
 3 files changed, 71 insertions(+), 23 deletions(-)

diff --git a/Platform/Intel/MinPlatformPkg/Library/SerialPortTerminalLib/SerialPortTerminalLib.c b/Platform/Intel/MinPlatformPkg/Library/SerialPortTerminalLib/SerialPortTerminalLib.c
index 66e8ee018b..ca5e966cb5 100644
--- a/Platform/Intel/MinPlatformPkg/Library/SerialPortTerminalLib/SerialPortTerminalLib.c
+++ b/Platform/Intel/MinPlatformPkg/Library/SerialPortTerminalLib/SerialPortTerminalLib.c
@@ -1,13 +1,26 @@
 /** @file
-  Main file for NULL named library for Serial Port Terminal Redirection library.
+  Main file for NULL named library for the Serial Port Terminal Redirection library.
 
-  Copyright (c) 2020, Intel Corporation. All rights reserved.<BR>
+  This library adds a Terminal Device connected to SerialDxe to the UEFI Console
+  Variables. This allows BIOS Setup, UEFI Shell, etc. to be used on a headless
+  system via a null modem and terminal
+  emulator.
+
+  Copyright (c) 2020 - 2022, Intel Corporation. All rights reserved.<BR>
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
 
 #include "SerialPortTerminalLib.h"
 
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID  *mTerminalType[] = {
+  &gEfiPcAnsiGuid,
+  &gEfiVT100Guid,
+  &gEfiVT100PlusGuid,
+  &gEfiVTUTF8Guid,
+  &gEfiTtyTermGuid
+};
+
 GLOBAL_REMOVE_IF_UNREFERENCED SERIAL_DEVICE_PATH mSerialDevicePath = {
   {
     {
@@ -59,10 +72,36 @@ AddSerialTerminal (
   VOID
   )
 {
-  DEBUG ((DEBUG_INFO, "[AddSerialPortTerminal]\n"));
+  UINT8   DefaultTerminalType;
+
+  //
+  // Update the Terminal Device Configuration Parameters
+  //
+  mSerialDevicePath.Uart.BaudRate = PcdGet64 (PcdUartDefaultBaudRate);
+  mSerialDevicePath.Uart.DataBits = PcdGet8 (PcdUartDefaultDataBits);
+  mSerialDevicePath.Uart.Parity   = PcdGet8 (PcdUartDefaultParity);
+  mSerialDevicePath.Uart.StopBits = PcdGet8 (PcdUartDefaultStopBits);
+  DefaultTerminalType             = PcdGet8 (PcdDefaultTerminalType);
+  DEBUG ((DEBUG_INFO, "[AddSerialPortTerminal] [%d, %d, %d, %d, %d]\n",
+      (int) mSerialDevicePath.Uart.BaudRate,
+      (int) mSerialDevicePath.Uart.DataBits,
+      (int) mSerialDevicePath.Uart.Parity,
+      (int) mSerialDevicePath.Uart.StopBits,
+      (int) DefaultTerminalType));
+
+  if (DefaultTerminalType >= 0 &&
+      DefaultTerminalType < (sizeof (mTerminalType) / sizeof (mTerminalType[0]))) {
+    CopyMem (
+      (VOID *) &(mSerialDevicePath.TerminalType.Guid),
+      (VOID *) mTerminalType[DefaultTerminalType],
+      sizeof (EFI_GUID)
+      );
+  } else {
+    DEBUG ((DEBUG_WARN, "PcdDefaultTerminalType has invalid value: %d\n", (int) DefaultTerminalType));
+  }
 
   //
-  // Append Serial Terminal into "ConIn"
+  // Append Serial Terminal into "ConIn", "ConOut", and "ErrOut"
   //
   EfiBootManagerUpdateConsoleVariable (ConOut, (EFI_DEVICE_PATH_PROTOCOL *) &mSerialDevicePath, NULL);
   EfiBootManagerUpdateConsoleVariable (ConIn, (EFI_DEVICE_PATH_PROTOCOL *) &mSerialDevicePath, NULL);
@@ -71,13 +110,12 @@ AddSerialTerminal (
 
 
 /**
-  Constructor for the Serial Port Device controller library.
+  Constructor for the Serial Port Terminal Device library.
 
-  @param ImageHandle    the image handle of the process
-  @param SystemTable    the EFI System Table pointer
+  @param ImageHandle    The Image Handle of the process
+  @param SystemTable    The EFI System Table pointer
 
-  @retval EFI_SUCCESS        the shell command handlers were installed sucessfully
-  @retval EFI_UNSUPPORTED    the shell level required was not found.
+  @retval EFI_SUCCESS   The Serial Port Terminal Device was installed successfully
 **/
 EFI_STATUS
 EFIAPI
@@ -86,15 +124,7 @@ SerialPortTerminalLibConstructor (
   IN EFI_SYSTEM_TABLE  *SystemTable
   )
 {
-  mSerialDevicePath.Uart.BaudRate = PcdGet64(PcdUartDefaultBaudRate);
-  mSerialDevicePath.Uart.DataBits = PcdGet8(PcdUartDefaultDataBits);
-  mSerialDevicePath.Uart.Parity   = PcdGet8(PcdUartDefaultParity);
-  mSerialDevicePath.Uart.StopBits = PcdGet8(PcdUartDefaultStopBits);
-  DEBUG ((DEBUG_INFO, "[SerialPortTerminalLibConstructor] [%d, %d, %d, %d]\n",
-      mSerialDevicePath.Uart.BaudRate,
-      mSerialDevicePath.Uart.DataBits,
-      mSerialDevicePath.Uart.Parity,
-      mSerialDevicePath.Uart.StopBits));
+  DEBUG ((DEBUG_INFO, "[SerialPortTerminalLibConstructor]\n"));
 
   AddSerialTerminal();
 
diff --git a/Platform/Intel/MinPlatformPkg/Library/SerialPortTerminalLib/SerialPortTerminalLib.h b/Platform/Intel/MinPlatformPkg/Library/SerialPortTerminalLib/SerialPortTerminalLib.h
index bfa73cca7d..33415721cd 100644
--- a/Platform/Intel/MinPlatformPkg/Library/SerialPortTerminalLib/SerialPortTerminalLib.h
+++ b/Platform/Intel/MinPlatformPkg/Library/SerialPortTerminalLib/SerialPortTerminalLib.h
@@ -1,7 +1,12 @@
 /** @file
-  Header file for NULL named library for for Serial Port Terminal Redirection library.
+  Header file for NULL named library for the Serial Port Terminal Redirection library.
 
-  Copyright (c) 2020, Intel Corporation. All rights reserved.<BR>
+  This library adds a Terminal Device connected to SerialDxe to the UEFI Console
+  Variables. This allows BIOS Setup, UEFI Shell, etc. to be used on a headless
+  system via a null modem and terminal
+  emulator.
+
+  Copyright (c) 2020 -2022, Intel Corporation. All rights reserved.<BR>
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -12,8 +17,10 @@
 #include <Uefi.h>
 #include <Guid/SerialPortLibVendor.h>
 #include <Library/UefiLib.h>
+#include <Library/BaseMemoryLib.h>
 #include <Library/DevicePathLib.h>
 #include <Library/DebugLib.h>
+#include <Library/PcdLib.h>
 #include <Library/UefiBootManagerLib.h>
 
 //
diff --git a/Platform/Intel/MinPlatformPkg/Library/SerialPortTerminalLib/SerialPortTerminalLib.inf b/Platform/Intel/MinPlatformPkg/Library/SerialPortTerminalLib/SerialPortTerminalLib.inf
index dc5bb91a8e..ac1a06b2a5 100644
--- a/Platform/Intel/MinPlatformPkg/Library/SerialPortTerminalLib/SerialPortTerminalLib.inf
+++ b/Platform/Intel/MinPlatformPkg/Library/SerialPortTerminalLib/SerialPortTerminalLib.inf
@@ -1,5 +1,9 @@
 ## @file
-# Component information file for Serial Port Terminal Redirection Library
+# Component information file for the Serial Port Terminal Redirection library.
+#
+#  This library adds a Terminal Device connected to SerialDxe to the UEFI Console
+#  Variables. This allows BIOS Setup, UEFI Shell, etc. to be used on a headless
+#  system via a null modem and terminal
 #
 # Copyright (c) 2020, Intel Corporation. All rights reserved.<BR>
 #
@@ -18,22 +22,29 @@
 [Packages]
   MdePkg/MdePkg.dec
   MdeModulePkg/MdeModulePkg.dec
-  BoardModulePkg/BoardModulePkg.dec
-  MinPlatformPkg/MinPlatformPkg.dec
 
 [Sources]
   SerialPortTerminalLib.c
   SerialPortTerminalLib.h
 
 [LibraryClasses]
+  BaseMemoryLib
   DevicePathLib
   DebugLib
   UefiDriverEntryPoint
   UefiBootManagerLib
   UefiLib
 
+[Guids]
+  gEfiPcAnsiGuid
+  gEfiVT100Guid
+  gEfiVT100PlusGuid
+  gEfiVTUTF8Guid
+  gEfiTtyTermGuid
+
 [Pcd]
   gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate
   gEfiMdePkgTokenSpaceGuid.PcdUartDefaultDataBits
   gEfiMdePkgTokenSpaceGuid.PcdUartDefaultParity
   gEfiMdePkgTokenSpaceGuid.PcdUartDefaultStopBits
+  gEfiMdePkgTokenSpaceGuid.PcdDefaultTerminalType
-- 
2.27.0.windows.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [edk2-platforms] [PATCH V2 5/5] KabylakeOpenBoardPkg/GalagoPro3: Enable HDMI DDC Debug Port
  2022-09-07  6:27 [edk2-platforms] [PATCH V2 0/5] KabylakeOpenBoardPkg: HDMI DDC I2C Bus Debugging Nate DeSimone
                   ` (3 preceding siblings ...)
  2022-09-07  6:27 ` [edk2-platforms] [PATCH V2 4/5] MinPlatformPkg: Add PcdDefaultTerminalType support to SerialPortTerminalLib Nate DeSimone
@ 2022-09-07  6:27 ` Nate DeSimone
  2022-09-08 22:59 ` [edk2-platforms] [PATCH V2 0/5] KabylakeOpenBoardPkg: HDMI DDC I2C Bus Debugging Isaac Oram
  5 siblings, 0 replies; 7+ messages in thread
From: Nate DeSimone @ 2022-09-07  6:27 UTC (permalink / raw)
  To: devel
  Cc: Chasel Chiu, Sai Chaganty, Isaac Oram, Benjamin Doron,
	Michael Kubacki, Jeremy Soller

Enables usage of the HDMI DDC I2C Bus SerialPortLib implementation
on the GalagoPro3 board.

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>
---
 .../GalagoPro3/OpenBoardPkg.dsc               | 74 ++++++++++++++++++-
 .../GalagoPro3/OpenBoardPkgPcd.dsc            | 31 ++++++++
 2 files changed, 103 insertions(+), 2 deletions(-)

diff --git a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc
index 5cf2d424ff..642f465f80 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc
+++ b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc
@@ -142,6 +142,12 @@
   PlatformHookLib|$(PROJECT)/Library/BasePlatformHookLib/BasePlatformHookLib.inf
   SiliconPolicyUpdateLib|$(PROJECT)/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf
 
+[LibraryClasses.common.PEI_CORE]
+!if $(TARGET) == DEBUG && gKabylakeOpenBoardPkgTokenSpaceGuid.PcdI2cHdmiDebugPortEnable == TRUE
+  DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
+  SerialPortLib|$(PLATFORM_BOARD_PACKAGE)/Library/I2cHdmiDebugSerialPortLib/PeiI2cHdmiDebugSerialPortLib.inf
+!endif
+
 [LibraryClasses.IA32.SEC]
   #######################################
   # Edk2 Packages
@@ -164,9 +170,10 @@
   #######################################
   # Edk2 Packages
   #######################################
+!if $(TARGET) == DEBUG
   DebugLib|MdeModulePkg/Library/PeiDxeDebugLibReportStatusCode/PeiDxeDebugLibReportStatusCode.inf
+!endif
   SerialPortLib|MdePkg/Library/BaseSerialPortLibNull/BaseSerialPortLibNull.inf
-  SetCacheMtrrLib|$(PLATFORM_PACKAGE)/Library/SetCacheMtrrLib/SetCacheMtrrLibNull.inf
 
   #######################################
   # Silicon Package
@@ -183,6 +190,7 @@
 !if $(TARGET) == DEBUG
   TestPointCheckLib|$(PLATFORM_PACKAGE)/Test/Library/TestPointCheckLib/PeiTestPointCheckLib.inf
 !endif
+  SetCacheMtrrLib|$(PLATFORM_PACKAGE)/Library/SetCacheMtrrLib/SetCacheMtrrLibNull.inf
 
   #######################################
   # Board Package
@@ -193,7 +201,19 @@
   PeiTbtPolicyLib|$(PLATFORM_BOARD_PACKAGE)/Features/Tbt/Library/PeiTbtPolicyLib/PeiTbtPolicyLib.inf
 !endif
 
+[LibraryClasses.common.DXE_CORE]
+!if $(TARGET) == DEBUG
+  DebugLib|MdeModulePkg/Library/PeiDxeDebugLibReportStatusCode/PeiDxeDebugLibReportStatusCode.inf
+!endif
+
 [LibraryClasses.common.DXE_DRIVER]
+  #######################################
+  # Edk2 Packages
+  #######################################
+!if $(TARGET) == DEBUG
+  DebugLib|MdeModulePkg/Library/PeiDxeDebugLibReportStatusCode/PeiDxeDebugLibReportStatusCode.inf
+!endif
+
   #######################################
   # Silicon Initialization Package
   #######################################
@@ -225,11 +245,24 @@
   SiliconPolicyUpdateLib|$(PROJECT)/Policy/Library/DxeSiliconPolicyUpdateLib/DxeSiliconPolicyUpdateLib.inf
 
 [LibraryClasses.X64.DXE_RUNTIME_DRIVER]
+  #######################################
+  # Edk2 Packages
+  #######################################
+!if $(TARGET) == DEBUG
+  DebugLib|MdeModulePkg/Library/PeiDxeDebugLibReportStatusCode/PeiDxeDebugLibReportStatusCode.inf
+!endif
+
   #######################################
   # Silicon Initialization Package
   #######################################
   ResetSystemLib|$(PLATFORM_SI_PACKAGE)/Pch/Library/DxeRuntimeResetSystemLib/DxeRuntimeResetSystemLib.inf
 
+[LibraryClasses.common.SMM_CORE]
+!if $(TARGET) == DEBUG && gKabylakeOpenBoardPkgTokenSpaceGuid.PcdI2cHdmiDebugPortEnable == TRUE
+  DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
+  SerialPortLib|$(PLATFORM_BOARD_PACKAGE)/Library/I2cHdmiDebugSerialPortLib/SmmI2cHdmiDebugSerialPortLib.inf
+!endif
+
 [LibraryClasses.X64.DXE_SMM_DRIVER]
   #######################################
   # Silicon Initialization Package
@@ -244,6 +277,7 @@
   TestPointLib|$(PLATFORM_PACKAGE)/Test/Library/TestPointLib/SmmTestPointLib.inf
 !if $(TARGET) == DEBUG
   TestPointCheckLib|$(PLATFORM_PACKAGE)/Test/Library/TestPointCheckLib/SmmTestPointCheckLib.inf
+  DebugLib|MdeModulePkg/Library/PeiDxeDebugLibReportStatusCode/PeiDxeDebugLibReportStatusCode.inf
 !endif
 
 #######################################
@@ -263,6 +297,9 @@
   MdeModulePkg/Universal/StatusCodeHandler/Pei/StatusCodeHandlerPei.inf {
     <LibraryClasses>
       DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf
+!if $(TARGET) == DEBUG  && gKabylakeOpenBoardPkgTokenSpaceGuid.PcdI2cHdmiDebugPortEnable == TRUE
+      SerialPortLib|$(PLATFORM_BOARD_PACKAGE)/Library/I2cHdmiDebugSerialPortLib/PeiI2cHdmiDebugSerialPortLib.inf
+!endif
   }
 
   IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.inf {
@@ -333,6 +370,26 @@
   #######################################
   # Edk2 Packages
   #######################################
+  !if $(TARGET) == DEBUG
+  MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/StatusCodeHandlerRuntimeDxe.inf {
+    <LibraryClasses>
+      DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf
+      !if gKabylakeOpenBoardPkgTokenSpaceGuid.PcdI2cHdmiDebugPortEnable == TRUE
+        SerialPortLib|$(PLATFORM_BOARD_PACKAGE)/Library/I2cHdmiDebugSerialPortLib/DxeI2cHdmiDebugSerialPortLib.inf
+      !endif
+  }
+    MdeModulePkg/Universal/ReportStatusCodeRouter/Smm/ReportStatusCodeRouterSmm.inf {
+      <LibraryClasses>
+        DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf
+    }
+  MdeModulePkg/Universal/StatusCodeHandler/Smm/StatusCodeHandlerSmm.inf {
+      <LibraryClasses>
+        DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf
+        !if gKabylakeOpenBoardPkgTokenSpaceGuid.PcdI2cHdmiDebugPortEnable == TRUE
+          SerialPortLib|$(PLATFORM_BOARD_PACKAGE)/Library/I2cHdmiDebugSerialPortLib/SmmI2cHdmiDebugSerialPortLib.inf
+        !endif
+    }
+  !endif
   IntelFsp2WrapperPkg/FspWrapperNotifyDxe/FspWrapperNotifyDxe.inf
   MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf
   MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf
@@ -341,9 +398,12 @@
   MdeModulePkg/Bus/Pci/SataControllerDxe/SataControllerDxe.inf
   MdeModulePkg/Universal/Console/GraphicsOutputDxe/GraphicsOutputDxe.inf
   MdeModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KeyboardDxe.inf
-  MdeModulePkg/Universal/BdsDxe/BdsDxe.inf{
+  MdeModulePkg/Universal/BdsDxe/BdsDxe.inf {
     <LibraryClasses>
       NULL|BoardModulePkg/Library/BdsPs2KbcLib/BdsPs2KbcLib.inf
+!if gMinPlatformPkgTokenSpaceGuid.PcdSerialTerminalEnable == TRUE
+      NULL|MinPlatformPkg/Library/SerialPortTerminalLib/SerialPortTerminalLib.inf
+!endif
   }
   UefiCpuPkg/CpuDxe/CpuDxe.inf
 
@@ -373,9 +433,19 @@
     <LibraryClasses>
       !if $(TARGET) == DEBUG
         DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
+        !if gKabylakeOpenBoardPkgTokenSpaceGuid.PcdI2cHdmiDebugPortEnable == TRUE
+          SerialPortLib|$(PLATFORM_BOARD_PACKAGE)/Library/I2cHdmiDebugSerialPortLib/SmmI2cHdmiDebugSerialPortLib.inf
+        !endif
       !endif
   }
 !endif
+!if gKabylakeOpenBoardPkgTokenSpaceGuid.PcdI2cHdmiDebugPortSerialTerminalEnable == TRUE
+  MdeModulePkg/Universal/SerialDxe/SerialDxe.inf {
+    <LibraryClasses>
+      DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf
+      SerialPortLib|$(PLATFORM_BOARD_PACKAGE)/Library/I2cHdmiDebugSerialPortLib/DxeI2cHdmiDebugSerialPortLib.inf
+  }
+!endif
 
   #######################################
   # Silicon Initialization Package
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkgPcd.dsc b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkgPcd.dsc
index 207c1de06d..0a2d08f300 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkgPcd.dsc
+++ b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkgPcd.dsc
@@ -334,6 +334,37 @@
   gBoardModulePkgTokenSpaceGuid.PcdSuperIoPciIsaBridgeDevice|{0x00, 0x00, 0x1F, 0x00}
   gKabylakeOpenBoardPkgTokenSpaceGuid.PcdGttMmAddress|0xDF000000
 
+  ## Enable usage the HDMI DDC channel as a debug port - Causes the BIOS debug log
+  #  to be written to the HDMI DDC channel.
+  #  The value is defined as below.
+  #  FALSE: Do NOT use the HDMI DDC channel as a debug port
+  #  TRUE:  Use the HDMI DDC channel as a debug port
+  # @Prompt Enable usage the HDMI DDC channel as a debug port
+  gKabylakeOpenBoardPkgTokenSpaceGuid.PcdI2cHdmiDebugPortEnable|FALSE
+
+  ## Enable usage the HDMI DDC channel as a serial terminal - Enables usage of the
+  #  HDMI DDC channel to display BIOS Setup, UEFI Shell, etc. using a terminal
+  #  emulator. Useful for cases where video is not operating correctly.
+  #
+  #  The value is defined as below.
+  #  FALSE: Do NOT use the HDMI DDC channel as a debug port
+  #  TRUE:  Use the HDMI DDC channel as a debug port
+  # @Prompt Enable usage the HDMI DDC channel as a debug port
+  gKabylakeOpenBoardPkgTokenSpaceGuid.PcdI2cHdmiDebugPortSerialTerminalEnable|FALSE
+  gMinPlatformPkgTokenSpaceGuid.PcdSerialTerminalEnable|gKabylakeOpenBoardPkgTokenSpaceGuid.PcdI2cHdmiDebugPortSerialTerminalEnable
+
+  ## Indicates the type of terminal to use.
+  #  If PcdI2cHdmiDebugPortSerialTerminalEnable is TRUE, this PCD will be used
+  #  to determine which terminal protocol to use.
+  #  0 - PCANSI
+  #  1 - VT100
+  #  2 - VT100+
+  #  3 - UTF8
+  #  4 - TTYTERM
+  # @Prompt Default Terminal Type.
+  # @ValidRange 0x80000001 | 0 - 4
+  gEfiMdePkgTokenSpaceGuid.PcdDefaultTerminalType|3
+
   ## Specifies the DDC I2C channel to claim as the HDMI debug port
   #  The value is defined as below.
   #  2: DDC channel B
-- 
2.27.0.windows.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [edk2-platforms] [PATCH V2 0/5] KabylakeOpenBoardPkg: HDMI DDC I2C Bus Debugging
  2022-09-07  6:27 [edk2-platforms] [PATCH V2 0/5] KabylakeOpenBoardPkg: HDMI DDC I2C Bus Debugging Nate DeSimone
                   ` (4 preceding siblings ...)
  2022-09-07  6:27 ` [edk2-platforms] [PATCH V2 5/5] KabylakeOpenBoardPkg/GalagoPro3: Enable HDMI DDC Debug Port Nate DeSimone
@ 2022-09-08 22:59 ` Isaac Oram
  5 siblings, 0 replies; 7+ messages in thread
From: Isaac Oram @ 2022-09-08 22:59 UTC (permalink / raw)
  To: Desimone, Nathaniel L, devel@edk2.groups.io
  Cc: Chiu, Chasel, Chaganty, Rangasai V, Dong, Eric, Gao, Liming,
	Benjamin Doron, Kubacki, Michael, Soller, Jeremy

For the series: Reviewed-by: Isaac Oram <isaac.w.oram@intel.com>

-----Original Message-----
From: Desimone, Nathaniel L <nathaniel.l.desimone@intel.com> 
Sent: Tuesday, September 6, 2022 11:28 PM
To: devel@edk2.groups.io
Cc: Chiu, Chasel <chasel.chiu@intel.com>; Chaganty, Rangasai V <rangasai.v.chaganty@intel.com>; Oram, Isaac W <isaac.w.oram@intel.com>; Dong, Eric <eric.dong@intel.com>; Gao, Liming <gaoliming@byosoft.com.cn>; Benjamin Doron <benjamin.doron00@gmail.com>; Kubacki, Michael <michael.kubacki@microsoft.com>; Soller, Jeremy <jeremy@system76.com>
Subject: [edk2-platforms] [PATCH V2 0/5] KabylakeOpenBoardPkg: HDMI DDC I2C Bus Debugging

Changes in V2:
 - Use SerialPortTerminalLib from MinPlatformPkg.
 - Override SerialPortLib on StatusCodeHandlerSmm not
   StatusCodeRouter.

Normally the HDMI DDC I2C bus is used to read the EDID data from the monitor. An unintended but useful property of this interface is that is does not require DMA to perform I/O. This means that this interface can be used to perform I/O before DRAM is initialized.

HDMI video output is a common feature of many laptops.
This makes the HDMI DDC bus the only I/O interface that is often exposed outside of the laptop chassis while simultaneously capable of being used in Pre-Memory.
Oddly... this makes it an ideal and novel way to perform closed chassis debug.

This patch series adds a implementation of using the HDMI DDC I2C Bus as a "poor man's" UART. This is accomplished using the GMBUS that is part of the Intel HD Graphics device. Accordingly, this implementation will only work on systems with the HDMI port routed to the Intel graphics device, and will not work on systems with HDMI routed to a discrete GPU.

In order to use this implementation, one will also need a BusPirate programmed with Nate's Custom Bus Pirate FW for I2C Serial Debug. This firmware is available from:

https://github.com/nate-desimone/Bus_Pirate

This firmware interfaces with the I2C Bus and forwards traffic from it to the FTDI USB Serial Adapter that is integrated with the BusPirate. In combination, this results in the HDMI port appearing to function as a regular UART to the user.

If you would like to see this in action, I made a short YouTube video:

https://www.youtube.com/watch?v=xe7cFhRsr80

Cc: Chasel Chiu <chasel.chiu@intel.com>
Cc: Sai Chaganty <rangasai.v.chaganty@intel.com>
Cc: Isaac Oram <isaac.w.oram@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
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>

Nate DeSimone (5):
  KabylakeOpenBoardPkg: Add I2cHdmiDebugSerialPortLib
  KabylakeOpenBoardPkg: Add HdmiDebugGpioInitLib
  KabylakeOpenBoardPkg: Add SecBoardInitLib
  MinPlatformPkg: Add PcdDefaultTerminalType support to
    SerialPortTerminalLib
  KabylakeOpenBoardPkg/GalagoPro3: Enable HDMI DDC Debug Port

 .../PeiAspireVn7Dash572GInitPreMemLib.c       |   3 +-
 .../AspireVn7Dash572G/OpenBoardPkg.dsc        |  11 +-
 .../AspireVn7Dash572G/OpenBoardPkgPcd.dsc     |   9 +
 .../BoardInitLib/PeiGalagoPro3InitPreMemLib.c |  13 +-
 .../GalagoPro3/OpenBoardPkg.dsc               |  84 +-
 .../GalagoPro3/OpenBoardPkgPcd.dsc            |  40 +
 .../Include/Library/HdmiDebugGpioInitLib.h    |  26 +
 .../PeiKabylakeRvp3InitPreMemLib.c            |  13 +-
 .../KabylakeRvp3/OpenBoardPkg.dsc             |  11 +-
 .../KabylakeRvp3/OpenBoardPkgPcd.dsc          |   9 +
 .../HdmiDebugGpioInitLib.c                    | 221 +++++
 .../HdmiDebugGpioInitLib.inf                  |  42 +
 .../DxeI2cHdmiDebugSerialPortLib.inf          |  51 ++
 .../DxeSmmI2cHdmiDebugSerialPortLib.c         | 161 ++++
 .../Library/I2cHdmiDebugSerialPortLib/Gmbus.c | 826 ++++++++++++++++++  .../Library/I2cHdmiDebugSerialPortLib/Gmbus.h | 324 +++++++
 .../I2cDebugPortProtocol.c                    | 194 ++++
 .../I2cDebugPortProtocol.h                    |  77 ++
 .../I2cDebugPortTplDxe.c                      |  44 +
 .../I2cDebugPortTplNull.c                     |  36 +
 .../I2cHdmiDebugSerialPortLib.c               | 201 +++++
 .../I2cHdmiDebugSerialPortLib/IgfxI2c.c       | 112 +++
 .../I2cHdmiDebugSerialPortLib/IgfxI2c.h       | 146 ++++
 .../PeiI2cHdmiDebugSerialPortLib.c            | 237 +++++
 .../PeiI2cHdmiDebugSerialPortLib.inf          |  52 ++
 .../SecI2cHdmiDebugSerialPortLib.c            | 134 +++
 .../SecI2cHdmiDebugSerialPortLib.inf          |  51 ++
 .../SmmI2cHdmiDebugSerialPortLib.inf          |  51 ++
 .../SecBoardInitLib/Ia32/SecBoardInit.nasm    |  18 +
 .../Library/SecBoardInitLib/SecBoardInitLib.c |  35 +
 .../SecBoardInitLib/SecBoardInitLib.inf       |  39 +
 .../KabylakeOpenBoardPkg/OpenBoardPkg.dec     |  33 +-
 .../SerialPortTerminalLib.c                   |  66 +-
 .../SerialPortTerminalLib.h                   |  11 +-
 .../SerialPortTerminalLib.inf                 |  17 +-
 35 files changed, 3343 insertions(+), 55 deletions(-)  create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Include/Library/HdmiDebugGpioInitLib.h
 create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/HdmiDebugGpioInitLib/HdmiDebugGpioInitLib.c
 create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/HdmiDebugGpioInitLib/HdmiDebugGpioInitLib.inf
 create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/DxeI2cHdmiDebugSerialPortLib.inf
 create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/DxeSmmI2cHdmiDebugSerialPortLib.c
 create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/Gmbus.c
 create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/Gmbus.h
 create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/I2cDebugPortProtocol.c
 create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/I2cDebugPortProtocol.h
 create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/I2cDebugPortTplDxe.c
 create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/I2cDebugPortTplNull.c
 create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/I2cHdmiDebugSerialPortLib.c
 create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/IgfxI2c.c
 create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/IgfxI2c.h
 create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/PeiI2cHdmiDebugSerialPortLib.c
 create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/PeiI2cHdmiDebugSerialPortLib.inf
 create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/SecI2cHdmiDebugSerialPortLib.c
 create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/SecI2cHdmiDebugSerialPortLib.inf
 create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/SmmI2cHdmiDebugSerialPortLib.inf
 create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/SecBoardInitLib/Ia32/SecBoardInit.nasm
 create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/SecBoardInitLib/SecBoardInitLib.c
 create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/SecBoardInitLib/SecBoardInitLib.inf

--
2.27.0.windows.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-09-08 22:59 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-07  6:27 [edk2-platforms] [PATCH V2 0/5] KabylakeOpenBoardPkg: HDMI DDC I2C Bus Debugging Nate DeSimone
2022-09-07  6:27 ` [edk2-platforms] [PATCH V2 1/5] KabylakeOpenBoardPkg: Add I2cHdmiDebugSerialPortLib Nate DeSimone
2022-09-07  6:27 ` [edk2-platforms] [PATCH V2 2/5] KabylakeOpenBoardPkg: Add HdmiDebugGpioInitLib Nate DeSimone
2022-09-07  6:27 ` [edk2-platforms] [PATCH V2 3/5] KabylakeOpenBoardPkg: Add SecBoardInitLib Nate DeSimone
2022-09-07  6:27 ` [edk2-platforms] [PATCH V2 4/5] MinPlatformPkg: Add PcdDefaultTerminalType support to SerialPortTerminalLib Nate DeSimone
2022-09-07  6:27 ` [edk2-platforms] [PATCH V2 5/5] KabylakeOpenBoardPkg/GalagoPro3: Enable HDMI DDC Debug Port Nate DeSimone
2022-09-08 22:59 ` [edk2-platforms] [PATCH V2 0/5] KabylakeOpenBoardPkg: HDMI DDC I2C Bus Debugging Isaac Oram

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox