2 * This file is part of the coreboot project.
4 * Copyright (C) 2007-2009 coresystems GmbH
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; version 2 of
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
22 #include <console/console.h>
23 #include <device/device.h>
24 #include <device/pci.h>
27 #include <cpu/x86/mtrr.h>
28 #include <cpu/x86/msr.h>
29 #include <cpu/x86/lapic.h>
30 #include <cpu/intel/microcode.h>
31 #include <cpu/intel/hyperthreading.h>
32 #include <cpu/x86/cache.h>
33 #include <cpu/x86/mtrr.h>
34 #include <cpu/x86/name.h>
37 static const uint32_t microcode_updates[] = {
38 #include "microcode-1624-m206e839.h"
39 #include "microcode-1729-m206ec54.h"
40 #include "microcode-1869-m806ec59.h"
41 /* Dummy terminator */
48 #define IA32_FEATURE_CONTROL 0x003a
50 #define CPUID_VMX (1 << 5)
51 #define CPUID_SMX (1 << 6)
52 static void enable_vmx(void)
54 struct cpuid_result regs;
57 msr = rdmsr(IA32_FEATURE_CONTROL);
59 if (msr.lo & (1 << 0)) {
60 /* VMX locked. If we set it again we get an illegal
67 if (regs.ecx & CPUID_VMX) {
69 if (regs.ecx & CPUID_SMX)
73 wrmsr(IA32_FEATURE_CONTROL, msr);
75 msr.lo |= (1 << 0); /* Set lock bit */
77 wrmsr(IA32_FEATURE_CONTROL, msr);
80 #define PMG_CST_CONFIG_CONTROL 0xe2
81 #define PMG_IO_BASE_ADDR 0xe3
82 #define PMG_IO_CAPTURE_ADDR 0xe4
84 /* MWAIT coordination I/O base address. This must match
85 * the \_PR_.CPU0 PM base address.
87 #define PMB0_BASE 0x510
89 /* PMB1: I/O port that triggers SMI once cores are in the same state.
90 * See CSM Trigger, at PMG_CST_CONFIG_CONTROL[6:4]
92 #define PMB1_BASE 0x800
93 #define HIGHEST_CLEVEL 3
94 static void configure_c_states(void)
98 msr = rdmsr(PMG_CST_CONFIG_CONTROL);
99 msr.lo |= (1 << 15); // config lock until next reset.
100 msr.lo |= (1 << 10); // Enable I/O MWAIT redirection for C-States
101 msr.lo &= ~(1 << 9); // Issue a single stop grant cycle upon stpclk
102 // TODO Do we want Deep C4 and Dynamic L2 shrinking?
104 /* Number of supported C-States */
106 msr.lo |= HIGHEST_CLEVEL; // support at most C3
108 wrmsr(PMG_CST_CONFIG_CONTROL, msr);
110 /* Set Processor MWAIT IO BASE (P_BLK) */
112 msr.lo = ((PMB0_BASE + 4) & 0xffff) | (((PMB1_BASE + 9) & 0xffff) << 16);
113 wrmsr(PMG_IO_BASE_ADDR, msr);
115 /* set C_LVL controls */
117 msr.lo = (PMB0_BASE + 4) | ((HIGHEST_CLEVEL - 2) << 16); // -2 because LVL0+1 aren't counted
118 wrmsr(PMG_IO_CAPTURE_ADDR, msr);
121 #define IA32_MISC_ENABLE 0x1a0
122 static void configure_misc(void)
126 msr = rdmsr(IA32_MISC_ENABLE);
127 msr.lo |= (1 << 3); /* TM1 enable */
128 msr.lo |= (1 << 13); /* TM2 enable */
129 msr.lo |= (1 << 17); /* Bidirectional PROCHOT# */
131 msr.lo |= (1 << 10); /* FERR# multiplexing */
133 // TODO: Only if IA32_PLATFORM_ID[17] = 0 and IA32_PLATFORM_ID[50] = 1
134 msr.lo |= (1 << 16); /* Enhanced SpeedStep Enable */
136 // TODO Do we want Deep C4 and Dynamic L2 shrinking?
137 wrmsr(IA32_MISC_ENABLE, msr);
139 msr.lo |= (1 << 20); /* Lock Enhanced SpeedStep Enable */
140 wrmsr(IA32_MISC_ENABLE, msr);
143 #define PIC_SENS_CFG 0x1aa
144 static void configure_pic_thermal_sensors(void)
148 msr = rdmsr(PIC_SENS_CFG);
150 msr.lo |= (1 << 21); // inter-core lock TM1
151 msr.lo |= (1 << 4); // Enable bypass filter
153 wrmsr(PIC_SENS_CFG, msr);
157 static unsigned ehci_debug_addr;
160 static void model_6ex_init(device_t cpu)
162 char processor_name[49];
164 /* Turn on caching if we haven't already */
167 /* Update the microcode */
168 intel_update_microcode(microcode_updates);
170 /* Print processor name */
171 fill_processor_name(processor_name);
172 printk(BIOS_INFO, "CPU: %s.\n", processor_name);
175 // Is this caution really needed?
177 ehci_debug_addr = get_ehci_debug();
186 set_ehci_debug(ehci_debug_addr);
189 /* Enable the local cpu apics */
192 /* Enable virtualization */
195 /* Configure C States */
196 configure_c_states();
198 /* Configure Enhanced SpeedStep and Thermal Sensors */
201 /* PIC thermal sensor control */
202 configure_pic_thermal_sensors();
204 /* Start up my cpu siblings */
205 intel_sibling_init(cpu);
208 static struct device_operations cpu_dev_ops = {
209 .init = model_6ex_init,
212 static struct cpu_device_id cpu_table[] = {
213 { X86_VENDOR_INTEL, 0x06e0 }, /* Intel Core Solo/Core Duo */
214 { X86_VENDOR_INTEL, 0x06e8 }, /* Intel Core Solo/Core Duo */
215 { X86_VENDOR_INTEL, 0x06ec }, /* Intel Core Solo/Core Duo */
219 static const struct cpu_driver driver __cpu_driver = {
221 .id_table = cpu_table,