AGESA F15: AMD family15 AGESA code
[coreboot.git] / src / vendorcode / amd / agesa / f15 / Proc / HT / Fam15 / htNbFam15.c
1 /* $NoKeywords:$ */
2 /**
3  * @file
4  *
5  * Initializers for Family 15h northbridge support.
6  *
7  * @xrefitem bom "File Content Label" "Release Content"
8  * @e project:      AGESA
9  * @e sub-project:  HyperTransport
10  * @e \$Revision: 44846 $   @e \$Date: 2011-01-06 22:21:05 -0700 (Thu, 06 Jan 2011) $
11  *
12  */
13 /*
14 *****************************************************************************
15 *
16 * Copyright (C) 2012 Advanced Micro Devices, Inc.
17 * All rights reserved.
18 *
19 * Redistribution and use in source and binary forms, with or without
20 * modification, are permitted provided that the following conditions are met:
21 *     * Redistributions of source code must retain the above copyright
22 *       notice, this list of conditions and the following disclaimer.
23 *     * Redistributions in binary form must reproduce the above copyright
24 *       notice, this list of conditions and the following disclaimer in the
25 *       documentation and/or other materials provided with the distribution.
26 *     * Neither the name of Advanced Micro Devices, Inc. nor the names of
27 *       its contributors may be used to endorse or promote products derived
28 *       from this software without specific prior written permission.
29 *
30 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
31 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
32 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
33 * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
34 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
35 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
36 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
37 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
39 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40 *
41 * ***************************************************************************
42 *
43 */
44
45 /*
46  *----------------------------------------------------------------------------
47  *                                MODULES USED
48  *
49  *----------------------------------------------------------------------------
50  */
51
52 #include "AGESA.h"
53 #include "amdlib.h"
54 #include "OptionsHt.h"
55 #include "Ids.h"
56 #include "Topology.h"
57 #include "htFeat.h"
58 #include "htNb.h"
59 #include "CommonReturns.h"
60 #include "htNbCoherent.h"
61 #include "htNbCoherentFam15.h"
62 #include "htNbNonCoherent.h"
63 #include "htNbNonCoherentFam15.h"
64 #include "htNbOptimization.h"
65 #include "htNbOptimizationFam15.h"
66 #include "htNbSystemFam15.h"
67 #include "htNbUtilities.h"
68 #include "htNbUtilitiesFam15.h"
69 #include "cpuFamRegisters.h"
70 CODE_GROUP (G2_PEI)
71 RDATA_GROUP (G2_PEI)
72 #include "Filecode.h"
73
74 #define FILECODE PROC_HT_FAM15_HTNBFAM15_FILECODE
75
76 extern OPTION_HT_CONFIGURATION OptionHtConfiguration;
77
78 /*----------------------------------------------------------------------------
79  *                          DEFINITIONS AND MACROS
80  *
81  *----------------------------------------------------------------------------
82  */
83
84 /*----------------------------------------------------------------------------
85  *                           TYPEDEFS AND STRUCTURES
86  *
87  *----------------------------------------------------------------------------
88  */
89 /*----------------------------------------------------------------------------
90  *                        PROTOTYPES OF LOCAL FUNCTIONS
91  *
92  *----------------------------------------------------------------------------
93  */
94
95 /***************************************************************************
96  ***               FAMILY/NORTHBRIDGE SPECIFIC FUNCTIONS                 ***
97  ***************************************************************************/
98
99 /**
100  * Map Northbridge links to package links for Family 15h, multi-module.
101  *
102  * Unfortunately, there is no way to do this except to type the BKDG text into this data structure.
103  * Note that there is one entry per package external sublink and each connected internal link.
104  */
105 CONST PACKAGE_HTLINK_MAP_ITEM ROMDATA HtFam15PackageLinkMap[] =
106 {
107   {3, 0, 0},        ///< Module zero, link 3: package link 0
108   {7, 0, 4},        ///< Module zero, link 7: package link 4
109   {0, 1, 1},        ///< Module one,  link 0: package link 1
110   {4, 1, 5},        ///< Module one,  link 4: package link 5
111   {1, 0, 2},        ///< Module zero, link 1: package link 2
112   {5, 0, 6},        ///< Module zero, link 5: package link 6
113   {0, 0, 3},        ///< Module zero, link 0: package link 3
114   {3, 1, 7},        ///< Module one,  link 3: package link 7
115   {2, 0, HT_LIST_MATCH_INTERNAL_LINK_0},        ///< Internal Link
116   {6, 0, HT_LIST_MATCH_INTERNAL_LINK_1},        ///< Internal Link
117   {4, 0, HT_LIST_MATCH_INTERNAL_LINK_2},        ///< Internal Link
118   {1, 1, HT_LIST_MATCH_INTERNAL_LINK_0},        ///< Internal Link
119   {5, 1, HT_LIST_MATCH_INTERNAL_LINK_1},        ///< Internal Link
120   {7, 1, HT_LIST_MATCH_INTERNAL_LINK_2},        ///< Internal Link
121   {HT_LIST_TERMINAL, HT_LIST_TERMINAL, HT_LIST_TERMINAL}, ///< End
122 };
123
124 /**
125  * A default Ignore Link list to power off the 3rd internal sublink.
126  */
127 STATIC CONST IGNORE_LINK ROMDATA Fam15IgnoreLinkList[] = {
128   {HT_LIST_MATCH_ANY, HT_LIST_MATCH_INTERNAL_LINK_2, POWERED_OFF},
129   {HT_LIST_TERMINAL}
130 };
131
132 /**
133  * Initial construction data for Family 15h North Bridge, default, full features.
134  */
135 CONST NORTHBRIDGE ROMDATA HtFam15NbDefault =
136 {
137   8,
138   WriteRoutingTable,
139   WriteNodeID,
140   ReadDefaultLink,
141   EnableRoutingTables,
142   DisableRoutingTables,
143   VerifyLinkIsCoherent,
144   ReadToken,
145   WriteToken,
146   WriteFullRoutingTable,
147   IsIllegalTypeMix,
148   Fam15IsExceededCapable,
149   Fam15StopLink,
150   (PF_HANDLE_SPECIAL_LINK_CASE)CommonReturnFalse,
151   HandleSpecialNodeCase,
152   ReadSouthbridgeLink,
153   VerifyLinkIsNonCoherent,
154   Fam15SetConfigAddrMap,
155   Fam15NorthBridgeFreqMask,
156   GatherLinkFeatures,
157   SetLinkRegang,
158   SetLinkFrequency,
159   SetLinkUnitIdClumping,
160   Fam15WriteTrafficDistribution,
161   Fam15WriteLinkPairDistribution,
162   Fam15WriteVictimDistribution,
163   Fam15BufferOptimizations,
164   Fam15GetNumCoresOnNode,
165   SetTotalNodesAndCores,
166   GetNodeCount,
167   LimitNodes,
168   ReadTrueLinkFailStatus,
169   Fam15GetNextLink,
170   GetPackageLink,
171   MakeLinkBase,
172   Fam15GetModuleInfo,
173   Fam15PostMailbox,
174   Fam15RetrieveMailbox,
175   Fam15StrappedGetSocket,
176   Fam15GetEnabledComputeUnits,
177   Fam15GetDualcoreComputeUnits,
178   0x00000001,
179   0x00000200,
180   18,
181   TRUE,
182   TRUE,
183   AMD_FAMILY_15,
184   (PACKAGE_HTLINK_MAP) &HtFam15PackageLinkMap,
185   0,
186   (IGNORE_LINK *)&Fam15IgnoreLinkList,
187   MakeKey,
188   NULL
189 };
190
191 /**
192  * Initial construction data for Family 15h North Bridge, for non-coherent only builds.
193  */
194 CONST NORTHBRIDGE ROMDATA HtFam15NbNonCoherentOnly =
195 {
196   8,
197   (PF_WRITE_ROUTING_TABLE)CommonVoid,
198   (PF_WRITE_NODEID)CommonVoid,
199   (PF_READ_DEFAULT_LINK)CommonReturnZero8,
200   (PF_ENABLE_ROUTING_TABLES)CommonVoid,
201   (PF_DISABLE_ROUTING_TABLES)CommonVoid,
202   (PF_VERIFY_LINK_IS_COHERENT)CommonReturnFalse,
203   (PF_READ_TOKEN)CommonReturnZero8,
204   (PF_WRITE_TOKEN)CommonVoid,
205   (PF_WRITE_FULL_ROUTING_TABLE)CommonVoid,
206   (PF_IS_ILLEGAL_TYPE_MIX)CommonReturnFalse,
207   (PF_IS_EXCEEDED_CAPABLE)CommonReturnFalse,
208   (PF_STOP_LINK)CommonVoid,
209   (PF_HANDLE_SPECIAL_LINK_CASE)CommonReturnFalse,
210   (PF_HANDLE_SPECIAL_NODE_CASE)CommonReturnFalse,
211   ReadSouthbridgeLink,
212   VerifyLinkIsNonCoherent,
213   Fam15SetConfigAddrMap,
214   Fam15NorthBridgeFreqMask,
215   GatherLinkFeatures,
216   SetLinkRegang,
217   SetLinkFrequency,
218   SetLinkUnitIdClumping,
219   (PF_WRITE_TRAFFIC_DISTRIBUTION)CommonVoid,
220   (PF_WRITE_LINK_PAIR_DISTRIBUTION)CommonVoid,
221   (PF_WRITE_VICTIM_DISTRIBUTION)CommonVoid,
222   Fam15BufferOptimizations,
223   Fam15GetNumCoresOnNode,
224   SetTotalNodesAndCores,
225   GetNodeCount,
226   LimitNodes,
227   ReadTrueLinkFailStatus,
228   Fam15GetNextLink,
229   GetPackageLink,
230   MakeLinkBase,
231   Fam15GetModuleInfo,
232   Fam15PostMailbox,
233   Fam15RetrieveMailbox,
234   Fam15GetSocket,
235   Fam15GetEnabledComputeUnits,
236   Fam15GetDualcoreComputeUnits,
237   0x00000001,
238   0x00000200,
239   18,
240   TRUE,
241   TRUE,
242   ((AMD_FAMILY_15) & ~(AMD_FAMILY_TN | AMD_FAMILY_KM)),
243   (PACKAGE_HTLINK_MAP) &HtFam15PackageLinkMap,
244   0,
245   NULL,
246   MakeKey,
247   NULL
248 };