summaryrefslogtreecommitdiff
path: root/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules
diff options
context:
space:
mode:
Diffstat (limited to 'src/vendorcode/amd/agesa/f14/Proc/GNB/Modules')
-rw-r--r--src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbCableSafe/GnbCableSafe.c222
-rw-r--r--src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbCableSafe/GnbCableSafeDefs.h66
-rw-r--r--src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbCommonLib/GnbCommonLib.h58
-rw-r--r--src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbCommonLib/GnbLib.c460
-rw-r--r--src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbCommonLib/GnbLib.h148
-rw-r--r--src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbCommonLib/GnbLibCpuAcc.c130
-rw-r--r--src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbCommonLib/GnbLibCpuAcc.h66
-rw-r--r--src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbCommonLib/GnbLibHeap.c129
-rw-r--r--src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbCommonLib/GnbLibHeap.h63
-rw-r--r--src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbCommonLib/GnbLibIoAcc.c123
-rw-r--r--src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbCommonLib/GnbLibIoAcc.h67
-rw-r--r--src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbCommonLib/GnbLibMemAcc.c126
-rw-r--r--src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbCommonLib/GnbLibMemAcc.h74
-rw-r--r--src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbCommonLib/GnbLibPci.c405
-rw-r--r--src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbCommonLib/GnbLibPci.h148
-rw-r--r--src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbCommonLib/GnbLibPciAcc.c157
-rw-r--r--src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbCommonLib/GnbLibPciAcc.h74
-rw-r--r--src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbGfxConfig/GfxConfigEnv.c176
-rw-r--r--src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbGfxConfig/GfxConfigPost.c180
-rw-r--r--src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbGfxConfig/GfxConfigPost.h55
-rw-r--r--src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbGfxConfig/GnbGfxConfig.h56
-rw-r--r--src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbGfxInitLibV1/GfxCardInfo.c185
-rw-r--r--src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbGfxInitLibV1/GfxCardInfo.h64
-rw-r--r--src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbGfxInitLibV1/GfxEnumConnectors.c574
-rw-r--r--src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbGfxInitLibV1/GfxEnumConnectors.h65
-rw-r--r--src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbGfxInitLibV1/GfxPowerPlayTable.c572
-rw-r--r--src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbGfxInitLibV1/GfxPowerPlayTable.h200
-rw-r--r--src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbGfxInitLibV1/GnbGfxInitLibV1.h56
-rw-r--r--src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbNbInitLibV1/GnbNbInitLibV1.c247
-rw-r--r--src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbNbInitLibV1/GnbNbInitLibV1.h74
-rw-r--r--src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieAlibV1/PcieAlib.c351
-rw-r--r--src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieAlibV1/PcieAlib.h83
-rw-r--r--src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieAlibV1/PcieAlibConfig.esl68
-rw-r--r--src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieAlibV1/PcieAlibCore.esl373
-rw-r--r--src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieAlibV1/PcieAlibHotplug.esl328
-rw-r--r--src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieAlibV1/PcieAlibPspp.esl682
-rw-r--r--src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieConfig/GnbPcieConfig.h54
-rw-r--r--src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieConfig/PcieConfigData.c379
-rw-r--r--src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieConfig/PcieConfigData.h65
-rw-r--r--src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieConfig/PcieConfigLib.c356
-rw-r--r--src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieConfig/PcieConfigLib.h123
-rw-r--r--src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieConfig/PcieInputParser.c218
-rw-r--r--src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieConfig/PcieInputParser.h75
-rw-r--r--src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieConfig/PcieMapTopology.c720
-rw-r--r--src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieConfig/PcieMapTopology.h58
-rw-r--r--src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/GnbPcieInitLibV1.h62
-rw-r--r--src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PcieAspm.c346
-rw-r--r--src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PcieAspm.h57
-rw-r--r--src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PcieAspmBlackList.c141
-rw-r--r--src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PcieAspmBlackList.h56
-rw-r--r--src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PcieAspmExitLatency.c192
-rw-r--r--src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PcieAspmExitLatency.h56
-rw-r--r--src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PciePhyServices.c197
-rw-r--r--src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PciePhyServices.h61
-rw-r--r--src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PciePifServices.c558
-rw-r--r--src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PciePifServices.h107
-rw-r--r--src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PciePortRegAcc.c230
-rw-r--r--src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PciePortRegAcc.h95
-rw-r--r--src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PciePortServices.c406
-rw-r--r--src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PciePortServices.h101
-rw-r--r--src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PciePowerMgmt.c350
-rw-r--r--src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PciePowerMgmt.h75
-rw-r--r--src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PcieSbLink.c221
-rw-r--r--src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PcieSbLink.h83
-rw-r--r--src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PcieSiliconServices.c255
-rw-r--r--src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PcieSiliconServices.h73
-rw-r--r--src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PcieSmuLib.esl217
-rw-r--r--src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PcieTimer.c100
-rw-r--r--src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PcieTimer.h56
-rw-r--r--src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PcieTopologyServices.c692
-rw-r--r--src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PcieTopologyServices.h134
-rw-r--r--src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PcieUtilityLib.c437
-rw-r--r--src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PcieUtilityLib.h128
-rw-r--r--src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PcieWrapperRegAcc.c291
-rw-r--r--src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PcieWrapperRegAcc.h128
-rw-r--r--src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieTrainingV1/GnbPcieTrainingV1.h52
-rw-r--r--src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieTrainingV1/PcieTraining.c828
-rw-r--r--src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieTrainingV1/PcieTraining.h64
-rw-r--r--src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieTrainingV1/PcieWorkarounds.c375
-rw-r--r--src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieTrainingV1/PcieWorkarounds.h56
80 files changed, 16233 insertions, 0 deletions
diff --git a/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbCableSafe/GnbCableSafe.c b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbCableSafe/GnbCableSafe.c
new file mode 100644
index 0000000000..08fd84a348
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbCableSafe/GnbCableSafe.c
@@ -0,0 +1,222 @@
+/* $NoKeywords:$ */
+/**
+ * @file
+ *
+ * Cable safe module
+ *
+ *
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: GNB
+ * @e $Revision: $ @e $Date: $
+ *
+ */
+/*
+ *****************************************************************************
+ *
+ * Copyright (c) 2011, Advanced Micro Devices, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Advanced Micro Devices, Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***************************************************************************
+ *
+ */
+
+/*----------------------------------------------------------------------------------------
+ * M O D U L E S U S E D
+ *----------------------------------------------------------------------------------------
+ */
+#include "AGESA.h"
+#include "amdlib.h"
+#include "Ids.h"
+#include "Gnb.h"
+#include "GnbPcie.h"
+#include GNB_MODULE_DEFINITIONS (GnbPcieConfig)
+#include "GnbRegistersON.h"
+#include "cpuFamilyTranslation.h"
+#include "NbSmuLib.h"
+#include "GnbCableSafeDefs.h"
+#include "Filecode.h"
+#define FILECODE PROC_GNB_MODULES_GNBCABLESAFE_GNBCABLESAFE_FILECODE
+/*----------------------------------------------------------------------------------------
+ * D E F I N I T I O N S A N D M A C R O S
+ *----------------------------------------------------------------------------------------
+ */
+
+/*----------------------------------------------------------------------------------------
+ * T Y P E D E F S A N D S T R U C T U R E S
+ *----------------------------------------------------------------------------------------
+ */
+
+
+UINT8 HdpIndexTranslationTable [] = {
+ 3, 2, 1, 0, 7, 6
+};
+
+UINT8 AuxIndexTranslationTable [] = {
+ 5, 4, 11, 10, 9, 8
+};
+
+UINT8 AuxDataTranslationTable [] = {
+ 0x10, 0x20, 0x40, 0x01, 0x02, 0x04
+};
+
+/*----------------------------------------------------------------------------------------
+ * P R O T O T Y P E S O F L O C A L F U N C T I O N S
+ *----------------------------------------------------------------------------------------
+ */
+
+VOID
+STATIC
+GnbCableSafeGetConnectorInfoArrayCallback (
+ IN PCIe_ENGINE_CONFIG *Engine,
+ IN OUT VOID *Buffer,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ );
+
+BOOLEAN
+GnbCableSafeIsSupported (
+ IN AMD_CONFIG_PARAMS *StdHeader
+ );
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Cable Safe module entry
+ *
+ *
+ *
+ * @param[in] StdHeader Standard configuration header
+ * @retval AGESA_STATUS
+ */
+
+AGESA_STATUS
+GnbCableSafeEntry (
+ IN AMD_CONFIG_PARAMS *StdHeader
+ )
+{
+ AGESA_STATUS Status;
+ PCIe_PLATFORM_CONFIG *Pcie;
+ PCIe_ENGINE_CONFIG *DdiEngineList [MaxHdp];
+ UINT8 HdpIndex;
+ UINT8 CurrentIndex;
+ GNB_CABLE_SAFE_DATA CableSafeData;
+ IDS_HDT_CONSOLE (GNB_TRACE, "GnbCableSafeEntry Enter\n");
+ Status = AGESA_SUCCESS;
+ if (GnbCableSafeIsSupported (StdHeader)) {
+ if (PcieLocateConfigurationData (StdHeader, &Pcie) == AGESA_SUCCESS) {
+ for (HdpIndex = 0; HdpIndex < MaxHdp; HdpIndex++) {
+ DdiEngineList[HdpIndex] = NULL;
+ }
+ LibAmdMemFill (&CableSafeData, 0, sizeof (CableSafeData), StdHeader);
+ PcieConfigRunProcForAllEngines (
+ DESCRIPTOR_ALLOCATED | DESCRIPTOR_DDI_ENGINE,
+ GnbCableSafeGetConnectorInfoArrayCallback,
+ DdiEngineList,
+ Pcie
+ );
+ CurrentIndex = 0;
+ for (HdpIndex = 0; HdpIndex < MaxHdp; HdpIndex++) {
+ if (DdiEngineList [HdpIndex] != NULL) {
+ CableSafeData.Data[HdpIndexTranslationTable[CurrentIndex]] = HdpIndex + 1;
+ CableSafeData.Data[AuxIndexTranslationTable[CurrentIndex]] = AuxDataTranslationTable [(DdiEngineList [HdpIndex])->Type.Ddi.DdiData.AuxIndex];
+ IDS_HDT_CONSOLE (NB_MISC, " Index [%d] HDP 0x%02x AUX 0x%02x\n", CurrentIndex, HdpIndex, (DdiEngineList [HdpIndex])->Type.Ddi.DdiData.AuxIndex);
+ CurrentIndex++;
+ }
+ }
+ CableSafeData.Config.Enable = 0x1;
+ CableSafeData.Config.DebounceFilter = 0x2;
+ CableSafeData.Config.SoftPeriod = 0x4;
+ CableSafeData.Config.Unit = 0x1;
+ CableSafeData.Config.Period = 0xf424;
+ NbSmuRcuRegisterWrite (
+ SMUx0B_x85D0_ADDRESS,
+ (UINT32*) &CableSafeData,
+ sizeof (CableSafeData) / sizeof (UINT32),
+ TRUE,
+ StdHeader
+ );
+ NbSmuServiceRequest (0x05, TRUE, StdHeader);
+ } else {
+ Status = AGESA_ERROR;
+ }
+ }
+ IDS_HDT_CONSOLE (GNB_TRACE, "GnbCableSafeEntry Exit [Status = 0x%04x]\n", Status);
+ return Status;
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Callback to init max port Gen capability
+ *
+ *
+ *
+ *
+ * @param[in] Engine Pointer to engine config descriptor
+ * @param[in, out] Buffer Not used
+ * @param[in] Pcie Pointer to global PCIe configuration
+ *
+ */
+
+VOID
+STATIC
+GnbCableSafeGetConnectorInfoArrayCallback (
+ IN PCIe_ENGINE_CONFIG *Engine,
+ IN OUT VOID *Buffer,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ PCIe_ENGINE_CONFIG **EngineList;
+ EngineList = (PCIe_ENGINE_CONFIG**) Buffer;
+ EngineList [Engine->Type.Ddi.DdiData.HdpIndex] = Engine;
+}
+
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Check if feature supported
+ *
+ * Module requre for LN B0 and above
+ *
+ *
+ * @param[in] StdHeader Standard configuration header
+ * @retval TRUE Cable safe needs to be enabled
+ */
+
+BOOLEAN
+GnbCableSafeIsSupported (
+ IN AMD_CONFIG_PARAMS *StdHeader
+ )
+{
+ BOOLEAN Result;
+ CPU_LOGICAL_ID LogicalId;
+ SMU_FIRMWARE_REV FirmwareRev;
+ Result = FALSE;
+ GetLogicalIdOfCurrentCore (&LogicalId, StdHeader);
+ FirmwareRev = NbSmuFirmwareRevision (StdHeader);
+ if (SMI_FIRMWARE_REVISION (FirmwareRev) >= 0x010904 && LogicalId.Revision > AMD_F12_LN_A1) {
+ Result = TRUE;
+ }
+ return Result;
+}
diff --git a/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbCableSafe/GnbCableSafeDefs.h b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbCableSafe/GnbCableSafeDefs.h
new file mode 100644
index 0000000000..d96fa0c71a
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbCableSafe/GnbCableSafeDefs.h
@@ -0,0 +1,66 @@
+/* $NoKeywords:$ */
+/**
+ * @file
+ *
+ * Cable safe module
+ *
+ *
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: GNB
+ * @e $Revision: $ @e $Date: $
+ *
+ */
+/*
+ *****************************************************************************
+ *
+ * Copyright (c) 2011, Advanced Micro Devices, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Advanced Micro Devices, Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***************************************************************************
+ *
+ */
+
+#ifndef _GNBCABLESAFEDEFS_H_
+#define _GNBCABLESAFEDEFS_H_
+
+#pragma pack (push, 1)
+
+/// Cable safe data package
+typedef struct {
+ struct {
+ UINT32 Enable :1; ///< Enable cable safe
+ UINT32 DebounceFilter :3; ///< Debounce filter
+ UINT32 SoftPeriod :4; ///< Soft period
+ UINT32 Unit :4; ///< Unit
+ UINT32 Reserved :4; ///< Reserved
+ UINT32 Period :16; ///< Period
+ } Config; ///< Configuration package
+ UINT8 Data [12]; ///< HDP/AUX info array
+} GNB_CABLE_SAFE_DATA;
+
+#pragma pack (pop)
+#endif
diff --git a/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbCommonLib/GnbCommonLib.h b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbCommonLib/GnbCommonLib.h
new file mode 100644
index 0000000000..b8517a00b1
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbCommonLib/GnbCommonLib.h
@@ -0,0 +1,58 @@
+/* $NoKeywords:$ */
+/**
+ * @file
+ *
+ * GNB register access services.
+ *
+ *
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: GNB
+ * @e \$Revision: 34897 $ @e \$Date: 2010-07-13 19:07:10 -0700 (Tue, 13 Jul 2010) $
+ *
+ */
+/*
+ *****************************************************************************
+ *
+ * Copyright (c) 2011, Advanced Micro Devices, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Advanced Micro Devices, Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***************************************************************************
+ *
+ */
+#ifndef _GNBCOMMONLIB_H_
+#define _GNBCOMMONLIB_H_
+
+#include "GnbLib.h"
+#include "GnbLibCpuAcc.h"
+#include "GnbLibHeap.h"
+#include "GnbLibIoAcc.h"
+#include "GnbLibMemAcc.h"
+#include "GnbLibPci.h"
+#include "GnbLibPciAcc.h"
+
+
+#endif
diff --git a/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbCommonLib/GnbLib.c b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbCommonLib/GnbLib.c
new file mode 100644
index 0000000000..5e8b67e603
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbCommonLib/GnbLib.c
@@ -0,0 +1,460 @@
+/* $NoKeywords:$ */
+/**
+ * @file
+ *
+ * GNB register access services.
+ *
+ *
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: GNB
+ * @e \$Revision: 34897 $ @e \$Date: 2010-07-13 19:07:10 -0700 (Tue, 13 Jul 2010) $
+ *
+ */
+/*
+ *****************************************************************************
+ *
+ * Copyright (c) 2011, Advanced Micro Devices, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Advanced Micro Devices, Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***************************************************************************
+ *
+ */
+
+/*----------------------------------------------------------------------------------------
+ * M O D U L E S U S E D
+ *----------------------------------------------------------------------------------------
+ */
+#include "Porting.h"
+#include "AMD.h"
+#include "amdlib.h"
+#include "Gnb.h"
+#include "GnbLib.h"
+#include "GnbLibIoAcc.h"
+#include "GnbLibPciAcc.h"
+#include "GnbLibMemAcc.h"
+#include "Filecode.h"
+#define FILECODE PROC_GNB_MODULES_GNBCOMMONLIB_GNBLIB_FILECODE
+/*----------------------------------------------------------------------------------------
+ * D E F I N I T I O N S A N D M A C R O S
+ *----------------------------------------------------------------------------------------
+ */
+
+
+/*----------------------------------------------------------------------------------------
+ * T Y P E D E F S A N D S T R U C T U R E S
+ *----------------------------------------------------------------------------------------
+ */
+
+
+/*----------------------------------------------------------------------------------------
+ * P R O T O T Y P E S O F L O C A L F U N C T I O N S
+ *----------------------------------------------------------------------------------------
+ */
+
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Read GNB indirect registers
+ *
+ *
+ *
+ * @param[in] Address PCI address of indirect register
+ * @param[in] IndirectAddress Offset of indirect register
+ * @param[in] Width Width
+ * @param[out] Value Pointer to value
+ * @param[in] Config Pointer to standard header
+ */
+VOID
+GnbLibPciIndirectRead (
+ IN UINT32 Address,
+ IN UINT32 IndirectAddress,
+ IN ACCESS_WIDTH Width,
+ OUT VOID *Value,
+ IN VOID *Config
+ )
+{
+ UINT32 IndexOffset;
+ IndexOffset = LibAmdAccessWidth (Width);
+ GnbLibPciWrite (Address, Width, &IndirectAddress, Config);
+ GnbLibPciRead (Address + IndexOffset, Width, Value, Config);
+}
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Read GNB indirect registers field
+ *
+ *
+ *
+ * @param[in] Address PCI address of indirect register
+ * @param[in] IndirectAddress Offset of indirect register
+ * @param[in] FieldOffset Field offset
+ * @param[in] FieldWidth Field width
+ * @param[out] Value Pointer to value
+ * @param[in] Config Pointer to standard header
+ */
+VOID
+GnbLibPciIndirectReadField (
+ IN UINT32 Address,
+ IN UINT32 IndirectAddress,
+ IN UINT8 FieldOffset,
+ IN UINT8 FieldWidth,
+ OUT UINT32 *Value,
+ IN VOID *Config
+ )
+{
+ UINT32 Mask;
+ GnbLibPciIndirectRead (Address, IndirectAddress, AccessWidth32, Value, Config);
+ Mask = (1 << FieldWidth) - 1;
+ *Value = (*Value >> FieldOffset) & Mask;
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Write GNB indirect registers
+ *
+ *
+ *
+ * @param[in] Address PCI address of indirect register
+ * @param[in] IndirectAddress Offset of indirect register
+ * @param[in] Width Width
+ * @param[in] Value Pointer to value
+ * @param[in] Config Pointer to standard header
+ */
+
+VOID
+GnbLibPciIndirectWrite (
+ IN UINT32 Address,
+ IN UINT32 IndirectAddress,
+ IN ACCESS_WIDTH Width,
+ IN VOID *Value,
+ IN VOID *Config
+ )
+{
+ UINT32 IndexOffset;
+ IndexOffset = LibAmdAccessWidth (Width);
+ GnbLibPciWrite (Address, Width, &IndirectAddress, Config);
+ GnbLibPciWrite (Address + IndexOffset, Width, Value, Config);
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Write GNB indirect registers field
+ *
+ *
+ *
+ * @param[in] Address PCI address of indirect register
+ * @param[in] IndirectAddress Offset of indirect register
+ * @param[in] FieldOffset Field offset
+ * @param[in] FieldWidth Field width
+ * @param[in] Value Pointer to value
+ * @param[in] S3Save Save for S3 (TRUE/FALSE)
+ * @param[in] Config Pointer to standard header
+ */
+VOID
+GnbLibPciIndirectWriteField (
+ IN UINT32 Address,
+ IN UINT32 IndirectAddress,
+ IN UINT8 FieldOffset,
+ IN UINT8 FieldWidth,
+ IN UINT32 Value,
+ IN BOOLEAN S3Save,
+ IN VOID *Config
+ )
+{
+ UINT32 Data;
+ UINT32 Mask;
+ GnbLibPciIndirectRead (Address, IndirectAddress, AccessWidth32, &Data, Config);
+ Mask = (1 << FieldWidth) - 1;
+ Data &= (~(Mask << FieldOffset));
+ Data |= ((Value & Mask) << FieldOffset);
+ GnbLibPciIndirectWrite (Address, IndirectAddress, S3Save ? AccessS3SaveWidth32 : AccessWidth32, &Data, Config);
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Read/Modify/Write GNB indirect registers field
+ *
+ *
+ *
+ * @param[in] Address PCI address of indirect register
+ * @param[in] IndirectAddress Offset of indirect register
+ * @param[in] Width Width
+ * @param[in] Mask And Mask
+ * @param[in] Value Or Value
+ * @param[in] Config Pointer to standard header
+ */
+VOID
+GnbLibPciIndirectRMW (
+ IN UINT32 Address,
+ IN UINT32 IndirectAddress,
+ IN ACCESS_WIDTH Width,
+ IN UINT32 Mask,
+ IN UINT32 Value,
+ IN VOID *Config
+ )
+{
+ UINT32 Data;
+ GnbLibPciIndirectRead (
+ Address,
+ IndirectAddress,
+ (Width >= AccessS3SaveWidth8) ? (Width - (AccessS3SaveWidth8 - AccessWidth8)) : Width,
+ &Data,
+ Config
+ );
+ Data = (Data & Mask) | Value;
+ GnbLibPciIndirectWrite (Address, IndirectAddress, Width, &Data, Config);
+}
+
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Read/Modify/Write PCI registers
+ *
+ *
+ *
+ * @param[in] Address PCI address
+ * @param[in] Width Access width
+ * @param[in] Mask AND Mask
+ * @param[in] Value OR Value
+ * @param[in] Config Pointer to standard header
+ */
+VOID
+GnbLibPciRMW (
+ IN UINT32 Address,
+ IN ACCESS_WIDTH Width,
+ IN UINT32 Mask,
+ IN UINT32 Value,
+ IN VOID *Config
+ )
+{
+ UINT32 Data;
+ GnbLibPciRead (Address, Width, &Data, Config);
+ Data = (Data & Mask) | Value;
+ GnbLibPciWrite (Address, Width, &Data, Config);
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Read/Modify/Write I/O registers
+ *
+ *
+ *
+ * @param[in] Address I/O Port
+ * @param[in] Width Access width
+ * @param[in] Mask AND Mask
+ * @param[in] Value OR Mask
+ * @param[in] Config Pointer to standard header
+ */
+VOID
+GnbLibIoRMW (
+ IN UINT16 Address,
+ IN ACCESS_WIDTH Width,
+ IN UINT32 Mask,
+ IN UINT32 Value,
+ IN VOID *Config
+ )
+{
+ UINT32 Data;
+ GnbLibIoRead (Address, Width, &Data, Config);
+ Data = (Data & Mask) | Value;
+ GnbLibIoWrite (Address, Width, &Data, Config);
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Read/Modify/Write MMIO registers
+ *
+ *
+ *
+ * @param[in] Address Physical address
+ * @param[in] Width Access width
+ * @param[in] Mask AND Mask
+ * @param[in] Value OR Value
+ * @param[in] Config Pointer to standard header
+ */
+VOID
+GnbLibMemRMW (
+ IN UINT64 Address,
+ IN ACCESS_WIDTH Width,
+ IN UINT32 Mask,
+ IN UINT32 Value,
+ IN VOID *Config
+ )
+{
+ UINT32 Data;
+ GnbLibMemRead (Address, Width, &Data, Config);
+ Data = (Data & Mask) | Value;
+ GnbLibMemWrite (Address, Width, &Data, Config);
+}
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Get number of sockets
+ *
+ *
+ *
+ * @param[in] StdHeader Standard configuration header
+ * @retval Total number of socket on platform
+ */
+
+UINT32
+GnbGetNumberOfSockets (
+ IN AMD_CONFIG_PARAMS *StdHeader
+ )
+{
+ return 1;
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Get number of Silicons on the socket
+ *
+ *
+ *
+ * @param[in] SiliconId Socket ID
+ * @param[in] StdHeader Standard configuration header
+ * @retval Number of silicons/modules in device in socket
+ */
+
+UINT32
+GnbGetNumberOfSiliconsOnSocket (
+ IN UINT32 SiliconId,
+ IN AMD_CONFIG_PARAMS *StdHeader
+ )
+{
+ return 1;
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Get PCI Address
+ *
+ *
+ *
+ * @param[in] SocketId Socket ID
+ * @param[in] SiliconId Silicon device Id
+ * @param[in] StdHeader Standard configuration header
+ * @retval PCI address of GNB for a given socket/silicon.
+ */
+
+PCI_ADDR
+GnbGetPciAddress (
+ IN UINT32 SocketId,
+ IN UINT32 SiliconId,
+ IN AMD_CONFIG_PARAMS *StdHeader
+ )
+{
+ PCI_ADDR Gnb;
+ Gnb.AddressValue = MAKE_SBDFO (0, 0, 0, 0, 0);
+ return Gnb;
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Check if anything plugged in socket
+ *
+ *
+ *
+ * @param[in] SocketId Socket ID
+ * @param[in] StdHeader Standard configuration header
+ * @retval TRUE CPU present in socket.
+ */
+
+BOOLEAN
+GnbIsDevicePresentInSocket (
+ IN UINT32 SocketId,
+ IN AMD_CONFIG_PARAMS *StdHeader
+ )
+{
+ return TRUE;
+}
+
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Claculate power of number
+ *
+ *
+ *
+ * @param[in] Value Number
+ * @param[in] Power Power
+ */
+
+UINT32
+GnbLibPowerOf (
+ IN UINT32 Value,
+ IN UINT32 Power
+ )
+{
+ UINT32 Result;
+ if (Power == 0) {
+ return 1;
+ }
+ Result = Value;
+ while ((--Power) > 0) {
+ Result *= Value;
+ }
+ return Result;
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Search buffer for pattern
+ *
+ *
+ * @param[in] Buf1 Pointer to source buffer which will be subject of search
+ * @param[in] Buf1Length Length of the source buffer
+ * @param[in] Buf2 Pointer to pattern buffer
+ * @param[in] Buf2Length Length of the pattern buffer
+ * @retval Pointer on first accurance of Buf2 in Buf1 or NULL
+ */
+
+VOID*
+GnbLibFind (
+ IN UINT8 *Buf1,
+ IN UINTN Buf1Length,
+ IN UINT8 *Buf2,
+ IN UINTN Buf2Length
+ )
+{
+ UINT8 *CurrentBuf1Ptr;
+ CurrentBuf1Ptr = Buf1;
+ while (CurrentBuf1Ptr < (Buf1 + Buf1Length - Buf2Length)) {
+ UINT8 *SourceBufPtr;
+ UINT8 *PatternBufPtr;
+ UINTN PatternBufLength;
+ SourceBufPtr = CurrentBuf1Ptr;
+ PatternBufPtr = Buf2;
+ PatternBufLength = Buf2Length;
+ while ((*SourceBufPtr++ == *PatternBufPtr++) && (PatternBufLength-- != 0));
+ if (PatternBufLength == 0) {
+ return CurrentBuf1Ptr;
+ }
+ CurrentBuf1Ptr++;
+ }
+ return NULL;
+}
+
+
diff --git a/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbCommonLib/GnbLib.h b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbCommonLib/GnbLib.h
new file mode 100644
index 0000000000..6b106b00a4
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbCommonLib/GnbLib.h
@@ -0,0 +1,148 @@
+/* $NoKeywords:$ */
+/**
+ * @file
+ *
+ * GNB register access services.
+ *
+ *
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: GNB
+ * @e \$Revision: 34897 $ @e \$Date: 2010-07-13 19:07:10 -0700 (Tue, 13 Jul 2010) $
+ *
+ */
+/*
+ *****************************************************************************
+ *
+ * Copyright (c) 2011, Advanced Micro Devices, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Advanced Micro Devices, Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***************************************************************************
+ *
+ */
+#ifndef _GNBLIB_H_
+#define _GNBLIB_H_
+
+#define IOC_WRITE_ENABLE 0x80
+
+
+VOID
+GnbLibPciIndirectWrite (
+ IN UINT32 Address,
+ IN UINT32 IndirectAddress,
+ IN ACCESS_WIDTH Width,
+ IN VOID *Value,
+ IN VOID *Config
+ );
+
+VOID
+GnbLibPciIndirectRead (
+ IN UINT32 Address,
+ IN UINT32 IndirectAddress,
+ IN ACCESS_WIDTH Width,
+ OUT VOID *Value,
+ IN VOID *Config
+ );
+
+VOID
+GnbLibPciIndirectRMW (
+ IN UINT32 Address,
+ IN UINT32 IndirectAddress,
+ IN ACCESS_WIDTH Width,
+ IN UINT32 Mask,
+ IN UINT32 Value,
+ IN VOID *Config
+ );
+
+VOID
+GnbLibPciIndirectWriteField (
+ IN UINT32 Address,
+ IN UINT32 IndirectAddress,
+ IN UINT8 FieldOffset,
+ IN UINT8 FieldWidth,
+ IN UINT32 Value,
+ IN BOOLEAN S3Save,
+ IN VOID *Config
+ );
+
+
+VOID
+GnbLibPciRMW (
+ IN UINT32 Address,
+ IN ACCESS_WIDTH Width,
+ IN UINT32 Mask,
+ IN UINT32 Value,
+ IN VOID *Config
+ );
+
+VOID
+GnbLibIoRMW (
+ IN UINT16 Address,
+ IN ACCESS_WIDTH Width,
+ IN UINT32 Mask,
+ IN UINT32 Value,
+ IN VOID *Config
+ );
+
+UINT32
+GnbGetNumberOfSockets (
+ IN AMD_CONFIG_PARAMS *StdHeader
+ );
+
+UINT32
+GnbGetNumberOfSiliconsOnSocket (
+ IN UINT32 SiliconId,
+ IN AMD_CONFIG_PARAMS *StdHeader
+ );
+
+BOOLEAN
+GnbIsDevicePresentInSocket (
+ IN UINT32 SocketId,
+ IN AMD_CONFIG_PARAMS *StdHeader
+ );
+
+PCI_ADDR
+GnbGetPciAddress (
+ IN UINT32 SocketId,
+ IN UINT32 SiliconId,
+ IN AMD_CONFIG_PARAMS *StdHeader
+ );
+
+UINT32
+GnbLibPowerOf (
+ IN UINT32 Value,
+ IN UINT32 Power
+ );
+
+VOID*
+GnbLibFind (
+ IN UINT8 *Buf1,
+ IN UINTN Buf1Length,
+ IN UINT8 *Buf2,
+ IN UINTN Buf2Length
+ );
+
+#endif
diff --git a/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbCommonLib/GnbLibCpuAcc.c b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbCommonLib/GnbLibCpuAcc.c
new file mode 100644
index 0000000000..8b9b93f428
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbCommonLib/GnbLibCpuAcc.c
@@ -0,0 +1,130 @@
+/* $NoKeywords:$ */
+/**
+ * @file
+ *
+ * Service procedure to access various CPU registers.
+ *
+ *
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: GNB
+ * @e \$Revision: 34897 $ @e \$Date: 2010-07-13 19:07:10 -0700 (Tue, 13 Jul 2010) $
+ *
+ */
+/*
+ *****************************************************************************
+ *
+ * Copyright (c) 2011, Advanced Micro Devices, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Advanced Micro Devices, Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***************************************************************************
+ *
+ */
+
+/*----------------------------------------------------------------------------------------
+ * M O D U L E S U S E D
+ *----------------------------------------------------------------------------------------
+ */
+#include "Porting.h"
+#include "AMD.h"
+#include "GnbLibPciAcc.h"
+#include "Filecode.h"
+#define FILECODE PROC_GNB_MODULES_GNBCOMMONLIB_GNBLIBCPUACC_FILECODE
+/*----------------------------------------------------------------------------------------
+ * D E F I N I T I O N S A N D M A C R O S
+ *----------------------------------------------------------------------------------------
+ */
+
+
+/*----------------------------------------------------------------------------------------
+ * T Y P E D E F S A N D S T R U C T U R E S
+ *----------------------------------------------------------------------------------------
+ */
+
+
+/*----------------------------------------------------------------------------------------
+ * P R O T O T Y P E S O F L O C A L F U N C T I O N S
+ *----------------------------------------------------------------------------------------
+ */
+
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Read CPU (DCT) indirect registers
+ *
+ *
+ *
+ * @param[in] Address PCI address of DCT register
+ * @param[in] IndirectAddress Offset of DCT register
+ * @param[out] Value Pointer to value
+ * @param[in] Config Pointer to standard header
+ */
+VOID
+GnbLibCpuPciIndirectRead (
+ IN UINT32 Address,
+ IN UINT32 IndirectAddress,
+ OUT UINT32 *Value,
+ IN VOID *Config
+ )
+{
+ UINT32 OffsetRegisterValue;
+ GnbLibPciWrite (Address, AccessWidth32, &IndirectAddress, Config);
+ do {
+ GnbLibPciRead (Address , AccessWidth32, &OffsetRegisterValue, Config);
+ } while ((OffsetRegisterValue & BIT31) == 0);
+ GnbLibPciRead (Address + 4, AccessWidth32, Value, Config);
+}
+
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Write CPU (DCT) indirect registers
+ *
+ *
+ *
+ * @param[in] Address PCI address of DCT register
+ * @param[in] IndirectAddress Offset of DCT register
+ * @param[in] Value Pointer to value
+ * @param[in] Config Pointer to standard header
+ */
+VOID
+GnbLibCpuPciIndirectWrite (
+ IN UINT32 Address,
+ IN UINT32 IndirectAddress,
+ IN UINT32 *Value,
+ IN VOID *Config
+ )
+{
+ UINT32 OffsetRegisterValue;
+ OffsetRegisterValue = IndirectAddress | BIT30;
+ GnbLibPciWrite (Address + 4, AccessWidth32, Value, Config);
+ GnbLibPciWrite (Address, AccessWidth32, &IndirectAddress, Config);
+ do {
+ GnbLibPciRead (Address , AccessWidth32, &OffsetRegisterValue, Config);
+ } while ((OffsetRegisterValue & BIT31) == 0);
+}
+
+
diff --git a/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbCommonLib/GnbLibCpuAcc.h b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbCommonLib/GnbLibCpuAcc.h
new file mode 100644
index 0000000000..b403d70af5
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbCommonLib/GnbLibCpuAcc.h
@@ -0,0 +1,66 @@
+/* $NoKeywords:$ */
+/**
+ * @file
+ *
+ * Service procedure to access various CPU registers.
+ *
+ *
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: GNB
+ * @e \$Revision: 34897 $ @e \$Date: 2010-07-13 19:07:10 -0700 (Tue, 13 Jul 2010) $
+ *
+ */
+/*
+ *****************************************************************************
+ *
+ * Copyright (c) 2011, Advanced Micro Devices, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Advanced Micro Devices, Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***************************************************************************
+ *
+ */
+#ifndef _CPUACCLIB_H_
+#define _CPUACCLIB_H_
+
+VOID
+GnbLibCpuPciIndirectWrite (
+ IN UINT32 Address,
+ IN UINT32 IndirectAddress,
+ IN UINT32 *Value,
+ IN VOID *Config
+ );
+
+VOID
+GnbLibCpuPciIndirectRead (
+ IN UINT32 Address,
+ IN UINT32 IndirectAddress,
+ OUT UINT32 *Value,
+ IN VOID *Config
+ );
+
+
+#endif
diff --git a/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbCommonLib/GnbLibHeap.c b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbCommonLib/GnbLibHeap.c
new file mode 100644
index 0000000000..5890ffe3a4
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbCommonLib/GnbLibHeap.c
@@ -0,0 +1,129 @@
+/* $NoKeywords:$ */
+/**
+ * @file
+ *
+ * Service procedure to access heap.
+ *
+ *
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: GNB
+ * @e \$Revision: 34897 $ @e \$Date: 2010-07-13 19:07:10 -0700 (Tue, 13 Jul 2010) $
+ *
+ */
+/*
+ *****************************************************************************
+ *
+ * Copyright (c) 2011, Advanced Micro Devices, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Advanced Micro Devices, Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***************************************************************************
+ *
+ */
+
+/*----------------------------------------------------------------------------------------
+ * M O D U L E S U S E D
+ *----------------------------------------------------------------------------------------
+ */
+#include "Porting.h"
+#include "AMD.h"
+#include "heapManager.h"
+#include "GnbLibPciAcc.h"
+#include "Filecode.h"
+#define FILECODE PROC_GNB_MODULES_GNBCOMMONLIB_GNBLIBHEAP_FILECODE
+/*----------------------------------------------------------------------------------------
+ * D E F I N I T I O N S A N D M A C R O S
+ *----------------------------------------------------------------------------------------
+ */
+
+
+/*----------------------------------------------------------------------------------------
+ * T Y P E D E F S A N D S T R U C T U R E S
+ *----------------------------------------------------------------------------------------
+ */
+
+
+/*---------------------------------------------------------------------------------------*/
+/**
+ * Allocates space for a new buffer in the heap
+ *
+ *
+ * @param[in] Handle Buffer handle
+ * @param[in] Length Buffer length
+ * @param[in] StdHeader Standard configuration header
+ *
+ * @retval NULL Buffer allocation fail
+ *
+ */
+
+VOID*
+GnbAllocateHeapBuffer (
+ IN UINT32 Handle,
+ IN UINTN Length,
+ IN AMD_CONFIG_PARAMS *StdHeader
+ )
+{
+ AGESA_STATUS Status;
+ ALLOCATE_HEAP_PARAMS AllocHeapParams;
+
+ AllocHeapParams.RequestedBufferSize = (UINT32) Length;
+ AllocHeapParams.BufferHandle = Handle;
+ AllocHeapParams.Persist = HEAP_SYSTEM_MEM;
+ Status = HeapAllocateBuffer (&AllocHeapParams, StdHeader);
+ if (Status != AGESA_SUCCESS) {
+ return NULL;
+ }
+ return AllocHeapParams.BufferPtr;
+}
+
+/*---------------------------------------------------------------------------------------*/
+/**
+ * Locates a previously allocated buffer on the heap.
+ *
+ *
+ * @param[in] Handle Buffer handle
+ * @param[in] StdHeader Standard configuration header
+ *
+ * @retval NULL Buffer handle not found
+ *
+ */
+
+VOID *
+GnbLocateHeapBuffer (
+ IN UINT32 Handle,
+ IN AMD_CONFIG_PARAMS *StdHeader
+ )
+{
+ AGESA_STATUS Status;
+ LOCATE_HEAP_PTR LocHeapParams;
+ LocHeapParams.BufferHandle = Handle;
+ Status = HeapLocateBuffer (&LocHeapParams, StdHeader);
+ if (Status != AGESA_SUCCESS) {
+ return NULL;
+ }
+ return LocHeapParams.BufferPtr;
+}
+
diff --git a/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbCommonLib/GnbLibHeap.h b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbCommonLib/GnbLibHeap.h
new file mode 100644
index 0000000000..01c4fd00f6
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbCommonLib/GnbLibHeap.h
@@ -0,0 +1,63 @@
+/* $NoKeywords:$ */
+/**
+ * @file
+ *
+ * Service procedure to access heap.
+ *
+ *
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: GNB
+ * @e \$Revision: 34897 $ @e \$Date: 2010-07-13 19:07:10 -0700 (Tue, 13 Jul 2010) $
+ *
+ */
+/*
+ *****************************************************************************
+ *
+ * Copyright (c) 2011, Advanced Micro Devices, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Advanced Micro Devices, Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***************************************************************************
+ *
+ */
+
+#ifndef _GNBHEAPLIB_H_
+#define _GNBHEAPLIB_H_
+
+VOID *
+GnbAllocateHeapBuffer (
+ IN UINT32 Handle,
+ IN UINTN Length,
+ IN AMD_CONFIG_PARAMS *StdHeader
+ );
+
+VOID *
+GnbLocateHeapBuffer (
+ IN UINT32 Handle,
+ IN AMD_CONFIG_PARAMS *StdHeader
+ );
+
+#endif
diff --git a/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbCommonLib/GnbLibIoAcc.c b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbCommonLib/GnbLibIoAcc.c
new file mode 100644
index 0000000000..d7d5242ac9
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbCommonLib/GnbLibIoAcc.c
@@ -0,0 +1,123 @@
+/* $NoKeywords:$ */
+/**
+ * @file
+ *
+* Service procedure to access I/O registers.
+ *
+ *
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: GNB
+ * @e \$Revision: 34897 $ @e \$Date: 2010-07-13 19:07:10 -0700 (Tue, 13 Jul 2010) $
+ *
+ */
+/*
+ *****************************************************************************
+ *
+ * Copyright (c) 2011, Advanced Micro Devices, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Advanced Micro Devices, Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***************************************************************************
+ *
+ */
+
+/*----------------------------------------------------------------------------------------
+ * M O D U L E S U S E D
+ *----------------------------------------------------------------------------------------
+ */
+#include "Porting.h"
+#include "AMD.h"
+#include "amdlib.h"
+#include "GnbLibIoAcc.h"
+#include "S3SaveState.h"
+#include "Filecode.h"
+#define FILECODE PROC_GNB_MODULES_GNBCOMMONLIB_GNBLIBIOACC_FILECODE
+/*----------------------------------------------------------------------------------------
+ * D E F I N I T I O N S A N D M A C R O S
+ *----------------------------------------------------------------------------------------
+ */
+
+
+/*----------------------------------------------------------------------------------------
+ * T Y P E D E F S A N D S T R U C T U R E S
+ *----------------------------------------------------------------------------------------
+ */
+
+
+/*----------------------------------------------------------------------------------------
+ * P R O T O T Y P E S O F L O C A L F U N C T I O N S
+ *----------------------------------------------------------------------------------------
+ */
+/*----------------------------------------------------------------------------------------*/
+
+/*---------------------------------------------------------------------------------------*/
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Write I/O Port
+ *
+ *
+ *
+ * @param[in] Address Physical Address
+ * @param[in] Width Access width
+ * @param[in] Value Pointer to value
+ * @param[in] StdHeader Standard configuration header
+ */
+
+VOID
+GnbLibIoWrite (
+ IN UINT16 Address,
+ IN ACCESS_WIDTH Width,
+ IN VOID *Value,
+ IN VOID *StdHeader
+ )
+{
+ if (Width >= AccessS3SaveWidth8) {
+ S3_SAVE_IO_WRITE (StdHeader, Address, Width, Value);
+ }
+ LibAmdIoWrite (Width, Address, Value, StdHeader);
+}
+/**
+ * Read IO port
+ *
+ *
+ *
+ * @param[in] Address Physical Address
+ * @param[in] Width Access width
+ * @param[out] Value Pointer to value
+ * @param[in] StdHeader Standard configuration header
+ */
+
+VOID
+GnbLibIoRead (
+ IN UINT16 Address,
+ IN ACCESS_WIDTH Width,
+ OUT VOID *Value,
+ IN VOID *StdHeader
+ )
+{
+ LibAmdIoRead (Width, Address, Value, StdHeader);
+}
+
diff --git a/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbCommonLib/GnbLibIoAcc.h b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbCommonLib/GnbLibIoAcc.h
new file mode 100644
index 0000000000..9c0f4a6d9c
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbCommonLib/GnbLibIoAcc.h
@@ -0,0 +1,67 @@
+/* $NoKeywords:$ */
+/**
+ * @file
+ *
+ * Service procedure to access I/O registers.
+ *
+ *
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: GNB
+ * @e \$Revision: 34897 $ @e \$Date: 2010-07-13 19:07:10 -0700 (Tue, 13 Jul 2010) $
+ *
+ */
+/*
+ *****************************************************************************
+ *
+ * Copyright (c) 2011, Advanced Micro Devices, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Advanced Micro Devices, Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***************************************************************************
+ *
+ */
+#ifndef _IOACCLIB_H_
+#define _IOACCLIB_H_
+
+
+VOID
+GnbLibIoWrite (
+ IN UINT16 Address,
+ IN ACCESS_WIDTH Width,
+ IN VOID *Value,
+ IN VOID *StdHeader
+ );
+
+VOID
+GnbLibIoRead (
+ IN UINT16 Address,
+ IN ACCESS_WIDTH Width,
+ OUT VOID *Value,
+ IN VOID *StdHeader
+ );
+
+
+#endif
diff --git a/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbCommonLib/GnbLibMemAcc.c b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbCommonLib/GnbLibMemAcc.c
new file mode 100644
index 0000000000..019d70501b
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbCommonLib/GnbLibMemAcc.c
@@ -0,0 +1,126 @@
+/* $NoKeywords:$ */
+/**
+ * @file
+ *
+ * Service procedure to access MMIO registers.
+ *
+ *
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: GNB
+ * @e \$Revision: 34897 $ @e \$Date: 2010-07-13 19:07:10 -0700 (Tue, 13 Jul 2010) $
+ *
+ */
+/*
+ *****************************************************************************
+ *
+ * Copyright (c) 2011, Advanced Micro Devices, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Advanced Micro Devices, Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***************************************************************************
+ *
+ */
+
+/*----------------------------------------------------------------------------------------
+ * M O D U L E S U S E D
+ *----------------------------------------------------------------------------------------
+ */
+#include "Porting.h"
+#include "AMD.h"
+#include "amdlib.h"
+#include "GnbLibMemAcc.h"
+#include "S3SaveState.h"
+#include "Filecode.h"
+#define FILECODE PROC_GNB_MODULES_GNBCOMMONLIB_GNBLIBMEMACC_FILECODE
+/*----------------------------------------------------------------------------------------
+ * D E F I N I T I O N S A N D M A C R O S
+ *----------------------------------------------------------------------------------------
+ */
+
+
+/*----------------------------------------------------------------------------------------
+ * T Y P E D E F S A N D S T R U C T U R E S
+ *----------------------------------------------------------------------------------------
+ */
+
+
+/*----------------------------------------------------------------------------------------
+ * P R O T O T Y P E S O F L O C A L F U N C T I O N S
+ *----------------------------------------------------------------------------------------
+ */
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Write Memory/MMIO registers
+ *
+ *
+ *
+ * @param[in] Address Physical Address
+ * @param[in] Width Access width
+ * @param[in] Value Pointer to value
+ * @param[in] StdHeader Standard configuration header
+ */
+
+VOID
+GnbLibMemWrite (
+ IN UINT64 Address,
+ IN ACCESS_WIDTH Width,
+ IN VOID *Value,
+ IN VOID *StdHeader
+ )
+{
+ if (Width >= AccessS3SaveWidth8) {
+ S3_SAVE_MEM_WRITE (StdHeader, Address, Width, Value);
+ }
+ LibAmdMemWrite (Width, Address, Value, StdHeader);
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Read Memory/MMIO registers
+ *
+ *
+ *
+ * @param[in] Address Physical Address
+ * @param[in] Width Access width
+ * @param[out] Value Pointer to value
+ * @param[in] StdHeader Standard configuration header
+ */
+
+VOID
+GnbLibMemRead (
+ IN UINT64 Address,
+ IN ACCESS_WIDTH Width,
+ OUT VOID *Value,
+ IN VOID *StdHeader
+ )
+{
+ LibAmdMemRead (Width, Address, Value, StdHeader);
+}
+
+
+
+
diff --git a/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbCommonLib/GnbLibMemAcc.h b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbCommonLib/GnbLibMemAcc.h
new file mode 100644
index 0000000000..7acb7cd8a9
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbCommonLib/GnbLibMemAcc.h
@@ -0,0 +1,74 @@
+/* $NoKeywords:$ */
+/**
+ * @file
+ *
+ * Service procedure to access MMIO registers.
+ *
+ *
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: GNB
+ * @e \$Revision: 34897 $ @e \$Date: 2010-07-13 19:07:10 -0700 (Tue, 13 Jul 2010) $
+ *
+ */
+/*
+ *****************************************************************************
+ *
+ * Copyright (c) 2011, Advanced Micro Devices, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Advanced Micro Devices, Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***************************************************************************
+ *
+ */
+#ifndef _MEMACCLIB_H_
+#define _MEMACCLIB_H_
+
+VOID
+GnbLibMemWrite (
+ IN UINT64 Address,
+ IN ACCESS_WIDTH Width,
+ IN VOID *Value,
+ IN VOID *StdHeader
+ );
+
+VOID
+GnbLibMemRead (
+ IN UINT64 Address,
+ IN ACCESS_WIDTH Width,
+ OUT VOID *Value,
+ IN VOID *StdHeader
+ );
+
+VOID
+GnbLibMemRMW (
+ IN UINT64 Address,
+ IN ACCESS_WIDTH Width,
+ IN UINT32 Mask,
+ IN UINT32 Value,
+ IN VOID *Config
+ );
+
+#endif
diff --git a/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbCommonLib/GnbLibPci.c b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbCommonLib/GnbLibPci.c
new file mode 100644
index 0000000000..8c02a9b569
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbCommonLib/GnbLibPci.c
@@ -0,0 +1,405 @@
+/* $NoKeywords:$ */
+/**
+ * @file
+ *
+ * Various PCI service routines.
+ *
+ *
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: GNB
+ * @e \$Revision: 34897 $ @e \$Date: 2010-07-13 19:07:10 -0700 (Tue, 13 Jul 2010) $
+ *
+ */
+/*
+ *****************************************************************************
+ *
+ * Copyright (c) 2011, Advanced Micro Devices, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Advanced Micro Devices, Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***************************************************************************
+ *
+ */
+
+
+#include "Porting.h"
+#include "AMD.h"
+#include "GnbLibPciAcc.h"
+#include "GnbLibPci.h"
+#include "GnbLibPci.h"
+#include "amdlib.h"
+#include "GnbLib.h"
+#include "Filecode.h"
+#define FILECODE PROC_GNB_MODULES_GNBCOMMONLIB_GNBLIBPCI_FILECODE
+
+/*----------------------------------------------------------------------------------------*/
+/*
+ * Check if device present
+ *
+ *
+ *
+ * @param[in] Address PCI address (as described in PCI_ADDR)
+ * @param[in] StdHeader Standard configuration header
+ * @retval TRUE Device is present
+ * @retval FALSE Device is not present
+ */
+
+BOOLEAN
+GnbLibPciIsDevicePresent (
+ IN UINT32 Address,
+ IN AMD_CONFIG_PARAMS *StdHeader
+ )
+{
+ UINT32 DeviceId;
+ GnbLibPciRead (Address, AccessWidth32, &DeviceId, StdHeader);
+ if (DeviceId == 0xffffffff) {
+ return FALSE;
+ } else {
+ return TRUE;
+ }
+}
+
+
+/*----------------------------------------------------------------------------------------*/
+/*
+ * Check if device is bridge
+ *
+ *
+ *
+ * @param[in] Address PCI address (as described in PCI_ADDR)
+ * @param[in] StdHeader Standard configuration header
+ * @retval TRUE Device is a bridge
+ * @retval FALSE Device is not a bridge
+ */
+
+BOOLEAN
+GnbLibPciIsBridgeDevice (
+ IN UINT32 Address,
+ IN AMD_CONFIG_PARAMS *StdHeader
+ )
+{
+ UINT8 Header;
+ GnbLibPciRead (Address | 0xe, AccessWidth8, &Header, StdHeader);
+ if ((Header & 0x7f) == 1) {
+ return TRUE;
+ } else {
+ return FALSE;
+ }
+}
+
+/*----------------------------------------------------------------------------------------*/
+/*
+ * Check if device is multifunction
+ *
+ *
+ *
+ * @param[in] Address PCI address (as described in PCI_ADDR)
+ * @param[in] StdHeader Standard configuration header
+ * @retval TRUE Device is a multifunction device.
+ * @retval FALSE Device is a single function device.
+ *
+ */
+BOOLEAN
+GnbLibPciIsMultiFunctionDevice (
+ IN UINT32 Address,
+ IN AMD_CONFIG_PARAMS *StdHeader
+ )
+{
+ UINT8 Header;
+ GnbLibPciRead (Address | 0xe, AccessWidth8, &Header, StdHeader);
+ if ((Header & 0x80) != 0) {
+ return TRUE;
+ } else {
+ return FALSE;
+ }
+}
+
+/*----------------------------------------------------------------------------------------*/
+/*
+ * Check if device is PCIe device
+ *
+ *
+ *
+ * @param[in] Address PCI address (as described in PCI_ADDR)
+ * @param[in] StdHeader Standard configuration header
+ * @retval TRUE Device is a PCIe device
+ * @retval FALSE Device is not a PCIe device
+ *
+ */
+
+BOOLEAN
+GnbLibPciIsPcieDevice (
+ IN UINT32 Address,
+ IN AMD_CONFIG_PARAMS *StdHeader
+ )
+{
+ if (GnbLibFindPciCapability (Address, 0x10, StdHeader) != 0 ) {
+ return TRUE;
+ } else {
+ return FALSE;
+ }
+}
+
+
+/*----------------------------------------------------------------------------------------*/
+/*
+ * Find PCI capability pointer
+ *
+ *
+ *
+ * @param[in] Address PCI address (as described in PCI_ADDR)
+ * @param[in] CapabilityId PCI capability ID
+ * @param[in] StdHeader Standard configuration header
+ * @retval Register address of capability pointer
+ *
+ */
+
+UINT8
+GnbLibFindPciCapability (
+ IN UINT32 Address,
+ IN UINT8 CapabilityId,
+ IN AMD_CONFIG_PARAMS *StdHeader
+ )
+{
+ UINT8 CapabilityPtr;
+ UINT8 CurrentCapabilityId;
+ CapabilityPtr = 0x34;
+ if (!GnbLibPciIsDevicePresent (Address, StdHeader)) {
+ return 0;
+ }
+ while (CapabilityPtr != 0) {
+ GnbLibPciRead (Address | CapabilityPtr, AccessWidth8 , &CapabilityPtr, StdHeader);
+ if (CapabilityPtr != 0) {
+ GnbLibPciRead (Address | CapabilityPtr , AccessWidth8 , &CurrentCapabilityId, StdHeader);
+ if (CurrentCapabilityId == CapabilityId) {
+ break;
+ }
+ CapabilityPtr++;
+ }
+ }
+ return CapabilityPtr;
+}
+/*----------------------------------------------------------------------------------------*/
+/*
+ * Find PCIe extended capability pointer
+ *
+ *
+ *
+ * @param[in] Address PCI address (as described in PCI_ADDR)
+ * @param[in] ExtendedCapabilityId Extended PCIe capability ID
+ * @param[in] StdHeader Standard configuration header
+ * @retval Register address of extended capability pointer
+ *
+ */
+
+
+UINT16
+GnbLibFindPcieExtendedCapability (
+ IN UINT32 Address,
+ IN UINT16 ExtendedCapabilityId,
+ IN AMD_CONFIG_PARAMS *StdHeader
+ )
+{
+ UINT16 CapabilityPtr;
+ UINT32 ExtendedCapabilityIdBlock;
+ if (GnbLibPciIsPcieDevice (Address, StdHeader)) {
+ GnbLibPciRead (Address | 0x100 , AccessWidth32 , &ExtendedCapabilityIdBlock, StdHeader);
+ if ((ExtendedCapabilityIdBlock != 0) && ((UINT16)ExtendedCapabilityIdBlock != 0xffff)) {
+ do {
+ CapabilityPtr = (UINT16) ((ExtendedCapabilityIdBlock >> 20) & 0xfff);
+ if ((UINT16)ExtendedCapabilityIdBlock == ExtendedCapabilityId) {
+ return CapabilityPtr;
+ }
+ GnbLibPciRead (Address | CapabilityPtr , AccessWidth32 , &ExtendedCapabilityIdBlock, StdHeader);
+ } while (((ExtendedCapabilityIdBlock >> 20) & 0xfff) != 0);
+ }
+ }
+ return 0;
+}
+
+/*----------------------------------------------------------------------------------------*/
+/*
+ * Scan range of device on PCI bus.
+ *
+ *
+ *
+ * @param[in] Start Start address to start scan from
+ * @param[in] End End address of scan
+ * @param[in] ScanData Supporting data
+ *
+ */
+/*----------------------------------------------------------------------------------------*/
+VOID
+GnbLibPciScan (
+ IN PCI_ADDR Start,
+ IN PCI_ADDR End,
+ IN GNB_PCI_SCAN_DATA *ScanData
+ )
+{
+ UINTN Bus;
+ UINTN Device;
+ UINTN LastDevice;
+ UINTN Function;
+ UINTN LastFunction;
+ PCI_ADDR PciDevice;
+ SCAN_STATUS Status;
+
+ for (Bus = Start.Address.Bus; Bus <= End.Address.Bus; Bus++) {
+ Device = (Bus == Start.Address.Bus) ? Start.Address.Device : 0x00;
+ LastDevice = (Bus == End.Address.Bus) ? End.Address.Device : 0x1F;
+ for ( ; Device <= LastDevice; Device++) {
+ if ((Bus == Start.Address.Bus) && (Device == Start.Address.Device)) {
+ Function = Start.Address.Function;
+ } else {
+ Function = 0x0;
+ }
+ PciDevice.AddressValue = MAKE_SBDFO (0, Bus, Device, Function, 0);
+ if (!GnbLibPciIsDevicePresent (PciDevice.AddressValue, ScanData->StdHeader)) {
+ continue;
+ }
+ if (GnbLibPciIsMultiFunctionDevice (PciDevice.AddressValue, ScanData->StdHeader)) {
+ if ((Bus == End.Address.Bus) && (Device == End.Address.Device)) {
+ LastFunction = Start.Address.Function;
+ } else {
+ LastFunction = 0x7;
+ }
+ } else {
+ LastFunction = 0x0;
+ }
+ for ( ; Function <= LastFunction; Function++) {
+ PciDevice.AddressValue = MAKE_SBDFO (0, Bus, Device, Function, 0);
+ if (GnbLibPciIsDevicePresent (PciDevice.AddressValue, ScanData->StdHeader)) {
+ Status = ScanData->GnbScanCallback (PciDevice, ScanData);
+ if ((Status & SCAN_SKIP_FUNCTIONS) != 0) {
+ Function = LastFunction + 1;
+ }
+ if ((Status & SCAN_SKIP_DEVICES) != 0) {
+ Device = LastDevice + 1;
+ }
+ if ((Status & SCAN_SKIP_BUSES) != 0) {
+ Bus = End.Address.Bus + 1;
+ }
+ }
+ }
+ }
+ }
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Scan all subordinate buses
+ *
+ *
+ * @param[in] Bridge PCI bridge address
+ * @param[in,out] ScanData Scan configuration data
+ *
+ */
+VOID
+GnbLibPciScanSecondaryBus (
+ IN PCI_ADDR Bridge,
+ IN OUT GNB_PCI_SCAN_DATA *ScanData
+ )
+{
+ PCI_ADDR StartRange;
+ PCI_ADDR EndRange;
+ UINT8 SecondaryBus;
+ GnbLibPciRead (Bridge.AddressValue | 0x19, AccessWidth8, &SecondaryBus, ScanData->StdHeader);
+ if (SecondaryBus != 0) {
+ StartRange.AddressValue = MAKE_SBDFO (0, SecondaryBus, 0, 0, 0);
+ EndRange.AddressValue = MAKE_SBDFO (0, SecondaryBus, 0x1f, 0x7, 0);
+ GnbLibPciScan (StartRange, EndRange, ScanData);
+ }
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Get PCIe device type
+ *
+ *
+ *
+ * @param[in] Device PCI address of device.
+ * @param[in] StdHeader Northbridge configuration structure pointer.
+ *
+ * @retval PCIE_DEVICE_TYPE
+ */
+ /*----------------------------------------------------------------------------------------*/
+
+PCIE_DEVICE_TYPE
+GnbLibGetPcieDeviceType (
+ IN PCI_ADDR Device,
+ IN AMD_CONFIG_PARAMS *StdHeader
+ )
+{
+ UINT8 PcieCapPtr;
+ UINT8 Value;
+
+ PcieCapPtr = GnbLibFindPciCapability (Device.AddressValue, PCIE_CAP_ID, StdHeader);
+ if (PcieCapPtr != 0) {
+ GnbLibPciRead (Device.AddressValue | (PcieCapPtr + 0x2) , AccessWidth8, &Value, StdHeader);
+ return Value >> 4;
+ }
+ return PcieNotPcieDevice;
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Save config space area
+ *
+ *
+ *
+ * @param[in] Address PCI address of device.
+ * @param[in] StartRegisterAddress Start register address.
+ * @param[in] EndRegisterAddress End register address.
+ * @param[in] Width Acess width.
+ * @param[in] StdHeader Standard header.
+ *
+ */
+ /*----------------------------------------------------------------------------------------*/
+
+VOID
+GnbLibS3SaveConfigSpace (
+ IN UINT32 Address,
+ IN UINT16 StartRegisterAddress,
+ IN UINT16 EndRegisterAddress,
+ IN ACCESS_WIDTH Width,
+ IN AMD_CONFIG_PARAMS *StdHeader
+ )
+{
+ UINT16 Index;
+ UINT16 Delta;
+ UINT16 Length;
+ Length = (StartRegisterAddress < EndRegisterAddress) ? (EndRegisterAddress - StartRegisterAddress) : (StartRegisterAddress - EndRegisterAddress);
+ Delta = LibAmdAccessWidth (Width);
+ for (Index = 0; Index <= Length; Index = Index + Delta) {
+ GnbLibPciRMW (
+ Address | ((StartRegisterAddress < EndRegisterAddress) ? (StartRegisterAddress + Index) : (StartRegisterAddress - Index)),
+ Width,
+ 0xffffffff,
+ 0x0,
+ StdHeader
+ );
+ }
+}
diff --git a/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbCommonLib/GnbLibPci.h b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbCommonLib/GnbLibPci.h
new file mode 100644
index 0000000000..df5e47e37b
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbCommonLib/GnbLibPci.h
@@ -0,0 +1,148 @@
+/* $NoKeywords:$ */
+/**
+ * @file
+ *
+ * Various PCI service routines.
+ *
+ *
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: GNB
+ * @e \$Revision: 36567 $ @e \$Date: 2010-08-20 11:35:15 -0700 (Fri, 20 Aug 2010) $
+ *
+ */
+/*
+ *****************************************************************************
+ *
+ * Copyright (c) 2011, Advanced Micro Devices, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Advanced Micro Devices, Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***************************************************************************
+ *
+ */
+
+#ifndef _PCILIB_H_
+#define _PCILIB_H_
+
+/// PCIe device type
+typedef enum {
+ PcieDeviceEndPoint, ///< Endpoint
+ PcieDeviceLegacyEndPoint, ///< Legacy endpoint
+ PcieDeviceRootComplex = 4, ///< Root complex
+ PcieDeviceUpstreamPort, ///< Upstream port
+ PcieDeviceDownstreamPort, ///< Downstream Port
+ PcieDevicePcieToPcix, ///< PCIe to PCI/PCIx bridge
+ PcieDevicePcixToPcie, ///< PCI/PCIx to PCIe bridge
+ PcieNotPcieDevice = 0xff ///< unknown device
+} PCIE_DEVICE_TYPE;
+
+typedef UINT32 SCAN_STATUS;
+
+#define SCAN_SKIP_FUNCTIONS 0x1
+#define SCAN_SKIP_DEVICES 0x2
+#define SCAN_SKIP_BUSES 0x4
+#define SCAN_SUCCESS 0x0
+
+// Forward declaration needed for multi-structure mutual references
+AGESA_FORWARD_DECLARATION (GNB_PCI_SCAN_DATA);
+
+typedef SCAN_STATUS (*GNB_SCAN_CALLBACK) (
+ IN PCI_ADDR Device,
+ IN OUT GNB_PCI_SCAN_DATA *ScanData
+ );
+
+///Scan supporting data
+typedef struct _GNB_PCI_SCAN_DATA {
+ GNB_SCAN_CALLBACK GnbScanCallback; ///< Callback for each found device
+ AMD_CONFIG_PARAMS *StdHeader; ///< Standard configuration header
+};
+
+#define PCIE_CAP_ID 0x10
+#define PCIE_LINK_CAP_REGISTER 0x0C
+#define PCIE_LINK_CTRL_REGISTER 0x10
+#define PCIE_DEVICE_CAP_REGISTER 0x04
+#define PCIE_ASPM_L1_SUPPORT_CAP BIT11
+
+BOOLEAN
+GnbLibPciIsDevicePresent (
+ IN UINT32 Address,
+ IN AMD_CONFIG_PARAMS *StdHeader
+ );
+
+BOOLEAN
+GnbLibPciIsBridgeDevice (
+ IN UINT32 Address,
+ IN AMD_CONFIG_PARAMS *StdHeader
+ );
+
+BOOLEAN
+GnbLibPciIsMultiFunctionDevice (
+ IN UINT32 Address,
+ IN AMD_CONFIG_PARAMS *StdHeader
+ );
+
+BOOLEAN
+GnbLibPciIsPcieDevice (
+ IN UINT32 Address,
+ IN AMD_CONFIG_PARAMS *StdHeader
+ );
+
+UINT8
+GnbLibFindPciCapability (
+ IN UINT32 Address,
+ IN UINT8 CapabilityId,
+ IN AMD_CONFIG_PARAMS *StdHeader
+ );
+
+VOID
+GnbLibPciScan (
+ IN PCI_ADDR Start,
+ IN PCI_ADDR End,
+ IN GNB_PCI_SCAN_DATA *ScanData
+ );
+
+VOID
+GnbLibPciScanSecondaryBus (
+ IN PCI_ADDR Bridge,
+ IN OUT GNB_PCI_SCAN_DATA *ScanData
+ );
+
+PCIE_DEVICE_TYPE
+GnbLibGetPcieDeviceType (
+ IN PCI_ADDR Device,
+ IN AMD_CONFIG_PARAMS *StdHeader
+ );
+
+VOID
+GnbLibS3SaveConfigSpace (
+ IN UINT32 Address,
+ IN UINT16 StartRegisterAddress,
+ IN UINT16 EndRegisterAddress,
+ IN ACCESS_WIDTH Width,
+ IN AMD_CONFIG_PARAMS *StdHeader
+ );
+
+#endif
diff --git a/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbCommonLib/GnbLibPciAcc.c b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbCommonLib/GnbLibPciAcc.c
new file mode 100644
index 0000000000..ac27a30e07
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbCommonLib/GnbLibPciAcc.c
@@ -0,0 +1,157 @@
+/* $NoKeywords:$ */
+/**
+ * @file
+ *
+ * Service procedure to access PCI config space registers
+ *
+ *
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: GNB
+ * @e \$Revision: 34897 $ @e \$Date: 2010-07-13 19:07:10 -0700 (Tue, 13 Jul 2010) $
+ *
+ */
+/*
+ *****************************************************************************
+ *
+ * Copyright (c) 2011, Advanced Micro Devices, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Advanced Micro Devices, Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***************************************************************************
+ *
+ */
+
+/*----------------------------------------------------------------------------------------
+ * M O D U L E S U S E D
+ *----------------------------------------------------------------------------------------
+ */
+#include "Porting.h"
+#include "AMD.h"
+#include "amdlib.h"
+#include "GnbLibPciAcc.h"
+#include "S3SaveState.h"
+#include "Filecode.h"
+#define FILECODE PROC_GNB_MODULES_GNBCOMMONLIB_GNBLIBPCIACC_FILECODE
+/*----------------------------------------------------------------------------------------
+ * D E F I N I T I O N S A N D M A C R O S
+ *----------------------------------------------------------------------------------------
+ */
+
+
+/*----------------------------------------------------------------------------------------
+ * T Y P E D E F S A N D S T R U C T U R E S
+ *----------------------------------------------------------------------------------------
+ */
+
+
+/*----------------------------------------------------------------------------------------
+ * P R O T O T Y P E S O F L O C A L F U N C T I O N S
+ *----------------------------------------------------------------------------------------
+ */
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Write PCI registers
+ *
+ *
+ *
+ * @param[in] Address PCI address (as presented in PCI_ADDR.AddressValue)
+ * @param[in] Width Access width
+ * @param[in] Value Pointer to value
+ * @param[in] StdHeader Pointer to standard header
+ */
+VOID
+GnbLibPciWrite (
+ IN UINT32 Address,
+ IN ACCESS_WIDTH Width,
+ IN VOID *Value,
+ IN AMD_CONFIG_PARAMS *StdHeader
+ )
+{
+ PCI_ADDR PciAddress;
+ PciAddress.AddressValue = Address;
+ if (Width >= AccessS3SaveWidth8) {
+ S3_SAVE_PCI_WRITE (StdHeader, PciAddress, Width, Value);
+ }
+ LibAmdPciWrite (Width, PciAddress, Value, StdHeader);
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Read PCI registers
+ *
+ *
+ *
+ * @param[in] Address PCI address (as presented in PCI_ADDR.AddressValue)
+ * @param[in] Width Access width
+ * @param[out] Value Pointer to value
+ * @param[in] StdHeader Pointer to standard header
+ */
+
+VOID
+GnbLibPciRead (
+ IN UINT32 Address,
+ IN ACCESS_WIDTH Width,
+ OUT VOID *Value,
+ IN AMD_CONFIG_PARAMS *StdHeader
+ )
+{
+ PCI_ADDR PciAddress;
+ PciAddress.AddressValue = Address;
+ LibAmdPciRead (Width, PciAddress, Value, StdHeader);
+}
+
+
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Poll PCI reg
+ *
+ *
+ *
+ * @param[in] Address PCI address (as presented in PCI_ADDR.AddressValue)
+ * @param[in] Width Access width
+ * @param[in] Data Data to compare
+ * @param[in] DataMask AND mask
+ * @param[in] StdHeader Standard configuration header
+ */
+
+VOID
+GnbLibPciPoll (
+ IN UINT32 Address,
+ IN ACCESS_WIDTH Width,
+ IN VOID *Data,
+ IN VOID *DataMask,
+ IN AMD_CONFIG_PARAMS *StdHeader
+ )
+{
+ PCI_ADDR PciAddress;
+ PciAddress.AddressValue = Address;
+ if (Width >= AccessS3SaveWidth8) {
+ S3_SAVE_PCI_POLL (StdHeader, PciAddress, Width, Data, DataMask, 0xffffffff);
+ }
+ LibAmdPciPoll (Width, PciAddress, Data, DataMask, 0xffffffff, StdHeader);
+}
diff --git a/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbCommonLib/GnbLibPciAcc.h b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbCommonLib/GnbLibPciAcc.h
new file mode 100644
index 0000000000..8e3fb0daa7
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbCommonLib/GnbLibPciAcc.h
@@ -0,0 +1,74 @@
+/* $NoKeywords:$ */
+/**
+ * @file
+ *
+ * Service procedure to access PCI config space registers
+ *
+ *
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: GNB
+ * @e \$Revision: 34897 $ @e \$Date: 2010-07-13 19:07:10 -0700 (Tue, 13 Jul 2010) $
+ *
+ */
+/*
+ *****************************************************************************
+ *
+ * Copyright (c) 2011, Advanced Micro Devices, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Advanced Micro Devices, Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***************************************************************************
+ *
+ */
+#ifndef _PCIACCLIB_H_
+#define _PCIACCLIB_H_
+
+VOID
+GnbLibPciWrite (
+ IN UINT32 Address,
+ IN ACCESS_WIDTH Width,
+ IN VOID *Value,
+ IN AMD_CONFIG_PARAMS *StdHeader
+ );
+
+VOID
+GnbLibPciRead (
+ IN UINT32 Address,
+ IN ACCESS_WIDTH Width,
+ OUT VOID *Value,
+ IN AMD_CONFIG_PARAMS *StdHeader
+ );
+
+VOID
+GnbLibPciPoll (
+ IN UINT32 Address,
+ IN ACCESS_WIDTH Width,
+ IN VOID *Data,
+ IN VOID *DataMask,
+ IN AMD_CONFIG_PARAMS *StdHeader
+ );
+
+#endif
diff --git a/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbGfxConfig/GfxConfigEnv.c b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbGfxConfig/GfxConfigEnv.c
new file mode 100644
index 0000000000..38e4b6abcd
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbGfxConfig/GfxConfigEnv.c
@@ -0,0 +1,176 @@
+/* $NoKeywords:$ */
+/**
+ * @file
+ *
+ * Initialize GFX configuration data structure.
+ *
+ *
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: GNB
+ * @e \$Revision: 39255 $ @e \$Date: 2010-10-08 11:27:41 -0700 (Fri, 08 Oct 2010) $
+ *
+ */
+/*
+ *****************************************************************************
+ *
+ * Copyright (c) 2011, Advanced Micro Devices, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Advanced Micro Devices, Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***************************************************************************
+ *
+ */
+
+/*----------------------------------------------------------------------------------------
+ * M O D U L E S U S E D
+ *----------------------------------------------------------------------------------------
+ */
+#include "AGESA.h"
+#include "amdlib.h"
+#include "Ids.h"
+#include "heapManager.h"
+#include "Gnb.h"
+#include "GnbGfx.h"
+#include GNB_MODULE_DEFINITIONS (GnbCommonLib)
+#include "GfxConfigPost.h"
+#include "OptionGnb.h"
+#include "Filecode.h"
+#define FILECODE PROC_GNB_MODULES_GNBGFXCONFIG_GFXCONFIGENV_FILECODE
+/*----------------------------------------------------------------------------------------
+ * D E F I N I T I O N S A N D M A C R O S
+ *----------------------------------------------------------------------------------------
+ */
+
+extern BUILD_OPT_CFG UserOptions;
+extern GNB_BUILD_OPTIONS GnbBuildOptions;
+
+/*----------------------------------------------------------------------------------------
+ * T Y P E D E F S A N D S T R U C T U R E S
+ *----------------------------------------------------------------------------------------
+ */
+
+
+/*----------------------------------------------------------------------------------------
+ * P R O T O T Y P E S O F L O C A L F U N C T I O N S
+ *----------------------------------------------------------------------------------------
+ */
+
+
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Get UMA info
+ *
+ * UMA info stored on heap by memory module
+ *
+ * @param[out] UmaInfo Pointer to UMA info structure
+ * @param[in] StdHeader Standard configuration header
+ */
+
+VOID
+GfxGetUmaInfo (
+ OUT UMA_INFO *UmaInfo,
+ IN AMD_CONFIG_PARAMS *StdHeader
+ )
+{
+ UMA_INFO *MemUmaInfo;
+
+ MemUmaInfo = GnbLocateHeapBuffer (AMD_UMA_INFO_HANDLE, StdHeader);
+ if (MemUmaInfo == NULL) {
+ LibAmdMemFill (UmaInfo, 0x00, sizeof (UMA_INFO), StdHeader);
+ UmaInfo->UmaMode = UMA_NONE;
+ } else {
+ LibAmdMemCopy (UmaInfo, MemUmaInfo, sizeof (UMA_INFO), StdHeader);
+ if ((UmaInfo->UmaBase == 0) || (UmaInfo->UmaSize == 0)) {
+ UmaInfo->UmaMode = UMA_NONE;
+ }
+ }
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Locate UMA configuration data
+ *
+ *
+ *
+ * @param[in] StdHeader Standard configuration header
+ * @param[in,out] Gfx Pointer to GFX configuration
+ * @retval AGESA_STATUS Data located
+ * @retval AGESA_FATA Data not found
+ */
+
+AGESA_STATUS
+GfxLocateConfigData (
+ IN AMD_CONFIG_PARAMS *StdHeader,
+ OUT GFX_PLATFORM_CONFIG **Gfx
+ )
+{
+ *Gfx = GnbLocateHeapBuffer (AMD_GFX_PLATFORM_CONFIG_HANDLE, StdHeader);
+ if (*Gfx == NULL) {
+ IDS_ERROR_TRAP;
+ return AGESA_FATAL;
+ }
+ (*Gfx)->StdHeader = (PVOID) StdHeader;
+ return AGESA_SUCCESS;
+}
+
+
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Update GFX config info at ENV
+ *
+ *
+ *
+ * @param[in] StdHeader Standard configuration header
+ * @retval AGESA_STATUS Always succeeds
+ */
+
+AGESA_STATUS
+GfxConfigEnvInterface (
+ IN AMD_CONFIG_PARAMS *StdHeader
+ )
+{
+
+ AMD_ENV_PARAMS *EnvParamsPtr;
+ GFX_PLATFORM_CONFIG *Gfx;
+ AGESA_STATUS Status;
+ IDS_HDT_CONSOLE (GNB_TRACE, "GfxConfigEnvInterface Enter\n");
+ Status = GfxLocateConfigData (StdHeader, &Gfx);
+ ASSERT (Status == AGESA_SUCCESS);
+ if (Status == AGESA_SUCCESS) {
+ EnvParamsPtr = (AMD_ENV_PARAMS *)StdHeader;
+ Gfx->Gnb3dStereoPinIndex = EnvParamsPtr->GnbEnvConfiguration.Gnb3dStereoPinIndex;
+ Gfx->LvdsSpreadSpectrum = EnvParamsPtr->GnbEnvConfiguration.LvdsSpreadSpectrum;
+ Gfx->LvdsSpreadSpectrumRate = EnvParamsPtr->GnbEnvConfiguration.LvdsSpreadSpectrumRate;
+ GfxGetUmaInfo (&Gfx->UmaInfo, StdHeader);
+ }
+ GNB_DEBUG_CODE (
+ GfxConfigDebugDump (Gfx);
+ );
+ IDS_HDT_CONSOLE (GNB_TRACE, "GfxConfigEnvInterface Exit [0x%x]\n", Status);
+ return Status;
+}
diff --git a/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbGfxConfig/GfxConfigPost.c b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbGfxConfig/GfxConfigPost.c
new file mode 100644
index 0000000000..12a8dc6bd4
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbGfxConfig/GfxConfigPost.c
@@ -0,0 +1,180 @@
+/* $NoKeywords:$ */
+/**
+ * @file
+ *
+ * Initialize GFX configuration data structure.
+ *
+ *
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: GNB
+ * @e \$Revision: 39255 $ @e \$Date: 2010-10-08 11:27:41 -0700 (Fri, 08 Oct 2010) $
+ *
+ */
+/*
+ *****************************************************************************
+ *
+ * Copyright (c) 2011, Advanced Micro Devices, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Advanced Micro Devices, Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***************************************************************************
+ *
+ */
+
+/*----------------------------------------------------------------------------------------
+ * M O D U L E S U S E D
+ *----------------------------------------------------------------------------------------
+ */
+#include "AGESA.h"
+#include "amdlib.h"
+#include "Ids.h"
+#include "heapManager.h"
+#include "Gnb.h"
+#include "GnbGfx.h"
+#include GNB_MODULE_DEFINITIONS (GnbCommonLib)
+#include "GfxConfigPost.h"
+#include "OptionGnb.h"
+#include "Filecode.h"
+#define FILECODE PROC_GNB_MODULES_GNBGFXCONFIG_GFXCONFIGPOST_FILECODE
+/*----------------------------------------------------------------------------------------
+ * D E F I N I T I O N S A N D M A C R O S
+ *----------------------------------------------------------------------------------------
+ */
+
+extern BUILD_OPT_CFG UserOptions;
+extern GNB_BUILD_OPTIONS GnbBuildOptions;
+
+/*----------------------------------------------------------------------------------------
+ * T Y P E D E F S A N D S T R U C T U R E S
+ *----------------------------------------------------------------------------------------
+ */
+
+
+/*----------------------------------------------------------------------------------------
+ * P R O T O T Y P E S O F L O C A L F U N C T I O N S
+ *----------------------------------------------------------------------------------------
+ */
+
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Allocate UMA configuration data
+ *
+ *
+ *
+ * @param[in] StdHeader Standard configuration header
+ * @param[in,out] Gfx Pointer to GFX configuration
+ * @param[in] PlatformConfig Platform configuration
+ * @retval AGESA_STATUS Always succeeds
+ */
+
+AGESA_STATUS
+GfxConfigPostInterface (
+ IN AMD_CONFIG_PARAMS *StdHeader
+ )
+{
+ GFX_PLATFORM_CONFIG *Gfx;
+ AMD_POST_PARAMS *PostParamsPtr;
+ AGESA_STATUS Status;
+ PostParamsPtr = (AMD_POST_PARAMS *)StdHeader;
+ Status = AGESA_SUCCESS;
+ IDS_HDT_CONSOLE (GNB_TRACE, "GfxConfigPostInterface Enter\n");
+ Gfx = GnbAllocateHeapBuffer (AMD_GFX_PLATFORM_CONFIG_HANDLE, sizeof (GFX_PLATFORM_CONFIG), StdHeader);
+ ASSERT (Gfx != NULL);
+ if (Gfx != NULL) {
+ LibAmdMemFill (Gfx, 0x00, sizeof (GFX_PLATFORM_CONFIG), StdHeader);
+ if (GnbBuildOptions.IgfxModeAsPcieEp) {
+ Gfx->GfxControllerMode = GfxControllerPcieEndpointMode;
+ Gfx->GfxPciAddress.AddressValue = MAKE_SBDFO (0, 0, 1, 0, 0);
+ } else {
+ Gfx->GfxControllerMode = GfxControllerLegacyBridgeMode;
+ Gfx->GfxPciAddress.AddressValue = MAKE_SBDFO (0, 1, 5, 0, 0);
+ }
+ Gfx->StdHeader = (PVOID) StdHeader;
+ Gfx->GnbHdAudio = PostParamsPtr->PlatformConfig.GnbHdAudio;
+ Gfx->AbmSupport = PostParamsPtr->PlatformConfig.AbmSupport;
+ Gfx->DynamicRefreshRate = PostParamsPtr->PlatformConfig.DynamicRefreshRate;
+ Gfx->LcdBackLightControl = PostParamsPtr->PlatformConfig.LcdBackLightControl;
+ Gfx->ForceGfxMode = GfxEnableAuto;
+ Gfx->AmdPlatformType = UserOptions.CfgAmdPlatformType;
+ Gfx->GmcClockGating = OptionEnabled;
+ Gfx->GmcPowerGating = GnbBuildOptions.GmcPowerGateStutterOnly ? GmcPowerGatingStutterOnly : GmcPowerGatingWidthStutter;
+ Gfx->UmaSteering = Garlic;
+ GNB_DEBUG_CODE (
+ GfxConfigDebugDump (Gfx);
+ );
+ } else {
+ Status = AGESA_ERROR;
+ }
+ IDS_OPTION_HOOK (IDS_GNB_PLATFORMCFG_OVERRIDE, Gfx, StdHeader);
+ IDS_HDT_CONSOLE (GNB_TRACE, "GfxConfigPostInterface Exit [0x%x]\n", Status);
+ return Status;
+}
+
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Debug dump
+ *
+ *
+ *
+ * @param[in] Gfx Pointer to GFX configuration
+ */
+
+VOID
+GfxConfigDebugDump (
+ IN GFX_PLATFORM_CONFIG *Gfx
+ )
+{
+ IDS_HDT_CONSOLE (GFX_MISC, "<-------------- GFX Config Start ------------->\n");
+ IDS_HDT_CONSOLE (GFX_MISC, " HD Audio - %s\n", (Gfx->GnbHdAudio == 0) ? "Disabled" : "Enabled");
+ IDS_HDT_CONSOLE (GFX_MISC, " DynamicRefreshRate - 0x%x\n", Gfx->DynamicRefreshRate);
+ IDS_HDT_CONSOLE (GFX_MISC, " LcdBackLightControl - 0x%x\n", Gfx->LcdBackLightControl);
+ IDS_HDT_CONSOLE (GFX_MISC, " AbmSupport - %s\n", (Gfx->AbmSupport == 0) ? "Disabled" : "Enabled");
+ IDS_HDT_CONSOLE (GFX_MISC, " GmcClockGating - %s\n", (Gfx->GmcClockGating == 0) ? "Disabled" : "Enabled");
+ IDS_HDT_CONSOLE (GFX_MISC, " GmcPowerGating - %s\n",
+ (Gfx->GmcPowerGating == GmcPowerGatingDisabled) ? "Disabled" : (
+ (Gfx->GmcPowerGating == GmcPowerGatingStutterOnly) ? "GmcPowerGatingStutterOnly" : (
+ (Gfx->GmcPowerGating == GmcPowerGatingWidthStutter) ? "GmcPowerGatingWidthStutter" : "Unknown"))
+ );
+ IDS_HDT_CONSOLE (GFX_MISC, " UmaSteering - %s\n",
+ (Gfx->UmaSteering == Onion) ? "Onion" : (
+ (Gfx->UmaSteering == Garlic) ? "Garlic" : "Unknown")
+ );
+ IDS_HDT_CONSOLE (GFX_MISC, " ForceGfxMode - %s\n",
+ (Gfx->ForceGfxMode == GfxEnableAuto) ? "Auto" : (
+ (Gfx->ForceGfxMode == GfxEnableForcePrimary) ? "Force Primary" : (
+ (Gfx->ForceGfxMode == GfxEnableForceSecondary) ? "Force Secondary" : "Unknown"))
+ );
+ IDS_HDT_CONSOLE (GFX_MISC, " UmaMode - %s\n", (Gfx->UmaInfo.UmaMode == UMA_NONE) ? "No UMA" : "UMA");
+ if (Gfx->UmaInfo.UmaMode != UMA_NONE) {
+ IDS_HDT_CONSOLE (GFX_MISC, " UmaBase - 0x%x\n", Gfx->UmaInfo.UmaBase);
+ IDS_HDT_CONSOLE (GFX_MISC, " UmaSize - 0x%x\n", Gfx->UmaInfo.UmaSize);
+ IDS_HDT_CONSOLE (GFX_MISC, " UmaAttributes - 0x%x\n", Gfx->UmaInfo.UmaAttributes);
+ }
+ IDS_HDT_CONSOLE (GFX_MISC, "<-------------- GFX Config End --------------->\n");
+
+}
diff --git a/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbGfxConfig/GfxConfigPost.h b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbGfxConfig/GfxConfigPost.h
new file mode 100644
index 0000000000..b262a4cee1
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbGfxConfig/GfxConfigPost.h
@@ -0,0 +1,55 @@
+/* $NoKeywords:$ */
+/**
+ * @file
+ *
+ * Initialize GFX configuration data structure.
+ *
+ *
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: GNB
+ * @e \$Revision: 39255 $ @e \$Date: 2010-10-08 11:27:41 -0700 (Fri, 08 Oct 2010) $
+ *
+ */
+/*
+ *****************************************************************************
+ *
+ * Copyright (c) 2011, Advanced Micro Devices, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Advanced Micro Devices, Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***************************************************************************
+ *
+ */
+
+#ifndef _GFXCONFIGPOST_H_
+#define _GFXCONFIGPOST_H_
+
+VOID
+GfxConfigDebugDump (
+ IN GFX_PLATFORM_CONFIG *Gfx
+ );
+
+#endif
diff --git a/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbGfxConfig/GnbGfxConfig.h b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbGfxConfig/GnbGfxConfig.h
new file mode 100644
index 0000000000..127117c337
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbGfxConfig/GnbGfxConfig.h
@@ -0,0 +1,56 @@
+/* $NoKeywords:$ */
+/**
+ * @file
+ *
+ * Initialize GFX configuration data structure.
+ *
+ *
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: GNB
+ * @e \$Revision: 39255 $ @e \$Date: 2010-10-08 11:27:41 -0700 (Fri, 08 Oct 2010) $
+ *
+ */
+/*
+ *****************************************************************************
+ *
+ * Copyright (c) 2011, Advanced Micro Devices, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Advanced Micro Devices, Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***************************************************************************
+ *
+ */
+
+#ifndef _GNBGFXCONFIG_H_
+#define _GNBGFXCONFIG_H_
+
+AGESA_STATUS
+GfxLocateConfigData (
+ IN AMD_CONFIG_PARAMS *StdHeader,
+ OUT GFX_PLATFORM_CONFIG **Gfx
+ );
+
+#endif
diff --git a/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbGfxInitLibV1/GfxCardInfo.c b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbGfxInitLibV1/GfxCardInfo.c
new file mode 100644
index 0000000000..9b59514096
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbGfxInitLibV1/GfxCardInfo.c
@@ -0,0 +1,185 @@
+/* $NoKeywords:$ */
+/**
+ * @file
+ *
+ * Supporting services to collect discrete GFX card info
+ *
+ *
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: GNB
+ * @e \$Revision: 38931 $ @e \$Date: 2010-10-01 15:50:05 -0700 (Fri, 01 Oct 2010) $
+ *
+ */
+/*
+ *****************************************************************************
+ *
+ * Copyright (c) 2011, Advanced Micro Devices, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Advanced Micro Devices, Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***************************************************************************
+ *
+ */
+
+/*----------------------------------------------------------------------------------------
+ * M O D U L E S U S E D
+ *----------------------------------------------------------------------------------------
+ */
+#include "AGESA.h"
+#include "Ids.h"
+#include "amdlib.h"
+#include "Gnb.h"
+#include "GnbGfx.h"
+#include GNB_MODULE_DEFINITIONS (GnbCommonLib)
+#include "GfxCardInfo.h"
+#include "Filecode.h"
+#define FILECODE PROC_GNB_MODULES_GNBGFXINITLIBV1_GFXCARDINFO_FILECODE
+/*----------------------------------------------------------------------------------------
+ * D E F I N I T I O N S A N D M A C R O S
+ *----------------------------------------------------------------------------------------
+ */
+
+
+/*----------------------------------------------------------------------------------------
+ * T Y P E D E F S A N D S T R U C T U R E S
+ *----------------------------------------------------------------------------------------
+ */
+
+typedef struct {
+ GNB_PCI_SCAN_DATA ScanData;
+ GFX_CARD_CARD_INFO *GfxCardInfo;
+ PCI_ADDR BaseBridge;
+ UINT8 BusNumber;
+} GFX_SCAN_DATA;
+
+
+/*----------------------------------------------------------------------------------------
+ * P R O T O T Y P E S O F L O C A L F U N C T I O N S
+ *----------------------------------------------------------------------------------------
+ */
+
+SCAN_STATUS
+GfxScanPcieDevice (
+ IN PCI_ADDR Device,
+ IN OUT GNB_PCI_SCAN_DATA *ScanData
+ );
+
+
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Get information about all discrete GFX card in system
+ *
+ *
+ *
+ * @param[out] GfxCardInfo Pointer to GFX card info structure
+ * @param[in] StdHeader Standard configuration header
+ */
+
+VOID
+GfxGetDiscreteCardInfo (
+ OUT GFX_CARD_CARD_INFO *GfxCardInfo,
+ IN AMD_CONFIG_PARAMS *StdHeader
+ )
+{
+ GFX_SCAN_DATA GfxScanData;
+ PCI_ADDR Start;
+ PCI_ADDR End;
+ IDS_HDT_CONSOLE (GNB_TRACE, "GfxGetDiscreteCardInfo Enter\n");
+ Start.AddressValue = MAKE_SBDFO (0, 0, 2, 0, 0);
+ End.AddressValue = MAKE_SBDFO (0, 0, 0x1f, 7, 0);
+ GfxScanData.BusNumber = 5;
+ GfxScanData.ScanData.GnbScanCallback = GfxScanPcieDevice;
+ GfxScanData.ScanData.StdHeader = StdHeader;
+ GfxScanData.GfxCardInfo = GfxCardInfo;
+ GnbLibPciScan (Start, End, &GfxScanData.ScanData);
+ IDS_HDT_CONSOLE (GNB_TRACE, "GfxGetDiscreteCardInfo Exit\n");
+}
+
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Evaluate device
+ *
+ *
+ *
+ * @param[in] Device PCI Address
+ * @param[in,out] ScanData Scan configuration data
+ * @retval Scan Status of 0
+ */
+
+SCAN_STATUS
+GfxScanPcieDevice (
+ IN PCI_ADDR Device,
+ IN OUT GNB_PCI_SCAN_DATA *ScanData
+ )
+{
+ UINT8 ClassCode;
+ UINT32 VendorId;
+
+ IDS_HDT_CONSOLE (GFX_MISC, " Evaluate device [%d:%d:%d]\n",
+ Device.Address.Bus, Device.Address.Device, Device.Address.Function
+ );
+
+ if (GnbLibPciIsBridgeDevice (Device.AddressValue, ScanData->StdHeader)) {
+ UINT32 SaveBusConfiguration;
+ UINT32 Value;
+
+ if (Device.Address.Bus == 0) {
+ ((GFX_SCAN_DATA *) ScanData)->BaseBridge = Device;
+ }
+ GnbLibPciRead (Device.AddressValue | 0x18, AccessWidth32, &SaveBusConfiguration, ScanData->StdHeader);
+ Value = (((0xFF << 8) | ((GFX_SCAN_DATA *) ScanData)->BusNumber) << 8) | Device.Address.Bus;
+ GnbLibPciWrite (Device.AddressValue | 0x18, AccessWidth32, &Value, ScanData->StdHeader);
+ ((GFX_SCAN_DATA *) ScanData)->BusNumber++;
+
+ GnbLibPciScanSecondaryBus (Device, ScanData);
+
+ ((GFX_SCAN_DATA *) ScanData)->BusNumber--;
+ GnbLibPciWrite (Device.AddressValue | 0x18, AccessWidth32, &SaveBusConfiguration, ScanData->StdHeader);
+ return 0;
+ }
+ GnbLibPciRead (Device.AddressValue | 0x0b, AccessWidth8, &ClassCode, ScanData->StdHeader);
+ if (ClassCode == 3) {
+ IDS_HDT_CONSOLE (GFX_MISC, " Found GFX Card\n"
+ );
+
+ GnbLibPciRead (Device.AddressValue | 0x00, AccessWidth32, &VendorId, ScanData->StdHeader);
+ if (!GnbLibPciIsPcieDevice (Device.AddressValue, ScanData->StdHeader)) {
+ IDS_HDT_CONSOLE (GFX_MISC, " GFX Card is PCI device\n"
+ );
+ ((GFX_SCAN_DATA *) ScanData)->GfxCardInfo->PciGfxCardBitmap |= (1 << ((GFX_SCAN_DATA *) ScanData)->BaseBridge.Address.Device);
+ return 0;
+ }
+ if ((UINT16) VendorId == 0x1002) {
+ IDS_HDT_CONSOLE (GFX_MISC, " GFX Card is AMD PCIe device\n"
+ );
+ ((GFX_SCAN_DATA *) ScanData)->GfxCardInfo->AmdPcieGfxCardBitmap |= (1 << ((GFX_SCAN_DATA *) ScanData)->BaseBridge.Address.Device);
+ }
+ ((GFX_SCAN_DATA *) ScanData)->GfxCardInfo->PcieGfxCardBitmap |= (1 << ((GFX_SCAN_DATA *) ScanData)->BaseBridge.Address.Device);
+ }
+ return 0;
+}
diff --git a/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbGfxInitLibV1/GfxCardInfo.h b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbGfxInitLibV1/GfxCardInfo.h
new file mode 100644
index 0000000000..289c77350e
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbGfxInitLibV1/GfxCardInfo.h
@@ -0,0 +1,64 @@
+/* $NoKeywords:$ */
+/**
+ * @file
+ *
+ * Supporting services to collect discrete GFX card info
+ *
+ *
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: GNB
+ * @e \$Revision: 34897 $ @e \$Date: 2010-07-13 19:07:10 -0700 (Tue, 13 Jul 2010) $
+ *
+ */
+/*
+ *****************************************************************************
+ *
+ * Copyright (c) 2011, Advanced Micro Devices, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Advanced Micro Devices, Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***************************************************************************
+ *
+ */
+
+
+#ifndef _GFXCARDINFO_H_
+#define _GFXCARDINFO_H_
+
+/// Graphics card information structure
+typedef struct {
+ UINT32 AmdPcieGfxCardBitmap; ///< AMD PCIE graphics card information
+ UINT32 PcieGfxCardBitmap; ///< All PCIE graphics card information
+ UINT32 PciGfxCardBitmap; ///< All PCI graphics card information
+} GFX_CARD_CARD_INFO;
+
+VOID
+GfxGetDiscreteCardInfo (
+ OUT GFX_CARD_CARD_INFO *GfxCardInfo,
+ IN AMD_CONFIG_PARAMS *StdHeader
+ );
+
+#endif
diff --git a/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbGfxInitLibV1/GfxEnumConnectors.c b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbGfxInitLibV1/GfxEnumConnectors.c
new file mode 100644
index 0000000000..0a0828ee32
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbGfxInitLibV1/GfxEnumConnectors.c
@@ -0,0 +1,574 @@
+/* $NoKeywords:$ */
+/**
+ * @file
+ *
+ * Service procedure to initialize Integrated Info Table
+ *
+ *
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: GNB
+ * @e \$Revision: 38950 $ @e \$Date: 2010-10-03 23:49:09 -0700 (Sun, 03 Oct 2010) $
+ *
+ */
+/*
+ *****************************************************************************
+ *
+ * Copyright (c) 2011, Advanced Micro Devices, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Advanced Micro Devices, Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***************************************************************************
+ *
+ */
+
+
+/*----------------------------------------------------------------------------------------
+ * M O D U L E S U S E D
+ *----------------------------------------------------------------------------------------
+ */
+#include "AGESA.h"
+#include "Ids.h"
+#include "amdlib.h"
+#include "Gnb.h"
+#include "GnbPcie.h"
+#include "GnbGfx.h"
+#include GNB_MODULE_DEFINITIONS (GnbCommonLib)
+#include GNB_MODULE_DEFINITIONS (GnbPcieInitLibV1)
+#include GNB_MODULE_DEFINITIONS (GnbPcieConfig)
+#include "GnbGfxFamServices.h"
+#include "GnbRegistersON.h"
+#include "Filecode.h"
+#define FILECODE PROC_GNB_MODULES_GNBGFXINITLIBV1_GFXENUMCONNECTORS_FILECODE
+/*----------------------------------------------------------------------------------------
+ * D E F I N I T I O N S A N D M A C R O S
+ *----------------------------------------------------------------------------------------
+ */
+
+
+
+/*----------------------------------------------------------------------------------------
+ * T Y P E D E F S A N D S T R U C T U R E S
+ *----------------------------------------------------------------------------------------
+ */
+
+
+typedef struct {
+ PCIE_CONNECTOR_TYPE ConnectorType;
+ UINT8 DisplayDeviceEnum;
+ UINT16 ConnectorEnum;
+ UINT16 EncoderEnum;
+ UINT8 ConnectorIndex;
+} EXT_CONNECTOR_INFO;
+
+typedef struct {
+ UINT8 DisplayDeviceEnum;
+ UINT8 DeviceIndex;
+ UINT16 DeviceTag;
+ UINT16 DeviceAcpiEnum;
+} EXT_DISPLAY_DEVICE_INFO;
+
+typedef struct {
+ AGESA_STATUS Status;
+ UINT8 DisplayDeviceEnum;
+ UINT8 RequestedPriorityIndex;
+ UINT8 CurrentPriorityIndex;
+ PCIe_ENGINE_CONFIG *Engine;
+} CONNECTOR_ENUM_INFO;
+
+
+/*----------------------------------------------------------------------------------------
+ * P R O T O T Y P E S O F L O C A L F U N C T I O N S
+ *----------------------------------------------------------------------------------------
+ */
+
+AGESA_STATUS
+GfxIntegratedEnumConnectorsForDevice (
+ IN UINT8 DisplayDeviceEnum,
+ OUT EXT_DISPLAY_PATH *DisplayPathList,
+ IN OUT PCIe_PLATFORM_CONFIG *Pcie,
+ IN GFX_PLATFORM_CONFIG *Gfx
+ );
+
+VOID
+GfxIntegratedDebugDumpDisplayPath (
+ IN EXT_DISPLAY_PATH *DisplayPath,
+ IN GFX_PLATFORM_CONFIG *Gfx
+ );
+
+
+
+EXT_CONNECTOR_INFO ConnectorInfoTable[] = {
+ {
+ ConnectorTypeDP,
+ DEVICE_DFP,
+ CONNECTOR_DISPLAYPORT_ENUM,
+ ENCODER_NOT_PRESENT,
+ 0,
+ },
+ {
+ ConnectorTypeEDP,
+ DEVICE_LCD,
+ CONNECTOR_eDP_ENUM,
+ ENCODER_NOT_PRESENT,
+ 1
+ },
+ {
+ ConnectorTypeSingleLinkDVI,
+ DEVICE_DFP,
+ CONNECTOR_SINGLE_LINK_DVI_D_ENUM,
+ ENCODER_NOT_PRESENT,
+ 2
+ },
+ {
+ ConnectorTypeDualLinkDVI,
+ DEVICE_DFP,
+ CONNECTOR_DUAL_LINK_DVI_D_ENUM,
+ ENCODER_NOT_PRESENT,
+ 3
+ },
+ {
+ ConnectorTypeHDMI,
+ DEVICE_DFP,
+ CONNECTOR_HDMI_TYPE_A_ENUM,
+ ENCODER_NOT_PRESENT,
+ 4
+ },
+ {
+ ConnectorTypeTravisDpToVga,
+ DEVICE_CRT,
+ CONNECTOR_VGA_ENUM,
+ ENCODER_TRAVIS_ENUM_ID1,
+ 5
+ },
+ {
+ ConnectorTypeTravisDpToLvds,
+ DEVICE_LCD,
+ CONNECTOR_LVDS_ENUM,
+ ENCODER_TRAVIS_ENUM_ID2,
+ 6
+ },
+ {
+ ConnectorTypeNutmegDpToVga,
+ DEVICE_CRT,
+ CONNECTOR_VGA_ENUM,
+ ENCODER_ALMOND_ENUM_ID1,
+ 5
+ },
+ {
+ ConnectorTypeSingleLinkDviI,
+ DEVICE_DFP,
+ CONNECTOR_SINGLE_LINK_DVI_I_ENUM,
+ ENCODER_NOT_PRESENT,
+ 5
+ },
+ {
+ ConnectorTypeCrt,
+ DEVICE_CRT,
+ CONNECTOR_VGA_ENUM,
+ ENCODER_NOT_PRESENT,
+ 5
+ },
+ {
+ ConnectorTypeLvds,
+ DEVICE_LCD,
+ CONNECTOR_LVDS_ENUM,
+ ENCODER_NOT_PRESENT,
+ 6
+ },
+ {
+ ConnectorTypeAutoDetect,
+ DEVICE_LCD,
+ CONNECTOR_LVDS_eDP_ENUM,
+ ENCODER_TRAVIS_ENUM_ID2,
+ 7
+ }
+};
+
+UINT8 ConnectorNumerArray[] = {
+// DP eDP SDVI-D DDVI-D HDMI VGA LVDS Auto (eDP, LVDS, Travis LVDS)
+ 6, 1, 6, 6, 6, 1, 1, 2
+};
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Enumerate all display connectors for specific display device type.
+ *
+ *
+ *
+ * @param[in] ConnectorType Connector type (see PCIe_DDI_DATA::ConnectorType).
+ * @retval Pointer to EXT_CONNECTOR_INFO
+ * @retval NULL if connector type unknown.
+ */
+EXT_CONNECTOR_INFO*
+GfxIntegratedExtConnectorInfo (
+ IN UINT8 ConnectorType
+ )
+{
+ UINTN Index;
+ for (Index = 0; Index < (sizeof (ConnectorInfoTable) / sizeof (EXT_CONNECTOR_INFO)); Index++) {
+ if (ConnectorInfoTable[Index].ConnectorType == ConnectorType) {
+ return &ConnectorInfoTable[Index];
+ }
+ }
+ return NULL;
+}
+
+EXT_DISPLAY_DEVICE_INFO DisplayDeviceInfoTable[] = {
+ {
+ DEVICE_CRT,
+ 1,
+ ATOM_DEVICE_CRT1_SUPPORT,
+ 0x100,
+ },
+ {
+ DEVICE_LCD,
+ 1,
+ ATOM_DEVICE_LCD1_SUPPORT,
+ 0x110,
+ },
+ {
+ DEVICE_DFP,
+ 1,
+ ATOM_DEVICE_DFP1_SUPPORT,
+ 0x210,
+ },
+ {
+ DEVICE_DFP,
+ 2,
+ ATOM_DEVICE_DFP2_SUPPORT,
+ 0x220,
+ },
+ {
+ DEVICE_DFP,
+ 3,
+ ATOM_DEVICE_DFP3_SUPPORT,
+ 0x230,
+ },
+ {
+ DEVICE_DFP,
+ 4,
+ ATOM_DEVICE_DFP4_SUPPORT,
+ 0x240,
+ },
+ {
+ DEVICE_DFP,
+ 5,
+ ATOM_DEVICE_DFP5_SUPPORT,
+ 0x250,
+ },
+ {
+ DEVICE_DFP,
+ 6,
+ ATOM_DEVICE_DFP6_SUPPORT,
+ 0x260,
+ }
+};
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Enumerate all display connectors for specific display device type.
+ *
+ *
+ *
+ * @param[in] DisplayDeviceEnum Display device enum
+ * @param[in] DisplayDeviceIndex Display device index
+ * @retval Pointer to EXT_DISPLAY_DEVICE_INFO
+ * @retval NULL if can not get display device info
+ */
+EXT_DISPLAY_DEVICE_INFO*
+GfxIntegratedExtDisplayDeviceInfo (
+ IN UINT8 DisplayDeviceEnum,
+ IN UINT8 DisplayDeviceIndex
+ )
+{
+ UINT8 Index;
+ UINT8 LastIndex;
+ LastIndex = 0xff;
+ for (Index = 0; Index < (sizeof (DisplayDeviceInfoTable) / sizeof (EXT_DISPLAY_DEVICE_INFO)); Index++) {
+ if (DisplayDeviceInfoTable[Index].DisplayDeviceEnum == DisplayDeviceEnum) {
+ LastIndex = Index;
+ if (DisplayDeviceInfoTable[Index].DeviceIndex == DisplayDeviceIndex) {
+ return &DisplayDeviceInfoTable[Index];
+ }
+ }
+ }
+ if (DisplayDeviceEnum == DEVICE_LCD && LastIndex != 0xff) {
+ return &DisplayDeviceInfoTable[LastIndex];
+ }
+ return NULL;
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Enumerate all display connectors
+ *
+ *
+ *
+ * @param[out] DisplayPathList Display path list
+ * @param[in,out] Pcie PCIe platform configuration info
+ * @param[in] Gfx Gfx configuration info
+ */
+AGESA_STATUS
+GfxIntegratedEnumerateAllConnectors (
+ OUT EXT_DISPLAY_PATH *DisplayPathList,
+ IN OUT PCIe_PLATFORM_CONFIG *Pcie,
+ IN GFX_PLATFORM_CONFIG *Gfx
+ )
+{
+ AGESA_STATUS AgesaStatus;
+ AGESA_STATUS Status;
+ AgesaStatus = AGESA_SUCCESS;
+ IDS_HDT_CONSOLE (GNB_TRACE, "GfxIntegratedEnumerateAllConnectors Enter\n");
+ Status = GfxIntegratedEnumConnectorsForDevice (
+ DEVICE_DFP,
+ DisplayPathList,
+ Pcie,
+ Gfx
+ );
+ AGESA_STATUS_UPDATE (Status, AgesaStatus);
+
+ Status = GfxIntegratedEnumConnectorsForDevice (
+ DEVICE_CRT,
+ DisplayPathList,
+ Pcie,
+ Gfx
+ );
+ AGESA_STATUS_UPDATE (Status, AgesaStatus);
+
+ Status = GfxIntegratedEnumConnectorsForDevice (
+ DEVICE_LCD,
+ DisplayPathList,
+ Pcie,
+ Gfx
+ );
+ AGESA_STATUS_UPDATE (Status, AgesaStatus);
+ IDS_HDT_CONSOLE (GNB_TRACE, "GfxIntegratedEnumerateAllConnectors Exit [0x%x]\n", Status);
+ return AgesaStatus;
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Enumerate all display connectors for specific display device type.
+ *
+ *
+ *
+ * @param[in] Engine Engine configuration info
+ * @param[in,out] Buffer Buffer pointer
+ * @param[in] Pcie PCIe configuration info
+ */
+VOID
+STATIC
+GfxIntegratedDdiInterfaceCallback (
+ IN PCIe_ENGINE_CONFIG *Engine,
+ IN OUT VOID *Buffer,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ CONNECTOR_ENUM_INFO *ConnectorEnumInfo;
+ EXT_CONNECTOR_INFO *ExtConnectorInfo;
+ ConnectorEnumInfo = (CONNECTOR_ENUM_INFO*) Buffer;
+ ExtConnectorInfo = GfxIntegratedExtConnectorInfo (Engine->Type.Ddi.DdiData.ConnectorType);
+ if (ExtConnectorInfo == NULL) {
+ AGESA_STATUS_UPDATE (AGESA_ERROR, ConnectorEnumInfo->Status);
+ PcieConfigDisableEngine (Engine);
+ return;
+ }
+ if (ExtConnectorInfo->DisplayDeviceEnum != ConnectorEnumInfo->DisplayDeviceEnum) {
+ //Not device type we are looking for
+ return;
+ }
+ if (Engine->Type.Ddi.DisplayPriorityIndex >= ConnectorEnumInfo->RequestedPriorityIndex &&
+ Engine->Type.Ddi.DisplayPriorityIndex < ConnectorEnumInfo->CurrentPriorityIndex) {
+ ConnectorEnumInfo->CurrentPriorityIndex = Engine->Type.Ddi.DisplayPriorityIndex;
+ ConnectorEnumInfo->Engine = Engine;
+ }
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Enumerate all display connectors for specific display device type.
+ *
+ *
+ *
+ * @param[in] DisplayDeviceEnum Display device list
+ * @param[out] DisplayPathList Display path list
+ * @param[in,out] Pcie PCIe configuration info
+ * @param[in] Gfx Gfx configuration info
+ */
+AGESA_STATUS
+GfxIntegratedEnumConnectorsForDevice (
+ IN UINT8 DisplayDeviceEnum,
+ OUT EXT_DISPLAY_PATH *DisplayPathList,
+ IN OUT PCIe_PLATFORM_CONFIG *Pcie,
+ IN GFX_PLATFORM_CONFIG *Gfx
+ )
+{
+ UINT8 DisplayDeviceIndex;
+ CONNECTOR_ENUM_INFO ConnectorEnumInfo;
+ EXT_CONNECTOR_INFO *ExtConnectorInfo;
+ EXT_DISPLAY_DEVICE_INFO *ExtDisplayDeviceInfo;
+ AGESA_STATUS Status;
+ UINT8 ConnectorIdArray[sizeof (ConnectorNumerArray)];
+ ConnectorEnumInfo.Status = AGESA_SUCCESS;
+ DisplayDeviceIndex = 1;
+ ConnectorEnumInfo.RequestedPriorityIndex = 0;
+ ConnectorEnumInfo.DisplayDeviceEnum = DisplayDeviceEnum;
+ LibAmdMemFill (ConnectorIdArray, 0x00, sizeof (ConnectorIdArray), GnbLibGetHeader (Gfx));
+ do {
+ ConnectorEnumInfo.Engine = NULL;
+ ConnectorEnumInfo.CurrentPriorityIndex = 0xff;
+ PcieConfigRunProcForAllEngines (
+ DESCRIPTOR_ALLOCATED | DESCRIPTOR_VIRTUAL | DESCRIPTOR_DDI_ENGINE,
+ GfxIntegratedDdiInterfaceCallback,
+ &ConnectorEnumInfo,
+ Pcie
+ );
+ if (ConnectorEnumInfo.Engine == NULL) {
+ break; // No more connector support this
+ }
+ ConnectorEnumInfo.RequestedPriorityIndex = ConnectorEnumInfo.CurrentPriorityIndex + 1;
+ ExtConnectorInfo = GfxIntegratedExtConnectorInfo (ConnectorEnumInfo.Engine->Type.Ddi.DdiData.ConnectorType);
+ ASSERT (ExtConnectorInfo != NULL);
+ ASSERT (ExtConnectorInfo->ConnectorIndex < sizeof (ConnectorIdArray));
+ if (ConnectorIdArray[ExtConnectorInfo->ConnectorIndex] >= ConnectorNumerArray[ExtConnectorInfo->ConnectorIndex]) {
+ //Run out of supported connectors
+ AGESA_STATUS_UPDATE (AGESA_ERROR, ConnectorEnumInfo.Status);
+ PcieConfigDisableEngine (ConnectorEnumInfo.Engine);
+ continue;
+ }
+ ConnectorEnumInfo.Engine->Type.Ddi.ConnectorId = ConnectorIdArray[ExtConnectorInfo->ConnectorIndex] + 1;
+ ExtDisplayDeviceInfo = GfxIntegratedExtDisplayDeviceInfo (DisplayDeviceEnum, DisplayDeviceIndex);
+ if (ExtDisplayDeviceInfo == NULL) {
+ //Run out of supported display device types
+ AGESA_STATUS_UPDATE (AGESA_ERROR, ConnectorEnumInfo.Status);
+ Status = AGESA_ERROR;
+ PcieConfigDisableEngine (ConnectorEnumInfo.Engine);
+ }
+
+ if ((Gfx->Gnb3dStereoPinIndex != 0) && (ConnectorEnumInfo.Engine->Type.Ddi.DdiData.HdpIndex == (Gfx->Gnb3dStereoPinIndex - 1))) {
+ AGESA_STATUS_UPDATE (AGESA_ERROR, ConnectorEnumInfo.Status);
+ Status = AGESA_ERROR;
+ PcieConfigDisableEngine (ConnectorEnumInfo.Engine);
+ }
+
+ ConnectorEnumInfo.Engine->Type.Ddi.DisplayDeviceId = DisplayDeviceIndex;
+
+ Status = GfxFmMapEngineToDisplayPath (ConnectorEnumInfo.Engine, DisplayPathList, Gfx);
+ AGESA_STATUS_UPDATE (Status, ConnectorEnumInfo.Status);
+ if (Status != AGESA_SUCCESS) {
+ continue;
+ }
+ ConnectorIdArray[ExtConnectorInfo->ConnectorIndex]++;
+ DisplayDeviceIndex++;
+ } while (ConnectorEnumInfo.Engine != NULL);
+ return ConnectorEnumInfo.Status;
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Initialize display path for given engine
+ *
+ *
+ *
+ * @param[in] Engine Engine configuration info
+ * @param[out] DisplayPath Display path list
+ * @param[out] SecondaryDisplayPath Secondary display path list
+ * @param[in] Gfx Gfx configuration info
+ */
+
+VOID
+GfxIntegratedCopyDisplayInfo (
+ IN PCIe_ENGINE_CONFIG *Engine,
+ OUT EXT_DISPLAY_PATH *DisplayPath,
+ OUT EXT_DISPLAY_PATH *SecondaryDisplayPath,
+ IN GFX_PLATFORM_CONFIG *Gfx
+ )
+{
+ EXT_CONNECTOR_INFO *ExtConnectorInfo;
+ EXT_DISPLAY_DEVICE_INFO *ExtDisplayDeviceInfo;
+ ExtConnectorInfo = GfxIntegratedExtConnectorInfo (Engine->Type.Ddi.DdiData.ConnectorType);
+ ExtDisplayDeviceInfo = GfxIntegratedExtDisplayDeviceInfo (ExtConnectorInfo->DisplayDeviceEnum, Engine->Type.Ddi.DisplayDeviceId);
+ DisplayPath->usDeviceConnector = ExtConnectorInfo->ConnectorEnum | (Engine->Type.Ddi.ConnectorId << 8);
+ DisplayPath->usDeviceTag = ExtDisplayDeviceInfo->DeviceTag;
+ DisplayPath->usDeviceACPIEnum = ExtDisplayDeviceInfo->DeviceAcpiEnum;
+ DisplayPath->ucExtAUXDDCLutIndex = Engine->Type.Ddi.DdiData.AuxIndex;
+ DisplayPath->ucExtHPDPINLutIndex = Engine->Type.Ddi.DdiData.HdpIndex;
+ DisplayPath->usExtEncoderObjId = ExtConnectorInfo->EncoderEnum;
+ if (Engine->Type.Ddi.DdiData.Mapping[0].ChannelMappingValue == 0) {
+ DisplayPath->ChannelMapping.ucChannelMapping = (Engine->EngineData.StartLane < Engine->EngineData.EndLane) ? 0xE4 : 0x1B;
+ } else {
+ DisplayPath->ChannelMapping.ucChannelMapping = Engine->Type.Ddi.DdiData.Mapping[0].ChannelMappingValue;
+ }
+ GNB_DEBUG_CODE (
+ GfxIntegratedDebugDumpDisplayPath (DisplayPath, Gfx);
+ );
+ if (Engine->Type.Ddi.DdiData.ConnectorType == ConnectorTypeDualLinkDVI) {
+ ASSERT (SecondaryDisplayPath != NULL);
+ GNB_DEBUG_CODE (
+ GfxIntegratedDebugDumpDisplayPath (DisplayPath, Gfx);
+ );
+ SecondaryDisplayPath->usDeviceConnector = DisplayPath->usDeviceConnector;
+ if (Engine->Type.Ddi.DdiData.Mapping[1].ChannelMappingValue == 0) {
+ DisplayPath->ChannelMapping.ucChannelMapping = (Engine->EngineData.StartLane < Engine->EngineData.EndLane) ? 0xE4 : 0x1B;
+ } else {
+ DisplayPath->ChannelMapping.ucChannelMapping = Engine->Type.Ddi.DdiData.Mapping[1].ChannelMappingValue;
+ }
+ }
+}
+
+
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Dump display path settings
+ *
+ *
+ *
+ * @param[in] DisplayPath Display path
+ * @param[in] Gfx Gfx configuration
+ */
+
+VOID
+GfxIntegratedDebugDumpDisplayPath (
+ IN EXT_DISPLAY_PATH *DisplayPath,
+ IN GFX_PLATFORM_CONFIG *Gfx
+ )
+{
+ IDS_HDT_CONSOLE (GFX_MISC, " usDeviceConnector = 0x%x\n",
+ DisplayPath->usDeviceConnector
+ );
+ IDS_HDT_CONSOLE (GFX_MISC, " usDeviceTag = 0x%x\n",
+ DisplayPath->usDeviceTag
+ );
+ IDS_HDT_CONSOLE (GFX_MISC, " usDeviceACPIEnum = 0x%x\n",
+ DisplayPath->usDeviceACPIEnum
+ );
+ IDS_HDT_CONSOLE (GFX_MISC, " usExtEncoderObjId = 0x%x\n",
+ DisplayPath->usExtEncoderObjId
+ );
+ IDS_HDT_CONSOLE (GFX_MISC, " ucChannelMapping = 0x%x\n",
+ DisplayPath->ChannelMapping.ucChannelMapping
+ );
+
+}
diff --git a/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbGfxInitLibV1/GfxEnumConnectors.h b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbGfxInitLibV1/GfxEnumConnectors.h
new file mode 100644
index 0000000000..b592965f40
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbGfxInitLibV1/GfxEnumConnectors.h
@@ -0,0 +1,65 @@
+/* $NoKeywords:$ */
+/**
+ * @file
+ *
+ * Service procedure to initialize Integrated Info Table
+ *
+ *
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: GNB
+ * @e \$Revision: 38519 $ @e \$Date: 2010-09-24 17:08:48 -0700 (Fri, 24 Sep 2010) $
+ *
+ */
+/*
+ *****************************************************************************
+ *
+ * Copyright (c) 2011, Advanced Micro Devices, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Advanced Micro Devices, Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***************************************************************************
+ *
+ */
+#ifndef _GFXENUMCONNECTORS_H_
+#define _GFXENUMCONNECTORS_H_
+
+
+VOID
+GfxIntegratedCopyDisplayInfo (
+ IN PCIe_ENGINE_CONFIG *Engine,
+ OUT EXT_DISPLAY_PATH *DisplayPath,
+ OUT EXT_DISPLAY_PATH *SecondaryDisplayPath,
+ IN GFX_PLATFORM_CONFIG *Gfx
+ );
+
+AGESA_STATUS
+GfxIntegratedEnumerateAllConnectors (
+ OUT EXT_DISPLAY_PATH *DisplayPathList,
+ IN OUT PCIe_PLATFORM_CONFIG *Pcie,
+ IN GFX_PLATFORM_CONFIG *Gfx
+ );
+
+#endif
diff --git a/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbGfxInitLibV1/GfxPowerPlayTable.c b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbGfxInitLibV1/GfxPowerPlayTable.c
new file mode 100644
index 0000000000..e42a83f675
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbGfxInitLibV1/GfxPowerPlayTable.c
@@ -0,0 +1,572 @@
+/* $NoKeywords:$ */
+/**
+ * @file
+ *
+ * Service procedure to initialize Integrated Info Table
+ *
+ *
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: GNB
+ * @e \$Revision: 38882 $ @e \$Date: 2010-09-30 18:42:57 -0700 (Thu, 30 Sep 2010) $
+ *
+ */
+/*
+ *****************************************************************************
+ *
+ * Copyright (c) 2011, Advanced Micro Devices, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Advanced Micro Devices, Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***************************************************************************
+ *
+ */
+
+
+/*----------------------------------------------------------------------------------------
+ * M O D U L E S U S E D
+ *----------------------------------------------------------------------------------------
+ */
+#include "AGESA.h"
+#include "Ids.h"
+#include "amdlib.h"
+#include "heapManager.h"
+#include "Gnb.h"
+#include "GnbFuseTable.h"
+#include "GnbPcie.h"
+#include "GnbGfx.h"
+#include "GnbFuseTable.h"
+#include "GnbGfxFamServices.h"
+#include GNB_MODULE_DEFINITIONS (GnbCommonLib)
+#include "GfxPowerPlayTable.h"
+#include "Filecode.h"
+#define FILECODE PROC_GNB_MODULES_GNBGFXINITLIBV1_GFXPOWERPLAYTABLE_FILECODE
+
+/*----------------------------------------------------------------------------------------
+ * D E F I N I T I O N S A N D M A C R O S
+ *----------------------------------------------------------------------------------------
+ */
+
+
+
+/*----------------------------------------------------------------------------------------
+ * T Y P E D E F S A N D S T R U C T U R E S
+ *----------------------------------------------------------------------------------------
+ */
+/// Software state
+typedef struct {
+ BOOLEAN Valid; ///< State valid
+ UINT16 Classification; ///< State classification
+ UINT32 CapsAndSettings; ///< State capability and settings
+ UINT32 Vclk; ///< UVD VCLK
+ UINT32 Dclk; ///< UVD DCLK
+ UINT8 NumberOfDpmStates; ///< Number of DPM states
+ UINT8 DpmSatesArray[MAX_NUM_OF_DPM_STATES]; ///< DPM state index array
+} SW_STATE;
+
+/// DPM state
+typedef struct {
+ BOOLEAN Valid; ///< State valid
+ UINT32 Sclk; ///< Sclk in kHz
+ UINT8 Vid; ///< VID index
+} DPM_STATE;
+
+/*----------------------------------------------------------------------------------------
+ * P R O T O T Y P E S O F L O C A L F U N C T I O N S
+ *----------------------------------------------------------------------------------------
+ */
+
+VOID
+GfxIntegratedDebugDumpPpTable (
+ IN ATOM_PPLIB_POWERPLAYTABLE3 *PpTable,
+ IN GFX_PLATFORM_CONFIG *Gfx
+ );
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Create new software state
+ *
+ *
+ * @param[in, out] SwStateArray Pointer to SW state array
+ * @retval Pointer to state entry in SW state array
+ */
+
+SW_STATE*
+GfxPowerPlayCreateSwState (
+ IN OUT SW_STATE *SwStateArray
+ )
+{
+ UINTN Index;
+ for (Index = 0; Index < MAX_NUM_OF_SW_STATES; Index++) {
+ if (SwStateArray[Index].Valid == FALSE) {
+ SwStateArray[Index].Valid = TRUE;
+ return &SwStateArray[Index];
+ }
+ }
+ return NULL;
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Create new DPM state
+ *
+ *
+ * @param[in, out] DpmStateArray Pointer to DPM state array
+ * @param[in] Sclk SCLK in kHz
+ * @param[in] Vid Vid index
+ * @retval Index of state entry in DPM state array
+ */
+
+UINT8
+GfxPowerPlayCreateDpmState (
+ IN DPM_STATE *DpmStateArray,
+ IN UINT32 Sclk,
+ IN UINT8 Vid
+ )
+{
+ UINT8 Index;
+ for (Index = 0; Index < MAX_NUM_OF_DPM_STATES; Index++) {
+ if (DpmStateArray[Index].Valid == FALSE) {
+ DpmStateArray[Index].Sclk = Sclk;
+ DpmStateArray[Index].Vid = Vid;
+ DpmStateArray[Index].Valid = TRUE;
+ return Index;
+ }
+ }
+ return 0;
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Locate existing or Create new DPM state
+ *
+ *
+ * @param[in, out] DpmStateArray Pointer to DPM state array
+ * @param[in] Sclk SCLK in kHz
+ * @param[in] Vid Vid index
+ * @retval Index of state entry in DPM state array
+ */
+
+UINT8
+GfxPowerPlayAddDpmState (
+ IN DPM_STATE *DpmStateArray,
+ IN UINT32 Sclk,
+ IN UINT8 Vid
+ )
+{
+ UINT8 Index;
+ for (Index = 0; Index < MAX_NUM_OF_DPM_STATES; Index++) {
+ if (DpmStateArray[Index].Valid && Sclk == DpmStateArray[Index].Sclk && Vid == DpmStateArray[Index].Vid) {
+ return Index;
+ }
+ }
+ return GfxPowerPlayCreateDpmState (DpmStateArray, Sclk, Vid);
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Add reference to DPM state for SW state
+ *
+ *
+ * @param[in, out] SwStateArray Pointer to SW state array
+ * @param[in] DpmStateIndex DPM state index
+ */
+
+VOID
+GfxPowerPlayAddDpmStateToSwState (
+ IN OUT SW_STATE *SwStateArray,
+ IN UINT8 DpmStateIndex
+ )
+{
+ SwStateArray->DpmSatesArray[SwStateArray->NumberOfDpmStates++] = DpmStateIndex;
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Copy SW state info to PPTable
+ *
+ *
+ * @param[out] StateArray Pointer to PPtable SW state array
+ * @param[in] SwStateArray Pointer to SW state array
+ * @param[in] StdHeader Standard configuration header
+ */
+UINT32
+GfxPowerPlayCopyStateInfo (
+ IN OUT STATE_ARRAY *StateArray,
+ IN SW_STATE *SwStateArray,
+ IN AMD_CONFIG_PARAMS *StdHeader
+ )
+{
+ UINT8 Index;
+ UINT8 SwStateIndex;
+ ATOM_PPLIB_STATE_V2 *States;
+ States = &StateArray->States[0];
+ SwStateIndex = 0;
+ for (Index = 0; Index < MAX_NUM_OF_SW_STATES; Index++) {
+ if (SwStateArray[Index].Valid && SwStateArray[Index].NumberOfDpmStates != 0) {
+ States->nonClockInfoIndex = SwStateIndex;
+ States->ucNumDPMLevels = SwStateArray[Index].NumberOfDpmStates;
+ LibAmdMemCopy (
+ &States->ClockInfoIndex[0],
+ SwStateArray[Index].DpmSatesArray,
+ SwStateArray[Index].NumberOfDpmStates,
+ StdHeader
+ );
+ States = (ATOM_PPLIB_STATE_V2*) ((UINT8*) States + sizeof (ATOM_PPLIB_STATE_V2) + sizeof (UINT8) * (States->ucNumDPMLevels - 1));
+ SwStateIndex++;
+ }
+ }
+ StateArray->ucNumEntries = SwStateIndex;
+ return (UINT32) ((UINT8*) States - (UINT8*) StateArray);
+}
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Copy clock info to PPTable
+ *
+ *
+ * @param[out] ClockInfoArray Pointer to clock info array
+ * @param[in] DpmStateArray Pointer to DPM state array
+ * @param[in] StdHeader Standard configuration header
+ */
+
+UINT32
+GfxPowerPlayCopyClockInfo (
+ IN CLOCK_INFO_ARRAY *ClockInfoArray,
+ IN DPM_STATE *DpmStateArray,
+ IN AMD_CONFIG_PARAMS *StdHeader
+ )
+{
+ UINT8 Index;
+ UINT8 ClkStateIndex;
+ ClkStateIndex = 0;
+ for (Index = 0; Index < MAX_NUM_OF_DPM_STATES; Index++) {
+ if (DpmStateArray[Index].Valid == TRUE) {
+ ClockInfoArray->ClockInfo[ClkStateIndex].ucEngineClockHigh = (UINT8) (DpmStateArray[Index].Sclk >> 16);
+ ClockInfoArray->ClockInfo[ClkStateIndex].usEngineClockLow = (UINT16) (DpmStateArray[Index].Sclk);
+ ClockInfoArray->ClockInfo[ClkStateIndex].vddcIndex = DpmStateArray[Index].Vid;
+ ClkStateIndex++;
+ }
+ }
+ ClockInfoArray->ucNumEntries = ClkStateIndex;
+ ClockInfoArray->ucEntrySize = sizeof (ATOM_PPLIB_SUMO_CLOCK_INFO);
+ return sizeof (CLOCK_INFO_ARRAY) + sizeof (ATOM_PPLIB_SUMO_CLOCK_INFO) * (ClkStateIndex) - sizeof (ATOM_PPLIB_SUMO_CLOCK_INFO);
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Copy non clock info to PPTable
+ *
+ *
+ * @param[out] NonClockInfoArray Pointer to PPtable Non clock array
+ * @param[in] SwStateArray Pointer to SW state array
+ * @param[in] StdHeader Standard configuration header
+ */
+
+UINT32
+GfxPowerPlayCopyNonClockInfo (
+ IN NON_CLOCK_INFO_ARRAY *NonClockInfoArray,
+ IN SW_STATE *SwStateArray,
+ IN AMD_CONFIG_PARAMS *StdHeader
+ )
+{
+ UINT8 Index;
+ UINT8 NonClkStateIndex;
+ NonClkStateIndex = 0;
+ for (Index = 0; Index < MAX_NUM_OF_SW_STATES; Index++) {
+ if (SwStateArray[Index].Valid && SwStateArray[Index].NumberOfDpmStates != 0) {
+ NonClockInfoArray->NonClockInfo[NonClkStateIndex].usClassification = SwStateArray[Index].Classification;
+ NonClockInfoArray->NonClockInfo[NonClkStateIndex].ulCapsAndSettings = SwStateArray[Index].CapsAndSettings;
+ NonClockInfoArray->NonClockInfo[NonClkStateIndex].ulDCLK = SwStateArray[Index].Dclk;
+ NonClockInfoArray->NonClockInfo[NonClkStateIndex].ulVCLK = SwStateArray[Index].Vclk;
+ NonClkStateIndex++;
+ }
+ }
+ NonClockInfoArray->ucNumEntries = NonClkStateIndex;
+ NonClockInfoArray->ucEntrySize = sizeof (ATOM_PPLIB_NONCLOCK_INFO);
+ return sizeof (NON_CLOCK_INFO_ARRAY) + sizeof (ATOM_PPLIB_NONCLOCK_INFO) * NonClkStateIndex - sizeof (ATOM_PPLIB_NONCLOCK_INFO);
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Check if fused state valid
+ *
+ *
+ * @param[out] Index State index
+ * @param[in] PpFuses Pointer to fuse table
+ * @param[in] Gfx Gfx configuration info
+ * @retval TRUE State is valid
+ */
+BOOLEAN
+GfxPowerPlayIsFusedStateValid (
+ IN UINT8 Index,
+ IN PP_FUSE_ARRAY *PpFuses,
+ IN GFX_PLATFORM_CONFIG *Gfx
+ )
+{
+ BOOLEAN Result;
+ Result = FALSE;
+ if (PpFuses->SclkDpmValid[Index] != 0) {
+ Result = TRUE;
+ if (PpFuses->PolicyLabel[Index] == POLICY_LABEL_BATTERY && (Gfx->AmdPlatformType & AMD_PLATFORM_MOBILE) == 0) {
+ Result = FALSE;
+ }
+ }
+ return Result;
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Get SW state calssification from fuses
+ *
+ *
+ * @param[out] Index State index
+ * @param[in] PpFuses Pointer to fuse table
+ * @param[in] Gfx Gfx configuration info
+ * @retval State classification
+ */
+
+UINT16
+GfxPowerPlayGetClassificationFromFuses (
+ IN UINT8 Index,
+ IN PP_FUSE_ARRAY *PpFuses,
+ IN GFX_PLATFORM_CONFIG *Gfx
+ )
+{
+ UINT16 Classification;
+ Classification = 0;
+ switch (PpFuses->PolicyFlags[Index]) {
+ case 0x1:
+ Classification |= ATOM_PPLIB_CLASSIFICATION_NONUVDSTATE;
+ break;
+ case 0x2:
+ Classification |= ATOM_PPLIB_CLASSIFICATION_UVDSTATE;
+ break;
+ case 0x4:
+ //Possible SD + HD state
+ break;
+ case 0x8:
+ Classification |= ATOM_PPLIB_CLASSIFICATION_HDSTATE;
+ break;
+ case 0x10:
+ Classification |= ATOM_PPLIB_CLASSIFICATION_SDSTATE;
+ break;
+ default:
+ break;
+ }
+ switch (PpFuses->PolicyLabel[Index]) {
+ case POLICY_LABEL_BATTERY:
+ Classification |= ATOM_PPLIB_CLASSIFICATION_UI_BATTERY;
+ break;
+ case POLICY_LABEL_PERFORMANCE:
+ Classification |= ATOM_PPLIB_CLASSIFICATION_UI_PERFORMANCE;
+ break;
+ default:
+ break;
+ }
+ return Classification;
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Build PP table
+ *
+ *
+ * @param[out] Buffer Buffer to create PP table
+ * @param[in] Gfx Gfx configuration info
+ * @retval AGESA_SUCCESS
+ * @retval AGESA_ERROR
+ */
+
+AGESA_STATUS
+GfxPowerPlayBuildTable (
+ OUT VOID *Buffer,
+ IN GFX_PLATFORM_CONFIG *Gfx
+ )
+{
+ ATOM_PPLIB_POWERPLAYTABLE3 *PpTable;
+ SW_STATE SwStateArray [MAX_NUM_OF_SW_STATES];
+ DPM_STATE DpmStateArray[MAX_NUM_OF_DPM_STATES];
+ UINT8 ClkStateIndex;
+ UINT8 DpmFuseIndex;
+ UINT8 Index;
+ UINT32 StateArrayLength;
+ UINT32 ClockArrayLength;
+ UINT32 NonClockArrayLength;
+ SW_STATE *State;
+ PP_FUSE_ARRAY *PpFuses;
+
+ PpFuses = GnbLocateHeapBuffer (AMD_PP_FUSE_TABLE_HANDLE, GnbLibGetHeader (Gfx));
+ ASSERT (PpFuses != NULL);
+ if (PpFuses == NULL) {
+ return AGESA_ERROR;
+ }
+
+ PpTable = (ATOM_PPLIB_POWERPLAYTABLE3 *) Buffer;
+ LibAmdMemFill (SwStateArray, 0x00, sizeof (SwStateArray), GnbLibGetHeader (Gfx));
+ LibAmdMemFill (DpmStateArray, 0x00, sizeof (DpmStateArray), GnbLibGetHeader (Gfx));
+ // Create States from Fuses
+ for (Index = 0; Index < MAX_NUM_OF_FUSED_SW_STATES; Index++) {
+ if (GfxPowerPlayIsFusedStateValid (Index, PpFuses, Gfx)) {
+ //Create new SW State;
+ State = GfxPowerPlayCreateSwState (SwStateArray);
+ State->Classification = GfxPowerPlayGetClassificationFromFuses (Index, PpFuses, Gfx);
+ if ((State->Classification & (ATOM_PPLIB_CLASSIFICATION_HDSTATE | ATOM_PPLIB_CLASSIFICATION_UVDSTATE)) != 0) {
+ State->Vclk = (PpFuses->VclkDid[PpFuses->VclkDclkSel[Index]] != 0) ? GfxFmCalculateClock (PpFuses->VclkDid[PpFuses->VclkDclkSel[Index]], GnbLibGetHeader (Gfx)) : 0;
+ State->Dclk = (PpFuses->DclkDid[PpFuses->VclkDclkSel[Index]] != 0) ? GfxFmCalculateClock (PpFuses->DclkDid[PpFuses->VclkDclkSel[Index]], GnbLibGetHeader (Gfx)) : 0;
+ }
+ if ((State->Classification & 0x7) == ATOM_PPLIB_CLASSIFICATION_UI_BATTERY) {
+ if (Gfx->AbmSupport != 0) {
+ State->CapsAndSettings |= ATOM_PPLIB_ENABLE_VARIBRIGHT;
+ }
+ if (Gfx->DynamicRefreshRate != 0) {
+ State->CapsAndSettings |= ATOM_PPLIB_ENABLE_DRR;
+ }
+ }
+ for (DpmFuseIndex = 0; DpmFuseIndex < MAX_NUM_OF_FUSED_DPM_STATES; DpmFuseIndex++) {
+ if ((PpFuses->SclkDpmValid[Index] & (1 << DpmFuseIndex)) != 0 ) {
+ UINT32 Sclk;
+ Sclk = (PpFuses->SclkDpmDid[DpmFuseIndex] != 0) ? GfxFmCalculateClock (PpFuses->SclkDpmDid[DpmFuseIndex], GnbLibGetHeader (Gfx)) : 0;
+ if (Sclk != 0) {
+ ClkStateIndex = GfxPowerPlayAddDpmState (DpmStateArray, Sclk, PpFuses->SclkDpmVid[DpmFuseIndex]);
+ GfxPowerPlayAddDpmStateToSwState (State, ClkStateIndex);
+ }
+ }
+ }
+ }
+ }
+ // Create Boot State
+ State = GfxPowerPlayCreateSwState (SwStateArray);
+ State->Classification = ATOM_PPLIB_CLASSIFICATION_BOOT;
+ ClkStateIndex = GfxPowerPlayAddDpmState (DpmStateArray, 200 * 100, 0);
+ GfxPowerPlayAddDpmStateToSwState (State, ClkStateIndex);
+
+ // Create Thermal State
+ State = GfxPowerPlayCreateSwState (SwStateArray);
+ State->Classification = ATOM_PPLIB_CLASSIFICATION_THERMAL;
+ ClkStateIndex = GfxPowerPlayAddDpmState (DpmStateArray, 200 * 100, 0);
+ GfxPowerPlayAddDpmStateToSwState (State, ClkStateIndex);
+
+ //Copy state info to actual PP table
+ StateArrayLength = GfxPowerPlayCopyStateInfo (
+ &PpTable->StateArray,
+ SwStateArray,
+ GnbLibGetHeader (Gfx)
+ );
+ ClockArrayLength = GfxPowerPlayCopyClockInfo (
+ (CLOCK_INFO_ARRAY*) ((UINT8 *)&PpTable->StateArray + StateArrayLength),
+ DpmStateArray,
+ GnbLibGetHeader (Gfx)
+ );
+ NonClockArrayLength = GfxPowerPlayCopyNonClockInfo (
+ (NON_CLOCK_INFO_ARRAY*) ((UINT8 *)&PpTable->StateArray + StateArrayLength + ClockArrayLength),
+ SwStateArray,
+ GnbLibGetHeader (Gfx)
+ );
+ //Fill static info
+ PpTable->sHeader.ucTableFormatRevision = 6;
+ PpTable->sHeader.ucTableContentRevision = 1;
+ PpTable->ucDataRevision = PpFuses->PPlayTableRev;
+ PpTable->sThermalController.ucType = ATOM_PP_THERMALCONTROLLER_SUMO;
+ PpTable->sThermalController.ucFanParameters = ATOM_PP_FANPARAMETERS_NOFAN;
+ if ((Gfx->AmdPlatformType & AMD_PLATFORM_MOBILE) != 0) {
+ PpTable->ulPlatformCaps |= ATOM_PP_PLATFORM_CAP_POWERPLAY;
+ }
+ PpTable->usStateArrayOffset = offsetof (ATOM_PPLIB_POWERPLAYTABLE3, StateArray);
+ PpTable->usClockInfoArrayOffset = (USHORT) (offsetof (ATOM_PPLIB_POWERPLAYTABLE3, StateArray) + StateArrayLength);
+ PpTable->usNonClockInfoArrayOffset = (USHORT) (offsetof (ATOM_PPLIB_POWERPLAYTABLE3, StateArray) + StateArrayLength + ClockArrayLength);
+ PpTable->sHeader.usStructureSize = (USHORT) (offsetof (ATOM_PPLIB_POWERPLAYTABLE3, StateArray) + StateArrayLength + ClockArrayLength + NonClockArrayLength);
+ PpTable->usFormatID = 7;
+ GNB_DEBUG_CODE (
+ GfxIntegratedDebugDumpPpTable (PpTable, Gfx);
+ );
+ return AGESA_SUCCESS;
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Dump PP table
+ *
+ *
+ *
+ * @param[in] PpTable Power Play table
+ * @param[in] Gfx Gfx configuration info
+ */
+
+VOID
+GfxIntegratedDebugDumpPpTable (
+ IN ATOM_PPLIB_POWERPLAYTABLE3 *PpTable,
+ IN GFX_PLATFORM_CONFIG *Gfx
+ )
+{
+ UINTN Index;
+ UINTN DpmIndex;
+ ATOM_PPLIB_STATE_V2 *StatesPtr;
+ NON_CLOCK_INFO_ARRAY *NonClockInfoArrayPtr;
+ CLOCK_INFO_ARRAY *ClockInfoArrayPtr;
+ IDS_HDT_CONSOLE (GFX_MISC, " < --- Power Play Table ------ > \n");
+
+ IDS_HDT_CONSOLE (GFX_MISC, " Table Revision = %d\n", PpTable->ucDataRevision
+ );
+ StatesPtr = PpTable->StateArray.States;
+ NonClockInfoArrayPtr = (NON_CLOCK_INFO_ARRAY *) ((UINT8 *) PpTable + PpTable->usNonClockInfoArrayOffset);
+ ClockInfoArrayPtr = (CLOCK_INFO_ARRAY *) ((UINT8 *) PpTable + PpTable->usClockInfoArrayOffset);
+ for (Index = 0; Index < PpTable->StateArray.ucNumEntries; Index++) {
+ IDS_HDT_CONSOLE (GFX_MISC, " State #%d\n", Index + 1
+ );
+ IDS_HDT_CONSOLE (GFX_MISC, " Classification 0x%x\n",
+ NonClockInfoArrayPtr->NonClockInfo[StatesPtr->nonClockInfoIndex].usClassification
+ );
+ IDS_HDT_CONSOLE (GFX_MISC, " VCLK = %dkHz\n",
+ NonClockInfoArrayPtr->NonClockInfo[StatesPtr->nonClockInfoIndex].ulVCLK
+ );
+ IDS_HDT_CONSOLE (GFX_MISC, " DCLK = %dkHz\n",
+ NonClockInfoArrayPtr->NonClockInfo[StatesPtr->nonClockInfoIndex].ulDCLK
+ );
+ IDS_HDT_CONSOLE (GFX_MISC, " DPM State Index: ");
+ for (DpmIndex = 0; DpmIndex < StatesPtr->ucNumDPMLevels; DpmIndex++) {
+ IDS_HDT_CONSOLE (GFX_MISC, "%d ",
+ StatesPtr->ClockInfoIndex [DpmIndex]
+ );
+ }
+ IDS_HDT_CONSOLE (GFX_MISC, "\n");
+ StatesPtr = (ATOM_PPLIB_STATE_V2 *) ((UINT8 *) StatesPtr + sizeof (ATOM_PPLIB_STATE_V2) + StatesPtr->ucNumDPMLevels - 1);
+ }
+ for (Index = 0; Index < ClockInfoArrayPtr->ucNumEntries; Index++) {
+ UINT32 Sclk;
+ Sclk = ClockInfoArrayPtr->ClockInfo[Index].usEngineClockLow | (ClockInfoArrayPtr->ClockInfo[Index].ucEngineClockHigh << 16);
+ IDS_HDT_CONSOLE (GFX_MISC, " DPM State #%d\n",
+ Index
+ );
+ IDS_HDT_CONSOLE (GFX_MISC, " SCLK = %d\n",
+ ClockInfoArrayPtr->ClockInfo[Index].usEngineClockLow | (ClockInfoArrayPtr->ClockInfo[Index].ucEngineClockHigh << 16)
+ );
+ IDS_HDT_CONSOLE (GFX_MISC, " Cac = %d\n",
+ ClockInfoArrayPtr->ClockInfo[Index].leakage
+ );
+ IDS_HDT_CONSOLE (GFX_MISC, " VID index = %d\n",
+ ClockInfoArrayPtr->ClockInfo[Index].vddcIndex
+ );
+ }
+}
diff --git a/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbGfxInitLibV1/GfxPowerPlayTable.h b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbGfxInitLibV1/GfxPowerPlayTable.h
new file mode 100644
index 0000000000..6fe93d7298
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbGfxInitLibV1/GfxPowerPlayTable.h
@@ -0,0 +1,200 @@
+/* $NoKeywords:$ */
+/**
+ * @file
+ *
+ * Service procedure to initialize Power Play Table
+ *
+ *
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: GNB
+ * @e \$Revision: 34897 $ @e \$Date: 2010-07-13 19:07:10 -0700 (Tue, 13 Jul 2010) $
+ *
+ */
+/*
+ *****************************************************************************
+ *
+ * Copyright (c) 2011, Advanced Micro Devices, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Advanced Micro Devices, Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***************************************************************************
+ *
+ */
+#ifndef _GFXPOWERPLAYTABLE_H_
+#define _GFXPOWERPLAYTABLE_H_
+
+#pragma pack (push, 1)
+
+#define POLICY_LABEL_BATTERY 0x1
+#define POLICY_LABEL_PERFORMANCE 0x2
+
+#define MAX_NUM_OF_SW_STATES 10
+#define MAX_NUM_OF_DPM_STATES 10
+#define MAX_NUM_OF_FUSED_DPM_STATES 5
+#define MAX_NUM_OF_FUSED_SW_STATES 6
+/// ATOM_PPLIB_POWERPLAYTABLE::ulPlatformCaps
+#define ATOM_PP_PLATFORM_CAP_BACKBIAS 1
+#define ATOM_PP_PLATFORM_CAP_POWERPLAY 2
+#define ATOM_PP_PLATFORM_CAP_SBIOSPOWERSOURCE 4
+#define ATOM_PP_PLATFORM_CAP_ASPM_L0s 8
+#define ATOM_PP_PLATFORM_CAP_ASPM_L1 16
+#define ATOM_PP_PLATFORM_CAP_HARDWAREDC 32
+#define ATOM_PP_PLATFORM_CAP_GEMINIPRIMARY 64
+#define ATOM_PP_PLATFORM_CAP_STEPVDDC 128
+#define ATOM_PP_PLATFORM_CAP_VOLTAGECONTROL 256
+#define ATOM_PP_PLATFORM_CAP_SIDEPORTCONTROL 512
+#define ATOM_PP_PLATFORM_CAP_TURNOFFPLL_ASPML1 1024
+#define ATOM_PP_PLATFORM_CAP_HTLINKCONTROL 2048
+#define ATOM_PP_PLATFORM_CAP_MVDDCONTROL 4096
+#define ATOM_PP_PLATFORM_CAP_GOTO_BOOT_ON_ALERT 0x2000 // Go to boot state on alerts, e.g. on an AC->DC transition.
+#define ATOM_PP_PLATFORM_CAP_DONT_WAIT_FOR_VBLANK_ON_ALERT 0x4000 // Do NOT wait for VBLANK during an alert (e.g. AC->DC transition).
+#define ATOM_PP_PLATFORM_CAP_VDDCI_CONTROL 0x8000 // Does
+#define ATOM_PP_PLATFORM_CAP_REGULATOR_HOT 0x00010000 // Enable the 'regulator hot' feature.
+#define ATOM_PP_PLATFORM_CAP_BACO 0x00020000 // Does the driver supports BACO state.
+
+
+#define ATOM_PPLIB_CLASSIFICATION_UI_BATTERY 1
+#define ATOM_PPLIB_CLASSIFICATION_UI_BALANCED 3
+#define ATOM_PPLIB_CLASSIFICATION_UI_PERFORMANCE 5
+
+#define ATOM_PPLIB_CLASSIFICATION_BOOT 0x0008
+#define ATOM_PPLIB_CLASSIFICATION_THERMAL 0x0010
+#define ATOM_PPLIB_CLASSIFICATION_LIMITEDPOWERSOURCE 0x0020
+#define ATOM_PPLIB_CLASSIFICATION_REST 0x0040
+#define ATOM_PPLIB_CLASSIFICATION_FORCED 0x0080
+#define ATOM_PPLIB_CLASSIFICATION_3DPERFORMANCE 0x0100
+#define ATOM_PPLIB_CLASSIFICATION_OVERDRIVETEMPLATE 0x0200
+#define ATOM_PPLIB_CLASSIFICATION_UVDSTATE 0x0400
+#define ATOM_PPLIB_CLASSIFICATION_3DLOW 0x0800
+#define ATOM_PPLIB_CLASSIFICATION_ACPI 0x1000
+#define ATOM_PPLIB_CLASSIFICATION_HD2STATE 0x2000
+#define ATOM_PPLIB_CLASSIFICATION_HDSTATE 0x4000
+#define ATOM_PPLIB_CLASSIFICATION_SDSTATE 0x8000
+#define ATOM_PPLIB_CLASSIFICATION_NONUVDSTATE 0x0000
+
+#define ATOM_PPLIB_ENABLE_VARIBRIGHT 0x00008000
+#define ATOM_PPLIB_ENABLE_DRR 0x00080000
+
+#define ATOM_PP_FANPARAMETERS_NOFAN 0x80
+#define ATOM_PP_THERMALCONTROLLER_SUMO 0x0E
+
+/// DPM state info
+typedef struct _ATOM_PPLIB_SUMO_CLOCK_INFO {
+ USHORT usEngineClockLow; ///< Sclk [15:0] (Sclk in 10khz)
+ UCHAR ucEngineClockHigh; ///< Sclk [23:16](Sclk in 10khz)
+ UCHAR vddcIndex; ///< 2-bit VDDC index;
+ UCHAR leakage; ///< Absolute Cac value;
+ UCHAR rsv; ///< Reserved
+ USHORT rsv1; ///< Reserved
+ ULONG rsv2[2]; ///< Reserved
+} ATOM_PPLIB_SUMO_CLOCK_INFO;
+
+/// Non clock info
+typedef struct _ATOM_PPLIB_NONCLOCK_INFO {
+ USHORT usClassification; ///< State classification see ATOM_PPLIB_CLASSIFICATION_*
+ UCHAR ucMinTemperature; ///< Reserved
+ UCHAR ucMaxTemperature; ///< Reserved
+ ULONG ulCapsAndSettings; ///< Capability Setting (ATOM_PPLIB_ENABLE_DRR or ATOM_PPLIB_ENABLE_VARIBRIGHT or 0)
+ UCHAR Reserved1; ///< Reserved
+ USHORT Reserved2; ///< Reserved
+ ULONG ulVCLK; ///< UVD clocks VCLK unit is in 10KHz
+ ULONG ulDCLK; ///< UVD clocks DCLK unit is in 10KHz
+ UCHAR ucUnused[5]; ///< Reserved
+} ATOM_PPLIB_NONCLOCK_INFO;
+
+/// Thermal controller info stub
+typedef struct _ATOM_PPLIB_THERMALCONTROLLER {
+ UCHAR ucType; ///< Reserved. Should be set 0xE
+ UCHAR ucI2cLine; ///< Reserved. Should be set 0
+ UCHAR ucI2cAddress; ///< Reserved. Should be set 0
+ UCHAR ucFanParameters; ///< Reserved. Should be set 0x80
+ UCHAR ucFanMinRPM; ///< Reserved. Should be set 0
+ UCHAR ucFanMaxRPM; ///< Reserved. Should be set 0
+ UCHAR ucReserved; ///< Reserved. Should be set 0
+ UCHAR ucFlags; ///< Reserved. Should be set 0
+} ATOM_PPLIB_THERMALCONTROLLER;
+
+/// SW state info
+typedef struct _ATOM_PPLIB_STATE_V2 {
+ UCHAR ucNumDPMLevels; ///< Number of valid DPM levels in this state
+ UCHAR nonClockInfoIndex; ///< Index to the array of NonClockInfos
+ UCHAR ClockInfoIndex[1]; ///< Array of DPM states. Actual number calculated during state enumeration
+} ATOM_PPLIB_STATE_V2;
+
+/// SW state Array
+typedef struct {
+ UCHAR ucNumEntries; ///< Number of SW states
+ ATOM_PPLIB_STATE_V2 States[1]; ///< SW state info. Actual number calculated during state enumeration
+} STATE_ARRAY;
+
+/// Clock info Array
+typedef struct {
+ UCHAR ucNumEntries; ///< Number of ClockInfo entries
+ UCHAR ucEntrySize; ///< size of ATOM_PPLIB_SUMO_CLOCK_INFO
+ ATOM_PPLIB_SUMO_CLOCK_INFO ClockInfo[1]; ///< Clock info array. Size will be determined dynamically base on fuses
+} CLOCK_INFO_ARRAY;
+
+/// Non clock info Array
+typedef struct {
+
+ UCHAR ucNumEntries; ///< Number of Entries;
+ UCHAR ucEntrySize; ///< Size of NonClockInfo
+ ATOM_PPLIB_NONCLOCK_INFO NonClockInfo[1]; ///< Non clock info array
+} NON_CLOCK_INFO_ARRAY;
+
+/// Power Play table
+typedef struct _ATOM_PPLIB_POWERPLAYTABLE3 {
+ ATOM_COMMON_TABLE_HEADER sHeader; ///< Common header
+ UCHAR ucDataRevision; ///< Revision of PP table
+ UCHAR Reserved1[4]; ///< Reserved
+ USHORT usStateArrayOffset; ///< Offset from start of this table to array of ucNumStates ATOM_PPLIB_STATE structures
+ USHORT usClockInfoArrayOffset; ///< Offset from start of the table to ClockInfoArray
+ USHORT usNonClockInfoArrayOffset; ///< Offset from Start of the table to NonClockInfoArray
+ USHORT Reserved2[2]; ///< Reserved
+ USHORT usTableSize; ///< the size of this structure, or the extended structure
+ ULONG ulPlatformCaps; ///< See ATOM_PPLIB_CAPS_*
+ ATOM_PPLIB_THERMALCONTROLLER sThermalController; ///< Thermal controller stub.
+ USHORT Reserved4[2]; ///< Reserved
+ UCHAR Reserved5; ///< Reserved
+ USHORT Reserved6; ///< Reserved
+ USHORT usFormatID; ///< Format ID
+ USHORT Reserved7[2]; ///< Reserved
+ STATE_ARRAY StateArray; ///< Array to hold the states.
+ CLOCK_INFO_ARRAY ClockInfoArray; ///< Array to hold clock info.
+ NON_CLOCK_INFO_ARRAY NonClockInfoArray; ///< Array to hold non clock info.
+} ATOM_PPLIB_POWERPLAYTABLE3;
+
+#pragma pack (pop)
+
+
+AGESA_STATUS
+GfxPowerPlayBuildTable (
+ OUT VOID *Buffer,
+ IN GFX_PLATFORM_CONFIG *Gfx
+ );
+
+
+#endif
diff --git a/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbGfxInitLibV1/GnbGfxInitLibV1.h b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbGfxInitLibV1/GnbGfxInitLibV1.h
new file mode 100644
index 0000000000..f76688b787
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbGfxInitLibV1/GnbGfxInitLibV1.h
@@ -0,0 +1,56 @@
+/* $NoKeywords:$ */
+/**
+ * @file
+ *
+ * Gfx Library
+ *
+ *
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: GNB
+ * @e \$Revision: 34897 $ @e \$Date: 2010-07-13 19:07:10 -0700 (Tue, 13 Jul 2010) $
+ *
+ */
+/*
+ *****************************************************************************
+ *
+ * Copyright (c) 2011, Advanced Micro Devices, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Advanced Micro Devices, Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***************************************************************************
+ *
+ */
+
+
+#ifndef _GNBGFXINITLIBV1_H_
+#define _GNBGFXINITLIBV1_H_
+
+#include "GnbGfx.h"
+#include "GfxEnumConnectors.h"
+#include "GfxPowerPlayTable.h"
+#include "GfxCardInfo.h"
+
+#endif
diff --git a/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbNbInitLibV1/GnbNbInitLibV1.c b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbNbInitLibV1/GnbNbInitLibV1.c
new file mode 100644
index 0000000000..468e57f74c
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbNbInitLibV1/GnbNbInitLibV1.c
@@ -0,0 +1,247 @@
+/* $NoKeywords:$ */
+/**
+ * @file
+ *
+ * NB services
+ *
+ *
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: GNB
+ * @e \$Revision: 38931 $ @e \$Date: 2010-10-01 15:50:05 -0700 (Fri, 01 Oct 2010) $
+ *
+ */
+/*
+ *****************************************************************************
+ *
+ * Copyright (c) 2011, Advanced Micro Devices, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Advanced Micro Devices, Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***************************************************************************
+ *
+ */
+
+/*----------------------------------------------------------------------------------------
+ * M O D U L E S U S E D
+ *----------------------------------------------------------------------------------------
+ */
+#include "AGESA.h"
+#include "Ids.h"
+#include "amdlib.h"
+#include "Gnb.h"
+#include GNB_MODULE_DEFINITIONS (GnbCommonLib)
+#include "GnbRegistersON.h"
+#include "Filecode.h"
+#define FILECODE PROC_GNB_MODULES_GNBNBINITLIBV1_GNBNBINITLIBV1_FILECODE
+/*----------------------------------------------------------------------------------------
+ * D E F I N I T I O N S A N D M A C R O S
+ *----------------------------------------------------------------------------------------
+ */
+
+
+/*----------------------------------------------------------------------------------------
+ * T Y P E D E F S A N D S T R U C T U R E S
+ *----------------------------------------------------------------------------------------
+ */
+
+
+/*----------------------------------------------------------------------------------------
+ * P R O T O T Y P E S O F L O C A L F U N C T I O N S
+ *----------------------------------------------------------------------------------------
+ */
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Init NB set top of memory
+ *
+ *
+ *
+ * @param[in] NbPciAddress Gnb PCI address
+ * @param[in] StdHeader Standard Configuration Header
+ */
+
+AGESA_STATUS
+GnbSetTom (
+ IN PCI_ADDR NbPciAddress,
+ IN AMD_CONFIG_PARAMS *StdHeader
+ )
+{
+ AGESA_STATUS Status;
+ UINT64 MsrData;
+ UINT32 Value;
+ Status = AGESA_SUCCESS;
+ //Read memory size below 4G from MSR C001_001A
+ LibAmdMsrRead (TOP_MEM, &MsrData, StdHeader);
+ //Write to NB register 0x90
+ Value = (UINT32)MsrData & 0xFF800000; //Keep bits 31:23
+ GnbLibPciRMW (
+ NbPciAddress.AddressValue | D0F0x90_ADDRESS,
+ AccessS3SaveWidth32,
+ 0x007FFFFF,
+ Value,
+ StdHeader
+ );
+ if (Value == 0) {
+ Status = AGESA_WARNING;
+ }
+
+ LibAmdMsrRead (SYS_CFG, &MsrData, StdHeader);
+ if ((MsrData & BIT21) != 0) {
+ //Read memory size above 4G from MSR C001_001D
+ LibAmdMsrRead (TOP_MEM2, &MsrData, StdHeader);
+ // Write memory size[39:32] to indirect register 1A[7:0]
+ Value = (UINT32) ((MsrData >> 32) & 0xFF);
+ GnbLibPciIndirectRMW (
+ NbPciAddress.AddressValue | D0F0x60_ADDRESS,
+ D0F0x64_x1A_ADDRESS | IOC_WRITE_ENABLE,
+ AccessS3SaveWidth32,
+ 0xFFFFFF00,
+ Value,
+ StdHeader
+ );
+
+ // Write memory size[31:23] to indirect register 19[31:23] and enable memory through bit 0
+ Value = (UINT32)MsrData & 0xFF800000; //Keep bits 31:23
+ Value |= BIT0; // Enable top of memory
+ GnbLibPciIndirectRMW (
+ NbPciAddress.AddressValue | D0F0x60_ADDRESS,
+ D0F0x64_x19_ADDRESS | IOC_WRITE_ENABLE,
+ AccessS3SaveWidth32,
+ 0x007FFFFF,
+ Value,
+ StdHeader
+ );
+ }
+ return Status;
+}
+
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Avoid LPC DMA transaction deadlock
+ *
+ *
+ *
+ * @param[in] NbPciAddress Gnb PCI address
+ * @param[in] StdHeader Standard Configuration Header
+ */
+
+VOID
+GnbLpcDmaDeadlockPrevention (
+ IN PCI_ADDR NbPciAddress,
+ IN AMD_CONFIG_PARAMS *StdHeader
+ )
+{
+ // For GPP Link core, enable special NP memory write protocol on the processor side PCIE controller
+ GnbLibPciIndirectRMW (
+ NbPciAddress.AddressValue | D0F0xE0_ADDRESS,
+ CORE_SPACE (1, 0x10),
+ AccessWidth32,
+ 0xFFFFFFFF,
+ 1 << 9,
+ StdHeader
+ );
+
+ //Enable special NP memory write protocol in ORB
+ GnbLibPciIndirectRMW (
+ NbPciAddress.AddressValue | D0F0x94_ADDRESS,
+ D0F0x98_x06_ADDRESS | (1 << D0F0x94_OrbIndWrEn_OFFSET),
+ AccessS3SaveWidth32,
+ 0xFFFFFFFF,
+ 1 << D0F0x98_x06_UmiNpMemWrEn_OFFSET,
+ StdHeader
+ );
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * NB Dynamic Wake
+ * ORB_CNB_Wake signal is used to inform the CNB NCLK controller and GNB LCLK controller
+ * that ORB is (or will soon) push data into the synchronizer FIFO (i.e. wake is high).
+ *
+ * @param[in] NbPciAddress Gnb PCI address
+ * @param[in] StdHeader Standard Configuration Header
+ */
+
+VOID
+GnbOrbDynamicWake (
+ IN PCI_ADDR NbPciAddress,
+ IN AMD_CONFIG_PARAMS *StdHeader
+ )
+{
+
+ D0F0x98_x2C_STRUCT D0F0x98_x2C;
+
+ GnbLibPciIndirectRead (
+ NbPciAddress.AddressValue | D0F0x94_ADDRESS,
+ D0F0x98_x2C_ADDRESS | (1 << D0F0x94_OrbIndWrEn_OFFSET),
+ AccessWidth32,
+ &D0F0x98_x2C.Value,
+ StdHeader
+ );
+
+ // Enable Dynamic wake
+ // Wake Hysteresis timer value. Specifies the number of SMU pulses to count.
+ D0F0x98_x2C.Field.DynWakeEn = 1;
+ D0F0x98_x2C.Field.WakeHysteresis = 0x64;
+
+ IDS_OPTION_HOOK (IDS_GNB_ORBDYNAMIC_WAKE, &D0F0x98_x2C, StdHeader);
+
+ GnbLibPciIndirectWrite (
+ NbPciAddress.AddressValue | D0F0x94_ADDRESS,
+ D0F0x98_x2C_ADDRESS | (1 << D0F0x94_OrbIndWrEn_OFFSET),
+ AccessS3SaveWidth32,
+ &D0F0x98_x2C.Value,
+ StdHeader
+ );
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Lock NB registers
+ *
+ *
+ *
+ * @param[in] NbPciAddress Gnb PCI address
+ * @param[in] StdHeader Standard Configuration Header
+ */
+
+VOID
+GnbLock (
+ IN PCI_ADDR NbPciAddress,
+ IN AMD_CONFIG_PARAMS *StdHeader
+ )
+{
+ GnbLibPciIndirectWriteField (
+ NbPciAddress.AddressValue | D0F0x60_ADDRESS,
+ D0F0x64_x00_ADDRESS | IOC_WRITE_ENABLE,
+ D0F0x64_x00_HwInitWrLock_OFFSET,
+ D0F0x64_x00_HwInitWrLock_WIDTH,
+ 0x1,
+ TRUE,
+ StdHeader
+ );
+}
diff --git a/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbNbInitLibV1/GnbNbInitLibV1.h b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbNbInitLibV1/GnbNbInitLibV1.h
new file mode 100644
index 0000000000..427fb93f8c
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbNbInitLibV1/GnbNbInitLibV1.h
@@ -0,0 +1,74 @@
+/* $NoKeywords:$ */
+/**
+ * @file
+ *
+ * NB services
+ *
+ *
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: GNB
+ * @e \$Revision: 34897 $ @e \$Date: 2010-07-13 19:07:10 -0700 (Tue, 13 Jul 2010) $
+ *
+ */
+/*
+ *****************************************************************************
+ *
+ * Copyright (c) 2011, Advanced Micro Devices, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Advanced Micro Devices, Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***************************************************************************
+ *
+ */
+#ifndef _GNBNBINITLIBV1_H_
+#define _GNBNBINITLIBV1_H_
+
+
+AGESA_STATUS
+GnbSetTom (
+ IN PCI_ADDR NbPciAddress,
+ IN AMD_CONFIG_PARAMS *StdHeader
+ );
+
+VOID
+GnbLpcDmaDeadlockPrevention (
+ IN PCI_ADDR NbPciAddress,
+ IN AMD_CONFIG_PARAMS *StdHeader
+ );
+
+VOID
+GnbOrbDynamicWake (
+ IN PCI_ADDR NbPciAddress,
+ IN AMD_CONFIG_PARAMS *StdHeader
+ );
+
+VOID
+GnbLock (
+ IN PCI_ADDR NbPciAddress,
+ IN AMD_CONFIG_PARAMS *StdHeader
+ );
+
+#endif
diff --git a/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieAlibV1/PcieAlib.c b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieAlibV1/PcieAlib.c
new file mode 100644
index 0000000000..b28e1a9189
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieAlibV1/PcieAlib.c
@@ -0,0 +1,351 @@
+/* $NoKeywords:$ */
+/**
+ * @file
+ *
+ * PCIe ALIB
+ *
+ *
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: GNB
+ * @e \$Revision: 39033 $ @e \$Date: 2010-10-04 14:23:23 -0700 (Mon, 04 Oct 2010) $
+ *
+ */
+/*
+ *****************************************************************************
+ *
+ * Copyright (c) 2011, Advanced Micro Devices, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Advanced Micro Devices, Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***************************************************************************
+ *
+ */
+
+/*----------------------------------------------------------------------------------------
+ * M O D U L E S U S E D
+ *----------------------------------------------------------------------------------------
+ */
+
+
+#include "AGESA.h"
+#include "Ids.h"
+#include "amdlib.h"
+#include "heapManager.h"
+#include "cpuLateInit.h"
+#include "cpuRegisters.h"
+#include "Gnb.h"
+#include "GnbPcie.h"
+#include "GnbPcieFamServices.h"
+#include GNB_MODULE_DEFINITIONS (GnbCommonLib)
+#include GNB_MODULE_DEFINITIONS (GnbPcieConfig)
+#include GNB_MODULE_DEFINITIONS (GnbPcieInitLibV1)
+#include "GnbRegistersON.h"
+#include "OptionGnb.h"
+#include "PcieAlib.h"
+#include "GnbFuseTable.h"
+#include "Filecode.h"
+#define FILECODE PROC_GNB_MODULES_GNBPCIEALIBV1_PCIEALIB_FILECODE
+/*----------------------------------------------------------------------------------------
+ * D E F I N I T I O N S A N D M A C R O S
+ *----------------------------------------------------------------------------------------
+ */
+
+extern UINT8 AlibSsdt[];
+
+/*----------------------------------------------------------------------------------------
+ * T Y P E D E F S A N D S T R U C T U R E S
+ *----------------------------------------------------------------------------------------
+ */
+
+
+/*----------------------------------------------------------------------------------------
+ * P R O T O T Y P E S O F L O C A L F U N C T I O N S
+ *----------------------------------------------------------------------------------------
+ */
+
+VOID
+STATIC
+PcieAlibSetPortGenCapabilityCallback (
+ IN PCIe_ENGINE_CONFIG *Engine,
+ IN OUT VOID *Buffer,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ );
+
+VOID
+STATIC
+PcieAlibSetPortInfoCallback (
+ IN PCIe_ENGINE_CONFIG *Engine,
+ IN OUT VOID *Buffer,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ );
+
+AGESA_STATUS
+PcieAlibBuildAcpiTable (
+ IN AMD_CONFIG_PARAMS *StdHeader,
+ OUT VOID **AlibSsdtPtr
+ );
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Create ACPI ALIB SSDT table
+ *
+ *
+ *
+ * @param[in] StdHeader Standard configuration header
+ * @retval AGESA_STATUS
+ */
+
+AGESA_STATUS
+PcieAlibFeature (
+ IN AMD_CONFIG_PARAMS *StdHeader
+ )
+{
+ AMD_LATE_PARAMS *LateParamsPtr;
+ LateParamsPtr = (AMD_LATE_PARAMS*) StdHeader;
+ return PcieAlibBuildAcpiTable (StdHeader, &LateParamsPtr->AcpiAlib);
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Build ALIB ACPI table
+ *
+ *
+ *
+ * @param[in] StdHeader Standard Configuration Header
+ * @param[in,out] AlibSsdtPtr Pointer to pointer to ALIB SSDT table
+ * @retval AGESA_SUCCESS
+ * @retval AGESA_ERROR
+ */
+
+AGESA_STATUS
+PcieAlibBuildAcpiTable (
+ IN AMD_CONFIG_PARAMS *StdHeader,
+ OUT VOID **AlibSsdtPtr
+ )
+{
+ AGESA_STATUS Status;
+ UINT32 AmlObjName;
+ PCIe_PLATFORM_CONFIG *Pcie;
+ PP_FUSE_ARRAY *PpFuseArray;
+ VOID *AlibSsdtBuffer;
+ VOID *AmlObjPtr;
+ UINT8 SclkVidArray[4];
+ UINT8 BootUpVid;
+ UINT8 BootUpVidIndex;
+ UINT8 Gen1VidIndex;
+ UINTN Index;
+ UINTN AlibSsdtlength;
+ Status = AGESA_SUCCESS;
+ AlibSsdtlength = ((ACPI_TABLE_HEADER*) &AlibSsdt[0])->TableLength;
+ if (*AlibSsdtPtr == NULL) {
+ AlibSsdtBuffer = GnbAllocateHeapBuffer (
+ AMD_ACPI_ALIB_BUFFER_HANDLE,
+ AlibSsdtlength,
+ StdHeader
+ );
+ ASSERT (AlibSsdtBuffer != NULL);
+ if (AlibSsdtBuffer == NULL) {
+ return AGESA_ERROR;
+ }
+ *AlibSsdtPtr = AlibSsdtBuffer;
+ } else {
+ AlibSsdtBuffer = *AlibSsdtPtr;
+ }
+ // Copy template to buffer
+ LibAmdMemCopy (AlibSsdtBuffer, &AlibSsdt[0], AlibSsdtlength, StdHeader);
+ // Set PCI MMIO configuration
+ AmlObjName = '10DA';
+ AmlObjPtr = GnbLibFind (AlibSsdtBuffer, AlibSsdtlength, (UINT8*) &AmlObjName, sizeof (AmlObjName));
+ if (AmlObjPtr != NULL) {
+ UINT64 MsrRegister;
+ LibAmdMsrRead (MSR_MMIO_Cfg_Base, &MsrRegister, StdHeader);
+ if ((MsrRegister & BIT0) != 0 && (MsrRegister & 0xFFFFFFFF00000000) == 0) {
+ *(UINT32*)((UINT8*)AmlObjPtr + 5) = (UINT32)(MsrRegister & 0xFFFFF00000);
+ } else {
+ Status = AGESA_ERROR;
+ }
+ } else {
+ Status = AGESA_ERROR;
+ }
+ // Set voltage configuration
+ PpFuseArray = GnbLocateHeapBuffer (AMD_PP_FUSE_TABLE_HANDLE, StdHeader);
+ if (PpFuseArray != NULL) {
+ AmlObjName = '30DA';
+ AmlObjPtr = GnbLibFind (AlibSsdtBuffer, AlibSsdtlength, (UINT8*) &AmlObjName, sizeof (AmlObjName));
+ ASSERT (AmlObjPtr != NULL);
+ if (AmlObjPtr != NULL) {
+ *(UINT8*)((UINT8*)AmlObjPtr + 5) = PpFuseArray->PcieGen2Vid;
+ } else {
+ Status = AGESA_ERROR;
+ }
+ } else {
+ Status = AGESA_ERROR;
+ }
+ GnbLibPciRead (
+ MAKE_SBDFO ( 0, 0, 0x18, 3, D18F3x15C_ADDRESS),
+ AccessWidth32,
+ &SclkVidArray[0],
+ StdHeader
+ );
+ Gen1VidIndex = 0;
+ BootUpVidIndex = 0;
+ BootUpVid = 0xff;
+ for (Index = 0; Index < 4; Index++) {
+ if (SclkVidArray[Index] > SclkVidArray[Gen1VidIndex]) {
+ Gen1VidIndex = (UINT8) Index;
+ }
+ if (SclkVidArray[Index] != 0 && SclkVidArray[Index] < BootUpVid) {
+ BootUpVid = SclkVidArray[Index];
+ BootUpVidIndex = (UINT8) Index;
+ }
+ }
+ AmlObjName = '40DA';
+ AmlObjPtr = GnbLibFind (AlibSsdtBuffer, AlibSsdtlength, (UINT8*) &AmlObjName, sizeof (AmlObjName));
+ ASSERT (AmlObjPtr != NULL);
+ if (AmlObjPtr != NULL) {
+ *(UINT8*)((UINT8*)AmlObjPtr + 5) = Gen1VidIndex;
+ } else {
+ Status = AGESA_ERROR;
+ }
+ AmlObjName = '50DA';
+ AmlObjPtr = GnbLibFind (AlibSsdtBuffer, AlibSsdtlength, (UINT8*) &AmlObjName, sizeof (AmlObjName));
+ ASSERT (AmlObjPtr != NULL);
+ if (AmlObjPtr != NULL) {
+ *(UINT8*)((UINT8*)AmlObjPtr + 5) = BootUpVidIndex;
+ } else {
+ Status = AGESA_ERROR;
+ }
+ // Set PCIe configuration
+ if (PcieLocateConfigurationData (StdHeader, &Pcie) == AGESA_SUCCESS) {
+ AmlObjName = '20DA';
+ AmlObjPtr = GnbLibFind (AlibSsdtBuffer, AlibSsdtlength, (UINT8*) &AmlObjName, sizeof (AmlObjName));
+ ASSERT (AmlObjPtr != NULL);
+ if (AmlObjPtr != NULL) {
+ *(UINT8*)((UINT8*)AmlObjPtr + 5) = Pcie->PsppPolicy;
+ } else {
+ Status = AGESA_ERROR;
+ }
+ AmlObjName = '60DA';
+ AmlObjPtr = GnbLibFind (AlibSsdtBuffer, AlibSsdtlength, (UINT8*) &AmlObjName, sizeof (AmlObjName));
+ ASSERT (AmlObjPtr != NULL);
+ if (AmlObjPtr != NULL) {
+ PcieConfigRunProcForAllEngines (
+ DESCRIPTOR_ALLOCATED | DESCRIPTOR_PCIE_ENGINE,
+ PcieAlibSetPortGenCapabilityCallback,
+ (UINT8*)((UINT8*)AmlObjPtr + 7),
+ Pcie
+ );
+ } else {
+ Status = AGESA_ERROR;
+ }
+ AmlObjName = '70DA';
+ AmlObjPtr = GnbLibFind (AlibSsdtBuffer, AlibSsdtlength, (UINT8*) &AmlObjName, sizeof (AmlObjName));
+ ASSERT (AmlObjPtr != NULL);
+ if (AmlObjPtr != NULL) {
+ PcieConfigRunProcForAllEngines (
+ DESCRIPTOR_ALLOCATED | DESCRIPTOR_PCIE_ENGINE,
+ PcieAlibSetPortInfoCallback,
+ (UINT8*)((UINT8*)AmlObjPtr + 4),
+ Pcie
+ );
+ } else {
+ Status = AGESA_ERROR;
+ }
+ } else {
+ ASSERT (FALSE);
+ Status = AGESA_ERROR;
+ }
+ if (Status == AGESA_ERROR) {
+ //Shrink table length to size of the header
+ ((ACPI_TABLE_HEADER*) AlibSsdtBuffer)->TableLength = sizeof (ACPI_TABLE_HEADER);
+ }
+ ChecksumAcpiTable ((ACPI_TABLE_HEADER*) AlibSsdtBuffer, StdHeader);
+ return Status;
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Callback to init max port Gen capability
+ *
+ *
+ *
+ *
+ * @param[in] Engine Pointer to engine config descriptor
+ * @param[in, out] Buffer Not used
+ * @param[in] Pcie Pointer to global PCIe configuration
+ *
+ */
+
+VOID
+STATIC
+PcieAlibSetPortGenCapabilityCallback (
+ IN PCIe_ENGINE_CONFIG *Engine,
+ IN OUT VOID *Buffer,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ UINT8 *PsppMaxPortCapbilityArray;
+ PsppMaxPortCapbilityArray = (UINT8*) Buffer;
+ if (Engine->Type.Port.PortData.LinkHotplug != HotplugDisabled || PcieConfigCheckPortStatus (Engine, INIT_STATUS_PCIE_TRAINING_SUCCESS)) {
+ PsppMaxPortCapbilityArray[(Engine->Type.Port.Address.Address.Device - 2) * 2 + 1] = (UINT8) PcieFmGetLinkSpeedCap (PCIE_PORT_GEN_CAP_MAX, Engine, Pcie) + 1;
+ }
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Callback to init port info
+ *
+ *
+ *
+ *
+ * @param[in] Engine Pointer to engine config descriptor
+ * @param[in, out] Buffer Not used
+ * @param[in] Pcie Pointer to global PCIe configuration
+ *
+ */
+
+VOID
+STATIC
+PcieAlibSetPortInfoCallback (
+ IN PCIe_ENGINE_CONFIG *Engine,
+ IN OUT VOID *Buffer,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ ALIB_PORT_INFO_PACKAGE *PortInfoPackage;
+ UINT8 PortIndex;
+ PortInfoPackage = (ALIB_PORT_INFO_PACKAGE*) Buffer;
+ PortIndex = (UINT8) Engine->Type.Port.Address.Address.Device - 2;
+ PortInfoPackage->PortInfo[PortIndex].StartPhyLane = (UINT8) Engine->EngineData.StartLane;
+ PortInfoPackage->PortInfo[PortIndex].EndPhyLane = (UINT8) Engine->EngineData.EndLane;
+ PortInfoPackage->PortInfo[PortIndex].StartCoreLane = (UINT8) Engine->Type.Port.StartCoreLane;
+ PortInfoPackage->PortInfo[PortIndex].EndCoreLane = (UINT8) Engine->Type.Port.EndCoreLane;
+ PortInfoPackage->PortInfo[PortIndex].PortId = Engine->Type.Port.PortId;
+ PortInfoPackage->PortInfo[PortIndex].WrapperId = 0x0130 | (PcieEngineGetParentWrapper (Engine)->WrapId);
+ PortInfoPackage->PortInfo[PortIndex].LinkHotplug = Engine->Type.Port.PortData.LinkHotplug;
+ PortInfoPackage->PortInfo[PortIndex].MaxSpeedCap = (UINT8) PcieFmGetLinkSpeedCap (PCIE_PORT_GEN_CAP_MAX, Engine, Pcie);
+}
+
diff --git a/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieAlibV1/PcieAlib.h b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieAlibV1/PcieAlib.h
new file mode 100644
index 0000000000..ae7e774c66
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieAlibV1/PcieAlib.h
@@ -0,0 +1,83 @@
+/* $NoKeywords:$ */
+/**
+ * @file
+ *
+ * PCIe ALIB
+ *
+ *
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: GNB
+ * @e \$Revision: 34897 $ @e \$Date: 2010-07-13 19:07:10 -0700 (Tue, 13 Jul 2010) $
+ *
+ */
+/*
+ *****************************************************************************
+ *
+ * Copyright (c) 2011, Advanced Micro Devices, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Advanced Micro Devices, Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***************************************************************************
+ *
+ */
+
+#ifndef _PCIEALIB_H_
+#define _PCIEALIB_H_
+
+#pragma pack (push, 1)
+///Port info asl buffer
+typedef struct {
+ UINT8 BufferOp; ///< Opcode
+ UINT8 PkgLength; ///< Package length
+ UINT8 BufferSize; ///< Buffer size
+ UINT8 ByteList; ///< Byte lisy
+ UINT8 StartPhyLane; ///< Port Start PHY lane
+ UINT8 EndPhyLane; ///< Port End PHY lane
+ UINT8 StartCoreLane; ///< Port Start Core lane
+ UINT8 EndCoreLane; ///< Port End Core lane
+ UINT8 PortId; ///< Port ID
+ UINT16 WrapperId; ///< Wrapper ID
+ UINT8 LinkHotplug; ///< Link hotplug type
+ UINT8 MaxSpeedCap; ///< Max port speed capability
+ UINT8 Reserved[1]; ///< Reserved
+} ALIB_PORT_INFO_BUFFER;
+///Ports info asl package
+typedef struct {
+ UINT8 PackageOp; ///< Opcode
+ UINT8 PkgLength; ///< Package length
+ UINT8 NumElements; ///< number of elements
+ UINT8 PackageElementList; ///< package element list
+ ALIB_PORT_INFO_BUFFER PortInfo[7]; ///< Array of port info buffers
+} ALIB_PORT_INFO_PACKAGE;
+
+#pragma pack (pop)
+
+AGESA_STATUS
+PcieAlibFeature (
+ IN AMD_CONFIG_PARAMS *StdHeader
+ );
+
+#endif
diff --git a/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieAlibV1/PcieAlibConfig.esl b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieAlibV1/PcieAlibConfig.esl
new file mode 100644
index 0000000000..e595c28036
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieAlibV1/PcieAlibConfig.esl
@@ -0,0 +1,68 @@
+/**
+ * @file
+ *
+ * ALIB PSPP config
+ *
+ *
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: GNB
+ * @e \$Revision: 25430 $ @e \$Date: 2010-01-18 22:25:55 -0800 (Mon, 18 Jan 2010) $
+ *
+ */
+/*
+ *****************************************************************************
+ *
+ * Copyright (c) 2011, Advanced Micro Devices, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Advanced Micro Devices, Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***************************************************************************
+ *
+ */
+
+#ifndef _PCIEALIBCONFIG_H_
+#define _PCIEALIBCONFIG_H_
+
+#define DEF_OFFSET_START_CORE_LANE 2
+#define DEF_OFFSET_END_CORE_LANE 3
+#define DEF_OFFSET_START_PHY_LANE 0
+#define DEF_OFFSET_END_PHY_LANE 1
+#define DEF_OFFSET_PORT_ID 4
+#define DEF_OFFSET_WRAPPER_ID 5
+#define DEF_OFFSET_LINK_HOTPLUG 7
+#define DEF_OFFSET_GEN2_CAP 8
+#define DEF_BASIC_HOTPLUG 1
+
+#define DEF_PSPP_POLICY_START 1
+#define DEF_PSPP_POLICY_STOP 0
+#define DEF_PSPP_POLICY_PERFORMANCE 1
+#define DEF_PSPP_POLICY_BALANCEHIGH 2
+#define DEF_PSPP_POLICY_BALANCELOW 3
+#define DEF_PSPP_POLICY_POWERSAVING 4
+#define DEF_PSPP_STATE_AC 0
+#define DEF_PSPP_STATE_DC 1
+
+#endif
diff --git a/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieAlibV1/PcieAlibCore.esl b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieAlibV1/PcieAlibCore.esl
new file mode 100644
index 0000000000..7b785a80e8
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieAlibV1/PcieAlibCore.esl
@@ -0,0 +1,373 @@
+/**
+ * @file
+ *
+ * ALIB ASL library
+ *
+ *
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: GNB
+ * @e \$Revision: 31805 $ @e \$Date: 2010-05-21 17:58:16 -0700 (Fri, 21 May 2010) $
+ *
+ */
+/*
+ *****************************************************************************
+ *
+ * Copyright (c) 2011, Advanced Micro Devices, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Advanced Micro Devices, Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***************************************************************************
+ *
+ */
+
+
+ /*----------------------------------------------------------------------------------------*/
+ /**
+ * PCIe MMIO Base address
+ *
+ */
+
+ Name (
+ AD01,
+ 0xE0000000
+ )
+
+ Alias (
+ AD01,
+ varPcieBase
+ )
+
+
+
+ /*----------------------------------------------------------------------------------------*/
+ /**
+ * PCIe port info
+ *
+ */
+
+ Name (
+ AD07,
+ Package () {
+ Buffer () {0,0,0,0,0,0,0,0,0,0}, //dev2
+ Buffer () {0,0,0,0,0,0,0,0,0,0}, //dev3
+ Buffer () {0,0,0,0,0,0,0,0,0,0}, //dev4
+ Buffer () {0,0,0,0,0,0,0,0,0,0}, //dev5
+ Buffer () {0,0,0,0,0,0,0,0,0,0}, //dev6
+ Buffer () {0,0,0,0,0,0,0,0,0,0}, //dev7
+ Buffer () {0,0,0,0,0,0,0,0,0,0}, //dev8
+ }
+ )
+
+ Alias (
+ AD07,
+ varPortInfo
+ )
+
+ /*----------------------------------------------------------------------------------------*/
+ /**
+ * Master control method
+ *
+ * Arg0 - Function ID
+ * Arg1 - Function specific data buffer
+ */
+ Method (ALIB, 2, NotSerialized) {
+ If (Lequal (Arg0, 0x1)) {
+ return (procPsppReportAcDsState (Arg1))
+ }
+ If (LEqual (Arg0, 0x2)) {
+ return (procPsppPerformanceRequest (Arg1))
+ }
+ If (LEqual (Arg0, 0x3)) {
+ return (procPsppControl (Arg1))
+ }
+ If (LEqual (Arg0, 0x4)) {
+ return (procPcieSetBusWidth (Arg1))
+ }
+ If (LEqual (Arg0, 0x5)) {
+ return (procAlibInit ())
+ }
+ If (LEqual (Arg0, 0x6)) {
+ return (procPciePortHotplug (Arg1))
+ }
+ return (0)
+ }
+
+ /*----------------------------------------------------------------------------------------*/
+ /**
+ * Alib Init
+ *
+ *
+ */
+ Method (procAlibInit, 0, Serialized) {
+
+ return (0)
+ }
+
+ /*----------------------------------------------------------------------------------------*/
+ /**
+ * Read PCI config register
+ *
+ * Arg0 - Port Index
+ *
+ */
+
+ /*----------------------------------------------------------------------------------------*/
+ /**
+ * Read PCI config register through MMIO
+ *
+ * Arg0 - PCI address Bus/device/func
+ * Arg1 - Register offset
+ */
+ Method (procPciDwordRead, 2, NotSerialized) {
+ Add (varPcieBase, ShiftLeft (Arg0, 12), Local0)
+ Add (Arg1, Local0, Local0)
+ OperationRegion(varOperationRegionMmio, SystemMemory, Local0, 0x4)
+ Field(varOperationRegionMmio, DWordAcc, NoLock, Preserve) {
+ Offset (0x0),
+ varPciReg32, 32,
+ }
+ return (varPciReg32)
+ }
+ /*----------------------------------------------------------------------------------------*/
+ /**
+ * Write PCI config register through MMIO
+ *
+ * Arg0 - PCI address Bus/device/func
+ * Arg1 - Register offset
+ * Arg2 - Value
+ */
+ Method (procPciDwordWrite, 3, NotSerialized) {
+ Add (varPcieBase, ShiftLeft (Arg0, 12), Local0)
+ Add (Arg1, Local0, Local0)
+ OperationRegion(varOperationRegionMmio, SystemMemory, Local0, 0x4)
+ Field(varOperationRegionMmio, DWordAcc, NoLock, Preserve) {
+ Offset (0x0),
+ varPciReg32, 32,
+ }
+ Store (Arg2, varPciReg32)
+ }
+ /*----------------------------------------------------------------------------------------*/
+ /**
+ * Write PCI config register through MMIO
+ *
+ * Arg0 - PCI address Bus/device/func
+ * Arg1 - Register offset
+ * Arg2 - AND mask
+ * Arg3 - OR mask
+ */
+ Method (procPciDwordRMW, 4, NotSerialized) {
+ Store (procPciDwordRead (Arg0, Arg1), Local0)
+ Or (And (Local0, Arg2), Arg3, Local0)
+ procPciDwordWrite (Arg0, Arg1, Local0)
+ }
+
+ Mutex(varPciePortAccessMutex, 0)
+ /*----------------------------------------------------------------------------------------*/
+ /**
+ * Read PCIe port indirect register
+ *
+ * Arg0 - Port Index
+ * Arg1 - Register offset
+ *
+ */
+ Method (procPciePortIndirectRegisterRead, 2, NotSerialized) {
+ Acquire(varPciePortAccessMutex, 0xFFFF)
+ Store (ShiftLeft (Add( Arg0, 2), 3), Local0)
+ procPciDwordWrite (Local0, 0xe0, Arg1)
+ Store (procPciDwordRead (Local0, 0xe4), Local0)
+ Release (varPciePortAccessMutex)
+ return (Local0)
+ }
+
+ /*----------------------------------------------------------------------------------------*/
+ /**
+ * Write PCIe port indirect register
+ *
+ * Arg0 - Port Index
+ * Arg1 - Register offset
+ * Arg2 - Value
+ */
+ Method (procPciePortIndirectRegisterWrite, 3, NotSerialized) {
+ Acquire(varPciePortAccessMutex, 0xFFFF)
+ Store (ShiftLeft (Add( Arg0, 2), 3), Local0)
+ procPciDwordWrite (Local0, 0xe0, Arg1)
+ procPciDwordWrite (Local0, 0xe4, Arg2)
+ Release (varPciePortAccessMutex)
+ }
+ /*----------------------------------------------------------------------------------------*/
+ /**
+ * Read PCIe port indirect register
+ *
+ * Arg0 - Port Index
+ * Arg1 - Register offset
+ * Arg2 - AND Mask
+ * Arg3 - OR Mask
+ *
+ */
+ Method (procPciePortIndirectRegisterRMW, 4, NotSerialized) {
+ Store (procPciePortIndirectRegisterRead (Arg0, Arg1), Local0)
+ Or (And (Local0, Arg2), Arg3, Local0)
+ procPciePortIndirectRegisterWrite (Arg0, Arg1, Local0)
+ }
+ Mutex(varHostAccessMutex, 0)
+ /*----------------------------------------------------------------------------------------*/
+ /**
+ * Read PCIe port indirect register
+ *
+ * Arg0 - BDF
+ * Arg1 - Register offset
+ * Arg2 - Register address
+ *
+ */
+ Method (procIndirectRegisterRead, 3, NotSerialized) {
+ Acquire(varHostAccessMutex, 0xFFFF)
+ procPciDwordWrite (Arg0, Arg1, Arg2)
+ Store (procPciDwordRead (Arg0, Add (Arg1, 4)), Local0)
+ Release(varHostAccessMutex)
+ return (Local0)
+ }
+
+ /*----------------------------------------------------------------------------------------*/
+ /**
+ * Write PCIe port indirect register
+ *
+ * Arg0 - BDF
+ * Arg1 - Register offset
+ * Arg2 - Register address
+ * Arg3 - Value
+ */
+ Method (procIndirectRegisterWrite, 4, NotSerialized) {
+ Acquire(varHostAccessMutex, 0xFFFF)
+ procPciDwordWrite (Arg0, Arg1, Arg2)
+ procPciDwordWrite (Arg0, Add (Arg1, 4), Arg3)
+ Release(varHostAccessMutex)
+ }
+
+ /*----------------------------------------------------------------------------------------*/
+ /**
+ * Read Modify Write indirect registers
+ *
+ * Arg0 - BDF
+ * Arg1 - Register Offset
+ * Arg2 - Register Address
+ * Arg3 - AND Mask
+ * Arg4 - OR Mask
+ *
+ */
+ Method (procIndirectRegisterRMW, 5, NotSerialized) {
+ Store (procIndirectRegisterRead (Arg0, Arg1, Arg2), Local0)
+ Or (And (Local0, Arg3), Arg4, Local0)
+ procIndirectRegisterWrite (Arg0, Arg1, Arg2, Local0)
+ }
+
+ /*----------------------------------------------------------------------------------------*/
+ /**
+ *
+ *
+ * Arg0 - Port ID
+ * Retval - buffer that represent port data set
+ */
+ Method (procPcieGetPortInfo, 1, NotSerialized) {
+ return (DeRefOf (Index (varPortInfo, Arg0)))
+ }
+
+ /*----------------------------------------------------------------------------------------*/
+ /**
+ * Find Pci Capability
+ *
+ * Arg0 - PCI address Bus/device/func
+ * Arg1 - Capability id
+ */
+ Method (procFindPciCapability, 2, NotSerialized) {
+ Store (0x34, Local1)
+ if (LEqual (procPciDwordRead (Arg0, 0x0), 0xFFFFFFFF)) {
+ // Device not present
+ return (0)
+ }
+ Store (1, Local0)
+ while (LEqual (Local0, 1)) {
+ Store (And (procPciDwordRead (Arg0, Local1), 0xFF), Local1)
+ if (LNotEqual (Local1, 0)) {
+ if (LEqual (And (procPciDwordRead (Arg0, Local1), 0xFF), Arg1)) {
+ Store (0, Local0)
+ } else {
+ Increment (Local1)
+ }
+ }
+ }
+ return (Local1)
+ }
+
+ /*----------------------------------------------------------------------------------------*/
+ /**
+ *
+ *
+ * Arg0 - Aspm
+ * Arg1 - 0: Read, 1: Write
+ */
+ Method (procPcieSbAspmControl, 2, NotSerialized) {
+ // Create an opregion for PM IO Registers
+ OperationRegion (PMIO, SystemIO, 0xCD6, 0x2)
+ Field (PMIO, ByteAcc, NoLock, Preserve)
+ {
+ PMRI, 8,
+ PMRD, 8
+ }
+ IndexField (PMRI, PMRD, ByteAcc, NoLock, Preserve)
+ {
+ Offset(0xE0), // IO Base address of A-Link Express/ A-Link Bridge register
+ ABAR, 32,
+ }
+ OperationRegion (ACFG, SystemIO, ABAR, 0x8)
+ Field (ACFG, DWordAcc, Nolock, Preserve) //AB_INDX/AB_DATA
+ {
+ ABIX, 32,
+ ABDA, 32
+ }
+
+ Store (0, Local0)
+ if (LEqual (Arg1, 0)) {
+ Store (0x80000068, ABIX)
+ Store (ABDA, Local0)
+ return (Local0)
+ } else {
+ Store (0x80000068, ABIX)
+ Store (ABDA, Local0)
+ Or (And (Local0, 0xfffffffc), Arg0, Local0)
+ Store (Local0, ABDA)
+ }
+
+ }
+
+#ifdef ALIB_DEBUG
+ Name (ABUF, Buffer (256) {})
+ Name (AFUN, 0xff)
+ Method (ADBG, 0, Serialized) {
+ ALIB (AFUN, ABUF);
+ }
+ Alias (procPciDwordRead, AXPR)
+#endif
+
diff --git a/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieAlibV1/PcieAlibHotplug.esl b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieAlibV1/PcieAlibHotplug.esl
new file mode 100644
index 0000000000..fead211aed
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieAlibV1/PcieAlibHotplug.esl
@@ -0,0 +1,328 @@
+/**
+ * @file
+ *
+ * ALIB ASL library
+ *
+ *
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: GNB
+ * @e \$Revision: 31805 $ @e \$Date: 2010-05-21 17:58:16 -0700 (Fri, 21 May 2010) $
+ *
+ */
+/*
+ *****************************************************************************
+ *
+ * Copyright (c) 2011, Advanced Micro Devices, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Advanced Micro Devices, Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***************************************************************************
+ *
+ */
+
+
+ /*----------------------------------------------------------------------------------------*/
+ /**
+ * Set PCIe Bus Width
+ *
+ * Arg0 - Data Buffer
+ */
+ Method (procPcieSetBusWidth, 1, Serialized) {
+ Store (Buffer (256) {}, Local7)
+ CreateWordField (Local7, 0x0, varReturnBufferLength)
+ CreateWordField (Local7, 0x2, varReturnBusWidth)
+ CreateByteField (Arg0, 0x2, varArgBusWidth)
+ //@todo deternime correct lane bitmap (check for reversal) gate/ungate unused lanes
+ Store (3, varReturnBufferLength)
+ Store (varArgBusWidth, varReturnBusWidth)
+ return (Local7)
+ }
+
+
+ /*----------------------------------------------------------------------------------------*/
+ /**
+ * PCIe port hotplug
+ *
+ * Arg0 - Data Buffer
+ * Local7 - Return buffer
+ */
+ Method (procPciePortHotplug, 1, Serialized) {
+ Store ("PciePortHotplug Enter", Debug)
+ Store (Buffer (256) {}, Local7)
+ CreateWordField (Local7, 0x0, varReturnBufferLength)
+ CreateByteField (Local7, 0x2, varReturnStatus)
+ CreateByteField (Local7, 0x3, varReturnDeviceStatus)
+ CreateWordField (Arg0, 0x2, varPortBdf)
+ CreateByteField (Arg0, 0x4, varHotplugState)
+ Subtract (ShiftRight (varPortBdf, 3), 2, Local1);
+ if (LEqual(varHotplugState, 1)) {
+ // Enable port
+ Store (procPciePortEnable (Local1), varHotplugState);
+ } else {
+ // Disable port
+ Store (procPciePortDisable (Local1), varHotplugState);
+ }
+ Store (0x4, varReturnBufferLength)
+ Store (0x0, varReturnStatus)
+ Store (varHotplugState, varReturnDeviceStatus)
+ Store ("PciePortHotplug Exit", Debug)
+ return (Local7)
+ }
+
+
+ /*----------------------------------------------------------------------------------------*/
+ /**
+ * Enable PCIe port
+ *
+ * 1) Ungate lanes
+ * 2) Enable Lanes
+ * 3) Train port
+ * 4) Disable unused lanes
+ * 5) Gate unused lanes
+ *
+ * Arg0 - Port Index
+ *
+ */
+ Method (procPciePortEnable, 1, NotSerialized) {
+ Store ("PciePortEnable Enter", Debug)
+ Name (varLinkIsLinkReversed, 0)
+ Store (procPcieGetPortInfo (Arg0), Local7)
+ CreateByteField (Local7, DEF_OFFSET_LINK_HOTPLUG, varHotplugType)
+ if (LNotEqual (varHotplugType, DEF_BASIC_HOTPLUG)) {
+ Store (" No action.[Hotplug type]", Debug)
+ Store ("PciePortEnable Exit", Debug)
+ return (1)
+ }
+ // Poweron phy lanes
+ CreateByteField (Local7, DEF_OFFSET_START_PHY_LANE, varStartPhyLane)
+ CreateByteField (Local7, DEF_OFFSET_END_PHY_LANE, varEndPhyLane)
+ procPcieLanePowerControl (varStartPhyLane, varEndPhyLane, 0)
+ // Enable lanes
+ CreateByteField (Local7, DEF_OFFSET_START_CORE_LANE, varStartCoreLane)
+ CreateByteField (Local7, DEF_OFFSET_END_CORE_LANE, varEndCoreLane)
+ procPcieLaneEnableControl (Arg0, varStartPhyLane, varEndPhyLane, 0)
+ //Release training
+ procPcieTrainingControl (Arg0, 0)
+ //Train link
+ Store (procPcieCheckDevicePrecence (Arg0), Local1)
+ if (LEqual (Local1, 1)) {
+ Store (" Device detected", Debug)
+ Store (procPcieIsPortReversed (Arg0), varLinkIsLinkReversed)
+ Subtract (procPcieGetLinkWidth (Arg0, 1), procPcieGetLinkWidth (Arg0, 0), Local2)
+ if (LNotEqual (Local2, 0)) {
+ //There is unused lanes after device plugged
+ if (LNotEqual(varLinkIsLinkReversed, 0)) {
+ Add (varStartCoreLane, Local2, Local3)
+ Store (varEndCoreLane, Local4)
+ } else {
+ Subtract (varEndCoreLane, Local2, Local4)
+ Store (varStartCoreLane, Local3)
+ }
+ procPcieLaneEnableControl (Arg0, Local3, Local4, 1)
+ if (LGreater (varStartPhyLane, varEndPhyLane)) {
+ Store (varEndPhyLane, Local3)
+ Store (varStartPhyLane, Local4)
+ } else {
+ Store (varEndPhyLane, Local4)
+ Store (varStartPhyLane, Local3)
+ }
+ if (LNotEqual(varLinkIsLinkReversed, 0)) {
+ Add (Local3, Local2, Local3)
+ } else {
+ Subtract (Local4, Local2, Local4)
+ }
+ procPcieLanePowerControl (Local3, Local4, 1)
+ }
+ Store ("PciePortEnable Exit", Debug)
+ return (1)
+ }
+ Store (" Device detection fail", Debug)
+ procPciePortDisable (Arg0)
+ Store ("PciePortEnable Exit", Debug)
+ return (0)
+ }
+
+ /*----------------------------------------------------------------------------------------*/
+ /**
+ * Disable PCIe port
+ *
+ * 1) Hold training
+ * 2) Disable lanes
+ * 3) Gate lanes
+ *
+ * Arg0 - Port Index
+ *
+ */
+ Method (procPciePortDisable, 1, NotSerialized) {
+ Store ("PciePortDisable Enter", Debug)
+ Store (procPcieGetPortInfo (Arg0), Local7)
+ CreateByteField (Local7, DEF_OFFSET_LINK_HOTPLUG, varHotplugType)
+ if (LNotEqual (varHotplugType, DEF_BASIC_HOTPLUG)) {
+ Store (" No action. [Hotplug type]", Debug)
+ Store ("PciePortDisable Exit", Debug)
+ return (0)
+ }
+ //Hold training
+ procPcieTrainingControl (Arg0, 1)
+ CreateByteField (Local7, DEF_OFFSET_START_CORE_LANE, varStartCoreLane)
+ CreateByteField (Local7, DEF_OFFSET_END_CORE_LANE, varEndCoreLane)
+ // Disable lane
+ procPcieLaneEnableControl (Arg0, varStartCoreLane, varEndCoreLane, 1)
+ CreateByteField (Local7, DEF_OFFSET_START_PHY_LANE, varStartPhyLane)
+ CreateByteField (Local7, DEF_OFFSET_END_PHY_LANE, varEndPhyLane)
+ // Poweroff phy lanes
+ procPcieLanePowerControl (varStartPhyLane, varEndPhyLane, 1)
+
+ Store ("PciePortDisable Exit", Debug)
+ return (0)
+ }
+ /*----------------------------------------------------------------------------------------*/
+ /**
+ * Is port reversed
+ *
+ * Arg0 - Port Index
+ * Retval - 0 - Not reversed / 1 - Reversed
+ */
+ Method (procPcieIsPortReversed , 1, NotSerialized) {
+ Store (procPcieGetPortInfo (Arg0), Local7)
+ CreateByteField (Local7, DEF_OFFSET_START_PHY_LANE, varStartPhyLane)
+ CreateByteField (Local7, DEF_OFFSET_END_PHY_LANE, varEndPhyLane)
+ Store (0, Local0)
+ if (LGreater (varStartPhyLane, varEndPhyLane)) {
+ Store (1, Local0)
+ }
+ And (procPciePortIndirectRegisterRead (Arg0, 0x50), 0x1, Local1)
+ return (Xor (Local0, Local1))
+ }
+
+ /*----------------------------------------------------------------------------------------*/
+ /**
+ * Training Control
+ *
+ * Arg0 - Port Index
+ * Arg1 - Hold Training (1) / Release Training (0)
+ */
+ Method (procPcieTrainingControl , 2, NotSerialized) {
+ Store ("PcieTrainingControl Enter", Debug)
+ Store (procPcieGetPortInfo (Arg0), Local7)
+ CreateByteField (Local7, DEF_OFFSET_PORT_ID, varPortId)
+ CreateWordField (Local7, DEF_OFFSET_WRAPPER_ID, varWrapperId)
+ procIndirectRegisterRMW (0x0, 0xE0, Or (ShiftLeft (varWrapperId, 16), Add (0x800, Multiply (0x100, varPortId))), Not (0x1), Arg1);
+ Store ("PcieTrainingControl Exit", Debug)
+ }
+
+
+ /*----------------------------------------------------------------------------------------*/
+ /**
+ * Check device presence
+ *
+ * Arg0 - Port Index
+ * Retval - 1 - Device present, 0 - Device not present
+ */
+ Method (procPcieCheckDevicePrecence, 1, NotSerialized) {
+ Store ("PcieCheckDevicePrecence Enter", Debug)
+ Store (0, Local0)
+ Store (0, Local7)
+ while (LLess (Local0, 320)) { // @todo for debug only should be 80
+ And (procPciePortIndirectRegisterRead (Arg0, 0xa5), 0x3f, Local1)
+ if (LEqual (Local1, 0x10)) {
+ Store (1, Local7)
+ Store (320, Local0)
+ Break
+ }
+ Stall (250)
+ Increment (Local0)
+ }
+ //Store (Concatenate ("Device Presence Status :", ToHexString (Local7)), Debug)
+ Store ("PcieCheckDevicePrecence Exit", Debug)
+ return (Local7)
+ }
+
+ /*----------------------------------------------------------------------------------------*/
+ /**
+ * Get actual negotiated/PHY or core link width
+ *
+ * Arg0 - Port Index
+ * Arg1 - 0/1 Negotiated/Phy
+ * Retval - Link Width
+ */
+ Method (procPcieGetLinkWidth, 2, NotSerialized) {
+ if (LEqual (Arg0, 0)){
+ //Get negotiated length
+ And (ShiftRight (procPciePortIndirectRegisterRead (Arg0, 0xA2), 4), 0x7, Local0)
+ Store (DeRefOf (Index (Buffer (){0, 1, 2, 4, 8, 12, 16}, Local0)), Local1)
+ } else {
+ //Get phy length
+ Store (procPcieGetPortInfo (Arg0), Local7)
+ CreateByteField (Local7, DEF_OFFSET_START_PHY_LANE, varStartPhyLane)
+ CreateByteField (Local7, DEF_OFFSET_END_PHY_LANE, varEndPhyLane)
+ if (LGreater (varStartPhyLane, varEndPhyLane)) {
+ Subtract (varStartPhyLane, varEndPhyLane, Local1)
+ } else {
+ Subtract (varEndPhyLane, varStartPhyLane, Local1)
+ }
+ Increment (Local1)
+ }
+ //Store (Concatenate ("Link Width :", ToHexString (Local7)), Debug)
+ return (Local1)
+ }
+
+ /*----------------------------------------------------------------------------------------*/
+ /**
+ * PCIe lane mux lane enable control (hotplug support)
+ *
+ * Arg0 - Port Index
+ * Arg1 - Start Lane
+ * Arg2 - End Lane
+ * Arg3 - Enable(0) / Disable(1)
+ */
+ Method (procPcieLaneEnableControl, 4, NotSerialized) {
+ Store ("PcieLaneEnableControl Enter", Debug)
+ Name (varStartCoreLane, 0)
+ Name (varEndCoreLane, 0)
+ Store (procPcieGetPortInfo (Arg0), Local7)
+ Store (Arg1, varStartCoreLane)
+ Store (Arg2, varEndCoreLane)
+ CreateWordField (Local7, DEF_OFFSET_WRAPPER_ID, varWrapperId)
+ if (LGreater (varStartCoreLane, varEndCoreLane)) {
+ Subtract (varStartCoreLane, varEndCoreLane, Local1)
+ Store (varEndCoreLane, Local2)
+ } else {
+ Subtract (varEndCoreLane, varStartCoreLane, Local1)
+ Store (varStartCoreLane, Local2)
+ }
+ ShiftLeft (Subtract (ShiftLeft (1, Add (Local1, 1)), 1), Local2, Local1)
+ //Store (Concatenate ("Lane Bitmap :", ToHexString (Local1)), Debug)
+ if (Lequal (Arg3, 0)) {
+ procIndirectRegisterRMW (0x0, 0xE0, Or (ShiftLeft (varWrapperId, 16), 0x8023), 0xffffffff, Local1);
+ } else {
+ procIndirectRegisterRMW (0x0, 0xE0, Or (ShiftLeft (varWrapperId, 16), 0x8023), Not (Local1), 0x0);
+ }
+ Stall (10)
+ Store ("PcieLaneEnableControl Exit", Debug)
+ }
+
+
diff --git a/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieAlibV1/PcieAlibPspp.esl b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieAlibV1/PcieAlibPspp.esl
new file mode 100644
index 0000000000..70d6a93b84
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieAlibV1/PcieAlibPspp.esl
@@ -0,0 +1,682 @@
+/**
+* @file
+*
+* ALIB PSPP ASL library
+*
+*
+*
+* @xrefitem bom "File Content Label" "Release Content"
+* @e project: AGESA
+* @e sub-project: GNB
+* @e \$Revision: 31805 $ @e \$Date: 2010-05-21 17:58:16 -0700 (Fri, 21 May 2010) $
+*
+*/
+/*
+ *****************************************************************************
+ *
+ * Copyright (c) 2011, Advanced Micro Devices, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Advanced Micro Devices, Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***************************************************************************
+ *
+ */
+
+ /*----------------------------------------------------------------------------------------*/
+ /**
+ * PCIe Performance Policy
+ *
+ * varPsppPolicy - 0 Disabled
+ * 1 Performance
+ * 2 Balance Hight
+ * 3 Balance Low
+ * 4 Power Saving
+ */
+ Name (
+ AD02,
+ 0x0
+ )
+
+ Alias (
+ AD02,
+ varPsppPolicy
+ )
+
+ /*----------------------------------------------------------------------------------------*/
+ /**
+ * GEN2 VID
+ *
+ */
+
+ Name (
+ AD03,
+ 0x0
+ )
+
+ Alias (
+ AD03,
+ varGen2Vid
+ )
+
+ /*----------------------------------------------------------------------------------------*/
+ /**
+ * GEN1 VID
+ *
+ */
+ Name (
+ AD04,
+ 0x0
+ )
+
+ Alias (
+ AD04,
+ varGen1Vid
+ )
+
+ /*----------------------------------------------------------------------------------------*/
+ /**
+ * Boot VID
+ *
+ */
+
+ Name (
+ AD05,
+ 0x0
+ )
+
+ Alias (
+ AD05,
+ varBootVid
+ )
+
+ /*----------------------------------------------------------------------------------------*/
+ /**
+ * Max Port GEN capability
+ *
+ */
+ Name (
+ AD06,
+ Package () {
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00
+ }
+ )
+
+ Alias (
+ AD06,
+ varPsppMaxPortCapabilityArray
+ )
+
+ /*----------------------------------------------------------------------------------------*/
+ /**
+ * Policy service status
+ *
+ * varPsppPolicyService - 0 (Stopped)
+ * 1 (Started)
+ */
+
+ Name (
+ varPsppPolicyService,
+ 0x0
+ )
+
+ /*----------------------------------------------------------------------------------------*/
+ /**
+ * AC DC state
+ *
+ * varPsppAcDcState - 0 (AC)
+ * 1 (DC)
+ */
+
+ Name (
+ varPsppAcDcState,
+ 0x0
+ )
+
+
+ Name (
+ varPsppClientIdArray,
+ Package () {
+ 0x0000,
+ 0x0000,
+ 0x0000,
+ 0x0000,
+ 0x0000,
+ 0x0000,
+ 0x0000
+ }
+ )
+
+ Name (
+ varPsppClientCapabilityArray,
+ Package () {
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00
+ }
+ )
+
+ Name (
+ varPsppCurrentCapabilityArray,
+ Package () {
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00
+ }
+ )
+ Name (
+ varDefaultGen1CapabilityArray,
+ Package () {
+ 0x2,
+ 0x2,
+ 0x2,
+ 0x2,
+ 0x2,
+ 0x2,
+ 0x2
+ }
+ )
+
+
+ /*----------------------------------------------------------------------------------------*/
+ /**
+ * Report AC/DC state
+ *
+ * Arg0 - Data Buffer
+ */
+ Method (procPsppReportAcDsState, 1, Serialized) {
+ Store ("PsppReportAcDsState Enter", Debug)
+ CreateByteField (Arg0, 0x2, varArgAcDcState)
+
+ Store ("AC/DC state = ", Debug)
+ Store (varArgAcDcState, Debug)
+ if (LEqual (varArgAcDcState, varPsppAcDcState)) {
+ Store (" No action. [AC/DC state not changed]", Debug)
+ Store ("PsppReportAcDsState Exit", Debug)
+ return (0)
+ }
+ Store (varArgAcDcState, varPsppAcDcState)
+ // Set DPM state for Power Saving, due to this policy will not attend ApplyPsppState service.
+ if (LEqual (varPsppPolicy, DEF_PSPP_POLICY_POWERSAVING)) {
+ procNbLclkDpmActivate(1, varPsppAcDcState)
+ }
+ if (LOr (LLessEqual (varPsppPolicy, DEF_PSPP_POLICY_PERFORMANCE), LGreaterEqual (varPsppPolicy, DEF_PSPP_POLICY_POWERSAVING))) {
+ Store (" No action. [Policy type]", Debug)
+ Store ("PsppReportAcDsState Exit", Debug)
+ return (0)
+ }
+ if (LEqual (varPsppPolicyService, DEF_PSPP_POLICY_STOP)) {
+ Store (" No action. [Policy not started]", Debug)
+ Store ("PsppReportAcDsState Exit", Debug)
+ return (0)
+ }
+ procApplyPsppState ()
+ Store ("PsppReportAcDsState Exit", Debug)
+ return (0)
+ }
+
+ /*----------------------------------------------------------------------------------------*/
+ /**
+ * PCIe Performance Request
+ *
+ * Arg0 - Data Buffer
+ */
+ Method (procPsppPerformanceRequest, 1) {
+ Store ("PsppPerformanceRequest Enter", Debug)
+ Name (varClientBus, 0)
+ Name (varPortIndex, 0)
+ Store (Buffer (256) {}, Local7)
+ CreateWordField (Local7, 0x0, varReturnBufferLength)
+ Store (3, varReturnBufferLength)
+ CreateByteField (Local7, 0x2, varReturnStatus)
+ Store (1, varReturnStatus)
+ if (LOr (LLessEqual (varPsppPolicy, DEF_PSPP_POLICY_PERFORMANCE), LGreaterEqual (varPsppPolicy, DEF_PSPP_POLICY_POWERSAVING))) {
+ Store (" No action. [Policy type]", Debug)
+ Store ("PsppPerformanceRequest Exit", Debug)
+ return (Local7)
+ }
+ if (LEqual (varPsppPolicyService, DEF_PSPP_POLICY_STOP)) {
+ Store (" No action. [Policy not started]", Debug)
+ Store ("PsppPerformanceRequest Exit", Debug)
+ return (Local7)
+ }
+ CreateWordField (Arg0, 0x2, varClientId)
+ CreateWordField (Arg0, 0x4, varValidFlag)
+ CreateWordField (Arg0, 0x6, varFlag)
+ CreateByteField (Arg0, 0x8, varRequestType)
+ CreateByteField (Arg0, 0x9, varRequestData)
+
+ Store (" Client ID:", Debug)
+ Store (varClientId, Debug)
+ Store (" Valid Flags:", Debug)
+ Store (varValidFlag, Debug)
+ Store (" Flags:", Debug)
+ Store (varFlag, Debug)
+ Store (" Request Type:", Debug)
+ Store (varRequestType, Debug)
+ Store (" Request Data:", Debug)
+ Store (varRequestData, Debug)
+
+ And (ShiftRight (varClientId, 8), 0xff, varClientBus)
+ While (LLessEqual (varPortIndex, varMaxPortIndexNumber)) {
+ if (LEqual (DeRefOf (Index (varPsppMaxPortCapabilityArray, varPortIndex)), 0)) {
+ Increment (varPortIndex)
+ Continue
+ }
+ Store (procPciDwordRead (ShiftLeft (Add( varPortIndex, 2), 3), 0x18), Local1)
+ And (ShiftRight (Local1, 16), 0xff, Local2) //Local2 Port Subordinate Bus number
+ And (ShiftRight (Local1, 8), 0xff, Local1) //Local1 Port Secondary Bus number
+ if (LAnd (LLess (varClientBus, Local1), LGreater (varClientBus, Local2))) {
+ Increment (varPortIndex)
+ Continue
+ }
+ Store ("Performance request for port index", Debug)
+ Store (varPortIndex, Debug)
+
+ if (LEqual (DeRefOf (Index (varPsppClientIdArray, varPortIndex)), 0x0000)) {
+ Store (varClientId, Index (varPsppClientIdArray, varPortIndex))
+ } ElseIf (LNotEqual (DeRefOf (Index (varPsppClientIdArray, varPortIndex)), varClientId)) {
+ // We already have registered client
+ Store (" No action. [Unsupported request]", Debug)
+ Store ("PsppPerformanceRequest Exit", Debug)
+ return (Local7)
+ }
+ if (LEqual (varRequestData, 0)) {
+ Store (0x0000, Index (varPsppClientIdArray, varPortIndex))
+ } else {
+ if (LEqual (And (varValidFlag, varFlag), 0x1)) {
+ Store (DerefOf (Index (varPsppMaxPortCapabilityArray, varPortIndex)), Index (varPsppClientCapabilityArray, varPortIndex))
+ } else {
+ Store (varRequestData, Index (varPsppClientCapabilityArray, varPortIndex))
+ }
+ }
+ procApplyPsppState ()
+ Store (2, varReturnStatus)
+ Store ("PsppPerformanceRequest Exit", Debug)
+ return (Local7)
+ }
+ Store ("PsppPerformanceRequest Exit", Debug)
+ return (Local7)
+ }
+
+ /*----------------------------------------------------------------------------------------*/
+ /**
+ * PSPP Start/Stop Management Request
+ *
+ * Arg0 - Data Buffer
+ */
+ Method (procPsppControl, 1, Serialized) {
+ Store ("PsppControl Enter", Debug)
+ Store (Buffer (256) {}, Local7)
+ CreateWordField (Local7, 0x0, varReturnBufferLength)
+ Store (3, varReturnBufferLength)
+ CreateByteField (Local7, 0x2, varReturnStatus)
+ CreateByteField (Arg0, 0x2, varArgPsppRequest)
+ Store (varArgPsppRequest, varPsppPolicyService)
+ // Set DPM state for PSPP Power Saving, due to this policy will not attend ApplyPsppState service.
+ if (LEqual (varPsppPolicy, DEF_PSPP_POLICY_POWERSAVING)) {
+ procNbLclkDpmActivate(1, varPsppAcDcState)
+ }
+ //Reevaluate PCIe speed for all devices base on PSPP state switch to boot up voltage
+ if (LAnd (LGreater (varPsppPolicy, DEF_PSPP_POLICY_PERFORMANCE), LLess (varPsppPolicy, DEF_PSPP_POLICY_POWERSAVING))) {
+ // Load default speed capability state
+ if (LEqual (varPsppPolicy, DEF_PSPP_POLICY_BALANCEHIGH)) {
+ procCopyPackage (RefOf (varPsppMaxPortCapabilityArray), RefOf (varPsppCurrentCapabilityArray))
+ } else {
+ procCopyPackage (RefOf (varDefaultGen1CapabilityArray), RefOf (varPsppCurrentCapabilityArray))
+ }
+ // Unregister all clients
+ if (LEqual (varPsppPolicyService, DEF_PSPP_POLICY_STOP)) {
+ Name (varDefaultPsppClientIdArray, Package () {0x0, 0x0, 0x0, 0x0, 0x0, 0x0})
+ procCopyPackage (RefOf (varDefaultPsppClientIdArray), RefOf (varPsppClientIdArray))
+ }
+ procApplyPsppState ()
+ }
+ Store (3, varReturnBufferLength)
+ Store (0, varReturnStatus)
+ Store ("PsppControl Exit", Debug)
+ return (Local7)
+ }
+
+ /*----------------------------------------------------------------------------------------*/
+ /**
+ * Evaluate PCIe speed on all links according to PSPP state and client requests
+ *
+ *
+ *
+ */
+ Method (procApplyPsppState, 0, Serialized) {
+ Store ("ApplyPsppState Enter", Debug)
+ Name (varPortIndex, 0)
+ Name (varLowPowerMode, 0)
+ Name (varPcieCapabilityArray, Package () {0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02})
+
+ Store (0, varPortIndex)
+ While (LLessEqual (varPortIndex, varMaxPortIndexNumber)) {
+ if (LNotEqual (DeRefOf (Index (varPsppMaxPortCapabilityArray, varPortIndex)), 0)) {
+ Store (procGetPortRequestedCapability (varPortIndex), Index (varPcieCapabilityArray, varPortIndex))
+ }
+ Increment (varPortIndex)
+ }
+ if (LNotEqual(Match (varPcieCapabilityArray, MEQ, 0x01, MTR, 0, 0), ONES)) {
+ procCopyPackage (RefOf (varDefaultGen1CapabilityArray), RefOf (varPcieCapabilityArray))
+ }
+ if (LNotEqual(Match (varPcieCapabilityArray, MEQ, 0x03, MTR, 0, 0), ONES)) {
+ // Set GEN2 voltage
+ Store ("Set GEN2 VID", Debug)
+ procPcieSetVoltage (varGen2Vid, 1)
+ procPcieAdjustPll (2)
+ procNbLclkDpmActivate(2, varPsppAcDcState)
+ }
+ Store (0, varPortIndex)
+ While (LLessEqual (varPortIndex, varMaxPortIndexNumber)) {
+ if (LEqual (DeRefOf (Index (varPsppMaxPortCapabilityArray, varPortIndex)), 0)) {
+ Increment (varPortIndex)
+ Continue
+ }
+ Store (procGetPortCurrentCapability (varPortIndex), Local0)
+ Store (DerefOf (Index (varPcieCapabilityArray, varPortIndex)), Local2)
+ if (LEqual (Local0, Local2)) {
+ Increment (varPortIndex)
+ Continue
+ }
+ procSetPortCapabilityAndSpeed (varPortIndex, Local2, 0)
+ Increment (varPortIndex)
+ }
+ if (LEqual(Match (varPcieCapabilityArray, MEQ, 0x03, MTR, 0, 0), ONES)) {
+ // Set GEN1 voltage
+ Store ("Set GEN1 VID", Debug)
+ procNbLclkDpmActivate(1, varPsppAcDcState)
+ procPcieAdjustPll (1)
+ procPcieSetVoltage (varGen1Vid, 0)
+ }
+ Store ("ApplyPsppState Exit", Debug)
+ }
+ /*----------------------------------------------------------------------------------------*/
+ /**
+ * Read PCI config register
+ *
+ * Arg0 - Port Index
+ *
+ */
+ Method (procGetPortRequestedCapability, 1) {
+ Store (0x3, Local0)
+ if (LEqual (DerefOf (Index (varPsppClientIdArray, Arg0)), 0x0000)) {
+ if (LOr (LEqual (varPsppAcDcState, DEF_PSPP_STATE_DC), LEqual (varPsppPolicy, DEF_PSPP_POLICY_BALANCELOW))) {
+ // Default policy cap to GEN1
+ Store (0x2, Local0)
+ }
+ } else {
+ Store (DerefOf (Index (varPsppClientCapabilityArray, Arg0)), Local0)
+ }
+ return (Local0)
+ }
+
+ /*----------------------------------------------------------------------------------------*/
+ /**
+ * Read PCI config register
+ *
+ * Arg0 - Port Index
+ *
+ */
+ Method (procGetPortCurrentCapability, 1) {
+ return (DerefOf (Index (varPsppCurrentCapabilityArray, Arg0)))
+ }
+
+ /*----------------------------------------------------------------------------------------*/
+ /**
+ * Set capability and speed
+ *
+ * Arg0 - Port Index
+ * Arg1 - Capability
+ * Arg2 - Speed
+ */
+ Method (procSetPortCapabilityAndSpeed, 3) {
+ Store ("SetPortCapabilityAndSpeed Enter", Debug)
+ if (LOr (LEqual (Arg1, 0x2), LEqual (Arg1, 0x3))) {
+ Store ("Port Index = ", Debug)
+ Store (Arg0, Debug)
+ Store ("Cap = ", Debug)
+ Store (Arg1, Debug)
+ Store ("Speed = ", Debug)
+ Store (Arg2, Debug)
+
+ Name (varDxF0xE4_xA4, 0x20000001)
+ Name (varPortPresent, 0x00000000)
+ Name (varDxF0x88, 0x00000002)
+ Name (varAXCFGx68_PmCtrl, 0x00000000)
+ Name (varLcCurrentDataRate,0x00000000)
+ Name (varSecondaryBus, 0x00000000)
+ Name (varHeaderType, 0x00000000)
+ Name (varMultiFunction, 0x00000000)
+ Name (varPcieLinkControlOffset, 0x00000000)
+ Name (varPcieLinkControlData, 0x00000000)
+ Name (varPcieLinkControlArray, Package () {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0})
+
+
+ //If request for UMI unhihe port congig space
+ if (LEqual (Arg0, 6)) {
+ procIndirectRegisterRMW (0x0, 0x60, 0x80, Not (0x40), 0x40);
+
+ }
+ Store (Arg1, Index (varPsppCurrentCapabilityArray, Arg0))
+ if (LEqual (Arg1, 0x2)) {
+ //Gen1
+ Store (0x00000000, varDxF0xE4_xA4)
+ Store (0x21, varDxF0x88)
+ }
+
+ // Programming for LcInitSpdChgWithCsrEn
+ if (LNotEqual (DeRefOf (Index (varPsppClientIdArray, Arg0)), 0x0000)) {
+ // Registered port, LcInitSpdChgWithCsrEn = 0.
+ procPciePortIndirectRegisterRMW (Arg0, 0xA1, Not (0x00001000), 0x0)
+ } else {
+ procPciePortIndirectRegisterRMW (Arg0, 0xA1, Not (0x00001000), 0x00001000)
+ }
+
+ // Initialize port
+ procPciePortIndirectRegisterRMW (Arg0, 0xA4, Not (0x20000001), varDxF0xE4_xA4)
+ //set target link speed
+ Store (ShiftLeft (Add( Arg0, 2), 3), Local0)
+ procPciDwordRMW (Local0, 0x88, Not (0x0000002f), varDxF0x88)
+
+ // Determine port PCI address and check port present
+ Store (ShiftLeft (Add( Arg0, 2), 3), Local0)
+ And (procPciDwordRead (Local0, 0x70), 0x400000, varPortPresent)
+ if (LNotEqual (varPortPresent, 0)) {
+ //Disable ASPM on EP
+ if (LNotEqual (Arg0, 6)) {
+ Store (procPciDwordRead (Local0, 0x18), Local3)
+ Store (And (ShiftRight (Local3, 8), 0xFF), varSecondaryBus)
+ Store ("Disable EP ASPM on SecondaryBus = ", Debug)
+ Store (varSecondaryBus, Debug)
+ Store (ShiftLeft (varSecondaryBus, 8), Local3)
+ Store (procPciDwordRead (Local3, 0xC), Local3)
+ Store (And (ShiftRight (Local3, 16), 0xFF), varHeaderType)
+ Store ("Header Type = ", Debug)
+ Store (varHeaderType, Debug)
+
+ if (LNotEqual (And (varHeaderType, 0x80), 0)) {
+ Store (0x7, varMultiFunction)
+ }
+
+ Store (ShiftLeft (varSecondaryBus, 8), Local3)
+ Store (0, Local2)
+ while (LLessEqual (Local2, varMultiFunction)) {
+
+ //Find PcieLinkControl register offset = PcieCapPtr + 0x10
+ Store (procFindPciCapability (Local3, 0x10), varPcieLinkControlOffset)
+ if (LNotEqual (varPcieLinkControlOffset, 0)) {
+ Add (varPcieLinkControlOffset, 0x10, varPcieLinkControlOffset)
+
+ Store ("Function number of SecondaryBus = ", Debug)
+ Store (Local2, Debug)
+ Store ("Find PcieLinkControl register offset = ", Debug)
+ Store (varPcieLinkControlOffset, Debug)
+ // Save ASPM on EP
+ Store (procPciDwordRead (Local3, varPcieLinkControlOffset), varPcieLinkControlData)
+ Store (And (varPcieLinkControlData, 0x3), Index (varPcieLinkControlArray, Local2))
+ Store ("PcieLinkControlData = ", Debug)
+ Store (varPcieLinkControlData, Debug)
+ Store ("Save ASPM = ", Debug)
+ Store (DerefOf (Index (varPcieLinkControlArray, Local2)), Debug)
+ // Disable ASPM
+ if (LNotEqual (And (varPcieLinkControlData, 0x3), 0x0)) {
+ procPciDwordRMW (Local3, varPcieLinkControlOffset, Not (0x00000003), 0x00)
+ Store ("Disable ASPM on EP Complete!!", Debug)
+ }
+ }
+ Increment (Local2)
+ Increment (Local3)
+ }
+
+ } else {
+
+ Store (procPcieSbAspmControl (0, 0), varAXCFGx68_PmCtrl)
+ And (varAXCFGx68_PmCtrl, 0x3, Local1)
+ if (LNotEqual (Local1, 0x0)) {
+ procPcieSbAspmControl (0, 1)
+ }
+ }
+ Store (1, Local2)
+ while (Local2) {
+ //retrain port
+ procPciDwordRMW (Local0, 0x68, Not (0x00000000), 0x20)
+ Sleep (30)
+ while (And (procPciDwordRead (Local0, 0x68), 0x08000000)) {Sleep (10)}
+ Store (0, Local2)
+ if (LEqual (Arg1, 0x2)) { // if Gen1
+ Store (procPciePortIndirectRegisterRead (Arg0, 0xA4), varLcCurrentDataRate)
+ if (LNotEqual (And (varLcCurrentDataRate, 0x800), 0)) {
+ Store (1, Local2)
+ }
+ }
+ }
+ //restore ASPM setting
+ if (LNotEqual (Arg0, 6)) {
+ // Restore EP
+ //if (LNotEqual (varPcieLinkControlOffset, 0)) {
+ // procPciDwordWrite (Local3, varPcieLinkControlOffset, varPcieLinkControlData)
+ //}
+ Store (ShiftLeft (varSecondaryBus, 8), Local3)
+ Store (0, Local2)
+ while (LLessEqual (Local2, varMultiFunction)) {
+
+ //Find PcieLinkControl register offset = PcieCapPtr + 0x10
+ Store (procFindPciCapability (Local3, 0x10), varPcieLinkControlOffset)
+ if (LNotEqual (varPcieLinkControlOffset, 0)) {
+ Add (varPcieLinkControlOffset, 0x10, varPcieLinkControlOffset)
+
+ Store ("Restore Function number of SecondaryBus = ", Debug)
+ Store (Local2, Debug)
+ Store ("Restore Find PcieLinkControl register offset = ", Debug)
+ Store (varPcieLinkControlOffset, Debug)
+ Store ("Restore ASPM = ", Debug)
+ Store (DerefOf (Index (varPcieLinkControlArray, Local2)), Debug)
+ procPciDwordWrite (Local3, varPcieLinkControlOffset, DerefOf (Index (varPcieLinkControlArray, Local2)))
+ }
+ Increment (Local2)
+ Increment (Local3)
+ }
+
+ } else {
+ // Restore SB
+ procPcieSbAspmControl (varAXCFGx68_PmCtrl, 1)
+ }
+ } else {
+ Store (" Device not present. Set capability and speed only", Debug)
+ }
+ //If request for UMI hide port congig space
+ if (LEqual (Arg0, 6)) {
+ procIndirectRegisterRMW (0x0, 0x60, 0x80, Not (0x40), 0x00);
+ }
+ }
+ Store ("SetPortCapabilityAndSpeed Exit", Debug)
+ }
+ Mutex (varVoltageChangeMutex, 0)
+ /*----------------------------------------------------------------------------------------*/
+ /**
+ * Request VID
+ *
+ * Arg0 - VID index
+ * Arg1 - 0 = do not wait intil voltage is set
+ * 1 = wait until voltage is set
+ */
+ Method (procPcieSetVoltage, 2) {
+ Store ("PcieSetVoltage(procPcieSetVoltage) Enter", Debug)
+ Acquire(varVoltageChangeMutex, 0xFFFF)
+ Store (procIndirectRegisterRead (0x0, 0x60, 0xEA), Local1)
+ //Enable voltage change
+ Or (Local1, 0x2, Local1)
+ procIndirectRegisterWrite (0x0, 0x60, 0xEA, Local1)
+ //Clear voltage index
+ And (Local1, Not (ShiftLeft (0x3, 3)), Local1)
+ //Set new voltage index
+ Store (" Voltage Index:", Debug)
+ Store (Arg0, Debug)
+ Or (Local1, ShiftLeft (Arg0, 3), Local1)
+ //Togle request
+ And (Not (Local1), 0x4, Local2)
+ Or (And (Local1, Not (0x4)), Local2, Local1)
+ procIndirectRegisterWrite (0x0, 0x60, 0xEA, Local1)
+ if (LNotEqual (Arg1, 0)) {
+ while (LNotEqual (ShiftLeft(Local1, 0x2), Local2)) {
+ And (procIndirectRegisterRead (0x0, 0x60, 0xEB), 0x1, Local1)
+ }
+ }
+ Release (varVoltageChangeMutex)
+ Store ("PcieSetVoltage(procPcieSetVoltage) Exit", Debug)
+ }
+
+ /*----------------------------------------------------------------------------------------*/
+ /**
+ * Read PCIe port indirect register
+ *
+ * Arg0 - Ref Source Pckage
+ * Arg1 - Ref to Destination Package
+ *
+ */
+ Method (procCopyPackage, 2, NotSerialized) {
+
+ Store (SizeOf (Arg0), Local1)
+ Store (0, Local0)
+ While (LLess (Local0, Local1)) {
+ Store (DerefOf(Index(DerefOf (Arg0), Local0)), Index(DerefOf (Arg1), Local0))
+ Increment (Local0)
+ }
+ }
+
diff --git a/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieConfig/GnbPcieConfig.h b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieConfig/GnbPcieConfig.h
new file mode 100644
index 0000000000..d18c103428
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieConfig/GnbPcieConfig.h
@@ -0,0 +1,54 @@
+/* $NoKeywords:$ */
+/**
+ * @file
+ *
+ * PCIe configuration
+ *
+ *
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: GNB
+ * @e \$Revision: 34897 $ @e \$Date: 2010-07-13 19:07:10 -0700 (Tue, 13 Jul 2010) $
+ *
+ */
+/*
+ *****************************************************************************
+ *
+ * Copyright (c) 2011, Advanced Micro Devices, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Advanced Micro Devices, Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***************************************************************************
+ *
+ */
+
+#ifndef _GNBPCIECONFIG_H_
+#define _GNBPCIECONFIG_H_
+
+
+#include "PcieConfigData.h"
+#include "PcieConfigLib.h"
+
+#endif
diff --git a/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieConfig/PcieConfigData.c b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieConfig/PcieConfigData.c
new file mode 100644
index 0000000000..30ebb61e28
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieConfig/PcieConfigData.c
@@ -0,0 +1,379 @@
+/* $NoKeywords:$ */
+/**
+ * @file
+ *
+ * GNB function to create/locate PCIe configuration data area
+ *
+ * Contain code that create/locate and rebase configuration data area.
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: GNB
+ * @e \$Revision: 39898 $ @e \$Date: 2010-10-15 17:08:45 -0400 (Fri, 15 Oct 2010) $
+ *
+ */
+/*
+ *****************************************************************************
+ *
+ * Copyright (c) 2011, Advanced Micro Devices, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Advanced Micro Devices, Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***************************************************************************
+ *
+ */
+
+/*----------------------------------------------------------------------------------------
+ * M O D U L E S U S E D
+ *----------------------------------------------------------------------------------------
+ */
+#include "AGESA.h"
+#include "Ids.h"
+#include "amdlib.h"
+#include "heapManager.h"
+#include "Gnb.h"
+#include "GnbPcie.h"
+#include "GnbPcieFamServices.h"
+#include GNB_MODULE_DEFINITIONS (GnbCommonLib)
+#include GNB_MODULE_DEFINITIONS (GnbPcieConfig)
+#include "PcieMapTopology.h"
+#include "PcieInputParser.h"
+#include "Filecode.h"
+#define FILECODE PROC_GNB_MODULES_GNBPCIECONFIG_PCIECONFIGDATA_FILECODE
+/*----------------------------------------------------------------------------------------
+ * D E F I N I T I O N S A N D M A C R O S
+ *----------------------------------------------------------------------------------------
+ */
+
+
+#define REBASE_PTR( Ptr, OldBase, NewBase) *(UINTN *)Ptr = (*(UINTN *)Ptr + (UINTN) NewBase - (UINTN) OldBase);
+
+extern BUILD_OPT_CFG UserOptions;
+
+/*----------------------------------------------------------------------------------------
+ * T Y P E D E F S A N D S T R U C T U R E S
+ *----------------------------------------------------------------------------------------
+ */
+
+
+/*----------------------------------------------------------------------------------------
+ * P R O T O T Y P E S O F L O C A L F U N C T I O N S
+ *----------------------------------------------------------------------------------------
+ */
+
+VOID
+PcieConfigDebugDump (
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ );
+
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Create internal PCIe configuration data
+ *
+ *
+ *
+ * @param[in] StdHeader Standard configuration header
+ * @retval AGESA_SUCCESS Configuration data successfully allocated.
+ * @retval AGESA_FATAL Configuration data allocation failed.
+ */
+
+AGESA_STATUS
+PcieConfigurationInit (
+ IN AMD_CONFIG_PARAMS *StdHeader
+ )
+{
+ AMD_EARLY_PARAMS *EarlyParamsPtr;
+ PCIe_COMPLEX_DESCRIPTOR *ComplexList;
+ PCIe_PLATFORM_CONFIG *Pcie;
+ AGESA_STATUS AgesaStatus;
+ AGESA_STATUS Status;
+ PCIe_COMPLEX_DESCRIPTOR *ComplexDescriptor;
+ UINTN ComplexesDataLength;
+ UINTN ComplexIndex;
+ UINTN NumberOfComplexes;
+ VOID *Buffer;
+ UINTN Index;
+ UINT32 NumberOfSockets;
+ UINT32 SocketId;
+
+ IDS_HDT_CONSOLE (GNB_TRACE, "PcieConfigurationInit Enter\n");
+ EarlyParamsPtr = (AMD_EARLY_PARAMS *) StdHeader;
+ ComplexList = EarlyParamsPtr->GnbConfig.PcieComplexList;
+ AgesaStatus = AGESA_SUCCESS;
+ ComplexesDataLength = 0;
+ NumberOfSockets = GnbGetNumberOfSockets (StdHeader);
+ for (SocketId = 0; SocketId < NumberOfSockets; SocketId++) {
+ if (GnbIsDevicePresentInSocket (SocketId, StdHeader)) {
+ UINTN CurrentComplexesDataLength;
+ Status = PcieFmGetComplexDataLength (SocketId, &CurrentComplexesDataLength);
+ ASSERT (Status == AGESA_SUCCESS);
+ ComplexesDataLength += CurrentComplexesDataLength;
+ }
+ }
+ NumberOfComplexes = PcieInputParserGetNumberOfComplexes (ComplexList);
+ Pcie = GnbAllocateHeapBuffer (AMD_PCIE_COMPLEX_DATA_HANDLE, sizeof (PCIe_PLATFORM_CONFIG) + ComplexesDataLength, StdHeader);
+ if (Pcie == NULL) {
+ IDS_ERROR_TRAP;
+ return AGESA_FATAL;
+ }
+ LibAmdMemFill (Pcie, 0x00, sizeof (PCIe_PLATFORM_CONFIG) + ComplexesDataLength, StdHeader);
+ Pcie->StdHeader = (PVOID) StdHeader;
+ Pcie->This = (UINTN) (Pcie);
+ Buffer = (UINT8 *) (Pcie) + sizeof (PCIe_PLATFORM_CONFIG);
+ ComplexIndex = 0;
+ for (SocketId = 0; SocketId < NumberOfSockets; SocketId++) {
+ if (GnbIsDevicePresentInSocket (SocketId, StdHeader)) {
+ UINTN CurrentComplexesDataLength;
+ if (ComplexIndex > MAX_NUMBER_OF_COMPLEXES) {
+ IDS_ERROR_TRAP;
+ return AGESA_FATAL;
+ }
+ Pcie->ComplexList[ComplexIndex].SiliconList = (PPCIe_SILICON_CONFIG) Buffer;
+ PcieFmBuildComplexConfiguration (Buffer, StdHeader);
+ for (Index = 0; Index < NumberOfComplexes; Index++) {
+ ComplexDescriptor = PcieInputParserGetComplexDescriptor (ComplexList, Index);
+ if (ComplexDescriptor->SocketId == SocketId) {
+ Status = PcieMapTopologyOnComplex (ComplexDescriptor, &Pcie->ComplexList[Index], Pcie);
+ AGESA_STATUS_UPDATE (Status, AgesaStatus);
+ }
+ }
+ PcieFmGetComplexDataLength (SocketId, &CurrentComplexesDataLength);
+ Buffer = (VOID *) ((UINT8 *)Buffer + CurrentComplexesDataLength);
+ ComplexIndex++;
+ }
+ }
+ Pcie->ComplexList[ComplexIndex - 1].Flags |= DESCRIPTOR_TERMINATE_LIST;
+ Pcie->LinkReceiverDetectionPooling = PCIE_LINK_RECEIVER_DETECTION_POOLING;
+ Pcie->LinkL0Pooling = PCIE_LINK_L0_POOLING;
+ Pcie->LinkGpioResetAssertionTime = PCIE_LINK_GPIO_RESET_ASSERT_TIME;
+ Pcie->LinkResetToTrainingTime = PCIE_LINK_RESET_TO_TRAINING_TIME;
+ Pcie->GfxCardWorkaround = GfxWorkaroundEnable;
+ if ((UserOptions.CfgAmdPlatformType & AMD_PLATFORM_MOBILE) != 0) {
+ Pcie->GfxCardWorkaround = GfxWorkaroundDisable;
+ }
+ Pcie->PsppPolicy = EarlyParamsPtr->GnbConfig.PsppPolicy;
+ IDS_OPTION_CALLOUT (IDS_CALLOUT_GNB_PCIE_PLATFORM_CONFIG, Pcie, StdHeader);
+ GNB_DEBUG_CODE (
+ PcieConfigDebugDump (Pcie);
+ );
+ IDS_HDT_CONSOLE (GNB_TRACE, "PcieConfigurationInit Exit [0x%x]\n", AgesaStatus);
+ return AgesaStatus;
+}
+
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Locate global PCIe configuration data
+ *
+ *
+ *
+ * @param[in] StdHeader Standard configuration header
+ * @param[out] Pcie Pointer to global PCIe configuration
+ * @retval AGESA_SUCCESS Configuration data successfully located
+ * @retval AGESA_FATAL Configuration can not be located.
+ */
+AGESA_STATUS
+PcieLocateConfigurationData (
+ IN AMD_CONFIG_PARAMS *StdHeader,
+ OUT PCIe_PLATFORM_CONFIG **Pcie
+ )
+{
+ PCIe_COMPLEX_CONFIG *Complex;
+ *Pcie = GnbLocateHeapBuffer (AMD_PCIE_COMPLEX_DATA_HANDLE, StdHeader);
+ if (*Pcie == NULL) {
+ IDS_ERROR_TRAP;
+ return AGESA_FATAL;
+ }
+ if ((UINTN) (*Pcie) != (UINTN) (*Pcie)->This) {
+ Complex = &(*Pcie)->ComplexList[0];
+ while (Complex != NULL) {
+ PCIe_SILICON_CONFIG *SiliconList;
+ REBASE_PTR (&Complex->SiliconList, (UINTN) (*Pcie)->This, (UINTN)*Pcie);
+ SiliconList = PcieComplexGetSiliconList (Complex);
+ PcieRebaseConfigurationData (SiliconList, (UINTN) (*Pcie)->This, (UINTN)*Pcie);
+ Complex = PcieLibGetNextDescriptor (Complex);
+ }
+ (*Pcie)->This = (UINTN)(*Pcie);
+ }
+ (*Pcie)->StdHeader = (PVOID) StdHeader;
+ return AGESA_SUCCESS;
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Rebase all pointers in Complex Configuration Data
+ *
+ *
+ *
+ * @param[in] SiliconList Pointer to first silicon descriptor of the complex
+ * @param[in] OldBase Old base address of the configuration data
+ * @param[in] NewBase New base address of the configuration data
+ */
+VOID
+PcieRebaseConfigurationData (
+ IN PCIe_SILICON_CONFIG *SiliconList,
+ IN UINTN OldBase,
+ IN UINTN NewBase
+ )
+{
+ while (SiliconList != NULL) {
+ PCIe_WRAPPER_CONFIG *WrapperList;
+ REBASE_PTR (&SiliconList->WrapperList, OldBase, NewBase);
+ REBASE_PTR (&SiliconList->FmSilicon, OldBase, NewBase);
+ WrapperList = PcieSiliconGetWrapperList (SiliconList);
+ while (WrapperList != NULL) {
+ PCIe_ENGINE_CONFIG *EngineList;
+ REBASE_PTR (&WrapperList->EngineList, OldBase, NewBase);
+ REBASE_PTR (&WrapperList->FmWrapper, OldBase, NewBase);
+ REBASE_PTR (&WrapperList->Silicon, OldBase, NewBase);
+ EngineList = PcieWrapperGetEngineList (WrapperList);
+ while (EngineList != NULL) {
+ REBASE_PTR (&EngineList->Wrapper, OldBase, NewBase);
+ EngineList = PcieLibGetNextDescriptor (EngineList);
+ }
+ WrapperList = PcieLibGetNextDescriptor (WrapperList);
+ }
+ SiliconList = PcieLibGetNextDescriptor (SiliconList);
+ }
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Helper function to dump configuration to debug out
+ *
+ *
+ * @param[in] Pcie Pointer to global PCIe configuration
+ */
+VOID
+PcieConfigDebugDump (
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ PCIe_ENGINE_CONFIG *EngineList;
+ PCIe_SILICON_CONFIG *SiliconList;
+ PCIe_WRAPPER_CONFIG *WrapperList;
+ PCIe_COMPLEX_CONFIG *ComplexList;
+ ComplexList = &Pcie->ComplexList[0];
+ IDS_HDT_CONSOLE (PCIE_MISC, "<-------------- PCIe Config Start----------------->\n");
+ IDS_HDT_CONSOLE (PCIE_MISC, " PSPP Policy - %s\n",
+ (Pcie->PsppPolicy == PsppPowerSaving) ? "Power Saving" :
+ (Pcie->PsppPolicy == PsppBalanceHigh) ? "Balance-High" : (
+ (Pcie->PsppPolicy == PsppBalanceLow) ? "Balance-Low" : (
+ (Pcie->PsppPolicy == PsppPerformance) ? "Performance" : (
+ (Pcie->PsppPolicy == PsppDisabled) ? "Disabled" : "Unknown")))
+ );
+ IDS_HDT_CONSOLE (PCIE_MISC, " GFX Workaround - %s\n",
+ (Pcie->GfxCardWorkaround == 0) ? "Disabled" : "Enabled"
+ );
+ IDS_HDT_CONSOLE (PCIE_MISC, " LinkL0Pooling - %dus\n",
+ Pcie->LinkL0Pooling
+ );
+ IDS_HDT_CONSOLE (PCIE_MISC, " LinkGpioResetAssertionTime - %dus\n",
+ Pcie->LinkGpioResetAssertionTime
+ );
+ IDS_HDT_CONSOLE (PCIE_MISC, " LinkReceiverDetectionPooling - %dus\n",
+ Pcie->LinkReceiverDetectionPooling
+ );
+ SiliconList = PcieComplexGetSiliconList (ComplexList);
+ while (SiliconList != NULL) {
+ WrapperList = PcieSiliconGetWrapperList (SiliconList);
+ while (WrapperList != NULL) {
+ IDS_HDT_CONSOLE (PCIE_MISC, " <---------Wrapper - %s Config -------->\n",
+ PcieFmDebugGetWrapperNameString (WrapperList)
+ );
+ IDS_HDT_CONSOLE (PCIE_MISC, " PowerOffUnusedLanes - %x\n PowerOffUnusedPlls - %x\n ClkGating - %x\n"
+ " LclkGating - %x\n TxclkGatingPllPowerDown - %x\n PllOffInL1 - %x\n",
+ WrapperList->Features.PowerOffUnusedLanes,
+ WrapperList->Features.PowerOffUnusedPlls,
+ WrapperList->Features.ClkGating,
+ WrapperList->Features.LclkGating,
+ WrapperList->Features.TxclkGatingPllPowerDown,
+ WrapperList->Features.PllOffInL1
+ );
+ IDS_HDT_CONSOLE (PCIE_MISC, " <---------Wrapper - %s Config End----->\n",
+ PcieFmDebugGetWrapperNameString (WrapperList)
+ );
+ EngineList = PcieWrapperGetEngineList (WrapperList);
+ while (EngineList != NULL) {
+ if (PcieLibIsEngineAllocated (EngineList)) {
+ IDS_HDT_CONSOLE (PCIE_MISC, " Engine Type - %s\n Start Phy Lane - %d\n End Phy Lane - %d\n",
+ ((EngineList->EngineData.EngineType == PciePortEngine) ? "PCIe Port" : "DDI Link"),
+ EngineList->EngineData.StartLane,
+ EngineList->EngineData.EndLane
+ );
+ if (PcieLibIsPcieEngine (EngineList)) {
+ IDS_HDT_CONSOLE (PCIE_MISC, " PCIe port configuration:\n");
+ IDS_HDT_CONSOLE (PCIE_MISC, " Port Training - %s\n",
+ (EngineList->Type.Port.PortData.PortPresent == PortDisabled) ? "Disable" : "Enabled"
+ );
+ IDS_HDT_CONSOLE (PCIE_MISC, " Start Core Lane - %d\n", EngineList->Type.Port.StartCoreLane);
+ IDS_HDT_CONSOLE (PCIE_MISC, " End Core Lane - %d\n", EngineList->Type.Port.EndCoreLane);
+ IDS_HDT_CONSOLE (PCIE_MISC, " PCI Address - %d:%d:%d\n",
+ EngineList->Type.Port.Address.Address.Bus,
+ EngineList->Type.Port.Address.Address.Device,
+ EngineList->Type.Port.Address.Address.Function
+ );
+ IDS_HDT_CONSOLE (PCIE_MISC, " Native PCI Dev Number - %d\n", EngineList->Type.Port.NativeDevNumber);
+ IDS_HDT_CONSOLE (PCIE_MISC, " Native PCI Func Number - %d\n", EngineList->Type.Port.NativeFunNumber);
+ IDS_HDT_CONSOLE (PCIE_MISC, " Hotplug - %s\n",
+ (EngineList->Type.Port.PortData.LinkHotplug == 0) ? "Disabled" : (
+ (EngineList->Type.Port.PortData.LinkHotplug == 1) ? "Basic" : (
+ (EngineList->Type.Port.PortData.LinkHotplug == 2) ? "Server" : (
+ (EngineList->Type.Port.PortData.LinkHotplug == 2) ? "Enhanced" : "Unknown")))
+ );
+ IDS_HDT_CONSOLE (PCIE_MISC, " ASPM - %s\n",
+ (EngineList->Type.Port.PortData.LinkAspm == 0) ? "Disabled" : (
+ (EngineList->Type.Port.PortData.LinkAspm == 1) ? "L0s" : (
+ (EngineList->Type.Port.PortData.LinkAspm == 2) ? "L1" : (
+ (EngineList->Type.Port.PortData.LinkAspm == 3) ? "L0s & L1" : "Unknown")))
+ );
+ IDS_HDT_CONSOLE (PCIE_MISC, " Speed - %d\n",
+ EngineList->Type.Port.PortData.LinkSpeedCapability
+ );
+ } else {
+ IDS_HDT_CONSOLE (PCIE_MISC, " DDI configuration:\n");
+ IDS_HDT_CONSOLE (PCIE_MISC, " Connector - %s\n",
+ (EngineList->Type.Ddi.DdiData.ConnectorType == ConnectorTypeDP) ? "DP" : (
+ (EngineList->Type.Ddi.DdiData.ConnectorType == ConnectorTypeEDP) ? "eDP" : (
+ (EngineList->Type.Ddi.DdiData.ConnectorType == ConnectorTypeSingleLinkDVI) ? "Single Link DVI" : (
+ (EngineList->Type.Ddi.DdiData.ConnectorType == ConnectorTypeDualLinkDVI) ? "Dual Link DVI" : (
+ (EngineList->Type.Ddi.DdiData.ConnectorType == ConnectorTypeHDMI) ? "HDMI" : (
+ (EngineList->Type.Ddi.DdiData.ConnectorType == ConnectorTypeTravisDpToVga) ? "Travis DP-to-VGA" : (
+ (EngineList->Type.Ddi.DdiData.ConnectorType == ConnectorTypeTravisDpToLvds) ? "Travis DP-to-LVDS" : (
+ (EngineList->Type.Ddi.DdiData.ConnectorType == ConnectorTypeLvds) ? "LVDS" : (
+ (EngineList->Type.Ddi.DdiData.ConnectorType == ConnectorTypeNutmegDpToVga) ? "Hudson-2 Nutmeg DP-to-VGA" : "Unknown"))))))))
+ );
+ IDS_HDT_CONSOLE (PCIE_MISC, " Aux - Aux%d\n", EngineList->Type.Ddi.DdiData.AuxIndex + 1);
+ IDS_HDT_CONSOLE (PCIE_MISC, " Hdp - Hdp%d\n", EngineList->Type.Ddi.DdiData.HdpIndex + 1);
+ }
+ }
+ EngineList = PcieLibGetNextDescriptor (EngineList);
+ }
+ WrapperList = PcieLibGetNextDescriptor (WrapperList);
+ }
+ SiliconList = PcieLibGetNextDescriptor (SiliconList);
+ }
+ IDS_HDT_CONSOLE (PCIE_MISC, "<-------------- PCIe Config End------------------>\n");
+} \ No newline at end of file
diff --git a/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieConfig/PcieConfigData.h b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieConfig/PcieConfigData.h
new file mode 100644
index 0000000000..f40a123a52
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieConfig/PcieConfigData.h
@@ -0,0 +1,65 @@
+/* $NoKeywords:$ */
+/**
+ * @file
+ *
+ * GNB function to create/locate PCIe configuration data area
+ *
+ * Contain code that create/locate and rebase configuration data area.
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: GNB
+ * @e \$Revision: 38519 $ @e \$Date: 2010-09-24 17:08:48 -0700 (Fri, 24 Sep 2010) $
+ *
+ */
+/*
+ *****************************************************************************
+ *
+ * Copyright (c) 2011, Advanced Micro Devices, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Advanced Micro Devices, Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***************************************************************************
+ *
+ */
+
+#ifndef _PCIECONFIGDATA_H_
+#define _PCIECONFIGDATA_H_
+
+
+AGESA_STATUS
+PcieLocateConfigurationData (
+ IN AMD_CONFIG_PARAMS *StdHeader,
+ OUT PCIe_PLATFORM_CONFIG **Pcie
+ );
+
+VOID
+PcieRebaseConfigurationData (
+ IN PCIe_SILICON_CONFIG *SiliconList,
+ IN UINTN OldBase,
+ IN UINTN NewBase
+ );
+
+#endif
+
diff --git a/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieConfig/PcieConfigLib.c b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieConfig/PcieConfigLib.c
new file mode 100644
index 0000000000..616e1d5e2a
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieConfig/PcieConfigLib.c
@@ -0,0 +1,356 @@
+/* $NoKeywords:$ */
+/**
+ * @file
+ *
+ * GNB function to create/locate PCIe configuration data area
+ *
+ * Contain code that create/locate and rebase configuration data area.
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: GNB
+ * @e \$Revision: 39898 $ @e \$Date: 2010-10-15 17:08:45 -0400 (Fri, 15 Oct 2010) $
+ *
+ */
+/*
+ *****************************************************************************
+ *
+ * Copyright (c) 2011, Advanced Micro Devices, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Advanced Micro Devices, Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***************************************************************************
+ *
+ */
+
+/*----------------------------------------------------------------------------------------
+ * M O D U L E S U S E D
+ *----------------------------------------------------------------------------------------
+ */
+#include "AGESA.h"
+#include "Ids.h"
+#include "amdlib.h"
+#include "Gnb.h"
+#include "GnbPcie.h"
+#include "GnbPcieFamServices.h"
+#include GNB_MODULE_DEFINITIONS (GnbCommonLib)
+#include GNB_MODULE_DEFINITIONS (GnbPcieConfig)
+#include "PcieMapTopology.h"
+#include "Filecode.h"
+#define FILECODE PROC_GNB_MODULES_GNBPCIECONFIG_PCIECONFIGLIB_FILECODE
+/*----------------------------------------------------------------------------------------
+ * D E F I N I T I O N S A N D M A C R O S
+ *----------------------------------------------------------------------------------------
+ */
+
+
+/*----------------------------------------------------------------------------------------
+ * T Y P E D E F S A N D S T R U C T U R E S
+ *----------------------------------------------------------------------------------------
+ */
+
+
+/*----------------------------------------------------------------------------------------
+ * P R O T O T Y P E S O F L O C A L F U N C T I O N S
+ *----------------------------------------------------------------------------------------
+ */
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Get number of core lanes
+ *
+ *
+ *
+ * @param[in] Engine Pointer to engine descriptor
+ * @retval Number of core lane
+ */
+UINT8
+PcieConfigGetNumberOfCoreLane (
+ IN PCIe_ENGINE_CONFIG *Engine
+ )
+{
+ if (Engine->Type.Port.StartCoreLane >= UNUSED_LANE_ID || Engine->Type.Port.EndCoreLane >= UNUSED_LANE_ID) {
+ return 0;
+ }
+ return (UINT8) (Engine->Type.Port.EndCoreLane - Engine->Type.Port.StartCoreLane + 1);
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Disable engine
+ *
+ *
+ *
+ * @param[in] Engine Pointer to engine config descriptor
+ */
+VOID
+PcieConfigDisableEngine (
+ IN PCIe_ENGINE_CONFIG *Engine
+ )
+{
+ if (Engine->Type.Port.IsSB) {
+ return;
+ }
+ Engine->Flags &= ~DESCRIPTOR_ALLOCATED;
+}
+
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Disable all engines on wrapper
+ *
+ *
+ *
+ * @param[in] EngineTypeMask Engine type bitmap.
+ * @param[in] Wrapper Pointer to wrapper config descriptor
+ */
+VOID
+PcieConfigDisableAllEngines (
+ IN UINTN EngineTypeMask,
+ IN PCIe_WRAPPER_CONFIG *Wrapper
+ )
+{
+ PCIe_ENGINE_CONFIG *EngineList;
+ EngineList = PcieWrapperGetEngineList (Wrapper);
+ while (EngineList != NULL) {
+ if ((EngineList->EngineData.EngineType & EngineTypeMask) != 0) {
+ PcieConfigDisableEngine (EngineList);
+ }
+ EngineList = PcieLibGetNextDescriptor (EngineList);
+ }
+}
+
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Get engine PHY lanes bitmap
+ *
+ *
+ *
+ * @param[in] Engine Pointer to engine config descriptor
+ */
+UINT32
+PcieConfigGetEnginePhyLaneBitMap (
+ IN PCIe_ENGINE_CONFIG *Engine
+ )
+{
+ UINT32 LaneBitMap;
+ LaneBitMap = 0;
+ if (PcieLibIsEngineAllocated (Engine)) {
+ LaneBitMap = ((1 << PcieConfigGetNumberOfPhyLane (Engine)) - 1) << (PcieUtilGetLoPhyLane (Engine) - PcieEngineGetParentWrapper (Engine)->StartPhyLane);
+ }
+ return LaneBitMap;
+}
+
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Get number of phy lanes
+ *
+ *
+ *
+ * @param[in] Engine Pointer to engine config descriptor
+ * @retval Number of Phy lane
+ */
+UINT8
+PcieConfigGetNumberOfPhyLane (
+ IN PCIe_ENGINE_CONFIG *Engine
+ )
+{
+ if (Engine->EngineData.StartLane >= UNUSED_LANE_ID || Engine->EngineData.StartLane >= UNUSED_LANE_ID) {
+ return 0;
+ }
+ if (Engine->EngineData.StartLane > Engine->EngineData.EndLane) {
+ return (UINT8) (Engine->EngineData.StartLane - Engine->EngineData.EndLane + 1);
+ } else {
+ return (UINT8) (Engine->EngineData.EndLane - Engine->EngineData.StartLane + 1);
+ }
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Get port configuration signature for given wrapper and core
+ *
+ * Support for unify register access through index/data pair on GNB
+ *
+ * @param[in] Wrapper Pointer to wrapper config descriptor
+ * @param[in] CoreId Core ID
+ * @retval Configuration Signature
+ */
+UINT64
+PcieConfigGetConfigurationSignature (
+ IN PCIe_WRAPPER_CONFIG *Wrapper,
+ IN UINT8 CoreId
+ )
+{
+ UINT64 ConfigurationSignature;
+ PCIe_ENGINE_CONFIG *EngineList;
+ ConfigurationSignature = 0;
+ EngineList = PcieWrapperGetEngineList (Wrapper);
+ while (EngineList != NULL) {
+ if (EngineList->Type.Port.CoreId == CoreId) {
+ ConfigurationSignature = (ConfigurationSignature << 8) | PcieConfigGetNumberOfCoreLane (EngineList);
+ }
+ EngineList = PcieLibGetNextDescriptor (EngineList);
+ }
+ return ConfigurationSignature;
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Check Port Status
+ *
+ *
+ *
+ * @param[in] Engine Pointer to engine config descriptor
+ * @param[in] PortStatus Check if status asserted for port
+ * @retval TRUE if status asserted
+ */
+BOOLEAN
+PcieConfigCheckPortStatus (
+ IN PCIe_ENGINE_CONFIG *Engine,
+ IN UINT32 PortStatus
+ )
+{
+ return (Engine->InitStatus & PortStatus) == 0 ? FALSE : TRUE;
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Set/Reset port status
+ *
+ *
+ *
+ * @param[in] Engine Pointer to engine config descriptor
+ * @param[in] SetStatus SetStatus
+ * @param[in] ResetStatus ResetStatus
+ *
+ */
+UINT32
+PcieConfigUpdatePortStatus (
+ IN PCIe_ENGINE_CONFIG *Engine,
+ IN UINT32 SetStatus,
+ IN UINT32 ResetStatus
+ )
+{
+ Engine->InitStatus |= SetStatus;
+ Engine->InitStatus &= (~ResetStatus);
+ return Engine->InitStatus;
+}
+
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Execute callback on all engine in topology
+ *
+ *
+ * @param[in] DescriptorFlags Wrapper Flags
+ * @param[in] Callback Pointer to callback function
+ * @param[in, out] Buffer Pointer to buffer to pass information to callback
+ * @param[in] Pcie Pointer to global PCIe configuration
+ */
+
+AGESA_STATUS
+PcieConfigRunProcForAllWrappers (
+ IN UINT32 DescriptorFlags,
+ IN PCIe_RUN_ON_WRAPPER_CALLBACK Callback,
+ IN OUT VOID *Buffer,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ AGESA_STATUS AgesaStatus;
+ AGESA_STATUS Status;
+ PCIe_COMPLEX_CONFIG *Complex;
+ AgesaStatus = AGESA_SUCCESS;
+ Complex = Pcie->ComplexList;
+ while (Complex != NULL) {
+ PCIe_SILICON_CONFIG *Silicon;
+ Silicon = PcieComplexGetSiliconList (Complex);
+ while (Silicon != NULL) {
+ PCIe_WRAPPER_CONFIG *Wrapper;
+ Wrapper = PcieSiliconGetWrapperList (Silicon);
+ while (Wrapper != NULL) {
+ if (!(PcieLibIsVirtualDesciptor (Wrapper) && (DescriptorFlags & DESCRIPTOR_VIRTUAL) == 0)) {
+ if ((DescriptorFlags & DESCRIPTOR_ALL_WRAPPERS & Wrapper->Flags) != 0) {
+ Status = Callback (Wrapper, Buffer, Pcie);
+ AGESA_STATUS_UPDATE (Status, AgesaStatus);
+ }
+ }
+ Wrapper = PcieLibGetNextDescriptor (Wrapper);
+ }
+ Silicon = PcieLibGetNextDescriptor (Silicon);
+ }
+ Complex = PcieLibGetNextDescriptor (Complex);
+ }
+ return AgesaStatus;
+}
+
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Execute callback on all engine in topology
+ *
+ *
+ * @param[in] DescriptorFlags Engine flags.
+ * @param[in] Callback Pointer to callback function
+ * @param[in, out] Buffer Pointer to buffer to pass information to callback
+ * @param[in] Pcie Pointer to global PCIe configuration
+ */
+
+VOID
+PcieConfigRunProcForAllEngines (
+ IN UINT32 DescriptorFlags,
+ IN PCIe_RUN_ON_ENGINE_CALLBACK Callback,
+ IN OUT VOID *Buffer,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ PCIe_COMPLEX_CONFIG *Complex;
+ Complex = Pcie->ComplexList;
+ while (Complex != NULL) {
+ PCIe_SILICON_CONFIG *Silicon;
+ Silicon = PcieComplexGetSiliconList (Complex);
+ while (Silicon != NULL) {
+ PCIe_WRAPPER_CONFIG *Wrapper;
+ Wrapper = PcieSiliconGetWrapperList (Silicon);
+ while (Wrapper != NULL) {
+ PCIe_ENGINE_CONFIG *Engine;
+ Engine = PcieWrapperGetEngineList (Wrapper);
+ while (Engine != NULL) {
+ if (!(PcieLibIsVirtualDesciptor (Engine) && (DescriptorFlags & DESCRIPTOR_VIRTUAL) == 0)) {
+ if (!((DescriptorFlags & DESCRIPTOR_ALLOCATED) != 0 && !PcieLibIsEngineAllocated (Engine))) {
+ if ((Engine->Flags & DESCRIPTOR_ALL_ENGINES & DescriptorFlags) != 0) {
+ Callback (Engine, Buffer, Pcie);
+ }
+ }
+ }
+ Engine = PcieLibGetNextDescriptor (Engine);
+ }
+ Wrapper = PcieLibGetNextDescriptor (Wrapper);
+ }
+ Silicon = PcieLibGetNextDescriptor (Silicon);
+ }
+ Complex = PcieLibGetNextDescriptor (Complex);
+ }
+}
diff --git a/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieConfig/PcieConfigLib.h b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieConfig/PcieConfigLib.h
new file mode 100644
index 0000000000..18b6615beb
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieConfig/PcieConfigLib.h
@@ -0,0 +1,123 @@
+/* $NoKeywords:$ */
+/**
+ * @file
+ *
+ * GNB function to create/locate PCIe configuration data area
+ *
+ * Contain code that create/locate and rebase configuration data area.
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: GNB
+ * @e \$Revision: 38519 $ @e \$Date: 2010-09-24 17:08:48 -0700 (Fri, 24 Sep 2010) $
+ *
+ */
+/*
+ *****************************************************************************
+ *
+ * Copyright (c) 2011, Advanced Micro Devices, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Advanced Micro Devices, Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***************************************************************************
+ *
+ */
+
+#ifndef _PCIECONFIGLIB_H_
+#define _PCIECONFIGLIB_H_
+
+typedef VOID (*PCIe_RUN_ON_ENGINE_CALLBACK) (
+ IN PCIe_ENGINE_CONFIG *Engine,
+ IN OUT VOID *Buffer,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ );
+
+typedef AGESA_STATUS (*PCIe_RUN_ON_WRAPPER_CALLBACK) (
+ IN PCIe_WRAPPER_CONFIG *Wrapper,
+ IN OUT VOID *Buffer,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ );
+
+UINT8
+PcieConfigGetNumberOfCoreLane (
+ IN PCIe_ENGINE_CONFIG *Engine
+ );
+
+VOID
+PcieConfigDisableAllEngines (
+ IN UINTN EngineTypeMask,
+ IN PCIe_WRAPPER_CONFIG *Wrapper
+ );
+
+VOID
+PcieConfigDisableEngine (
+ IN PCIe_ENGINE_CONFIG *Engine
+ );
+
+UINT32
+PcieConfigGetEnginePhyLaneBitMap (
+ IN PCIe_ENGINE_CONFIG *Engine
+ );
+
+UINT8
+PcieConfigGetNumberOfPhyLane (
+ IN PCIe_ENGINE_CONFIG *Engine
+ );
+
+UINT64
+PcieConfigGetConfigurationSignature (
+ IN PCIe_WRAPPER_CONFIG *Wrapper,
+ IN UINT8 CoreId
+ );
+
+BOOLEAN
+PcieConfigCheckPortStatus (
+ IN PCIe_ENGINE_CONFIG *Engine,
+ IN UINT32 PortStatus
+ );
+
+UINT32
+PcieConfigUpdatePortStatus (
+ IN PCIe_ENGINE_CONFIG *Engine,
+ IN UINT32 SetStatus,
+ IN UINT32 ResetStatus
+ );
+
+VOID
+PcieConfigRunProcForAllEngines (
+ IN UINT32 DescriptorFlags,
+ IN PCIe_RUN_ON_ENGINE_CALLBACK Callback,
+ IN OUT VOID *Buffer,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ );
+
+AGESA_STATUS
+PcieConfigRunProcForAllWrappers (
+ IN UINT32 DescriptorFlags,
+ IN PCIe_RUN_ON_WRAPPER_CALLBACK Callback,
+ IN OUT VOID *Buffer,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ );
+#endif
+
diff --git a/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieConfig/PcieInputParser.c b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieConfig/PcieInputParser.c
new file mode 100644
index 0000000000..6a9da54ee7
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieConfig/PcieInputParser.c
@@ -0,0 +1,218 @@
+/* $NoKeywords:$ */
+/**
+ * @file
+ *
+ * Procedure to parse PCIe input configuration data
+ *
+ *
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: GNB
+ * @e \$Revision: 39898 $ @e \$Date: 2010-10-15 17:08:45 -0400 (Fri, 15 Oct 2010) $
+ *
+ */
+/*
+ *****************************************************************************
+ *
+ * Copyright (c) 2011, Advanced Micro Devices, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Advanced Micro Devices, Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***************************************************************************
+ *
+ */
+
+/*----------------------------------------------------------------------------------------
+ * M O D U L E S U S E D
+ *----------------------------------------------------------------------------------------
+ */
+#include "AGESA.h"
+#include "Ids.h"
+#include "Gnb.h"
+#include "GnbPcie.h"
+#include "Filecode.h"
+#define FILECODE PROC_GNB_MODULES_GNBPCIECONFIG_PCIEINPUTPARSER_FILECODE
+/*----------------------------------------------------------------------------------------
+ * D E F I N I T I O N S A N D M A C R O S
+ *----------------------------------------------------------------------------------------
+ */
+
+
+/*----------------------------------------------------------------------------------------
+ * T Y P E D E F S A N D S T R U C T U R E S
+ *----------------------------------------------------------------------------------------
+ */
+
+
+/*----------------------------------------------------------------------------------------
+ * P R O T O T Y P E S O F L O C A L F U N C T I O N S
+ *----------------------------------------------------------------------------------------
+ */
+
+
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Get number of complexes in platform topology configuration
+ *
+ *
+ *
+ * @param[in] ComplexList First complex configuration in complex configuration array
+ * @retval Number of Complexes
+ *
+ */
+UINTN
+PcieInputParserGetNumberOfComplexes (
+ IN PCIe_COMPLEX_DESCRIPTOR *ComplexList
+ )
+{
+ UINTN Result;
+ Result = 0;
+ while (ComplexList != NULL) {
+ Result++;
+ ComplexList = PcieLibGetNextDescriptor (ComplexList);
+ }
+ return Result;
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Get number of PCIe engines in given complex
+ *
+ *
+ *
+ * @param[in] Complex Complex configuration
+ * @retval Number of Engines
+ */
+UINTN
+PcieInputParserGetLengthOfPcieEnginesList (
+ IN PCIe_COMPLEX_DESCRIPTOR *Complex
+ )
+{
+ UINTN Result;
+ PCIe_PORT_DESCRIPTOR *PciePortList;
+ Result = 0;
+ PciePortList = Complex->PciePortList;
+ while (PciePortList != NULL) {
+ Result++;
+ PciePortList = PcieLibGetNextDescriptor (PciePortList);
+ }
+ return Result;
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Get number of DDI engines in given complex
+ *
+ *
+ *
+ * @param[in] Complex Complex configuration
+ * @retval Number of Engines
+ */
+UINTN
+PcieInputParserGetLengthOfDdiEnginesList (
+ IN PCIe_COMPLEX_DESCRIPTOR *Complex
+ )
+{
+ UINTN Result;
+ PCIe_DDI_DESCRIPTOR *DdiLinkList;
+ Result = 0;
+ DdiLinkList = Complex->DdiLinkList;
+ while (DdiLinkList != NULL) {
+ Result++;
+ DdiLinkList = PcieLibGetNextDescriptor (DdiLinkList);
+ }
+ return Result;
+}
+
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Get number of engines in given complex
+ *
+ *
+ *
+ * @param[in] Complex Complex configuration header
+ * @retval Number of Engines
+ */
+UINTN
+PcieInputParserGetNumberOfEngines (
+ IN PCIe_COMPLEX_DESCRIPTOR *Complex
+ )
+{
+ UINTN Result;
+
+ Result = PcieInputParserGetLengthOfDdiEnginesList (Complex) +
+ PcieInputParserGetLengthOfPcieEnginesList (Complex);
+ return Result;
+}
+
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Get Complex descriptor by index from given Platform configuration
+ *
+ *
+ *
+ * @param[in] ComplexList Platform topology configuration
+ * @param[in] Index Complex descriptor Index
+ * @retval Pointer to Complex Descriptor
+ */
+PCIe_COMPLEX_DESCRIPTOR*
+PcieInputParserGetComplexDescriptor (
+ IN PCIe_COMPLEX_DESCRIPTOR *ComplexList,
+ IN UINTN Index
+ )
+{
+ ASSERT (Index < (PcieInputParserGetNumberOfComplexes (ComplexList)));
+ return &ComplexList[Index];
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Get Engine descriptor from given complex by index
+ *
+ *
+ *
+ * @param[in] Complex Complex descriptor
+ * @param[in] Index Engine descriptor index
+ * @retval Pointer to Engine Descriptor
+ */
+PCIe_ENGINE_DESCRIPTOR*
+PcieInputParserGetEngineDescriptor (
+ IN PCIe_COMPLEX_DESCRIPTOR *Complex,
+ IN UINTN Index
+ )
+{
+ UINTN PcieListlength;
+ ASSERT (Index < (PcieInputParserGetNumberOfEngines (Complex)));
+ PcieListlength = PcieInputParserGetLengthOfPcieEnginesList (Complex);
+ if (Index < PcieListlength) {
+ return (PCIe_ENGINE_DESCRIPTOR*) &((Complex->PciePortList)[Index]);
+ } else {
+ return (PCIe_ENGINE_DESCRIPTOR*) &((Complex->DdiLinkList)[Index - PcieListlength]);
+ }
+}
+
diff --git a/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieConfig/PcieInputParser.h b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieConfig/PcieInputParser.h
new file mode 100644
index 0000000000..e30d1e1387
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieConfig/PcieInputParser.h
@@ -0,0 +1,75 @@
+/* $NoKeywords:$ */
+/**
+ * @file
+ *
+ * Procedure to parse PCIe input configuration data
+ *
+ *
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: GNB
+ * @e \$Revision: 34897 $ @e \$Date: 2010-07-13 19:07:10 -0700 (Tue, 13 Jul 2010) $
+ *
+ */
+/*
+ *****************************************************************************
+ *
+ * Copyright (c) 2011, Advanced Micro Devices, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Advanced Micro Devices, Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***************************************************************************
+ *
+ */
+#ifndef _PCIEINPUTPARSER_H_
+#define _PCIEINPUTPARSER_H_
+
+
+UINTN
+PcieInputParserGetNumberOfComplexes (
+ IN PCIe_COMPLEX_DESCRIPTOR *ComplexList
+ );
+
+UINTN
+PcieInputParserGetNumberOfEngines (
+ IN PCIe_COMPLEX_DESCRIPTOR *Complex
+ );
+
+
+PCIe_COMPLEX_DESCRIPTOR*
+PcieInputParserGetComplexDescriptor (
+ IN PCIe_COMPLEX_DESCRIPTOR *ComplexList,
+ IN UINTN Index
+ );
+
+PCIe_ENGINE_DESCRIPTOR*
+PcieInputParserGetEngineDescriptor (
+ IN PCIe_COMPLEX_DESCRIPTOR *Complex,
+ IN UINTN Index
+ );
+
+
+#endif
+
diff --git a/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieConfig/PcieMapTopology.c b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieConfig/PcieMapTopology.c
new file mode 100644
index 0000000000..70215514e2
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieConfig/PcieMapTopology.c
@@ -0,0 +1,720 @@
+/* $NoKeywords:$ */
+/**
+ * @file
+ *
+ * Procedure to map user define topology to processor configuration
+ *
+ *
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: GNB
+ * @e \$Revision: 39898 $ @e \$Date: 2010-10-15 17:08:45 -0400 (Fri, 15 Oct 2010) $
+ *
+ */
+/*
+ *****************************************************************************
+ *
+ * Copyright (c) 2011, Advanced Micro Devices, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Advanced Micro Devices, Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***************************************************************************
+ *
+ */
+
+/*----------------------------------------------------------------------------------------
+ * M O D U L E S U S E D
+ *----------------------------------------------------------------------------------------
+ */
+#include "AGESA.h"
+#include "Ids.h"
+#include "amdlib.h"
+#include "Gnb.h"
+#include "GnbPcie.h"
+#include "GnbPcieFamServices.h"
+#include "GeneralServices.h"
+#include "PcieInputParser.h"
+#include "PcieMapTopology.h"
+#include GNB_MODULE_DEFINITIONS (GnbPcieConfig)
+#include "Filecode.h"
+#define FILECODE PROC_GNB_MODULES_GNBPCIECONFIG_PCIEMAPTOPOLOGY_FILECODE
+/*----------------------------------------------------------------------------------------
+ * D E F I N I T I O N S A N D M A C R O S
+ *----------------------------------------------------------------------------------------
+ */
+
+
+/*----------------------------------------------------------------------------------------
+ * T Y P E D E F S A N D S T R U C T U R E S
+ *----------------------------------------------------------------------------------------
+ */
+
+
+/*----------------------------------------------------------------------------------------
+ * P R O T O T Y P E S O F L O C A L F U N C T I O N S
+ *----------------------------------------------------------------------------------------
+ */
+
+
+AGESA_STATUS
+STATIC
+PcieMapPortsPciAddresses (
+ IN PCIe_SILICON_CONFIG *Silicon,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ );
+
+AGESA_STATUS
+PcieMapTopologyOnWrapper (
+ IN PCIe_COMPLEX_DESCRIPTOR *ComplexDescriptor,
+ IN OUT PCIe_WRAPPER_CONFIG *Wrapper,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ );
+
+VOID
+PcieMapInitializeEngineData (
+ IN PCIe_COMPLEX_DESCRIPTOR *ComplexDescriptor,
+ IN OUT PCIe_WRAPPER_CONFIG *Wrapper,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ );
+
+BOOLEAN
+PcieCheckPortPciDeviceMapping (
+ IN PCIe_PORT_DESCRIPTOR *PortDescriptor,
+ IN PCIe_ENGINE_CONFIG *Engine
+ );
+
+VOID
+PcieComplexConfigConfigDump (
+ IN PCIe_COMPLEX_DESCRIPTOR *ComplexDescriptor,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ );
+
+BOOLEAN
+PcieIsDescriptorLinkWidthValid (
+ IN PCIe_ENGINE_DESCRIPTOR *EngineDescriptor
+ );
+
+BOOLEAN
+PcieCheckLanesMatch (
+ IN PCIe_ENGINE_DESCRIPTOR *EngineDescriptor,
+ IN PCIe_ENGINE_CONFIG *Engine
+ );
+
+BOOLEAN
+PcieCheckDescriptorMapsToWrapper (
+ IN PCIe_ENGINE_DESCRIPTOR *EngineDescriptor,
+ IN PCIe_WRAPPER_CONFIG *Wrapper
+ );
+
+VOID
+PcieAllocateEngine (
+ IN UINT8 DescriptorIndex,
+ IN PCIe_ENGINE_CONFIG *Engine
+ );
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Configure engine list to support lane allocation according to configuration ID.
+ *
+ *
+ *
+ * @param[in] ComplexDescriptor Pointer to used define complex descriptor
+ * @param[in] Complex Pointer to complex descriptor
+ * @param[in] Pcie Pointer to global PCIe configuration
+ * @retval AGESA_SUCCESS Topology successfully mapped
+ * @retval AGESA_ERROR Topology can not be mapped
+ */
+
+AGESA_STATUS
+PcieMapTopologyOnComplex (
+ IN PCIe_COMPLEX_DESCRIPTOR *ComplexDescriptor,
+ IN PCIe_COMPLEX_CONFIG *Complex,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ PCIe_SILICON_CONFIG *Silicon;
+ PCIe_WRAPPER_CONFIG *Wrapper;
+ AGESA_STATUS AgesaStatus;
+ AGESA_STATUS Status;
+
+ AgesaStatus = AGESA_SUCCESS;
+ IDS_HDT_CONSOLE (GNB_TRACE, "PcieMapTopologyOnComplex Enter\n");
+ GNB_DEBUG_CODE (
+ PcieComplexConfigConfigDump (ComplexDescriptor, Pcie);
+ );
+ Silicon = PcieComplexGetSiliconList (Complex);
+ while (Silicon != NULL) {
+ Wrapper = PcieSiliconGetWrapperList (Silicon);
+ while (Wrapper != NULL) {
+ Status = PcieMapTopologyOnWrapper (ComplexDescriptor, Wrapper, Pcie);
+ AGESA_STATUS_UPDATE (Status, AgesaStatus);
+ if (Status == AGESA_ERROR) {
+ PcieConfigDisableAllEngines (PciePortEngine | PcieDdiEngine, Wrapper);
+ IDS_HDT_CONSOLE (PCIE_MISC, " ERROR! Fail to map topology on %s Wrapper\n",
+ PcieFmDebugGetWrapperNameString (Wrapper)
+ );
+ ASSERT (FALSE);
+ }
+ Wrapper = PcieLibGetNextDescriptor (Wrapper);
+ }
+ Status = PcieMapPortsPciAddresses (Silicon, Pcie);
+ AGESA_STATUS_UPDATE (Status, AgesaStatus);
+ Silicon = PcieLibGetNextDescriptor (Silicon);
+ }
+ IDS_HDT_CONSOLE (GNB_TRACE, "PcieMapTopologyOnComplex Exit [%x]\n", AgesaStatus);
+ return AgesaStatus;
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Configure engine list to support lane allocation according to configuration ID.
+ *
+ *
+ *
+ * @param[in] EngineType Engine type
+ * @param[in] ComplexDescriptor Pointer to used define complex descriptor
+ * @param[in] Wrapper Pointer to wrapper config descriptor
+ * @retval AGESA_SUCCESS Topology successfully mapped
+ * @retval AGESA_ERROR Topology can not be mapped
+ */
+AGESA_STATUS
+PcieEnginesToWrapper (
+ IN PCIE_ENGINE_TYPE EngineType,
+ IN PCIe_COMPLEX_DESCRIPTOR *ComplexDescriptor,
+ IN PCIe_WRAPPER_CONFIG *Wrapper
+ )
+{
+ AGESA_STATUS Status;
+ PCIe_ENGINE_CONFIG *EngineList;
+ PCIe_ENGINE_DESCRIPTOR *EngineDescriptor;
+ UINT8 ConfigurationId;
+ UINT8 Allocations;
+ UINTN Index;
+ UINTN NumberOfDescriptors;
+
+ ConfigurationId = 0;
+ Allocations = 0;
+ IDS_HDT_CONSOLE (GNB_TRACE, "PcieEnginesToWrapper Enter\n");
+ NumberOfDescriptors = PcieInputParserGetNumberOfEngines (ComplexDescriptor);
+ do {
+ Status = PcieFmConfigureEnginesLaneAllocation (Wrapper, EngineType, ConfigurationId++);
+
+ if (Status == AGESA_SUCCESS) {
+ Allocations = 0;
+ for (Index = 0; Index < NumberOfDescriptors; Index++) {
+ EngineDescriptor = PcieInputParserGetEngineDescriptor (ComplexDescriptor, Index);
+ if (EngineDescriptor->EngineData.EngineType == EngineType) {
+ // Step 1, belongs to wrapper check.
+ if (PcieCheckDescriptorMapsToWrapper (EngineDescriptor, Wrapper)) {
+ ++Allocations;
+ EngineList = PcieWrapperGetEngineList (Wrapper);
+ while (EngineList != NULL) {
+ if (!PcieLibIsEngineAllocated (EngineList)) {
+ // Step 2.user descriptor less or equal to link width of engine
+ if (PcieCheckLanesMatch (EngineDescriptor, EngineList)) {
+ // Step 3, Check if link width is correct.x1, x2, x4, x8, x16.
+ if (!PcieIsDescriptorLinkWidthValid (EngineDescriptor)) {
+ PcieConfigDisableEngine (EngineList);
+ return AGESA_ERROR;
+ }
+ if (EngineDescriptor->EngineData.EngineType == PciePortEngine) {
+ // Step 4, Family specifc, port device number match engine device
+ if (PcieCheckPortPciDeviceMapping ((PCIe_PORT_DESCRIPTOR*) EngineDescriptor, EngineList)) {
+ //Step 5, Family specifc, lanes can be muxed.
+ if (PcieFmCheckPortPcieLaneCanBeMuxed ((PCIe_PORT_DESCRIPTOR*) EngineDescriptor, EngineList)) {
+ PcieAllocateEngine ((UINT8) Index, EngineList);
+ --Allocations;
+ }
+ }
+ } else {
+ PcieAllocateEngine ((UINT8) Index, EngineList);
+ --Allocations;
+ }
+ }
+ }//end if PcieLibIsEngineAllocated
+ EngineList = PcieLibGetNextDescriptor (EngineList);
+ }
+ }//end if PcieCheckDescriptorMapsToWrapper
+ }// end if EngineType
+ }//end for
+ }
+ } while (Status == AGESA_SUCCESS && Allocations != 0);
+ IDS_HDT_CONSOLE (GNB_TRACE, "PcieEnginesToWrapper Exit [%x]\n", Status);
+ return Status;
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Check if lane from user port descriptor (PCIe_PORT_DESCRIPTOR) belongs to wrapper (PCIe_WRAPPER_CONFIG)
+ *
+ *
+ * @param[in] EngineDescriptor Pointer to used define engine descriptor
+ * @param[in] Wrapper Pointer to PCIe_WRAPPER_CONFIG
+ * @retval TRUE Belongs to wrapper
+ * @retval FALSE Not belongs to wrapper
+ */
+BOOLEAN
+PcieCheckDescriptorMapsToWrapper (
+ IN PCIe_ENGINE_DESCRIPTOR *EngineDescriptor,
+ IN PCIe_WRAPPER_CONFIG *Wrapper
+ )
+{
+ BOOLEAN Result;
+ UINT16 DescriptorHiLane;
+ UINT16 DescriptorLoLane;
+ UINT16 DescriptorNumberOfLanes;
+
+ DescriptorLoLane = MIN (EngineDescriptor->EngineData.StartLane, EngineDescriptor->EngineData.EndLane);
+ DescriptorHiLane = MAX (EngineDescriptor->EngineData.StartLane, EngineDescriptor->EngineData.EndLane);
+ DescriptorNumberOfLanes = DescriptorHiLane - DescriptorLoLane + 1;
+ Result = TRUE;
+
+ if (!(DescriptorLoLane >= Wrapper->StartPhyLane && DescriptorHiLane <= Wrapper->EndPhyLane)) {
+ // Lanes of descriptor does not belongs to wrapper
+ Result = FALSE;
+ }
+ return Result;
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Set Engine to be allocated.
+ *
+ *
+ * @param[in] DescriptorIndex UINT8 index
+ * @param[in] Engine Pointer to engine config
+ */
+VOID
+PcieAllocateEngine (
+ IN UINT8 DescriptorIndex,
+ IN PCIe_ENGINE_CONFIG *Engine
+ )
+{
+ Engine->Flags |= DESCRIPTOR_ALLOCATED;
+ Engine->Scratch = DescriptorIndex;
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Configure engine list to support lane allocation according to configuration ID.
+ *
+ * PCIE port
+ *
+ *
+ * 1 Check if lane from user port descriptor (PCIe_PORT_DESCRIPTOR) belongs to wrapper (PCIe_WRAPPER_CONFIG)
+ * 2 Check if link width from user descriptor less or equal to link width of engine (PCIe_ENGINE_CONFIG)
+ * 3 Check if link width is correct. Correct link width for PCIe port x1, x2, x4, x8, x16, correct link width for DDI x4, x8
+ * 4 Check if user port device number (PCIe_PORT_DESCRIPTOR) match engine port device number (PCIe_ENGINE_CONFIG)
+ * 5 Check if lane can be muxed
+ *
+ *
+ * DDI Link
+ *
+ * 1 Check if lane from user port descriptor (PCIe_DDI_DESCRIPTOR) belongs to wrapper (PCIe_WRAPPER_CONFIG)
+ * 2 Check lane from (PCIe_DDI_DESCRIPTOR) match exactly phy lane (PCIe_ENGINE_CONFIG)
+ *
+ *
+ *
+ * @param[in] ComplexDescriptor Pointer to used define complex descriptor
+ * @param[in,out] Wrapper Pointer to wrapper config descriptor
+ * @param[in] Pcie Pointer to global PCIe configuration
+ * @retval AGESA_SUCCESS Topology successfully mapped
+ * @retval AGESA_ERROR Topology can not be mapped
+ */
+AGESA_STATUS
+PcieMapTopologyOnWrapper (
+ IN PCIe_COMPLEX_DESCRIPTOR *ComplexDescriptor,
+ IN OUT PCIe_WRAPPER_CONFIG *Wrapper,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ AGESA_STATUS AgesaStatus;
+ AGESA_STATUS Status;
+ PCIe_ENGINE_CONFIG *EngineList;
+ UINT32 WrapperPhyLaneBitMap;
+
+ AgesaStatus = AGESA_SUCCESS;
+ if (PcieLibIsPcieWrapper (Wrapper)) {
+ Status = PcieEnginesToWrapper (PciePortEngine, ComplexDescriptor, Wrapper);
+ AGESA_STATUS_UPDATE (Status, AgesaStatus);
+ if (Status == AGESA_ERROR) {
+ // If we can not map topology on wrapper we can not enable any engines.
+ PutEventLog (
+ AGESA_ERROR,
+ GNB_EVENT_INVALID_PCIE_TOPOLOGY_CONFIGURATION,
+ Wrapper->WrapId,
+ Wrapper->StartPhyLane,
+ Wrapper->EndPhyLane,
+ 0,
+ GnbLibGetHeader (Pcie)
+ );
+ PcieConfigDisableAllEngines (PciePortEngine, Wrapper);
+ }
+ EngineList = PcieWrapperGetEngineList (Wrapper);
+ // Assure SB is allocated
+ while (EngineList != NULL) {
+ if ((EngineList->EngineData.EngineType == PciePortEngine) && (EngineList->Type.Port.IsSB)) {
+ EngineList->Flags |= DESCRIPTOR_ALLOCATED;
+ }
+ EngineList = PcieLibGetNextDescriptor (EngineList);
+ }
+ }
+ if (PcieLibIsDdiWrapper (Wrapper)) {
+ Status = PcieEnginesToWrapper (PcieDdiEngine, ComplexDescriptor, Wrapper);
+ AGESA_STATUS_UPDATE (Status, AgesaStatus);
+ if (Status == AGESA_ERROR) {
+ // If we can not map topology on wrapper we can not enable any engines.
+ PutEventLog (
+ AGESA_ERROR,
+ GNB_EVENT_INVALID_DDI_TOPOLOGY_CONFIGURATION,
+ Wrapper->WrapId,
+ Wrapper->StartPhyLane,
+ Wrapper->EndPhyLane,
+ 0,
+ GnbLibGetHeader (Pcie)
+ );
+ PcieConfigDisableAllEngines (PcieDdiEngine, Wrapper);
+ }
+ }
+ // Copy engine data
+ PcieMapInitializeEngineData (ComplexDescriptor, Wrapper, Pcie);
+
+ EngineList = PcieWrapperGetEngineList (Wrapper);
+ // Verify if we oversubscribe lanes and PHY link width
+ WrapperPhyLaneBitMap = 0;
+ while (EngineList != NULL) {
+ UINT32 EnginePhyLaneBitMap;
+ if (PcieLibIsEngineAllocated (EngineList)) {
+ EnginePhyLaneBitMap = PcieConfigGetEnginePhyLaneBitMap (EngineList);
+ if ((WrapperPhyLaneBitMap & EnginePhyLaneBitMap) != 0) {
+ IDS_HDT_CONSOLE (PCIE_MISC, " ERROR! Lanes double subscribe lanes [Engine Lanes %d..%d]\n",
+ EngineList->EngineData.StartLane,
+ EngineList->EngineData.EndLane
+ );
+ PutEventLog (
+ AGESA_ERROR,
+ GNB_EVENT_INVALID_LANES_CONFIGURATION,
+ EngineList->EngineData.StartLane,
+ EngineList->EngineData.EndLane,
+ 0,
+ 0,
+ GnbLibGetHeader (Pcie)
+ );
+ PcieConfigDisableEngine (EngineList);
+ Status = AGESA_ERROR;
+ AGESA_STATUS_UPDATE (Status, AgesaStatus);
+ } else {
+ WrapperPhyLaneBitMap |= EnginePhyLaneBitMap;
+ }
+ }
+ EngineList = PcieLibGetNextDescriptor (EngineList);
+ }
+ return AgesaStatus;
+}
+
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Initialize engine data
+ *
+ *
+ *
+ * @param[in] ComplexDescriptor Pointer to user defined complex descriptor
+ * @param[in,out] Wrapper Pointer to wrapper config descriptor
+ * @param[in] Pcie Pointer to global PCIe configuration
+ */
+VOID
+PcieMapInitializeEngineData (
+ IN PCIe_COMPLEX_DESCRIPTOR *ComplexDescriptor,
+ IN OUT PCIe_WRAPPER_CONFIG *Wrapper,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ PCIe_ENGINE_CONFIG *EngineList;
+ PCIe_ENGINE_DESCRIPTOR *EngineDescriptor;
+
+ EngineList = PcieWrapperGetEngineList (Wrapper);
+ while (EngineList != NULL) {
+ if (PcieLibIsEngineAllocated (EngineList)) {
+ if (EngineList->Scratch != 0xFF) {
+ EngineDescriptor = PcieInputParserGetEngineDescriptor (ComplexDescriptor, EngineList->Scratch);
+ LibAmdMemCopy (&EngineList->EngineData, &EngineDescriptor->EngineData, sizeof (EngineDescriptor->EngineData), GnbLibGetHeader (Pcie));
+ if (PcieLibIsDdiEngine (EngineList)) {
+ LibAmdMemCopy (&EngineList->Type.Ddi, &((PCIe_DDI_DESCRIPTOR*) EngineDescriptor)->Ddi, sizeof (PCIe_DDI_DATA), GnbLibGetHeader (Pcie));
+ EngineList->Type.Ddi.DisplayPriorityIndex = (UINT8) EngineList->Scratch;
+ } else if (PcieLibIsPcieEngine (EngineList)) {
+ LibAmdMemCopy (&EngineList->Type.Port, &((PCIe_PORT_DESCRIPTOR*) EngineDescriptor)->Port, sizeof (PCIe_PORT_DATA), GnbLibGetHeader (Pcie));
+ }
+ }
+ }
+ EngineList = PcieLibGetNextDescriptor (EngineList);
+ }
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Allocate PCI addresses for all PCIe engines on silicon
+ *
+ *
+ *
+ * @param[in] PortDescriptor Pointer to user defined engine descriptor
+ * @param[in] Engine Pointer engine configuration
+ * @retval TRUE Descriptor can be mapped to engine
+ * @retval FALSE Descriptor can NOT be mapped to engine
+ */
+
+BOOLEAN
+PcieCheckPortPciDeviceMapping (
+ IN PCIe_PORT_DESCRIPTOR *PortDescriptor,
+ IN PCIe_ENGINE_CONFIG *Engine
+ )
+{
+ BOOLEAN Result;
+
+ if ((PortDescriptor->Port.DeviceNumber == Engine->Type.Port.NativeDevNumber &&
+ PortDescriptor->Port.FunctionNumber == Engine->Type.Port.NativeFunNumber) ||
+ (PortDescriptor->Port.DeviceNumber == 0 && PortDescriptor->Port.FunctionNumber == 0)) {
+ Result = TRUE;
+ } else {
+ Result = PcieFmCheckPortPciDeviceMapping (PortDescriptor, Engine);
+ }
+
+ return Result;
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Allocate PCI addresses for all PCIe engines on silicon
+ *
+ *
+ *
+ * @param[in] Silicon Pointer to silicon configurration
+ * @param[in] Pcie Pointer PCIe configuration
+ * @retval AGESA_ERROR Fail to allocate PCI device address
+ * @retval AGESA_SUCCESS Successfully allocate PCI address for all PCIe ports
+ */
+
+AGESA_STATUS
+STATIC
+PcieMapPortsPciAddresses (
+ IN PCIe_SILICON_CONFIG *Silicon,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ AGESA_STATUS Status;
+ AGESA_STATUS AgesaStatus;
+ PCIe_WRAPPER_CONFIG *WrapperList;
+ PCIe_ENGINE_CONFIG *EngineList;
+ AgesaStatus = AGESA_SUCCESS;
+ WrapperList = PcieSiliconGetWrapperList (Silicon);
+ while (WrapperList != NULL) {
+ EngineList = PcieWrapperGetEngineList (WrapperList);
+ while (EngineList != NULL) {
+ if (PcieLibIsPcieEngine (EngineList) && PcieLibIsEngineAllocated (EngineList)) {
+ Status = PcieFmMapPortPciAddress (EngineList, Pcie);
+ AGESA_STATUS_UPDATE (Status, AgesaStatus);
+ if (Status == AGESA_SUCCESS) {
+ EngineList->Type.Port.Address.AddressValue = MAKE_SBDFO (
+ 0,
+ Silicon->Address.Address.Bus,
+ EngineList->Type.Port.PortData.DeviceNumber,
+ EngineList->Type.Port.PortData.FunctionNumber,
+ 0
+ );
+ } else {
+ EngineList->Type.Port.PortData.PortPresent = OFF;
+ IDS_HDT_CONSOLE (PCIE_MISC, " ERROR! Fail to allocate PCI address for PCIe port\n"
+ );
+ //Report error
+ PutEventLog (
+ AGESA_ERROR,
+ GNB_EVENT_INVALID_PCIE_PORT_CONFIGURATION,
+ EngineList->Type.Port.PortData.DeviceNumber,
+ 0,
+ 0,
+ 0,
+ GnbLibGetHeader (Pcie)
+ );
+ }
+ }
+ EngineList = PcieLibGetNextDescriptor (EngineList);
+ }
+ WrapperList = PcieLibGetNextDescriptor (WrapperList);
+ }
+ return AgesaStatus;
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * If link width from user descriptor less or equal to link width of engine
+ *
+ *
+ * @param[in] EngineDescriptor Pointer to used define engine descriptor
+ * @param[in] Engine Pointer to engine config
+ * @retval TRUE Descriptor can be mapped to engine
+ * @retval FALSE Descriptor can NOT be mapped to engine
+ */
+
+BOOLEAN
+PcieCheckLanesMatch (
+ IN PCIe_ENGINE_DESCRIPTOR *EngineDescriptor,
+ IN PCIe_ENGINE_CONFIG *Engine
+ )
+{
+ BOOLEAN Result;
+ UINT16 DescriptorHiLane;
+ UINT16 DescriptorLoLane;
+ UINT16 DescriptorNumberOfLanes;
+
+ DescriptorLoLane = MIN (EngineDescriptor->EngineData.StartLane, EngineDescriptor->EngineData.EndLane);
+ DescriptorHiLane = MAX (EngineDescriptor->EngineData.StartLane, EngineDescriptor->EngineData.EndLane);
+ DescriptorNumberOfLanes = DescriptorHiLane - DescriptorLoLane + 1;
+ Result = FALSE;
+
+ if (EngineDescriptor->EngineData.EngineType == PciePortEngine) {
+ //
+ // If link width from user descriptor less or equal to link width of engine (PCIe_ENGINE_CONFIG)
+ //
+ if (DescriptorNumberOfLanes <= PcieConfigGetNumberOfCoreLane (Engine)) {
+ Result = TRUE;
+ }
+ } else if (EngineDescriptor->EngineData.EngineType == PcieDdiEngine) {
+ //
+ //For Ddi, check lane from (PCIe_DDI_DESCRIPTOR) match exactly phy lane (PCIe_ENGINE_CONFIG)
+ //
+ if ((Engine->EngineData.StartLane == DescriptorLoLane) && (Engine->EngineData.EndLane == DescriptorHiLane)) {
+ Result = TRUE;
+ }
+ }
+
+ return Result;
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Correct link width for PCIe port x1, x2, x4, x8, x16, correct link width for DDI x4, x8
+ *
+ *
+ * @param[in] EngineDescriptor A pointer of PCIe_ENGINE_DESCRIPTOR
+ * @retval TRUE Descriptor can be mapped to engine
+ * @retval FALSE Descriptor can NOT be mapped to engine
+ */
+
+BOOLEAN
+PcieIsDescriptorLinkWidthValid (
+ IN PCIe_ENGINE_DESCRIPTOR *EngineDescriptor
+ )
+{
+ BOOLEAN Result;
+ UINT16 DescriptorHiLane;
+ UINT16 DescriptorLoLane;
+ UINT16 DescriptorNumberOfLanes;
+
+ Result = FALSE;
+ DescriptorLoLane = MIN (EngineDescriptor->EngineData.StartLane, EngineDescriptor->EngineData.EndLane);
+ DescriptorHiLane = MAX (EngineDescriptor->EngineData.StartLane, EngineDescriptor->EngineData.EndLane);
+ DescriptorNumberOfLanes = DescriptorHiLane - DescriptorLoLane + 1;
+
+ if (EngineDescriptor->EngineData.EngineType == PciePortEngine) {
+ if (DescriptorNumberOfLanes == 1 || DescriptorNumberOfLanes == 2 || DescriptorNumberOfLanes == 4 ||
+ DescriptorNumberOfLanes == 8 || DescriptorNumberOfLanes == 16) {
+ Result = TRUE;
+ }
+ } else if (EngineDescriptor->EngineData.EngineType == PcieDdiEngine) {
+ if (DescriptorNumberOfLanes == 4 || DescriptorNumberOfLanes == 8) {
+ Result = TRUE;
+ }
+ }
+
+ GNB_DEBUG_CODE (
+ if (!Result) {
+ IDS_HDT_CONSOLE (PCIE_MISC, " Invalid Link width [Engine Lanes %d..%d]\n",
+ DescriptorLoLane,
+ DescriptorHiLane
+ );
+ }
+ );
+
+ return Result;
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Helper function to dump input configuration to debug out
+ *
+ *
+ * @param[in] ComplexDescriptor Pointer to used define complex descriptor
+ * @param[in] Pcie Pointer to global PCIe configuration
+ */
+VOID
+PcieComplexConfigConfigDump (
+ IN PCIe_COMPLEX_DESCRIPTOR *ComplexDescriptor,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ PCIe_ENGINE_DESCRIPTOR *EngineDescriptor;
+ UINTN Index;
+ UINTN NumberOfEngines;
+ IDS_HDT_CONSOLE (PCIE_MISC, "<---------- PCIe User Config Start------------->\n");
+
+ NumberOfEngines = PcieInputParserGetNumberOfEngines (ComplexDescriptor);
+ IDS_HDT_CONSOLE (PCIE_MISC, " ComplexDescriptor SocketId - %d\n NumberOfEngines - %d\n",
+ ComplexDescriptor->SocketId,
+ NumberOfEngines
+ );
+
+ for (Index = 0; Index < NumberOfEngines; Index++) {
+ EngineDescriptor = PcieInputParserGetEngineDescriptor (ComplexDescriptor, Index);
+ IDS_HDT_CONSOLE (PCIE_MISC, " Engine Type - %s\n",
+ (EngineDescriptor->EngineData.EngineType == PciePortEngine) ? "PCIe Port" : (
+ (EngineDescriptor->EngineData.EngineType == PcieDdiEngine) ? "DDI Link" : (
+ (EngineDescriptor->EngineData.EngineType == PcieUnusedEngine) ? "Unused" : "Invalid"))
+ );
+ IDS_HDT_CONSOLE (PCIE_MISC, " Start Phy Lane - %d\n End Phy Lane - %d\n",
+ EngineDescriptor->EngineData.StartLane,
+ EngineDescriptor->EngineData.EndLane
+ );
+ if (EngineDescriptor->EngineData.EngineType == PciePortEngine) {
+ IDS_HDT_CONSOLE (PCIE_MISC, " PortPresent - %d\n ChannelType - %d\n DeviceNumber - %d\n FunctionNumber - %d\n LinkSpeedCapability - %d\n LinkAspm - %d\n LinkHotplug - %d\n ResetId - %d\n" ,
+ ((PCIe_PORT_DESCRIPTOR *) EngineDescriptor)->Port.PortPresent,
+ ((PCIe_PORT_DESCRIPTOR *) EngineDescriptor)->Port.ChannelType,
+ ((PCIe_PORT_DESCRIPTOR *) EngineDescriptor)->Port.DeviceNumber,
+ ((PCIe_PORT_DESCRIPTOR *) EngineDescriptor)->Port.FunctionNumber,
+ ((PCIe_PORT_DESCRIPTOR *) EngineDescriptor)->Port.LinkSpeedCapability,
+ ((PCIe_PORT_DESCRIPTOR *) EngineDescriptor)->Port.LinkAspm,
+ ((PCIe_PORT_DESCRIPTOR *) EngineDescriptor)->Port.LinkHotplug,
+ ((PCIe_PORT_DESCRIPTOR *) EngineDescriptor)->Port.ResetId
+ );
+ }
+ if (EngineDescriptor->EngineData.EngineType == PcieDdiEngine) {
+ IDS_HDT_CONSOLE (PCIE_MISC, " ConnectorType - %d\n AuxIndex - %d\n HdpIndex - %d\n" ,
+ ((PCIe_DDI_DESCRIPTOR *) EngineDescriptor)->Ddi.ConnectorType,
+ ((PCIe_DDI_DESCRIPTOR *) EngineDescriptor)->Ddi.AuxIndex,
+ ((PCIe_DDI_DESCRIPTOR *) EngineDescriptor)->Ddi.HdpIndex
+ );
+ }
+ }
+ IDS_HDT_CONSOLE (PCIE_MISC, "<---------- PCIe User Config End-------------->\n");
+}
+
diff --git a/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieConfig/PcieMapTopology.h b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieConfig/PcieMapTopology.h
new file mode 100644
index 0000000000..0155bb3a74
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieConfig/PcieMapTopology.h
@@ -0,0 +1,58 @@
+/* $NoKeywords:$ */
+/**
+ * @file
+ *
+ * Procedure to map user define topology to processor configuration
+ *
+ *
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: GNB
+ * @e \$Revision: 34897 $ @e \$Date: 2010-07-13 19:07:10 -0700 (Tue, 13 Jul 2010) $
+ *
+ */
+/*
+ *****************************************************************************
+ *
+ * Copyright (c) 2011, Advanced Micro Devices, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Advanced Micro Devices, Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***************************************************************************
+ *
+ */
+#ifndef _PCIEMAPTOPOLOGY_H_
+#define _PCIEMAPTOPOLOGY_H_
+
+AGESA_STATUS
+PcieMapTopologyOnComplex (
+ IN PCIe_COMPLEX_DESCRIPTOR *ComplexDescriptor,
+ IN PCIe_COMPLEX_CONFIG *Complex,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ );
+
+#endif
+
+
diff --git a/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/GnbPcieInitLibV1.h b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/GnbPcieInitLibV1.h
new file mode 100644
index 0000000000..b94117713c
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/GnbPcieInitLibV1.h
@@ -0,0 +1,62 @@
+/* $NoKeywords:$ */
+/**
+ * @file
+ *
+ * PCIe Init Library
+ *
+ *
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: GNB
+ * @e \$Revision: 34897 $ @e \$Date: 2010-07-13 19:07:10 -0700 (Tue, 13 Jul 2010) $
+ *
+ */
+/*
+ *****************************************************************************
+ *
+ * Copyright (c) 2011, Advanced Micro Devices, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Advanced Micro Devices, Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***************************************************************************
+ *
+ */
+#ifndef _PCIEINITLIBV1_H_
+#define _PCIEINITLIBV1_H_
+
+#include "PciePifServices.h"
+#include "PciePortRegAcc.h"
+#include "PciePowerMgmt.h"
+#include "PcieTimer.h"
+#include "PcieTopologyServices.h"
+#include "PcieUtilityLib.h"
+#include "PcieWrapperRegAcc.h"
+#include "PcieAspmExitLatency.h"
+#include "PcieSiliconServices.h"
+#include "PciePortServices.h"
+#include "PcieAspm.h"
+#include "PcieSbLink.h"
+#include "PciePhyServices.h"
+#endif
diff --git a/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PcieAspm.c b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PcieAspm.c
new file mode 100644
index 0000000000..07b42315d8
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PcieAspm.c
@@ -0,0 +1,346 @@
+/* $NoKeywords:$ */
+/**
+ * @file
+ *
+ * PCIe link ASPM
+ *
+ *
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: GNB
+ * @e \$Revision: 38935 $ @e \$Date: 2010-10-01 18:45:23 -0700 (Fri, 01 Oct 2010) $
+ *
+ */
+/*
+ *****************************************************************************
+ *
+ * Copyright (c) 2011, Advanced Micro Devices, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Advanced Micro Devices, Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***************************************************************************
+ *
+ */
+
+/*----------------------------------------------------------------------------------------
+ * M O D U L E S U S E D
+ *----------------------------------------------------------------------------------------
+ */
+#include "AGESA.h"
+#include "Ids.h"
+#include "Gnb.h"
+#include "GnbPcie.h"
+#include "OptionGnb.h"
+#include GNB_MODULE_DEFINITIONS (GnbCommonLib)
+#include GNB_MODULE_DEFINITIONS (GnbPcieInitLibV1)
+#include "PcieAspmBlackList.h"
+#include "Filecode.h"
+#define FILECODE PROC_GNB_MODULES_GNBPCIEINITLIBV1_PCIEASPM_FILECODE
+/*----------------------------------------------------------------------------------------
+ * D E F I N I T I O N S A N D M A C R O S
+ *----------------------------------------------------------------------------------------
+ */
+
+extern GNB_BUILD_OPTIONS GnbBuildOptions;
+/*----------------------------------------------------------------------------------------
+ * T Y P E D E F S A N D S T R U C T U R E S
+ *----------------------------------------------------------------------------------------
+ */
+
+typedef struct {
+ GNB_PCI_SCAN_DATA ScanData;
+ PCIE_ASPM_TYPE Aspm;
+ PCI_ADDR DownstreamPort;
+} PCIE_ASPM_DATA;
+
+/*----------------------------------------------------------------------------------------
+ * P R O T O T Y P E S O F L O C A L F U N C T I O N S
+ *----------------------------------------------------------------------------------------
+ */
+
+
+SCAN_STATUS
+PcieAspmCallback (
+ IN PCI_ADDR Device,
+ IN OUT GNB_PCI_SCAN_DATA *ScanData
+ );
+
+VOID
+PcieAspmEnableOnLink (
+ IN PCI_ADDR Downstream,
+ IN PCI_ADDR Upstream,
+ IN PCIE_ASPM_TYPE Aspm,
+ IN AMD_CONFIG_PARAMS *StdHeader
+ );
+
+PCIE_ASPM_TYPE
+PcieAspmGetPmCapability (
+ IN PCI_ADDR Device,
+ IN AMD_CONFIG_PARAMS *StdHeader
+ );
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Enable PCIE Advance state power management
+ *
+ *
+ *
+ * @param[in] DownstreamPort PCI Address of the downstream port
+ * @param[in] Aspm ASPM type
+ * @param[in] StdHeader Standard configuration header
+ * @retval AGESA_STATUS
+ */
+
+VOID
+PcieLinkAspmEnable (
+ IN PCI_ADDR DownstreamPort,
+ IN PCIE_ASPM_TYPE Aspm,
+ IN AMD_CONFIG_PARAMS *StdHeader
+ )
+{
+ PCIE_ASPM_DATA PcieAspmData;
+ PcieAspmData.Aspm = Aspm;
+ PcieAspmData.ScanData.StdHeader = StdHeader;
+ PcieAspmData.ScanData.GnbScanCallback = PcieAspmCallback;
+ GnbLibPciScan (DownstreamPort, DownstreamPort, &PcieAspmData.ScanData);
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Evaluate device
+ *
+ *
+ *
+ * @param[in] Device PCI Address
+ * @param[in,out] ScanData Scan configuration data
+ * @retval Scan Status of 0
+ */
+
+SCAN_STATUS
+PcieAspmCallback (
+ IN PCI_ADDR Device,
+ IN OUT GNB_PCI_SCAN_DATA *ScanData
+ )
+{
+ SCAN_STATUS ScanStatus;
+ PCIE_ASPM_DATA *PcieAspmData;
+ PCIE_DEVICE_TYPE DeviceType;
+ ScanStatus = SCAN_SUCCESS;
+ IDS_HDT_CONSOLE (GNB_TRACE, " PcieAspmCallback for Device = %d:%d:%d\n",
+ Device.Address.Bus,
+ Device.Address.Device,
+ Device.Address.Function
+ );
+ PcieAspmData = (PCIE_ASPM_DATA *) ScanData;
+ ScanStatus = SCAN_SUCCESS;
+ DeviceType = GnbLibGetPcieDeviceType (Device, ScanData->StdHeader);
+ switch (DeviceType) {
+ case PcieDeviceRootComplex:
+ case PcieDeviceDownstreamPort:
+ PcieAspmData->DownstreamPort = Device;
+ //PcieExitLatencyData->LinkCount++;
+ GnbLibPciRMW (Device.AddressValue | 0x18, AccessS3SaveWidth32, 0xffffffffull, 0x0, ScanData->StdHeader);
+ GnbLibPciScanSecondaryBus (Device, &PcieAspmData->ScanData);
+ //PcieExitLatencyData->LinkCount--;
+ break;
+ case PcieDeviceUpstreamPort:
+ PcieAspmEnableOnLink (
+ PcieAspmData->DownstreamPort,
+ Device,
+ PcieAspmData->Aspm,
+ ScanData->StdHeader
+ );
+ GnbLibPciRMW (Device.AddressValue | 0x18, AccessS3SaveWidth32, 0xffffffffull, 0x0, ScanData->StdHeader);
+ GnbLibPciScanSecondaryBus (Device, &PcieAspmData->ScanData);
+ ScanStatus = SCAN_SKIP_FUNCTIONS | SCAN_SKIP_DEVICES | SCAN_SKIP_BUSES;
+ break;
+ case PcieDeviceEndPoint:
+ case PcieDeviceLegacyEndPoint:
+ PcieAspmEnableOnLink (
+ PcieAspmData->DownstreamPort,
+ Device,
+ PcieAspmData->Aspm,
+ ScanData->StdHeader
+ );
+ ScanStatus = SCAN_SKIP_FUNCTIONS | SCAN_SKIP_DEVICES | SCAN_SKIP_BUSES;
+ break;
+ default:
+ break;
+ }
+ return ScanStatus;
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Set ASMP State on PCIe device function
+ *
+ *
+ *
+ * @param[in] Function PCI address of function.
+ * @param[in] Aspm Aspm capability to enable
+ * @param[in] StdHeader Standard configuration header
+ *
+ */
+ /*----------------------------------------------------------------------------------------*/
+VOID
+PcieAspmEnableOnFunction (
+ IN PCI_ADDR Function,
+ IN PCIE_ASPM_TYPE Aspm,
+ IN AMD_CONFIG_PARAMS *StdHeader
+ )
+{
+ UINT8 PcieCapPtr;
+ PcieCapPtr = GnbLibFindPciCapability (Function.AddressValue, PCIE_CAP_ID, StdHeader);
+ if (PcieCapPtr != 0) {
+ GnbLibPciRMW (
+ Function.AddressValue | (PcieCapPtr + PCIE_LINK_CTRL_REGISTER) ,
+ AccessS3SaveWidth8,
+ ~(BIT0 & BIT1),
+ Aspm,
+ StdHeader
+ );
+ }
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Set ASMP State on all function of PCI device
+ *
+ *
+ *
+ * @param[in] Device PCI address of device.
+ * @param[in] Aspm Aspm capability to enable
+ * @param[in] StdHeader Standard configuration header
+ *
+ */
+ /*----------------------------------------------------------------------------------------*/
+VOID
+PcieAspmEnableOnDevice (
+ IN PCI_ADDR Device,
+ IN PCIE_ASPM_TYPE Aspm,
+ IN AMD_CONFIG_PARAMS *StdHeader
+ )
+{
+ UINT8 MaxFunc;
+ UINT8 CurrentFunc;
+ MaxFunc = GnbLibPciIsMultiFunctionDevice (Device.AddressValue, StdHeader) ? 7 : 0;
+ for (CurrentFunc = 0; CurrentFunc <= MaxFunc; CurrentFunc++) {
+ Device.Address.Function = CurrentFunc;
+ if (GnbLibPciIsDevicePresent (Device.AddressValue, StdHeader)) {
+ PcieAspmEnableOnFunction (Device, Aspm, StdHeader);
+ }
+ }
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Enable ASPM on link
+ *
+ *
+ *
+ * @param[in] Downstream PCI Address of downstrteam port
+ * @param[in] Upstream PCI Address of upstream port
+ * @param[in] Aspm Aspm capability to enable
+ * @param[in] StdHeader Standard configuration header
+ */
+
+VOID
+PcieAspmEnableOnLink (
+ IN PCI_ADDR Downstream,
+ IN PCI_ADDR Upstream,
+ IN PCIE_ASPM_TYPE Aspm,
+ IN AMD_CONFIG_PARAMS *StdHeader
+ )
+{
+ PCIe_LINK_ASPM LinkAsmp;
+ PCIE_ASPM_TYPE DownstreamCap;
+ PCIE_ASPM_TYPE UpstreamCap;
+ LinkAsmp.DownstreamPort = Downstream;
+ DownstreamCap = PcieAspmGetPmCapability (Downstream, StdHeader);
+ LinkAsmp.UpstreamPort = Upstream;
+ UpstreamCap = PcieAspmGetPmCapability (Upstream, StdHeader);
+ LinkAsmp.DownstreamAspm = DownstreamCap & UpstreamCap & Aspm & AspmL1;
+ LinkAsmp.UpstreamAspm = LinkAsmp.DownstreamAspm;
+ LinkAsmp.RequestedAspm = Aspm;
+ if ((UpstreamCap & Aspm & AspmL0s) != 0) {
+ LinkAsmp.UpstreamAspm |= AspmL0s;
+ }
+ if ((DownstreamCap & Aspm & AspmL0s) != 0) {
+ LinkAsmp.DownstreamAspm |= AspmL0s;
+ }
+ if (GnbBuildOptions.PcieAspmBlackListEnable == 1) {
+ PcieAspmBlackListFeature (&LinkAsmp, StdHeader);
+ }
+ //AgesaPcieLinkAspm (&LinkAsmp, StdHeader);
+ IDS_HDT_CONSOLE (GNB_TRACE, " Set ASPM [%d] for Device = %d:%d:%d\n",
+ (LinkAsmp.UpstreamAspm) ,
+ LinkAsmp.UpstreamPort.Address.Bus,
+ LinkAsmp.UpstreamPort.Address.Device,
+ LinkAsmp.UpstreamPort.Address.Function
+ );
+ IDS_HDT_CONSOLE (GNB_TRACE, " Set ASPM [%d] for Device = %d:%d:%d\n",
+ (LinkAsmp.DownstreamAspm) ,
+ LinkAsmp.DownstreamPort.Address.Bus,
+ LinkAsmp.DownstreamPort.Address.Device,
+ LinkAsmp.DownstreamPort.Address.Function
+ );
+ PcieAspmEnableOnDevice (Upstream, LinkAsmp.UpstreamAspm, StdHeader);
+ PcieAspmEnableOnFunction (Downstream, LinkAsmp.DownstreamAspm, StdHeader);
+}
+
+
+
+/**----------------------------------------------------------------------------------------*/
+/**
+ * Port/Endpoint ASMP capability
+ *
+ *
+ *
+ * @param[in] Device PCI address of downstream port
+ * @param[in] StdHeader Standard configuration header
+ *
+ * @retval PCIE_ASPM_TYPE
+ */
+ /*----------------------------------------------------------------------------------------*/
+PCIE_ASPM_TYPE
+PcieAspmGetPmCapability (
+ IN PCI_ADDR Device,
+ IN AMD_CONFIG_PARAMS *StdHeader
+ )
+{
+ UINT8 PcieCapPtr;
+ UINT32 Value;
+ PcieCapPtr = GnbLibFindPciCapability (Device.AddressValue, PCIE_CAP_ID, StdHeader);
+ if (PcieCapPtr == 0) {
+ return 0;
+ }
+ GnbLibPciRead (
+ Device.AddressValue | (PcieCapPtr + PCIE_LINK_CAP_REGISTER),
+ AccessWidth32,
+ &Value,
+ StdHeader
+ );
+ return (Value >> 10) & 3;
+}
diff --git a/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PcieAspm.h b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PcieAspm.h
new file mode 100644
index 0000000000..101d3938cf
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PcieAspm.h
@@ -0,0 +1,57 @@
+/* $NoKeywords:$ */
+/**
+ * @file
+ *
+ * PCIe link ASPM
+ *
+ *
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: GNB
+ * @e \$Revision: 34897 $ @e \$Date: 2010-07-13 19:07:10 -0700 (Tue, 13 Jul 2010) $
+ *
+ */
+/*
+ *****************************************************************************
+ *
+ * Copyright (c) 2011, Advanced Micro Devices, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Advanced Micro Devices, Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***************************************************************************
+ *
+ */
+
+#ifndef _PCIEASPM_H_
+#define _PCIEASPM_H_
+
+VOID
+PcieLinkAspmEnable (
+ IN PCI_ADDR DownstreamPort,
+ IN PCIE_ASPM_TYPE Aspm,
+ IN AMD_CONFIG_PARAMS *StdHeader
+ );
+
+#endif
diff --git a/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PcieAspmBlackList.c b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PcieAspmBlackList.c
new file mode 100644
index 0000000000..ecb6b4344a
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PcieAspmBlackList.c
@@ -0,0 +1,141 @@
+/**
+ * @file
+ *
+ * PCIe link ASPM Black List
+ *
+ *
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: GNB
+ * @e \$Revision: 33827 $ @e \$Date: 2010-06-24 22:11:37 +0800 (Thu, 24 Jun 2010) $
+ *
+ */
+/*
+ *****************************************************************************
+ *
+ * Copyright (c) 2011, Advanced Micro Devices, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Advanced Micro Devices, Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***************************************************************************
+ *
+ */
+
+/*----------------------------------------------------------------------------------------
+ * M O D U L E S U S E D
+ *----------------------------------------------------------------------------------------
+ */
+#include "AGESA.h"
+#include "Gnb.h"
+#include "GnbPcie.h"
+#include GNB_MODULE_DEFINITIONS (GnbCommonLib)
+#include "PcieAspmBlackList.h"
+#include "Filecode.h"
+#define FILECODE PROC_GNB_MODULES_GNBPCIEINITLIBV1_PCIEASPMBLACKLIST_FILECODE
+/*----------------------------------------------------------------------------------------
+ * D E F I N I T I O N S A N D M A C R O S
+ *----------------------------------------------------------------------------------------
+ */
+
+
+/*----------------------------------------------------------------------------------------
+ * T Y P E D E F S A N D S T R U C T U R E S
+ *----------------------------------------------------------------------------------------
+ */
+
+/*----------------------------------------------------------------------------------------
+ * P R O T O T Y P E S O F L O C A L F U N C T I O N S
+ *----------------------------------------------------------------------------------------
+ */
+
+
+UINT16 AspmBrDeviceTable[] = {
+ 0x1002, 0x9441, (UINT16) ~(AspmL1 | AspmL0s),
+ 0x10B5, 0xFFFF, (UINT16) ~(AspmL1 | AspmL0s),
+ 0x10DE, 0x0402, (UINT16) ~(AspmL1 | AspmL0s),
+ 0x10DE, 0x0193, (UINT16) ~(AspmL1 | AspmL0s),
+ 0x10DE, 0x0422, (UINT16) ~(AspmL1 | AspmL0s),
+ 0x10DE, 0x0292, (UINT16) ~(AspmL1 | AspmL0s),
+ 0x10DE, 0x00F9, (UINT16) ~(AspmL1 | AspmL0s),
+ 0x10DE, 0x0141, (UINT16) ~(AspmL1 | AspmL0s),
+ 0x10DE, 0x0092, (UINT16) ~(AspmL1 | AspmL0s),
+ 0x10DE, 0x01D0, (UINT16) ~(AspmL1 | AspmL0s),
+ 0x10DE, 0x01D1, (UINT16) ~(AspmL1 | AspmL0s),
+ 0x10DE, 0x01D2, (UINT16) ~(AspmL1 | AspmL0s),
+ 0x10DE, 0x01D3, (UINT16) ~(AspmL1 | AspmL0s),
+ 0x10DE, 0x01D5, (UINT16) ~(AspmL1 | AspmL0s),
+ 0x10DE, 0x01D7, (UINT16) ~(AspmL1 | AspmL0s),
+ 0x10DE, 0x01D8, (UINT16) ~(AspmL1 | AspmL0s),
+ 0x10DE, 0x01DC, (UINT16) ~(AspmL1 | AspmL0s),
+ 0x10DE, 0x01DE, (UINT16) ~(AspmL1 | AspmL0s),
+ 0x10DE, 0x01DF, (UINT16) ~(AspmL1 | AspmL0s),
+ 0x10DE, 0x016A, (UINT16) ~(AspmL1 | AspmL0s),
+ 0x10DE, 0x0392, (UINT16) ~(AspmL1 | AspmL0s),
+ 0x168C, 0xFFFF, (UINT16) ~(AspmL0s),
+ 0x1B4B, 0x91A3, (UINT16) ~(AspmL0s)
+};
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Pcie ASPM Black List
+ *
+ *
+ *
+ * @param[in] LinkAsmp PCie ASPM black list
+ * @param[in] StdHeader Standard configuration header
+ * @retval AGESA_STATUS
+ */
+
+AGESA_STATUS
+PcieAspmBlackListFeature (
+ IN PCIe_LINK_ASPM *LinkAsmp,
+ IN AMD_CONFIG_PARAMS *StdHeader
+ )
+{
+ UINT32 UpstreamDeviceId;
+ UINT32 DownstreamDeviceId;
+ UINTN i;
+ GnbLibPciRead (LinkAsmp->UpstreamPort.AddressValue, AccessWidth32, &UpstreamDeviceId, StdHeader);
+ GnbLibPciRead (LinkAsmp->DownstreamPort.AddressValue, AccessWidth32, &DownstreamDeviceId, StdHeader);
+ for (i = 0; i < (sizeof (AspmBrDeviceTable) / sizeof (UINT16)); i = i + 3) {
+ UINT32 DeviceId;
+ UINT32 VendorId;
+ VendorId = AspmBrDeviceTable[i];
+ DeviceId = AspmBrDeviceTable[i + 1];
+ if (VendorId == (UINT16)UpstreamDeviceId || VendorId == (UINT16)DownstreamDeviceId ) {
+ if (DeviceId == 0xFFFF || DeviceId == (UpstreamDeviceId >> 16) || DeviceId == (DownstreamDeviceId >> 16)) {
+ LinkAsmp->UpstreamAspm &= AspmBrDeviceTable[i + 2];
+ LinkAsmp->DownstreamAspm &= AspmBrDeviceTable[i + 2];
+ }
+ }
+ }
+ if ((UINT16)UpstreamDeviceId == 0x168c) {
+ // Atheros (Ignore dev capability enable L1 if requested)
+ LinkAsmp->UpstreamAspm = LinkAsmp->RequestedAspm & AspmL1;
+ LinkAsmp->DownstreamAspm = LinkAsmp->UpstreamAspm;
+ GnbLibPciRMW (LinkAsmp->UpstreamPort.AddressValue | 0x70C, AccessS3SaveWidth32, 0x0, 0x0F003F01, StdHeader);
+ }
+ return AGESA_SUCCESS;
+}
diff --git a/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PcieAspmBlackList.h b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PcieAspmBlackList.h
new file mode 100644
index 0000000000..a6cebc9ae8
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PcieAspmBlackList.h
@@ -0,0 +1,56 @@
+/**
+ * @file
+ *
+ * PCIe ASPM Black List
+ *
+ *
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: GNB
+ * @e \$Revision: 24971 $ @e \$Date: 2010-01-13 10:25:06 +0800 (Wed, 13 Jan 2010) $
+ *
+ */
+/*
+ *****************************************************************************
+ *
+ * Copyright (c) 2011, Advanced Micro Devices, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Advanced Micro Devices, Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***************************************************************************
+ *
+ */
+
+#ifndef _PCIEASPMBLACKLIST_H_
+#define _PCIEASPMBLACKLIST_H_
+
+///PCIe ASPM Black List
+
+AGESA_STATUS
+PcieAspmBlackListFeature (
+ IN PCIe_LINK_ASPM *LinkAsmp,
+ IN AMD_CONFIG_PARAMS *StdHeader
+ );
+#endif
diff --git a/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PcieAspmExitLatency.c b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PcieAspmExitLatency.c
new file mode 100644
index 0000000000..1dffc52b80
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PcieAspmExitLatency.c
@@ -0,0 +1,192 @@
+/* $NoKeywords:$ */
+/**
+ * @file
+ *
+ * Service procedure to calculate PCIe topology segment maximum exit latency
+ *
+ *
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: GNB
+ * @e \$Revision: 38298 $ @e \$Date: 2010-09-21 07:15:32 -0700 (Tue, 21 Sep 2010) $
+ *
+ */
+/*
+ *****************************************************************************
+ *
+ * Copyright (c) 2011, Advanced Micro Devices, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Advanced Micro Devices, Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***************************************************************************
+ *
+ */
+
+/*----------------------------------------------------------------------------------------
+ * M O D U L E S U S E D
+ *----------------------------------------------------------------------------------------
+ */
+#include "AGESA.h"
+#include "Ids.h"
+#include "Gnb.h"
+#include "GnbPcie.h"
+#include GNB_MODULE_DEFINITIONS (GnbCommonLib)
+#include GNB_MODULE_DEFINITIONS (GnbPcieInitLibV1)
+#include "Filecode.h"
+#define FILECODE PROC_GNB_MODULES_GNBPCIEINITLIBV1_PCIEASPMEXITLATENCY_FILECODE
+/*----------------------------------------------------------------------------------------
+ * D E F I N I T I O N S A N D M A C R O S
+ *----------------------------------------------------------------------------------------
+ */
+
+
+/*----------------------------------------------------------------------------------------
+ * T Y P E D E F S A N D S T R U C T U R E S
+ *----------------------------------------------------------------------------------------
+ */
+
+typedef struct {
+ GNB_PCI_SCAN_DATA ScanData;
+ PCIe_ASPM_LATENCY_INFO *AspmLatencyInfo;
+ PCI_ADDR DownstreamPort;
+ UINT8 LinkCount;
+} PCIE_EXIT_LATENCY_DATA;
+
+/*----------------------------------------------------------------------------------------
+ * P R O T O T Y P E S O F L O C A L F U N C T I O N S
+ *----------------------------------------------------------------------------------------
+ */
+
+SCAN_STATUS
+PcieAspmGetMaxExitLatencyCallback (
+ IN PCI_ADDR Device,
+ IN OUT GNB_PCI_SCAN_DATA *ScanData
+ );
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Determine ASPM L-state maximum exit latency for PCIe segment
+ *
+ * Scan through all link in segment to determine maxim exit latency requirement by EPs.
+ *
+ * @param[in] DownstreamPort PCI address of PCIe port
+ * @param[out] AspmLatencyInfo Latency info
+ * @param[in] StdHeader Standard configuration header
+ *
+ */
+
+VOID
+PcieAspmGetMaxExitLatency (
+ IN PCI_ADDR DownstreamPort,
+ OUT PCIe_ASPM_LATENCY_INFO *AspmLatencyInfo,
+ IN AMD_CONFIG_PARAMS *StdHeader
+ )
+{
+ PCIE_EXIT_LATENCY_DATA PcieExitLatencyData;
+ PcieExitLatencyData.AspmLatencyInfo = AspmLatencyInfo;
+ PcieExitLatencyData.ScanData.StdHeader = StdHeader;
+ PcieExitLatencyData.LinkCount = 0;
+ PcieExitLatencyData.ScanData.GnbScanCallback = PcieAspmGetMaxExitLatencyCallback;
+ GnbLibPciScan (DownstreamPort, DownstreamPort, &PcieExitLatencyData.ScanData);
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Evaluate device
+ *
+ *
+ *
+ * @param[in] Device PCI Address
+ * @param[in,out] ScanData Scan configuration data
+ * @retval Scan Status of 0
+ */
+
+SCAN_STATUS
+PcieAspmGetMaxExitLatencyCallback (
+ IN PCI_ADDR Device,
+ IN OUT GNB_PCI_SCAN_DATA *ScanData
+ )
+{
+ SCAN_STATUS ScanStatus;
+ PCIE_EXIT_LATENCY_DATA *PcieExitLatencyData;
+ PCIE_DEVICE_TYPE DeviceType;
+ UINT32 Value;
+ UINT8 PcieCapPtr;
+ UINT8 L1AcceptableLatency;
+
+ PcieExitLatencyData = (PCIE_EXIT_LATENCY_DATA*) ScanData;
+ ScanStatus = SCAN_SUCCESS;
+ DeviceType = GnbLibGetPcieDeviceType (Device, ScanData->StdHeader);
+ IDS_HDT_CONSOLE (GNB_TRACE, " PcieAspmGetMaxExitLatencyCallback for Device = %d:%d:%d\n",
+ Device.Address.Bus,
+ Device.Address.Device,
+ Device.Address.Function
+ );
+ switch (DeviceType) {
+ case PcieDeviceRootComplex:
+ case PcieDeviceDownstreamPort:
+ PcieExitLatencyData->DownstreamPort = Device;
+ PcieExitLatencyData->LinkCount++;
+ GnbLibPciScanSecondaryBus (Device, &PcieExitLatencyData->ScanData);
+ PcieExitLatencyData->LinkCount--;
+ break;
+ case PcieDeviceUpstreamPort:
+ GnbLibPciScanSecondaryBus (Device, &PcieExitLatencyData->ScanData);
+ break;
+ case PcieDeviceEndPoint:
+ case PcieDeviceLegacyEndPoint:
+ PcieCapPtr = GnbLibFindPciCapability (Device.AddressValue, PCIE_CAP_ID, ScanData->StdHeader);
+ ASSERT (PcieCapPtr != 0);
+ GnbLibPciRead (
+ Device.AddressValue | (PcieCapPtr + PCIE_LINK_CAP_REGISTER),
+ AccessWidth32,
+ &Value,
+ ScanData->StdHeader
+ );
+ if ((Value & PCIE_ASPM_L1_SUPPORT_CAP) != 0) {
+ GnbLibPciRead (
+ Device.AddressValue | (PcieCapPtr + PCIE_DEVICE_CAP_REGISTER),
+ AccessWidth32,
+ &Value,
+ ScanData->StdHeader
+ );
+ L1AcceptableLatency = (UINT8) (1 << ((Value >> 9) & 0x7));
+ if (PcieExitLatencyData->LinkCount > 1) {
+ L1AcceptableLatency = L1AcceptableLatency + PcieExitLatencyData->LinkCount;
+ }
+ if (PcieExitLatencyData->AspmLatencyInfo->MaxL1ExitLatency < L1AcceptableLatency) {
+ PcieExitLatencyData->AspmLatencyInfo->MaxL1ExitLatency = L1AcceptableLatency;
+ }
+ IDS_HDT_CONSOLE (PCIE_MISC, " Device max exit latency L1 - %d us\n",
+ L1AcceptableLatency
+ );
+ }
+ break;
+ default:
+ break;
+ }
+ return SCAN_SUCCESS;
+}
+
diff --git a/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PcieAspmExitLatency.h b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PcieAspmExitLatency.h
new file mode 100644
index 0000000000..5099c0f830
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PcieAspmExitLatency.h
@@ -0,0 +1,56 @@
+/* $NoKeywords:$ */
+/**
+ * @file
+ *
+ * Service procedure to calculate PCIe topology segment maximum exit latency
+ *
+ *
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: GNB
+ * @e \$Revision: 34897 $ @e \$Date: 2010-07-13 19:07:10 -0700 (Tue, 13 Jul 2010) $
+ *
+ */
+/*
+ *****************************************************************************
+ *
+ * Copyright (c) 2011, Advanced Micro Devices, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Advanced Micro Devices, Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***************************************************************************
+ *
+ */
+
+#ifndef _PCIEASPMEXITLATENCY_H_
+#define _PCIEASPMEXITLATENCY_H_
+
+VOID
+PcieAspmGetMaxExitLatency (
+ IN PCI_ADDR DownstreamPort,
+ OUT PCIe_ASPM_LATENCY_INFO *AspmLatencyInfo,
+ IN AMD_CONFIG_PARAMS *StdHeader
+ );
+#endif
diff --git a/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PciePhyServices.c b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PciePhyServices.c
new file mode 100644
index 0000000000..3fbd2f43a7
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PciePhyServices.c
@@ -0,0 +1,197 @@
+/* $NoKeywords:$ */
+/**
+ * @file
+ *
+ * PCIe PIF initialization routine
+ *
+ *
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: GNB
+ * @e \$Revision: 38931 $ @e \$Date: 2010-10-01 15:50:05 -0700 (Fri, 01 Oct 2010) $
+ *
+ */
+/*
+ *****************************************************************************
+ *
+ * Copyright (c) 2011, Advanced Micro Devices, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Advanced Micro Devices, Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***************************************************************************
+ *
+ */
+/*----------------------------------------------------------------------------------------
+ * M O D U L E S U S E D
+ *----------------------------------------------------------------------------------------
+ */
+
+#include "AGESA.h"
+#include "Ids.h"
+#include "amdlib.h"
+#include "Gnb.h"
+#include "GnbPcie.h"
+#include GNB_MODULE_DEFINITIONS (GnbCommonLib)
+#include GNB_MODULE_DEFINITIONS (GnbPcieInitLibV1)
+#include "GnbRegistersON.h"
+#include "Filecode.h"
+#define FILECODE PROC_GNB_MODULES_GNBPCIEINITLIBV1_PCIEPHYSERVICES_FILECODE
+/*----------------------------------------------------------------------------------------
+ * D E F I N I T I O N S A N D M A C R O S
+ *----------------------------------------------------------------------------------------
+ */
+
+#define MAX_NUM_PHYs 2
+#define MAX_NUM_LANE_PER_PHY 8
+
+/*----------------------------------------------------------------------------------------
+ * T Y P E D E F S A N D S T R U C T U R E S
+ *----------------------------------------------------------------------------------------
+ */
+
+
+/*----------------------------------------------------------------------------------------
+ * P R O T O T Y P E S O F L O C A L F U N C T I O N S
+ *----------------------------------------------------------------------------------------
+ */
+
+
+/*----------------------------------------------------------------------------------------
+ * E X P O R T E D F U N C T I O N S
+ *----------------------------------------------------------------------------------------
+ */
+
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * PHY lane ganging
+ *
+ *
+ *
+ * @param[out] Wrapper Pointer to internal configuration data area
+ * @param[in] Pcie Pointer to global PCIe configuration
+ */
+VOID
+PciePhyApplyGanging (
+ IN PCIe_WRAPPER_CONFIG *Wrapper,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ PCIe_ENGINE_CONFIG *EngineList;
+ UINT8 GangMatrix [MAX_NUM_PHYs][MAX_NUM_LANE_PER_PHY];
+ UINT8 MasterMatrix [MAX_NUM_PHYs][MAX_NUM_LANE_PER_PHY];
+ UINT16 LoPhylane;
+ UINT16 HiPhylane;
+ UINT8 Phy;
+ UINT16 Lane;
+ UINT16 PhyLinkWidth;
+ IDS_HDT_CONSOLE (GNB_TRACE, "PciePhyApplyGanging Enter\n");
+ LibAmdMemFill (GangMatrix, 0, sizeof (GangMatrix), GnbLibGetHeader (Pcie));
+ LibAmdMemFill (MasterMatrix, 0, sizeof (MasterMatrix), GnbLibGetHeader (Pcie));
+ EngineList = PcieWrapperGetEngineList (Wrapper);
+ while (EngineList != NULL) {
+ if (PcieLibIsEngineAllocated (EngineList)) {
+ HiPhylane = PcieUtilGetHiPhyLane (EngineList) - Wrapper->StartPhyLane;
+ LoPhylane = PcieUtilGetLoPhyLane (EngineList) - Wrapper->StartPhyLane;
+ PhyLinkWidth = HiPhylane - LoPhylane + 1;
+
+ if (PhyLinkWidth >= 8) {
+ for (Lane = LoPhylane; Lane <= HiPhylane; Lane++) {
+ ((UINT8 *) GangMatrix)[Lane] = 1;
+ }
+ } else {
+ if (PhyLinkWidth > 0 && PhyLinkWidth < 4) {
+ for (Lane = (LoPhylane / 4) * 4; Lane < (((LoPhylane / 4) * 4) + 4) ; Lane++) {
+ ((UINT8 *) MasterMatrix)[Lane] = 1;
+ }
+ }
+ }
+ }
+ EngineList = PcieLibGetNextDescriptor (EngineList);
+ }
+ for (Phy = 0; Phy < Wrapper->NumberOfPIFs; Phy++) {
+ for (Lane = 0; Lane < MAX_NUM_LANE_PER_PHY; Lane++) {
+ D0F0xE4_PHY_6005_STRUCT D0F0xE4_PHY_6005;
+ D0F0xE4_PHY_6005.Value = PcieRegisterRead (
+ Wrapper,
+ PHY_SPACE (Wrapper->WrapId, Phy, D0F0xE4_PHY_6005_ADDRESS + Lane * 0x80),
+ Pcie
+ );
+ D0F0xE4_PHY_6005.Field.GangedModeEn = GangMatrix [Phy][Lane];
+ D0F0xE4_PHY_6005.Field.IsOwnMstr = MasterMatrix [Phy][Lane];
+ PcieRegisterWrite (
+ Wrapper,
+ PHY_SPACE (Wrapper->WrapId, Phy, D0F0xE4_PHY_6005_ADDRESS + Lane * 0x80),
+ D0F0xE4_PHY_6005.Value,
+ FALSE,
+ Pcie
+ );
+ }
+ }
+ IDS_HDT_CONSOLE (GNB_TRACE, "PciePhyApplyGanging Exit\n");
+}
+
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Point "virtual" PLL clock picker away from PCIe
+ *
+ *
+ *
+ * @param[in] Wrapper Pointer to internal configuration data area
+ * @param[in] Pcie Pointer to global PCIe configuration
+ */
+VOID
+PciePhyAvertClockPickers (
+ IN PCIe_WRAPPER_CONFIG *Wrapper,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ UINT32 DdiLanes;
+ UINT8 Nibble;
+ IDS_HDT_CONSOLE (GNB_TRACE, "PciePhyAvertClockPickers Enter\n");
+ DdiLanes = PcieUtilGetWrapperLaneBitMap (LANE_TYPE_DDI_ALLOCATED, 0, Wrapper, Pcie);
+ for (Nibble = 0; Nibble < 4; Nibble++) {
+ if (DdiLanes & (0xf << (Nibble * 4))) {
+ PcieRegisterRMW (
+ Wrapper,
+ PHY_SPACE (Wrapper->WrapId, (Nibble >> 1), D0F0xE4_PHY_0009_ADDRESS + (Nibble & 0x1)),
+ D0F0xE4_PHY_0009_PCIePllSel_MASK,
+ 0x0 << D0F0xE4_PHY_0009_PCIePllSel_OFFSET,
+ FALSE,
+ Pcie
+ );
+ PcieRegisterRMW (
+ Wrapper,
+ PHY_SPACE (Wrapper->WrapId, (Nibble >> 1), D0F0xE4_PHY_000B_ADDRESS + (Nibble & 0x1)),
+ D0F0xE4_PHY_000B_MargPktSbiEn_MASK | D0F0xE4_PHY_000B_PcieModeSbiEn_MASK,
+ (0x0 << D0F0xE4_PHY_000B_MargPktSbiEn_OFFSET) | (0x0 << D0F0xE4_PHY_000B_PcieModeSbiEn_OFFSET),
+ FALSE,
+ Pcie
+ );
+ }
+ }
+ IDS_HDT_CONSOLE (GNB_TRACE, "PciePhyAvertClockPickers Exit\n");
+}
diff --git a/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PciePhyServices.h b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PciePhyServices.h
new file mode 100644
index 0000000000..0f28e29c3d
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PciePhyServices.h
@@ -0,0 +1,61 @@
+/* $NoKeywords:$ */
+/**
+ * @file
+ *
+ * PCIe PIF initialization routine
+ *
+ *
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: GNB
+ * @e \$Revision: 34897 $ @e \$Date: 2010-07-13 19:07:10 -0700 (Tue, 13 Jul 2010) $
+ *
+ */
+/*
+ *****************************************************************************
+ *
+ * Copyright (c) 2011, Advanced Micro Devices, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Advanced Micro Devices, Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***************************************************************************
+ *
+ */
+
+#ifndef _PCIEPHYSERVICES_H_
+#define _PCIEPHYSERVICES_H_
+
+VOID
+PciePhyApplyGanging (
+ IN PCIe_WRAPPER_CONFIG *Wrapper,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ );
+
+VOID
+PciePhyAvertClockPickers (
+ IN PCIe_WRAPPER_CONFIG *Wrapper,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ );
+#endif
diff --git a/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PciePifServices.c b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PciePifServices.c
new file mode 100644
index 0000000000..717a80a158
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PciePifServices.c
@@ -0,0 +1,558 @@
+/* $NoKeywords:$ */
+/**
+ * @file
+ *
+ * PCIe PIF initialization routine
+ *
+ *
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: GNB
+ * @e \$Revision: 38931 $ @e \$Date: 2010-10-01 15:50:05 -0700 (Fri, 01 Oct 2010) $
+ *
+ */
+/*
+ *****************************************************************************
+ *
+ * Copyright (c) 2011, Advanced Micro Devices, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Advanced Micro Devices, Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***************************************************************************
+ *
+ */
+/*----------------------------------------------------------------------------------------
+ * M O D U L E S U S E D
+ *----------------------------------------------------------------------------------------
+ */
+
+#include "AGESA.h"
+#include "Ids.h"
+#include "amdlib.h"
+#include "Gnb.h"
+#include "GnbPcie.h"
+#include GNB_MODULE_DEFINITIONS (GnbCommonLib)
+#include GNB_MODULE_DEFINITIONS (GnbPcieInitLibV1)
+#include "GnbRegistersON.h"
+#include "Filecode.h"
+#define FILECODE PROC_GNB_MODULES_GNBPCIEINITLIBV1_PCIEPIFSERVICES_FILECODE
+/*----------------------------------------------------------------------------------------
+ * D E F I N I T I O N S A N D M A C R O S
+ *----------------------------------------------------------------------------------------
+ */
+
+#define PIF_GANG_0to1 0x1
+#define PIF_GANG_2to3 (0x1 << 1)
+#define PIF_GANG_4to5 (0x1 << 2)
+#define PIF_GANG_6to7 (0x1 << 3)
+#define PIF_GANG_0to3 (0x1 << 4)
+#define PIF_GANG_4to7 (0x1 << 8)
+#define PIF_GANG_0to7 (0x1 << 9)
+#define PIF_GANG_ALL (0x1 << 25)
+
+/*----------------------------------------------------------------------------------------
+ * T Y P E D E F S A N D S T R U C T U R E S
+ *----------------------------------------------------------------------------------------
+ */
+
+
+/*----------------------------------------------------------------------------------------
+ * P R O T O T Y P E S O F L O C A L F U N C T I O N S
+ *----------------------------------------------------------------------------------------
+ */
+
+
+/*----------------------------------------------------------------------------------------
+ * E X P O R T E D F U N C T I O N S
+ *----------------------------------------------------------------------------------------
+ */
+
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Apply PIF ganging for all lanes for given wrapper
+ *
+ *
+ *
+ * @param[in] Wrapper Pointer to Wrapper config descriptor
+ * @param[in] Pcie Pointer to PICe configuration data area
+ */
+
+
+VOID
+PciePifApplyGanging (
+ IN PCIe_WRAPPER_CONFIG *Wrapper,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ PCIe_ENGINE_CONFIG *EngineList;
+ UINT32 LaneBitmap;
+ UINT8 Pif;
+ D0F0xE4_PIF_0011_STRUCT D0F0xE4_PIF_0011[2];
+ IDS_HDT_CONSOLE (GNB_TRACE, "PciePifApplyGanging Enter\n");
+ LibAmdMemFill (&D0F0xE4_PIF_0011, 0, sizeof (D0F0xE4_PIF_0011), GnbLibGetHeader (Pcie));
+ EngineList = PcieWrapperGetEngineList (Wrapper);
+ while (EngineList != NULL) {
+ if (PcieLibIsEngineAllocated (EngineList)) {
+ LaneBitmap = PcieUtilGetEngineLaneBitMap (LANE_TYPE_ALLOCATED, 0, EngineList, Pcie);
+ switch (LaneBitmap) {
+ case 0x0003:
+ D0F0xE4_PIF_0011[0].Field.X2Lane10 = 0x1;
+ break;
+ case 0x000c:
+ D0F0xE4_PIF_0011[0].Field.X2Lane32 = 0x1;
+ break;
+ case 0x0030:
+ D0F0xE4_PIF_0011[0].Field.X2Lane54 = 0x1;
+ break;
+ case 0x00c0:
+ D0F0xE4_PIF_0011[0].Field.X2Lane76 = 0x1;
+ break;
+ case 0x000f:
+ D0F0xE4_PIF_0011[0].Field.X4Lane30 = 0x1;
+ break;
+ case 0x00f0:
+ D0F0xE4_PIF_0011[0].Field.X4Lane74 = 0x1;
+ break;
+ case 0x00ff:
+ D0F0xE4_PIF_0011[0].Field.X8Lane70 = 0x1;
+ break;
+ case 0x0300:
+ D0F0xE4_PIF_0011[1].Field.X2Lane10 = 1;
+ break;
+ case 0x0c00:
+ D0F0xE4_PIF_0011[1].Field.X2Lane32 = 0x1;
+ break;
+ case 0x3000:
+ D0F0xE4_PIF_0011[1].Field.X2Lane54 = 0x1;
+ break;
+ case 0xc000:
+ D0F0xE4_PIF_0011[1].Field.X2Lane76 = 0x1;
+ break;
+ case 0x0f00:
+ D0F0xE4_PIF_0011[1].Field.X4Lane30 = 0x1;
+ break;
+ case 0xf000:
+ D0F0xE4_PIF_0011[1].Field.X4Lane74 = 0x1;
+ break;
+ case 0xff00:
+ D0F0xE4_PIF_0011[1].Field.X8Lane70 = 0x1;
+ break;
+ case 0xffff:
+ D0F0xE4_PIF_0011[0].Field.MultiPif = 0x1;
+ D0F0xE4_PIF_0011[1].Field.MultiPif = 0x1;
+ break;
+ default:
+ break;
+ }
+ }
+ EngineList = PcieLibGetNextDescriptor (EngineList);
+ }
+ for (Pif = 0; Pif < Wrapper->NumberOfPIFs; Pif++) {
+ PcieRegisterWrite (
+ Wrapper,
+ PIF_SPACE (Wrapper->WrapId, Pif, D0F0xE4_PIF_0011_ADDRESS),
+ D0F0xE4_PIF_0011[Pif].Value,
+ FALSE,
+ Pcie
+ );
+ }
+ IDS_HDT_CONSOLE (GNB_TRACE, "PciePifApplyGanging Exit\n");
+}
+
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * PLL powerdown
+ *
+ *
+ * @param[in] LaneBitmap Power down PLL for these lanes
+ * @param[in] Wrapper Pointer to Wrapper config descriptor
+ * @param[in] Pcie Pointer to PICe configuration data area
+ */
+
+VOID
+PciePifPllPowerDown (
+ IN UINT32 LaneBitmap,
+ IN PCIe_WRAPPER_CONFIG *Wrapper,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ UINT8 Nibble;
+ UINT16 NibbleBitmap;
+ D0F0xE4_PIF_0012_STRUCT D0F0xE4_PIF_0012;
+ IDS_HDT_CONSOLE (GNB_TRACE, "PciePifPllPowerDown Enter\n");
+ for (Nibble = 0; Nibble < 4; Nibble++) {
+ NibbleBitmap = (0xF << (Nibble * 4));
+ if ((LaneBitmap & NibbleBitmap) == NibbleBitmap) {
+ D0F0xE4_PIF_0012.Value = PcieRegisterRead (
+ Wrapper,
+ PIF_SPACE (Wrapper->WrapId, (Nibble >> 1), D0F0xE4_PIF_0012_ADDRESS + (Nibble & 0x1)),
+ Pcie
+ );
+
+ D0F0xE4_PIF_0012.Field.PllPowerStateInTxs2 = PifPowerStateOff;
+ D0F0xE4_PIF_0012.Field.PllPowerStateInOff = PifPowerStateOff;
+ D0F0xE4_PIF_0012.Field.TxPowerStateInTxs2 = PifPowerStateOff;
+ D0F0xE4_PIF_0012.Field.RxPowerStateInRxs2 = PifPowerStateOff;
+ PcieRegisterWrite (
+ Wrapper,
+ PIF_SPACE (Wrapper->WrapId, (Nibble >> 1), D0F0xE4_PIF_0012_ADDRESS + (Nibble & 0x1)),
+ D0F0xE4_PIF_0012.Value,
+ TRUE,
+ Pcie
+ );
+ }
+ }
+ IDS_HDT_CONSOLE (GNB_TRACE, "PciePifPllPowerDown Exit\n");
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * PLL init for DDI
+ *
+ *
+ *
+ * @param[in] Wrapper Pointer to Wrapper config descriptor
+ * @param[in] Pcie Pointer to PICe configuration data area
+ */
+
+VOID
+PciePifPllInitForDdi (
+ IN PCIe_WRAPPER_CONFIG *Wrapper,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ UINT8 Nibble;
+ UINT32 LaneBitmap;
+ D0F0xE4_PIF_0012_STRUCT D0F0xE4_PIF_0012;
+ IDS_HDT_CONSOLE (GNB_TRACE, "PciePifPllInitForDdi Enter\n");
+ LaneBitmap = PcieUtilGetWrapperLaneBitMap (LANE_TYPE_DDI_ALLOCATED, 0, Wrapper, Pcie);
+ for (Nibble = 0; Nibble < 4; Nibble++) {
+ if (LaneBitmap & (0xF << (Nibble * 4))) {
+ D0F0xE4_PIF_0012.Value = PcieRegisterRead (
+ Wrapper,
+ PIF_SPACE (Wrapper->WrapId, (Nibble >> 1), D0F0xE4_PIF_0012_ADDRESS + (Nibble & 0x1)),
+ Pcie
+ );
+
+ D0F0xE4_PIF_0012.Field.PllPowerStateInTxs2 = PifPowerStateOff;
+ D0F0xE4_PIF_0012.Field.PllPowerStateInOff = PifPowerStateOff;
+ D0F0xE4_PIF_0012.Field.PllRampUpTime = 0x2;
+ PcieRegisterWrite (
+ Wrapper,
+ PIF_SPACE (Wrapper->WrapId, (Nibble >> 1), D0F0xE4_PIF_0012_ADDRESS + (Nibble & 0x1)),
+ D0F0xE4_PIF_0012.Value,
+ FALSE,
+ Pcie
+ );
+ }
+ }
+ IDS_HDT_CONSOLE (GNB_TRACE, "PciePifPllInitForDdi Exit\n");
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Poll for on PIF to indicate action completion
+ *
+ *
+ *
+ * @param[in] Wrapper Pointer to wrapper config descriptor
+ * @param[in] Pcie Pointer to global PCIe configuration
+ */
+VOID
+PciePollPifForCompeletion (
+ IN PCIe_WRAPPER_CONFIG *Wrapper,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ UINT32 TimeStamp;
+ UINT8 Pif;
+ D0F0xE4_PIF_0015_STRUCT D0F0xE4_PIF_0015;
+ TimeStamp = PcieTimerGetTimeStamp (Pcie);
+ for (Pif = 0; Pif < Wrapper->NumberOfPIFs; Pif++) {
+ do {
+ D0F0xE4_PIF_0015.Value = PcieRegisterRead (
+ Wrapper,
+ PIF_SPACE (Wrapper->WrapId, Pif, D0F0xE4_PIF_0015_ADDRESS),
+ Pcie
+ );
+ if (TIMESTAMPS_DELTA (TimeStamp, PcieTimerGetTimeStamp (Pcie)) > 100) {
+ break;
+ }
+ } while ((D0F0xE4_PIF_0015.Value & 0xff) != 0xff);
+ }
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Disable fifo reset
+ *
+ *
+ *
+ * @param[in] Wrapper Pointer to Wrapper config descriptor
+ * @param[in] Pcie Pointer to PICe configuration data area
+ */
+
+
+VOID
+PciePifDisableFifoReset (
+ IN PCIe_WRAPPER_CONFIG *Wrapper,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ UINT8 Pif;
+ for (Pif = 0; Pif < Wrapper->NumberOfPIFs; Pif++) {
+ PcieRegisterWriteField (
+ Wrapper,
+ PIF_SPACE (Wrapper->WrapId, Pif, D0F0xE4_PIF_0010_ADDRESS),
+ D0F0xE4_PIF_0010_RxDetectFifoResetMode_OFFSET,
+ D0F0xE4_PIF_0010_RxDetectFifoResetMode_WIDTH,
+ 0,
+ FALSE,
+ Pcie
+ );
+ }
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Program LS2 exit time
+ *
+ *
+ *
+ * @param[in] Wrapper Pointer to wrapper config descriptor
+ * @param[in] Pcie Pointer to global PCIe configuration
+ */
+
+VOID
+PciePifSetLs2ExitTime (
+ IN PCIe_WRAPPER_CONFIG *Wrapper,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ UINT8 Pif;
+ IDS_HDT_CONSOLE (GNB_TRACE, "PciePifSetLs2ExitTime Enter\n");
+ for (Pif = 0; Pif < Wrapper->NumberOfPIFs; Pif++) {
+ PcieRegisterWriteField (
+ Wrapper,
+ PIF_SPACE (Wrapper->WrapId, Pif, D0F0xE4_PIF_0010_ADDRESS),
+ D0F0xE4_PIF_0010_Ls2ExitTime_OFFSET,
+ D0F0xE4_PIF_0010_Ls2ExitTime_WIDTH,
+ 0x0,
+ FALSE,
+ Pcie
+ );
+ }
+ IDS_HDT_CONSOLE (GNB_TRACE, "PciePifSetLs2ExitTime Exit\n");
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Set PLL mode for L1
+ *
+ *
+ * @param[in] LaneBitmap Power down PLL for these lanes
+ * @param[in] Wrapper Pointer to Wrapper config descriptor
+ * @param[in] Pcie Pointer to PICe configuration data area
+ */
+
+VOID
+PciePifSetPllModeForL1 (
+ IN UINT32 LaneBitmap,
+ IN PCIe_WRAPPER_CONFIG *Wrapper,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ UINT8 Nibble;
+ D0F0xE4_PIF_0012_STRUCT D0F0xE4_PIF_0012;
+ for (Nibble = 0; Nibble < 4; Nibble++) {
+ if (LaneBitmap & (0xF << (Nibble * 4))) {
+ D0F0xE4_PIF_0012.Value = PcieRegisterRead (
+ Wrapper,
+ PIF_SPACE (Wrapper->WrapId, (Nibble >> 1), D0F0xE4_PIF_0012_ADDRESS + (Nibble & 0x1)),
+ Pcie
+ );
+ D0F0xE4_PIF_0012.Field.RxPowerStateInRxs2 = PifPowerStateLS2;
+ D0F0xE4_PIF_0012.Field.TxPowerStateInTxs2 = PifPowerStateLS2;
+ D0F0xE4_PIF_0012.Field.PllPowerStateInTxs2 = PifPowerStateOff;
+ D0F0xE4_PIF_0012.Field.PllPowerStateInOff = PifPowerStateOff;
+ D0F0xE4_PIF_0012.Field.PllRampUpTime = 0x0;
+ PcieRegisterWrite (
+ Wrapper,
+ PIF_SPACE (Wrapper->WrapId, (Nibble >> 1), D0F0xE4_PIF_0012_ADDRESS + (Nibble & 0x1)),
+ D0F0xE4_PIF_0012.Value,
+ TRUE,
+ Pcie
+ );
+ }
+ }
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Program receiver detection power mode
+ *
+ *
+ *
+ * @param[in] Wrapper Pointer to wrapper config descriptor
+ * @param[in] Pcie Pointer to global PCIe configuration
+ */
+
+VOID
+PciePifSetRxDetectPowerMode (
+ IN PCIe_WRAPPER_CONFIG *Wrapper,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ UINT8 Pif;
+ IDS_HDT_CONSOLE (GNB_TRACE, "PciePifSetRxDetectPowerMode Enter\n");
+ for (Pif = 0; Pif < Wrapper->NumberOfPIFs; Pif++) {
+ PcieRegisterWriteField (
+ Wrapper,
+ PIF_SPACE (Wrapper->WrapId, Pif, D0F0xE4_PIF_0010_ADDRESS),
+ D0F0xE4_PIF_0010_RxDetectTxPwrMode_OFFSET,
+ D0F0xE4_PIF_0010_RxDetectTxPwrMode_WIDTH,
+ 0x1,
+ FALSE,
+ Pcie
+ );
+ }
+ IDS_HDT_CONSOLE (GNB_TRACE, "PciePifSetRxDetectPowerMode Enter\n");
+}
+
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Pll ramp up time
+ *
+ *
+ *
+ * @param[in] Rampup Ramp up time
+ * @param[in] Wrapper Pointer to wrapper config descriptor
+ * @param[in] Pcie Pointer to global PCIe configuration
+ */
+VOID
+PciePifSetPllRampTime (
+ IN PCIE_PLL_RAMPUP_TIME Rampup,
+ IN PCIe_WRAPPER_CONFIG *Wrapper,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ UINT8 Pif;
+ D0F0xE4_PIF_0012_STRUCT D0F0xE4_PIF_0012;
+ D0F0xE4_PIF_0013_STRUCT D0F0xE4_PIF_0013;
+ D0F0xE4_PIF_0010_STRUCT D0F0xE4_PIF_0010;
+ for (Pif = 0; Pif < Wrapper->NumberOfPIFs; Pif++) {
+ D0F0xE4_PIF_0012.Value = PcieRegisterRead (
+ Wrapper,
+ PIF_SPACE (Wrapper->WrapId, Pif, D0F0xE4_PIF_0012_ADDRESS),
+ Pcie
+ );
+ D0F0xE4_PIF_0013.Value = PcieRegisterRead (
+ Wrapper,
+ PIF_SPACE (Wrapper->WrapId, Pif, D0F0xE4_PIF_0013_ADDRESS),
+ Pcie
+ );
+ D0F0xE4_PIF_0010.Value = PcieRegisterRead (
+ Wrapper,
+ PIF_SPACE (Wrapper->WrapId, Pif, D0F0xE4_PIF_0010_ADDRESS),
+ Pcie
+ );
+ if (Rampup == NormalRampup) {
+ D0F0xE4_PIF_0012.Field.PllRampUpTime = 0x1;
+ D0F0xE4_PIF_0013.Field.PllRampUpTime = 0x1;
+ D0F0xE4_PIF_0010.Field.Ls2ExitTime = 0x0;
+ } else {
+ D0F0xE4_PIF_0012.Field.PllRampUpTime = 0x3;
+ D0F0xE4_PIF_0013.Field.PllRampUpTime = 0x3;
+ D0F0xE4_PIF_0010.Field.Ls2ExitTime = 0x6;
+ }
+ PcieRegisterWrite (
+ Wrapper,
+ PIF_SPACE (Wrapper->WrapId, Pif, D0F0xE4_PIF_0012_ADDRESS),
+ D0F0xE4_PIF_0012.Value,
+ FALSE,
+ Pcie
+ );
+ PcieRegisterWrite (
+ Wrapper,
+ PIF_SPACE (Wrapper->WrapId, Pif, D0F0xE4_PIF_0013_ADDRESS),
+ D0F0xE4_PIF_0013.Value,
+ FALSE,
+ Pcie
+ );
+ PcieRegisterWrite (
+ Wrapper,
+ PIF_SPACE (Wrapper->WrapId, Pif, D0F0xE4_PIF_0010_ADDRESS),
+ D0F0xE4_PIF_0010.Value,
+ FALSE,
+ Pcie
+ );
+ }
+}
+
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Power down PIFs
+ *
+ *
+ *
+ * @param[in] Control Power up or Power down control
+ * @param[in] Wrapper Pointer to wrapper config descriptor
+ * @param[in] Pcie Pointer to global PCIe configuration
+ */
+VOID
+PciePifPllPowerControl (
+ IN PCIE_PIF_POWER_CONTROL Control,
+ IN PCIe_WRAPPER_CONFIG *Wrapper,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ UINT8 Pif;
+ UINT8 PllPowerStateInOff;
+ PllPowerStateInOff = (Control == PowerDownPifs) ? PifPowerStateOff : PifPowerStateL0;
+ for (Pif = 0; Pif < Wrapper->NumberOfPIFs; Pif++) {
+ PcieRegisterWriteField (
+ Wrapper,
+ PIF_SPACE (Wrapper->WrapId, Pif, D0F0xE4_PIF_0012_ADDRESS),
+ D0F0xE4_PIF_0012_PllPowerStateInOff_OFFSET,
+ D0F0xE4_PIF_0012_PllPowerStateInOff_WIDTH,
+ PllPowerStateInOff,
+ FALSE,
+ Pcie
+ );
+ PcieRegisterWriteField (
+ Wrapper,
+ PIF_SPACE (Wrapper->WrapId, Pif, D0F0xE4_PIF_0013_ADDRESS),
+ D0F0xE4_PIF_0013_PllPowerStateInOff_OFFSET,
+ D0F0xE4_PIF_0013_PllPowerStateInOff_WIDTH,
+ PllPowerStateInOff,
+ FALSE,
+ Pcie
+ );
+ }
+}
diff --git a/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PciePifServices.h b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PciePifServices.h
new file mode 100644
index 0000000000..a69ed41c7a
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PciePifServices.h
@@ -0,0 +1,107 @@
+/* $NoKeywords:$ */
+/**
+ * @file
+ *
+ * PCIe PIF initialization routine
+ *
+ *
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: GNB
+ * @e \$Revision: 34897 $ @e \$Date: 2010-07-13 19:07:10 -0700 (Tue, 13 Jul 2010) $
+ *
+ */
+/*
+ *****************************************************************************
+ *
+ * Copyright (c) 2011, Advanced Micro Devices, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Advanced Micro Devices, Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***************************************************************************
+ *
+ */
+
+#ifndef _PCIEPIFSERVICES_H_
+#define _PCIEPIFSERVICES_H_
+
+VOID
+PciePifApplyGanging (
+ IN PCIe_WRAPPER_CONFIG *Wrapper,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ );
+
+VOID
+PciePifPllPowerDown (
+ IN UINT32 LaneBitmap,
+ IN PCIe_WRAPPER_CONFIG *Wrapper,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ );
+
+VOID
+PciePifPllInitForDdi (
+ IN PCIe_WRAPPER_CONFIG *Wrapper,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ );
+
+VOID
+PciePollPifForCompeletion (
+ IN PCIe_WRAPPER_CONFIG *Wrapper,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ );
+
+VOID
+PciePifDisableFifoReset (
+ IN PCIe_WRAPPER_CONFIG *Wrapper,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ );
+
+VOID
+PciePifSetLs2ExitTime (
+ IN PCIe_WRAPPER_CONFIG *Wrapper,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ );
+
+VOID
+PciePifSetRxDetectPowerMode (
+ IN PCIe_WRAPPER_CONFIG *Wrapper,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ );
+
+VOID
+PciePifSetPllRampTime (
+ IN PCIE_PLL_RAMPUP_TIME Rampup,
+ IN PCIe_WRAPPER_CONFIG *Wrapper,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ );
+
+VOID
+PciePifPllPowerControl (
+ IN PCIE_PIF_POWER_CONTROL Control,
+ IN PCIe_WRAPPER_CONFIG *Wrapper,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ );
+
+#endif
diff --git a/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PciePortRegAcc.c b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PciePortRegAcc.c
new file mode 100644
index 0000000000..491e148d15
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PciePortRegAcc.c
@@ -0,0 +1,230 @@
+/* $NoKeywords:$ */
+/**
+ * @file
+ *
+ * Supporting services to access PCIe port indirect register
+ * space.
+ *
+ *
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: GNB
+ * @e \$Revision: 34897 $ @e \$Date: 2010-07-13 19:07:10 -0700 (Tue, 13 Jul 2010) $
+ *
+ */
+/*
+ *****************************************************************************
+ *
+ * Copyright (c) 2011, Advanced Micro Devices, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Advanced Micro Devices, Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***************************************************************************
+ *
+ */
+
+/*----------------------------------------------------------------------------------------
+ * M O D U L E S U S E D
+ *----------------------------------------------------------------------------------------
+ */
+#include "AGESA.h"
+#include "Ids.h"
+#include "Gnb.h"
+#include "GnbPcie.h"
+#include "GnbPcieFamServices.h"
+#include GNB_MODULE_DEFINITIONS (GnbCommonLib)
+#include "Filecode.h"
+#define FILECODE PROC_GNB_MODULES_GNBPCIEINITLIBV1_PCIEPORTREGACC_FILECODE
+/*----------------------------------------------------------------------------------------
+ * D E F I N I T I O N S A N D M A C R O S
+ *----------------------------------------------------------------------------------------
+ */
+
+
+/*----------------------------------------------------------------------------------------
+ * T Y P E D E F S A N D S T R U C T U R E S
+ *----------------------------------------------------------------------------------------
+ */
+
+
+/*----------------------------------------------------------------------------------------
+ * P R O T O T Y P E S O F L O C A L F U N C T I O N S
+ *----------------------------------------------------------------------------------------
+ */
+
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Read PCIe port indirect register.
+ *
+ * Support for unify register access through index/data pair on PCIe port
+ *
+ * @param[in] Engine Pointer to Engine descriptor for this port
+ * @param[in] Address Register address
+ * @param[in] Pcie Pointer to internal configuration data area
+ * @retval Register Value
+ */
+
+UINT32
+PciePortRegisterRead (
+ IN PCIe_ENGINE_CONFIG *Engine,
+ IN UINT16 Address,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ UINT32 Value;
+ GnbLibPciWrite (Engine->Type.Port.Address.AddressValue | 0xE0, AccessWidth32, &Address, GnbLibGetHeader (Pcie));
+ GnbLibPciRead (Engine->Type.Port.Address.AddressValue | 0xE4, AccessWidth32, &Value, GnbLibGetHeader (Pcie));
+ return Value;
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Write PCIe Port Indirect register.
+ *
+ * Support for unify register access through index/data pair on GNB
+ *
+ * @param[in] Engine Pointer to Engine descriptor for this port
+ * @param[in] Address Register address
+ * @param[in] Value New register value
+ * @param[in] S3Save Save for S3 flag
+ * @param[in] Pcie Pointer to internal configuration data area
+ */
+VOID
+PciePortRegisterWrite (
+ IN PCIe_ENGINE_CONFIG *Engine,
+ IN UINT16 Address,
+ IN UINT32 Value,
+ IN BOOLEAN S3Save,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ ASSERT (S3Save == TRUE || S3Save == FALSE);
+
+ IDS_HDT_CONSOLE (PCIE_PORTREG_TRACE, " *WR PCIEIND_P (%d:%d:%d):0x%04x = 0x%08x\n",
+ Engine->Type.Port.Address.Address.Bus,
+ Engine->Type.Port.Address.Address.Device,
+ Engine->Type.Port.Address.Address.Function,
+ Address,
+ Value
+ );
+ GnbLibPciWrite (Engine->Type.Port.Address.AddressValue | 0xE0, S3Save ? AccessS3SaveWidth32 : AccessWidth32, &Address, GnbLibGetHeader (Pcie));
+ GnbLibPciWrite (Engine->Type.Port.Address.AddressValue | 0xE4, S3Save ? AccessS3SaveWidth32 : AccessWidth32, &Value, GnbLibGetHeader (Pcie));
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Write PCIe Port Indirect register field.
+ *
+ * Support for unify register access through index/data pair on GNB
+ *
+ * @param[in] Engine Pointer to Engine descriptor for this port
+ * @param[in] Address Register address
+ * @param[in] FieldOffset Field offset
+ * @param[in] FieldWidth Field width
+ * @param[in] S3Save Save for S3 flag
+ * @param[in] Value New register value
+ * @param[in] Pcie Pointer to internal configuration data area
+ */
+
+VOID
+PciePortRegisterWriteField (
+ IN PCIe_ENGINE_CONFIG *Engine,
+ IN UINT16 Address,
+ IN UINT8 FieldOffset,
+ IN UINT8 FieldWidth,
+ IN UINT32 Value,
+ IN BOOLEAN S3Save,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ UINT32 Data;
+ UINT32 Mask;
+ Data = PciePortRegisterRead (Engine, Address, Pcie);
+ Mask = (1 << FieldWidth) - 1;
+ Value &= Mask;
+ Data &= (~(Mask << FieldOffset));
+ PciePortRegisterWrite (Engine, Address, Data | (Value << FieldOffset), S3Save, Pcie);
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Write PCIe Port Indirect register field.
+ *
+ * Support for unify register access through index/data pair on GNB
+ *
+ * @param[in] Engine Pointer to Engine descriptor for this port
+ * @param[in] Address Register address
+ * @param[in] FieldOffset Field offset
+ * @param[in] FieldWidth Field width
+ * @param[in] Pcie Pointer to internal configuration data area
+ * @retval Register Field Value.
+ */
+
+UINT32
+PciePortRegisterReadField (
+ IN PCIe_ENGINE_CONFIG *Engine,
+ IN UINT16 Address,
+ IN UINT8 FieldOffset,
+ IN UINT8 FieldWidth,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ UINT32 Value;
+ Value = PciePortRegisterRead (Engine, Address, Pcie);
+ Value = (Value >> FieldOffset) & ((1 << FieldWidth) - 1);
+ return Value;
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Read/Modify/Write PCIe port register.
+ *
+ * Support for unify register access through index/data pair on GNB
+ *
+ * @param[in] Engine Pointer to Engine descriptor for this port
+ * @param[in] Address Register address
+ * @param[in] AndMask Value & (~AndMask)
+ * @param[in] OrMask Value | OrMask
+ * @param[in] S3Save Save register for S3 (True/False)
+ * @param[in] Pcie Pointer to global PCIe configuration
+ */
+
+VOID
+PciePortRegisterRMW (
+ IN PCIe_ENGINE_CONFIG *Engine,
+ IN UINT16 Address,
+ IN UINT32 AndMask,
+ IN UINT32 OrMask,
+ IN BOOLEAN S3Save,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ UINT32 Value;
+ Value = PciePortRegisterRead (Engine, Address, Pcie);
+ Value = (Value & (~AndMask)) | OrMask;
+ PciePortRegisterWrite (Engine, Address, Value, S3Save, Pcie);
+}
+
diff --git a/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PciePortRegAcc.h b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PciePortRegAcc.h
new file mode 100644
index 0000000000..244e7b55b0
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PciePortRegAcc.h
@@ -0,0 +1,95 @@
+/* $NoKeywords:$ */
+/**
+ * @file
+ *
+ * Supporting services to access PCIe port indirect register space.
+ *
+ *
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: GNB
+ * @e \$Revision: 34897 $ @e \$Date: 2010-07-13 19:07:10 -0700 (Tue, 13 Jul 2010) $
+ *
+ */
+/*
+ *****************************************************************************
+ *
+ * Copyright (c) 2011, Advanced Micro Devices, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Advanced Micro Devices, Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***************************************************************************
+ *
+ */
+#ifndef _PCIEPORTREGACC_H_
+#define _PCIEPORTREGACC_H_
+
+UINT32
+PciePortRegisterRead (
+ IN PCIe_ENGINE_CONFIG *Engine,
+ IN UINT16 Address,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ );
+
+VOID
+PciePortRegisterWrite (
+ IN PCIe_ENGINE_CONFIG *Engine,
+ IN UINT16 Address,
+ IN UINT32 Value,
+ IN BOOLEAN S3Save,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ );
+
+VOID
+PciePortRegisterWriteField (
+ IN PCIe_ENGINE_CONFIG *Engine,
+ IN UINT16 Address,
+ IN UINT8 FieldOffset,
+ IN UINT8 FieldWidth,
+ IN UINT32 Value,
+ IN BOOLEAN S3Save,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ );
+
+UINT32
+PciePortRegisterReadField (
+ IN PCIe_ENGINE_CONFIG *Engine,
+ IN UINT16 Address,
+ IN UINT8 FieldOffset,
+ IN UINT8 FieldWidth,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ );
+
+VOID
+PciePortRegisterRMW (
+ IN PCIe_ENGINE_CONFIG *Engine,
+ IN UINT16 Address,
+ IN UINT32 AndMask,
+ IN UINT32 OrMask,
+ IN BOOLEAN S3Save,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ );
+
+#endif
diff --git a/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PciePortServices.c b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PciePortServices.c
new file mode 100644
index 0000000000..b2c490f122
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PciePortServices.c
@@ -0,0 +1,406 @@
+/* $NoKeywords:$ */
+/**
+ * @file
+ *
+ * PCIe port initialization service procedure
+ *
+ *
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: GNB
+ * @e \$Revision: 38931 $ @e \$Date: 2010-10-01 15:50:05 -0700 (Fri, 01 Oct 2010) $
+ *
+ */
+/*
+ *****************************************************************************
+ *
+ * Copyright (c) 2011, Advanced Micro Devices, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Advanced Micro Devices, Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***************************************************************************
+ *
+ */
+
+/*----------------------------------------------------------------------------------------
+ * M O D U L E S U S E D
+ *----------------------------------------------------------------------------------------
+ */
+#include "AGESA.h"
+#include "Ids.h"
+#include "amdlib.h"
+#include "Gnb.h"
+#include "GnbPcie.h"
+#include GNB_MODULE_DEFINITIONS (GnbCommonLib)
+#include GNB_MODULE_DEFINITIONS (GnbPcieInitLibV1)
+#include "GnbRegistersON.h"
+#include "Filecode.h"
+#define FILECODE PROC_GNB_MODULES_GNBPCIEINITLIBV1_PCIEPORTSERVICES_FILECODE
+/*----------------------------------------------------------------------------------------
+ * D E F I N I T I O N S A N D M A C R O S
+ *----------------------------------------------------------------------------------------
+ */
+
+
+/*----------------------------------------------------------------------------------------
+ * T Y P E D E F S A N D S T R U C T U R E S
+ *----------------------------------------------------------------------------------------
+ */
+
+
+/*----------------------------------------------------------------------------------------
+ * P R O T O T Y P E S O F L O C A L F U N C T I O N S
+ *----------------------------------------------------------------------------------------
+ */
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Set completion timeout
+ *
+ *
+ *
+ * @param[in] Engine Pointer to engine config descriptor
+ * @param[in] Pcie Pointer to global PCIe configuration
+ *
+ */
+
+VOID
+PcieCompletionTimeout (
+ IN PCIe_ENGINE_CONFIG *Engine,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ GnbLibPciRMW (
+ Engine->Type.Port.Address.AddressValue | DxF0x80_ADDRESS,
+ AccessWidth32,
+ 0xffffffff,
+ 0x6 << DxF0x80_CplTimeoutValue_OFFSET,
+ GnbLibGetHeader (Pcie)
+ );
+ if (Engine->Type.Port.PortData.LinkHotplug != HotplugDisabled) {
+ PciePortRegisterWriteField (
+ Engine,
+ DxF0xE4_x20_ADDRESS,
+ DxF0xE4_x20_TxFlushTlpDis_OFFSET,
+ DxF0xE4_x20_TxFlushTlpDis_WIDTH,
+ 0x0,
+ TRUE,
+ Pcie
+ );
+ }
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Init hotplug port
+ *
+ *
+ *
+ * @param[in] Engine Pointer to engine config descriptor
+ * @param[in] Pcie Pointer to global PCIe configuration
+ *
+ */
+
+VOID
+PcieLinkInitHotplug (
+ IN PCIe_ENGINE_CONFIG *Engine,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ DxF0xE4_xB5_STRUCT DxF0xE4_xB5;
+ if ((Engine->Type.Port.PortData.LinkHotplug == HotplugEnhanced) || (Engine->Type.Port.PortData.LinkHotplug == HotplugInboard)) {
+ DxF0xE4_xB5.Value = PciePortRegisterRead (Engine, DxF0xE4_xB5_ADDRESS, Pcie);
+ DxF0xE4_xB5.Field.LcEhpRxPhyCmd = 0x3;
+ DxF0xE4_xB5.Field.LcEhpTxPhyCmd = 0x3;
+ DxF0xE4_xB5.Field.LcEnhancedHotPlugEn = 0x1;
+ PciePortRegisterWrite (
+ Engine,
+ DxF0xE4_xB5_ADDRESS,
+ DxF0xE4_xB5.Value,
+ TRUE,
+ Pcie
+ );
+ PcieRegisterWriteField (
+ PcieEngineGetParentWrapper (Engine),
+ CORE_SPACE (Engine->Type.Port.CoreId, 0x10),
+ 1,
+ 3,
+ 0x5,
+ TRUE,
+ Pcie
+ );
+ PcieRegisterWriteField (
+ PcieEngineGetParentWrapper (Engine),
+ WRAP_SPACE (PcieEngineGetParentWrapper (Engine)->WrapId, D0F0xE4_WRAP_8011_ADDRESS),
+ D0F0xE4_WRAP_8011_RcvrDetClkEnable_OFFSET,
+ D0F0xE4_WRAP_8011_RcvrDetClkEnable_WIDTH,
+ 0x1,
+ TRUE,
+ Pcie
+ );
+ }
+ if (Engine->Type.Port.PortData.LinkHotplug != HotplugDisabled) {
+ GnbLibPciRMW (
+ Engine->Type.Port.Address.AddressValue | DxF0x6C_ADDRESS,
+ AccessS3SaveWidth32,
+ 0xffffffff,
+ 1 << DxF0x6C_HotplugCapable_OFFSET,
+ GnbLibGetHeader (Pcie)
+ );
+ PciePortRegisterWriteField (
+ Engine,
+ DxF0xE4_x20_ADDRESS,
+ DxF0xE4_x20_TxFlushTlpDis_OFFSET,
+ DxF0xE4_x20_TxFlushTlpDis_WIDTH,
+ 0x0,
+ TRUE,
+ Pcie
+ );
+ PciePortRegisterWriteField (
+ Engine,
+ DxF0xE4_x70_ADDRESS,
+ DxF0xE4_x70_RxRcbCplTimeoutMode_OFFSET,
+ DxF0xE4_x70_RxRcbCplTimeoutMode_WIDTH,
+ 0x1,
+ FALSE,
+ Pcie
+ );
+ }
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Set misc slot capability
+ *
+ *
+ *
+ * @param[in] Engine Pointer to engine config descriptor
+ * @param[in] Pcie Pointer to global PCIe configuration
+ *
+ */
+
+VOID
+PcieLinkSetSlotCap (
+ IN PCIe_ENGINE_CONFIG *Engine,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ GnbLibPciRMW (
+ Engine->Type.Port.Address.AddressValue | DxF0x58_ADDRESS,
+ AccessWidth32,
+ 0xffffffff,
+ 1 << DxF0x58_SlotImplemented_OFFSET,
+ GnbLibGetHeader (Pcie)
+ );
+ GnbLibPciRMW (
+ Engine->Type.Port.Address.AddressValue | DxF0x3C_ADDRESS,
+ AccessWidth32,
+ 0xffffffff,
+ 1 << DxF0x3C_IntPin_OFFSET,
+ GnbLibGetHeader (Pcie)
+ );
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Safe mode to force link advertize Gen1 only capability in TS
+ *
+ *
+ *
+ * @param[in] Engine Pointer to engine config descriptor
+ * @param[in] Pcie Pointer to global PCIe configuration
+ *
+ */
+
+VOID
+PcieLinkSafeMode (
+ IN PCIe_ENGINE_CONFIG *Engine,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ Engine->Type.Port.PortData.LinkSpeedCapability = PcieGen1;
+ PcieSetLinkSpeedCap (PcieGen1, Engine, Pcie);
+ PciePortRegisterRMW (
+ Engine,
+ DxF0xE4_xA2_ADDRESS,
+ DxF0xE4_xA2_LcUpconfigureDis_MASK,
+ (1 << DxF0xE4_xA2_LcUpconfigureDis_OFFSET),
+ FALSE,
+ Pcie
+ );
+}
+
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Set current link speed
+ *
+ *
+ * @param[in] Engine Pointer to engine configuration descriptor
+ * @param[in] Pcie Pointer to global PCIe configuration
+ *
+ */
+VOID
+PcieSetLinkWidthCap (
+ IN PCIe_ENGINE_CONFIG *Engine,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ PciePortRegisterRMW (
+ Engine,
+ DxF0xE4_xA2_ADDRESS,
+ DxF0xE4_xA2_LcUpconfigureDis_MASK,
+ 0,
+ FALSE,
+ Pcie
+ );
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Set current link speed
+ *
+ *
+ * @param[in] LinkSpeedCapability Link Speed Capability
+ * @param[in] Engine Pointer to engine configuration descriptor
+ * @param[in] Pcie Pointer to global PCIe configuration
+ *
+ */
+VOID
+PcieSetLinkSpeedCap (
+ IN PCIE_LINK_SPEED_CAP LinkSpeedCapability,
+ IN PCIe_ENGINE_CONFIG *Engine,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ DxF0xE4_xA4_STRUCT DxF0xE4_xA4;
+ DxF0xE4_xC0_STRUCT DxF0xE4_xC0;
+ DxF0x88_STRUCT DxF0x88;
+ GnbLibPciRead (
+ Engine->Type.Port.Address.AddressValue | DxF0x88_ADDRESS,
+ AccessWidth32,
+ &DxF0x88.Value,
+ GnbLibGetHeader (Pcie)
+ );
+ DxF0xE4_xA4.Value = PciePortRegisterRead (
+ Engine,
+ DxF0xE4_xA4_ADDRESS,
+ Pcie
+ );
+ DxF0xE4_xC0.Value = PciePortRegisterRead (
+ Engine,
+ DxF0xE4_xC0_ADDRESS,
+ Pcie
+ );
+
+ switch (LinkSpeedCapability) {
+ case PcieGen2:
+ DxF0xE4_xA4.Field.LcGen2EnStrap = 0x1;
+ DxF0xE4_xA4.Field.LcMultUpstreamAutoSpdChngEn = 0x1;
+ DxF0xE4_xC0.Field.StrapAutoRcSpeedNegotiationDis = 0x0;
+ DxF0x88.Field.TargetLinkSpeed = 0x2;
+ DxF0x88.Field.HwAutonomousSpeedDisable = 0x0;
+ break;
+ case PcieGen1:
+ DxF0xE4_xA4.Field.LcGen2EnStrap = 0x0;
+ DxF0xE4_xA4.Field.LcMultUpstreamAutoSpdChngEn = 0x0;
+ DxF0xE4_xC0.Field.StrapAutoRcSpeedNegotiationDis = 0x1;
+ DxF0x88.Field.TargetLinkSpeed = 0x1;
+ DxF0x88.Field.HwAutonomousSpeedDisable = 0x1;
+ PcieRegisterWriteField (
+ PcieEngineGetParentWrapper (Engine),
+ WRAP_SPACE (PcieEngineGetParentWrapper (Engine)->WrapId, D0F0xE4_WRAP_0803_ADDRESS + 0x100 * Engine->Type.Port.PortId),
+ D0F0xE4_WRAP_0803_StrapBifDeemphasisSel_OFFSET,
+ D0F0xE4_WRAP_0803_StrapBifDeemphasisSel_WIDTH,
+ 0,
+ FALSE,
+ Pcie
+ );
+ break;
+ default:
+ ASSERT (FALSE);
+ break;
+ }
+ PciePortRegisterWrite (
+ Engine,
+ DxF0xE4_xA4_ADDRESS,
+ DxF0xE4_xA4.Value,
+ FALSE,
+ Pcie
+ );
+ PciePortRegisterWrite (
+ Engine,
+ DxF0xE4_xC0_ADDRESS,
+ DxF0xE4_xC0.Value,
+ FALSE,
+ Pcie
+ );
+ GnbLibPciWrite (
+ Engine->Type.Port.Address.AddressValue | DxF0x88_ADDRESS,
+ AccessWidth32,
+ &DxF0x88.Value,
+ GnbLibGetHeader (Pcie)
+ );
+}
+
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Force compliance
+ *
+ *
+ *
+ * @param[in] Engine Pointer to engine config descriptor
+ * @param[in] Pcie Pointer to global PCIe configuration
+ *
+ */
+
+VOID
+PcieForceCompliance (
+ IN PCIe_ENGINE_CONFIG *Engine,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ if (Engine->Type.Port.PortData.LinkSpeedCapability >= PcieGen2) {
+ GnbLibPciRMW (
+ Engine->Type.Port.Address.AddressValue | DxF0x88_ADDRESS,
+ AccessWidth32,
+ 0xffffffff,
+ 0x1 << DxF0x88_EnterCompliance_OFFSET,
+ GnbLibGetHeader (Pcie)
+ );
+ } else if (Engine->Type.Port.PortData.LinkSpeedCapability == PcieGen1) {
+ PciePortRegisterWriteField (
+ Engine,
+ DxF0xE4_xC0_ADDRESS,
+ DxF0xE4_xC0_StrapForceCompliance_OFFSET,
+ DxF0xE4_xC0_StrapForceCompliance_WIDTH,
+ 0x1,
+ FALSE,
+ Pcie
+ );
+ }
+}
+
diff --git a/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PciePortServices.h b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PciePortServices.h
new file mode 100644
index 0000000000..fe7267731a
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PciePortServices.h
@@ -0,0 +1,101 @@
+/* $NoKeywords:$ */
+/**
+ * @file
+ *
+ * PCIe port initialization service procedure
+ *
+ *
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: GNB
+ * @e \$Revision: 38728 $ @e \$Date: 2010-09-28 14:25:41 -0700 (Tue, 28 Sep 2010) $
+ *
+ */
+/*
+ *****************************************************************************
+ *
+ * Copyright (c) 2011, Advanced Micro Devices, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Advanced Micro Devices, Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***************************************************************************
+ *
+ */
+#ifndef _PCIEPORTSERVICES_H_
+#define _PCIEPORTSERVICES_H_
+
+
+VOID
+PcieSetLinkSpeedCap (
+ IN PCIE_LINK_SPEED_CAP LinkSpeedCapability,
+ IN PCIe_ENGINE_CONFIG *Engine,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ );
+
+VOID
+PcieSetLinkWidthCap (
+ IN PCIe_ENGINE_CONFIG *Engine,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ );
+
+VOID
+PcieLinkSafeMode (
+ IN PCIe_ENGINE_CONFIG *Engine,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ );
+
+VOID
+PcieCompletionTimeout (
+ IN PCIe_ENGINE_CONFIG *Engine,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ );
+
+VOID
+PcieLinkSetSlotCap (
+ IN PCIe_ENGINE_CONFIG *Engine,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ );
+
+VOID
+PcieLinkInitHotplug (
+ IN PCIe_ENGINE_CONFIG *Engine,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ );
+
+VOID
+PcieForceCompliance (
+ IN PCIe_ENGINE_CONFIG *Engine,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ );
+
+VOID
+PciePifSetPllModeForL1 (
+ IN UINT32 LaneBitmap,
+ IN PCIe_WRAPPER_CONFIG *Wrapper,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ );
+#endif
+
+
diff --git a/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PciePowerMgmt.c b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PciePowerMgmt.c
new file mode 100644
index 0000000000..0dae507a47
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PciePowerMgmt.c
@@ -0,0 +1,350 @@
+/* $NoKeywords:$ */
+/**
+ * @file
+ *
+ * Power saving features/services
+ *
+ *
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: GNB
+ * @e \$Revision: 38931 $ @e \$Date: 2010-10-01 15:50:05 -0700 (Fri, 01 Oct 2010) $
+ *
+ */
+/*
+ *****************************************************************************
+ *
+ * Copyright (c) 2011, Advanced Micro Devices, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Advanced Micro Devices, Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***************************************************************************
+ *
+ */
+
+/*----------------------------------------------------------------------------------------
+ * M O D U L E S U S E D
+ *----------------------------------------------------------------------------------------
+ */
+#include "AGESA.h"
+#include "Ids.h"
+#include "amdlib.h"
+#include "Gnb.h"
+#include "GnbPcie.h"
+#include GNB_MODULE_DEFINITIONS (GnbCommonLib)
+#include GNB_MODULE_DEFINITIONS (GnbPcieInitLibV1)
+#include "GnbRegistersON.h"
+#include "Filecode.h"
+#define FILECODE PROC_GNB_MODULES_GNBPCIEINITLIBV1_PCIEPOWERMGMT_FILECODE
+
+/*----------------------------------------------------------------------------------------
+ * D E F I N I T I O N S A N D M A C R O S
+ *----------------------------------------------------------------------------------------
+ */
+
+
+/*----------------------------------------------------------------------------------------
+ * T Y P E D E F S A N D S T R U C T U R E S
+ *----------------------------------------------------------------------------------------
+ */
+
+
+/*----------------------------------------------------------------------------------------
+ * P R O T O T Y P E S O F L O C A L F U N C T I O N S
+ *----------------------------------------------------------------------------------------
+ */
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Power down unused lanes and plls
+ *
+ *
+ * @param[in] Wrapper Pointer to wrapper config descriptor
+ * @param[in] Pcie Pointer to global PCIe configuration
+ */
+
+VOID
+PciePwrPowerDownUnusedLanes (
+ IN PCIe_WRAPPER_CONFIG *Wrapper,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ UINT32 UnusedLanes;
+ IDS_HDT_CONSOLE (GNB_TRACE, "PciePwrPowerDownUnusedLanes Enter\n");
+ UnusedLanes = PcieUtilGetWrapperLaneBitMap (LANE_TYPE_ALL, LANE_TYPE_ACTIVE, Wrapper, Pcie);
+ if (Wrapper->Features.PowerOffUnusedLanes != 0) {
+ PcieTopologyLaneControl (
+ DisableLanes,
+ UnusedLanes,
+ Wrapper,
+ Pcie
+ );
+ }
+ if (Wrapper->Features.PowerOffUnusedPlls != 0) {
+ PciePifPllPowerDown (
+ UnusedLanes,
+ Wrapper,
+ Pcie
+ );
+ }
+ IDS_HDT_CONSOLE (GNB_TRACE, "PciePwrPowerDownUnusedLanes Exit\n");
+}
+
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Lane bitmam to enable PLL power down in L1
+ *
+ *
+ * @param[in] PllPowerUpLatency Pointer to wrapper config descriptor
+ * @param[in] Wrapper Pointer to wrapper config descriptor
+ * @param[in] Pcie Pointer to global PCIe configuration
+ * @retval Lane bitmap for which PLL can be powered down in L1
+ */
+
+UINT32
+PcieLanesToPowerDownPllInL1 (
+ IN UINT8 PllPowerUpLatency,
+ IN PCIe_WRAPPER_CONFIG *Wrapper,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ UINT8 LaneGroupExitLatency [4];
+ UINT32 LaneBitmapForPllOffInL1;
+ PCIe_ENGINE_CONFIG *EngineList;
+ UINTN Index;
+ IDS_HDT_CONSOLE (GNB_TRACE, "PcieLanesToPowerDownPllInL1 Enter\n");
+ LaneBitmapForPllOffInL1 = 0;
+ if (Wrapper->Features.PllOffInL1 != 0) {
+ LibAmdMemFill (&LaneGroupExitLatency[0], 0xFF, sizeof (LaneGroupExitLatency), GnbLibGetHeader (Pcie));
+ EngineList = PcieWrapperGetEngineList (Wrapper);
+ while (EngineList != NULL) {
+ PCIe_ASPM_LATENCY_INFO LinkLatencyInfo;
+ UINT32 ActiveLanesBitmap;
+ UINT32 HotplugLanesBitmap;
+ if (EngineList->EngineData.EngineType == PciePortEngine) {
+ LinkLatencyInfo.MaxL1ExitLatency = 0;
+ LinkLatencyInfo.MaxL0sExitLatency = 0;
+ ActiveLanesBitmap = PcieUtilGetEngineLaneBitMap (LANE_TYPE_PCIE_ACTIVE, 0, EngineList, Pcie);
+ HotplugLanesBitmap = PcieUtilGetEngineLaneBitMap (LANE_TYPE_PCIE_HOTPLUG, 0, EngineList, Pcie);
+ if (ActiveLanesBitmap != 0 && HotplugLanesBitmap == 0 && !EngineList->Type.Port.IsSB) {
+ PcieAspmGetMaxExitLatency (EngineList->Type.Port.Address, &LinkLatencyInfo, GnbLibGetHeader (Pcie));
+ }
+ if (HotplugLanesBitmap != 0 || EngineList->Type.Port.IsSB) {
+ LinkLatencyInfo.MaxL1ExitLatency = 0xff;
+ }
+ IDS_HDT_CONSOLE (GNB_TRACE, " Engine %d Active Lanes 0x%x, Hotplug Lanes 0x%x\n", EngineList->Type.Port.NativeDevNumber, ActiveLanesBitmap, HotplugLanesBitmap);
+ for (Index = 0; Index < 4; Index++) {
+ if ((ActiveLanesBitmap & (0xF << (Index * 4))) != 0) {
+ if (LaneGroupExitLatency [Index] > LinkLatencyInfo.MaxL1ExitLatency) {
+ IDS_HDT_CONSOLE (GNB_TRACE, " Index %d Latency %d\n", Index, LinkLatencyInfo.MaxL1ExitLatency);
+ LaneGroupExitLatency [Index] = LinkLatencyInfo.MaxL1ExitLatency;
+ }
+ }
+ }
+ }
+ EngineList = PcieLibGetNextDescriptor (EngineList);
+ }
+ LaneBitmapForPllOffInL1 = 0;
+ for (Index = 0; Index < 4; Index++) {
+ IDS_HDT_CONSOLE (GNB_TRACE, " Index %d Final Latency %d\n", Index, LaneGroupExitLatency[Index]);
+ if (LaneGroupExitLatency[Index] > PllPowerUpLatency) {
+ LaneBitmapForPllOffInL1 |= (0xF << (Index * 4));
+ }
+ }
+ }
+ IDS_HDT_CONSOLE (GNB_TRACE, " Lane bitmap %04x\n", LaneBitmapForPllOffInL1);
+ IDS_HDT_CONSOLE (GNB_TRACE, "PcieLanesToPowerDownPllInL1 Exit\n");
+ return LaneBitmapForPllOffInL1;
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Auto-Power Down electrical Idle detector
+ *
+ *
+ * @param[in] Wrapper Pointer to wrapper config descriptor
+ * @param[in] Pcie Pointer to global PCIe configuration
+ */
+
+VOID
+PciePwrAutoPowerDownElectricalIdleDetector (
+ IN PCIe_WRAPPER_CONFIG *Wrapper,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ UINT8 Pif;
+ IDS_HDT_CONSOLE (GNB_TRACE, "PciePwrAutoPowerDownElectricalIdleDetector Enter\n");
+ for (Pif = 0; Pif < Wrapper->NumberOfPIFs; Pif++) {
+ PcieRegisterWriteField (
+ Wrapper,
+ PIF_SPACE (Wrapper->WrapId, Pif, D0F0xE4_PIF_0010_ADDRESS),
+ D0F0xE4_PIF_0010_EiDetCycleMode_OFFSET,
+ D0F0xE4_PIF_0010_EiDetCycleMode_WIDTH,
+ 0x0,
+ TRUE,
+ Pcie
+ );
+
+ PcieRegisterWriteField (
+ Wrapper,
+ PIF_SPACE (Wrapper->WrapId, Pif, D0F0xE4_PIF_0010_ADDRESS),
+ D0F0xE4_PIF_0010_EiCycleOffTime_OFFSET,
+ D0F0xE4_PIF_0010_EiCycleOffTime_WIDTH,
+ 0x2,
+ TRUE,
+ Pcie
+ );
+
+ PcieRegisterWriteField (
+ Wrapper,
+ PIF_SPACE (Wrapper->WrapId, Pif, D0F0xE4_PIF_0010_ADDRESS),
+ D0F0xE4_PIF_0010_EiDetCycleMode_OFFSET,
+ D0F0xE4_PIF_0010_EiDetCycleMode_WIDTH,
+ 0x1,
+ TRUE,
+ Pcie
+ );
+ }
+ IDS_HDT_CONSOLE (GNB_TRACE, "PciePwrAutoPowerDownElectricalIdleDetector Exit\n");
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Clock gating
+ *
+ *
+ *
+ * @param[in] Wrapper Pointer to wrapper config descriptor
+ * @param[in] Pcie Pointer to global PCIe configuration
+ */
+
+VOID
+PciePwrClockGating (
+ IN PCIe_WRAPPER_CONFIG *Wrapper,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ D0F0xE4_WRAP_8011_STRUCT D0F0xE4_WRAP_8011;
+ D0F0xE4_WRAP_8012_STRUCT D0F0xE4_WRAP_8012;
+ D0F0xE4_WRAP_8014_STRUCT D0F0xE4_WRAP_8014;
+ D0F0xE4_WRAP_8016_STRUCT D0F0xE4_WRAP_8016;
+ UINT8 CoreId;
+ IDS_HDT_CONSOLE (GNB_TRACE, "PciePwrClockGating Enter\n");
+ D0F0xE4_WRAP_8014.Value = PcieRegisterRead (
+ Wrapper,
+ WRAP_SPACE (Wrapper->WrapId, D0F0xE4_WRAP_8014_ADDRESS),
+ Pcie
+ );
+ D0F0xE4_WRAP_8012.Value = PcieRegisterRead (
+ Wrapper,
+ WRAP_SPACE (Wrapper->WrapId, D0F0xE4_WRAP_8012_ADDRESS),
+ Pcie
+ );
+
+ D0F0xE4_WRAP_8011.Value = PcieRegisterRead (
+ Wrapper,
+ WRAP_SPACE (Wrapper->WrapId, D0F0xE4_WRAP_8011_ADDRESS),
+ Pcie
+ );
+
+ if (Wrapper->Features.ClkGating == 0x1) {
+ D0F0xE4_WRAP_8014.Field.TxclkPermGateEnable = 0x1;
+ D0F0xE4_WRAP_8014.Field.TxclkPrbsGateEnable = 0x1;
+
+ D0F0xE4_WRAP_8014.Field.PcieGatePifA1xEnable = 0x1;
+ D0F0xE4_WRAP_8014.Field.PcieGatePifA2p5xEnable = 0x1;
+
+ D0F0xE4_WRAP_8011.Field.TxclkDynGateEnable = 0x1;
+ D0F0xE4_WRAP_8011.Field.TxclkRegsGateEnable = 0x1;
+ D0F0xE4_WRAP_8011.Field.TxclkLcntGateEnable = 0x1;
+ D0F0xE4_WRAP_8011.Field.RcvrDetClkEnable = 0x1;
+ D0F0xE4_WRAP_8011.Field.TxclkPermGateEven = 0x1;
+ D0F0xE4_WRAP_8011.Field.TxclkDynGateLatency = 0x3f;
+ D0F0xE4_WRAP_8011.Field.TxclkRegsGateLatency = 0x3f;
+ D0F0xE4_WRAP_8011.Field.TxclkPermGateLatency = 0x3f;
+
+ D0F0xE4_WRAP_8012.Field.Pif2p5xIdleResumeLatency = 0x7;
+ D0F0xE4_WRAP_8012.Field.Pif2p5xIdleGateEnable = 0x1;
+ D0F0xE4_WRAP_8012.Field.Pif2p5xIdleGateLatency = 0x1;
+ D0F0xE4_WRAP_8012.Field.Pif1xIdleResumeLatency = 0x7;
+ D0F0xE4_WRAP_8012.Field.Pif1xIdleGateEnable = 0x1;
+ D0F0xE4_WRAP_8012.Field.Pif1xIdleGateLatency = 0x1;
+ }
+ if (Wrapper->Features.TxclkGatingPllPowerDown == 0x1) {
+ D0F0xE4_WRAP_8014.Field.TxclkPermGateOnlyWhenPllPwrDn = 0x1;
+ }
+ PcieRegisterWrite (
+ Wrapper,
+ WRAP_SPACE (Wrapper->WrapId, D0F0xE4_WRAP_8014_ADDRESS),
+ D0F0xE4_WRAP_8014.Value,
+ TRUE,
+ Pcie
+ );
+ PcieRegisterWrite (
+ Wrapper,
+ WRAP_SPACE (Wrapper->WrapId, D0F0xE4_WRAP_8012_ADDRESS),
+ D0F0xE4_WRAP_8012.Value,
+ TRUE,
+ Pcie
+ );
+ PcieRegisterWrite (
+ Wrapper,
+ WRAP_SPACE (Wrapper->WrapId, D0F0xE4_WRAP_8011_ADDRESS),
+ D0F0xE4_WRAP_8011.Value,
+ TRUE,
+ Pcie
+ );
+ for (CoreId = Wrapper->StartPcieCoreId; CoreId <= Wrapper->EndPcieCoreId; CoreId++) {
+ PcieRegisterWriteField (
+ Wrapper,
+ CORE_SPACE (CoreId, D0F0xE4_CORE_0011_ADDRESS),
+ D0F0xE4_CORE_0011_DynClkLatency_OFFSET,
+ D0F0xE4_CORE_0011_DynClkLatency_WIDTH,
+ 0xf,
+ TRUE,
+ Pcie
+ );
+ }
+ if (Wrapper->Features.LclkGating == 0x1) {
+ D0F0xE4_WRAP_8016.Value = PcieRegisterRead (
+ Wrapper,
+ WRAP_SPACE (Wrapper->WrapId, D0F0xE4_WRAP_8016_ADDRESS),
+ Pcie
+ );
+ D0F0xE4_WRAP_8016.Field.LclkDynGateEnable = 0x1;
+ D0F0xE4_WRAP_8016.Field.LclkGateFree = 0x1;
+ PcieRegisterWrite (
+ Wrapper,
+ WRAP_SPACE (Wrapper->WrapId, D0F0xE4_WRAP_8016_ADDRESS),
+ D0F0xE4_WRAP_8016.Value,
+ TRUE,
+ Pcie
+ );
+ }
+ IDS_HDT_CONSOLE (GNB_TRACE, "PciePwrClockGating Exit\n");
+}
+
+
diff --git a/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PciePowerMgmt.h b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PciePowerMgmt.h
new file mode 100644
index 0000000000..2a17d56803
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PciePowerMgmt.h
@@ -0,0 +1,75 @@
+/* $NoKeywords:$ */
+/**
+ * @file
+ *
+ * Power saving features/services
+ *
+ *
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: GNB
+ * @e \$Revision: 34897 $ @e \$Date: 2010-07-13 19:07:10 -0700 (Tue, 13 Jul 2010) $
+ *
+ */
+/*
+ *****************************************************************************
+ *
+ * Copyright (c) 2011, Advanced Micro Devices, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Advanced Micro Devices, Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***************************************************************************
+ *
+ */
+#ifndef _PCIEPOWERSAVINGFEATURES_H_
+#define _PCIEPOWERSAVINGFEATURES_H_
+
+
+VOID
+PciePwrPowerDownUnusedLanes (
+ IN PCIe_WRAPPER_CONFIG *Wrapper,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ );
+
+UINT32
+PcieLanesToPowerDownPllInL1 (
+ IN UINT8 PllPowerUpLatency,
+ IN PCIe_WRAPPER_CONFIG *Wrapper,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ );
+
+VOID
+PciePwrAutoPowerDownElectricalIdleDetector (
+ IN PCIe_WRAPPER_CONFIG *Wrapper,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ );
+
+VOID
+PciePwrClockGating (
+ IN PCIe_WRAPPER_CONFIG *Wrapper,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ );
+
+#endif
diff --git a/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PcieSbLink.c b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PcieSbLink.c
new file mode 100644
index 0000000000..122a9e305b
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PcieSbLink.c
@@ -0,0 +1,221 @@
+/* $NoKeywords:$ */
+/**
+ * @file
+ *
+ * GNB-SB link procedure
+ *
+ *
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: GNB
+ * @e \$Revision: 38931 $ @e \$Date: 2010-10-01 15:50:05 -0700 (Fri, 01 Oct 2010) $
+ *
+ */
+/*
+ *****************************************************************************
+ *
+ * Copyright (c) 2011, Advanced Micro Devices, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Advanced Micro Devices, Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***************************************************************************
+ *
+ */
+
+/*----------------------------------------------------------------------------------------
+ * M O D U L E S U S E D
+ *----------------------------------------------------------------------------------------
+ */
+#include "AGESA.h"
+#include "Ids.h"
+#include "amdlib.h"
+#include "Gnb.h"
+#include "GnbPcie.h"
+#include GNB_MODULE_DEFINITIONS (GnbCommonLib)
+#include GNB_MODULE_DEFINITIONS (GnbPcieInitLibV1)
+#include "GnbRegistersON.h"
+#include "Filecode.h"
+#define FILECODE PROC_GNB_MODULES_GNBPCIEINITLIBV1_PCIESBLINK_FILECODE
+/*----------------------------------------------------------------------------------------
+ * D E F I N I T I O N S A N D M A C R O S
+ *----------------------------------------------------------------------------------------
+ */
+
+
+/*----------------------------------------------------------------------------------------
+ * T Y P E D E F S A N D S T R U C T U R E S
+ *----------------------------------------------------------------------------------------
+ */
+
+
+/*----------------------------------------------------------------------------------------
+ * P R O T O T Y P E S O F L O C A L F U N C T I O N S
+ *----------------------------------------------------------------------------------------
+ */
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Enable/Disable ASPM on GNB-SB link
+ *
+ *
+ *
+ * @param[in] Engine Pointer to engine config descriptor
+ * @param[in] Pcie Pointer to global PCIe configuration
+ *
+ */
+
+AGESA_STATUS
+PcieSbLinkAspmControl (
+ IN PCIe_ENGINE_CONFIG *Engine,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ AGESA_STATUS Status;
+ UINT8 NbAspm;
+
+ Status = PcieSbInitAspm (Engine->Type.Port.PortData.LinkAspm, GnbLibGetHeader (Pcie));
+ if (Status != AGESA_SUCCESS) {
+ return AGESA_UNSUPPORTED;
+ }
+
+ NbAspm = Engine->Type.Port.PortData.LinkAspm;
+
+ PcieNbAspmEnable (Engine->Type.Port.Address, NbAspm, GnbLibGetHeader (Pcie));
+ return AGESA_SUCCESS;
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Init SB ASPM.
+ * Enable ASPM states on SB
+ *
+ *
+ * @param[in] Aspm ASPM bitmap.
+ * @param[in] StdHeader Standard configuration header
+ */
+/*----------------------------------------------------------------------------------------*/
+
+AGESA_STATUS
+PcieSbInitAspm (
+ IN PCIE_ASPM_TYPE Aspm,
+ IN AMD_CONFIG_PARAMS *StdHeader
+ )
+{
+ AGESA_STATUS Status;
+ UINT16 AlinkPort;
+
+ Status = PcieSbAgetAlinkIoAddress (&AlinkPort, StdHeader);
+ if (Status != AGESA_SUCCESS) {
+ return Status;
+ }
+ GnbLibIoRMW (AlinkPort, AccessS3SaveWidth32, 0x0, 0x40000038, StdHeader);
+ GnbLibIoRMW (AlinkPort + 4, AccessS3SaveWidth32, 0x0, 0xA0, StdHeader);
+ GnbLibIoRMW (AlinkPort, AccessS3SaveWidth32, 0x0, 0x4000003c, StdHeader);
+ GnbLibIoRMW (AlinkPort + 4, AccessS3SaveWidth32, 0xffff00ff, 0x6900, StdHeader);
+ GnbLibIoRMW (AlinkPort, AccessS3SaveWidth32, 0x0, 0x80000068, StdHeader);
+ GnbLibIoRMW (AlinkPort + 4, AccessS3SaveWidth32, 0xfffffffc, Aspm, StdHeader);
+ return AGESA_SUCCESS;
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Get Alink config address
+ *
+ *
+ */
+/*----------------------------------------------------------------------------------------*/
+
+AGESA_STATUS
+PcieSbAgetAlinkIoAddress (
+ OUT UINT16 *AlinkPort,
+ IN AMD_CONFIG_PARAMS *StdHeader
+ )
+{
+ UINT8 AlinkPortIndex;
+ AlinkPortIndex = 0xE0;
+ GnbLibIoWrite (0xCD6, AccessWidth8, &AlinkPortIndex, StdHeader);
+ GnbLibIoRead (0xCD7, AccessWidth8, AlinkPort, StdHeader);
+ AlinkPortIndex = 0xE1;
+ GnbLibIoWrite (0xCD6, AccessWidth8, &AlinkPortIndex, StdHeader);
+ GnbLibIoRead (0xCD7, AccessWidth8, (VOID*) ((UINT8*) AlinkPort + 1), StdHeader);
+ if (&AlinkPort == 0) {
+ return AGESA_UNSUPPORTED;
+ }
+ return AGESA_SUCCESS;
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Set ASMP State on PCIe device function
+ *
+ *
+ *
+ * @param[in] Function PCI address of function.
+ * @param[in] Aspm ASPM bitmap.
+ * @param[in] StdHeader Standard configuration header
+ *
+ */
+ /*----------------------------------------------------------------------------------------*/
+
+VOID
+PcieNbAspmEnable (
+ IN PCI_ADDR Function,
+ IN PCIE_ASPM_TYPE Aspm,
+ IN AMD_CONFIG_PARAMS *StdHeader
+ )
+{
+ UINT8 PcieCapPtr;
+ PcieCapPtr = GnbLibFindPciCapability (Function.AddressValue, PCIE_CAP_ID, StdHeader);
+ if (PcieCapPtr != 0) {
+ GnbLibPciRMW (
+ Function.AddressValue | (PcieCapPtr + PCIE_LINK_CTRL_REGISTER) ,
+ AccessS3SaveWidth8,
+ ~(BIT0 | BIT1),
+ Aspm,
+ StdHeader
+ );
+ }
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Enable VC on GNB-SB link
+ *
+ *
+ *
+ * @param[in] Engine Pointer to engine config descriptor
+ * @param[in] Pcie Pointer to global PCIe configuration
+ *
+ */
+
+VOID
+PcieSbLinkVcEnable (
+ IN PCIe_ENGINE_CONFIG *Engine,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+
+}
+
diff --git a/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PcieSbLink.h b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PcieSbLink.h
new file mode 100644
index 0000000000..e389faa56c
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PcieSbLink.h
@@ -0,0 +1,83 @@
+/* $NoKeywords:$ */
+/**
+ * @file
+ *
+ * GNB-SB link procedure
+ *
+ *
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: GNB
+ * @e \$Revision: 34897 $ @e \$Date: 2010-07-13 19:07:10 -0700 (Tue, 13 Jul 2010) $
+ *
+ */
+/*
+ *****************************************************************************
+ *
+ * Copyright (c) 2011, Advanced Micro Devices, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Advanced Micro Devices, Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***************************************************************************
+ *
+ */
+#ifndef _PCIESBLINK_H_
+#define _PCIESBLINK_H_
+
+
+
+
+AGESA_STATUS
+PcieSbLinkAspmControl (
+ IN PCIe_ENGINE_CONFIG *Engine,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ );
+
+VOID
+PcieSbLinkVcEnable (
+ IN PCIe_ENGINE_CONFIG *Engine,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ );
+
+AGESA_STATUS
+PcieSbInitAspm (
+ IN PCIE_ASPM_TYPE Aspm,
+ IN AMD_CONFIG_PARAMS *StdHeader
+ );
+
+AGESA_STATUS
+PcieSbAgetAlinkIoAddress (
+ OUT UINT16 *AlinkPort,
+ IN AMD_CONFIG_PARAMS *StdHeader
+ );
+
+VOID
+PcieNbAspmEnable (
+ IN PCI_ADDR Function,
+ IN PCIE_ASPM_TYPE Aspm,
+ IN AMD_CONFIG_PARAMS *StdHeader
+ );
+
+#endif
diff --git a/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PcieSiliconServices.c b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PcieSiliconServices.c
new file mode 100644
index 0000000000..c298337840
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PcieSiliconServices.c
@@ -0,0 +1,255 @@
+/* $NoKeywords:$ */
+/**
+ * @file
+ *
+ * Family specific PCIe complex initialization services
+ *
+ *
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: GNB
+ * @e \$Revision: 34930 $ @e \$Date: 2010-07-14 02:57:05 -0700 (Wed, 14 Jul 2010) $
+ *
+ */
+/*
+ *****************************************************************************
+ *
+ * Copyright (c) 2011, Advanced Micro Devices, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Advanced Micro Devices, Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***************************************************************************
+ *
+ */
+/*----------------------------------------------------------------------------------------
+ * M O D U L E S U S E D
+ *----------------------------------------------------------------------------------------
+ */
+#include "AGESA.h"
+#include "Ids.h"
+#include "amdlib.h"
+#include "Gnb.h"
+#include "GnbPcie.h"
+#include GNB_MODULE_DEFINITIONS (GnbCommonLib)
+#include GNB_MODULE_DEFINITIONS (GnbPcieConfig)
+#include GNB_MODULE_DEFINITIONS (GnbPcieInitLibV1)
+#include "GnbRegistersON.h"
+#include "Filecode.h"
+#define FILECODE PROC_GNB_MODULES_GNBPCIEINITLIBV1_PCIESILICONSERVICES_FILECODE
+/*----------------------------------------------------------------------------------------
+ * D E F I N I T I O N S A N D M A C R O S
+ *----------------------------------------------------------------------------------------
+ */
+
+/*----------------------------------------------------------------------------------------
+ * T Y P E D E F S A N D S T R U C T U R E S
+ *----------------------------------------------------------------------------------------
+ */
+
+
+/*----------------------------------------------------------------------------------------
+ * P R O T O T Y P E S O F L O C A L F U N C T I O N S
+ *----------------------------------------------------------------------------------------
+ */
+
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Get Gen1 voltage Index
+ *
+ *
+ *
+ *
+ * @param[in] StdHeader Standard configuration header
+ */
+UINT8
+PcieSiliconGetGen1VoltageIndex (
+ IN AMD_CONFIG_PARAMS *StdHeader
+ )
+{
+ UINT8 Index;
+ UINT8 Gen1VidIndex;
+ UINT8 SclkVidArray[4];
+ GnbLibPciRead (
+ MAKE_SBDFO ( 0, 0, 0x18, 3, D18F3x15C_ADDRESS),
+ AccessWidth32,
+ &SclkVidArray[0],
+ StdHeader
+ );
+ Gen1VidIndex = 0;
+ for (Index = 0; Index < 4; Index++) {
+ if (SclkVidArray[Index] > SclkVidArray[Gen1VidIndex]) {
+ Gen1VidIndex = Index;
+ }
+ }
+ return Gen1VidIndex;
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Request Pcie voltage change
+ *
+ *
+ *
+ * @param[in] VidIndex The request VID index
+ * @param[in] StdHeader Standard configuration header
+ */
+VOID
+PcieSiliconRequestVoltage (
+ IN UINT8 VidIndex,
+ IN AMD_CONFIG_PARAMS *StdHeader
+ )
+{
+ D0F0x64_x6A_STRUCT D0F0x64_x6A;
+ D0F0x64_x6B_STRUCT D0F0x64_x6B;
+
+ //Enable voltage client
+ GnbLibPciIndirectRead (
+ MAKE_SBDFO (0, 0, 0, 0, D0F0x60_ADDRESS),
+ D0F0x64_x6A_ADDRESS | IOC_WRITE_ENABLE,
+ AccessS3SaveWidth32,
+ &D0F0x64_x6A.Value,
+ StdHeader
+ );
+
+ D0F0x64_x6A.Field.VoltageChangeEn = 0x1;
+
+ GnbLibPciIndirectWrite (
+ MAKE_SBDFO (0, 0, 0, 0, D0F0x60_ADDRESS),
+ D0F0x64_x6A_ADDRESS | IOC_WRITE_ENABLE,
+ AccessS3SaveWidth32,
+ &D0F0x64_x6A.Value,
+ StdHeader
+ );
+
+ D0F0x64_x6A.Field.VoltageLevel = VidIndex;
+ D0F0x64_x6A.Field.VoltageChangeReq = !D0F0x64_x6A.Field.VoltageChangeReq;
+
+ GnbLibPciIndirectWrite (
+ MAKE_SBDFO (0, 0, 0, 0, D0F0x60_ADDRESS),
+ D0F0x64_x6A_ADDRESS | IOC_WRITE_ENABLE,
+ AccessS3SaveWidth32,
+ &D0F0x64_x6A.Value,
+ StdHeader
+ );
+ do {
+ GnbLibPciIndirectRead (
+ MAKE_SBDFO (0, 0, 0, 0, D0F0x60_ADDRESS),
+ D0F0x64_x6B_ADDRESS | IOC_WRITE_ENABLE,
+ AccessS3SaveWidth32,
+ &D0F0x64_x6B.Value,
+ StdHeader
+ );
+ } while (D0F0x64_x6A.Field.VoltageChangeReq != D0F0x64_x6B.Field.VoltageChangeAck);
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Unhide all ports
+ *
+ *
+ *
+ * @param[in] Silicon Pointer to silicon configuration descriptor
+ * @param[in] Pcie Pointer to global PCIe configuration
+ */
+
+VOID
+PcieSiliconUnHidePorts (
+ IN PCIe_SILICON_CONFIG *Silicon,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ GnbLibPciIndirectRMW (
+ Silicon->Address.AddressValue | D0F0x60_ADDRESS,
+ D0F0x64_x0C_ADDRESS | IOC_WRITE_ENABLE,
+ AccessS3SaveWidth32,
+ ~(BIT2 | BIT3 | BIT4 | BIT5 | BIT6 | BIT7),
+ 0x0,
+ GnbLibGetHeader (Pcie)
+ );
+ GnbLibPciIndirectRMW (
+ Silicon->Address.AddressValue | D0F0x60_ADDRESS,
+ D0F0x64_x00_ADDRESS | IOC_WRITE_ENABLE,
+ AccessS3SaveWidth32,
+ ~BIT6,
+ BIT6,
+ GnbLibGetHeader (Pcie)
+ );
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Hide unused ports
+ *
+ *
+ *
+ * @param[in] Silicon Pointer to silicon configuration data area
+ * @param[in] Pcie Pointer to data area up to 256 byte
+ */
+
+VOID
+PcieSiliconHidePorts (
+ IN PCIe_SILICON_CONFIG *Silicon,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ D0F0x64_x0C_STRUCT D0F0x64_x0C;
+ PCIe_WRAPPER_CONFIG *WrapperList;
+ D0F0x64_x0C.Value = 0;
+ WrapperList = PcieSiliconGetWrapperList (Silicon);
+ while (WrapperList != NULL) {
+ PCIe_ENGINE_CONFIG *EngineList;
+ EngineList = PcieWrapperGetEngineList (WrapperList);
+ while (EngineList != NULL) {
+ if (EngineList->EngineData.EngineType == PciePortEngine) {
+ if (!PcieConfigCheckPortStatus (EngineList, INIT_STATUS_PCIE_TRAINING_SUCCESS) &&
+ ((EngineList->Type.Port.PortData.LinkHotplug == HotplugDisabled) || (EngineList->Type.Port.PortData.LinkHotplug == HotplugInboard)) &&
+ !EngineList->Type.Port.IsSB) {
+ D0F0x64_x0C.Value |= 1 << EngineList->Type.Port.NativeDevNumber;
+ }
+ }
+ EngineList = PcieLibGetNextDescriptor (EngineList);
+ }
+ WrapperList = PcieLibGetNextDescriptor (WrapperList);
+ }
+
+ GnbLibPciIndirectRMW (
+ Silicon->Address.AddressValue | D0F0x60_ADDRESS,
+ D0F0x64_x0C_ADDRESS | IOC_WRITE_ENABLE,
+ AccessS3SaveWidth32,
+ ~(BIT2 | BIT3 | BIT4 | BIT5 | BIT6 | BIT7),
+ D0F0x64_x0C.Value,
+ GnbLibGetHeader (Pcie)
+ );
+ GnbLibPciIndirectRMW (
+ Silicon->Address.AddressValue | D0F0x60_ADDRESS,
+ D0F0x64_x00_ADDRESS | IOC_WRITE_ENABLE,
+ AccessS3SaveWidth32,
+ ~BIT6,
+ 0x0,
+ GnbLibGetHeader (Pcie)
+ );
+}
+
diff --git a/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PcieSiliconServices.h b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PcieSiliconServices.h
new file mode 100644
index 0000000000..2169e4993b
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PcieSiliconServices.h
@@ -0,0 +1,73 @@
+/* $NoKeywords:$ */
+/**
+ * @file
+ *
+ * PCIe Complex Services
+ *
+ *
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: GNB
+ * @e \$Revision: 34897 $ @e \$Date: 2010-07-13 19:07:10 -0700 (Tue, 13 Jul 2010) $
+ *
+ */
+/*
+ *****************************************************************************
+ *
+ * Copyright (c) 2011, Advanced Micro Devices, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Advanced Micro Devices, Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***************************************************************************
+ *
+ */
+
+#ifndef _PCIESILICONSERVICES_H_
+#define _PCIESILICONSERVICES_H_
+
+UINT8
+PcieSiliconGetGen1VoltageIndex (
+ IN AMD_CONFIG_PARAMS *StdHeader
+ );
+
+VOID
+PcieSiliconRequestVoltage (
+ IN UINT8 VidIndex,
+ IN AMD_CONFIG_PARAMS *StdHeader
+ );
+
+VOID
+PcieSiliconUnHidePorts (
+ IN PCIe_SILICON_CONFIG *Silicon,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ );
+
+VOID
+PcieSiliconHidePorts (
+ IN PCIe_SILICON_CONFIG *Silicon,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ );
+
+#endif
diff --git a/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PcieSmuLib.esl b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PcieSmuLib.esl
new file mode 100644
index 0000000000..5ca83524a4
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PcieSmuLib.esl
@@ -0,0 +1,217 @@
+/**
+ * @file
+ *
+ * ALIB PSPP Pcie Smu Lib V1
+ *
+ *
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: GNB
+ * @e \$Revision: 25430 $ @e \$Date: 2010-01-18 22:25:55 -0800 (Mon, 18 Jan 2010) $
+ *
+ */
+/*
+ *****************************************************************************
+ *
+ * Copyright (c) 2011, Advanced Micro Devices, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Advanced Micro Devices, Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***************************************************************************
+ *
+ */
+ /*----------------------------------------------------------------------------------------*/
+ /**
+ * SMU indirect register read
+ *
+ * Arg0 - Smu register offset
+ *
+ */
+ Method (procNbSmuIndirectRegisterRead, 1, NotSerialized) {
+ Store (procIndirectRegisterRead (0x0, 0x60, 0xCD), Local0)
+ // Access 32 bit width
+ Increment (Arg0)
+ // Reverse ReqToggle
+ Or (And (Local0, 0xFEFFFFFF), And (Not (And (Local0, 0x01000000)), 0x01000000),Local0)
+ // Assign Address and ReqType = 0
+ Or (And (Local0, 0xFD00FFFF), ShiftLeft (Arg0, 16), Local0)
+
+ procIndirectRegisterWrite (0x0, 0x60, 0xCD, Local0)
+
+ Store (procIndirectRegisterRead (0x0, 0x60, 0xCE), Local0)
+ return (Local0)
+ }
+
+ /*----------------------------------------------------------------------------------------*/
+ /**
+ * SMU indirect register Write
+ *
+ * Arg0 - Smu register offset
+ * Arg1 - Value
+ * Arg2 - Width, 0 = 16, 1 = 32
+ *
+ */
+ Method (procNbSmuIndirectRegisterWrite, 3, NotSerialized) {
+ Store (procIndirectRegisterRead (0x0, 0x60, 0xCD), Local0)
+ // Get low 16 bit value
+ Store (And (Arg1, 0xFFFF), Local1)
+ // Reverse ReqToggle
+ Or (And (Local0, 0xFEFFFFFF), And (Not (And (Local0, 0x01000000)), 0x01000000),Local0)
+ // Assign Address
+ Or (And (Local0, 0xFD000000), ShiftLeft (Arg0, 16), Local0)
+ // ReqType = 1
+ Or (Local0, 0x02000000, Local0)
+ // Assign Low 16 bit value
+ Or (Local0, Local1, Local0)
+
+ procIndirectRegisterWrite (0x0, 0x60, 0xCD, Local0)
+
+ if (LEqual (Arg2, 1)) {
+ // Get high 16 bit value
+ Store (ShiftRight (Arg1, 16), Local1)
+ // Reverse ReqToggle
+ Or (And (Local0, 0xFEFFFFFF), And (Not (And (Local0, 0x01000000)), 0x01000000),Local0)
+ // Assign Address
+ Or (And (Local0, 0xFF000000), ShiftLeft (Add (Arg0, 1), 16), Local0)
+ // Assign High 16 bit value
+ Or (Local0, Local1, Local0)
+
+ procIndirectRegisterWrite (0x0, 0x60, 0xCD, Local0)
+ }
+
+ }
+
+ /*----------------------------------------------------------------------------------------*/
+ /**
+ * SMU Service request
+ *
+ * Arg0 - Smu service id
+ * Arg1 - Flags - Poll Ack = 1, Poll down = 2
+ *
+ */
+ Method (procNbSmuServiceRequest, 2, NotSerialized) {
+ Store ("NbSmuServiceRequest Enter", Debug)
+ Store ("Request id =", Debug)
+ Store (Arg0, Debug)
+
+ Or (ShiftLeft (Arg0, 3), 0x1, Local0)
+ procNbSmuIndirectRegisterWrite (0x3, Local0, 1)
+
+ if (LAnd (Arg1, 1)) {
+ while (LNotEqual (AND(procNbSmuIndirectRegisterRead (0x3), 0x2), 0x2)) {
+ Store ("--Wait Ack--", Debug)
+ }
+ }
+ if (LAnd (Arg1, 2)) {
+ while (LNotEqual (AND(procNbSmuIndirectRegisterRead (0x3), 0x4), 0x4)) {
+ Store ("--Wait Done--", Debug)
+ }
+ }
+ // Clear IRQ register
+ procNbSmuIndirectRegisterWrite (0x3, 0, 0)
+ Store ("NbSmuServiceRequest Exit", Debug)
+ }
+
+ /*----------------------------------------------------------------------------------------*/
+ /**
+ * Write RCU register
+ *
+ * Arg0 - Register Address
+ * Arg1 - Register Data
+ *
+ */
+ Method (procSmuRcuWrite, 2, NotSerialized) {
+ procNbSmuIndirectRegisterWrite (0xB, Arg0, 0)
+ procNbSmuIndirectRegisterWrite (0x5, Arg1, 1)
+
+ }
+
+ /*----------------------------------------------------------------------------------------*/
+ /**
+ * Read RCU register
+ *
+ * Arg0 - Register Address
+ * Retval - RCU register value
+ */
+ Method (procSmuRcuRead, 1, NotSerialized) {
+ procNbSmuIndirectRegisterWrite (0xB, Arg0, 0)
+ Store (procNbSmuIndirectRegisterRead (0x5), Local0)
+ return (Local0)
+ }
+
+ /*----------------------------------------------------------------------------------------*/
+ /**
+ * SMU SRBM Register Read
+ *
+ * Arg0 - FCR register address
+ *
+ */
+ Method (procNbSmuSrbmRegisterRead, 1, NotSerialized) {
+ //SMUx0B_x8600
+ Store (Or (And (Arg0, 0xFF), 0x01865000), Local0)
+ //SMUx0B_x8604
+ Store (Or (And (Arg0, 0xFFFFFF00), 4), Local1)
+ //SMUx0B_x8608
+ Store (Or (ShiftLeft (3, 30), ShiftLeft (1, 18)), Local2)
+ //Write SMU RCU
+ procSmuRcuWrite (0x8600, Local0)
+ procSmuRcuWrite (0x8604, Local1)
+ procSmuRcuWrite (0x8608, Local2)
+ // ServiceId
+ if (LEqual (ShiftRight (Arg0, 16), 0xFE00)) {
+ procNbSmuServiceRequest (0xD, 0x3)
+ }
+ if (LEqual (ShiftRight (Arg0, 16), 0xFE30)) {
+ procNbSmuServiceRequest (0xB, 0x3)
+ }
+ return (procSmuRcuRead(0x8650))
+ }
+
+
+ /*----------------------------------------------------------------------------------------*/
+ /**
+ * SMU SRBM Register Write
+ *
+ * Arg0 - FCR register address
+ * Arg1 - Value
+ *
+ */
+ Method (procNbSmuSrbmRegisterWrite, 2, NotSerialized) {
+ //SMUx0B_x8600
+ Store (Or (And (Arg0, 0xFF), 0x01865000), Local0)
+ //SMUx0B_x8604
+ Store (Or (And (Arg0, 0xFFFFFF00), 4), Local1)
+ //SMUx0B_x8608
+ Store (Or (ShiftLeft (3, 30), ShiftLeft (1, 18)), Local2)
+ Or (Local2, ShiftLeft (1, 16), Local2)
+ //Write SMU RCU
+ procSmuRcuWrite (0x8600, Local0)
+ procSmuRcuWrite (0x8604, Local1)
+ procSmuRcuWrite (0x8608, Local2)
+ //Write Data
+ procSmuRcuWrite (0x8650, Arg1)
+ // ServiceId
+ procNbSmuServiceRequest (0xB, 0x3)
+ }
diff --git a/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PcieTimer.c b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PcieTimer.c
new file mode 100644
index 0000000000..0abd677486
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PcieTimer.c
@@ -0,0 +1,100 @@
+/* $NoKeywords:$ */
+/**
+ * @file
+ *
+ * PCIe timer access procedure
+ *
+ *
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: GNB
+ * @e \$Revision: 38931 $ @e \$Date: 2010-10-01 15:50:05 -0700 (Fri, 01 Oct 2010) $
+ *
+ */
+/*
+ *****************************************************************************
+ *
+ * Copyright (c) 2011, Advanced Micro Devices, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Advanced Micro Devices, Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***************************************************************************
+ *
+ */
+
+/*----------------------------------------------------------------------------------------
+ * M O D U L E S U S E D
+ *----------------------------------------------------------------------------------------
+ */
+#include "AGESA.h"
+#include "Ids.h"
+#include "amdlib.h"
+#include "Gnb.h"
+#include "GnbPcie.h"
+#include GNB_MODULE_DEFINITIONS (GnbCommonLib)
+#include GNB_MODULE_DEFINITIONS (GnbPcieInitLibV1)
+#include "GnbRegistersON.h"
+#include "Filecode.h"
+#define FILECODE PROC_GNB_MODULES_GNBPCIEINITLIBV1_PCIETIMER_FILECODE
+/*----------------------------------------------------------------------------------------
+ * D E F I N I T I O N S A N D M A C R O S
+ *----------------------------------------------------------------------------------------
+ */
+
+
+/*----------------------------------------------------------------------------------------
+ * T Y P E D E F S A N D S T R U C T U R E S
+ *----------------------------------------------------------------------------------------
+ */
+
+
+/*----------------------------------------------------------------------------------------
+ * P R O T O T Y P E S O F L O C A L F U N C T I O N S
+ *----------------------------------------------------------------------------------------
+ */
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Get PCIe timer timestamp
+ *
+ *
+ *
+ * @param[in] Pcie Pointer to internal configuration data area
+ * @retval Time stamp value
+ */
+
+UINT32
+PcieTimerGetTimeStamp (
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ D0F0xE4_WRAP_80F0_STRUCT D0F0xE4_WRAP_80F0;
+ D0F0xE4_WRAP_80F0.Value = PcieRegisterRead (
+ (PCIe_WRAPPER_CONFIG *)(((PCIe_SILICON_CONFIG *)(Pcie->ComplexList->SiliconList))->WrapperList),
+ WRAP_SPACE (0, D0F0xE4_WRAP_80F0_ADDRESS),
+ Pcie
+ );
+ return D0F0xE4_WRAP_80F0.Value;
+} \ No newline at end of file
diff --git a/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PcieTimer.h b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PcieTimer.h
new file mode 100644
index 0000000000..e00cc1c010
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PcieTimer.h
@@ -0,0 +1,56 @@
+/* $NoKeywords:$ */
+/**
+ * @file
+ *
+ * PCIe timer access procedure
+ *
+ *
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: GNB
+ * @e \$Revision: 34897 $ @e \$Date: 2010-07-13 19:07:10 -0700 (Tue, 13 Jul 2010) $
+ *
+ */
+/*
+ *****************************************************************************
+ *
+ * Copyright (c) 2011, Advanced Micro Devices, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Advanced Micro Devices, Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***************************************************************************
+ *
+ */
+#ifndef _PCIETIMER_H_
+#define _PCIETIMER_H_
+
+UINT32
+PcieTimerGetTimeStamp (
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ );
+
+#define TIMESTAMPS_DELTA(Time2, Time1) ((Time2 > Time1) ? (Time2 - Time1) : (0xffffffffull - Time1 + Time2))
+
+#endif
diff --git a/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PcieTopologyServices.c b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PcieTopologyServices.c
new file mode 100644
index 0000000000..2bddde40f1
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PcieTopologyServices.c
@@ -0,0 +1,692 @@
+/* $NoKeywords:$ */
+/**
+ * @file
+ *
+ * PCIe topology initialization service procedures.
+ *
+ *
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: GNB
+ * @e \$Revision: 38931 $ @e \$Date: 2010-10-01 15:50:05 -0700 (Fri, 01 Oct 2010) $
+ *
+ */
+/*
+ *****************************************************************************
+ *
+ * Copyright (c) 2011, Advanced Micro Devices, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Advanced Micro Devices, Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***************************************************************************
+ *
+ */
+
+/*----------------------------------------------------------------------------------------
+ * M O D U L E S U S E D
+ *----------------------------------------------------------------------------------------
+ */
+#include "AGESA.h"
+#include "Ids.h"
+#include "amdlib.h"
+#include "Gnb.h"
+#include "GnbPcie.h"
+#include "GnbPcieFamServices.h"
+#include GNB_MODULE_DEFINITIONS (GnbCommonLib)
+#include GNB_MODULE_DEFINITIONS (GnbPcieConfig)
+#include GNB_MODULE_DEFINITIONS (GnbPcieInitLibV1)
+#include "GnbRegistersON.h"
+#include "Filecode.h"
+#define FILECODE PROC_GNB_MODULES_GNBPCIEINITLIBV1_PCIETOPOLOGYSERVICES_FILECODE
+/*----------------------------------------------------------------------------------------
+ * D E F I N I T I O N S A N D M A C R O S
+ *----------------------------------------------------------------------------------------
+ */
+
+
+/*----------------------------------------------------------------------------------------
+ * T Y P E D E F S A N D S T R U C T U R E S
+ *----------------------------------------------------------------------------------------
+ */
+
+
+/*----------------------------------------------------------------------------------------
+ * P R O T O T Y P E S O F L O C A L F U N C T I O N S
+ *----------------------------------------------------------------------------------------
+ */
+
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Prepare for reconfiguration
+ *
+ *
+ *
+ * @param[in] Wrapper Pointer to wrapper config descriptor
+ * @param[in] Pcie Pointer to global PCIe configuration
+ */
+VOID
+PcieTopologyPrepareForReconfig (
+ IN PCIe_WRAPPER_CONFIG *Wrapper,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ D0F0xE4_WRAP_8062_STRUCT D0F0xE4_WRAP_8062;
+ UINT8 CoreId;
+ if (PcieLibIsPcieWrapper (Wrapper)) {
+ for (CoreId = Wrapper->StartPcieCoreId; CoreId <= Wrapper->EndPcieCoreId; CoreId++) {
+ PcieRegisterWriteField (
+ Wrapper,
+ CORE_SPACE (CoreId, D0F0xE4_CORE_0011_ADDRESS),
+ D0F0xE4_CORE_0011_DynClkLatency_OFFSET,
+ D0F0xE4_CORE_0011_DynClkLatency_WIDTH,
+ 0xf,
+ FALSE,
+ Pcie
+ );
+ }
+
+ D0F0xE4_WRAP_8062.Value = PcieRegisterRead (
+ Wrapper,
+ WRAP_SPACE (Wrapper->WrapId, D0F0xE4_WRAP_8062_ADDRESS),
+ Pcie
+ );
+
+ D0F0xE4_WRAP_8062.Field.ConfigXferMode = 0x0;
+ D0F0xE4_WRAP_8062.Field.BlockOnIdle = 0x0;
+ PcieRegisterWrite (
+ Wrapper,
+ WRAP_SPACE (Wrapper->WrapId, D0F0xE4_WRAP_8062_ADDRESS),
+ D0F0xE4_WRAP_8062.Value,
+ FALSE,
+ Pcie
+ );
+ }
+}
+
+
+UINT8 LaneMuxSelectorTable[8] = { 0, 1, 2, 3, 4, 5, 6, 7 };
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Locate mux array index
+ *
+ *
+ *
+ * @param[in, out] LaneMuxSelectorArrayPtr Pointer to mux selector array
+ * @param[in] LaneMuxValue The value that match to array
+ * @retval Index Index successfully mapped
+ */
+UINT8
+PcieTopologyLocateMuxIndex (
+ IN OUT UINT8 *LaneMuxSelectorArrayPtr,
+ IN UINT8 LaneMuxValue
+ )
+{
+ UINT8 Index;
+ for (Index = 0; Index < sizeof (LaneMuxSelectorTable); Index++ ) {
+ if (LaneMuxSelectorArrayPtr [Index] == LaneMuxValue) {
+ return Index;
+ }
+ }
+ return 0;
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Apply lane mux
+ *
+ *
+ *
+ * @param[in] Wrapper Pointer to wrapper config descriptor
+ * @param[in] Pcie Pointer to global PCIe configuration
+ */
+
+VOID
+PcieTopologyApplyLaneMux (
+ IN PCIe_WRAPPER_CONFIG *Wrapper,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ PCIe_ENGINE_CONFIG *EngineList;
+ UINT8 CurrentPhyLane;
+ UINT8 CurrentCoreLane;
+ UINT8 CoreLaneIndex;
+ UINT8 PhyLaneIndex;
+ UINT8 NumberOfPhyLane;
+ UINT8 TxLaneMuxSelectorArray [sizeof (LaneMuxSelectorTable)];
+ UINT8 RxLaneMuxSelectorArray [sizeof (LaneMuxSelectorTable)];
+ UINT8 Index;
+ UINT32 TxMaxSelectorValue;
+ UINT32 RxMaxSelectorValue;
+
+ IDS_HDT_CONSOLE (GNB_TRACE, "PcieTopologyApplyLaneMux Enter\n");
+ if (PcieLibIsPcieWrapper (Wrapper)) {
+ EngineList = PcieWrapperGetEngineList (Wrapper);
+ LibAmdMemCopy (
+ &TxLaneMuxSelectorArray[0],
+ &LaneMuxSelectorTable[0],
+ sizeof (LaneMuxSelectorTable),
+ GnbLibGetHeader (Pcie)
+ );
+ LibAmdMemCopy (
+ &RxLaneMuxSelectorArray[0],
+ &LaneMuxSelectorTable[0],
+ sizeof (LaneMuxSelectorTable),
+ GnbLibGetHeader (Pcie)
+ );
+ while (EngineList != NULL) {
+ if (PcieLibIsPcieEngine (EngineList) && PcieLibIsEngineAllocated (EngineList)) {
+ CurrentPhyLane = (UINT8) PcieUtilGetLoPhyLane (EngineList) - Wrapper->StartPhyLane;
+ NumberOfPhyLane = (UINT8) PcieConfigGetNumberOfPhyLane (EngineList);
+ CurrentCoreLane = (UINT8) EngineList->Type.Port.StartCoreLane;
+ if (PcieUtilIsLinkReversed (FALSE, EngineList, Pcie)) {
+ CurrentCoreLane = CurrentCoreLane + PcieConfigGetNumberOfCoreLane (EngineList) - NumberOfPhyLane;
+ }
+ for (Index = 0; Index < NumberOfPhyLane; Index = Index + 2 ) {
+ CoreLaneIndex = (CurrentCoreLane + Index) / 2;
+ PhyLaneIndex = (CurrentPhyLane + Index) / 2;
+
+ if (RxLaneMuxSelectorArray [CoreLaneIndex] != PhyLaneIndex) {
+ RxLaneMuxSelectorArray [PcieTopologyLocateMuxIndex (RxLaneMuxSelectorArray, PhyLaneIndex)] = RxLaneMuxSelectorArray [CoreLaneIndex];
+ RxLaneMuxSelectorArray [CoreLaneIndex] = PhyLaneIndex;
+ }
+ if (TxLaneMuxSelectorArray [PhyLaneIndex] != CoreLaneIndex) {
+ TxLaneMuxSelectorArray [PcieTopologyLocateMuxIndex (TxLaneMuxSelectorArray, CoreLaneIndex)] = TxLaneMuxSelectorArray [PhyLaneIndex];
+ TxLaneMuxSelectorArray [PhyLaneIndex] = CoreLaneIndex;
+ }
+ }
+ }
+ EngineList = PcieLibGetNextDescriptor (EngineList);
+ }
+ RxMaxSelectorValue = 0;
+ TxMaxSelectorValue = 0;
+ for (Index = 0; Index < sizeof (LaneMuxSelectorTable); Index++) {
+ RxMaxSelectorValue |= (RxLaneMuxSelectorArray[Index] << (Index * 4));
+ TxMaxSelectorValue |= (TxLaneMuxSelectorArray[Index] << (Index * 4));
+ }
+ PcieRegisterWrite (
+ Wrapper,
+ WRAP_SPACE (Wrapper->WrapId, D0F0xE4_WRAP_8021_ADDRESS),
+ TxMaxSelectorValue,
+ FALSE,
+ Pcie
+ );
+ PcieRegisterWrite (
+ Wrapper,
+ WRAP_SPACE (Wrapper->WrapId, D0F0xE4_WRAP_8022_ADDRESS),
+ RxMaxSelectorValue,
+ FALSE,
+ Pcie
+ );
+ }
+ IDS_HDT_CONSOLE (GNB_TRACE, "PcieTopologyApplyLaneMux Exit\n");
+}
+
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Select master PLL
+ *
+ *
+ *
+ * @param[in] Wrapper Pointer to wrapper config descriptor
+ * @param[in] Pcie Pointer to global PCIe configuration
+ */
+
+VOID
+PcieTopologySelectMasterPll (
+ IN PCIe_WRAPPER_CONFIG *Wrapper,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ PCIe_ENGINE_CONFIG *EngineList;
+ UINT16 MasterPhyLane;
+ UINT16 MasterHotplugPhyLane;
+ D0F0xE4_WRAP_8013_STRUCT D0F0xE4_WRAP_8013;
+ EngineList = PcieWrapperGetEngineList (Wrapper);
+ MasterPhyLane = 0xffff;
+ MasterHotplugPhyLane = 0xffff;
+ IDS_HDT_CONSOLE (GNB_TRACE, "PcieTopologySelectMasterPll Enter\n");
+ while (EngineList != NULL) {
+ if (PcieLibIsEngineAllocated (EngineList)) {
+ if (EngineList->EngineData.EngineType == PciePortEngine) {
+ MasterPhyLane = EngineList->EngineData.StartLane;
+ if (EngineList->Type.Port.PortData.LinkHotplug != HotplugDisabled) {
+ MasterHotplugPhyLane = MasterPhyLane;
+ }
+ }
+ }
+ EngineList = PcieLibGetNextDescriptor (EngineList);
+ }
+
+ if (MasterPhyLane == 0xffff) {
+ MasterPhyLane = MasterHotplugPhyLane;
+ if (MasterPhyLane == 0xffff) {
+ MasterPhyLane = Wrapper->StartPhyLane;
+ }
+ }
+ D0F0xE4_WRAP_8013.Value = PcieRegisterRead (
+ Wrapper,
+ WRAP_SPACE (Wrapper->WrapId, D0F0xE4_WRAP_8013_ADDRESS),
+ Pcie
+ );
+
+ MasterPhyLane = MasterPhyLane - Wrapper->StartPhyLane;
+ if ( MasterPhyLane <= 3 ) {
+ D0F0xE4_WRAP_8013.Field.MasterPciePllA = 0x1;
+ D0F0xE4_WRAP_8013.Field.MasterPciePllB = 0x0;
+ D0F0xE4_WRAP_8013.Field.MasterPciePllC = 0x0;
+ D0F0xE4_WRAP_8013.Field.MasterPciePllD = 0x0;
+ } else if (MasterPhyLane <= 7) {
+ D0F0xE4_WRAP_8013.Field.MasterPciePllA = 0x0;
+ D0F0xE4_WRAP_8013.Field.MasterPciePllB = 0x1;
+ D0F0xE4_WRAP_8013.Field.MasterPciePllC = 0x0;
+ D0F0xE4_WRAP_8013.Field.MasterPciePllD = 0x0;
+ } else if (MasterPhyLane <= 11) {
+ D0F0xE4_WRAP_8013.Field.MasterPciePllA = 0x0;
+ D0F0xE4_WRAP_8013.Field.MasterPciePllB = 0x0;
+ D0F0xE4_WRAP_8013.Field.MasterPciePllC = 0x1;
+ D0F0xE4_WRAP_8013.Field.MasterPciePllD = 0x0;
+ } else {
+ D0F0xE4_WRAP_8013.Field.MasterPciePllA = 0x0;
+ D0F0xE4_WRAP_8013.Field.MasterPciePllB = 0x0;
+ D0F0xE4_WRAP_8013.Field.MasterPciePllC = 0x0;
+ D0F0xE4_WRAP_8013.Field.MasterPciePllD = 0x1;
+ }
+ PcieRegisterWrite (
+ Wrapper,
+ WRAP_SPACE (Wrapper->WrapId, D0F0xE4_WRAP_8013_ADDRESS),
+ D0F0xE4_WRAP_8013.Value,
+ FALSE,
+ Pcie
+ );
+
+ IDS_HDT_CONSOLE (GNB_TRACE, "PcieTopologySelectMasterPll Enter\n");
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Execute/clean up reconfiguration
+ *
+ *
+ * @param[in] Wrapper Pointer to wrapper config descriptor
+ * @param[in] Pcie Pointer to global PCIe configuration
+ */
+VOID
+PcieTopologyExecuteReconfig (
+ IN PCIe_WRAPPER_CONFIG *Wrapper,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ D0F0xE4_WRAP_8062_STRUCT D0F0xE4_WRAP_8062;
+ D0F0xE4_WRAP_8060_STRUCT D0F0xE4_WRAP_8060;
+
+ if (PcieLibIsPcieWrapper (Wrapper)) {
+ IDS_HDT_CONSOLE (GNB_TRACE, "PcieTopologyExecuteReconfig Enter\n");
+
+ PcieTopologyInitSrbmReset (FALSE, Wrapper, Pcie);
+
+ D0F0xE4_WRAP_8062.Value = PcieRegisterRead (
+ Wrapper,
+ WRAP_SPACE (Wrapper->WrapId, D0F0xE4_WRAP_8062_ADDRESS),
+ Pcie
+ );
+ D0F0xE4_WRAP_8060.Value = PcieRegisterRead (
+ Wrapper,
+ WRAP_SPACE (Wrapper->WrapId, D0F0xE4_WRAP_8060_ADDRESS),
+ Pcie
+ );
+
+ D0F0xE4_WRAP_8062.Field.ReconfigureEn = 0x1;
+ PcieRegisterWrite (
+ Wrapper,
+ WRAP_SPACE (Wrapper->WrapId, D0F0xE4_WRAP_8062_ADDRESS),
+ D0F0xE4_WRAP_8062.Value,
+ FALSE,
+ Pcie
+ );
+ D0F0xE4_WRAP_8060.Field.Reconfigure = 0x1;
+ PcieRegisterWrite (
+ Wrapper,
+ WRAP_SPACE (Wrapper->WrapId, D0F0xE4_WRAP_8060_ADDRESS),
+ D0F0xE4_WRAP_8060.Value,
+ FALSE,
+ Pcie
+ );
+ do {
+ D0F0xE4_WRAP_8060.Value = PcieRegisterRead (
+ Wrapper,
+ WRAP_SPACE (Wrapper->WrapId, D0F0xE4_WRAP_8060_ADDRESS),
+ Pcie
+ );
+
+ } while (D0F0xE4_WRAP_8060.Field.Reconfigure == 1);
+ D0F0xE4_WRAP_8062.Field.ConfigXferMode = 0x1;
+ D0F0xE4_WRAP_8062.Field.ReconfigureEn = 0x0;
+ PcieRegisterWrite (
+ Wrapper,
+ WRAP_SPACE (Wrapper->WrapId, D0F0xE4_WRAP_8062_ADDRESS),
+ D0F0xE4_WRAP_8062.Value,
+ FALSE,
+ Pcie
+ );
+ PcieTopologyInitSrbmReset (TRUE, Wrapper, Pcie);
+ IDS_HDT_CONSOLE (GNB_TRACE, "PcieTopologyExecuteReconfig Exit\n");
+ }
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Enable lane reversal
+ *
+ *
+ * @param[in] Wrapper Pointer to wrapper config descriptor
+ * @param[in] Pcie Pointer to global PCIe configuration
+ */
+VOID
+PcieTopologySetLinkReversal (
+ IN PCIe_WRAPPER_CONFIG *Wrapper,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ PCIe_ENGINE_CONFIG *EngineList;
+ IDS_HDT_CONSOLE (GNB_TRACE, "PcieTopologySetLinkReversal Enter\n");
+ EngineList = PcieWrapperGetEngineList (Wrapper);
+ while (EngineList != NULL) {
+ if (PcieLibIsEngineAllocated (EngineList)) {
+ if (PcieLibIsPcieEngine (EngineList)) {
+ if (EngineList->EngineData.StartLane > EngineList->EngineData.EndLane) {
+ PciePortRegisterWriteField (
+ EngineList,
+ DxF0xE4_xC1_ADDRESS,
+ DxF0xE4_xC1_StrapReverseLanes_OFFSET,
+ DxF0xE4_xC1_StrapReverseLanes_WIDTH,
+ 0x1,
+ FALSE,
+ Pcie
+ );
+ }
+ }
+ }
+ EngineList = PcieLibGetNextDescriptor (EngineList);
+ }
+ IDS_HDT_CONSOLE (GNB_TRACE, "PcieTopologySetLinkReversal Exit\n");
+}
+
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Reduce link width
+ *
+ *
+ * @param[in] LinkWidth Link width
+ * @param[in] Engine Pointer to Engine config descriptor
+ * @param[in] Pcie Pointer to global PCIe configuration
+ */
+VOID
+PcieTopologyReduceLinkWidth (
+ IN UINT8 LinkWidth,
+ IN PCIe_ENGINE_CONFIG *Engine,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ PCIe_WRAPPER_CONFIG *Wrapper;
+ UINT32 LinkReversed;
+ UINT8 DeltaLinkWidthBitmap;
+ UINT32 LanesToDisable;
+ Wrapper = PcieEngineGetParentWrapper (Engine);
+ LinkReversed = PcieUtilIsLinkReversed (TRUE, Engine, Pcie);
+
+ DeltaLinkWidthBitmap = (1 << (PcieConfigGetNumberOfCoreLane (Engine) - LinkWidth)) - 1;
+ LanesToDisable = (DeltaLinkWidthBitmap << ((LinkReversed == 1) ? Engine->Type.Port.StartCoreLane : (Engine->Type.Port.StartCoreLane + LinkWidth)));
+
+ PcieTopologyLaneControl (
+ DisableLanes,
+ LanesToDisable,
+ Wrapper,
+ Pcie
+ );
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Lanes enable/disable control
+ *
+ * @param[in] Control Lane control action
+ * @param[in] LaneBitMap Core lanes bitmap
+ * @param[in] Wrapper Pointer to Wrapper config descriptor
+ * @param[in] Pcie Pointer to global PCIe configuration
+ */
+VOID
+PcieTopologyLaneControl (
+ IN LANE_CONTROL Control,
+ IN UINT32 LaneBitMap,
+ IN PCIe_WRAPPER_CONFIG *Wrapper,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ D0F0xE4_WRAP_8023_STRUCT D0F0xE4_WRAP_8023;
+ D0F0xE4_WRAP_8023.Value = PcieRegisterRead (
+ Wrapper,
+ WRAP_SPACE (Wrapper->WrapId, D0F0xE4_WRAP_8023_ADDRESS),
+ Pcie
+ );
+
+ if (Control == EnableLanes) {
+ D0F0xE4_WRAP_8023.Value |= LaneBitMap;
+ } else if (Control == DisableLanes) {
+ D0F0xE4_WRAP_8023.Value &= (~LaneBitMap);
+ }
+ D0F0xE4_WRAP_8023.Value &= ((1 << (Wrapper->EndPhyLane - Wrapper->StartPhyLane + 1)) - 1);
+ PcieRegisterWrite (
+ Wrapper,
+ WRAP_SPACE (Wrapper->WrapId, D0F0xE4_WRAP_8023_ADDRESS),
+ D0F0xE4_WRAP_8023.Value,
+ FALSE,
+ Pcie
+ );
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Init SRBM reset
+ *
+ * @param[in] SrbmResetEnable SRBM reset enable flag.
+ * @param[in] Wrapper Pointer to wrapper config descriptor
+ * @param[in] Pcie Pointer to global PCIe configuration
+ */
+VOID
+PcieTopologyInitSrbmReset (
+ IN BOOLEAN SrbmResetEnable,
+ IN PCIe_WRAPPER_CONFIG *Wrapper,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ UINT32 pcireg;
+ UINT32 regmask = 0x7030;;
+ pcireg = PcieRegisterRead (
+ Wrapper,
+ WRAP_SPACE (Wrapper->WrapId, 0x8063),
+ Pcie
+ );
+ if (SrbmResetEnable) {
+ pcireg |= regmask;
+ } else {
+ pcireg &= ~(regmask);
+ }
+ PcieRegisterWrite (
+ Wrapper,
+ WRAP_SPACE (Wrapper->WrapId, 0x8063),
+ pcireg,
+ FALSE,
+ Pcie
+ );
+
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Set core configuration according to PCIe port topology
+ *
+ *
+ *
+ * @param[in] Wrapper Pointer to wrapper config descriptor
+ * @param[in] Pcie Pointer to global PCIe configuration
+ * @retval AGESA_SUCCESS Topology successfully mapped
+ * @retval AGESA_ERROR Topology can not be mapped
+ */
+
+AGESA_STATUS
+PcieTopologySetCoreConfig (
+ IN PCIe_WRAPPER_CONFIG *Wrapper,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ UINT8 CoreId;
+ AGESA_STATUS Status;
+ Status = AGESA_SUCCESS;
+ if (PcieLibIsPcieWrapper (Wrapper)) {
+ for (CoreId = Wrapper->StartPcieCoreId; CoreId <= Wrapper->EndPcieCoreId; CoreId++) {
+ UINT64 ConfigurationSignature;
+ UINT8 NewConfigurationValue;
+ ConfigurationSignature = PcieConfigGetConfigurationSignature (Wrapper, CoreId);
+ Status = PcieFmGetCoreConfigurationValue (Wrapper, CoreId, ConfigurationSignature, &NewConfigurationValue);
+ if (Status == AGESA_SUCCESS) {
+ IDS_HDT_CONSOLE (PCIE_MISC, " Core Configuration: Wrapper [%s], CoreID [%d] - %s\n",
+ PcieFmDebugGetWrapperNameString (Wrapper),
+ CoreId,
+ PcieFmDebugGetCoreConfigurationString (Wrapper, NewConfigurationValue)
+ );
+ PcieRegisterWriteField (
+ Wrapper,
+ WRAP_SPACE (Wrapper->WrapId, D0F0xE4_WRAP_0080_ADDRESS),
+ D0F0xE4_WRAP_0080_StrapBifLinkConfig_OFFSET,
+ D0F0xE4_WRAP_0080_StrapBifLinkConfig_WIDTH,
+ NewConfigurationValue,
+ FALSE,
+ Pcie
+ );
+ } else {
+ IDS_HDT_CONSOLE (PCIE_MISC, " ERROR! Core Configuration : Wrapper [%s], Signature [0x%x, 0x%x]\n",
+ PcieFmDebugGetWrapperNameString (Wrapper),
+ ((UINT32*)&ConfigurationSignature)[1],
+ ((UINT32*)&ConfigurationSignature)[0]
+ );
+ PcieConfigDisableAllEngines (PciePortEngine | PcieDdiEngine, Wrapper);
+ }
+ }
+ }
+ return Status;
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Relinquish control to DDI for specific lanes
+ *
+ *
+ * @param[in] Wrapper Pointer to wrapper configuration descriptor
+ * @param[in] Pcie Pointer to global PCIe configuration
+ */
+VOID
+PcieSetDdiOwnPhy (
+ IN PCIe_WRAPPER_CONFIG *Wrapper,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ UINT32 LaneBitmap;
+
+ if (PcieLibIsDdiWrapper (Wrapper)) {
+ IDS_HDT_CONSOLE (GNB_TRACE, "PcieFmSetDdiOwnPhy Enter\n");
+ LaneBitmap = PcieUtilGetWrapperLaneBitMap (LANE_TYPE_DDI_ALLOCATED, 0, Wrapper, Pcie);
+ IDS_HDT_CONSOLE (GNB_TRACE, "PcieFmSetDdiOwnPhy Exit\n");
+ }
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Set TX control for PCIe lanes
+ *
+ *
+ *
+ * @param[in] Wrapper Pointer to wrapper config descriptor
+ * @param[in] Pcie Pointer to global PCIe configuration
+ */
+VOID
+PcieWrapSetTxS1CtrlForLaneMux (
+ IN PCIe_WRAPPER_CONFIG *Wrapper,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ D0F0xE4_WRAP_8025_STRUCT D0F0xE4_WRAP_8025;
+ UINT32 LaneBitmap;
+ UINTN Index;
+ D0F0xE4_WRAP_8025.Value = PcieRegisterRead (
+ Wrapper,
+ WRAP_SPACE (Wrapper->WrapId, D0F0xE4_WRAP_8025_ADDRESS),
+ Pcie
+ );
+ Index = 0;
+ LaneBitmap = PcieUtilGetWrapperLaneBitMap (LANE_TYPE_PCIE_ALL, LANE_TYPE_PCIE_SB, Wrapper, Pcie);
+ while (LaneBitmap != 0) {
+ if ((LaneBitmap & 0xf) != 0) {
+ D0F0xE4_WRAP_8025.Value &= (~(0xff << (Index * 8)));
+ D0F0xE4_WRAP_8025.Value |= (((0x03 << 3) | 0x1) << (Index * 8));
+ }
+ LaneBitmap >>= 4;
+ ++Index;
+ }
+ PcieRegisterWrite (
+ Wrapper,
+ WRAP_SPACE (Wrapper->WrapId, D0F0xE4_WRAP_8025_ADDRESS),
+ D0F0xE4_WRAP_8025.Value,
+ FALSE,
+ Pcie
+ );
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Set TX control for lane muxes
+ *
+ *
+ *
+ * @param[in] Wrapper Pointer to wrapper config descriptor
+ * @param[in] Pcie Pointer to global PCIe configuration
+ */
+VOID
+PcieWrapSetTxOffCtrlForLaneMux (
+ IN PCIe_WRAPPER_CONFIG *Wrapper,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ PcieRegisterWrite (
+ Wrapper,
+ WRAP_SPACE (Wrapper->WrapId, D0F0xE4_WRAP_8025_ADDRESS),
+ 0x1f1f1f1f,
+ FALSE,
+ Pcie
+ );
+}
diff --git a/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PcieTopologyServices.h b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PcieTopologyServices.h
new file mode 100644
index 0000000000..e737d05e51
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PcieTopologyServices.h
@@ -0,0 +1,134 @@
+/* $NoKeywords:$ */
+/**
+ * @file
+ *
+ * PCIe topology initialization service procedures.
+ *
+ *
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: GNB
+ * @e \$Revision: 34897 $ @e \$Date: 2010-07-13 19:07:10 -0700 (Tue, 13 Jul 2010) $
+ *
+ */
+/*
+ *****************************************************************************
+ *
+ * Copyright (c) 2011, Advanced Micro Devices, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Advanced Micro Devices, Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***************************************************************************
+ *
+ */
+#ifndef _PCIETOPOLOGYSERVICES_H_
+#define _PCIETOPOLOGYSERVICES_H_
+
+/// Lane Control
+typedef enum {
+ EnableLanes, ///< Enable Lanes
+ DisableLanes ///< Disable Lanes
+} LANE_CONTROL;
+
+VOID
+PcieTopologyPrepareForReconfig (
+ IN PCIe_WRAPPER_CONFIG *Wrapper,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ );
+
+AGESA_STATUS
+PcieTopologySetCoreConfig (
+ IN PCIe_WRAPPER_CONFIG *Wrapper,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ );
+
+VOID
+PcieTopologyApplyLaneMux (
+ IN PCIe_WRAPPER_CONFIG *Wrapper,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ );
+
+VOID
+PcieTopologySelectMasterPll (
+ IN PCIe_WRAPPER_CONFIG *Wrapper,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ );
+
+VOID
+PcieTopologyExecuteReconfig (
+ IN PCIe_WRAPPER_CONFIG *Wrapper,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ );
+
+VOID
+PcieTopologySetLinkReversal (
+ IN PCIe_WRAPPER_CONFIG *Wrapper,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ );
+
+
+VOID
+PcieTopologyReduceLinkWidth (
+ IN UINT8 LinkWidth,
+ IN PCIe_ENGINE_CONFIG *Engine,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ );
+
+VOID
+PcieTopologyLaneControl (
+ IN LANE_CONTROL Control,
+ IN UINT32 LaneBitMap,
+ IN PCIe_WRAPPER_CONFIG *Wrapper,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ );
+
+VOID
+PcieTopologyInitSrbmReset (
+ IN BOOLEAN SrbmResetEnable,
+ IN PCIe_WRAPPER_CONFIG *Wrapper,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ );
+
+VOID
+PcieSetDdiOwnPhy (
+ IN PCIe_WRAPPER_CONFIG *Wrapper,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ );
+
+VOID
+PcieWrapSetTxS1CtrlForLaneMux (
+ IN PCIe_WRAPPER_CONFIG *Wrapper,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ );
+
+VOID
+PcieWrapSetTxOffCtrlForLaneMux (
+ IN PCIe_WRAPPER_CONFIG *Wrapper,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ );
+
+#endif
+
+
diff --git a/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PcieUtilityLib.c b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PcieUtilityLib.c
new file mode 100644
index 0000000000..ef868203dd
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PcieUtilityLib.c
@@ -0,0 +1,437 @@
+/* $NoKeywords:$ */
+/**
+ * @file
+ *
+ * PCIe utility. Various supporting functions.
+ *
+ *
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: GNB
+ * @e \$Revision: 38931 $ @e \$Date: 2010-10-01 15:50:05 -0700 (Fri, 01 Oct 2010) $
+ *
+ */
+/*
+ *****************************************************************************
+ *
+ * Copyright (c) 2011, Advanced Micro Devices, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Advanced Micro Devices, Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***************************************************************************
+ *
+ */
+
+/*----------------------------------------------------------------------------------------
+ * M O D U L E S U S E D
+ *----------------------------------------------------------------------------------------
+ */
+#include "AGESA.h"
+#include "Ids.h"
+#include "amdlib.h"
+#include "Gnb.h"
+#include "GnbPcie.h"
+#include GNB_MODULE_DEFINITIONS (GnbCommonLib)
+#include GNB_MODULE_DEFINITIONS (GnbPcieConfig)
+#include GNB_MODULE_DEFINITIONS (GnbPcieInitLibV1)
+#include "GnbRegistersON.h"
+#include "Filecode.h"
+#define FILECODE PROC_GNB_MODULES_GNBPCIEINITLIBV1_PCIEUTILITYLIB_FILECODE
+/*----------------------------------------------------------------------------------------
+ * D E F I N I T I O N S A N D M A C R O S
+ *----------------------------------------------------------------------------------------
+ */
+
+
+/*----------------------------------------------------------------------------------------
+ * T Y P E D E F S A N D S T R U C T U R E S
+ *----------------------------------------------------------------------------------------
+ */
+typedef struct {
+ UINT32 Flags;
+ PCIE_LINK_SPEED_CAP LinkSpeedCapability;
+} PCIE_GLOBAL_GEN_CAP_WORKSPACE;
+
+/*----------------------------------------------------------------------------------------
+ * P R O T O T Y P E S O F L O C A L F U N C T I O N S
+ *----------------------------------------------------------------------------------------
+ */
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Get link state history from HW state machine
+ *
+ *
+ *
+ * @param[in] Engine Pointer to engine config descriptor
+ * @param[out] History Buffer to save history
+ * @param[in] Length Buffer length
+ * @param[in] Pcie Pointer to global PCIe configuration
+ */
+
+VOID
+PcieUtilGetLinkHwStateHistory (
+ IN PCIe_ENGINE_CONFIG *Engine,
+ OUT UINT8 *History,
+ IN UINT8 Length,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ UINT8 ReadLength;
+ UINT32 LocalHistory [6];
+ UINT16 Index;
+ ASSERT (Length <= 16);
+ ASSERT (Length > 0);
+ if (Length > 6*4) {
+ Length = 6*4;
+ }
+ ReadLength = (Length + 3) / 4;
+ for (Index = 0; Index < ReadLength; Index++) {
+ LocalHistory[Index] = PciePortRegisterRead (
+ Engine,
+ DxF0xE4_xA5_ADDRESS + Index,
+ Pcie
+ );
+ }
+ LibAmdMemCopy (History, LocalHistory, Length, GnbLibGetHeader (Pcie));
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Search array for specific pattern
+ *
+ *
+ * @param[in] Buf1 Pointer to source buffer which will be subject of search
+ * @param[in] Buf1Length Length of the source buffer
+ * @param[in] Buf2 Pointer to pattern buffer
+ * @param[in] Buf2Length Length of the pattern buffer
+ * @retval TRUE Pattern found
+ * @retval TRUE Pattern not found
+ */
+
+BOOLEAN
+PcieUtilSearchArray (
+ IN UINT8 *Buf1,
+ IN UINTN Buf1Length,
+ IN UINT8 *Buf2,
+ IN UINTN Buf2Length
+ )
+{
+ UINT8 *CurrentBuf1Ptr;
+ CurrentBuf1Ptr = Buf1;
+ while (CurrentBuf1Ptr < (Buf1 + Buf1Length - Buf2Length)) {
+ UINT8 *SourceBufPtr;
+ UINT8 *PatternBufPtr;
+ UINTN PatternBufLength;
+ SourceBufPtr = CurrentBuf1Ptr;
+ PatternBufPtr = Buf2;
+ PatternBufLength = Buf2Length;
+ while ((*SourceBufPtr++ == *PatternBufPtr++) && (PatternBufLength-- != 0));
+ if (PatternBufLength == 0) {
+ return TRUE;
+ }
+ CurrentBuf1Ptr++;
+ }
+ return FALSE;
+}
+
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Check if link reversed
+ *
+ *
+ * @param[in] HwLinkState Check for HW auto link reversal
+ * @param[in] Engine Pointer to engine config descriptor
+ * @param[in] Pcie Pointer to PCIe config descriptor
+ * @retval TRUE if link reversed
+ */
+BOOLEAN
+PcieUtilIsLinkReversed (
+ IN BOOLEAN HwLinkState,
+ IN PCIe_ENGINE_CONFIG *Engine,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ UINT32 LinkReversal;
+
+ LinkReversal = (Engine->EngineData.StartLane > Engine->EngineData.EndLane) ? 1 : 0;
+ if (HwLinkState) {
+ DxF0xE4_x50_STRUCT DxF0xE4_x50;
+ DxF0xE4_x50.Value = PciePortRegisterRead (
+ Engine,
+ DxF0xE4_x50_ADDRESS,
+ Pcie
+ );
+ LinkReversal ^= DxF0xE4_x50.Field.PortLaneReversal;
+ }
+ return ((LinkReversal & BIT0) != 0) ? TRUE : FALSE;
+}
+
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Get link width detected during training
+ *
+ *
+ *
+ * @param[in] Engine Pointer to engine config descriptor
+ * @param[in] Pcie Pointer to global PCIe configuration
+ * @retval Link width
+ */
+UINT8
+PcieUtilGetLinkWidth (
+ IN PCIe_ENGINE_CONFIG *Engine,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ UINT8 LinkWidth;
+ DxF0xE4_xA2_STRUCT DxF0xE4_xA2;
+ DxF0xE4_xA2.Value = PciePortRegisterRead (
+ Engine,
+ DxF0xE4_xA2_ADDRESS,
+ Pcie
+ );
+ switch (DxF0xE4_xA2.Field.LcLinkWidthRd) {
+ case 0x6:
+ LinkWidth = 16;
+ break;
+ case 0x5:
+ LinkWidth = 12;
+ break;
+ case 0x4:
+ LinkWidth = 8;
+ break;
+ case 0x3:
+ LinkWidth = 4;
+ break;
+ case 0x2:
+ LinkWidth = 2;
+ break;
+ case 0x1:
+ LinkWidth = 1;
+ break;
+ default:
+ LinkWidth = 0;
+ }
+ return LinkWidth;
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Get bitmap of engine lane of requested type
+ *
+ *
+ * @param[in] IncludeLaneType Include Lane type
+ * @param[in] ExcludeLaneType Exclude Lane type
+ * @param[in] Engine Pointer to engine config descriptor
+ * @param[in] Pcie Pointer to global PCIe configuration
+ * @retval Lane bitmap
+ */
+
+UINT32
+PcieUtilGetEngineLaneBitMap (
+ IN UINT32 IncludeLaneType,
+ IN UINT32 ExcludeLaneType,
+ IN PCIe_ENGINE_CONFIG *Engine,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ UINT32 LaneBitmap;
+ UINT16 LaneOffset;
+ LaneBitmap = 0;
+ if ((IncludeLaneType & LANE_TYPE_PCIE_LANES) && Engine->EngineData.EngineType == PciePortEngine) {
+ if (IncludeLaneType & LANE_TYPE_PCIE_ALL) {
+ LaneBitmap |= (((1 << PcieConfigGetNumberOfCoreLane (Engine)) - 1) << Engine->Type.Port.StartCoreLane);
+ }
+ if (PcieLibIsEngineAllocated (Engine)) {
+ if (IncludeLaneType & LANE_TYPE_PCIE_ALLOCATED) {
+ LaneBitmap |= (((1 << PcieConfigGetNumberOfPhyLane (Engine)) - 1) << Engine->Type.Port.StartCoreLane);
+ }
+ if (IncludeLaneType & LANE_TYPE_PCIE_ACTIVE) {
+ if (Engine->Type.Port.PortData.LinkHotplug == HotplugEnhanced) {
+ LaneBitmap |= PcieUtilGetEngineLaneBitMap (LANE_TYPE_PCIE_ALLOCATED, 0, Engine, Pcie);
+ } else if (PcieConfigCheckPortStatus (Engine, INIT_STATUS_PCIE_PORT_IN_COMPLIANCE)) {
+ LaneBitmap |= PcieUtilGetEngineLaneBitMap (LANE_TYPE_PCIE_ALLOCATED, 0, Engine, Pcie);
+ } else if (PcieConfigCheckPortStatus (Engine, INIT_STATUS_PCIE_TRAINING_SUCCESS)) {
+ UINT8 LinkWidth;
+ BOOLEAN LinkReversed;
+ LinkWidth = PcieUtilGetLinkWidth (Engine, Pcie);
+ if (LinkWidth > PcieConfigGetNumberOfPhyLane (Engine)) {
+ LinkWidth = PcieConfigGetNumberOfPhyLane (Engine);
+ }
+ LinkReversed = PcieUtilIsLinkReversed (TRUE, Engine, Pcie);
+ LaneOffset = LinkReversed ? (Engine->Type.Port.EndCoreLane - LinkWidth + 1) : Engine->Type.Port.StartCoreLane;
+ LaneBitmap |= (((1 << LinkWidth) - 1) << LaneOffset);
+ }
+ }
+ if (IncludeLaneType & LANE_TYPE_PCIE_SB) {
+ if (Engine->Type.Port.IsSB) {
+ LaneBitmap |= PcieUtilGetEngineLaneBitMap (LANE_TYPE_PCIE_ACTIVE, 0, Engine, Pcie);
+ IDS_HDT_CONSOLE (GNB_TRACE, "SB Lane Bitmap is 0x%x\n", LaneBitmap);
+ }
+ }
+ if (IncludeLaneType & LANE_TYPE_PCIE_HOTPLUG) {
+ if (Engine->Type.Port.PortData.LinkHotplug != HotplugDisabled) {
+ LaneBitmap |= PcieUtilGetEngineLaneBitMap (LANE_TYPE_PCIE_ALLOCATED, 0, Engine, Pcie);
+ }
+ }
+ }
+ }
+ if ((IncludeLaneType & LANE_TYPE_DDI_LANES) && Engine->EngineData.EngineType == PcieDdiEngine) {
+ if (PcieLibIsEngineAllocated (Engine)) {
+ if (IncludeLaneType & (LANE_TYPE_DDI_ALLOCATED | LANE_TYPE_DDI_ALL)) {
+ LaneOffset = PcieUtilGetLoPhyLane (Engine) - PcieEngineGetParentWrapper (Engine)->StartPhyLane;
+ LaneBitmap |= ((1 << PcieConfigGetNumberOfPhyLane (Engine)) - 1) << LaneOffset;
+ }
+ if (IncludeLaneType & LANE_TYPE_DDI_ACTIVE) {
+ if (Engine->InitStatus & INIT_STATUS_DDI_ACTIVE) {
+ LaneBitmap |= PcieUtilGetEngineLaneBitMap (LANE_TYPE_DDI_ALL, 0, Engine, Pcie);
+ }
+ }
+ }
+ }
+ if (ExcludeLaneType != 0) {
+ LaneBitmap &= (~PcieUtilGetEngineLaneBitMap (ExcludeLaneType, 0, Engine, Pcie));
+ }
+ return LaneBitmap;
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Get bitmap of Wrapper lane of requested type
+ *
+ *
+ * @param[in] IncludeLaneType Include Lane type
+ * @param[in] ExcludeLaneType Exclude Lane type
+ * @param[in] Wrapper Pointer to wrapper config descriptor
+ * @param[in] Pcie Pointer to PCIe config descriptor
+ * @retval Lane bitmap
+ */
+
+UINT32
+PcieUtilGetWrapperLaneBitMap (
+ IN UINT32 IncludeLaneType,
+ IN UINT32 ExcludeLaneType,
+ IN PCIe_WRAPPER_CONFIG *Wrapper,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ PCIe_ENGINE_CONFIG *EngineList;
+ UINT32 LaneBitmap;
+ EngineList = PcieWrapperGetEngineList (Wrapper);
+ LaneBitmap = 0;
+ if ((IncludeLaneType | ExcludeLaneType) != 0) {
+ if ((IncludeLaneType & LANE_TYPE_ALL) == LANE_TYPE_ALL) {
+ LaneBitmap = (1 << (Wrapper->EndPhyLane - Wrapper->StartPhyLane + 1)) - 1;
+ if (ExcludeLaneType != 0) {
+ LaneBitmap &= (~PcieUtilGetWrapperLaneBitMap (ExcludeLaneType, 0, Wrapper, Pcie));
+ }
+ } else {
+ while (EngineList != NULL) {
+ LaneBitmap |= PcieUtilGetEngineLaneBitMap (IncludeLaneType, ExcludeLaneType, EngineList, Pcie);
+ EngineList = PcieLibGetNextDescriptor (EngineList);
+ }
+ }
+ }
+ return LaneBitmap;
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Program port register table
+ *
+ *
+ *
+ * @param[in] Table Pointer to table
+ * @param[in] Length number of entries
+ * @param[in] Engine Pointer to engine config descriptor
+ * @param[in] S3Save Save for S3 flag
+ * @param[in] Pcie Pointer to global PCIe configuration
+ *
+ */
+
+VOID
+PciePortProgramRegisterTable (
+ IN PCIE_PORT_REGISTER_ENTRY *Table,
+ IN UINTN Length,
+ IN PCIe_ENGINE_CONFIG *Engine,
+ IN BOOLEAN S3Save,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ UINTN Index;
+ UINT32 Value;
+ for (Index = 0; Index < Length; Index++) {
+ Value = PciePortRegisterRead (
+ Engine,
+ Table[Index].Reg,
+ Pcie
+ );
+ Value &= (~Table[Index].Mask);
+ Value |= Table[Index].Data;
+ PciePortRegisterWrite (
+ Engine,
+ Table[Index].Reg,
+ Value,
+ S3Save,
+ Pcie
+ );
+ }
+}
+
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Lock registers
+ *
+ *
+ * @param[in] Wrapper Pointer to wrapper config descriptor
+ * @param[in] Pcie Pointer to global PCIe configuration
+ */
+
+VOID
+PcieLockRegisters (
+ IN PCIe_WRAPPER_CONFIG *Wrapper,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ UINT8 CoreId;
+ IDS_HDT_CONSOLE (GNB_TRACE, "PcieLockRegisters Enter\n");
+ if (PcieLibIsPcieWrapper (Wrapper)) {
+ for (CoreId = Wrapper->StartPcieCoreId; CoreId <= Wrapper->EndPcieCoreId; CoreId++) {
+ PcieRegisterWriteField (
+ Wrapper,
+ CORE_SPACE (CoreId, 0x10),
+ 0,
+ 1,
+ 0x1,
+ TRUE,
+ Pcie
+ );
+ }
+ }
+ IDS_HDT_CONSOLE (GNB_TRACE, "PcieLockRegisters Exit\n");
+}
diff --git a/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PcieUtilityLib.h b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PcieUtilityLib.h
new file mode 100644
index 0000000000..5a8aa11a86
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PcieUtilityLib.h
@@ -0,0 +1,128 @@
+/* $NoKeywords:$ */
+/**
+ * @file
+ *
+ * PCIe utility. Various supporting functions.
+ *
+ *
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: GNB
+ * @e \$Revision: 38931 $ @e \$Date: 2010-10-01 15:50:05 -0700 (Fri, 01 Oct 2010) $
+ *
+ */
+/*
+ *****************************************************************************
+ *
+ * Copyright (c) 2011, Advanced Micro Devices, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Advanced Micro Devices, Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***************************************************************************
+ *
+ */
+
+#ifndef _PCIEUTILLIB_H_
+#define _PCIEUTILLIB_H_
+
+/// Core lanes
+typedef enum {
+ AllCoreLanes, ///< All core lanes
+ AllocatedCoreLanes, ///< Allocated core lanes
+ ActiveCoreLanes, ///< Active core lanes
+ HotplugCoreLanes, ///< Hot plug core lanes
+ SbCoreLanes, ///< South bridge core lanes
+} CORE_LANES;
+
+/// DDI lanes
+typedef enum {
+ DdiAllLanes, ///< All DDI Lanes
+ DdiActiveLanes ///< Active DDI Lanes
+} DDI_LANES;
+
+BOOLEAN
+PcieUtilSearchArray (
+ IN UINT8 *Buf1,
+ IN UINTN Buf1Length,
+ IN UINT8 *Buf2,
+ IN UINTN Buf2Length
+ );
+
+VOID
+PcieUtilGetLinkHwStateHistory (
+ IN PCIe_ENGINE_CONFIG *Engine,
+ OUT UINT8 *History,
+ IN UINT8 Length,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ );
+
+
+BOOLEAN
+PcieUtilIsLinkReversed (
+ IN BOOLEAN HwLinkState,
+ IN PCIe_ENGINE_CONFIG *Engine,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ );
+
+
+UINT8
+PcieUtilGetLinkWidth (
+ IN PCIe_ENGINE_CONFIG *Engine,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ );
+
+
+UINT32
+PcieUtilGetEngineLaneBitMap (
+ IN UINT32 IncludeLaneType,
+ IN UINT32 ExcludeLaneType,
+ IN PCIe_ENGINE_CONFIG *Engine,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ );
+
+UINT32
+PcieUtilGetWrapperLaneBitMap (
+ IN UINT32 IncludeLaneType,
+ IN UINT32 ExcludeLaneType,
+ IN PCIe_WRAPPER_CONFIG *Wrapper,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ );
+
+VOID
+PciePortProgramRegisterTable (
+ IN PCIE_PORT_REGISTER_ENTRY *Table,
+ IN UINTN Length,
+ IN PCIe_ENGINE_CONFIG *Engine,
+ IN BOOLEAN S3Save,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ );
+
+VOID
+PcieLockRegisters (
+ IN PCIe_WRAPPER_CONFIG *Wrapper,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ );
+
+#endif
diff --git a/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PcieWrapperRegAcc.c b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PcieWrapperRegAcc.c
new file mode 100644
index 0000000000..f47e58e742
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PcieWrapperRegAcc.c
@@ -0,0 +1,291 @@
+/* $NoKeywords:$ */
+/**
+ * @file
+ *
+ * Supporting services to access PCIe wrapper/core/PIF/PHY indirect register spaces
+ *
+ *
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: GNB
+ * @e \$Revision: 34897 $ @e \$Date: 2010-07-13 19:07:10 -0700 (Tue, 13 Jul 2010) $
+ *
+ */
+/*
+ *****************************************************************************
+ *
+ * Copyright (c) 2011, Advanced Micro Devices, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Advanced Micro Devices, Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***************************************************************************
+ *
+ */
+
+#include "AGESA.h"
+#include "Ids.h"
+#include "Gnb.h"
+#include "GnbPcie.h"
+#include "GnbPcieFamServices.h"
+#include GNB_MODULE_DEFINITIONS (GnbCommonLib)
+#include GNB_MODULE_DEFINITIONS (GnbPcieInitLibV1)
+#include "Filecode.h"
+#define FILECODE PROC_GNB_MODULES_GNBPCIEINITLIBV1_PCIEWRAPPERREGACC_FILECODE
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Read PCIe register value.
+ *
+ * Support for unify register access through index/data pair on GNB
+ *
+ * @param[in] Wrapper Pointer to Wrapper descriptor
+ * @param[in] Address Register address
+ * @param[in] Pcie Pointer to global PCIe configuration
+ * @retval Register Value
+ */
+UINT32
+PcieRegisterRead (
+ IN PCIe_WRAPPER_CONFIG *Wrapper,
+ IN UINT32 Address,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ return PcieSiliconRegisterRead (PcieWrapperGetParentSilicon (Wrapper), Address, Pcie);
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Read PCIe register value.
+ *
+ * Support for unify register access through index/data pair on GNB
+ *
+ * @param[in] Silicon Pointer to silicon descriptor
+ * @param[in] Address Register address
+ * @param[in] Pcie Pointer to global PCIe configuration
+ * @retval Register Value
+ */
+
+UINT32
+PcieSiliconRegisterRead (
+ IN PCIe_SILICON_CONFIG *Silicon,
+ IN UINT32 Address,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ UINT32 Value;
+ GnbLibPciWrite (Silicon->Address.AddressValue | 0xE0, AccessWidth32, &Address, GnbLibGetHeader (Pcie));
+ GnbLibPciRead (Silicon->Address.AddressValue | 0xE4, AccessWidth32, &Value, GnbLibGetHeader (Pcie));
+ return Value;
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Write PCIe register value.
+ *
+ * Support for unify register access through index/data pair on GNB
+ *
+ * @param[in] Wrapper Pointer to wrapper descriptor
+ * @param[in] Address Register address
+ * @param[in] Value New register value
+ * @param[in] S3Save Save register for S3 (True/False)
+ * @param[in] Pcie Pointer to global PCIe configuration
+ */
+VOID
+PcieRegisterWrite (
+ IN PCIe_WRAPPER_CONFIG *Wrapper,
+ IN UINT32 Address,
+ IN UINT32 Value,
+ IN BOOLEAN S3Save,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ PcieSiliconRegisterWrite (
+ PcieWrapperGetParentSilicon (Wrapper),
+ Address,
+ Value,
+ S3Save,
+ Pcie
+ );
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Write PCIe register value.
+ *
+ * Support for unify register access through index/data pair on GNB
+ *
+ * @param[in] Silicon Pointer to silicon descriptor
+ * @param[in] Address Register address
+ * @param[in] Value New register value
+ * @param[in] S3Save Save register for S3 (True/False)
+ * @param[in] Pcie Pointer to global PCIe configuration
+ */
+VOID
+PcieSiliconRegisterWrite (
+ IN PCIe_SILICON_CONFIG *Silicon,
+ IN UINT32 Address,
+ IN UINT32 Value,
+ IN BOOLEAN S3Save,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ IDS_HDT_CONSOLE (PCIE_HOSTREG_TRACE, " *WR %s (%d:%d:%d):0x%08x = 0x%08x\n",
+ PcieFmDebugGetHostRegAddressSpaceString ((UINT16) (Address >> 16)),
+ Silicon->Address.Address.Bus,
+ Silicon->Address.Address.Device,
+ Silicon->Address.Address.Function,
+ Address,
+ Value
+ );
+ GnbLibPciWrite (Silicon->Address.AddressValue | 0xE0, S3Save ? AccessS3SaveWidth32 : AccessWidth32, &Address, GnbLibGetHeader (Pcie));
+ GnbLibPciWrite (Silicon->Address.AddressValue | 0xE4, S3Save ? AccessS3SaveWidth32 : AccessWidth32, &Value, GnbLibGetHeader (Pcie));
+}
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Read PCIe register field.
+ *
+ * Support for unify register access through index/data pair on GNB
+ *
+ * @param[in] Wrapper Pointer to wrapper descriptor
+ * @param[in] Address Register address
+ * @param[in] FieldOffset Field offset
+ * @param[in] FieldWidth Field width
+ * @param[in] Pcie Pointer to global PCIe configuration
+ * @retval Register field value
+ */
+
+UINT32
+PcieRegisterReadField (
+ IN PCIe_WRAPPER_CONFIG *Wrapper,
+ IN UINT32 Address,
+ IN UINT8 FieldOffset,
+ IN UINT8 FieldWidth,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ UINT32 Value;
+ Value = PcieRegisterRead (Wrapper, Address, Pcie);
+ Value = (Value >> FieldOffset) & (~(0xFFFFFFFF << FieldWidth));
+ return Value;
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Write PCIe register field.
+ *
+ * Support for unify register access through index/data pair on GNB
+ *
+ * @param[in] Wrapper Pointer to wrapper descriptor
+ * @param[in] Address Register address
+ * @param[in] FieldOffset Field offset
+ * @param[in] FieldWidth Field width
+ * @param[in] Value Value to write
+ * @param[in] S3Save Save register for S3 (True/False)
+ * @param[in] Pcie Pointer to global PCIe configuration
+ */
+
+
+VOID
+PcieRegisterWriteField (
+ IN PCIe_WRAPPER_CONFIG *Wrapper,
+ IN UINT32 Address,
+ IN UINT8 FieldOffset,
+ IN UINT8 FieldWidth,
+ IN UINT32 Value,
+ IN BOOLEAN S3Save,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ UINT32 TempValue;
+ UINT32 Mask;
+ TempValue = PcieRegisterRead (Wrapper, Address, Pcie);
+ Mask = (~(0xFFFFFFFF << FieldWidth));
+ Value &= Mask;
+ TempValue &= (~(Mask << FieldOffset));
+ PcieRegisterWrite (Wrapper, Address, TempValue | (Value << FieldOffset), S3Save, Pcie);
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Read/Modify/Write PCIe register.
+ *
+ * Support for unify register access through index/data pair on GNB
+ *
+ * @param[in] Wrapper Pointer to wrapper descriptor
+ * @param[in] Address Register address
+ * @param[in] AndMask Value & (~AndMask)
+ * @param[in] OrMask Value | OrMask
+ * @param[in] S3Save Save register for S3 (True/False)
+ * @param[in] Pcie Pointer to global PCIe configuration
+ */
+
+VOID
+PcieRegisterRMW (
+ IN PCIe_WRAPPER_CONFIG *Wrapper,
+ IN UINT32 Address,
+ IN UINT32 AndMask,
+ IN UINT32 OrMask,
+ IN BOOLEAN S3Save,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ PcieSiliconRegisterRMW (
+ PcieWrapperGetParentSilicon (Wrapper),
+ Address,
+ AndMask,
+ OrMask,
+ S3Save,
+ Pcie
+ );
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Read/Modify/Write PCIe register.
+ *
+ * Support for unify register access through index/data pair on GNB
+ *
+ * @param[in] Silicon Pointer to silicon descriptor
+ * @param[in] Address Register address
+ * @param[in] AndMask Value & (~AndMask)
+ * @param[in] OrMask Value | OrMask
+ * @param[in] S3Save Save register for S3 (True/False)
+ * @param[in] Pcie Pointer to global PCIe configuration
+ */
+
+VOID
+PcieSiliconRegisterRMW (
+ IN PCIe_SILICON_CONFIG *Silicon,
+ IN UINT32 Address,
+ IN UINT32 AndMask,
+ IN UINT32 OrMask,
+ IN BOOLEAN S3Save,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ UINT32 Value;
+ Value = PcieSiliconRegisterRead (Silicon, Address, Pcie);
+ Value = (Value & (~AndMask)) | OrMask;
+ PcieSiliconRegisterWrite (Silicon, Address, Value, S3Save, Pcie);
+} \ No newline at end of file
diff --git a/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PcieWrapperRegAcc.h b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PcieWrapperRegAcc.h
new file mode 100644
index 0000000000..d0224278ab
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieInitLibV1/PcieWrapperRegAcc.h
@@ -0,0 +1,128 @@
+/* $NoKeywords:$ */
+/**
+ * @file
+ *
+ * Supporting services to access PCIe wrapper/core/PIF/PHY indirect register spaces
+ *
+ *
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: GNB
+ * @e \$Revision: 38931 $ @e \$Date: 2010-10-01 15:50:05 -0700 (Fri, 01 Oct 2010) $
+ *
+ */
+/*
+ *****************************************************************************
+ *
+ * Copyright (c) 2011, Advanced Micro Devices, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Advanced Micro Devices, Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***************************************************************************
+ *
+ */
+
+#ifndef _PCIEWRAPPERREGACC_H_
+#define _PCIEWRAPPERREGACC_H_
+
+//#define WRAP_SPACE(w, x) (0x01300000 | (w << 16) | (x))
+//#define CORE_SPACE(c, x) (0x00010000 | (c << 24) | (x))
+//#define PHY_SPACE(w, p, x) (0x00200000 | ((p + 1) << 24) | (w << 16) | (x))
+//#define PIF_SPACE(w, p, x) (0x00100000 | ((p + 1) << 24) | (w << 16) | (x))
+#define IMP_SPACE(x) (0x01080000 | (x))
+
+UINT32
+PcieRegisterRead (
+ IN PCIe_WRAPPER_CONFIG *Wrapper,
+ IN UINT32 Address,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ );
+
+VOID
+PcieRegisterWrite (
+ IN PCIe_WRAPPER_CONFIG *Wrapper,
+ IN UINT32 Address,
+ IN UINT32 Value,
+ IN BOOLEAN S3Save,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ );
+
+UINT32
+PcieRegisterReadField (
+ IN PCIe_WRAPPER_CONFIG *Wrapper,
+ IN UINT32 Address,
+ IN UINT8 FieldOffset,
+ IN UINT8 FieldWidth,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ );
+
+VOID
+PcieRegisterWriteField (
+ IN PCIe_WRAPPER_CONFIG *Wrapper,
+ IN UINT32 Address,
+ IN UINT8 FieldOffset,
+ IN UINT8 FieldWidth,
+ IN UINT32 Value,
+ IN BOOLEAN S3Save,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ );
+
+VOID
+PcieRegisterRMW (
+ IN PCIe_WRAPPER_CONFIG *Wrapper,
+ IN UINT32 Address,
+ IN UINT32 AndMask,
+ IN UINT32 OrMask,
+ IN BOOLEAN S3Save,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ );
+
+UINT32
+PcieSiliconRegisterRead (
+ IN PCIe_SILICON_CONFIG *Silicon,
+ IN UINT32 Address,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ );
+
+VOID
+PcieSiliconRegisterWrite (
+ IN PCIe_SILICON_CONFIG *Silicon,
+ IN UINT32 Address,
+ IN UINT32 Value,
+ IN BOOLEAN S3Save,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ );
+
+VOID
+PcieSiliconRegisterRMW (
+ IN PCIe_SILICON_CONFIG *Silicon,
+ IN UINT32 Address,
+ IN UINT32 AndMask,
+ IN UINT32 OrMask,
+ IN BOOLEAN S3Save,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ );
+
+#endif
diff --git a/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieTrainingV1/GnbPcieTrainingV1.h b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieTrainingV1/GnbPcieTrainingV1.h
new file mode 100644
index 0000000000..4d897e4193
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieTrainingV1/GnbPcieTrainingV1.h
@@ -0,0 +1,52 @@
+/* $NoKeywords:$ */
+/**
+ * @file
+ *
+ * PCIe training library
+ *
+ *
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: GNB
+ * @e \$Revision: 34897 $ @e \$Date: 2010-07-13 19:07:10 -0700 (Tue, 13 Jul 2010) $
+ *
+ */
+/*
+ *****************************************************************************
+ *
+ * Copyright (c) 2011, Advanced Micro Devices, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Advanced Micro Devices, Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***************************************************************************
+ *
+ */
+#ifndef _GNBPCIETRAININGV1_H_
+#define _GNBPCIETRAININGV1_H_
+
+#include "PcieTraining.h"
+#include "PcieWorkarounds.h"
+
+#endif
diff --git a/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieTrainingV1/PcieTraining.c b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieTrainingV1/PcieTraining.c
new file mode 100644
index 0000000000..ada2ccbcb9
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieTrainingV1/PcieTraining.c
@@ -0,0 +1,828 @@
+/* $NoKeywords:$ */
+/**
+ * @file
+ *
+ * PCIe link training
+ *
+ *
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: GNB
+ * @e \$Revision: 38950 $ @e \$Date: 2010-10-03 23:49:09 -0700 (Sun, 03 Oct 2010) $
+ *
+ */
+/*
+ *****************************************************************************
+ *
+ * Copyright (c) 2011, Advanced Micro Devices, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Advanced Micro Devices, Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***************************************************************************
+ *
+ */
+
+/*----------------------------------------------------------------------------------------
+ * M O D U L E S U S E D
+ *----------------------------------------------------------------------------------------
+ */
+#include "AGESA.h"
+#include "Ids.h"
+#include "amdlib.h"
+#include "GeneralServices.h"
+#include "Gnb.h"
+#include "GnbPcie.h"
+#include GNB_MODULE_DEFINITIONS (GnbCommonLib)
+#include GNB_MODULE_DEFINITIONS (GnbPcieConfig)
+#include GNB_MODULE_DEFINITIONS (GnbPcieInitLibV1)
+#include "PcieWorkarounds.h"
+#include "GnbRegistersON.h"
+#include "Filecode.h"
+#define FILECODE PROC_GNB_MODULES_GNBPCIETRAININGV1_PCIETRAINING_FILECODE
+/*----------------------------------------------------------------------------------------
+ * D E F I N I T I O N S A N D M A C R O S
+ *----------------------------------------------------------------------------------------
+ */
+
+
+/*----------------------------------------------------------------------------------------
+ * T Y P E D E F S A N D S T R U C T U R E S
+ *----------------------------------------------------------------------------------------
+ */
+
+
+/*----------------------------------------------------------------------------------------
+ * P R O T O T Y P E S O F L O C A L F U N C T I O N S
+ *----------------------------------------------------------------------------------------
+ */
+
+VOID
+STATIC
+PcieTrainingDebugDumpPortState (
+ IN PCIe_ENGINE_CONFIG *CurrentEngine,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ );
+
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Set link State
+ *
+ *
+ * @param[in] CurrentEngine Pointer to engine config descriptor
+ * @param[in] State State to set
+ * @param[in] UpdateTimeStamp Update time stamp
+ * @param[in] Pcie Pointer to global PCIe configuration
+ *
+ */
+VOID
+PcieTrainingSetPortState (
+ IN PCIe_ENGINE_CONFIG *CurrentEngine,
+ IN UINT8 State,
+ IN BOOLEAN UpdateTimeStamp,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ UINT32 TimeStamp;
+ CurrentEngine->Type.Port.State = State;
+ if (UpdateTimeStamp) {
+ TimeStamp = PcieTimerGetTimeStamp (Pcie);
+ CurrentEngine->Type.Port.TimeStamp = TimeStamp;
+ }
+ GNB_DEBUG_CODE (
+ PcieTrainingDebugDumpPortState (CurrentEngine, Pcie)
+ );
+}
+
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Set state for all engines connected to same reset ID
+ *
+ *
+ *
+ * @param[in] Engine Pointer to engine config descriptor
+ * @param[in, out] Buffer Pointer to Reset Id
+ * @param[in] Pcie Pointer to global PCIe configuration
+ *
+ */
+VOID
+PcieSetResetStateOnEngines (
+ IN PCIe_ENGINE_CONFIG *Engine,
+ IN OUT VOID *Buffer,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ UINT8 ResetId;
+ ResetId = *(UINT8 *)Buffer;
+ if (Engine->Type.Port.PortData.ResetId == ResetId) {
+ PcieTrainingSetPortState (Engine, LinkStateResetDuration, TRUE, Pcie);
+ }
+}
+
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Assert GPIO port reset.
+ *
+ * Transition to LinkStateResetDuration state
+ *
+ * @param[in] CurrentEngine Pointer to engine config descriptor
+ * @param[in] Pcie Pointer to global PCIe configuration
+ *
+ */
+VOID
+STATIC
+PcieTrainingAssertReset (
+ IN PCIe_ENGINE_CONFIG *CurrentEngine,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ PCIe_SLOT_RESET_INFO ResetInfo;
+ ResetInfo.ResetControl = AssertSlotReset;
+ ResetInfo.ResetId = CurrentEngine->Type.Port.PortData.ResetId;
+ LibAmdMemCopy (&ResetInfo.StdHeader, GnbLibGetHeader (Pcie), sizeof (AMD_CONFIG_PARAMS), GnbLibGetHeader (Pcie));
+ AgesaPcieSlotResetControl (0, &ResetInfo);
+ PcieConfigRunProcForAllEngines (
+ DESCRIPTOR_ALLOCATED | DESCRIPTOR_PCIE_ENGINE,
+ PcieSetResetStateOnEngines,
+ (VOID *)&CurrentEngine->Type.Port.PortData.ResetId,
+ Pcie
+ );
+}
+
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Check for reset duration
+ *
+ * Transition to LinkStateResetDuration state
+ *
+ * @param[in] CurrentEngine Pointer to engine config descriptor
+ * @param[in] Pcie Pointer to global PCIe configuration
+ *
+ */
+VOID
+PcieTrainingCheckResetDuration (
+ IN PCIe_ENGINE_CONFIG *CurrentEngine,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ UINT32 TimeStamp;
+ TimeStamp = PcieTimerGetTimeStamp (Pcie);
+ if (TIMESTAMPS_DELTA (TimeStamp, CurrentEngine->Type.Port.TimeStamp) >= Pcie->LinkGpioResetAssertionTime) {
+ PcieTrainingSetPortState (CurrentEngine, LinkStateResetExit, FALSE, Pcie);
+ }
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Deassert GPIO port reset.
+ *
+ * Transition to LinkStateResetDuration state
+ *
+ * @param[in] CurrentEngine Pointer to engine config descriptor
+ * @param[in] Pcie Platform configuration
+ *
+ */
+VOID
+PcieTrainingDeassertReset (
+ IN PCIe_ENGINE_CONFIG *CurrentEngine,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ PCIe_SLOT_RESET_INFO ResetInfo;
+ ResetInfo.ResetControl = DeassertSlotReset;
+ ResetInfo.ResetId = CurrentEngine->Type.Port.PortData.ResetId;
+ LibAmdMemCopy (&ResetInfo.StdHeader, GnbLibGetHeader (Pcie), sizeof (AMD_CONFIG_PARAMS), GnbLibGetHeader (Pcie));
+ AgesaPcieSlotResetControl (0, &ResetInfo);
+ PcieTrainingSetPortState (CurrentEngine, LinkTrainingResetTimeout, TRUE, Pcie);
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Check for after reset deassertion timeout
+ *
+ *
+ * @param[in] CurrentEngine Pointer to engine config descriptor
+ * @param[in] Pcie Pointer to global PCIe configuration
+ *
+ */
+VOID
+STATIC
+PcieTrainingCheckResetTimeout (
+ IN PCIe_ENGINE_CONFIG *CurrentEngine,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ UINT32 TimeStamp;
+ TimeStamp = PcieTimerGetTimeStamp (Pcie);
+ if (TIMESTAMPS_DELTA (TimeStamp, CurrentEngine->Type.Port.TimeStamp) >= Pcie->LinkResetToTrainingTime) {
+ PcieTrainingSetPortState (CurrentEngine, LinkStateReleaseTraining, FALSE, Pcie);
+ }
+}
+
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Release training
+ *
+ *
+ * @param[in] CurrentEngine Pointer to engine config descriptor
+ * @param[in] Pcie Pointer to global PCIe configuration
+ *
+ */
+VOID
+STATIC
+PcieTrainingRelease (
+ IN PCIe_ENGINE_CONFIG *CurrentEngine,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ UINT8 LinkTrainingState;
+ PcieRegisterWriteField (
+ PcieEngineGetParentWrapper (CurrentEngine),
+ WRAP_SPACE (PcieEngineGetParentWrapper (CurrentEngine)->WrapId, D0F0xE4_WRAP_0800_ADDRESS + 0x100 * CurrentEngine->Type.Port.PortId),
+ D0F0xE4_WRAP_0800_HoldTraining_OFFSET,
+ D0F0xE4_WRAP_0800_HoldTraining_WIDTH,
+ 0,
+ FALSE,
+ Pcie
+ );
+ if (CurrentEngine->Type.Port.PortData.MiscControls.LinkComplianceMode == 0x1) {
+ LinkTrainingState = LinkStateCompliance;
+ } else {
+ LinkTrainingState = LinkStateDetectPresence;
+ }
+ PcieTrainingSetPortState (CurrentEngine, LinkTrainingState, TRUE, Pcie);
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Detect presence of any EP on the link
+ *
+ *
+ * @param[in] CurrentEngine Pointer to engine config descriptor
+ * @param[in] Pcie Pointer to global PCIe configuration
+ *
+ */
+
+VOID
+STATIC
+PcieTrainingDetectPresence (
+ IN PCIe_ENGINE_CONFIG *CurrentEngine,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ UINT8 LinkHwStateHistory[4];
+ UINT32 TimeStamp;
+ PcieUtilGetLinkHwStateHistory (CurrentEngine, &LinkHwStateHistory[0], 4, Pcie);
+ if (LinkHwStateHistory[0] > 4) {
+ PcieTrainingSetPortState (CurrentEngine, LinkStateDetecting, TRUE, Pcie);
+ return;
+ }
+ TimeStamp = PcieTimerGetTimeStamp (Pcie);
+ if (TIMESTAMPS_DELTA (TimeStamp, CurrentEngine->Type.Port.TimeStamp) >= Pcie->LinkReceiverDetectionPooling) {
+ PcieTrainingSetPortState (CurrentEngine, LinkStateDeviceNotPresent, FALSE, Pcie);
+ }
+}
+
+UINT8 FailPattern1 [] = {0x2a, 0x6};
+UINT8 FailPattern2 [] = {0x2a, 0x9};
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Detect Link State
+ *
+ *
+ * @param[in] CurrentEngine Pointer to engine config descriptor
+ * @param[in] Pcie Pointer to global PCIe configuration
+ *
+ */
+
+VOID
+STATIC
+PcieTrainingDetectLinkState (
+ IN PCIe_ENGINE_CONFIG *CurrentEngine,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ UINT8 LinkHwStateHistory[16];
+ UINT32 TimeStamp;
+ UINT8 LinkTrainingState;
+ PcieUtilGetLinkHwStateHistory (CurrentEngine, &LinkHwStateHistory[0], 4, Pcie);
+ if (LinkHwStateHistory[0] == 0x10) {
+ PcieTrainingSetPortState (CurrentEngine, LinkStateL0, FALSE, Pcie);
+ return;
+ };
+ TimeStamp = PcieTimerGetTimeStamp (Pcie);
+ if (TIMESTAMPS_DELTA (TimeStamp, CurrentEngine->Type.Port.TimeStamp) >= Pcie->LinkL0Pooling) {
+ LinkTrainingState = LinkStateTrainingFail;
+ PcieUtilGetLinkHwStateHistory (CurrentEngine, &LinkHwStateHistory[0], 16, Pcie);
+ if (LinkHwStateHistory[0] == 0x7) {
+ LinkTrainingState = LinkStateCompliance;
+ } else if (PcieUtilSearchArray (LinkHwStateHistory, sizeof (LinkHwStateHistory), FailPattern1, sizeof (FailPattern1))) {
+ LinkTrainingState = LinkStateBrokenLane;
+ } else if (PcieUtilSearchArray (LinkHwStateHistory, sizeof (LinkHwStateHistory), FailPattern2, sizeof (FailPattern2))) {
+ LinkTrainingState = LinkStateGen2Fail;
+ }
+ PcieTrainingSetPortState (CurrentEngine, LinkTrainingState, FALSE, Pcie);
+ }
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Broken Lane
+ *
+ *
+ * @param[in] CurrentEngine Pointer to engine config descriptor
+ * @param[in] Pcie Pointer to global PCIe configuration
+ *
+ */
+
+VOID
+PcieTrainingBrokenLine (
+ IN PCIe_ENGINE_CONFIG *CurrentEngine,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ UINT8 CurrentLinkWidth;
+ UINT8 LinkTrainingState;
+ CurrentLinkWidth = PcieUtilGetLinkWidth (CurrentEngine, Pcie);
+ if (CurrentLinkWidth < PcieConfigGetNumberOfPhyLane (CurrentEngine) && CurrentLinkWidth > 0) {
+ CurrentEngine->InitStatus |= INIT_STATUS_PCIE_PORT_GEN2_RECOVERY;
+ PcieTopologyReduceLinkWidth (CurrentLinkWidth, CurrentEngine, Pcie);
+ LinkTrainingState = LinkStateResetAssert;
+ PutEventLog (
+ AGESA_WARNING,
+ GNB_EVENT_BROKEN_LANE_RECOVERY,
+ CurrentEngine->Type.Port.Address.AddressValue,
+ 0,
+ 0,
+ 0,
+ GnbLibGetHeader (Pcie)
+ );
+ } else {
+ LinkTrainingState = LinkStateGen2Fail;
+ }
+ PcieTrainingSetPortState (CurrentEngine, LinkTrainingState, FALSE, Pcie);
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Check if link fail because device does not support Gen2
+ *
+ *
+ * @param[in] CurrentEngine Pointer to engine config descriptor
+ * @param[in] Pcie Pointer to global PCIe configuration
+ *
+ */
+VOID
+PcieTrainingGen2Fail (
+ IN PCIe_ENGINE_CONFIG *CurrentEngine,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ UINT8 LinkTrainingState;
+ if (CurrentEngine->Type.Port.PortData.MiscControls.LinkSafeMode != PcieGen1) {
+ PcieConfigUpdatePortStatus (CurrentEngine, INIT_STATUS_PCIE_PORT_GEN2_RECOVERY, 0);
+ CurrentEngine->Type.Port.PortData.MiscControls.LinkSafeMode = PcieGen1;
+ PcieLinkSafeMode (CurrentEngine, Pcie);
+ LinkTrainingState = LinkStateResetAssert;
+ PutEventLog (
+ AGESA_WARNING,
+ GNB_EVENT_BROKEN_LANE_RECOVERY,
+ CurrentEngine->Type.Port.Address.AddressValue,
+ 0,
+ 0,
+ 0,
+ GnbLibGetHeader (Pcie)
+ );
+ } else {
+ LinkTrainingState = LinkStateTrainingFail;
+ }
+ PcieTrainingSetPortState (CurrentEngine, LinkTrainingState, FALSE, Pcie);
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Link in L0
+ *
+ *
+ * @param[in] CurrentEngine Pointer to engine config descriptor
+ * @param[in] Pcie Pointer to global PCIe configuration
+ *
+ */
+VOID
+STATIC
+PcieCheckLinkL0 (
+ IN PCIe_ENGINE_CONFIG *CurrentEngine,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ PcieTrainingSetPortState (CurrentEngine, LinkStateVcoNegotiation, TRUE, Pcie);
+}
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Check if link fail because device does not support Gen X
+ *
+ *
+ * @param[in] CurrentEngine Pointer to engine config descriptor
+ * @param[in] Pcie Pointer to global PCIe configuration
+ *
+ */
+VOID
+STATIC
+PcieTrainingCheckVcoNegotiation (
+ IN PCIe_ENGINE_CONFIG *CurrentEngine,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ UINT32 TimeStamp;
+ DxF0x128_STRUCT DxF0x128;
+ TimeStamp = PcieTimerGetTimeStamp (Pcie);
+ GnbLibPciRead (CurrentEngine->Type.Port.Address.AddressValue | DxF0x128_ADDRESS, AccessWidth32, &DxF0x128, GnbLibGetHeader (Pcie));
+ if (DxF0x128.Field.VcNegotiationPending == 0) {
+ UINT16 NumberOfPhyLane;
+ NumberOfPhyLane = PcieConfigGetNumberOfPhyLane (CurrentEngine);
+ if (Pcie->GfxCardWorkaround == GfxWorkaroundEnable && NumberOfPhyLane >= 8) {
+ // Limit exposure of workaround to x8 and x16 port.
+ PcieTrainingSetPortState (CurrentEngine, LinkStateGfxWorkaround, TRUE, Pcie);
+ } else {
+ PcieTrainingSetPortState (CurrentEngine, LinkStateTrainingSuccess, FALSE, Pcie);
+ }
+ return;
+ }
+ if (TIMESTAMPS_DELTA (TimeStamp, CurrentEngine->Type.Port.TimeStamp) >= 1000 * 1000) {
+ PcieTrainingSetPortState (CurrentEngine, LinkStateRetrain, FALSE, Pcie);
+ }
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Check if for GFX workaround condition
+ *
+ *
+ * @param[in] CurrentEngine Pointer to engine config descriptor
+ * @param[in] Pcie Pointer to global PCIe configuration
+ *
+ */
+VOID
+STATIC
+PcieTrainingGfxWorkaround (
+ IN PCIe_ENGINE_CONFIG *CurrentEngine,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ UINT32 TimeStamp;
+ GFX_WORKAROUND_STATUS GfxWorkaroundStatus;
+ TimeStamp = PcieTimerGetTimeStamp (Pcie);
+
+ GfxWorkaroundStatus = PcieGfxCardWorkaround (CurrentEngine->Type.Port.Address, GnbLibGetHeader (Pcie));
+ switch (GfxWorkaroundStatus) {
+ case GFX_WORKAROUND_DEVICE_NOT_READY:
+ if (TIMESTAMPS_DELTA (TimeStamp, CurrentEngine->Type.Port.TimeStamp) >= 1000 * 2000) {
+ PcieTrainingSetPortState (CurrentEngine, LinkStateTrainingFail, TRUE, Pcie);
+ }
+ break;
+ case GFX_WORKAROUND_SUCCESS:
+ PcieTrainingSetPortState (CurrentEngine, LinkStateTrainingSuccess, FALSE, Pcie);
+ break;
+ case GFX_WORKAROUND_RESET_DEVICE:
+ if (CurrentEngine->Type.Port.GfxWrkRetryCount < 5) {
+ CurrentEngine->Type.Port.GfxWrkRetryCount++;
+ PcieTrainingSetPortState (CurrentEngine, LinkStateResetAssert, TRUE, Pcie);
+ } else {
+ PcieTrainingSetPortState (CurrentEngine, LinkStateTrainingFail, TRUE, Pcie);
+ }
+ break;
+ default:
+ ASSERT (FALSE);
+ }
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Retrain link
+ *
+ *
+ * @param[in] CurrentEngine Pointer to engine config descriptor
+ * @param[in] Pcie Pointer to global PCIe configuration
+ *
+ */
+VOID
+STATIC
+PcieTrainingRetrainLink (
+ IN PCIe_ENGINE_CONFIG *CurrentEngine,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ PciePortRegisterWriteField (
+ CurrentEngine,
+ DxF0xE4_xA2_ADDRESS,
+ DxF0xE4_xA2_LcReconfigNow_OFFSET,
+ DxF0xE4_xA2_LcReconfigNow_WIDTH,
+ 1,
+ FALSE,
+ Pcie
+ );
+ PcieTrainingSetPortState (CurrentEngine, LinkStateDetecting, TRUE, Pcie);
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Training fail on this port
+ *
+ *
+ * @param[in] CurrentEngine Pointer to engine config descriptor
+ * @param[in] Pcie Pointer to global PCIe configuration
+ *
+ */
+VOID
+STATIC
+PcieTrainingFail (
+ IN PCIe_ENGINE_CONFIG *CurrentEngine,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ PcieConfigUpdatePortStatus (CurrentEngine, INIT_STATUS_PCIE_PORT_TRAINING_FAIL, 0);
+ PcieTrainingSetPortState (CurrentEngine, LinkStateDeviceNotPresent, FALSE, Pcie);
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Links training success
+ *
+ *
+ * @param[in] CurrentEngine Pointer to engine config descriptor
+ * @param[in] Pcie Pointer to global PCIe configuration
+ *
+ */
+
+VOID
+STATIC
+PcieTrainingSuccess (
+ IN PCIe_ENGINE_CONFIG *CurrentEngine,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ PcieConfigUpdatePortStatus (CurrentEngine, INIT_STATUS_PCIE_TRAINING_SUCCESS, 0);
+ PcieTrainingSetPortState (CurrentEngine, LinkStateTrainingCompleted, FALSE, Pcie);
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Links in compliance
+ *
+ *
+ * @param[in] CurrentEngine Pointer to engine config descriptor
+ * @param[in] Pcie Pointer to global PCIe configuration
+ *
+ */
+VOID
+STATIC
+PcieTrainingCompliance (
+ IN PCIe_ENGINE_CONFIG *CurrentEngine,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ PcieConfigUpdatePortStatus (CurrentEngine, INIT_STATUS_PCIE_PORT_IN_COMPLIANCE, 0);
+ PcieTrainingSetPortState (CurrentEngine, LinkStateTrainingCompleted, FALSE, Pcie);
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * PCie EP not present
+ *
+ *
+ * @param[in] CurrentEngine Pointer to engine config descriptor
+ * @param[in] Pcie Pointer to global PCIe configuration
+ *
+ */
+VOID
+STATIC
+PcieTrainingNotPresent (
+ IN PCIe_ENGINE_CONFIG *CurrentEngine,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ if ((CurrentEngine->Type.Port.PortData.LinkHotplug == HotplugEnhanced) || (CurrentEngine->Type.Port.PortData.LinkHotplug == HotplugServer)) {
+ } else {
+ PcieRegisterWriteField (
+ PcieEngineGetParentWrapper (CurrentEngine),
+ WRAP_SPACE (PcieEngineGetParentWrapper (CurrentEngine)->WrapId, D0F0xE4_WRAP_0800_ADDRESS + 0x100 * CurrentEngine->Type.Port.PortId),
+ D0F0xE4_WRAP_0800_HoldTraining_OFFSET,
+ D0F0xE4_WRAP_0800_HoldTraining_WIDTH,
+ 1,
+ FALSE,
+ Pcie
+ );
+ }
+ PcieTrainingSetPortState (CurrentEngine, LinkStateTrainingCompleted, FALSE, Pcie);
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Final state. Port training completed.
+ *
+ * Initialization status recorded in PCIe_ENGINE_CONFIG.InitStatus
+ *
+ * @param[in] CurrentEngine Pointer to engine config descriptor
+ * @param[in] Pcie Pointer to global PCIe configuration
+ *
+ */
+VOID
+STATIC
+PcieTrainingCompleted (
+ IN PCIe_ENGINE_CONFIG *CurrentEngine,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Training state handling
+ *
+ *
+ *
+ * @param[in] Engine Pointer to engine config descriptor
+ * @param[in, out] Buffer Indicate if engine in non final state
+ * @param[in] Pcie Pointer to global PCIe configuration
+ *
+ */
+
+VOID
+STATIC
+PcieTrainingPortCallback (
+ IN PCIe_ENGINE_CONFIG *Engine,
+ IN OUT VOID *Buffer,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ BOOLEAN *TrainingComplete;
+ TrainingComplete = (BOOLEAN *) Buffer;
+ if (Engine->Type.Port.State != LinkStateTrainingCompleted) {
+ *TrainingComplete = FALSE;
+ }
+ switch (Engine->Type.Port.State) {
+ case LinkStateResetAssert:
+ PcieTrainingAssertReset (Engine, Pcie);
+ break;
+ case LinkStateResetDuration:
+ PcieTrainingCheckResetDuration (Engine, Pcie);
+ break;
+ case LinkStateResetExit:
+ PcieTrainingDeassertReset (Engine, Pcie);
+ break;
+ case LinkTrainingResetTimeout:
+ PcieTrainingCheckResetTimeout (Engine, Pcie);
+ break;
+ case LinkStateReleaseTraining:
+ PcieTrainingRelease (Engine, Pcie);
+ break;
+ case LinkStateDetectPresence:
+ PcieTrainingDetectPresence (Engine, Pcie);
+ break;
+ case LinkStateDetecting:
+ PcieTrainingDetectLinkState (Engine, Pcie);
+ break;
+ case LinkStateBrokenLane:
+ PcieTrainingBrokenLine (Engine, Pcie);
+ break;
+ case LinkStateGen2Fail:
+ PcieTrainingGen2Fail (Engine, Pcie);
+ break;
+ case LinkStateL0:
+ PcieCheckLinkL0 (Engine, Pcie);
+ break;
+ case LinkStateVcoNegotiation:
+ PcieTrainingCheckVcoNegotiation (Engine, Pcie);
+ break;
+ case LinkStateRetrain:
+ PcieTrainingRetrainLink (Engine, Pcie);
+ break;
+ case LinkStateTrainingFail:
+ PcieTrainingFail (Engine, Pcie);
+ break;
+ case LinkStateGfxWorkaround:
+ PcieTrainingGfxWorkaround (Engine, Pcie);
+ break;
+ case LinkStateTrainingSuccess:
+ PcieTrainingSuccess (Engine, Pcie);
+ break;
+ case LinkStateCompliance:
+ PcieTrainingCompliance (Engine, Pcie);
+ break;
+ case LinkStateDeviceNotPresent:
+ PcieTrainingNotPresent (Engine, Pcie);
+ break;
+ case LinkStateTrainingCompleted:
+ PcieTrainingCompleted (Engine, Pcie);
+ break;
+ default:
+ break;
+ }
+
+}
+
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Main link training procedure
+ *
+ * Port end up in three possible state LinkStateTrainingNotPresent/LinkStateCompliance/
+ * LinkStateTrainingSuccess
+ *
+ * @param[in] Pcie Pointer to global PCIe configuration
+ * @retval AGESA_STATUS
+ *
+ */
+
+AGESA_STATUS
+PcieTraining (
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ AGESA_STATUS Status;
+ BOOLEAN TrainingComplete;
+ Status = AGESA_SUCCESS;
+ IDS_HDT_CONSOLE (GNB_TRACE, "PcieTraining Enter\n");
+ do {
+ TrainingComplete = TRUE;
+ PcieConfigRunProcForAllEngines (
+ DESCRIPTOR_ALLOCATED | DESCRIPTOR_PCIE_ENGINE,
+ PcieTrainingPortCallback,
+ &TrainingComplete,
+ Pcie
+ );
+ } while (!TrainingComplete);
+ IDS_HDT_CONSOLE (GNB_TRACE, "PcieTraining Exit [%x]\n", Status);
+ return Status;
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Helper function to dump port state on state transition
+ *
+ *
+ * @param[in] CurrentEngine Pointer to engine config descriptor
+ * @param[in] Pcie Pointer to global PCIe configuration
+ *
+ */
+
+VOID
+STATIC
+PcieTrainingDebugDumpPortState (
+ IN PCIe_ENGINE_CONFIG *CurrentEngine,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ )
+{
+ IDS_HDT_CONSOLE (PCIE_MISC, " Port %d:%d:%d State [%s] Time Stamp [%d]\n",
+ CurrentEngine->Type.Port.Address.Address.Bus,
+ CurrentEngine->Type.Port.Address.Address.Device,
+ CurrentEngine->Type.Port.Address.Address.Function,
+ (CurrentEngine->Type.Port.State == LinkStateTrainingFail) ? "LinkStateTrainingFail " : (
+ (CurrentEngine->Type.Port.State == LinkStateTrainingSuccess) ? "LinkStateTrainingSuccess " : (
+ (CurrentEngine->Type.Port.State == LinkStateCompliance) ? "LinkStateCompliance " : (
+ (CurrentEngine->Type.Port.State == LinkStateDeviceNotPresent) ? "LinkStateDeviceNotPresent" : (
+ (CurrentEngine->Type.Port.State == LinkStateResetAssert) ? "LinkStateResetAssert " : (
+ (CurrentEngine->Type.Port.State == LinkStateResetDuration) ? "LinkStateResetDuration " : (
+ (CurrentEngine->Type.Port.State == LinkStateResetDuration) ? "LinkStateResetExit " : (
+ (CurrentEngine->Type.Port.State == LinkTrainingResetTimeout) ? "LinkTrainingResetTimeout " : (
+ (CurrentEngine->Type.Port.State == LinkStateReleaseTraining) ? "LinkStateReleaseTraining " : (
+ (CurrentEngine->Type.Port.State == LinkStateDetectPresence) ? "LinkStateDetectPresence " : (
+ (CurrentEngine->Type.Port.State == LinkStateDetecting) ? "LinkStateDetecting " : (
+ (CurrentEngine->Type.Port.State == LinkStateBrokenLane) ? "LinkStateBrokenLane " : (
+ (CurrentEngine->Type.Port.State == LinkStateGen2Fail) ? "LinkStateGen2Fail " : (
+ (CurrentEngine->Type.Port.State == LinkStateL0) ? "LinkStateL0 " : (
+ (CurrentEngine->Type.Port.State == LinkStateVcoNegotiation) ? "LinkStateVcoNegotiation " : (
+ (CurrentEngine->Type.Port.State == LinkStateGfxWorkaround) ? "LinkStateGfxWorkaround " : (
+ (CurrentEngine->Type.Port.State == LinkStateTrainingCompleted) ? "LinkStateTrainingComplete" : (
+ (CurrentEngine->Type.Port.State == LinkStateRetrain) ? "LinkStateRetrain " : (
+ (CurrentEngine->Type.Port.State == LinkStateResetExit) ? "LinkStateResetExit " : "Unknown")))))))))))))))))),
+ CurrentEngine->Type.Port.TimeStamp
+ );
+}
diff --git a/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieTrainingV1/PcieTraining.h b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieTrainingV1/PcieTraining.h
new file mode 100644
index 0000000000..96cb828732
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieTrainingV1/PcieTraining.h
@@ -0,0 +1,64 @@
+/* $NoKeywords:$ */
+/**
+ * @file
+ *
+ * PCIe link training
+ *
+ *
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: GNB
+ * @e \$Revision: 34897 $ @e \$Date: 2010-07-13 19:07:10 -0700 (Tue, 13 Jul 2010) $
+ *
+ */
+/*
+ *****************************************************************************
+ *
+ * Copyright (c) 2011, Advanced Micro Devices, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Advanced Micro Devices, Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***************************************************************************
+ *
+ */
+#ifndef _PCIETRAINING_H_
+#define _PCIETRAINING_H_
+
+
+AGESA_STATUS
+PcieTraining (
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ );
+
+VOID
+PcieTrainingSetPortState (
+ IN PCIe_ENGINE_CONFIG *CurrentEngine,
+ IN UINT8 State,
+ IN BOOLEAN UpdateTimeStamp,
+ IN PCIe_PLATFORM_CONFIG *Pcie
+ );
+
+#endif
+
diff --git a/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieTrainingV1/PcieWorkarounds.c b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieTrainingV1/PcieWorkarounds.c
new file mode 100644
index 0000000000..5191465096
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieTrainingV1/PcieWorkarounds.c
@@ -0,0 +1,375 @@
+/* $NoKeywords:$ */
+/**
+ * @file
+ *
+ * Various workarounds
+ *
+ *
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: GNB
+ * @e \$Revision: 38931 $ @e \$Date: 2010-10-01 15:50:05 -0700 (Fri, 01 Oct 2010) $
+ *
+ */
+/*
+ *****************************************************************************
+ *
+ * Copyright (c) 2011, Advanced Micro Devices, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Advanced Micro Devices, Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***************************************************************************
+ *
+ */
+
+/*----------------------------------------------------------------------------------------
+ * M O D U L E S U S E D
+ *----------------------------------------------------------------------------------------
+ */
+#include "AGESA.h"
+#include "Ids.h"
+#include "amdlib.h"
+#include "Gnb.h"
+#include "GnbPcie.h"
+#include GNB_MODULE_DEFINITIONS (GnbCommonLib)
+#include GNB_MODULE_DEFINITIONS (GnbPcieConfig)
+#include "GnbRegistersON.h"
+#include "Filecode.h"
+#define FILECODE PROC_GNB_MODULES_GNBPCIETRAININGV1_PCIEWORKAROUNDS_FILECODE
+/*----------------------------------------------------------------------------------------
+ * D E F I N I T I O N S A N D M A C R O S
+ *----------------------------------------------------------------------------------------
+ */
+
+extern BUILD_OPT_CFG UserOptions;
+
+/*----------------------------------------------------------------------------------------
+ * T Y P E D E F S A N D S T R U C T U R E S
+ *----------------------------------------------------------------------------------------
+ */
+AGESA_STATUS
+PcieConfigureBridgeResources (
+ IN PCI_ADDR Port,
+ IN AMD_CONFIG_PARAMS *StdHeader
+ );
+
+VOID
+PcieFreeBridgeResources (
+ IN PCI_ADDR Port,
+ IN AMD_CONFIG_PARAMS *StdHeader
+ );
+
+GFX_WORKAROUND_STATUS
+PcieDeskewWorkaround (
+ IN PCI_ADDR Device,
+ IN AMD_CONFIG_PARAMS *StdHeader
+ );
+
+GFX_WORKAROUND_STATUS
+PcieNvWorkaround (
+ IN PCI_ADDR Device,
+ IN AMD_CONFIG_PARAMS *StdHeader
+ );
+
+VOID
+PcieProgramCpuMmio (
+ OUT UINT32 *SaveValues,
+ IN AMD_CONFIG_PARAMS *StdHeader
+ );
+
+VOID
+PcieRestoreCpuMmio (
+ IN UINT32 *RestoreValues,
+ IN AMD_CONFIG_PARAMS *StdHeader
+ );
+
+BOOLEAN
+PcieIsDeskewCardDetected (
+ IN UINT16 DeviceId
+ );
+
+/*----------------------------------------------------------------------------------------
+ * P R O T O T Y P E S O F L O C A L F U N C T I O N S
+ *----------------------------------------------------------------------------------------
+ */
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * ATI RV370/RV380 card workaround
+ *
+ *
+ *
+ * @param[in] Port PCI addreses of the port
+ * @param[in] StdHeader Standard configuration header
+ * @retval GFX_WORKAROUND_STATUS Return the GFX Card Workaround status
+ */
+GFX_WORKAROUND_STATUS
+PcieGfxCardWorkaround (
+ IN PCI_ADDR Port,
+ IN AMD_CONFIG_PARAMS *StdHeader
+ )
+{
+ GFX_WORKAROUND_STATUS Status;
+ UINT16 DeviceId;
+ UINT16 VendorId;
+ UINT8 DevClassCode;
+ UINT32 SaveValueData[2];
+ PCI_ADDR Ep;
+
+ Status = GFX_WORKAROUND_SUCCESS;
+
+ Ep.AddressValue = MAKE_SBDFO (0, Port.Address.Bus + Port.Address.Device, 0, 0, 0);
+ if (PcieConfigureBridgeResources (Port, StdHeader) == AGESA_SUCCESS) {
+ GnbLibPciRead (Ep.AddressValue | 0x00, AccessWidth16, &DeviceId, StdHeader);
+ Status = GFX_WORKAROUND_DEVICE_NOT_READY;
+ if (DeviceId != 0xffff) {
+ GnbLibPciRead (Ep.AddressValue | 0x02, AccessWidth16, &VendorId, StdHeader);
+ if (VendorId != 0xffff) {
+ GnbLibPciRead (Ep.AddressValue | 0x0B, AccessWidth8, &DevClassCode, StdHeader);
+ Status = GFX_WORKAROUND_SUCCESS;
+ if (DevClassCode == 3) {
+ PcieProgramCpuMmio (SaveValueData, StdHeader);
+ if (VendorId == 0x1002 && PcieIsDeskewCardDetected (DeviceId)) {
+ Status = PcieDeskewWorkaround (Ep, StdHeader);
+ } else if (VendorId == 0x10DE) {
+ Status = PcieNvWorkaround (Ep, StdHeader);
+ }
+ PcieRestoreCpuMmio (SaveValueData, StdHeader);
+ }
+ }
+ }
+ PcieFreeBridgeResources (Port, StdHeader);
+ }
+ return Status;
+}
+
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * RV370/RV380 Deskew workaround
+ *
+ *
+ *
+ * @param[in] Device Pcie Address of ATI RV370/RV380 card.
+ * @param[in] StdHeader Standard configuration header
+ */
+GFX_WORKAROUND_STATUS
+PcieDeskewWorkaround (
+ IN PCI_ADDR Device,
+ IN AMD_CONFIG_PARAMS *StdHeader
+ )
+{
+ UINTN MmioBase;
+ UINT16 MmioData1;
+ UINT32 MmioData2;
+
+ MmioBase = UserOptions.CfgTempPcieMmioBaseAddress;
+ if (MmioBase == 0) {
+ return GFX_WORKAROUND_SUCCESS;
+ }
+ GnbLibPciWrite (Device.AddressValue | 0x18, AccessWidth32, &MmioBase, StdHeader);
+ GnbLibPciRMW (Device.AddressValue | 0x04, AccessWidth8 , ~BIT1, BIT1, StdHeader);
+ GnbLibMemRMW (MmioBase + 0x120, AccessWidth16, 0, 0xb700, StdHeader);
+ GnbLibMemRead (MmioBase + 0x120, AccessWidth16, &MmioData1, StdHeader);
+ if (MmioData1 == 0xb700) {
+ GnbLibMemRMW (MmioBase + 0x124, AccessWidth32, 0, 0x13, StdHeader);
+ GnbLibMemRead (MmioBase + 0x124, AccessWidth32, &MmioData2, StdHeader);
+ if (MmioData2 == 0x13) {
+ GnbLibMemRead (MmioBase + 0x12C, AccessWidth32, &MmioData2, StdHeader);
+ if (MmioData2 & BIT8) {
+ return GFX_WORKAROUND_RESET_DEVICE;
+ }
+ }
+ }
+ GnbLibPciRMW (Device.AddressValue | 0x04, AccessWidth8, ~BIT1, 0x0, StdHeader);
+ GnbLibPciRMW (Device.AddressValue | 0x18, AccessWidth32, 0x0, 0x0, StdHeader);
+
+ return GFX_WORKAROUND_SUCCESS;
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * NV43 card workaround (lost SSID)
+ *
+ *
+ *
+ * @param[in] Device Pcie Address of NV43 card.
+ * @param[in] StdHeader Standard configuration header
+ */
+GFX_WORKAROUND_STATUS
+PcieNvWorkaround (
+ IN PCI_ADDR Device,
+ IN AMD_CONFIG_PARAMS *StdHeader
+ )
+{
+ UINT32 DeviceSSID;
+ UINTN MmioBase;
+ UINT32 MmioData3;
+
+ MmioBase = UserOptions.CfgTempPcieMmioBaseAddress;
+ if (MmioBase == 0) {
+ return GFX_WORKAROUND_SUCCESS;
+ }
+ GnbLibPciRMW (Device.AddressValue | 0x30, AccessWidth32, 0x0, ((UINT32)MmioBase) | 1, StdHeader);
+ GnbLibPciRMW (Device.AddressValue | 0x4, AccessWidth8, 0x0, 0x2, StdHeader);
+ GnbLibPciRead (Device.AddressValue | 0x2c, AccessWidth32, &DeviceSSID, StdHeader);
+ GnbLibMemRead (MmioBase + 0x54, AccessWidth32, &MmioData3, StdHeader);
+ if (DeviceSSID != MmioData3) {
+ GnbLibPciRMW (Device.AddressValue | 0x40, AccessWidth32, 0x0, MmioData3, StdHeader);
+ }
+ GnbLibPciRMW (Device.AddressValue | 0x30, AccessWidth32, 0x0, 0x0, StdHeader);
+ GnbLibPciRMW (Device.AddressValue | 0x4, AccessWidth8, 0x0, 0x0, StdHeader);
+ return GFX_WORKAROUND_SUCCESS;
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Allocate temporary resources for Pcie P2P bridge
+ *
+ *
+ *
+ * @param[in] Port Pci Address of Port to initialize.
+ * @param[in] StdHeader Standard configuration header
+ */
+AGESA_STATUS
+PcieConfigureBridgeResources (
+ IN PCI_ADDR Port,
+ IN AMD_CONFIG_PARAMS *StdHeader
+ )
+{
+ UINT32 Value;
+ UINT32 MmioBase;
+
+ MmioBase = UserOptions.CfgTempPcieMmioBaseAddress;
+ if (MmioBase == 0) {
+ return AGESA_WARNING;
+ }
+ Value = Port.Address.Bus + ((Port.Address.Bus + Port.Address.Device) << 8) + ((Port.Address.Bus + Port.Address.Device) << 16);
+ GnbLibPciWrite (Port.AddressValue | DxF0x18_ADDRESS, AccessWidth32, &Value, StdHeader);
+ Value = MmioBase + (MmioBase >> 16);
+ GnbLibPciWrite (Port.AddressValue | DxF0x20_ADDRESS, AccessWidth32, &Value, StdHeader);
+ Value = 0x000fff0;
+ GnbLibPciWrite (Port.AddressValue | DxF0x24_ADDRESS, AccessWidth32, &Value, StdHeader);
+ Value = 0x2;
+ GnbLibPciWrite (Port.AddressValue | DxF0x04_ADDRESS, AccessWidth8, &Value, StdHeader);
+ return AGESA_SUCCESS;
+}
+
+/*----------------------------------------------------------------------------------------*/
+/**
+ * Free temporary resources for Pcie P2P bridge
+ *
+ *
+ *
+ * @param[in] Port Pci Address of Port to clear resource allocation.
+ * @param[in] StdHeader Standard configuration header
+ */
+VOID
+PcieFreeBridgeResources (
+ IN PCI_ADDR Port,
+ IN AMD_CONFIG_PARAMS *StdHeader
+ )
+{
+ UINT32 Value;
+
+ Value = 0;
+ GnbLibPciWrite (Port.AddressValue | DxF0x04_ADDRESS, AccessWidth8, &Value, StdHeader);
+ GnbLibPciWrite (Port.AddressValue | DxF0x18_ADDRESS, AccessWidth32, &Value, StdHeader);
+ GnbLibPciWrite (Port.AddressValue | DxF0x20_ADDRESS, AccessWidth32, &Value, StdHeader);
+ GnbLibPciWrite (Port.AddressValue | DxF0x24_ADDRESS, AccessWidth32, &Value, StdHeader);
+
+}
+
+
+/*----------------------------------------------------------------------------------------*/
+/*
+ * Save CPU MMIO register
+ *
+ *
+ *
+ * @param[out] UINT32 SaveValues
+ * @param[in] StdHeader Standard configuration header
+ *
+ */
+VOID
+PcieProgramCpuMmio (
+ OUT UINT32 *SaveValues,
+ IN AMD_CONFIG_PARAMS *StdHeader
+ )
+{
+ //Save CPU MMIO Register
+ GnbLibPciRead (MAKE_SBDFO (0, 0, 0x18, 0x1, 0xB8), AccessWidth32, SaveValues, StdHeader);
+ GnbLibPciRead (MAKE_SBDFO (0, 0, 0x18, 0x1, 0xBC), AccessWidth32, SaveValues + 1, StdHeader);
+
+ //Write Temp Pcie MMIO to CPU
+ GnbLibPciRMW (MAKE_SBDFO (0, 0, 0x18, 0x1, 0xBC), AccessWidth32, 0, (UserOptions.CfgTempPcieMmioBaseAddress >> 16) << 8, StdHeader);
+ GnbLibPciRMW (MAKE_SBDFO (0, 0, 0x18, 0x1, 0xB8), AccessWidth32, 0, ((UserOptions.CfgTempPcieMmioBaseAddress >> 16) << 8) | 0x3, StdHeader);
+
+}
+
+/*----------------------------------------------------------------------------------------*/
+/*
+ * Restore CPU MMIO register
+ *
+ *
+ *
+ * @param[in] PCIe_PLATFORM_CONFIG Pcie
+ * @param[in] StdHeader Standard configuration header
+ */
+VOID
+PcieRestoreCpuMmio (
+ IN UINT32 *RestoreValues,
+ IN AMD_CONFIG_PARAMS *StdHeader
+ )
+{
+ //Restore CPU MMIO Register
+ GnbLibPciRMW (MAKE_SBDFO (0, 0, 0x18, 0x1, 0xB8), AccessWidth32, 0, *RestoreValues, StdHeader);
+ GnbLibPciRMW (MAKE_SBDFO (0, 0, 0x18, 0x1, 0xBC), AccessWidth32, 0, *(RestoreValues + 1), StdHeader);
+
+}
+
+/*----------------------------------------------------------------------------------------*/
+/*
+ * Check if card required test for deskew workaround
+ *
+ *
+ *
+ * @param[in] DeviceId Device ID
+ */
+
+BOOLEAN
+PcieIsDeskewCardDetected (
+ IN UINT16 DeviceId
+ )
+{
+ if ((DeviceId >= 0x3150 && DeviceId <= 0x3152) || (DeviceId == 0x3154) ||
+ (DeviceId == 0x3E50) || (DeviceId == 0x3E54) ||
+ ((DeviceId & 0xfff8) == 0x5460) || ((DeviceId & 0xfff8) == 0x5B60)) {
+ return TRUE;
+ }
+ return FALSE;
+}
+
+
diff --git a/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieTrainingV1/PcieWorkarounds.h b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieTrainingV1/PcieWorkarounds.h
new file mode 100644
index 0000000000..da9330b478
--- /dev/null
+++ b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieTrainingV1/PcieWorkarounds.h
@@ -0,0 +1,56 @@
+/* $NoKeywords:$ */
+/**
+ * @file
+ *
+ * Various workarounds
+ *
+ *
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: GNB
+ * @e \$Revision: 34897 $ @e \$Date: 2010-07-13 19:07:10 -0700 (Tue, 13 Jul 2010) $
+ *
+ */
+/*
+ *****************************************************************************
+ *
+ * Copyright (c) 2011, Advanced Micro Devices, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Advanced Micro Devices, Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***************************************************************************
+ *
+ */
+#ifndef _PCIEWORKAROUNDS_H_
+#define _PCIEWORKAROUNDS_H_
+
+GFX_WORKAROUND_STATUS
+PcieGfxCardWorkaround (
+ IN PCI_ADDR Port,
+ IN AMD_CONFIG_PARAMS *StdHeader
+ );
+
+
+#endif