AMD F14 southbridge update
[coreboot.git] / src / southbridge / amd / cimx / sb800 / 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 /// CPUID data received registers format
159 typedef struct _CPUID_DATA {
160   IN OUT   unsigned int          EAX_Reg;                ///< CPUID instruction result in EAX
161   IN OUT   unsigned int          EBX_Reg;                ///< CPUID instruction result in EBX
162   IN OUT   unsigned int          ECX_Reg;                ///< CPUID instruction result in ECX
163   IN OUT   unsigned int          EDX_Reg;                ///< CPUID instruction result in EDX
164 } CPUID_DATA;
165
166 #define WARM_RESET 1
167 #define COLD_RESET 2      // Cold reset
168 #define RESET_CPU  4      // Triggers a CPU reset
169
170 /// HT frequency for external callbacks
171 typedef enum {
172   HT_FREQUENCY_200M          = 0,                 ///< HT speed 200 for external callbacks
173   HT_FREQUENCY_400M          = 2,                 ///< HT speed 400 for external callbacks
174   HT_FREQUENCY_600M          = 4,                 ///< HT speed 600 for external callbacks
175   HT_FREQUENCY_800M          = 5,                 ///< HT speed 800 for external callbacks
176   HT_FREQUENCY_1000M         = 6,                 ///< HT speed 1000 for external callbacks
177   HT_FREQUENCY_1200M         = 7,                 ///< HT speed 1200 for external callbacks
178   HT_FREQUENCY_1400M         = 8,                 ///< HT speed 1400 for external callbacks
179   HT_FREQUENCY_1600M         = 9,                 ///< HT speed 1600 for external callbacks
180   HT_FREQUENCY_1800M         = 10,                ///< HT speed 1800 for external callbacks
181   HT_FREQUENCY_2000M         = 11,                ///< HT speed 2000 for external callbacks
182   HT_FREQUENCY_2200M         = 12,                ///< HT speed 2200 for external callbacks
183   HT_FREQUENCY_2400M         = 13,                ///< HT speed 2400 for external callbacks
184   HT_FREQUENCY_2600M         = 14,                ///< HT speed 2600 for external callbacks
185   HT_FREQUENCY_2800M         = 17,                ///< HT speed 2800 for external callbacks
186   HT_FREQUENCY_3000M         = 18,                ///< HT speed 3000 for external callbacks
187   HT_FREQUENCY_3200M         = 19                 ///< HT speed 3200 for external callbacks
188 } HT_FREQUENCIES;
189
190 #ifndef BIT0
191   #define BIT0        0x0000000000000001ull
192 #endif
193 #ifndef BIT1
194   #define BIT1        0x0000000000000002ull
195 #endif
196 #ifndef BIT2
197   #define BIT2        0x0000000000000004ull
198 #endif
199 #ifndef BIT3
200   #define BIT3        0x0000000000000008ull
201 #endif
202 #ifndef BIT4
203   #define BIT4        0x0000000000000010ull
204 #endif
205 #ifndef BIT5
206   #define BIT5        0x0000000000000020ull
207 #endif
208 #ifndef BIT6
209   #define BIT6        0x0000000000000040ull
210 #endif
211 #ifndef BIT7
212   #define BIT7        0x0000000000000080ull
213 #endif
214 #ifndef BIT8
215   #define BIT8        0x0000000000000100ull
216 #endif
217 #ifndef BIT9
218   #define BIT9        0x0000000000000200ull
219 #endif
220 #ifndef BIT10
221   #define BIT10       0x0000000000000400ull
222 #endif
223 #ifndef BIT11
224   #define BIT11       0x0000000000000800ull
225 #endif
226 #ifndef BIT12
227   #define BIT12       0x0000000000001000ull
228 #endif
229 #ifndef BIT13
230   #define BIT13       0x0000000000002000ull
231 #endif
232 #ifndef BIT14
233   #define BIT14       0x0000000000004000ull
234 #endif
235 #ifndef BIT15
236   #define BIT15       0x0000000000008000ull
237 #endif
238 #ifndef BIT16
239   #define BIT16       0x0000000000010000ull
240 #endif
241 #ifndef BIT17
242   #define BIT17       0x0000000000020000ull
243 #endif
244 #ifndef BIT18
245   #define BIT18       0x0000000000040000ull
246 #endif
247 #ifndef BIT19
248   #define BIT19       0x0000000000080000ull
249 #endif
250 #ifndef BIT20
251   #define BIT20       0x0000000000100000ull
252 #endif
253 #ifndef BIT21
254   #define BIT21       0x0000000000200000ull
255 #endif
256 #ifndef BIT22
257   #define BIT22       0x0000000000400000ull
258 #endif
259 #ifndef BIT23
260   #define BIT23       0x0000000000800000ull
261 #endif
262 #ifndef BIT24
263   #define BIT24       0x0000000001000000ull
264 #endif
265 #ifndef BIT25
266   #define BIT25       0x0000000002000000ull
267 #endif
268 #ifndef BIT26
269   #define BIT26       0x0000000004000000ull
270 #endif
271 #ifndef BIT27
272   #define BIT27       0x0000000008000000ull
273 #endif
274 #ifndef BIT28
275   #define BIT28       0x0000000010000000ull
276 #endif
277 #ifndef BIT29
278   #define BIT29       0x0000000020000000ull
279 #endif
280 #ifndef BIT30
281   #define BIT30       0x0000000040000000ull
282 #endif
283 #ifndef BIT31
284   #define BIT31       0x0000000080000000ull
285 #endif
286 #ifndef BIT32
287   #define BIT32       0x0000000100000000ull
288 #endif
289 #ifndef BIT33
290   #define BIT33       0x0000000200000000ull
291 #endif
292 #ifndef BIT34
293   #define BIT34       0x0000000400000000ull
294 #endif
295 #ifndef BIT35
296   #define BIT35       0x0000000800000000ull
297 #endif
298 #ifndef BIT36
299   #define BIT36       0x0000001000000000ull
300 #endif
301 #ifndef BIT37
302   #define BIT37       0x0000002000000000ull
303 #endif
304 #ifndef BIT38
305   #define BIT38       0x0000004000000000ull
306 #endif
307 #ifndef BIT39
308   #define BIT39       0x0000008000000000ull
309 #endif
310 #ifndef BIT40
311   #define BIT40       0x0000010000000000ull
312 #endif
313 #ifndef BIT41
314   #define BIT41       0x0000020000000000ull
315 #endif
316 #ifndef BIT42
317   #define BIT42       0x0000040000000000ull
318 #endif
319 #ifndef BIT43
320   #define BIT43       0x0000080000000000ull
321 #endif
322 #ifndef BIT44
323   #define BIT44       0x0000100000000000ull
324 #endif
325 #ifndef BIT45
326   #define BIT45       0x0000200000000000ull
327 #endif
328 #ifndef BIT46
329   #define BIT46       0x0000400000000000ull
330 #endif
331 #ifndef BIT47
332   #define BIT47       0x0000800000000000ull
333 #endif
334 #ifndef BIT48
335   #define BIT48       0x0001000000000000ull
336 #endif
337 #ifndef BIT49
338   #define BIT49       0x0002000000000000ull
339 #endif
340 #ifndef BIT50
341   #define BIT50       0x0004000000000000ull
342 #endif
343 #ifndef BIT51
344   #define BIT51       0x0008000000000000ull
345 #endif
346 #ifndef BIT52
347   #define BIT52       0x0010000000000000ull
348 #endif
349 #ifndef BIT53
350   #define BIT53       0x0020000000000000ull
351 #endif
352 #ifndef BIT54
353   #define BIT54       0x0040000000000000ull
354 #endif
355 #ifndef BIT55
356   #define BIT55       0x0080000000000000ull
357 #endif
358 #ifndef BIT56
359   #define BIT56       0x0100000000000000ull
360 #endif
361 #ifndef BIT57
362   #define BIT57       0x0200000000000000ull
363 #endif
364 #ifndef BIT58
365   #define BIT58       0x0400000000000000ull
366 #endif
367 #ifndef BIT59
368   #define BIT59       0x0800000000000000ull
369 #endif
370 #ifndef BIT60
371   #define BIT60       0x1000000000000000ull
372 #endif
373 #ifndef BIT61
374   #define BIT61       0x2000000000000000ull
375 #endif
376 #ifndef BIT62
377   #define BIT62       0x4000000000000000ull
378 #endif
379 #ifndef BIT63
380   #define BIT63       0x8000000000000000ull
381 #endif
382 #endif