Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
Saket Sinha | 867bcb6 | 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 | 728c4af | 2016-05-07 07:46:22 -0700 | [diff] [blame] | 6 | * Copyright (C) 2016, Bin Meng <bmeng.cn@gmail.com> |
Saket Sinha | 867bcb6 | 2015-08-22 12:20:55 +0530 | [diff] [blame] | 7 | */ |
| 8 | |
Bin Meng | 05855fd | 2018-07-18 21:42:17 -0700 | [diff] [blame] | 9 | #ifndef __ASM_ACPI_TABLE_H__ |
| 10 | #define __ASM_ACPI_TABLE_H__ |
| 11 | |
Simon Glass | 26c3d3d | 2020-09-22 12:45:30 -0600 | [diff] [blame] | 12 | #ifndef __ACPI__ |
| 13 | |
Simon Glass | 401d1c4 | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 14 | #include <pci.h> |
| 15 | |
Simon Glass | 776cc20 | 2020-04-08 16:57:36 -0600 | [diff] [blame] | 16 | struct acpi_facs; |
| 17 | struct acpi_fadt; |
Bin Meng | 79c2c25 | 2016-06-17 02:13:16 -0700 | [diff] [blame] | 18 | struct acpi_global_nvs; |
Simon Glass | 776cc20 | 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 | f3275aa | 2018-11-20 23:52:37 +0200 | [diff] [blame] | 24 | |
Saket Sinha | 867bcb6 | 2015-08-22 12:20:55 +0530 | [diff] [blame] | 25 | /* These can be used by the target port */ |
| 26 | |
Bin Meng | dfbb18b | 2016-05-07 07:46:24 -0700 | [diff] [blame] | 27 | void acpi_fill_header(struct acpi_table_header *header, char *signature); |
Saket Sinha | 867bcb6 | 2015-08-22 12:20:55 +0530 | [diff] [blame] | 28 | void acpi_create_fadt(struct acpi_fadt *fadt, struct acpi_facs *facs, |
Bin Meng | ab5efd5 | 2016-05-07 07:46:25 -0700 | [diff] [blame] | 29 | void *dsdt); |
Bin Meng | fc4f5cc | 2016-05-07 07:46:30 -0700 | [diff] [blame] | 30 | int acpi_create_madt_lapics(u32 current); |
Bin Meng | ab5efd5 | 2016-05-07 07:46:25 -0700 | [diff] [blame] | 31 | int acpi_create_madt_ioapic(struct acpi_madt_ioapic *ioapic, u8 id, |
| 32 | u32 addr, u32 gsi_base); |
| 33 | int acpi_create_madt_irqoverride(struct acpi_madt_irqoverride *irqoverride, |
| 34 | u8 bus, u8 source, u32 gsirq, u16 flags); |
| 35 | int acpi_create_madt_lapic_nmi(struct acpi_madt_lapic_nmi *lapic_nmi, |
| 36 | u8 cpu, u16 flags, u8 lint); |
Bin Meng | 7e79a6b | 2016-05-07 07:46:26 -0700 | [diff] [blame] | 37 | u32 acpi_fill_madt(u32 current); |
Andy Shevchenko | ace7762 | 2017-07-21 22:32:05 +0300 | [diff] [blame] | 38 | int acpi_create_mcfg_mmconfig(struct acpi_mcfg_mmconfig *mmconfig, u32 base, |
| 39 | u16 seg_nr, u8 start, u8 end); |
| 40 | u32 acpi_fill_mcfg(u32 current); |
Andy Shevchenko | ddd2a42 | 2019-07-14 19:23:57 +0300 | [diff] [blame] | 41 | u32 acpi_fill_csrt(u32 current); |
Simon Glass | 8d7ff12 | 2020-07-07 21:32:05 -0600 | [diff] [blame] | 42 | |
| 43 | /** |
Simon Glass | d262898 | 2020-09-22 12:45:09 -0600 | [diff] [blame] | 44 | * 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 | */ |
| 51 | int acpi_write_hpet(struct acpi_ctx *ctx); |
| 52 | |
| 53 | /** |
Simon Glass | f37979e | 2020-09-22 12:45:10 -0600 | [diff] [blame] | 54 | * 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 | */ |
| 61 | int acpi_write_dbg2_pci_uart(struct acpi_ctx *ctx, struct udevice *dev, |
| 62 | uint access_size); |
| 63 | |
| 64 | /** |
Simon Glass | 8d7ff12 | 2020-07-07 21:32:05 -0600 | [diff] [blame] | 65 | * 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 | */ |
| 70 | int acpi_create_gnvs(struct acpi_global_nvs *gnvs); |
| 71 | |
Simon Glass | 42fd8c1 | 2017-01-16 07:03:35 -0700 | [diff] [blame] | 72 | ulong write_acpi_tables(ulong start); |
Bin Meng | e76bf38 | 2017-04-21 07:24:36 -0700 | [diff] [blame] | 73 | |
| 74 | /** |
Bin Meng | 45410da | 2018-01-30 05:01:16 -0800 | [diff] [blame] | 75 | * 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 | */ |
| 81 | ulong acpi_get_rsdp_addr(void); |
Bin Meng | 05855fd | 2018-07-18 21:42:17 -0700 | [diff] [blame] | 82 | |
Simon Glass | 9b3e6d4 | 2020-09-22 12:45:14 -0600 | [diff] [blame] | 83 | /** |
| 84 | * arch_read_sci_irq_select() - Read the system-control interrupt number |
| 85 | * |
| 86 | * @returns value of IRQ register in the PMC |
| 87 | */ |
| 88 | int 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 | */ |
| 95 | int 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 | */ |
| 103 | int arch_madt_sci_irq_polarity(int sci); |
| 104 | |
Simon Glass | 540f0ba | 2020-09-22 12:45:16 -0600 | [diff] [blame] | 105 | /** |
| 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 | */ |
| 116 | void 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 | */ |
| 130 | void 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 | */ |
| 141 | void 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 | */ |
| 151 | void 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 | */ |
| 160 | int 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 | */ |
| 171 | int 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 | */ |
| 181 | int 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 | */ |
| 195 | int 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 | */ |
| 207 | void 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 | */ |
| 218 | void intel_acpi_fill_fadt(struct acpi_fadt *fadt); |
| 219 | |
Simon Glass | 26c3d3d | 2020-09-22 12:45:30 -0600 | [diff] [blame] | 220 | #endif /* !__ACPI__ */ |
| 221 | |
Bin Meng | 05855fd | 2018-07-18 21:42:17 -0700 | [diff] [blame] | 222 | #endif /* __ASM_ACPI_TABLE_H__ */ |