Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
Saket Sinha | 331141a | 2015-08-22 12:20:55 +0530 | [diff] [blame] | 2 | /* |
| 3 | * Based on acpi.c from coreboot |
| 4 | * |
| 5 | * Copyright (C) 2015, Saket Sinha <saket.sinha89@gmail.com> |
Bin Meng | bbcff8d | 2016-05-07 07:46:22 -0700 | [diff] [blame] | 6 | * Copyright (C) 2016, Bin Meng <bmeng.cn@gmail.com> |
Saket Sinha | 331141a | 2015-08-22 12:20:55 +0530 | [diff] [blame] | 7 | */ |
| 8 | |
Bin Meng | 3f04707 | 2018-07-18 21:42:17 -0700 | [diff] [blame] | 9 | #ifndef __ASM_ACPI_TABLE_H__ |
| 10 | #define __ASM_ACPI_TABLE_H__ |
| 11 | |
Simon Glass | f4112b0 | 2020-09-22 12:45:30 -0600 | [diff] [blame] | 12 | #ifndef __ACPI__ |
| 13 | |
Simon Glass | 3ba929a | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 14 | #include <pci.h> |
| 15 | |
Simon Glass | 858fed1 | 2020-04-08 16:57:36 -0600 | [diff] [blame] | 16 | struct acpi_facs; |
| 17 | struct acpi_fadt; |
Bin Meng | d9050c6 | 2016-06-17 02:13:16 -0700 | [diff] [blame] | 18 | struct acpi_global_nvs; |
Simon Glass | 858fed1 | 2020-04-08 16:57:36 -0600 | [diff] [blame] | 19 | struct acpi_madt_ioapic; |
| 20 | struct acpi_madt_irqoverride; |
| 21 | struct acpi_madt_lapic_nmi; |
| 22 | struct acpi_mcfg_mmconfig; |
| 23 | struct acpi_table_header; |
Andy Shevchenko | 6e84f087 | 2018-11-20 23:52:37 +0200 | [diff] [blame] | 24 | |
Saket Sinha | 331141a | 2015-08-22 12:20:55 +0530 | [diff] [blame] | 25 | /* These can be used by the target port */ |
| 26 | |
Bin Meng | 44256b0 | 2016-05-07 07:46:25 -0700 | [diff] [blame] | 27 | void acpi_create_fadt(struct acpi_fadt *fadt, struct acpi_facs *facs, |
| 28 | void *dsdt); |
Bin Meng | 3c5234e | 2016-05-07 07:46:30 -0700 | [diff] [blame] | 29 | int acpi_create_madt_lapics(u32 current); |
Bin Meng | 44256b0 | 2016-05-07 07:46:25 -0700 | [diff] [blame] | 30 | int acpi_create_madt_ioapic(struct acpi_madt_ioapic *ioapic, u8 id, |
| 31 | u32 addr, u32 gsi_base); |
Saket Sinha | 331141a | 2015-08-22 12:20:55 +0530 | [diff] [blame] | 32 | int acpi_create_madt_irqoverride(struct acpi_madt_irqoverride *irqoverride, |
Bin Meng | 44256b0 | 2016-05-07 07:46:25 -0700 | [diff] [blame] | 33 | u8 bus, u8 source, u32 gsirq, u16 flags); |
| 34 | int acpi_create_madt_lapic_nmi(struct acpi_madt_lapic_nmi *lapic_nmi, |
| 35 | u8 cpu, u16 flags, u8 lint); |
Bin Meng | a1ec7db | 2016-05-07 07:46:26 -0700 | [diff] [blame] | 36 | u32 acpi_fill_madt(u32 current); |
Andy Shevchenko | c1ae980 | 2017-07-21 22:32:05 +0300 | [diff] [blame] | 37 | int acpi_create_mcfg_mmconfig(struct acpi_mcfg_mmconfig *mmconfig, u32 base, |
| 38 | u16 seg_nr, u8 start, u8 end); |
| 39 | u32 acpi_fill_mcfg(u32 current); |
Andy Shevchenko | 607dbd1 | 2019-07-14 19:23:57 +0300 | [diff] [blame] | 40 | u32 acpi_fill_csrt(u32 current); |
Simon Glass | 9ed41e7 | 2020-07-07 21:32:05 -0600 | [diff] [blame] | 41 | |
| 42 | /** |
Simon Glass | 4ffe8b0 | 2020-09-22 12:45:09 -0600 | [diff] [blame] | 43 | * acpi_write_hpet() - Write out a HPET table |
| 44 | * |
| 45 | * Write out the table for High-Precision Event Timers |
| 46 | * |
| 47 | * @ctx: Current ACPI context |
Heinrich Schuchardt | 47b4c02 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 48 | * Return: 0 if OK, -ve on error |
Simon Glass | 4ffe8b0 | 2020-09-22 12:45:09 -0600 | [diff] [blame] | 49 | */ |
| 50 | int acpi_write_hpet(struct acpi_ctx *ctx); |
| 51 | |
| 52 | /** |
Simon Glass | 9597189 | 2020-09-22 12:45:10 -0600 | [diff] [blame] | 53 | * acpi_write_dbg2_pci_uart() - Write out a DBG2 table |
| 54 | * |
| 55 | * @ctx: Current ACPI context |
| 56 | * @dev: Debug UART device to describe |
| 57 | * @access_size: Access size for UART (e.g. ACPI_ACCESS_SIZE_DWORD_ACCESS) |
Heinrich Schuchardt | 47b4c02 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 58 | * Return: 0 if OK, -ve on error |
Simon Glass | 9597189 | 2020-09-22 12:45:10 -0600 | [diff] [blame] | 59 | */ |
| 60 | int acpi_write_dbg2_pci_uart(struct acpi_ctx *ctx, struct udevice *dev, |
| 61 | uint access_size); |
| 62 | |
| 63 | /** |
Simon Glass | 9ed41e7 | 2020-07-07 21:32:05 -0600 | [diff] [blame] | 64 | * acpi_create_gnvs() - Create a GNVS (Global Non Volatile Storage) table |
| 65 | * |
| 66 | * @gnvs: Table to fill in |
Heinrich Schuchardt | 47b4c02 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 67 | * Return: 0 if OK, -ve on error |
Simon Glass | 9ed41e7 | 2020-07-07 21:32:05 -0600 | [diff] [blame] | 68 | */ |
| 69 | int acpi_create_gnvs(struct acpi_global_nvs *gnvs); |
| 70 | |
Simon Glass | ca37a39 | 2017-01-16 07:03:35 -0700 | [diff] [blame] | 71 | ulong write_acpi_tables(ulong start); |
Bin Meng | 34bc74a | 2017-04-21 07:24:36 -0700 | [diff] [blame] | 72 | |
| 73 | /** |
Bin Meng | e102925 | 2018-01-30 05:01:16 -0800 | [diff] [blame] | 74 | * acpi_get_rsdp_addr() - get ACPI RSDP table address |
| 75 | * |
| 76 | * This routine returns the ACPI RSDP table address in the system memory. |
| 77 | * |
| 78 | * @return: ACPI RSDP table address |
| 79 | */ |
| 80 | ulong acpi_get_rsdp_addr(void); |
Bin Meng | 3f04707 | 2018-07-18 21:42:17 -0700 | [diff] [blame] | 81 | |
Simon Glass | d73344b | 2020-09-22 12:45:14 -0600 | [diff] [blame] | 82 | /** |
| 83 | * arch_read_sci_irq_select() - Read the system-control interrupt number |
| 84 | * |
| 85 | * @returns value of IRQ register in the PMC |
| 86 | */ |
| 87 | int arch_read_sci_irq_select(void); |
| 88 | |
| 89 | /** |
| 90 | * arch_write_sci_irq_select() - Set the system-control interrupt number |
| 91 | * |
| 92 | * @scis: New value for IRQ register in the PMC |
| 93 | */ |
| 94 | int arch_write_sci_irq_select(uint scis); |
| 95 | |
| 96 | /** |
| 97 | * arch_madt_sci_irq_polarity() - Return the priority to use for the MADT |
| 98 | * |
| 99 | * @sci: System-control interrupt number |
Heinrich Schuchardt | 47b4c02 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 100 | * Return: priority to use (MP_IRQ_POLARITY_...) |
Simon Glass | d73344b | 2020-09-22 12:45:14 -0600 | [diff] [blame] | 101 | */ |
| 102 | int arch_madt_sci_irq_polarity(int sci); |
| 103 | |
Simon Glass | 87cf8d2 | 2020-09-22 12:45:16 -0600 | [diff] [blame] | 104 | /** |
| 105 | * acpi_create_dmar_drhd() - Create a table for DMA remapping with the IOMMU |
| 106 | * |
| 107 | * See here for the specification |
| 108 | * https://software.intel.com/sites/default/files/managed/c5/15/vt-directed-io-spec.pdf |
| 109 | * |
| 110 | * @ctx: ACPI context pointer |
| 111 | * @flags: (DRHD_INCLUDE_...) |
| 112 | * @segment: PCI segment asscociated with this unit |
| 113 | * @bar: Base address of remapping hardware register-set for this unit |
| 114 | */ |
| 115 | void acpi_create_dmar_drhd(struct acpi_ctx *ctx, uint flags, uint segment, |
| 116 | u64 bar); |
| 117 | |
| 118 | /** |
| 119 | * acpi_create_dmar_rmrr() - Set up an RMRR |
| 120 | * |
| 121 | * This sets up a Reserved-Memory Region Reporting structure, used to allow |
| 122 | * DMA to regions used by devices that the BIOS controls. |
| 123 | * |
| 124 | * @ctx: ACPI context pointer |
| 125 | * @segment: PCI segment asscociated with this unit |
| 126 | * @bar: Base address of mapping |
| 127 | * @limit: End address of mapping |
| 128 | */ |
| 129 | void acpi_create_dmar_rmrr(struct acpi_ctx *ctx, uint segment, u64 bar, |
| 130 | u64 limit); |
| 131 | |
| 132 | /** |
| 133 | * acpi_dmar_drhd_fixup() - Set the length of an DRHD |
| 134 | * |
| 135 | * This sets the DRHD length field based on the current ctx->current |
| 136 | * |
| 137 | * @ctx: ACPI context pointer |
| 138 | * @base: Address of the start of the DRHD |
| 139 | */ |
| 140 | void acpi_dmar_drhd_fixup(struct acpi_ctx *ctx, void *base); |
| 141 | |
| 142 | /** |
| 143 | * acpi_dmar_rmrr_fixup() - Set the length of an RMRR |
| 144 | * |
| 145 | * This sets the RMRR length field based on the current ctx->current |
| 146 | * |
| 147 | * @ctx: ACPI context pointer |
| 148 | * @base: Address of the start of the RMRR |
| 149 | */ |
| 150 | void acpi_dmar_rmrr_fixup(struct acpi_ctx *ctx, void *base); |
| 151 | |
| 152 | /** |
| 153 | * acpi_create_dmar_ds_pci() - Set up a DMAR scope for a PCI device |
| 154 | * |
| 155 | * @ctx: ACPI context pointer |
| 156 | * @bdf: PCI device to add |
Heinrich Schuchardt | 47b4c02 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 157 | * Return: length of mapping in bytes |
Simon Glass | 87cf8d2 | 2020-09-22 12:45:16 -0600 | [diff] [blame] | 158 | */ |
| 159 | int acpi_create_dmar_ds_pci(struct acpi_ctx *ctx, pci_dev_t bdf); |
| 160 | |
| 161 | /** |
| 162 | * acpi_create_dmar_ds_pci_br() - Set up a DMAR scope for a PCI bridge |
| 163 | * |
| 164 | * This is used to provide a mapping for a PCI bridge |
| 165 | * |
| 166 | * @ctx: ACPI context pointer |
| 167 | * @bdf: PCI device to add |
Heinrich Schuchardt | 47b4c02 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 168 | * Return: length of mapping in bytes |
Simon Glass | 87cf8d2 | 2020-09-22 12:45:16 -0600 | [diff] [blame] | 169 | */ |
| 170 | int acpi_create_dmar_ds_pci_br(struct acpi_ctx *ctx, pci_dev_t bdf); |
| 171 | |
| 172 | /** |
| 173 | * acpi_create_dmar_ds_ioapic() - Set up a DMAR scope for an IOAPIC device |
| 174 | * |
| 175 | * @ctx: ACPI context pointer |
| 176 | * @enumeration_id: Enumeration ID (typically 2) |
| 177 | * @bdf: PCI device to add |
Heinrich Schuchardt | 47b4c02 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 178 | * Return: length of mapping in bytes |
Simon Glass | 87cf8d2 | 2020-09-22 12:45:16 -0600 | [diff] [blame] | 179 | */ |
| 180 | int acpi_create_dmar_ds_ioapic(struct acpi_ctx *ctx, uint enumeration_id, |
| 181 | pci_dev_t bdf); |
| 182 | |
| 183 | /** |
| 184 | * acpi_create_dmar_ds_msi_hpet() - Set up a DMAR scope for an HPET |
| 185 | * |
| 186 | * Sets up a scope for a High-Precision Event Timer that supports |
| 187 | * Message-Signalled Interrupts |
| 188 | * |
| 189 | * @ctx: ACPI context pointer |
| 190 | * @enumeration_id: Enumeration ID (typically 0) |
| 191 | * @bdf: PCI device to add |
Heinrich Schuchardt | 47b4c02 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 192 | * Return: length of mapping in bytes |
Simon Glass | 87cf8d2 | 2020-09-22 12:45:16 -0600 | [diff] [blame] | 193 | */ |
| 194 | int acpi_create_dmar_ds_msi_hpet(struct acpi_ctx *ctx, uint enumeration_id, |
| 195 | pci_dev_t bdf); |
| 196 | |
| 197 | /** |
| 198 | * acpi_fadt_common() - Handle common parts of filling out an FADT |
| 199 | * |
| 200 | * This sets up the Fixed ACPI Description Table |
| 201 | * |
| 202 | * @fadt: Pointer to place to put FADT |
| 203 | * @facs: Pointer to the FACS |
| 204 | * @dsdt: Pointer to the DSDT |
| 205 | */ |
| 206 | void acpi_fadt_common(struct acpi_fadt *fadt, struct acpi_facs *facs, |
| 207 | void *dsdt); |
| 208 | |
| 209 | /** |
| 210 | * intel_acpi_fill_fadt() - Set up the contents of the FADT |
| 211 | * |
| 212 | * This sets up parts of the Fixed ACPI Description Table that are common to |
| 213 | * Intel chips |
| 214 | * |
| 215 | * @fadt: Pointer to place to put FADT |
| 216 | */ |
| 217 | void intel_acpi_fill_fadt(struct acpi_fadt *fadt); |
| 218 | |
Simon Glass | f4112b0 | 2020-09-22 12:45:30 -0600 | [diff] [blame] | 219 | #endif /* !__ACPI__ */ |
| 220 | |
Bin Meng | 3f04707 | 2018-07-18 21:42:17 -0700 | [diff] [blame] | 221 | #endif /* __ASM_ACPI_TABLE_H__ */ |