7 * Common Northbridge function for training flow for DDR3
9 * @xrefitem bom "File Content Label" "Release Content"
11 * @e sub-project: (Mem/NB)
12 * @e \$Revision: 59563 $ @e \$Date: 2011-09-26 12:06:49 -0600 (Mon, 26 Sep 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 *----------------------------------------------------------------------------
58 #include "OptionMemory.h"
66 #define FILECODE PROC_MEM_NB_MNTRAIN3_FILECODE
69 /*----------------------------------------------------------------------------
70 * DEFINITIONS AND MACROS
72 *----------------------------------------------------------------------------
75 /*----------------------------------------------------------------------------
76 * TYPEDEFS AND STRUCTURES
78 *----------------------------------------------------------------------------
81 /*----------------------------------------------------------------------------
82 * PROTOTYPES OF LOCAL FUNCTIONS
84 *----------------------------------------------------------------------------
90 IN OUT MEM_TECH_BLOCK *TechPtr
92 /*----------------------------------------------------------------------------
95 *----------------------------------------------------------------------------
97 extern MEM_FEAT_TRAIN_SEQ memTrainSequenceDDR3[];
98 /* -----------------------------------------------------------------------------*/
101 * This function initiates DQS training
103 * @param[in,out] *NBPtr - Pointer to the MEM_NB_BLOCK
109 IN OUT MEM_NB_BLOCK *NBPtr
112 MEM_TECH_BLOCK *TechPtr;
115 TechPtr = NBPtr->TechPtr;
117 if (TechPtr->NBPtr->MCTPtr->NodeMemSize) {
118 //Execute Technology specific training features
120 while (memTrainSequenceDDR3[i].TrainingSequenceEnabled != 0) {
121 if (memTrainSequenceDDR3[i].TrainingSequenceEnabled (NBPtr)) {
122 NBPtr->TrainingSequenceIndex = i;
123 Retval = memTrainSequenceDDR3[i].TrainingSequence (NBPtr);
131 /* -----------------------------------------------------------------------------*/
134 * This function initiates DQS training for Server NB
136 * @param[in,out] *NBPtr - Pointer to the MEM_NB_BLOCK
142 IN OUT MEM_NB_BLOCK *NBPtr
145 MEM_TECH_BLOCK *TechPtr;
147 TechPtr = NBPtr->TechPtr;
148 i = NBPtr->TrainingSequenceIndex;
149 if (TechPtr->NBPtr->MCTPtr->NodeMemSize != 0) {
150 AGESA_TESTPOINT (TpProcMemBeforeAgesaHookBeforeDQSTraining, &NBPtr->MemPtr->StdHeader);
151 IDS_HDT_CONSOLE (MEM_FLOW, "\nCalling out to Platform BIOS...\n");
152 if (AgesaHookBeforeDQSTraining (NBPtr->MCTPtr->SocketId, TechPtr->NBPtr->MemPtr) == AGESA_SUCCESS) {
153 // Right now we do not have anything to do if the callout is implemented
155 AGESA_TESTPOINT (TpProcMemAfterAgesaHookBeforeDQSTraining, &NBPtr->MemPtr->StdHeader);
156 //Execute Technology specific training features
157 if (memTrainSequenceDDR3[i].MemTechFeatBlock->EnterHardwareTraining (TechPtr)) {
158 TechPtr->TechnologySpecificHook[LrdimmBuf2DramTrain] (TechPtr, NULL);
159 if (memTrainSequenceDDR3[i].MemTechFeatBlock->SwWLTraining (TechPtr)) {
160 MemFInitTableDrive (NBPtr, MTAfterSwWLTrn);
161 if (memTrainSequenceDDR3[i].MemTechFeatBlock->HwBasedWLTrainingPart1 (TechPtr)) {
162 MemFInitTableDrive (NBPtr, MTAfterHwWLTrnP1);
163 if (memTrainSequenceDDR3[i].MemTechFeatBlock->HwBasedDQSReceiverEnableTrainingPart1 (TechPtr)) {
164 MemFInitTableDrive (NBPtr, MTAfterHwRxEnTrnP1);
165 // If target speed is higher than start-up speed, do frequency change and second pass of WL
167 if (MemNHwWlPart2Nb (TechPtr)) {
168 if (memTrainSequenceDDR3[i].MemTechFeatBlock->TrainExitHwTrn (TechPtr)) {
169 IDS_OPTION_HOOK (IDS_PHY_DLL_STANDBY_CTRL, NBPtr, &(NBPtr->MemPtr->StdHeader));
170 if (memTrainSequenceDDR3[i].MemTechFeatBlock->NonOptimizedSWDQSRecEnTrainingPart1 (TechPtr)) {
171 if (memTrainSequenceDDR3[i].MemTechFeatBlock->OptimizedSwDqsRecEnTrainingPart1 (TechPtr)) {
172 MemFInitTableDrive (NBPtr, MTAfterSwRxEnTrn);
173 if (memTrainSequenceDDR3[i].MemTechFeatBlock->NonOptimizedSRdWrPosTraining (TechPtr)) {
174 if (memTrainSequenceDDR3[i].MemTechFeatBlock->OptimizedSRdWrPosTraining (TechPtr)) {
175 MemFInitTableDrive (NBPtr, MTAfterDqsRwPosTrn);
176 if (!NBPtr->FamilySpecificHook[MemPstateStageChange] (NBPtr, NULL)) {
179 if (NBPtr->Execute1dMaxRdLatTraining) {
181 if (memTrainSequenceDDR3[i].MemTechFeatBlock->MaxRdLatencyTraining (TechPtr)) {
182 MemFInitTableDrive (NBPtr, MTAfterMaxRdLatTrn);
184 } while (NBPtr->ChangeNbFrequency (NBPtr));
186 // If not running MRL training, set everything back for training
187 memTrainSequenceDDR3[i].MemTechFeatBlock->TrainExitHwTrn (TechPtr);
195 } while (NBPtr->MemPstateStage == MEMORY_PSTATE_2ND_STAGE);
200 MemTMarkTrainFail (TechPtr);
204 /* -----------------------------------------------------------------------------*/
207 * This function executes HW WL at multiple speeds
209 * @param[in,out] *TechPtr - Pointer to the MEM_TECH_BLOCK
210 * @return TRUE - No errors occurred
211 * FALSE - errors occurred
217 IN OUT MEM_TECH_BLOCK *TechPtr
223 i = TechPtr->NBPtr->TrainingSequenceIndex;
224 while ((TechPtr->NBPtr->DCTPtr->Timings.TargetSpeed > TechPtr->NBPtr->DCTPtr->Timings.Speed) && (TechPtr->NBPtr->MemPstateStage != MEMORY_PSTATE_1ST_STAGE)) {
225 TechPtr->PrevSpeed = TechPtr->NBPtr->DCTPtr->Timings.Speed;
226 if (TechPtr->NBPtr->RampUpFrequency (TechPtr->NBPtr)) {
227 TechPtr->TechnologySpecificHook[LrdimmBuf2DramTrain] (TechPtr, NULL);
228 if (!memTrainSequenceDDR3[i].MemTechFeatBlock->HwBasedWLTrainingPart2 (TechPtr)) {
232 MemFInitTableDrive (TechPtr->NBPtr, MTAfterHwWLTrnP2);
233 if (!memTrainSequenceDDR3[i].MemTechFeatBlock->HwBasedDQSReceiverEnableTrainingPart2 (TechPtr)) {
237 MemFInitTableDrive (TechPtr->NBPtr, MTAfterHwRxEnTrnP2);