All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Glass <sjg@chromium.org>
To: u-boot@lists.denx.de
Subject: [PATCH v2 31/57] x86: acpi: Add support for additional Intel tables
Date: Sat, 29 Aug 2020 17:31:50 -0600	[thread overview]
Message-ID: <20200829173153.v2.31.I8aa77aa9037dc3d08929270b114eac2f8fc9daa3@changeid> (raw)
In-Reply-To: <20200829233217.3821412-1-sjg@chromium.org>

Apollo Lake needs to generate a few more table types used on Intel SoCs.
Add support for these into the x86 ACPI code.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

Changes in v1:
- Move this code into an x86-specific file
- Update commit message
- Use OEM_TABLE_ID instead of ACPI_TABLE_CREATOR

 arch/x86/include/asm/acpi_table.h | 115 ++++++++++++++++++++++++++++++
 arch/x86/lib/acpi_table.c         | 111 ++++++++++++++++++++++++++++
 include/acpi/acpi_table.h         |  43 +++++++++++
 3 files changed, 269 insertions(+)

diff --git a/arch/x86/include/asm/acpi_table.h b/arch/x86/include/asm/acpi_table.h
index 3245e447813..faf31730730 100644
--- a/arch/x86/include/asm/acpi_table.h
+++ b/arch/x86/include/asm/acpi_table.h
@@ -98,4 +98,119 @@ int arch_write_sci_irq_select(uint scis);
  */
 int arch_madt_sci_irq_polarity(int sci);
 
+/**
+ * acpi_create_dmar_drhd() - Create a table for DMA remapping with the IOMMU
+ *
+ * See here for the specification
+ * https://software.intel.com/sites/default/files/managed/c5/15/vt-directed-io-spec.pdf
+ *
+ * @ctx: ACPI context pointer
+ * @flags: (DRHD_INCLUDE_...)
+ * @segment: PCI segment asscociated with this unit
+ * @bar: Base address of remapping hardware register-set for this unit
+ */
+void acpi_create_dmar_drhd(struct acpi_ctx *ctx, uint flags, uint segment,
+			   u64 bar);
+
+/**
+ * acpi_create_dmar_rmrr() - Set up an RMRR
+ *
+ * This sets up a Reserved-Memory Region Reporting structure, used to allow
+ * DMA to regions used by devices that the BIOS controls.
+ *
+ * @ctx: ACPI context pointer
+ * @segment: PCI segment asscociated with this unit
+ * @bar: Base address of mapping
+ * @limit: End address of mapping
+ */
+void acpi_create_dmar_rmrr(struct acpi_ctx *ctx, uint segment, u64 bar,
+			   u64 limit);
+
+/**
+ * acpi_dmar_drhd_fixup() - Set the length of an DRHD
+ *
+ * This sets the DRHD length field based on the current ctx->current
+ *
+ * @ctx: ACPI context pointer
+ * @base: Address of the start of the DRHD
+ */
+void acpi_dmar_drhd_fixup(struct acpi_ctx *ctx, void *base);
+
+/**
+ * acpi_dmar_rmrr_fixup() - Set the length of an RMRR
+ *
+ * This sets the RMRR length field based on the current ctx->current
+ *
+ * @ctx: ACPI context pointer
+ * @base: Address of the start of the RMRR
+ */
+void acpi_dmar_rmrr_fixup(struct acpi_ctx *ctx, void *base);
+
+/**
+ * acpi_create_dmar_ds_pci() - Set up a DMAR scope for a PCI device
+ *
+ * @ctx: ACPI context pointer
+ * @bdf: PCI device to add
+ * @return length of mapping in bytes
+ */
+int acpi_create_dmar_ds_pci(struct acpi_ctx *ctx, pci_dev_t bdf);
+
+/**
+ * acpi_create_dmar_ds_pci_br() - Set up a DMAR scope for a PCI bridge
+ *
+ * This is used to provide a mapping for a PCI bridge
+ *
+ * @ctx: ACPI context pointer
+ * @bdf: PCI device to add
+ * @return length of mapping in bytes
+ */
+int acpi_create_dmar_ds_pci_br(struct acpi_ctx *ctx, pci_dev_t bdf);
+
+/**
+ * acpi_create_dmar_ds_ioapic() - Set up a DMAR scope for an IOAPIC device
+ *
+ * @ctx: ACPI context pointer
+ * @enumeration_id: Enumeration ID (typically 2)
+ * @bdf: PCI device to add
+ * @return length of mapping in bytes
+ */
+int acpi_create_dmar_ds_ioapic(struct acpi_ctx *ctx, uint enumeration_id,
+			       pci_dev_t bdf);
+
+/**
+ * acpi_create_dmar_ds_msi_hpet() - Set up a DMAR scope for an HPET
+ *
+ * Sets up a scope for a High-Precision Event Timer that supports
+ * Message-Signalled Interrupts
+ *
+ * @ctx: ACPI context pointer
+ * @enumeration_id: Enumeration ID (typically 0)
+ * @bdf: PCI device to add
+ * @return length of mapping in bytes
+ */
+int acpi_create_dmar_ds_msi_hpet(struct acpi_ctx *ctx, uint enumeration_id,
+				 pci_dev_t bdf);
+
+/**
+ * acpi_fadt_common() - Handle common parts of filling out an FADT
+ *
+ * This sets up the Fixed ACPI Description Table
+ *
+ * @fadt: Pointer to place to put FADT
+ * @facs: Pointer to the FACS
+ * @dsdt: Pointer to the DSDT
+ */
+void acpi_fadt_common(struct acpi_fadt *fadt, struct acpi_facs *facs,
+		      void *dsdt);
+
+/**
+ * intel_acpi_fill_fadt() - Set up the contents of the FADT
+ *
+ * This sets up parts of the Fixed ACPI Description Table that are common to
+ * Intel chips
+ *
+ * @fadt: Pointer to place to put FADT
+ */
+void intel_acpi_fill_fadt(struct acpi_fadt *fadt);
+
 #endif /* __ASM_ACPI_TABLE_H__ */
