]> Git Repo - J-u-boot.git/blame - lib/acpi/mcfg.c
Merge branch 'master' of https://source.denx.de/u-boot/custodians/u-boot-samsung
[J-u-boot.git] / lib / acpi / mcfg.c
CommitLineData
058fb9f5
MF
1// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Write an ACPI MCFG table
4 *
5 * Copyright 2022 Google LLC
6 */
7
8#define LOG_CATEGORY LOGC_ACPI
9
058fb9f5
MF
10#include <mapmem.h>
11#include <tables_csum.h>
12#include <acpi/acpi_table.h>
13#include <dm/acpi.h>
467382ca
TR
14#include <linux/errno.h>
15#include <linux/string.h>
16#include <linux/types.h>
058fb9f5
MF
17
18int acpi_create_mcfg_mmconfig(struct acpi_mcfg_mmconfig *mmconfig, u32 base,
19 u16 seg_nr, u8 start, u8 end)
20{
21 memset(mmconfig, 0, sizeof(*mmconfig));
22 mmconfig->base_address_l = base;
23 mmconfig->base_address_h = 0;
24 mmconfig->pci_segment_group_number = seg_nr;
25 mmconfig->start_bus_number = start;
26 mmconfig->end_bus_number = end;
27
28 return sizeof(struct acpi_mcfg_mmconfig);
29}
30
31__weak int acpi_fill_mcfg(struct acpi_ctx *ctx)
32{
33 return -ENOENT;
34}
35
36/* MCFG is defined in the PCI Firmware Specification 3.0 */
37int acpi_write_mcfg(struct acpi_ctx *ctx, const struct acpi_writer *entry)
38{
39 struct acpi_table_header *header;
40 struct acpi_mcfg *mcfg;
41 int ret;
42
43 mcfg = ctx->current;
44 header = &mcfg->header;
45
46 memset(mcfg, '\0', sizeof(struct acpi_mcfg));
47
48 /* Fill out header fields */
49 acpi_fill_header(header, "MCFG");
50 header->length = sizeof(struct acpi_mcfg);
51 header->revision = 1;
52 acpi_inc(ctx, sizeof(*mcfg));
53
54 ret = acpi_fill_mcfg(ctx);
55 if (ret)
56 return log_msg_ret("fill", ret);
57
58 /* (Re)calculate length and checksum */
59 header->length = (ulong)ctx->current - (ulong)mcfg;
60 header->checksum = table_compute_checksum(mcfg, header->length);
61
62 acpi_add_table(ctx, mcfg);
63
64 return 0;
65}
66ACPI_WRITER(5mcfg, "MCFG", acpi_write_mcfg, 0);
This page took 0.076753 seconds and 4 git commands to generate.