5 * Link optimization support specific to family 10h processors.
7 * @xrefitem bom "File Content Label" "Release Content"
9 * @e sub-project: HyperTransport
10 * @e \$Revision: 56279 $ @e \$Date: 2011-07-11 13:11:28 -0600 (Mon, 11 Jul 2011) $
14 *****************************************************************************
16 * Copyright (C) 2012 Advanced Micro Devices, Inc.
17 * All rights reserved.
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.
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.
41 * ***************************************************************************
46 *----------------------------------------------------------------------------
49 *----------------------------------------------------------------------------
58 #include "htInterface.h"
60 #include "htNbOptimizationFam10.h"
65 #define FILECODE PROC_HT_FAM10_HTNBOPTIMIZATIONFAM10_FILECODE
66 /*----------------------------------------------------------------------------
67 * DEFINITIONS AND MACROS
69 *----------------------------------------------------------------------------
72 /*----------------------------------------------------------------------------------------*/
74 * Northbridge specific Frequency limit.
76 * @HtNbMethod{::F_NORTH_BRIDGE_FREQ_MASK}
78 * Return a mask that eliminates HT frequencies that cannot be used due to a slow
79 * northbridge frequency.
81 * @param[in] Node Result could (later) be for a specific Node
82 * @param[in] Interface Access to non-HT support functions.
83 * @param[in] PlatformConfig Platform profile/build option config structure.
84 * @param[in] Nb this northbridge
86 * @return Frequency mask
89 Fam10NorthBridgeFreqMask (
91 IN HT_INTERFACE *Interface,
92 IN PLATFORM_CONFIGURATION *PlatformConfig,
99 ASSERT (Node < MAX_NODES);
100 ASSERT (Interface != NULL);
101 // The interface to power management will return a system based result.
102 // So we only need to call it once, not on every link. Save the answer,
103 // and check to see if we can use a saved answer on subsequent calls.
105 if (Nb->CoreFrequency == 0) {
106 NbCoreFreq = Interface->GetMinNbCoreFreq (PlatformConfig, Nb->ConfigHandle);
107 NbCoreFreq = (NbCoreFreq / 100);
108 ASSERT (NbCoreFreq != 0);
109 Nb->CoreFrequency = NbCoreFreq;
111 NbCoreFreq = Nb->CoreFrequency;
115 // NbCoreFreq is minimum northbridge speed in hundreds of MHz.
116 // HT can not go faster than the minimum speed of the northbridge.
118 if ((NbCoreFreq >= 6) && (NbCoreFreq <= 26)) {
119 // Convert frequency to bit and all less significant bits,
120 // by setting next power of 2 and subtracting 1.
122 Supported = ((UINT32)1 << ((NbCoreFreq >> 1) + 2)) - 1;
123 } else if ((NbCoreFreq > 26) && (NbCoreFreq <= 32)) {
124 // Convert frequency to bit and all less significant bits,
125 // by setting next power of 2 and subtracting 1, noting that
126 // next power of two is two greater than non-extended frequencies
127 // (because of the register break).
129 Supported = ((UINT32)1 << ((NbCoreFreq >> 1) + 4)) - 1;
130 } else if (NbCoreFreq > 32) {
131 Supported = HT_FREQUENCY_LIMIT_MAX;
132 } else if (NbCoreFreq == 4) {
133 // unlikely cases, but include as a defensive measure, also avoid trick above
134 Supported = HT_FREQUENCY_LIMIT_400M;
135 } else if (NbCoreFreq == 2) {
136 Supported = HT_FREQUENCY_LIMIT_200M;
139 Supported = HT_FREQUENCY_LIMIT_200M;
145 /*----------------------------------------------------------------------------------------*/
147 * Northbridge specific Frequency limit.
149 * @HtNbMethod{::F_NORTH_BRIDGE_FREQ_MASK}
151 * Return a mask that eliminates HT frequencies that cannot be used due to a slow
152 * northbridge frequency.
154 * @param[in] Node Result could (later) be for a specific Node
155 * @param[in] Interface Access to non-HT support functions.
156 * @param[in] PlatformConfig Platform profile/build option config structure.
157 * @param[in] Nb this northbridge
159 * @return Frequency mask
162 Fam10RevDNorthBridgeFreqMask (
164 IN HT_INTERFACE *Interface,
165 IN PLATFORM_CONFIGURATION *PlatformConfig,
172 ASSERT (Node < MAX_NODES);
173 ASSERT (Interface != NULL);
174 // The interface to power management will return a system based result.
175 // So we only need to call it once, not on every link. Save the answer,
176 // and check to see if we can use a saved answer on subsequent calls.
178 if (Nb->CoreFrequency == 0) {
179 NbCoreFreq = Interface->GetMinNbCoreFreq (PlatformConfig, Nb->ConfigHandle);
180 NbCoreFreq = (NbCoreFreq / 100);
181 ASSERT (NbCoreFreq != 0);
182 Nb->CoreFrequency = NbCoreFreq;
184 NbCoreFreq = Nb->CoreFrequency;
187 // For Rev D, the Ht frequency can go twice the Nb COF, as long as it's HT3.
188 // (side note: we are not speculatively upgrading HT1 at 6 .. 10 to HT3,
189 // to avoid complicated recovery if the final speed is HT1.)
190 if (NbCoreFreq > 10) {
191 NbCoreFreq = NbCoreFreq * 2;
194 // NbCoreFreq is minimum northbridge speed in hundreds of MHz.
195 // HT can not go faster than the minimum speed of the northbridge.
197 if ((NbCoreFreq >= 6) && (NbCoreFreq <= 26)) {
198 // Convert frequency to bit and all less significant bits,
199 // by setting next power of 2 and subtracting 1.
201 Supported = ((UINT32)1 << ((NbCoreFreq >> 1) + 2)) - 1;
202 } else if ((NbCoreFreq > 26) && (NbCoreFreq <= 32)) {
203 // Convert frequency to bit and all less significant bits,
204 // by setting next power of 2 and subtracting 1, noting that
205 // next power of two is two greater than non-extended frequencies
206 // (because of the register break).
208 Supported = ((UINT32)1 << ((NbCoreFreq >> 1) + 4)) - 1;
209 } else if (NbCoreFreq > 32) {
210 Supported = HT_FREQUENCY_LIMIT_MAX;
211 } else if (NbCoreFreq == 4) {
212 // unlikely cases, but include as a defensive measure, also avoid trick above
213 Supported = HT_FREQUENCY_LIMIT_400M;
214 } else if (NbCoreFreq == 2) {
215 Supported = HT_FREQUENCY_LIMIT_200M;
218 Supported = HT_FREQUENCY_LIMIT_200M;