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