Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 2 | |
| 3 | /* |
| 4 | * coreboot ACPI support - headers and defines. |
| 5 | */ |
| 6 | |
Furquan Shaikh | 56eafbb | 2020-04-30 18:38:55 -0700 | [diff] [blame] | 7 | #ifndef __ACPI_ACPI_H__ |
| 8 | #define __ACPI_ACPI_H__ |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 9 | |
| 10 | /* |
| 11 | * The type and enable fields are common in ACPI, but the |
| 12 | * values themselves are hardware implementation defined. |
| 13 | */ |
| 14 | #if CONFIG(ACPI_INTEL_HARDWARE_SLEEP_VALUES) |
| 15 | #define SLP_EN (1 << 13) |
| 16 | #define SLP_TYP_SHIFT 10 |
| 17 | #define SLP_TYP (7 << SLP_TYP_SHIFT) |
| 18 | #define SLP_TYP_S0 0 |
| 19 | #define SLP_TYP_S1 1 |
| 20 | #define SLP_TYP_S3 5 |
| 21 | #define SLP_TYP_S4 6 |
| 22 | #define SLP_TYP_S5 7 |
| 23 | #elif CONFIG(ACPI_AMD_HARDWARE_SLEEP_VALUES) |
| 24 | #define SLP_EN (1 << 13) |
| 25 | #define SLP_TYP_SHIFT 10 |
| 26 | #define SLP_TYP (7 << SLP_TYP_SHIFT) |
| 27 | #define SLP_TYP_S0 0 |
| 28 | #define SLP_TYP_S1 1 |
| 29 | #define SLP_TYP_S3 3 |
| 30 | #define SLP_TYP_S4 4 |
| 31 | #define SLP_TYP_S5 5 |
| 32 | #endif |
| 33 | |
| 34 | #define ACPI_TABLE_CREATOR "COREBOOT" /* Must be exactly 8 bytes long! */ |
| 35 | #define OEM_ID "COREv4" /* Must be exactly 6 bytes long! */ |
Elyes HAOUAS | 288426d | 2020-10-01 16:52:26 +0200 | [diff] [blame] | 36 | #define ACPI_DSDT_REV_1 0x01 /* DSDT revision: ACPI v1 */ |
Elyes HAOUAS | 7f53ec6 | 2020-10-05 16:33:52 +0200 | [diff] [blame] | 37 | #define ACPI_DSDT_REV_2 0x02 /* DSDT revision: ACPI v2.0 and greater */ |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 38 | |
| 39 | #if !defined(__ASSEMBLER__) && !defined(__ACPI__) |
| 40 | #include <commonlib/helpers.h> |
| 41 | #include <device/device.h> |
| 42 | #include <uuid.h> |
| 43 | #include <cper.h> |
Kyösti Mälkki | ac0dc4a | 2020-11-18 07:40:21 +0200 | [diff] [blame] | 44 | #include <romstage_handoff.h> |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 45 | #include <types.h> |
| 46 | |
Tim Wawrzynczak | 05a6d5c | 2021-11-24 09:54:59 -0700 | [diff] [blame] | 47 | enum acpi_device_sleep_states { |
| 48 | ACPI_DEVICE_SLEEP_D0 = 0, |
| 49 | ACPI_DEVICE_SLEEP_D1 = 1, |
| 50 | ACPI_DEVICE_SLEEP_D2 = 2, |
| 51 | ACPI_DEVICE_SLEEP_D3 = 3, |
| 52 | ACPI_DEVICE_SLEEP_D3_HOT = ACPI_DEVICE_SLEEP_D3, |
| 53 | ACPI_DEVICE_SLEEP_D3_COLD = 4, |
| 54 | }; |
| 55 | |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 56 | #define RSDP_SIG "RSD PTR " /* RSDT pointer signature */ |
| 57 | #define ASLC "CORE" /* Must be exactly 4 bytes long! */ |
| 58 | |
Raul E Rangel | 1c0b9f2 | 2020-07-09 11:58:38 -0600 | [diff] [blame] | 59 | #define ACPI_NAME_BUFFER_SIZE 5 /* 4 chars + 1 NUL */ |
| 60 | |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 61 | /* |
| 62 | * The assigned ACPI ID for the coreboot project is 'BOOT' |
| 63 | * http://www.uefi.org/acpi_id_list |
| 64 | */ |
| 65 | #define COREBOOT_ACPI_ID "BOOT" /* ACPI ID for coreboot HIDs */ |
| 66 | |
| 67 | /* List of ACPI HID that use the coreboot ACPI ID */ |
| 68 | enum coreboot_acpi_ids { |
| 69 | COREBOOT_ACPI_ID_CBTABLE = 0x0000, /* BOOT0000 */ |
| 70 | COREBOOT_ACPI_ID_MAX = 0xFFFF, /* BOOTFFFF */ |
| 71 | }; |
| 72 | |
| 73 | enum acpi_tables { |
| 74 | /* Tables defined by ACPI and used by coreboot */ |
Jonathan Zhang | 2a4e1f4 | 2021-04-01 11:43:37 -0700 | [diff] [blame] | 75 | BERT, DBG2, DMAR, DSDT, EINJ, FACS, FADT, HEST, HMAT, HPET, IVRS, MADT, |
| 76 | MCFG, RSDP, RSDT, SLIT, SRAT, SSDT, TCPA, TPM2, XSDT, ECDT, LPIT, |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 77 | /* Additional proprietary tables used by coreboot */ |
Jason Glenesk | 61624b2 | 2020-11-02 20:06:23 -0800 | [diff] [blame] | 78 | VFCT, NHLT, SPMI, CRAT |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 79 | }; |
| 80 | |
| 81 | /* RSDP (Root System Description Pointer) */ |
| 82 | typedef struct acpi_rsdp { |
| 83 | char signature[8]; /* RSDP signature */ |
| 84 | u8 checksum; /* Checksum of the first 20 bytes */ |
| 85 | char oem_id[6]; /* OEM ID */ |
| 86 | u8 revision; /* RSDP revision */ |
| 87 | u32 rsdt_address; /* Physical address of RSDT (32 bits) */ |
| 88 | u32 length; /* Total RSDP length (incl. extended part) */ |
| 89 | u64 xsdt_address; /* Physical address of XSDT (64 bits) */ |
| 90 | u8 ext_checksum; /* Checksum of the whole table */ |
| 91 | u8 reserved[3]; |
| 92 | } __packed acpi_rsdp_t; |
| 93 | |
| 94 | /* GAS (Generic Address Structure) */ |
| 95 | typedef struct acpi_gen_regaddr { |
| 96 | u8 space_id; /* Address space ID */ |
| 97 | u8 bit_width; /* Register size in bits */ |
| 98 | u8 bit_offset; /* Register bit offset */ |
| 99 | u8 access_size; /* Access size since ACPI 2.0c */ |
| 100 | u32 addrl; /* Register address, low 32 bits */ |
| 101 | u32 addrh; /* Register address, high 32 bits */ |
| 102 | } __packed acpi_addr_t; |
| 103 | |
Elyes HAOUAS | 5f5fd85 | 2020-10-15 12:24:00 +0200 | [diff] [blame] | 104 | #define ACPI_ADDRESS_SPACE_MEMORY 0 /* System memory */ |
| 105 | #define ACPI_ADDRESS_SPACE_IO 1 /* System I/O */ |
| 106 | #define ACPI_ADDRESS_SPACE_PCI 2 /* PCI config space */ |
| 107 | #define ACPI_ADDRESS_SPACE_EC 3 /* Embedded controller */ |
| 108 | #define ACPI_ADDRESS_SPACE_SMBUS 4 /* SMBus */ |
| 109 | #define ACPI_ADDRESS_SPACE_CMOS 5 /* SystemCMOS */ |
| 110 | #define ACPI_ADDRESS_SPACE_PCI_BAR_TARGET 6 /* PciBarTarget */ |
| 111 | #define ACPI_ADDRESS_SPACE_IPMI 7 /* IPMI */ |
| 112 | #define ACPI_ADDRESS_SPACE_GENERAL_PURPOSE_IO 8 /* GeneralPurposeIO */ |
| 113 | #define ACPI_ADDRESS_SPACE_GENERIC_SERIAL_BUS 9 /* GenericSerialBus */ |
| 114 | #define ACPI_ADDRESS_SPACE_PCC 0x0A /* Platform Comm. Channel */ |
| 115 | #define ACPI_ADDRESS_SPACE_FIXED 0x7f /* Functional fixed hardware */ |
| 116 | #define ACPI_FFIXEDHW_VENDOR_INTEL 1 /* Intel */ |
| 117 | #define ACPI_FFIXEDHW_CLASS_HLT 0 /* C1 Halt */ |
| 118 | #define ACPI_FFIXEDHW_CLASS_IO_HLT 1 /* C1 I/O then Halt */ |
| 119 | #define ACPI_FFIXEDHW_CLASS_MWAIT 2 /* MWAIT Native C-state */ |
| 120 | #define ACPI_FFIXEDHW_FLAG_HW_COORD 1 /* Hardware Coordination bit */ |
| 121 | #define ACPI_FFIXEDHW_FLAG_BM_STS 2 /* BM_STS avoidance bit */ |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 122 | /* 0x80-0xbf: Reserved */ |
| 123 | /* 0xc0-0xff: OEM defined */ |
| 124 | |
| 125 | /* Access size definitions for Generic address structure */ |
| 126 | #define ACPI_ACCESS_SIZE_UNDEFINED 0 /* Undefined (legacy reasons) */ |
| 127 | #define ACPI_ACCESS_SIZE_BYTE_ACCESS 1 |
| 128 | #define ACPI_ACCESS_SIZE_WORD_ACCESS 2 |
| 129 | #define ACPI_ACCESS_SIZE_DWORD_ACCESS 3 |
| 130 | #define ACPI_ACCESS_SIZE_QWORD_ACCESS 4 |
| 131 | |
Michael Niewöhner | ab088c9 | 2021-09-23 17:04:35 +0200 | [diff] [blame] | 132 | /* Macros for common resource types */ |
| 133 | #define ACPI_REG_MSR(address, offset, width) \ |
Michael Niewöhner | f72c7b1 | 2021-10-05 21:42:57 +0200 | [diff] [blame] | 134 | (acpi_addr_t){ \ |
Michael Niewöhner | ab088c9 | 2021-09-23 17:04:35 +0200 | [diff] [blame] | 135 | .space_id = ACPI_ADDRESS_SPACE_FIXED, \ |
| 136 | .access_size = ACPI_ACCESS_SIZE_QWORD_ACCESS, \ |
| 137 | .addrl = address, \ |
| 138 | .bit_offset = offset, \ |
| 139 | .bit_width = width, \ |
| 140 | } |
| 141 | |
Michael Niewöhner | f72c7b1 | 2021-10-05 21:42:57 +0200 | [diff] [blame] | 142 | #define ACPI_REG_UNSUPPORTED (acpi_addr_t){0} |
Michael Niewöhner | ab088c9 | 2021-09-23 17:04:35 +0200 | [diff] [blame] | 143 | |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 144 | /* Common ACPI HIDs */ |
| 145 | #define ACPI_HID_FDC "PNP0700" |
| 146 | #define ACPI_HID_KEYBOARD "PNP0303" |
| 147 | #define ACPI_HID_MOUSE "PNP0F03" |
| 148 | #define ACPI_HID_COM "PNP0501" |
| 149 | #define ACPI_HID_LPT "PNP0400" |
| 150 | #define ACPI_HID_PNP "PNP0C02" |
| 151 | #define ACPI_HID_CONTAINER "PNP0A05" |
| 152 | |
| 153 | /* Generic ACPI header, provided by (almost) all tables */ |
| 154 | typedef struct acpi_table_header { |
| 155 | char signature[4]; /* ACPI signature (4 ASCII characters) */ |
| 156 | u32 length; /* Table length in bytes (incl. header) */ |
| 157 | u8 revision; /* Table version (not ACPI version!) */ |
| 158 | u8 checksum; /* To make sum of entire table == 0 */ |
| 159 | char oem_id[6]; /* OEM identification */ |
| 160 | char oem_table_id[8]; /* OEM table identification */ |
| 161 | u32 oem_revision; /* OEM revision number */ |
| 162 | char asl_compiler_id[4]; /* ASL compiler vendor ID */ |
| 163 | u32 asl_compiler_revision; /* ASL compiler revision number */ |
| 164 | } __packed acpi_header_t; |
| 165 | |
| 166 | /* A maximum number of 32 ACPI tables ought to be enough for now. */ |
| 167 | #define MAX_ACPI_TABLES 32 |
| 168 | |
| 169 | /* RSDT (Root System Description Table) */ |
| 170 | typedef struct acpi_rsdt { |
| 171 | acpi_header_t header; |
| 172 | u32 entry[MAX_ACPI_TABLES]; |
| 173 | } __packed acpi_rsdt_t; |
| 174 | |
| 175 | /* XSDT (Extended System Description Table) */ |
| 176 | typedef struct acpi_xsdt { |
| 177 | acpi_header_t header; |
| 178 | u64 entry[MAX_ACPI_TABLES]; |
| 179 | } __packed acpi_xsdt_t; |
| 180 | |
| 181 | /* HPET timers */ |
| 182 | typedef struct acpi_hpet { |
| 183 | acpi_header_t header; |
| 184 | u32 id; |
| 185 | acpi_addr_t addr; |
| 186 | u8 number; |
| 187 | u16 min_tick; |
| 188 | u8 attributes; |
| 189 | } __packed acpi_hpet_t; |
| 190 | |
| 191 | /* MCFG (PCI Express MMIO config space BAR description table) */ |
| 192 | typedef struct acpi_mcfg { |
| 193 | acpi_header_t header; |
| 194 | u8 reserved[8]; |
| 195 | } __packed acpi_mcfg_t; |
| 196 | |
| 197 | typedef struct acpi_tcpa { |
| 198 | acpi_header_t header; |
| 199 | u16 platform_class; |
| 200 | u32 laml; |
| 201 | u64 lasa; |
| 202 | } __packed acpi_tcpa_t; |
| 203 | |
| 204 | typedef struct acpi_tpm2 { |
| 205 | acpi_header_t header; |
| 206 | u16 platform_class; |
| 207 | u8 reserved[2]; |
| 208 | u64 control_area; |
| 209 | u32 start_method; |
| 210 | u8 msp[12]; |
| 211 | u32 laml; |
| 212 | u64 lasa; |
| 213 | } __packed acpi_tpm2_t; |
| 214 | |
| 215 | typedef struct acpi_mcfg_mmconfig { |
| 216 | u32 base_address; |
| 217 | u32 base_reserved; |
| 218 | u16 pci_segment_group_number; |
| 219 | u8 start_bus_number; |
| 220 | u8 end_bus_number; |
| 221 | u8 reserved[4]; |
| 222 | } __packed acpi_mcfg_mmconfig_t; |
| 223 | |
Jonathan Zhang | 2a4e1f4 | 2021-04-01 11:43:37 -0700 | [diff] [blame] | 224 | /* |
| 225 | * HMAT (Heterogeneous Memory Attribute Table) |
| 226 | * ACPI spec 6.4 section 5.2.27 |
| 227 | */ |
| 228 | typedef struct acpi_hmat { |
| 229 | acpi_header_t header; |
| 230 | u32 resv; |
| 231 | /* Followed by HMAT table structure[n] */ |
| 232 | } __packed acpi_hmat_t; |
| 233 | |
| 234 | /* HMAT: Memory Proximity Domain Attributes structure */ |
| 235 | typedef struct acpi_hmat_mpda { |
| 236 | u16 type; /* Type (0) */ |
| 237 | u16 resv; |
| 238 | u32 length; /* Length in bytes (40) */ |
| 239 | u16 flags; |
| 240 | u16 resv1; |
| 241 | u32 proximity_domain_initiator; |
| 242 | u32 proximity_domain_memory; |
| 243 | u32 resv2; |
| 244 | u64 resv3; |
| 245 | u64 resv4; |
| 246 | } __packed acpi_hmat_mpda_t; |
| 247 | |
| 248 | /* HMAT: System Locality Latency and Bandwidth Information structure */ |
| 249 | typedef struct acpi_hmat_sllbi { |
| 250 | u16 type; /* Type (1) */ |
| 251 | u16 resv; |
| 252 | u32 length; /* Length in bytes */ |
| 253 | u8 flags; |
| 254 | u8 data_type; |
| 255 | /* |
| 256 | * Transfer size defined as a 5-biased power of 2 exponent, |
| 257 | * when the bandwidth/latency value is achieved. |
| 258 | */ |
| 259 | u8 min_transfer_size; |
| 260 | u8 resv1; |
| 261 | u32 num_initiator_domains; |
| 262 | u32 num_target_domains; |
| 263 | u32 resv2; |
| 264 | u64 entry_base_unit; |
| 265 | /* Followed by initiator proximity domain list */ |
| 266 | /* Followed by target proximity domain list */ |
| 267 | /* Followed by latency / bandwidth values */ |
| 268 | } __packed acpi_hmat_sllbi_t; |
| 269 | |
| 270 | /* HMAT: Memory Side Cache Information structure */ |
| 271 | typedef struct acpi_hmat_msci { |
| 272 | u16 type; /* Type (2) */ |
| 273 | u16 resv; |
| 274 | u32 length; /* Length in bytes */ |
| 275 | u32 domain; /* Proximity domain for the memory */ |
| 276 | u32 resv1; |
| 277 | u64 cache_size; |
| 278 | /* Describes level, associativity, write policy, cache line size */ |
| 279 | u32 cache_attributes; |
| 280 | u16 resv2; |
| 281 | /* |
| 282 | * Number of SMBIOS handlers that contribute to the |
| 283 | * memory side cache physical devices |
| 284 | */ |
| 285 | u16 num_handlers; |
| 286 | /* Followed by SMBIOS handlers*/ |
| 287 | } __packed acpi_hmat_msci_t; |
| 288 | |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 289 | /* SRAT (System Resource Affinity Table) */ |
| 290 | typedef struct acpi_srat { |
| 291 | acpi_header_t header; |
| 292 | u32 resv; |
| 293 | u64 resv1; |
| 294 | /* Followed by static resource allocation structure[n] */ |
| 295 | } __packed acpi_srat_t; |
| 296 | |
Jonathan Zhang | 3164b64 | 2021-04-21 17:51:31 -0700 | [diff] [blame] | 297 | #define ACPI_SRAT_STRUCTURE_LAPIC 0 |
| 298 | #define ACPI_SRAT_STRUCTURE_MEM 1 |
| 299 | #define ACPI_SRAT_STRUCTURE_GIA 5 |
| 300 | |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 301 | /* SRAT: Processor Local APIC/SAPIC Affinity Structure */ |
| 302 | typedef struct acpi_srat_lapic { |
| 303 | u8 type; /* Type (0) */ |
| 304 | u8 length; /* Length in bytes (16) */ |
| 305 | u8 proximity_domain_7_0; /* Proximity domain bits[7:0] */ |
| 306 | u8 apic_id; /* Local APIC ID */ |
| 307 | u32 flags; /* Enable bit 0 = 1, other bits reserved to 0 */ |
| 308 | u8 local_sapic_eid; /* Local SAPIC EID */ |
| 309 | u8 proximity_domain_31_8[3]; /* Proximity domain bits[31:8] */ |
| 310 | u32 clock_domain; /* _CDM Clock Domain */ |
| 311 | } __packed acpi_srat_lapic_t; |
| 312 | |
| 313 | /* SRAT: Memory Affinity Structure */ |
| 314 | typedef struct acpi_srat_mem { |
| 315 | u8 type; /* Type (1) */ |
| 316 | u8 length; /* Length in bytes (40) */ |
| 317 | u32 proximity_domain; /* Proximity domain */ |
| 318 | u16 resv; |
| 319 | u32 base_address_low; /* Mem range base address, low */ |
| 320 | u32 base_address_high; /* Mem range base address, high */ |
| 321 | u32 length_low; /* Mem range length, low */ |
| 322 | u32 length_high; /* Mem range length, high */ |
| 323 | u32 resv1; |
| 324 | u32 flags; /* Enable bit 0, hot pluggable bit 1; Non Volatile bit 2, |
| 325 | * other bits reserved to 0 |
| 326 | */ |
| 327 | u32 resv2[2]; |
| 328 | } __packed acpi_srat_mem_t; |
| 329 | |
Jonathan Zhang | 3164b64 | 2021-04-21 17:51:31 -0700 | [diff] [blame] | 330 | /* SRAT: Generic Initiator Affinity Structure (ACPI spec 6.4 section 5.2.16.6) */ |
| 331 | typedef struct acpi_srat_gia { |
| 332 | u8 type; /* Type (5) */ |
| 333 | u8 length; /* Length in bytes (32) */ |
| 334 | u8 resv; |
| 335 | u8 dev_handle_type; /* Device handle type */ |
| 336 | u32 proximity_domain; /*Proximity domain */ |
| 337 | u8 dev_handle[16]; /* Device handle */ |
| 338 | u32 flags; |
| 339 | u32 resv1; |
| 340 | } __packed acpi_srat_gia_t; |
| 341 | |
| 342 | #define ACPI_SRAT_GIA_DEV_HANDLE_ACPI 0 |
| 343 | #define ACPI_SRAT_GIA_DEV_HANDLE_PCI 1 |
| 344 | |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 345 | /* SLIT (System Locality Distance Information Table) */ |
| 346 | typedef struct acpi_slit { |
| 347 | acpi_header_t header; |
| 348 | /* Followed by static resource allocation 8+byte[num*num] */ |
| 349 | } __packed acpi_slit_t; |
| 350 | |
| 351 | /* MADT (Multiple APIC Description Table) */ |
| 352 | typedef struct acpi_madt { |
| 353 | acpi_header_t header; |
| 354 | u32 lapic_addr; /* Local APIC address */ |
| 355 | u32 flags; /* Multiple APIC flags */ |
| 356 | } __packed acpi_madt_t; |
| 357 | |
Michael Niewöhner | f0a44ae | 2021-01-01 21:04:09 +0100 | [diff] [blame] | 358 | /* |
| 359 | * LPIT (Low Power Idle Table) |
| 360 | * Conforms to "Intel Low Power S0 Idle" specification, rev 002 from July 2017. |
| 361 | */ |
| 362 | typedef struct acpi_lpit { |
| 363 | acpi_header_t header; |
| 364 | } __packed acpi_lpit_t; |
| 365 | |
| 366 | /* LPIT: LPI descriptor flags */ |
| 367 | typedef struct acpi_lpi_flags { |
| 368 | uint32_t disabled : 1; |
| 369 | uint32_t counter_not_available : 1; |
| 370 | uint32_t reserved : 30; |
| 371 | } __packed acpi_lpi_desc_flags_t; |
| 372 | |
| 373 | /* LPIT: LPI descriptor types */ |
| 374 | enum acpi_lpi_desc_type { |
| 375 | ACPI_LPI_DESC_TYPE_NATIVE_CSTATE = 0x00, |
| 376 | /* type >= 1 reserved */ |
| 377 | }; |
| 378 | |
| 379 | /* LPIT: LPI descriptor header */ |
| 380 | typedef struct acpi_lpi_desc_hdr { |
| 381 | uint32_t type; |
| 382 | uint32_t length; |
| 383 | uint16_t uid; |
| 384 | uint16_t reserved; |
| 385 | } __packed acpi_lpi_desc_hdr_t; |
| 386 | |
| 387 | #define ACPI_LPIT_CTR_FREQ_TSC 0 |
| 388 | |
| 389 | /* LPIT: Native C-state instruction based LPI structure */ |
| 390 | typedef struct acpi_lpi_desc_ncst { |
| 391 | acpi_lpi_desc_hdr_t header; |
| 392 | acpi_lpi_desc_flags_t flags; |
| 393 | acpi_addr_t entry_trigger; /* Entry trigger C-state */ |
| 394 | uint32_t min_residency; /* Minimum residency or "break-even" in microseconds */ |
| 395 | uint32_t max_latency; /* Worst case exit latency in microseconds */ |
| 396 | acpi_addr_t residency_counter; |
| 397 | uint64_t counter_frequency; /* Frequency in cycles per second - 0 means TSC freq */ |
| 398 | } __packed acpi_lpi_desc_ncst_t; |
| 399 | |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 400 | /* VFCT image header */ |
| 401 | typedef struct acpi_vfct_image_hdr { |
| 402 | u32 PCIBus; |
| 403 | u32 PCIDevice; |
| 404 | u32 PCIFunction; |
| 405 | u16 VendorID; |
| 406 | u16 DeviceID; |
| 407 | u16 SSVID; |
| 408 | u16 SSID; |
| 409 | u32 Revision; |
| 410 | u32 ImageLength; |
| 411 | u8 VbiosContent; // dummy - copy VBIOS here |
| 412 | } __packed acpi_vfct_image_hdr_t; |
| 413 | |
| 414 | /* VFCT (VBIOS Fetch Table) */ |
| 415 | typedef struct acpi_vfct { |
| 416 | acpi_header_t header; |
| 417 | u8 TableUUID[16]; |
| 418 | u32 VBIOSImageOffset; |
| 419 | u32 Lib1ImageOffset; |
| 420 | u32 Reserved[4]; |
| 421 | acpi_vfct_image_hdr_t image_hdr; |
| 422 | } __packed acpi_vfct_t; |
| 423 | |
| 424 | typedef struct acpi_ivrs_info { |
| 425 | } __packed acpi_ivrs_info_t; |
| 426 | |
| 427 | /* IVRS IVHD (I/O Virtualization Hardware Definition Block) Type 10h */ |
| 428 | typedef struct acpi_ivrs_ivhd { |
| 429 | uint8_t type; |
| 430 | uint8_t flags; |
| 431 | uint16_t length; |
| 432 | uint16_t device_id; |
| 433 | uint16_t capability_offset; |
| 434 | uint32_t iommu_base_low; |
| 435 | uint32_t iommu_base_high; |
| 436 | uint16_t pci_segment_group; |
| 437 | uint16_t iommu_info; |
| 438 | uint32_t iommu_feature_info; |
| 439 | uint8_t entry[0]; |
| 440 | } __packed acpi_ivrs_ivhd_t; |
| 441 | |
| 442 | /* IVRS (I/O Virtualization Reporting Structure) Type 10h */ |
| 443 | typedef struct acpi_ivrs { |
| 444 | acpi_header_t header; |
| 445 | uint32_t iv_info; |
| 446 | uint32_t reserved[2]; |
| 447 | struct acpi_ivrs_ivhd ivhd; |
| 448 | } __packed acpi_ivrs_t; |
| 449 | |
Jason Glenesk | 61624b2 | 2020-11-02 20:06:23 -0800 | [diff] [blame] | 450 | /* CRAT (Component Resource Affinity Table Structure) */ |
| 451 | struct acpi_crat_header { |
| 452 | acpi_header_t header; |
| 453 | uint32_t total_entries; |
| 454 | uint16_t num_nodes; |
| 455 | uint8_t reserved[6]; |
| 456 | } __packed; |
| 457 | |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 458 | /* IVHD Type 11h IOMMU Attributes */ |
| 459 | typedef struct ivhd11_iommu_attr { |
| 460 | uint32_t reserved1 : 13; |
| 461 | uint32_t perf_counters : 4; |
| 462 | uint32_t perf_counter_banks : 6; |
| 463 | uint32_t msi_num_ppr : 5; |
| 464 | uint32_t reserved2 : 4; |
| 465 | } __packed ivhd11_iommu_attr_t; |
| 466 | |
| 467 | /* IVRS IVHD (I/O Virtualization Hardware Definition Block) Type 11h */ |
| 468 | typedef struct acpi_ivrs_ivhd_11 { |
| 469 | uint8_t type; |
| 470 | uint8_t flags; |
| 471 | uint16_t length; |
| 472 | uint16_t device_id; |
| 473 | uint16_t capability_offset; |
| 474 | uint32_t iommu_base_low; |
| 475 | uint32_t iommu_base_high; |
| 476 | uint16_t pci_segment_group; |
| 477 | uint16_t iommu_info; |
| 478 | struct ivhd11_iommu_attr iommu_attributes; |
| 479 | uint32_t efr_reg_image_low; |
| 480 | uint32_t efr_reg_image_high; |
| 481 | uint32_t reserved[2]; |
| 482 | uint8_t entry[0]; |
| 483 | } __packed acpi_ivrs_ivhd11_t; |
| 484 | |
| 485 | enum dev_scope_type { |
| 486 | SCOPE_PCI_ENDPOINT = 1, |
| 487 | SCOPE_PCI_SUB = 2, |
| 488 | SCOPE_IOAPIC = 3, |
| 489 | SCOPE_MSI_HPET = 4, |
| 490 | SCOPE_ACPI_NAMESPACE_DEVICE = 5 |
| 491 | }; |
| 492 | |
| 493 | typedef struct dev_scope { |
| 494 | u8 type; |
| 495 | u8 length; |
| 496 | u8 reserved[2]; |
| 497 | u8 enumeration; |
| 498 | u8 start_bus; |
| 499 | struct { |
| 500 | u8 dev; |
| 501 | u8 fn; |
| 502 | } __packed path[0]; |
| 503 | } __packed dev_scope_t; |
| 504 | |
| 505 | enum dmar_type { |
| 506 | DMAR_DRHD = 0, |
| 507 | DMAR_RMRR = 1, |
| 508 | DMAR_ATSR = 2, |
| 509 | DMAR_RHSA = 3, |
John Zhao | 6edbb18 | 2021-03-24 11:55:09 -0700 | [diff] [blame] | 510 | DMAR_ANDD = 4, |
| 511 | DMAR_SATC = 5 |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 512 | }; |
| 513 | |
| 514 | enum { |
| 515 | DRHD_INCLUDE_PCI_ALL = 1 |
| 516 | }; |
| 517 | |
John Zhao | 091532d | 2021-04-17 16:03:21 -0700 | [diff] [blame] | 518 | enum { |
| 519 | ATC_REQUIRED = 1 |
| 520 | }; |
| 521 | |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 522 | enum dmar_flags { |
| 523 | DMAR_INTR_REMAP = 1 << 0, |
| 524 | DMAR_X2APIC_OPT_OUT = 1 << 1, |
| 525 | DMA_CTRL_PLATFORM_OPT_IN_FLAG = 1 << 2, |
| 526 | }; |
| 527 | |
| 528 | typedef struct dmar_entry { |
| 529 | u16 type; |
| 530 | u16 length; |
| 531 | u8 flags; |
| 532 | u8 reserved; |
| 533 | u16 segment; |
| 534 | u64 bar; |
| 535 | } __packed dmar_entry_t; |
| 536 | |
| 537 | typedef struct dmar_rmrr_entry { |
| 538 | u16 type; |
| 539 | u16 length; |
| 540 | u16 reserved; |
| 541 | u16 segment; |
| 542 | u64 bar; |
| 543 | u64 limit; |
| 544 | } __packed dmar_rmrr_entry_t; |
| 545 | |
| 546 | typedef struct dmar_atsr_entry { |
| 547 | u16 type; |
| 548 | u16 length; |
| 549 | u8 flags; |
| 550 | u8 reserved; |
| 551 | u16 segment; |
| 552 | } __packed dmar_atsr_entry_t; |
| 553 | |
| 554 | typedef struct dmar_rhsa_entry { |
| 555 | u16 type; |
| 556 | u16 length; |
| 557 | u32 reserved; |
| 558 | u64 base_address; |
| 559 | u32 proximity_domain; |
| 560 | } __packed dmar_rhsa_entry_t; |
| 561 | |
| 562 | typedef struct dmar_andd_entry { |
| 563 | u16 type; |
| 564 | u16 length; |
| 565 | u8 reserved[3]; |
| 566 | u8 device_number; |
| 567 | u8 device_name[]; |
| 568 | } __packed dmar_andd_entry_t; |
| 569 | |
John Zhao | 6edbb18 | 2021-03-24 11:55:09 -0700 | [diff] [blame] | 570 | typedef struct dmar_satc_entry { |
| 571 | u16 type; |
| 572 | u16 length; |
| 573 | u8 flags; |
| 574 | u8 reserved; |
| 575 | u16 segment_number; |
John Zhao | 6edbb18 | 2021-03-24 11:55:09 -0700 | [diff] [blame] | 576 | } __packed dmar_satc_entry_t; |
| 577 | |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 578 | /* DMAR (DMA Remapping Reporting Structure) */ |
| 579 | typedef struct acpi_dmar { |
| 580 | acpi_header_t header; |
| 581 | u8 host_address_width; |
| 582 | u8 flags; |
| 583 | u8 reserved[10]; |
| 584 | dmar_entry_t structure[0]; |
| 585 | } __packed acpi_dmar_t; |
| 586 | |
| 587 | /* MADT: APIC Structure Types */ |
| 588 | enum acpi_apic_types { |
| 589 | LOCAL_APIC, /* Processor local APIC */ |
| 590 | IO_APIC, /* I/O APIC */ |
| 591 | IRQ_SOURCE_OVERRIDE, /* Interrupt source override */ |
| 592 | NMI_TYPE, /* NMI source */ |
| 593 | LOCAL_APIC_NMI, /* Local APIC NMI */ |
| 594 | LAPIC_ADDRESS_OVERRIDE, /* Local APIC address override */ |
| 595 | IO_SAPIC, /* I/O SAPIC */ |
| 596 | LOCAL_SAPIC, /* Local SAPIC */ |
| 597 | PLATFORM_IRQ_SOURCES, /* Platform interrupt sources */ |
| 598 | LOCAL_X2APIC, /* Processor local x2APIC */ |
| 599 | LOCAL_X2APIC_NMI, /* Local x2APIC NMI */ |
| 600 | GICC, /* GIC CPU Interface */ |
| 601 | GICD, /* GIC Distributor */ |
| 602 | GIC_MSI_FRAME, /* GIC MSI Frame */ |
| 603 | GICR, /* GIC Redistributor */ |
| 604 | GIC_ITS, /* Interrupt Translation Service */ |
| 605 | /* 0x10-0x7f: Reserved */ |
| 606 | /* 0x80-0xff: Reserved for OEM use */ |
| 607 | }; |
| 608 | |
| 609 | /* MADT: Processor Local APIC Structure */ |
| 610 | typedef struct acpi_madt_lapic { |
| 611 | u8 type; /* Type (0) */ |
| 612 | u8 length; /* Length in bytes (8) */ |
| 613 | u8 processor_id; /* ACPI processor ID */ |
| 614 | u8 apic_id; /* Local APIC ID */ |
| 615 | u32 flags; /* Local APIC flags */ |
| 616 | } __packed acpi_madt_lapic_t; |
| 617 | |
| 618 | /* MADT: Local APIC NMI Structure */ |
| 619 | typedef struct acpi_madt_lapic_nmi { |
| 620 | u8 type; /* Type (4) */ |
| 621 | u8 length; /* Length in bytes (6) */ |
| 622 | u8 processor_id; /* ACPI processor ID */ |
| 623 | u16 flags; /* MPS INTI flags */ |
| 624 | u8 lint; /* Local APIC LINT# */ |
| 625 | } __packed acpi_madt_lapic_nmi_t; |
| 626 | |
Raul E Rangel | f5552ce | 2021-02-11 11:27:56 -0700 | [diff] [blame] | 627 | #define ACPI_MADT_LAPIC_NMI_ALL_PROCESSORS 0xff |
| 628 | |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 629 | /* MADT: I/O APIC Structure */ |
| 630 | typedef struct acpi_madt_ioapic { |
| 631 | u8 type; /* Type (1) */ |
| 632 | u8 length; /* Length in bytes (12) */ |
| 633 | u8 ioapic_id; /* I/O APIC ID */ |
| 634 | u8 reserved; |
| 635 | u32 ioapic_addr; /* I/O APIC address */ |
| 636 | u32 gsi_base; /* Global system interrupt base */ |
| 637 | } __packed acpi_madt_ioapic_t; |
| 638 | |
Raul E Rangel | 169302a | 2022-04-25 14:59:05 -0600 | [diff] [blame] | 639 | #define MP_IRQ_POLARITY_DEFAULT 0x0 |
| 640 | #define MP_IRQ_POLARITY_HIGH 0x1 |
| 641 | #define MP_IRQ_POLARITY_LOW 0x3 |
| 642 | #define MP_IRQ_POLARITY_MASK 0x3 |
| 643 | #define MP_IRQ_TRIGGER_DEFAULT 0x0 |
| 644 | #define MP_IRQ_TRIGGER_EDGE 0x4 |
| 645 | #define MP_IRQ_TRIGGER_LEVEL 0xc |
| 646 | #define MP_IRQ_TRIGGER_MASK 0xc |
| 647 | |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 648 | /* MADT: Interrupt Source Override Structure */ |
| 649 | typedef struct acpi_madt_irqoverride { |
| 650 | u8 type; /* Type (2) */ |
| 651 | u8 length; /* Length in bytes (10) */ |
| 652 | u8 bus; /* ISA (0) */ |
| 653 | u8 source; /* Bus-relative int. source (IRQ) */ |
| 654 | u32 gsirq; /* Global system interrupt */ |
| 655 | u16 flags; /* MPS INTI flags */ |
| 656 | } __packed acpi_madt_irqoverride_t; |
| 657 | |
| 658 | /* MADT: Processor Local x2APIC Structure */ |
| 659 | typedef struct acpi_madt_lx2apic { |
| 660 | u8 type; /* Type (9) */ |
| 661 | u8 length; /* Length in bytes (16) */ |
| 662 | u16 reserved; |
| 663 | u32 x2apic_id; /* Local x2APIC ID */ |
| 664 | u32 flags; /* Same as Local APIC flags */ |
| 665 | u32 processor_id; /* ACPI processor ID */ |
| 666 | } __packed acpi_madt_lx2apic_t; |
| 667 | |
| 668 | /* MADT: Processor Local x2APIC NMI Structure */ |
| 669 | typedef struct acpi_madt_lx2apic_nmi { |
| 670 | u8 type; /* Type (10) */ |
| 671 | u8 length; /* Length in bytes (12) */ |
| 672 | u16 flags; /* Same as MPS INTI flags */ |
| 673 | u32 processor_id; /* ACPI processor ID */ |
| 674 | u8 lint; /* Local APIC LINT# */ |
| 675 | u8 reserved[3]; |
| 676 | } __packed acpi_madt_lx2apic_nmi_t; |
| 677 | |
| 678 | #define ACPI_DBG2_PORT_SERIAL 0x8000 |
| 679 | #define ACPI_DBG2_PORT_SERIAL_16550 0x0000 |
| 680 | #define ACPI_DBG2_PORT_SERIAL_16550_DBGP 0x0001 |
| 681 | #define ACPI_DBG2_PORT_SERIAL_ARM_PL011 0x0003 |
| 682 | #define ACPI_DBG2_PORT_SERIAL_ARM_SBSA 0x000e |
| 683 | #define ACPI_DBG2_PORT_SERIAL_ARM_DDC 0x000f |
| 684 | #define ACPI_DBG2_PORT_SERIAL_BCM2835 0x0010 |
| 685 | #define ACPI_DBG2_PORT_IEEE1394 0x8001 |
| 686 | #define ACPI_DBG2_PORT_IEEE1394_STANDARD 0x0000 |
| 687 | #define ACPI_DBG2_PORT_USB 0x8002 |
| 688 | #define ACPI_DBG2_PORT_USB_XHCI 0x0000 |
| 689 | #define ACPI_DBG2_PORT_USB_EHCI 0x0001 |
| 690 | #define ACPI_DBG2_PORT_NET 0x8003 |
| 691 | |
| 692 | /* DBG2: Microsoft Debug Port Table 2 header */ |
| 693 | typedef struct acpi_dbg2_header { |
| 694 | acpi_header_t header; |
| 695 | uint32_t devices_offset; |
| 696 | uint32_t devices_count; |
| 697 | } __attribute__((packed)) acpi_dbg2_header_t; |
| 698 | |
| 699 | /* DBG2: Microsoft Debug Port Table 2 device entry */ |
| 700 | typedef struct acpi_dbg2_device { |
| 701 | uint8_t revision; |
| 702 | uint16_t length; |
| 703 | uint8_t address_count; |
| 704 | uint16_t namespace_string_length; |
| 705 | uint16_t namespace_string_offset; |
| 706 | uint16_t oem_data_length; |
| 707 | uint16_t oem_data_offset; |
| 708 | uint16_t port_type; |
| 709 | uint16_t port_subtype; |
| 710 | uint8_t reserved[2]; |
| 711 | uint16_t base_address_offset; |
| 712 | uint16_t address_size_offset; |
| 713 | } __attribute__((packed)) acpi_dbg2_device_t; |
| 714 | |
| 715 | /* FADT (Fixed ACPI Description Table) */ |
| 716 | typedef struct acpi_fadt { |
| 717 | acpi_header_t header; |
| 718 | u32 firmware_ctrl; |
| 719 | u32 dsdt; |
| 720 | u8 reserved; /* Should be 0 */ |
| 721 | u8 preferred_pm_profile; |
| 722 | u16 sci_int; |
| 723 | u32 smi_cmd; |
| 724 | u8 acpi_enable; |
| 725 | u8 acpi_disable; |
| 726 | u8 s4bios_req; |
| 727 | u8 pstate_cnt; |
| 728 | u32 pm1a_evt_blk; |
| 729 | u32 pm1b_evt_blk; |
| 730 | u32 pm1a_cnt_blk; |
| 731 | u32 pm1b_cnt_blk; |
| 732 | u32 pm2_cnt_blk; |
| 733 | u32 pm_tmr_blk; |
| 734 | u32 gpe0_blk; |
| 735 | u32 gpe1_blk; |
| 736 | u8 pm1_evt_len; |
| 737 | u8 pm1_cnt_len; |
| 738 | u8 pm2_cnt_len; |
| 739 | u8 pm_tmr_len; |
| 740 | u8 gpe0_blk_len; |
| 741 | u8 gpe1_blk_len; |
| 742 | u8 gpe1_base; |
| 743 | u8 cst_cnt; |
| 744 | u16 p_lvl2_lat; |
| 745 | u16 p_lvl3_lat; |
| 746 | u16 flush_size; |
| 747 | u16 flush_stride; |
| 748 | u8 duty_offset; |
| 749 | u8 duty_width; |
| 750 | u8 day_alrm; |
| 751 | u8 mon_alrm; |
| 752 | u8 century; |
| 753 | u16 iapc_boot_arch; |
| 754 | u8 res2; |
| 755 | u32 flags; |
| 756 | acpi_addr_t reset_reg; |
| 757 | u8 reset_value; |
Elyes Haouas | b55ac09 | 2022-02-16 14:42:19 +0100 | [diff] [blame] | 758 | u16 ARM_boot_arch; /* Must be zero if ACPI Revision <= 5.0 */ |
Elyes Haouas | 8b950f4 | 2022-02-16 12:08:16 +0100 | [diff] [blame] | 759 | u8 FADT_MinorVersion; /* Must be zero if ACPI Revision <= 5.0 */ |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 760 | u32 x_firmware_ctl_l; |
| 761 | u32 x_firmware_ctl_h; |
| 762 | u32 x_dsdt_l; |
| 763 | u32 x_dsdt_h; |
| 764 | acpi_addr_t x_pm1a_evt_blk; |
| 765 | acpi_addr_t x_pm1b_evt_blk; |
| 766 | acpi_addr_t x_pm1a_cnt_blk; |
| 767 | acpi_addr_t x_pm1b_cnt_blk; |
| 768 | acpi_addr_t x_pm2_cnt_blk; |
| 769 | acpi_addr_t x_pm_tmr_blk; |
| 770 | acpi_addr_t x_gpe0_blk; |
| 771 | acpi_addr_t x_gpe1_blk; |
| 772 | /* Revision 5 */ |
| 773 | acpi_addr_t sleep_control_reg; |
| 774 | acpi_addr_t sleep_status_reg; |
| 775 | /* Revision 6 */ |
| 776 | u64 hypervisor_vendor_identity; |
| 777 | } __packed acpi_fadt_t; |
| 778 | |
| 779 | /* FADT TABLE Revision values */ |
Elyes Haouas | 8b950f4 | 2022-02-16 12:08:16 +0100 | [diff] [blame] | 780 | #define ACPI_FADT_REV_ACPI_1 1 |
| 781 | #define ACPI_FADT_REV_ACPI_2 3 |
| 782 | #define ACPI_FADT_REV_ACPI_3 4 |
| 783 | #define ACPI_FADT_REV_ACPI_4 4 |
| 784 | #define ACPI_FADT_REV_ACPI_5 5 |
| 785 | #define ACPI_FADT_REV_ACPI_6 6 |
| 786 | |
| 787 | /* FADT Minor Version value: |
| 788 | * Bits 0-3: minor version |
| 789 | * Bits 4-7: Errata |
| 790 | * value of 1 means this is compatible with Errata A, |
| 791 | * value of 2 would be compatible with Errata B, and so on |
| 792 | * Version 6.3 Errata A would be: (1 << 4) | 3 |
| 793 | */ |
| 794 | #define ACPI_FADT_MINOR_VERSION_0 0 /* coreboot currently use this version */ |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 795 | |
| 796 | /* Flags for p_lvl2_lat and p_lvl3_lat */ |
| 797 | #define ACPI_FADT_C2_NOT_SUPPORTED 101 |
| 798 | #define ACPI_FADT_C3_NOT_SUPPORTED 1001 |
| 799 | |
| 800 | /* FADT Feature Flags */ |
| 801 | #define ACPI_FADT_WBINVD (1 << 0) |
| 802 | #define ACPI_FADT_WBINVD_FLUSH (1 << 1) |
| 803 | #define ACPI_FADT_C1_SUPPORTED (1 << 2) |
| 804 | #define ACPI_FADT_C2_MP_SUPPORTED (1 << 3) |
| 805 | #define ACPI_FADT_POWER_BUTTON (1 << 4) |
| 806 | #define ACPI_FADT_SLEEP_BUTTON (1 << 5) |
| 807 | #define ACPI_FADT_FIXED_RTC (1 << 6) |
| 808 | #define ACPI_FADT_S4_RTC_WAKE (1 << 7) |
| 809 | #define ACPI_FADT_32BIT_TIMER (1 << 8) |
| 810 | #define ACPI_FADT_DOCKING_SUPPORTED (1 << 9) |
| 811 | #define ACPI_FADT_RESET_REGISTER (1 << 10) |
| 812 | #define ACPI_FADT_SEALED_CASE (1 << 11) |
| 813 | #define ACPI_FADT_HEADLESS (1 << 12) |
| 814 | #define ACPI_FADT_SLEEP_TYPE (1 << 13) |
| 815 | #define ACPI_FADT_PCI_EXPRESS_WAKE (1 << 14) |
| 816 | #define ACPI_FADT_PLATFORM_CLOCK (1 << 15) |
| 817 | #define ACPI_FADT_S4_RTC_VALID (1 << 16) |
| 818 | #define ACPI_FADT_REMOTE_POWER_ON (1 << 17) |
| 819 | #define ACPI_FADT_APIC_CLUSTER (1 << 18) |
| 820 | #define ACPI_FADT_APIC_PHYSICAL (1 << 19) |
| 821 | /* Bits 20-31: reserved ACPI 3.0 & 4.0 */ |
| 822 | #define ACPI_FADT_HW_REDUCED_ACPI (1 << 20) |
| 823 | #define ACPI_FADT_LOW_PWR_IDLE_S0 (1 << 21) |
| 824 | /* bits 22-31: reserved since ACPI 5.0 */ |
| 825 | |
| 826 | /* FADT Boot Architecture Flags */ |
| 827 | #define ACPI_FADT_LEGACY_DEVICES (1 << 0) |
| 828 | #define ACPI_FADT_8042 (1 << 1) |
| 829 | #define ACPI_FADT_VGA_NOT_PRESENT (1 << 2) |
| 830 | #define ACPI_FADT_MSI_NOT_SUPPORTED (1 << 3) |
| 831 | #define ACPI_FADT_NO_PCIE_ASPM_CONTROL (1 << 4) |
| 832 | #define ACPI_FADT_NO_CMOS_RTC (1 << 5) |
| 833 | #define ACPI_FADT_LEGACY_FREE 0x00 /* No legacy devices (including 8042) */ |
| 834 | |
| 835 | /* FADT ARM Boot Architecture Flags */ |
| 836 | #define ACPI_FADT_ARM_PSCI_COMPLIANT (1 << 0) |
| 837 | #define ACPI_FADT_ARM_PSCI_USE_HVC (1 << 1) |
| 838 | /* bits 2-16: reserved since ACPI 5.1 */ |
| 839 | |
| 840 | /* FADT Preferred Power Management Profile */ |
| 841 | enum acpi_preferred_pm_profiles { |
| 842 | PM_UNSPECIFIED = 0, |
| 843 | PM_DESKTOP = 1, |
| 844 | PM_MOBILE = 2, |
| 845 | PM_WORKSTATION = 3, |
| 846 | PM_ENTERPRISE_SERVER = 4, |
| 847 | PM_SOHO_SERVER = 5, |
| 848 | PM_APPLIANCE_PC = 6, |
| 849 | PM_PERFORMANCE_SERVER = 7, |
| 850 | PM_TABLET = 8, /* ACPI 5.0 & greater */ |
| 851 | }; |
| 852 | |
| 853 | /* FACS (Firmware ACPI Control Structure) */ |
| 854 | typedef struct acpi_facs { |
| 855 | char signature[4]; /* "FACS" */ |
| 856 | u32 length; /* Length in bytes (>= 64) */ |
| 857 | u32 hardware_signature; /* Hardware signature */ |
| 858 | u32 firmware_waking_vector; /* Firmware waking vector */ |
| 859 | u32 global_lock; /* Global lock */ |
| 860 | u32 flags; /* FACS flags */ |
| 861 | u32 x_firmware_waking_vector_l; /* X FW waking vector, low */ |
| 862 | u32 x_firmware_waking_vector_h; /* X FW waking vector, high */ |
| 863 | u8 version; /* FACS version */ |
| 864 | u8 resv1[3]; /* This value is 0 */ |
| 865 | u32 ospm_flags; /* 64BIT_WAKE_F */ |
| 866 | u8 resv2[24]; /* This value is 0 */ |
| 867 | } __packed acpi_facs_t; |
| 868 | |
| 869 | /* FACS flags */ |
| 870 | #define ACPI_FACS_S4BIOS_F (1 << 0) |
| 871 | #define ACPI_FACS_64BIT_WAKE_F (1 << 1) |
| 872 | /* Bits 31..2: reserved */ |
| 873 | |
| 874 | /* ECDT (Embedded Controller Boot Resources Table) */ |
| 875 | typedef struct acpi_ecdt { |
| 876 | acpi_header_t header; |
| 877 | acpi_addr_t ec_control; /* EC control register */ |
| 878 | acpi_addr_t ec_data; /* EC data register */ |
| 879 | u32 uid; /* UID */ |
| 880 | u8 gpe_bit; /* GPE bit */ |
| 881 | u8 ec_id[]; /* EC ID */ |
| 882 | } __packed acpi_ecdt_t; |
| 883 | |
| 884 | /* HEST (Hardware Error Source Table) */ |
| 885 | typedef struct acpi_hest { |
| 886 | acpi_header_t header; |
| 887 | u32 error_source_count; |
| 888 | /* error_source_struct(s) */ |
| 889 | } __packed acpi_hest_t; |
| 890 | |
| 891 | /* Error Source Descriptors */ |
| 892 | typedef struct acpi_hest_esd { |
| 893 | u16 type; |
| 894 | u16 source_id; |
| 895 | u16 resv; |
| 896 | u8 flags; |
| 897 | u8 enabled; |
| 898 | u32 prealloc_erecords; /* The number of error records to |
| 899 | * pre-allocate for this error source. |
| 900 | */ |
| 901 | u32 max_section_per_record; |
| 902 | } __packed acpi_hest_esd_t; |
| 903 | |
| 904 | /* Hardware Error Notification */ |
| 905 | typedef struct acpi_hest_hen { |
| 906 | u8 type; |
| 907 | u8 length; |
| 908 | u16 conf_we; /* Configuration Write Enable */ |
| 909 | u32 poll_interval; |
| 910 | u32 vector; |
| 911 | u32 sw2poll_threshold_val; |
| 912 | u32 sw2poll_threshold_win; |
| 913 | u32 error_threshold_val; |
| 914 | u32 error_threshold_win; |
| 915 | } __packed acpi_hest_hen_t; |
| 916 | |
| 917 | /* BERT (Boot Error Record Table) */ |
| 918 | typedef struct acpi_bert { |
| 919 | acpi_header_t header; |
| 920 | u32 region_length; |
| 921 | u64 error_region; |
| 922 | } __packed acpi_bert_t; |
| 923 | |
| 924 | /* Generic Error Data Entry */ |
| 925 | typedef struct acpi_hest_generic_data { |
| 926 | guid_t section_type; |
| 927 | u32 error_severity; |
| 928 | u16 revision; |
| 929 | u8 validation_bits; |
| 930 | u8 flags; |
| 931 | u32 data_length; |
| 932 | guid_t fru_id; |
| 933 | u8 fru_text[20]; |
| 934 | /* error data */ |
| 935 | } __packed acpi_hest_generic_data_t; |
| 936 | |
| 937 | /* Generic Error Data Entry v300 */ |
| 938 | typedef struct acpi_hest_generic_data_v300 { |
| 939 | guid_t section_type; |
| 940 | u32 error_severity; |
| 941 | u16 revision; |
| 942 | u8 validation_bits; |
| 943 | u8 flags; /* see CPER Section Descriptor, Flags field */ |
| 944 | u32 data_length; |
| 945 | guid_t fru_id; |
| 946 | u8 fru_text[20]; |
| 947 | cper_timestamp_t timestamp; |
| 948 | /* error data */ |
| 949 | } __packed acpi_hest_generic_data_v300_t; |
| 950 | #define HEST_GENERIC_ENTRY_V300 0x300 |
| 951 | |
| 952 | /* Both Generic Error Status & Generic Error Data Entry, Error Severity field */ |
| 953 | #define ACPI_GENERROR_SEV_RECOVERABLE 0 |
| 954 | #define ACPI_GENERROR_SEV_FATAL 1 |
| 955 | #define ACPI_GENERROR_SEV_CORRECTED 2 |
| 956 | #define ACPI_GENERROR_SEV_NONE 3 |
| 957 | |
| 958 | /* Generic Error Data Entry, Validation Bits field */ |
| 959 | #define ACPI_GENERROR_VALID_FRUID BIT(0) |
| 960 | #define ACPI_GENERROR_VALID_FRUID_TEXT BIT(1) |
| 961 | #define ACPI_GENERROR_VALID_TIMESTAMP BIT(2) |
| 962 | |
Felix Held | 403fa86 | 2021-07-26 22:43:00 +0200 | [diff] [blame] | 963 | /* |
| 964 | * Generic Error Status Block |
| 965 | * |
| 966 | * If there is a raw data section at the end of the generic error status block after the |
| 967 | * zero or more generic error data entries, raw_data_length indicates the length of the raw |
| 968 | * section and raw_data_offset is the offset of the beginning of the raw data section from |
| 969 | * the start of the acpi_generic_error_status block it is contained in. So if raw_data_length |
| 970 | * is non-zero, raw_data_offset must be at least sizeof(acpi_generic_error_status_t). |
| 971 | */ |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 972 | typedef struct acpi_generic_error_status { |
| 973 | u32 block_status; |
| 974 | u32 raw_data_offset; /* must follow any generic entries */ |
| 975 | u32 raw_data_length; |
| 976 | u32 data_length; /* generic data */ |
| 977 | u32 error_severity; |
| 978 | /* Generic Error Data structures, zero or more entries */ |
| 979 | } __packed acpi_generic_error_status_t; |
| 980 | |
| 981 | /* Generic Status Block, Block Status values */ |
| 982 | #define GENERIC_ERR_STS_UNCORRECTABLE_VALID BIT(0) |
| 983 | #define GENERIC_ERR_STS_CORRECTABLE_VALID BIT(1) |
| 984 | #define GENERIC_ERR_STS_MULT_UNCORRECTABLE BIT(2) |
| 985 | #define GENERIC_ERR_STS_MULT_CORRECTABLE BIT(3) |
| 986 | #define GENERIC_ERR_STS_ENTRY_COUNT_SHIFT 4 |
| 987 | #define GENERIC_ERR_STS_ENTRY_COUNT_MAX 0x3ff |
| 988 | #define GENERIC_ERR_STS_ENTRY_COUNT_MASK \ |
| 989 | (GENERIC_ERR_STS_ENTRY_COUNT_MAX \ |
| 990 | << GENERIC_ERR_STS_ENTRY_COUNT_SHIFT) |
| 991 | |
| 992 | typedef struct acpi_cstate { |
| 993 | u8 ctype; |
| 994 | u16 latency; |
| 995 | u32 power; |
| 996 | acpi_addr_t resource; |
| 997 | } __packed acpi_cstate_t; |
| 998 | |
Jason Glenesk | ca36aed | 2020-09-15 21:01:57 -0700 | [diff] [blame] | 999 | struct acpi_sw_pstate { |
| 1000 | u32 core_freq; |
| 1001 | u32 power; |
| 1002 | u32 transition_latency; |
| 1003 | u32 bus_master_latency; |
| 1004 | u32 control_value; |
| 1005 | u32 status_value; |
| 1006 | } __packed; |
| 1007 | |
| 1008 | struct acpi_xpss_sw_pstate { |
| 1009 | u64 core_freq; |
| 1010 | u64 power; |
| 1011 | u64 transition_latency; |
| 1012 | u64 bus_master_latency; |
| 1013 | u64 control_value; |
| 1014 | u64 status_value; |
| 1015 | u64 control_mask; |
| 1016 | u64 status_mask; |
| 1017 | } __packed; |
| 1018 | |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 1019 | typedef struct acpi_tstate { |
| 1020 | u32 percent; |
| 1021 | u32 power; |
| 1022 | u32 latency; |
| 1023 | u32 control; |
| 1024 | u32 status; |
| 1025 | } __packed acpi_tstate_t; |
| 1026 | |
Raul E Rangel | c704832 | 2021-04-19 15:58:25 -0600 | [diff] [blame] | 1027 | enum acpi_lpi_state_flags { |
| 1028 | ACPI_LPI_STATE_DISABLED = 0, |
| 1029 | ACPI_LPI_STATE_ENABLED |
| 1030 | }; |
| 1031 | |
| 1032 | /* Low Power Idle State */ |
| 1033 | struct acpi_lpi_state { |
| 1034 | u32 min_residency_us; |
| 1035 | u32 worst_case_wakeup_latency_us; |
| 1036 | u32 flags; |
| 1037 | u32 arch_context_lost_flags; |
| 1038 | u32 residency_counter_frequency_hz; |
| 1039 | u32 enabled_parent_state; |
| 1040 | acpi_addr_t entry_method; |
| 1041 | acpi_addr_t residency_counter_register; |
| 1042 | acpi_addr_t usage_counter_register; |
| 1043 | const char *state_name; |
| 1044 | }; |
| 1045 | |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 1046 | /* Port types for ACPI _UPC object */ |
| 1047 | enum acpi_upc_type { |
| 1048 | UPC_TYPE_A, |
| 1049 | UPC_TYPE_MINI_AB, |
| 1050 | UPC_TYPE_EXPRESSCARD, |
| 1051 | UPC_TYPE_USB3_A, |
| 1052 | UPC_TYPE_USB3_B, |
| 1053 | UPC_TYPE_USB3_MICRO_B, |
| 1054 | UPC_TYPE_USB3_MICRO_AB, |
| 1055 | UPC_TYPE_USB3_POWER_B, |
| 1056 | UPC_TYPE_C_USB2_ONLY, |
| 1057 | UPC_TYPE_C_USB2_SS_SWITCH, |
| 1058 | UPC_TYPE_C_USB2_SS, |
| 1059 | UPC_TYPE_PROPRIETARY = 0xff, |
| 1060 | /* |
| 1061 | * The following types are not directly defined in the ACPI |
| 1062 | * spec but are used by coreboot to identify a USB device type. |
| 1063 | */ |
| 1064 | UPC_TYPE_INTERNAL = 0xff, |
| 1065 | UPC_TYPE_UNUSED, |
| 1066 | UPC_TYPE_HUB |
| 1067 | }; |
| 1068 | |
| 1069 | enum acpi_ipmi_interface_type { |
| 1070 | IPMI_INTERFACE_RESERVED = 0, |
| 1071 | IPMI_INTERFACE_KCS, |
| 1072 | IPMI_INTERFACE_SMIC, |
| 1073 | IPMI_INTERFACE_BT, |
| 1074 | IPMI_INTERFACE_SSIF, |
| 1075 | }; |
| 1076 | |
| 1077 | #define ACPI_IPMI_PCI_DEVICE_FLAG (1 << 0) |
| 1078 | #define ACPI_IPMI_INT_TYPE_SCI (1 << 0) |
| 1079 | #define ACPI_IPMI_INT_TYPE_APIC (1 << 1) |
| 1080 | |
| 1081 | /* ACPI IPMI 2.0 */ |
| 1082 | struct acpi_spmi { |
| 1083 | acpi_header_t header; |
| 1084 | u8 interface_type; |
| 1085 | u8 reserved; |
| 1086 | u16 specification_revision; |
| 1087 | u8 interrupt_type; |
| 1088 | u8 gpe; |
| 1089 | u8 reserved2; |
| 1090 | u8 pci_device_flag; |
| 1091 | |
| 1092 | u32 global_system_interrupt; |
| 1093 | acpi_addr_t base_address; |
| 1094 | union { |
| 1095 | struct { |
| 1096 | u8 pci_segment_group; |
| 1097 | u8 pci_bus; |
| 1098 | u8 pci_device; |
| 1099 | u8 pci_function; |
| 1100 | }; |
| 1101 | u8 uid[4]; |
| 1102 | }; |
| 1103 | u8 reserved3; |
| 1104 | } __packed; |
| 1105 | |
Rocky Phagura | eff0713 | 2021-01-10 15:42:50 -0800 | [diff] [blame] | 1106 | /* EINJ APEI Standard Definitions */ |
| 1107 | /* EINJ Error Types |
| 1108 | Refer to the ACPI spec, EINJ section, for more info on bit definitions |
| 1109 | */ |
| 1110 | #define ACPI_EINJ_CPU_CE (1 << 0) |
| 1111 | #define ACPI_EINJ_CPU_UCE (1 << 1) |
| 1112 | #define ACPI_EINJ_CPU_UCE_FATAL (1 << 2) |
| 1113 | #define ACPI_EINJ_MEM_CE (1 << 3) |
| 1114 | #define ACPI_EINJ_MEM_UCE (1 << 4) |
| 1115 | #define ACPI_EINJ_MEM_UCE_FATAL (1 << 5) |
| 1116 | #define ACPI_EINJ_PCIE_CE (1 << 6) |
| 1117 | #define ACPI_EINJ_PCIE_UCE_NON_FATAL (1 << 7) |
| 1118 | #define ACPI_EINJ_PCIE_UCE_FATAL (1 << 8) |
| 1119 | #define ACPI_EINJ_PLATFORM_CE (1 << 9) |
| 1120 | #define ACPI_EINJ_PLATFORM_UCE (1 << 10) |
| 1121 | #define ACPI_EINJ_PLATFORM_UCE_FATAL (1 << 11) |
| 1122 | #define ACPI_EINJ_VENDOR_DEFINED (1 << 31) |
| 1123 | #define ACPI_EINJ_DEFAULT_CAP (ACPI_EINJ_MEM_CE | ACPI_EINJ_MEM_UCE | \ |
| 1124 | ACPI_EINJ_PCIE_CE | ACPI_EINJ_PCIE_UCE_FATAL) |
| 1125 | |
| 1126 | /* EINJ actions */ |
| 1127 | #define ACTION_COUNT 9 |
| 1128 | #define BEGIN_INJECT_OP 0x00 |
| 1129 | #define GET_TRIGGER_ACTION_TABLE 0x01 |
| 1130 | #define SET_ERROR_TYPE 0x02 |
| 1131 | #define GET_ERROR_TYPE 0x03 |
| 1132 | #define END_INJECT_OP 0x04 |
| 1133 | #define EXECUTE_INJECT_OP 0x05 |
| 1134 | #define CHECK_BUSY_STATUS 0x06 |
| 1135 | #define GET_CMD_STATUS 0x07 |
| 1136 | #define SET_ERROR_TYPE_WITH_ADDRESS 0x08 |
| 1137 | #define TRIGGER_ERROR 0xFF |
| 1138 | |
| 1139 | /* EINJ Instructions */ |
| 1140 | #define READ_REGISTER 0x00 |
| 1141 | #define READ_REGISTER_VALUE 0x01 |
| 1142 | #define WRITE_REGISTER 0x02 |
| 1143 | #define WRITE_REGISTER_VALUE 0x03 |
| 1144 | #define NO_OP 0x04 |
| 1145 | |
| 1146 | /* EINJ (Error Injection Table) */ |
| 1147 | typedef struct acpi_gen_regaddr1 { |
| 1148 | u8 space_id; /* Address space ID */ |
| 1149 | u8 bit_width; /* Register size in bits */ |
| 1150 | u8 bit_offset; /* Register bit offset */ |
| 1151 | u8 access_size; /* Access size since ACPI 2.0c */ |
| 1152 | u64 addr; /* Register address */ |
| 1153 | } __packed acpi_addr64_t; |
| 1154 | |
| 1155 | /* Instruction entry */ |
| 1156 | typedef struct acpi_einj_action_table { |
| 1157 | u8 action; |
| 1158 | u8 instruction; |
| 1159 | u16 flags; |
| 1160 | acpi_addr64_t reg; |
| 1161 | u64 value; |
| 1162 | u64 mask; |
| 1163 | } __packed acpi_einj_action_table_t; |
| 1164 | |
| 1165 | typedef struct acpi_injection_header { |
| 1166 | u32 einj_header_size; |
| 1167 | u32 flags; |
| 1168 | u32 entry_count; |
| 1169 | } __packed acpi_injection_header_t; |
| 1170 | |
| 1171 | typedef struct acpi_einj_trigger_table { |
| 1172 | u32 header_size; |
| 1173 | u32 revision; |
| 1174 | u32 table_size; |
| 1175 | u32 entry_count; |
| 1176 | acpi_einj_action_table_t trigger_action[1]; |
| 1177 | } __packed acpi_einj_trigger_table_t; |
| 1178 | |
| 1179 | typedef struct set_error_type { |
| 1180 | u32 errtype; |
| 1181 | u32 vendorerrortype; |
| 1182 | u32 flags; |
| 1183 | u32 apicid; |
| 1184 | u64 memaddr; |
| 1185 | u64 memrange; |
| 1186 | u32 pciesbdf; |
| 1187 | } __packed set_error_type_t; |
| 1188 | |
| 1189 | #define EINJ_PARAM_NUM 6 |
| 1190 | typedef struct acpi_einj_smi { |
| 1191 | u64 op_state; |
| 1192 | u64 err_inject[EINJ_PARAM_NUM]; |
| 1193 | u64 trigger_action_table; |
| 1194 | u64 err_inj_cap; |
| 1195 | u64 op_status; |
| 1196 | u64 cmd_sts; |
| 1197 | u64 einj_addr; |
| 1198 | u64 einj_addr_msk; |
| 1199 | set_error_type_t setaddrtable; |
| 1200 | u64 reserved[50]; |
| 1201 | } __packed acpi_einj_smi_t; |
| 1202 | |
| 1203 | /* EINJ Flags */ |
| 1204 | #define EINJ_DEF_TRIGGER_PORT 0xb2 |
| 1205 | #define FLAG_PRESERVE 0x01 |
| 1206 | #define FLAG_IGNORE 0x00 |
| 1207 | |
| 1208 | /* EINJ Registers */ |
| 1209 | #define EINJ_REG_MEMORY(address) \ |
| 1210 | { \ |
| 1211 | .space_id = ACPI_ADDRESS_SPACE_MEMORY, \ |
| 1212 | .bit_width = 64, \ |
| 1213 | .bit_offset = 0, \ |
| 1214 | .access_size = ACPI_ACCESS_SIZE_QWORD_ACCESS, \ |
| 1215 | .addr = address} |
| 1216 | |
| 1217 | #define EINJ_REG_IO() \ |
| 1218 | { \ |
| 1219 | .space_id = ACPI_ADDRESS_SPACE_IO, \ |
| 1220 | .bit_width = 0x10, \ |
| 1221 | .bit_offset = 0, \ |
| 1222 | .access_size = ACPI_ACCESS_SIZE_WORD_ACCESS, \ |
| 1223 | .addr = EINJ_DEF_TRIGGER_PORT} /* HW dependent code can override this also */ |
| 1224 | |
| 1225 | typedef struct acpi_einj { |
| 1226 | acpi_header_t header; |
| 1227 | acpi_injection_header_t inj_header; |
| 1228 | acpi_einj_action_table_t action_table[ACTION_COUNT]; |
| 1229 | } __packed acpi_einj_t; |
| 1230 | |
| 1231 | |
Arthur Heymans | 2e7e2d9 | 2022-03-03 22:28:27 +0100 | [diff] [blame] | 1232 | uintptr_t get_coreboot_rsdp(void); |
Rocky Phagura | eff0713 | 2021-01-10 15:42:50 -0800 | [diff] [blame] | 1233 | void acpi_create_einj(acpi_einj_t *einj, uintptr_t addr, u8 actions); |
| 1234 | |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 1235 | unsigned long fw_cfg_acpi_tables(unsigned long start); |
| 1236 | |
| 1237 | /* These are implemented by the target port or north/southbridge. */ |
Raul E Rangel | 6b446b9 | 2021-11-19 11:38:35 -0700 | [diff] [blame] | 1238 | void preload_acpi_dsdt(void); |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 1239 | unsigned long write_acpi_tables(unsigned long addr); |
| 1240 | unsigned long acpi_fill_madt(unsigned long current); |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 1241 | unsigned long acpi_fill_ivrs_ioapic(acpi_ivrs_t *ivrs, unsigned long current); |
| 1242 | void acpi_create_ssdt_generator(acpi_header_t *ssdt, const char *oem_table_id); |
| 1243 | void acpi_write_bert(acpi_bert_t *bert, uintptr_t region, size_t length); |
| 1244 | void acpi_create_fadt(acpi_fadt_t *fadt, acpi_facs_t *facs, void *dsdt); |
Kyösti Mälkki | f9aac92 | 2020-05-30 16:16:28 +0300 | [diff] [blame] | 1245 | |
Tarun Tuli | c66ea98 | 2022-05-03 20:35:47 +0000 | [diff] [blame] | 1246 | void soc_lpi_get_constraints(void *unused); |
| 1247 | |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 1248 | void acpi_fill_fadt(acpi_fadt_t *fadt); |
Angel Pons | 79572e4 | 2020-07-13 00:17:43 +0200 | [diff] [blame] | 1249 | void arch_fill_fadt(acpi_fadt_t *fadt); |
Kyösti Mälkki | f9aac92 | 2020-05-30 16:16:28 +0300 | [diff] [blame] | 1250 | void soc_fill_fadt(acpi_fadt_t *fadt); |
Kyösti Mälkki | 02fd15d | 2020-06-02 03:34:43 +0300 | [diff] [blame] | 1251 | void mainboard_fill_fadt(acpi_fadt_t *fadt); |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 1252 | |
Kyösti Mälkki | 2ab4a96 | 2020-06-30 11:41:47 +0300 | [diff] [blame] | 1253 | void acpi_fill_gnvs(void); |
Kyösti Mälkki | 3dc1792 | 2021-03-16 19:01:48 +0200 | [diff] [blame] | 1254 | void acpi_fill_cnvs(void); |
Kyösti Mälkki | 2ab4a96 | 2020-06-30 11:41:47 +0300 | [diff] [blame] | 1255 | |
Michael Niewöhner | f0a44ae | 2021-01-01 21:04:09 +0100 | [diff] [blame] | 1256 | unsigned long acpi_fill_lpit(unsigned long current); |
| 1257 | |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 1258 | /* These can be used by the target port. */ |
| 1259 | u8 acpi_checksum(u8 *table, u32 length); |
| 1260 | |
| 1261 | void acpi_add_table(acpi_rsdp_t *rsdp, void *table); |
| 1262 | |
| 1263 | int acpi_create_madt_lapic(acpi_madt_lapic_t *lapic, u8 cpu, u8 apic); |
| 1264 | int acpi_create_madt_ioapic(acpi_madt_ioapic_t *ioapic, u8 id, u32 addr, |
| 1265 | u32 gsi_base); |
| 1266 | int acpi_create_madt_irqoverride(acpi_madt_irqoverride_t *irqoverride, |
| 1267 | u8 bus, u8 source, u32 gsirq, u16 flags); |
| 1268 | int acpi_create_madt_lapic_nmi(acpi_madt_lapic_nmi_t *lapic_nmi, u8 cpu, |
| 1269 | u16 flags, u8 lint); |
| 1270 | void acpi_create_madt(acpi_madt_t *madt); |
| 1271 | unsigned long acpi_create_madt_lapics(unsigned long current); |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 1272 | int acpi_create_madt_lx2apic(acpi_madt_lx2apic_t *lapic, u32 cpu, u32 apic); |
| 1273 | int acpi_create_madt_lx2apic_nmi(acpi_madt_lx2apic_nmi_t *lapic_nmi, u32 cpu, |
| 1274 | u16 flags, u8 lint); |
| 1275 | int acpi_create_srat_lapic(acpi_srat_lapic_t *lapic, u8 node, u8 apic); |
| 1276 | int acpi_create_srat_mem(acpi_srat_mem_t *mem, u8 node, u32 basek, u32 sizek, |
| 1277 | u32 flags); |
Jonathan Zhang | 3164b64 | 2021-04-21 17:51:31 -0700 | [diff] [blame] | 1278 | /* |
| 1279 | * Given the Generic Initiator device's BDF, the proximity domain's ID |
| 1280 | * and flag, create Generic Initiator Affinity structure in SRAT. |
| 1281 | */ |
| 1282 | int acpi_create_srat_gia_pci(acpi_srat_gia_t *gia, u32 proximity_domain, |
| 1283 | u16 seg, u8 bus, u8 dev, u8 func, u32 flags); |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 1284 | int acpi_create_mcfg_mmconfig(acpi_mcfg_mmconfig_t *mmconfig, u32 base, |
| 1285 | u16 seg_nr, u8 start, u8 end); |
| 1286 | unsigned long acpi_create_srat_lapics(unsigned long current); |
| 1287 | void acpi_create_srat(acpi_srat_t *srat, |
| 1288 | unsigned long (*acpi_fill_srat)(unsigned long current)); |
| 1289 | |
| 1290 | void acpi_create_slit(acpi_slit_t *slit, |
| 1291 | unsigned long (*acpi_fill_slit)(unsigned long current)); |
| 1292 | |
Jonathan Zhang | 2a4e1f4 | 2021-04-01 11:43:37 -0700 | [diff] [blame] | 1293 | /* |
| 1294 | * Create a Memory Proximity Domain Attributes structure for HMAT, |
| 1295 | * given proximity domain for the attached initiaor, and |
| 1296 | * proximimity domain for the memory. |
| 1297 | */ |
| 1298 | int acpi_create_hmat_mpda(acpi_hmat_mpda_t *mpda, u32 initiator, u32 memory); |
Martin Roth | 0949e73 | 2021-10-01 14:28:22 -0600 | [diff] [blame] | 1299 | /* Create Heterogeneous Memory Attribute Table */ |
Jonathan Zhang | 2a4e1f4 | 2021-04-01 11:43:37 -0700 | [diff] [blame] | 1300 | void acpi_create_hmat(acpi_hmat_t *hmat, |
| 1301 | unsigned long (*acpi_fill_hmat)(unsigned long current)); |
| 1302 | |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 1303 | void acpi_create_vfct(const struct device *device, |
| 1304 | acpi_vfct_t *vfct, |
| 1305 | unsigned long (*acpi_fill_vfct)(const struct device *device, |
| 1306 | acpi_vfct_t *vfct_struct, |
| 1307 | unsigned long current)); |
| 1308 | |
| 1309 | void acpi_create_ipmi(const struct device *device, |
| 1310 | struct acpi_spmi *spmi, |
| 1311 | const u16 ipmi_revision, |
| 1312 | const acpi_addr_t *addr, |
| 1313 | const enum acpi_ipmi_interface_type type, |
| 1314 | const s8 gpe_interrupt, |
| 1315 | const u32 apic_interrupt, |
| 1316 | const u32 uid); |
| 1317 | |
| 1318 | void acpi_create_ivrs(acpi_ivrs_t *ivrs, |
| 1319 | unsigned long (*acpi_fill_ivrs)(acpi_ivrs_t *ivrs_struct, |
| 1320 | unsigned long current)); |
| 1321 | |
Jason Glenesk | 61624b2 | 2020-11-02 20:06:23 -0800 | [diff] [blame] | 1322 | void acpi_create_crat(struct acpi_crat_header *crat, |
| 1323 | unsigned long (*acpi_fill_crat)(struct acpi_crat_header *crat_struct, |
| 1324 | unsigned long current)); |
| 1325 | |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 1326 | void acpi_create_hpet(acpi_hpet_t *hpet); |
| 1327 | unsigned long acpi_write_hpet(const struct device *device, unsigned long start, |
| 1328 | acpi_rsdp_t *rsdp); |
| 1329 | |
| 1330 | /* cpu/intel/speedstep/acpi.c */ |
| 1331 | void generate_cpu_entries(const struct device *device); |
| 1332 | |
| 1333 | void acpi_create_mcfg(acpi_mcfg_t *mcfg); |
| 1334 | |
| 1335 | void acpi_create_facs(acpi_facs_t *facs); |
| 1336 | |
| 1337 | void acpi_create_dbg2(acpi_dbg2_header_t *dbg2_header, |
| 1338 | int port_type, int port_subtype, |
| 1339 | acpi_addr_t *address, uint32_t address_size, |
| 1340 | const char *device_path); |
| 1341 | |
| 1342 | unsigned long acpi_write_dbg2_pci_uart(acpi_rsdp_t *rsdp, unsigned long current, |
| 1343 | const struct device *dev, uint8_t access_size); |
| 1344 | void acpi_create_dmar(acpi_dmar_t *dmar, enum dmar_flags flags, |
| 1345 | unsigned long (*acpi_fill_dmar)(unsigned long)); |
| 1346 | unsigned long acpi_create_dmar_drhd(unsigned long current, u8 flags, |
| 1347 | u16 segment, u64 bar); |
| 1348 | unsigned long acpi_create_dmar_rmrr(unsigned long current, u16 segment, |
| 1349 | u64 bar, u64 limit); |
| 1350 | unsigned long acpi_create_dmar_atsr(unsigned long current, u8 flags, |
| 1351 | u16 segment); |
| 1352 | unsigned long acpi_create_dmar_rhsa(unsigned long current, u64 base_addr, |
| 1353 | u32 proximity_domain); |
| 1354 | unsigned long acpi_create_dmar_andd(unsigned long current, u8 device_number, |
| 1355 | const char *device_name); |
John Zhao | 6edbb18 | 2021-03-24 11:55:09 -0700 | [diff] [blame] | 1356 | unsigned long acpi_create_dmar_satc(unsigned long current, u8 flags, |
John Zhao | 091532d | 2021-04-17 16:03:21 -0700 | [diff] [blame] | 1357 | u16 segment); |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 1358 | void acpi_dmar_drhd_fixup(unsigned long base, unsigned long current); |
| 1359 | void acpi_dmar_rmrr_fixup(unsigned long base, unsigned long current); |
| 1360 | void acpi_dmar_atsr_fixup(unsigned long base, unsigned long current); |
John Zhao | 6edbb18 | 2021-03-24 11:55:09 -0700 | [diff] [blame] | 1361 | void acpi_dmar_satc_fixup(unsigned long base, unsigned long current); |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 1362 | unsigned long acpi_create_dmar_ds_pci_br(unsigned long current, |
| 1363 | u8 bus, u8 dev, u8 fn); |
| 1364 | unsigned long acpi_create_dmar_ds_pci(unsigned long current, |
| 1365 | u8 bus, u8 dev, u8 fn); |
| 1366 | unsigned long acpi_create_dmar_ds_ioapic(unsigned long current, |
| 1367 | u8 enumeration_id, |
| 1368 | u8 bus, u8 dev, u8 fn); |
| 1369 | unsigned long acpi_create_dmar_ds_msi_hpet(unsigned long current, |
| 1370 | u8 enumeration_id, |
| 1371 | u8 bus, u8 dev, u8 fn); |
| 1372 | void acpi_write_hest(acpi_hest_t *hest, |
| 1373 | unsigned long (*acpi_fill_hest)(acpi_hest_t *hest)); |
| 1374 | |
| 1375 | unsigned long acpi_create_hest_error_source(acpi_hest_t *hest, |
| 1376 | acpi_hest_esd_t *esd, u16 type, void *data, u16 len); |
| 1377 | |
Michael Niewöhner | f0a44ae | 2021-01-01 21:04:09 +0100 | [diff] [blame] | 1378 | void acpi_create_lpit(acpi_lpit_t *lpit); |
| 1379 | unsigned long acpi_create_lpi_desc_ncst(acpi_lpi_desc_ncst_t *lpi_desc, uint16_t uid); |
| 1380 | |
Felix Held | f7dbf4a | 2021-06-07 16:56:04 +0200 | [diff] [blame] | 1381 | /* chipsets that select ACPI_BERT must implement this function */ |
Felix Held | 2940548 | 2021-05-28 16:01:57 +0200 | [diff] [blame] | 1382 | enum cb_err acpi_soc_get_bert_region(void **region, size_t *length); |
Francois Toguo | 522e0db | 2021-01-21 09:55:19 -0800 | [diff] [blame] | 1383 | |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 1384 | /* For ACPI S3 support. */ |
Kyösti Mälkki | a4c0e1a | 2020-06-18 08:28:12 +0300 | [diff] [blame] | 1385 | void __noreturn acpi_resume(void *wake_vec); |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 1386 | void mainboard_suspend_resume(void); |
| 1387 | void *acpi_find_wakeup_vector(void); |
| 1388 | |
| 1389 | /* ACPI_Sn assignments are defined to always equal the sleep state numbers */ |
| 1390 | enum { |
| 1391 | ACPI_S0 = 0, |
| 1392 | ACPI_S1 = 1, |
| 1393 | ACPI_S2 = 2, |
| 1394 | ACPI_S3 = 3, |
| 1395 | ACPI_S4 = 4, |
| 1396 | ACPI_S5 = 5, |
| 1397 | }; |
| 1398 | |
| 1399 | #if CONFIG(ACPI_INTEL_HARDWARE_SLEEP_VALUES) \ |
| 1400 | || CONFIG(ACPI_AMD_HARDWARE_SLEEP_VALUES) |
| 1401 | /* Given the provided PM1 control register return the ACPI sleep type. */ |
| 1402 | static inline int acpi_sleep_from_pm1(uint32_t pm1_cnt) |
| 1403 | { |
| 1404 | switch (((pm1_cnt) & SLP_TYP) >> SLP_TYP_SHIFT) { |
| 1405 | case SLP_TYP_S0: return ACPI_S0; |
| 1406 | case SLP_TYP_S1: return ACPI_S1; |
| 1407 | case SLP_TYP_S3: return ACPI_S3; |
| 1408 | case SLP_TYP_S4: return ACPI_S4; |
| 1409 | case SLP_TYP_S5: return ACPI_S5; |
| 1410 | } |
| 1411 | return -1; |
| 1412 | } |
| 1413 | #endif |
| 1414 | |
Kyösti Mälkki | e0d3868 | 2020-06-07 12:01:58 +0300 | [diff] [blame] | 1415 | uint8_t acpi_get_preferred_pm_profile(void); |
| 1416 | |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 1417 | /* Returns ACPI_Sx values. */ |
| 1418 | int acpi_get_sleep_type(void); |
| 1419 | |
| 1420 | /* Read and clear GPE status */ |
| 1421 | int acpi_get_gpe(int gpe); |
| 1422 | |
Kyösti Mälkki | 0a9e72e | 2019-08-11 01:22:28 +0300 | [diff] [blame] | 1423 | /* Once we enter payload, is SMI handler installed and capable of |
| 1424 | responding to APM_CNT Advanced Power Management Control commands. */ |
| 1425 | static inline int permanent_smi_handler(void) |
| 1426 | { |
| 1427 | return CONFIG(HAVE_SMI_HANDLER); |
| 1428 | } |
| 1429 | |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 1430 | static inline int acpi_s3_resume_allowed(void) |
| 1431 | { |
| 1432 | return CONFIG(HAVE_ACPI_RESUME); |
| 1433 | } |
| 1434 | |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 1435 | static inline int acpi_is_wakeup_s3(void) |
| 1436 | { |
Kyösti Mälkki | 4a3f67a | 2020-06-18 13:44:29 +0300 | [diff] [blame] | 1437 | if (!acpi_s3_resume_allowed()) |
| 1438 | return 0; |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 1439 | |
Kyösti Mälkki | 4a3f67a | 2020-06-18 13:44:29 +0300 | [diff] [blame] | 1440 | if (ENV_ROMSTAGE_OR_BEFORE) |
| 1441 | return (acpi_get_sleep_type() == ACPI_S3); |
| 1442 | |
Kyösti Mälkki | ac0dc4a | 2020-11-18 07:40:21 +0200 | [diff] [blame] | 1443 | return romstage_handoff_is_resume(); |
Kyösti Mälkki | 4a3f67a | 2020-06-18 13:44:29 +0300 | [diff] [blame] | 1444 | } |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 1445 | |
| 1446 | static inline uintptr_t acpi_align_current(uintptr_t current) |
| 1447 | { |
| 1448 | return ALIGN_UP(current, 16); |
| 1449 | } |
| 1450 | |
| 1451 | /* ACPI table revisions should match the revision of the ACPI spec |
| 1452 | * supported. This function keeps the table versions synced. This could |
| 1453 | * be made into a weak function if there is ever a need to override the |
| 1454 | * coreboot default ACPI spec version supported. */ |
| 1455 | int get_acpi_table_revision(enum acpi_tables table); |
Elyes Haouas | 8b950f4 | 2022-02-16 12:08:16 +0100 | [diff] [blame] | 1456 | u8 get_acpi_fadt_minor_version(void); |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 1457 | |
Kyösti Mälkki | 94e0465 | 2020-06-01 13:26:22 +0300 | [diff] [blame] | 1458 | #endif // !defined(__ASSEMBLER__) && !defined(__ACPI__) |
Furquan Shaikh | e084463 | 2020-05-02 10:23:37 -0700 | [diff] [blame] | 1459 | |
Furquan Shaikh | 56eafbb | 2020-04-30 18:38:55 -0700 | [diff] [blame] | 1460 | #endif /* __ACPI_ACPI_H__ */ |