From nobody Sat May 18 23:44:12 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+90592+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+90592+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1655525159; cv=none; d=zohomail.com; s=zohoarc; b=ejTklJG/9IAzE1/A4Cg+d7C6AbnHw2q6DyFk0GDd33J1X/7Drzvro/VvxQak0/NQKT/fiZ3mbe7QRcIXcpnV9jCBslbTqn7gxJ6PoMBibhh7uX+NEaeseITr2Glc7c5Ea3ZAU3HGmUKlFPllvOSiS5hJvvNLELM7BTCeqPU53f4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1655525159; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=06dCYG9mJNgMCJK+2Qs7GjDWKIBpOFnGkGU+rwhjBRU=; b=kvqBA/MeLp9ccKT/GMFEJYfF2YiLQoC9A1w1qo8Q6N3OoPni0AKqpHiaVo+EueoQcjNl2CdO3OtikK8AMxaGD45xIVdge53SLrgmC1+cxxhMZYpMKwVLRhyAy9ztfcOviRFhrr5SM2E8ll8/5BTsuJTEG4ORQ5sjpx+ElqkT/Ok= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+90592+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1655525159290540.079728510177; Fri, 17 Jun 2022 21:05:59 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id T9egYY1788612xKZYBWJxHxZ; Fri, 17 Jun 2022 21:05:58 -0700 X-Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mx.groups.io with SMTP id smtpd.web09.6192.1655525155936388213 for ; Fri, 17 Jun 2022 21:05:57 -0700 X-IronPort-AV: E=McAfee;i="6400,9594,10380"; a="305057849" X-IronPort-AV: E=Sophos;i="5.92,306,1650956400"; d="scan'208";a="305057849" X-Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jun 2022 21:05:55 -0700 X-IronPort-AV: E=Sophos;i="5.92,306,1650956400"; d="scan'208";a="613763916" X-Received: from nldesimo-desk1.amr.corp.intel.com ([10.7.159.54]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jun 2022 21:05:55 -0700 From: "Nate DeSimone" To: devel@edk2.groups.io Cc: Chasel Chiu , Sai Chaganty , Isaac Oram , Benjamin Doron , Michael Kubacki , Jeremy Soller Subject: [edk2-devel] [edk2-platforms] [PATCH V1 1/5] KabylakeOpenBoardPkg: Add I2cHdmiDebugSerialPortLib Date: Fri, 17 Jun 2022 21:05:46 -0700 Message-Id: <20220618040550.8467-2-nathaniel.l.desimone@intel.com> In-Reply-To: <20220618040550.8467-1-nathaniel.l.desimone@intel.com> References: <20220618040550.8467-1-nathaniel.l.desimone@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,nathaniel.l.desimone@intel.com X-Gm-Message-State: DNWOOor30fUbreEqCDNXQM9fx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1655525158; bh=aqFO91oTf3OCfFgOuiifRs2Rx4m/ybGo9RSp3aHmJoU=; h=Cc:Date:From:Reply-To:Subject:To; b=FBRdvzmlgiM+uSTZBROGPfDPWrWyTwleA33DXPbMPlGrPOXhWARJczxUi9GNSbb8a2W 5veyV88+4BVt9d/3BeQG7z3iuqRySS88mYZ8TJxhsB1wM33Hntrpv9LhAADhLhGXCkibF NCxoA+/X9VQcPD7EF67eMSxeTjbN0Wgg84Y= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1655525160618100016 Content-Type: text/plain; charset="utf-8" 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 Cc: Sai Chaganty Cc: Isaac Oram Cc: Benjamin Doron Cc: Michael Kubacki Cc: Jeremy Soller Signed-off-by: Nate DeSimone --- .../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/I2cHdmiDebu= gSerialPortLib/DxeI2cHdmiDebugSerialPortLib.inf create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebu= gSerialPortLib/DxeSmmI2cHdmiDebugSerialPortLib.c create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebu= gSerialPortLib/Gmbus.c create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebu= gSerialPortLib/Gmbus.h create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebu= gSerialPortLib/I2cDebugPortProtocol.c create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebu= gSerialPortLib/I2cDebugPortProtocol.h create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebu= gSerialPortLib/I2cDebugPortTplDxe.c create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebu= gSerialPortLib/I2cDebugPortTplNull.c create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebu= gSerialPortLib/I2cHdmiDebugSerialPortLib.c create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebu= gSerialPortLib/IgfxI2c.c create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebu= gSerialPortLib/IgfxI2c.h create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebu= gSerialPortLib/PeiI2cHdmiDebugSerialPortLib.c create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebu= gSerialPortLib/PeiI2cHdmiDebugSerialPortLib.inf create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebu= gSerialPortLib/SecI2cHdmiDebugSerialPortLib.c create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebu= gSerialPortLib/SecI2cHdmiDebugSerialPortLib.inf create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebu= gSerialPortLib/SmmI2cHdmiDebugSerialPortLib.inf diff --git a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/OpenBoar= dPkgPcd.dsc b/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/OpenBoa= rdPkgPcd.dsc index 02080aa864..822040c06f 100644 --- a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/OpenBoardPkgPcd= .dsc +++ b/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/OpenBoardPkgPcd= .dsc @@ -427,6 +427,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|0x0= 0 #@todo - Set to correct value for VN7-572G =20 [PcdsFixedAtBuild.IA32] ###################################### diff --git a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkgPcd= .dsc b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkgPcd.dsc index 26e2c16aae..c05535aab7 100644 --- a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkgPcd.dsc +++ b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkgPcd.dsc @@ -359,6 +359,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 =20 [PcdsFixedAtBuild.IA32] ###################################### diff --git a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkgP= cd.dsc b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkgPcd.d= sc index ccf757e202..bdd5bc4127 100644 --- a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkgPcd.dsc +++ b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkgPcd.dsc @@ -359,6 +359,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 =20 [PcdsFixedAtBuild.IA32] ###################################### diff --git a/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerial= PortLib/DxeI2cHdmiDebugSerialPortLib.inf b/Platform/Intel/KabylakeOpenBoard= Pkg/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.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D DxeI2cHdmiDebugSerialPortLib + FILE_GUID =3D 53A31F61-7B95-4AD0-8F02-B03BCE6FC781 + VERSION_STRING =3D 1.0 + MODULE_TYPE =3D DXE_DRIVER + LIBRARY_CLASS =3D 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 =3D 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/I2cHdmiDebugSerial= PortLib/DxeSmmI2cHdmiDebugSerialPortLib.c b/Platform/Intel/KabylakeOpenBoar= dPkg/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.
+SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include +#include + +#include +#include + +//Once we reach DXE phase we can start assuming global variables are write= able. +STATIC PCH_TYPE mPchType =3D PchTypeUnknown; +STATIC UINT32 mControlBits =3D 0; +STATIC UINT8 mI2cHdmiDebugDdcBusPinPair =3D 0; +STATIC BOOLEAN mIgdBusMasterReset =3D 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 seria= l device. + @retval RETURN_UNSUPPORTED The serial device does not support this op= eration. + @retval RETURN_DEVICE_ERROR The serial device is not functioning corre= ctly. + +**/ +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))) !=3D 0 ) { + return EFI_UNSUPPORTED; + } + Control &=3D (UINT32) ~(EFI_SERIAL_INPUT_BUFFER_EMPTY); + mControlBits =3D Control; + return EFI_SUCCESS; +} + +/** + Retrieve the status of the control bits on a serial device. + + @param Control A pointer to return the current control si= gnals 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 op= eration. + @retval RETURN_DEVICE_ERROR The serial device is not functioning corre= ctly. + +**/ +RETURN_STATUS +EFIAPI +SerialPortGetControl ( + OUT UINT32 *Control + ) +{ + EFI_STATUS Status; + UINT8 NumberOfBytesInFifoBuffer; + + Status =3D I2cDebugPortReadyToRead (&NumberOfBytesInFifoBuffer); + if (EFI_ERROR (Status)) { + return Status; + } + *Control =3D (EFI_SERIAL_CLEAR_TO_SEND | EFI_SERIAL_DATA_SET_READY | + EFI_SERIAL_CARRIER_DETECT | EFI_SERIAL_OUTPUT_BUFFER_EMPTY); + if (NumberOfBytesInFifoBuffer <=3D 0) { + *Control |=3D EFI_SERIAL_INPUT_BUFFER_EMPTY; + } + *Control |=3D mControlBits; + return Status; +} + +/** + Returns the type of PCH on the system + + @retval The PCH type. +**/ +PCH_TYPE +GetPchType ( + VOID + ) +{ + if (mPchType =3D=3D PchTypeUnknown) { + mPchType =3D 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 successf= ully determined + @retval EFI_INVALID_PARAMETER - The given DDC I2C channel does= not exist. + @retval EFI_UNSUPPORTED - The platform is using a PCH th= at is not supported yet. +**/ +EFI_STATUS +GetGmbusBusPinPairForI2cDebugPort ( + OUT UINT8 *DdcBusPinPair + ) +{ + EFI_STATUS Status; + + if (mI2cHdmiDebugDdcBusPinPair =3D=3D 0) { + Status =3D GetGmbusBusPinPair ( + (IGFX_I2C_CHANNEL) PcdGet32 (PcdI2cHdmiDebugPortDdcI2cChan= nel), + &mI2cHdmiDebugDdcBusPinPair + ); + if (EFI_ERROR (Status)) { + mI2cHdmiDebugDdcBusPinPair =3D 0; + return Status; + } + } + *DdcBusPinPair =3D 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 f= lag +**/ +VOID +SetIgdBusMasterReset ( + BOOLEAN IgdBusMasterReset + ) +{ + mIgdBusMasterReset =3D IgdBusMasterReset; +} diff --git a/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerial= PortLib/Gmbus.c b/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugS= erialPortLib/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.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include +#include +#include + +#include +#include + +/** + 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 =3D PCI_LIB_ADDRESS (SA_IGD_BUS, SA_IGD_DEV, SA_IGD_FUN_= 0, R_SA_IGD_GTTMMADR); + GttMmAdr =3D PciRead32 (GttMmPciAddress) & 0xFFFFFFF0; + //DEBUG ((DEBUG_INFO, "GttMmPciAddress =3D %x\n", (UINTN) GttMmPciAddres= s)); //@TODO + //DEBUG ((DEBUG_INFO, "GttMmAdr =3D %x\n", (UINTN) GttMmAdr)); //@TODO + //DEBUG ((DEBUG_INFO, "GMBUS2 =3D %x\n", (UINTN) MmioRead32 (GttMmAdr + = R_SA_GTTMMADR_GMBUS2_STATUS))); //@TODO + //DEBUG ((DEBUG_INFO, "IGD CMD =3D %x\n", (UINTN) PciRead16 (PCI_LIB_ADD= RESS (SA_IGD_BUS, SA_IGD_DEV, SA_IGD_FUN_0, R_SA_IGD_CMD)))); //@TODO + if (GttMmAdr =3D=3D 0) { + //DEBUG ((DEBUG_INFO, "Programming GTT MMIO\n"));//@TODO + GttMmAdr =3D (UINT32) FixedPcdGet32 (PcdGttMmAddress); + if (GttMmAdr =3D=3D 0) { + return 0; + } + //DEBUG ((DEBUG_INFO, "GMBUS2 Before =3D %x\n", (UINTN) MmioRead32 (Gt= tMmAdr + R_SA_GTTMMADR_GMBUS2_STATUS))); //@TODO + // + // Program and read back GTT Memory Mapped BAR + // + PciWrite32 (GttMmPciAddress, (UINT32) (GttMmAdr & 0xFF000000)); + GttMmAdr =3D PciRead32 (GttMmPciAddress) & 0xFFFFFFF0; + //DEBUG ((DEBUG_INFO, "GttMmAdr =3D %x\n", (UINTN) GttMmAdr));//@TODO + //DEBUG ((DEBUG_INFO, "GMBUS2 After =3D %x\n", (UINTN) MmioRead32 (Gtt= MmAdr + 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_CM= D) + ) + & (BIT2 | BIT1)) !=3D (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_I= GD_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 stat= e 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)) !=3D 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_S= A_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 writte= n. + @retval EFI_DEVICE_ERROR - An error occurred while writti= ng to GMBUS0 +**/ +EFI_STATUS +SetGmbus0ClockPortSelect ( + IN UINT32 GmbusClkPrtSel + ) +{ + UINTN GttMmAdr; + + GttMmAdr =3D 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 writte= n. + @retval EFI_DEVICE_ERROR - An error occurred while writti= ng to GMBUS1 +**/ +EFI_STATUS +SetGmbus1Command ( + IN UINT32 GmbusCmdSts + ) +{ + UINTN GttMmAdr; + + GttMmAdr =3D 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 readin= g from GMBUS2 +**/ +EFI_STATUS +GetGmbus2Status ( + OUT UINT32 *GmbusStatus + ) +{ + UINTN GttMmAdr; + + GttMmAdr =3D GmbusGetGttMmAdr (); + if (GttMmAdr =3D=3D 0) { + return EFI_UNSUPPORTED; + } + *GmbusStatus =3D 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 writte= n. + @retval EFI_DEVICE_ERROR - An error occurred while writti= ng to GMBUS2 +**/ +EFI_STATUS +SetGmbus2Status ( + IN UINT32 GmbusStatus + ) +{ + UINTN GttMmAdr; + + GttMmAdr =3D GmbusGetGttMmAdr (); + if (GttMmAdr =3D=3D 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 readin= g from GMBUS2 +**/ +EFI_STATUS +GetGmbus3Data ( + OUT UINT32 *GmbusData + ) +{ + UINTN GttMmAdr; + + GttMmAdr =3D GmbusGetGttMmAdr (); + if (GttMmAdr =3D=3D 0) { + return EFI_UNSUPPORTED; + } + *GmbusData =3D 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 writte= n. + @retval EFI_DEVICE_ERROR - An error occurred while writti= ng to GMBUS3 +**/ +EFI_STATUS +SetGmbus3Data ( + IN UINT32 GmbusData + ) +{ + UINTN GttMmAdr; + + GttMmAdr =3D GmbusGetGttMmAdr (); + if (GttMmAdr =3D=3D 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 rese= t on the GMBUS controller. + + @retval EFI_SUCCESS - The GMBUS error was successful= ly cleared. + @retval EFI_TIMEOUT - The GMBUS I2C controller did n= ot respond within the required timeout period. + @retval EFI_DEVICE_ERROR - An error occurred while access= ing 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 =3D 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 =3D 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 =3D 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 indica= ted must be 1, otherwise it must be 0. + + @retval EFI_SUCCESS - The GMBUS controller has clear= ed all of the bits in the bitmask. + @retval EFI_TIMEOUT - The GMBUS controller did not c= lear all of the bits in the bitmask + within the required timeout pe= riod. + @retval EFI_DEVICE_ERROR - An error occurred while access= ing 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 =3D EFI_TIMEOUT; + for (Index =3D 0; Index < GMBUS_TIMEOUT; Index++) { + Status2 =3D 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 =3D EFI_SUCCESS; + break; + } + } else { + if (!(GmbusStatus & StatusBitMask)) { + Status =3D EFI_SUCCESS; + break; + } + } + } + if (EFI_ERROR (Status)) { + //DEBUG ((DEBUG_INFO, "GmbusStatus =3D %x\n", (UINTN) GmbusStatus));//= @TODO + } + if (Status =3D=3D EFI_TIMEOUT) { + if (WaitForAssertion) { + //DEBUG ((DEBUG_INFO, "Error: %a() - Gmbus assertion did not occur w= ithin timeout period.\n", __FUNCTION__)); + } else { + //DEBUG ((DEBUG_INFO, "Error: %a() - Gmbus de-assertion did not occu= r within timeout period.\n", __FUNCTION__)); + } + } + return Status; +} + +/** + Initialize the GMBUS to use a given GPIO pin pair and clock speed in pre= paration + 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 co= ntroller should use. + + @retval EFI_SUCCESS - The GMBUS has been initialized= successfully. + @retval EFI_INVALID_PARAMETER - The given BusSpeed does not ma= tch a valid clock rate value. + @retval EFI_TIMEOUT - The GMBUS I2C controller did n= ot respond within the required timeout period. + @retval EFI_DEVICE_ERROR - An error occurred while access= ing 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 !=3D GMBUS_CLOCK_RATE_100K) && (BusSpeed !=3D GMBUS_CLOCK_= RATE_50K) && + (BusSpeed !=3D GMBUS_CLOCK_RATE_400K) && (BusSpeed !=3D GMBUS_CLOCK_= RATE_1M)) { + return EFI_INVALID_PARAMETER; + } + // + // Wait for GMBUS to complete any pending commands + // + Status =3D 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__)); //@t= odo + // + // Program the GMBUS Port and Clock + // + GmbusClkPrtSel =3D (BusSpeed << 8) | DdcBusPinPair; + Status =3D 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 =3D 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 =3D 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 su= ccessfully. + @retval EFI_DEVICE_ERROR - An error occurred while access= ing the GMBUS I2C controller. +**/ +EFI_STATUS +GmbusRelease ( + VOID + ) +{ + EFI_STATUS Status; + + // + // Clear the GMBUS Port and Clock + // + Status =3D 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 G= MBUS resource. + // The GMBUS controller will then reset the INUSE bit to 0. + // + Status =3D 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 t= he read operation + @param[in] SlaveAddress - The I2C device address to read= data from + @param[in] SendStopCondition - TRUE: After the read is compl= ete, 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 repe= ated START condition to the I2C bus after + GmbusRead() exits by ca= lling either GmbusRead() or GmbusWrite() + immediately after this = function returns. + @param[in] SendIndexBeforeRead - TRUE: Before executing the re= ad 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 writ= e) 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 fr= om the I2C bus. On output, the number of bytes + actually read. + @param[out] ReadBuffer - The memory buffer to return th= e read data. + + @retval EFI_SUCCESS - The data was successfully read. + @retval EFI_INVALID_PARAMETER - One of the following condition= s: + * ByteCount is 0 or >GMBUS_MAX= _BYTES. + * ReadBuffer is NULL + * SlaveAddress does not have B= IT0 set (required for reads.) + @retval EFI_TIMEOUT - The GMBUS I2C controller did n= ot respond within the required timeout period. + @retval EFI_DEVICE_ERROR - An error occurred while access= ing 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 =3D EFI_SUCCESS; + BytesRead =3D 0; + GmbusStatus =3D 0; + + // + // Input Validation + // + if ((*ByteCount) <=3D 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 =3D=3D NULL) { + DEBUG ((DEBUG_INFO, "Error: %a() - ReadBuffer is NULL.\n", __FUNCTION_= _)); + return EFI_INVALID_PARAMETER; + } + if ((SlaveAddress & BIT0) !=3D 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 =3D GmbusPrepare (GMBUS_CLOCK_RATE_50K, (DdcBusPinPair & B_SA_GTT= MMADR_GMBUS0_PIN_PAIR_MASK)); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_INFO, "Error: %a() - GmbusPrepare() failed - %r\n", __FU= NCTION__, Status)); + goto Done; + } + + // + // Construct the command for the GMBUS controller + // + GmbusCmdSts =3D ((UINT32) SlaveAddress) | + B_SA_GTTMMADR_GMBUS1_BUS_CYCLE_SEL_START | + B_SA_GTTMMADR_GMBUS1_SW_RDY | + B_SA_GTTMMADR_GMBUS1_EN_TIMEOUT; + GmbusCmdSts |=3D (((*ByteCount) << N_SA_GTTMMADR_GMBUS1_TOTAL_BYTE_CO= UNT) & B_SA_GTTMMADR_GMBUS1_TOTAL_BYTE_COUNT_MASK); + if (SendStopCondition) { + GmbusCmdSts |=3D B_SA_GTTMMADR_GMBUS1_BUS_CYCLE_SEL_STOP; + } + if (SendIndexBeforeRead) { + GmbusCmdSts |=3D B_SA_GTTMMADR_GMBUS1_BUS_CYCLE_SEL_INDEX; + GmbusCmdSts |=3D ((IndexData << N_SA_GTTMMADR_GMBUS1_INDEX) & B_SA_GT= TMMADR_GMBUS1_INDEX_MASK); + } + + // + // Send the command to the GMBUS controller, this will cause the I2C tra= nsaction to begin immediately + // + Status =3D 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 i= n the GMBUS1 register + // * When an active GMBUS cycle has terminated with a STOP condition + // * During a GMBUS write transaction, when the data register can acce= pt 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 =3D 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 =3D GetGmbus2Status (&GmbusStatus); + if (EFI_ERROR (Status2)) { + Status =3D Status2; + DEBUG ((DEBUG_INFO, "Error: %a() - GetGmbus2Status() failed - %r\n",= __FUNCTION__, Status)); + goto Done; + } + if (EFI_ERROR (Status) && ((GmbusStatus & B_SA_GTTMMADR_GMBUS2_NACK_IN= DICATOR) =3D=3D 0)) { + DEBUG ((DEBUG_INFO, "Error: %a() - Unexpected behavior detected!\n",= __FUNCTION__)); + DEBUG ((DEBUG_INFO, "The GMBUS controller did not encounter a NACK a= nd it did not set the HW_RDY bit.\n")); + DEBUG ((DEBUG_INFO, "Status =3D %r\n", Status)); + Status =3D EFI_DEVICE_ERROR; + goto Done; + } + if (((GmbusStatus & B_SA_GTTMMADR_GMBUS2_NACK_INDICATOR) !=3D 0) || + ((GmbusStatus & B_SA_GTTMMADR_GMBUS2_SLAVE_STALL_TIMEOUT_ERROR) != =3D 0)) { + // + // If a NACK or Slave Stall Timeout occurs, then a bus error has occ= urred. + // 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 operati= on.\n", __FUNCTION__)); + Status =3D GmbusRecoverError (); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_INFO, "Error: %a() - GmbusRecoverError() failed - %r= \n", __FUNCTION__, Status)); + goto Done; + } + Status =3D EFI_DEVICE_ERROR; + goto Done; + } + // + // No error conditions were encountered, read the data and write it to= the data buffer + // + Status =3D GetGmbus3Data (&GmbusData); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_INFO, "Error: %a() - GetGmbus3Data() failed - %r\n", _= _FUNCTION__, Status)); + goto Done; + } + for (Index =3D 0; (Index < sizeof (UINT32)) && (BytesRead < (*ByteCoun= t)); Index++) { + ReadBuffer[BytesRead] =3D (GmbusData >> (Index * 8)) & 0xFF; + BytesRead++; + } + } + + // + // Wait for the GMBUS controller to enter the IDLE state + // + Status =3D 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 =3D GmbusRelease (); + if (EFI_ERROR (Status2)) { + Status =3D Status2; + DEBUG ((DEBUG_INFO, "Error: %a() - GmbusRelease() failed - %r\n", __FU= NCTION__, Status)); + } + GmbusResetBusMaster (); + + (*ByteCount) =3D BytesRead; + return Status; +} + +/** + Writes data to the I2C bus using the GMBUS I2C controller + + @param[in] DdcBusPinPair - The GPIO pin pair to use for t= he write operation + @param[in] SlaveAddress - The I2C device address to writ= e data to + @param[in] SendStopCondition - TRUE: After the write is comp= lete, 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 repe= ated START condition to the I2C bus after + GmbusRead() exits by ca= lling either GmbusRead() or GmbusWrite() + immediately after this = function returns. + @param[in] ByteCount - The number of bytes to write t= o the I2C bus. + @param[in] WriteBuffer - The data to be written to the = I2C bus. + + @retval EFI_SUCCESS - The data was successfully writ= ten. + @retval EFI_INVALID_PARAMETER - One of the following condition= s: + * ByteCount is 0 or >GMBUS_MAX= _BYTES. + * WriteBuffer is NULL + * SlaveAddress does not have B= IT0 cleared (required for writes.) + @retval EFI_TIMEOUT - The GMBUS I2C controller did n= ot respond within the required timeout period. + @retval EFI_DEVICE_ERROR - An error occurred while access= ing 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 =3D EFI_SUCCESS; + BytesWritten =3D 0; + GmbusStatus =3D 0; + FirstLoop =3D TRUE; + + //DEBUG ((DEBUG_INFO, "%a() - Enter\n", __FUNCTION__)); //@todo + // + // Input Validation + // + if (ByteCount <=3D 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_M= AX_BYTES[%d].\n", __FUNCTION__, GMBUS_MAX_BYTES)); + return EFI_INVALID_PARAMETER; + } + if (WriteBuffer =3D=3D NULL) { + //DEBUG ((DEBUG_INFO, "Error: %a() - ReadBuffer is NULL.\n", __FUNCTIO= N__)); + return EFI_INVALID_PARAMETER; + } + if ((SlaveAddress & BIT0) !=3D 0) { + //DEBUG ((DEBUG_INFO, "Error: %a() - BIT0 of SlaveAddress should be cl= eared for an I2C write.\n", __FUNCTION__)); + return EFI_INVALID_PARAMETER; + } + + // + // Configure Gmbus port and clock speed + //GMBUS_CLOCK_RATE_100K @todo + Status =3D GmbusPrepare (GMBUS_CLOCK_RATE_50K, (DdcBusPinPair & B_SA_GTT= MMADR_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 =3D ((UINT32) SlaveAddress) | + B_SA_GTTMMADR_GMBUS1_BUS_CYCLE_SEL_START | + B_SA_GTTMMADR_GMBUS1_SW_RDY | + B_SA_GTTMMADR_GMBUS1_EN_TIMEOUT; + GmbusCmdSts |=3D ((ByteCount << N_SA_GTTMMADR_GMBUS1_TOTAL_BYTE_COUNT= ) & B_SA_GTTMMADR_GMBUS1_TOTAL_BYTE_COUNT_MASK); + if (SendStopCondition) { + GmbusCmdSts |=3D 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 =3D 0; + for (Index =3D 0; (Index < sizeof (UINT32)) && (BytesWritten < ByteCount= ); Index++) { + GmbusData |=3D (WriteBuffer[BytesWritten] << (Index * 8)); + BytesWritten++; + } + Status =3D 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 tra= nsaction to begin immediately + // + Status =3D 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 t= he + // GMBUS controller's data buffer. + // + if(!FirstLoop) { + GmbusData =3D 0; + for (Index =3D 0; (Index < sizeof (UINT32)) && (BytesWritten < ByteC= ount); Index++) { + GmbusData |=3D (WriteBuffer[BytesWritten] << (Index * 8)); + BytesWritten++; + } + Status =3D SetGmbus3Data (GmbusData); + if (EFI_ERROR (Status)) { + //DEBUG ((DEBUG_INFO, "Error: %a() - SetGmbus3Data() failed - %r\n= ", __FUNCTION__, Status)); + goto Done; + } + } + FirstLoop =3D 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 i= n the GMBUS1 register + // * When an active GMBUS cycle has terminated with a STOP condition + // * During a GMBUS write transaction, when the data register can acce= pt 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 =3D 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 =3D GetGmbus2Status (&GmbusStatus); + if (EFI_ERROR (Status2)) { + Status =3D Status2; + //DEBUG ((DEBUG_INFO, "Error: %a() - GetGmbus2Status() failed - %r\n= ", __FUNCTION__, Status)); + goto Done; + } + if (EFI_ERROR (Status) && ((GmbusStatus & B_SA_GTTMMADR_GMBUS2_NACK_IN= DICATOR) =3D=3D 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 =3D %r\n", Status)); + Status =3D EFI_DEVICE_ERROR; + goto Done; + } + if (((GmbusStatus & B_SA_GTTMMADR_GMBUS2_NACK_INDICATOR) !=3D 0) || + ((GmbusStatus & B_SA_GTTMMADR_GMBUS2_SLAVE_STALL_TIMEOUT_ERROR) != =3D 0)) { + // + // If a NACK or Slave Stall Timeout occurs, then a bus error has occ= urred. + // 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 oper= ation.\n", __FUNCTION__)); + Status =3D GmbusRecoverError (); + if (EFI_ERROR (Status)) { + //DEBUG ((DEBUG_INFO, "Error: %a() - GmbusRecoverError() failed - = %r\n", __FUNCTION__, Status)); + goto Done; + } + Status =3D EFI_DEVICE_ERROR; + goto Done; + } + } + + // + // Wait for the GMBUS controller to enter the IDLE state + // + Status =3D 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 =3D GmbusRelease (); + if (EFI_ERROR (Status2)) { + Status =3D Status2; + //DEBUG ((DEBUG_INFO, "Error: %a() - GmbusRelease() failed - %r\n", __= FUNCTION__, Status)); + } + GmbusResetBusMaster (); + + return Status; +} diff --git a/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerial= PortLib/Gmbus.h b/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugS= erialPortLib/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.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Conventions: + - 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 + +//@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 +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D +Value | Name | Description +------+-------------------------+-----------------------------------------= ------------------------------------------- +000b | No cycle | No GMBUS cycle is generated +001b | No Index, No Stop, Wait | GMBUS cycle is generated without an INDE= X, 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 INDE= X and with a STOP +110b | Reserved | Reserved +111b | Index, Stop | GMBUS cycle is generated with an INDEX a= nd 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 stat= e 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 f= lag +**/ +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 writte= n. + @retval EFI_DEVICE_ERROR - An error occurred while writti= ng 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 writte= n. + @retval EFI_DEVICE_ERROR - An error occurred while writti= ng 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 readin= g 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 writte= n. + @retval EFI_DEVICE_ERROR - An error occurred while writti= ng 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 readin= g 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 writte= n. + @retval EFI_DEVICE_ERROR - An error occurred while writti= ng to GMBUS3 +**/ +EFI_STATUS +SetGmbus3Data ( + IN UINT32 GmbusData + ); + +/** + Set and clear the software clear interrupt bit. This causes a local rese= t on the GMBUS controller. + + @retval EFI_SUCCESS - The GMBUS error was successful= ly cleared. + @retval EFI_TIMEOUT - The GMBUS I2C controller did n= ot respond within the required timeout period. + @retval EFI_DEVICE_ERROR - An error occurred while access= ing 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 indica= ted must be 1, otherwise it must be 0. + + @retval EFI_SUCCESS - The GMBUS controller has clear= ed all of the bits in the bitmask. + @retval EFI_TIMEOUT - The GMBUS controller did not c= lear all of the bits in the bitmask + within the required timeout pe= riod. + @retval EFI_DEVICE_ERROR - An error occurred while access= ing 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 pre= paration + 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 co= ntroller should use. + + @retval EFI_SUCCESS - The GMBUS has been initialized= successfully. + @retval EFI_INVALID_PARAMETER - The given BusSpeed does not ma= tch a valid clock rate value. + @retval EFI_TIMEOUT - The GMBUS I2C controller did n= ot respond within the required timeout period. + @retval EFI_DEVICE_ERROR - An error occurred while access= ing 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 su= ccessfully. + @retval EFI_DEVICE_ERROR - An error occurred while access= ing 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 t= he read operation + @param[in] SlaveAddress - The I2C device address to read= data from + @param[in] SendStopCondition - TRUE: After the read is compl= ete, 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 repe= ated START condition to the I2C bus after + GmbusRead() exits by ca= lling either GmbusRead() or GmbusWrite() + immediately after this = function returns. + @param[in] SendIndexBeforeRead - TRUE: Before executing the re= ad 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 writ= e) 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 fr= om the I2C bus. On output, the number of bytes + actually read. + @param[out] ReadBuffer - The memory buffer to return th= e read data. + + @retval EFI_SUCCESS - The data was successfully read. + @retval EFI_INVALID_PARAMETER - One of the following condition= s: + * ByteCount is 0 or >GMBUS_MAX= _BYTES. + * ReadBuffer is NULL + * SlaveAddress does not have B= IT0 set (required for reads.) + @retval EFI_TIMEOUT - The GMBUS I2C controller did n= ot respond within the required timeout period. + @retval EFI_DEVICE_ERROR - An error occurred while access= ing 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 t= he write operation + @param[in] SlaveAddress - The I2C device address to writ= e data to + @param[in] SendStopCondition - TRUE: After the write is comp= lete, 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 repe= ated START condition to the I2C bus after + GmbusRead() exits by ca= lling either GmbusRead() or GmbusWrite() + immediately after this = function returns. + @param[in] ByteCount - The number of bytes to write t= o the I2C bus. + @param[in] WriteBuffer - The data to be written to the = I2C bus. + + @retval EFI_SUCCESS - The data was successfully writ= ten. + @retval EFI_INVALID_PARAMETER - One of the following condition= s: + * ByteCount is 0 or >GMBUS_MAX= _BYTES. + * WriteBuffer is NULL + * SlaveAddress does not have B= IT0 cleared (required for writes.) + @retval EFI_TIMEOUT - The GMBUS I2C controller did n= ot respond within the required timeout period. + @retval EFI_DEVICE_ERROR - An error occurred while access= ing 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/I2cHdmiDebugSerial= PortLib/I2cDebugPortProtocol.c b/Platform/Intel/KabylakeOpenBoardPkg/Librar= y/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.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include +#include + +#include +#include +#include + +/** + 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 t= o the I2C debug port. + + @retval EFI_SUCCESS - The data was successfully writ= ten. + @retval EFI_INVALID_PARAMETER - One of the following condition= s: + * ByteCount is 0 + * Buffer is NULL + @retval EFI_TIMEOUT - The I2C controller did not res= pond within the required timeout period. + @retval EFI_DEVICE_ERROR - An error occurred while access= ing 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 <=3D 0) { + return EFI_INVALID_PARAMETER; + } + if (Buffer =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + Status =3D GetGmbusBusPinPairForI2cDebugPort (&DdcBusPinPair); + if (EFI_ERROR (Status)) { + return Status; + } + RaiseTplForI2cDebugPortAccess (); + for (Index =3D 0; Index < Count; Index +=3D I2C_DEBUG_PORT_MAX_DATA_SIZE= ) { + MicroSecondDelay (3000); //3ms stall to let the BusPirate catch up + if ((Index + I2C_DEBUG_PORT_MAX_DATA_SIZE) >=3D Count) { + CurrentSize =3D (UINT8) (Count - Index); + } else { + CurrentSize =3D I2C_DEBUG_PORT_MAX_DATA_SIZE; + } + WriteBuffer[0] =3D (I2C_DEBUG_PORT_WRITE_COMMAND << I2C_DEBUG_PORT_CO= MMAND_BIT_POSITION) | + (CurrentSize & I2C_DEBUG_PORT_DATA_SIZE_BIT_MASK); + CopyMem (&(WriteBuffer[1]), &(Buffer[Index]), CurrentSize); + Status =3D GmbusWrite (DdcBusPinPair, I2C_DEBUG_PORT_WRITE_DEVICE_ADDR= ESS, 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 th= e read data. + @param[in, out] Count - The number of bytes to read fr= om 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 condition= s: + * ByteCount is 0 + * Buffer is NULL + @retval EFI_TIMEOUT - The I2C controller did not res= pond within the required timeout period. + @retval EFI_DEVICE_ERROR - An error occurred while access= ing 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 =3D 0; + if ((*Count) <=3D 0) { + return EFI_INVALID_PARAMETER; + } + if (Buffer =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + Status =3D GetGmbusBusPinPairForI2cDebugPort (&DdcBusPinPair); + if (EFI_ERROR (Status)) { + return Status; + } + RaiseTplForI2cDebugPortAccess (); + for (Index =3D 0; Index < (*Count); Index +=3D I2C_DEBUG_PORT_MAX_DATA_S= IZE) { + MicroSecondDelay (3000); //3ms stall to let the BusPirate catch up + if ((Index + I2C_DEBUG_PORT_MAX_DATA_SIZE) >=3D (*Count)) { + CurrentSize =3D (*Count) - Index; + } else { + CurrentSize =3D I2C_DEBUG_PORT_MAX_DATA_SIZE; + } + GmbusIndexData =3D (I2C_DEBUG_PORT_READ_COMMAND << I2C_DEBUG_PORT_COM= MAND_BIT_POSITION) | + (CurrentSize & I2C_DEBUG_PORT_DATA_SIZE_BIT_MASK); + Status =3D GmbusRead ( + DdcBusPinPair, + I2C_DEBUG_PORT_READ_DEVICE_ADDRESS, + TRUE, + TRUE, + GmbusIndexData, + &CurrentSize, + &(Buffer[Index]) + ); + if (EFI_ERROR (Status)) { + break; + } + BytesRead +=3D CurrentSize; + if (((Index + I2C_DEBUG_PORT_MAX_DATA_SIZE) < (*Count)) && (CurrentSiz= e < I2C_DEBUG_PORT_MAX_DATA_SIZE)) { + break; + } + } + RestoreTplAfterI2cDebugPortAccess (); + + (*Count) =3D BytesRead; + //DEBUG ((DEBUG_INFO, "I2cDebugPortRead() - Exit\n")); + return Status; +} + +/** + Queries the I2C debug port to see if there are any data waiting to be re= ad + + @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 success= fully queried + @retval EFI_INVALID_PARAMETER - One of the following condition= s: + * NumberOfBytesInFifoBuffer is= NULL + @retval EFI_TIMEOUT - The I2C controller did not res= pond within the required timeout period. + @retval EFI_DEVICE_ERROR - An error occurred while access= ing 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 =3D 1; + if (NumberOfBytesInFifoBuffer =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + Status =3D GetGmbusBusPinPairForI2cDebugPort (&DdcBusPinPair); + if (EFI_ERROR (Status)) { + return Status; + } + MicroSecondDelay (3000); //3ms stall to let the BusPirate catch up + GmbusIndexData =3D (I2C_DEBUG_PORT_READY_TO_READ_COMMAND << I2C_DEBUG_P= ORT_COMMAND_BIT_POSITION) | + (1 & I2C_DEBUG_PORT_DATA_SIZE_BIT_MASK); //READY_TO_RE= AD always returns 1 byte + RaiseTplForI2cDebugPortAccess (); + Status =3D GmbusRead (DdcBusPinPair, I2C_DEBUG_PORT_READ_DEVICE_ADDRESS,= TRUE, TRUE, GmbusIndexData, &BytesRead, NumberOfBytesInFifoBuffer); + if (EFI_ERROR (Status)) { + return Status; + } + RestoreTplAfterI2cDebugPortAccess (); + if (BytesRead !=3D 1) { + Status =3D EFI_DEVICE_ERROR; + } + //DEBUG ((DEBUG_INFO, "I2cDebugPortReadyToRead() - Exit\n")); + return Status; +} diff --git a/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerial= PortLib/I2cDebugPortProtocol.h b/Platform/Intel/KabylakeOpenBoardPkg/Librar= y/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.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include + +#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 t= o the I2C debug port. + + @retval EFI_SUCCESS - The data was successfully writ= ten. + @retval EFI_INVALID_PARAMETER - One of the following condition= s: + * ByteCount is 0 + * Buffer is NULL + @retval EFI_TIMEOUT - The I2C controller did not res= pond within the required timeout period. + @retval EFI_DEVICE_ERROR - An error occurred while access= ing 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 th= e read data. + @param[in, out] Count - The number of bytes to read fr= om 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 condition= s: + * ByteCount is 0 + * Buffer is NULL + @retval EFI_TIMEOUT - The I2C controller did not res= pond within the required timeout period. + @retval EFI_DEVICE_ERROR - An error occurred while access= ing 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 re= ad + + @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 success= fully queried + @retval EFI_INVALID_PARAMETER - One of the following condition= s: + * NumberOfBytesInFifoBuffer is= NULL + @retval EFI_TIMEOUT - The I2C controller did not res= pond within the required timeout period. + @retval EFI_DEVICE_ERROR - An error occurred while access= ing the I2C controller. +**/ +EFI_STATUS +I2cDebugPortReadyToRead ( + OUT UINT8 *NumberOfBytesInFifoBuffer + ); diff --git a/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerial= PortLib/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.
+SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include + +STATIC EFI_TPL mPreviousTpl =3D 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 =3D 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 =3D 0; + } +} diff --git a/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerial= PortLib/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.
+SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include + +/** + 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/I2cHdmiDebugSerial= PortLib/I2cHdmiDebugSerialPortLib.c b/Platform/Intel/KabylakeOpenBoardPkg/L= ibrary/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.
+SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include +#include + +#include +#include + +/** + Initialize the serial device hardware. + + If no initialization is required, then return RETURN_SUCCESS. + If the serial device was successfully initialized, then return RETURN_SU= CCESS. + 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 devic= e. + 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 =3D=3D NULL) { + return 0; + } + if (NumberOfBytes =3D=3D 0) { + return 0; + } + Status =3D I2cDebugPortWrite (Buffer, (UINT32) NumberOfBytes); + //DEBUG ((DEBUG_INFO, "Status =3D %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 re= ad 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 =3D=3D NULL) { + return 0; + } + if (NumberOfBytes =3D=3D 0) { + return 0; + } + BytesRead =3D (UINT32) NumberOfBytes; + Status =3D 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 FALS= E is returned. + + @retval TRUE Data is waiting to be read from the serial devi= ce. + @retval FALSE There is no data waiting to be read from the se= rial device. + +**/ +BOOLEAN +EFIAPI +SerialPortPoll ( + VOID + ) +{ + EFI_STATUS Status; + UINT8 NumberOfBytesInFifoBuffer; + + Status =3D I2cDebugPortReadyToRead (&NumberOfBytesInFifoBuffer); + if (EFI_ERROR (Status)) { + return FALSE; + } + if (NumberOfBytesInFifoBuffer <=3D 0) { + return FALSE; + } + return TRUE; +} + +/** + Sets the baud rate, receive FIFO depth, transmit/receice time out, parit= y, + 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 d= evice's default time + out value. + On output, the value actually set. + @param Parity The type of parity to use on this serial devic= e. A Parity value of + DefaultParity will use the device's default pa= rity value. + On output, the value actually set. + @param DataBits The number of data bits to use on the serial d= evice. 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 ser= ial device. + @retval RETURN_UNSUPPORTED The serial device does not support thi= s operation. + @retval RETURN_INVALID_PARAMETER One or more of the attributes has an u= nsupported value. + @retval RETURN_DEVICE_ERROR The serial device is not functioning c= orrectly. + +**/ +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/I2cHdmiDebugSerial= PortLib/IgfxI2c.c b/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebu= gSerialPortLib/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.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include +#include + +/** + Returns the type of PCH on the system + + @retval The PCH type. +**/ +PCH_TYPE +GetPchTypeInternal ( + VOID + ) +{ + PCH_TYPE PchType; + UINT16 DeviceId; + + PchType =3D PchTypeUnknown; + DeviceId =3D PciRead16 (PCI_LIB_ADDRESS (PCH_PCI_BUS, PCH_LPC_PCI_DEV, = PCH_LPC_PCI_FUN, R_PCH_LPC_DID)); + if ((DeviceId >=3D V_SPT_LP_PCH_START_DEVICE_ID) && (DeviceId <=3D V_SPT= _LP_PCH_END_DEVICE_ID)) { + PchType =3D PchTypeSptLp; + } else if ((DeviceId >=3D V_SPT_H_PCH_START_DEVICE_ID) && (DeviceId <=3D= V_SPT_H_PCH_END_DEVICE_ID )) { + PchType =3D PchTypeSptH; + } else if ((DeviceId >=3D V_KBP_H_PCH_START_DEVICE_ID) && (DeviceId <=3D= V_KBP_H_PCH_END_DEVICE_ID)) { + PchType =3D PchTypeKbpH; + if ((DeviceId =3D=3D V_KBP_H_PCH_DEVICE_ID_ES) || (DeviceId =3D=3D V_K= BP_H_PCH_DEVICE_ID_SVR_ES)) { + PchType =3D PchTypeSptH; + } + } else if ((DeviceId >=3D V_CNL_LP_PCH_START_DEVICE_ID) && (DeviceId <= =3D V_CNL_LP_PCH_END_DEVICE_ID)) { + PchType =3D PchTypeCnlLp; + } else if ((DeviceId >=3D V_CNL_H_PCH_START_DEVICE_ID) && (DeviceId <=3D= V_CNL_H_PCH_END_DEVICE_ID)) { + PchType =3D 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 give= n DDC channel. + + @retval EFI_SUCCESS - The GPIO pin pair was successf= ully determined + @retval EFI_INVALID_PARAMETER - The given DDC I2C channel does= not exist. + @retval EFI_UNSUPPORTED - The platform is using a PCH th= at is not supported yet. +**/ +EFI_STATUS +GetGmbusBusPinPair ( + IN IGFX_I2C_CHANNEL Channel, + OUT UINT8 *DdcBusPinPair + ) +{ + PCH_TYPE PchType; + *DdcBusPinPair =3D 0; + + PchType =3D GetPchType (); + switch (PchType) { + // The PCH design lineage from SkyLake, KabyLake, AmberLake, & early C= offeeLake + case PchTypeSptLp: + case PchTypeSptH: + case PchTypeKbpH: + switch (Channel) { + case EnumDdcB: + *DdcBusPinPair =3D V_KBL_PCH_HDMI_DDC_B_PIN_PAIR; + return EFI_SUCCESS; + case EnumDdcC: + *DdcBusPinPair =3D V_KBL_PCH_HDMI_DDC_C_PIN_PAIR; + return EFI_SUCCESS; + case EnumDdcD: + *DdcBusPinPair =3D 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 =3D V_CNL_PCH_HDMI_DDC_B_PIN_PAIR; + return EFI_SUCCESS; + case EnumDdcC: + *DdcBusPinPair =3D V_CNL_PCH_HDMI_DDC_C_PIN_PAIR; + return EFI_SUCCESS; + case EnumDdcD: + *DdcBusPinPair =3D V_CNL_PCH_HDMI_DDC_D_PIN_PAIR; + return EFI_SUCCESS; + case EnumDdcF: + *DdcBusPinPair =3D 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/I2cHdmiDebugSerial= PortLib/IgfxI2c.h b/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebu= gSerialPortLib/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.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Conventions: + - 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 + +// +// 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 =3D 0, + PchTypeSptLp, + PchTypeSptH, + PchTypeKbpH, + PchTypeCnlLp, + PchTypeCnlH, + PchTypeMax +} PCH_TYPE; + +typedef enum { + PchH =3D 1, + PchLp, + PchUnknownSeries +} PCH_SERIES; + +typedef enum { + EnumDdcUnknown =3D 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 give= n DDC channel. + + @retval EFI_SUCCESS - The GPIO pin pair was successf= ully determined + @retval EFI_INVALID_PARAMETER - The given DDC I2C channel does= not exist. + @retval EFI_UNSUPPORTED - The platform is using a PCH th= at 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 successf= ully determined + @retval EFI_INVALID_PARAMETER - The given DDC I2C channel does= not exist. + @retval EFI_UNSUPPORTED - The platform is using a PCH th= at 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/I2cHdmiDebugSerial= PortLib/PeiI2cHdmiDebugSerialPortLib.c b/Platform/Intel/KabylakeOpenBoardPk= g/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.
+SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include + +#include +#include +#include +#include +#include + +#include +#include + +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 =3D 0; + GuidHob =3D GetFirstGuidHob (&gI2cHdmiDebugHobGuid); + if (GuidHob =3D=3D NULL) { + //DEBUG ((DEBUG_INFO, "HOB Not Found, Creating HOB\n")); + Context =3D (I2C_HDMI_DEBUG_PORT_CONTEXT *) BuildGuidHob (&gI2cHdmiDeb= ugHobGuid, sizeof (I2C_HDMI_DEBUG_PORT_CONTEXT)); + if (Context =3D=3D NULL) { + return NULL; + } + ZeroMem ((VOID *) Context, sizeof (I2C_HDMI_DEBUG_PORT_CONTEXT)); + Context->PchType =3D GetPchTypeInternal (); + //DEBUG ((DEBUG_INFO, "PchType =3D %d\n", (UINTN) Context->PchType)); + Status =3D GetGmbusBusPinPair ( + (IGFX_I2C_CHANNEL) PcdGet32 (PcdI2cHdmiDebugPortDdcI2cChan= nel), + &I2cHdmiDebugDdcBusPinPair + ); + if (EFI_ERROR (Status)) { + I2cHdmiDebugDdcBusPinPair =3D 0; + } + Context->I2cHdmiDebugDdcBusPinPair =3D I2cHdmiDebugDdcBusPinPair; + //DEBUG ((DEBUG_INFO, "I2cHdmiDebugDdcBusPinPair =3D %d\n", (UINTN) I2= cHdmiDebugDdcBusPinPair)); + //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 seria= l device. + @retval RETURN_UNSUPPORTED The serial device does not support this op= eration. + @retval RETURN_DEVICE_ERROR The serial device is not functioning corre= ctly. + +**/ +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))) !=3D 0 ) { + return EFI_UNSUPPORTED; + } + + Context =3D GetI2cHdmiDebugPortContext (); + if (Context =3D=3D NULL) { + return EFI_UNSUPPORTED; + } + Control &=3D (UINT32) ~(EFI_SERIAL_INPUT_BUFFER_EMPTY); + Context->ControlBits =3D Control; + return EFI_SUCCESS; +} + +/** + Retrieve the status of the control bits on a serial device. + + @param Control A pointer to return the current control si= gnals 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 op= eration. + @retval RETURN_DEVICE_ERROR The serial device is not functioning corre= ctly. + +**/ +RETURN_STATUS +EFIAPI +SerialPortGetControl ( + OUT UINT32 *Control + ) +{ + EFI_STATUS Status; + I2C_HDMI_DEBUG_PORT_CONTEXT *Context; + UINT8 NumberOfBytesInFifoBuffer; + + Context =3D GetI2cHdmiDebugPortContext (); + if (Context =3D=3D NULL) { + return EFI_UNSUPPORTED; + } + Status =3D I2cDebugPortReadyToRead (&NumberOfBytesInFifoBuffer); + if (EFI_ERROR (Status)) { + return Status; + } + *Control =3D (EFI_SERIAL_CLEAR_TO_SEND | EFI_SERIAL_DATA_SET_READY | + EFI_SERIAL_CARRIER_DETECT | EFI_SERIAL_OUTPUT_BUFFER_EMPTY); + if (NumberOfBytesInFifoBuffer <=3D 0) { + *Control |=3D EFI_SERIAL_INPUT_BUFFER_EMPTY; + } + *Control |=3D 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 =3D GetI2cHdmiDebugPortContext (); + if (Context =3D=3D NULL) { + return PchTypeUnknown; + } + //DEBUG ((DEBUG_INFO, "PchType =3D %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 successf= ully determined + @retval EFI_INVALID_PARAMETER - The given DDC I2C channel does= not exist. + @retval EFI_UNSUPPORTED - The platform is using a PCH th= at is not supported yet. +**/ +EFI_STATUS +GetGmbusBusPinPairForI2cDebugPort ( + OUT UINT8 *DdcBusPinPair + ) +{ + I2C_HDMI_DEBUG_PORT_CONTEXT *Context; + + //DEBUG ((DEBUG_INFO, "%a() - Enter\n", __FUNCTION__)); + Context =3D GetI2cHdmiDebugPortContext (); + if (Context =3D=3D NULL) { + return EFI_UNSUPPORTED; + } + + *DdcBusPinPair =3D Context->I2cHdmiDebugDdcBusPinPair; + //DEBUG ((DEBUG_INFO, "I2cHdmiDebugDdcBusPinPair =3D %d\n", (UINTN) Cont= ext->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 =3D GetI2cHdmiDebugPortContext (); + if (Context =3D=3D 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 f= lag +**/ +VOID +SetIgdBusMasterReset ( + BOOLEAN IgdBusMasterReset + ) +{ + I2C_HDMI_DEBUG_PORT_CONTEXT *Context; + + Context =3D GetI2cHdmiDebugPortContext (); + if (Context =3D=3D NULL) { + return; + } + + Context->IgdBusMasterReset =3D IgdBusMasterReset; +} diff --git a/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerial= PortLib/PeiI2cHdmiDebugSerialPortLib.inf b/Platform/Intel/KabylakeOpenBoard= Pkg/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.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D PeiI2cHdmiDebugSerialPortLib + FILE_GUID =3D 9B537D5A-BD66-4FD5-A3F2-F3377840492E + VERSION_STRING =3D 1.0 + MODULE_TYPE =3D BASE + LIBRARY_CLASS =3D SerialPortLib|PEI_CORE PEIM +# +# The following information is for reference only and not required by the = build tools. +# +# VALID_ARCHITECTURES =3D 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/I2cHdmiDebugSerial= PortLib/SecI2cHdmiDebugSerialPortLib.c b/Platform/Intel/KabylakeOpenBoardPk= g/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.
+SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include + +#include +#include + +/** + 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 seria= l device. + @retval RETURN_UNSUPPORTED The serial device does not support this op= eration. + @retval RETURN_DEVICE_ERROR The serial device is not functioning corre= ctly. + +**/ +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))) !=3D 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 si= gnals 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 op= eration. + @retval RETURN_DEVICE_ERROR The serial device is not functioning corre= ctly. + +**/ +RETURN_STATUS +EFIAPI +SerialPortGetControl ( + OUT UINT32 *Control + ) +{ + EFI_STATUS Status; + UINT8 NumberOfBytesInFifoBuffer; + + Status =3D I2cDebugPortReadyToRead (&NumberOfBytesInFifoBuffer); + if (EFI_ERROR (Status)) { + return Status; + } + *Control =3D (EFI_SERIAL_CLEAR_TO_SEND | EFI_SERIAL_DATA_SET_READY | + EFI_SERIAL_CARRIER_DETECT | EFI_SERIAL_OUTPUT_BUFFER_EMPTY); + if (NumberOfBytesInFifoBuffer <=3D 0) { + *Control |=3D 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 successf= ully determined + @retval EFI_INVALID_PARAMETER - The given DDC I2C channel does= not exist. + @retval EFI_UNSUPPORTED - The platform is using a PCH th= at is not supported yet. +**/ +EFI_STATUS +GetGmbusBusPinPairForI2cDebugPort ( + OUT UINT8 *DdcBusPinPair + ) +{ + return GetGmbusBusPinPair ((IGFX_I2C_CHANNEL) FixedPcdGet32 (PcdI2cHdmiD= ebugPortDdcI2cChannel), 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 f= lag +**/ +VOID +SetIgdBusMasterReset ( + BOOLEAN IgdBusMasterReset + ) +{ +} diff --git a/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerial= PortLib/SecI2cHdmiDebugSerialPortLib.inf b/Platform/Intel/KabylakeOpenBoard= Pkg/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.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D BaseI2cHdmiDebugSerialPortLib + FILE_GUID =3D 4B838C3E-0D23-4CCE-9069-E0E3D2B9CB49 + VERSION_STRING =3D 1.0 + MODULE_TYPE =3D SEC + LIBRARY_CLASS =3D SerialPortLib +# +# The following information is for reference only and not required by the = build tools. +# +# VALID_ARCHITECTURES =3D 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/I2cHdmiDebugSerial= PortLib/SmmI2cHdmiDebugSerialPortLib.inf b/Platform/Intel/KabylakeOpenBoard= Pkg/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.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D SmmI2cHdmiDebugSerialPortLib + FILE_GUID =3D 14B7E774-CF36-4CEC-AD5E-42FF37363F21 + VERSION_STRING =3D 1.0 + MODULE_TYPE =3D DXE_SMM_DRIVER + LIBRARY_CLASS =3D SerialPortLib|DXE_SMM_DRIVER SMM_CORE +# +# The following information is for reference only and not required by the = build tools. +# +# VALID_ARCHITECTURES =3D 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/Platfor= m/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.
+# Copyright (c) 2017 - 2022, Intel Corporation. All rights reserved.
# # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -35,7 +35,7 @@ gSpiFlashDebugHobGuid =3D {0xcaaaf418, 0= x38a5, 0x4d49, {0xbe, 0x7 =20 gTbtInfoHobGuid =3D {0x74a81eaa, 0x033c, 0x4783, {0= xbe, 0x2b, 0x84, 0x85, 0x74, 0xa6, 0x97, 0xb7}} =20 -gPlatformModuleTokenSpaceGuid =3D {0x69d13bf0, 0xaf91, 0x4d96, {0= xaa, 0x9f, 0x21, 0x84, 0xc5, 0xce, 0x3b, 0xc0}} +gI2cHdmiDebugHobGuid =3D {0x93a54938, 0x3a3e, 0x48cf, {0= x9f, 0x0a, 0xaf, 0x6e, 0x0a, 0xa7, 0xc6, 0x44}} =20 =20 [Protocols] @@ -52,9 +52,12 @@ gPeiTbtPolicyBoardInitDonePpiGuid =3D {0x970f9c60, = 0x8547, 0x49d7, { 0xa4, 0x =20 [PcdsFixedAtBuild] =20 +gKabylakeOpenBoardPkgTokenSpaceGuid.PcdGttMmAddress|0x00000000|UINT32|0x90= 00000F + gKabylakeOpenBoardPkgTokenSpaceGuid.PcdLpcIoDecodeRange|0x0010|UINT16|0x10= 001004 gKabylakeOpenBoardPkgTokenSpaceGuid.PchLpcIoEnableDecoding|0x3c03|UINT16|0= x10001005 =20 + gKabylakeOpenBoardPkgTokenSpaceGuid.PcdLpcSioIndexPort|0x4e|UINT16|0x90000= 018 gKabylakeOpenBoardPkgTokenSpaceGuid.PcdLpcSioDataPort|0x4f|UINT16|0x900000= 1F =20 @@ -73,6 +76,14 @@ gKabylakeOpenBoardPkgTokenSpaceGuid.PcdFlashNvDebugMessa= geBase|0x00000000|UINT32 gKabylakeOpenBoardPkgTokenSpaceGuid.PcdFlashNvDebugMessageSize|0x00000000|= UINT32|0x90000031 gKabylakeOpenBoardPkgTokenSpaceGuid.PcdFlashNvDebugMessageOffset|0x0000000= 0|UINT32|0x90000032 =20 +## 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|0x000= 00000|UINT32|0x90000035 + [PcdsDynamic] =20 # Board GPIO Table --=20 2.27.0.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#90592): https://edk2.groups.io/g/devel/message/90592 Mute This Topic: https://groups.io/mt/91835973/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Sat May 18 23:44:12 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+90594+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+90594+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1655525159; cv=none; d=zohomail.com; s=zohoarc; b=NJKUur8lhAptp1irZwEef38xw94TVtsGstzBtoephcUX9ZfL4eRDAJyOjdDGDMgD8sJVXW8J5IUJHzA4CBCSik8lg8FlZdRYgpVBBVrXwSnF+fn0fYqE8UeLMOTud5qY8UgDIshexbRWD2xph8n/aT/Cr8C85+dnwgliGx2pTz8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1655525159; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=ZKrwbyiz4tlYoAx8d4y1V5/BBV9UfRsKrJQMm9HWFNU=; b=KQp8lOpo3RT9kgfVsJVfAg5GS9l6SgOVC6f8JYLWG/ZqI8Vx+FZ2dRsz7k9lPbVXH+fjZdn8dhkKkI/EwxE53pma0hihvWAKk7RafI904KabMjPj8YqdZfu55pXD/PTmuaQ0zEN7YWpRmmL1WKIemZWmC8REdD82B7qyHEkmz8M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+90594+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1655525159525630.3395386634046; Fri, 17 Jun 2022 21:05:59 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 9FQcYY1788612xreWjtD2uo3; Fri, 17 Jun 2022 21:05:59 -0700 X-Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mx.groups.io with SMTP id smtpd.web09.6193.1655525157666528425 for ; Fri, 17 Jun 2022 21:05:57 -0700 X-IronPort-AV: E=McAfee;i="6400,9594,10380"; a="305057850" X-IronPort-AV: E=Sophos;i="5.92,306,1650956400"; d="scan'208";a="305057850" X-Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jun 2022 21:05:55 -0700 X-IronPort-AV: E=Sophos;i="5.92,306,1650956400"; d="scan'208";a="613763920" X-Received: from nldesimo-desk1.amr.corp.intel.com ([10.7.159.54]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jun 2022 21:05:55 -0700 From: "Nate DeSimone" To: devel@edk2.groups.io Cc: Chasel Chiu , Sai Chaganty , Isaac Oram , Benjamin Doron , Michael Kubacki , Jeremy Soller Subject: [edk2-devel] [edk2-platforms] [PATCH V1 2/5] KabylakeOpenBoardPkg: Add HdmiDebugGpioInitLib Date: Fri, 17 Jun 2022 21:05:47 -0700 Message-Id: <20220618040550.8467-3-nathaniel.l.desimone@intel.com> In-Reply-To: <20220618040550.8467-1-nathaniel.l.desimone@intel.com> References: <20220618040550.8467-1-nathaniel.l.desimone@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,nathaniel.l.desimone@intel.com X-Gm-Message-State: WZuqmKknLfGHVbUlXzPbHxxjx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1655525159; bh=imHh+vIwBhocT2HZcSaMpBRBScagl/Uy1ovWmFvifvw=; h=Cc:Date:From:Reply-To:Subject:To; b=gwDQ8dUH7JfyEwUj3JSZA5HDVx/ryWCbVjPjcu4SQNm3byEpmtqziQfubDkKuxDVD3a XEJ5rK8jzM3NqeFcS5MsQ1WTfBEJaKhrhjbF8iREfh6kCPYBKpDcF1H/SamjL+WIVBqxC UmxZtXqPidlJdvQndHwB7OpFIofAzJ2Wbhw= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1655525160575100013 Content-Type: text/plain; charset="utf-8" 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 Cc: Sai Chaganty Cc: Isaac Oram Cc: Benjamin Doron Cc: Michael Kubacki Cc: Jeremy Soller Signed-off-by: Nate DeSimone --- .../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/Hdm= iDebugGpioInitLib.h create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/HdmiDebugGp= ioInitLib/HdmiDebugGpioInitLib.c create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/HdmiDebugGp= ioInitLib/HdmiDebugGpioInitLib.inf diff --git a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/OpenBoar= dPkg.dsc b/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/OpenBoardP= kg.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.
+# Copyright (c) 2017 - 2022, Intel Corporation. All rights reserved.
# # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -184,6 +184,7 @@ GpioExpanderLib|$(PLATFORM_BOARD_PACKAGE)/Library/BaseGpioExpanderLib/Ba= seGpioExpanderLib.inf I2cAccessLib|$(PLATFORM_BOARD_PACKAGE)/Library/PeiI2cAccessLib/PeiI2cAcc= essLib.inf PlatformSecLib|$(PLATFORM_PACKAGE)/FspWrapper/Library/SecFspWrapperPlatf= ormSecLib/SecFspWrapperPlatformSecLib.inf + HdmiDebugGpioInitLib|$(PLATFORM_BOARD_PACKAGE)/Library/HdmiDebugGpioInit= Lib/HdmiDebugGpioInitLib.inf =20 # Thunderbolt !if gKabylakeOpenBoardPkgTokenSpaceGuid.PcdTbtEnable =3D=3D TRUE diff --git a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.ds= c 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.
+# Copyright (c) 2019 - 2022, Intel Corporation. All rights reserved.
# # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -128,6 +128,7 @@ GpioExpanderLib|$(PLATFORM_BOARD_PACKAGE)/Library/BaseGpioExpanderLib/Ba= seGpioExpanderLib.inf I2cAccessLib|$(PLATFORM_BOARD_PACKAGE)/Library/PeiI2cAccessLib/PeiI2cAcc= essLib.inf PlatformSecLib|$(PLATFORM_PACKAGE)/FspWrapper/Library/SecFspWrapperPlatf= ormSecLib/SecFspWrapperPlatformSecLib.inf + HdmiDebugGpioInitLib|$(PLATFORM_BOARD_PACKAGE)/Library/HdmiDebugGpioInit= Lib/HdmiDebugGpioInitLib.inf =20 # Thunderbolt !if gKabylakeOpenBoardPkgTokenSpaceGuid.PcdTbtEnable =3D=3D TRUE diff --git a/Platform/Intel/KabylakeOpenBoardPkg/Include/Library/HdmiDebugG= pioInitLib.h b/Platform/Intel/KabylakeOpenBoardPkg/Include/Library/HdmiDebu= gGpioInitLib.h new file mode 100644 index 0000000000..33bdeb74fc --- /dev/null +++ b/Platform/Intel/KabylakeOpenBoardPkg/Include/Library/HdmiDebugGpioInit= Lib.h @@ -0,0 +1,26 @@ +/** @file + GPIO initialization for the HDMI I2C Debug Port + +Copyright (c) 2022, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef HDMI_DEBUG_GPIO_INIT_LIB_H_ +#define HDMI_DEBUG_GPIO_INIT_LIB_H_ + +#include + +/** + 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 suppo= rted 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.
+# Copyright (c) 2017 - 2022, Intel Corporation. All rights reserved.
# # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -171,6 +171,7 @@ GpioExpanderLib|$(PLATFORM_BOARD_PACKAGE)/Library/BaseGpioExpanderLib/Ba= seGpioExpanderLib.inf I2cAccessLib|$(PLATFORM_BOARD_PACKAGE)/Library/PeiI2cAccessLib/PeiI2cAcc= essLib.inf PlatformSecLib|$(PLATFORM_PACKAGE)/FspWrapper/Library/SecFspWrapperPlatf= ormSecLib/SecFspWrapperPlatformSecLib.inf + HdmiDebugGpioInitLib|$(PLATFORM_BOARD_PACKAGE)/Library/HdmiDebugGpioInit= Lib/HdmiDebugGpioInitLib.inf =20 # Thunderbolt !if gKabylakeOpenBoardPkgTokenSpaceGuid.PcdTbtEnable =3D=3D TRUE diff --git a/Platform/Intel/KabylakeOpenBoardPkg/Library/HdmiDebugGpioInitL= ib/HdmiDebugGpioInitLib.c b/Platform/Intel/KabylakeOpenBoardPkg/Library/Hdm= iDebugGpioInitLib/HdmiDebugGpioInitLib.c new file mode 100644 index 0000000000..3d9e37f34a --- /dev/null +++ b/Platform/Intel/KabylakeOpenBoardPkg/Library/HdmiDebugGpioInitLib/Hdmi= DebugGpioInitLib.c @@ -0,0 +1,221 @@ +/** @file + GPIO initialization for the HDMI I2C Debug Port + +Copyright (c) 2022, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include + +#include +#include +#include + +// +// 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 =3D 0, + PchTypeSptLp, + PchTypeSptH, + PchTypeKbpH, + PchTypeCnlLp, + PchTypeCnlH, + PchTypeMax +} PCH_TYPE; + +typedef enum { + PchH =3D 1, + PchLp, + PchUnknownSeries +} PCH_SERIES; + +typedef enum { + EnumDdcUnknown =3D 0, + EnumDdcA, + EnumDdcB, + EnumDdcC, + EnumDdcD, + EnumDdcE, + EnumDdcF, + EnumI2cChannelMax +} IGFX_I2C_CHANNEL; + +/*** SKL-LP ***/ + +// HDMI-B DDC GPIO Pins +GPIO_INIT_CONFIG mDebugGpioTableSklLpDdpB[] =3D +{ + {GPIO_SKL_LP_GPP_E18, {GpioPadModeNative1, GpioHostOwnDefault, GpioDirNo= ne, GpioOutDefault, GpioIntDis, GpioHostDeepReset, GpioTermNone}}, //DDP= B_CTRLCLK + {GPIO_SKL_LP_GPP_E19, {GpioPadModeNative1, GpioHostOwnDefault, GpioDirNo= ne, GpioOutDefault, GpioIntDis, GpioHostDeepReset, GpioTermNone}}, //DDP= B_CTRLDATA + {END_OF_GPIO_TABLE, {GpioPadModeGpio, GpioHostOwnGpio, GpioDirNo= ne, GpioOutDefault, GpioIntDis, GpioDswReset, GpioTermNone}},//Marking = End of Table +}; +UINT16 mDebugGpioTableSklLpDdpBSize =3D sizeof (mDebugGpioTableSklLpDdpB) = / sizeof (GPIO_INIT_CONFIG) - 1; + +// HDMI-C DDC GPIO Pins +GPIO_INIT_CONFIG mDebugGpioTableSklLpDdpC[] =3D +{ + {GPIO_SKL_LP_GPP_E20, {GpioPadModeNative1, GpioHostOwnDefault, GpioDirNo= ne, GpioOutDefault, GpioIntDis, GpioHostDeepReset, GpioTermNone}}, //DDP= C_CTRLCLK + {GPIO_SKL_LP_GPP_E21, {GpioPadModeNative1, GpioHostOwnDefault, GpioDirNo= ne, GpioOutDefault, GpioIntDis, GpioHostDeepReset, GpioTermNone}}, //DDP= C_CTRLDATA + {END_OF_GPIO_TABLE, {GpioPadModeGpio, GpioHostOwnGpio, GpioDirNo= ne, GpioOutDefault, GpioIntDis, GpioDswReset, GpioTermNone}},//Marking = End of Table +}; +UINT16 mDebugGpioTableSklLpDdpCSize =3D sizeof (mDebugGpioTableSklLpDdpC) = / sizeof (GPIO_INIT_CONFIG) - 1; + +// HDMI-D DDC GPIO Pins +GPIO_INIT_CONFIG mDebugGpioTableSklLpDdpD[] =3D +{ + {GPIO_SKL_LP_GPP_E22, {GpioPadModeNative1, GpioHostOwnDefault, GpioDirNo= ne, GpioOutDefault, GpioIntDis, GpioHostDeepReset, GpioTermNone}}, //DDP= D_CTRLCLK + {GPIO_SKL_LP_GPP_E23, {GpioPadModeNative1, GpioHostOwnDefault, GpioDirNo= ne, GpioOutDefault, GpioIntDis, GpioHostDeepReset, GpioTermNone}}, //DDP= D_CTRLDATA + {END_OF_GPIO_TABLE, {GpioPadModeGpio, GpioHostOwnGpio, GpioDirNo= ne, GpioOutDefault, GpioIntDis, GpioDswReset, GpioTermNone}},//Marking = End of Table +}; +UINT16 mDebugGpioTableSklLpDdpDSize =3D sizeof (mDebugGpioTableSklLpDdpD) = / sizeof (GPIO_INIT_CONFIG) - 1; + +/*** SKL-H ***/ + +// HDMI-B DDC GPIO Pins +GPIO_INIT_CONFIG mDebugGpioTableSklHDdpB[] =3D +{ + {GPIO_SKL_H_GPP_I5, {GpioPadModeNative1, GpioHostOwnDefault, GpioDirNo= ne, GpioOutDefault, GpioIntDis, GpioHostDeepReset, GpioTermNone}}, //DDP= B_CTRLCLK + {GPIO_SKL_H_GPP_I6, {GpioPadModeNative1, GpioHostOwnDefault, GpioDirNo= ne, GpioOutDefault, GpioIntDis, GpioHostDeepReset, GpioTermNone}}, //DDP= B_CTRLDATA + {END_OF_GPIO_TABLE, {GpioPadModeGpio, GpioHostOwnGpio, GpioDirNo= ne, GpioOutDefault, GpioIntDis, GpioDswReset, GpioTermNone}},//Marking = End of Table +}; +UINT16 mDebugGpioTableSklHDdpBSize =3D sizeof (mDebugGpioTableSklHDdpB) / = sizeof (GPIO_INIT_CONFIG) - 1; + +// HDMI-C DDC GPIO Pins +GPIO_INIT_CONFIG mDebugGpioTableSklHDdpC[] =3D +{ + {GPIO_SKL_H_GPP_I7, {GpioPadModeNative1, GpioHostOwnDefault, GpioDirNo= ne, GpioOutDefault, GpioIntDis, GpioHostDeepReset, GpioTermNone}}, //DDP= C_CTRLCLK + {GPIO_SKL_H_GPP_I8, {GpioPadModeNative1, GpioHostOwnDefault, GpioDirNo= ne, GpioOutDefault, GpioIntDis, GpioHostDeepReset, GpioTermNone}}, //DDP= C_CTRLDATA + {END_OF_GPIO_TABLE, {GpioPadModeGpio, GpioHostOwnGpio, GpioDirNo= ne, GpioOutDefault, GpioIntDis, GpioDswReset, GpioTermNone}},//Marking = End of Table +}; +UINT16 mDebugGpioTableSklHDdpCSize =3D sizeof (mDebugGpioTableSklHDdpC) / = sizeof (GPIO_INIT_CONFIG) - 1; + +// HDMI-D DDC GPIO Pins +GPIO_INIT_CONFIG mDebugGpioTableSklHDdpD[] =3D +{ + {GPIO_SKL_H_GPP_I9, {GpioPadModeNative1, GpioHostOwnDefault, GpioDirNo= ne, GpioOutDefault, GpioIntDis, GpioHostDeepReset, GpioTermNone}}, //DDP= D_CTRLCLK + {GPIO_SKL_H_GPP_I10, {GpioPadModeNative1, GpioHostOwnDefault, GpioDirNo= ne, GpioOutDefault, GpioIntDis, GpioHostDeepReset, GpioTermNone}}, //DDP= D_CTRLDATA + {END_OF_GPIO_TABLE, {GpioPadModeGpio, GpioHostOwnGpio, GpioDirNo= ne, GpioOutDefault, GpioIntDis, GpioDswReset, GpioTermNone}},//Marking = End of Table +}; +UINT16 mDebugGpioTableSklHDdpDSize =3D 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 =3D GpioConfigurePads (GpioTableCount, GpioDefinition); + +} + + +PCH_TYPE +HdmiGpioInitGetPchType ( + VOID + ) +{ + PCH_TYPE PchType; + UINT16 DeviceId; + + PchType =3D PchTypeUnknown; + DeviceId =3D PciRead16 (PCI_LIB_ADDRESS (PCH_PCI_BUS, PCH_LPC_PCI_DEV, = PCH_LPC_PCI_FUN, R_PCH_LPC_DID)); + if ((DeviceId >=3D V_SPT_LP_PCH_START_DEVICE_ID) && (DeviceId <=3D V_SPT= _LP_PCH_END_DEVICE_ID)) { + PchType =3D PchTypeSptLp; + } else if ((DeviceId >=3D V_SPT_H_PCH_START_DEVICE_ID) && (DeviceId <=3D= V_SPT_H_PCH_END_DEVICE_ID )) { + PchType =3D PchTypeSptH; + } else if ((DeviceId >=3D V_KBP_H_PCH_START_DEVICE_ID) && (DeviceId <=3D= V_KBP_H_PCH_END_DEVICE_ID)) { + PchType =3D PchTypeKbpH; + if ((DeviceId =3D=3D V_KBP_H_PCH_DEVICE_ID_ES) || (DeviceId =3D=3D V_K= BP_H_PCH_DEVICE_ID_SVR_ES)) { + PchType =3D 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 suppo= rted yet. + +**/ +EFI_STATUS +HdmiDebugGpioInit ( + VOID + ) +{ + IGFX_I2C_CHANNEL Channel; + PCH_TYPE PchType; + + PchType =3D HdmiGpioInitGetPchType (); + Channel =3D (IGFX_I2C_CHANNEL) PcdGet32 (PcdI2cHdmiDebugPortDdcI2cChanne= l); + switch (PchType) { + case PchTypeSptLp: + switch (Channel) { + case EnumDdcB: + HdmiDebugConfigureGpio (mDebugGpioTableSklLpDdpB, mDebugGpioTabl= eSklLpDdpBSize); + return EFI_SUCCESS; + case EnumDdcC: + HdmiDebugConfigureGpio (mDebugGpioTableSklLpDdpC, mDebugGpioTabl= eSklLpDdpCSize); + return EFI_SUCCESS; + case EnumDdcD: + HdmiDebugConfigureGpio (mDebugGpioTableSklLpDdpD, mDebugGpioTabl= eSklLpDdpDSize); + return EFI_SUCCESS; + + default: + return EFI_UNSUPPORTED; + } + break; + case PchTypeSptH: + case PchTypeKbpH: + switch (Channel) { + case EnumDdcB: + HdmiDebugConfigureGpio (mDebugGpioTableSklHDdpB, mDebugGpioTable= SklHDdpBSize); + return EFI_SUCCESS; + case EnumDdcC: + HdmiDebugConfigureGpio (mDebugGpioTableSklHDdpC, mDebugGpioTable= SklHDdpCSize); + return EFI_SUCCESS; + case EnumDdcD: + HdmiDebugConfigureGpio (mDebugGpioTableSklHDdpD, mDebugGpioTable= SklHDdpDSize); + return EFI_SUCCESS; + + default: + return EFI_UNSUPPORTED; + } + break; + default: + return EFI_UNSUPPORTED; + } +} diff --git a/Platform/Intel/KabylakeOpenBoardPkg/Library/HdmiDebugGpioInitL= ib/HdmiDebugGpioInitLib.inf b/Platform/Intel/KabylakeOpenBoardPkg/Library/H= dmiDebugGpioInitLib/HdmiDebugGpioInitLib.inf new file mode 100644 index 0000000000..3c83f68774 --- /dev/null +++ b/Platform/Intel/KabylakeOpenBoardPkg/Library/HdmiDebugGpioInitLib/Hdmi= DebugGpioInitLib.inf @@ -0,0 +1,42 @@ +### @file +# Component description file for the HDMI I2C Debug Port GPIO initializati= on library +# +# Copyright (c) 2022, Intel Corporation. All rights reserved.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D BaseHdmiDebugGpioInitLib + FILE_GUID =3D 4CC9D17A-B6D4-4FE2-AB82-27D539A8D8A9 + VERSION_STRING =3D 1.0 + MODULE_TYPE =3D BASE + LIBRARY_CLASS =3D HdmiDebugGpioInitLib +# +# The following information is for reference only and not required by the = build tools. +# +# VALID_ARCHITECTURES =3D 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 --=20 2.27.0.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#90594): https://edk2.groups.io/g/devel/message/90594 Mute This Topic: https://groups.io/mt/91835975/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Sat May 18 23:44:12 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+90593+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+90593+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1655525159; cv=none; d=zohomail.com; s=zohoarc; b=TJYvc8GTzhISVAFXIOtVFwXLKBgeSHtAcUjLqWXUiKZEENqMx/AJ0yh5PxHWRtQ5KLA9h00r1kkqlM6SNzj7WqbvGyrJMBGL0n5GswYCowqVSwDDa5nqalGchZLWc92ztsdTTAqnBR4dxsPaKlAyDg/4J8xRqrj9yapkWKTuS5o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1655525159; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=vfPvnTLb6MYLxZToCqaki6+fsBX9Jw2/0aTRZOWm2/M=; b=F5QtfzxejFcagpuh2n9h9XBZ9YDtauzw5bH4ernUJz8FF4jDjH5r/g3ZfoFqpl/WVIKrcj3Ef+6M7dnwLIuyipn7ouu0vArT0RvTZcZ4BMSEcIRKyYr736gJpPOt0aVR/uxQi8G7bBydtz/WvNUTwJQuolTvQ33zKVAJ5GhrB1k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+90593+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1655525159677595.7657949819076; Fri, 17 Jun 2022 21:05:59 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 0I1PYY1788612xQVPTqlSpp9; Fri, 17 Jun 2022 21:05:58 -0700 X-Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mx.groups.io with SMTP id smtpd.web09.6192.1655525155936388213 for ; Fri, 17 Jun 2022 21:05:57 -0700 X-IronPort-AV: E=McAfee;i="6400,9594,10380"; a="305057851" X-IronPort-AV: E=Sophos;i="5.92,306,1650956400"; d="scan'208";a="305057851" X-Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jun 2022 21:05:55 -0700 X-IronPort-AV: E=Sophos;i="5.92,306,1650956400"; d="scan'208";a="613763924" X-Received: from nldesimo-desk1.amr.corp.intel.com ([10.7.159.54]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jun 2022 21:05:55 -0700 From: "Nate DeSimone" To: devel@edk2.groups.io Cc: Chasel Chiu , Sai Chaganty , Isaac Oram , Benjamin Doron , Michael Kubacki , Jeremy Soller Subject: [edk2-devel] [edk2-platforms] [PATCH V1 3/5] KabylakeOpenBoardPkg: Add SecBoardInitLib Date: Fri, 17 Jun 2022 21:05:48 -0700 Message-Id: <20220618040550.8467-4-nathaniel.l.desimone@intel.com> In-Reply-To: <20220618040550.8467-1-nathaniel.l.desimone@intel.com> References: <20220618040550.8467-1-nathaniel.l.desimone@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,nathaniel.l.desimone@intel.com X-Gm-Message-State: 8TqmurOy4dOcoJ7yx8FbQRDhx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1655525158; bh=eANJVw3ep/cLWlkZ9S4fkkC79qaI805AxvKxjSNzfWg=; h=Cc:Date:From:Reply-To:Subject:To; b=F5haYm3vG/58LZEEA62qMQwiVgafmyhz0tFDg+QMpQItW1caKa/3bPoN2yS75Ds+kwJ QJX/5SHj4kCq0aCSuBZ5exyEbGjKt4QGomaqZTDh4bQwS5NAjoN2TvVBroMnUp7IfyCcG dvq4In0vB/+KNqdYv+zbecyMSmLKtl2+K7s= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1655525160573100012 Content-Type: text/plain; charset="utf-8" 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 Cc: Sai Chaganty Cc: Isaac Oram Cc: Benjamin Doron Cc: Michael Kubacki Cc: Jeremy Soller Signed-off-by: Nate DeSimone --- .../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/SecBoardIni= tLib/Ia32/SecBoardInit.nasm create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/SecBoardIni= tLib/SecBoardInitLib.c create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/SecBoardIni= tLib/SecBoardInitLib.inf diff --git a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Library/= BoardInitLib/PeiAspireVn7Dash572GInitPreMemLib.c b/Platform/Intel/KabylakeO= penBoardPkg/AspireVn7Dash572G/Library/BoardInitLib/PeiAspireVn7Dash572GInit= PreMemLib.c index d17685be82..1c9a65399b 100644 --- a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Library/BoardIn= itLib/PeiAspireVn7Dash572GInitPreMemLib.c +++ b/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Library/BoardIn= itLib/PeiAspireVn7Dash572GInitPreMemLib.c @@ -1,6 +1,6 @@ /** @file =20 -Copyright (c) 2017 - 2021, Intel Corporation. All rights reserved.
+Copyright (c) 2017 - 2022, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -251,7 +251,6 @@ AspireVn7Dash572GBoardDebugInit ( /// /// Do Early PCH init /// - EarlySiliconInit (); LpcInit (); =20 // NB: MinPlatform specification defines platform initialisation flow. diff --git a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/OpenBoar= dPkg.dsc b/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/OpenBoardP= kg.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/Sec= TestPointCheckLib.inf - SecBoardInitLib|$(PLATFORM_PACKAGE)/PlatformInit/Library/SecBoardInitLib= Null/SecBoardInitLibNull.inf - SiliconPolicyUpdateLib|MinPlatformPkg/PlatformInit/Library/SiliconPolicy= UpdateLibNull/SiliconPolicyUpdateLibNull.inf + SiliconPolicyUpdateLib|$(PLATFORM_PACKAGE)/PlatformInit/Library/SiliconP= olicyUpdateLibNull/SiliconPolicyUpdateLibNull.inf + + ####################################### + # Board-specific + ####################################### + SecBoardInitLib|$(PLATFORM_BOARD_PACKAGE)/Library/SecBoardInitLib/SecBoa= rdInitLib.inf =20 [LibraryClasses.common.PEI_CORE] ####################################### diff --git a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/BoardIn= itLib/PeiGalagoPro3InitPreMemLib.c b/Platform/Intel/KabylakeOpenBoardPkg/Ga= lagoPro3/Library/BoardInitLib/PeiGalagoPro3InitPreMemLib.c index f4833149f3..051dac0b20 100644 --- a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/BoardInitLib/P= eiGalagoPro3InitPreMemLib.c +++ b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/BoardInitLib/P= eiGalagoPro3InitPreMemLib.c @@ -1,7 +1,7 @@ /** @file System 76 GalagoPro3 board pre-memory initialization. =20 -Copyright (c) 2019 - 2021, Intel Corporation. All rights reserved.
+Copyright (c) 2019 - 2022, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -167,9 +167,9 @@ SioInit ( } =20 /** - 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 =20 **/ VOID @@ -227,10 +227,6 @@ GalagoPro3BoardDebugInit ( VOID ) { - /// - /// Do Early PCH init - /// - EarlySiliconInit (); return EFI_SUCCESS; } =20 @@ -242,4 +238,3 @@ GalagoPro3BoardBootModeDetect ( { return BOOT_WITH_FULL_CONFIGURATION; } - diff --git a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.ds= c 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/SecBoardInitLib= Null/SecBoardInitLibNull.inf TestPointCheckLib|$(PLATFORM_PACKAGE)/Test/Library/TestPointCheckLib/Sec= TestPointCheckLib.inf + SiliconPolicyUpdateLib|$(PLATFORM_PACKAGE)/PlatformInit/Library/SiliconP= olicyUpdateLibNull/SiliconPolicyUpdateLibNull.inf + + ####################################### + # Board-specific + ####################################### + SecBoardInitLib|$(PLATFORM_BOARD_PACKAGE)/Library/SecBoardInitLib/SecBoa= rdInitLib.inf =20 [LibraryClasses.common.PEIM] ####################################### diff --git a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/Library/Board= InitLib/PeiKabylakeRvp3InitPreMemLib.c b/Platform/Intel/KabylakeOpenBoardPk= g/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 =20 -Copyright (c) 2017 - 2021, Intel Corporation. All rights reserved.
+Copyright (c) 2017 - 2022, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -257,9 +257,9 @@ SioInit ( } =20 /** - 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 =20 **/ VOID @@ -321,10 +321,6 @@ KabylakeRvp3BoardDebugInit ( VOID ) { - /// - /// Do Early PCH init - /// - EarlySiliconInit (); return EFI_SUCCESS; } =20 @@ -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/Sec= TestPointCheckLib.inf - SecBoardInitLib|$(PLATFORM_PACKAGE)/PlatformInit/Library/SecBoardInitLib= Null/SecBoardInitLibNull.inf - SiliconPolicyUpdateLib|MinPlatformPkg/PlatformInit/Library/SiliconPolicy= UpdateLibNull/SiliconPolicyUpdateLibNull.inf + SiliconPolicyUpdateLib|$(PLATFORM_PACKAGE)/PlatformInit/Library/SiliconP= olicyUpdateLibNull/SiliconPolicyUpdateLibNull.inf + + ####################################### + # Board-specific + ####################################### + SecBoardInitLib|$(PLATFORM_BOARD_PACKAGE)/Library/SecBoardInitLib/SecBoa= rdInitLib.inf =20 [LibraryClasses.common.PEIM] ####################################### diff --git a/Platform/Intel/KabylakeOpenBoardPkg/Library/SecBoardInitLib/Ia= 32/SecBoardInit.nasm b/Platform/Intel/KabylakeOpenBoardPkg/Library/SecBoard= InitLib/Ia32/SecBoardInit.nasm new file mode 100644 index 0000000000..c9cfa236ea --- /dev/null +++ b/Platform/Intel/KabylakeOpenBoardPkg/Library/SecBoardInitLib/Ia32/SecB= oardInit.nasm @@ -0,0 +1,18 @@ +;; @file +; Kaby Lake board SEC initialization. +; +; Copyright (c) 2022, Intel Corporation. All rights reserved.
+; 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/Se= cBoardInitLib.c b/Platform/Intel/KabylakeOpenBoardPkg/Library/SecBoardInitL= ib/SecBoardInitLib.c new file mode 100644 index 0000000000..22712d12db --- /dev/null +++ b/Platform/Intel/KabylakeOpenBoardPkg/Library/SecBoardInitLib/SecBoardI= nitLib.c @@ -0,0 +1,35 @@ +/** @file + Kaby Lake board SEC initialization. + +Copyright (c) 2022, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include +#include + +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/Se= cBoardInitLib.inf b/Platform/Intel/KabylakeOpenBoardPkg/Library/SecBoardIni= tLib/SecBoardInitLib.inf new file mode 100644 index 0000000000..192a78865f --- /dev/null +++ b/Platform/Intel/KabylakeOpenBoardPkg/Library/SecBoardInitLib/SecBoardI= nitLib.inf @@ -0,0 +1,39 @@ +## @file +# Component information file for Kaby Lake SEC Board Init Library +# +# Copyright (c) 2022, Intel Corporation. All rights reserved.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D SecKabyLakeBoardInitLib + FILE_GUID =3D B9DC6910-67E0-4FCE-A1A4-675115E71455 + MODULE_TYPE =3D SEC + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D 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.PcdI2cHdmiDebugPortSerialTerminalEna= ble ## CONSUMES diff --git a/Platform/Intel/KabylakeOpenBoardPkg/OpenBoardPkg.dec b/Platfor= m/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.PcdFlashNvDebugMessa= geBase|0x00000000|UINT32 gKabylakeOpenBoardPkgTokenSpaceGuid.PcdFlashNvDebugMessageSize|0x00000000|= UINT32|0x90000031 gKabylakeOpenBoardPkgTokenSpaceGuid.PcdFlashNvDebugMessageOffset|0x0000000= 0|UINT32|0x90000032 =20 +## Enable usage the HDMI DDC channel as a debug port - Causes the BIOS deb= ug 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|BOOLEA= N|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 termin= al +# 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.PcdI2cHdmiDebugPortSerialTerminalEnabl= e|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 --=20 2.27.0.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#90593): https://edk2.groups.io/g/devel/message/90593 Mute This Topic: https://groups.io/mt/91835974/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Sat May 18 23:44:12 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+90595+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+90595+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1655525160; cv=none; d=zohomail.com; s=zohoarc; b=ThMPzAo4TAcN2Ig/OlDZMuOeFi9X7uoI2Kq1NpS9jkITmVWTDEAsgM6A+rBVFtkeL1UwyUbYsTK+WBtavKQE9n2YgYxyW2kLhdtP0nd0V+rzB92zm8llw6s6JUxuRhulbj7eWHSy9oGfyVnUuRulfkNdxhgw51oP4R8yscXQkp0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1655525160; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=XyLk6usAfsANlkGt/NgQhTiPj/tM32wcZ1lnzr9s9XQ=; b=VqRtL9/kFliFbe85agdun7zs0RJKPizstQXbV++BKQQD3ODOdmwjMSzPLn7PpWQJM+WwFcSoBB653FsPVq3vzAblSahkncvVHvqe8qNsr7PxPkJ4eAMuyFUfvWOehZZ7C5dyPC7c9wZBFr4AKXo1T3zlhpmWXtflpUuL5ew18VQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+90595+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1655525160302245.93519937147994; Fri, 17 Jun 2022 21:06:00 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id DLceYY1788612xnMeTlWsVJH; Fri, 17 Jun 2022 21:05:59 -0700 X-Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mx.groups.io with SMTP id smtpd.web09.6192.1655525155936388213 for ; Fri, 17 Jun 2022 21:05:57 -0700 X-IronPort-AV: E=McAfee;i="6400,9594,10380"; a="305057852" X-IronPort-AV: E=Sophos;i="5.92,306,1650956400"; d="scan'208";a="305057852" X-Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jun 2022 21:05:55 -0700 X-IronPort-AV: E=Sophos;i="5.92,306,1650956400"; d="scan'208";a="613763927" X-Received: from nldesimo-desk1.amr.corp.intel.com ([10.7.159.54]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jun 2022 21:05:55 -0700 From: "Nate DeSimone" To: devel@edk2.groups.io Cc: Eric Dong , Isaac Oram , Liming Gao , Sai Chaganty , Benjamin Doron , Michael Kubacki , Jeremy Soller Subject: [edk2-devel] [edk2-platforms] [PATCH V1 4/5] BoardModulePkg: Add BdsSerialPortTerminalLib Date: Fri, 17 Jun 2022 21:05:49 -0700 Message-Id: <20220618040550.8467-5-nathaniel.l.desimone@intel.com> In-Reply-To: <20220618040550.8467-1-nathaniel.l.desimone@intel.com> References: <20220618040550.8467-1-nathaniel.l.desimone@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,nathaniel.l.desimone@intel.com X-Gm-Message-State: Vn8cZWNP2uYZjfWAI3WGa2cxx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1655525159; bh=lTXnuBKyeENw6gAAM4LnPkp53PPzTZpeWajIvYM6aUQ=; h=Cc:Date:From:Reply-To:Subject:To; b=OcrJpbYzTI0K/lK6Vqg+AqQ+AQcBt1ZurCLP5o1x0b3tZpPNWSbTgSGBKeArQo6Y/N4 gKBr0hC47dUvtpD3z+ag2PIe+rCvf1eyFbELrN2gWvqnpwlPy4Ud988Fq9/TEDpFrTk8b 1GHDVkLzzidScj7J8cufsqtxwp//jn3GWDg= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1655525160557100011 Content-Type: text/plain; charset="utf-8" BdsSerialPortTerminalLib add a terminal device to the Serial UART device created by MdeModulePkg/Universal/SerialDxe to the UEFI Console Variables (ConIn, ConOut, ErrOut). This allows BIOS Setup, UEFI Shell, etc. to be used on a headless system via a null modem and terminal emulation software. Cc: Eric Dong Cc: Isaac Oram Cc: Liming Gao Cc: Sai Chaganty Cc: Benjamin Doron Cc: Michael Kubacki Cc: Jeremy Soller Signed-off-by: Nate DeSimone --- .../Intel/BoardModulePkg/BoardModulePkg.dsc | 3 +- .../BdsSerialPortTerminalLib.c | 114 ++++++++++++++++++ .../BdsSerialPortTerminalLib.h | 53 ++++++++ .../BdsSerialPortTerminalLib.inf | 49 ++++++++ 4 files changed, 218 insertions(+), 1 deletion(-) create mode 100644 Platform/Intel/BoardModulePkg/Library/BdsSerialPortTerm= inalLib/BdsSerialPortTerminalLib.c create mode 100644 Platform/Intel/BoardModulePkg/Library/BdsSerialPortTerm= inalLib/BdsSerialPortTerminalLib.h create mode 100644 Platform/Intel/BoardModulePkg/Library/BdsSerialPortTerm= inalLib/BdsSerialPortTerminalLib.inf diff --git a/Platform/Intel/BoardModulePkg/BoardModulePkg.dsc b/Platform/In= tel/BoardModulePkg/BoardModulePkg.dsc index 9f00592a19..c93b536f0d 100644 --- a/Platform/Intel/BoardModulePkg/BoardModulePkg.dsc +++ b/Platform/Intel/BoardModulePkg/BoardModulePkg.dsc @@ -6,7 +6,7 @@ # INF files to generate AutoGen.c and AutoGen.h files # for the build infrastructure. # -# Copyright (c) 2019 - 2021, Intel Corporation. All rights reserved.
+# Copyright (c) 2019 - 2022, Intel Corporation. All rights reserved.
# # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -91,3 +91,4 @@ =20 BoardModulePkg/Library/PeiFirmwareBootMediaInfoLib/PeiFirmwareBootMediaI= nfoLib.inf BoardModulePkg/Library/BdsPs2KbcLib/BdsPs2KbcLib.inf + BoardModulePkg/Library/BdsSerialPortTerminalLib/BdsSerialPortTerminalLib= .inf diff --git a/Platform/Intel/BoardModulePkg/Library/BdsSerialPortTerminalLib= /BdsSerialPortTerminalLib.c b/Platform/Intel/BoardModulePkg/Library/BdsSeri= alPortTerminalLib/BdsSerialPortTerminalLib.c new file mode 100644 index 0000000000..178ca2b3ac --- /dev/null +++ b/Platform/Intel/BoardModulePkg/Library/BdsSerialPortTerminalLib/BdsSer= ialPortTerminalLib.c @@ -0,0 +1,114 @@ +/** @file + Main file for NULL named library that 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) 2022, Intel Corporation. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include "BdsSerialPortTerminalLib.h" + +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID *mTerminalType[] =3D { + &gEfiPcAnsiGuid, + &gEfiVT100Guid, + &gEfiVT100PlusGuid, + &gEfiVTUTF8Guid, + &gEfiTtyTermGuid +}; + +GLOBAL_REMOVE_IF_UNREFERENCED SERIAL_DEVICE_PATH mSerialDevicePath =3D { + { + { + HARDWARE_DEVICE_PATH, + HW_VENDOR_DP, + { + (UINT8) sizeof (VENDOR_DEVICE_PATH), + (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8) + } + }, + EDKII_SERIAL_PORT_LIB_VENDOR_GUID + }, + { + { + MESSAGING_DEVICE_PATH, + MSG_UART_DP, + { + (UINT8) sizeof (UART_DEVICE_PATH), + (UINT8) ((sizeof (UART_DEVICE_PATH)) >> 8) + } + }, + 0, // Reserved + 115200, // BaudRate + 8, // DataBits + 1, // Parity + 1 // StopBits + }, + { + { + MESSAGING_DEVICE_PATH, + MSG_VENDOR_DP, + { + (UINT8) (sizeof (VENDOR_DEVICE_PATH)), + (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8), + } + }, + DEVICE_PATH_MESSAGING_PC_ANSI + }, + gEndEntire +}; + +/** + Updates the ConOut, ConIn, ErrOut variables with the serial terminal dev= ice path + @param none + @retval none +**/ +VOID +AddSerialTerminal ( + VOID + ) +{ + DEBUG ((DEBUG_INFO, "[AddSerialPortTerminal]\n")); + + // + // Update the Terminal Device Configuration Parameters + // + mSerialDevicePath.Uart.BaudRate =3D PcdGet64 (PcdUartDefaultBaudRate); + mSerialDevicePath.Uart.DataBits =3D PcdGet8 (PcdUartDefaultDataBits); + mSerialDevicePath.Uart.Parity =3D PcdGet8 (PcdUartDefaultParity); + mSerialDevicePath.Uart.StopBits =3D PcdGet8 (PcdUartDefaultStopBits); + CopyMem ( + (VOID *) &(mSerialDevicePath.TerminalType.Guid), + (VOID *) mTerminalType[PcdGet8 (PcdDefaultTerminalType)], + sizeof (EFI_GUID) + ); + + // + // Append Serial Terminal into "ConIn", "ConOut", and "ErrOut" + // + EfiBootManagerUpdateConsoleVariable (ConOut, (EFI_DEVICE_PATH_PROTOCOL *= ) &mSerialDevicePath, NULL); + EfiBootManagerUpdateConsoleVariable (ConIn, (EFI_DEVICE_PATH_PROTOCOL *)= &mSerialDevicePath, NULL); + EfiBootManagerUpdateConsoleVariable (ErrOut, (EFI_DEVICE_PATH_PROTOCOL *= ) &mSerialDevicePath, NULL); +} + +/** + Constructor for the Serial Port Terminal Device library. + + @param ImageHandle The Image Handle of the process + @param SystemTable The EFI System Table pointer + + @retval EFI_SUCCESS The Serial Port Terminal Device was installed succ= essfully +**/ +EFI_STATUS +EFIAPI +SerialPortTerminalLibConstructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + AddSerialTerminal (); + + return EFI_SUCCESS; +} diff --git a/Platform/Intel/BoardModulePkg/Library/BdsSerialPortTerminalLib= /BdsSerialPortTerminalLib.h b/Platform/Intel/BoardModulePkg/Library/BdsSeri= alPortTerminalLib/BdsSerialPortTerminalLib.h new file mode 100644 index 0000000000..39d6486712 --- /dev/null +++ b/Platform/Intel/BoardModulePkg/Library/BdsSerialPortTerminalLib/BdsSer= ialPortTerminalLib.h @@ -0,0 +1,53 @@ +/** @file + Header file for NULL named library that adds a Terminal Device + connected to SerialDxe to the UEFI Console Variables. This allows BIOS S= etup, + UEFI Shell, etc. to be used on a headless system via a null modem and te= rminal + emulator. + + Copyright (c) 2022, Intel Corporation. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef BDS_SERIAL_PORT_TERMINAL_LIB_H_ +#define BDS_SERIAL_PORT_TERMINAL_LIB_H_ + +#include +#include +#include +#include +#include +#include +#include +#include + +// +// Below is the platform console device path +// +typedef struct { + VENDOR_DEVICE_PATH Guid; + UART_DEVICE_PATH Uart; + VENDOR_DEVICE_PATH TerminalType; + EFI_DEVICE_PATH_PROTOCOL End; +} SERIAL_DEVICE_PATH; + +#define gPciRootBridge \ + { \ + { \ + ACPI_DEVICE_PATH, \ + ACPI_DP, \ + { \ + (UINT8) (sizeof (ACPI_HID_DEVICE_PATH)), \ + (UINT8) ((sizeof (ACPI_HID_DEVICE_PATH)) >> 8) \ + }, \ + }, \ + EISA_PNP_ID (0x0A03), \ + 0 \ + } + +#define gEndEntire \ + { \ + END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE, { END_DEVICE_PAT= H_LENGTH, 0 } \ + } + +#endif diff --git a/Platform/Intel/BoardModulePkg/Library/BdsSerialPortTerminalLib= /BdsSerialPortTerminalLib.inf b/Platform/Intel/BoardModulePkg/Library/BdsSe= rialPortTerminalLib/BdsSerialPortTerminalLib.inf new file mode 100644 index 0000000000..befaeee3e5 --- /dev/null +++ b/Platform/Intel/BoardModulePkg/Library/BdsSerialPortTerminalLib/BdsSer= ialPortTerminalLib.inf @@ -0,0 +1,49 @@ +## @file +# Component information file for NULL named library that adds a Terminal D= evice +# 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) 2022, Intel Corporation. All rights reserved.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## +[Defines] + INF_VERSION =3D 0x00010006 + BASE_NAME =3D SerialPortTerminalLib + FILE_GUID =3D E12BFA46-95F2-4ADC-9774-7E38DE78741E + MODULE_TYPE =3D UEFI_DRIVER + VERSION_STRING =3D 1.2 + LIBRARY_CLASS =3D NULL|UEFI_DRIVER + CONSTRUCTOR =3D SerialPortTerminalLibConstructor + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + +[Sources] + BdsSerialPortTerminalLib.c + BdsSerialPortTerminalLib.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 --=20 2.27.0.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#90595): https://edk2.groups.io/g/devel/message/90595 Mute This Topic: https://groups.io/mt/91835976/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Sat May 18 23:44:12 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+90596+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+90596+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1655525160; cv=none; d=zohomail.com; s=zohoarc; b=POlAqemZ5jFIZJt7Y1n03D+7Pbvlj5NzNyVkb0Y0rW9q4wJUk6lrFOaJkj129NbSG6h9bZf6xe5gMXnz74zGJK8NQK8+444PLtA/mtGUVWOlLxdK4B4xkLV8pTzntaMJOkOpsRduazWKAJGNDEsH51dmp0FcPkJEYQKT4W+29tQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1655525160; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=mNBekPeSO/xJceRb7PR1AtDUxv2ikcjucwiaVR4x+CE=; b=NcpvUREIWdscq3QokaWj3leXHSOAPGYYJ+DnPz5qw6rq8qWqIKjgWklliL6O9ucR/dIto2mGaD+ue6FD5CNDZNCT3e0ROqddgFgtbw91e/PBZMPoSZxHc3EQmOQ2WrEVoKU3mLnGyt4ENh+G2F51fgyR77QZAFHGXnUnHM8W0zc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+90596+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1655525160085934.3538921437864; Fri, 17 Jun 2022 21:06:00 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id e0NLYY1788612xEp6kAmmJZ4; Fri, 17 Jun 2022 21:05:59 -0700 X-Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mx.groups.io with SMTP id smtpd.web09.6193.1655525157666528425 for ; Fri, 17 Jun 2022 21:05:58 -0700 X-IronPort-AV: E=McAfee;i="6400,9594,10380"; a="305057853" X-IronPort-AV: E=Sophos;i="5.92,306,1650956400"; d="scan'208";a="305057853" X-Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jun 2022 21:05:56 -0700 X-IronPort-AV: E=Sophos;i="5.92,306,1650956400"; d="scan'208";a="613763929" X-Received: from nldesimo-desk1.amr.corp.intel.com ([10.7.159.54]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jun 2022 21:05:55 -0700 From: "Nate DeSimone" To: devel@edk2.groups.io Cc: Chasel Chiu , Sai Chaganty , Isaac Oram , Benjamin Doron , Michael Kubacki , Jeremy Soller Subject: [edk2-devel] [edk2-platforms] [PATCH V1 5/5] KabylakeOpenBoardPkg/GalagoPro3: Enable HDMI DDC Debug Port Date: Fri, 17 Jun 2022 21:05:50 -0700 Message-Id: <20220618040550.8467-6-nathaniel.l.desimone@intel.com> In-Reply-To: <20220618040550.8467-1-nathaniel.l.desimone@intel.com> References: <20220618040550.8467-1-nathaniel.l.desimone@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,nathaniel.l.desimone@intel.com X-Gm-Message-State: EL4LpThh87HJmBqY1qs8YlLTx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1655525159; bh=j5+kOKPGDc4+jVmd7rc9ng6qLRwvnR7GVOYeNkg3zbo=; h=Cc:Date:From:Reply-To:Subject:To; b=t1YA+zZCe4Qo2I6PiC14bKiUjoQ22ad8fkjlMII6d3BeRcoU7nyJF4sgfAdoo/+21I0 Pt/3d7olYmnP5GpRX5Rj/hjCvoDaw/eNnRLksVrpd4rui7iy58h4Yutf50o3IcnaL8wvH AwDcePmgt/6+agPHX1CEa3ADy3BqOqmNPMg= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1655525160577100014 Content-Type: text/plain; charset="utf-8" Enables usage of the HDMI DDC I2C Bus SerialPortLib implementation on the GalagoPro3 board. Cc: Chasel Chiu Cc: Sai Chaganty Cc: Isaac Oram Cc: Benjamin Doron Cc: Michael Kubacki Cc: Jeremy Soller Signed-off-by: Nate DeSimone --- .../GalagoPro3/OpenBoardPkg.dsc | 78 ++++++++++++++++++- .../GalagoPro3/OpenBoardPkg.fdf | 6 +- .../GalagoPro3/OpenBoardPkgPcd.dsc | 30 +++++++ 3 files changed, 111 insertions(+), 3 deletions(-) diff --git a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.ds= c b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc index 5cf2d424ff..2e3c6d3ca5 100644 --- a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc +++ b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc @@ -142,6 +142,12 @@ PlatformHookLib|$(PROJECT)/Library/BasePlatformHookLib/BasePlatformHookL= ib.inf SiliconPolicyUpdateLib|$(PROJECT)/FspWrapper/Library/PeiSiliconPolicyUpd= ateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf =20 +[LibraryClasses.common.PEI_CORE] +!if $(TARGET) =3D=3D DEBUG && gKabylakeOpenBoardPkgTokenSpaceGuid.PcdI2cHd= miDebugPortEnable =3D=3D TRUE + DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf + SerialPortLib|$(PLATFORM_BOARD_PACKAGE)/Library/I2cHdmiDebugSerialPortLi= b/PeiI2cHdmiDebugSerialPortLib.inf +!endif + [LibraryClasses.IA32.SEC] ####################################### # Edk2 Packages @@ -166,7 +172,6 @@ ####################################### DebugLib|MdeModulePkg/Library/PeiDxeDebugLibReportStatusCode/PeiDxeDebug= LibReportStatusCode.inf SerialPortLib|MdePkg/Library/BaseSerialPortLibNull/BaseSerialPortLibNull= .inf - SetCacheMtrrLib|$(PLATFORM_PACKAGE)/Library/SetCacheMtrrLib/SetCacheMtrr= LibNull.inf =20 ####################################### # Silicon Package @@ -183,6 +188,7 @@ !if $(TARGET) =3D=3D DEBUG TestPointCheckLib|$(PLATFORM_PACKAGE)/Test/Library/TestPointCheckLib/Pei= TestPointCheckLib.inf !endif + SetCacheMtrrLib|$(PLATFORM_PACKAGE)/Library/SetCacheMtrrLib/SetCacheMtrr= LibNull.inf =20 ####################################### # Board Package @@ -193,7 +199,19 @@ PeiTbtPolicyLib|$(PLATFORM_BOARD_PACKAGE)/Features/Tbt/Library/PeiTbtPol= icyLib/PeiTbtPolicyLib.inf !endif =20 +[LibraryClasses.common.DXE_CORE] +!if $(TARGET) =3D=3D DEBUG + DebugLib|MdeModulePkg/Library/PeiDxeDebugLibReportStatusCode/PeiDxeDebug= LibReportStatusCode.inf +!endif + [LibraryClasses.common.DXE_DRIVER] + ####################################### + # Edk2 Packages + ####################################### +!if $(TARGET) =3D=3D DEBUG + DebugLib|MdeModulePkg/Library/PeiDxeDebugLibReportStatusCode/PeiDxeDebug= LibReportStatusCode.inf +!endif + ####################################### # Silicon Initialization Package ####################################### @@ -225,11 +243,24 @@ SiliconPolicyUpdateLib|$(PROJECT)/Policy/Library/DxeSiliconPolicyUpdateL= ib/DxeSiliconPolicyUpdateLib.inf =20 [LibraryClasses.X64.DXE_RUNTIME_DRIVER] + ####################################### + # Edk2 Packages + ####################################### +!if $(TARGET) =3D=3D DEBUG + DebugLib|MdeModulePkg/Library/PeiDxeDebugLibReportStatusCode/PeiDxeDebug= LibReportStatusCode.inf +!endif + ####################################### # Silicon Initialization Package ####################################### ResetSystemLib|$(PLATFORM_SI_PACKAGE)/Pch/Library/DxeRuntimeResetSystemL= ib/DxeRuntimeResetSystemLib.inf =20 +[LibraryClasses.common.SMM_CORE] +!if $(TARGET) =3D=3D DEBUG && gKabylakeOpenBoardPkgTokenSpaceGuid.PcdI2cHd= miDebugPortEnable =3D=3D TRUE + DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf + SerialPortLib|$(PLATFORM_BOARD_PACKAGE)/Library/I2cHdmiDebugSerialPortLi= b/SmmI2cHdmiDebugSerialPortLib.inf +!endif + [LibraryClasses.X64.DXE_SMM_DRIVER] ####################################### # Silicon Initialization Package @@ -245,6 +276,14 @@ !if $(TARGET) =3D=3D DEBUG TestPointCheckLib|$(PLATFORM_PACKAGE)/Test/Library/TestPointCheckLib/Smm= TestPointCheckLib.inf !endif +# @todo DebugLibReportStatusCode isn't working for SMM drivers for some re= ason +# temporary W/A is to link the serial port lib into every SMM driver +# I think the only driver that needs this is PiSmmCpuDxeSmm... +# But more testing is needed. +!if $(TARGET) =3D=3D DEBUG && gKabylakeOpenBoardPkgTokenSpaceGuid.PcdI2cHd= miDebugPortEnable =3D=3D TRUE + DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf + SerialPortLib|$(PLATFORM_BOARD_PACKAGE)/Library/I2cHdmiDebugSerialPortLi= b/SmmI2cHdmiDebugSerialPortLib.inf +!endif =20 ####################################### # PEI Components @@ -258,11 +297,17 @@ UefiCpuPkg/SecCore/SecCore.inf { PcdLib|MdePkg/Library/PeiPcdLib/PeiPcdLib.inf +!if $(TARGET) =3D=3D DEBUG && gKabylakeOpenBoardPkgTokenSpaceGuid.PcdI2cH= dmiDebugPortEnable =3D=3D TRUE + DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf +!endif } =20 MdeModulePkg/Universal/StatusCodeHandler/Pei/StatusCodeHandlerPei.inf { DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf +!if $(TARGET) =3D=3D DEBUG && gKabylakeOpenBoardPkgTokenSpaceGuid.PcdI2cH= dmiDebugPortEnable =3D=3D TRUE + SerialPortLib|$(PLATFORM_BOARD_PACKAGE)/Library/I2cHdmiDebugSerialPo= rtLib/PeiI2cHdmiDebugSerialPortLib.inf +!endif } =20 IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.inf { @@ -333,6 +378,13 @@ ####################################### # Edk2 Packages ####################################### + MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/StatusCodeHandlerRun= timeDxe.inf { + + DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf +!if $(TARGET) =3D=3D DEBUG && gKabylakeOpenBoardPkgTokenSpaceGuid.PcdI2cHd= miDebugPortEnable =3D=3D TRUE + SerialPortLib|$(PLATFORM_BOARD_PACKAGE)/Library/I2cHdmiDebugSerialPo= rtLib/DxeI2cHdmiDebugSerialPortLib.inf +!endif + } IntelFsp2WrapperPkg/FspWrapperNotifyDxe/FspWrapperNotifyDxe.inf MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf @@ -341,9 +393,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 { NULL|BoardModulePkg/Library/BdsPs2KbcLib/BdsPs2KbcLib.inf +!if gKabylakeOpenBoardPkgTokenSpaceGuid.PcdI2cHdmiDebugPortSerialTerminalE= nable =3D=3D TRUE + NULL|BoardModulePkg/Library/BdsSerialPortTerminalLib/BdsSerialPortTe= rminalLib.inf +!endif } UefiCpuPkg/CpuDxe/CpuDxe.inf =20 @@ -373,9 +428,20 @@ !if $(TARGET) =3D=3D DEBUG DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialP= ort.inf + !if gKabylakeOpenBoardPkgTokenSpaceGuid.PcdI2cHdmiDebugPortEnable = =3D=3D TRUE + SerialPortLib|$(PLATFORM_BOARD_PACKAGE)/Library/I2cHdmiDebugSeri= alPortLib/SmmI2cHdmiDebugSerialPortLib.inf + !endif !endif } !endif +!if gKabylakeOpenBoardPkgTokenSpaceGuid.PcdI2cHdmiDebugPortSerialTerminalE= nable =3D=3D TRUE + MdeModulePkg/Universal/SerialDxe/SerialDxe.inf { + + DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf + SerialPortLib|$(PLATFORM_BOARD_PACKAGE)/Library/I2cHdmiDebugSerialPo= rtLib/DxeI2cHdmiDebugSerialPortLib.inf + } + MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf +!endif =20 ####################################### # Silicon Initialization Package @@ -422,6 +488,14 @@ NULL|$(PROJECT)/Library/BoardAcpiLib/DxeMultiBoardAcpiSupportLib.i= nf !endif } + MdeModulePkg/Universal/ReportStatusCodeRouter/Smm/ReportStatusCodeRouter= Smm.inf { + + DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf +# @todo This is causing crashes still... more debug needed. +#!if $(TARGET) =3D=3D DEBUG && gKabylakeOpenBoardPkgTokenSpaceGuid.PcdI2cH= dmiDebugPortEnable =3D=3D TRUE +# SerialPortLib|$(PLATFORM_BOARD_PACKAGE)/Library/I2cHdmiDebugSerialP= ortLib/SmmI2cHdmiDebugSerialPortLib.inf +#!endif + } =20 !endif =20 diff --git a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.fd= f b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.fdf index 239b6b720a..6468962730 100644 --- a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.fdf +++ b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.fdf @@ -1,7 +1,7 @@ ## @file # System 76 GalagoPro3 board flash file. # -# Copyright (c) 2019 - 2021, Intel Corporation. All rights reserved.
+# Copyright (c) 2019 - 2022, Intel Corporation. All rights reserved.
# # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -347,6 +347,10 @@ INF $(PLATFORM_PACKAGE)/PlatformInit/PlatformInitDxe/= PlatformInitDxe.inf INF IntelFsp2WrapperPkg/FspWrapperNotifyDxe/FspWrapperNotifyDxe.inf =20 INF $(PLATFORM_PACKAGE)/Test/TestPointStubDxe/TestPointStubDxe.inf +!if gKabylakeOpenBoardPkgTokenSpaceGuid.PcdI2cHdmiDebugPortSerialTerminalE= nable =3D=3D TRUE + INF MdeModulePkg/Universal/SerialDxe/SerialDxe.inf + INF MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf +!endif =20 [FV.FvUefiBoot] BlockSize =3D $(FLASH_BLOCK_SIZE) diff --git a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkgPcd= .dsc b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkgPcd.dsc index c05535aab7..4a37d6157b 100644 --- a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkgPcd.dsc +++ b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkgPcd.dsc @@ -361,6 +361,36 @@ gBoardModulePkgTokenSpaceGuid.PcdSuperIoPciIsaBridgeDevice|{0x00, 0x00, = 0x1F, 0x00} gKabylakeOpenBoardPkgTokenSpaceGuid.PcdGttMmAddress|0xDF000000 =20 + ## Enable usage the HDMI DDC channel as a debug port - Causes the BIOS d= ebug 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 usag= e of the + # HDMI DDC channel to display BIOS Setup, UEFI Shell, etc. using a term= inal + # 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.PcdI2cHdmiDebugPortSerialTerminalEna= ble|FALSE + + ## 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 --=20 2.27.0.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#90596): https://edk2.groups.io/g/devel/message/90596 Mute This Topic: https://groups.io/mt/91835977/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-