From nobody Wed May 8 01:07:44 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+93539+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+93539+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1662685633; cv=none; d=zohomail.com; s=zohoarc; b=cK5DBfHyazS4K9A5mE3T2IPvGqzEzCImr/RLm0HJ0m6bz1HkwPH8COPcCQq27IGYvL7bVlDdYoA85xQ1sQKtxqsuQdpcw/mOw+jlXbNQptChh2Y19eFNIDNnE7jDqYrii52B1h+nGzhmCaRLayer2FCbDw0mNlcZULA3I6IlcNQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1662685633; 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=u/F/JTSxXqj3ZO3gbNW73DNUHKFGAPDpxLV9A9BF+w0=; b=oJQk+uGXLmSnMuBwUgIzlh8vY35vzKiPSRf+7HaRG4BEALHPF8jZmQmCzMsjPeKlhQ/5uYIMqKH9Z4l8oRmmW+/Hg337GawuWqe7PJZp41U1Z26qUuYYd3WvO3vP5IN6nYTcbz25xqPdt81xS33E+urxFzbooe2hJYeRoys9VfI= 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+93539+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 1662685633760527.9120097069111; Thu, 8 Sep 2022 18:07:13 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id Ft8CYY1788612xX4S4ML7jba; Thu, 08 Sep 2022 18:07:13 -0700 X-Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mx.groups.io with SMTP id smtpd.web08.1280.1662685631700254532 for ; Thu, 08 Sep 2022 18:07:12 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10464"; a="323568618" X-IronPort-AV: E=Sophos;i="5.93,300,1654585200"; d="scan'208";a="323568618" X-Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Sep 2022 18:07:11 -0700 X-IronPort-AV: E=Sophos;i="5.93,300,1654585200"; d="scan'208";a="676950460" X-Received: from nldesimo-desk1.amr.corp.intel.com ([10.24.80.62]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Sep 2022 18:07:11 -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 V3 1/6] KabylakeOpenBoardPkg: Add HdmiDebugPchDetectionLib Date: Thu, 8 Sep 2022 18:06:59 -0700 Message-Id: <20220909010704.7186-2-nathaniel.l.desimone@intel.com> In-Reply-To: <20220909010704.7186-1-nathaniel.l.desimone@intel.com> References: <20220909010704.7186-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: acvlNBWppDe9IytIkIII1oRbx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1662685633; bh=ELTNooemz1i6MX4kq0TxGDnwMTvmS6YUgpL4xHMGWLw=; h=Cc:Date:From:Reply-To:Subject:To; b=UQ0h+n7xJjc2Lvq6d9REFKaEHABx9KAPMDl1zyFyp9UObSR/C5fQs2LOb/JF2hhoWA1 tA906gN0xayulr0JrZ7ZSTEVKUs/a1t7IDp32VhlpFQiQMxjT/OmVvTS2Q9PwCS866J2V jNDYba6t9kGEgLZWCFAyg7gBItBCqFsT88M= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1662685634276100004 Content-Type: text/plain; charset="utf-8" This library detects the type of PCH present on the system to the granualarity level needed to determine which GMBUS pins to use to access the HDMI DDC I2C bus. Cc: Chasel Chiu Cc: Sai Chaganty Cc: Isaac Oram Cc: Benjamin Doron Cc: Michael Kubacki Cc: Jeremy Soller Signed-off-by: Nate DeSimone --- .../AspireVn7Dash572G/OpenBoardPkg.dsc | 1 + .../GalagoPro3/OpenBoardPkg.dsc | 1 + .../Library/HdmiDebugPchDetectionLib.h | 34 ++++++++++ .../KabylakeRvp3/OpenBoardPkg.dsc | 1 + .../HdmiDebugPchDetectionLib.c | 67 +++++++++++++++++++ .../HdmiDebugPchDetectionLib.inf | 38 +++++++++++ 6 files changed, 142 insertions(+) create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Include/Library/Hdm= iDebugPchDetectionLib.h create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/HdmiDebugPc= hDetectionLib/HdmiDebugPchDetectionLib.c create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/HdmiDebugPc= hDetectionLib/HdmiDebugPchDetectionLib.inf diff --git a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/OpenBoar= dPkg.dsc b/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/OpenBoardP= kg.dsc index 29aa8d9111..5e9ed615cf 100644 --- a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/OpenBoardPkg.dsc +++ b/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/OpenBoardPkg.dsc @@ -184,6 +184,7 @@ GpioExpanderLib|$(PLATFORM_BOARD_PACKAGE)/Library/BaseGpioExpanderLib/Ba= seGpioExpanderLib.inf I2cAccessLib|$(PLATFORM_BOARD_PACKAGE)/Library/PeiI2cAccessLib/PeiI2cAcc= essLib.inf PlatformSecLib|$(PLATFORM_PACKAGE)/FspWrapper/Library/SecFspWrapperPlatf= ormSecLib/SecFspWrapperPlatformSecLib.inf + HdmiDebugPchDetectionLib|$(PLATFORM_BOARD_PACKAGE)/Library/HdmiDebugPchD= etectionLib/HdmiDebugPchDetectionLib.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..59d361b472 100644 --- a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc +++ b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc @@ -128,6 +128,7 @@ GpioExpanderLib|$(PLATFORM_BOARD_PACKAGE)/Library/BaseGpioExpanderLib/Ba= seGpioExpanderLib.inf I2cAccessLib|$(PLATFORM_BOARD_PACKAGE)/Library/PeiI2cAccessLib/PeiI2cAcc= essLib.inf PlatformSecLib|$(PLATFORM_PACKAGE)/FspWrapper/Library/SecFspWrapperPlatf= ormSecLib/SecFspWrapperPlatformSecLib.inf + HdmiDebugPchDetectionLib|$(PLATFORM_BOARD_PACKAGE)/Library/HdmiDebugPchD= etectionLib/HdmiDebugPchDetectionLib.inf =20 # Thunderbolt !if gKabylakeOpenBoardPkgTokenSpaceGuid.PcdTbtEnable =3D=3D TRUE diff --git a/Platform/Intel/KabylakeOpenBoardPkg/Include/Library/HdmiDebugP= chDetectionLib.h b/Platform/Intel/KabylakeOpenBoardPkg/Include/Library/Hdmi= DebugPchDetectionLib.h new file mode 100644 index 0000000000..af5e6059f5 --- /dev/null +++ b/Platform/Intel/KabylakeOpenBoardPkg/Include/Library/HdmiDebugPchDetec= tionLib.h @@ -0,0 +1,34 @@ +/** @file + PCH Detection for the HDMI I2C Debug Port + +Copyright (c) 2022, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef HDMI_DEBUG_PCH_DETECTION_LIB_H_ +#define HDMI_DEBUG_PCH_DETECTION_LIB_H_ + +#include + +typedef enum { + PchTypeUnknown =3D 0, + PchTypeSptLp, + PchTypeSptH, + PchTypeKbpH, + PchTypeCnlLp, + PchTypeCnlH, + PchTypeMax +} PCH_TYPE; + +/** + Returns the type of PCH on the system + + @retval The PCH type. +**/ +PCH_TYPE +GetPchTypeInternal ( + VOID + ); + +#endif diff --git a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkg.= dsc b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkg.dsc index a46d36b056..3085a80ca2 100644 --- a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkg.dsc +++ b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkg.dsc @@ -171,6 +171,7 @@ GpioExpanderLib|$(PLATFORM_BOARD_PACKAGE)/Library/BaseGpioExpanderLib/Ba= seGpioExpanderLib.inf I2cAccessLib|$(PLATFORM_BOARD_PACKAGE)/Library/PeiI2cAccessLib/PeiI2cAcc= essLib.inf PlatformSecLib|$(PLATFORM_PACKAGE)/FspWrapper/Library/SecFspWrapperPlatf= ormSecLib/SecFspWrapperPlatformSecLib.inf + HdmiDebugPchDetectionLib|$(PLATFORM_BOARD_PACKAGE)/Library/HdmiDebugPchD= etectionLib/HdmiDebugPchDetectionLib.inf =20 # Thunderbolt !if gKabylakeOpenBoardPkgTokenSpaceGuid.PcdTbtEnable =3D=3D TRUE diff --git a/Platform/Intel/KabylakeOpenBoardPkg/Library/HdmiDebugPchDetect= ionLib/HdmiDebugPchDetectionLib.c b/Platform/Intel/KabylakeOpenBoardPkg/Lib= rary/HdmiDebugPchDetectionLib/HdmiDebugPchDetectionLib.c new file mode 100644 index 0000000000..596976dd1b --- /dev/null +++ b/Platform/Intel/KabylakeOpenBoardPkg/Library/HdmiDebugPchDetectionLib/= HdmiDebugPchDetectionLib.c @@ -0,0 +1,67 @@ +/** @file + PCH Detection for the HDMI I2C Debug Port + +Copyright (c) 2022, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#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_CNL_LP_PCH_START_DEVICE_ID 0x9D80 +#define V_CNL_LP_PCH_END_DEVICE_ID 0x9D9F +#define V_CNL_H_PCH_START_DEVICE_ID 0xA300 +#define V_CNL_H_PCH_END_DEVICE_ID 0xA31F + +#define V_KBP_H_PCH_DEVICE_ID_ES 0xA2C0 //= /< This is SKL-PCH-H in KBL-PCH-H package +#define V_KBP_H_PCH_DEVICE_ID_SVR_ES 0xA2D0 //= /< This is SKL-PCH-H in KBL-PCH-H package + +/** + Returns the type of PCH on the system + + @retval The PCH type. +**/ +PCH_TYPE +GetPchTypeInternal ( + VOID + ) +{ + PCH_TYPE PchType; + UINT16 DeviceId; + + PchType =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; +} diff --git a/Platform/Intel/KabylakeOpenBoardPkg/Library/HdmiDebugPchDetect= ionLib/HdmiDebugPchDetectionLib.inf b/Platform/Intel/KabylakeOpenBoardPkg/L= ibrary/HdmiDebugPchDetectionLib/HdmiDebugPchDetectionLib.inf new file mode 100644 index 0000000000..897f60fbb9 --- /dev/null +++ b/Platform/Intel/KabylakeOpenBoardPkg/Library/HdmiDebugPchDetectionLib/= HdmiDebugPchDetectionLib.inf @@ -0,0 +1,38 @@ +### @file +# Component description file for the HDMI I2C Debug Port PCH Detection lib= rary +# +# Copyright (c) 2022, Intel Corporation. All rights reserved.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D BaseHdmiDebugPchDetectionLib + FILE_GUID =3D EA098B52-45DF-4367-A32D-F36ACF91A0A9 + VERSION_STRING =3D 1.0 + MODULE_TYPE =3D BASE + LIBRARY_CLASS =3D HdmiDebugPchDetectionLib +# +# The following information is for reference only and not required by the = build tools. +# +# VALID_ARCHITECTURES =3D IA32 X64 +# + +[LibraryClasses] + BaseLib + PciLib + +[Packages] + MdePkg/MdePkg.dec + KabylakeOpenBoardPkg/OpenBoardPkg.dec + +[Sources] + HdmiDebugPchDetectionLib.c + +[Ppis] + +[Guids] + +[Pcd] --=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 (#93539): https://edk2.groups.io/g/devel/message/93539 Mute This Topic: https://groups.io/mt/93563550/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 Wed May 8 01:07:44 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+93541+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+93541+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1662685635; cv=none; d=zohomail.com; s=zohoarc; b=UkKZgIN1A8X/LWB2O15exkYV4fano6epEph9zIoxq7XdoVd3GUstNVzOtKjK0WE8c/8ZLqeImHHLApEa7Gl6n/VhDX7MZf6NKOEOLjLAZQLvrusabPAdFeXUcPf2+8zaqPwyCWnqTsZ35OMx8PC8PtasyH/4OH9d0DPpxDXYMBA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1662685635; 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=h73rZgJjhDdSc92JOXZ+ZXWmbd3upET9/Ds5D5vTElA=; b=jqQvH9JZ32LZCU/Sm65Obqjc1qa678FFlzIw827whNMzF0zKpRudQT6EPU1fUrQPd4Ru2ZuyKJPzBgDVv/2wvprcYN0PU1dIGfEgn+yJpZ40b9AiduBLBWPi50JhmmyB0V6N64VAd/xkE+QMX49KFi4Cwo8Slv9jj8pC3xT72RY= 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+93541+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 1662685635629718.7813113536228; Thu, 8 Sep 2022 18:07:15 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id Xc59YY1788612xK3DrQ2FiXB; Thu, 08 Sep 2022 18:07:13 -0700 X-Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mx.groups.io with SMTP id smtpd.web11.1258.1662685632496425130 for ; Thu, 08 Sep 2022 18:07:12 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10464"; a="323568620" X-IronPort-AV: E=Sophos;i="5.93,300,1654585200"; d="scan'208";a="323568620" X-Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Sep 2022 18:07:12 -0700 X-IronPort-AV: E=Sophos;i="5.93,300,1654585200"; d="scan'208";a="676950465" X-Received: from nldesimo-desk1.amr.corp.intel.com ([10.24.80.62]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Sep 2022 18:07:11 -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 V3 2/6] KabylakeOpenBoardPkg: Add I2cHdmiDebugSerialPortLib Date: Thu, 8 Sep 2022 18:07:00 -0700 Message-Id: <20220909010704.7186-3-nathaniel.l.desimone@intel.com> In-Reply-To: <20220909010704.7186-1-nathaniel.l.desimone@intel.com> References: <20220909010704.7186-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: 65To7QCqnKBzKFVUDfxzk83Kx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1662685633; bh=yBL73M4KWD9qOPze71I9Rv2RV83eoQ9/XpI8SNA/ziA=; h=Cc:Date:From:Reply-To:Subject:To; b=QwEweAWULp9piQtId0Pl9nl+G67kjRz3rdWcTDHOP3jT9USe35kbUIXSwfTjgTW3fu+ ntZY+GJcPq7oTQEkhqME102Yp79bUCqi3R+euOpSv9FjcYn8PonDV1DH8V9W3uKfvB0RW ckFXVFt6scXq0DpgQy5PRFx7DbmejS0zPFg= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1662685636358100015 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 | 53 ++ .../DxeSmmI2cHdmiDebugSerialPortLib.c | 161 ++++ .../Library/I2cHdmiDebugSerialPortLib/Gmbus.c | 755 ++++++++++++++++++ .../Library/I2cHdmiDebugSerialPortLib/Gmbus.h | 319 ++++++++ .../I2cDebugPortProtocol.c | 189 +++++ .../I2cDebugPortProtocol.h | 77 ++ .../I2cDebugPortTplDxe.c | 44 + .../I2cDebugPortTplNull.c | 36 + .../I2cHdmiDebugSerialPortLib.c | 198 +++++ .../I2cHdmiDebugSerialPortLib/IgfxI2c.c | 79 ++ .../I2cHdmiDebugSerialPortLib/IgfxI2c.h | 99 +++ .../PeiI2cHdmiDebugSerialPortLib.c | 224 ++++++ .../PeiI2cHdmiDebugSerialPortLib.inf | 54 ++ .../SecI2cHdmiDebugSerialPortLib.c | 134 ++++ .../SecI2cHdmiDebugSerialPortLib.inf | 53 ++ .../SmmI2cHdmiDebugSerialPortLib.inf | 53 ++ .../KabylakeOpenBoardPkg/OpenBoardPkg.dec | 15 +- 20 files changed, 2568 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 da8f9a075c..a9d531a269 100644 --- a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/OpenBoardPkgPcd= .dsc +++ b/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/OpenBoardPkgPcd= .dsc @@ -399,6 +399,15 @@ ###################################### gBoardModulePkgTokenSpaceGuid.PcdPs2KbMsEnable|1 gBoardModulePkgTokenSpaceGuid.PcdSuperIoPciIsaBridgeDevice|{0x00, 0x00, = 0x1F, 0x00} + gKabylakeOpenBoardPkgTokenSpaceGuid.PcdGttMmAddress|0xDF000000 + + ## Specifies the DDC I2C channel to claim as the HDMI debug port + # The value is defined as below. + # 2: DDC channel B + # 3: DDC channel C + # 4: DDC channel D + # @Prompt DDC I2C channel to claim as the HDMI debug port + gKabylakeOpenBoardPkgTokenSpaceGuid.PcdI2cHdmiDebugPortDdcI2cChannel|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 2b9fbe81c0..207c1de06d 100644 --- a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkgPcd.dsc +++ b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkgPcd.dsc @@ -332,6 +332,15 @@ ###################################### gBoardModulePkgTokenSpaceGuid.PcdPs2KbMsEnable|1 gBoardModulePkgTokenSpaceGuid.PcdSuperIoPciIsaBridgeDevice|{0x00, 0x00, = 0x1F, 0x00} + gKabylakeOpenBoardPkgTokenSpaceGuid.PcdGttMmAddress|0xDF000000 + + ## Specifies the DDC I2C channel to claim as the HDMI debug port + # The value is defined as below. + # 2: DDC channel B + # 3: DDC channel C + # 4: DDC channel D + # @Prompt DDC I2C channel to claim as the HDMI debug port + gKabylakeOpenBoardPkgTokenSpaceGuid.PcdI2cHdmiDebugPortDdcI2cChannel|0x03 =20 [PcdsFixedAtBuild.IA32] ###################################### diff --git a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkgP= cd.dsc b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkgPcd.d= sc index 360b99e0cf..2f7765e58a 100644 --- a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkgPcd.dsc +++ b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkgPcd.dsc @@ -332,6 +332,15 @@ ###################################### gBoardModulePkgTokenSpaceGuid.PcdPs2KbMsEnable|1 gBoardModulePkgTokenSpaceGuid.PcdSuperIoPciIsaBridgeDevice|{0x00, 0x00, = 0x1F, 0x00} + gKabylakeOpenBoardPkgTokenSpaceGuid.PcdGttMmAddress|0xDF000000 + + ## Specifies the DDC I2C channel to claim as the HDMI debug port + # The value is defined as below. + # 2: DDC channel B + # 3: DDC channel C + # 4: DDC channel D + # @Prompt DDC I2C channel to claim as the HDMI debug port + gKabylakeOpenBoardPkgTokenSpaceGuid.PcdI2cHdmiDebugPortDdcI2cChannel|0x00 =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..736b11a561 --- /dev/null +++ b/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib= /DxeI2cHdmiDebugSerialPortLib.inf @@ -0,0 +1,53 @@ +### @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 + HdmiDebugPchDetectionLib + +[Packages] + MdePkg/MdePkg.dec + KabylakeOpenBoardPkg/OpenBoardPkg.dec + KabylakeSiliconPkg/SiPkg.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..c645311784 --- /dev/null +++ b/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib= /Gmbus.c @@ -0,0 +1,755 @@ +/** @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; + if (GttMmAdr =3D=3D 0) { + GttMmAdr =3D (UINT32) FixedPcdGet32 (PcdGttMmAddress); + if (GttMmAdr =3D=3D 0) { + return 0; + } + // + // Program and read back GTT Memory Mapped BAR + // + PciWrite32 (GttMmPciAddress, (UINT32) (GttMmAdr & 0xFF000000)); + GttMmAdr =3D PciRead32 (GttMmPciAddress) & 0xFFFFFFF0; + } + // + // 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)) { + return Status; + } + Status =3D SetGmbus1Command (0); + if (EFI_ERROR (Status)) { + return Status; + } + // + // Wait for reset to complete + // + Status =3D GmbusWaitForReady (B_SA_GTTMMADR_GMBUS2_BUS_ACTIVE, FALSE); + if (EFI_ERROR (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; + + Status =3D EFI_TIMEOUT; + for (Index =3D 0; Index < GMBUS_TIMEOUT; Index++) { + Status2 =3D GetGmbus2Status (&GmbusStatus); + if (EFI_ERROR (Status2)) { + return Status2; + } + if (WaitForAssertion) { + if (GmbusStatus & StatusBitMask) { + Status =3D EFI_SUCCESS; + break; + } + } else { + if (!(GmbusStatus & StatusBitMask)) { + Status =3D EFI_SUCCESS; + break; + } + } + } + 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 + // + 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)) { + return Status; + } + // + // Program the GMBUS Port and Clock + // + GmbusClkPrtSel =3D (BusSpeed << 8) | DdcBusPinPair; + Status =3D SetGmbus0ClockPortSelect (GmbusClkPrtSel); + if (EFI_ERROR (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)) { + return Status; + } + if (GmbusStatus & B_SA_GTTMMADR_GMBUS2_NACK_INDICATOR) { + Status =3D GmbusRecoverError (); + if (EFI_ERROR (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)) { + 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)) { + } + + 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) { + return EFI_INVALID_PARAMETER; + } + if ((*ByteCount) > GMBUS_MAX_BYTES) { + return EFI_INVALID_PARAMETER; + } + if (ReadBuffer =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + if ((SlaveAddress & BIT0) !=3D BIT0) { + 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)) { + 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)) { + 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); + // + // Check the GMBUS2 register for error conditions (NACK or Slave Stall= Timeout) + // + Status2 =3D GetGmbus2Status (&GmbusStatus); + if (EFI_ERROR (Status2)) { + Status =3D Status2; + goto Done; + } + if (EFI_ERROR (Status) && ((GmbusStatus & B_SA_GTTMMADR_GMBUS2_NACK_IN= DICATOR) =3D=3D 0)) { + 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. + // + Status =3D GmbusRecoverError (); + if (EFI_ERROR (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)) { + 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)) { + return Status; + } + +Done: + Status2 =3D GmbusRelease (); + if (EFI_ERROR (Status2)) { + Status =3D Status2; + } + 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; + + // + // Input Validation + // + if (ByteCount <=3D 0) { + return EFI_INVALID_PARAMETER; + } + if (ByteCount > GMBUS_MAX_BYTES) { + return EFI_INVALID_PARAMETER; + } + if (WriteBuffer =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + if ((SlaveAddress & BIT0) !=3D 0) { + 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)) { + 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)) { + 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)) { + goto Done; + } + + while ((BytesWritten < ByteCount) || FirstLoop) { + // + // 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)) { + goto Done; + } + } + FirstLoop =3D FALSE; + + // + // 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)) { + } + // + // Check the GMBUS2 register for error conditions (NACK or Slave Stall= Timeout) + // + Status2 =3D GetGmbus2Status (&GmbusStatus); + if (EFI_ERROR (Status2)) { + Status =3D Status2; + goto Done; + } + if (EFI_ERROR (Status) && ((GmbusStatus & B_SA_GTTMMADR_GMBUS2_NACK_IN= DICATOR) =3D=3D 0)) { + 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. + // + Status =3D GmbusRecoverError (); + if (EFI_ERROR (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)) { + return Status; + } + +Done: + Status2 =3D GmbusRelease (); + if (EFI_ERROR (Status2)) { + Status =3D Status2; + } + 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..da583b4c13 --- /dev/null +++ b/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib= /Gmbus.h @@ -0,0 +1,319 @@ +/** @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 +#include + +#define SA_SEG_NUM 0x0000000 +#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..f76bcf364c --- /dev/null +++ b/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib= /I2cDebugPortProtocol.c @@ -0,0 +1,189 @@ +/** @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; + + 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 (); + + 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; + + 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; + 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; + + 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; + } + 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..6160bdd48a --- /dev/null +++ b/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib= /I2cHdmiDebugSerialPortLib.c @@ -0,0 +1,198 @@ +/** @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!!! */ + /******************************************************/ + if (Buffer =3D=3D NULL) { + return 0; + } + if (NumberOfBytes =3D=3D 0) { + return 0; + } + Status =3D I2cDebugPortWrite (Buffer, (UINT32) NumberOfBytes); + 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..f06d65a6f5 --- /dev/null +++ b/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib= /IgfxI2c.c @@ -0,0 +1,79 @@ +/** @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 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..259bade446 --- /dev/null +++ b/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib= /IgfxI2c.h @@ -0,0 +1,99 @@ +/** @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 +#include + +// +// 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 { + 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 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..5dbb7145bf --- /dev/null +++ b/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib= /PeiI2cHdmiDebugSerialPortLib.c @@ -0,0 +1,224 @@ +/** @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; + + I2cHdmiDebugDdcBusPinPair =3D 0; + GuidHob =3D GetFirstGuidHob (&gI2cHdmiDebugHobGuid); + if (GuidHob =3D=3D NULL) { + 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 (); + Status =3D GetGmbusBusPinPair ( + (IGFX_I2C_CHANNEL) PcdGet32 (PcdI2cHdmiDebugPortDdcI2cChan= nel), + &I2cHdmiDebugDdcBusPinPair + ); + if (EFI_ERROR (Status)) { + I2cHdmiDebugDdcBusPinPair =3D 0; + } + Context->I2cHdmiDebugDdcBusPinPair =3D I2cHdmiDebugDdcBusPinPair; + return Context; + } else { + 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; + + Context =3D GetI2cHdmiDebugPortContext (); + if (Context =3D=3D NULL) { + return PchTypeUnknown; + } + 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; + + Context =3D GetI2cHdmiDebugPortContext (); + if (Context =3D=3D NULL) { + return EFI_UNSUPPORTED; + } + + *DdcBusPinPair =3D Context->I2cHdmiDebugDdcBusPinPair; + 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..c82e0c9e9b --- /dev/null +++ b/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib= /PeiI2cHdmiDebugSerialPortLib.inf @@ -0,0 +1,54 @@ +### @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 + HdmiDebugPchDetectionLib + +[Packages] + MdePkg/MdePkg.dec + KabylakeOpenBoardPkg/OpenBoardPkg.dec + KabylakeSiliconPkg/SiPkg.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..3b84b25c31 --- /dev/null +++ b/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib= /SecI2cHdmiDebugSerialPortLib.inf @@ -0,0 +1,53 @@ +### @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 + HdmiDebugPchDetectionLib + +[Packages] + MdePkg/MdePkg.dec + KabylakeOpenBoardPkg/OpenBoardPkg.dec + KabylakeSiliconPkg/SiPkg.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..68ff314950 --- /dev/null +++ b/Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib= /SmmI2cHdmiDebugSerialPortLib.inf @@ -0,0 +1,53 @@ +### @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 + HdmiDebugPchDetectionLib + +[Packages] + MdePkg/MdePkg.dec + KabylakeOpenBoardPkg/OpenBoardPkg.dec + KabylakeSiliconPkg/SiPkg.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 (#93541): https://edk2.groups.io/g/devel/message/93541 Mute This Topic: https://groups.io/mt/93563552/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 Wed May 8 01:07:44 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+93540+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+93540+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1662685635; cv=none; d=zohomail.com; s=zohoarc; b=A4mxKUZmiEPEmBF/gnXsGIkweHAUF78VA+43ClFiB2WWG0pKiDxV5D95MqCEP4/v1LSpESc6sUUaJPHUIk2zTFuAvKPqj7+1yuNNlqbCiJDvDNdDGdSpbXZNrhP/vWTmXQOXd/WaQd/bNZ7A55720ESIxMQkQqndxH2OOoLC8Uc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1662685635; 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=gJ9Tmzi1+mErbdqs7niP8TJDME9ZqsbPd0Q78Jo2bJY=; b=BRbWIqlibg3O/8O6VkVywB/os+oa+465rdubKsn5kfrgThmuz8fjFNGRt5svfB4fxvYF5n4L2Zxhedh8dIbijahKQ3H2BbxWOBT3/QeoN1cyq/pDPSu9pbS8ZjbV90XiKkH1IGEQHPD3sbomZyCMG9XVNs+GnxJAHbl67zSHXnw= 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+93540+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 1662685635140866.2044914251384; Thu, 8 Sep 2022 18:07:15 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id PbBnYY1788612xSYCkfy0jzu; Thu, 08 Sep 2022 18:07:14 -0700 X-Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mx.groups.io with SMTP id smtpd.web08.1280.1662685631700254532 for ; Thu, 08 Sep 2022 18:07:12 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10464"; a="323568623" X-IronPort-AV: E=Sophos;i="5.93,300,1654585200"; d="scan'208";a="323568623" X-Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Sep 2022 18:07:12 -0700 X-IronPort-AV: E=Sophos;i="5.93,300,1654585200"; d="scan'208";a="676950469" X-Received: from nldesimo-desk1.amr.corp.intel.com ([10.24.80.62]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Sep 2022 18:07:12 -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 V3 3/6] KabylakeOpenBoardPkg: Add HdmiDebugGpioInitLib Date: Thu, 8 Sep 2022 18:07:01 -0700 Message-Id: <20220909010704.7186-4-nathaniel.l.desimone@intel.com> In-Reply-To: <20220909010704.7186-1-nathaniel.l.desimone@intel.com> References: <20220909010704.7186-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: WUgtVzNzWojoUYXDPOZmZ2tfx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1662685634; bh=eO2ce109WjkgT9eLG4RFiFjy7fjFK1LZCFCY5bkiJP4=; h=Cc:Date:From:Reply-To:Subject:To; b=NtzbEvHH6dNYK8YZ9dufzSeYac4DEakh1GPMRCHXb7hWTcU9qZqRFkwv6B38k1HiOMk MpPsKy3nbQ78aFKRuqkjYKyqV6KmHbEl4ddhkoDzdIcWh9M1gPc6IfsXzhB24N689UN4l huvYJl3ud0uNF99UBRJeUZAI39hVnmFIpc0= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1662685636321100013 Content-Type: text/plain; charset="utf-8" This library initializes any GPIOs necessary 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 | 163 ++++++++++++++++++ .../HdmiDebugGpioInitLib.inf | 43 +++++ 6 files changed, 238 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 5e9ed615cf..0edc315b59 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 HdmiDebugPchDetectionLib|$(PLATFORM_BOARD_PACKAGE)/Library/HdmiDebugPchD= etectionLib/HdmiDebugPchDetectionLib.inf =20 # Thunderbolt diff --git a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.ds= c b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc index 59d361b472..a34c21496b 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 HdmiDebugPchDetectionLib|$(PLATFORM_BOARD_PACKAGE)/Library/HdmiDebugPchD= etectionLib/HdmiDebugPchDetectionLib.inf =20 # Thunderbolt 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 3085a80ca2..faaafde84f 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 HdmiDebugPchDetectionLib|$(PLATFORM_BOARD_PACKAGE)/Library/HdmiDebugPchD= etectionLib/HdmiDebugPchDetectionLib.inf =20 # Thunderbolt 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..b82ac41df7 --- /dev/null +++ b/Platform/Intel/KabylakeOpenBoardPkg/Library/HdmiDebugGpioInitLib/Hdmi= DebugGpioInitLib.c @@ -0,0 +1,163 @@ +/** @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 +#include + +//GPIO Table Terminator +#define END_OF_GPIO_TABLE 0xFFFFFFFF + +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); + +} + +/** + 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 GetPchTypeInternal (); + 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..de921a5208 --- /dev/null +++ b/Platform/Intel/KabylakeOpenBoardPkg/Library/HdmiDebugGpioInitLib/Hdmi= DebugGpioInitLib.inf @@ -0,0 +1,43 @@ +### @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 + HdmiDebugPchDetectionLib + +[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 (#93540): https://edk2.groups.io/g/devel/message/93540 Mute This Topic: https://groups.io/mt/93563551/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 Wed May 8 01:07:44 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+93542+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+93542+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1662685635; cv=none; d=zohomail.com; s=zohoarc; b=fka5dWBkY11pnxJmltof9G9JdQm2pyCouc4vuFkg9L5tmQInNglUXwpHZ8kpjsjTHKvEYCtrIiucyDlMryfJw4Zwgs7n9pXKOKAMVYPpNehMPwNg97dOyt0cgW4NFdZcRB/pSzSKe/dldsk+M2i5ehn/Dns1RaX0U2eHqGRFQPw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1662685635; 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=Zqhq1er1y6gwvxwN8iAyo13ZGVeuBnTaZaKflde/dpM=; b=i9xTsgy6evcjQw/JqsTVnLSSjCI8u4W+6jpgBpXom+K3fsTCHS0OoAbbqtSgCs48EvvSi8l8ZJl5Y5kLy0g7gNETNpjFB7kx5i8d8F3HcZvcgOjkGutcZ+47eWbpx1VmT+UHybQYiHZlSO0LlamIGZ4H2Nl1fphkkYxmXkwlBXM= 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+93542+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 1662685635684432.19725873341565; Thu, 8 Sep 2022 18:07:15 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id bfnDYY1788612xa3GicW0wxD; Thu, 08 Sep 2022 18:07:15 -0700 X-Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mx.groups.io with SMTP id smtpd.web08.1280.1662685631700254532 for ; Thu, 08 Sep 2022 18:07:12 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10464"; a="323568626" X-IronPort-AV: E=Sophos;i="5.93,300,1654585200"; d="scan'208";a="323568626" X-Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Sep 2022 18:07:12 -0700 X-IronPort-AV: E=Sophos;i="5.93,300,1654585200"; d="scan'208";a="676950472" X-Received: from nldesimo-desk1.amr.corp.intel.com ([10.24.80.62]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Sep 2022 18:07:12 -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 V3 4/6] KabylakeOpenBoardPkg: Add SecBoardInitLib Date: Thu, 8 Sep 2022 18:07:02 -0700 Message-Id: <20220909010704.7186-5-nathaniel.l.desimone@intel.com> In-Reply-To: <20220909010704.7186-1-nathaniel.l.desimone@intel.com> References: <20220909010704.7186-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: AFfA5YrIMPpEmgPzCovDae6fx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1662685635; bh=X1NgKMmhdDM91TsWxn1b/d5WmoaEr8kiWESvQCe6YrI=; h=Cc:Date:From:Reply-To:Subject:To; b=Kwz4XJXlz6RZlArN3KkNHRL67DQzo8MOkrCp4eXv7NeNYvl5Sf6DxAXMdto0pAQcUtV 2uGtFB2fwNucZ6DUt5AuXnx+ieG6b8J1/fzxIKjC+Wlbh+ivDOmJnJruiV9nzQcXaXckY jw4LMrKLeeJPu1SgSsIRmYupqNar6GEyXg4= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1662685636322100014 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 0edc315b59..f2841bbf99 100644 --- a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/OpenBoardPkg.dsc +++ b/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/OpenBoardPkg.dsc @@ -210,8 +210,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 a34c21496b..734024e24f 100644 --- a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc +++ b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc @@ -153,8 +153,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 faaafde84f..37837eeb04 100644 --- a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkg.dsc +++ b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkg.dsc @@ -190,8 +190,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 (#93542): https://edk2.groups.io/g/devel/message/93542 Mute This Topic: https://groups.io/mt/93563553/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 Wed May 8 01:07:44 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+93543+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+93543+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1662685636; cv=none; d=zohomail.com; s=zohoarc; b=Hw9NRlzUo0fe03AWb/v7Ca6T6zVCgRkz3w+bpb0uUDl2/kQeuDTbKAZpiBm0aCN5O+80DNGucpiRSQjTO+uQgTSWeNMtKcIAHSeZ6gJUJHq3TLMtXMyrxA2cwk42TGVZo3RSjzEU7MOYLa3+YUfKCsMyTcIkk2GWb0GDqLyWld4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1662685636; 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=p4gE1excb5tfH2o4oKtL0OnM7JRowx0tlztwKQ9nXJ8=; b=IChkrU5EaADbHi9GzWZZvZS6T195e/2FIrz981jxetBk7Gr3wcXtRPZnjUQhGmEiwPzBBVSrKdCIUiX0LBwCt+cGHKZIAvKPyMqG3eR21OsiFZkfrcdRNjioPog5mwXwc9dUaLiifW6nMrg931GPHA4Kx3FotCrC6kiiFo0myy4= 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+93543+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 1662685636607273.8304219224415; Thu, 8 Sep 2022 18:07:16 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id GUg0YY1788612x0kaELeJaSo; Thu, 08 Sep 2022 18:07:16 -0700 X-Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mx.groups.io with SMTP id smtpd.web12.1316.1662685633362162071 for ; Thu, 08 Sep 2022 18:07:13 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10464"; a="323568634" X-IronPort-AV: E=Sophos;i="5.93,300,1654585200"; d="scan'208";a="323568634" X-Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Sep 2022 18:07:13 -0700 X-IronPort-AV: E=Sophos;i="5.93,300,1654585200"; d="scan'208";a="676950481" X-Received: from nldesimo-desk1.amr.corp.intel.com ([10.24.80.62]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Sep 2022 18:07:12 -0700 From: "Nate DeSimone" To: devel@edk2.groups.io Cc: Chasel Chiu , Sai Chaganty , Isaac Oram , Eric Dong , Liming Gao , Benjamin Doron , Michael Kubacki , Jeremy Soller Subject: [edk2-devel] [edk2-platforms] [PATCH V3 5/6] MinPlatformPkg: Add PcdDefaultTerminalType support to SerialPortTerminalLib Date: Thu, 8 Sep 2022 18:07:03 -0700 Message-Id: <20220909010704.7186-6-nathaniel.l.desimone@intel.com> In-Reply-To: <20220909010704.7186-1-nathaniel.l.desimone@intel.com> References: <20220909010704.7186-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: OdEkWlA4Ah0LazMFWRDqjYcTx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1662685636; bh=4cBKWcmoWgf3marjVvP/4vz3xY269L/v41R6oNLs/zU=; h=Cc:Date:From:Reply-To:Subject:To; b=C5v6OG1ShOVnMsd2RZEqt5P5pjjXHVIgJQ7OF0LBxXi1QnSZwZkqqvmUd1RNrVs2/Xw 1sMWlhA/3/BLFPeFwLP6m+VXYf6rshA0YM99fEJbJGit7o2eqLcP0dSGbYkBXHRXZdiFm 44VNaQDXPOtCfdMO3koWDngY+urwpwgx6Mk= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1662685638368100025 Content-Type: text/plain; charset="utf-8" - Sets the terminal type GUID for ConIn, ConOut, and ConErr to the terminal type indicated by PcdDefaultTerminalType. - Some improvements to the comments in SerialPortTerminalLib Cc: Chasel Chiu Cc: Sai Chaganty Cc: Isaac Oram Cc: Eric Dong Cc: Liming Gao Cc: Benjamin Doron Cc: Michael Kubacki Cc: Jeremy Soller Signed-off-by: Nate DeSimone --- .../SerialPortTerminalLib.c | 66 ++++++++++++++----- .../SerialPortTerminalLib.h | 11 +++- .../SerialPortTerminalLib.inf | 17 ++++- 3 files changed, 71 insertions(+), 23 deletions(-) diff --git a/Platform/Intel/MinPlatformPkg/Library/SerialPortTerminalLib/Se= rialPortTerminalLib.c b/Platform/Intel/MinPlatformPkg/Library/SerialPortTer= minalLib/SerialPortTerminalLib.c index 66e8ee018b..ca5e966cb5 100644 --- a/Platform/Intel/MinPlatformPkg/Library/SerialPortTerminalLib/SerialPor= tTerminalLib.c +++ b/Platform/Intel/MinPlatformPkg/Library/SerialPortTerminalLib/SerialPor= tTerminalLib.c @@ -1,13 +1,26 @@ /** @file - Main file for NULL named library for Serial Port Terminal Redirection li= brary. + Main file for NULL named library for the Serial Port Terminal Redirectio= n library. =20 - Copyright (c) 2020, Intel Corporation. All rights reserved.
+ This library adds a Terminal Device connected to SerialDxe to the UEFI C= onsole + Variables. This allows BIOS Setup, UEFI Shell, etc. to be used on a head= less + system via a null modem and terminal + emulator. + + Copyright (c) 2020 - 2022, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ =20 #include "SerialPortTerminalLib.h" =20 +GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID *mTerminalType[] =3D { + &gEfiPcAnsiGuid, + &gEfiVT100Guid, + &gEfiVT100PlusGuid, + &gEfiVTUTF8Guid, + &gEfiTtyTermGuid +}; + GLOBAL_REMOVE_IF_UNREFERENCED SERIAL_DEVICE_PATH mSerialDevicePath =3D { { { @@ -59,10 +72,36 @@ AddSerialTerminal ( VOID ) { - DEBUG ((DEBUG_INFO, "[AddSerialPortTerminal]\n")); + UINT8 DefaultTerminalType; + + // + // 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); + DefaultTerminalType =3D PcdGet8 (PcdDefaultTerminalType); + DEBUG ((DEBUG_INFO, "[AddSerialPortTerminal] [%d, %d, %d, %d, %d]\n", + (int) mSerialDevicePath.Uart.BaudRate, + (int) mSerialDevicePath.Uart.DataBits, + (int) mSerialDevicePath.Uart.Parity, + (int) mSerialDevicePath.Uart.StopBits, + (int) DefaultTerminalType)); + + if (DefaultTerminalType >=3D 0 && + DefaultTerminalType < (sizeof (mTerminalType) / sizeof (mTerminalTyp= e[0]))) { + CopyMem ( + (VOID *) &(mSerialDevicePath.TerminalType.Guid), + (VOID *) mTerminalType[DefaultTerminalType], + sizeof (EFI_GUID) + ); + } else { + DEBUG ((DEBUG_WARN, "PcdDefaultTerminalType has invalid value: %d\n", = (int) DefaultTerminalType)); + } =20 // - // Append Serial Terminal into "ConIn" + // Append Serial Terminal into "ConIn", "ConOut", and "ErrOut" // EfiBootManagerUpdateConsoleVariable (ConOut, (EFI_DEVICE_PATH_PROTOCOL *= ) &mSerialDevicePath, NULL); EfiBootManagerUpdateConsoleVariable (ConIn, (EFI_DEVICE_PATH_PROTOCOL *)= &mSerialDevicePath, NULL); @@ -71,13 +110,12 @@ AddSerialTerminal ( =20 =20 /** - Constructor for the Serial Port Device controller library. + Constructor for the Serial Port Terminal Device library. =20 - @param ImageHandle the image handle of the process - @param SystemTable the EFI System Table pointer + @param ImageHandle The Image Handle of the process + @param SystemTable The EFI System Table pointer =20 - @retval EFI_SUCCESS the shell command handlers were installed suc= essfully - @retval EFI_UNSUPPORTED the shell level required was not found. + @retval EFI_SUCCESS The Serial Port Terminal Device was installed succ= essfully **/ EFI_STATUS EFIAPI @@ -86,15 +124,7 @@ SerialPortTerminalLibConstructor ( IN EFI_SYSTEM_TABLE *SystemTable ) { - mSerialDevicePath.Uart.BaudRate =3D PcdGet64(PcdUartDefaultBaudRate); - mSerialDevicePath.Uart.DataBits =3D PcdGet8(PcdUartDefaultDataBits); - mSerialDevicePath.Uart.Parity =3D PcdGet8(PcdUartDefaultParity); - mSerialDevicePath.Uart.StopBits =3D PcdGet8(PcdUartDefaultStopBits); - DEBUG ((DEBUG_INFO, "[SerialPortTerminalLibConstructor] [%d, %d, %d, %d]= \n", - mSerialDevicePath.Uart.BaudRate, - mSerialDevicePath.Uart.DataBits, - mSerialDevicePath.Uart.Parity, - mSerialDevicePath.Uart.StopBits)); + DEBUG ((DEBUG_INFO, "[SerialPortTerminalLibConstructor]\n")); =20 AddSerialTerminal(); =20 diff --git a/Platform/Intel/MinPlatformPkg/Library/SerialPortTerminalLib/Se= rialPortTerminalLib.h b/Platform/Intel/MinPlatformPkg/Library/SerialPortTer= minalLib/SerialPortTerminalLib.h index bfa73cca7d..33415721cd 100644 --- a/Platform/Intel/MinPlatformPkg/Library/SerialPortTerminalLib/SerialPor= tTerminalLib.h +++ b/Platform/Intel/MinPlatformPkg/Library/SerialPortTerminalLib/SerialPor= tTerminalLib.h @@ -1,7 +1,12 @@ /** @file - Header file for NULL named library for for Serial Port Terminal Redirect= ion library. + Header file for NULL named library for the Serial Port Terminal Redirect= ion library. =20 - Copyright (c) 2020, Intel Corporation. All rights reserved.
+ This library adds a Terminal Device connected to SerialDxe to the UEFI C= onsole + Variables. This allows BIOS Setup, UEFI Shell, etc. to be used on a head= less + system via a null modem and terminal + emulator. + + Copyright (c) 2020 -2022, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -12,8 +17,10 @@ #include #include #include +#include #include #include +#include #include =20 // diff --git a/Platform/Intel/MinPlatformPkg/Library/SerialPortTerminalLib/Se= rialPortTerminalLib.inf b/Platform/Intel/MinPlatformPkg/Library/SerialPortT= erminalLib/SerialPortTerminalLib.inf index dc5bb91a8e..ac1a06b2a5 100644 --- a/Platform/Intel/MinPlatformPkg/Library/SerialPortTerminalLib/SerialPor= tTerminalLib.inf +++ b/Platform/Intel/MinPlatformPkg/Library/SerialPortTerminalLib/SerialPor= tTerminalLib.inf @@ -1,5 +1,9 @@ ## @file -# Component information file for Serial Port Terminal Redirection Library +# Component information file for the Serial Port Terminal Redirection libr= ary. +# +# This library adds a Terminal Device connected to SerialDxe to the UEFI = Console +# Variables. This allows BIOS Setup, UEFI Shell, etc. to be used on a hea= dless +# system via a null modem and terminal # # Copyright (c) 2020, Intel Corporation. All rights reserved.
# @@ -18,22 +22,29 @@ [Packages] MdePkg/MdePkg.dec MdeModulePkg/MdeModulePkg.dec - BoardModulePkg/BoardModulePkg.dec - MinPlatformPkg/MinPlatformPkg.dec =20 [Sources] SerialPortTerminalLib.c SerialPortTerminalLib.h =20 [LibraryClasses] + BaseMemoryLib DevicePathLib DebugLib UefiDriverEntryPoint UefiBootManagerLib UefiLib =20 +[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 (#93543): https://edk2.groups.io/g/devel/message/93543 Mute This Topic: https://groups.io/mt/93563554/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 Wed May 8 01:07:44 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+93544+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+93544+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1662685636; cv=none; d=zohomail.com; s=zohoarc; b=jaR3tcKZAPS5/KAKSZ1iewB7zGDbXHQUBtHgFwqoCCZ1o/6pr0omdVDOj1jeXOgyNPzL3GUjpixf/EaSa9aEQ046/4TT/hMFfOTTXmR6DEOzK8erHJTTB49zCh/qQPd/hbRrGNgqR+Qeex8Zb2wNbigWLyQWNPSwAoNYWiacTHs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1662685636; 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=OeKsziW+lhrNUp1d7mQhpqNsXgGiwxPpZbTg4q1JXYA=; b=UG8wphQwlLzfg+7o0dbpHKRsgQX85nDLXWuUEHfRsR++DioVoOxmmy1swCeI5yrTnOPOsTL4TA8cEj0xPpTzZRYolwmeaZYpPCTSfgEBxHQhhyzKOP2xw8TdrwZdjblEuTWAgDj4LsCtPPzMxqJ3aZ2wbijhYzNc8FEB27p5fdY= 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+93544+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 1662685636884211.76201915576723; Thu, 8 Sep 2022 18:07:16 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id zjFhYY1788612xU6Naet1IaC; Thu, 08 Sep 2022 18:07:16 -0700 X-Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mx.groups.io with SMTP id smtpd.web12.1316.1662685633362162071 for ; Thu, 08 Sep 2022 18:07:13 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10464"; a="323568641" X-IronPort-AV: E=Sophos;i="5.93,300,1654585200"; d="scan'208";a="323568641" X-Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Sep 2022 18:07:13 -0700 X-IronPort-AV: E=Sophos;i="5.93,300,1654585200"; d="scan'208";a="676950484" X-Received: from nldesimo-desk1.amr.corp.intel.com ([10.24.80.62]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Sep 2022 18:07:13 -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 V3 6/6] KabylakeOpenBoardPkg/GalagoPro3: Enable HDMI DDC Debug Port Date: Thu, 8 Sep 2022 18:07:04 -0700 Message-Id: <20220909010704.7186-7-nathaniel.l.desimone@intel.com> In-Reply-To: <20220909010704.7186-1-nathaniel.l.desimone@intel.com> References: <20220909010704.7186-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: RxaB7WbZJs2bKq9LUDDPQDm8x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1662685636; bh=urgQolykoXmWnl0zB8hzJ6JIExsDLAKtAoou8pE63pM=; h=Cc:Date:From:Reply-To:Subject:To; b=w15w0CGt2D2ZQbSm/aMj1OhyhiV2aNo3JRPDmyT7XBQElfoP5AHXaprGJ5gTOhPUe4i 9BqIposQFdjbjOcUMqXteoLcGzuz5c+UmoD33aWMX/vTf4BRX3GQGkpFqf8tL8O4Khkeu nRJzAkF5pA2QAqw1jtYOMgLKEZBaf5t6j0E= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1662685638479100026 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 | 74 ++++++++++++++++++- .../GalagoPro3/OpenBoardPkgPcd.dsc | 31 ++++++++ 2 files changed, 103 insertions(+), 2 deletions(-) diff --git a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.ds= c b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc index 734024e24f..f0e9a21cca 100644 --- a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc +++ b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc @@ -143,6 +143,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 @@ -165,9 +171,10 @@ ####################################### # Edk2 Packages ####################################### +!if $(TARGET) =3D=3D DEBUG DebugLib|MdeModulePkg/Library/PeiDxeDebugLibReportStatusCode/PeiDxeDebug= LibReportStatusCode.inf +!endif SerialPortLib|MdePkg/Library/BaseSerialPortLibNull/BaseSerialPortLibNull= .inf - SetCacheMtrrLib|$(PLATFORM_PACKAGE)/Library/SetCacheMtrrLib/SetCacheMtrr= LibNull.inf =20 ####################################### # Silicon Package @@ -184,6 +191,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 @@ -194,7 +202,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 ####################################### @@ -226,11 +246,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 +278,7 @@ TestPointLib|$(PLATFORM_PACKAGE)/Test/Library/TestPointLib/SmmTestPointL= ib.inf !if $(TARGET) =3D=3D DEBUG TestPointCheckLib|$(PLATFORM_PACKAGE)/Test/Library/TestPointCheckLib/Smm= TestPointCheckLib.inf + DebugLib|MdeModulePkg/Library/PeiDxeDebugLibReportStatusCode/PeiDxeDebug= LibReportStatusCode.inf !endif =20 ####################################### @@ -264,6 +298,9 @@ 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 { @@ -334,6 +371,26 @@ ####################################### # Edk2 Packages ####################################### + !if $(TARGET) =3D=3D DEBUG + MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/StatusCodeHandlerRun= timeDxe.inf { + + DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf + !if gKabylakeOpenBoardPkgTokenSpaceGuid.PcdI2cHdmiDebugPortEnable = =3D=3D TRUE + SerialPortLib|$(PLATFORM_BOARD_PACKAGE)/Library/I2cHdmiDebugSerial= PortLib/DxeI2cHdmiDebugSerialPortLib.inf + !endif + } + MdeModulePkg/Universal/ReportStatusCodeRouter/Smm/ReportStatusCodeRout= erSmm.inf { + + DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf + } + MdeModulePkg/Universal/StatusCodeHandler/Smm/StatusCodeHandlerSmm.inf { + + DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf + !if gKabylakeOpenBoardPkgTokenSpaceGuid.PcdI2cHdmiDebugPortEnable = =3D=3D TRUE + SerialPortLib|$(PLATFORM_BOARD_PACKAGE)/Library/I2cHdmiDebugSeri= alPortLib/SmmI2cHdmiDebugSerialPortLib.inf + !endif + } + !endif IntelFsp2WrapperPkg/FspWrapperNotifyDxe/FspWrapperNotifyDxe.inf MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf @@ -342,9 +399,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 gMinPlatformPkgTokenSpaceGuid.PcdSerialTerminalEnable =3D=3D TRUE + NULL|MinPlatformPkg/Library/SerialPortTerminalLib/SerialPortTerminal= Lib.inf +!endif } UefiCpuPkg/CpuDxe/CpuDxe.inf =20 @@ -374,9 +434,19 @@ !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 + } +!endif =20 ####################################### # Silicon Initialization Package diff --git a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkgPcd= .dsc b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkgPcd.dsc index 207c1de06d..0a2d08f300 100644 --- a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkgPcd.dsc +++ b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkgPcd.dsc @@ -334,6 +334,37 @@ gBoardModulePkgTokenSpaceGuid.PcdSuperIoPciIsaBridgeDevice|{0x00, 0x00, = 0x1F, 0x00} gKabylakeOpenBoardPkgTokenSpaceGuid.PcdGttMmAddress|0xDF000000 =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 + gMinPlatformPkgTokenSpaceGuid.PcdSerialTerminalEnable|gKabylakeOpenBoard= PkgTokenSpaceGuid.PcdI2cHdmiDebugPortSerialTerminalEnable + + ## Indicates the type of terminal to use. + # If PcdI2cHdmiDebugPortSerialTerminalEnable is TRUE, this PCD will be = used + # to determine which terminal protocol to use. + # 0 - PCANSI + # 1 - VT100 + # 2 - VT100+ + # 3 - UTF8 + # 4 - TTYTERM + # @Prompt Default Terminal Type. + # @ValidRange 0x80000001 | 0 - 4 + gEfiMdePkgTokenSpaceGuid.PcdDefaultTerminalType|3 + ## Specifies the DDC I2C channel to claim as the HDMI debug port # The value is defined as below. # 2: DDC channel B --=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 (#93544): https://edk2.groups.io/g/devel/message/93544 Mute This Topic: https://groups.io/mt/93563555/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-