blob: 75631c16a6a55e80abb92f69d8e6595506b49f8e [file] [log] [blame]
Stefan Reinauer5c554632012-04-04 00:09:50 +02001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2007-2009 coresystems GmbH
5 * Copyright (C) 2011 The ChromiumOS Authors. All rights reserved.
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.
Stefan Reinauer5c554632012-04-04 00:09:50 +020016 */
17
18#include <console/console.h>
19#include <device/device.h>
Stefan Reinauer5c554632012-04-04 00:09:50 +020020#include <string.h>
21#include <arch/acpi.h>
22#include <cpu/cpu.h>
23#include <cpu/x86/mtrr.h>
24#include <cpu/x86/msr.h>
25#include <cpu/x86/lapic.h>
26#include <cpu/intel/microcode.h>
27#include <cpu/intel/speedstep.h>
28#include <cpu/intel/turbo.h>
29#include <cpu/x86/cache.h>
30#include <cpu/x86/name.h>
31#include <pc80/mc146818rtc.h>
Stefan Reinauer5c554632012-04-04 00:09:50 +020032#include "model_206ax.h"
Duncan Laurie55632112012-07-16 12:19:00 -070033#include "chip.h"
Vladimir Serbinenkoc16e9dfa2015-05-29 16:18:01 +020034#include <cpu/intel/smm/gen1/smi.h>
Matt DeVilliered6fe2f2016-12-14 16:12:43 -060035#include <cpu/intel/common/common.h>
Vladimir Serbinenkoc16e9dfa2015-05-29 16:18:01 +020036
Stefan Reinauer5c554632012-04-04 00:09:50 +020037/*
Martin Roth4c3ab732013-07-08 16:23:54 -060038 * List of supported C-states in this processor
Stefan Reinauer5c554632012-04-04 00:09:50 +020039 *
40 * Latencies are typical worst-case package exit time in uS
41 * taken from the SandyBridge BIOS specification.
42 */
43static acpi_cstate_t cstate_map[] = {
44 { /* 0: C0 */
Lee Leahy9d62e7e2017-03-15 17:40:50 -070045 }, { /* 1: C1 */
Stefan Reinauer5c554632012-04-04 00:09:50 +020046 .latency = 1,
47 .power = 1000,
48 .resource = {
49 .addrl = 0x00, /* MWAIT State 0 */
50 .space_id = ACPI_ADDRESS_SPACE_FIXED,
51 .bit_width = ACPI_FFIXEDHW_VENDOR_INTEL,
52 .bit_offset = ACPI_FFIXEDHW_CLASS_MWAIT,
53 .resv = ACPI_FFIXEDHW_FLAG_HW_COORD,
54 }
55 },
56 { /* 2: C1E */
57 .latency = 1,
58 .power = 1000,
59 .resource = {
60 .addrl = 0x01, /* MWAIT State 0 Sub-state 1 */
61 .space_id = ACPI_ADDRESS_SPACE_FIXED,
62 .bit_width = ACPI_FFIXEDHW_VENDOR_INTEL,
63 .bit_offset = ACPI_FFIXEDHW_CLASS_MWAIT,
64 .resv = ACPI_FFIXEDHW_FLAG_HW_COORD,
65 }
66 },
67 { /* 3: C3 */
68 .latency = 63,
69 .power = 500,
70 .resource = {
71 .addrl = 0x10, /* MWAIT State 1 */
72 .space_id = ACPI_ADDRESS_SPACE_FIXED,
73 .bit_width = ACPI_FFIXEDHW_VENDOR_INTEL,
74 .bit_offset = ACPI_FFIXEDHW_CLASS_MWAIT,
75 .resv = ACPI_FFIXEDHW_FLAG_HW_COORD,
76 }
77 },
78 { /* 4: C6 */
79 .latency = 87,
80 .power = 350,
81 .resource = {
82 .addrl = 0x20, /* MWAIT State 2 */
83 .space_id = ACPI_ADDRESS_SPACE_FIXED,
84 .bit_width = ACPI_FFIXEDHW_VENDOR_INTEL,
85 .bit_offset = ACPI_FFIXEDHW_CLASS_MWAIT,
86 .resv = ACPI_FFIXEDHW_FLAG_HW_COORD,
87 }
88 },
89 { /* 5: C7 */
90 .latency = 90,
91 .power = 200,
92 .resource = {
93 .addrl = 0x30, /* MWAIT State 3 */
94 .space_id = ACPI_ADDRESS_SPACE_FIXED,
95 .bit_width = ACPI_FFIXEDHW_VENDOR_INTEL,
96 .bit_offset = ACPI_FFIXEDHW_CLASS_MWAIT,
97 .resv = ACPI_FFIXEDHW_FLAG_HW_COORD,
98 }
99 },
100 { /* 6: C7S */
101 .latency = 90,
102 .power = 200,
103 .resource = {
104 .addrl = 0x31, /* MWAIT State 3 Sub-state 1 */
105 .space_id = ACPI_ADDRESS_SPACE_FIXED,
106 .bit_width = ACPI_FFIXEDHW_VENDOR_INTEL,
107 .bit_offset = ACPI_FFIXEDHW_CLASS_MWAIT,
108 .resv = ACPI_FFIXEDHW_FLAG_HW_COORD,
109 }
110 },
111 { 0 }
112};
113
Stefan Reinauer5c554632012-04-04 00:09:50 +0200114/* Convert time in seconds to POWER_LIMIT_1_TIME MSR value */
115static const u8 power_limit_time_sec_to_msr[] = {
116 [0] = 0x00,
117 [1] = 0x0a,
118 [2] = 0x0b,
119 [3] = 0x4b,
120 [4] = 0x0c,
121 [5] = 0x2c,
122 [6] = 0x4c,
123 [7] = 0x6c,
124 [8] = 0x0d,
125 [10] = 0x2d,
126 [12] = 0x4d,
127 [14] = 0x6d,
128 [16] = 0x0e,
129 [20] = 0x2e,
130 [24] = 0x4e,
131 [28] = 0x6e,
132 [32] = 0x0f,
133 [40] = 0x2f,
134 [48] = 0x4f,
135 [56] = 0x6f,
136 [64] = 0x10,
137 [80] = 0x30,
138 [96] = 0x50,
139 [112] = 0x70,
140 [128] = 0x11,
141};
142
143/* Convert POWER_LIMIT_1_TIME MSR value to seconds */
144static const u8 power_limit_time_msr_to_sec[] = {
145 [0x00] = 0,
146 [0x0a] = 1,
147 [0x0b] = 2,
148 [0x4b] = 3,
149 [0x0c] = 4,
150 [0x2c] = 5,
151 [0x4c] = 6,
152 [0x6c] = 7,
153 [0x0d] = 8,
154 [0x2d] = 10,
155 [0x4d] = 12,
156 [0x6d] = 14,
157 [0x0e] = 16,
158 [0x2e] = 20,
159 [0x4e] = 24,
160 [0x6e] = 28,
161 [0x0f] = 32,
162 [0x2f] = 40,
163 [0x4f] = 48,
164 [0x6f] = 56,
165 [0x10] = 64,
166 [0x30] = 80,
167 [0x50] = 96,
168 [0x70] = 112,
169 [0x11] = 128,
170};
171
Duncan Laurie77dbbac2012-06-25 09:51:59 -0700172int cpu_config_tdp_levels(void)
173{
174 msr_t platform_info;
175
176 /* Minimum CPU revision */
177 if (cpuid_eax(1) < IVB_CONFIG_TDP_MIN_CPUID)
178 return 0;
179
180 /* Bits 34:33 indicate how many levels supported */
181 platform_info = rdmsr(MSR_PLATFORM_INFO);
182 return (platform_info.hi >> 1) & 3;
183}
184
Stefan Reinauer5c554632012-04-04 00:09:50 +0200185/*
186 * Configure processor power limits if possible
187 * This must be done AFTER set of BIOS_RESET_CPL
188 */
189void set_power_limits(u8 power_limit_1_time)
190{
191 msr_t msr = rdmsr(MSR_PLATFORM_INFO);
192 msr_t limit;
Lee Leahy73a28942017-03-15 17:52:06 -0700193 unsigned int power_unit;
194 unsigned int tdp, min_power, max_power, max_time;
Stefan Reinauer5c554632012-04-04 00:09:50 +0200195 u8 power_limit_1_val;
196
Edward O'Callaghan5cfef132014-08-03 20:00:47 +1000197 if (power_limit_1_time >= ARRAY_SIZE(power_limit_time_sec_to_msr))
Stefan Reinauer5c554632012-04-04 00:09:50 +0200198 return;
199
200 if (!(msr.lo & PLATFORM_INFO_SET_TDP))
201 return;
202
203 /* Get units */
204 msr = rdmsr(MSR_PKG_POWER_SKU_UNIT);
205 power_unit = 2 << ((msr.lo & 0xf) - 1);
206
207 /* Get power defaults for this SKU */
208 msr = rdmsr(MSR_PKG_POWER_SKU);
209 tdp = msr.lo & 0x7fff;
210 min_power = (msr.lo >> 16) & 0x7fff;
211 max_power = msr.hi & 0x7fff;
212 max_time = (msr.hi >> 16) & 0x7f;
213
214 printk(BIOS_DEBUG, "CPU TDP: %u Watts\n", tdp / power_unit);
215
216 if (power_limit_time_msr_to_sec[max_time] > power_limit_1_time)
217 power_limit_1_time = power_limit_time_msr_to_sec[max_time];
218
219 if (min_power > 0 && tdp < min_power)
220 tdp = min_power;
221
222 if (max_power > 0 && tdp > max_power)
223 tdp = max_power;
224
225 power_limit_1_val = power_limit_time_sec_to_msr[power_limit_1_time];
226
227 /* Set long term power limit to TDP */
228 limit.lo = 0;
229 limit.lo |= tdp & PKG_POWER_LIMIT_MASK;
230 limit.lo |= PKG_POWER_LIMIT_EN;
231 limit.lo |= (power_limit_1_val & PKG_POWER_LIMIT_TIME_MASK) <<
232 PKG_POWER_LIMIT_TIME_SHIFT;
233
234 /* Set short term power limit to 1.25 * TDP */
235 limit.hi = 0;
236 limit.hi |= ((tdp * 125) / 100) & PKG_POWER_LIMIT_MASK;
237 limit.hi |= PKG_POWER_LIMIT_EN;
238 /* Power limit 2 time is only programmable on SNB EP/EX */
239
240 wrmsr(MSR_PKG_POWER_LIMIT, limit);
Duncan Laurie77dbbac2012-06-25 09:51:59 -0700241
242 /* Use nominal TDP values for CPUs with configurable TDP */
243 if (cpu_config_tdp_levels()) {
244 msr = rdmsr(MSR_CONFIG_TDP_NOMINAL);
245 limit.hi = 0;
246 limit.lo = msr.lo & 0xff;
247 wrmsr(MSR_TURBO_ACTIVATION_RATIO, limit);
248 }
Stefan Reinauer5c554632012-04-04 00:09:50 +0200249}
250
251static void configure_c_states(void)
252{
253 msr_t msr;
254
255 msr = rdmsr(MSR_PMG_CST_CONFIG_CONTROL);
256 msr.lo |= (1 << 28); // C1 Auto Undemotion Enable
257 msr.lo |= (1 << 27); // C3 Auto Undemotion Enable
258 msr.lo |= (1 << 26); // C1 Auto Demotion Enable
259 msr.lo |= (1 << 25); // C3 Auto Demotion Enable
260 msr.lo &= ~(1 << 10); // Disable IO MWAIT redirection
261 msr.lo |= 7; // No package C-state limit
262 wrmsr(MSR_PMG_CST_CONFIG_CONTROL, msr);
263
Patrick Georgi644e83b2013-02-09 15:35:30 +0100264 msr = rdmsr(MSR_PMG_IO_CAPTURE_ADDR);
Stefan Reinauer5c554632012-04-04 00:09:50 +0200265 msr.lo &= ~0x7ffff;
266 msr.lo |= (PMB0_BASE + 4); // LVL_2 base address
267 msr.lo |= (2 << 16); // CST Range: C7 is max C-state
Patrick Georgi644e83b2013-02-09 15:35:30 +0100268 wrmsr(MSR_PMG_IO_CAPTURE_ADDR, msr);
Stefan Reinauer5c554632012-04-04 00:09:50 +0200269
270 msr = rdmsr(MSR_MISC_PWR_MGMT);
271 msr.lo &= ~(1 << 0); // Enable P-state HW_ALL coordination
272 wrmsr(MSR_MISC_PWR_MGMT, msr);
273
274 msr = rdmsr(MSR_POWER_CTL);
275 msr.lo |= (1 << 18); // Enable Energy Perf Bias MSR 0x1b0
276 msr.lo |= (1 << 1); // C1E Enable
277 msr.lo |= (1 << 0); // Bi-directional PROCHOT#
278 wrmsr(MSR_POWER_CTL, msr);
279
280 /* C3 Interrupt Response Time Limit */
281 msr.hi = 0;
282 msr.lo = IRTL_VALID | IRTL_1024_NS | 0x50;
283 wrmsr(MSR_PKGC3_IRTL, msr);
284
285 /* C6 Interrupt Response Time Limit */
286 msr.hi = 0;
287 msr.lo = IRTL_VALID | IRTL_1024_NS | 0x68;
288 wrmsr(MSR_PKGC6_IRTL, msr);
289
290 /* C7 Interrupt Response Time Limit */
291 msr.hi = 0;
292 msr.lo = IRTL_VALID | IRTL_1024_NS | 0x6D;
293 wrmsr(MSR_PKGC7_IRTL, msr);
294
295 /* Primary Plane Current Limit */
296 msr = rdmsr(MSR_PP0_CURRENT_CONFIG);
297 msr.lo &= ~0x1fff;
298 msr.lo |= PP0_CURRENT_LIMIT;
299 wrmsr(MSR_PP0_CURRENT_CONFIG, msr);
300
301 /* Secondary Plane Current Limit */
302 msr = rdmsr(MSR_PP1_CURRENT_CONFIG);
303 msr.lo &= ~0x1fff;
Duncan Laurie4e4320f2012-06-25 09:53:58 -0700304 if (cpuid_eax(1) >= 0x30600)
305 msr.lo |= PP1_CURRENT_LIMIT_IVB;
306 else
307 msr.lo |= PP1_CURRENT_LIMIT_SNB;
Stefan Reinauer5c554632012-04-04 00:09:50 +0200308 wrmsr(MSR_PP1_CURRENT_CONFIG, msr);
309}
310
Duncan Laurie55632112012-07-16 12:19:00 -0700311static void configure_thermal_target(void)
312{
313 struct cpu_intel_model_206ax_config *conf;
Edward O'Callaghan2c9d2cf2014-10-27 23:29:29 +1100314 struct device *lapic;
Duncan Laurie55632112012-07-16 12:19:00 -0700315 msr_t msr;
316
317 /* Find pointer to CPU configuration */
318 lapic = dev_find_lapic(SPEEDSTEP_APIC_MAGIC);
319 if (!lapic || !lapic->chip_info)
320 return;
321 conf = lapic->chip_info;
322
Martin Roth4c3ab732013-07-08 16:23:54 -0600323 /* Set TCC activation offset if supported */
Duncan Laurie55632112012-07-16 12:19:00 -0700324 msr = rdmsr(MSR_PLATFORM_INFO);
325 if ((msr.lo & (1 << 30)) && conf->tcc_offset) {
326 msr = rdmsr(MSR_TEMPERATURE_TARGET);
327 msr.lo &= ~(0xf << 24); /* Bits 27:24 */
328 msr.lo |= (conf->tcc_offset & 0xf) << 24;
329 wrmsr(MSR_TEMPERATURE_TARGET, msr);
330 }
331}
332
Stefan Reinauer5c554632012-04-04 00:09:50 +0200333static void configure_misc(void)
334{
335 msr_t msr;
336
337 msr = rdmsr(IA32_MISC_ENABLE);
338 msr.lo |= (1 << 0); /* Fast String enable */
Lee Leahy7b5f12b92017-03-15 17:16:59 -0700339 msr.lo |= (1 << 3); /* TM1/TM2/EMTTM enable */
Stefan Reinauer5c554632012-04-04 00:09:50 +0200340 msr.lo |= (1 << 16); /* Enhanced SpeedStep Enable */
341 wrmsr(IA32_MISC_ENABLE, msr);
342
343 /* Disable Thermal interrupts */
344 msr.lo = 0;
345 msr.hi = 0;
346 wrmsr(IA32_THERM_INTERRUPT, msr);
347
348 /* Enable package critical interrupt only */
349 msr.lo = 1 << 4;
350 msr.hi = 0;
351 wrmsr(IA32_PACKAGE_THERM_INTERRUPT, msr);
352}
353
354static void enable_lapic_tpr(void)
355{
356 msr_t msr;
357
358 msr = rdmsr(MSR_PIC_MSG_CONTROL);
359 msr.lo &= ~(1 << 10); /* Enable APIC TPR updates */
360 wrmsr(MSR_PIC_MSG_CONTROL, msr);
361}
362
363static void configure_dca_cap(void)
364{
365 struct cpuid_result cpuid_regs;
366 msr_t msr;
367
368 /* Check feature flag in CPUID.(EAX=1):ECX[18]==1 */
369 cpuid_regs = cpuid(1);
370 if (cpuid_regs.ecx & (1 << 18)) {
371 msr = rdmsr(IA32_PLATFORM_DCA_CAP);
372 msr.lo |= 1;
373 wrmsr(IA32_PLATFORM_DCA_CAP, msr);
374 }
375}
376
377static void set_max_ratio(void)
378{
Duncan Laurie77dbbac2012-06-25 09:51:59 -0700379 msr_t msr, perf_ctl;
Stefan Reinauer5c554632012-04-04 00:09:50 +0200380
Duncan Laurie77dbbac2012-06-25 09:51:59 -0700381 perf_ctl.hi = 0;
382
383 /* Check for configurable TDP option */
384 if (cpu_config_tdp_levels()) {
385 /* Set to nominal TDP ratio */
386 msr = rdmsr(MSR_CONFIG_TDP_NOMINAL);
387 perf_ctl.lo = (msr.lo & 0xff) << 8;
388 } else {
389 /* Platform Info bits 15:8 give max ratio */
390 msr = rdmsr(MSR_PLATFORM_INFO);
391 perf_ctl.lo = msr.lo & 0xff00;
392 }
393 wrmsr(IA32_PERF_CTL, perf_ctl);
Stefan Reinauer5c554632012-04-04 00:09:50 +0200394
395 printk(BIOS_DEBUG, "model_x06ax: frequency set to %d\n",
Duncan Laurie77dbbac2012-06-25 09:51:59 -0700396 ((perf_ctl.lo >> 8) & 0xff) * SANDYBRIDGE_BCLK);
Stefan Reinauer5c554632012-04-04 00:09:50 +0200397}
398
399static void set_energy_perf_bias(u8 policy)
400{
401 msr_t msr;
402
403 /* Energy Policy is bits 3:0 */
404 msr = rdmsr(IA32_ENERGY_PERFORMANCE_BIAS);
405 msr.lo &= ~0xf;
406 msr.lo |= policy & 0xf;
407 wrmsr(IA32_ENERGY_PERFORMANCE_BIAS, msr);
408
409 printk(BIOS_DEBUG, "model_x06ax: energy policy set to %u\n",
410 policy);
411}
412
413static void configure_mca(void)
414{
415 msr_t msr;
416 int i;
417
418 msr.lo = msr.hi = 0;
419 /* This should only be done on a cold boot */
420 for (i = 0; i < 7; i++)
421 wrmsr(IA32_MC0_STATUS + (i * 4), msr);
422}
423
Arthur Heymans68f68882018-04-11 13:03:34 +0200424int cpu_get_apic_id_map(int *apic_id_map)
425{
426 struct cpuid_result result;
427 unsigned int threads_per_package, threads_per_core, i, shift = 0;
428
429 /* Logical processors (threads) per core */
430 result = cpuid_ext(0xb, 0);
431 threads_per_core = result.ebx & 0xffff;
432
433 /* Logical processors (threads) per package */
434 result = cpuid_ext(0xb, 1);
435 threads_per_package = result.ebx & 0xffff;
436
437 if (threads_per_core == 1)
438 shift++;
439
440 for (i = 0; i < threads_per_package && i < CONFIG_MAX_CPUS; i++)
441 apic_id_map[i] = i << shift;
442
443 return threads_per_package;
444}
445
446/*
447 * Initialize any extra cores/threads in this package.
448 */
449static void intel_cores_init(struct device *cpu)
450{
451 struct cpuid_result result;
452 unsigned int threads_per_package, threads_per_core, i;
453
454 /* Logical processors (threads) per core */
455 result = cpuid_ext(0xb, 0);
456 threads_per_core = result.ebx & 0xffff;
457
458 /* Logical processors (threads) per package */
459 result = cpuid_ext(0xb, 1);
460 threads_per_package = result.ebx & 0xffff;
461
462 /* Only initialize extra cores from BSP */
463 if (cpu->path.apic.apic_id)
464 return;
465
466 printk(BIOS_DEBUG, "CPU: %u has %u cores, %u threads per core\n",
467 cpu->path.apic.apic_id, threads_per_package/threads_per_core,
468 threads_per_core);
469
470 for (i = 1; i < threads_per_package; ++i) {
471 struct device_path cpu_path;
472 struct device *new;
473
474 /* Build the CPU device path */
475 cpu_path.type = DEVICE_PATH_APIC;
476 cpu_path.apic.apic_id =
477 cpu->path.apic.apic_id + i;
478
479 /* Update APIC ID if no hyperthreading */
480 if (threads_per_core == 1)
481 cpu_path.apic.apic_id <<= 1;
482
483 /* Allocate the new CPU device structure */
484 new = alloc_dev(cpu->bus, &cpu_path);
485 if (!new)
486 continue;
487
488 printk(BIOS_DEBUG, "CPU: %u has core %u\n",
489 cpu->path.apic.apic_id,
490 new->path.apic.apic_id);
491
492 /* Start the new CPU */
493 if (is_smp_boot() && !start_cpu(new)) {
494 /* Record the error in cpu? */
495 printk(BIOS_ERR, "CPU %u would not start!\n",
496 new->path.apic.apic_id);
497 }
498 }
499}
500
Patrick Rudolph9e1b9b52018-07-27 17:25:05 +0200501static void model_206ax_report(void)
502{
503 static const char *const mode[] = {"NOT ", ""};
504 struct cpuid_result cpuidr;
505 char processor_name[49];
506 int vt, txt, aes;
507
508 /* Print processor name */
509 fill_processor_name(processor_name);
510 printk(BIOS_INFO, "CPU: %s.\n", processor_name);
511
512 /* Print platform ID */
513 printk(BIOS_INFO, "CPU: platform id %x\n", get_platform_id());
514
515 /* CPUID and features */
516 cpuidr = cpuid(1);
517 printk(BIOS_INFO, "CPU: cpuid(1) 0x%x\n", cpuidr.eax);
518 aes = (cpuidr.ecx & (1 << 25)) ? 1 : 0;
519 txt = (cpuidr.ecx & (1 << 6)) ? 1 : 0;
520 vt = (cpuidr.ecx & (1 << 5)) ? 1 : 0;
521 printk(BIOS_INFO, "CPU: AES %ssupported\n", mode[aes]);
522 printk(BIOS_INFO, "CPU: TXT %ssupported\n", mode[txt]);
523 printk(BIOS_INFO, "CPU: VT %ssupported\n", mode[vt]);
524}
525
Edward O'Callaghan2c9d2cf2014-10-27 23:29:29 +1100526static void model_206ax_init(struct device *cpu)
Stefan Reinauer5c554632012-04-04 00:09:50 +0200527{
Stefan Reinauer5c554632012-04-04 00:09:50 +0200528
529 /* Turn on caching if we haven't already */
530 x86_enable_cache();
531
Arthur Heymans68f68882018-04-11 13:03:34 +0200532 intel_update_microcode_from_cbfs();
533
Stefan Reinauer5c554632012-04-04 00:09:50 +0200534 /* Clear out pending MCEs */
535 configure_mca();
536
Patrick Rudolph9e1b9b52018-07-27 17:25:05 +0200537 /* Print infos */
538 model_206ax_report();
Patrick Rudolph74203de2017-11-20 11:57:01 +0100539
Arthur Heymans68f68882018-04-11 13:03:34 +0200540 /* Setup MTRRs based on physical address size */
541 x86_setup_mtrrs_with_detect();
542 x86_mtrr_check();
543
Stefan Reinauer5c554632012-04-04 00:09:50 +0200544 /* Setup Page Attribute Tables (PAT) */
545 // TODO set up PAT
546
Elyes HAOUASd6e96862016-08-21 10:12:15 +0200547 /* Enable the local CPU APICs */
Stefan Reinauer5c554632012-04-04 00:09:50 +0200548 enable_lapic_tpr();
549 setup_lapic();
550
Matt DeVilliered6fe2f2016-12-14 16:12:43 -0600551 /* Set virtualization based on Kconfig option */
552 set_vmx();
Marc Jones5986eda2012-10-25 09:37:19 -0600553
Stefan Reinauer5c554632012-04-04 00:09:50 +0200554 /* Configure C States */
555 configure_c_states();
556
557 /* Configure Enhanced SpeedStep and Thermal Sensors */
558 configure_misc();
559
Duncan Laurie55632112012-07-16 12:19:00 -0700560 /* Thermal throttle activation offset */
561 configure_thermal_target();
562
Stefan Reinauer5c554632012-04-04 00:09:50 +0200563 /* Enable Direct Cache Access */
564 configure_dca_cap();
565
566 /* Set energy policy */
567 set_energy_perf_bias(ENERGY_POLICY_NORMAL);
568
569 /* Set Max Ratio */
570 set_max_ratio();
571
572 /* Enable Turbo */
573 enable_turbo();
Sven Schnelle51676b12012-07-29 19:18:03 +0200574
Arthur Heymans68f68882018-04-11 13:03:34 +0200575 /* Start up extra cores */
576 intel_cores_init(cpu);
Stefan Reinauer5c554632012-04-04 00:09:50 +0200577}
578
579static struct device_operations cpu_dev_ops = {
580 .init = model_206ax_init,
581};
582
Jonathan Neuschäfer8f06ce32017-11-20 01:56:44 +0100583static const struct cpu_device_id cpu_table[] = {
Stefan Reinauer5c554632012-04-04 00:09:50 +0200584 { X86_VENDOR_INTEL, 0x206a0 }, /* Intel Sandybridge */
585 { X86_VENDOR_INTEL, 0x206a6 }, /* Intel Sandybridge D1 */
586 { X86_VENDOR_INTEL, 0x206a7 }, /* Intel Sandybridge D2/J1 */
Stefan Reinauer08067ba2012-10-15 13:47:04 -0700587 { X86_VENDOR_INTEL, 0x306a0 }, /* Intel IvyBridge */
Stefan Reinauer5c554632012-04-04 00:09:50 +0200588 { X86_VENDOR_INTEL, 0x306a2 }, /* Intel IvyBridge */
589 { X86_VENDOR_INTEL, 0x306a4 }, /* Intel IvyBridge */
590 { X86_VENDOR_INTEL, 0x306a5 }, /* Intel IvyBridge */
591 { X86_VENDOR_INTEL, 0x306a6 }, /* Intel IvyBridge */
592 { X86_VENDOR_INTEL, 0x306a8 }, /* Intel IvyBridge */
593 { X86_VENDOR_INTEL, 0x306a9 }, /* Intel IvyBridge */
594 { 0, 0 },
595};
596
597static const struct cpu_driver driver __cpu_driver = {
598 .ops = &cpu_dev_ops,
599 .id_table = cpu_table,
600 .cstates = cstate_map,
601};