diff --git a/arch/x86/lib/acpi_table.c b/arch/x86/lib/acpi_table.c
index 28a27103342..b0cc1f123e2 100644
--- a/arch/x86/lib/acpi_table.c
+++ b/arch/x86/lib/acpi_table.c
@@ -616,3 +616,114 @@ int acpi_write_dbg2_pci_uart(struct acpi_ctx *ctx, struct udevice *dev,
 
 	return 0;
 }
+
+void acpi_fadt_common(struct acpi_fadt *fadt, struct acpi_facs *facs,
+		      void *dsdt)
+{
+	struct acpi_table_header *header = &fadt->header;
+
+	memset((void *)fadt, '\0', sizeof(struct acpi_fadt));
+
+	acpi_fill_header(header, "FACP");
+	header->length = sizeof(struct acpi_fadt);
+	header->revision = 4;
+	memcpy(header->oem_id, OEM_ID, 6);
+	memcpy(header->oem_table_id, OEM_TABLE_ID, 8);
+	memcpy(header->aslc_id, ASLC_ID, 4);
+	header->aslc_revision = 1;
+
+	fadt->firmware_ctrl = (unsigned long)facs;
+	fadt->dsdt = (unsigned long)dsdt;
+
+	fadt->x_firmware_ctl_l = (unsigned long)facs;
+	fadt->x_firmware_ctl_h = 0;
+	fadt->x_dsdt_l = (unsigned long)dsdt;
+	fadt->x_dsdt_h = 0;
+
+	fadt->preferred_pm_profile = ACPI_PM_MOBILE;
+
+	/* Use ACPI 3.0 revision */
+	fadt->header.revision = 4;
+}
+
+void acpi_create_dmar_drhd(struct acpi_ctx *ctx, uint flags, uint segment,
+			   u64 bar)
+{
+	struct dmar_entry *drhd = ctx->current;
+
+	memset(drhd, '\0', sizeof(*drhd));
+	drhd->type = DMAR_DRHD;
+	drhd->length = sizeof(*drhd); /* will be fixed up later */
+	drhd->flags = flags;
+	drhd->segment = segment;
+	drhd->bar = bar;
+	acpi_inc(ctx, drhd->length);
+}
+
+void acpi_create_dmar_rmrr(struct acpi_ctx *ctx, uint segment, u64 bar,
+			   u64 limit)
+{
+	struct dmar_rmrr_entry *rmrr = ctx->current;
+
+	memset(rmrr, '\0', sizeof(*rmrr));
+	rmrr->type = DMAR_RMRR;
+	rmrr->length = sizeof(*rmrr); /* will be fixed up later */
+	rmrr->segment = segment;
+	rmrr->bar = bar;
+	rmrr->limit = limit;
+	acpi_inc(ctx, rmrr->length);
+}
+
+void acpi_dmar_drhd_fixup(struct acpi_ctx *ctx, void *base)
+{
+	struct dmar_entry *drhd = base;
+
+	drhd->length = ctx->current - base;
+}
+
+void acpi_dmar_rmrr_fixup(struct acpi_ctx *ctx, void *base)
+{
+	struct dmar_rmrr_entry *rmrr = base;
+
+	rmrr->length = ctx->current - base;
+}
+
+static int acpi_create_dmar_ds(struct acpi_ctx *ctx, enum dev_scope_type type,
+			       uint enumeration_id, pci_dev_t bdf)
+{
+	/* we don't support longer paths yet */
+	const size_t dev_scope_length = sizeof(struct dev_scope) + 2;
+	struct dev_scope *ds = ctx->current;
+
+	memset(ds, '\0', dev_scope_length);
+	ds->type = type;
+	ds->length = dev_scope_length;
+	ds->enumeration = enumeration_id;
+	ds->start_bus = PCI_BUS(bdf);
+	ds->path[0].dev = PCI_DEV(bdf);
+	ds->path[0].fn = PCI_FUNC(bdf);
+
+	return ds->length;
+}
+
+int acpi_create_dmar_ds_pci_br(struct acpi_ctx *ctx, pci_dev_t bdf)
+{
+	return acpi_create_dmar_ds(ctx, SCOPE_PCI_SUB, 0, bdf);
+}
+
+int acpi_create_dmar_ds_pci(struct acpi_ctx *ctx, pci_dev_t bdf)
+{
+	return acpi_create_dmar_ds(ctx, SCOPE_PCI_ENDPOINT, 0, bdf);
+}
+
+int acpi_create_dmar_ds_ioapic(struct acpi_ctx *ctx, uint enumeration_id,
+			       pci_dev_t bdf)
+{
+	return acpi_create_dmar_ds(ctx, SCOPE_IOAPIC, enumeration_id, bdf);
+}
+
+int acpi_create_dmar_ds_msi_hpet(struct acpi_ctx *ctx, uint enumeration_id,
+				 pci_dev_t bdf)
+{
+	return acpi_create_dmar_ds(ctx, SCOPE_MSI_HPET, enumeration_id, bdf);
+}
diff --git a/include/acpi/acpi_table.h b/include/acpi/acpi_table.h
index c826a797f5b..a2e510cf56e 100644
--- a/include/acpi/acpi_table.h
+++ b/include/acpi/acpi_table.h
@@ -377,6 +377,49 @@ struct acpi_csrt_shared_info {
 	u32 max_block_size;
 };
 
