7 * Common platform specific configuration.
9 * @xrefitem bom "File Content Label" "Release Content"
11 * @e sub-project: (Proc/Recovery/Mem/Ps)
12 * @e \$Revision: 44324 $ @e \$Date: 2010-12-22 02:16:51 -0700 (Wed, 22 Dec 2010) $
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 *----------------------------------------------------------------------------
49 *----------------------------------------------------------------------------
55 #include "AdvancedApi.h"
58 #include "cpuFamRegisters.h"
59 #include "cpuRegisters.h"
60 #include "OptionMemory.h"
67 #define FILECODE PROC_RECOVERY_MEM_PS_MRP_FILECODE
70 /*----------------------------------------------------------------------------
71 * DEFINITIONS AND MACROS
73 *----------------------------------------------------------------------------
76 /*----------------------------------------------------------------------------
77 * TYPEDEFS AND STRUCTURES
79 *----------------------------------------------------------------------------
81 /*----------------------------------------------------------------------------
82 * PROTOTYPES OF LOCAL FUNCTIONS
84 *----------------------------------------------------------------------------
86 /*----------------------------------------------------------------------------
89 *----------------------------------------------------------------------------
91 extern MEM_PSC_FLOW_BLOCK* memRecPlatSpecFlowArray[];
93 /* -----------------------------------------------------------------------------*/
96 * This function gets platform specific configuration such as Max Freq., Slow Mode, Dram Term,
99 * @param[in] *NBPtr Pointer to MEM_NB_BLOCK
100 * @return TRUE - Successfully execute platform specific configuration flow.
101 * @return FALSE - Fail to execute platform specific configuration flow.
106 IN OUT MEM_NB_BLOCK *NBPtr
112 while (memRecPlatSpecFlowArray[i] != NULL) {
113 if ((memRecPlatSpecFlowArray[i])->DramTerm (NBPtr, (memRecPlatSpecFlowArray[i])->EntryOfTables)) {
114 if ((memRecPlatSpecFlowArray[i])->ODTPattern (NBPtr, (memRecPlatSpecFlowArray[i])->EntryOfTables)) {
115 if ((memRecPlatSpecFlowArray[i])->SAO (NBPtr, (memRecPlatSpecFlowArray[i])->EntryOfTables)) {
116 if ((memRecPlatSpecFlowArray[i])->MR0WrCL (NBPtr, (memRecPlatSpecFlowArray[i])->EntryOfTables)) {
117 if ((memRecPlatSpecFlowArray[i])->RC2IBT (NBPtr, (memRecPlatSpecFlowArray[i])->EntryOfTables)) {
118 if ((memRecPlatSpecFlowArray[i])->RC10OpSpeed (NBPtr, (memRecPlatSpecFlowArray[i])->EntryOfTables)) {
119 if ((memRecPlatSpecFlowArray[i])->LRIBT (NBPtr, (memRecPlatSpecFlowArray[i])->EntryOfTables)) {
120 if ((memRecPlatSpecFlowArray[i])->LRNPR (NBPtr, (memRecPlatSpecFlowArray[i])->EntryOfTables)) {
121 if ((memRecPlatSpecFlowArray[i])->LRNLR (NBPtr, (memRecPlatSpecFlowArray[i])->EntryOfTables)) {
137 /* -----------------------------------------------------------------------------*/
140 * This function constructs the rank type map of Dimm0, Dimm1, Dimm2. Also it counts the number
141 * of dimm in the table.
143 * @param[in] Dimm0 Rank type of Dimm0
144 * @param[in] Dimm1 Rank type of Dimm1
145 * @param[in] Dimm2 Rank type of Dimm2
146 * @param[in, out] *RankTypeInTable Pointer to RankTypeInTable variable
151 MemPRecConstructRankTypeMap (
155 IN OUT UINT16 *RankTypeInTable
162 *RankTypeInTable = 0;
166 for (i = 0; i < MAX_DIMMS_PER_CHANNEL; i++) {
169 RT = (Dimm0 == 0) ? NP : Dimm0;
173 RT = (Dimm1 == 0) ? NP : Dimm1;
177 RT = (Dimm2 == 0) ? NP : Dimm2;
181 // dimm3 is not used, fills nibble3 with "NP"
185 *RankTypeInTable |= RT << BitShift;
189 /*-----------------------------------------------------------------------------*/
192 * This function matches the CPU_LOGICAL_ID and PackageType with certain criteria to
193 * determine if it is supported by this NB type.
195 * @param[in,out] *NBPtr - Pointer to the MEM_NB_BLOCK
196 * @param[in] LogicalId - CPU_LOGICAL_ID
197 * @param[in] PackageType - Package Type
199 * @return TRUE - NB type is matched !
200 * @return FALSE - NB type is not matched !
204 MemPRecIsIdSupported (
205 IN OUT MEM_NB_BLOCK *NBPtr,
206 IN CPU_LOGICAL_ID LogicalId,
213 LibAmdCpuidRead (AMD_CPUID_FMF, &CpuId, &(NBPtr->MemPtr->StdHeader));
214 PkgType = (UINT8) (CpuId.EBX_Reg >> 28) & 0xF; // bit 31:28
216 if (((NBPtr->MCTPtr->LogicalCpuid.Family & LogicalId.Family) != 0)
217 && ((NBPtr->MCTPtr->LogicalCpuid.Revision & LogicalId.Revision) != 0)) {
218 if ((PackageType == PT_DONT_CARE) || (PackageType == PkgType)) {
225 /* -----------------------------------------------------------------------------*/
228 * This function returns the rank type map of a channel.
230 * @param[in] *CurrentChannel Pointer to CH_DEF_STRUCT
232 * @return UINT16 - The map of rank type.
236 MemPRecGetPsRankType (
237 IN CH_DEF_STRUCT *CurrentChannel
244 for (i = 0; i < MAX_DIMMS_PER_CHANNEL; i++) {
245 if ((CurrentChannel->DimmQrPresent & (UINT8) 1 << i) != 0) {
247 DIMMRankType |= (UINT16) 8 << (i << 2);
249 } else if ((CurrentChannel->DimmDrPresent & (UINT8) 1 << i) != 0) {
250 DIMMRankType |= (UINT16) 4 << (i << 2);
251 } else if ((CurrentChannel->DimmSRPresent & (UINT8) 1 << i) != 0) {
252 DIMMRankType |= (UINT16) 2 << (i << 2);
254 DIMMRankType |= (UINT16) 1 << (i << 2);