blob: d5c8805df38ab1a607038e56ad6c18715ea19493 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Saket Sinha867bcb62015-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 Meng728c4af2016-05-07 07:46:22 -07006 * Copyright (C) 2016, Bin Meng <bmeng.cn@gmail.com>
Saket Sinha867bcb62015-08-22 12:20:55 +05307 */
8
Bin Meng05855fd2018-07-18 21:42:17 -07009#ifndef __ASM_ACPI_TABLE_H__
10#define __ASM_ACPI_TABLE_H__
11
Simon Glass26c3d3d2020-09-22 12:45:30 -060012#ifndef __ACPI__
13
Simon Glass401d1c42020-10-30 21:38:53 -060014#include <pci.h>
15
Simon Glass776cc202020-04-08 16:57:36 -060016struct acpi_facs;
17struct acpi_fadt;
Bin Meng79c2c252016-06-17 02:13:16 -070018struct acpi_global_nvs;
Simon Glass776cc202020-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 Shevchenkof3275aa2018-11-20 23:52:37 +020024
Saket Sinha867bcb62015-08-22 12:20:55 +053025/* These can be used by the target port */
26
Bin Mengdfbb18b2016-05-07 07:46:24 -070027void acpi_fill_header(struct acpi_table_header *header, char *signature);
Saket Sinha867bcb62015-08-22 12:20:55 +053028void acpi_create_fadt(struct acpi_fadt *fadt, struct acpi_facs *facs,
Bin Mengab5efd52016-05-07 07:46:25 -070029 void *dsdt);
Bin Mengfc4f5cc2016-05-07 07:46:30 -070030int acpi_create_madt_lapics(u32 current);
Bin Mengab5efd52016-05-07 07:46:25 -070031int acpi_create_madt_ioapic(struct acpi_madt_ioapic *ioapic, u8 id,
32 u32 addr, u32 gsi_base);
33int acpi_create_madt_irqoverride(struct acpi_madt_irqoverride *irqoverride,
34 u8 bus, u8 source, u32 gsirq, u16 flags);
35int acpi_create_madt_lapic_nmi(struct acpi_madt_lapic_nmi *lapic_nmi,
36 u8 cpu, u16 flags, u8 lint);
Bin Meng7e79a6b2016-05-07 07:46:26 -070037u32 acpi_fill_madt(u32 current);
Andy Shevchenkoace77622017-07-21 22:32:05 +030038int acpi_create_mcfg_mmconfig(struct acpi_mcfg_mmconfig *mmconfig, u32 base,
39 u16 seg_nr, u8 start, u8 end);
40u32 acpi_fill_mcfg(u32 current);
Andy Shevchenkoddd2a422019-07-14 19:23:57 +030041u32 acpi_fill_csrt(u32 current);
Simon Glass8d7ff122020-07-07 21:32:05 -060042
43/**
Simon Glassd2628982020-09-22 12:45:09 -060044 * acpi_write_hpet() - Write out a HPET table
45 *
46 * Write out the table for High-Precision Event Timers
47 *
48 * @ctx: Current ACPI context
49 * @return 0 if OK, -ve on error
50 */
51int acpi_write_hpet(struct acpi_ctx *ctx);
52
53/**
Simon Glassf37979e2020-09-22 12:45:10 -060054 * acpi_write_dbg2_pci_uart() - Write out a DBG2 table
55 *
56 * @ctx: Current ACPI context
57 * @dev: Debug UART device to describe
58 * @access_size: Access size for UART (e.g. ACPI_ACCESS_SIZE_DWORD_ACCESS)
59 * @return 0 if OK, -ve on error
60 */
61int acpi_write_dbg2_pci_uart(struct acpi_ctx *ctx, struct udevice *dev,
62 uint access_size);
63
64/**
Simon Glass8d7ff122020-07-07 21:32:05 -060065 * acpi_create_gnvs() - Create a GNVS (Global Non Volatile Storage) table
66 *
67 * @gnvs: Table to fill in
68 * @return 0 if OK, -ve on error
69 */
70int acpi_create_gnvs(struct acpi_global_nvs *gnvs);
71
Simon Glass42fd8c12017-01-16 07:03:35 -070072ulong write_acpi_tables(ulong start);
Bin Menge76bf382017-04-21 07:24:36 -070073
74/**
Bin Meng45410da2018-01-30 05:01:16 -080075 * acpi_get_rsdp_addr() - get ACPI RSDP table address
76 *
77 * This routine returns the ACPI RSDP table address in the system memory.
78 *
79 * @return: ACPI RSDP table address
80 */
81ulong acpi_get_rsdp_addr(void);
Bin Meng05855fd2018-07-18 21:42:17 -070082
Simon Glass9b3e6d42020-09-22 12:45:14 -060083/**
84 * arch_read_sci_irq_select() - Read the system-control interrupt number
85 *
86 * @returns value of IRQ register in the PMC
87 */
88int arch_read_sci_irq_select(void);
89
90/**
91 * arch_write_sci_irq_select() - Set the system-control interrupt number
92 *
93 * @scis: New value for IRQ register in the PMC
94 */
95int arch_write_sci_irq_select(uint scis);
96
97/**
98 * arch_madt_sci_irq_polarity() - Return the priority to use for the MADT
99 *
100 * @sci: System-control interrupt number
101 * @return priority to use (MP_IRQ_POLARITY_...)
102 */
103int arch_madt_sci_irq_polarity(int sci);
104
Simon Glass540f0ba2020-09-22 12:45:16 -0600105/**
106 * acpi_create_dmar_drhd() - Create a table for DMA remapping with the IOMMU
107 *
108 * See here for the specification
109 * https://software.intel.com/sites/default/files/managed/c5/15/vt-directed-io-spec.pdf
110 *
111 * @ctx: ACPI context pointer
112 * @flags: (DRHD_INCLUDE_...)
113 * @segment: PCI segment asscociated with this unit
114 * @bar: Base address of remapping hardware register-set for this unit
115 */
116void acpi_create_dmar_drhd(struct acpi_ctx *ctx, uint flags, uint segment,
117 u64 bar);
118
119/**
120 * acpi_create_dmar_rmrr() - Set up an RMRR
121 *
122 * This sets up a Reserved-Memory Region Reporting structure, used to allow
123 * DMA to regions used by devices that the BIOS controls.
124 *
125 * @ctx: ACPI context pointer
126 * @segment: PCI segment asscociated with this unit
127 * @bar: Base address of mapping
128 * @limit: End address of mapping
129 */
130void acpi_create_dmar_rmrr(struct acpi_ctx *ctx, uint segment, u64 bar,
131 u64 limit);
132
133/**
134 * acpi_dmar_drhd_fixup() - Set the length of an DRHD
135 *
136 * This sets the DRHD length field based on the current ctx->current
137 *
138 * @ctx: ACPI context pointer
139 * @base: Address of the start of the DRHD
140 */
141void acpi_dmar_drhd_fixup(struct acpi_ctx *ctx, void *base);
142
143/**
144 * acpi_dmar_rmrr_fixup() - Set the length of an RMRR
145 *
146 * This sets the RMRR length field based on the current ctx->current
147 *
148 * @ctx: ACPI context pointer
149 * @base: Address of the start of the RMRR
150 */
151void acpi_dmar_rmrr_fixup(struct acpi_ctx *ctx, void *base);
152
153/**
154 * acpi_create_dmar_ds_pci() - Set up a DMAR scope for a PCI device
155 *
156 * @ctx: ACPI context pointer
157 * @bdf: PCI device to add
158 * @return length of mapping in bytes
159 */
160int acpi_create_dmar_ds_pci(struct acpi_ctx *ctx, pci_dev_t bdf);
161
162/**
163 * acpi_create_dmar_ds_pci_br() - Set up a DMAR scope for a PCI bridge
164 *
165 * This is used to provide a mapping for a PCI bridge
166 *
167 * @ctx: ACPI context pointer
168 * @bdf: PCI device to add
169 * @return length of mapping in bytes
170 */
171int acpi_create_dmar_ds_pci_br(struct acpi_ctx *ctx, pci_dev_t bdf);
172
173/**
174 * acpi_create_dmar_ds_ioapic() - Set up a DMAR scope for an IOAPIC device
175 *
176 * @ctx: ACPI context pointer
177 * @enumeration_id: Enumeration ID (typically 2)
178 * @bdf: PCI device to add
179 * @return length of mapping in bytes
180 */
181int acpi_create_dmar_ds_ioapic(struct acpi_ctx *ctx, uint enumeration_id,
182 pci_dev_t bdf);
183
184/**
185 * acpi_create_dmar_ds_msi_hpet() - Set up a DMAR scope for an HPET
186 *
187 * Sets up a scope for a High-Precision Event Timer that supports
188 * Message-Signalled Interrupts
189 *
190 * @ctx: ACPI context pointer
191 * @enumeration_id: Enumeration ID (typically 0)
192 * @bdf: PCI device to add
193 * @return length of mapping in bytes
194 */
195int acpi_create_dmar_ds_msi_hpet(struct acpi_ctx *ctx, uint enumeration_id,
196 pci_dev_t bdf);
197
198/**
199 * acpi_fadt_common() - Handle common parts of filling out an FADT
200 *
201 * This sets up the Fixed ACPI Description Table
202 *
203 * @fadt: Pointer to place to put FADT
204 * @facs: Pointer to the FACS
205 * @dsdt: Pointer to the DSDT
206 */
207void acpi_fadt_common(struct acpi_fadt *fadt, struct acpi_facs *facs,
208 void *dsdt);
209
210/**
211 * intel_acpi_fill_fadt() - Set up the contents of the FADT
212 *
213 * This sets up parts of the Fixed ACPI Description Table that are common to
214 * Intel chips
215 *
216 * @fadt: Pointer to place to put FADT
217 */
218void intel_acpi_fill_fadt(struct acpi_fadt *fadt);
219
Simon Glass26c3d3d2020-09-22 12:45:30 -0600220#endif /* !__ACPI__ */
221
Bin Meng05855fd2018-07-18 21:42:17 -0700222#endif /* __ASM_ACPI_TABLE_H__ */