soc/intel/xeon_sp: Read ioapic configuration from hardware
This is more robust than hardcoding whathever FSP has set up and is a lot less code. Change-Id: I6423ddc139d742879d791b054ea082768749c0a7 Signed-off-by: Arthur Heymans <arthur@aheymans.xyz> Reviewed-on: https://review.coreboot.org/c/coreboot/+/70265 Reviewed-by: Jonathan Zhang <jonzhang@fb.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
parent
8a979d92c9
commit
8a3e2b8364
|
@ -73,34 +73,26 @@ static unsigned long acpi_madt_irq_overrides(unsigned long current)
|
||||||
return current;
|
return current;
|
||||||
}
|
}
|
||||||
|
|
||||||
__weak const struct madt_ioapic_info *soc_get_ioapic_info(size_t *entries)
|
static const uintptr_t default_ioapic_bases[] = { IO_APIC_ADDR };
|
||||||
|
|
||||||
|
__weak size_t soc_get_ioapic_info(const uintptr_t *ioapic_bases[])
|
||||||
{
|
{
|
||||||
*entries = 0;
|
*ioapic_bases = default_ioapic_bases;
|
||||||
return NULL;
|
return ARRAY_SIZE(default_ioapic_bases);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long acpi_fill_madt(unsigned long current)
|
unsigned long acpi_fill_madt(unsigned long current)
|
||||||
{
|
{
|
||||||
const struct madt_ioapic_info *ioapic_table;
|
const uintptr_t *ioapic_table;
|
||||||
size_t ioapic_entries;
|
size_t ioapic_entries;
|
||||||
|
|
||||||
/* Local APICs */
|
/* Local APICs */
|
||||||
current = acpi_create_madt_lapics_with_nmis(current);
|
current = acpi_create_madt_lapics_with_nmis(current);
|
||||||
|
|
||||||
/* IOAPIC */
|
/* IOAPIC */
|
||||||
ioapic_table = soc_get_ioapic_info(&ioapic_entries);
|
ioapic_entries = soc_get_ioapic_info(&ioapic_table);
|
||||||
if (ioapic_entries) {
|
for (int i = 0; i < ioapic_entries; i++)
|
||||||
for (int i = 0; i < ioapic_entries; i++) {
|
current += acpi_create_madt_ioapic_from_hw((void *)current, ioapic_table[i]);
|
||||||
current += acpi_create_madt_ioapic(
|
|
||||||
(void *)current,
|
|
||||||
ioapic_table[i].id,
|
|
||||||
ioapic_table[i].addr,
|
|
||||||
ioapic_table[i].gsi_base);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
/* Default SOC IOAPIC entry */
|
|
||||||
current += acpi_create_madt_ioapic_from_hw((void *)current, IO_APIC_ADDR);
|
|
||||||
}
|
|
||||||
|
|
||||||
return acpi_madt_irq_overrides(current);
|
return acpi_madt_irq_overrides(current);
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,17 +93,11 @@ void soc_power_states_generation(int core_id, int cores_per_package);
|
||||||
*/
|
*/
|
||||||
int common_calculate_power_ratio(int tdp, int p1_ratio, int ratio);
|
int common_calculate_power_ratio(int tdp, int p1_ratio, int ratio);
|
||||||
|
|
||||||
struct madt_ioapic_info {
|
|
||||||
u8 id;
|
|
||||||
u32 addr;
|
|
||||||
u32 gsi_base;
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Returns a table of MADT ioapic_info entries and the number of entries
|
* Return the number of table entries and takes a pointer to an array of ioapic bases.
|
||||||
* If the SOC doesn't implement this hook a default ioapic setting is used.
|
|
||||||
*/
|
*/
|
||||||
const struct madt_ioapic_info *soc_get_ioapic_info(size_t *entries);
|
size_t soc_get_ioapic_info(const uintptr_t *ioapic_bases[]);
|
||||||
|
|
||||||
struct soc_pmc_lpm {
|
struct soc_pmc_lpm {
|
||||||
unsigned int num_substates;
|
unsigned int num_substates;
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include <intelblocks/acpi.h>
|
#include <intelblocks/acpi.h>
|
||||||
#include <soc/pci_devs.h>
|
#include <soc/pci_devs.h>
|
||||||
#include <soc/util.h>
|
#include <soc/util.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
#include "chip.h"
|
#include "chip.h"
|
||||||
|
|
||||||
|
@ -87,42 +88,14 @@ const acpi_cstate_t *soc_get_cstate_map(size_t *entries)
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void print_madt_ioapic(int socket, int stack,
|
static uintptr_t xeonsp_ioapic_bases[CONFIG(XEON_SP_HAVE_IIO_IOAPIC) * 8 + 1];
|
||||||
int ioapic_id, uint32_t ioapic_base, int gsi_base)
|
|
||||||
{
|
|
||||||
printk(BIOS_DEBUG, "Adding MADT IOAPIC for socket: %d, stack: %d, ioapic_id: 0x%x, "
|
|
||||||
"ioapic_base: 0x%x, gsi_base: 0x%x\n",
|
|
||||||
socket, stack, ioapic_id, ioapic_base, gsi_base);
|
|
||||||
}
|
|
||||||
|
|
||||||
const struct madt_ioapic_info *soc_get_ioapic_info(size_t *entries)
|
size_t soc_get_ioapic_info(const uintptr_t *ioapic_bases[])
|
||||||
{
|
{
|
||||||
int cur_index;
|
int index = 0;
|
||||||
int gsi_per_iiostack = 0;
|
|
||||||
|
|
||||||
const IIO_UDS *hob = get_iio_uds();
|
const IIO_UDS *hob = get_iio_uds();
|
||||||
|
|
||||||
uint8_t gsi_bases[CONFIG(XEON_SP_HAVE_IIO_IOAPIC) * 8 + 1] = { 0 };
|
*ioapic_bases = xeonsp_ioapic_bases;
|
||||||
|
|
||||||
for (uint8_t i = 1; i < sizeof(gsi_bases); i++) {
|
|
||||||
int gsi_base = CONFIG_XEON_SP_PCH_IOAPIC_GSI_BASES;
|
|
||||||
gsi_bases[i] = gsi_base + (i * gsi_per_iiostack);
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct madt_ioapic_info madt_tbl[ARRAY_SIZE(gsi_bases)];
|
|
||||||
|
|
||||||
cur_index = 0;
|
|
||||||
madt_tbl[cur_index].id = PCH_IOAPIC_ID;
|
|
||||||
madt_tbl[cur_index].addr = hob->PlatformData.IIO_resource[0].StackRes[0].IoApicBase;
|
|
||||||
madt_tbl[cur_index].gsi_base = gsi_bases[cur_index];
|
|
||||||
print_madt_ioapic(0, 0, madt_tbl[cur_index].id,
|
|
||||||
madt_tbl[cur_index].addr, madt_tbl[cur_index].gsi_base);
|
|
||||||
++cur_index;
|
|
||||||
|
|
||||||
if (!CONFIG(XEON_SP_HAVE_IIO_IOAPIC)) {
|
|
||||||
*entries = cur_index;
|
|
||||||
return madt_tbl;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int socket = 0; socket < hob->PlatformData.numofIIO; ++socket) {
|
for (int socket = 0; socket < hob->PlatformData.numofIIO; ++socket) {
|
||||||
for (int stack = 0; stack < MAX_IIO_STACK; ++stack) {
|
for (int stack = 0; stack < MAX_IIO_STACK; ++stack) {
|
||||||
|
@ -130,25 +103,22 @@ const struct madt_ioapic_info *soc_get_ioapic_info(size_t *entries)
|
||||||
&hob->PlatformData.IIO_resource[socket].StackRes[stack];
|
&hob->PlatformData.IIO_resource[socket].StackRes[stack];
|
||||||
if (!is_iio_stack_res(ri))
|
if (!is_iio_stack_res(ri))
|
||||||
continue;
|
continue;
|
||||||
assert(cur_index < ARRAY_SIZE(gsi_bases));
|
uint32_t ioapic_base = ri->IoApicBase;
|
||||||
madt_tbl[cur_index].id = soc_get_iio_ioapicid(socket, stack);
|
assert(index < ARRAY_SIZE(xeonsp_ioapic_bases));
|
||||||
madt_tbl[cur_index].gsi_base = gsi_bases[cur_index];
|
xeonsp_ioapic_bases[index++] = ioapic_base;
|
||||||
madt_tbl[cur_index].addr = ri->IoApicBase;
|
if (!CONFIG(XEON_SP_HAVE_IIO_IOAPIC))
|
||||||
|
return index;
|
||||||
/*
|
/*
|
||||||
* Stack 0 has non-PCH IOAPIC and PCH IOAPIC.
|
* Stack 0 has non-PCH IOAPIC and PCH IOAPIC.
|
||||||
* The IIO IOAPIC is placed at 0x1000 from the reported base.
|
* The IIO IOAPIC is placed at 0x1000 from the reported base.
|
||||||
*/
|
*/
|
||||||
if (stack == 0 && socket == 0)
|
if (socket == 0 && stack == 0) {
|
||||||
madt_tbl[cur_index].addr += 0x1000;
|
ioapic_base += 0x1000;
|
||||||
|
assert(index < ARRAY_SIZE(xeonsp_ioapic_bases));
|
||||||
print_madt_ioapic(socket, stack, madt_tbl[cur_index].id,
|
xeonsp_ioapic_bases[index++] = ioapic_base;
|
||||||
madt_tbl[cur_index].addr,
|
}
|
||||||
madt_tbl[cur_index].gsi_base);
|
|
||||||
++cur_index;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*entries = cur_index;
|
return index;
|
||||||
return madt_tbl;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,10 +112,6 @@ config XEON_SP_HAVE_IIO_IOAPIC
|
||||||
bool
|
bool
|
||||||
default y
|
default y
|
||||||
|
|
||||||
config XEON_SP_PCH_IOAPIC_GSI_BASES
|
|
||||||
hex
|
|
||||||
default 0x78
|
|
||||||
|
|
||||||
if INTEL_TXT
|
if INTEL_TXT
|
||||||
|
|
||||||
config INTEL_TXT_SINIT_SIZE
|
config INTEL_TXT_SINIT_SIZE
|
||||||
|
|
|
@ -63,8 +63,4 @@ config XEON_SP_HAVE_IIO_IOAPIC
|
||||||
bool
|
bool
|
||||||
default y
|
default y
|
||||||
|
|
||||||
config XEON_SP_PCH_IOAPIC_GSI_BASES
|
|
||||||
hex
|
|
||||||
default 0x18
|
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
Loading…
Reference in New Issue