From patchwork Mon Jan 27 05:06:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 240222 List-Id: U-Boot discussion From: sjg at chromium.org (Simon Glass) Date: Sun, 26 Jan 2020 22:06:18 -0700 Subject: [PATCH 071/108] x86: acpi: Support external GNVS tables In-Reply-To: <20200127050655.170614-1-sjg@chromium.org> References: <20200127050655.170614-1-sjg@chromium.org> Message-ID: <20200126220508.71.Ic4e4767888256deed0503035fd4cc5c4d1060a62@changeid> At present U-Boot puts a magic number in the ASL for the GNVS table and searches for later. Add a Kconfig option to use a different approach, where the ASL files declare the table as an external symbol. U-Boot can then put it wherever it likes, without any magic numbers or searching. Signed-off-by: Simon Glass --- arch/x86/Kconfig | 7 ++++ arch/x86/cpu/apollolake/Kconfig | 1 + arch/x86/include/asm/acpi/global_nvs.h | 3 ++ arch/x86/lib/acpi_table.c | 47 ++++++++++++++------------ 4 files changed, 36 insertions(+), 22 deletions(-) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index c4a9a9f624..af44da1091 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -755,6 +755,13 @@ config GENERATE_ACPI_TABLE by the operating system. It defines platform-independent interfaces for configuration and power management monitoring. +config ACPI_GNVS_EXTERNAL + bool + help + Put the GNVS (Global Non-Volatile Sleeping) table separate from the + DSDT and add a pointer to the table from the DSDT. This allows + U-Boot to better control the address of the GNVS. + endmenu config HAVE_ACPI_RESUME diff --git a/arch/x86/cpu/apollolake/Kconfig b/arch/x86/cpu/apollolake/Kconfig index 2ae6837f75..c66863c52e 100644 --- a/arch/x86/cpu/apollolake/Kconfig +++ b/arch/x86/cpu/apollolake/Kconfig @@ -15,6 +15,7 @@ config INTEL_APOLLOLAKE select TPL_PCH_SUPPORT select PCH_SUPPORT select P2SB + select ACPI_GNVS_EXTERNAL imply ENABLE_MRC_CACHE imply AHCI_PCI imply SCSI diff --git a/arch/x86/include/asm/acpi/global_nvs.h b/arch/x86/include/asm/acpi/global_nvs.h index d56d35ca53..a552cf6374 100644 --- a/arch/x86/include/asm/acpi/global_nvs.h +++ b/arch/x86/include/asm/acpi/global_nvs.h @@ -11,6 +11,9 @@ * ACPI_GNVS_SIZE. They are to be used in platform's global_nvs.asl file * to declare the GNVS OperationRegion, as well as write_acpi_tables() * for the GNVS address runtime fix up. + * + * If using CONFIG_ACPI_GNVS_EXTERNAL, we don't need to locate the GNVS in + * DSDT, since it is created by code, so ACPI_GNVS_ADDR is unused. */ #define ACPI_GNVS_ADDR 0xdeadbeef #define ACPI_GNVS_SIZE 0x100 diff --git a/arch/x86/lib/acpi_table.c b/arch/x86/lib/acpi_table.c index 68e0779357..4c35111c48 100644 --- a/arch/x86/lib/acpi_table.c +++ b/arch/x86/lib/acpi_table.c @@ -437,31 +437,34 @@ ulong write_acpi_tables(ulong start_addr) } acpi_align(ctx); - /* Pack GNVS into the ACPI table area */ - for (i = 0; i < dsdt->length; i++) { - u32 *gnvs = (u32 *)((u32)dsdt + i); - if (*gnvs == ACPI_GNVS_ADDR) { - ulong addr = (ulong)map_to_sysmem(ctx->current); - - debug("Fix up global NVS in DSDT to %#08lx\n", addr); - *gnvs = addr; - break; + if (!IS_ENABLED(CONFIG_ACPI_GNVS_EXTERNAL)) { + /* Pack GNVS into the ACPI table area */ + for (i = 0; i < dsdt->length; i++) { + u32 *gnvs = (u32 *)((u32)dsdt + i); + + if (*gnvs == ACPI_GNVS_ADDR) { + *gnvs = map_to_sysmem(ctx->current); + debug("Fix up global NVS in DSDT to %#08x\n", + *gnvs); + break; + } } - } - - /* Update DSDT checksum since we patched the GNVS address */ - dsdt->checksum = 0; - dsdt->checksum = table_compute_checksum((void *)dsdt, dsdt->length); - /* - * Fill in platform-specific global NVS variables. If this fails we - * cannot return the error but this should only happen while debugging. - */ - addr = acpi_create_gnvs(ctx->current); - if (IS_ERR_VALUE(addr)) - printf("Error: Gailed to create GNVS\n"); + /* Update DSDT checksum since we patched the GNVS address */ + dsdt->checksum = 0; + dsdt->checksum = table_compute_checksum(dsdt, dsdt->length); - acpi_inc_align(ctx, sizeof(struct acpi_global_nvs)); + /* + * Fill in platform-specific global NVS variables. If this fails + * we cannot return the error but this should only happen while + * debugging. + */ + addr = acpi_create_gnvs(ctx->current); + if (IS_ERR_VALUE(addr)) + printf("Error: Gailed to create GNVS\n"); + acpi_create_gnvs(ctx->current); + acpi_inc_align(ctx, sizeof(struct acpi_global_nvs)); + } debug("ACPI: * FADT\n"); fadt = ctx->current;