7 * Platform specific settings for DR DDR2 L1 system
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 L1 */
52 #include "OptionMemory.h"
53 #include "PlatformMemoryConfiguration.h"
56 #include "cpuFamRegisters.h"
61 #define FILECODE PROC_MEM_ARDK_DR_MARDR2_FILECODE
62 /*----------------------------------------------------------------------------
63 * DEFINITIONS AND MACROS
65 *----------------------------------------------------------------------------
68 /*----------------------------------------------------------------------------
69 * TYPEDEFS AND STRUCTURES
71 *----------------------------------------------------------------------------
74 /*----------------------------------------------------------------------------
75 * PROTOTYPES OF LOCAL FUNCTIONS
77 *----------------------------------------------------------------------------
81 *-----------------------------------------------------------------------------
84 *-----------------------------------------------------------------------------
87 STATIC CONST UINT8 ROMDATA DrRDdr2CLKDis[] = {0x00, 0x00, 0xC0, 0x30, 0x0C, 0x03, 0x00, 0x00};
89 // Chip select 0, 1, 4, 5 maps to M[B,A]_CKE[0]
90 // Chip select 2, 3, 6, 7 maps to M[B,A]_CKE[1]
91 STATIC CONST UINT8 ROMDATA DrRDdr2CKETri[] = {0x33, 0xCC};
93 // 2 dimms per channel
94 // Dimm 0: BP_MEMODTx[2,0]
95 // Dimm 1: BP_MEMODTx[3,1]
96 STATIC CONST UINT8 ROMDATA DrRDdr2ODTTri2D[] = {0x03, 0x0C, 0x32, 0xC8};
97 // 3 dimms per channel
98 // Dimm 0: BP_MEMODTx[0]
99 // Dimm 1: BP_MEMODTx[3,1]
100 // Dimm 2: BP_MEMODTx[2]
101 STATIC CONST UINT8 ROMDATA DrRDdr2ODTTri3D[] = {0x03, 0x0C, 0x30, 0xC8};
102 // 4 dimms per channel
103 // Dimm 0: BP_MEMODTx[0]
104 // Dimm 1: BP_MEMODTx[1]
105 // Dimm 2: BP_MEMODTx[2]
106 // Dimm 3: BP_MEMODTx[3]
107 STATIC CONST UINT8 ROMDATA DrRDdr2ODTTri4D[] = {0x03, 0x0C, 0x30, 0xC0};
109 // BIOS must not tri-state chip select pin corresponding to the second chip
110 // select of a single rank registered dimm
111 STATIC CONST UINT8 ROMDATA DrRDdr2CSTri[] = {0x01, 0x03, 0x04, 0x0C, 0x10, 0x30, 0x40, 0xC0};
113 /* -----------------------------------------------------------------------------*/
116 * This is function sets the platform specific settings for DR DDR2 L1 system
118 * @param[in,out] *MemData Pointer to MEM_DATA_STRUCTURE
119 * @param[in] SocketID Socket number
120 * @param[in,out] *CurrentChannel Pointer to CH_DEF_STRUCT
122 * @return AGESA_SUCCESS
123 * @return CurrentChannel->MemClkDisMap Points this pointer to RB MemClkDis table
124 * @return CurrentChannel->ChipSelTriMap Points this pointer to RB CS table
125 * @return CurrentChannel->CKETriMap Points this pointer to RB ODT table
126 * @return CurrentChannel->ODTTriMap Points this pointer to RB CKE table
127 * @return CurrentChannel->DctEccDQSLike Indicates the bytes that should be averaged for ECC
128 * @return CurrentChannel->DctEccDQSScale Indicates the scale that should be used for Averaging ECC byte
129 * @return CurrentChannel->DctAddrTmg Address Command Timing Settings for specified channel
130 * @return CurrentChannel->DctOdcCtl Drive Strength settings for specified channel
131 * @return CurrentChannel->SlowMode Slow Mode
137 IN OUT MEM_DATA_STRUCT *MemData,
139 IN OUT CH_DEF_STRUCT *CurrentChannel
142 STATIC CONST ADV_PSCFG_ENTRY PSCfg4D[] = {
143 {ANY_, ANY_, 0x00000000, 0x00111222, 1},
144 {ANY_, ANY_, 0x00370000, 0x00111222, 2}
147 STATIC CONST ADV_PSCFG_ENTRY PSCfg8D[] = {
148 {ANY_, ANY_, 0x00000000, 0x00111222, 1},
149 {ANY_, ANY_, 0x00370000, 0x00111222, 2},
150 {ANY_, ANY_, 0x002F0000, 0x00111222, ANY_}
153 CONST ADV_PSCFG_ENTRY *PSCfgPtr;
165 UINT8 *DimmsPerChPtr;
167 ASSERT (MemData != 0);
168 ASSERT (CurrentChannel != 0);
170 if ((CurrentChannel->MCTPtr->LogicalCpuid.Family & AMD_FAMILY_10_RB) == 0) {
171 return AGESA_UNSUPPORTED;
173 if (CurrentChannel->TechType != DDR2_TECHNOLOGY) {
174 return AGESA_UNSUPPORTED;
176 if (CurrentChannel->RegDimmPresent != CurrentChannel->ChDimmValid) {
177 return AGESA_UNSUPPORTED;
181 Loads = CurrentChannel->Loads;
182 Dimms = CurrentChannel->Dimms;
183 Speed = CurrentChannel->DCTPtr->Timings.Speed;
184 DimmsPerChPtr = FindPSOverrideEntry (MemData->ParameterListPtr->PlatformMemoryConfiguration, PSO_MAX_DIMMS, SocketID, CurrentChannel->ChannelID, 0, NULL, NULL);
185 if (DimmsPerChPtr != NULL) {
186 MaxDimmPerCH = *DimmsPerChPtr;
190 QRPresent = CurrentChannel->DimmQrPresent;
191 DRx4Present = CurrentChannel->DimmDrPresent & CurrentChannel->Dimmx4Present;
193 Dimms = (Dimms + 1) / 2;
197 if (MaxDimmPerCH <= 2) {
199 TabSize = GET_SIZE_OF (PSCfg4D);
202 TabSize = GET_SIZE_OF (PSCfg8D);
206 for (i = 0; i < TabSize; i++) {
207 if ((PSCfgPtr[i].Dimms == ANY_) || (PSCfgPtr[i].Dimms == Dimms)) {
208 if ((PSCfgPtr[i].Speed == ANY_) || (PSCfgPtr[i].Speed == Speed)) {
209 if ((PSCfgPtr[i].Loads == ANY_) || (PSCfgPtr[i].Loads >= Loads)) {
210 AddrTmgCTL = PSCfgPtr[i].AddrTmg;
211 DctOdcCtl = PSCfgPtr[i].Odc;
217 ASSERT (i == TabSize);
218 SlowMode = FALSE; // 1T
221 // Overrides and/or exceptions
224 if (QRPresent == 0x55) {
225 // QR for 4DIMM case only
226 AddrTmgCTL = 0x002F0000;
227 if (Speed >= DDR667_FREQUENCY) {
228 DctOdcCtl = 0x00331222;
232 if (Speed >= DDR667_FREQUENCY) {
233 if ((QRPresent != 0) || (DRx4Present != 0)) {
234 AddrTmgCTL |= 0x00002F00;
237 AddrTmgCTL |= 0x0000002F;
239 if (Dimms == 3 || Dimms == 4) {
240 DctOdcCtl = 0x00331222;
244 // Adjust Processor ODT
246 DctOdcCtl |= 0x20000000; // 75ohms
248 DctOdcCtl |= 0x10000000; // 150ohms
251 CurrentChannel->MemClkDisMap = (UINT8 *) DrRDdr2CLKDis;
252 CurrentChannel->CKETriMap = (UINT8 *) DrRDdr2CKETri;
253 CurrentChannel->ChipSelTriMap = (UINT8 *) DrRDdr2CSTri;
255 switch (MaxDimmPerCH) {
257 CurrentChannel->ODTTriMap = (UINT8 *) DrRDdr2ODTTri3D;
260 CurrentChannel->ODTTriMap = (UINT8 *) DrRDdr2ODTTri4D;
263 CurrentChannel->ODTTriMap = (UINT8 *) DrRDdr2ODTTri2D;
266 CurrentChannel->DctEccDqsLike = 0x0504;
267 CurrentChannel->DctEccDqsScale = 0;
268 CurrentChannel->DctAddrTmg = AddrTmgCTL;
269 CurrentChannel->DctOdcCtl = DctOdcCtl;
270 CurrentChannel->SlowMode = SlowMode;
272 return AGESA_SUCCESS;