7 * Northbridge Phy support for Hydra
9 * @xrefitem bom "File Content Label" "Release Content"
11 * @e sub-project: (Mem/NB/HY)
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 * ***************************************************************************
48 *----------------------------------------------------------------------------
51 *----------------------------------------------------------------------------
64 #include "OptionMemory.h" // need def for MEM_FEAT_BLOCK_NB
66 #include "PlatformMemoryConfiguration.h"
71 #define FILECODE PROC_MEM_NB_HY_MNPHYHY_FILECODE
72 /*----------------------------------------------------------------------------
73 * DEFINITIONS AND MACROS
75 *----------------------------------------------------------------------------
79 /*----------------------------------------------------------------------------
80 * TYPEDEFS AND STRUCTURES
82 *----------------------------------------------------------------------------
85 /*----------------------------------------------------------------------------
86 * PROTOTYPES OF LOCAL FUNCTIONS
88 *----------------------------------------------------------------------------
93 /*----------------------------------------------------------------------------
96 *----------------------------------------------------------------------------
98 /* -----------------------------------------------------------------------------*/
101 /* -----------------------------------------------------------------------------*/
105 * This function initializes the DDR phy compensation logic
107 * @param[in,out] *NBPtr - Pointer to the MEM_NB_BLOCK
113 IN OUT MEM_NB_BLOCK *NBPtr
116 CONST UINT8 TableCompRiseSlew20x[] = {7, 3, 2, 2};
117 CONST UINT8 TableCompRiseSlew15x[] = {7, 7, 3, 2};
118 CONST UINT8 TableCompFallSlew20x[] = {7, 5, 3, 2};
119 CONST UINT8 TableCompFallSlew15x[] = {7, 7, 5, 3};
123 UINT8 MaxDimmsPerChannel;
124 UINT8 *DimmsPerChPtr;
126 CurrDct = NBPtr->Dct;
129 // Get Platform Information
131 DimmsPerChPtr = FindPSOverrideEntry (NBPtr->RefPtr->PlatformMemoryConfiguration, PSO_MAX_DIMMS, NBPtr->MCTPtr->SocketId, NBPtr->ChannelPtr->ChannelID, 0, NULL, NULL);
132 if (DimmsPerChPtr != NULL) {
133 MaxDimmsPerChannel = *DimmsPerChPtr;
135 MaxDimmsPerChannel = 2;
138 // 1. BIOS disables the phy compensation register by programming F2x9C_x08[DisAutoComp]=1
139 // 2. BIOS waits 5 us for the disabling of the compensation engine to complete.
140 // DisAutoComp will be cleared after Dram init has completed
142 MemNSwitchDCTNb (NBPtr, 0);
143 MemNSetBitFieldNb (NBPtr, BFDisAutoComp, 1);
144 MemUWait10ns (500, NBPtr->MemPtr);
145 MemNSwitchDCTNb (NBPtr, CurrDct);
147 // 3. For each normalized driver strength code read from
148 // F2x[1, 0]9C_x00[AddrCmdDrvStren], program the
149 // corresponding 3 bit predriver code in F2x9C_x0A[D3Cmp1NCal, D3Cmp1PCal].
151 // 4. For each normalized driver strength code read from
152 // F2x[1, 0]9C_x00[DataDrvStren], program the corresponding
153 // 3 bit predriver code in F2x9C_x0A[D3Cmp0NCal, D3Cmp0PCal, D3Cmp2NCal,
156 j = (UINT8) MemNGetBitFieldNb (NBPtr, BFAddrCmdDrvStren);
157 i = (UINT8) MemNGetBitFieldNb (NBPtr, BFDataDrvStren);
159 MemNSwitchDCTNb (NBPtr, 0);
161 MemNSetBitFieldNb (NBPtr, BFD3Cmp1NCal, TableCompRiseSlew20x[j]);
162 MemNSetBitFieldNb (NBPtr, BFD3Cmp1PCal, TableCompFallSlew20x[j]);
165 MemNSetBitFieldNb (NBPtr, BFD3Cmp0NCal, TableCompRiseSlew15x[i]);
166 MemNSetBitFieldNb (NBPtr, BFD3Cmp0PCal, TableCompFallSlew15x[i]);
167 MemNSetBitFieldNb (NBPtr, BFD3Cmp2NCal, TableCompRiseSlew15x[i]);
168 MemNSetBitFieldNb (NBPtr, BFD3Cmp2PCal, TableCompFallSlew15x[i]);
171 // Special Case for certain configs
173 // 3DPCH Fully populated.
174 if ((MaxDimmsPerChannel == 3) && (NBPtr->ChannelPtr->Dimms == 3)) {
175 MemNSetBitFieldNb (NBPtr, BFD3Cmp0NCal, 3);
176 MemNSetBitFieldNb (NBPtr, BFD3Cmp0PCal, 5);
177 MemNSetBitFieldNb (NBPtr, BFD3Cmp2NCal, 3);
178 MemNSetBitFieldNb (NBPtr, BFD3Cmp2PCal, 5);
181 MemNSwitchDCTNb (NBPtr, CurrDct);
184 /* -----------------------------------------------------------------------------*/
188 * This is a general purpose function that executes before DRAM training
190 * @param[in,out] *NBPtr - Pointer to the MEM_NB_BLOCK
195 MemNBeforeDQSTrainingHy (
196 IN OUT MEM_NB_BLOCK *NBPtr
204 MemTBeginTraining (NBPtr->TechPtr);
206 for (Dct = 0; Dct < NBPtr->DctCount; Dct++) {
207 MemNSwitchDCTNb (NBPtr, Dct);
208 if (NBPtr->DCTPtr->Timings.DctMemSize != 0) {
209 for (ChipSel = 0; ChipSel < MAX_CS_PER_CHANNEL; ChipSel += 2) {
210 if (MemNGetMCTSysAddrNb (NBPtr, ChipSel, &TestAddrRJ16)) {
212 RealAddr = MemUSetUpperFSbase (TestAddrRJ16, NBPtr->MemPtr);
214 MemUDummyCLRead (RealAddr);
216 MemNSetBitFieldNb (NBPtr, BFErr350, 0x8000);
217 MemUWait10ns (60, NBPtr->MemPtr); // Wait 300ns
218 MemNSetBitFieldNb (NBPtr, BFErr350, 0x0000);
219 MemUWait10ns (400, NBPtr->MemPtr); // Wait 2us
220 MemUProcIOClFlush (TestAddrRJ16, 1, NBPtr->MemPtr);
225 if (NBPtr->IsSupported[CheckEccDLLPwrDnConfig]) {
226 if (!NBPtr->MCTPtr->Status[SbEccDimms]) {
227 MemNSetBitFieldNb (NBPtr, BFEccDLLPwrDnConf, 0x0010);
229 if (NBPtr->DCTPtr->Timings.Dimmx4Present == 0) {
230 MemNSetBitFieldNb (NBPtr, BFEccDLLConf, 0x0080);
235 MemTEndTraining (NBPtr->TechPtr);
237 MemNSetBitFieldNb (NBPtr, BFDisDatMsk, 1);