blob: f038e87e5a36f76b204cc037c01cc039e15629bf [file] [log] [blame]
Duncan Lauriec88c54c2014-04-30 16:36:13 -07001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2009 coresystems GmbH
5 * Copyright (C) 2014 Google Inc.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of the License.
10 *
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.
15 *
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, MA 02110-1301 USA
19 */
20
21#include <arch/acpi.h>
22#include <arch/acpigen.h>
23#include <arch/io.h>
24#include <arch/smp/mpspec.h>
25#include <cbmem.h>
26#include <console/console.h>
27#include <cpu/x86/smm.h>
28#include <console/console.h>
29#include <types.h>
30#include <string.h>
31#include <arch/cpu.h>
32#include <cpu/x86/msr.h>
33#include <cpu/x86/tsc.h>
34#include <cpu/intel/turbo.h>
35#include <ec/google/chromeec/ec.h>
36#include <vendorcode/google/chromeos/gnvs.h>
Julius Werner4ee4bd52014-10-20 13:46:39 -070037#include <soc/acpi.h>
38#include <soc/cpu.h>
39#include <soc/iomap.h>
40#include <soc/lpc.h>
41#include <soc/msr.h>
42#include <soc/pci_devs.h>
43#include <soc/pm.h>
44#include <soc/intel/broadwell/chip.h>
Duncan Lauriec88c54c2014-04-30 16:36:13 -070045
46/*
Martin Rothde7ed6f2014-12-07 14:58:18 -070047 * List of supported C-states in this processor. Only the ULT parts support C8,
Duncan Lauriec88c54c2014-04-30 16:36:13 -070048 * C9, and C10.
49 */
50enum {
51 C_STATE_C0, /* 0 */
52 C_STATE_C1, /* 1 */
53 C_STATE_C1E, /* 2 */
54 C_STATE_C3, /* 3 */
55 C_STATE_C6_SHORT_LAT, /* 4 */
56 C_STATE_C6_LONG_LAT, /* 5 */
57 C_STATE_C7_SHORT_LAT, /* 6 */
58 C_STATE_C7_LONG_LAT, /* 7 */
59 C_STATE_C7S_SHORT_LAT, /* 8 */
60 C_STATE_C7S_LONG_LAT, /* 9 */
61 C_STATE_C8, /* 10 */
62 C_STATE_C9, /* 11 */
63 C_STATE_C10, /* 12 */
64 NUM_C_STATES
65};
66
67#define MWAIT_RES(state, sub_state) \
68 { \
69 .addrl = (((state) << 4) | (sub_state)), \
70 .space_id = ACPI_ADDRESS_SPACE_FIXED, \
71 .bit_width = ACPI_FFIXEDHW_VENDOR_INTEL, \
72 .bit_offset = ACPI_FFIXEDHW_CLASS_MWAIT, \
73 .access_size = ACPI_FFIXEDHW_FLAG_HW_COORD, \
74 }
75
76static acpi_cstate_t cstate_map[NUM_C_STATES] = {
77 [C_STATE_C0] = { },
78 [C_STATE_C1] = {
79 .latency = 0,
80 .power = 1000,
81 .resource = MWAIT_RES(0,0),
82 },
83 [C_STATE_C1E] = {
84 .latency = 0,
85 .power = 1000,
86 .resource = MWAIT_RES(0,1),
87 },
88 [C_STATE_C3] = {
89 .latency = C_STATE_LATENCY_FROM_LAT_REG(0),
90 .power = 900,
91 .resource = MWAIT_RES(1, 0),
92 },
93 [C_STATE_C6_SHORT_LAT] = {
94 .latency = C_STATE_LATENCY_FROM_LAT_REG(1),
95 .power = 800,
96 .resource = MWAIT_RES(2, 0),
97 },
98 [C_STATE_C6_LONG_LAT] = {
99 .latency = C_STATE_LATENCY_FROM_LAT_REG(2),
100 .power = 800,
101 .resource = MWAIT_RES(2, 1),
102 },
103 [C_STATE_C7_SHORT_LAT] = {
104 .latency = C_STATE_LATENCY_FROM_LAT_REG(1),
105 .power = 700,
106 .resource = MWAIT_RES(3, 0),
107 },
108 [C_STATE_C7_LONG_LAT] = {
109 .latency = C_STATE_LATENCY_FROM_LAT_REG(2),
110 .power = 700,
111 .resource = MWAIT_RES(3, 1),
112 },
113 [C_STATE_C7S_SHORT_LAT] = {
114 .latency = C_STATE_LATENCY_FROM_LAT_REG(1),
115 .power = 700,
116 .resource = MWAIT_RES(3, 2),
117 },
118 [C_STATE_C7S_LONG_LAT] = {
119 .latency = C_STATE_LATENCY_FROM_LAT_REG(2),
120 .power = 700,
121 .resource = MWAIT_RES(3, 3),
122 },
123 [C_STATE_C8] = {
124 .latency = C_STATE_LATENCY_FROM_LAT_REG(3),
125 .power = 600,
126 .resource = MWAIT_RES(4, 0),
127 },
128 [C_STATE_C9] = {
129 .latency = C_STATE_LATENCY_FROM_LAT_REG(4),
130 .power = 500,
131 .resource = MWAIT_RES(5, 0),
132 },
133 [C_STATE_C10] = {
134 .latency = C_STATE_LATENCY_FROM_LAT_REG(5),
135 .power = 400,
136 .resource = MWAIT_RES(6, 0),
137 },
138};
139
140static int cstate_set_s0ix[3] = {
141 C_STATE_C1E,
142 C_STATE_C7S_LONG_LAT,
143 C_STATE_C10
144};
145
146static int cstate_set_non_s0ix[3] = {
147 C_STATE_C1E,
148 C_STATE_C3,
149 C_STATE_C7S_LONG_LAT
150};
151
152static int get_cores_per_package(void)
153{
154 struct cpuinfo_x86 c;
155 struct cpuid_result result;
156 int cores = 1;
157
158 get_fms(&c, cpuid_eax(1));
159 if (c.x86 != 6)
160 return 1;
161
162 result = cpuid_ext(0xb, 1);
163 cores = result.ebx & 0xff;
164
165 return cores;
166}
167
168void acpi_init_gnvs(global_nvs_t *gnvs)
169{
170 /* Set unknown wake source */
171 gnvs->pm1i = -1;
172
173 /* CPU core count */
174 gnvs->pcnt = dev_count_cpu();
175
176#if CONFIG_CONSOLE_CBMEM
177 /* Update the mem console pointer. */
178 gnvs->cbmc = (u32)cbmem_find(CBMEM_ID_CONSOLE);
179#endif
180
181#if CONFIG_CHROMEOS
182 /* Initialize Verified Boot data */
183 chromeos_init_vboot(&(gnvs->chromeos));
184#if CONFIG_EC_GOOGLE_CHROMEEC
185 gnvs->chromeos.vbt2 = google_ec_running_ro() ?
186 ACTIVE_ECFW_RO : ACTIVE_ECFW_RW;
187#endif
188 gnvs->chromeos.vbt2 = ACTIVE_ECFW_RO;
189#endif
190}
191
192void acpi_create_intel_hpet(acpi_hpet_t * hpet)
193{
194 acpi_header_t *header = &(hpet->header);
195 acpi_addr_t *addr = &(hpet->addr);
196
197 memset((void *) hpet, 0, sizeof(acpi_hpet_t));
198
199 /* fill out header fields */
200 memcpy(header->signature, "HPET", 4);
201 memcpy(header->oem_id, OEM_ID, 6);
202 memcpy(header->oem_table_id, ACPI_TABLE_CREATOR, 8);
203 memcpy(header->asl_compiler_id, ASLC, 4);
204
205 header->length = sizeof(acpi_hpet_t);
206 header->revision = 1;
207
208 /* fill out HPET address */
209 addr->space_id = 0; /* Memory */
210 addr->bit_width = 64;
211 addr->bit_offset = 0;
212 addr->addrl = (unsigned long long)HPET_BASE_ADDRESS & 0xffffffff;
213 addr->addrh = (unsigned long long)HPET_BASE_ADDRESS >> 32;
214
215 hpet->id = 0x8086a201; /* Intel */
216 hpet->number = 0x00;
217 hpet->min_tick = 0x0080;
218
219 header->checksum =
220 acpi_checksum((void *) hpet, sizeof(acpi_hpet_t));
221}
222
223unsigned long acpi_fill_mcfg(unsigned long current)
224{
225 current += acpi_create_mcfg_mmconfig((acpi_mcfg_mmconfig_t *)current,
226 MCFG_BASE_ADDRESS, 0, 0, 255);
227 return current;
228}
229
230void acpi_fill_in_fadt(acpi_fadt_t *fadt)
231{
232 const uint16_t pmbase = ACPI_BASE_ADDRESS;
233
234 fadt->sci_int = acpi_sci_irq();
235 fadt->smi_cmd = APM_CNT;
236 fadt->acpi_enable = APM_CNT_ACPI_ENABLE;
237 fadt->acpi_disable = APM_CNT_ACPI_DISABLE;
238 fadt->s4bios_req = 0x0;
239 fadt->pstate_cnt = 0;
240
241 fadt->pm1a_evt_blk = pmbase + PM1_STS;
242 fadt->pm1b_evt_blk = 0x0;
243 fadt->pm1a_cnt_blk = pmbase + PM1_CNT;
244 fadt->pm1b_cnt_blk = 0x0;
245 fadt->pm2_cnt_blk = pmbase + PM2_CNT;
246 fadt->pm_tmr_blk = pmbase + PM1_TMR;
247 fadt->gpe0_blk = pmbase + GPE0_STS(0);
248 fadt->gpe1_blk = 0;
249
250 fadt->pm1_evt_len = 4;
251 fadt->pm1_cnt_len = 2;
252 fadt->pm2_cnt_len = 1;
253 fadt->pm_tmr_len = 4;
254 fadt->gpe0_blk_len = 32;
255 fadt->gpe1_blk_len = 0;
256 fadt->gpe1_base = 0;
257 fadt->cst_cnt = 0;
258 fadt->p_lvl2_lat = 1;
259 fadt->p_lvl3_lat = 87;
260 fadt->flush_size = 1024;
261 fadt->flush_stride = 16;
262 fadt->duty_offset = 1;
263 fadt->duty_width = 0;
264 fadt->day_alrm = 0xd;
265 fadt->mon_alrm = 0x00;
266 fadt->century = 0x00;
267 fadt->iapc_boot_arch = ACPI_FADT_LEGACY_DEVICES | ACPI_FADT_8042;
268
269 fadt->flags = ACPI_FADT_WBINVD | ACPI_FADT_C1_SUPPORTED |
270 ACPI_FADT_C2_MP_SUPPORTED | ACPI_FADT_SLEEP_BUTTON |
271 ACPI_FADT_RESET_REGISTER | ACPI_FADT_SEALED_CASE |
272 ACPI_FADT_S4_RTC_WAKE | ACPI_FADT_PLATFORM_CLOCK;
273
274 fadt->reset_reg.space_id = 1;
275 fadt->reset_reg.bit_width = 8;
276 fadt->reset_reg.bit_offset = 0;
277 fadt->reset_reg.resv = 0;
278 fadt->reset_reg.addrl = 0xcf9;
279 fadt->reset_reg.addrh = 0;
280 fadt->reset_value = 6;
281
282 fadt->x_pm1a_evt_blk.space_id = 1;
283 fadt->x_pm1a_evt_blk.bit_width = fadt->pm1_evt_len * 8;
284 fadt->x_pm1a_evt_blk.bit_offset = 0;
285 fadt->x_pm1a_evt_blk.resv = 0;
286 fadt->x_pm1a_evt_blk.addrl = pmbase + PM1_STS;
287 fadt->x_pm1a_evt_blk.addrh = 0x0;
288
289 fadt->x_pm1b_evt_blk.space_id = 1;
290 fadt->x_pm1b_evt_blk.bit_width = 0;
291 fadt->x_pm1b_evt_blk.bit_offset = 0;
292 fadt->x_pm1b_evt_blk.resv = 0;
293 fadt->x_pm1b_evt_blk.addrl = 0x0;
294 fadt->x_pm1b_evt_blk.addrh = 0x0;
295
296 fadt->x_pm1a_cnt_blk.space_id = 1;
297 fadt->x_pm1a_cnt_blk.bit_width = fadt->pm1_cnt_len * 8;
298 fadt->x_pm1a_cnt_blk.bit_offset = 0;
299 fadt->x_pm1a_cnt_blk.resv = 0;
300 fadt->x_pm1a_cnt_blk.addrl = pmbase + PM1_CNT;
301 fadt->x_pm1a_cnt_blk.addrh = 0x0;
302
303 fadt->x_pm1b_cnt_blk.space_id = 1;
304 fadt->x_pm1b_cnt_blk.bit_width = 0;
305 fadt->x_pm1b_cnt_blk.bit_offset = 0;
306 fadt->x_pm1b_cnt_blk.resv = 0;
307 fadt->x_pm1b_cnt_blk.addrl = 0x0;
308 fadt->x_pm1b_cnt_blk.addrh = 0x0;
309
310 fadt->x_pm2_cnt_blk.space_id = 1;
311 fadt->x_pm2_cnt_blk.bit_width = fadt->pm2_cnt_len * 8;
312 fadt->x_pm2_cnt_blk.bit_offset = 0;
313 fadt->x_pm2_cnt_blk.resv = 0;
314 fadt->x_pm2_cnt_blk.addrl = pmbase + PM2_CNT;
315 fadt->x_pm2_cnt_blk.addrh = 0x0;
316
317 fadt->x_pm_tmr_blk.space_id = 1;
318 fadt->x_pm_tmr_blk.bit_width = fadt->pm_tmr_len * 8;
319 fadt->x_pm_tmr_blk.bit_offset = 0;
320 fadt->x_pm_tmr_blk.resv = 0;
321 fadt->x_pm_tmr_blk.addrl = pmbase + PM1_TMR;
322 fadt->x_pm_tmr_blk.addrh = 0x0;
323
324 fadt->x_gpe0_blk.space_id = 0;
325 fadt->x_gpe0_blk.bit_width = 0;
326 fadt->x_gpe0_blk.bit_offset = 0;
327 fadt->x_gpe0_blk.resv = 0;
328 fadt->x_gpe0_blk.addrl = 0;
329 fadt->x_gpe0_blk.addrh = 0;
330
331 fadt->x_gpe1_blk.space_id = 1;
332 fadt->x_gpe1_blk.bit_width = 0;
333 fadt->x_gpe1_blk.bit_offset = 0;
334 fadt->x_gpe1_blk.resv = 0;
335 fadt->x_gpe1_blk.addrl = 0x0;
336 fadt->x_gpe1_blk.addrh = 0x0;
337}
338
339static acpi_tstate_t tss_table_fine[] = {
340 { 100, 1000, 0, 0x00, 0 },
341 { 94, 940, 0, 0x1f, 0 },
342 { 88, 880, 0, 0x1e, 0 },
343 { 82, 820, 0, 0x1d, 0 },
344 { 75, 760, 0, 0x1c, 0 },
345 { 69, 700, 0, 0x1b, 0 },
346 { 63, 640, 0, 0x1a, 0 },
347 { 57, 580, 0, 0x19, 0 },
348 { 50, 520, 0, 0x18, 0 },
349 { 44, 460, 0, 0x17, 0 },
350 { 38, 400, 0, 0x16, 0 },
351 { 32, 340, 0, 0x15, 0 },
352 { 25, 280, 0, 0x14, 0 },
353 { 19, 220, 0, 0x13, 0 },
354 { 13, 160, 0, 0x12, 0 },
355};
356
357static acpi_tstate_t tss_table_coarse[] = {
358 { 100, 1000, 0, 0x00, 0 },
359 { 88, 875, 0, 0x1f, 0 },
360 { 75, 750, 0, 0x1e, 0 },
361 { 63, 625, 0, 0x1d, 0 },
362 { 50, 500, 0, 0x1c, 0 },
363 { 38, 375, 0, 0x1b, 0 },
364 { 25, 250, 0, 0x1a, 0 },
365 { 13, 125, 0, 0x19, 0 },
366};
367
368static int generate_T_state_entries(int core, int cores_per_package)
369{
370 int len;
371
372 /* Indicate SW_ALL coordination for T-states */
373 len = acpigen_write_TSD_package(core, cores_per_package, SW_ALL);
374
375 /* Indicate FFixedHW so OS will use MSR */
376 len += acpigen_write_empty_PTC();
377
378 /* Set a T-state limit that can be modified in NVS */
379 len += acpigen_write_TPC("\\TLVL");
380
381 /*
382 * CPUID.(EAX=6):EAX[5] indicates support
383 * for extended throttle levels.
384 */
385 if (cpuid_eax(6) & (1 << 5))
386 len += acpigen_write_TSS_package(
387 ARRAY_SIZE(tss_table_fine), tss_table_fine);
388 else
389 len += acpigen_write_TSS_package(
390 ARRAY_SIZE(tss_table_coarse), tss_table_coarse);
391
392 return len;
393}
394
395static int generate_C_state_entries(void)
396{
397 device_t dev = SA_DEV_ROOT;
398 config_t *config = dev->chip_info;
399 acpi_cstate_t map[3];
400 int *set;
401 int i;
402
403 if (config->s0ix_enable)
404 set = cstate_set_s0ix;
405 else
406 set = cstate_set_non_s0ix;
407
408 for (i = 0; i < 3; i++) {
409 memcpy(&map[i], &cstate_map[set[i]], sizeof(acpi_cstate_t));
410 map[i].ctype = i + 1;
411 }
412
413 /* Generate C-state tables */
414 return acpigen_write_CST_package(map, ARRAY_SIZE(map));
415}
416
417static int calculate_power(int tdp, int p1_ratio, int ratio)
418{
419 u32 m;
420 u32 power;
421
422 /*
423 * M = ((1.1 - ((p1_ratio - ratio) * 0.00625)) / 1.1) ^ 2
424 *
425 * Power = (ratio / p1_ratio) * m * tdp
426 */
427
428 m = (110000 - ((p1_ratio - ratio) * 625)) / 11;
429 m = (m * m) / 1000;
430
431 power = ((ratio * 100000 / p1_ratio) / 100);
432 power *= (m / 100) * (tdp / 1000);
433 power /= 1000;
434
435 return (int)power;
436}
437
Vladimir Serbinenkob219da82014-11-09 03:29:30 +0100438static void generate_P_state_entries(int core, int cores_per_package)
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700439{
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700440 int ratio_min, ratio_max, ratio_turbo, ratio_step;
441 int coord_type, power_max, power_unit, num_entries;
442 int ratio, power, clock, clock_max;
443 msr_t msr;
444
445 /* Determine P-state coordination type from MISC_PWR_MGMT[0] */
446 msr = rdmsr(MSR_MISC_PWR_MGMT);
447 if (msr.lo & MISC_PWR_MGMT_EIST_HW_DIS)
448 coord_type = SW_ANY;
449 else
450 coord_type = HW_ALL;
451
452 /* Get bus ratio limits and calculate clock speeds */
453 msr = rdmsr(MSR_PLATFORM_INFO);
454 ratio_min = (msr.hi >> (40-32)) & 0xff; /* Max Efficiency Ratio */
455
456 /* Determine if this CPU has configurable TDP */
457 if (cpu_config_tdp_levels()) {
458 /* Set max ratio to nominal TDP ratio */
459 msr = rdmsr(MSR_CONFIG_TDP_NOMINAL);
460 ratio_max = msr.lo & 0xff;
461 } else {
462 /* Max Non-Turbo Ratio */
463 ratio_max = (msr.lo >> 8) & 0xff;
464 }
465 clock_max = ratio_max * CPU_BCLK;
466
467 /* Calculate CPU TDP in mW */
468 msr = rdmsr(MSR_PKG_POWER_SKU_UNIT);
469 power_unit = 2 << ((msr.lo & 0xf) - 1);
470 msr = rdmsr(MSR_PKG_POWER_SKU);
471 power_max = ((msr.lo & 0x7fff) / power_unit) * 1000;
472
473 /* Write _PCT indicating use of FFixedHW */
Vladimir Serbinenkob219da82014-11-09 03:29:30 +0100474 acpigen_write_empty_PCT();
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700475
476 /* Write _PPC with no limit on supported P-state */
Vladimir Serbinenkob219da82014-11-09 03:29:30 +0100477 acpigen_write_PPC_NVS();
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700478
479 /* Write PSD indicating configured coordination type */
Vladimir Serbinenkob219da82014-11-09 03:29:30 +0100480 acpigen_write_PSD_package(core, 1, coord_type);
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700481
482 /* Add P-state entries in _PSS table */
Vladimir Serbinenkob219da82014-11-09 03:29:30 +0100483 acpigen_write_name("_PSS");
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700484
485 /* Determine ratio points */
486 ratio_step = PSS_RATIO_STEP;
487 num_entries = (ratio_max - ratio_min) / ratio_step;
488 while (num_entries > PSS_MAX_ENTRIES-1) {
489 ratio_step <<= 1;
490 num_entries >>= 1;
491 }
492
493 /* P[T] is Turbo state if enabled */
494 if (get_turbo_state() == TURBO_ENABLED) {
495 /* _PSS package count including Turbo */
Vladimir Serbinenkob219da82014-11-09 03:29:30 +0100496 acpigen_write_package(num_entries + 2);
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700497
498 msr = rdmsr(MSR_TURBO_RATIO_LIMIT);
499 ratio_turbo = msr.lo & 0xff;
500
501 /* Add entry for Turbo ratio */
Vladimir Serbinenkob219da82014-11-09 03:29:30 +0100502 acpigen_write_PSS_package(
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700503 clock_max + 1, /*MHz*/
504 power_max, /*mW*/
505 PSS_LATENCY_TRANSITION, /*lat1*/
506 PSS_LATENCY_BUSMASTER, /*lat2*/
507 ratio_turbo << 8, /*control*/
508 ratio_turbo << 8); /*status*/
509 } else {
510 /* _PSS package count without Turbo */
Vladimir Serbinenkob219da82014-11-09 03:29:30 +0100511 acpigen_write_package(num_entries + 1);
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700512 }
513
514 /* First regular entry is max non-turbo ratio */
Vladimir Serbinenkob219da82014-11-09 03:29:30 +0100515 acpigen_write_PSS_package(
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700516 clock_max, /*MHz*/
517 power_max, /*mW*/
518 PSS_LATENCY_TRANSITION, /*lat1*/
519 PSS_LATENCY_BUSMASTER, /*lat2*/
520 ratio_max << 8, /*control*/
521 ratio_max << 8); /*status*/
522
523 /* Generate the remaining entries */
524 for (ratio = ratio_min + ((num_entries - 1) * ratio_step);
525 ratio >= ratio_min; ratio -= ratio_step) {
526
527 /* Calculate power at this ratio */
528 power = calculate_power(power_max, ratio_max, ratio);
529 clock = ratio * CPU_BCLK;
530
Vladimir Serbinenkob219da82014-11-09 03:29:30 +0100531 acpigen_write_PSS_package(
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700532 clock, /*MHz*/
533 power, /*mW*/
534 PSS_LATENCY_TRANSITION, /*lat1*/
535 PSS_LATENCY_BUSMASTER, /*lat2*/
536 ratio << 8, /*control*/
537 ratio << 8); /*status*/
538 }
539
540 /* Fix package length */
Vladimir Serbinenkob219da82014-11-09 03:29:30 +0100541 acpigen_pop_len();
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700542}
543
544void generate_cpu_entries(void)
545{
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700546 int coreID, cpuID, pcontrol_blk = ACPI_BASE_ADDRESS, plen = 6;
547 int totalcores = dev_count_cpu();
548 int cores_per_package = get_cores_per_package();
549 int numcpus = totalcores/cores_per_package;
550
551 printk(BIOS_DEBUG, "Found %d CPU(s) with %d core(s) each.\n",
552 numcpus, cores_per_package);
553
554 for (cpuID=1; cpuID <=numcpus; cpuID++) {
555 for (coreID=1; coreID<=cores_per_package; coreID++) {
556 if (coreID>1) {
557 pcontrol_blk = 0;
558 plen = 0;
559 }
560
561 /* Generate processor \_PR.CPUx */
Vladimir Serbinenkob219da82014-11-09 03:29:30 +0100562 acpigen_write_processor(
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700563 (cpuID-1)*cores_per_package+coreID-1,
564 pcontrol_blk, plen);
565
566 /* Generate P-state tables */
Vladimir Serbinenkob219da82014-11-09 03:29:30 +0100567 generate_P_state_entries(
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700568 coreID-1, cores_per_package);
569
570 /* Generate C-state tables */
Vladimir Serbinenkob219da82014-11-09 03:29:30 +0100571 generate_C_state_entries();
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700572
573 /* Generate T-state tables */
Vladimir Serbinenkob219da82014-11-09 03:29:30 +0100574 generate_T_state_entries(
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700575 cpuID-1, cores_per_package);
576
Vladimir Serbinenkob219da82014-11-09 03:29:30 +0100577 acpigen_pop_len();
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700578 }
579 }
580}
581
582unsigned long acpi_madt_irq_overrides(unsigned long current)
583{
584 int sci = acpi_sci_irq();
585 acpi_madt_irqoverride_t *irqovr;
586 uint16_t flags = MP_IRQ_TRIGGER_LEVEL;
587
588 /* INT_SRC_OVR */
589 irqovr = (void *)current;
590 current += acpi_create_madt_irqoverride(irqovr, 0, 0, 2, 0);
591
592 if (sci >= 20)
593 flags |= MP_IRQ_POLARITY_LOW;
594 else
595 flags |= MP_IRQ_POLARITY_HIGH;
596
597 /* SCI */
598 irqovr = (void *)current;
599 current += acpi_create_madt_irqoverride(irqovr, 0, sci, sci, flags);
600
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700601 return current;
602}