7 * Common Technology functions for DDR3
9 * @xrefitem bom "File Content Label" "Release Content"
11 * @e sub-project: (Mem/Tech/DDR3)
12 * @e \$Revision: 56279 $ @e \$Date: 2011-07-11 13:11:28 -0600 (Mon, 11 Jul 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 * ***************************************************************************
47 *----------------------------------------------------------------------------
50 *----------------------------------------------------------------------------
64 #include "OptionMemory.h"
65 #include "PlatformMemoryConfiguration.h"
71 #define FILECODE PROC_MEM_TECH_DDR3_MT3_FILECODE
72 /*----------------------------------------------------------------------------
73 * DEFINITIONS AND MACROS
75 *----------------------------------------------------------------------------
78 /*----------------------------------------------------------------------------
79 * TYPEDEFS AND STRUCTURES
81 *----------------------------------------------------------------------------
84 /*----------------------------------------------------------------------------
85 * PROTOTYPES OF LOCAL FUNCTIONS
87 *----------------------------------------------------------------------------
90 /*----------------------------------------------------------------------------
93 *----------------------------------------------------------------------------
95 /* -----------------------------------------------------------------------------*/
98 * This function Constructs the technology block
100 * @param[in,out] *NBPtr - Pointer to the MEM_NB_BLOCK
101 * @param[in,out] *TechPtr - Pointer to the MEM_TECH_BLOCK
106 MemConstructTechBlock3 (
107 IN OUT MEM_TECH_BLOCK *TechPtr,
108 IN OUT MEM_NB_BLOCK *NBPtr
111 TECHNOLOGY_TYPE *TechTypePtr;
117 CH_DEF_STRUCT *ChannelPtr;
121 TechTypePtr = (TECHNOLOGY_TYPE *) FindPSOverrideEntry (NBPtr->RefPtr->PlatformMemoryConfiguration, PSO_MEM_TECH, NBPtr->MCTPtr->SocketId, 0, 0, NULL, NULL);
122 if (TechTypePtr != NULL) {
123 // Ensure the platform override value is valid
124 ASSERT ((*TechTypePtr == DDR3_TECHNOLOGY) || (*TechTypePtr == DDR2_TECHNOLOGY));
125 if (*TechTypePtr != DDR3_TECHNOLOGY) {
130 TechPtr->NBPtr = NBPtr;
131 TechPtr->RefPtr = NBPtr->RefPtr;
132 MCTPtr = NBPtr->MCTPtr;
134 TechPtr->SendAllMRCmds = MemTSendAllMRCmds3;
135 TechPtr->FreqChgCtrlWrd = FreqChgCtrlWrd3;
136 TechPtr->SetDramMode = MemTSetDramMode3;
137 TechPtr->DimmPresence = MemTDIMMPresence3;
138 TechPtr->SpdCalcWidth = MemTSPDCalcWidth3;
139 TechPtr->SpdGetTargetSpeed = MemTSPDGetTargetSpeed3;
140 TechPtr->AutoCycTiming = MemTAutoCycTiming3;
141 TechPtr->SpdSetBanks = MemTSPDSetBanks3;
142 TechPtr->SetDqsEccTmgs = MemTSetDQSEccTmgs;
143 TechPtr->GetCSIntLvAddr = MemTGetCSIntLvAddr3;
144 TechPtr->AdjustTwrwr = MemTAdjustTwrwr3;
145 TechPtr->AdjustTwrrd = MemTAdjustTwrrd3;
146 TechPtr->GetDimmSpdBuffer = MemTGetDimmSpdBuffer3;
147 TechPtr->GetLD = MemTGetLD3;
148 TechPtr->MaxFilterDly = 0;
151 // Map the Logical Dimms on this channel to the SPD that should be used for that logical DIMM.
152 // The pointers to the DIMM SPD information is as follows (2 Dimm/Ch and 3 Dimm/Ch examples).
154 // DIMM Spd Buffer Current Channel DimmSpdPtr[MAX_DIMMS_PER_CHANNEL] array
155 // (Number of dimms varies by platform) (Array size is determined in AGESA.H) Dimm operations loop
156 // on this array only)
157 // 2 DIMMS PER CHANNEL
159 // Socket N Channel N Dimm 0 SR/DR DIMM <--------------DimmSpdPtr[0]
160 // Dimm 1 SR/DR DIMM <--------------DimmSpdPtr[1]
161 // DimmSpdPtr[2]------->NULL
162 // DimmSpdPtr[3]------->NULL
164 // Socket N Channel N Dimm 0 SR/DR DIMM <--------------DimmSpdPtr[0]
165 // Dimm 1 QR DIMM <---------+----DimmSpdPtr[1]
166 // | DimmSpdPtr[2]------->NULL
167 // +----DimmSpdPtr[3]
169 // Socket N Channel N Dimm 0 QR DIMM <-----+--------DimmSpdPtr[0]
170 // Dimm 1 QR DIMM <-----|---+----DimmSpdPtr[1]
171 // +-- | ---DimmSpdPtr[2]
172 // +----DimmSpdPtr[3]
174 // 3 DIMMS PER CHANNEL
176 // Socket N Channel N Dimm 0 SR/DR DIMM <--------------DimmSpdPtr[0]
177 // Dimm 1 SR/DR DIMM <--------------DimmSpdPtr[1]
178 // Dimm 3 SR/DR DIMM <--------------DimmSpdPtr[2]
179 // DimmSpdPtr[3]------->NULL
181 // Socket N Channel N Dimm 0 SR/DR DIMM <--------------DimmSpdPtr[0]
182 // Dimm 1 QR DIMM <---------+----DimmSpdPtr[1]
183 // Dimm 3 SR/DR DIMM <-------- | ---DimmSpdPtr[2]
184 // +----DimmSpdPtr[3]
189 // This code will assign SPD pointers on the basis of Physical ranks, even though
190 // an LRDIMM may only use one or two logical ranks, that determination will have to
191 // be made from downstream code. An LRDIMM with greater than 2 Physical ranks will have
192 // its DimmSpdPtr[] mapped as if it were a QR in the above diagrams.
194 for (Dct = 0; Dct < NBPtr->DctCount; Dct++) {
195 NBPtr->SwitchDCT (NBPtr, Dct);
196 DCTPtr = NBPtr->DCTPtr;
197 for (Channel = 0; Channel < NBPtr->ChannelCount; Channel++) {
198 NBPtr->SwitchChannel (NBPtr, Channel);
199 ChannelPtr = NBPtr->ChannelPtr;
200 ChannelPtr->TechType = DDR3_TECHNOLOGY;
201 ChannelPtr->MCTPtr = MCTPtr;
202 ChannelPtr->DCTPtr = DCTPtr;
204 DimmSlots = GetMaxDimmsPerChannel (NBPtr->RefPtr->PlatformMemoryConfiguration,
206 NBPtr->GetSocketRelativeChannel (NBPtr, Dct, Channel)
209 // Initialize the SPD pointers for each Dimm
211 for (i = 0 ; i < (sizeof (ChannelPtr->DimmSpdPtr) / sizeof (ChannelPtr->DimmSpdPtr[0])) ; i++) {
212 ChannelPtr->DimmSpdPtr[i] = NULL;
214 for (i = 0 ; i < DimmSlots; i++) {
215 ChannelPtr->DimmSpdPtr[i] = &(ChannelPtr->SpdPtr[i]);
216 if ( (i + 2) < (sizeof (ChannelPtr->DimmSpdPtr) / sizeof (ChannelPtr->DimmSpdPtr[0]))) {
217 if (ChannelPtr->DimmSpdPtr[i]->DimmPresent) {
218 if ((((ChannelPtr->DimmSpdPtr[i]->Data[SPD_RANKS] >> 3) & 0x07) + 1) > 2) {
219 ChannelPtr->DimmSpdPtr[i + 2] = &(ChannelPtr->SpdPtr[i]);
226 // Initialize Common technology functions
227 MemTCommonTechInit (TechPtr);
232 /*----------------------------------------------------------------------------
235 *----------------------------------------------------------------------------