Simon Glass | 776cc20 | 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 | cd93d62 | 2020-05-10 11:40:13 -0600 | [diff] [blame] | 16 | #include <linux/bitops.h> |
| 17 | |
Simon Glass | 776cc20 | 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 | d262898 | 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 | 776cc20 | 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 | 89c2798 | 2020-04-08 16:57:37 -0600 | [diff] [blame] | 29 | #if !defined(__ACPI__) |
| 30 | |
Simon Glass | 86e1778 | 2020-04-26 09:19:47 -0600 | [diff] [blame] | 31 | struct acpi_ctx; |
| 32 | |
Simon Glass | 776cc20 | 2020-04-08 16:57:36 -0600 | [diff] [blame] | 33 | /* |
| 34 | * RSDP (Root System Description Pointer) |
| 35 | * Note: ACPI 1.0 didn't have length, xsdt_address, and ext_checksum |
| 36 | */ |
| 37 | struct acpi_rsdp { |
| 38 | char signature[8]; /* RSDP signature */ |
| 39 | u8 checksum; /* Checksum of the first 20 bytes */ |
| 40 | char oem_id[6]; /* OEM ID */ |
| 41 | u8 revision; /* 0 for ACPI 1.0, others 2 */ |
| 42 | u32 rsdt_address; /* Physical address of RSDT (32 bits) */ |
| 43 | u32 length; /* Total RSDP length (incl. extended part) */ |
| 44 | u64 xsdt_address; /* Physical address of XSDT (64 bits) */ |
| 45 | u8 ext_checksum; /* Checksum of the whole table */ |
| 46 | u8 reserved[3]; |
| 47 | }; |
| 48 | |
| 49 | /* Generic ACPI header, provided by (almost) all tables */ |
| 50 | struct __packed acpi_table_header { |
| 51 | char signature[4]; /* ACPI signature (4 ASCII characters) */ |
| 52 | u32 length; /* Table length in bytes (incl. header) */ |
| 53 | u8 revision; /* Table version (not ACPI version!) */ |
| 54 | volatile u8 checksum; /* To make sum of entire table == 0 */ |
| 55 | char oem_id[6]; /* OEM identification */ |
| 56 | char oem_table_id[8]; /* OEM table identification */ |
| 57 | u32 oem_revision; /* OEM revision number */ |
| 58 | char aslc_id[4]; /* ASL compiler vendor ID */ |
| 59 | u32 aslc_revision; /* ASL compiler revision number */ |
| 60 | }; |
| 61 | |
Simon Glass | d262898 | 2020-09-22 12:45:09 -0600 | [diff] [blame^] | 62 | struct acpi_gen_regaddr { |
| 63 | u8 space_id; /* Address space ID */ |
| 64 | u8 bit_width; /* Register size in bits */ |
| 65 | u8 bit_offset; /* Register bit offset */ |
| 66 | u8 access_size; /* Access size */ |
| 67 | u32 addrl; /* Register address, low 32 bits */ |
| 68 | u32 addrh; /* Register address, high 32 bits */ |
| 69 | }; |
| 70 | |
Simon Glass | 776cc20 | 2020-04-08 16:57:36 -0600 | [diff] [blame] | 71 | /* A maximum number of 32 ACPI tables ought to be enough for now */ |
| 72 | #define MAX_ACPI_TABLES 32 |
| 73 | |
| 74 | /* RSDT (Root System Description Table) */ |
| 75 | struct acpi_rsdt { |
| 76 | struct acpi_table_header header; |
| 77 | u32 entry[MAX_ACPI_TABLES]; |
| 78 | }; |
| 79 | |
| 80 | /* XSDT (Extended System Description Table) */ |
| 81 | struct acpi_xsdt { |
| 82 | struct acpi_table_header header; |
| 83 | u64 entry[MAX_ACPI_TABLES]; |
| 84 | }; |
| 85 | |
Simon Glass | d262898 | 2020-09-22 12:45:09 -0600 | [diff] [blame^] | 86 | /* HPET timers */ |
| 87 | struct __packed acpi_hpet { |
| 88 | struct acpi_table_header header; |
| 89 | u32 id; |
| 90 | struct acpi_gen_regaddr addr; |
| 91 | u8 number; |
| 92 | u16 min_tick; |
| 93 | u8 attributes; |
| 94 | }; |
| 95 | |
Simon Glass | 776cc20 | 2020-04-08 16:57:36 -0600 | [diff] [blame] | 96 | /* FADT Preferred Power Management Profile */ |
| 97 | enum acpi_pm_profile { |
| 98 | ACPI_PM_UNSPECIFIED = 0, |
| 99 | ACPI_PM_DESKTOP, |
| 100 | ACPI_PM_MOBILE, |
| 101 | ACPI_PM_WORKSTATION, |
| 102 | ACPI_PM_ENTERPRISE_SERVER, |
| 103 | ACPI_PM_SOHO_SERVER, |
| 104 | ACPI_PM_APPLIANCE_PC, |
| 105 | ACPI_PM_PERFORMANCE_SERVER, |
| 106 | ACPI_PM_TABLET |
| 107 | }; |
| 108 | |
| 109 | /* FADT flags for p_lvl2_lat and p_lvl3_lat */ |
| 110 | #define ACPI_FADT_C2_NOT_SUPPORTED 101 |
| 111 | #define ACPI_FADT_C3_NOT_SUPPORTED 1001 |
| 112 | |
| 113 | /* FADT Boot Architecture Flags */ |
| 114 | #define ACPI_FADT_LEGACY_FREE 0x00 |
| 115 | #define ACPI_FADT_LEGACY_DEVICES BIT(0) |
| 116 | #define ACPI_FADT_8042 BIT(1) |
| 117 | #define ACPI_FADT_VGA_NOT_PRESENT BIT(2) |
| 118 | #define ACPI_FADT_MSI_NOT_SUPPORTED BIT(3) |
| 119 | #define ACPI_FADT_NO_PCIE_ASPM_CONTROL BIT(4) |
| 120 | |
| 121 | /* FADT Feature Flags */ |
| 122 | #define ACPI_FADT_WBINVD BIT(0) |
| 123 | #define ACPI_FADT_WBINVD_FLUSH BIT(1) |
| 124 | #define ACPI_FADT_C1_SUPPORTED BIT(2) |
| 125 | #define ACPI_FADT_C2_MP_SUPPORTED BIT(3) |
| 126 | #define ACPI_FADT_POWER_BUTTON BIT(4) |
| 127 | #define ACPI_FADT_SLEEP_BUTTON BIT(5) |
| 128 | #define ACPI_FADT_FIXED_RTC BIT(6) |
| 129 | #define ACPI_FADT_S4_RTC_WAKE BIT(7) |
| 130 | #define ACPI_FADT_32BIT_TIMER BIT(8) |
| 131 | #define ACPI_FADT_DOCKING_SUPPORTED BIT(9) |
| 132 | #define ACPI_FADT_RESET_REGISTER BIT(10) |
| 133 | #define ACPI_FADT_SEALED_CASE BIT(11) |
| 134 | #define ACPI_FADT_HEADLESS BIT(12) |
| 135 | #define ACPI_FADT_SLEEP_TYPE BIT(13) |
| 136 | #define ACPI_FADT_PCI_EXPRESS_WAKE BIT(14) |
| 137 | #define ACPI_FADT_PLATFORM_CLOCK BIT(15) |
| 138 | #define ACPI_FADT_S4_RTC_VALID BIT(16) |
| 139 | #define ACPI_FADT_REMOTE_POWER_ON BIT(17) |
| 140 | #define ACPI_FADT_APIC_CLUSTER BIT(18) |
| 141 | #define ACPI_FADT_APIC_PHYSICAL BIT(19) |
| 142 | #define ACPI_FADT_HW_REDUCED_ACPI BIT(20) |
| 143 | #define ACPI_FADT_LOW_PWR_IDLE_S0 BIT(21) |
| 144 | |
| 145 | enum acpi_address_space_type { |
| 146 | ACPI_ADDRESS_SPACE_MEMORY = 0, /* System memory */ |
| 147 | ACPI_ADDRESS_SPACE_IO, /* System I/O */ |
| 148 | ACPI_ADDRESS_SPACE_PCI, /* PCI config space */ |
| 149 | ACPI_ADDRESS_SPACE_EC, /* Embedded controller */ |
| 150 | ACPI_ADDRESS_SPACE_SMBUS, /* SMBus */ |
| 151 | ACPI_ADDRESS_SPACE_PCC = 0x0a, /* Platform Comm. Channel */ |
| 152 | ACPI_ADDRESS_SPACE_FIXED = 0x7f /* Functional fixed hardware */ |
| 153 | }; |
| 154 | |
| 155 | enum acpi_address_space_size { |
| 156 | ACPI_ACCESS_SIZE_UNDEFINED = 0, |
| 157 | ACPI_ACCESS_SIZE_BYTE_ACCESS, |
| 158 | ACPI_ACCESS_SIZE_WORD_ACCESS, |
| 159 | ACPI_ACCESS_SIZE_DWORD_ACCESS, |
| 160 | ACPI_ACCESS_SIZE_QWORD_ACCESS |
| 161 | }; |
| 162 | |
Simon Glass | 776cc20 | 2020-04-08 16:57:36 -0600 | [diff] [blame] | 163 | /* FADT (Fixed ACPI Description Table) */ |
| 164 | struct __packed acpi_fadt { |
| 165 | struct acpi_table_header header; |
| 166 | u32 firmware_ctrl; |
| 167 | u32 dsdt; |
| 168 | u8 res1; |
| 169 | u8 preferred_pm_profile; |
| 170 | u16 sci_int; |
| 171 | u32 smi_cmd; |
| 172 | u8 acpi_enable; |
| 173 | u8 acpi_disable; |
| 174 | u8 s4bios_req; |
| 175 | u8 pstate_cnt; |
| 176 | u32 pm1a_evt_blk; |
| 177 | u32 pm1b_evt_blk; |
| 178 | u32 pm1a_cnt_blk; |
| 179 | u32 pm1b_cnt_blk; |
| 180 | u32 pm2_cnt_blk; |
| 181 | u32 pm_tmr_blk; |
| 182 | u32 gpe0_blk; |
| 183 | u32 gpe1_blk; |
| 184 | u8 pm1_evt_len; |
| 185 | u8 pm1_cnt_len; |
| 186 | u8 pm2_cnt_len; |
| 187 | u8 pm_tmr_len; |
| 188 | u8 gpe0_blk_len; |
| 189 | u8 gpe1_blk_len; |
| 190 | u8 gpe1_base; |
| 191 | u8 cst_cnt; |
| 192 | u16 p_lvl2_lat; |
| 193 | u16 p_lvl3_lat; |
| 194 | u16 flush_size; |
| 195 | u16 flush_stride; |
| 196 | u8 duty_offset; |
| 197 | u8 duty_width; |
| 198 | u8 day_alrm; |
| 199 | u8 mon_alrm; |
| 200 | u8 century; |
| 201 | u16 iapc_boot_arch; |
| 202 | u8 res2; |
| 203 | u32 flags; |
| 204 | struct acpi_gen_regaddr reset_reg; |
| 205 | u8 reset_value; |
| 206 | u16 arm_boot_arch; |
| 207 | u8 minor_revision; |
| 208 | u32 x_firmware_ctl_l; |
| 209 | u32 x_firmware_ctl_h; |
| 210 | u32 x_dsdt_l; |
| 211 | u32 x_dsdt_h; |
| 212 | struct acpi_gen_regaddr x_pm1a_evt_blk; |
| 213 | struct acpi_gen_regaddr x_pm1b_evt_blk; |
| 214 | struct acpi_gen_regaddr x_pm1a_cnt_blk; |
| 215 | struct acpi_gen_regaddr x_pm1b_cnt_blk; |
| 216 | struct acpi_gen_regaddr x_pm2_cnt_blk; |
| 217 | struct acpi_gen_regaddr x_pm_tmr_blk; |
| 218 | struct acpi_gen_regaddr x_gpe0_blk; |
| 219 | struct acpi_gen_regaddr x_gpe1_blk; |
| 220 | }; |
| 221 | |
Simon Glass | 91fe8b7 | 2020-04-08 16:57:38 -0600 | [diff] [blame] | 222 | /* FADT TABLE Revision values - note these do not match the ACPI revision */ |
| 223 | #define ACPI_FADT_REV_ACPI_1_0 1 |
| 224 | #define ACPI_FADT_REV_ACPI_2_0 3 |
| 225 | #define ACPI_FADT_REV_ACPI_3_0 4 |
| 226 | #define ACPI_FADT_REV_ACPI_4_0 4 |
| 227 | #define ACPI_FADT_REV_ACPI_5_0 5 |
| 228 | #define ACPI_FADT_REV_ACPI_6_0 6 |
| 229 | |
| 230 | /* MADT TABLE Revision values - note these do not match the ACPI revision */ |
| 231 | #define ACPI_MADT_REV_ACPI_3_0 2 |
| 232 | #define ACPI_MADT_REV_ACPI_4_0 3 |
| 233 | #define ACPI_MADT_REV_ACPI_5_0 3 |
| 234 | #define ACPI_MADT_REV_ACPI_6_0 5 |
| 235 | |
| 236 | #define ACPI_MCFG_REV_ACPI_3_0 1 |
| 237 | |
| 238 | /* IVRS Revision Field */ |
| 239 | #define IVRS_FORMAT_FIXED 0x01 /* Type 10h & 11h only */ |
| 240 | #define IVRS_FORMAT_MIXED 0x02 /* Type 10h, 11h, & 40h */ |
| 241 | |
Simon Glass | 776cc20 | 2020-04-08 16:57:36 -0600 | [diff] [blame] | 242 | /* FACS flags */ |
| 243 | #define ACPI_FACS_S4BIOS_F BIT(0) |
| 244 | #define ACPI_FACS_64BIT_WAKE_F BIT(1) |
| 245 | |
| 246 | /* FACS (Firmware ACPI Control Structure) */ |
| 247 | struct acpi_facs { |
| 248 | char signature[4]; /* "FACS" */ |
| 249 | u32 length; /* Length in bytes (>= 64) */ |
| 250 | u32 hardware_signature; /* Hardware signature */ |
| 251 | u32 firmware_waking_vector; /* Firmware waking vector */ |
| 252 | u32 global_lock; /* Global lock */ |
| 253 | u32 flags; /* FACS flags */ |
| 254 | u32 x_firmware_waking_vector_l; /* X FW waking vector, low */ |
| 255 | u32 x_firmware_waking_vector_h; /* X FW waking vector, high */ |
| 256 | u8 version; /* Version 2 */ |
| 257 | u8 res1[3]; |
| 258 | u32 ospm_flags; /* OSPM enabled flags */ |
| 259 | u8 res2[24]; |
| 260 | }; |
| 261 | |
| 262 | /* MADT flags */ |
| 263 | #define ACPI_MADT_PCAT_COMPAT BIT(0) |
| 264 | |
| 265 | /* MADT (Multiple APIC Description Table) */ |
| 266 | struct acpi_madt { |
| 267 | struct acpi_table_header header; |
| 268 | u32 lapic_addr; /* Local APIC address */ |
| 269 | u32 flags; /* Multiple APIC flags */ |
| 270 | }; |
| 271 | |
| 272 | /* MADT: APIC Structure Type*/ |
| 273 | enum acpi_apic_types { |
| 274 | ACPI_APIC_LAPIC = 0, /* Processor local APIC */ |
| 275 | ACPI_APIC_IOAPIC, /* I/O APIC */ |
| 276 | ACPI_APIC_IRQ_SRC_OVERRIDE, /* Interrupt source override */ |
| 277 | ACPI_APIC_NMI_SRC, /* NMI source */ |
| 278 | ACPI_APIC_LAPIC_NMI, /* Local APIC NMI */ |
| 279 | ACPI_APIC_LAPIC_ADDR_OVERRIDE, /* Local APIC address override */ |
| 280 | ACPI_APIC_IOSAPIC, /* I/O SAPIC */ |
| 281 | ACPI_APIC_LSAPIC, /* Local SAPIC */ |
| 282 | ACPI_APIC_PLATFORM_IRQ_SRC, /* Platform interrupt sources */ |
| 283 | ACPI_APIC_LX2APIC, /* Processor local x2APIC */ |
| 284 | ACPI_APIC_LX2APIC_NMI, /* Local x2APIC NMI */ |
| 285 | }; |
| 286 | |
| 287 | /* MADT: Processor Local APIC Structure */ |
| 288 | |
| 289 | #define LOCAL_APIC_FLAG_ENABLED BIT(0) |
| 290 | |
| 291 | struct acpi_madt_lapic { |
| 292 | u8 type; /* Type (0) */ |
| 293 | u8 length; /* Length in bytes (8) */ |
| 294 | u8 processor_id; /* ACPI processor ID */ |
| 295 | u8 apic_id; /* Local APIC ID */ |
| 296 | u32 flags; /* Local APIC flags */ |
| 297 | }; |
| 298 | |
| 299 | /* MADT: I/O APIC Structure */ |
| 300 | struct acpi_madt_ioapic { |
| 301 | u8 type; /* Type (1) */ |
| 302 | u8 length; /* Length in bytes (12) */ |
| 303 | u8 ioapic_id; /* I/O APIC ID */ |
| 304 | u8 reserved; |
| 305 | u32 ioapic_addr; /* I/O APIC address */ |
| 306 | u32 gsi_base; /* Global system interrupt base */ |
| 307 | }; |
| 308 | |
| 309 | /* MADT: Interrupt Source Override Structure */ |
| 310 | struct __packed acpi_madt_irqoverride { |
| 311 | u8 type; /* Type (2) */ |
| 312 | u8 length; /* Length in bytes (10) */ |
| 313 | u8 bus; /* ISA (0) */ |
| 314 | u8 source; /* Bus-relative int. source (IRQ) */ |
| 315 | u32 gsirq; /* Global system interrupt */ |
| 316 | u16 flags; /* MPS INTI flags */ |
| 317 | }; |
| 318 | |
| 319 | /* MADT: Local APIC NMI Structure */ |
| 320 | struct __packed acpi_madt_lapic_nmi { |
| 321 | u8 type; /* Type (4) */ |
| 322 | u8 length; /* Length in bytes (6) */ |
| 323 | u8 processor_id; /* ACPI processor ID */ |
| 324 | u16 flags; /* MPS INTI flags */ |
| 325 | u8 lint; /* Local APIC LINT# */ |
| 326 | }; |
| 327 | |
| 328 | /* MCFG (PCI Express MMIO config space BAR description table) */ |
| 329 | struct acpi_mcfg { |
| 330 | struct acpi_table_header header; |
| 331 | u8 reserved[8]; |
| 332 | }; |
| 333 | |
| 334 | struct acpi_mcfg_mmconfig { |
| 335 | u32 base_address_l; |
| 336 | u32 base_address_h; |
| 337 | u16 pci_segment_group_number; |
| 338 | u8 start_bus_number; |
| 339 | u8 end_bus_number; |
| 340 | u8 reserved[4]; |
| 341 | }; |
| 342 | |
| 343 | /* PM1_CNT bit defines */ |
| 344 | #define PM1_CNT_SCI_EN BIT(0) |
| 345 | |
| 346 | /* ACPI global NVS structure */ |
| 347 | struct acpi_global_nvs; |
| 348 | |
| 349 | /* CSRT (Core System Resource Table) */ |
| 350 | struct acpi_csrt { |
| 351 | struct acpi_table_header header; |
| 352 | }; |
| 353 | |
| 354 | struct acpi_csrt_group { |
| 355 | u32 length; |
| 356 | u32 vendor_id; |
| 357 | u32 subvendor_id; |
| 358 | u16 device_id; |
| 359 | u16 subdevice_id; |
| 360 | u16 revision; |
| 361 | u16 reserved; |
| 362 | u32 shared_info_length; |
| 363 | }; |
| 364 | |
| 365 | struct acpi_csrt_shared_info { |
| 366 | u16 major_version; |
| 367 | u16 minor_version; |
| 368 | u32 mmio_base_low; |
| 369 | u32 mmio_base_high; |
| 370 | u32 gsi_interrupt; |
| 371 | u8 interrupt_polarity; |
| 372 | u8 interrupt_mode; |
| 373 | u8 num_channels; |
| 374 | u8 dma_address_width; |
| 375 | u16 base_request_line; |
| 376 | u16 num_handshake_signals; |
| 377 | u32 max_block_size; |
| 378 | }; |
| 379 | |
Simon Glass | bfeb5d4 | 2020-04-08 16:57:39 -0600 | [diff] [blame] | 380 | enum dmar_type { |
| 381 | DMAR_DRHD = 0, |
| 382 | DMAR_RMRR = 1, |
| 383 | DMAR_ATSR = 2, |
| 384 | DMAR_RHSA = 3, |
| 385 | DMAR_ANDD = 4 |
| 386 | }; |
| 387 | |
| 388 | enum { |
| 389 | DRHD_INCLUDE_PCI_ALL = BIT(0) |
| 390 | }; |
| 391 | |
| 392 | enum dmar_flags { |
| 393 | DMAR_INTR_REMAP = BIT(0), |
| 394 | DMAR_X2APIC_OPT_OUT = BIT(1), |
| 395 | DMAR_CTRL_PLATFORM_OPT_IN_FLAG = BIT(2), |
| 396 | }; |
| 397 | |
| 398 | struct dmar_entry { |
| 399 | u16 type; |
| 400 | u16 length; |
| 401 | u8 flags; |
| 402 | u8 reserved; |
| 403 | u16 segment; |
| 404 | u64 bar; |
| 405 | }; |
| 406 | |
| 407 | struct dmar_rmrr_entry { |
| 408 | u16 type; |
| 409 | u16 length; |
| 410 | u16 reserved; |
| 411 | u16 segment; |
| 412 | u64 bar; |
| 413 | u64 limit; |
| 414 | }; |
| 415 | |
| 416 | /* DMAR (DMA Remapping Reporting Structure) */ |
| 417 | struct __packed acpi_dmar { |
| 418 | struct acpi_table_header header; |
| 419 | u8 host_address_width; |
| 420 | u8 flags; |
| 421 | u8 reserved[10]; |
| 422 | struct dmar_entry structure[0]; |
| 423 | }; |
| 424 | |
Simon Glass | 776cc20 | 2020-04-08 16:57:36 -0600 | [diff] [blame] | 425 | /* DBG2 definitions are partially used for SPCR interface_type */ |
| 426 | |
| 427 | /* Types for port_type field */ |
| 428 | |
| 429 | #define ACPI_DBG2_SERIAL_PORT 0x8000 |
| 430 | #define ACPI_DBG2_1394_PORT 0x8001 |
| 431 | #define ACPI_DBG2_USB_PORT 0x8002 |
| 432 | #define ACPI_DBG2_NET_PORT 0x8003 |
| 433 | |
| 434 | /* Subtypes for port_subtype field */ |
| 435 | |
| 436 | #define ACPI_DBG2_16550_COMPATIBLE 0x0000 |
| 437 | #define ACPI_DBG2_16550_SUBSET 0x0001 |
| 438 | #define ACPI_DBG2_ARM_PL011 0x0003 |
| 439 | #define ACPI_DBG2_ARM_SBSA_32BIT 0x000D |
| 440 | #define ACPI_DBG2_ARM_SBSA_GENERIC 0x000E |
| 441 | #define ACPI_DBG2_ARM_DCC 0x000F |
| 442 | #define ACPI_DBG2_BCM2835 0x0010 |
| 443 | |
| 444 | #define ACPI_DBG2_1394_STANDARD 0x0000 |
| 445 | |
| 446 | #define ACPI_DBG2_USB_XHCI 0x0000 |
| 447 | #define ACPI_DBG2_USB_EHCI 0x0001 |
| 448 | |
| 449 | #define ACPI_DBG2_UNKNOWN 0x00FF |
| 450 | |
| 451 | /* SPCR (Serial Port Console Redirection table) */ |
| 452 | struct __packed acpi_spcr { |
| 453 | struct acpi_table_header header; |
| 454 | u8 interface_type; |
| 455 | u8 reserved[3]; |
| 456 | struct acpi_gen_regaddr serial_port; |
| 457 | u8 interrupt_type; |
| 458 | u8 pc_interrupt; |
| 459 | u32 interrupt; /* Global system interrupt */ |
| 460 | u8 baud_rate; |
| 461 | u8 parity; |
| 462 | u8 stop_bits; |
| 463 | u8 flow_control; |
| 464 | u8 terminal_type; |
| 465 | u8 reserved1; |
| 466 | u16 pci_device_id; /* Must be 0xffff if not PCI device */ |
| 467 | u16 pci_vendor_id; /* Must be 0xffff if not PCI device */ |
| 468 | u8 pci_bus; |
| 469 | u8 pci_device; |
| 470 | u8 pci_function; |
| 471 | u32 pci_flags; |
| 472 | u8 pci_segment; |
| 473 | u32 reserved2; |
| 474 | }; |
| 475 | |
Simon Glass | 91fe8b7 | 2020-04-08 16:57:38 -0600 | [diff] [blame] | 476 | /* Tables defined/reserved by ACPI and generated by U-Boot */ |
| 477 | enum acpi_tables { |
| 478 | ACPITAB_BERT, |
| 479 | ACPITAB_DBG2, |
| 480 | ACPITAB_DMAR, |
| 481 | ACPITAB_DSDT, |
| 482 | ACPITAB_ECDT, |
| 483 | ACPITAB_FACS, |
| 484 | ACPITAB_FADT, |
| 485 | ACPITAB_HEST, |
| 486 | ACPITAB_HPET, |
| 487 | ACPITAB_IVRS, |
| 488 | ACPITAB_MADT, |
| 489 | ACPITAB_MCFG, |
| 490 | ACPITAB_NHLT, |
| 491 | ACPITAB_RSDP, |
| 492 | ACPITAB_RSDT, |
| 493 | ACPITAB_SLIT, |
| 494 | ACPITAB_SPCR, |
| 495 | ACPITAB_SPMI, |
| 496 | ACPITAB_SRAT, |
| 497 | ACPITAB_SSDT, |
| 498 | ACPITAB_TCPA, |
| 499 | ACPITAB_TPM2, |
| 500 | ACPITAB_VFCT, |
| 501 | ACPITAB_XSDT, |
| 502 | |
| 503 | ACPITAB_COUNT, |
| 504 | }; |
| 505 | |
| 506 | /** |
| 507 | * acpi_get_table_revision() - Get the revision number generated for a table |
| 508 | * |
| 509 | * This keeps the version-number information in one place |
| 510 | * |
| 511 | * @table: ACPI table to check |
| 512 | * @return version number that U-Boot generates |
| 513 | */ |
| 514 | int acpi_get_table_revision(enum acpi_tables table); |
| 515 | |
Simon Glass | bfeb5d4 | 2020-04-08 16:57:39 -0600 | [diff] [blame] | 516 | /** |
| 517 | * acpi_create_dmar() - Create a DMA Remapping Reporting (DMAR) table |
| 518 | * |
| 519 | * @dmar: Place to put the table |
| 520 | * @flags: DMAR flags to use |
| 521 | * @return 0 if OK, -ve on error |
| 522 | */ |
| 523 | int acpi_create_dmar(struct acpi_dmar *dmar, enum dmar_flags flags); |
| 524 | |
Simon Glass | 93f7f82 | 2020-04-26 09:19:46 -0600 | [diff] [blame] | 525 | /** |
| 526 | * acpi_fill_header() - Set up a new table header |
| 527 | * |
| 528 | * This sets all fields except length, revision, checksum and aslc_revision |
| 529 | * |
| 530 | * @header: ACPI header to update |
| 531 | * @signature: Table signature to use (4 characters) |
| 532 | */ |
| 533 | void acpi_fill_header(struct acpi_table_header *header, char *signature); |
| 534 | |
Simon Glass | 86e1778 | 2020-04-26 09:19:47 -0600 | [diff] [blame] | 535 | /** |
| 536 | * acpi_align() - Align the ACPI output pointer to a 16-byte boundary |
| 537 | * |
| 538 | * @ctx: ACPI context |
| 539 | */ |
| 540 | void acpi_align(struct acpi_ctx *ctx); |
| 541 | |
| 542 | /** |
| 543 | * acpi_align64() - Align the ACPI output pointer to a 64-byte boundary |
| 544 | * |
| 545 | * @ctx: ACPI context |
| 546 | */ |
| 547 | void acpi_align64(struct acpi_ctx *ctx); |
| 548 | |
| 549 | /** |
| 550 | * acpi_inc() - Increment the ACPI output pointer by a bit |
| 551 | * |
| 552 | * The pointer is NOT aligned afterwards. |
| 553 | * |
| 554 | * @ctx: ACPI context |
| 555 | * @amount: Amount to increment by |
| 556 | */ |
| 557 | void acpi_inc(struct acpi_ctx *ctx, uint amount); |
| 558 | |
| 559 | /** |
| 560 | * acpi_inc_align() - Increment the ACPI output pointer by a bit and align |
| 561 | * |
| 562 | * The pointer is aligned afterwards to a 16-byte boundary |
| 563 | * |
| 564 | * @ctx: ACPI context |
| 565 | * @amount: Amount to increment by |
| 566 | */ |
| 567 | void acpi_inc_align(struct acpi_ctx *ctx, uint amount); |
| 568 | |
Simon Glass | 29b3511 | 2020-04-26 09:19:50 -0600 | [diff] [blame] | 569 | /** |
| 570 | * acpi_add_table() - Add a new table to the RSDP and XSDT |
| 571 | * |
| 572 | * @ctx: ACPI context |
| 573 | * @table: Table to add |
| 574 | * @return 0 if OK, -E2BIG if too many tables |
| 575 | */ |
| 576 | int acpi_add_table(struct acpi_ctx *ctx, void *table); |
| 577 | |
Simon Glass | 7e586f6 | 2020-04-26 09:19:51 -0600 | [diff] [blame] | 578 | /** |
| 579 | * acpi_setup_base_tables() - Set up context along with RSDP, RSDT and XSDT |
| 580 | * |
| 581 | * Set up the context with the given start position. Some basic tables are |
| 582 | * always needed, so set them up as well. |
| 583 | * |
| 584 | * @ctx: Context to set up |
| 585 | */ |
| 586 | void acpi_setup_base_tables(struct acpi_ctx *ctx, void *start); |
| 587 | |
Simon Glass | 89c2798 | 2020-04-08 16:57:37 -0600 | [diff] [blame] | 588 | #endif /* !__ACPI__*/ |
| 589 | |
Simon Glass | 776cc20 | 2020-04-08 16:57:36 -0600 | [diff] [blame] | 590 | #include <asm/acpi_table.h> |
| 591 | |
| 592 | #endif /* __ACPI_TABLE_H__ */ |