remove trailing whitespace
[coreboot.git] / src / southbridge / amd / cimx / sb900 / Amd.h
1 /*****************************************************************************
2  * AMD Generic Encapsulated Software Architecture                            */
3 /**
4  * @file
5  *
6  * Agesa structures and definitions
7  *
8  * Contains AMD AGESA/CIMx core interface
9  *
10  * @xrefitem bom "File Content Label" "Release Content"
11  * @e project:      AGESA
12  * @e sub-project:  Include
13  * @e \$Revision:$   @e \$Date:$
14  */
15 /*
16  *****************************************************************************
17  *
18  * This file is part of the coreboot project.
19  *
20  * Copyright (C) 2011 Advanced Micro Devices, Inc.
21  *
22  * This program is free software; you can redistribute it and/or modify
23  * it under the terms of the GNU General Public License as published by
24  * the Free Software Foundation; version 2 of the License.
25  *
26  * This program is distributed in the hope that it will be useful,
27  * but WITHOUT ANY WARRANTY; without even the implied warranty of
28  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
29  * GNU General Public License for more details.
30  *
31  * You should have received a copy of the GNU General Public License
32  * along with this program; if not, write to the Free Software
33  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
34  * ***************************************************************************
35  *
36  */
37
38
39 #ifndef _AMD_H_
40 #define _AMD_H_
41
42 // AGESA Types and Definitions
43 #ifndef NULL
44   #define NULL 0
45 #endif
46
47 #define LAST_ENTRY 0xFFFFFFFF
48 #define IOCF8 0xCF8
49 #define IOCFC 0xCFC
50 #define IN
51 #define OUT
52
53 #ifndef Int16FromChar
54 #define Int16FromChar(a,b) ((a) << 0 | (b) << 8)
55 #endif
56 #ifndef Int32FromChar
57 #define Int32FromChar(a,b,c,d) ((a) << 0 | (b) << 8 | (c) << 16 | (d) << 24)
58 #endif
59
60 #define IMAGE_SIGNATURE     Int32FromChar ('$', 'A', 'M', 'D')
61
62 typedef unsigned int AGESA_STATUS;
63
64 #define AGESA_SUCCESS       ((AGESA_STATUS) 0x0)
65 #define AGESA_ALERT         ((AGESA_STATUS) 0x40000000)
66 #define AGESA_WARNING       ((AGESA_STATUS) 0x40000001)
67 #define AGESA_UNSUPPORTED   ((AGESA_STATUS) 0x80000003)
68 #define AGESA_ERROR         ((AGESA_STATUS) 0xC0000001)
69 #define AGESA_CRITICAL      ((AGESA_STATUS) 0xC0000002)
70 #define AGESA_FATAL         ((AGESA_STATUS) 0xC0000003)
71
72 typedef AGESA_STATUS (*CALLOUT_ENTRY) (unsigned int Param1, unsigned int Param2, void* ConfigPtr);
73 typedef AGESA_STATUS (*IMAGE_ENTRY) (IN OUT void* ConfigPtr);
74 typedef AGESA_STATUS (*MODULE_ENTRY) (IN OUT void* ConfigPtr);
75
76 ///This allocation type is used by the AmdCreateStruct entry point
77 typedef enum {
78   PreMemHeap = 0,                                           ///< Create heap in cache.
79   PostMemDram,                                              ///< Create heap in memory.
80   ByHost                                                    ///< Create heap by Host.
81 } ALLOCATION_METHOD;
82
83 /// These width descriptors are used by the library function, and others, to specify the data size
84 typedef enum ACCESS_WIDTH {
85   AccessWidth8 = 1,                                         ///< Access width is 8 bits.
86   AccessWidth16,                                            ///< Access width is 16 bits.
87   AccessWidth32,                                            ///< Access width is 32 bits.
88   AccessWidth64,                                            ///< Access width is 64 bits.
89
90   AccessS3SaveWidth8 = 0x81,                                ///< Save 8 bits data.
91   AccessS3SaveWidth16,                                      ///< Save 16 bits data.
92   AccessS3SaveWidth32,                                      ///< Save 32 bits data.
93   AccessS3SaveWidth64,                                      ///< Save 64 bits data.
94 } ACCESS_WIDTH;
95
96 // AGESA Structures
97
98 /// The standard header for all AGESA services.
99 typedef struct _AMD_CONFIG_PARAMS {
100   IN       unsigned int          ImageBasePtr;     ///< The AGESA Image base address.
101   IN       unsigned int          Func;             ///< The service desired, @sa dispatch.h.
102   IN       unsigned int          AltImageBasePtr;  ///< Alternate Image location
103   IN       unsigned int          PcieBasePtr;      ///< PCIe MMIO Base address, if configured.
104   union {                                    ///< Callback pointer
105     IN       unsigned long long          PlaceHolder;    ///< Place holder
106     IN       CALLOUT_ENTRY   CalloutPtr;     ///< For Callout from AGESA
107   } CALLBACK;
108   IN OUT   unsigned int          Reserved[2];      ///< This space is reserved for future use.
109 } AMD_CONFIG_PARAMS;
110
111
112 /// AGESA Binary module header structure
113 typedef struct _AMD_IMAGE_HEADER {
114   IN       unsigned int  Signature;                          ///< Binary Signature
115   IN       signed char   CreatorID[8];                       ///< 8 characters ID
116   IN       signed char   Version[12];                        ///< 12 characters version
117   IN       unsigned int  ModuleInfoOffset;                   ///< Offset of module
118   IN       unsigned int  EntryPointAddress;                  ///< Entry address
119   IN       unsigned int  ImageBase;                          ///< Image base
120   IN       unsigned int  RelocTableOffset;                   ///< Relocate Table offset
121   IN       unsigned int  ImageSize;                          ///< Size
122   IN       unsigned short  Checksum;                           ///< Checksum
123   IN       unsigned char   ImageType;                          ///< Type
124   IN       unsigned char   V_Reserved;                         ///< Reserved
125 } AMD_IMAGE_HEADER;
126
127 /// AGESA Binary module header structure
128 typedef struct _AMD_MODULE_HEADER {
129   IN       unsigned int          ModuleHeaderSignature;      ///< Module signature
130   IN       signed char           ModuleIdentifier[8];        ///< 8 characters ID
131   IN       signed char           ModuleVersion[12];          ///< 12 characters version
132   IN       MODULE_ENTRY    ModuleDispatcherPtr;        ///< A pointer point to dispatcher
133   IN       struct _AMD_MODULE_HEADER  *NextBlockPtr;    ///< Next module header link
134 } AMD_MODULE_HEADER;
135
136 #define FUNC_0    0   // bit-placed for PCI address creation
137 #define FUNC_1    1
138 #define FUNC_2    2
139 #define FUNC_3    3
140 #define FUNC_4    4
141 #define FUNC_5    5
142 #define FUNC_6    6
143 #define FUNC_7    7
144
145 //   SBDFO - Segment Bus Device Function Offset
146 //   31:28   Segment (4-bits)
147 //   27:20   Bus     (8-bits)
148 //   19:15   Device  (5-bits)
149 //   14:12   Function (3-bits)
150 //   11:00   Offset  (12-bits)
151
152 #if 0
153 #define MAKE_SBDFO(Seg, Bus, Dev, Fun, Off) ((((unsigned int) (Seg)) << 28) | (((unsigned int) (Bus)) << 20) | \
154                    (((unsigned int) (Dev)) << 15) | (((unsigned int) (Fun)) << 12) | ((unsigned int) (Off)))
155 #endif
156 #define ILLEGAL_SBDFO 0xFFFFFFFF
157
158 /*
159 /// CPUID data received registers format
160 typedef struct _SB_CPUID_DATA {
161   IN OUT   unsigned int          EAX_Reg;                ///< CPUID instruction result in EAX
162   IN OUT   unsigned int          EBX_Reg;                ///< CPUID instruction result in EBX
163   IN OUT   unsigned int          ECX_Reg;                ///< CPUID instruction result in ECX
164   IN OUT   unsigned int          EDX_Reg;                ///< CPUID instruction result in EDX
165 } SB_CPUID_DATA;
166 */
167
168 #define WARM_RESET 1
169 #define COLD_RESET 2      // Cold reset
170 #define RESET_CPU  4      // Triggers a CPU reset
171
172 /// HT frequency for external callbacks
173 typedef enum {
174   HT_FREQUENCY_200M          = 0,                 ///< HT speed 200 for external callbacks
175   HT_FREQUENCY_400M          = 2,                 ///< HT speed 400 for external callbacks
176   HT_FREQUENCY_600M          = 4,                 ///< HT speed 600 for external callbacks
177   HT_FREQUENCY_800M          = 5,                 ///< HT speed 800 for external callbacks
178   HT_FREQUENCY_1000M         = 6,                 ///< HT speed 1000 for external callbacks
179   HT_FREQUENCY_1200M         = 7,                 ///< HT speed 1200 for external callbacks
180   HT_FREQUENCY_1400M         = 8,                 ///< HT speed 1400 for external callbacks
181   HT_FREQUENCY_1600M         = 9,                 ///< HT speed 1600 for external callbacks
182   HT_FREQUENCY_1800M         = 10,                ///< HT speed 1800 for external callbacks
183   HT_FREQUENCY_2000M         = 11,                ///< HT speed 2000 for external callbacks
184   HT_FREQUENCY_2200M         = 12,                ///< HT speed 2200 for external callbacks
185   HT_FREQUENCY_2400M         = 13,                ///< HT speed 2400 for external callbacks
186   HT_FREQUENCY_2600M         = 14,                ///< HT speed 2600 for external callbacks
187   HT_FREQUENCY_2800M         = 17,                ///< HT speed 2800 for external callbacks
188   HT_FREQUENCY_3000M         = 18,                ///< HT speed 3000 for external callbacks
189   HT_FREQUENCY_3200M         = 19                 ///< HT speed 3200 for external callbacks
190 } HT_FREQUENCIES;
191
192 #ifndef BIT0
193   #define BIT0        0x0000000000000001ull
194 #endif
195 #ifndef BIT1
196   #define BIT1        0x0000000000000002ull
197 #endif
198 #ifndef BIT2
199   #define BIT2        0x0000000000000004ull
200 #endif
201 #ifndef BIT3
202   #define BIT3        0x0000000000000008ull
203 #endif
204 #ifndef BIT4
205   #define BIT4        0x0000000000000010ull
206 #endif
207 #ifndef BIT5
208   #define BIT5        0x0000000000000020ull
209 #endif
210 #ifndef BIT6
211   #define BIT6        0x0000000000000040ull
212 #endif
213 #ifndef BIT7
214   #define BIT7        0x0000000000000080ull
215 #endif
216 #ifndef BIT8
217   #define BIT8        0x0000000000000100ull
218 #endif
219 #ifndef BIT9
220   #define BIT9        0x0000000000000200ull
221 #endif
222 #ifndef BIT10
223   #define BIT10       0x0000000000000400ull
224 #endif
225 #ifndef BIT11
226   #define BIT11       0x0000000000000800ull
227 #endif
228 #ifndef BIT12
229   #define BIT12       0x0000000000001000ull
230 #endif
231 #ifndef BIT13
232   #define BIT13       0x0000000000002000ull
233 #endif
234 #ifndef BIT14
235   #define BIT14       0x0000000000004000ull
236 #endif
237 #ifndef BIT15
238   #define BIT15       0x0000000000008000ull
239 #endif
240 #ifndef BIT16
241   #define BIT16       0x0000000000010000ull
242 #endif
243 #ifndef BIT17
244   #define BIT17       0x0000000000020000ull
245 #endif
246 #ifndef BIT18
247   #define BIT18       0x0000000000040000ull
248 #endif
249 #ifndef BIT19
250   #define BIT19       0x0000000000080000ull
251 #endif
252 #ifndef BIT20
253   #define BIT20       0x0000000000100000ull
254 #endif
255 #ifndef BIT21
256   #define BIT21       0x0000000000200000ull
257 #endif
258 #ifndef BIT22
259   #define BIT22       0x0000000000400000ull
260 #endif
261 #ifndef BIT23
262   #define BIT23       0x0000000000800000ull
263 #endif
264 #ifndef BIT24
265   #define BIT24       0x0000000001000000ull
266 #endif
267 #ifndef BIT25
268   #define BIT25       0x0000000002000000ull
269 #endif
270 #ifndef BIT26
271   #define BIT26       0x0000000004000000ull
272 #endif
273 #ifndef BIT27
274   #define BIT27       0x0000000008000000ull
275 #endif
276 #ifndef BIT28
277   #define BIT28       0x0000000010000000ull
278 #endif
279 #ifndef BIT29
280   #define BIT29       0x0000000020000000ull
281 #endif
282 #ifndef BIT30
283   #define BIT30       0x0000000040000000ull
284 #endif
285 #ifndef BIT31
286   #define BIT31       0x0000000080000000ull
287 #endif
288 #ifndef BIT32
289   #define BIT32       0x0000000100000000ull
290 #endif
291 #ifndef BIT33
292   #define BIT33       0x0000000200000000ull
293 #endif
294 #ifndef BIT34
295   #define BIT34       0x0000000400000000ull
296 #endif
297 #ifndef BIT35
298   #define BIT35       0x0000000800000000ull
299 #endif
300 #ifndef BIT36
301   #define BIT36       0x0000001000000000ull
302 #endif
303 #ifndef BIT37
304   #define BIT37       0x0000002000000000ull
305 #endif
306 #ifndef BIT38
307   #define BIT38       0x0000004000000000ull
308 #endif
309 #ifndef BIT39
310   #define BIT39       0x0000008000000000ull
311 #endif
312 #ifndef BIT40
313   #define BIT40       0x0000010000000000ull
314 #endif
315 #ifndef BIT41
316   #define BIT41       0x0000020000000000ull
317 #endif
318 #ifndef BIT42
319   #define BIT42       0x0000040000000000ull
320 #endif
321 #ifndef BIT43
322   #define BIT43       0x0000080000000000ull
323 #endif
324 #ifndef BIT44
325   #define BIT44       0x0000100000000000ull
326 #endif
327 #ifndef BIT45
328   #define BIT45       0x0000200000000000ull
329 #endif
330 #ifndef BIT46
331   #define BIT46       0x0000400000000000ull
332 #endif
333 #ifndef BIT47
334   #define BIT47       0x0000800000000000ull
335 #endif
336 #ifndef BIT48
337   #define BIT48       0x0001000000000000ull
338 #endif
339 #ifndef BIT49
340   #define BIT49       0x0002000000000000ull
341 #endif
342 #ifndef BIT50
343   #define BIT50       0x0004000000000000ull
344 #endif
345 #ifndef BIT51
346   #define BIT51       0x0008000000000000ull
347 #endif
348 #ifndef BIT52
349   #define BIT52       0x0010000000000000ull
350 #endif
351 #ifndef BIT53
352   #define BIT53       0x0020000000000000ull
353 #endif
354 #ifndef BIT54
355   #define BIT54       0x0040000000000000ull
356 #endif
357 #ifndef BIT55
358   #define BIT55       0x0080000000000000ull
359 #endif
360 #ifndef BIT56
361   #define BIT56       0x0100000000000000ull
362 #endif
363 #ifndef BIT57
364   #define BIT57       0x0200000000000000ull
365 #endif
366 #ifndef BIT58
367   #define BIT58       0x0400000000000000ull
368 #endif
369 #ifndef BIT59
370   #define BIT59       0x0800000000000000ull
371 #endif
372 #ifndef BIT60
373   #define BIT60       0x1000000000000000ull
374 #endif
375 #ifndef BIT61
376   #define BIT61       0x2000000000000000ull
377 #endif
378 #ifndef BIT62
379   #define BIT62       0x4000000000000000ull
380 #endif
381 #ifndef BIT63
382   #define BIT63       0x8000000000000000ull
383 #endif
384 #endif