blob: 0d07f7cad870f3c804bea360f7f87862c9f072ff [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Saket Sinha331141a2015-08-22 12:20:55 +05302/*
3 * Based on acpi.c from coreboot
4 *
5 * Copyright (C) 2015, Saket Sinha <saket.sinha89@gmail.com>
Bin Mengbbcff8d2016-05-07 07:46:22 -07006 * Copyright (C) 2016, Bin Meng <bmeng.cn@gmail.com>
Saket Sinha331141a2015-08-22 12:20:55 +05307 */
8
Bin Meng3f047072018-07-18 21:42:17 -07009#ifndef __ASM_ACPI_TABLE_H__
10#define __ASM_ACPI_TABLE_H__
11
Simon Glassf4112b02020-09-22 12:45:30 -060012#ifndef __ACPI__
13
Simon Glass3ba929a2020-10-30 21:38:53 -060014#include <pci.h>
15
Simon Glass858fed12020-04-08 16:57:36 -060016struct acpi_facs;
17struct acpi_fadt;
Bin Mengd9050c62016-06-17 02:13:16 -070018struct acpi_global_nvs;
Simon Glass858fed12020-04-08 16:57:36 -060019struct acpi_madt_ioapic;
20struct acpi_madt_irqoverride;
21struct acpi_madt_lapic_nmi;
22struct acpi_mcfg_mmconfig;
23struct acpi_table_header;
Andy Shevchenko6e84f0872018-11-20 23:52:37 +020024
Saket Sinha331141a2015-08-22 12:20:55 +053025/* These can be used by the target port */
26
Bin Meng3c5234e2016-05-07 07:46:30 -070027int acpi_create_madt_lapics(u32 current);
Bin Meng44256b02016-05-07 07:46:25 -070028int acpi_create_madt_ioapic(struct acpi_madt_ioapic *ioapic, u8 id,
29 u32 addr, u32 gsi_base);
Saket Sinha331141a2015-08-22 12:20:55 +053030int acpi_create_madt_irqoverride(struct acpi_madt_irqoverride *irqoverride,
Bin Meng44256b02016-05-07 07:46:25 -070031 u8 bus, u8 source, u32 gsirq, u16 flags);
32int acpi_create_madt_lapic_nmi(struct acpi_madt_lapic_nmi *lapic_nmi,
33 u8 cpu, u16 flags, u8 lint);
Bin Menga1ec7db2016-05-07 07:46:26 -070034u32 acpi_fill_madt(u32 current);
Andy Shevchenkoc1ae9802017-07-21 22:32:05 +030035int acpi_create_mcfg_mmconfig(struct acpi_mcfg_mmconfig *mmconfig, u32 base,
36 u16 seg_nr, u8 start, u8 end);
37u32 acpi_fill_mcfg(u32 current);
Simon Glass9ed41e72020-07-07 21:32:05 -060038
39/**
Simon Glass4ffe8b02020-09-22 12:45:09 -060040 * acpi_write_hpet() - Write out a HPET table
41 *
42 * Write out the table for High-Precision Event Timers
43 *
44 * @ctx: Current ACPI context
Heinrich Schuchardt47b4c022022-01-19 18:05:50 +010045 * Return: 0 if OK, -ve on error
Simon Glass4ffe8b02020-09-22 12:45:09 -060046 */
47int acpi_write_hpet(struct acpi_ctx *ctx);
48
49/**
Simon Glass95971892020-09-22 12:45:10 -060050 * acpi_write_dbg2_pci_uart() - Write out a DBG2 table
51 *
52 * @ctx: Current ACPI context
53 * @dev: Debug UART device to describe
54 * @access_size: Access size for UART (e.g. ACPI_ACCESS_SIZE_DWORD_ACCESS)
Heinrich Schuchardt47b4c022022-01-19 18:05:50 +010055 * Return: 0 if OK, -ve on error
Simon Glass95971892020-09-22 12:45:10 -060056 */
57int acpi_write_dbg2_pci_uart(struct acpi_ctx *ctx, struct udevice *dev,
58 uint access_size);
59
60/**
Simon Glass9ed41e72020-07-07 21:32:05 -060061 * acpi_create_gnvs() - Create a GNVS (Global Non Volatile Storage) table
62 *
63 * @gnvs: Table to fill in
Heinrich Schuchardt47b4c022022-01-19 18:05:50 +010064 * Return: 0 if OK, -ve on error
Simon Glass9ed41e72020-07-07 21:32:05 -060065 */
66int acpi_create_gnvs(struct acpi_global_nvs *gnvs);
67
Simon Glassca37a392017-01-16 07:03:35 -070068ulong write_acpi_tables(ulong start);
Bin Meng34bc74a2017-04-21 07:24:36 -070069
70/**
Bin Menge1029252018-01-30 05:01:16 -080071 * acpi_get_rsdp_addr() - get ACPI RSDP table address
72 *
73 * This routine returns the ACPI RSDP table address in the system memory.
74 *
75 * @return: ACPI RSDP table address
76 */
77ulong acpi_get_rsdp_addr(void);
Bin Meng3f047072018-07-18 21:42:17 -070078
Simon Glassd73344b2020-09-22 12:45:14 -060079/**
80 * arch_read_sci_irq_select() - Read the system-control interrupt number
81 *
82 * @returns value of IRQ register in the PMC
83 */
84int arch_read_sci_irq_select(void);
85
86/**
87 * arch_write_sci_irq_select() - Set the system-control interrupt number
88 *
89 * @scis: New value for IRQ register in the PMC
90 */
91int arch_write_sci_irq_select(uint scis);
92
93/**
94 * arch_madt_sci_irq_polarity() - Return the priority to use for the MADT
95 *
96 * @sci: System-control interrupt number
Heinrich Schuchardt47b4c022022-01-19 18:05:50 +010097 * Return: priority to use (MP_IRQ_POLARITY_...)
Simon Glassd73344b2020-09-22 12:45:14 -060098 */
99int arch_madt_sci_irq_polarity(int sci);
100
Simon Glass87cf8d22020-09-22 12:45:16 -0600101/**
102 * acpi_create_dmar_drhd() - Create a table for DMA remapping with the IOMMU
103 *
104 * See here for the specification
105 * https://software.intel.com/sites/default/files/managed/c5/15/vt-directed-io-spec.pdf
106 *
107 * @ctx: ACPI context pointer
108 * @flags: (DRHD_INCLUDE_...)
109 * @segment: PCI segment asscociated with this unit
110 * @bar: Base address of remapping hardware register-set for this unit
111 */
112void acpi_create_dmar_drhd(struct acpi_ctx *ctx, uint flags, uint segment,
113 u64 bar);
114
115/**
116 * acpi_create_dmar_rmrr() - Set up an RMRR
117 *
118 * This sets up a Reserved-Memory Region Reporting structure, used to allow
119 * DMA to regions used by devices that the BIOS controls.
120 *
121 * @ctx: ACPI context pointer
122 * @segment: PCI segment asscociated with this unit
123 * @bar: Base address of mapping
124 * @limit: End address of mapping
125 */
126void acpi_create_dmar_rmrr(struct acpi_ctx *ctx, uint segment, u64 bar,
127 u64 limit);
128
129/**
130 * acpi_dmar_drhd_fixup() - Set the length of an DRHD
131 *
132 * This sets the DRHD length field based on the current ctx->current
133 *
134 * @ctx: ACPI context pointer
135 * @base: Address of the start of the DRHD
136 */
137void acpi_dmar_drhd_fixup(struct acpi_ctx *ctx, void *base);
138
139/**
140 * acpi_dmar_rmrr_fixup() - Set the length of an RMRR
141 *
142 * This sets the RMRR length field based on the current ctx->current
143 *
144 * @ctx: ACPI context pointer
145 * @base: Address of the start of the RMRR
146 */
147void acpi_dmar_rmrr_fixup(struct acpi_ctx *ctx, void *base);
148
149/**
150 * acpi_create_dmar_ds_pci() - Set up a DMAR scope for a PCI device
151 *
152 * @ctx: ACPI context pointer
153 * @bdf: PCI device to add
Heinrich Schuchardt47b4c022022-01-19 18:05:50 +0100154 * Return: length of mapping in bytes
Simon Glass87cf8d22020-09-22 12:45:16 -0600155 */
156int acpi_create_dmar_ds_pci(struct acpi_ctx *ctx, pci_dev_t bdf);
157
158/**
159 * acpi_create_dmar_ds_pci_br() - Set up a DMAR scope for a PCI bridge
160 *
161 * This is used to provide a mapping for a PCI bridge
162 *
163 * @ctx: ACPI context pointer
164 * @bdf: PCI device to add
Heinrich Schuchardt47b4c022022-01-19 18:05:50 +0100165 * Return: length of mapping in bytes
Simon Glass87cf8d22020-09-22 12:45:16 -0600166 */
167int acpi_create_dmar_ds_pci_br(struct acpi_ctx *ctx, pci_dev_t bdf);
168
169/**
170 * acpi_create_dmar_ds_ioapic() - Set up a DMAR scope for an IOAPIC device
171 *
172 * @ctx: ACPI context pointer
173 * @enumeration_id: Enumeration ID (typically 2)
174 * @bdf: PCI device to add
Heinrich Schuchardt47b4c022022-01-19 18:05:50 +0100175 * Return: length of mapping in bytes
Simon Glass87cf8d22020-09-22 12:45:16 -0600176 */
177int acpi_create_dmar_ds_ioapic(struct acpi_ctx *ctx, uint enumeration_id,
178 pci_dev_t bdf);
179
180/**
181 * acpi_create_dmar_ds_msi_hpet() - Set up a DMAR scope for an HPET
182 *
183 * Sets up a scope for a High-Precision Event Timer that supports
184 * Message-Signalled Interrupts
185 *
186 * @ctx: ACPI context pointer
187 * @enumeration_id: Enumeration ID (typically 0)
188 * @bdf: PCI device to add
Heinrich Schuchardt47b4c022022-01-19 18:05:50 +0100189 * Return: length of mapping in bytes
Simon Glass87cf8d22020-09-22 12:45:16 -0600190 */
191int acpi_create_dmar_ds_msi_hpet(struct acpi_ctx *ctx, uint enumeration_id,
192 pci_dev_t bdf);
193
194/**
195 * acpi_fadt_common() - Handle common parts of filling out an FADT
196 *
197 * This sets up the Fixed ACPI Description Table
198 *
199 * @fadt: Pointer to place to put FADT
200 * @facs: Pointer to the FACS
201 * @dsdt: Pointer to the DSDT
202 */
203void acpi_fadt_common(struct acpi_fadt *fadt, struct acpi_facs *facs,
204 void *dsdt);
205
206/**
207 * intel_acpi_fill_fadt() - Set up the contents of the FADT
208 *
209 * This sets up parts of the Fixed ACPI Description Table that are common to
210 * Intel chips
211 *
212 * @fadt: Pointer to place to put FADT
213 */
214void intel_acpi_fill_fadt(struct acpi_fadt *fadt);
215
Simon Glassf4112b02020-09-22 12:45:30 -0600216#endif /* !__ACPI__ */
217
Bin Meng3f047072018-07-18 21:42:17 -0700218#endif /* __ASM_ACPI_TABLE_H__ */