AMD Agesa macro expansion fix
[coreboot.git] / src / vendorcode / amd / agesa / f12 / Proc / Mem / mu.h
1 /* $NoKeywords:$ */
2 /**
3  * @file
4  *
5  * mu.h
6  *
7  * Utility support
8  *
9  * @xrefitem bom "File Content Label" "Release Content"
10  * @e project: AGESA
11  * @e sub-project: (Mem)
12  * @e \$Revision: 45735 $ @e \$Date: 2011-01-21 07:49:28 +0800 (Fri, 21 Jan 2011) $
13  *
14  **/
15 /*****************************************************************************
16   *
17  * Copyright (c) 2011, 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 _MU_H_
46 #define _MU_H_
47
48 /*----------------------------------------------------------------------------
49  *   Mixed (DEFINITIONS AND MACROS / TYPEDEFS, STRUCTURES, ENUMS)
50  *
51  *----------------------------------------------------------------------------
52  */
53
54 /*-----------------------------------------------------------------------------
55  *                         DEFINITIONS AND MACROS
56  *
57  *-----------------------------------------------------------------------------
58  */
59 #ifndef PSO_ENTRY
60   #define PSO_ENTRY UINT8
61 #endif
62
63 //
64 // Maximum value macro
65 //
66 #ifndef MAX
67 #define MAX(X, Y) (((X) < (Y)) ? (Y) : (X))
68 #endif
69 //
70 // Minimum Value macro
71 //
72 #ifndef MIN
73 #define MIN(X, Y) (((X) < (Y)) ? (X) : (Y))
74 #endif
75 //
76 // Absolute Value Macro
77 //
78 #define ABS(X) (((X) < 0) ? (-(X)) : (X))
79
80
81
82 /*----------------------------------------------------------------------------
83  *                         TYPEDEFS, STRUCTURES, ENUMS
84  *
85  *----------------------------------------------------------------------------
86  */
87
88 /// Test patterns for DQS training
89 typedef enum {
90   TestPattern0,             ///< Test pattern used in first pass of receiver enable training
91   TestPattern1,             ///< Test pattern used in first pass of receiver enable training
92   TestPattern2,             ///< Test pattern used in second pass of receiver enable training
93   TestPatternJD1B,          ///< 72-bit test pattern used in position training (ganged mode)
94   TestPatternJD1A,          ///< 72-bit test pattern used in position training
95   TestPatternJD256B,        ///< 256-bit test pattern used in position training (ganged mode)
96   TestPatternJD256A,        ///< 256-bit test pattern used in position training
97   TestPatternML,            ///< Test pattern used in first pass of max latency training
98   TestPattern3,             ///< Test pattern used in first pass of receiver enable training
99   TestPattern4              ///< Test pattern used in first pass of receiver enable training
100 } TRAIN_PATTERN;
101
102 /*----------------------------------------------------------------------------
103  *                           FUNCTIONS PROTOTYPE
104  *
105  *----------------------------------------------------------------------------
106  */
107
108 VOID
109 MemUWriteCachelines (
110   IN       UINT32 Address,
111   IN       UINT8 Pattern[],
112   IN       UINT16 ClCount
113   );
114
115 VOID
116 MemUReadCachelines (
117   IN       UINT8 Buffer[],
118   IN       UINT32 Address,
119   IN       UINT16 ClCount
120   );
121
122 VOID
123 MemUDummyCLRead (
124   IN       UINT32 Address
125   );
126
127 VOID
128 MemUFlushPattern (
129   IN       UINT32 Address,
130   IN       UINT16 ClCount
131   );
132
133
134 VOID
135 MemUFillTrainPattern (
136   IN       TRAIN_PATTERN Pattern,
137   IN       UINT8 Buffer[],
138   IN       UINT16 Size
139   );
140
141 UINT32
142 MemUSetUpperFSbase (
143   IN       UINT32 Address,
144   IN OUT   MEM_DATA_STRUCT *MemPtr
145   );
146
147 VOID
148 MemUSetTargetWTIO (
149   IN       UINT32 Address,
150   IN OUT   MEM_DATA_STRUCT *MemPtr
151   );
152
153 VOID
154 MemUResetTargetWTIO (
155   IN OUT   MEM_DATA_STRUCT *MemPtr
156   );
157
158 VOID
159 MemUProcIOClFlush (
160   IN       UINT32 Address,
161   IN       UINT16 ClCount,
162   IN OUT   MEM_DATA_STRUCT *MemPtr
163   );
164
165 VOID
166 MemUWait10ns (
167   IN       UINT32 Count,
168   IN OUT   MEM_DATA_STRUCT *MemPtr
169   );
170
171 VOID
172 MemUGetWrLvNblErr (
173   IN OUT   UINT16 *ErrBitmap,
174   IN       UINT32 TestAddr,
175   IN       UINT16 ClCount
176   );
177
178 VOID
179 AlignPointerTo16Byte (
180   IN OUT   UINT8 **BufferPtrPtr
181   );
182
183 VOID *
184 FindPSOverrideEntry (
185   IN       PSO_TABLE *PlatformMemoryConfiguration,
186   IN       PSO_ENTRY EntryType,
187   IN       UINT8 SocketID,
188   IN       UINT8 ChannelID
189   );
190
191 UINT8
192 GetMaxDimmsPerChannel (
193   IN       PSO_TABLE *PlatformMemoryConfiguration,
194   IN UINT8 SocketID,
195   IN UINT8 ChannelID
196   );
197
198 UINT8
199 GetMaxChannelsPerSocket (
200   IN       PSO_TABLE *PlatformMemoryConfiguration,
201   IN UINT8 SocketID,
202   IN       AMD_CONFIG_PARAMS *StdHeader
203   );
204
205 UINT8
206 GetMaxCSPerChannel (
207   IN      PSO_TABLE *PlatformMemoryConfiguration,
208   IN      UINT8 SocketID,
209   IN      UINT8 ChannelID
210   );
211
212 UINT8
213 GetSpdSocketIndex (
214   IN       PSO_TABLE *PlatformMemoryConfiguration,
215   IN UINT8 SocketID,
216   IN       AMD_CONFIG_PARAMS *StdHeader
217   );
218
219 UINT8
220 GetSpdChannelIndex (
221   IN       PSO_TABLE *PlatformMemoryConfiguration,
222   IN UINT8 SocketID,
223   IN UINT8 ChannelID,
224   IN       AMD_CONFIG_PARAMS *StdHeader
225   );
226
227 UINT32
228 GetVarMtrrHiMsk (
229   IN       CPU_LOGICAL_ID *LogicalIdPtr,
230   IN       AMD_CONFIG_PARAMS *StdHeader
231   );
232
233 VOID
234 MemUMFenceInstr (
235   VOID
236   );
237
238 UINT32
239 MemUnsToMemClk (
240   IN       MEMORY_BUS_SPEED Speed,
241   IN       UINT32 NumberOfns
242   );
243 #endif  /* _MU_H_ */
244
245