AGESA F15: AMD family15 AGESA code
[coreboot.git] / src / vendorcode / amd / agesa / f15 / Include / OptionMemory.h
1 /* $NoKeywords:$ */
2 /**
3  * @file
4  *
5  * AMD Memory option API.
6  *
7  * Contains structures and values used to control the Memory option code.
8  *
9  * @xrefitem bom "File Content Label" "Release Content"
10  * @e project:      AGESA
11  * @e sub-project:  OPTION
12  * @e \$Revision: 55039 $   @e \$Date: 2011-06-15 23:31:36 -0600 (Wed, 15 Jun 2011) $
13  *
14  */
15 /*****************************************************************************
16  *
17  * Copyright (C) 2012 Advanced Micro Devices, Inc.
18  * All rights reserved.
19  *
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.
30  *
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.
41  *
42  ******************************************************************************
43  */
44
45 #ifndef _OPTION_MEMORY_H_
46 #define _OPTION_MEMORY_H_
47
48 /* Memory Includes */
49 #include "mm.h"
50 #include "mn.h"
51 #include "mt.h"
52 #include "ma.h"
53 #include "mp.h"
54 /*----------------------------------------------------------------------------------------
55  *          M I X E D   (Definitions And Macros / Typedefs, Structures, Enums)
56  *----------------------------------------------------------------------------------------
57  */
58
59 /*----------------------------------------------------------------------------------------
60  *                 D E F I N I T I O N S     A N D     M A C R O S
61  *----------------------------------------------------------------------------------------
62  */
63
64 #define MAX_FF_TYPES      6   ///< Maximum number of DDR Form factors (UDIMMs, RDIMMMs, SODIMMS) supported
65
66 /*----------------------------------------------------------------------------------------
67  *               T Y P E D E F S,   S T R U C T U R E S,    E N U M S
68  *----------------------------------------------------------------------------------------
69  */
70
71 /*
72 * STANDARD MEMORY FEATURE FUNCTION POINTER
73 */
74
75 typedef BOOLEAN OPTION_MEM_FEATURE_NB (
76   IN OUT   MEM_NB_BLOCK *NBPtr
77   );
78
79 typedef BOOLEAN MEM_TECH_FEAT (
80   IN OUT   MEM_TECH_BLOCK *TechPtr
81   );
82
83 typedef UINT8 MEM_TABLE_FEAT (
84   IN OUT   MEM_TABLE_ALIAS **MTPtr
85   );
86
87 #define MEM_FEAT_BLOCK_NB_STRUCT_VERSION  0x01
88
89 /**
90  *  MEMORY FEATURE BLOCK - This structure serves as a vector table for standard
91  *  memory feature implementation functions.  It contains vectors for all of the
92  *  features that are supported by the various Northbridge devices supported by
93  *  AGESA.
94  */
95 typedef struct _MEM_FEAT_BLOCK_NB {
96   UINT16              OptMemFeatVersion; ///< Version of memory feature block.
97   OPTION_MEM_FEATURE_NB  *OnlineSpare; ///< Online spare support.
98   OPTION_MEM_FEATURE_NB  *InterleaveBanks; ///< Bank (Chip select) interleaving support.
99   OPTION_MEM_FEATURE_NB  *UndoInterleaveBanks; ///< Undo Bank (Chip Select) interleaving.
100   OPTION_MEM_FEATURE_NB  *CheckInterleaveNodes; ///< Check for Node interleaving support.
101   OPTION_MEM_FEATURE_NB  *InterleaveNodes; ///< Node interleaving support.
102   OPTION_MEM_FEATURE_NB  *InterleaveChannels; ///< Channel interleaving support.
103   OPTION_MEM_FEATURE_NB  *InterleaveRegion;  ///< Interleave Region support.
104   OPTION_MEM_FEATURE_NB  *CheckEcc; ///< Check for ECC support.
105   OPTION_MEM_FEATURE_NB  *InitEcc; ///< ECC support.
106   OPTION_MEM_FEATURE_NB  *Training; ///< Choose the type of training (Parallel, standard or hardcoded).
107   OPTION_MEM_FEATURE_NB  *LvDdr3; ///< Low voltage DDR3 dimm support
108   OPTION_MEM_FEATURE_NB  *OnDimmThermal; ///< On-Dimm thermal management
109   MEM_TECH_FEAT  *DramInit; ///< Choose the type of Dram init (hardware based or software based).
110   OPTION_MEM_FEATURE_NB  *ExcludeDIMM; ///< Exclude a dimm.
111   OPTION_MEM_FEATURE_NB  *InitEarlySampleSupport; ///< Initialize early sample support.
112   OPTION_MEM_FEATURE_NB  *InitCPG; ///< Continuous pattern generation.
113   OPTION_MEM_FEATURE_NB  *InitHwRxEn; ///< Hardware Receiver Enable Training Initilization.
114 } MEM_FEAT_BLOCK_NB;
115
116 typedef AGESA_STATUS MEM_MAIN_FLOW_CONTROL (
117   IN OUT   MEM_MAIN_DATA_BLOCK *MemMainPtr
118   );
119
120 typedef BOOLEAN OPTION_MEM_FEATURE_MAIN (
121   IN MEM_MAIN_DATA_BLOCK *MMPtr
122   );
123
124 typedef BOOLEAN MEM_NB_CONSTRUCTOR (
125   IN OUT   MEM_NB_BLOCK *NBPtr,
126   IN OUT   MEM_DATA_STRUCT *MemPtr,
127   IN       MEM_FEAT_BLOCK_NB *FeatPtr,
128   IN       MEM_SHARED_DATA *mmSharedPtr,     ///< Pointer to Memory scratchpad
129   IN       UINT8 NodeID
130   );
131
132 typedef BOOLEAN MEM_TECH_CONSTRUCTOR (
133   IN OUT   MEM_TECH_BLOCK *TechPtr,
134   IN OUT   MEM_NB_BLOCK   *NBPtr
135   );
136
137 typedef VOID MEM_INITIALIZER (
138   IN OUT   MEM_DATA_STRUCT *MemPtr
139  );
140
141 typedef AGESA_STATUS MEM_PLATFORM_CFG (
142   IN struct _MEM_DATA_STRUCT *MemData,
143   IN UINT8 SocketID,
144   IN CH_DEF_STRUCT *CurrentChannel
145   );
146
147 typedef BOOLEAN MEM_IDENDIMM_CONSTRUCTOR (
148   IN OUT   MEM_NB_BLOCK *NBPtr,
149   IN OUT   MEM_DATA_STRUCT *MemPtr,
150   IN       UINT8 NodeID
151   );
152
153 typedef VOID MEM_TECH_TRAINING_FEAT (
154   IN OUT   MEM_TECH_BLOCK *TechPtr,
155   IN       UINT8 Pass
156   );
157
158 typedef BOOLEAN MEM_RESUME_CONSTRUCTOR (
159   IN OUT   VOID *S3NBPtr,
160   IN OUT   MEM_DATA_STRUCT *MemPtr,
161   IN       UINT8 NodeID
162   );
163
164 typedef AGESA_STATUS MEM_PLAT_SPEC_CFG (
165   IN struct _MEM_DATA_STRUCT *MemData,
166   IN OUT   CH_DEF_STRUCT *CurrentChannel,
167   IN OUT   MEM_PS_BLOCK *PsPtr
168   );
169
170 typedef AGESA_STATUS MEM_FLOW_CFG (
171   IN OUT   MEM_MAIN_DATA_BLOCK *MemData
172   );
173
174 #define MEM_FEAT_BLOCK_MAIN_STRUCT_VERSION  0x01
175
176 /**
177  * MAIN FEATURE BLOCK - This structure serves as vector table for memory features
178  * that shared between all northbridge devices.
179  */
180 typedef struct _MEM_FEAT_BLOCK_MAIN {
181   UINT16              OptMemFeatVersion; ///< Version of main feature block.
182   OPTION_MEM_FEATURE_MAIN *Training; ///< Training features.
183   OPTION_MEM_FEATURE_MAIN *ExcludeDIMM; ///< Exclude a dimm.
184   OPTION_MEM_FEATURE_MAIN *OnlineSpare; ///< On-line spare.
185   OPTION_MEM_FEATURE_MAIN *InterleaveNodes; ///< Node interleave.
186   OPTION_MEM_FEATURE_MAIN *InitEcc; ///< Initialize ECC on all nodes if they all support it.
187   OPTION_MEM_FEATURE_MAIN *MemClr; ///< Memory Clear.
188   OPTION_MEM_FEATURE_MAIN *MemDmi; ///< Memory DMI Support.
189   OPTION_MEM_FEATURE_MAIN *LvDDR3; ///< Low voltage DDR3 support.
190   OPTION_MEM_FEATURE_MAIN *UmaAllocation; ///< Uma Allocation.
191   OPTION_MEM_FEATURE_MAIN *MemSave; ///< Memory Context Save
192   OPTION_MEM_FEATURE_MAIN *MemRestore; ///< Memory Context Restore
193 } MEM_FEAT_BLOCK_MAIN;
194
195 #define MEM_NB_SUPPORT_STRUCT_VERSION  0x01
196 #define MEM_TECH_FEAT_BLOCK_STRUCT_VERSION  0x01
197 #define MEM_TECH_TRAIN_SEQUENCE_STRUCT_VERSION  0x01
198 #define MEM_TECH_LRDIMM_STRUCT_VERSION 0x01
199 /**
200  *  MEMORY TECHNOLOGY FEATURE BLOCK - This structure serves as a vector table for standard
201  *  memory feature implementation functions.  It contains vectors for all of the
202  *  features that are supported by the various Technology features supported by
203  *  AGESA.
204  */
205 typedef struct _MEM_TECH_FEAT_BLOCK {
206   UINT16  OptMemTechFeatVersion; ///< Version of memory Tech feature block.
207   MEM_TECH_FEAT *EnterHardwareTraining; ///<Enter HW WL Training
208   MEM_TECH_FEAT *SwWLTraining; ///<SW Write Levelization training
209   MEM_TECH_FEAT *HwBasedWLTrainingPart1; ///<HW based write levelization Training Part 1
210   MEM_TECH_FEAT *HwBasedDQSReceiverEnableTrainingPart1; ///<HW based DQS receiver Enabled Training Part 1
211   MEM_TECH_FEAT *HwBasedWLTrainingPart2; ///<HW based write levelization Training Part 2
212   MEM_TECH_FEAT *HwBasedDQSReceiverEnableTrainingPart2; ///<HW based DQS receiver Enabled Training Part 2
213   MEM_TECH_FEAT *TrainExitHwTrn; ///<Exit HW WL Training
214   MEM_TECH_FEAT *NonOptimizedSWDQSRecEnTrainingPart1; ///< Non-Optimized Software based receiver Enable Training part 1
215   MEM_TECH_FEAT *OptimizedSwDqsRecEnTrainingPart1; ///< Optimized Software based receiver Enable Training part 1
216   MEM_TECH_FEAT *NonOptimizedSRdWrPosTraining; ///< Non-Optimized Rd Wr Position training
217   MEM_TECH_FEAT *OptimizedSRdWrPosTraining; ///< Optimized Rd Wr Position training
218   MEM_TECH_FEAT *MaxRdLatencyTraining; ///< MaxReadLatency Training
219   MEM_TECH_FEAT *RdPosTraining; ///< HW Rx En Seed Training
220   MEM_TECH_FEAT *RdDqs__Training; ///< Read DQS Training
221 } MEM_TECH_FEAT_BLOCK;
222
223 /**
224  *  MEMORY TECHNOLOGY LRDIMM BLOCK - This structure serves as a vector table for standard
225  *  memory feature implementation functions.  It contains vectors for all of the
226  *  features that are supported by the various LRDIMM features supported by
227  *  AGESA.
228  */
229 typedef struct _MEM_TECH_LRDIMM {
230   UINT16  OptMemTechLrdimmVersion; ///< Version of memory Tech feature block.
231   MEM_TECH_FEAT *MemTInitializeLrdimm; ///< LRDIMM initialization
232 } MEM_TECH_LRDIMM;
233 /**
234  * MEMORY NORTHBRIDGE SUPPORT STRUCT - This structure groups the Northbridge dependent
235  * options together in a list to provide a single access point for all code to use
236  * and to ensure that everything corresponding to the same NB type is grouped together.
237  *
238  * The Technology Block pointers are not included in this structure because DRAM technology
239  * needs to be decoupled from the northbridge type.
240  *
241  */
242 typedef struct _MEM_NB_SUPPORT {
243   UINT16              MemNBSupportVersion; ///< Version of northbridge support.
244   MEM_NB_CONSTRUCTOR  *MemConstructNBBlock; ///< NorthBridge block constructor.
245   MEM_INITIALIZER     *MemNInitDefaults; ///< Default value initialization for MEM_DATA_STRUCT.
246   MEM_FEAT_BLOCK_NB      *MemFeatBlock; ///< Memory feature block.
247   MEM_RESUME_CONSTRUCTOR *MemS3ResumeConstructNBBlock; ///< S3 memory initialization northbridge block constructor.
248   MEM_IDENDIMM_CONSTRUCTOR *MemIdentifyDimmConstruct; ///< Constructor for address to dimm identification.
249 } MEM_NB_SUPPORT;
250
251 /*
252  *  MEMORY Non-Training FEATURES - This structure serves as a vector table for standard
253  *  memory non-training feature implementation functions.  It contains vectors for all of the
254  *  features that are supported by the various Technology devices supported by
255  *  AGESA.
256  */
257
258 /**
259  * MAIN TRAINING SEQUENCE LIST - This structure serves as vector table for memory features
260  * that shared between all northbridge devices.
261  */
262 typedef struct _MEM_FEAT_TRAIN_SEQ {
263   UINT16              OptMemTrainingSequenceListVersion; ///< Version of main feature block.
264   OPTION_MEM_FEATURE_NB *TrainingSequence; ///< Training Sequence function.
265   OPTION_MEM_FEATURE_NB *TrainingSequenceEnabled; ///< Enable function.
266   MEM_TECH_FEAT_BLOCK      *MemTechFeatBlock; ///< Memory feature block.
267 } MEM_FEAT_TRAIN_SEQ;
268
269 /**
270  * PLATFORM SPECIFIC CONFIGURATION BLOCK - This structure groups various PSC table
271  * entries which are used by PSC engine
272  */
273 typedef struct _MEM_PSC_TABLE_BLOCK {
274   PSC_TBL_ENTRY **TblEntryOfMaxFreq; ///< Table entry of MaxFreq.
275   PSC_TBL_ENTRY **TblEntryOfDramTerm; ///< Table entry of Dram Term.
276   PSC_TBL_ENTRY **TblEntryOfODTPattern; ///< Table entry of ODT Pattern.
277   PSC_TBL_ENTRY **TblEntryOfSAO; ///< Table entry of Slow access mode, AddrTmg and ODC..
278   PSC_TBL_ENTRY **TblEntryOfMR0WR; ///< Table entry of MR0[WR].
279   PSC_TBL_ENTRY **TblEntryOfMR0CL; ///< Table entry of MR0[CL].
280   PSC_TBL_ENTRY **TblEntryOfRC2IBT; ///< Table entry of RC2 IBT.
281   PSC_TBL_ENTRY **TblEntryOfRC10OpSpeed; ///< Table entry of RC10[operating speed].
282   PSC_TBL_ENTRY **TblEntryOfLRIBT;///< Table entry of LRDIMM IBT
283   PSC_TBL_ENTRY **TblEntryOfLRNPR; ///< Table entry of LRDIMM F0RC13[NumPhysicalRanks].
284   PSC_TBL_ENTRY **TblEntryOfLRNLR; ///< Table entry of LRDIMM F0RC13[NumLogicalRanks].
285   PSC_TBL_ENTRY **TblEntryOfGen; ///< Table entry of CLKDis map and CKE, ODT as well as ChipSel tri-state map.
286   PSC_TBL_ENTRY **TblEntryOfS__; ///< Table entry of training configs
287   PSC_TBL_ENTRY **TblEntryOfWLSeed; ///< Table entry of WL seed
288   PSC_TBL_ENTRY **TblEntryOfHWRxENSeed; ///< Table entry of HW RxEN seed
289 } MEM_PSC_TABLE_BLOCK;
290
291 typedef BOOLEAN MEM_PSC_FLOW (
292   IN OUT   MEM_NB_BLOCK *NBPtr,
293   IN       MEM_PSC_TABLE_BLOCK *EntryOfTables
294   );
295
296 /**
297  * PLATFORM SPECIFIC CONFIGURATION FLOW BLOCK - Pointers to the sub-engines of platform
298  * specific configuration.
299  */
300 typedef struct _MEM_PSC_FLOW_BLOCK {
301   MEM_PSC_TABLE_BLOCK *EntryOfTables; ///<Entry of NB specific MEM_PSC_TABLE_BLOCK
302   MEM_PSC_FLOW *MaxFrequency; ///< Sub-engine which performs "Max Frequency" value extraction.
303   MEM_PSC_FLOW *DramTerm; ///< Sub-engine which performs "Dram Term" value extraction.
304   MEM_PSC_FLOW *ODTPattern; ///< Sub-engine which performs "ODT Pattern" value extraction.
305   MEM_PSC_FLOW *SAO; ///< Sub-engine which performs "Slow access mode, AddrTmg and ODC" value extraction.
306   MEM_PSC_FLOW *MR0WrCL; ///< Sub-engine which performs "MR0[WR] and MR0[CL]" value extraction.
307   MEM_PSC_FLOW *RC2IBT; ///< Sub-engine "RC2 IBT" value extraction.
308   MEM_PSC_FLOW *RC10OpSpeed; ///< Sub-engine "RC10[operating speed]" value extraction.
309   MEM_PSC_FLOW *LRIBT; ///< Sub-engine "LRDIMM IBT" value extraction.
310   MEM_PSC_FLOW *LRNPR; ///< Sub-engine "LRDIMM F0RC13[NumPhysicalRanks]" value extraction.
311   MEM_PSC_FLOW *LRNLR; ///< Sub-engine "LRDIMM F0RC13[NumLogicalRanks]" value extraction.
312   MEM_PSC_FLOW *S__; ///< Sub-engine which performs training configuration  checking
313   MEM_PSC_FLOW *TrainingSeedVal; ///< Sub-engine for WL and HW RxEn pass1 seed value extraction
314 } MEM_PSC_FLOW_BLOCK;
315
316 /*----------------------------------------------------------------------------------------
317  *                        F U N C T I O N    P R O T O T Y P E
318  *----------------------------------------------------------------------------------------
319  */
320 /* Feature Default Return */
321 BOOLEAN MemFDefRet (
322   IN OUT   MEM_NB_BLOCK *NBPtr
323   );
324
325 BOOLEAN MemMDefRet (
326   IN MEM_MAIN_DATA_BLOCK *MMPtr
327   );
328
329 BOOLEAN MemMDefRetFalse (
330   IN   MEM_MAIN_DATA_BLOCK *MMPtr
331   );
332
333 /* Table Feature Default Return */
334 UINT8 MemFTableDefRet (
335   IN OUT   MEM_TABLE_ALIAS **MTPtr
336   );
337 /* S3 Feature Default Return */
338 BOOLEAN MemFS3DefConstructorRet (
339   IN OUT   VOID *S3NBPtr,
340   IN OUT   MEM_DATA_STRUCT *MemPtr,
341   IN       UINT8 NodeID
342   );
343
344 BOOLEAN MemNIdentifyDimmConstructorRetDef (
345   IN OUT   MEM_NB_BLOCK *NBPtr,
346   IN OUT   MEM_DATA_STRUCT *MemPtr,
347   IN       UINT8 NodeID
348   );
349
350 BOOLEAN
351 MemProcessConditionalOverrides (
352   IN       PSO_TABLE *PlatformMemoryConfiguration,
353   IN OUT   MEM_NB_BLOCK *NBPtr,
354   IN       UINT8 PsoAction,
355   IN       UINT8 Dimm
356    );
357
358 #endif  // _OPTION_MEMORY_H_