7 * Platform specific settings for HY DDR3 R-DIMM system
9 * @xrefitem bom "File Content Label" "Release Content"
11 * @e sub-project: (Mem/Ps)
12 * @e \$Revision: 52286 $ @e \$Date: 2011-05-04 03:48:21 -0600 (Wed, 04 May 2011) $
15 /*****************************************************************************
17 * Copyright (C) 2012 Advanced Micro Devices, Inc.
18 * All rights reserved.
20 * Redistribution and use in source and binary forms, with or without
21 * modification, are permitted provided that the following conditions are met:
22 * * Redistributions of source code must retain the above copyright
23 * notice, this list of conditions and the following disclaimer.
24 * * Redistributions in binary form must reproduce the above copyright
25 * notice, this list of conditions and the following disclaimer in the
26 * documentation and/or other materials provided with the distribution.
27 * * Neither the name of Advanced Micro Devices, Inc. nor the names of
28 * its contributors may be used to endorse or promote products derived
29 * from this software without specific prior written permission.
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
32 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
33 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
34 * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
35 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
36 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
37 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
38 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
39 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
40 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
42 * ***************************************************************************
46 /* This file contains routine that add platform specific support L1 */
50 #include "AdvancedApi.h"
54 #include "cpuFamRegisters.h"
59 #include "GeneralServices.h"
60 #include "OptionMemory.h"
61 #include "PlatformMemoryConfiguration.h"
65 #define FILECODE PROC_MEM_PS_HY_MPRHY3_FILECODE
66 /*----------------------------------------------------------------------------
67 * DEFINITIONS AND MACROS
69 *----------------------------------------------------------------------------
72 /*----------------------------------------------------------------------------
73 * TYPEDEFS AND STRUCTURES
75 *----------------------------------------------------------------------------
78 /*----------------------------------------------------------------------------
79 * PROTOTYPES OF LOCAL FUNCTIONS
81 *----------------------------------------------------------------------------
86 IN OUT MEM_NB_BLOCK *NBPtr
91 MemPGetPORFreqLimitRHy3 (
92 IN OUT MEM_NB_BLOCK *NBPtr
95 *-----------------------------------------------------------------------------
98 *-----------------------------------------------------------------------------
102 * ODT Settings for 1 Dimm or 2 Dimms Per Channel
104 * Speeds Supported, # of Dimms, # of QRDimms, DramTerm, QR DramTerm, Dynamic DramTerm
106 STATIC CONST DRAM_TERM_ENTRY HyRDdr3DramTerm2D[] = {
107 {DDR667 + DDR800 + DDR1066 + DDR1333 + DDR1600, ONE_DIMM, NO_DIMM, 1, 0, 0},
108 {DDR667 + DDR800 + DDR1066, TWO_DIMM, NO_DIMM, 3, 0, 2},
109 {DDR1333, TWO_DIMM, NO_DIMM, 5, 0, 2},
110 {DDR1600, TWO_DIMM, NO_DIMM, 5, 0, 1},
111 {DDR667 + DDR800 + DDR1066 + DDR1333, ONE_DIMM, ONE_DIMM, 0, 1, 2},
112 {DDR1600, ONE_DIMM, ONE_DIMM, 0, 1, 1},
113 {DDR667 + DDR800, TWO_DIMM, ONE_DIMM, 5, 1, 2},
114 {DDR1066 + DDR1333 + DDR1600, TWO_DIMM, ONE_DIMM, 5, 1, 1},
115 {DDR667 + DDR800, TWO_DIMM, TWO_DIMM, 0, 1, 2},
116 {DDR1066 + DDR1333 + DDR1600, TWO_DIMM, TWO_DIMM, 0, 1, 1}
119 * ODT Settings for 3 Dimms Per Channel
121 * Speeds Supported, # of Dimms, # of QRDimms, DramTerm, QR DramTerm, Dynamic DramTerm
123 STATIC CONST DRAM_TERM_ENTRY HyRDdr3DramTerm3D[] = {
124 {DDR667 + DDR800 + DDR1066 + DDR1333 + DDR1600, ONE_DIMM, NO_DIMM, 1, 0, 0},
125 {DDR667 + DDR800 + DDR1066, TWO_DIMM, NO_DIMM, 3, 0, 2},
126 {DDR1333 + DDR1600, TWO_DIMM, NO_DIMM, 5, 0, 2},
127 {DDR667 + DDR800 + DDR1066 + DDR1333 + DDR1600, THREE_DIMM, NO_DIMM, 3, 0, 2},
128 {DDR667 + DDR800 + DDR1066 + DDR1333, ONE_DIMM, ONE_DIMM, 0, 1, 2},
129 {DDR667 + DDR800, TWO_DIMM, ONE_DIMM, 5, 1, 2},
130 {DDR1066 + DDR1333 + DDR1600, TWO_DIMM, ONE_DIMM, 5, 1, 1},
131 {DDR667 + DDR800 + DDR1066 + DDR1333 + DDR1600, THREE_DIMM, ONE_DIMM, 3, 1, 2}
134 * POR Max Frequency supported for specific Dimm configurations for 1 Dimm Per Channel
136 * Dimm Config, # of Dimms, Max Freq @ 1.5V, Max Freq @ 1.35V, Max Freq @ 1.25
138 STATIC CONST POR_SPEED_LIMIT HyRDdr3PSPorFreqLimit1D[] = {
139 {SR_DIMM0 + DR_DIMM0, 1, DDR1333_FREQUENCY, DDR1333_FREQUENCY, 0},
140 {QR_DIMM0, 1, DDR1333_FREQUENCY, DDR1333_FREQUENCY, 0}
143 * POR Max Frequency supported for specific Dimm configurations for 2 Dimms Per Channel
145 * Dimm Config, # of Dimms, Max Freq @ 1.5V, Max Freq @ 1.35V, Max Freq @ 1.25
147 STATIC CONST POR_SPEED_LIMIT HyRDdr3PSPorFreqLimit2D[] = {
148 {SR_DIMM1 + DR_DIMM1, 1, DDR1333_FREQUENCY, DDR1333_FREQUENCY, 0},
149 {QR_DIMM1, 1, DDR1333_FREQUENCY, DDR1066_FREQUENCY, 0},
150 {SR_DIMM0 + DR_DIMM0 + SR_DIMM1 + DR_DIMM1, 2, DDR1333_FREQUENCY, DDR1333_FREQUENCY, 0},
151 {QR_DIMM0 + ANY_DIMM1, 2, DDR1066_FREQUENCY, DDR800_FREQUENCY, 0},
152 {ANY_DIMM0 + QR_DIMM1, 2, DDR1066_FREQUENCY, DDR800_FREQUENCY, 0}
155 * POR Max Frequency supported for specific Dimm configurations for 3 Dimms Per Channel
157 * Dimm Config, # of Dimms, Max Freq @ 1.5V, Max Freq @ 1.35V, Max Freq @ 1.25
159 STATIC CONST POR_SPEED_LIMIT HyRDdr3PSPorFreqLimit3D[] = {
160 {SR_DIMM2 + DR_DIMM2, 1, DDR1333_FREQUENCY, DDR1333_FREQUENCY, 0},
161 {SR_DIMM0 + DR_DIMM0 + SR_DIMM2 + DR_DIMM2, 2, DDR1333_FREQUENCY, DDR1333_FREQUENCY, 0},
162 {QR_DIMM1, 1, DDR1066_FREQUENCY, DDR1066_FREQUENCY, 0},
163 {QR_DIMM1 + SR_DIMM2 + DR_DIMM2, 2, DDR800_FREQUENCY, DDR800_FREQUENCY, 0},
164 {SR_DIMM0 + SR_DIMM1 + SR_DIMM2, 3, DDR1066_FREQUENCY, DDR1066_FREQUENCY, 0},
165 {SR_DIMM0 + DR_DIMM0 + SR_DIMM1 + DR_DIMM1 + SR_DIMM2 + DR_DIMM2, 3, DDR1066_FREQUENCY, DDR800_FREQUENCY, 0},
166 {SR_DIMM0 + DR_DIMM0 + QR_DIMM1 + SR_DIMM2 + DR_DIMM2, 3, DDR800_FREQUENCY, DDR667_FREQUENCY, 0}
169 /* -----------------------------------------------------------------------------*/
172 * This function is the constructor platform specific settings for R DIMM-DDR3 HY DDR3
174 * @param[in,out] *MemPtr Pointer to MEM_DATA_STRUCTURE
175 * @param[in,out] *ChannelPtr Pointer to CH_DEF_STRUCT
176 * @param[in,out] *PsPtr Pointer to MEM_PS_BLOCK
178 * @return AGESA_SUCCESS
183 MemPConstructPsRHy3 (
184 IN OUT MEM_DATA_STRUCT *MemPtr,
185 IN OUT CH_DEF_STRUCT *ChannelPtr,
186 IN OUT MEM_PS_BLOCK *PsPtr
189 ASSERT (MemPtr != 0);
190 ASSERT (ChannelPtr != 0);
192 if ((ChannelPtr->MCTPtr->LogicalCpuid.Family & AMD_FAMILY_10_HY) == 0) {
193 return AGESA_UNSUPPORTED;
195 if (ChannelPtr->TechType != DDR3_TECHNOLOGY) {
196 return AGESA_UNSUPPORTED;
198 if (ChannelPtr->RegDimmPresent != ChannelPtr->ChDimmValid) {
199 return AGESA_UNSUPPORTED;
201 PsPtr->MemPDoPs = MemPDoPsRHy3;
202 PsPtr->MemPGetPORFreqLimit = MemPGetPORFreqLimitRHy3;
204 return AGESA_SUCCESS;
207 /* -----------------------------------------------------------------------------*/
210 * This is function sets the platform specific settings for R-DDR3 HY DDR3
212 * @param[in,out] *NBPtr Pointer to MEM_NB_BLOCK
214 * @return TRUE - Find settings for corresponding platform and dimm population.
215 * @return FALSE - Fail to find settings for corresponding platform and dimm population.
222 IN OUT MEM_NB_BLOCK *NBPtr
225 CONST DRAM_TERM_ENTRY *DramTermPtr;
226 UINT8 MaxDimmsPerChannel;
227 UINT8 *DimmsPerChPtr;
232 DimmsPerChPtr = FindPSOverrideEntry (NBPtr->RefPtr->PlatformMemoryConfiguration, PSO_MAX_DIMMS, NBPtr->MCTPtr->SocketId, NBPtr->ChannelPtr->ChannelID, 0, NULL, NULL);
233 if (DimmsPerChPtr != NULL) {
234 MaxDimmsPerChannel = *DimmsPerChPtr;
236 MaxDimmsPerChannel = 2;
239 if ((MaxDimmsPerChannel == 1) || (MaxDimmsPerChannel == 2)) {
240 DramTermSize = GET_SIZE_OF (HyRDdr3DramTerm2D);
241 DramTermPtr = HyRDdr3DramTerm2D;
242 } else if (MaxDimmsPerChannel == 3) {
243 DramTermSize = GET_SIZE_OF (HyRDdr3DramTerm3D);
244 DramTermPtr = HyRDdr3DramTerm3D;
249 if (!MemPGetDramTerm (NBPtr, DramTermSize, DramTermPtr)) {
253 // Special Cases for certain configs not covered by the table
255 // 3DPCH Fully populated.
256 if ((MaxDimmsPerChannel == 3) && (NBPtr->ChannelPtr->Dimms == 3)) {
257 NBPtr->PsPtr->DramTerm = 5; //30 Ohms
258 NBPtr->PsPtr->QR_DramTerm = 1; // 60 Ohms
263 /* -----------------------------------------------------------------------------*/
266 * This is function gets the POR speed limit for R-DDR3 HY
268 * @param[in,out] *NBPtr Pointer to MEM_NB_BLOCK
274 MemPGetPORFreqLimitRHy3 (
275 IN OUT MEM_NB_BLOCK *NBPtr
278 UINT8 *DimmsPerChPtr;
282 CONST POR_SPEED_LIMIT *FreqLimitPtr;
285 DCTPtr = NBPtr->DCTPtr;
286 DimmsPerChPtr = FindPSOverrideEntry (NBPtr->RefPtr->PlatformMemoryConfiguration, PSO_MAX_DIMMS, NBPtr->MCTPtr->SocketId, NBPtr->ChannelPtr->ChannelID, 0, NULL, NULL);
287 if (DimmsPerChPtr != NULL) {
288 MaxDimmPerCH = *DimmsPerChPtr;
293 if (MaxDimmPerCH == 4) {
294 DCTPtr->Timings.DimmExclude |= DCTPtr->Timings.DctDimmValid;
295 PutEventLog (AGESA_CRITICAL, MEM_ERROR_UNSUPPORTED_DIMM_CONFIG, NBPtr->Node, NBPtr->Dct, NBPtr->Channel, 0, &NBPtr->MemPtr->StdHeader);
296 SetMemError (AGESA_CRITICAL, NBPtr->MCTPtr);
297 // Change target speed to highest value so it won't affect other channels when leveling frequency across the node.
298 NBPtr->DCTPtr->Timings.TargetSpeed = UNSUPPORTED_DDR_FREQUENCY;
300 } else if (MaxDimmPerCH == 3) {
301 FreqLimitPtr = HyRDdr3PSPorFreqLimit3D;
302 FreqLimitSize = GET_SIZE_OF (HyRDdr3PSPorFreqLimit3D);
303 } else if (MaxDimmPerCH == 2) {
304 FreqLimitPtr = HyRDdr3PSPorFreqLimit2D;
305 FreqLimitSize = GET_SIZE_OF (HyRDdr3PSPorFreqLimit2D);
307 FreqLimitPtr = HyRDdr3PSPorFreqLimit1D;
308 FreqLimitSize = GET_SIZE_OF (HyRDdr3PSPorFreqLimit1D);
311 SpeedLimit = MemPGetPorFreqLimit (NBPtr, FreqLimitSize, FreqLimitPtr);
313 if (SpeedLimit != 0) {
314 if (DCTPtr->Timings.TargetSpeed > SpeedLimit) {
315 DCTPtr->Timings.TargetSpeed = SpeedLimit;
318 DCTPtr->Timings.DimmExclude |= DCTPtr->Timings.DctDimmValid;
319 PutEventLog (AGESA_CRITICAL, MEM_ERROR_UNSUPPORTED_DIMM_CONFIG, NBPtr->Node, NBPtr->Dct, NBPtr->Channel, 0, &NBPtr->MemPtr->StdHeader);
320 SetMemError (AGESA_CRITICAL, NBPtr->MCTPtr);
321 // Change target speed to highest value so it won't affect other channels when leveling frequency across the node.
322 NBPtr->DCTPtr->Timings.TargetSpeed = UNSUPPORTED_DDR_FREQUENCY;