2020-04-05 15:47:17 +02:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
2015-05-13 03:19:47 +02:00
|
|
|
|
2020-05-02 19:24:23 +02:00
|
|
|
#include <acpi/acpi.h>
|
2020-06-17 22:37:49 +02:00
|
|
|
#include <acpi/acpi_gnvs.h>
|
2021-01-21 15:05:26 +01:00
|
|
|
#include <acpi/acpi_pm.h>
|
2020-05-02 19:24:23 +02:00
|
|
|
#include <acpi/acpigen.h>
|
2015-10-02 02:21:33 +02:00
|
|
|
#include <arch/cpu.h>
|
2015-09-04 23:19:35 +02:00
|
|
|
#include <arch/ioapic.h>
|
2015-05-13 03:19:47 +02:00
|
|
|
#include <arch/smp/mpspec.h>
|
|
|
|
#include <console/console.h>
|
|
|
|
#include <cpu/x86/smm.h>
|
|
|
|
#include <cpu/x86/msr.h>
|
2018-07-27 23:17:29 +02:00
|
|
|
#include <cpu/intel/common/common.h>
|
2015-05-13 03:19:47 +02:00
|
|
|
#include <cpu/intel/turbo.h>
|
2017-05-04 14:32:17 +02:00
|
|
|
#include <intelblocks/cpulib.h>
|
2017-09-29 02:06:01 +02:00
|
|
|
#include <intelblocks/lpc_lib.h>
|
2017-10-12 01:12:21 +02:00
|
|
|
#include <intelblocks/sgx.h>
|
2017-11-12 05:03:29 +01:00
|
|
|
#include <intelblocks/uart.h>
|
2017-09-18 20:03:46 +02:00
|
|
|
#include <intelblocks/systemagent.h>
|
2015-09-09 01:12:44 +02:00
|
|
|
#include <soc/intel/common/acpi.h>
|
2015-05-13 03:19:47 +02:00
|
|
|
#include <soc/acpi.h>
|
|
|
|
#include <soc/cpu.h>
|
|
|
|
#include <soc/iomap.h>
|
|
|
|
#include <soc/msr.h>
|
2020-12-21 14:17:01 +01:00
|
|
|
#include <soc/nvs.h>
|
2015-05-13 03:19:47 +02:00
|
|
|
#include <soc/pci_devs.h>
|
|
|
|
#include <soc/pm.h>
|
2016-08-30 17:17:13 +02:00
|
|
|
#include <soc/ramstage.h>
|
2017-09-18 20:03:46 +02:00
|
|
|
#include <soc/systemagent.h>
|
2015-10-02 02:21:33 +02:00
|
|
|
#include <string.h>
|
|
|
|
#include <types.h>
|
2016-02-25 17:45:43 +01:00
|
|
|
#include <wrdd.h>
|
2018-04-18 10:11:59 +02:00
|
|
|
#include <device/pci_ops.h>
|
2015-05-13 03:19:47 +02:00
|
|
|
|
2019-03-21 15:38:06 +01:00
|
|
|
#include "chip.h"
|
|
|
|
|
2020-10-15 00:27:59 +02:00
|
|
|
#define CPUID_6_EAX_ISST (1 << 7)
|
|
|
|
|
2015-05-13 03:19:47 +02:00
|
|
|
/*
|
2015-05-13 03:23:27 +02:00
|
|
|
* List of suported C-states in this processor.
|
2015-05-13 03:19:47 +02:00
|
|
|
*/
|
|
|
|
enum {
|
2015-05-13 03:23:27 +02:00
|
|
|
C_STATE_C0, /* 0 */
|
|
|
|
C_STATE_C1, /* 1 */
|
|
|
|
C_STATE_C1E, /* 2 */
|
|
|
|
C_STATE_C3, /* 3 */
|
|
|
|
C_STATE_C6_SHORT_LAT, /* 4 */
|
|
|
|
C_STATE_C6_LONG_LAT, /* 5 */
|
|
|
|
C_STATE_C7_SHORT_LAT, /* 6 */
|
|
|
|
C_STATE_C7_LONG_LAT, /* 7 */
|
|
|
|
C_STATE_C7S_SHORT_LAT, /* 8 */
|
|
|
|
C_STATE_C7S_LONG_LAT, /* 9 */
|
|
|
|
C_STATE_C8, /* 10 */
|
|
|
|
C_STATE_C9, /* 11 */
|
|
|
|
C_STATE_C10, /* 12 */
|
2015-05-13 03:19:47 +02:00
|
|
|
NUM_C_STATES
|
|
|
|
};
|
2015-05-13 03:23:27 +02:00
|
|
|
#define MWAIT_RES(state, sub_state) \
|
|
|
|
{ \
|
|
|
|
.addrl = (((state) << 4) | (sub_state)), \
|
|
|
|
.space_id = ACPI_ADDRESS_SPACE_FIXED, \
|
|
|
|
.bit_width = ACPI_FFIXEDHW_VENDOR_INTEL, \
|
|
|
|
.bit_offset = ACPI_FFIXEDHW_CLASS_MWAIT, \
|
|
|
|
.access_size = ACPI_FFIXEDHW_FLAG_HW_COORD, \
|
2015-05-13 03:19:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static acpi_cstate_t cstate_map[NUM_C_STATES] = {
|
|
|
|
[C_STATE_C0] = { },
|
|
|
|
[C_STATE_C1] = {
|
|
|
|
.latency = 0,
|
2015-09-11 23:25:15 +02:00
|
|
|
.power = C1_POWER,
|
2015-05-13 03:23:27 +02:00
|
|
|
.resource = MWAIT_RES(0, 0),
|
2015-05-13 03:19:47 +02:00
|
|
|
},
|
|
|
|
[C_STATE_C1E] = {
|
|
|
|
.latency = 0,
|
2015-09-11 23:25:15 +02:00
|
|
|
.power = C1_POWER,
|
2015-05-13 03:23:27 +02:00
|
|
|
.resource = MWAIT_RES(0, 1),
|
2015-05-13 03:19:47 +02:00
|
|
|
},
|
|
|
|
[C_STATE_C3] = {
|
|
|
|
.latency = C_STATE_LATENCY_FROM_LAT_REG(0),
|
2015-09-11 23:25:15 +02:00
|
|
|
.power = C3_POWER,
|
2015-05-13 03:19:47 +02:00
|
|
|
.resource = MWAIT_RES(1, 0),
|
|
|
|
},
|
|
|
|
[C_STATE_C6_SHORT_LAT] = {
|
|
|
|
.latency = C_STATE_LATENCY_FROM_LAT_REG(1),
|
2015-09-11 23:25:15 +02:00
|
|
|
.power = C6_POWER,
|
2015-05-13 03:19:47 +02:00
|
|
|
.resource = MWAIT_RES(2, 0),
|
|
|
|
},
|
|
|
|
[C_STATE_C6_LONG_LAT] = {
|
|
|
|
.latency = C_STATE_LATENCY_FROM_LAT_REG(2),
|
2015-09-11 23:25:15 +02:00
|
|
|
.power = C6_POWER,
|
2015-05-13 03:19:47 +02:00
|
|
|
.resource = MWAIT_RES(2, 1),
|
|
|
|
},
|
|
|
|
[C_STATE_C7_SHORT_LAT] = {
|
|
|
|
.latency = C_STATE_LATENCY_FROM_LAT_REG(1),
|
2015-09-11 23:25:15 +02:00
|
|
|
.power = C7_POWER,
|
2015-05-13 03:19:47 +02:00
|
|
|
.resource = MWAIT_RES(3, 0),
|
|
|
|
},
|
|
|
|
[C_STATE_C7_LONG_LAT] = {
|
|
|
|
.latency = C_STATE_LATENCY_FROM_LAT_REG(2),
|
2015-09-11 23:25:15 +02:00
|
|
|
.power = C7_POWER,
|
2015-05-13 03:19:47 +02:00
|
|
|
.resource = MWAIT_RES(3, 1),
|
|
|
|
},
|
|
|
|
[C_STATE_C7S_SHORT_LAT] = {
|
|
|
|
.latency = C_STATE_LATENCY_FROM_LAT_REG(1),
|
2015-09-11 23:25:15 +02:00
|
|
|
.power = C7_POWER,
|
2015-05-13 03:19:47 +02:00
|
|
|
.resource = MWAIT_RES(3, 2),
|
|
|
|
},
|
|
|
|
[C_STATE_C7S_LONG_LAT] = {
|
|
|
|
.latency = C_STATE_LATENCY_FROM_LAT_REG(2),
|
2015-09-11 23:25:15 +02:00
|
|
|
.power = C7_POWER,
|
2015-05-13 03:19:47 +02:00
|
|
|
.resource = MWAIT_RES(3, 3),
|
|
|
|
},
|
|
|
|
[C_STATE_C8] = {
|
|
|
|
.latency = C_STATE_LATENCY_FROM_LAT_REG(3),
|
2015-09-11 23:25:15 +02:00
|
|
|
.power = C8_POWER,
|
2015-05-13 03:19:47 +02:00
|
|
|
.resource = MWAIT_RES(4, 0),
|
|
|
|
},
|
|
|
|
[C_STATE_C9] = {
|
|
|
|
.latency = C_STATE_LATENCY_FROM_LAT_REG(4),
|
2015-09-11 23:25:15 +02:00
|
|
|
.power = C9_POWER,
|
2015-05-13 03:19:47 +02:00
|
|
|
.resource = MWAIT_RES(5, 0),
|
|
|
|
},
|
|
|
|
[C_STATE_C10] = {
|
|
|
|
.latency = C_STATE_LATENCY_FROM_LAT_REG(5),
|
2015-09-11 23:25:15 +02:00
|
|
|
.power = C10_POWER,
|
2015-05-13 03:19:47 +02:00
|
|
|
.resource = MWAIT_RES(6, 0),
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2015-05-13 03:23:27 +02:00
|
|
|
static int cstate_set_s0ix[] = {
|
2015-05-13 03:19:47 +02:00
|
|
|
C_STATE_C1E,
|
|
|
|
C_STATE_C7S_LONG_LAT,
|
|
|
|
C_STATE_C10
|
|
|
|
};
|
|
|
|
|
2015-05-13 03:23:27 +02:00
|
|
|
static int cstate_set_non_s0ix[] = {
|
2015-05-13 03:19:47 +02:00
|
|
|
C_STATE_C1E,
|
|
|
|
C_STATE_C3,
|
2015-05-13 03:23:27 +02:00
|
|
|
C_STATE_C7S_LONG_LAT,
|
2015-05-13 03:19:47 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
static int get_cores_per_package(void)
|
|
|
|
{
|
|
|
|
struct cpuinfo_x86 c;
|
|
|
|
struct cpuid_result result;
|
|
|
|
int cores = 1;
|
|
|
|
|
|
|
|
get_fms(&c, cpuid_eax(1));
|
|
|
|
if (c.x86 != 6)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
result = cpuid_ext(0xb, 1);
|
|
|
|
cores = result.ebx & 0xff;
|
|
|
|
|
|
|
|
return cores;
|
|
|
|
}
|
|
|
|
|
2020-06-28 21:39:59 +02:00
|
|
|
void soc_fill_gnvs(struct global_nvs *gnvs)
|
2015-05-13 03:19:47 +02:00
|
|
|
{
|
2019-09-27 23:20:27 +02:00
|
|
|
const struct soc_intel_skylake_config *config = config_of_soc();
|
2015-09-04 22:53:14 +02:00
|
|
|
|
2015-05-13 03:19:47 +02:00
|
|
|
/* Set unknown wake source */
|
|
|
|
gnvs->pm1i = -1;
|
|
|
|
|
2015-09-04 22:53:14 +02:00
|
|
|
/* Enable DPTF based on mainboard configuration */
|
|
|
|
gnvs->dpte = config->dptf_enable;
|
2016-02-25 17:45:43 +01:00
|
|
|
|
|
|
|
/* Fill in the Wifi Region id */
|
|
|
|
gnvs->cid1 = wifi_regulatory_domain();
|
2016-10-18 23:25:25 +02:00
|
|
|
|
|
|
|
/* Set USB2/USB3 wake enable bitmaps. */
|
|
|
|
gnvs->u2we = config->usb2_wake_enable_bitmap;
|
|
|
|
gnvs->u3we = config->usb3_wake_enable_bitmap;
|
2017-10-12 01:12:21 +02:00
|
|
|
|
2019-10-22 23:05:06 +02:00
|
|
|
if (CONFIG(SOC_INTEL_COMMON_BLOCK_SGX_ENABLE))
|
2017-10-12 01:12:21 +02:00
|
|
|
sgx_fill_gnvs(gnvs);
|
2020-01-03 10:59:02 +01:00
|
|
|
|
|
|
|
/* Fill in Above 4GB MMIO resource */
|
|
|
|
sa_fill_gnvs(gnvs);
|
2015-05-13 03:19:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
unsigned long acpi_fill_mcfg(unsigned long current)
|
|
|
|
{
|
|
|
|
current += acpi_create_mcfg_mmconfig((acpi_mcfg_mmconfig_t *)current,
|
2018-03-02 23:56:38 +01:00
|
|
|
CONFIG_MMCONF_BASE_ADDRESS, 0, 0,
|
2018-03-02 23:47:11 +01:00
|
|
|
(CONFIG_SA_PCIEX_LENGTH >> 20) - 1);
|
2015-05-13 03:19:47 +02:00
|
|
|
return current;
|
|
|
|
}
|
|
|
|
|
2015-09-04 23:19:35 +02:00
|
|
|
unsigned long acpi_fill_madt(unsigned long current)
|
|
|
|
{
|
|
|
|
/* Local APICs */
|
|
|
|
current = acpi_create_madt_lapics(current);
|
|
|
|
|
|
|
|
/* IOAPIC */
|
|
|
|
current += acpi_create_madt_ioapic((acpi_madt_ioapic_t *) current,
|
|
|
|
2, IO_APIC_ADDR, 0);
|
|
|
|
|
|
|
|
return acpi_madt_irq_overrides(current);
|
|
|
|
}
|
|
|
|
|
src: Remove variable length arrays
Variable length arrays were a feature added in C99 that allows the
length of an array to be determined at runtime. Eg.
int sum(size_t n) {
int arr[n];
...
}
This adds a small amount of runtime overhead, but is also very
dangerous, since it allows use of an unlimited amount of stack memory,
potentially leading to stack overflow. This is only worsened in
coreboot, which often has very little stack space to begin with. Citing
concerns like this, all instances of VLA's were recently removed from the
Linux kernel. In the immortal words of Linus Torvalds [0],
AND USING VLA'S IS ACTIVELY STUPID! It generates much more code, and
much _slower_ code (and more fragile code), than just using a fixed
key size would have done. [...] Anyway, some of these are definitely
easy to just fix, and using VLA's is actively bad not just for
security worries, but simply because VLA's are a really horribly bad
idea in general in the kernel.
This patch follows suit and zaps all VLA's in coreboot. Some of the
existing VLA's are accidental ones, and all but one can be replaced with
small fixed-size buffers. The single tricky exception is in the SPI
controller interface, which will require a rewrite of old drivers
to remove [1].
[0] https://lkml.org/lkml/2018/3/7/621
[1] https://ticket.coreboot.org/issues/217
Change-Id: I7d9d1ddadbf1cee5f695165bbe3f0effb7bd32b9
Signed-off-by: Jacob Garber <jgarber1@ualberta.ca>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/33821
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Patrick Georgi <pgeorgi@google.com>
2019-06-27 00:18:16 +02:00
|
|
|
static void write_c_state_entries(acpi_cstate_t *map, const int *set, size_t max_c_state)
|
2015-05-13 03:19:47 +02:00
|
|
|
{
|
src: Remove variable length arrays
Variable length arrays were a feature added in C99 that allows the
length of an array to be determined at runtime. Eg.
int sum(size_t n) {
int arr[n];
...
}
This adds a small amount of runtime overhead, but is also very
dangerous, since it allows use of an unlimited amount of stack memory,
potentially leading to stack overflow. This is only worsened in
coreboot, which often has very little stack space to begin with. Citing
concerns like this, all instances of VLA's were recently removed from the
Linux kernel. In the immortal words of Linus Torvalds [0],
AND USING VLA'S IS ACTIVELY STUPID! It generates much more code, and
much _slower_ code (and more fragile code), than just using a fixed
key size would have done. [...] Anyway, some of these are definitely
easy to just fix, and using VLA's is actively bad not just for
security worries, but simply because VLA's are a really horribly bad
idea in general in the kernel.
This patch follows suit and zaps all VLA's in coreboot. Some of the
existing VLA's are accidental ones, and all but one can be replaced with
small fixed-size buffers. The single tricky exception is in the SPI
controller interface, which will require a rewrite of old drivers
to remove [1].
[0] https://lkml.org/lkml/2018/3/7/621
[1] https://ticket.coreboot.org/issues/217
Change-Id: I7d9d1ddadbf1cee5f695165bbe3f0effb7bd32b9
Signed-off-by: Jacob Garber <jgarber1@ualberta.ca>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/33821
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Patrick Georgi <pgeorgi@google.com>
2019-06-27 00:18:16 +02:00
|
|
|
for (size_t i = 0; i < max_c_state; i++) {
|
2015-05-13 03:19:47 +02:00
|
|
|
memcpy(&map[i], &cstate_map[set[i]], sizeof(acpi_cstate_t));
|
|
|
|
map[i].ctype = i + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Generate C-state tables */
|
src: Remove variable length arrays
Variable length arrays were a feature added in C99 that allows the
length of an array to be determined at runtime. Eg.
int sum(size_t n) {
int arr[n];
...
}
This adds a small amount of runtime overhead, but is also very
dangerous, since it allows use of an unlimited amount of stack memory,
potentially leading to stack overflow. This is only worsened in
coreboot, which often has very little stack space to begin with. Citing
concerns like this, all instances of VLA's were recently removed from the
Linux kernel. In the immortal words of Linus Torvalds [0],
AND USING VLA'S IS ACTIVELY STUPID! It generates much more code, and
much _slower_ code (and more fragile code), than just using a fixed
key size would have done. [...] Anyway, some of these are definitely
easy to just fix, and using VLA's is actively bad not just for
security worries, but simply because VLA's are a really horribly bad
idea in general in the kernel.
This patch follows suit and zaps all VLA's in coreboot. Some of the
existing VLA's are accidental ones, and all but one can be replaced with
small fixed-size buffers. The single tricky exception is in the SPI
controller interface, which will require a rewrite of old drivers
to remove [1].
[0] https://lkml.org/lkml/2018/3/7/621
[1] https://ticket.coreboot.org/issues/217
Change-Id: I7d9d1ddadbf1cee5f695165bbe3f0effb7bd32b9
Signed-off-by: Jacob Garber <jgarber1@ualberta.ca>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/33821
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Patrick Georgi <pgeorgi@google.com>
2019-06-27 00:18:16 +02:00
|
|
|
acpigen_write_CST_package(map, max_c_state);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void generate_c_state_entries(int s0ix_enable)
|
|
|
|
{
|
|
|
|
if (s0ix_enable) {
|
|
|
|
acpi_cstate_t map[ARRAY_SIZE(cstate_set_s0ix)];
|
|
|
|
write_c_state_entries(map, cstate_set_s0ix, ARRAY_SIZE(map));
|
|
|
|
} else {
|
|
|
|
acpi_cstate_t map[ARRAY_SIZE(cstate_set_non_s0ix)];
|
|
|
|
write_c_state_entries(map, cstate_set_non_s0ix, ARRAY_SIZE(map));
|
|
|
|
}
|
2015-05-13 03:19:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static int calculate_power(int tdp, int p1_ratio, int ratio)
|
|
|
|
{
|
|
|
|
u32 m;
|
|
|
|
u32 power;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* M = ((1.1 - ((p1_ratio - ratio) * 0.00625)) / 1.1) ^ 2
|
|
|
|
*
|
|
|
|
* Power = (ratio / p1_ratio) * m * tdp
|
|
|
|
*/
|
|
|
|
|
|
|
|
m = (110000 - ((p1_ratio - ratio) * 625)) / 11;
|
|
|
|
m = (m * m) / 1000;
|
|
|
|
|
|
|
|
power = ((ratio * 100000 / p1_ratio) / 100);
|
|
|
|
power *= (m / 100) * (tdp / 1000);
|
|
|
|
power /= 1000;
|
|
|
|
|
|
|
|
return (int)power;
|
|
|
|
}
|
|
|
|
|
2015-05-13 03:23:27 +02:00
|
|
|
static void generate_p_state_entries(int core, int cores_per_package)
|
2015-05-13 03:19:47 +02:00
|
|
|
{
|
|
|
|
int ratio_min, ratio_max, ratio_turbo, ratio_step;
|
|
|
|
int coord_type, power_max, power_unit, num_entries;
|
|
|
|
int ratio, power, clock, clock_max;
|
|
|
|
msr_t msr;
|
|
|
|
|
|
|
|
/* Determine P-state coordination type from MISC_PWR_MGMT[0] */
|
|
|
|
msr = rdmsr(MSR_MISC_PWR_MGMT);
|
|
|
|
if (msr.lo & MISC_PWR_MGMT_EIST_HW_DIS)
|
|
|
|
coord_type = SW_ANY;
|
|
|
|
else
|
|
|
|
coord_type = HW_ALL;
|
|
|
|
|
|
|
|
/* Get bus ratio limits and calculate clock speeds */
|
|
|
|
msr = rdmsr(MSR_PLATFORM_INFO);
|
|
|
|
ratio_min = (msr.hi >> (40-32)) & 0xff; /* Max Efficiency Ratio */
|
|
|
|
|
|
|
|
/* Determine if this CPU has configurable TDP */
|
|
|
|
if (cpu_config_tdp_levels()) {
|
|
|
|
/* Set max ratio to nominal TDP ratio */
|
|
|
|
msr = rdmsr(MSR_CONFIG_TDP_NOMINAL);
|
|
|
|
ratio_max = msr.lo & 0xff;
|
|
|
|
} else {
|
|
|
|
/* Max Non-Turbo Ratio */
|
|
|
|
ratio_max = (msr.lo >> 8) & 0xff;
|
|
|
|
}
|
2017-06-02 08:26:14 +02:00
|
|
|
clock_max = ratio_max * CONFIG_CPU_BCLK_MHZ;
|
2015-05-13 03:19:47 +02:00
|
|
|
|
|
|
|
/* Calculate CPU TDP in mW */
|
|
|
|
msr = rdmsr(MSR_PKG_POWER_SKU_UNIT);
|
|
|
|
power_unit = 2 << ((msr.lo & 0xf) - 1);
|
|
|
|
msr = rdmsr(MSR_PKG_POWER_SKU);
|
|
|
|
power_max = ((msr.lo & 0x7fff) / power_unit) * 1000;
|
|
|
|
|
|
|
|
/* Write _PCT indicating use of FFixedHW */
|
|
|
|
acpigen_write_empty_PCT();
|
|
|
|
|
|
|
|
/* Write _PPC with no limit on supported P-state */
|
|
|
|
acpigen_write_PPC_NVS();
|
|
|
|
|
|
|
|
/* Write PSD indicating configured coordination type */
|
|
|
|
acpigen_write_PSD_package(core, 1, coord_type);
|
|
|
|
|
|
|
|
/* Add P-state entries in _PSS table */
|
|
|
|
acpigen_write_name("_PSS");
|
|
|
|
|
|
|
|
/* Determine ratio points */
|
|
|
|
ratio_step = PSS_RATIO_STEP;
|
2015-05-13 03:23:27 +02:00
|
|
|
num_entries = ((ratio_max - ratio_min) / ratio_step) + 1;
|
|
|
|
if (num_entries > PSS_MAX_ENTRIES) {
|
|
|
|
ratio_step += 1;
|
|
|
|
num_entries = ((ratio_max - ratio_min) / ratio_step) + 1;
|
2015-05-13 03:19:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* P[T] is Turbo state if enabled */
|
|
|
|
if (get_turbo_state() == TURBO_ENABLED) {
|
|
|
|
/* _PSS package count including Turbo */
|
|
|
|
acpigen_write_package(num_entries + 2);
|
|
|
|
|
|
|
|
msr = rdmsr(MSR_TURBO_RATIO_LIMIT);
|
|
|
|
ratio_turbo = msr.lo & 0xff;
|
|
|
|
|
|
|
|
/* Add entry for Turbo ratio */
|
|
|
|
acpigen_write_PSS_package(
|
2015-05-13 03:23:27 +02:00
|
|
|
clock_max + 1, /* MHz */
|
|
|
|
power_max, /* mW */
|
|
|
|
PSS_LATENCY_TRANSITION, /* lat1 */
|
|
|
|
PSS_LATENCY_BUSMASTER, /* lat2 */
|
|
|
|
ratio_turbo << 8, /* control */
|
|
|
|
ratio_turbo << 8); /* status */
|
2015-05-13 03:19:47 +02:00
|
|
|
} else {
|
|
|
|
/* _PSS package count without Turbo */
|
|
|
|
acpigen_write_package(num_entries + 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* First regular entry is max non-turbo ratio */
|
|
|
|
acpigen_write_PSS_package(
|
2015-05-13 03:23:27 +02:00
|
|
|
clock_max, /* MHz */
|
|
|
|
power_max, /* mW */
|
|
|
|
PSS_LATENCY_TRANSITION, /* lat1 */
|
|
|
|
PSS_LATENCY_BUSMASTER, /* lat2 */
|
|
|
|
ratio_max << 8, /* control */
|
|
|
|
ratio_max << 8); /* status */
|
2015-05-13 03:19:47 +02:00
|
|
|
|
|
|
|
/* Generate the remaining entries */
|
|
|
|
for (ratio = ratio_min + ((num_entries - 1) * ratio_step);
|
|
|
|
ratio >= ratio_min; ratio -= ratio_step) {
|
|
|
|
|
|
|
|
/* Calculate power at this ratio */
|
|
|
|
power = calculate_power(power_max, ratio_max, ratio);
|
2017-06-02 08:26:14 +02:00
|
|
|
clock = ratio * CONFIG_CPU_BCLK_MHZ;
|
2015-05-13 03:19:47 +02:00
|
|
|
|
|
|
|
acpigen_write_PSS_package(
|
2015-05-13 03:23:27 +02:00
|
|
|
clock, /* MHz */
|
|
|
|
power, /* mW */
|
|
|
|
PSS_LATENCY_TRANSITION, /* lat1 */
|
|
|
|
PSS_LATENCY_BUSMASTER, /* lat2 */
|
|
|
|
ratio << 8, /* control */
|
|
|
|
ratio << 8); /* status */
|
2015-05-13 03:19:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Fix package length */
|
|
|
|
acpigen_pop_len();
|
|
|
|
}
|
|
|
|
|
2020-10-14 19:30:46 +02:00
|
|
|
static void generate_cppc_entries(int core_id)
|
|
|
|
{
|
|
|
|
/* Generate GCPC table in first logical core */
|
|
|
|
if (core_id == 0) {
|
|
|
|
struct cppc_config cppc_config;
|
|
|
|
cpu_init_cppc_config(&cppc_config, CPPC_VERSION_2);
|
|
|
|
acpigen_write_CPPC_package(&cppc_config);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Write _CST entry for each logical core */
|
|
|
|
acpigen_write_CPPC_method();
|
|
|
|
}
|
|
|
|
|
2020-04-25 06:59:21 +02:00
|
|
|
void generate_cpu_entries(const struct device *device)
|
2015-05-13 03:19:47 +02:00
|
|
|
{
|
2015-05-13 03:23:27 +02:00
|
|
|
int core_id, cpu_id, pcontrol_blk = ACPI_BASE_ADDRESS, plen = 6;
|
2015-05-13 03:19:47 +02:00
|
|
|
int totalcores = dev_count_cpu();
|
|
|
|
int cores_per_package = get_cores_per_package();
|
|
|
|
int numcpus = totalcores/cores_per_package;
|
2019-09-27 23:20:27 +02:00
|
|
|
config_t *config = config_of_soc();
|
2015-05-13 03:23:27 +02:00
|
|
|
int is_s0ix_enable = config->s0ix_enable;
|
2020-10-14 19:30:46 +02:00
|
|
|
const bool isst_supported = cpuid_eax(6) & CPUID_6_EAX_ISST;
|
2015-05-13 03:19:47 +02:00
|
|
|
|
|
|
|
printk(BIOS_DEBUG, "Found %d CPU(s) with %d core(s) each.\n",
|
|
|
|
numcpus, cores_per_package);
|
|
|
|
|
2015-05-13 03:23:27 +02:00
|
|
|
for (cpu_id = 0; cpu_id < numcpus; cpu_id++) {
|
|
|
|
for (core_id = 0; core_id < cores_per_package; core_id++) {
|
|
|
|
if (core_id > 0) {
|
2015-05-13 03:19:47 +02:00
|
|
|
pcontrol_blk = 0;
|
|
|
|
plen = 0;
|
|
|
|
}
|
|
|
|
|
2019-12-18 15:07:59 +01:00
|
|
|
/* Generate processor \_SB.CPUx */
|
2015-05-13 03:19:47 +02:00
|
|
|
acpigen_write_processor(
|
2015-05-13 03:23:27 +02:00
|
|
|
cpu_id*cores_per_package+core_id,
|
2015-05-13 03:19:47 +02:00
|
|
|
pcontrol_blk, plen);
|
|
|
|
/* Generate C-state tables */
|
src: Remove variable length arrays
Variable length arrays were a feature added in C99 that allows the
length of an array to be determined at runtime. Eg.
int sum(size_t n) {
int arr[n];
...
}
This adds a small amount of runtime overhead, but is also very
dangerous, since it allows use of an unlimited amount of stack memory,
potentially leading to stack overflow. This is only worsened in
coreboot, which often has very little stack space to begin with. Citing
concerns like this, all instances of VLA's were recently removed from the
Linux kernel. In the immortal words of Linus Torvalds [0],
AND USING VLA'S IS ACTIVELY STUPID! It generates much more code, and
much _slower_ code (and more fragile code), than just using a fixed
key size would have done. [...] Anyway, some of these are definitely
easy to just fix, and using VLA's is actively bad not just for
security worries, but simply because VLA's are a really horribly bad
idea in general in the kernel.
This patch follows suit and zaps all VLA's in coreboot. Some of the
existing VLA's are accidental ones, and all but one can be replaced with
small fixed-size buffers. The single tricky exception is in the SPI
controller interface, which will require a rewrite of old drivers
to remove [1].
[0] https://lkml.org/lkml/2018/3/7/621
[1] https://ticket.coreboot.org/issues/217
Change-Id: I7d9d1ddadbf1cee5f695165bbe3f0effb7bd32b9
Signed-off-by: Jacob Garber <jgarber1@ualberta.ca>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/33821
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Patrick Georgi <pgeorgi@google.com>
2019-06-27 00:18:16 +02:00
|
|
|
generate_c_state_entries(is_s0ix_enable);
|
2015-05-13 03:19:47 +02:00
|
|
|
|
2018-07-27 23:17:29 +02:00
|
|
|
if (config->eist_enable) {
|
2017-05-12 08:13:57 +02:00
|
|
|
/* Generate P-state tables */
|
|
|
|
generate_p_state_entries(core_id,
|
|
|
|
cores_per_package);
|
2018-07-27 23:17:29 +02:00
|
|
|
}
|
2020-08-03 15:01:18 +02:00
|
|
|
|
2020-10-14 19:30:46 +02:00
|
|
|
if (isst_supported)
|
|
|
|
generate_cppc_entries(core_id);
|
2020-08-03 15:01:18 +02:00
|
|
|
|
2015-05-13 03:19:47 +02:00
|
|
|
acpigen_pop_len();
|
|
|
|
}
|
|
|
|
}
|
2018-11-28 12:07:19 +01:00
|
|
|
|
|
|
|
/* PPKG is usually used for thermal management
|
|
|
|
of the first and only package. */
|
|
|
|
acpigen_write_processor_package("PPKG", 0, cores_per_package);
|
|
|
|
|
|
|
|
/* Add a method to notify processor nodes */
|
|
|
|
acpigen_write_processor_cnot(cores_per_package);
|
2015-05-13 03:19:47 +02:00
|
|
|
}
|
|
|
|
|
2017-09-18 20:03:46 +02:00
|
|
|
static unsigned long acpi_fill_dmar(unsigned long current)
|
|
|
|
{
|
2019-07-03 06:25:59 +02:00
|
|
|
struct device *const igfx_dev = pcidev_path_on_root(SA_DEVFN_IGD);
|
2017-09-18 20:03:46 +02:00
|
|
|
const u32 gfx_vtbar = MCHBAR32(GFXVTBAR) & ~0xfff;
|
|
|
|
const bool gfxvten = MCHBAR32(GFXVTBAR) & 1;
|
|
|
|
|
|
|
|
/* iGFX has to be enabled, GFXVTBAR set and in 32-bit space. */
|
2020-08-03 12:29:41 +02:00
|
|
|
const bool emit_igd =
|
|
|
|
igfx_dev && igfx_dev->enabled &&
|
|
|
|
gfx_vtbar && gfxvten &&
|
|
|
|
!MCHBAR32(GFXVTBAR + 4);
|
|
|
|
|
|
|
|
/* First, add DRHD entries */
|
|
|
|
if (emit_igd) {
|
|
|
|
const unsigned long tmp = current;
|
2017-09-18 20:03:46 +02:00
|
|
|
|
|
|
|
current += acpi_create_dmar_drhd(current, 0, 0, gfx_vtbar);
|
2018-03-29 14:59:57 +02:00
|
|
|
current += acpi_create_dmar_ds_pci(current, 0, 2, 0);
|
2017-09-18 20:03:46 +02:00
|
|
|
|
|
|
|
acpi_dmar_drhd_fixup(tmp, current);
|
|
|
|
}
|
|
|
|
|
|
|
|
const u32 vtvc0bar = MCHBAR32(VTVC0BAR) & ~0xfff;
|
|
|
|
const bool vtvc0en = MCHBAR32(VTVC0BAR) & 1;
|
|
|
|
|
|
|
|
/* General VTBAR has to be set and in 32-bit space. */
|
2019-08-30 19:42:23 +02:00
|
|
|
if (vtvc0bar && vtvc0en && !MCHBAR32(VTVC0BAR + 4)) {
|
2017-09-18 20:03:46 +02:00
|
|
|
const unsigned long tmp = current;
|
|
|
|
|
2019-08-30 19:42:23 +02:00
|
|
|
current += acpi_create_dmar_drhd(current, DRHD_INCLUDE_PCI_ALL, 0, vtvc0bar);
|
2017-09-18 20:03:46 +02:00
|
|
|
|
2019-08-30 19:42:23 +02:00
|
|
|
current += acpi_create_dmar_ds_ioapic(current, 2, V_P2SB_IBDF_BUS,
|
|
|
|
V_P2SB_IBDF_DEV, V_P2SB_IBDF_FUN);
|
2017-09-18 20:03:46 +02:00
|
|
|
|
2019-08-30 19:42:23 +02:00
|
|
|
current += acpi_create_dmar_ds_msi_hpet(current, 0, V_P2SB_HBDF_BUS,
|
|
|
|
V_P2SB_HBDF_DEV, V_P2SB_HBDF_FUN);
|
2017-09-18 20:03:46 +02:00
|
|
|
|
|
|
|
acpi_dmar_drhd_fixup(tmp, current);
|
|
|
|
}
|
|
|
|
|
2020-08-03 12:29:41 +02:00
|
|
|
/* Then, add RMRR entries after all DRHD entries */
|
|
|
|
if (emit_igd) {
|
|
|
|
const unsigned long tmp = current;
|
|
|
|
|
|
|
|
current += acpi_create_dmar_rmrr(current, 0,
|
|
|
|
sa_get_gsm_base(), sa_get_tolud_base() - 1);
|
|
|
|
current += acpi_create_dmar_ds_pci(current, 0, 2, 0);
|
|
|
|
acpi_dmar_rmrr_fixup(tmp, current);
|
|
|
|
}
|
|
|
|
|
2017-09-18 20:03:46 +02:00
|
|
|
return current;
|
|
|
|
}
|
|
|
|
|
2020-04-24 15:41:18 +02:00
|
|
|
unsigned long northbridge_write_acpi_tables(const struct device *const dev,
|
2017-09-18 20:03:46 +02:00
|
|
|
unsigned long current,
|
|
|
|
struct acpi_rsdp *const rsdp)
|
|
|
|
{
|
2019-07-12 12:10:19 +02:00
|
|
|
const struct soc_intel_skylake_config *const config = config_of(dev);
|
2017-09-18 20:03:46 +02:00
|
|
|
acpi_dmar_t *const dmar = (acpi_dmar_t *)current;
|
|
|
|
|
|
|
|
/* Create DMAR table only if we have VT-d capability. */
|
2019-07-12 12:10:19 +02:00
|
|
|
if (config->ignore_vtd || !soc_is_vtd_capable())
|
2017-09-18 20:03:46 +02:00
|
|
|
return current;
|
|
|
|
|
|
|
|
printk(BIOS_DEBUG, "ACPI: * DMAR\n");
|
|
|
|
acpi_create_dmar(dmar, DMAR_INTR_REMAP, acpi_fill_dmar);
|
|
|
|
current += dmar->header.length;
|
|
|
|
current = acpi_align_current(current);
|
|
|
|
acpi_add_table(rsdp, dmar);
|
|
|
|
|
|
|
|
return current;
|
|
|
|
}
|
|
|
|
|
2015-05-13 03:19:47 +02:00
|
|
|
unsigned long acpi_madt_irq_overrides(unsigned long current)
|
|
|
|
{
|
|
|
|
int sci = acpi_sci_irq();
|
|
|
|
acpi_madt_irqoverride_t *irqovr;
|
|
|
|
uint16_t flags = MP_IRQ_TRIGGER_LEVEL;
|
|
|
|
|
|
|
|
/* INT_SRC_OVR */
|
|
|
|
irqovr = (void *)current;
|
|
|
|
current += acpi_create_madt_irqoverride(irqovr, 0, 0, 2, 0);
|
|
|
|
|
|
|
|
if (sci >= 20)
|
|
|
|
flags |= MP_IRQ_POLARITY_LOW;
|
|
|
|
else
|
|
|
|
flags |= MP_IRQ_POLARITY_HIGH;
|
|
|
|
|
|
|
|
/* SCI */
|
|
|
|
irqovr = (void *)current;
|
|
|
|
current += acpi_create_madt_irqoverride(irqovr, 0, sci, sci, flags);
|
|
|
|
|
2020-11-23 15:53:28 +01:00
|
|
|
/* NMI */
|
|
|
|
current += acpi_create_madt_lapic_nmi((acpi_madt_lapic_nmi_t *)current, 0xff, 5, 1);
|
|
|
|
|
2015-05-13 03:19:47 +02:00
|
|
|
return current;
|
|
|
|
}
|
2015-05-13 03:23:27 +02:00
|
|
|
|
2020-04-24 15:41:18 +02:00
|
|
|
unsigned long southbridge_write_acpi_tables(const struct device *device,
|
2015-05-13 03:23:27 +02:00
|
|
|
unsigned long current,
|
|
|
|
struct acpi_rsdp *rsdp)
|
|
|
|
{
|
2017-11-12 05:03:29 +01:00
|
|
|
current = acpi_write_dbg2_pci_uart(rsdp, current,
|
2018-05-24 08:51:06 +02:00
|
|
|
uart_get_device(),
|
2017-11-12 05:03:29 +01:00
|
|
|
ACPI_ACCESS_SIZE_DWORD_ACCESS);
|
2015-05-13 03:23:27 +02:00
|
|
|
current = acpi_write_hpet(device, current, rsdp);
|
2015-12-11 00:07:38 +01:00
|
|
|
return acpi_align_current(current);
|
2015-05-13 03:23:27 +02:00
|
|
|
}
|
|
|
|
|
2015-09-09 01:12:44 +02:00
|
|
|
/* Save wake source information for calculating ACPI _SWS values */
|
2021-01-22 18:59:07 +01:00
|
|
|
int soc_fill_acpi_wake(const struct chipset_power_state *ps, uint32_t *pm1, uint32_t **gpe0)
|
2015-09-09 01:12:44 +02:00
|
|
|
{
|
2019-09-27 23:20:27 +02:00
|
|
|
const struct soc_intel_skylake_config *config = config_of_soc();
|
2015-09-09 01:12:44 +02:00
|
|
|
static uint32_t gpe0_sts[GPE0_REG_MAX];
|
|
|
|
uint32_t pm1_en;
|
2016-10-26 05:07:22 +02:00
|
|
|
uint32_t gpe0_std;
|
2015-09-09 01:12:44 +02:00
|
|
|
int i;
|
2016-10-27 16:53:17 +02:00
|
|
|
const int last_index = GPE0_REG_MAX - 1;
|
2015-09-09 01:12:44 +02:00
|
|
|
|
2016-10-26 05:07:22 +02:00
|
|
|
pm1_en = ps->pm1_en;
|
|
|
|
gpe0_std = ps->gpe0_en[3];
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Chipset state in the suspend well (but not RTC) is lost in Deep S3
|
|
|
|
* so enable Deep S3 wake events that are configured by the mainboard
|
|
|
|
*/
|
2017-04-11 06:02:13 +02:00
|
|
|
if (ps->prev_sleep_state == ACPI_S3 &&
|
|
|
|
(config->deep_s3_enable_ac || config->deep_s3_enable_dc)) {
|
2016-10-26 05:07:22 +02:00
|
|
|
pm1_en |= PWRBTN_STS; /* Always enabled as wake source */
|
|
|
|
if (config->deep_sx_config & DSX_EN_LAN_WAKE_PIN)
|
|
|
|
gpe0_std |= LAN_WAK_EN;
|
|
|
|
if (config->deep_sx_config & DSX_EN_WAKE_PIN)
|
|
|
|
pm1_en |= PCIEXPWAK_STS;
|
|
|
|
}
|
|
|
|
|
2015-09-09 01:12:44 +02:00
|
|
|
*pm1 = ps->pm1_sts & pm1_en;
|
|
|
|
|
|
|
|
/* Mask off GPE0 status bits that are not enabled */
|
|
|
|
*gpe0 = &gpe0_sts[0];
|
2016-10-27 16:53:17 +02:00
|
|
|
for (i = 0; i < last_index; i++)
|
2015-09-09 01:12:44 +02:00
|
|
|
gpe0_sts[i] = ps->gpe0_sts[i] & ps->gpe0_en[i];
|
2016-10-27 16:53:17 +02:00
|
|
|
gpe0_sts[last_index] = ps->gpe0_sts[last_index] & gpe0_std;
|
2015-09-09 01:12:44 +02:00
|
|
|
|
|
|
|
return GPE0_REG_MAX;
|
|
|
|
}
|
|
|
|
|
2017-09-14 00:01:52 +02:00
|
|
|
const char *soc_acpi_name(const struct device *dev)
|
2016-08-30 17:17:13 +02:00
|
|
|
{
|
|
|
|
if (dev->path.type == DEVICE_PATH_DOMAIN)
|
|
|
|
return "PCI0";
|
|
|
|
|
2018-05-08 00:33:18 +02:00
|
|
|
if (dev->path.type == DEVICE_PATH_USB) {
|
|
|
|
switch (dev->path.usb.port_type) {
|
|
|
|
case 0:
|
|
|
|
/* Root Hub */
|
|
|
|
return "RHUB";
|
|
|
|
case 2:
|
|
|
|
/* USB2 ports */
|
|
|
|
switch (dev->path.usb.port_id) {
|
|
|
|
case 0: return "HS01";
|
|
|
|
case 1: return "HS02";
|
|
|
|
case 2: return "HS03";
|
|
|
|
case 3: return "HS04";
|
|
|
|
case 4: return "HS05";
|
|
|
|
case 5: return "HS06";
|
|
|
|
case 6: return "HS07";
|
|
|
|
case 7: return "HS08";
|
|
|
|
case 8: return "HS09";
|
|
|
|
case 9: return "HS10";
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
/* USB3 ports */
|
|
|
|
switch (dev->path.usb.port_id) {
|
|
|
|
case 0: return "SS01";
|
|
|
|
case 1: return "SS02";
|
|
|
|
case 2: return "SS03";
|
|
|
|
case 3: return "SS04";
|
|
|
|
case 4: return "SS05";
|
|
|
|
case 5: return "SS06";
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2016-08-30 17:17:13 +02:00
|
|
|
if (dev->path.type != DEVICE_PATH_PCI)
|
|
|
|
return NULL;
|
|
|
|
|
2020-08-06 21:13:09 +02:00
|
|
|
/* Match functions 0 and 1 for possible GPUs on a secondary bus */
|
|
|
|
if (dev->bus && dev->bus->secondary > 0) {
|
|
|
|
switch (PCI_FUNC(dev->path.pci.devfn)) {
|
|
|
|
case 0: return "DEV0";
|
|
|
|
case 1: return "DEV1";
|
|
|
|
}
|
2019-09-26 14:45:29 +02:00
|
|
|
return NULL;
|
2020-08-06 21:13:09 +02:00
|
|
|
}
|
2019-09-26 14:45:29 +02:00
|
|
|
|
2016-08-30 17:17:13 +02:00
|
|
|
switch (dev->path.pci.devfn) {
|
|
|
|
case SA_DEVFN_ROOT: return "MCHC";
|
2020-08-06 21:13:09 +02:00
|
|
|
case SA_DEVFN_PEG0: return "PEGP";
|
2016-08-30 17:17:13 +02:00
|
|
|
case SA_DEVFN_IGD: return "GFX0";
|
|
|
|
case PCH_DEVFN_ISH: return "ISHB";
|
|
|
|
case PCH_DEVFN_XHCI: return "XHCI";
|
|
|
|
case PCH_DEVFN_USBOTG: return "XDCI";
|
|
|
|
case PCH_DEVFN_THERMAL: return "THRM";
|
|
|
|
case PCH_DEVFN_CIO: return "ICIO";
|
|
|
|
case PCH_DEVFN_I2C0: return "I2C0";
|
|
|
|
case PCH_DEVFN_I2C1: return "I2C1";
|
|
|
|
case PCH_DEVFN_I2C2: return "I2C2";
|
|
|
|
case PCH_DEVFN_I2C3: return "I2C3";
|
2017-03-05 08:07:00 +01:00
|
|
|
case PCH_DEVFN_CSE: return "CSE1";
|
|
|
|
case PCH_DEVFN_CSE_2: return "CSE2";
|
|
|
|
case PCH_DEVFN_CSE_IDER: return "CSED";
|
|
|
|
case PCH_DEVFN_CSE_KT: return "CSKT";
|
|
|
|
case PCH_DEVFN_CSE_3: return "CSE3";
|
2016-08-30 17:17:13 +02:00
|
|
|
case PCH_DEVFN_SATA: return "SATA";
|
|
|
|
case PCH_DEVFN_UART2: return "UAR2";
|
|
|
|
case PCH_DEVFN_I2C4: return "I2C4";
|
|
|
|
case PCH_DEVFN_I2C5: return "I2C5";
|
|
|
|
case PCH_DEVFN_PCIE1: return "RP01";
|
|
|
|
case PCH_DEVFN_PCIE2: return "RP02";
|
|
|
|
case PCH_DEVFN_PCIE3: return "RP03";
|
|
|
|
case PCH_DEVFN_PCIE4: return "RP04";
|
|
|
|
case PCH_DEVFN_PCIE5: return "RP05";
|
|
|
|
case PCH_DEVFN_PCIE6: return "RP06";
|
|
|
|
case PCH_DEVFN_PCIE7: return "RP07";
|
|
|
|
case PCH_DEVFN_PCIE8: return "RP08";
|
|
|
|
case PCH_DEVFN_PCIE9: return "RP09";
|
|
|
|
case PCH_DEVFN_PCIE10: return "RP10";
|
|
|
|
case PCH_DEVFN_PCIE11: return "RP11";
|
|
|
|
case PCH_DEVFN_PCIE12: return "RP12";
|
soc/intel/skl/acpi: add description for missing PCIe ports
According to the documentation, Sunrise PCH-H [1,2] and Lewisburg PCH
[3] supports up to 16 PCIe ports. However, ACPI contains a description
for only 12 ports. This patch adds ACPI code for missing ports
[1] page 182, Intel (R) 100 Series and Intel (R) C230 Series PCH
Family Platform Controller Hub (PCH), Datasheet, Vol 1 of 2,
December 2018, Document Number: 332690-005EN
[2] page 180, Intel (R) 200 Series and Intel (R) Z370 Series PCH
Family Platform Controller Hub (PCH), Datasheet, Vol 1 of 2,
October 2017, Document Number: 335192-003
[3] page 39, Intel(R) C620 Series Chipset Platform Controller Hub
(PCH) Datasheet, May 2019. Document Number: 336067-007US
Change-Id: I954870136e0c8e5ff5d7ff623c7a6432b829abaf
Signed-off-by: Maxim Polyakov <max.senia.poliak@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/35072
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
2019-08-23 14:22:21 +02:00
|
|
|
case PCH_DEVFN_PCIE13: return "RP13";
|
|
|
|
case PCH_DEVFN_PCIE14: return "RP14";
|
|
|
|
case PCH_DEVFN_PCIE15: return "RP15";
|
|
|
|
case PCH_DEVFN_PCIE16: return "RP16";
|
2016-08-30 17:17:13 +02:00
|
|
|
case PCH_DEVFN_UART0: return "UAR0";
|
|
|
|
case PCH_DEVFN_UART1: return "UAR1";
|
|
|
|
case PCH_DEVFN_GSPI0: return "SPI0";
|
|
|
|
case PCH_DEVFN_GSPI1: return "SPI1";
|
|
|
|
case PCH_DEVFN_EMMC: return "EMMC";
|
|
|
|
case PCH_DEVFN_SDIO: return "SDIO";
|
|
|
|
case PCH_DEVFN_SDCARD: return "SDXC";
|
|
|
|
case PCH_DEVFN_P2SB: return "P2SB";
|
|
|
|
case PCH_DEVFN_PMC: return "PMC_";
|
|
|
|
case PCH_DEVFN_HDA: return "HDAS";
|
|
|
|
case PCH_DEVFN_SMBUS: return "SBUS";
|
|
|
|
case PCH_DEVFN_SPI: return "FSPI";
|
|
|
|
case PCH_DEVFN_GBE: return "IGBE";
|
|
|
|
case PCH_DEVFN_TRACEHUB:return "THUB";
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
2017-05-23 20:53:47 +02:00
|
|
|
|
|
|
|
static int acpigen_soc_gpio_op(const char *op, unsigned int gpio_num)
|
|
|
|
{
|
|
|
|
/* op (gpio_num) */
|
|
|
|
acpigen_emit_namestring(op);
|
|
|
|
acpigen_write_integer(gpio_num);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int acpigen_soc_get_gpio_state(const char *op, unsigned int gpio_num)
|
|
|
|
{
|
|
|
|
/* Store (op (gpio_num), Local0) */
|
|
|
|
acpigen_write_store();
|
|
|
|
acpigen_soc_gpio_op(op, gpio_num);
|
|
|
|
acpigen_emit_byte(LOCAL0_OP);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int acpigen_soc_read_rx_gpio(unsigned int gpio_num)
|
|
|
|
{
|
|
|
|
return acpigen_soc_get_gpio_state("\\_SB.PCI0.GRXS", gpio_num);
|
|
|
|
}
|
|
|
|
|
|
|
|
int acpigen_soc_get_tx_gpio(unsigned int gpio_num)
|
|
|
|
{
|
|
|
|
return acpigen_soc_get_gpio_state("\\_SB.PCI0.GTXS", gpio_num);
|
|
|
|
}
|
|
|
|
|
|
|
|
int acpigen_soc_set_tx_gpio(unsigned int gpio_num)
|
|
|
|
{
|
|
|
|
return acpigen_soc_gpio_op("\\_SB.PCI0.STXS", gpio_num);
|
|
|
|
}
|
|
|
|
|
|
|
|
int acpigen_soc_clear_tx_gpio(unsigned int gpio_num)
|
|
|
|
{
|
|
|
|
return acpigen_soc_gpio_op("\\_SB.PCI0.CTXS", gpio_num);
|
|
|
|
}
|