+/* Port types for ACPI _UPC object */
+enum acpi_upc_type {
+	UPC_TYPE_A,
+	UPC_TYPE_MINI_AB,
+	UPC_TYPE_EXPRESSCARD,
+	UPC_TYPE_USB3_A,
+	UPC_TYPE_USB3_B,
+	UPC_TYPE_USB3_MICRO_B,
+	UPC_TYPE_USB3_MICRO_AB,
+	UPC_TYPE_USB3_POWER_B,
+	UPC_TYPE_C_USB2_ONLY,
+	UPC_TYPE_C_USB2_SS_SWITCH,
+	UPC_TYPE_C_USB2_SS,
+	UPC_TYPE_PROPRIETARY = 0xff,
+	/*
+	 * The following types are not directly defined in the ACPI
+	 * spec but are used by coreboot to identify a USB device type.
+	 */
+	UPC_TYPE_INTERNAL = 0xff,
+	UPC_TYPE_UNUSED,
+	UPC_TYPE_HUB
+};
+
+enum dev_scope_type {
+	SCOPE_PCI_ENDPOINT = 1,
+	SCOPE_PCI_SUB = 2,
+	SCOPE_IOAPIC = 3,
+	SCOPE_MSI_HPET = 4,
+	SCOPE_ACPI_NAMESPACE_DEVICE = 5
+};
+
+struct __packed dev_scope {
+	u8 type;
+	u8 length;
+	u8 reserved[2];
+	u8 enumeration;
+	u8 start_bus;
+	struct {
+		u8 dev;
+		u8 fn;
+	} __packed path[0];
+};
+
 enum dmar_type {
 	DMAR_DRHD = 0,
 	DMAR_RMRR = 1,
-- 
2.28.0.402.g5ffc5be6b7-goog

  parent reply	other threads:[~2020-08-29 23:31 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-29 23:31 [PATCH v2 00/57] dm: Add programatic generation of ACPI tables (part D) Simon Glass
2020-08-29 23:31 ` [PATCH v2 01/57] x86: acpi: Add cros_ec tables Simon Glass
2020-08-29 23:31 ` [PATCH v2 02/57] x86: acpi: Add base asl files for common x86 devices Simon Glass
2020-08-29 23:31 ` [PATCH v2 03/57] x86: acpi: apl: Add asl files for Apollo Lake Simon Glass
2020-08-29 23:31 ` [PATCH v2 04/57] x86: acpi: Add DPTF asl files Simon Glass
2020-08-29 23:31 ` [PATCH v2 05/57] x86: apl: Correct PCIE_ECAM_BASE Simon Glass
2020-08-29 23:31 ` [PATCH v2 06/57] x86: Add a config for the systemagent PCIEX regions size Simon Glass
2020-08-29 23:31 ` [PATCH v2 07/57] x86: Add a common global NVS structure Simon Glass
2020-08-29 23:31 ` [PATCH v2 08/57] x86: acpi: Support external GNVS tables Simon Glass
2020-08-29 23:31 ` [PATCH v2 09/57] x86: acpi: Expand the GNVS Simon Glass
2020-08-29 23:31 ` [PATCH v2 10/57] x86: coral: Add ACPI tables for coral Simon Glass
2020-08-29 23:31 ` [PATCH v2 11/57] acpi: Add support for writing a _PRW Simon Glass
2020-08-29 23:31 ` [PATCH v2 12/57] acpi: Add support for conditions and return values Simon Glass
2020-08-29 23:31 ` [PATCH v2 13/57] acpi: Support generating a multi-function _DSM for devices Simon Glass
2020-08-29 23:31 ` [PATCH v2 14/57] dm: acpi: Use correct GPIO polarity type in acpi_dp_add_gpio() Simon Glass
2020-08-29 23:31 ` [PATCH v2 15/57] x86: link: Allow more space for U-Boot Simon Glass
2020-08-29 23:31 ` [PATCH v2 16/57] i2c: Add a generic driver to generate ACPI info Simon Glass
2020-08-31 10:41   ` Heiko Schocher
2020-08-31 11:38     ` Andy Shevchenko
2020-08-29 23:31 ` [PATCH v2 17/57] x86: Add wake sources for the acpi_gpe driver Simon Glass
2020-08-29 23:31 ` [PATCH v2 18/57] x86: apl: Support writing the IntelGraphicsMem table Simon Glass
2020-08-29 23:31 ` [PATCH v2 19/57] x86: acpi: Add a common routine to write WiFi info Simon Glass
2020-08-29 23:31 ` [PATCH v2 20/57] x86: Add some definitions for SMM Simon Glass
2020-08-29 23:31 ` [PATCH v2 21/57] x86: apl: Add power-management definitions Simon Glass
2020-08-29 23:31 ` [PATCH v2 22/57] x86: apl: Update iomap for ACPI Simon Glass
2020-08-29 23:31 ` [PATCH v2 23/57] x86: Add a few common Intel CPU functions Simon Glass
2020-08-29 23:31 ` [PATCH v2 24/57] x86: acpi: Support generation of the HPET table Simon Glass
2020-08-29 23:31 ` [PATCH v2 25/57] x86: acpi: Support generation of the DBG2 table Simon Glass
2020-08-29 23:31 ` [PATCH v2 26/57] acpi: Add support for generating processor tables Simon Glass
2020-08-29 23:31 ` [PATCH v2 27/57] x86: acpi: Add PCT and PTC tables Simon Glass
2020-08-29 23:31 ` [PATCH v2 28/57] acpi: Add more support for generating processor tables Simon Glass
2020-08-29 23:31 ` [PATCH v2 29/57] x86: acpi: Add common Intel ACPI tables Simon Glass
2020-08-29 23:31 ` [PATCH v2 30/57] x86: Support Atom SoCs using SWSMISCI rather than the SWSCI Simon Glass
2020-08-29 23:31 ` Simon Glass [this message]
2020-08-29 23:31 ` [PATCH v2 32/57] x86: apl: Allow reading hostbridge base addresses Simon Glass
2020-08-29 23:31 ` [PATCH v2 33/57] p2sb: Add some definitions used for ACPI Simon Glass
2020-08-29 23:31 ` [PATCH v2 34/57] x86: apl: Generate required ACPI tables Simon Glass
2020-08-29 23:31 ` [PATCH v2 35/57] x86: apl: Add support for hostbridge ACPI generation Simon Glass
2020-08-29 23:31 ` [PATCH v2 36/57] x86: apl: Generate CPU tables Simon Glass
2020-08-29 23:31 ` [PATCH v2 37/57] x86: apl: Generate ACPI table for LPC Simon Glass
2020-08-29 23:31 ` [PATCH v2 38/57] x86: apl: Drop unnecessary code in PMC driver Simon Glass
2020-08-29 23:31 ` [PATCH v2 39/57] tpm: cr50: Add ACPI support Simon Glass
2020-08-29 23:31 ` [PATCH v2 40/57] x86: fsp: Update the FSP API with the end-firmware method Simon Glass
2020-08-29 23:32 ` [PATCH v2 41/57] x86: cpu: Report address width from cpu_get_info() Simon Glass
2020-08-29 23:32 ` [PATCH v2 42/57] x86: Sort the MTRR table Simon Glass
2020-08-29 23:32 ` [PATCH v2 43/57] x86: Notify the FSP of the 'end firmware' event Simon Glass
2020-08-29 23:32 ` [PATCH v2 44/57] x86: Correct the assembly guard in e820.h Simon Glass
2020-08-29 23:32 ` [PATCH v2 45/57] x86: Add a header guard to asm/acpi_table.h Simon Glass
2020-08-29 23:32 ` [PATCH v2 46/57] x86: Correct handling of MADT table CPUs Simon Glass
2020-08-29 23:32 ` [PATCH v2 47/57] acpi: tpm: Add a TPM2 table Simon Glass
2020-08-29 23:32 ` [PATCH v2 48/57] acpi: tpm: Add a TPM1 table Simon Glass
2020-08-29 23:32 ` [PATCH v2 49/57] x86: acpi: Set the log category for x86 table generation Simon Glass
2020-08-29 23:32 ` [PATCH v2 50/57] x86: coral: Add audio descriptor files Simon Glass
2020-08-29 23:32 ` [PATCH v2 51/57] x86: apl: Check low-level init in FSP-S pre-init Simon Glass
2020-08-29 23:32 ` [PATCH v2 52/57] x86: fsp: Add more debugging for silicon init Simon Glass
2020-08-29 23:32 ` [PATCH v2 53/57] x86: fsp: Show FSP-S or FSP-M address in fsp_get_header() Simon Glass
2020-08-29 23:32 ` [PATCH v2 54/57] acpi: Use defines for field lengths Simon Glass
2020-08-29 23:32 ` [PATCH v2 55/57] x86: Add a way to add to the e820 memory table Simon Glass
2020-08-29 23:32 ` [PATCH v2 56/57] x86: Move include of bitops out of ACPI region Simon Glass
2020-08-29 23:32 ` [PATCH v2 57/57] x86: coral: Update config and device tree for ACPI Simon Glass
2020-09-04 14:16 ` [PATCH v2 08/57] x86: acpi: Support external GNVS tables Wolfgang Wallner
2020-09-06 15:56   ` Simon Glass

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200829173153.v2.31.I8aa77aa9037dc3d08929270b114eac2f8fc9daa3@changeid \
    --to=sjg@chromium.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.