7 * Platform specific settings for PH DDR3 SO-dimms
9 * @xrefitem bom "File Content Label" "Release Content"
11 * @e sub-project: (Mem/Ardk/PH)
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 S1g4 */
52 #include "OptionMemory.h"
53 #include "PlatformMemoryConfiguration.h"
56 #include "cpuFamRegisters.h"
61 #define FILECODE PROC_MEM_ARDK_PH_MASPH3_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 PhSDdr3CLKDis[] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
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 PhSDdr3CKETri[] = {0x55, 0xAA};
91 // Bit 0: M[B,A]0_ODT[0]
92 // Bit 1: M[B,A]1_ODT[0]
93 // Bit 2: M[B,A]0_ODT[1]
94 // Bit 3: M[B,A]1_ODT[1]
95 STATIC CONST UINT8 ROMDATA PhSDdr3ODTTri[] = {0x01, 0x04, 0x02, 0x08};
96 // Bit 0: M[B,A]0_CS_H/L[0]
97 // Bit 1: M[B,A]0_CS_H/L[1]
98 // Bit 2: M[B,A]0_CS_H/L[2]
99 // Bit 3: M[B,A]0_CS_H/L[3]
100 STATIC CONST UINT8 ROMDATA PhSDdr3CSTri[] = {0x01, 0x02, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00};
102 /* -----------------------------------------------------------------------------*/
105 * This is function sets the platform specific settings for PH DDR3 SO-dimms
108 * @param[in,out] *MemData Pointer to MEM_DATA_STRUCTURE
109 * @param[in] SocketID Socket number
110 * @param[in,out] *CurrentChannel Pointer to CH_DEF_STRUCT
112 * @return AGESA_SUCCESS
113 * @return CurrentChannel->MemClkDisMap Points this pointer to RB MemClkDis table
114 * @return CurrentChannel->ChipSelTriMap Points this pointer to RB CS table
115 * @return CurrentChannel->CKETriMap Points this pointer to RB ODT table
116 * @return CurrentChannel->ODTTriMap Points this pointer to RB CKE table
117 * @return CurrentChannel->DctEccDQSLike Indicates the bytes that should be averaged for ECC
118 * @return CurrentChannel->DctEccDQSScale Indicates the scale that should be used for Averaging ECC byte
119 * @return CurrentChannel->DctAddrTmg Address Command Timing Settings for specified channel
120 * @return CurrentChannel->DctOdcCtl Drive Strength settings for specified channel
121 * @return CurrentChannel->SlowMode Slow Mode
128 IN OUT MEM_DATA_STRUCT *MemData,
130 IN OUT CH_DEF_STRUCT *CurrentChannel
133 STATIC CONST PSCFG_ENTRY PSCfg[] = {
134 {DDR800_FREQUENCY, 0xFF, 0x00000000, 0x00113222},
135 {DDR1066_FREQUENCY, 0xFF, 0x00000000, 0x10113222},
136 {DDR1333_FREQUENCY, 0xFF, 0x00000000, 0x20113222},
139 STATIC CONST ADV_R_PSCFG_WL_ODT_ENTRY PSCfgDIMMWlODT[] = {
140 {SR_DIMM1, {0x00, 0x02, 0x00, 0x00}, 1},
141 {DR_DIMM1, {0x00, 0x08, 0x00, 0x00}, 1},
142 {SR_DIMM0 + DR_DIMM0 + SR_DIMM1 + DR_DIMM1, {0x03, 0x03, 0x00, 0x00}, 2}
155 UINT8 *DimmsPerChPtr;
157 UINT16 _DIMMRankType;
160 ASSERT (MemData != 0);
161 ASSERT (CurrentChannel != 0);
169 SlowMode = FALSE; // 1T
170 if ((CurrentChannel->MCTPtr->LogicalCpuid.Family & AMD_FAMILY_10_PH) == 0) {
171 return AGESA_UNSUPPORTED;
173 if (CurrentChannel->TechType != DDR3_TECHNOLOGY) {
174 return AGESA_UNSUPPORTED;
176 if (CurrentChannel->SODimmPresent != CurrentChannel->ChDimmValid) {
177 return AGESA_UNSUPPORTED;
180 Loads = CurrentChannel->Loads;
181 Dimms = CurrentChannel->Dimms;
182 Speed = CurrentChannel->DCTPtr->Timings.Speed;
184 DIMMRankType = MemAGetPsRankType (CurrentChannel);
186 DimmsPerChPtr = FindPSOverrideEntry (MemData->ParameterListPtr->PlatformMemoryConfiguration, PSO_MAX_DIMMS, SocketID, CurrentChannel->ChannelID, 0, NULL, NULL);
187 if (DimmsPerChPtr != NULL) {
188 MaxDimmPerCH = *DimmsPerChPtr;
193 for (i = 0; i < GET_SIZE_OF (PSCfg); i++) {
194 if (Speed == PSCfg[i].Speed) {
195 if (Loads <= PSCfg[i].Loads) {
196 AddrTmgCTL = PSCfg[i].AddrTmg;
197 DctOdcCtl = PSCfg[i].Odc;
204 for (i = 0; i < GET_SIZE_OF (PSCfgDIMMWlODT); i++) {
205 if (Dimms != PSCfgDIMMWlODT[i].Dimms) {
209 _DIMMRankType = DIMMRankType & PSCfgDIMMWlODT[i].DIMMRankType;
210 for (j = 0; j < MAX_DIMMS_PER_CHANNEL; j++) {
211 if ((_DIMMRankType & (UINT16) 0x0F << (j << 2)) != 0) {
215 if (DimmTpMatch == PSCfgDIMMWlODT[i].Dimms) {
216 PhyWLODT[0] = PSCfgDIMMWlODT[i].PhyWrLvOdt[0];
217 PhyWLODT[1] = PSCfgDIMMWlODT[i].PhyWrLvOdt[1];
218 PhyWLODT[2] = PSCfgDIMMWlODT[i].PhyWrLvOdt[2];
219 PhyWLODT[3] = PSCfgDIMMWlODT[i].PhyWrLvOdt[3];
225 // Overrides and/or exceptions
227 if (MaxDimmPerCH == 2) {
229 DctOdcCtl = 0x20223323;
231 if (Speed == DDR800_FREQUENCY) {
232 AddrTmgCTL = 0x00000039;
233 } else if (Speed == DDR1066_FREQUENCY) {
234 AddrTmgCTL = 0x00000037;
237 DctOdcCtl = 0x20113222;
240 if (CurrentChannel->DimmSRPresent != 0) {
242 } else if (CurrentChannel->DimmDrPresent != 0) {
247 CurrentChannel->MemClkDisMap = (UINT8 *) PhSDdr3CLKDis;
248 CurrentChannel->CKETriMap = (UINT8 *) PhSDdr3CKETri;
249 CurrentChannel->ODTTriMap = (UINT8 *) PhSDdr3ODTTri;
250 CurrentChannel->ChipSelTriMap = (UINT8 *) PhSDdr3CSTri;
252 CurrentChannel->DctAddrTmg = AddrTmgCTL;
253 CurrentChannel->DctOdcCtl = DctOdcCtl;
254 for (i = 0; i < sizeof (CurrentChannel->PhyWLODT); i++) {
255 CurrentChannel->PhyWLODT[i] = PhyWLODT[i];
257 CurrentChannel->SlowMode = SlowMode;
259 return AGESA_SUCCESS;