blob: 8e6d6efbb703805c4f00915a3969b33b8b1725f4 [file] [log] [blame]
zbao7d94cf92012-07-02 14:19:14 +08001/* $NoKeywords:$ */
2/**
3 * @file
4 *
5 * PCIe late post initialization.
6 *
7 *
8 *
9 * @xrefitem bom "File Content Label" "Release Content"
10 * @e project: AGESA
11 * @e sub-project: GNB
12 * @e \$Revision: 63425 $ @e \$Date: 2011-12-22 11:24:10 -0600 (Thu, 22 Dec 2011) $
13 *
14 */
15/*
16*****************************************************************************
17*
Siyuan Wang641f00c2013-06-08 11:50:55 +080018 * Copyright (c) 2008 - 2012, Advanced Micro Devices, Inc.
19 * All rights reserved.
20 *
21 * Redistribution and use in source and binary forms, with or without
22 * modification, are permitted provided that the following conditions are met:
23 * * Redistributions of source code must retain the above copyright
24 * notice, this list of conditions and the following disclaimer.
25 * * Redistributions in binary form must reproduce the above copyright
26 * notice, this list of conditions and the following disclaimer in the
27 * documentation and/or other materials provided with the distribution.
28 * * Neither the name of Advanced Micro Devices, Inc. nor the names of
29 * its contributors may be used to endorse or promote products derived
30 * from this software without specific prior written permission.
31 *
32 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
33 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
34 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
35 * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
36 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
37 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
38 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
39 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
40 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
41 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
zbao7d94cf92012-07-02 14:19:14 +080042* ***************************************************************************
43*
44*/
45/*----------------------------------------------------------------------------------------
46 * M O D U L E S U S E D
47 *----------------------------------------------------------------------------------------
48 */
49#include "AGESA.h"
50#include "Ids.h"
51#include "amdlib.h"
52#include "Gnb.h"
53#include "GnbCommonLib.h"
54#include "GnbTable.h"
55#include "GnbPcieConfig.h"
56#include "GnbNbInitLibV1.h"
57#include "GnbNbInitLibV4.h"
58#include "GnbFuseTableTN.h"
59#include "GnbRegisterAccTN.h"
60#include "GnbRegistersTN.h"
61#include "heapManager.h"
62#include "GnbFuseTable.h"
63#include "OptionGnb.h"
64#include "Filecode.h"
65#define FILECODE PROC_GNB_MODULES_GNBINITTN_GNBENVINITTN_FILECODE
66/*----------------------------------------------------------------------------------------
67 * D E F I N I T I O N S A N D M A C R O S
68 *----------------------------------------------------------------------------------------
69 */
70extern GNB_BUILD_OPTIONS GnbBuildOptions;
71extern GNB_TABLE ROMDATA GnbEnvInitTableTN [];
72
73/*----------------------------------------------------------------------------------------
74 * T Y P E D E F S A N D S T R U C T U R E S
75 *----------------------------------------------------------------------------------------
76 */
77
78
79/*----------------------------------------------------------------------------------------
80 * 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
81 *----------------------------------------------------------------------------------------
82 */
83AGESA_STATUS
84GnbEnvInterfaceTN (
85 IN AMD_CONFIG_PARAMS *StdHeader
86 );
87
88
89/*----------------------------------------------------------------------------------------*/
90/**
91 * PCIe Early Post Init
92 *
93 *
94 *
95 * @param[in] StdHeader Standard configuration header
96 * @retval AGESA_STATUS
97 */
98
99AGESA_STATUS
100GnbEnvInterfaceTN (
101 IN AMD_CONFIG_PARAMS *StdHeader
102 )
103{
104 AGESA_STATUS Status;
105 AMD_ENV_PARAMS *EnvParamsPtr;
106 UINT32 Property;
107 GNB_HANDLE *GnbHandle;
108 D18F5x170_STRUCT D18F5x170;
109 D0F0xBC_x1F8DC_STRUCT D0F0xBC_x1F8DC;
110 PP_FUSE_ARRAY *PpFuseArray;
111
112 IDS_HDT_CONSOLE (GNB_TRACE, "GnbEnvInterfaceTN Enter\n");
113 Property = TABLE_PROPERTY_DEAFULT;
114 EnvParamsPtr = (AMD_ENV_PARAMS *) StdHeader;
115 GnbHandle = GnbGetHandle (StdHeader);
116 ASSERT (GnbHandle != NULL);
117 GnbLoadFuseTableTN (StdHeader);
118 Status = GnbSetTom (GnbGetHostPciAddress (GnbHandle), StdHeader);
119 GnbOrbDynamicWake (GnbGetHostPciAddress (GnbHandle), StdHeader);
120 GnbClumpUnitIdV4 (GnbHandle, StdHeader);
121 GnbLpcDmaDeadlockPreventionV4 (GnbHandle, StdHeader);
122 Property |= GnbBuildOptions.CfgLoadlineEnable ? TABLE_PROPERTY_LOADLINE_ENABLE : 0;
123 Property |= GnbBuildOptions.CfgIommuL1ClockGatingEnable ? TABLE_PROPERTY_IOMMU_L1_CLOCK_GATING : 0;
124 Property |= GnbBuildOptions.CfgIommuL2ClockGatingEnable ? TABLE_PROPERTY_IOMMU_L2_CLOCK_GATING : 0;
125 if (!EnvParamsPtr->GnbEnvConfiguration.IommuSupport) {
126 Property |= TABLE_PROPERTY_IOMMU_DISABLED;
127 }
128
129 if (GnbBuildOptions.CfgNbdpmEnable) {
130 GnbRegisterReadTN (
131 TYPE_D18F5,
132 D18F5x170_ADDRESS,
133 &D18F5x170.Value,
134 0,
135 StdHeader
136 );
137 // Check if NbPstate enbale
138 if ((D18F5x170.Field.SwNbPstateLoDis != 1) && (D18F5x170.Field.NbPstateMaxVal != 0)) {
139 Property |= TABLE_PROPERTY_NBDPM;
140 PpFuseArray = GnbLocateHeapBuffer (AMD_PP_FUSE_TABLE_HANDLE, StdHeader);
141 if (PpFuseArray != NULL) {
142 // NBDPM is requesting SclkVid0 from the register.
143 // Write them back if SclkVid has been changed in PpFuseArray.
144 GnbRegisterReadTN (D0F0xBC_x1F8DC_TYPE, D0F0xBC_x1F8DC_ADDRESS, &D0F0xBC_x1F8DC.Value, 0, StdHeader);
145 if ((D0F0xBC_x1F8DC.Field.SClkVid0 != PpFuseArray->SclkVid[0]) ||
146 (D0F0xBC_x1F8DC.Field.SClkVid1 != PpFuseArray->SclkVid[1]) ||
147 (D0F0xBC_x1F8DC.Field.SClkVid2 != PpFuseArray->SclkVid[2]) ||
148 (D0F0xBC_x1F8DC.Field.SClkVid3 != PpFuseArray->SclkVid[3])) {
149 D0F0xBC_x1F8DC.Field.SClkVid0 = PpFuseArray->SclkVid[0];
150 D0F0xBC_x1F8DC.Field.SClkVid1 = PpFuseArray->SclkVid[1];
151 D0F0xBC_x1F8DC.Field.SClkVid2 = PpFuseArray->SclkVid[2];
152 D0F0xBC_x1F8DC.Field.SClkVid3 = PpFuseArray->SclkVid[3];
153 GnbRegisterWriteTN (D0F0xBC_x1F8DC_TYPE, D0F0xBC_x1F8DC_ADDRESS, &D0F0xBC_x1F8DC.Value, GNB_REG_ACC_FLAG_S3SAVE, StdHeader);
154 }
155 }
156 }
157 }
158
159 IDS_OPTION_HOOK (IDS_GNB_PROPERTY, &Property, StdHeader);
160
161 Status = GnbProcessTable (
162 GnbHandle,
163 GnbEnvInitTableTN,
164 Property,
165 GNB_TABLE_FLAGS_FORCE_S3_SAVE,
166 StdHeader
167 );
168 IDS_HDT_CONSOLE (GNB_TRACE, "GnbEnvInterfaceTN Exit [0x%x]\n", Status);
169 return Status;
170}