Simon Glass | 858fed1 | 2020-04-08 16:57:36 -0600 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
| 2 | /* |
| 3 | * Helpers for ACPI table generation |
| 4 | * |
| 5 | * Based on acpi.c from coreboot |
| 6 | * |
| 7 | * Copyright 2019 Google LLC |
| 8 | * |
| 9 | * Copyright (C) 2015, Saket Sinha <saket.sinha89@gmail.com> |
| 10 | * Copyright (C) 2016, Bin Meng <bmeng.cn@gmail.com> |
| 11 | */ |
| 12 | |
| 13 | #ifndef __ACPI_TABLE_H__ |
| 14 | #define __ACPI_TABLE_H__ |
| 15 | |
Simon Glass | 48ca578 | 2020-09-22 12:45:39 -0600 | [diff] [blame] | 16 | #include <dm/acpi.h> |
Simon Glass | 4dcacfc | 2020-05-10 11:40:13 -0600 | [diff] [blame] | 17 | |
Simon Glass | 858fed1 | 2020-04-08 16:57:36 -0600 | [diff] [blame] | 18 | #define RSDP_SIG "RSD PTR " /* RSDP pointer signature */ |
| 19 | #define OEM_ID "U-BOOT" /* U-Boot */ |
| 20 | #define OEM_TABLE_ID "U-BOOTBL" /* U-Boot Table */ |
| 21 | #define ASLC_ID "INTL" /* Intel ASL Compiler */ |
| 22 | |
Simon Glass | 4ffe8b0 | 2020-09-22 12:45:09 -0600 | [diff] [blame] | 23 | /* TODO(sjg@chromium.org): Figure out how to get compiler revision */ |
| 24 | #define ASL_REVISION 0 |
| 25 | |
Simon Glass | 858fed1 | 2020-04-08 16:57:36 -0600 | [diff] [blame] | 26 | #define ACPI_RSDP_REV_ACPI_1_0 0 |
| 27 | #define ACPI_RSDP_REV_ACPI_2_0 2 |
| 28 | |
Simon Glass | 4969d21 | 2020-04-08 16:57:37 -0600 | [diff] [blame] | 29 | #if !defined(__ACPI__) |
| 30 | |
Simon Glass | b11c2b3 | 2020-09-22 12:45:41 -0600 | [diff] [blame] | 31 | #include <linux/bitops.h> |
| 32 | |
Simon Glass | 0e11384 | 2020-04-26 09:19:47 -0600 | [diff] [blame] | 33 | struct acpi_ctx; |
| 34 | |
Simon Glass | 858fed1 | 2020-04-08 16:57:36 -0600 | [diff] [blame] | 35 | /* |
| 36 | * RSDP (Root System Description Pointer) |
| 37 | * Note: ACPI 1.0 didn't have length, xsdt_address, and ext_checksum |
| 38 | */ |
| 39 | struct acpi_rsdp { |
| 40 | char signature[8]; /* RSDP signature */ |
| 41 | u8 checksum; /* Checksum of the first 20 bytes */ |
| 42 | char oem_id[6]; /* OEM ID */ |
| 43 | u8 revision; /* 0 for ACPI 1.0, others 2 */ |
| 44 | u32 rsdt_address; /* Physical address of RSDT (32 bits) */ |
| 45 | u32 length; /* Total RSDP length (incl. extended part) */ |
| 46 | u64 xsdt_address; /* Physical address of XSDT (64 bits) */ |
| 47 | u8 ext_checksum; /* Checksum of the whole table */ |
| 48 | u8 reserved[3]; |
| 49 | }; |
| 50 | |
| 51 | /* Generic ACPI header, provided by (almost) all tables */ |
| 52 | struct __packed acpi_table_header { |
Simon Glass | 48ca578 | 2020-09-22 12:45:39 -0600 | [diff] [blame] | 53 | char signature[ACPI_NAME_LEN]; /* ACPI signature (4 ASCII chars) */ |
Simon Glass | 858fed1 | 2020-04-08 16:57:36 -0600 | [diff] [blame] | 54 | u32 length; /* Table length in bytes (incl. header) */ |
| 55 | u8 revision; /* Table version (not ACPI version!) */ |
| 56 | volatile u8 checksum; /* To make sum of entire table == 0 */ |
| 57 | char oem_id[6]; /* OEM identification */ |
| 58 | char oem_table_id[8]; /* OEM table identification */ |
| 59 | u32 oem_revision; /* OEM revision number */ |
Heinrich Schuchardt | 10de8a8 | 2024-01-21 12:52:48 +0100 | [diff] [blame] | 60 | char creator_id[4]; /* ASL compiler vendor ID */ |
| 61 | u32 creator_revision; /* ASL compiler revision number */ |
Simon Glass | 858fed1 | 2020-04-08 16:57:36 -0600 | [diff] [blame] | 62 | }; |
| 63 | |
Heinrich Schuchardt | b9291b4 | 2024-01-21 14:44:36 +0100 | [diff] [blame] | 64 | /** |
| 65 | * struct acpi_gen_regaddr - generic address structure (GAS) |
| 66 | */ |
Simon Glass | 4ffe8b0 | 2020-09-22 12:45:09 -0600 | [diff] [blame] | 67 | struct acpi_gen_regaddr { |
Heinrich Schuchardt | b9291b4 | 2024-01-21 14:44:36 +0100 | [diff] [blame] | 68 | /** |
| 69 | * @space_id: address space ID |
| 70 | * |
| 71 | * See table "Operation Region Address Space Identifiers" in the ACPI |
| 72 | * specification. |
| 73 | */ |
| 74 | u8 space_id; |
| 75 | /** @bit_width: size in bits of the register */ |
| 76 | u8 bit_width; |
| 77 | /** @bit_offset: bit offset of the register */ |
| 78 | u8 bit_offset; |
| 79 | /** |
| 80 | * @access_size: access size |
| 81 | * |
| 82 | * * 0 - undefined |
| 83 | * * 1 - byte access |
| 84 | * * 2 - word (2 bytes) access |
| 85 | * * 3 - Dword (4 bytes) access |
| 86 | * * 4 - Qword (8 bytes) access |
| 87 | * |
| 88 | * See ACPI_ACCESS_SIZE_*_ACCESS macros. |
| 89 | */ |
| 90 | u8 access_size; |
| 91 | /** @addrl: register address, low 32 bits */ |
| 92 | u32 addrl; |
| 93 | /** @addrh: register address, high 32 bits */ |
| 94 | u32 addrh; |
Simon Glass | 4ffe8b0 | 2020-09-22 12:45:09 -0600 | [diff] [blame] | 95 | }; |
| 96 | |
Simon Glass | 858fed1 | 2020-04-08 16:57:36 -0600 | [diff] [blame] | 97 | /* A maximum number of 32 ACPI tables ought to be enough for now */ |
| 98 | #define MAX_ACPI_TABLES 32 |
| 99 | |
| 100 | /* RSDT (Root System Description Table) */ |
| 101 | struct acpi_rsdt { |
| 102 | struct acpi_table_header header; |
| 103 | u32 entry[MAX_ACPI_TABLES]; |
| 104 | }; |
| 105 | |
| 106 | /* XSDT (Extended System Description Table) */ |
Heinrich Schuchardt | bb307a6 | 2023-11-21 15:41:27 +0100 | [diff] [blame] | 107 | struct __packed acpi_xsdt { |
Simon Glass | 858fed1 | 2020-04-08 16:57:36 -0600 | [diff] [blame] | 108 | struct acpi_table_header header; |
| 109 | u64 entry[MAX_ACPI_TABLES]; |
| 110 | }; |
| 111 | |
Heinrich Schuchardt | b9291b4 | 2024-01-21 14:44:36 +0100 | [diff] [blame] | 112 | /** |
| 113 | * struct acpi_hpet: High Precision Event Timers (HETP) |
| 114 | * |
| 115 | * The structure is defined in the |
| 116 | * "IA-PC HPET (High Precision Event Timers) Specification", rev 1.0a, Oct 2004 |
| 117 | */ |
| 118 | struct acpi_hpet { |
| 119 | /** @header: table header */ |
Simon Glass | 4ffe8b0 | 2020-09-22 12:45:09 -0600 | [diff] [blame] | 120 | struct acpi_table_header header; |
Heinrich Schuchardt | b9291b4 | 2024-01-21 14:44:36 +0100 | [diff] [blame] | 121 | /** @id hardware ID of Event Timer Block */ |
Simon Glass | 4ffe8b0 | 2020-09-22 12:45:09 -0600 | [diff] [blame] | 122 | u32 id; |
Heinrich Schuchardt | b9291b4 | 2024-01-21 14:44:36 +0100 | [diff] [blame] | 123 | /** @addr: address of Event Timer Block */ |
Simon Glass | 4ffe8b0 | 2020-09-22 12:45:09 -0600 | [diff] [blame] | 124 | struct acpi_gen_regaddr addr; |
Heinrich Schuchardt | b9291b4 | 2024-01-21 14:44:36 +0100 | [diff] [blame] | 125 | /** @number: HPET sequence number */ |
Simon Glass | 4ffe8b0 | 2020-09-22 12:45:09 -0600 | [diff] [blame] | 126 | u8 number; |
Heinrich Schuchardt | b9291b4 | 2024-01-21 14:44:36 +0100 | [diff] [blame] | 127 | /** @min_tick: minimum clock ticks without lost interrupts */ |
Simon Glass | 4ffe8b0 | 2020-09-22 12:45:09 -0600 | [diff] [blame] | 128 | u16 min_tick; |
Heinrich Schuchardt | b9291b4 | 2024-01-21 14:44:36 +0100 | [diff] [blame] | 129 | /** @attributes: page protection and OEM atttribute */ |
Simon Glass | 4ffe8b0 | 2020-09-22 12:45:09 -0600 | [diff] [blame] | 130 | u8 attributes; |
Heinrich Schuchardt | b9291b4 | 2024-01-21 14:44:36 +0100 | [diff] [blame] | 131 | } __packed; |
Simon Glass | 4ffe8b0 | 2020-09-22 12:45:09 -0600 | [diff] [blame] | 132 | |
Simon Glass | 272a703 | 2020-09-22 12:45:32 -0600 | [diff] [blame] | 133 | struct __packed acpi_tpm2 { |
| 134 | struct acpi_table_header header; |
| 135 | u16 platform_class; |
| 136 | u8 reserved[2]; |
| 137 | u64 control_area; |
| 138 | u32 start_method; |
| 139 | u8 msp[12]; |
| 140 | u32 laml; |
| 141 | u64 lasa; |
| 142 | }; |
| 143 | |
Simon Glass | 2802628 | 2020-09-22 12:45:33 -0600 | [diff] [blame] | 144 | struct __packed acpi_tcpa { |
| 145 | struct acpi_table_header header; |
| 146 | u16 platform_class; |
| 147 | u32 laml; |
| 148 | u64 lasa; |
| 149 | }; |
| 150 | |
Simon Glass | 858fed1 | 2020-04-08 16:57:36 -0600 | [diff] [blame] | 151 | /* FADT Preferred Power Management Profile */ |
| 152 | enum acpi_pm_profile { |
| 153 | ACPI_PM_UNSPECIFIED = 0, |
| 154 | ACPI_PM_DESKTOP, |
| 155 | ACPI_PM_MOBILE, |
| 156 | ACPI_PM_WORKSTATION, |
| 157 | ACPI_PM_ENTERPRISE_SERVER, |
| 158 | ACPI_PM_SOHO_SERVER, |
| 159 | ACPI_PM_APPLIANCE_PC, |
| 160 | ACPI_PM_PERFORMANCE_SERVER, |
| 161 | ACPI_PM_TABLET |
| 162 | }; |
| 163 | |
| 164 | /* FADT flags for p_lvl2_lat and p_lvl3_lat */ |
| 165 | #define ACPI_FADT_C2_NOT_SUPPORTED 101 |
| 166 | #define ACPI_FADT_C3_NOT_SUPPORTED 1001 |
| 167 | |
| 168 | /* FADT Boot Architecture Flags */ |
| 169 | #define ACPI_FADT_LEGACY_FREE 0x00 |
| 170 | #define ACPI_FADT_LEGACY_DEVICES BIT(0) |
| 171 | #define ACPI_FADT_8042 BIT(1) |
| 172 | #define ACPI_FADT_VGA_NOT_PRESENT BIT(2) |
| 173 | #define ACPI_FADT_MSI_NOT_SUPPORTED BIT(3) |
| 174 | #define ACPI_FADT_NO_PCIE_ASPM_CONTROL BIT(4) |
| 175 | |
| 176 | /* FADT Feature Flags */ |
| 177 | #define ACPI_FADT_WBINVD BIT(0) |
| 178 | #define ACPI_FADT_WBINVD_FLUSH BIT(1) |
| 179 | #define ACPI_FADT_C1_SUPPORTED BIT(2) |
| 180 | #define ACPI_FADT_C2_MP_SUPPORTED BIT(3) |
| 181 | #define ACPI_FADT_POWER_BUTTON BIT(4) |
| 182 | #define ACPI_FADT_SLEEP_BUTTON BIT(5) |
| 183 | #define ACPI_FADT_FIXED_RTC BIT(6) |
| 184 | #define ACPI_FADT_S4_RTC_WAKE BIT(7) |
| 185 | #define ACPI_FADT_32BIT_TIMER BIT(8) |
| 186 | #define ACPI_FADT_DOCKING_SUPPORTED BIT(9) |
| 187 | #define ACPI_FADT_RESET_REGISTER BIT(10) |
| 188 | #define ACPI_FADT_SEALED_CASE BIT(11) |
| 189 | #define ACPI_FADT_HEADLESS BIT(12) |
| 190 | #define ACPI_FADT_SLEEP_TYPE BIT(13) |
| 191 | #define ACPI_FADT_PCI_EXPRESS_WAKE BIT(14) |
| 192 | #define ACPI_FADT_PLATFORM_CLOCK BIT(15) |
| 193 | #define ACPI_FADT_S4_RTC_VALID BIT(16) |
| 194 | #define ACPI_FADT_REMOTE_POWER_ON BIT(17) |
| 195 | #define ACPI_FADT_APIC_CLUSTER BIT(18) |
| 196 | #define ACPI_FADT_APIC_PHYSICAL BIT(19) |
| 197 | #define ACPI_FADT_HW_REDUCED_ACPI BIT(20) |
| 198 | #define ACPI_FADT_LOW_PWR_IDLE_S0 BIT(21) |
| 199 | |
Simon Glass | 3e11c8c | 2021-12-01 09:03:08 -0700 | [diff] [blame] | 200 | /* ARM boot flags */ |
| 201 | #define ACPI_ARM_PSCI_COMPLIANT BIT(0) |
| 202 | |
Simon Glass | 858fed1 | 2020-04-08 16:57:36 -0600 | [diff] [blame] | 203 | enum acpi_address_space_type { |
| 204 | ACPI_ADDRESS_SPACE_MEMORY = 0, /* System memory */ |
| 205 | ACPI_ADDRESS_SPACE_IO, /* System I/O */ |
| 206 | ACPI_ADDRESS_SPACE_PCI, /* PCI config space */ |
| 207 | ACPI_ADDRESS_SPACE_EC, /* Embedded controller */ |
| 208 | ACPI_ADDRESS_SPACE_SMBUS, /* SMBus */ |
| 209 | ACPI_ADDRESS_SPACE_PCC = 0x0a, /* Platform Comm. Channel */ |
| 210 | ACPI_ADDRESS_SPACE_FIXED = 0x7f /* Functional fixed hardware */ |
| 211 | }; |
| 212 | |
| 213 | enum acpi_address_space_size { |
| 214 | ACPI_ACCESS_SIZE_UNDEFINED = 0, |
| 215 | ACPI_ACCESS_SIZE_BYTE_ACCESS, |
| 216 | ACPI_ACCESS_SIZE_WORD_ACCESS, |
| 217 | ACPI_ACCESS_SIZE_DWORD_ACCESS, |
| 218 | ACPI_ACCESS_SIZE_QWORD_ACCESS |
| 219 | }; |
| 220 | |
Simon Glass | 858fed1 | 2020-04-08 16:57:36 -0600 | [diff] [blame] | 221 | /* FADT (Fixed ACPI Description Table) */ |
| 222 | struct __packed acpi_fadt { |
| 223 | struct acpi_table_header header; |
| 224 | u32 firmware_ctrl; |
| 225 | u32 dsdt; |
| 226 | u8 res1; |
| 227 | u8 preferred_pm_profile; |
| 228 | u16 sci_int; |
| 229 | u32 smi_cmd; |
| 230 | u8 acpi_enable; |
| 231 | u8 acpi_disable; |
| 232 | u8 s4bios_req; |
| 233 | u8 pstate_cnt; |
| 234 | u32 pm1a_evt_blk; |
| 235 | u32 pm1b_evt_blk; |
| 236 | u32 pm1a_cnt_blk; |
| 237 | u32 pm1b_cnt_blk; |
| 238 | u32 pm2_cnt_blk; |
| 239 | u32 pm_tmr_blk; |
| 240 | u32 gpe0_blk; |
| 241 | u32 gpe1_blk; |
| 242 | u8 pm1_evt_len; |
| 243 | u8 pm1_cnt_len; |
| 244 | u8 pm2_cnt_len; |
| 245 | u8 pm_tmr_len; |
| 246 | u8 gpe0_blk_len; |
| 247 | u8 gpe1_blk_len; |
| 248 | u8 gpe1_base; |
| 249 | u8 cst_cnt; |
| 250 | u16 p_lvl2_lat; |
| 251 | u16 p_lvl3_lat; |
| 252 | u16 flush_size; |
| 253 | u16 flush_stride; |
| 254 | u8 duty_offset; |
| 255 | u8 duty_width; |
| 256 | u8 day_alrm; |
| 257 | u8 mon_alrm; |
| 258 | u8 century; |
| 259 | u16 iapc_boot_arch; |
| 260 | u8 res2; |
| 261 | u32 flags; |
| 262 | struct acpi_gen_regaddr reset_reg; |
| 263 | u8 reset_value; |
| 264 | u16 arm_boot_arch; |
| 265 | u8 minor_revision; |
Heinrich Schuchardt | ec95806 | 2023-12-16 09:11:57 +0100 | [diff] [blame] | 266 | u64 x_firmware_ctrl; |
| 267 | u64 x_dsdt; |
Simon Glass | 858fed1 | 2020-04-08 16:57:36 -0600 | [diff] [blame] | 268 | struct acpi_gen_regaddr x_pm1a_evt_blk; |
| 269 | struct acpi_gen_regaddr x_pm1b_evt_blk; |
| 270 | struct acpi_gen_regaddr x_pm1a_cnt_blk; |
| 271 | struct acpi_gen_regaddr x_pm1b_cnt_blk; |
| 272 | struct acpi_gen_regaddr x_pm2_cnt_blk; |
| 273 | struct acpi_gen_regaddr x_pm_tmr_blk; |
| 274 | struct acpi_gen_regaddr x_gpe0_blk; |
| 275 | struct acpi_gen_regaddr x_gpe1_blk; |
Simon Glass | 3e11c8c | 2021-12-01 09:03:08 -0700 | [diff] [blame] | 276 | struct acpi_gen_regaddr sleep_control_reg; |
| 277 | struct acpi_gen_regaddr sleep_status_reg; |
| 278 | u64 hyp_vendor_id; |
Simon Glass | 858fed1 | 2020-04-08 16:57:36 -0600 | [diff] [blame] | 279 | }; |
| 280 | |
Simon Glass | b2672ea | 2020-04-08 16:57:38 -0600 | [diff] [blame] | 281 | /* FADT TABLE Revision values - note these do not match the ACPI revision */ |
| 282 | #define ACPI_FADT_REV_ACPI_1_0 1 |
| 283 | #define ACPI_FADT_REV_ACPI_2_0 3 |
| 284 | #define ACPI_FADT_REV_ACPI_3_0 4 |
| 285 | #define ACPI_FADT_REV_ACPI_4_0 4 |
| 286 | #define ACPI_FADT_REV_ACPI_5_0 5 |
| 287 | #define ACPI_FADT_REV_ACPI_6_0 6 |
| 288 | |
| 289 | /* MADT TABLE Revision values - note these do not match the ACPI revision */ |
| 290 | #define ACPI_MADT_REV_ACPI_3_0 2 |
| 291 | #define ACPI_MADT_REV_ACPI_4_0 3 |
| 292 | #define ACPI_MADT_REV_ACPI_5_0 3 |
| 293 | #define ACPI_MADT_REV_ACPI_6_0 5 |
| 294 | |
| 295 | #define ACPI_MCFG_REV_ACPI_3_0 1 |
| 296 | |
| 297 | /* IVRS Revision Field */ |
| 298 | #define IVRS_FORMAT_FIXED 0x01 /* Type 10h & 11h only */ |
| 299 | #define IVRS_FORMAT_MIXED 0x02 /* Type 10h, 11h, & 40h */ |
| 300 | |
Simon Glass | 858fed1 | 2020-04-08 16:57:36 -0600 | [diff] [blame] | 301 | /* FACS flags */ |
| 302 | #define ACPI_FACS_S4BIOS_F BIT(0) |
| 303 | #define ACPI_FACS_64BIT_WAKE_F BIT(1) |
| 304 | |
| 305 | /* FACS (Firmware ACPI Control Structure) */ |
| 306 | struct acpi_facs { |
Simon Glass | 48ca578 | 2020-09-22 12:45:39 -0600 | [diff] [blame] | 307 | char signature[ACPI_NAME_LEN]; /* "FACS" */ |
Simon Glass | 858fed1 | 2020-04-08 16:57:36 -0600 | [diff] [blame] | 308 | u32 length; /* Length in bytes (>= 64) */ |
| 309 | u32 hardware_signature; /* Hardware signature */ |
| 310 | u32 firmware_waking_vector; /* Firmware waking vector */ |
| 311 | u32 global_lock; /* Global lock */ |
| 312 | u32 flags; /* FACS flags */ |
| 313 | u32 x_firmware_waking_vector_l; /* X FW waking vector, low */ |
| 314 | u32 x_firmware_waking_vector_h; /* X FW waking vector, high */ |
| 315 | u8 version; /* Version 2 */ |
| 316 | u8 res1[3]; |
| 317 | u32 ospm_flags; /* OSPM enabled flags */ |
| 318 | u8 res2[24]; |
| 319 | }; |
| 320 | |
| 321 | /* MADT flags */ |
| 322 | #define ACPI_MADT_PCAT_COMPAT BIT(0) |
| 323 | |
| 324 | /* MADT (Multiple APIC Description Table) */ |
| 325 | struct acpi_madt { |
| 326 | struct acpi_table_header header; |
| 327 | u32 lapic_addr; /* Local APIC address */ |
| 328 | u32 flags; /* Multiple APIC flags */ |
| 329 | }; |
| 330 | |
| 331 | /* MADT: APIC Structure Type*/ |
| 332 | enum acpi_apic_types { |
| 333 | ACPI_APIC_LAPIC = 0, /* Processor local APIC */ |
| 334 | ACPI_APIC_IOAPIC, /* I/O APIC */ |
| 335 | ACPI_APIC_IRQ_SRC_OVERRIDE, /* Interrupt source override */ |
| 336 | ACPI_APIC_NMI_SRC, /* NMI source */ |
| 337 | ACPI_APIC_LAPIC_NMI, /* Local APIC NMI */ |
| 338 | ACPI_APIC_LAPIC_ADDR_OVERRIDE, /* Local APIC address override */ |
| 339 | ACPI_APIC_IOSAPIC, /* I/O SAPIC */ |
| 340 | ACPI_APIC_LSAPIC, /* Local SAPIC */ |
| 341 | ACPI_APIC_PLATFORM_IRQ_SRC, /* Platform interrupt sources */ |
| 342 | ACPI_APIC_LX2APIC, /* Processor local x2APIC */ |
| 343 | ACPI_APIC_LX2APIC_NMI, /* Local x2APIC NMI */ |
Simon Glass | 3e11c8c | 2021-12-01 09:03:08 -0700 | [diff] [blame] | 344 | ACPI_APIC_GICC, /* Generic Interrupt Ctlr CPU i/f */ |
| 345 | ACPI_APIC_GICD /* Generic Interrupt Ctlr Distributor */ |
Simon Glass | 858fed1 | 2020-04-08 16:57:36 -0600 | [diff] [blame] | 346 | }; |
| 347 | |
| 348 | /* MADT: Processor Local APIC Structure */ |
| 349 | |
| 350 | #define LOCAL_APIC_FLAG_ENABLED BIT(0) |
| 351 | |
| 352 | struct acpi_madt_lapic { |
| 353 | u8 type; /* Type (0) */ |
| 354 | u8 length; /* Length in bytes (8) */ |
| 355 | u8 processor_id; /* ACPI processor ID */ |
| 356 | u8 apic_id; /* Local APIC ID */ |
| 357 | u32 flags; /* Local APIC flags */ |
| 358 | }; |
| 359 | |
| 360 | /* MADT: I/O APIC Structure */ |
| 361 | struct acpi_madt_ioapic { |
| 362 | u8 type; /* Type (1) */ |
| 363 | u8 length; /* Length in bytes (12) */ |
| 364 | u8 ioapic_id; /* I/O APIC ID */ |
| 365 | u8 reserved; |
| 366 | u32 ioapic_addr; /* I/O APIC address */ |
| 367 | u32 gsi_base; /* Global system interrupt base */ |
| 368 | }; |
| 369 | |
| 370 | /* MADT: Interrupt Source Override Structure */ |
| 371 | struct __packed acpi_madt_irqoverride { |
| 372 | u8 type; /* Type (2) */ |
| 373 | u8 length; /* Length in bytes (10) */ |
| 374 | u8 bus; /* ISA (0) */ |
| 375 | u8 source; /* Bus-relative int. source (IRQ) */ |
| 376 | u32 gsirq; /* Global system interrupt */ |
| 377 | u16 flags; /* MPS INTI flags */ |
| 378 | }; |
| 379 | |
| 380 | /* MADT: Local APIC NMI Structure */ |
| 381 | struct __packed acpi_madt_lapic_nmi { |
| 382 | u8 type; /* Type (4) */ |
| 383 | u8 length; /* Length in bytes (6) */ |
| 384 | u8 processor_id; /* ACPI processor ID */ |
| 385 | u16 flags; /* MPS INTI flags */ |
| 386 | u8 lint; /* Local APIC LINT# */ |
| 387 | }; |
| 388 | |
Simon Glass | 3e11c8c | 2021-12-01 09:03:08 -0700 | [diff] [blame] | 389 | /* flags for acpi_madr_gicc flags word */ |
| 390 | enum { |
| 391 | ACPI_MADRF_ENABLED = BIT(0), |
| 392 | ACPI_MADRF_PERF = BIT(1), |
| 393 | ACPI_MADRF_VGIC = BIT(2), |
| 394 | }; |
| 395 | |
| 396 | /** |
| 397 | * struct __packed acpi_madr_gicc - GIC CPU interface (type 0xb) |
| 398 | * |
| 399 | * This holds information about the Generic Interrupt Controller (GIC) CPU |
| 400 | * interface. See ACPI Spec v6.3 section 5.2.12.14 |
| 401 | */ |
Heinrich Schuchardt | b9291b4 | 2024-01-21 14:44:36 +0100 | [diff] [blame] | 402 | struct acpi_madr_gicc { |
Simon Glass | 3e11c8c | 2021-12-01 09:03:08 -0700 | [diff] [blame] | 403 | u8 type; |
| 404 | u8 length; |
| 405 | u16 reserved; |
| 406 | u32 cpu_if_num; |
| 407 | u32 processor_id; |
| 408 | u32 flags; |
| 409 | u32 parking_proto; |
| 410 | u32 perf_gsiv; |
| 411 | u64 parked_addr; |
| 412 | u64 phys_base; |
| 413 | u64 gicv; |
| 414 | u64 gich; |
| 415 | u32 vgic_maint_irq; |
| 416 | u64 gicr_base; |
| 417 | u64 mpidr; |
| 418 | u8 efficiency; |
| 419 | u8 reserved2; |
| 420 | u16 spi_overflow_irq; |
Heinrich Schuchardt | b9291b4 | 2024-01-21 14:44:36 +0100 | [diff] [blame] | 421 | } __packed; |
Simon Glass | 3e11c8c | 2021-12-01 09:03:08 -0700 | [diff] [blame] | 422 | |
| 423 | /** |
| 424 | * struct __packed acpi_madr_gicc - GIC distributor (type 0xc) |
| 425 | * |
| 426 | * This holds information about the Generic Interrupt Controller (GIC) |
| 427 | * Distributor interface. See ACPI Spec v6.3 section 5.2.12.15 |
| 428 | */ |
Heinrich Schuchardt | b9291b4 | 2024-01-21 14:44:36 +0100 | [diff] [blame] | 429 | struct acpi_madr_gicd { |
Simon Glass | 3e11c8c | 2021-12-01 09:03:08 -0700 | [diff] [blame] | 430 | u8 type; |
| 431 | u8 length; |
| 432 | u16 reserved; |
| 433 | u32 gic_id; |
| 434 | u64 phys_base; |
| 435 | u32 reserved2; |
| 436 | u8 gic_version; |
| 437 | u8 reserved3[3]; |
Heinrich Schuchardt | b9291b4 | 2024-01-21 14:44:36 +0100 | [diff] [blame] | 438 | } __packed; |
Simon Glass | 3e11c8c | 2021-12-01 09:03:08 -0700 | [diff] [blame] | 439 | |
Simon Glass | 858fed1 | 2020-04-08 16:57:36 -0600 | [diff] [blame] | 440 | /* MCFG (PCI Express MMIO config space BAR description table) */ |
| 441 | struct acpi_mcfg { |
| 442 | struct acpi_table_header header; |
| 443 | u8 reserved[8]; |
| 444 | }; |
| 445 | |
| 446 | struct acpi_mcfg_mmconfig { |
| 447 | u32 base_address_l; |
| 448 | u32 base_address_h; |
| 449 | u16 pci_segment_group_number; |
| 450 | u8 start_bus_number; |
| 451 | u8 end_bus_number; |
| 452 | u8 reserved[4]; |
| 453 | }; |
| 454 | |
| 455 | /* PM1_CNT bit defines */ |
| 456 | #define PM1_CNT_SCI_EN BIT(0) |
| 457 | |
| 458 | /* ACPI global NVS structure */ |
| 459 | struct acpi_global_nvs; |
| 460 | |
| 461 | /* CSRT (Core System Resource Table) */ |
| 462 | struct acpi_csrt { |
| 463 | struct acpi_table_header header; |
| 464 | }; |
| 465 | |
Simon Glass | 3e11c8c | 2021-12-01 09:03:08 -0700 | [diff] [blame] | 466 | /** |
| 467 | * struct acpi_csrt_group - header for a group within the CSRT |
| 468 | * |
| 469 | * The CSRT consists of one or more groups and this is the header for each |
| 470 | * |
| 471 | * See Core System Resources Table (CSRT), March 13, 2017, Microsoft Corporation |
| 472 | * for details |
| 473 | * |
| 474 | * https://uefi.org/sites/default/files/resources/CSRT%20v2.pdf |
| 475 | * |
| 476 | * @shared_info_length indicates the number of shared-info bytes following this |
| 477 | * struct (which may be 0) |
| 478 | */ |
Simon Glass | 858fed1 | 2020-04-08 16:57:36 -0600 | [diff] [blame] | 479 | struct acpi_csrt_group { |
| 480 | u32 length; |
| 481 | u32 vendor_id; |
| 482 | u32 subvendor_id; |
| 483 | u16 device_id; |
| 484 | u16 subdevice_id; |
| 485 | u16 revision; |
| 486 | u16 reserved; |
| 487 | u32 shared_info_length; |
| 488 | }; |
| 489 | |
Simon Glass | 3e11c8c | 2021-12-01 09:03:08 -0700 | [diff] [blame] | 490 | /** |
| 491 | * struct acpi_csrt_descriptor - describes the information that follows |
| 492 | * |
| 493 | * See the spec as above for details |
| 494 | */ |
| 495 | struct acpi_csrt_descriptor { |
| 496 | u32 length; |
| 497 | u16 type; |
| 498 | u16 subtype; |
| 499 | u32 uid; |
| 500 | }; |
| 501 | |
| 502 | /** |
| 503 | * struct acpi_csrt_shared_info - shared info for Intel tangier |
| 504 | * |
| 505 | * This provides the shared info for this particular board. Notes that the CSRT |
| 506 | * does not describe the format of data, so this format may not be used by any |
| 507 | * other board. |
| 508 | */ |
Simon Glass | 858fed1 | 2020-04-08 16:57:36 -0600 | [diff] [blame] | 509 | struct acpi_csrt_shared_info { |
| 510 | u16 major_version; |
| 511 | u16 minor_version; |
| 512 | u32 mmio_base_low; |
| 513 | u32 mmio_base_high; |
| 514 | u32 gsi_interrupt; |
| 515 | u8 interrupt_polarity; |
| 516 | u8 interrupt_mode; |
| 517 | u8 num_channels; |
| 518 | u8 dma_address_width; |
| 519 | u16 base_request_line; |
| 520 | u16 num_handshake_signals; |
| 521 | u32 max_block_size; |
| 522 | }; |
| 523 | |
Simon Glass | 87cf8d2 | 2020-09-22 12:45:16 -0600 | [diff] [blame] | 524 | /* Port types for ACPI _UPC object */ |
| 525 | enum acpi_upc_type { |
| 526 | UPC_TYPE_A, |
| 527 | UPC_TYPE_MINI_AB, |
| 528 | UPC_TYPE_EXPRESSCARD, |
| 529 | UPC_TYPE_USB3_A, |
| 530 | UPC_TYPE_USB3_B, |
| 531 | UPC_TYPE_USB3_MICRO_B, |
| 532 | UPC_TYPE_USB3_MICRO_AB, |
| 533 | UPC_TYPE_USB3_POWER_B, |
| 534 | UPC_TYPE_C_USB2_ONLY, |
| 535 | UPC_TYPE_C_USB2_SS_SWITCH, |
| 536 | UPC_TYPE_C_USB2_SS, |
| 537 | UPC_TYPE_PROPRIETARY = 0xff, |
| 538 | /* |
| 539 | * The following types are not directly defined in the ACPI |
| 540 | * spec but are used by coreboot to identify a USB device type. |
| 541 | */ |
| 542 | UPC_TYPE_INTERNAL = 0xff, |
| 543 | UPC_TYPE_UNUSED, |
| 544 | UPC_TYPE_HUB |
| 545 | }; |
| 546 | |
| 547 | enum dev_scope_type { |
| 548 | SCOPE_PCI_ENDPOINT = 1, |
| 549 | SCOPE_PCI_SUB = 2, |
| 550 | SCOPE_IOAPIC = 3, |
| 551 | SCOPE_MSI_HPET = 4, |
| 552 | SCOPE_ACPI_NAMESPACE_DEVICE = 5 |
| 553 | }; |
| 554 | |
| 555 | struct __packed dev_scope { |
| 556 | u8 type; |
| 557 | u8 length; |
| 558 | u8 reserved[2]; |
| 559 | u8 enumeration; |
| 560 | u8 start_bus; |
| 561 | struct { |
| 562 | u8 dev; |
| 563 | u8 fn; |
| 564 | } __packed path[0]; |
| 565 | }; |
| 566 | |
Simon Glass | e962989 | 2020-04-08 16:57:39 -0600 | [diff] [blame] | 567 | enum dmar_type { |
| 568 | DMAR_DRHD = 0, |
| 569 | DMAR_RMRR = 1, |
| 570 | DMAR_ATSR = 2, |
| 571 | DMAR_RHSA = 3, |
| 572 | DMAR_ANDD = 4 |
| 573 | }; |
| 574 | |
| 575 | enum { |
| 576 | DRHD_INCLUDE_PCI_ALL = BIT(0) |
| 577 | }; |
| 578 | |
| 579 | enum dmar_flags { |
| 580 | DMAR_INTR_REMAP = BIT(0), |
| 581 | DMAR_X2APIC_OPT_OUT = BIT(1), |
| 582 | DMAR_CTRL_PLATFORM_OPT_IN_FLAG = BIT(2), |
| 583 | }; |
| 584 | |
| 585 | struct dmar_entry { |
| 586 | u16 type; |
| 587 | u16 length; |
| 588 | u8 flags; |
| 589 | u8 reserved; |
| 590 | u16 segment; |
| 591 | u64 bar; |
| 592 | }; |
| 593 | |
| 594 | struct dmar_rmrr_entry { |
| 595 | u16 type; |
| 596 | u16 length; |
| 597 | u16 reserved; |
| 598 | u16 segment; |
| 599 | u64 bar; |
| 600 | u64 limit; |
| 601 | }; |
| 602 | |
| 603 | /* DMAR (DMA Remapping Reporting Structure) */ |
| 604 | struct __packed acpi_dmar { |
| 605 | struct acpi_table_header header; |
| 606 | u8 host_address_width; |
| 607 | u8 flags; |
| 608 | u8 reserved[10]; |
| 609 | struct dmar_entry structure[0]; |
| 610 | }; |
| 611 | |
Simon Glass | 858fed1 | 2020-04-08 16:57:36 -0600 | [diff] [blame] | 612 | /* DBG2 definitions are partially used for SPCR interface_type */ |
| 613 | |
| 614 | /* Types for port_type field */ |
| 615 | |
| 616 | #define ACPI_DBG2_SERIAL_PORT 0x8000 |
| 617 | #define ACPI_DBG2_1394_PORT 0x8001 |
| 618 | #define ACPI_DBG2_USB_PORT 0x8002 |
| 619 | #define ACPI_DBG2_NET_PORT 0x8003 |
| 620 | |
| 621 | /* Subtypes for port_subtype field */ |
| 622 | |
| 623 | #define ACPI_DBG2_16550_COMPATIBLE 0x0000 |
| 624 | #define ACPI_DBG2_16550_SUBSET 0x0001 |
| 625 | #define ACPI_DBG2_ARM_PL011 0x0003 |
| 626 | #define ACPI_DBG2_ARM_SBSA_32BIT 0x000D |
| 627 | #define ACPI_DBG2_ARM_SBSA_GENERIC 0x000E |
| 628 | #define ACPI_DBG2_ARM_DCC 0x000F |
| 629 | #define ACPI_DBG2_BCM2835 0x0010 |
| 630 | |
| 631 | #define ACPI_DBG2_1394_STANDARD 0x0000 |
| 632 | |
| 633 | #define ACPI_DBG2_USB_XHCI 0x0000 |
| 634 | #define ACPI_DBG2_USB_EHCI 0x0001 |
| 635 | |
| 636 | #define ACPI_DBG2_UNKNOWN 0x00FF |
| 637 | |
Simon Glass | 9597189 | 2020-09-22 12:45:10 -0600 | [diff] [blame] | 638 | /* DBG2: Microsoft Debug Port Table 2 header */ |
| 639 | struct __packed acpi_dbg2_header { |
| 640 | struct acpi_table_header header; |
| 641 | u32 devices_offset; |
| 642 | u32 devices_count; |
| 643 | }; |
| 644 | |
| 645 | /* DBG2: Microsoft Debug Port Table 2 device entry */ |
| 646 | struct __packed acpi_dbg2_device { |
| 647 | u8 revision; |
| 648 | u16 length; |
| 649 | u8 address_count; |
| 650 | u16 namespace_string_length; |
| 651 | u16 namespace_string_offset; |
| 652 | u16 oem_data_length; |
| 653 | u16 oem_data_offset; |
| 654 | u16 port_type; |
| 655 | u16 port_subtype; |
| 656 | u8 reserved[2]; |
| 657 | u16 base_address_offset; |
| 658 | u16 address_size_offset; |
| 659 | }; |
| 660 | |
Simon Glass | 858fed1 | 2020-04-08 16:57:36 -0600 | [diff] [blame] | 661 | /* SPCR (Serial Port Console Redirection table) */ |
| 662 | struct __packed acpi_spcr { |
| 663 | struct acpi_table_header header; |
| 664 | u8 interface_type; |
| 665 | u8 reserved[3]; |
| 666 | struct acpi_gen_regaddr serial_port; |
| 667 | u8 interrupt_type; |
| 668 | u8 pc_interrupt; |
| 669 | u32 interrupt; /* Global system interrupt */ |
| 670 | u8 baud_rate; |
| 671 | u8 parity; |
| 672 | u8 stop_bits; |
| 673 | u8 flow_control; |
| 674 | u8 terminal_type; |
| 675 | u8 reserved1; |
| 676 | u16 pci_device_id; /* Must be 0xffff if not PCI device */ |
| 677 | u16 pci_vendor_id; /* Must be 0xffff if not PCI device */ |
| 678 | u8 pci_bus; |
| 679 | u8 pci_device; |
| 680 | u8 pci_function; |
| 681 | u32 pci_flags; |
| 682 | u8 pci_segment; |
| 683 | u32 reserved2; |
| 684 | }; |
| 685 | |
Simon Glass | 3e11c8c | 2021-12-01 09:03:08 -0700 | [diff] [blame] | 686 | /** |
| 687 | * struct acpi_gtdt - Generic Timer Description Table (GTDT) |
| 688 | * |
| 689 | * See ACPI Spec v6.3 section 5.2.24 for details |
| 690 | */ |
Heinrich Schuchardt | b9291b4 | 2024-01-21 14:44:36 +0100 | [diff] [blame] | 691 | struct acpi_gtdt { |
Simon Glass | 3e11c8c | 2021-12-01 09:03:08 -0700 | [diff] [blame] | 692 | struct acpi_table_header header; |
| 693 | u64 cnt_ctrl_base; |
| 694 | u32 reserved0; |
| 695 | u32 sec_el1_gsiv; |
| 696 | u32 sec_el1_flags; |
| 697 | u32 el1_gsiv; |
| 698 | u32 el1_flags; |
| 699 | u32 virt_el1_gsiv; |
| 700 | u32 virt_el1_flags; |
| 701 | u32 el2_gsiv; |
| 702 | u32 el2_flags; |
| 703 | u64 cnt_read_base; |
| 704 | u32 plat_timer_count; |
| 705 | u32 plat_timer_offset; |
| 706 | u32 virt_el2_gsiv; |
| 707 | u32 virt_el2_flags; |
Heinrich Schuchardt | b9291b4 | 2024-01-21 14:44:36 +0100 | [diff] [blame] | 708 | } __packed; |
Simon Glass | 3e11c8c | 2021-12-01 09:03:08 -0700 | [diff] [blame] | 709 | |
| 710 | /** |
| 711 | * struct acpi_bgrt - Boot Graphics Resource Table (BGRT) |
| 712 | * |
| 713 | * Optional table that provides a mechanism to indicate that an image was drawn |
| 714 | * on the screen during boot, and some information about the image. |
| 715 | * |
| 716 | * See ACPI Spec v6.3 section 5.2.22 for details |
| 717 | */ |
Heinrich Schuchardt | b9291b4 | 2024-01-21 14:44:36 +0100 | [diff] [blame] | 718 | struct acpi_bgrt { |
Simon Glass | 3e11c8c | 2021-12-01 09:03:08 -0700 | [diff] [blame] | 719 | struct acpi_table_header header; |
| 720 | u16 version; |
| 721 | u8 status; |
| 722 | u8 image_type; |
| 723 | u64 addr; |
| 724 | u32 offset_x; |
| 725 | u32 offset_y; |
Heinrich Schuchardt | b9291b4 | 2024-01-21 14:44:36 +0100 | [diff] [blame] | 726 | } __packed; |
Simon Glass | 3e11c8c | 2021-12-01 09:03:08 -0700 | [diff] [blame] | 727 | |
| 728 | /* Types for PPTT */ |
| 729 | #define ACPI_PPTT_TYPE_PROC 0 |
| 730 | #define ACPI_PPTT_TYPE_CACHE 1 |
| 731 | |
| 732 | /* Flags for PPTT */ |
| 733 | #define ACPI_PPTT_PHYSICAL_PACKAGE BIT(0) |
| 734 | #define ACPI_PPTT_PROC_ID_VALID BIT(1) |
| 735 | #define ACPI_PPTT_PROC_IS_THREAD BIT(2) |
| 736 | #define ACPI_PPTT_NODE_IS_LEAF BIT(3) |
| 737 | #define ACPI_PPTT_CHILDREN_IDENTICAL BIT(4) |
| 738 | |
| 739 | /** |
| 740 | * struct acpi_pptt_header - Processor Properties Topology Table (PPTT) header |
| 741 | * |
| 742 | * Describes the topological structure of processors and their shared resources, |
| 743 | * such as caches. |
| 744 | * |
| 745 | * See ACPI Spec v6.3 section 5.2.29 for details |
| 746 | */ |
Heinrich Schuchardt | b9291b4 | 2024-01-21 14:44:36 +0100 | [diff] [blame] | 747 | struct acpi_pptt_header { |
Simon Glass | 3e11c8c | 2021-12-01 09:03:08 -0700 | [diff] [blame] | 748 | u8 type; /* ACPI_PPTT_TYPE_... */ |
| 749 | u8 length; |
| 750 | u16 reserved; |
Heinrich Schuchardt | b9291b4 | 2024-01-21 14:44:36 +0100 | [diff] [blame] | 751 | } __packed; |
Simon Glass | 3e11c8c | 2021-12-01 09:03:08 -0700 | [diff] [blame] | 752 | |
| 753 | /** |
| 754 | * struct acpi_pptt_proc - a processor as described by PPTT |
| 755 | */ |
Heinrich Schuchardt | b9291b4 | 2024-01-21 14:44:36 +0100 | [diff] [blame] | 756 | struct acpi_pptt_proc { |
Simon Glass | 3e11c8c | 2021-12-01 09:03:08 -0700 | [diff] [blame] | 757 | struct acpi_pptt_header hdr; |
| 758 | u32 flags; |
| 759 | u32 parent; |
| 760 | u32 proc_id; |
| 761 | u32 num_resources; |
Heinrich Schuchardt | b9291b4 | 2024-01-21 14:44:36 +0100 | [diff] [blame] | 762 | } __packed; |
Simon Glass | 3e11c8c | 2021-12-01 09:03:08 -0700 | [diff] [blame] | 763 | |
| 764 | /* Cache flags for acpi_pptt_cache */ |
| 765 | #define ACPI_PPTT_SIZE_VALID BIT(0) |
| 766 | #define ACPI_PPTT_SETS_VALID BIT(1) |
| 767 | #define ACPI_PPTT_ASSOC_VALID BIT(2) |
| 768 | #define ACPI_PPTT_ALLOC_TYPE_VALID BIT(3) |
| 769 | #define ACPI_PPTT_CACHE_TYPE_VALID BIT(4) |
| 770 | #define ACPI_PPTT_WRITE_POLICY_VALID BIT(5) |
| 771 | #define ACPI_PPTT_LINE_SIZE_VALID BIT(6) |
| 772 | |
| 773 | #define ACPI_PPTT_ALL_VALID 0x7f |
| 774 | #define ACPI_PPTT_ALL_BUT_WRITE_POL 0x5f |
| 775 | |
| 776 | #define ACPI_PPTT_READ_ALLOC BIT(0) |
| 777 | #define ACPI_PPTT_WRITE_ALLOC BIT(1) |
| 778 | #define ACPI_PPTT_CACHE_TYPE_SHIFT 2 |
| 779 | #define ACPI_PPTT_CACHE_TYPE_MASK (3 << ACPI_PPTT_CACHE_TYPE_SHIFT) |
| 780 | #define ACPI_PPTT_CACHE_TYPE_DATA 0 |
| 781 | #define ACPI_PPTT_CACHE_TYPE_INSTR 1 |
| 782 | #define ACPI_PPTT_CACHE_TYPE_UNIFIED 2 |
| 783 | #define ACPI_PPTT_CACHE_TYPE_DATA 0 |
| 784 | #define ACPI_PPTT_WRITE_THROUGH BIT(4) |
| 785 | |
| 786 | /** |
| 787 | * struct acpi_pptt_cache - a cache as described by PPTT |
| 788 | */ |
Heinrich Schuchardt | b9291b4 | 2024-01-21 14:44:36 +0100 | [diff] [blame] | 789 | struct acpi_pptt_cache { |
Simon Glass | 3e11c8c | 2021-12-01 09:03:08 -0700 | [diff] [blame] | 790 | struct acpi_pptt_header hdr; |
| 791 | u32 flags; |
| 792 | u32 next_cache_level; |
| 793 | u32 size; |
| 794 | u32 sets; |
| 795 | u8 assoc; |
| 796 | u8 attributes; |
| 797 | u16 line_size; |
Heinrich Schuchardt | b9291b4 | 2024-01-21 14:44:36 +0100 | [diff] [blame] | 798 | } __packed; |
Simon Glass | 3e11c8c | 2021-12-01 09:03:08 -0700 | [diff] [blame] | 799 | |
Simon Glass | b2672ea | 2020-04-08 16:57:38 -0600 | [diff] [blame] | 800 | /* Tables defined/reserved by ACPI and generated by U-Boot */ |
| 801 | enum acpi_tables { |
| 802 | ACPITAB_BERT, |
| 803 | ACPITAB_DBG2, |
| 804 | ACPITAB_DMAR, |
| 805 | ACPITAB_DSDT, |
| 806 | ACPITAB_ECDT, |
| 807 | ACPITAB_FACS, |
| 808 | ACPITAB_FADT, |
| 809 | ACPITAB_HEST, |
| 810 | ACPITAB_HPET, |
| 811 | ACPITAB_IVRS, |
| 812 | ACPITAB_MADT, |
| 813 | ACPITAB_MCFG, |
| 814 | ACPITAB_NHLT, |
| 815 | ACPITAB_RSDP, |
| 816 | ACPITAB_RSDT, |
| 817 | ACPITAB_SLIT, |
| 818 | ACPITAB_SPCR, |
| 819 | ACPITAB_SPMI, |
| 820 | ACPITAB_SRAT, |
| 821 | ACPITAB_SSDT, |
| 822 | ACPITAB_TCPA, |
| 823 | ACPITAB_TPM2, |
| 824 | ACPITAB_VFCT, |
| 825 | ACPITAB_XSDT, |
| 826 | |
| 827 | ACPITAB_COUNT, |
| 828 | }; |
| 829 | |
| 830 | /** |
| 831 | * acpi_get_table_revision() - Get the revision number generated for a table |
| 832 | * |
| 833 | * This keeps the version-number information in one place |
| 834 | * |
| 835 | * @table: ACPI table to check |
Heinrich Schuchardt | 47b4c02 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 836 | * Return: version number that U-Boot generates |
Simon Glass | b2672ea | 2020-04-08 16:57:38 -0600 | [diff] [blame] | 837 | */ |
| 838 | int acpi_get_table_revision(enum acpi_tables table); |
| 839 | |
Simon Glass | e962989 | 2020-04-08 16:57:39 -0600 | [diff] [blame] | 840 | /** |
| 841 | * acpi_create_dmar() - Create a DMA Remapping Reporting (DMAR) table |
| 842 | * |
| 843 | * @dmar: Place to put the table |
| 844 | * @flags: DMAR flags to use |
Heinrich Schuchardt | 47b4c02 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 845 | * Return: 0 if OK, -ve on error |
Simon Glass | e962989 | 2020-04-08 16:57:39 -0600 | [diff] [blame] | 846 | */ |
| 847 | int acpi_create_dmar(struct acpi_dmar *dmar, enum dmar_flags flags); |
| 848 | |
Simon Glass | 17968c3 | 2020-04-26 09:19:46 -0600 | [diff] [blame] | 849 | /** |
Simon Glass | 9597189 | 2020-09-22 12:45:10 -0600 | [diff] [blame] | 850 | * acpi_create_dbg2() - Create a DBG2 table |
| 851 | * |
| 852 | * This table describes how to access the debug UART |
| 853 | * |
| 854 | * @dbg2: Place to put information |
| 855 | * @port_type: Serial port type (see ACPI_DBG2_...) |
| 856 | * @port_subtype: Serial port sub-type (see ACPI_DBG2_...) |
| 857 | * @address: ACPI address of port |
| 858 | * @address_size: Size of address space |
| 859 | * @device_path: Path of device (created using acpi_device_path()) |
| 860 | */ |
| 861 | void acpi_create_dbg2(struct acpi_dbg2_header *dbg2, |
| 862 | int port_type, int port_subtype, |
| 863 | struct acpi_gen_regaddr *address, uint32_t address_size, |
| 864 | const char *device_path); |
| 865 | |
| 866 | /** |
Simon Glass | 0e11384 | 2020-04-26 09:19:47 -0600 | [diff] [blame] | 867 | * acpi_align() - Align the ACPI output pointer to a 16-byte boundary |
| 868 | * |
| 869 | * @ctx: ACPI context |
| 870 | */ |
| 871 | void acpi_align(struct acpi_ctx *ctx); |
| 872 | |
| 873 | /** |
| 874 | * acpi_align64() - Align the ACPI output pointer to a 64-byte boundary |
| 875 | * |
| 876 | * @ctx: ACPI context |
| 877 | */ |
| 878 | void acpi_align64(struct acpi_ctx *ctx); |
| 879 | |
| 880 | /** |
| 881 | * acpi_inc() - Increment the ACPI output pointer by a bit |
| 882 | * |
| 883 | * The pointer is NOT aligned afterwards. |
| 884 | * |
| 885 | * @ctx: ACPI context |
| 886 | * @amount: Amount to increment by |
| 887 | */ |
| 888 | void acpi_inc(struct acpi_ctx *ctx, uint amount); |
| 889 | |
| 890 | /** |
| 891 | * acpi_inc_align() - Increment the ACPI output pointer by a bit and align |
| 892 | * |
| 893 | * The pointer is aligned afterwards to a 16-byte boundary |
| 894 | * |
| 895 | * @ctx: ACPI context |
| 896 | * @amount: Amount to increment by |
| 897 | */ |
| 898 | void acpi_inc_align(struct acpi_ctx *ctx, uint amount); |
| 899 | |
Simon Glass | 575a547 | 2020-04-26 09:19:50 -0600 | [diff] [blame] | 900 | /** |
| 901 | * acpi_add_table() - Add a new table to the RSDP and XSDT |
| 902 | * |
| 903 | * @ctx: ACPI context |
| 904 | * @table: Table to add |
Heinrich Schuchardt | 47b4c02 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 905 | * Return: 0 if OK, -E2BIG if too many tables |
Simon Glass | 575a547 | 2020-04-26 09:19:50 -0600 | [diff] [blame] | 906 | */ |
| 907 | int acpi_add_table(struct acpi_ctx *ctx, void *table); |
| 908 | |
Andy Shevchenko | 6f15ab7 | 2023-09-01 11:27:10 -0600 | [diff] [blame] | 909 | static inline int acpi_add_fadt(struct acpi_ctx *ctx, struct acpi_fadt *fadt) |
| 910 | { |
| 911 | acpi_add_table(ctx, fadt); |
| 912 | acpi_inc(ctx, sizeof(struct acpi_fadt)); |
| 913 | return 0; |
| 914 | } |
| 915 | |
Simon Glass | 9c442a6 | 2020-04-26 09:19:51 -0600 | [diff] [blame] | 916 | /** |
Simon Glass | 5d093f3 | 2020-11-04 09:57:25 -0700 | [diff] [blame] | 917 | * acpi_write_rsdp() - Write out an RSDP indicating where the ACPI tables are |
| 918 | * |
| 919 | * @rsdp: Address to write RSDP |
| 920 | * @rsdt: Address of RSDT |
| 921 | * @xsdt: Address of XSDT |
| 922 | */ |
| 923 | void acpi_write_rsdp(struct acpi_rsdp *rsdp, struct acpi_rsdt *rsdt, |
| 924 | struct acpi_xsdt *xsdt); |
| 925 | |
Simon Glass | 96bf433 | 2021-12-01 09:02:45 -0700 | [diff] [blame] | 926 | /** |
| 927 | * acpi_fill_header() - Set up a table header |
| 928 | * |
| 929 | * @header: Pointer to header to set up |
| 930 | * @signature: 4-character signature to use (e.g. "FACS") |
| 931 | */ |
| 932 | void acpi_fill_header(struct acpi_table_header *header, char *signature); |
| 933 | |
Simon Glass | 89ce519 | 2021-12-01 09:03:01 -0700 | [diff] [blame] | 934 | /** |
| 935 | * acpi_fill_csrt() - Fill out the body of the CSRT |
| 936 | * |
| 937 | * This should write the contents of the Core System Resource Table (CSRT) |
| 938 | * to the context. The header (struct acpi_table_header) has already been |
| 939 | * written. |
| 940 | * |
| 941 | * @ctx: ACPI context to write to |
| 942 | * @return 0 if OK, -ve on error |
| 943 | */ |
| 944 | int acpi_fill_csrt(struct acpi_ctx *ctx); |
| 945 | |
Simon Glass | b0da223 | 2022-01-29 14:30:52 -0700 | [diff] [blame] | 946 | /** |
Heinrich Schuchardt | 2c1fd4a | 2023-11-09 09:23:02 -0800 | [diff] [blame] | 947 | * acpi_get_rsdp_addr() - get ACPI RSDP table address |
| 948 | * |
| 949 | * This routine returns the ACPI RSDP table address in the system memory. |
| 950 | * |
| 951 | * @return: ACPI RSDP table address |
| 952 | */ |
| 953 | ulong acpi_get_rsdp_addr(void); |
| 954 | |
| 955 | /** |
Simon Glass | b0da223 | 2022-01-29 14:30:52 -0700 | [diff] [blame] | 956 | * write_acpi_tables() - Write out the ACPI tables |
| 957 | * |
| 958 | * This writes all ACPI tables to the given address |
| 959 | * |
| 960 | * @start: Start address for the tables |
| 961 | * @return address of end of tables, where the next tables can be written |
| 962 | */ |
| 963 | ulong write_acpi_tables(ulong start); |
| 964 | |
Simon Glass | 7ae6976 | 2023-05-04 16:54:58 -0600 | [diff] [blame] | 965 | /** |
| 966 | * acpi_find_table() - Look up an ACPI table |
| 967 | * |
| 968 | * @sig: Signature of table (4 characters, upper case) |
| 969 | * Return: pointer to table header, or NULL if not found |
| 970 | */ |
| 971 | struct acpi_table_header *acpi_find_table(const char *sig); |
| 972 | |
Simon Glass | 4969d21 | 2020-04-08 16:57:37 -0600 | [diff] [blame] | 973 | #endif /* !__ACPI__*/ |
| 974 | |
Simon Glass | 858fed1 | 2020-04-08 16:57:36 -0600 | [diff] [blame] | 975 | #include <asm/acpi_table.h> |
| 976 | |
| 977 | #endif /* __ACPI_TABLE_H__ */ |