7 * Platform specific settings for LN DDR3 SO-dimms
9 * @xrefitem bom "File Content Label" "Release Content"
11 * @e sub-project: (Mem/Ardk)
12 * @e \$Revision: 47807 $ @e \$Date: 2011-03-01 01:53:18 +0800 (Tue, 01 Mar 2011) $
15 /*****************************************************************************
17 * Copyright (c) 2011, 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.
41 * ***************************************************************************
45 /* This file contains routine that add platform specific support AM3 */
51 #include "PlatformMemoryConfiguration.h"
55 #include "F12PackageType.h"
56 #include "cpuFamRegisters.h"
61 #define FILECODE PROC_MEM_ARDK_LN_MASLN3_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 LnSDdr3CLKDis[] = {0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
88 STATIC CONST UINT8 ROMDATA LnSDdr3CLKDisFM1[] = {0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00};
89 STATIC CONST UINT8 ROMDATA LnSDdr3CKETri[] = {0x55, 0xAA};
90 STATIC CONST UINT8 ROMDATA LnSDdr3ODTTri[] = {0x01, 0x02, 0x04, 0x08};
91 STATIC CONST UINT8 ROMDATA LnSDdr3CSTri[] = {0x01, 0x02, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00};
93 /* -----------------------------------------------------------------------------*/
96 * This is function sets the platform specific settings for LN DDR3 SO-dimms
99 * @param[in,out] *MemData Pointer to MEM_DATA_STRUCTURE
100 * @param[in] SocketID Socket number
101 * @param[in,out] *CurrentChannel Pointer to CH_DEF_STRUCT
103 * @return AGESA_SUCCESS
104 * @return CurrentChannel->MemClkDisMap Points this pointer to LN MemClkDis table
105 * @return CurrentChannel->ChipSelTriMap Points this pointer to LN CS table
106 * @return CurrentChannel->CKETriMap Points this pointer to LN ODT table
107 * @return CurrentChannel->ODTTriMap Points this pointer to LN CKE table
108 * @return CurrentChannel->DctEccDQSLike Indicates the bytes that should be averaged for ECC
109 * @return CurrentChannel->DctEccDQSScale Indicates the scale that should be used for Averaging ECC byte
110 * @return CurrentChannel->DctAddrTmg Address Command Timing Settings for specified channel
111 * @return CurrentChannel->DctOdcCtl Drive Strength settings for specified channel
112 * @return CurrentChannel->SlowMode Slow Mode
119 IN OUT MEM_DATA_STRUCT *MemData,
121 IN OUT CH_DEF_STRUCT *CurrentChannel
124 STATIC CONST ADV_PSCFG_ENTRY PSCfg[] = {
125 {DDR800_FREQUENCY, ANY_, 0x00000000, 0x00002222, 1},
126 {DDR800_FREQUENCY, ANY_, 0x00000039, 0x20222323, 2},
127 {DDR1066_FREQUENCY, ANY_, 0x003D3D3D, 0x10002222, 1},
128 {DDR1066_FREQUENCY, ANY_, 0x00000037, 0x30222323, 2},
129 {DDR1333_FREQUENCY, ANY_, 0x003D3D3D, 0x20002222, 1},
130 {DDR1333_FREQUENCY, ANY_, 0x00000035, 0x30222323, 2},
131 {DDR1600_FREQUENCY, ANY_, 0x003C3C3C, 0x30112222, 1},
132 {DDR1600_FREQUENCY, ANY_, 0x00000033, 0x30222323, 2},
133 {DDR1866_FREQUENCY, ANY_, 0x00003C3C, 0x30112222, 1},
134 {DDR1866_FREQUENCY, ANY_, 0x00000031, 0x30222323, 2},
140 // Fn2_F4 180, Fn2_F4 181, Fn2_F4 182, Fn2_F4 183, # Dimms to match
142 STATIC CONST ADV_PSCFG_ODT_ENTRY PSCfgDIMMsODT[] = {
144 0x00000000, 0x00000000, 0x00000001, 0x00000000, 1},
146 0x00000000, 0x00000000, 0x00000201, 0x00000000, 1},
148 0x00000000, 0x00000000, 0x00040000, 0x00000000, 1},
150 0x00000000, 0x00000000, 0x08040000, 0x00000000, 1},
151 {SR_DIMM0 + DR_DIMM0 + SR_DIMM1 + DR_DIMM1, \
152 0x01010404, 0x00000000, 0x09050605, 0x00000000, 2}
167 UINT16 _DIMMRankType;
169 UINT8 *DimmsPerChPtr;
172 ASSERT (MemData != 0);
173 ASSERT (CurrentChannel != 0);
184 if ((CurrentChannel->MCTPtr->LogicalCpuid.Family & AMD_FAMILY_LN) == 0) {
185 return AGESA_UNSUPPORTED;
187 if (CurrentChannel->TechType != DDR3_TECHNOLOGY) {
188 return AGESA_UNSUPPORTED;
190 if (CurrentChannel->SODimmPresent != CurrentChannel->ChDimmValid) {
191 return AGESA_UNSUPPORTED;
195 DIMMRankType = MemAGetPsRankType (CurrentChannel);
196 Loads = CurrentChannel->Loads;
197 Dimms = CurrentChannel->Dimms;
198 Speed = CurrentChannel->DCTPtr->Timings.Speed;
199 SlowMode = TRUE; // 2T
200 DimmsPerChPtr = FindPSOverrideEntry (MemData->ParameterListPtr->PlatformMemoryConfiguration, PSO_MAX_DIMMS, SocketID, CurrentChannel->ChannelID);
201 if (DimmsPerChPtr != NULL) {
202 DimmsPerCH = *DimmsPerChPtr;
207 for (i = 0; i < GET_SIZE_OF (PSCfg); i++) {
208 if ((PSCfg[i].Dimms == ANY_) || (PSCfg[i].Dimms == Dimms)) {
209 if ((PSCfg[i].Speed == ANY_) || (PSCfg[i].Speed == Speed)) {
210 if ((PSCfg[i].Loads == ANY_) || (PSCfg[i].Loads >= Loads)) {
211 AddrTmgCTL = PSCfg[i].AddrTmg;
212 DctOdcCtl = PSCfg[i].Odc;
218 ASSERT (i < GET_SIZE_OF (PSCfg));
222 if (Speed != DDR1866_FREQUENCY) {
225 if (CurrentChannel->DimmDrPresent != 0) {
226 if (Speed == DDR1066_FREQUENCY) {
227 AddrTmgCTL = 0x00000000;
228 } else if (Speed == DDR1333_FREQUENCY) {
229 AddrTmgCTL = 0x00003D3D;
230 } else if (Speed == DDR1600_FREQUENCY) {
231 AddrTmgCTL = 0x00003C3C;
238 // Programmable ODT pattern
240 for (i = 0; i < GET_SIZE_OF (PSCfgDIMMsODT); i++) {
241 if (Dimms != PSCfgDIMMsODT[i].Dimms) {
245 _DIMMRankType = DIMMRankType & PSCfgDIMMsODT[i].DIMMRankType;
246 for (j = 0; j < MAX_DIMMS_PER_CHANNEL; j++) {
247 if ((_DIMMRankType & (UINT16) 0x0F << (j << 2)) != 0) {
251 if (DimmTpMatch == PSCfgDIMMsODT[i].Dimms) {
252 PhyRODTCS = PSCfgDIMMsODT[i].PhyRODTCSLow;
253 PhyWODTCS = PSCfgDIMMsODT[i].PhyWODTCSLow;
261 PhyWLODT[0] = PhyWLODT[2] = (UINT8) (PhyWODTCS & 0x0F);
262 PhyWLODT[1] = PhyWLODT[3] = (UINT8) ((PhyWODTCS >> 16) & 0x0F);
264 if (LibAmdGetPackageType (&(MemData->StdHeader)) == PACKAGE_TYPE_FM1) {
265 CurrentChannel->MemClkDisMap = (UINT8 *) LnSDdr3CLKDisFM1;
267 CurrentChannel->MemClkDisMap = (UINT8 *) LnSDdr3CLKDis;
269 CurrentChannel->CKETriMap = (UINT8 *) LnSDdr3CKETri;
270 CurrentChannel->ODTTriMap = (UINT8 *) LnSDdr3ODTTri;
271 CurrentChannel->ChipSelTriMap = (UINT8 *) LnSDdr3CSTri;
273 CurrentChannel->DctAddrTmg = AddrTmgCTL;
274 CurrentChannel->DctOdcCtl = DctOdcCtl;
275 CurrentChannel->PhyRODTCSLow = PhyRODTCS;
276 CurrentChannel->PhyWODTCSLow = PhyWODTCS;
277 for (i = 0; i < sizeof (CurrentChannel->PhyWLODT); i++) {
278 CurrentChannel->PhyWLODT[i] = PhyWLODT[i];
280 CurrentChannel->SlowMode = SlowMode;
282 if ((DimmsPerCH == 2) && (Speed >= DDR1333_FREQUENCY) && (Dimms == 1)) {
283 // Set Dqs and DQ drive strength to 1.0x for 1 dimm on 2 dimms per channel DDR3-1333
284 CurrentChannel->DctOdcCtl |= 0x110000;
287 return AGESA_SUCCESS;