7 * Platform specific settings for RB DDR3 SO-dimms
9 * @xrefitem bom "File Content Label" "Release Content"
11 * @e sub-project: (Mem/Ardk/RB)
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 * ***************************************************************************
51 #include "OptionMemory.h"
52 #include "PlatformMemoryConfiguration.h"
55 #include "cpuFamRegisters.h"
60 #define FILECODE PROC_MEM_ARDK_RB_MASRB3_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 RbSDdr3CLKDis[] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
87 // Even chip select maps to M[B,A]_CKE[0]
88 // Odd chip select maps to M[B,A]_CKE[1]
89 STATIC CONST UINT8 ROMDATA RbSDdr3CKETri[] = {0x55, 0xAA};
90 // Bit 0: M[B,A]0_ODT[0]
91 // Bit 1: M[B,A]1_ODT[0]
92 // Bit 2: M[B,A]0_ODT[1]
93 // Bit 3: M[B,A]1_ODT[1]
94 STATIC CONST UINT8 ROMDATA RbSDdr3ODTTri[] = {0x01, 0x04, 0x02, 0x08};
95 // Bit 0: M[B,A]0_CS_H/L[0]
96 // Bit 1: M[B,A]0_CS_H/L[1]
97 // Bit 2: M[B,A]0_CS_H/L[2]
98 // Bit 3: M[B,A]0_CS_H/L[3]
99 STATIC CONST UINT8 ROMDATA RbSDdr3CSTri[] = {0x01, 0x02, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00};
101 /* -----------------------------------------------------------------------------*/
104 * This is function sets the platform specific settings for RB DDR3 SO-dimms
107 * @param[in,out] *MemData Pointer to MEM_DATA_STRUCTURE
108 * @param[in] SocketID Socket number
109 * @param[in,out] *CurrentChannel Pointer to CH_DEF_STRUCT
111 * @return AGESA_SUCCESS
112 * @return CurrentChannel->MemClkDisMap Points this pointer to RB MemClkDis table
113 * @return CurrentChannel->ChipSelTriMap Points this pointer to RB CS table
114 * @return CurrentChannel->CKETriMap Points this pointer to RB ODT table
115 * @return CurrentChannel->ODTTriMap Points this pointer to RB CKE table
116 * @return CurrentChannel->DctEccDQSLike Indicates the bytes that should be averaged for ECC
117 * @return CurrentChannel->DctEccDQSScale Indicates the scale that should be used for Averaging ECC byte
118 * @return CurrentChannel->DctAddrTmg Address Command Timing Settings for specified channel
119 * @return CurrentChannel->DctOdcCtl Drive Strength settings for specified channel
120 * @return CurrentChannel->SlowMode Slow Mode
127 IN OUT MEM_DATA_STRUCT *MemData,
129 IN OUT CH_DEF_STRUCT *CurrentChannel
132 STATIC CONST PSCFG_ENTRY PSCfg[] = {
133 {DDR800_FREQUENCY, 0xFF, 0x00000000, 0x00113222},
134 {DDR1066_FREQUENCY, 0xFF, 0x00000000, 0x10113222},
135 {DDR1333_FREQUENCY, 0xFF, 0x00000000, 0x20113222},
138 STATIC CONST ADV_R_PSCFG_WL_ODT_ENTRY PSCfgDIMMWlODT[] = {
139 {SR_DIMM1, {0x00, 0x02, 0x00, 0x00}, 1},
140 {DR_DIMM1, {0x00, 0x08, 0x00, 0x00}, 1},
141 {SR_DIMM0 + DR_DIMM0 + SR_DIMM1 + DR_DIMM1, {0x03, 0x03, 0x00, 0x00}, 2}
154 UINT8 *DimmsPerChPtr;
156 UINT16 _DIMMRankType;
159 ASSERT (MemData != 0);
160 ASSERT (CurrentChannel != 0);
168 SlowMode = FALSE; // 1T
169 if ((CurrentChannel->MCTPtr->LogicalCpuid.Family & AMD_FAMILY_10_RB) == 0) {
170 return AGESA_UNSUPPORTED;
172 if (CurrentChannel->TechType != DDR3_TECHNOLOGY) {
173 return AGESA_UNSUPPORTED;
175 if (CurrentChannel->SODimmPresent != CurrentChannel->ChDimmValid) {
176 return AGESA_UNSUPPORTED;
179 Loads = CurrentChannel->Loads;
180 Dimms = CurrentChannel->Dimms;
181 Speed = CurrentChannel->DCTPtr->Timings.Speed;
183 DIMMRankType = MemAGetPsRankType (CurrentChannel);
185 DimmsPerChPtr = FindPSOverrideEntry (MemData->ParameterListPtr->PlatformMemoryConfiguration, PSO_MAX_DIMMS, SocketID, CurrentChannel->ChannelID, 0, NULL, NULL);
186 if (DimmsPerChPtr != NULL) {
187 MaxDimmPerCH = *DimmsPerChPtr;
192 for (i = 0; i < GET_SIZE_OF (PSCfg); i++) {
193 if (Speed == PSCfg[i].Speed) {
194 if (Loads <= PSCfg[i].Loads) {
195 AddrTmgCTL = PSCfg[i].AddrTmg;
196 DctOdcCtl = PSCfg[i].Odc;
203 for (i = 0; i < GET_SIZE_OF (PSCfgDIMMWlODT); i++) {
204 if (Dimms != PSCfgDIMMWlODT[i].Dimms) {
208 _DIMMRankType = DIMMRankType & PSCfgDIMMWlODT[i].DIMMRankType;
209 for (j = 0; j < MAX_DIMMS_PER_CHANNEL; j++) {
210 if ((_DIMMRankType & (UINT16) 0x0F << (j << 2)) != 0) {
214 if (DimmTpMatch == PSCfgDIMMWlODT[i].Dimms) {
215 PhyWLODT[0] = PSCfgDIMMWlODT[i].PhyWrLvOdt[0];
216 PhyWLODT[1] = PSCfgDIMMWlODT[i].PhyWrLvOdt[1];
217 PhyWLODT[2] = PSCfgDIMMWlODT[i].PhyWrLvOdt[2];
218 PhyWLODT[3] = PSCfgDIMMWlODT[i].PhyWrLvOdt[3];
224 // Overrides and/or exceptions
226 if (MaxDimmPerCH == 2) {
228 DctOdcCtl = 0x20223323;
230 if (Speed == DDR800_FREQUENCY) {
231 AddrTmgCTL = 0x00000039;
232 } else if (Speed == DDR1066_FREQUENCY) {
233 AddrTmgCTL = 0x00000037;
236 DctOdcCtl = 0x20113222;
239 if (CurrentChannel->DimmSRPresent != 0) {
241 } else if (CurrentChannel->DimmDrPresent != 0) {
246 CurrentChannel->MemClkDisMap = (UINT8 *) RbSDdr3CLKDis;
247 CurrentChannel->CKETriMap = (UINT8 *) RbSDdr3CKETri;
248 CurrentChannel->ODTTriMap = (UINT8 *) RbSDdr3ODTTri;
249 CurrentChannel->ChipSelTriMap = (UINT8 *) RbSDdr3CSTri;
251 CurrentChannel->DctAddrTmg = AddrTmgCTL;
252 CurrentChannel->DctOdcCtl = DctOdcCtl;
253 for (i = 0; i < sizeof (CurrentChannel->PhyWLODT); i++) {
254 CurrentChannel->PhyWLODT[i] = PhyWLODT[i];
256 CurrentChannel->SlowMode = SlowMode;
258 return AGESA_SUCCESS;