Arthur Heymans has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/76128?usp=email )
Change subject: acpi: Move HPET generation to a common location ......................................................................
acpi: Move HPET generation to a common location
HPET is usually a feature of the hardware that needs to no runtime to check whether it is present or it is typically unconditionally enabled. This means a simple Kconfig option to generate the ACPI tables is suffices, which allows reduction of boilerplate.
Signed-off-by: Arthur Heymans arthur@aheymans.xyz Change-Id: I38b9962a8d568267356256a3edc51348b9417e20 --- M src/acpi/Kconfig M src/acpi/acpi.c M src/include/acpi/acpi.h M src/soc/amd/common/block/acpi/Kconfig M src/soc/amd/common/block/acpi/Makefile.inc D src/soc/amd/common/block/acpi/tables.c M src/soc/intel/baytrail/Kconfig M src/soc/intel/baytrail/southcluster.c M src/soc/intel/braswell/Kconfig M src/soc/intel/braswell/acpi.c M src/soc/intel/broadwell/pch/Kconfig M src/soc/intel/broadwell/pch/lpc.c M src/soc/intel/common/block/acpi/Kconfig M src/soc/intel/common/block/acpi/acpi.c M src/soc/intel/common/block/include/intelblocks/lpc_lib.h M src/soc/intel/denverton_ns/Kconfig M src/soc/intel/denverton_ns/acpi.c M src/southbridge/amd/pi/hudson/Kconfig M src/southbridge/amd/pi/hudson/lpc.c M src/southbridge/intel/bd82x6x/Kconfig M src/southbridge/intel/bd82x6x/lpc.c M src/southbridge/intel/i82371eb/Kconfig M src/southbridge/intel/i82371eb/isa.c M src/southbridge/intel/i82801gx/Kconfig M src/southbridge/intel/i82801gx/lpc.c M src/southbridge/intel/i82801ix/Kconfig M src/southbridge/intel/i82801ix/lpc.c M src/southbridge/intel/i82801jx/Kconfig M src/southbridge/intel/i82801jx/lpc.c M src/southbridge/intel/ibexpeak/Kconfig M src/southbridge/intel/ibexpeak/lpc.c M src/southbridge/intel/lynxpoint/Kconfig M src/southbridge/intel/lynxpoint/lpc.c 33 files changed, 31 insertions(+), 73 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/28/76128/1
diff --git a/src/acpi/Kconfig b/src/acpi/Kconfig index a45a68c..a766319 100644 --- a/src/acpi/Kconfig +++ b/src/acpi/Kconfig @@ -68,3 +68,10 @@ depends on HAVE_ACPI_TABLES help Selected by platforms that support and fill Intel Low Power Idle Table. + +config ACPI_HPET + bool + default n + depends on HAVE_ACPI_TABLES + help + Select this on platforms that feature a HPET. diff --git a/src/acpi/acpi.c b/src/acpi/acpi.c index 5a571d7..f3fe232 100644 --- a/src/acpi/acpi.c +++ b/src/acpi/acpi.c @@ -1034,12 +1034,13 @@ }
/* http://www.intel.com/hardwaredesign/hpetspec_1.pdf */ -static void acpi_create_hpet(acpi_hpet_t *hpet) +static void acpi_create_hpet(acpi_header_t *header, void *arg) { - acpi_header_t *header = &(hpet->header); - acpi_addr_t *addr = &(hpet->addr); + if (!CONFIG(ACPI_HPET)) + return;
- memset((void *)hpet, 0, sizeof(acpi_hpet_t)); + acpi_hpet_t *hpet = (acpi_hpet_t *)header; + acpi_addr_t *addr = &(hpet->addr);
if (!header) return; @@ -1064,8 +1065,6 @@ hpet->id = read32p(HPET_BASE_ADDRESS); hpet->number = 0; hpet->min_tick = CONFIG_HPET_MIN_TICKS; - - header->checksum = acpi_checksum((void *)hpet, sizeof(acpi_hpet_t)); }
/* @@ -1356,25 +1355,6 @@ header->checksum = acpi_checksum((void *)crat, header->length); }
-unsigned long acpi_write_hpet(const struct device *device, unsigned long current, - acpi_rsdp_t *rsdp) -{ - acpi_hpet_t *hpet; - - /* - * We explicitly add these tables later on: - */ - printk(BIOS_DEBUG, "ACPI: * HPET\n"); - - hpet = (acpi_hpet_t *)current; - current += sizeof(acpi_hpet_t); - current = ALIGN_UP(current, 16); - acpi_create_hpet(hpet); - acpi_add_table(rsdp, hpet); - - return current; -} - static void acpi_create_dbg2(acpi_dbg2_header_t *dbg2, int port_type, int port_subtype, acpi_addr_t *address, uint32_t address_size, @@ -1927,6 +1907,7 @@ { acpi_create_lpit, NULL, sizeof(acpi_lpit_t) }, { acpi_create_madt, NULL, sizeof(acpi_header_t) }, { acpi_create_bert, NULL, sizeof(acpi_bert_t) }, + { acpi_create_hpet, NULL, sizeof(acpi_hpet_t) }, };
current = start; diff --git a/src/include/acpi/acpi.h b/src/include/acpi/acpi.h index d3f209a..3b953e0 100644 --- a/src/include/acpi/acpi.h +++ b/src/include/acpi/acpi.h @@ -1418,9 +1418,6 @@ unsigned long (*acpi_fill_crat)(struct acpi_crat_header *crat_struct, unsigned long current));
-unsigned long acpi_write_hpet(const struct device *device, unsigned long start, - acpi_rsdp_t *rsdp); - /* cpu/intel/speedstep/acpi.c */ void generate_cpu_entries(const struct device *device);
diff --git a/src/soc/amd/common/block/acpi/Kconfig b/src/soc/amd/common/block/acpi/Kconfig index 9355f7d..df4f61b 100644 --- a/src/soc/amd/common/block/acpi/Kconfig +++ b/src/soc/amd/common/block/acpi/Kconfig @@ -5,6 +5,7 @@ select ACPI_COMMON_MADT_IOAPIC select ACPI_COMMON_MADT_LAPIC select ACPI_CUSTOM_MADT + select ACPI_HPET help Select this option to use the AcpiMmio ACPI registers.
diff --git a/src/soc/amd/common/block/acpi/Makefile.inc b/src/soc/amd/common/block/acpi/Makefile.inc index a0d9290..a9688a7 100644 --- a/src/soc/amd/common/block/acpi/Makefile.inc +++ b/src/soc/amd/common/block/acpi/Makefile.inc @@ -5,7 +5,6 @@ smm-y += acpi.c
ramstage-y += pm_state.c -ramstage-y += tables.c ramstage-$(CONFIG_ACPI_BERT) += bert.c ramstage-$(CONFIG_SOC_AMD_COMMON_BLOCK_ACPI_ALIB) += alib.c ramstage-$(CONFIG_SOC_AMD_COMMON_BLOCK_ACPI_CPPC) += cppc.c diff --git a/src/soc/amd/common/block/acpi/tables.c b/src/soc/amd/common/block/acpi/tables.c deleted file mode 100644 index bda283a..0000000 --- a/src/soc/amd/common/block/acpi/tables.c +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ - -#include <acpi/acpi.h> -#include <acpi/acpigen.h> -#include <amdblocks/acpi.h> -#include <device/device.h> -#include <types.h> - -unsigned long southbridge_write_acpi_tables(const struct device *device, - unsigned long current, - struct acpi_rsdp *rsdp) -{ - return acpi_write_hpet(device, current, rsdp); -} diff --git a/src/soc/intel/baytrail/Kconfig b/src/soc/intel/baytrail/Kconfig index 958af34..7e5267e 100644 --- a/src/soc/intel/baytrail/Kconfig +++ b/src/soc/intel/baytrail/Kconfig @@ -9,6 +9,7 @@ def_bool y select ACPI_COMMON_MADT_IOAPIC select ACPI_COMMON_MADT_LAPIC + select ACPI_HPET select ACPI_INTEL_HARDWARE_SLEEP_VALUES select ARCH_X86 select BOOT_DEVICE_SPI_FLASH_NO_EARLY_WRITES diff --git a/src/soc/intel/baytrail/southcluster.c b/src/soc/intel/baytrail/southcluster.c index 1afea59..8beee73 100644 --- a/src/soc/intel/baytrail/southcluster.c +++ b/src/soc/intel/baytrail/southcluster.c @@ -476,7 +476,6 @@ static struct device_operations device_ops = { .read_resources = sc_read_resources, .set_resources = pci_dev_set_resources, - .write_acpi_tables = acpi_write_hpet, .init = sc_init, .enable = southcluster_enable_dev, .scan_bus = scan_static_bus, diff --git a/src/soc/intel/braswell/Kconfig b/src/soc/intel/braswell/Kconfig index f618118..a48397d 100644 --- a/src/soc/intel/braswell/Kconfig +++ b/src/soc/intel/braswell/Kconfig @@ -115,6 +115,9 @@ Enable this to disable the HPET support Solves the Linux MP-BIOS bug timer not connected.
+config ACPI_HPET + default y if !DISABLE_HPET + config USE_GOOGLE_FSP bool help diff --git a/src/soc/intel/braswell/acpi.c b/src/soc/intel/braswell/acpi.c index a278e55..6423ebe 100644 --- a/src/soc/intel/braswell/acpi.c +++ b/src/soc/intel/braswell/acpi.c @@ -321,14 +321,7 @@ unsigned long southcluster_write_acpi_tables(const struct device *device, unsigned long current, struct acpi_rsdp *rsdp) { - acpi_header_t *ssdt2; - - if (!CONFIG(DISABLE_HPET)) { - current = acpi_write_hpet(device, current, rsdp); - current = acpi_align_current(current); - } - - ssdt2 = (acpi_header_t *)current; + acpi_header_t *ssdt2 = (acpi_header_t *)current; memset(ssdt2, 0, sizeof(acpi_header_t)); acpi_create_serialio_ssdt(ssdt2); if (ssdt2->length) { diff --git a/src/soc/intel/broadwell/pch/Kconfig b/src/soc/intel/broadwell/pch/Kconfig index bd1bea5..90aa02b 100644 --- a/src/soc/intel/broadwell/pch/Kconfig +++ b/src/soc/intel/broadwell/pch/Kconfig @@ -6,6 +6,7 @@ def_bool y select ACPI_COMMON_MADT_IOAPIC select ACPI_COMMON_MADT_LAPIC + select ACPI_HPET select ACPI_INTEL_HARDWARE_SLEEP_VALUES select ACPI_SOC_NVS select AZALIA_PLUGIN_SUPPORT diff --git a/src/soc/intel/broadwell/pch/lpc.c b/src/soc/intel/broadwell/pch/lpc.c index 9aaca21..c568f90 100644 --- a/src/soc/intel/broadwell/pch/lpc.c +++ b/src/soc/intel/broadwell/pch/lpc.c @@ -605,7 +605,6 @@ PCH_DEV_UART1 : PCH_DEV_UART0, ACPI_ACCESS_SIZE_DWORD_ACCESS); } - return acpi_write_hpet(device, current, rsdp); }
static struct device_operations device_ops = { diff --git a/src/soc/intel/common/block/acpi/Kconfig b/src/soc/intel/common/block/acpi/Kconfig index c750e7e..0264140 100644 --- a/src/soc/intel/common/block/acpi/Kconfig +++ b/src/soc/intel/common/block/acpi/Kconfig @@ -4,6 +4,7 @@ select ACPI_COMMON_MADT_IOAPIC select ACPI_COMMON_MADT_LAPIC if !SOC_INTEL_COMMON_BLOCK_ACPI_CPU_HYBRID select ACPI_CUSTOM_MADT + select ACPI_HPET bool help Intel Processor common code for ACPI diff --git a/src/soc/intel/common/block/acpi/acpi.c b/src/soc/intel/common/block/acpi/acpi.c index 2c27b15..6886063 100644 --- a/src/soc/intel/common/block/acpi/acpi.c +++ b/src/soc/intel/common/block/acpi/acpi.c @@ -150,8 +150,6 @@ uart_get_device(), ACPI_ACCESS_SIZE_DWORD_ACCESS); } - - return acpi_write_hpet(device, current, rsdp); }
__weak diff --git a/src/soc/intel/common/block/include/intelblocks/lpc_lib.h b/src/soc/intel/common/block/include/intelblocks/lpc_lib.h index 0c4780b..a4d5704 100644 --- a/src/soc/intel/common/block/include/intelblocks/lpc_lib.h +++ b/src/soc/intel/common/block/include/intelblocks/lpc_lib.h @@ -94,7 +94,7 @@ */ void pch_misc_init(void); /* - * Calls acpi_write_hpet which creates and fills HPET table and + * Calls acpi_write_dbg2_pci_uart which created DBG2 table and * adds it to the RSDT (and XSDT) structure. */ unsigned long southbridge_write_acpi_tables(const struct device *device, diff --git a/src/soc/intel/denverton_ns/Kconfig b/src/soc/intel/denverton_ns/Kconfig index dcf9a5f..080ec26 100644 --- a/src/soc/intel/denverton_ns/Kconfig +++ b/src/soc/intel/denverton_ns/Kconfig @@ -35,6 +35,7 @@ select SOC_INTEL_COMMON_BLOCK_ACPI select SOC_INTEL_COMMON_BLOCK_PMC select ACPI_INTEL_HARDWARE_SLEEP_VALUES + select ACPI_HPET select SOC_INTEL_COMMON_BLOCK_SPI select SOC_INTEL_COMMON_BLOCK_FAST_SPI select SOC_INTEL_COMMON_BLOCK_GPIO diff --git a/src/soc/intel/denverton_ns/acpi.c b/src/soc/intel/denverton_ns/acpi.c index 6ddcc08..feb6d6f 100644 --- a/src/soc/intel/denverton_ns/acpi.c +++ b/src/soc/intel/denverton_ns/acpi.c @@ -152,7 +152,6 @@ { acpi_header_t *ssdt2;
- current = acpi_write_hpet(device, current, rsdp); current = (ALIGN_UP(current, 16));
ssdt2 = (acpi_header_t *)current; diff --git a/src/southbridge/amd/pi/hudson/Kconfig b/src/southbridge/amd/pi/hudson/Kconfig index 6a3d61d..b0873da 100644 --- a/src/southbridge/amd/pi/hudson/Kconfig +++ b/src/southbridge/amd/pi/hudson/Kconfig @@ -13,6 +13,7 @@ select ACPI_COMMON_MADT_IOAPIC select ACPI_COMMON_MADT_LAPIC select ACPI_CUSTOM_MADT + select ACPI_HPET select HAVE_USBDEBUG_OPTIONS select HAVE_CF9_RESET select HAVE_CF9_RESET_PREPARE diff --git a/src/southbridge/amd/pi/hudson/lpc.c b/src/southbridge/amd/pi/hudson/lpc.c index 0a4e038..821f6b1 100644 --- a/src/southbridge/amd/pi/hudson/lpc.c +++ b/src/southbridge/amd/pi/hudson/lpc.c @@ -342,9 +342,6 @@ .read_resources = hudson_lpc_read_resources, .set_resources = hudson_lpc_set_resources, .enable_resources = hudson_lpc_enable_resources, -#if CONFIG(HAVE_ACPI_TABLES) - .write_acpi_tables = acpi_write_hpet, -#endif .init = lpc_init, .final = lpc_final, .scan_bus = scan_static_bus, diff --git a/src/southbridge/intel/bd82x6x/Kconfig b/src/southbridge/intel/bd82x6x/Kconfig index 5ba913d..b5aa4d7 100644 --- a/src/southbridge/intel/bd82x6x/Kconfig +++ b/src/southbridge/intel/bd82x6x/Kconfig @@ -12,6 +12,7 @@ def_bool y select ACPI_COMMON_MADT_IOAPIC select ACPI_COMMON_MADT_LAPIC + select ACPI_HPET select ACPI_INTEL_HARDWARE_SLEEP_VALUES select ACPI_SOC_NVS select AZALIA_PLUGIN_SUPPORT diff --git a/src/southbridge/intel/bd82x6x/lpc.c b/src/southbridge/intel/bd82x6x/lpc.c index 0cf7b9c..cc168b7 100644 --- a/src/southbridge/intel/bd82x6x/lpc.c +++ b/src/southbridge/intel/bd82x6x/lpc.c @@ -662,7 +662,6 @@ .read_resources = pch_lpc_read_resources, .set_resources = pci_dev_set_resources, .enable_resources = pci_dev_enable_resources, - .write_acpi_tables = acpi_write_hpet, .acpi_fill_ssdt = southbridge_fill_ssdt, .acpi_name = lpc_acpi_name, .init = lpc_init, diff --git a/src/southbridge/intel/i82371eb/Kconfig b/src/southbridge/intel/i82371eb/Kconfig index 3f84668..33384fc 100644 --- a/src/southbridge/intel/i82371eb/Kconfig +++ b/src/southbridge/intel/i82371eb/Kconfig @@ -1,6 +1,7 @@ config SOUTHBRIDGE_INTEL_I82371EB select ACPI_COMMON_MADT_IOAPIC if SMP select ACPI_COMMON_MADT_LAPIC if SMP + select ACPI_HPET select ACPI_NO_CUSTOM_MADT select ACPI_INTEL_HARDWARE_SLEEP_VALUES select SOUTHBRIDGE_INTEL_COMMON_SMBUS diff --git a/src/southbridge/intel/i82371eb/isa.c b/src/southbridge/intel/i82371eb/isa.c index 7d86e8a..ad31139 100644 --- a/src/southbridge/intel/i82371eb/isa.c +++ b/src/southbridge/intel/i82371eb/isa.c @@ -106,7 +106,6 @@ .set_resources = pci_dev_set_resources, .enable_resources = pci_dev_enable_resources, #if CONFIG(HAVE_ACPI_TABLES) - .write_acpi_tables = acpi_write_hpet, .acpi_fill_ssdt = generate_cpu_entries, #endif .init = isa_init, diff --git a/src/southbridge/intel/i82801gx/Kconfig b/src/southbridge/intel/i82801gx/Kconfig index 2467e39..c7414e6 100644 --- a/src/southbridge/intel/i82801gx/Kconfig +++ b/src/southbridge/intel/i82801gx/Kconfig @@ -4,6 +4,7 @@ bool select ACPI_COMMON_MADT_IOAPIC select ACPI_COMMON_MADT_LAPIC + select ACPI_HPET select ACPI_INTEL_HARDWARE_SLEEP_VALUES select ACPI_SOC_NVS select AZALIA_PLUGIN_SUPPORT diff --git a/src/southbridge/intel/i82801gx/lpc.c b/src/southbridge/intel/i82801gx/lpc.c index 28cde3e..cff84a8 100644 --- a/src/southbridge/intel/i82801gx/lpc.c +++ b/src/southbridge/intel/i82801gx/lpc.c @@ -433,7 +433,6 @@ .read_resources = i82801gx_lpc_read_resources, .set_resources = pci_dev_set_resources, .enable_resources = pci_dev_enable_resources, - .write_acpi_tables = acpi_write_hpet, .acpi_fill_ssdt = southbridge_fill_ssdt, .acpi_name = lpc_acpi_name, .init = lpc_init, diff --git a/src/southbridge/intel/i82801ix/Kconfig b/src/southbridge/intel/i82801ix/Kconfig index fb33474..97b4358 100644 --- a/src/southbridge/intel/i82801ix/Kconfig +++ b/src/southbridge/intel/i82801ix/Kconfig @@ -4,6 +4,7 @@ bool select ACPI_COMMON_MADT_IOAPIC select ACPI_COMMON_MADT_LAPIC + select ACPI_HPET select ACPI_INTEL_HARDWARE_SLEEP_VALUES select ACPI_SOC_NVS select AZALIA_PLUGIN_SUPPORT diff --git a/src/southbridge/intel/i82801ix/lpc.c b/src/southbridge/intel/i82801ix/lpc.c index d897130..eabcf1c 100644 --- a/src/southbridge/intel/i82801ix/lpc.c +++ b/src/southbridge/intel/i82801ix/lpc.c @@ -465,7 +465,6 @@ .read_resources = i82801ix_lpc_read_resources, .set_resources = pci_dev_set_resources, .enable_resources = pci_dev_enable_resources, - .write_acpi_tables = acpi_write_hpet, .acpi_fill_ssdt = southbridge_fill_ssdt, .acpi_name = lpc_acpi_name, .init = lpc_init, diff --git a/src/southbridge/intel/i82801jx/Kconfig b/src/southbridge/intel/i82801jx/Kconfig index 3f0ab10..5a132ef 100644 --- a/src/southbridge/intel/i82801jx/Kconfig +++ b/src/southbridge/intel/i82801jx/Kconfig @@ -4,6 +4,7 @@ bool select ACPI_COMMON_MADT_IOAPIC select ACPI_COMMON_MADT_LAPIC + select ACPI_HPET select ACPI_INTEL_HARDWARE_SLEEP_VALUES select AZALIA_PLUGIN_SUPPORT select HAVE_POWER_STATE_AFTER_FAILURE diff --git a/src/southbridge/intel/i82801jx/lpc.c b/src/southbridge/intel/i82801jx/lpc.c index e93502f..7810d2d 100644 --- a/src/southbridge/intel/i82801jx/lpc.c +++ b/src/southbridge/intel/i82801jx/lpc.c @@ -468,7 +468,6 @@ .read_resources = i82801jx_lpc_read_resources, .set_resources = pci_dev_set_resources, .enable_resources = pci_dev_enable_resources, - .write_acpi_tables = acpi_write_hpet, .acpi_fill_ssdt = southbridge_fill_ssdt, .acpi_name = lpc_acpi_name, .init = lpc_init, diff --git a/src/southbridge/intel/ibexpeak/Kconfig b/src/southbridge/intel/ibexpeak/Kconfig index adc3842..e6d16c3 100644 --- a/src/southbridge/intel/ibexpeak/Kconfig +++ b/src/southbridge/intel/ibexpeak/Kconfig @@ -9,6 +9,7 @@ def_bool y select ACPI_COMMON_MADT_IOAPIC select ACPI_COMMON_MADT_LAPIC + select ACPI_HPET select ACPI_INTEL_HARDWARE_SLEEP_VALUES select AZALIA_PLUGIN_SUPPORT select HAVE_SMI_HANDLER diff --git a/src/southbridge/intel/ibexpeak/lpc.c b/src/southbridge/intel/ibexpeak/lpc.c index 7d85883..cee8871 100644 --- a/src/southbridge/intel/ibexpeak/lpc.c +++ b/src/southbridge/intel/ibexpeak/lpc.c @@ -538,7 +538,6 @@ .enable_resources = pci_dev_enable_resources, .acpi_fill_ssdt = southbridge_fill_ssdt, .acpi_name = lpc_acpi_name, - .write_acpi_tables = acpi_write_hpet, .init = lpc_init, .final = lpc_final, .enable = pch_lpc_enable, diff --git a/src/southbridge/intel/lynxpoint/Kconfig b/src/southbridge/intel/lynxpoint/Kconfig index 0804298..a7109b7 100644 --- a/src/southbridge/intel/lynxpoint/Kconfig +++ b/src/southbridge/intel/lynxpoint/Kconfig @@ -9,6 +9,7 @@ def_bool y select ACPI_COMMON_MADT_IOAPIC select ACPI_COMMON_MADT_LAPIC + select ACPI_HPET select ACPI_INTEL_HARDWARE_SLEEP_VALUES select ACPI_SOC_NVS select AZALIA_PLUGIN_SUPPORT diff --git a/src/southbridge/intel/lynxpoint/lpc.c b/src/southbridge/intel/lynxpoint/lpc.c index e44d9a8..67f1e54 100644 --- a/src/southbridge/intel/lynxpoint/lpc.c +++ b/src/southbridge/intel/lynxpoint/lpc.c @@ -768,13 +768,6 @@ /* Align ACPI tables to 16byte */ current = acpi_align_current(current);
- /* - * We explicitly add these tables later on: - */ - current = acpi_write_hpet(device, current, rsdp); - - current = acpi_align_current(current); - if (pch_is_lp()) { printk(BIOS_DEBUG, "ACPI: * SSDT2\n"); acpi_header_t *ssdt = (acpi_header_t *)current;