2 * This file is part of the coreboot project.
4 * Copyright (C) 2006 coresystems GmbH
5 * (Written by Stefan Reinauer <stepan@coresystems.de> for coresystems GmbH)
6 * Copyright (C) 2007 University of Mannheim
7 * (Written by Sven Kapferer <skapfere@rumms.uni-mannheim.de> for Uni Ma.)
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; version 2 of the License.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA
24 * This code sets the Processor Name String for AMD64 CPUs.
26 * Written by Stefan Reinauer <stepan@coresystems.de> using
27 * the Revision Guide for AMD Athlon™ 64 and AMD Opteron™ Processors
28 * Document ID 25759 Rev 3.59, April 2006 (Public Version).
30 * Updated by Sven Kapferer <skapfere@rumms.uni-mannheim.de> using
31 * the Revision Guide for AMD NPT Family 0Fh Processors
32 * Document ID 33610 Rev 3.00, October 2006 (Public Version).
35 #include <console/console.h>
37 #include <cpu/x86/msr.h>
39 /* The maximum length of CPU names is 48 bytes, including the final NULL byte.
40 * If you change these names your BIOS will _NOT_ pass the AMD validation and
41 * your mainboard will not be posted on the AMD Recommended Motherboard Website
44 #if K8_REV_F_SUPPORT == 0
45 static char *processor_names[]={
46 /* 0x00 */ "AMD Engineering Sample",
47 /* 0x01-0x03 */ NULL, NULL, NULL,
48 /* 0x04 */ "AMD Athlon(tm) 64 Processor XX00+",
49 /* 0x05 */ "AMD Athlon(tm) 64 X2 Dual Core Processor XX00+",
50 /* 0x06-0x07 */ NULL, NULL,
51 /* 0x08 */ "Mobile AMD Athlon(tm) 64 Processor XX00+",
52 /* 0x09 */ "Mobile AMD Athlon(tm) 64 Processor XX00+",
53 /* 0x0A */ "AMD Turion(tm) 64 Mobile Technology ML-XX",
54 /* 0x0B */ "AMD Turion(tm) 64 Mobile Technology MT-XX",
55 /* 0x0C */ "AMD Opteron(tm) Processor 1YY",
56 /* 0x0D */ "AMD Opteron(tm) Processor 1YY",
57 /* 0x0E */ "AMD Opteron(tm) Processor 1YY HE",
58 /* 0x0F */ "AMD Opteron(tm) Processor 1YY EE",
59 /* 0x10 */ "AMD Opteron(tm) Processor 2YY",
60 /* 0x11 */ "AMD Opteron(tm) Processor 2YY",
61 /* 0x12 */ "AMD Opteron(tm) Processor 2YY HE",
62 /* 0x13 */ "AMD Opteron(tm) Processor 2YY EE",
63 /* 0x14 */ "AMD Opteron(tm) Processor 8YY",
64 /* 0x15 */ "AMD Opteron(tm) Processor 8YY",
65 /* 0x16 */ "AMD Opteron(tm) Processor 8YY HE",
66 /* 0x17 */ "AMD Opteron(tm) Processor 8YY EE",
67 /* 0x18 */ "AMD Athlon(tm) 64 Processor VV00+",
68 /* 0x19-0x1C */ NULL, NULL, NULL, NULL,
69 /* 0x1D */ "Mobile AMD Athlon(tm) XP-M Processor XX00+",
70 /* 0x1E */ "Mobile AMD Athlon(tm) XP-M Processor XX00+",
72 /* 0x20 */ "AMD Athlon(tm) XP Processor XX00+",
73 /* 0x21 */ "Mobile AMD Sempron(tm) Processor TT00+",
74 /* 0x22 */ "AMD Sempron(tm) Processor TT00+",
75 /* 0x23 */ "Mobile AMD Sempron(tm) Processor TT00+",
76 /* 0x24 */ "AMD Athlon(tm) 64 FX-ZZ Processor",
78 /* 0x26 */ "AMD Sempron(tm) Processor TT00+",
79 /* 0x27-0x28 */ NULL, NULL,
80 /* 0x29 */ "Dual Core AMD Opteron(tm) Processor 1RR SE",
81 /* 0x2A */ "Dual Core AMD Opteron(tm) Processor 2RR SE",
82 /* 0x2B */ "Dual Core AMD Opteron(tm) Processor 8RR SE",
83 /* 0x2C */ "Dual Core AMD Opteron(tm) Processor 1RR",
84 /* 0x2D */ "Dual Core AMD Opteron(tm) Processor 1RR",
85 /* 0x2E */ "Dual Core AMD Opteron(tm) Processor 1RR HE",
86 /* 0x2F */ "Dual Core AMD Opteron(tm) Processor 1RR EE",
87 /* 0x30 */ "Dual Core AMD Opteron(tm) Processor 2RR",
88 /* 0x31 */ "Dual Core AMD Opteron(tm) Processor 2RR",
89 /* 0x32 */ "Dual Core AMD Opteron(tm) Processor 2RR HE",
90 /* 0x33 */ "Dual Core AMD Opteron(tm) Processor 2RR EE",
91 /* 0x34 */ "Dual Core AMD Opteron(tm) Processor 8RR",
92 /* 0x35 */ "Dual Core AMD Opteron(tm) Processor 8RR",
93 /* 0x36 */ "Dual Core AMD Opteron(tm) Processor 8RR HE",
94 /* 0x37 */ "Dual Core AMD Opteron(tm) Processor 8RR EE",
95 /* 0x38 */ "Dual Core AMD Opteron(tm) Processor 1RR",
96 /* 0x39 */ "Dual Core AMD Opteron(tm) Processor 2RR",
97 /* 0x3A */ "Dual Core AMD Opteron(tm) Processor 8RR"
98 #define MAX_CPU_NUMBER 0x3A
102 /* wrmsr_amd() is from yhlu's changes to model_fxx_init.c */
104 static inline void wrmsr_amd(unsigned index, msr_t msr)
106 __asm__ __volatile__ (
109 : "c" (index), "a" (msr.lo), "d" (msr.hi), "D" (0x9c5a203a)
113 static inline unsigned int cpuid_eax(unsigned int op)
120 : "ebx", "ecx", "edx");
124 static inline unsigned int cpuid_ebx(unsigned int op)
126 unsigned int eax, ebx;
129 : "=a" (eax), "=b" (ebx)
135 static inline unsigned int cpuid_ecx(unsigned int op)
137 unsigned int eax, ecx;
140 : "=a" (eax), "=c" (ecx)
146 static inline void strcpy(char *dst, char *src)
148 while (*src) *dst++ = *src++;
152 int init_processor_name(void)
162 char *processor_name_string=NULL;
163 char program_string[48];
164 unsigned int *program_values = (unsigned int *)program_string;
166 #if K8_REV_F_SUPPORT == 0
167 /* Find out which CPU brand it is */
168 EightBitBrandId = cpuid_ebx(0x00000001) & 0xff;
169 BrandId = cpuid_ebx(0x80000001) & 0xffff;
171 if(!EightBitBrandId && !BrandId) {
174 } else if(!EightBitBrandId) {
175 BrandTableIndex = (BrandId >> 6) & 0x3f; // BrandId[11:6]
176 NN = BrandId & 0x3f; // // BrandId[6:0]
178 BrandTableIndex = EightBitBrandId >> (5-2) & 0xfc; // { 0b, 8BitBrandId[7:5], 00b }
179 NN = EightBitBrandId & 0x1f; // 8BitBrandId[4:0]
182 /* Look up the CPU brand in above table */
183 if (BrandTableIndex <= MAX_CPU_NUMBER)
184 processor_name_string = processor_names[BrandTableIndex];
186 if (!processor_name_string)
187 processor_name_string = "AMD Processor model unknown";
190 #if K8_REV_F_SUPPORT == 1
195 BrandId = cpuid_ebx(0x80000001) & 0xffff;
196 Socket = (cpuid_eax(0x80000001) & 0x00000030) >> 4; // 00b = S1g1, 01b = F (1207), 11b = AM2
197 CmpCap = cpuid_ecx(0x80000008) & 0x03; // Number of CPU cores
199 PwrLmt = ((BrandId >> 14) & 0x01) | ((BrandId >> 5) & 0x0e); // BrandId[8:6,14]
200 BrandTableIndex = (BrandId >> 9) & 0x1f; // BrandId[13:9]
201 NN = ((BrandId >> 15) & 0x01) | (BrandId & 0x3f); // BrandId[15,5:0]
203 if (((BrandTableIndex == 0) && (PwrLmt == 0)) || (NN == 0)) {
204 processor_name_string = "AMD Engineering Sample";
206 /* Use all fields to identify CPU */
207 switch ((Socket << 16) | (CmpCap << 12) | (BrandTableIndex << 4)
211 processor_name_string =
212 "Dual-Core AMD Opteron(tm) Processor 22RR HE";
215 processor_name_string =
216 "Dual-Core AMD Opteron(tm) Processor 22RR";
219 processor_name_string =
220 "Dual-Core AMD Opteron(tm) Processor 22RR SE";
223 processor_name_string =
224 "Dual-Core AMD Opteron(tm) Processor 82RR HE";
227 processor_name_string =
228 "Dual-Core AMD Opteron(tm) Processor 82RR";
231 processor_name_string =
232 "Dual-Core AMD Opteron(tm) Processor 82RR SE";
237 processor_name_string =
238 "AMD Athlon(tm) 64 Processor TT00+";
242 processor_name_string =
243 "AMD Sempron(tm) Processor TT00+";
246 processor_name_string =
247 "Dual-Core AMD Opteron(tm) Processor 12RR";
250 processor_name_string =
251 "Dual-Core AMD Opteron(tm) Processor 12RR SE";
257 processor_name_string =
258 "AMD Athlon(tm) 64 X2 Dual Core Processor TT00+";
261 processor_name_string =
262 "AMD Athlon(tm) 64 FX-ZZ Dual Core Processor";
266 processor_name_string =
267 "AMD Turion(tm) 64 X2 Mobile Technology TL-YY";
270 processor_name_string = "AMD Processor model unknown";
275 memset(program_string, 0, 48);
276 strcpy(program_string, processor_name_string);
278 /* Now create a model number - See Table 4. Model Number Calculation
279 * in the Revision Guide. NOTE: #6, EE was changed to VV because
280 * otherwise it clashes with the brand names.
283 for (i=0; i<47; i++) { // 48 -1
284 if(program_string[i] == program_string[i+1]) {
285 switch (program_string[i]) {
286 #if K8_REV_F_SUPPORT == 0
287 case 'X': ModelNumber = 22+ NN; break;
288 case 'Y': ModelNumber = 38 + (2*NN); break;
290 case 'T': ModelNumber = 24 + NN; break;
291 case 'R': ModelNumber = 45 + (5*NN); break;
292 case 'V': ModelNumber = 9 + NN; break;
295 #if K8_REV_F_SUPPORT == 1
296 case 'R': ModelNumber = NN - 1; break;
297 case 'P': ModelNumber = 26 + NN; break;
298 case 'T': ModelNumber = 15 + (CmpCap * 10) + NN; break;
299 case 'Z': ModelNumber = 57 + NN; break;
300 case 'Y': ModelNumber = 29 + NN; break;
304 if(ModelNumber && ModelNumber < 100) {
305 // No idea what to do with RR=100. According
306 // to the revision guide this is possible.
308 // --> "AMD Opteron(tm) Processor 8100"?
309 program_string[i]=(ModelNumber/10)+'0';
310 program_string[i+1]=(ModelNumber%10)+'0';
316 printk_debug("CPU model %s\n", program_string);
318 for (i=0; i<6; i++) {
319 progmsr.lo = program_values[(2*i)+0];
320 progmsr.hi = program_values[(2*i)+1];
321 wrmsr_amd(0xc0010030+i, progmsr);