Rename {CPU|NB|SB}/amd/*_wrapper folders
[coreboot.git] / src / vendorcode / amd / agesa / Proc / Mem / Ps / RB / mpuRb3.c
1 /* $NoKeywords:$ */
2 /**
3  * @file
4  *
5  * mpuRb3.c
6  *
7  * Platform specific settings for RB DDR3 U-DIMM system
8  *
9  * @xrefitem bom "File Content Label" "Release Content"
10  * @e project: AGESA
11  * @e sub-project: (Mem/Ps)
12  * @e \$Revision: 35136 $ @e \$Date: 2010-07-16 11:29:48 +0800 (Fri, 16 Jul 2010) $
13  *
14  **/
15 /*
16  *****************************************************************************
17  *
18  * Copyright (c) 2011, Advanced Micro Devices, Inc.
19  * All rights reserved.
20  * 
21  * Redistribution and use in source and binary forms, with or without
22  * modification, are permitted provided that the following conditions are met:
23  *     * Redistributions of source code must retain the above copyright
24  *       notice, this list of conditions and the following disclaimer.
25  *     * Redistributions in binary form must reproduce the above copyright
26  *       notice, this list of conditions and the following disclaimer in the
27  *       documentation and/or other materials provided with the distribution.
28  *     * Neither the name of Advanced Micro Devices, Inc. nor the names of 
29  *       its contributors may be used to endorse or promote products derived 
30  *       from this software without specific prior written permission.
31  * 
32  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
33  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
34  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
35  * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
36  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
37  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
38  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
39  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
40  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
41  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
42  * 
43  * ***************************************************************************
44  *
45  */
46
47 /* This file contains routine that add platform specific support L1 */
48
49
50 #include "AGESA.h"
51 #include "AdvancedApi.h"
52 #include "mport.h"
53 #include "ma.h"
54 #include "Ids.h"
55 #include "cpuFamRegisters.h"
56 #include "mm.h"
57 #include "mn.h"
58 #include "mp.h"
59 #include "mu.h"
60 #include "OptionMemory.h"
61 #include "PlatformMemoryConfiguration.h"
62 #include "GeneralServices.h"
63 #include "Filecode.h"
64 CODE_GROUP (G2_PEI)
65 RDATA_GROUP (G2_PEI)
66
67 #define FILECODE PROC_MEM_PS_RB_MPURB3_FILECODE
68 /*----------------------------------------------------------------------------
69  *                          DEFINITIONS AND MACROS
70  *
71  *----------------------------------------------------------------------------
72  */
73
74 /*----------------------------------------------------------------------------
75  *                           TYPEDEFS AND STRUCTURES
76  *
77  *----------------------------------------------------------------------------
78  */
79
80 /*----------------------------------------------------------------------------
81  *                        PROTOTYPES OF LOCAL FUNCTIONS
82  *
83  *----------------------------------------------------------------------------
84  */
85 BOOLEAN
86 STATIC
87 MemPDoPsURb3 (
88   IN OUT   MEM_NB_BLOCK *NBPtr
89   );
90
91 VOID
92 STATIC
93 MemPGetPORFreqLimitURb3 (
94   IN OUT   MEM_NB_BLOCK *NBPtr
95   );
96
97 /*
98  *-----------------------------------------------------------------------------
99  *                                EXPORTED FUNCTIONS
100  *
101  *-----------------------------------------------------------------------------
102  */
103 STATIC CONST DRAM_TERM_ENTRY DrUDdr3DramTerm[] = {
104   {DDR800 + DDR1066 + DDR1333 + DDR1600, ONE_DIMM, NO_DIMM, 1, 0, 0},
105   {DDR800 + DDR1066, TWO_DIMM, NO_DIMM, 3, 0, 2},
106   {DDR1333, TWO_DIMM, NO_DIMM, 5, 0, 2},
107   {DDR1600, TWO_DIMM, NO_DIMM, 5, 0, 1}
108 };
109 /* -----------------------------------------------------------------------------*/
110 /**
111  *
112  *     This function is the constructor for the platform specific settings for U-DDR3 RB DDR3
113  *
114  *     @param[in,out]   *MemPtr           Pointer to MEM_DATA_STRUCTURE
115  *     @param[in,out]   *ChannelPtr       Pointer to CH_DEF_STRUCT
116  *     @param[in,out]   *PsPtr       Pointer to MEM_PS_BLOCK
117  *
118  *     @return          AGESA_SUCCESS
119  *
120  */
121
122 AGESA_STATUS
123 MemPConstructPsURb3 (
124   IN OUT   MEM_DATA_STRUCT *MemPtr,
125   IN OUT   CH_DEF_STRUCT *ChannelPtr,
126   IN OUT   MEM_PS_BLOCK *PsPtr
127   )
128 {
129   ASSERT (MemPtr != 0);
130   ASSERT (ChannelPtr != 0);
131
132   if ((ChannelPtr->MCTPtr->LogicalCpuid.Family & AMD_FAMILY_10_RB) == 0) {
133     return AGESA_UNSUPPORTED;
134   }
135   if (ChannelPtr->TechType != DDR3_TECHNOLOGY) {
136     return AGESA_UNSUPPORTED;
137   }
138   if ((ChannelPtr->RegDimmPresent != 0) || (ChannelPtr->SODimmPresent != 0)) {
139     return AGESA_UNSUPPORTED;
140   }
141
142   PsPtr->MemPDoPs = MemPDoPsURb3;
143   PsPtr->MemPGetPORFreqLimit = MemPGetPORFreqLimitURb3;
144   return AGESA_SUCCESS;
145 }
146
147 /* -----------------------------------------------------------------------------*/
148 /**
149  *
150  *     This is function sets the platform specific settings for U-DDR3 RB DDR3
151  *
152  *     @param[in,out]   *NBPtr           Pointer to MEM_NB_BLOCK
153  *
154  *     @return          TRUE - Find settings for corresponding platform and dimm population.
155  *     @return          FALSE - Fail to find settings for corresponding platform and dimm population.
156  *
157  */
158
159 BOOLEAN
160 STATIC
161 MemPDoPsURb3 (
162   IN OUT   MEM_NB_BLOCK *NBPtr
163   )
164 {
165   if (!MemPGetDramTerm (NBPtr, GET_SIZE_OF (DrUDdr3DramTerm), DrUDdr3DramTerm)) {
166     return FALSE;
167   }
168
169   return TRUE;
170 }
171
172 /* -----------------------------------------------------------------------------*/
173 /**
174  *
175  *     This is function gets the POR speed limit for U-DDR3 RB
176  *
177  *     @param[in,out]   *NBPtr           Pointer to MEM_NB_BLOCK
178  *
179  *
180  */
181 VOID
182 STATIC
183 MemPGetPORFreqLimitURb3 (
184   IN OUT   MEM_NB_BLOCK *NBPtr
185   )
186 {
187   UINT16 SpeedLimit;
188
189   if (NBPtr->RefPtr->DDR3Voltage == VOLT1_5) {
190     //
191     // Highest POR supported speed for Unbuffered dimm is 1333
192     //
193     SpeedLimit = DDR1333_FREQUENCY;
194   } else {
195     //
196     // Max LV DDR3 Speed is 1066 for this silicon
197     //
198     SpeedLimit = DDR1066_FREQUENCY;
199   }
200
201   if (NBPtr->DCTPtr->Timings.TargetSpeed > SpeedLimit) {
202     NBPtr->DCTPtr->Timings.TargetSpeed = SpeedLimit;
203   } else if (NBPtr->DCTPtr->Timings.TargetSpeed == DDR667_FREQUENCY) {
204     // Unbuffered DDR3 at 333MHz is not supported
205     NBPtr->DCTPtr->Timings.DimmExclude |= NBPtr->DCTPtr->Timings.DctDimmValid;
206     PutEventLog (AGESA_ERROR, MEM_ERROR_UNSUPPORTED_333MHZ_UDIMM, NBPtr->Node, NBPtr->Dct, NBPtr->Channel, 0, &NBPtr->MemPtr->StdHeader);
207     SetMemError (AGESA_ERROR, NBPtr->MCTPtr);
208     // Change target speed to highest value so it won't affect other channels when leveling frequency across the node.
209     NBPtr->DCTPtr->Timings.TargetSpeed = UNSUPPORTED_DDR_FREQUENCY;
210   }
211 }