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