blob: 39ffa20936d2cb3813b3cae5e3ff1609552fe6d6 [file] [log] [blame]
Aaron Durbin61cd57b2013-10-30 14:36:11 -05001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2007-2009 coresystems GmbH
5 * Copyright (C) 2013 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.
Aaron Durbin61cd57b2013-10-30 14:36:11 -050015 */
16
17#include <arch/acpi.h>
18#include <arch/acpigen.h>
Aaron Durbin1af36632013-11-07 10:42:16 -060019#include <arch/io.h>
20#include <arch/smp/mpspec.h>
Shawn Nematbakhsh51d787a2014-01-16 17:52:21 -080021#include <cbmem.h>
Aaron Durbin1af36632013-11-07 10:42:16 -060022#include <console/console.h>
Aaron Durbin303525b2013-11-05 11:42:32 -060023#include <cpu/x86/smm.h>
Duncan Laurie8923be52013-11-05 13:02:30 -080024#include <console/console.h>
Aaron Durbin61cd57b2013-10-30 14:36:11 -050025#include <types.h>
26#include <string.h>
Duncan Laurie8923be52013-11-05 13:02:30 -080027#include <arch/cpu.h>
28#include <cpu/x86/msr.h>
29#include <cpu/x86/tsc.h>
30#include <cpu/intel/turbo.h>
Aaron Durbin61cd57b2013-10-30 14:36:11 -050031
Julius Werner18ea2d32014-10-07 16:42:17 -070032#include <soc/acpi.h>
33#include <soc/iomap.h>
34#include <soc/irq.h>
35#include <soc/msr.h>
36#include <soc/pattrs.h>
37#include <soc/pmc.h>
Aaron Durbin61cd57b2013-10-30 14:36:11 -050038
Shawn Nematbakhsh51d787a2014-01-16 17:52:21 -080039#include <ec/google/chromeec/ec.h>
40#include <vendorcode/google/chromeos/gnvs.h>
41
Duncan Laurie8923be52013-11-05 13:02:30 -080042#define MWAIT_RES(state, sub_state) \
43 { \
44 .addrl = (((state) << 4) | (sub_state)), \
45 .space_id = ACPI_ADDRESS_SPACE_FIXED, \
46 .bit_width = ACPI_FFIXEDHW_VENDOR_INTEL, \
47 .bit_offset = ACPI_FFIXEDHW_CLASS_MWAIT, \
48 .access_size = ACPI_FFIXEDHW_FLAG_HW_COORD, \
49 }
50
51/* C-state map without S0ix */
52static acpi_cstate_t cstate_map[] = {
53 {
54 /* C1 */
55 .ctype = 1, /* ACPI C1 */
56 .latency = 1,
57 .power = 1000,
58 .resource = MWAIT_RES(0, 0),
59 },
60 {
61 /* C6NS with no L2 shrink */
62 /* NOTE: this substate is above CPUID limit */
63 .ctype = 2, /* ACPI C2 */
64 .latency = 500,
65 .power = 10,
Duncan Laurie22f1dcd2013-12-02 10:14:47 -080066 .resource = MWAIT_RES(5, 1),
Duncan Laurie8923be52013-11-05 13:02:30 -080067 },
68 {
69 /* C6FS with full L2 shrink */
70 .ctype = 3, /* ACPI C3 */
71 .latency = 1500, /* 1.5ms worst case */
Aaron Durbin4177db52014-02-05 14:55:26 -060072 .power = 1,
Duncan Laurie8923be52013-11-05 13:02:30 -080073 .resource = MWAIT_RES(5, 2),
74 }
75};
76
Shawn Nematbakhsh51d787a2014-01-16 17:52:21 -080077void acpi_init_gnvs(global_nvs_t *gnvs)
78{
79 /* Set unknown wake source */
80 gnvs->pm1i = -1;
81
82 /* CPU core count */
83 gnvs->pcnt = dev_count_cpu();
84
85 /* Top of Low Memory (start of resource allocation) */
86 gnvs->tolm = nc_read_top_of_low_memory();
87
88#if CONFIG_CONSOLE_CBMEM
89 /* Update the mem console pointer. */
90 gnvs->cbmc = (u32)cbmem_find(CBMEM_ID_CONSOLE);
91#endif
92
93#if CONFIG_CHROMEOS
94 /* Initialize Verified Boot data */
95 chromeos_init_vboot(&(gnvs->chromeos));
96#if CONFIG_EC_GOOGLE_CHROMEEC
97 gnvs->chromeos.vbt2 = google_ec_running_ro() ?
98 ACTIVE_ECFW_RO : ACTIVE_ECFW_RW;
99#endif
100#endif
101}
102
Aaron Durbin1af36632013-11-07 10:42:16 -0600103static int acpi_sci_irq(void)
104{
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -0800105 u32 *actl = (u32 *)(ILB_BASE_ADDRESS + ACTL);
Aaron Durbin1af36632013-11-07 10:42:16 -0600106 int scis;
107 static int sci_irq;
108
109 if (sci_irq)
110 return sci_irq;
111
112 /* Determine how SCI is routed. */
113 scis = read32(actl) & SCIS_MASK;
114 switch (scis) {
115 case SCIS_IRQ9:
116 case SCIS_IRQ10:
117 case SCIS_IRQ11:
118 sci_irq = scis - SCIS_IRQ9 + 9;
119 break;
120 case SCIS_IRQ20:
121 case SCIS_IRQ21:
122 case SCIS_IRQ22:
123 case SCIS_IRQ23:
124 sci_irq = scis - SCIS_IRQ20 + 20;
125 break;
126 default:
127 printk(BIOS_DEBUG, "Invalid SCI route! Defaulting to IRQ9.\n");
128 sci_irq = 9;
129 break;
130 }
131
132 printk(BIOS_DEBUG, "SCI is IRQ%d\n", sci_irq);
133 return sci_irq;
134}
135
Aaron Durbin61cd57b2013-10-30 14:36:11 -0500136void acpi_create_intel_hpet(acpi_hpet_t * hpet)
137{
138 acpi_header_t *header = &(hpet->header);
139 acpi_addr_t *addr = &(hpet->addr);
140
141 memset((void *) hpet, 0, sizeof(acpi_hpet_t));
142
143 /* fill out header fields */
144 memcpy(header->signature, "HPET", 4);
145 memcpy(header->oem_id, OEM_ID, 6);
146 memcpy(header->oem_table_id, ACPI_TABLE_CREATOR, 8);
147 memcpy(header->asl_compiler_id, ASLC, 4);
148
149 header->length = sizeof(acpi_hpet_t);
150 header->revision = 1;
151
152 /* fill out HPET address */
153 addr->space_id = 0; /* Memory */
154 addr->bit_width = 64;
155 addr->bit_offset = 0;
156 addr->addrl = (unsigned long long)HPET_BASE_ADDRESS & 0xffffffff;
157 addr->addrh = (unsigned long long)HPET_BASE_ADDRESS >> 32;
158
159 hpet->id = 0x8086a201; /* Intel */
160 hpet->number = 0x00;
161 hpet->min_tick = 0x0080;
162
163 header->checksum =
164 acpi_checksum((void *) hpet, sizeof(acpi_hpet_t));
165}
Duncan Laurie03ff2a22013-11-04 17:15:20 -0800166
167unsigned long acpi_fill_mcfg(unsigned long current)
168{
169 current += acpi_create_mcfg_mmconfig((acpi_mcfg_mmconfig_t *)current,
170 MCFG_BASE_ADDRESS, 0, 0, 255);
171 return current;
172}
Aaron Durbin303525b2013-11-05 11:42:32 -0600173
174void acpi_fill_in_fadt(acpi_fadt_t *fadt)
175{
176 const uint16_t pmbase = ACPI_BASE_ADDRESS;
177
Aaron Durbin1af36632013-11-07 10:42:16 -0600178 fadt->sci_int = acpi_sci_irq();
Aaron Durbin303525b2013-11-05 11:42:32 -0600179 fadt->smi_cmd = APM_CNT;
180 fadt->acpi_enable = APM_CNT_ACPI_ENABLE;
181 fadt->acpi_disable = APM_CNT_ACPI_DISABLE;
182 fadt->s4bios_req = 0x0;
183 fadt->pstate_cnt = 0;
184
185 fadt->pm1a_evt_blk = pmbase + PM1_STS;
186 fadt->pm1b_evt_blk = 0x0;
187 fadt->pm1a_cnt_blk = pmbase + PM1_CNT;
188 fadt->pm1b_cnt_blk = 0x0;
189 fadt->pm2_cnt_blk = pmbase + PM2A_CNT_BLK;
190 fadt->pm_tmr_blk = pmbase + PM1_TMR;
191 fadt->gpe0_blk = pmbase + GPE0_STS;
192 fadt->gpe1_blk = 0;
193
194 fadt->pm1_evt_len = 4;
195 fadt->pm1_cnt_len = 2;
196 fadt->pm2_cnt_len = 1;
197 fadt->pm_tmr_len = 4;
Aaron Durbin997d2522013-11-08 17:37:48 -0600198 fadt->gpe0_blk_len = 2 * (GPE0_EN - GPE0_STS);
Aaron Durbin303525b2013-11-05 11:42:32 -0600199 fadt->gpe1_blk_len = 0;
200 fadt->gpe1_base = 0;
201 fadt->cst_cnt = 0;
202 fadt->p_lvl2_lat = 1;
203 fadt->p_lvl3_lat = 87;
204 fadt->flush_size = 1024;
205 fadt->flush_stride = 16;
206 fadt->duty_offset = 1;
207 fadt->duty_width = 0;
208 fadt->day_alrm = 0xd;
209 fadt->mon_alrm = 0x00;
210 fadt->century = 0x00;
211 fadt->iapc_boot_arch = ACPI_FADT_LEGACY_DEVICES | ACPI_FADT_8042;
212
213 fadt->flags = ACPI_FADT_WBINVD | ACPI_FADT_C1_SUPPORTED |
214 ACPI_FADT_C2_MP_SUPPORTED | ACPI_FADT_SLEEP_BUTTON |
215 ACPI_FADT_RESET_REGISTER | ACPI_FADT_SEALED_CASE |
216 ACPI_FADT_S4_RTC_WAKE | ACPI_FADT_PLATFORM_CLOCK;
217
218 fadt->reset_reg.space_id = 1;
219 fadt->reset_reg.bit_width = 8;
220 fadt->reset_reg.bit_offset = 0;
221 fadt->reset_reg.resv = 0;
222 fadt->reset_reg.addrl = 0xcf9;
223 fadt->reset_reg.addrh = 0;
224 fadt->reset_value = 6;
225
226 fadt->x_pm1a_evt_blk.space_id = 1;
Aaron Durbin997d2522013-11-08 17:37:48 -0600227 fadt->x_pm1a_evt_blk.bit_width = fadt->pm1_evt_len * 8;
Aaron Durbin303525b2013-11-05 11:42:32 -0600228 fadt->x_pm1a_evt_blk.bit_offset = 0;
229 fadt->x_pm1a_evt_blk.resv = 0;
230 fadt->x_pm1a_evt_blk.addrl = pmbase + PM1_STS;
231 fadt->x_pm1a_evt_blk.addrh = 0x0;
232
233 fadt->x_pm1b_evt_blk.space_id = 1;
234 fadt->x_pm1b_evt_blk.bit_width = 0;
235 fadt->x_pm1b_evt_blk.bit_offset = 0;
236 fadt->x_pm1b_evt_blk.resv = 0;
237 fadt->x_pm1b_evt_blk.addrl = 0x0;
238 fadt->x_pm1b_evt_blk.addrh = 0x0;
239
240 fadt->x_pm1a_cnt_blk.space_id = 1;
Aaron Durbin997d2522013-11-08 17:37:48 -0600241 fadt->x_pm1a_cnt_blk.bit_width = fadt->pm1_cnt_len * 8;
Aaron Durbin303525b2013-11-05 11:42:32 -0600242 fadt->x_pm1a_cnt_blk.bit_offset = 0;
243 fadt->x_pm1a_cnt_blk.resv = 0;
244 fadt->x_pm1a_cnt_blk.addrl = pmbase + PM1_CNT;
245 fadt->x_pm1a_cnt_blk.addrh = 0x0;
246
247 fadt->x_pm1b_cnt_blk.space_id = 1;
248 fadt->x_pm1b_cnt_blk.bit_width = 0;
249 fadt->x_pm1b_cnt_blk.bit_offset = 0;
250 fadt->x_pm1b_cnt_blk.resv = 0;
251 fadt->x_pm1b_cnt_blk.addrl = 0x0;
252 fadt->x_pm1b_cnt_blk.addrh = 0x0;
253
254 fadt->x_pm2_cnt_blk.space_id = 1;
Aaron Durbin997d2522013-11-08 17:37:48 -0600255 fadt->x_pm2_cnt_blk.bit_width = fadt->pm2_cnt_len * 8;
Aaron Durbin303525b2013-11-05 11:42:32 -0600256 fadt->x_pm2_cnt_blk.bit_offset = 0;
257 fadt->x_pm2_cnt_blk.resv = 0;
258 fadt->x_pm2_cnt_blk.addrl = pmbase + PM2A_CNT_BLK;
259 fadt->x_pm2_cnt_blk.addrh = 0x0;
260
261 fadt->x_pm_tmr_blk.space_id = 1;
Aaron Durbin997d2522013-11-08 17:37:48 -0600262 fadt->x_pm_tmr_blk.bit_width = fadt->pm_tmr_len * 8;
Aaron Durbin303525b2013-11-05 11:42:32 -0600263 fadt->x_pm_tmr_blk.bit_offset = 0;
264 fadt->x_pm_tmr_blk.resv = 0;
265 fadt->x_pm_tmr_blk.addrl = pmbase + PM1_TMR;
266 fadt->x_pm_tmr_blk.addrh = 0x0;
267
268 fadt->x_gpe0_blk.space_id = 1;
Aaron Durbin997d2522013-11-08 17:37:48 -0600269 fadt->x_gpe0_blk.bit_width = fadt->gpe0_blk_len * 8;
Aaron Durbin303525b2013-11-05 11:42:32 -0600270 fadt->x_gpe0_blk.bit_offset = 0;
271 fadt->x_gpe0_blk.resv = 0;
272 fadt->x_gpe0_blk.addrl = pmbase + GPE0_STS;
273 fadt->x_gpe0_blk.addrh = 0x0;
274
275 fadt->x_gpe1_blk.space_id = 1;
276 fadt->x_gpe1_blk.bit_width = 0;
277 fadt->x_gpe1_blk.bit_offset = 0;
278 fadt->x_gpe1_blk.resv = 0;
279 fadt->x_gpe1_blk.addrl = 0x0;
280 fadt->x_gpe1_blk.addrh = 0x0;
Duncan Laurie8923be52013-11-05 13:02:30 -0800281}
Aaron Durbin303525b2013-11-05 11:42:32 -0600282
Duncan Laurie8923be52013-11-05 13:02:30 -0800283static acpi_tstate_t baytrail_tss_table[] = {
284 { 100, 1000, 0, 0x00, 0 },
285 { 88, 875, 0, 0x1e, 0 },
286 { 75, 750, 0, 0x1c, 0 },
287 { 63, 625, 0, 0x1a, 0 },
288 { 50, 500, 0, 0x18, 0 },
289 { 38, 375, 0, 0x16, 0 },
290 { 25, 250, 0, 0x14, 0 },
291 { 13, 125, 0, 0x12, 0 },
292};
293
Vladimir Serbinenko7fb149d2014-10-08 22:56:27 +0200294static void generate_T_state_entries(int core, int cores_per_package)
Duncan Laurie8923be52013-11-05 13:02:30 -0800295{
Duncan Laurie8923be52013-11-05 13:02:30 -0800296 /* Indicate SW_ALL coordination for T-states */
Vladimir Serbinenko7fb149d2014-10-08 22:56:27 +0200297 acpigen_write_TSD_package(core, cores_per_package, SW_ALL);
Duncan Laurie8923be52013-11-05 13:02:30 -0800298
299 /* Indicate FFixedHW so OS will use MSR */
Vladimir Serbinenko7fb149d2014-10-08 22:56:27 +0200300 acpigen_write_empty_PTC();
Duncan Laurie8923be52013-11-05 13:02:30 -0800301
302 /* Set NVS controlled T-state limit */
Vladimir Serbinenko7fb149d2014-10-08 22:56:27 +0200303 acpigen_write_TPC("\\TLVL");
Duncan Laurie8923be52013-11-05 13:02:30 -0800304
305 /* Write TSS table for MSR access */
Vladimir Serbinenko7fb149d2014-10-08 22:56:27 +0200306 acpigen_write_TSS_package(
Duncan Laurie8923be52013-11-05 13:02:30 -0800307 ARRAY_SIZE(baytrail_tss_table), baytrail_tss_table);
Duncan Laurie8923be52013-11-05 13:02:30 -0800308}
309
310static int calculate_power(int tdp, int p1_ratio, int ratio)
311{
312 u32 m;
313 u32 power;
314
315 /*
316 * M = ((1.1 - ((p1_ratio - ratio) * 0.00625)) / 1.1) ^ 2
317 *
318 * Power = (ratio / p1_ratio) * m * tdp
319 */
320
321 m = (110000 - ((p1_ratio - ratio) * 625)) / 11;
322 m = (m * m) / 1000;
323
324 power = ((ratio * 100000 / p1_ratio) / 100);
325 power *= (m / 100) * (tdp / 1000);
326 power /= 1000;
327
328 return (int)power;
329}
330
Vladimir Serbinenko7fb149d2014-10-08 22:56:27 +0200331static void generate_P_state_entries(int core, int cores_per_package)
Duncan Laurie8923be52013-11-05 13:02:30 -0800332{
Duncan Laurie8923be52013-11-05 13:02:30 -0800333 int ratio_min, ratio_max, ratio_turbo, ratio_step, ratio_range_2;
334 int coord_type, power_max, power_unit, num_entries;
335 int ratio, power, clock, clock_max;
336 int vid, vid_turbo, vid_min, vid_max, vid_range_2;
337 u32 control_status;
338 const struct pattrs *pattrs = pattrs_get();
339 msr_t msr;
340
341 /* Inputs from CPU attributes */
342 ratio_max = pattrs->iacore_ratios[IACORE_MAX];
343 ratio_min = pattrs->iacore_ratios[IACORE_LFM];
344 vid_max = pattrs->iacore_vids[IACORE_MAX];
345 vid_min = pattrs->iacore_vids[IACORE_LFM];
346
Aaron Durbin4177db52014-02-05 14:55:26 -0600347 /* Set P-states coordination type based on MSR disable bit */
Duncan Laurie31ac9e32014-03-28 10:52:13 -0700348 coord_type = (pattrs->num_cpus > 2) ? SW_ALL : HW_ALL;
Duncan Laurie8923be52013-11-05 13:02:30 -0800349
350 /* Max Non-Turbo Frequency */
351 clock_max = (ratio_max * pattrs->bclk_khz) / 1000;
352
353 /* Calculate CPU TDP in mW */
354 msr = rdmsr(MSR_PKG_POWER_SKU_UNIT);
355 power_unit = 1 << (msr.lo & 0xf);
356 msr = rdmsr(MSR_PKG_POWER_LIMIT);
357 power_max = ((msr.lo & 0x7fff) / power_unit) * 1000;
358
359 /* Write _PCT indicating use of FFixedHW */
Vladimir Serbinenko7fb149d2014-10-08 22:56:27 +0200360 acpigen_write_empty_PCT();
Duncan Laurie8923be52013-11-05 13:02:30 -0800361
Duncan Lauriead8d9132013-12-10 07:41:33 -0800362 /* Write _PPC with NVS specified limit on supported P-state */
Vladimir Serbinenko7fb149d2014-10-08 22:56:27 +0200363 acpigen_write_PPC_NVS();
Duncan Laurie8923be52013-11-05 13:02:30 -0800364
365 /* Write PSD indicating configured coordination type */
Vladimir Serbinenko7fb149d2014-10-08 22:56:27 +0200366 acpigen_write_PSD_package(core, 1, coord_type);
Duncan Laurie8923be52013-11-05 13:02:30 -0800367
368 /* Add P-state entries in _PSS table */
Vladimir Serbinenko7fb149d2014-10-08 22:56:27 +0200369 acpigen_write_name("_PSS");
Duncan Laurie8923be52013-11-05 13:02:30 -0800370
371 /* Determine ratio points */
372 ratio_step = 1;
373 num_entries = (ratio_max - ratio_min) / ratio_step;
374 while (num_entries > 15) { /* ACPI max is 15 ratios */
375 ratio_step <<= 1;
376 num_entries >>= 1;
377 }
378
379 /* P[T] is Turbo state if enabled */
380 if (get_turbo_state() == TURBO_ENABLED) {
381 /* _PSS package count including Turbo */
Vladimir Serbinenko7fb149d2014-10-08 22:56:27 +0200382 acpigen_write_package(num_entries + 2);
Duncan Laurie8923be52013-11-05 13:02:30 -0800383
384 ratio_turbo = pattrs->iacore_ratios[IACORE_TURBO];
385 vid_turbo = pattrs->iacore_vids[IACORE_TURBO];
386 control_status = (ratio_turbo << 8) | vid_turbo;
387
388 /* Add entry for Turbo ratio */
Vladimir Serbinenko7fb149d2014-10-08 22:56:27 +0200389 acpigen_write_PSS_package(
Duncan Laurie8923be52013-11-05 13:02:30 -0800390 clock_max + 1, /*MHz*/
391 power_max, /*mW*/
392 10, /*lat1*/
393 10, /*lat2*/
394 control_status, /*control*/
395 control_status); /*status*/
396 } else {
397 /* _PSS package count without Turbo */
Vladimir Serbinenko7fb149d2014-10-08 22:56:27 +0200398 acpigen_write_package(num_entries + 1);
Duncan Laurie8923be52013-11-05 13:02:30 -0800399 ratio_turbo = ratio_max;
400 vid_turbo = vid_max;
401 }
402
403 /* First regular entry is max non-turbo ratio */
404 control_status = (ratio_max << 8) | vid_max;
Vladimir Serbinenko7fb149d2014-10-08 22:56:27 +0200405 acpigen_write_PSS_package(
Duncan Laurie8923be52013-11-05 13:02:30 -0800406 clock_max, /*MHz*/
407 power_max, /*mW*/
408 10, /*lat1*/
409 10, /*lat2*/
410 control_status, /*control */
411 control_status); /*status*/
412
413 /* Set up ratio and vid ranges for VID calculation */
414 ratio_range_2 = (ratio_turbo - ratio_min) * 2;
415 vid_range_2 = (vid_turbo - vid_min) * 2;
416
417 /* Generate the remaining entries */
418 for (ratio = ratio_min + ((num_entries - 1) * ratio_step);
419 ratio >= ratio_min; ratio -= ratio_step) {
420
421 /* Calculate VID for this ratio */
422 vid = ((ratio - ratio_min) * vid_range_2) /
423 ratio_range_2 + vid_min;
424 /* Round up if remainder */
425 if (((ratio - ratio_min) * vid_range_2) % ratio_range_2)
426 vid++;
427
428 /* Calculate power at this ratio */
429 power = calculate_power(power_max, ratio_max, ratio);
430 clock = (ratio * pattrs->bclk_khz) / 1000;
431 control_status = (ratio << 8) | (vid & 0xff);
432
Vladimir Serbinenko7fb149d2014-10-08 22:56:27 +0200433 acpigen_write_PSS_package(
Duncan Laurie8923be52013-11-05 13:02:30 -0800434 clock, /*MHz*/
435 power, /*mW*/
436 10, /*lat1*/
437 10, /*lat2*/
438 control_status, /*control*/
439 control_status); /*status*/
440 }
441
442 /* Fix package length */
Vladimir Serbinenko7fb149d2014-10-08 22:56:27 +0200443 acpigen_pop_len();
Duncan Laurie8923be52013-11-05 13:02:30 -0800444}
445
Alexander Couzens5eea4582015-04-12 22:18:55 +0200446void generate_cpu_entries(device_t device)
Duncan Laurie8923be52013-11-05 13:02:30 -0800447{
Vladimir Serbinenko7fb149d2014-10-08 22:56:27 +0200448 int core;
Duncan Laurie8923be52013-11-05 13:02:30 -0800449 int pcontrol_blk = get_pmbase(), plen = 6;
450 const struct pattrs *pattrs = pattrs_get();
451
452 for (core=0; core<pattrs->num_cpus; core++) {
453 if (core > 0) {
454 pcontrol_blk = 0;
455 plen = 0;
456 }
457
458 /* Generate processor \_PR.CPUx */
Vladimir Serbinenko7fb149d2014-10-08 22:56:27 +0200459 acpigen_write_processor(
Duncan Laurie8923be52013-11-05 13:02:30 -0800460 core, pcontrol_blk, plen);
461
462 /* Generate P-state tables */
Vladimir Serbinenko7fb149d2014-10-08 22:56:27 +0200463 generate_P_state_entries(
Duncan Laurie8923be52013-11-05 13:02:30 -0800464 core, pattrs->num_cpus);
465
466 /* Generate C-state tables */
Vladimir Serbinenko7fb149d2014-10-08 22:56:27 +0200467 acpigen_write_CST_package(
Duncan Laurie8923be52013-11-05 13:02:30 -0800468 cstate_map, ARRAY_SIZE(cstate_map));
469
470 /* Generate T-state tables */
Vladimir Serbinenko7fb149d2014-10-08 22:56:27 +0200471 generate_T_state_entries(
Duncan Laurie8923be52013-11-05 13:02:30 -0800472 core, pattrs->num_cpus);
473
Vladimir Serbinenko7fb149d2014-10-08 22:56:27 +0200474 acpigen_pop_len();
Duncan Laurie8923be52013-11-05 13:02:30 -0800475 }
Aaron Durbin303525b2013-11-05 11:42:32 -0600476}
Aaron Durbin1af36632013-11-07 10:42:16 -0600477
478unsigned long acpi_madt_irq_overrides(unsigned long current)
479{
480 int sci_irq = acpi_sci_irq();
481 acpi_madt_irqoverride_t *irqovr;
482 uint16_t sci_flags = MP_IRQ_TRIGGER_LEVEL;
483
484 /* INT_SRC_OVR */
485 irqovr = (void *)current;
486 current += acpi_create_madt_irqoverride(irqovr, 0, 0, 2, 0);
487
488 if (sci_irq >= 20)
489 sci_flags |= MP_IRQ_POLARITY_LOW;
490 else
491 sci_flags |= MP_IRQ_POLARITY_HIGH;
492
493 irqovr = (void *)current;
494 current += acpi_create_madt_irqoverride(irqovr, 0, sci_irq, sci_irq,
495 sci_flags);
496
497 return current;
498}