blob: 1b49ccadc0c1a03c0a835d1e88016672fcb8e3b9 [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 Glass858fed12020-04-08 16:57:36 -060014struct acpi_facs;
15struct acpi_fadt;
Bin Mengd9050c62016-06-17 02:13:16 -070016struct acpi_global_nvs;
Simon Glass858fed12020-04-08 16:57:36 -060017struct acpi_madt_ioapic;
18struct acpi_madt_irqoverride;
19struct acpi_madt_lapic_nmi;
20struct acpi_mcfg_mmconfig;
21struct acpi_table_header;
Andy Shevchenko6e84f0872018-11-20 23:52:37 +020022
Saket Sinha331141a2015-08-22 12:20:55 +053023/* These can be used by the target port */
24
Bin Mengb063d5f2016-05-07 07:46:24 -070025void acpi_fill_header(struct acpi_table_header *header, char *signature);
Bin Meng44256b02016-05-07 07:46:25 -070026void acpi_create_fadt(struct acpi_fadt *fadt, struct acpi_facs *facs,
27 void *dsdt);
Bin Meng3c5234e2016-05-07 07:46:30 -070028int acpi_create_madt_lapics(u32 current);
Bin Meng44256b02016-05-07 07:46:25 -070029int acpi_create_madt_ioapic(struct acpi_madt_ioapic *ioapic, u8 id,
30 u32 addr, u32 gsi_base);
Saket Sinha331141a2015-08-22 12:20:55 +053031int acpi_create_madt_irqoverride(struct acpi_madt_irqoverride *irqoverride,
Bin Meng44256b02016-05-07 07:46:25 -070032 u8 bus, u8 source, u32 gsirq, u16 flags);
33int acpi_create_madt_lapic_nmi(struct acpi_madt_lapic_nmi *lapic_nmi,
34 u8 cpu, u16 flags, u8 lint);
Bin Menga1ec7db2016-05-07 07:46:26 -070035u32 acpi_fill_madt(u32 current);
Andy Shevchenkoc1ae9802017-07-21 22:32:05 +030036int acpi_create_mcfg_mmconfig(struct acpi_mcfg_mmconfig *mmconfig, u32 base,
37 u16 seg_nr, u8 start, u8 end);
38u32 acpi_fill_mcfg(u32 current);
Andy Shevchenko607dbd12019-07-14 19:23:57 +030039u32 acpi_fill_csrt(u32 current);
Simon Glass9ed41e72020-07-07 21:32:05 -060040
41/**
Simon Glass4ffe8b02020-09-22 12:45:09 -060042 * acpi_write_hpet() - Write out a HPET table
43 *
44 * Write out the table for High-Precision Event Timers
45 *
46 * @ctx: Current ACPI context
47 * @return 0 if OK, -ve on error
48 */
49int acpi_write_hpet(struct acpi_ctx *ctx);
50
51/**
Simon Glass95971892020-09-22 12:45:10 -060052 * acpi_write_dbg2_pci_uart() - Write out a DBG2 table
53 *
54 * @ctx: Current ACPI context
55 * @dev: Debug UART device to describe
56 * @access_size: Access size for UART (e.g. ACPI_ACCESS_SIZE_DWORD_ACCESS)
57 * @return 0 if OK, -ve on error
58 */
59int acpi_write_dbg2_pci_uart(struct acpi_ctx *ctx, struct udevice *dev,
60 uint access_size);
61
62/**
Simon Glass9ed41e72020-07-07 21:32:05 -060063 * acpi_create_gnvs() - Create a GNVS (Global Non Volatile Storage) table
64 *
65 * @gnvs: Table to fill in
66 * @return 0 if OK, -ve on error
67 */
68int acpi_create_gnvs(struct acpi_global_nvs *gnvs);
69
Simon Glassca37a392017-01-16 07:03:35 -070070ulong write_acpi_tables(ulong start);
Bin Meng34bc74a2017-04-21 07:24:36 -070071
72/**
Bin Menge1029252018-01-30 05:01:16 -080073 * acpi_get_rsdp_addr() - get ACPI RSDP table address
74 *
75 * This routine returns the ACPI RSDP table address in the system memory.
76 *
77 * @return: ACPI RSDP table address
78 */
79ulong acpi_get_rsdp_addr(void);
Bin Meng3f047072018-07-18 21:42:17 -070080
Simon Glassd73344b2020-09-22 12:45:14 -060081/**
82 * arch_read_sci_irq_select() - Read the system-control interrupt number
83 *
84 * @returns value of IRQ register in the PMC
85 */
86int arch_read_sci_irq_select(void);
87
88/**
89 * arch_write_sci_irq_select() - Set the system-control interrupt number
90 *
91 * @scis: New value for IRQ register in the PMC
92 */
93int arch_write_sci_irq_select(uint scis);
94
95/**
96 * arch_madt_sci_irq_polarity() - Return the priority to use for the MADT
97 *
98 * @sci: System-control interrupt number
99 * @return priority to use (MP_IRQ_POLARITY_...)
100 */
101int arch_madt_sci_irq_polarity(int sci);
102
Simon Glass87cf8d22020-09-22 12:45:16 -0600103/**
104 * acpi_create_dmar_drhd() - Create a table for DMA remapping with the IOMMU
105 *
106 * See here for the specification
107 * https://software.intel.com/sites/default/files/managed/c5/15/vt-directed-io-spec.pdf
108 *
109 * @ctx: ACPI context pointer
110 * @flags: (DRHD_INCLUDE_...)
111 * @segment: PCI segment asscociated with this unit
112 * @bar: Base address of remapping hardware register-set for this unit
113 */
114void acpi_create_dmar_drhd(struct acpi_ctx *ctx, uint flags, uint segment,
115 u64 bar);
116
117/**
118 * acpi_create_dmar_rmrr() - Set up an RMRR
119 *
120 * This sets up a Reserved-Memory Region Reporting structure, used to allow
121 * DMA to regions used by devices that the BIOS controls.
122 *
123 * @ctx: ACPI context pointer
124 * @segment: PCI segment asscociated with this unit
125 * @bar: Base address of mapping
126 * @limit: End address of mapping
127 */
128void acpi_create_dmar_rmrr(struct acpi_ctx *ctx, uint segment, u64 bar,
129 u64 limit);
130
131/**
132 * acpi_dmar_drhd_fixup() - Set the length of an DRHD
133 *
134 * This sets the DRHD length field based on the current ctx->current
135 *
136 * @ctx: ACPI context pointer
137 * @base: Address of the start of the DRHD
138 */
139void acpi_dmar_drhd_fixup(struct acpi_ctx *ctx, void *base);
140
141/**
142 * acpi_dmar_rmrr_fixup() - Set the length of an RMRR
143 *
144 * This sets the RMRR length field based on the current ctx->current
145 *
146 * @ctx: ACPI context pointer
147 * @base: Address of the start of the RMRR
148 */
149void acpi_dmar_rmrr_fixup(struct acpi_ctx *ctx, void *base);
150
151/**
152 * acpi_create_dmar_ds_pci() - Set up a DMAR scope for a PCI device
153 *
154 * @ctx: ACPI context pointer
155 * @bdf: PCI device to add
156 * @return length of mapping in bytes
157 */
158int acpi_create_dmar_ds_pci(struct acpi_ctx *ctx, pci_dev_t bdf);
159
160/**
161 * acpi_create_dmar_ds_pci_br() - Set up a DMAR scope for a PCI bridge
162 *
163 * This is used to provide a mapping for a PCI bridge
164 *
165 * @ctx: ACPI context pointer
166 * @bdf: PCI device to add
167 * @return length of mapping in bytes
168 */
169int acpi_create_dmar_ds_pci_br(struct acpi_ctx *ctx, pci_dev_t bdf);
170
171/**
172 * acpi_create_dmar_ds_ioapic() - Set up a DMAR scope for an IOAPIC device
173 *
174 * @ctx: ACPI context pointer
175 * @enumeration_id: Enumeration ID (typically 2)
176 * @bdf: PCI device to add
177 * @return length of mapping in bytes
178 */
179int acpi_create_dmar_ds_ioapic(struct acpi_ctx *ctx, uint enumeration_id,
180 pci_dev_t bdf);
181
182/**
183 * acpi_create_dmar_ds_msi_hpet() - Set up a DMAR scope for an HPET
184 *
185 * Sets up a scope for a High-Precision Event Timer that supports
186 * Message-Signalled Interrupts
187 *
188 * @ctx: ACPI context pointer
189 * @enumeration_id: Enumeration ID (typically 0)
190 * @bdf: PCI device to add
191 * @return length of mapping in bytes
192 */
193int acpi_create_dmar_ds_msi_hpet(struct acpi_ctx *ctx, uint enumeration_id,
194 pci_dev_t bdf);
195
196/**
197 * acpi_fadt_common() - Handle common parts of filling out an FADT
198 *
199 * This sets up the Fixed ACPI Description Table
200 *
201 * @fadt: Pointer to place to put FADT
202 * @facs: Pointer to the FACS
203 * @dsdt: Pointer to the DSDT
204 */
205void acpi_fadt_common(struct acpi_fadt *fadt, struct acpi_facs *facs,
206 void *dsdt);
207
208/**
209 * intel_acpi_fill_fadt() - Set up the contents of the FADT
210 *
211 * This sets up parts of the Fixed ACPI Description Table that are common to
212 * Intel chips
213 *
214 * @fadt: Pointer to place to put FADT
215 */
216void intel_acpi_fill_fadt(struct acpi_fadt *fadt);
217
Simon Glassf4112b02020-09-22 12:45:30 -0600218#endif /* !__ACPI__ */
219
Bin Meng3f047072018-07-18 21:42:17 -0700220#endif /* __ASM_ACPI_TABLE_H__ */