diff options
author | Tom Rini <trini@konsulko.com> | 2022-02-10 17:02:06 +0300 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2022-02-10 17:19:44 +0300 |
commit | 2ccd2bc8c3580e00c51094c5cc2b3e2ead8d35c3 (patch) | |
tree | 4e7349b8831fee4b342a971025273d3cd042a2f9 /lib | |
parent | 6662e5e406fdee26ba981dd4af3308f51f254f0a (diff) | |
parent | f3078d4ea707931c2307a623ecf6e4d215b413d5 (diff) | |
download | u-boot-2ccd2bc8c3580e00c51094c5cc2b3e2ead8d35c3.tar.xz |
Merge tag 'dm-pull-8feb22-take3' of https://gitlab.denx.de/u-boot/custodians/u-boot-dm
patman snake-case conversion
binman fit improvements
ACPI fixes and making MCFG available to ARM
[trini: Update scripts/pylint.base]
Signed-off-by: Tom Rini <trini@konsulko.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/acpi/Makefile | 1 | ||||
-rw-r--r-- | lib/acpi/mcfg.c | 64 |
2 files changed, 65 insertions, 0 deletions
diff --git a/lib/acpi/Makefile b/lib/acpi/Makefile index f9b504988f..956b5a0d72 100644 --- a/lib/acpi/Makefile +++ b/lib/acpi/Makefile @@ -11,6 +11,7 @@ obj-y += acpi_writer.o ifndef CONFIG_QEMU obj-y += base.o obj-y += csrt.o +obj-y += mcfg.o # Sandbox does not build a .asl file ifndef CONFIG_SANDBOX diff --git a/lib/acpi/mcfg.c b/lib/acpi/mcfg.c new file mode 100644 index 0000000000..7404ae586a --- /dev/null +++ b/lib/acpi/mcfg.c @@ -0,0 +1,64 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Write an ACPI MCFG table + * + * Copyright 2022 Google LLC + */ + +#define LOG_CATEGORY LOGC_ACPI + +#include <common.h> +#include <mapmem.h> +#include <tables_csum.h> +#include <acpi/acpi_table.h> +#include <dm/acpi.h> + +int acpi_create_mcfg_mmconfig(struct acpi_mcfg_mmconfig *mmconfig, u32 base, + u16 seg_nr, u8 start, u8 end) +{ + memset(mmconfig, 0, sizeof(*mmconfig)); + mmconfig->base_address_l = base; + mmconfig->base_address_h = 0; + mmconfig->pci_segment_group_number = seg_nr; + mmconfig->start_bus_number = start; + mmconfig->end_bus_number = end; + + return sizeof(struct acpi_mcfg_mmconfig); +} + +__weak int acpi_fill_mcfg(struct acpi_ctx *ctx) +{ + return -ENOENT; +} + +/* MCFG is defined in the PCI Firmware Specification 3.0 */ +int acpi_write_mcfg(struct acpi_ctx *ctx, const struct acpi_writer *entry) +{ + struct acpi_table_header *header; + struct acpi_mcfg *mcfg; + int ret; + + mcfg = ctx->current; + header = &mcfg->header; + + memset(mcfg, '\0', sizeof(struct acpi_mcfg)); + + /* Fill out header fields */ + acpi_fill_header(header, "MCFG"); + header->length = sizeof(struct acpi_mcfg); + header->revision = 1; + acpi_inc(ctx, sizeof(*mcfg)); + + ret = acpi_fill_mcfg(ctx); + if (ret) + return log_msg_ret("fill", ret); + + /* (Re)calculate length and checksum */ + header->length = (ulong)ctx->current - (ulong)mcfg; + header->checksum = table_compute_checksum(mcfg, header->length); + + acpi_add_table(ctx, mcfg); + + return 0; +} +ACPI_WRITER(5mcfg, "MCFG", acpi_write_mcfg, 0); |