diff options
author | Kyösti Mälkki <kyosti.malkki@gmail.com> | 2023-04-28 07:04:34 +0300 |
---|---|---|
committer | Kyösti Mälkki <kyosti.malkki@gmail.com> | 2023-08-08 06:51:03 +0000 |
commit | 88decca14f84184e95482d6b16c0791a70eae9ce (patch) | |
tree | c1bb745dbc263de44bba888071ef52d565f37a60 /src/acpi | |
parent | d99de5db5b9e46fd2595c0946cad9bb6da9b2b8d (diff) |
ACPI: Add helper fill_fadt_extended_pm_io()
Once platform code has filled in the (legacy) ACPI PM register
map, added function will fill in the extended entries in FADT.
TEST=samsung/lumpy and amd/mandolin FADT stays unchanged.
Change-Id: I90925fce35458cf5480bfefc7cdddebd41b42058
Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/74913
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Martin L Roth <gaumless@gmail.com>
Diffstat (limited to 'src/acpi')
-rw-r--r-- | src/acpi/Makefile.inc | 1 | ||||
-rw-r--r-- | src/acpi/fadt_filler.c | 72 |
2 files changed, 73 insertions, 0 deletions
diff --git a/src/acpi/Makefile.inc b/src/acpi/Makefile.inc index efa7e3bb4f..0c49e682ea 100644 --- a/src/acpi/Makefile.inc +++ b/src/acpi/Makefile.inc @@ -14,6 +14,7 @@ ramstage-$(CONFIG_ACPI_SOC_NVS) += gnvs.c ramstage-y += pld.c ramstage-y += sata.c ramstage-y += soundwire.c +ramstage-y += fadt_filler.c all-y += acpi_pm.c smm-y += acpi_pm.c diff --git a/src/acpi/fadt_filler.c b/src/acpi/fadt_filler.c new file mode 100644 index 0000000000..af65dbbadf --- /dev/null +++ b/src/acpi/fadt_filler.c @@ -0,0 +1,72 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include <acpi/acpi.h> +#include <console/console.h> +#include <stdint.h> + +static void fill_x_pm_io(acpi_addr_t *x_pm_blk, int access_size, uint16_t ioport, uint8_t len) +{ + x_pm_blk->space_id = ACPI_ADDRESS_SPACE_IO; + x_pm_blk->bit_width = len * 8; + x_pm_blk->bit_offset = 0; + x_pm_blk->access_size = access_size; + x_pm_blk->addrl = ioport; + x_pm_blk->addrh = 0x0; +} + +static void do_sanity_error(const char *func, const int line) +{ + printk(BIOS_ERR, "ACPI: FADT error detected, %s line %d.\n", func, line); +} + +#define fadt_sanity(x) do { if (!(x)) do_sanity_error(__func__, __LINE__); } while (0) + +void fill_fadt_extended_pm_io(acpi_fadt_t *fadt) +{ + fadt_sanity(fadt->pm1a_evt_blk && (fadt->pm1_evt_len >= 4)); + + /* Upper word is reserved and Linux complains about 32 bit. */ + fadt_sanity(fadt->pm1a_cnt_blk && (fadt->pm1_cnt_len == 2)); + + fill_x_pm_io(&fadt->x_pm1a_evt_blk, ACPI_ACCESS_SIZE_WORD_ACCESS, + fadt->pm1a_evt_blk, fadt->pm1_evt_len); + + fill_x_pm_io(&fadt->x_pm1a_cnt_blk, ACPI_ACCESS_SIZE_WORD_ACCESS, + fadt->pm1a_cnt_blk, fadt->pm1_cnt_len); + + if (fadt->pm1b_evt_blk) + fill_x_pm_io(&fadt->x_pm1b_evt_blk, ACPI_ACCESS_SIZE_WORD_ACCESS, + fadt->pm1b_evt_blk, fadt->pm1_evt_len); + + if (fadt->pm1b_cnt_blk) + fill_x_pm_io(&fadt->x_pm1b_cnt_blk, ACPI_ACCESS_SIZE_WORD_ACCESS, + fadt->pm1b_cnt_blk, fadt->pm1_cnt_len); + + if (fadt->pm_tmr_blk) { + fadt_sanity(fadt->pm_tmr_len == 4); + fill_x_pm_io(&fadt->x_pm_tmr_blk, ACPI_ACCESS_SIZE_DWORD_ACCESS, + fadt->pm_tmr_blk, fadt->pm_tmr_len); + } + + if (fadt->pm2_cnt_blk) + fill_x_pm_io(&fadt->x_pm2_cnt_blk, ACPI_ACCESS_SIZE_BYTE_ACCESS, + fadt->pm2_cnt_blk, fadt->pm2_cnt_len); + + /* + * Windows 10 requires x_gpe0_blk to be set starting with FADT revision 5. + * The bit_width field intentionally overflows here. + * The OSPM can instead use the values in `fadt->gpe0_blk{,_len}`, which + * seems to work fine on Linux 5.0 and Windows 10. + * + * FIXME: GPE1_BASE is not initialised. + * + */ + + if (fadt->gpe0_blk) + fill_x_pm_io(&fadt->x_gpe0_blk, ACPI_ACCESS_SIZE_BYTE_ACCESS, + fadt->gpe0_blk, fadt->gpe0_blk_len); + + if (fadt->gpe1_blk) + fill_x_pm_io(&fadt->x_gpe1_blk, ACPI_ACCESS_SIZE_BYTE_ACCESS, + fadt->gpe1_blk, fadt->gpe1_blk_len); +} |