Create new socket for FCPGA370 and PGA370 CPU's for CAR. Add CAR support for Coppermi...
[coreboot.git] / src / cpu / intel / model_68x / model_68x_init.c
1 /*
2  * This file is part of the coreboot project.
3  *
4  * Copyright (C) 2007-2009 coresystems GmbH
5  * Copyright (C) 2010 Joseph Smith <joe@settoplinux.org>
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License as
9  * published by the Free Software Foundation; version 2 of
10  * the License.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
20  * MA 02110-1301 USA
21  */
22
23 #include <console/console.h>
24 #include <device/device.h>
25 #include <device/pci.h>
26 #include <string.h>
27 #include <cpu/cpu.h>
28 #include <cpu/x86/mtrr.h>
29 #include <cpu/x86/msr.h>
30 #include <cpu/x86/lapic.h>
31 #include <cpu/intel/microcode.h>
32 #include <cpu/x86/cache.h>
33 #include <usbdebug.h>
34
35 static const uint32_t microcode_updates[] = {
36         #include "microcode-534-MU16810d.h"
37         #include "microcode-535-MU16810e.h"
38         #include "microcode-536-MU16810f.h"
39         #include "microcode-537-MU268110.h"
40         #include "microcode-538-MU168111.h"
41         #include "microcode-550-MU168307.h"
42         #include "microcode-551-MU168308.h"
43         #include "microcode-727-MU168313.h"
44         #include "microcode-728-MU168314.h"
45         #include "microcode-729-MU268310.h"
46         #include "microcode-611-MU168607.h"
47         #include "microcode-612-MU168608.h"
48         #include "microcode-615-MU16860a.h"
49         #include "microcode-617-MU16860c.h"
50         #include "microcode-618-MU268602.h"
51         #include "microcode-662-MU168a01.h"
52         #include "microcode-691-MU168a04.h"
53         #include "microcode-692-MU168a05.h"
54         /*  Dummy terminator  */
55         0x0, 0x0, 0x0, 0x0,
56         0x0, 0x0, 0x0, 0x0,
57         0x0, 0x0, 0x0, 0x0,
58         0x0, 0x0, 0x0, 0x0,
59 };
60
61 static inline void strcpy(char *dst, char *src)
62 {
63         while (*src) *dst++ = *src++;
64 }
65
66 static void fill_processor_name(char *processor_name)
67 {
68         struct cpuid_result regs;
69         char temp_processor_name[49];
70         char *processor_name_start;
71         unsigned int *name_as_ints = (unsigned int *)temp_processor_name;
72         int i;
73
74         for (i=0; i<3; i++) {
75                 regs = cpuid(0x80000002 + i);
76                 name_as_ints[i*4 + 0] = regs.eax;
77                 name_as_ints[i*4 + 1] = regs.ebx;
78                 name_as_ints[i*4 + 2] = regs.ecx;
79                 name_as_ints[i*4 + 3] = regs.edx;
80         }
81
82         temp_processor_name[48] = 0;
83
84         /* Skip leading spaces */
85         processor_name_start = temp_processor_name;
86         while (*processor_name_start == ' ')
87                 processor_name_start++;
88
89         memset(processor_name, 0, 49);
90         strcpy(processor_name, processor_name_start);
91 }
92
93 #if CONFIG_USBDEBUG
94 static unsigned ehci_debug_addr;
95 #endif
96
97 static void model_68x_init(device_t cpu)
98 {
99         char processor_name[49];
100
101         /* Turn on caching if we haven't already */
102         x86_enable_cache();
103
104         /* Update the microcode */
105         intel_update_microcode(microcode_updates);
106
107         /* Print processor name */
108         fill_processor_name(processor_name);
109         printk(BIOS_INFO, "CPU: %s.\n", processor_name);
110
111 #if CONFIG_USBDEBUG
112         // Is this caution really needed?
113         if(!ehci_debug_addr)
114                 ehci_debug_addr = get_ehci_debug();
115         set_ehci_debug(0);
116 #endif
117
118         /* Setup MTRRs */
119         x86_setup_mtrrs(36);
120         x86_mtrr_check();
121
122 #if CONFIG_USBDEBUG
123         set_ehci_debug(ehci_debug_addr);
124 #endif
125
126         /* Enable the local cpu apics */
127         setup_lapic();
128 }
129
130 static struct device_operations cpu_dev_ops = {
131         .init     = model_68x_init,
132 };
133
134 static struct cpu_device_id cpu_table[] = {
135         { X86_VENDOR_INTEL, 0x0680 },
136         { 0, 0 },
137 };
138
139 static const struct cpu_driver driver __cpu_driver = {
140         .ops      = &cpu_dev_ops,
141         .id_table = cpu_table,
142 };
143