From mboxrd@z Thu Jan 1 00:00:00 1970 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 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=BV7iC91N; spf=pass (domain: intel.com, ip: 192.55.52.88, mailfrom: nathaniel.l.desimone@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1662685632; x=1694221632; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=30GXw08viYAP1gkZd5HU9VQG0g8ksxtL+1oAXQOvk/4=; b=BV7iC91NMiRuSlBtqyKLCyNECKKTM7x+NHBPbxh2HNeMKwJcAY9Fma+y eoAyqdsM01rNJMYdH3R/+CGqXsByF3SqES2Tp/sWfqZauhtGAGtVYx1wY tOvDHFHGSsw05ZJxwT3gjefuxbkr7U0rywhIn2KQcH6WeHKRuOb8pxjty 0BeKazQx0jy8T14GvQANLKuxcZiH0c4krGq2D/DCSRIGRO1K5ntYUUMr9 kHYOZAUAf7sEYKbYxVGdl7QK8NXlcaUx+5fbZtRhdpWi0xQeMdDL96KLC yI5mRbj1SIvXIWQ25l9zfjklbvBnYqD8gVCEbcHCwLNDf+LWI2BeX3gFK g==; 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" 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" 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-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> X-Mailer: git-send-email 2.27.0.windows.1 In-Reply-To: <20220909010704.7186-1-nathaniel.l.desimone@intel.com> References: <20220909010704.7186-1-nathaniel.l.desimone@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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/HdmiDebugPchDetectionLib.h create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/HdmiDebugPchDetectionLib/HdmiDebugPchDetectionLib.c create mode 100644 Platform/Intel/KabylakeOpenBoardPkg/Library/HdmiDebugPchDetectionLib/HdmiDebugPchDetectionLib.inf diff --git a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/OpenBoardPkg.dsc b/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/OpenBoardPkg.dsc index 29aa8d9111..5e9ed615cf 100644 --- a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/OpenBoardPkg.dsc +++ b/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/OpenBoardPkg.dsc @@ -184,6 +184,7 @@ GpioExpanderLib|$(PLATFORM_BOARD_PACKAGE)/Library/BaseGpioExpanderLib/BaseGpioExpanderLib.inf I2cAccessLib|$(PLATFORM_BOARD_PACKAGE)/Library/PeiI2cAccessLib/PeiI2cAccessLib.inf PlatformSecLib|$(PLATFORM_PACKAGE)/FspWrapper/Library/SecFspWrapperPlatformSecLib/SecFspWrapperPlatformSecLib.inf + HdmiDebugPchDetectionLib|$(PLATFORM_BOARD_PACKAGE)/Library/HdmiDebugPchDetectionLib/HdmiDebugPchDetectionLib.inf # Thunderbolt !if gKabylakeOpenBoardPkgTokenSpaceGuid.PcdTbtEnable == TRUE diff --git a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc index 93cf93942b..59d361b472 100644 --- a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc +++ b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc @@ -128,6 +128,7 @@ GpioExpanderLib|$(PLATFORM_BOARD_PACKAGE)/Library/BaseGpioExpanderLib/BaseGpioExpanderLib.inf I2cAccessLib|$(PLATFORM_BOARD_PACKAGE)/Library/PeiI2cAccessLib/PeiI2cAccessLib.inf PlatformSecLib|$(PLATFORM_PACKAGE)/FspWrapper/Library/SecFspWrapperPlatformSecLib/SecFspWrapperPlatformSecLib.inf + HdmiDebugPchDetectionLib|$(PLATFORM_BOARD_PACKAGE)/Library/HdmiDebugPchDetectionLib/HdmiDebugPchDetectionLib.inf # Thunderbolt !if gKabylakeOpenBoardPkgTokenSpaceGuid.PcdTbtEnable == TRUE diff --git a/Platform/Intel/KabylakeOpenBoardPkg/Include/Library/HdmiDebugPchDetectionLib.h b/Platform/Intel/KabylakeOpenBoardPkg/Include/Library/HdmiDebugPchDetectionLib.h new file mode 100644 index 0000000000..af5e6059f5 --- /dev/null +++ b/Platform/Intel/KabylakeOpenBoardPkg/Include/Library/HdmiDebugPchDetectionLib.h @@ -0,0 +1,34 @@ +/** @file + PCH Detection for the HDMI I2C Debug Port + +Copyright (c) 2022, Intel Corporation. All rights reserved.
+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 = 0, + PchTypeSptLp, + PchTypeSptH, + PchTypeKbpH, + PchTypeCnlLp, + PchTypeCnlH, + PchTypeMax +} PCH_TYPE; + +/** + Returns the type of PCH on the system + + @retval The PCH type. +**/ +PCH_TYPE +GetPchTypeInternal ( + VOID + ); + +#endif diff --git a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkg.dsc b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkg.dsc index a46d36b056..3085a80ca2 100644 --- a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkg.dsc +++ b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkg.dsc @@ -171,6 +171,7 @@ GpioExpanderLib|$(PLATFORM_BOARD_PACKAGE)/Library/BaseGpioExpanderLib/BaseGpioExpanderLib.inf I2cAccessLib|$(PLATFORM_BOARD_PACKAGE)/Library/PeiI2cAccessLib/PeiI2cAccessLib.inf PlatformSecLib|$(PLATFORM_PACKAGE)/FspWrapper/Library/SecFspWrapperPlatformSecLib/SecFspWrapperPlatformSecLib.inf + HdmiDebugPchDetectionLib|$(PLATFORM_BOARD_PACKAGE)/Library/HdmiDebugPchDetectionLib/HdmiDebugPchDetectionLib.inf # Thunderbolt !if gKabylakeOpenBoardPkgTokenSpaceGuid.PcdTbtEnable == TRUE diff --git a/Platform/Intel/KabylakeOpenBoardPkg/Library/HdmiDebugPchDetectionLib/HdmiDebugPchDetectionLib.c b/Platform/Intel/KabylakeOpenBoardPkg/Library/HdmiDebugPchDetectionLib/HdmiDebugPchDetectionLib.c new file mode 100644 index 0000000000..596976dd1b --- /dev/null +++ b/Platform/Intel/KabylakeOpenBoardPkg/Library/HdmiDebugPchDetectionLib/HdmiDebugPchDetectionLib.c @@ -0,0 +1,67 @@ +/** @file + PCH Detection for the HDMI I2C Debug Port + +Copyright (c) 2022, Intel Corporation. All rights reserved.
+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 = PchTypeUnknown; + DeviceId = PciRead16 (PCI_LIB_ADDRESS (PCH_PCI_BUS, PCH_LPC_PCI_DEV, PCH_LPC_PCI_FUN, R_PCH_LPC_DID)); + if ((DeviceId >= V_SPT_LP_PCH_START_DEVICE_ID) && (DeviceId <= V_SPT_LP_PCH_END_DEVICE_ID)) { + PchType = PchTypeSptLp; + } else if ((DeviceId >= V_SPT_H_PCH_START_DEVICE_ID) && (DeviceId <= V_SPT_H_PCH_END_DEVICE_ID )) { + PchType = PchTypeSptH; + } else if ((DeviceId >= V_KBP_H_PCH_START_DEVICE_ID) && (DeviceId <= V_KBP_H_PCH_END_DEVICE_ID)) { + PchType = PchTypeKbpH; + if ((DeviceId == V_KBP_H_PCH_DEVICE_ID_ES) || (DeviceId == V_KBP_H_PCH_DEVICE_ID_SVR_ES)) { + PchType = PchTypeSptH; + } + } else if ((DeviceId >= V_CNL_LP_PCH_START_DEVICE_ID) && (DeviceId <= V_CNL_LP_PCH_END_DEVICE_ID)) { + PchType = PchTypeCnlLp; + } else if ((DeviceId >= V_CNL_H_PCH_START_DEVICE_ID) && (DeviceId <= V_CNL_H_PCH_END_DEVICE_ID)) { + PchType = PchTypeCnlH; + } + + return PchType; +} diff --git a/Platform/Intel/KabylakeOpenBoardPkg/Library/HdmiDebugPchDetectionLib/HdmiDebugPchDetectionLib.inf b/Platform/Intel/KabylakeOpenBoardPkg/Library/HdmiDebugPchDetectionLib/HdmiDebugPchDetectionLib.inf new file mode 100644 index 0000000000..897f60fbb9 --- /dev/null +++ b/Platform/Intel/KabylakeOpenBoardPkg/Library/HdmiDebugPchDetectionLib/HdmiDebugPchDetectionLib.inf @@ -0,0 +1,38 @@ +### @file +# Component description file for the HDMI I2C Debug Port PCH Detection library +# +# Copyright (c) 2022, Intel Corporation. All rights reserved.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = BaseHdmiDebugPchDetectionLib + FILE_GUID = EA098B52-45DF-4367-A32D-F36ACF91A0A9 + VERSION_STRING = 1.0 + MODULE_TYPE = BASE + LIBRARY_CLASS = HdmiDebugPchDetectionLib +# +# The following information is for reference only and not required by the build tools. +# +# VALID_ARCHITECTURES = IA32 X64 +# + +[LibraryClasses] + BaseLib + PciLib + +[Packages] + MdePkg/MdePkg.dec + KabylakeOpenBoardPkg/OpenBoardPkg.dec + +[Sources] + HdmiDebugPchDetectionLib.c + +[Ppis] + +[Guids] + +[Pcd] -- 2.27.0.windows.1