7 * Northbridge Orochi MCT supporting functions
9 * @xrefitem bom "File Content Label" "Release Content"
11 * @e sub-project: (Mem/NB/OR)
12 * @e \$Revision: 51634 $ @e \$Date: 2011-04-26 03:12:52 -0600 (Tue, 26 Apr 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 *----------------------------------------------------------------------------
61 #include "OptionMemory.h" // need def for MEM_FEAT_BLOCK_NB
62 #include "cpuFeatures.h"
69 #define FILECODE PROC_MEM_NB_OR_MNMCTOR_FILECODE
70 /*----------------------------------------------------------------------------
71 * DEFINITIONS AND MACROS
73 *----------------------------------------------------------------------------
76 /*----------------------------------------------------------------------------
77 * TYPEDEFS AND STRUCTURES
79 *----------------------------------------------------------------------------
82 /*----------------------------------------------------------------------------
83 * PROTOTYPES OF LOCAL FUNCTIONS
85 *----------------------------------------------------------------------------
89 /*----------------------------------------------------------------------------
92 *----------------------------------------------------------------------------
94 extern BUILD_OPT_CFG UserOptions;
96 /* -----------------------------------------------------------------------------*/
100 * This function sets final values for specific registers.
102 * @param[in,out] *NBPtr - Pointer to the MEM_NB_BLOCK
104 * @return TRUE - No fatal error occurs.
105 * @return FALSE - Fatal error occurs.
110 IN OUT MEM_NB_BLOCK *NBPtr
113 MEM_DATA_STRUCT *MemPtr;
114 MEM_PARAMETER_STRUCT *RefPtr;
115 DRAM_PREFETCH_MODE DramPrefetchMode;
123 MemPtr = NBPtr->MemPtr;
124 RefPtr = MemPtr->ParameterListPtr;
125 DramPrefetchMode = MemPtr->PlatFormConfig->PlatformProfile.AdvancedPerformanceProfile.DramPrefetchMode;
126 Speed = NBPtr->DCTPtr->Timings.Speed;
130 // FlushWrOnStpGnt = 0
131 // PrefThreeConf = 110b
132 // PrefTwoConf = 011b
139 Value32 = MemNGetBitFieldNb (NBPtr, BFMctCfgHiReg);
140 Value32 &= 0xD003CF80;
141 Value32 |= 0x0CE00041;
142 MemNSetBitFieldNb (NBPtr, BFMctCfgHiReg, Value32);
144 if (DramPrefetchMode == DISABLE_DRAM_PREFETCH_FOR_IO || DramPrefetchMode == DISABLE_DRAM_PREFETCHER) {
145 MemNSetBitFieldNb (NBPtr, BFPrefIoDis, 1);
148 if (DramPrefetchMode == DISABLE_DRAM_PREFETCH_FOR_CPU || DramPrefetchMode == DISABLE_DRAM_PREFETCHER) {
149 MemNSetBitFieldNb (NBPtr, BFPrefCpuDis, 1);
152 if (Speed == DDR667_FREQUENCY) {
156 } else if (Speed == DDR800_FREQUENCY) {
160 } else if (Speed == DDR1066_FREQUENCY) {
164 } else if (Speed == DDR1333_FREQUENCY) {
168 } else if (Speed == DDR1600_FREQUENCY) {
172 } else if (Speed == DDR1866_FREQUENCY) {
186 // PrefFiveConf = 111b
187 // PrefFourConf = 111b
188 // EnSplitDctLimits = 1
189 // CohPrefPrbLmt = IF (PrbFltrEn) THEN 000b ELSE 001b ENDIF
190 // AdapPrefNegativeStep = 00b
191 // AdapPrefPositiveStep = 00b
192 // AdapPrefMissRatio = 01b
193 Value32 = MemNGetBitFieldNb (NBPtr, BFExtMctCfgLoReg);
194 Value32 &= 0x003FE8C0;
195 Value32 |= 0x0FC01001;
196 Value32 |= (UINT32) DcqBwThrotWm << 28;
197 MemNSetBitFieldNb (NBPtr, BFExtMctCfgLoReg, Value32);
204 Value32 = MemNGetBitFieldNb (NBPtr, BFExtMctCfgHiReg);
205 Value32 &= 0xF7FFFC00;
206 Value32 |= (((UINT32) DcqBwThrotWm2 << 5) | (UINT32) DcqBwThrotWm1);
207 // FlushWrOnS3StpGnt to 1
208 Value32 |= (UINT32) 1 << 27;
209 MemNSetBitFieldNb (NBPtr, BFExtMctCfgHiReg, Value32);
211 for (Dct = 0; Dct < MAX_DCTS_PER_NODE_OR; Dct++) {
212 MemNSwitchDCTNb (NBPtr, Dct);
214 if (NBPtr->DCTPtr->Timings.DctMemSize != 0) {
218 MemNPhyPowerSavingUnb (NBPtr);
222 if (NBPtr->RefPtr->EnablePowerDown) {
223 MemNSetBitFieldNb (NBPtr, BFPowerDownEn, 1);
229 if (IsFeatureEnabled (C6Cstate, NBPtr->MemPtr->PlatFormConfig, &(NBPtr->MemPtr->StdHeader))) {
230 IDS_SKIP_HOOK (IDS_TRACE_MODE, NBPtr, &NBPtr->MemPtr->StdHeader) {
231 MemNSetBitFieldNb (NBPtr, BFLockDramCfg, 1);
235 return (BOOLEAN) (NBPtr->MCTPtr->ErrCode < AGESA_FATAL);
239 /*----------------------------------------------------------------------------
242 *----------------------------------------------------------------------------
244 /*-----------------------------------------------------------------------------
247 * This function handles scrubber register settings for orochi.
249 * @param[in,out] *NBPtr - Pointer to the MEM_NB_BLOCK
250 * @param[in,out] OptParam - If the function is called before scrub rate is set or after
251 * TRUE function is called before scrub rate is set
252 * FALSE function is called after scrub rate is set
255 * ----------------------------------------------------------------------------
258 MemNScrubberErratumOr (
259 IN OUT MEM_NB_BLOCK *NBPtr,
260 IN OUT VOID *OptParam
266 if (*(BOOLEAN *) OptParam == TRUE) {
267 MemNSwitchDCTNb (NBPtr, 0);
269 ASSERT (NBPtr->Dct == 0);
270 L3Scrub = (UINT8) MemNGetBitFieldNb (NBPtr, BFL3Scrub);
271 DramScrub = (UINT8) MemNGetBitFieldNb (NBPtr, BFDramScrub);
273 // Set scrubber for DCT1
274 MemNSwitchDCTNb (NBPtr, 1);
275 MemNSetBitFieldNb (NBPtr, BFL3Scrub, L3Scrub);
276 MemNSetBitFieldNb (NBPtr, BFDramScrub, DramScrub);
282 /* -----------------------------------------------------------------------------*/
286 * This function changes DataTxFifoWrDly based on training result of WrDatDly
288 * @param[in,out] *NBPtr - Pointer to the MEM_NB_BLOCK
289 * @param[in,out] OptParam - Optional parameter
295 MemNDataTxFifoWrDlyOverrideOr (
296 IN OUT MEM_NB_BLOCK *NBPtr,
297 IN OUT VOID *OptParam
304 BOOLEAN DataTxFifoWrDly;
306 // This should be done only after DQS Position training
307 if (NBPtr->NbFreqChgState <= 1) {
311 // Set DataTxFifoWrDly based on WrDatDly
312 // if all WrDatDly of populated dimms on a DCT are equal to 7h
313 // Set DataTxFifoWrDly to >= 2h
314 for (Dct = 0; Dct < 2; Dct ++) {
315 MemNSwitchDCTNb (NBPtr, Dct);
316 DataTxFifoWrDly = TRUE;
317 CsEnabled = NBPtr->DCTPtr->Timings.CsEnabled;
318 for (i = 0; i < MAX_DIMMS_PER_CHANNEL; i ++) {
319 if ((CsEnabled & (UINT16) (3 << (i << 1))) != 0) {
320 for (ByteLane = 0; ByteLane < (NBPtr->MCTPtr->Status[SbEccDimms] ? 9 : 8); ByteLane++) {
321 if ((GetTrainDlyFromHeapNb (NBPtr, AccessWrDatDly, DIMM_BYTE_ACCESS (i, ByteLane)) >> 5) != 7) {
322 DataTxFifoWrDly = FALSE;
326 if (!DataTxFifoWrDly) {
332 if (DataTxFifoWrDly) {
333 if (MemNGetBitFieldNb (NBPtr, BFDataTxFifoWrDly) < 2) {
334 MemNSetBitFieldNb (NBPtr, BFDataTxFifoWrDly, 2);