7 * Memory Controller, registered dimms
9 * @xrefitem bom "File Content Label" "Release Content"
11 * @e sub-project: (Mem/Ardk)
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 AM3 */
51 #include "OptionMemory.h"
52 #include "PlatformMemoryConfiguration.h"
55 #include "cpuFamRegisters.h"
60 #define FILECODE PROC_MEM_ARDK_HY_MARHY3_FILECODE
61 /*----------------------------------------------------------------------------
62 * DEFINITIONS AND MACROS
64 *----------------------------------------------------------------------------
67 /*----------------------------------------------------------------------------
68 * TYPEDEFS AND STRUCTURES
70 *----------------------------------------------------------------------------
73 /*----------------------------------------------------------------------------
74 * PROTOTYPES OF LOCAL FUNCTIONS
76 *----------------------------------------------------------------------------
80 *-----------------------------------------------------------------------------
83 *-----------------------------------------------------------------------------
86 STATIC CONST UINT8 ROMDATA HyRDdr3CLKDis[] = {0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00};
88 // Even chip select maps to M[B,A]_CKE[0]
89 // Odd chip select maps to M[B,A]_CKE[1]
90 STATIC CONST UINT8 ROMDATA HyRDdr3CKETri[] = {0x55, 0xAA};
92 // 2 dimms per channel
93 // Dimm 0: BP_MEMODTx[2,0]
94 // Dimm 1: BP_MEMODTx[3,1]
95 STATIC CONST UINT8 ROMDATA HyRDdr3ODTTri2D[] = {0x03, 0x0C, 0x32, 0xC8};
96 // 3 dimms per channel
97 // Dimm 0: BP_MEMODTx[0]
98 // Dimm 1: BP_MEMODTx[3,1]
99 // Dimm 2: BP_MEMODTx[2]
100 STATIC CONST UINT8 ROMDATA HyRDdr3ODTTri3D[] = {0x03, 0x0C, 0x30, 0xC8};
101 // 4 dimms per channel
102 // Dimm 0: BP_MEMODTx[0]
103 // Dimm 1: BP_MEMODTx[1]
104 // Dimm 2: BP_MEMODTx[2]
105 // Dimm 3: BP_MEMODTx[3]
106 STATIC CONST UINT8 ROMDATA HyRDdr3ODTTri4D[] = {0x03, 0x0C, 0x30, 0xC0};
108 // BIOS must not tri-state chip select pin corresponding to the second chip
109 // select of a single rank registered dimm
110 STATIC CONST UINT8 ROMDATA HyRDdr3CSTri[] = {0x01, 0x03, 0x04, 0x0C, 0x10, 0x30, 0x40, 0xC0};
112 /* -----------------------------------------------------------------------------*/
115 * This is function sets the platform specific settings for HY DDR3 L1 system
117 * @param[in,out] *MemData Pointer to MEM_DATA_STRUCTURE
118 * @param[in] SocketID Socket number
119 * @param[in] *CurrentChannel Pointer to CH_DEF_STRUCT
121 * @return AGESA_SUCCESS
122 * @return CurrentChannel->MemClkDisMap Points this pointer to HY MemClkDis table
123 * @return CurrentChannel->ChipSelTriMap Points this pointer to HY CS table
124 * @return CurrentChannel->CKETriMap Points this pointer to HY ODT table
125 * @return CurrentChannel->ODTTriMap Points this pointer to HY CKE table
126 * @return CurrentChannel->DctEccDQSLike Indicates the bytes that should be averaged for ECC
127 * @return CurrentChannel->DctEccDQSScale Indicates the scale that should be used for Averaging ECC byte
128 * @return CurrentChannel->DctAddrTmg Address Command Timing Settings for specified channel
129 * @return CurrentChannel->DctOdcCtl Drive Strength settings for specified channel
130 * @return CurrentChannel->SlowMode Slow Mode
136 IN OUT MEM_DATA_STRUCT *MemData,
138 IN OUT CH_DEF_STRUCT *CurrentChannel
142 // Address Timings and Drive Strengths for 1 DIMM per channel or 2 Dimms per Channel
144 // Code searches table for matching speed, then matches the current dimm
145 // population and # of dimms to current config and programs the Addr Timing and RC2/RC2
147 // Frequency, Dimm Config ,
148 // Address Timing Value(F2x[1, 0]9C_x04), RC2/RC8 Value, # Dimms to match
150 STATIC CONST ADV_R_PSCFG_ENTRY PSCfg2DIMMs[] = {
151 {DDR800_FREQUENCY, SR_DIMM0 + DR_DIMM0 + SR_DIMM1 + DR_DIMM1, \
152 0x00000000, 0x0000, 1},
153 {DDR800_FREQUENCY, QR_DIMM0 + QR_DIMM1, \
154 0x00000000, 0x0040, 1},
155 {DDR800_FREQUENCY, ANY_DIMM0 + ANY_DIMM1, \
156 0x00000000, 0x4004, 2},
157 {DDR1066_FREQUENCY, SR_DIMM0 + DR_DIMM0 + SR_DIMM1 + DR_DIMM1, \
158 0x003C3C3C, 0x0000,1},
159 {DDR1066_FREQUENCY, QR_DIMM0 + QR_DIMM1, \
160 0x003C3C3C, 0x0040, 1},
161 {DDR1066_FREQUENCY, SR_DIMM0 + DR_DIMM0 + SR_DIMM1 + DR_DIMM1, \
162 0x003A3C3A, 0x4004, 2},
163 {DDR1066_FREQUENCY, QR_DIMM0 + ANY_DIMM1, \
164 0x003A3C3A, 0x4004, 2},
165 {DDR1066_FREQUENCY, ANY_DIMM0 + QR_DIMM1, \
166 0x003A3C3A, 0x4004, 2},
167 {DDR1333_FREQUENCY, SR_DIMM0 + DR_DIMM0 + SR_DIMM1 + DR_DIMM1, \
168 0x003A3A3A, 0x0000, 1},
169 {DDR1333_FREQUENCY, QR_DIMM0 + QR_DIMM1, \
170 0x003A3A3A, 0x0040, 1},
171 {DDR1333_FREQUENCY, SR_DIMM0 + DR_DIMM0 + SR_DIMM1 + DR_DIMM1, \
172 0x00383A38, 0x4040, 2},
173 {DDR1333_FREQUENCY, QR_DIMM0 + ANY_DIMM1, \
174 0x00383A38, 0x4004, 2},
175 {DDR1333_FREQUENCY, ANY_DIMM0 + QR_DIMM1, \
176 0x00383A38, 0x4004, 2},
177 {DDR1600_FREQUENCY, SR_DIMM0 + DR_DIMM0 + SR_DIMM1 + DR_DIMM1, \
178 0x00373937, 0x0000, 1},
179 {DDR1600_FREQUENCY, QR_DIMM0 + QR_DIMM1, \
180 0x00373937, 0x0040, 1},
181 {DDR1600_FREQUENCY, ANY_DIMM0 + ANY_DIMM1, \
182 0x00353935, 0x4004, 2}
185 // Address Timings and Drive Strengths for 3 DIMMs per channel
187 // Code searches table for matching speed, then matches the current dimm
188 // population and # of dimms to current config and programs the Addr Timing and RC2/RC2
190 // Frequency, Dimm Config ,
191 // Address Timing Value(F2x[1, 0]9C_x04), RC2/RC8 Value, # Dimms to match
193 STATIC CONST ADV_R_PSCFG_ENTRY PSCfg3DIMMs[] = {
194 {DDR800_FREQUENCY, SR_DIMM0 + DR_DIMM0 + SR_DIMM1 + DR_DIMM1 + SR_DIMM2 + DR_DIMM2, \
195 0x00000000, 0x0000, 1},
196 {DDR800_FREQUENCY, SR_DIMM0 + DR_DIMM0 + SR_DIMM1 + DR_DIMM1 + SR_DIMM2 + DR_DIMM2, \
197 0x00000000, 0x4040, 2},
198 {DDR800_FREQUENCY, SR_DIMM0 + DR_DIMM0 + ANY_DIMM1 + SR_DIMM2 + DR_DIMM2, \
199 0x00380038, 0x4004, 3},
200 {DDR800_FREQUENCY, QR_DIMM1, \
201 0x00000000, 0x0040, 1},
202 {DDR800_FREQUENCY, SR_DIMM0 + DR_DIMM0 + QR_DIMM1 + SR_DIMM2 + DR_DIMM2, \
203 0x00000000, 0x4004, 2},
204 {DDR1066_FREQUENCY, SR_DIMM0 + DR_DIMM0 + SR_DIMM1 + DR_DIMM1 + SR_DIMM2 + DR_DIMM2, \
205 0x003C3C3C, 0x0000, 1},
206 {DDR1066_FREQUENCY, SR_DIMM0 + DR_DIMM0 + SR_DIMM1 + DR_DIMM1 + SR_DIMM2 + DR_DIMM2, \
207 0x003A3C3A, 0x4040, 2},
208 {DDR1066_FREQUENCY, SR_DIMM0 + DR_DIMM0 + SR_DIMM1 + DR_DIMM1 + SR_DIMM2 + DR_DIMM2, \
209 0x00373C37, 0x4040, 3},
210 {DDR1066_FREQUENCY, SR_DIMM0 + DR_DIMM0 + QR_DIMM1 + SR_DIMM2 + DR_DIMM2, \
211 0x00373C37, 0x4004, 3},
212 {DDR1066_FREQUENCY, QR_DIMM1, \
213 0x003C3C3C, 0x0040, 1},
214 {DDR1066_FREQUENCY, SR_DIMM0 + DR_DIMM0 + QR_DIMM1 + SR_DIMM2 + DR_DIMM2, \
215 0x003A3C3A, 0x4004, 2},
216 {DDR1333_FREQUENCY, SR_DIMM0 + DR_DIMM0 + SR_DIMM1 + DR_DIMM1 + SR_DIMM2 + DR_DIMM2, \
217 0x003A3A3A, 0x0000, 1},
218 {DDR1333_FREQUENCY, SR_DIMM0 + DR_DIMM0 + SR_DIMM1 + DR_DIMM1 + SR_DIMM2 + DR_DIMM2, \
219 0x00383A38, 0x4040, 2},
220 {DDR1333_FREQUENCY, SR_DIMM0 + DR_DIMM0 + ANY_DIMM1 + SR_DIMM2 + DR_DIMM2, \
221 0x00343A34, 0x4004, 3},
222 {DDR1333_FREQUENCY, QR_DIMM1, \
223 0x003A3A3A, 0x0040, 1},
224 {DDR1333_FREQUENCY, SR_DIMM0 + DR_DIMM0 + QR_DIMM1 + SR_DIMM2 + DR_DIMM2, \
225 0x00383A38, 0x4004, 2},
226 {DDR1600_FREQUENCY, SR_DIMM0 + DR_DIMM0 + SR_DIMM1 + DR_DIMM1 + SR_DIMM2 + DR_DIMM2, \
227 0x00393939, 0x0000, 1},
228 {DDR1600_FREQUENCY, SR_DIMM0 + DR_DIMM0 + SR_DIMM1 + DR_DIMM1 + SR_DIMM2 + DR_DIMM2, \
229 0x00363936, 0x4040, 2},
230 {DDR1600_FREQUENCY, SR_DIMM0 + DR_DIMM0 + ANY_DIMM1 + SR_DIMM2 + DR_DIMM2, \
231 0x00303930, 0x4004, 3},
232 {DDR1600_FREQUENCY, QR_DIMM1, \
233 0x00393939, 0x0040, 1},
234 {DDR1600_FREQUENCY, SR_DIMM0 + DR_DIMM0 + QR_DIMM1 + SR_DIMM2 + DR_DIMM2, \
235 0x00363936, 0x4004, 2}
238 // DIMM ODT Pattern (1 or 2 DIMMs per channel)
241 // Fn2_9C 180, Fn2_9C 181, Fn2_9C 182, Fn2_9C 183, # Dimms to match
243 STATIC CONST ADV_PSCFG_ODT_ENTRY PSCfg2DIMMsODT[] = {
245 0x00000000, 0x00000000, 0x00000001, 0x00000000, 1},
247 0x00000000, 0x00000000, 0x00000104, 0x00000000, 1},
249 0x00000000, 0x00000000, 0x00000505, 0x00000505, 1},
251 0x00000000, 0x00000000, 0x00020000, 0x00000000, 1},
253 0x00000000, 0x00000000, 0x02080000, 0x00000000, 1},
255 0x00000000, 0x00000000, 0x0A0A0000, 0x0A0A0000, 1},
256 {SR_DIMM0 + DR_DIMM0 + SR_DIMM1 + DR_DIMM1, \
257 0x01010202, 0x00000000, 0x09030603, 0x00000000, 2},
258 {SR_DIMM0 + DR_DIMM0 + QR_DIMM1, \
259 0x01010A0A, 0x01010000, 0x01030E0B, 0x01090000, 2},
260 {QR_DIMM0 + SR_DIMM1 + DR_DIMM1, \
261 0x05050202, 0x00000202, 0x0D070203, 0x00000206, 2},
262 {QR_DIMM0 + QR_DIMM1, \
263 0x05050A0A, 0x05050A0A, 0x05070A0B, 0x050D0A0E, 2}
265 // DIMM ODT Pattern (3 DIMMs per channel)
268 // Fn2_9C 180, Fn2_9C 181, Fn2_9C 182, Fn2_9C 183, # Dimms to match
270 STATIC CONST ADV_PSCFG_ODT_ENTRY PSCfg3DIMMsODT[] = {
271 {SR_DIMM2 + DR_DIMM2, \
272 0x00000000, 0x00000000, 0x00000000, 0x00000404, 1},
273 {SR_DIMM0 + DR_DIMM0, \
274 0x00000000, 0x00000000, 0x00000101, 0x00000000, 1},
275 {SR_DIMM0 + DR_DIMM0 + SR_DIMM2 + DR_DIMM2, \
276 0x00000404, 0x00000101, 0x00000405, 0x00000105, 2},
277 {SR_DIMM0 + DR_DIMM0 + SR_DIMM1 + DR_DIMM1 + SR_DIMM2 + DR_DIMM2, \
278 0x05050606, 0x00000303, 0x0D070607, 0x00000307, 3},
280 0x00000000, 0x00000000, 0x080A0000, 0x020A0000, 1},
281 {QR_DIMM1 + SR_DIMM2 + DR_DIMM2, \
282 0x04040000, 0x04040A0A, 0x04060000, 0x040C0A0E, 2},
283 {SR_DIMM0 + DR_DIMM0 + QR_DIMM1, \
284 0x01010A0A, 0x01010000, 0x01030A0B, 0x01090000, 2},
285 {SR_DIMM0 + DR_DIMM0 + QR_DIMM1 + SR_DIMM2 + DR_DIMM2, \
286 0x05050E0E, 0x05050B0B, 0x05070E0F, 0x050D0B0F, 3}
289 // DIMM ODT Pattern (4 DIMMs per channel)
292 // Fn2_9C 180, Fn2_9C 181, Fn2_9C 182, Fn2_9C 183, # Dimms to match
294 STATIC CONST ADV_PSCFG_ODT_ENTRY PSCfg4DIMMsODT[] = {
296 0x00000000, 0x00000000, 0x00000000, 0x08080000, 1},
297 {ANY_DIMM2 + ANY_DIMM3, \
298 0x00000000, 0x04040808, 0x00000000, 0x0C0C0C0C, 2},
299 {ANY_DIMM1 + ANY_DIMM2 + ANY_DIMM3, \
300 0x0C0C0000, 0x06060A0A, 0x0E0E0000, 0x0E0E0E0E, 3},
301 {ANY_DIMM0 + ANY_DIMM1 + ANY_DIMM2 + ANY_DIMM3, \
302 0x0D0D0E0E, 0x07070B0B, 0x0F0F0F0F, 0x0F0F0F0F, 4}
305 // DIMM Write Leveling ODT Pattern for 1 or 2 Dimms Per Channel
307 // Dimm Config, WrLvOdt (Fn2_9C_0x08[11:8]) Value for each Dimm, # Dimms to match
309 STATIC CONST ADV_R_PSCFG_WL_ODT_ENTRY PSCfg2DIMMsWlODT[] = {
310 {SR_DIMM0, {0x01, 0x00, 0x00, 0x00}, 1},
311 {DR_DIMM0, {0x04, 0x00, 0x00, 0x00}, 1},
312 {QR_DIMM0, {0x05, 0x00, 0x00, 0x00}, 1},
313 {SR_DIMM1, {0x00, 0x02, 0x00, 0x00}, 1},
314 {DR_DIMM1, {0x00, 0x08, 0x00, 0x00}, 1},
315 {QR_DIMM1, {0x00, 0x0A, 0x00, 0x00}, 1},
316 {SR_DIMM0 + DR_DIMM0 + SR_DIMM1 + DR_DIMM1, {0x03, 0x03, 0x00, 0x00}, 2},
317 {SR_DIMM0 + QR_DIMM1, {0x0B, 0x03, 0x00, 0x09}, 2},
318 {DR_DIMM0 + QR_DIMM1, {0x0B, 0x03, 0x00, 0x09}, 2},
319 {QR_DIMM0 + SR_DIMM1, {0x03, 0x07, 0x06, 0x00}, 2},
320 {QR_DIMM0 + DR_DIMM1, {0x03, 0x07, 0x06, 0x00}, 2},
321 {QR_DIMM0 + QR_DIMM1, {0x0B, 0x07, 0x0E, 0x0D}, 2}
324 // DIMM Write Leveling ODT Pattern 3 Dimms Per Channel
326 // Dimm Config, WrLvOdt (Fn2_9C_0x08[11:8]) Value for each Dimm, # Dimms to match
328 STATIC CONST ADV_R_PSCFG_WL_ODT_ENTRY PSCfg3DIMMsWlODT[] = {
329 {SR_DIMM2 + DR_DIMM2, {0x00, 0x00, 0x04, 0x00}, 1},
330 {SR_DIMM0 + DR_DIMM0, {0x01, 0x02, 0x00, 0x00}, 1},
331 {SR_DIMM0 + DR_DIMM0 + SR_DIMM2 + DR_DIMM2, {0x05, 0x00, 0x05, 0x00}, 2},
332 {SR_DIMM0 + DR_DIMM0 + SR_DIMM1 + DR_DIMM1 + SR_DIMM2 + DR_DIMM2, {0x07, 0x07, 0x07, 0x00}, 3},
333 {QR_DIMM1, {0x00, 0x0A, 0x00, 0x0A}, 1},
334 {QR_DIMM1 + SR_DIMM2 + DR_DIMM2, {0x00, 0x06, 0x0E, 0x0C}, 2},
335 {SR_DIMM0 + DR_DIMM0 + QR_DIMM1, {0x0B, 0x03, 0x00, 0x09}, 2},
336 {SR_DIMM0 + DR_DIMM0 + QR_DIMM1 + SR_DIMM2 + DR_DIMM2, {0x0F, 0x07, 0x0F, 0x0D}, 3}
339 // DIMM Write Leveling ODT Pattern 4 Dimms Per Channel
341 // Dimm Config, WrLvOdt (Fn2_9C_0x08[11:8]) Value for each Dimm, # Dimms to match
343 STATIC CONST ADV_R_PSCFG_WL_ODT_ENTRY PSCfg4DIMMsWlODT[] = {
344 {ANY_DIMM3, {0x00, 0x00, 0x00, 0x08}, 1},
345 {ANY_DIMM2 + ANY_DIMM3, {0x00, 0x00, 0x0C, 0x0C}, 2},
346 {ANY_DIMM1 + ANY_DIMM2 + ANY_DIMM3, {0x00, 0x0E, 0x0E, 0x0E}, 3},
347 {ANY_DIMM0 + ANY_DIMM1 + ANY_DIMM2 + ANY_DIMM3, {0x0F, 0x0F, 0x0F, 0x0F}, 4}
356 UINT16 _DIMMRankType;
362 UINT32 PhyRODTCSHigh;
364 UINT32 PhyWODTCSHigh;
368 UINT8 PSCfgWlODTSize;
371 CONST ADV_R_PSCFG_ENTRY *PSCfgPtr;
372 CONST ADV_PSCFG_ODT_ENTRY *PSCfgODTPtr;
373 CONST ADV_R_PSCFG_WL_ODT_ENTRY *PSCfgWlODTPtr;
374 UINT8 *DimmsPerChPtr;
376 ASSERT (MemData != NULL);
377 ASSERT (CurrentChannel != NULL);
392 if ((CurrentChannel->MCTPtr->LogicalCpuid.Family & AMD_FAMILY_10_HY) == 0) {
393 return AGESA_UNSUPPORTED;
395 if (CurrentChannel->TechType != DDR3_TECHNOLOGY) {
396 return AGESA_UNSUPPORTED;
398 if (CurrentChannel->RegDimmPresent == 0) {
399 return AGESA_UNSUPPORTED;
403 Dimms = CurrentChannel->Dimms;
404 Speed = CurrentChannel->DCTPtr->Timings.Speed;
405 DimmsPerChPtr = FindPSOverrideEntry (MemData->ParameterListPtr->PlatformMemoryConfiguration, PSO_MAX_DIMMS, SocketID, CurrentChannel->ChannelID, 0, NULL, NULL);
406 if (DimmsPerChPtr != NULL) {
407 MaxDimmPerCH = *DimmsPerChPtr;
412 DIMMRankType = MemAGetPsRankType (CurrentChannel);
414 if (MaxDimmPerCH == 4) {
417 PSCfgODTPtr = PSCfg4DIMMsODT;
418 PSCfgWlODTPtr = PSCfg4DIMMsWlODT;
419 PSCfgODTSize = sizeof (PSCfg4DIMMsODT) / sizeof (ADV_PSCFG_ODT_ENTRY);
420 PSCfgWlODTSize = sizeof (PSCfg4DIMMsWlODT) / sizeof (ADV_R_PSCFG_WL_ODT_ENTRY);
421 } else if (MaxDimmPerCH == 3) {
422 PSCfgPtr = PSCfg3DIMMs;
423 PSCfgSize = sizeof (PSCfg3DIMMs) / sizeof (ADV_R_PSCFG_ENTRY);
424 PSCfgODTPtr = PSCfg3DIMMsODT;
425 PSCfgWlODTPtr = PSCfg3DIMMsWlODT;
426 PSCfgODTSize = sizeof (PSCfg3DIMMsODT) / sizeof (ADV_PSCFG_ODT_ENTRY);
427 PSCfgWlODTSize = sizeof (PSCfg3DIMMsWlODT) / sizeof (ADV_R_PSCFG_WL_ODT_ENTRY);
429 PSCfgPtr = PSCfg2DIMMs;
430 PSCfgSize = sizeof (PSCfg2DIMMs) / sizeof (ADV_R_PSCFG_ENTRY);
431 PSCfgODTPtr = PSCfg2DIMMsODT;
432 PSCfgWlODTPtr = PSCfg2DIMMsWlODT;
433 PSCfgODTSize = sizeof (PSCfg2DIMMsODT) / sizeof (ADV_PSCFG_ODT_ENTRY);
434 PSCfgWlODTSize = sizeof (PSCfg2DIMMsWlODT) / sizeof (ADV_R_PSCFG_WL_ODT_ENTRY);
437 // AddrTmgCTL and DctOdcCtl
438 if (MaxDimmPerCH != 4) {
439 for (i = 0; i < PSCfgSize; i++, PSCfgPtr++) {
440 if ((Speed != PSCfgPtr->Speed) || (Dimms != PSCfgPtr->Dimms)) {
444 _DIMMRankType = DIMMRankType & PSCfgPtr->DIMMRankType;
445 for (j = 0; j < MAX_DIMMS_PER_CHANNEL; j++) {
446 if ((_DIMMRankType & (UINT16) 0x0F << (j << 2)) != 0) {
450 if (DimmTpMatch == PSCfgPtr->Dimms) {
451 AddrTmgCTL = PSCfgPtr->AddrTmg;
452 DctOdcCtl = 0x00223222;
453 RC2RC8 = PSCfgPtr->RC2RC8;
460 // Overrides and/or exceptions
463 for (j = 0; j < MAX_DIMMS_PER_CHANNEL; j++) {
464 if ((DIMMRankType & (UINT16) 0x03 << (j << 2)) != 0) {
468 if (MaxDimmPerCH == 4) {
469 if (DimmTpMatch > 0) {
470 DctOdcCtl = 0x00223222;
471 if ((Speed == DDR800_FREQUENCY) && (DimmTpMatch == 1)) {
472 DctOdcCtl = 0x00113222;
475 if (DimmTpMatch >= 3) {
476 AddrTmgCTL |= 0x002F0000;
478 if (DimmTpMatch >= 2) {
481 } else if ((MaxDimmPerCH == 3) && (CurrentChannel->Dimms == 3)) {
482 DctOdcCtl = 0x00113222;
484 if ((Dimms == 1) && (DimmTpMatch == 1)) {
485 DctOdcCtl = 0x00113222;
490 for (j = 0; j < MAX_DIMMS_PER_CHANNEL; j++) {
491 // CtrlWrd02(s) will contain the info. of SPD byte 63 after MemTDIMMPresence3 execution.
492 if (CurrentChannel->CtrlWrd02[j] > 0) {
493 if (CurrentChannel->CtrlWrd02[j] == 1) {
494 // Store real RC2 and RC8 value (High byte) into CtrlWrd02(s) and CtrlWrd08(s).
495 CurrentChannel->CtrlWrd02[j] = (UINT8) (RC2RC8 >> 12) & 0x000F;
496 CurrentChannel->CtrlWrd08[j] = (UINT8) (RC2RC8 >> 8) & 0x000F;
498 // Store real RC2 and RC8 value (low byte) into CtrlWrd02(s) and CtrlWrd08(s).
499 CurrentChannel->CtrlWrd02[j] = (UINT8) (RC2RC8 >> 4) & 0x000F;
500 CurrentChannel->CtrlWrd08[j] = (UINT8) RC2RC8 & 0x000F;
506 for (i = 0; i < PSCfgODTSize; i++, PSCfgODTPtr++) {
507 if (Dimms != PSCfgODTPtr->Dimms) {
511 _DIMMRankType = DIMMRankType & PSCfgODTPtr->DIMMRankType;
512 for (j = 0; j < MAX_DIMMS_PER_CHANNEL; j++) {
513 if ((_DIMMRankType & (UINT16) 0x0F << (j << 2)) != 0) {
517 if (DimmTpMatch == PSCfgODTPtr->Dimms) {
518 PhyRODTCSLow = PSCfgODTPtr->PhyRODTCSLow;
519 PhyRODTCSHigh = PSCfgODTPtr->PhyRODTCSHigh;
520 PhyWODTCSLow = PSCfgODTPtr->PhyWODTCSLow;
521 PhyWODTCSHigh = PSCfgODTPtr->PhyWODTCSHigh;
527 for (i = 0; i < PSCfgWlODTSize; i++, PSCfgWlODTPtr++) {
528 if (Dimms != PSCfgWlODTPtr->Dimms) {
532 _DIMMRankType = DIMMRankType & PSCfgWlODTPtr->DIMMRankType;
533 for (j = 0; j < MAX_DIMMS_PER_CHANNEL; j++) {
534 if ((_DIMMRankType & (UINT16) 0x0F << (j << 2)) != 0) {
538 if (DimmTpMatch == PSCfgWlODTPtr->Dimms) {
539 PhyWLODT[0] = PSCfgWlODTPtr->PhyWrLvOdt[0];
540 PhyWLODT[1] = PSCfgWlODTPtr->PhyWrLvOdt[1];
541 PhyWLODT[2] = PSCfgWlODTPtr->PhyWrLvOdt[2];
542 PhyWLODT[3] = PSCfgWlODTPtr->PhyWrLvOdt[3];
548 DctOdcCtl |= 0x20000000;
550 CurrentChannel->MemClkDisMap = (UINT8 *) HyRDdr3CLKDis;
551 CurrentChannel->CKETriMap = (UINT8 *) HyRDdr3CKETri;
552 CurrentChannel->ChipSelTriMap = (UINT8 *) HyRDdr3CSTri;
554 switch (MaxDimmPerCH) {
556 CurrentChannel->ODTTriMap = (UINT8 *) HyRDdr3ODTTri3D;
559 CurrentChannel->ODTTriMap = (UINT8 *) HyRDdr3ODTTri4D;
562 CurrentChannel->ODTTriMap = (UINT8 *) HyRDdr3ODTTri2D; // Most conservative
565 CurrentChannel->DctAddrTmg = AddrTmgCTL;
566 CurrentChannel->DctOdcCtl = DctOdcCtl;
567 CurrentChannel->PhyRODTCSLow = PhyRODTCSLow;
568 CurrentChannel->PhyRODTCSHigh = PhyRODTCSHigh;
569 CurrentChannel->PhyWODTCSLow = PhyWODTCSLow;
570 CurrentChannel->PhyWODTCSHigh = PhyWODTCSHigh;
571 for (i = 0; i < sizeof (CurrentChannel->PhyWLODT); i++) {
572 CurrentChannel->PhyWLODT[i] = PhyWLODT[i];
574 CurrentChannel->SlowMode = SlowMode;
576 return AGESA_SUCCESS;