blob: f5e2e81c81c00c3c778e8b041c4226f1c59d1050 [file] [log] [blame]
Stefan Reinauer688b3852004-01-28 16:56:14 +00001/*
Uwe Hermannc70e9fc2010-02-15 23:10:19 +00002 * This file is part of the coreboot project.
Stefan Reinauerc0ac7e92009-11-10 22:17:15 +00003 *
Stefan Reinauerb657a3c2009-07-21 21:38:33 +00004 * Copyright (C) 2004 SUSE LINUX AG
Stefan Reinauerc0ac7e92009-11-10 22:17:15 +00005 * Copyright (C) 2004 Nick Barker
Stefan Reinauerb657a3c2009-07-21 21:38:33 +00006 * Copyright (C) 2008-2009 coresystems GmbH
Lee Leahy6f80ccc2017-03-16 15:18:22 -07007 * Copyright (C) 2015 Timothy Pearson <tpearson@raptorengineeringinc.com>,
8 * Raptor Engineering
Werner Zehd4d76952016-07-27 06:56:36 +02009 * Copyright (C) 2016 Siemens AG
Uwe Hermannc70e9fc2010-02-15 23:10:19 +000010 * (Written by Stefan Reinauer <stepan@coresystems.de>)
Stefan Reinauer688b3852004-01-28 16:56:14 +000011 *
Uwe Hermannc70e9fc2010-02-15 23:10:19 +000012 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; version 2 of the License.
Stefan Reinauerc0ac7e92009-11-10 22:17:15 +000015 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
Uwe Hermannc70e9fc2010-02-15 23:10:19 +000020 */
21
22/*
Uwe Hermanne9c44732010-11-22 00:42:42 +000023 * coreboot ACPI support - headers and defines.
Ronald G. Minnich02fa3b22004-10-06 17:33:54 +000024 */
Stefan Reinauer688b3852004-01-28 16:56:14 +000025
Stefan Reinauer688b3852004-01-28 16:56:14 +000026#ifndef __ASM_ACPI_H
27#define __ASM_ACPI_H
28
Kyösti Mälkkia969ed32016-06-15 06:08:15 +030029#define HIGH_MEMORY_SAVE (CONFIG_RAMTOP - CONFIG_RAMBASE)
Kyösti Mälkkia969ed32016-06-15 06:08:15 +030030
Aaron Durbin20a588b2016-07-13 23:13:25 -050031/*
32 * The type and enable fields are common in ACPI, but the
Marshall Dawson6139a5c62017-10-04 15:10:00 -060033 * values themselves are hardware implementation defined.
Aaron Durbin20a588b2016-07-13 23:13:25 -050034 */
Marshall Dawson6139a5c62017-10-04 15:10:00 -060035#if IS_ENABLED(CONFIG_ACPI_INTEL_HARDWARE_SLEEP_VALUES)
36 #define SLP_EN (1 << 13)
37 #define SLP_TYP_SHIFT 10
38 #define SLP_TYP (7 << SLP_TYP_SHIFT)
39 #define SLP_TYP_S0 0
40 #define SLP_TYP_S1 1
41 #define SLP_TYP_S3 5
42 #define SLP_TYP_S4 6
43 #define SLP_TYP_S5 7
44#elif IS_ENABLED(CONFIG_ACPI_AMD_HARDWARE_SLEEP_VALUES)
45 #define SLP_EN (1 << 13)
46 #define SLP_TYP_SHIFT 10
47 #define SLP_TYP (7 << SLP_TYP_SHIFT)
48 #define SLP_TYP_S0 0
49 #define SLP_TYP_S1 1
50 #define SLP_TYP_S3 3
51 #define SLP_TYP_S4 4
52 #define SLP_TYP_S5 5
Aaron Durbin20a588b2016-07-13 23:13:25 -050053#endif
54
55#if !defined(__ASSEMBLER__) && !defined(__ACPI__) && !defined(__ROMCC__)
Peter Stuge0888c362007-04-07 09:17:00 +000056#include <stdint.h>
Stefan Reinauer6a001132017-07-13 02:20:27 +020057#include <compiler.h>
Alexander Couzense19c8b02015-04-02 23:20:45 +020058#include <rules.h>
Aaron Durbin07a1b282015-12-10 17:07:38 -060059#include <commonlib/helpers.h>
Alexander Couzens5eea4582015-04-12 22:18:55 +020060#include <device/device.h>
Stefan Reinauer14e22772010-04-27 06:56:47 +000061
Uwe Hermanne9c44732010-11-22 00:42:42 +000062#define RSDP_SIG "RSD PTR " /* RSDT pointer signature */
63#define ACPI_TABLE_CREATOR "COREBOOT" /* Must be exactly 8 bytes long! */
64#define OEM_ID "CORE " /* Must be exactly 6 bytes long! */
65#define ASLC "CORE" /* Must be exactly 4 bytes long! */
Duncan Laurie02fdb3e2016-09-22 14:08:33 -070066
Duncan Laurie59eddac2017-02-28 16:58:06 -080067/*
68 * The assigned ACPI ID for the coreboot project is 'BOOT'
69 * http://www.uefi.org/acpi_id_list
70 */
71#define COREBOOT_ACPI_ID "BOOT" /* ACPI ID for coreboot HIDs */
Duncan Laurie37319032016-05-26 12:47:05 -070072
73/* List of ACPI HID that use the coreboot ACPI ID */
74enum coreboot_acpi_ids {
Duncan Laurie59eddac2017-02-28 16:58:06 -080075 COREBOOT_ACPI_ID_CBTABLE = 0x0000, /* BOOT0000 */
76 COREBOOT_ACPI_ID_MAX = 0xFFFF, /* BOOTFFFF */
Duncan Laurie37319032016-05-26 12:47:05 -070077};
Stefan Reinauer777224c2005-01-19 14:06:41 +000078
Uwe Hermanne9c44732010-11-22 00:42:42 +000079/* RSDP (Root System Description Pointer) */
Stefan Reinauer688b3852004-01-28 16:56:14 +000080typedef struct acpi_rsdp {
Uwe Hermanne9c44732010-11-22 00:42:42 +000081 char signature[8]; /* RSDP signature */
82 u8 checksum; /* Checksum of the first 20 bytes */
83 char oem_id[6]; /* OEM ID */
84 u8 revision; /* 0 for ACPI 1.0, 2 for ACPI 2.0/3.0/4.0 */
85 u32 rsdt_address; /* Physical address of RSDT (32 bits) */
86 u32 length; /* Total RSDP length (incl. extended part) */
87 u64 xsdt_address; /* Physical address of XSDT (64 bits) */
88 u8 ext_checksum; /* Checksum of the whole table */
Stefan Reinauer688b3852004-01-28 16:56:14 +000089 u8 reserved[3];
Stefan Reinauer6a001132017-07-13 02:20:27 +020090} __packed acpi_rsdp_t;
Uwe Hermanne9c44732010-11-22 00:42:42 +000091/* Note: ACPI 1.0 didn't have length, xsdt_address, and ext_checksum. */
Stefan Reinauer688b3852004-01-28 16:56:14 +000092
Uwe Hermanne9c44732010-11-22 00:42:42 +000093/* GAS (Generic Address Structure) */
Stefan Reinauer688b3852004-01-28 16:56:14 +000094typedef struct acpi_gen_regaddr {
Uwe Hermanne9c44732010-11-22 00:42:42 +000095 u8 space_id; /* Address space ID */
96 u8 bit_width; /* Register size in bits */
97 u8 bit_offset; /* Register bit offset */
Martin Rothaee18692012-04-26 15:54:15 -060098 union {
Lee Leahy6f80ccc2017-03-16 15:18:22 -070099 u8 resv; /* Reserved in ACPI 2.0 - 2.0b */
100 u8 access_size; /* Access size in ACPI 2.0c/3.0/4.0/5.0
101 */
Martin Rothaee18692012-04-26 15:54:15 -0600102 };
Uwe Hermanne9c44732010-11-22 00:42:42 +0000103 u32 addrl; /* Register address, low 32 bits */
104 u32 addrh; /* Register address, high 32 bits */
Stefan Reinauer6a001132017-07-13 02:20:27 +0200105} __packed acpi_addr_t;
Stefan Reinauer688b3852004-01-28 16:56:14 +0000106
Uwe Hermanne9c44732010-11-22 00:42:42 +0000107#define ACPI_ADDRESS_SPACE_MEMORY 0 /* System memory */
108#define ACPI_ADDRESS_SPACE_IO 1 /* System I/O */
109#define ACPI_ADDRESS_SPACE_PCI 2 /* PCI config space */
110#define ACPI_ADDRESS_SPACE_EC 3 /* Embedded controller */
111#define ACPI_ADDRESS_SPACE_SMBUS 4 /* SMBus */
Martin Rothaee18692012-04-26 15:54:15 -0600112#define ACPI_ADDRESS_SPACE_PCC 0x0A /* Platform Comm. Channel */
Uwe Hermanne9c44732010-11-22 00:42:42 +0000113#define ACPI_ADDRESS_SPACE_FIXED 0x7f /* Functional fixed hardware */
Stefan Reinauer355551672012-04-27 21:51:49 +0200114#define ACPI_FFIXEDHW_VENDOR_INTEL 1 /* Intel */
115#define ACPI_FFIXEDHW_CLASS_HLT 0 /* C1 Halt */
116#define ACPI_FFIXEDHW_CLASS_IO_HLT 1 /* C1 I/O then Halt */
117#define ACPI_FFIXEDHW_CLASS_MWAIT 2 /* MWAIT Native C-state */
118#define ACPI_FFIXEDHW_FLAG_HW_COORD 1 /* Hardware Coordination bit */
119#define ACPI_FFIXEDHW_FLAG_BM_STS 2 /* BM_STS avoidance bit */
Uwe Hermanne9c44732010-11-22 00:42:42 +0000120/* 0x80-0xbf: Reserved */
121/* 0xc0-0xff: OEM defined */
Stefan Reinauerc0ac7e92009-11-10 22:17:15 +0000122
Martin Rothaee18692012-04-26 15:54:15 -0600123/* Access size definitions for Generic address structure */
Lee Leahy6f80ccc2017-03-16 15:18:22 -0700124#define ACPI_ACCESS_SIZE_UNDEFINED 0 /* Undefined (legacy reasons) */
Martin Rothaee18692012-04-26 15:54:15 -0600125#define ACPI_ACCESS_SIZE_BYTE_ACCESS 1
126#define ACPI_ACCESS_SIZE_WORD_ACCESS 2
127#define ACPI_ACCESS_SIZE_DWORD_ACCESS 3
128#define ACPI_ACCESS_SIZE_QWORD_ACCESS 4
129
Uwe Hermanne9c44732010-11-22 00:42:42 +0000130/* Generic ACPI header, provided by (almost) all tables */
131typedef struct acpi_table_header {
132 char signature[4]; /* ACPI signature (4 ASCII characters) */
133 u32 length; /* Table length in bytes (incl. header) */
134 u8 revision; /* Table version (not ACPI version!) */
135 u8 checksum; /* To make sum of entire table == 0 */
136 char oem_id[6]; /* OEM identification */
137 char oem_table_id[8]; /* OEM table identification */
138 u32 oem_revision; /* OEM revision number */
139 char asl_compiler_id[4]; /* ASL compiler vendor ID */
Stefan Reinauer688b3852004-01-28 16:56:14 +0000140 u32 asl_compiler_revision; /* ASL compiler revision number */
Stefan Reinauer6a001132017-07-13 02:20:27 +0200141} __packed acpi_header_t;
Stefan Reinauer688b3852004-01-28 16:56:14 +0000142
Uwe Hermanne9c44732010-11-22 00:42:42 +0000143/* A maximum number of 32 ACPI tables ought to be enough for now. */
Stefan Reinauerc0ac7e92009-11-10 22:17:15 +0000144#define MAX_ACPI_TABLES 32
Stefan Reinauerb657a3c2009-07-21 21:38:33 +0000145
Uwe Hermanne9c44732010-11-22 00:42:42 +0000146/* RSDT (Root System Description Table) */
Stefan Reinauer688b3852004-01-28 16:56:14 +0000147typedef struct acpi_rsdt {
148 struct acpi_table_header header;
Stefan Reinauerb657a3c2009-07-21 21:38:33 +0000149 u32 entry[MAX_ACPI_TABLES];
Stefan Reinauer6a001132017-07-13 02:20:27 +0200150} __packed acpi_rsdt_t;
Stefan Reinauer688b3852004-01-28 16:56:14 +0000151
Uwe Hermanne9c44732010-11-22 00:42:42 +0000152/* XSDT (Extended System Description Table) */
Li-Ta Lobe977a12005-03-04 22:03:07 +0000153typedef struct acpi_xsdt {
154 struct acpi_table_header header;
Stefan Reinauerb657a3c2009-07-21 21:38:33 +0000155 u64 entry[MAX_ACPI_TABLES];
Stefan Reinauer6a001132017-07-13 02:20:27 +0200156} __packed acpi_xsdt_t;
Stefan Reinauer688b3852004-01-28 16:56:14 +0000157
Uwe Hermanne9c44732010-11-22 00:42:42 +0000158/* HPET timers */
Stefan Reinauer688b3852004-01-28 16:56:14 +0000159typedef struct acpi_hpet {
160 struct acpi_table_header header;
161 u32 id;
162 struct acpi_gen_regaddr addr;
163 u8 number;
164 u16 min_tick;
165 u8 attributes;
Stefan Reinauer6a001132017-07-13 02:20:27 +0200166} __packed acpi_hpet_t;
Stefan Reinauer688b3852004-01-28 16:56:14 +0000167
Uwe Hermanne9c44732010-11-22 00:42:42 +0000168/* MCFG (PCI Express MMIO config space BAR description table) */
Rudolf Mareke6409f22007-11-03 12:50:26 +0000169typedef struct acpi_mcfg {
170 struct acpi_table_header header;
171 u8 reserved[8];
Stefan Reinauer6a001132017-07-13 02:20:27 +0200172} __packed acpi_mcfg_t;
Rudolf Mareke6409f22007-11-03 12:50:26 +0000173
Vladimir Serbinenkof44ac132015-05-20 19:52:01 +0200174typedef struct acpi_tcpa {
175 struct acpi_table_header header;
176 u16 platform_class;
177 u32 laml;
178 u64 lasa;
Stefan Reinauer6a001132017-07-13 02:20:27 +0200179} __packed acpi_tcpa_t;
Vladimir Serbinenkof44ac132015-05-20 19:52:01 +0200180
Rudolf Mareke6409f22007-11-03 12:50:26 +0000181typedef struct acpi_mcfg_mmconfig {
182 u32 base_address;
183 u32 base_reserved;
184 u16 pci_segment_group_number;
185 u8 start_bus_number;
186 u8 end_bus_number;
187 u8 reserved[4];
Stefan Reinauer6a001132017-07-13 02:20:27 +0200188} __packed acpi_mcfg_mmconfig_t;
Rudolf Mareke6409f22007-11-03 12:50:26 +0000189
Uwe Hermanne9c44732010-11-22 00:42:42 +0000190/* SRAT (System Resource Affinity Table) */
Stefan Reinauerf622d592005-11-26 16:56:05 +0000191typedef struct acpi_srat {
Uwe Hermanne9c44732010-11-22 00:42:42 +0000192 struct acpi_table_header header;
193 u32 resv;
Stefan Reinauerf622d592005-11-26 16:56:05 +0000194 u64 resv1;
Uwe Hermanne9c44732010-11-22 00:42:42 +0000195 /* Followed by static resource allocation structure[n] */
Stefan Reinauer6a001132017-07-13 02:20:27 +0200196} __packed acpi_srat_t;
Stefan Reinauerf622d592005-11-26 16:56:05 +0000197
Uwe Hermanne9c44732010-11-22 00:42:42 +0000198/* SRAT: Processor Local APIC/SAPIC Affinity Structure */
Stefan Reinauerf622d592005-11-26 16:56:05 +0000199typedef struct acpi_srat_lapic {
Uwe Hermanne9c44732010-11-22 00:42:42 +0000200 u8 type; /* Type (0) */
201 u8 length; /* Length in bytes (16) */
202 u8 proximity_domain_7_0; /* Proximity domain bits[7:0] */
203 u8 apic_id; /* Local APIC ID */
204 u32 flags; /* Enable bit 0 = 1, other bits reserved to 0 */
205 u8 local_sapic_eid; /* Local SAPIC EID */
206 u8 proximity_domain_31_8[3]; /* Proximity domain bits[31:8] */
207 u32 resv; /* TODO: Clock domain in ACPI 4.0. */
Stefan Reinauer6a001132017-07-13 02:20:27 +0200208} __packed acpi_srat_lapic_t;
Stefan Reinauerf622d592005-11-26 16:56:05 +0000209
Uwe Hermanne9c44732010-11-22 00:42:42 +0000210/* SRAT: Memory Affinity Structure */
Stefan Reinauerf622d592005-11-26 16:56:05 +0000211typedef struct acpi_srat_mem {
Uwe Hermanne9c44732010-11-22 00:42:42 +0000212 u8 type; /* Type (1) */
213 u8 length; /* Length in bytes (40) */
214 u32 proximity_domain; /* Proximity domain */
215 u16 resv;
216 u32 base_address_low; /* Mem range base address, low */
217 u32 base_address_high; /* Mem range base address, high */
218 u32 length_low; /* Mem range length, low */
219 u32 length_high; /* Mem range length, high */
Stefan Reinauerf622d592005-11-26 16:56:05 +0000220 u32 resv1;
Lee Leahy6f80ccc2017-03-16 15:18:22 -0700221 u32 flags; /* Enable bit 0, hot pluggable bit 1; Non Volatile bit 2,
222 * other bits reserved to 0
223 */
Uwe Hermanne9c44732010-11-22 00:42:42 +0000224 u32 resv2[2];
Stefan Reinauer6a001132017-07-13 02:20:27 +0200225} __packed acpi_srat_mem_t;
Stefan Reinauerf622d592005-11-26 16:56:05 +0000226
Uwe Hermanne9c44732010-11-22 00:42:42 +0000227/* SLIT (System Locality Distance Information Table) */
Yinghai Lud4b278c2006-10-04 20:46:15 +0000228typedef struct acpi_slit {
Uwe Hermanne9c44732010-11-22 00:42:42 +0000229 struct acpi_table_header header;
230 /* Followed by static resource allocation 8+byte[num*num] */
Stefan Reinauer6a001132017-07-13 02:20:27 +0200231} __packed acpi_slit_t;
Stefan Reinauerf622d592005-11-26 16:56:05 +0000232
Uwe Hermanne9c44732010-11-22 00:42:42 +0000233/* MADT (Multiple APIC Description Table) */
Stefan Reinauer06feb882004-02-03 16:11:35 +0000234typedef struct acpi_madt {
235 struct acpi_table_header header;
Uwe Hermanne9c44732010-11-22 00:42:42 +0000236 u32 lapic_addr; /* Local APIC address */
237 u32 flags; /* Multiple APIC flags */
Stefan Reinauer6a001132017-07-13 02:20:27 +0200238} __packed acpi_madt_t;
Stefan Reinauer06feb882004-02-03 16:11:35 +0000239
Patrick Rudolpha5c2ac62016-03-31 20:04:23 +0200240/* VFCT image header */
241struct acpi_vfct_image_hdr {
242 u32 PCIBus;
243 u32 PCIDevice;
244 u32 PCIFunction;
245 u16 VendorID;
246 u16 DeviceID;
247 u16 SSVID;
248 u16 SSID;
249 u32 Revision;
250 u32 ImageLength;
251 u8 VbiosContent; // dummy - copy VBIOS here
Stefan Reinauer6a001132017-07-13 02:20:27 +0200252} __packed;
Patrick Rudolpha5c2ac62016-03-31 20:04:23 +0200253
254/* VFCT (VBIOS Fetch Table) */
255struct acpi_vfct {
256 struct acpi_table_header header;
257 u8 TableUUID[16];
258 u32 VBIOSImageOffset;
259 u32 Lib1ImageOffset;
260 u32 Reserved[4];
261 struct acpi_vfct_image_hdr image_hdr;
Stefan Reinauer6a001132017-07-13 02:20:27 +0200262} __packed;
Patrick Rudolpha5c2ac62016-03-31 20:04:23 +0200263
Timothy Pearsonff8ccf02015-08-11 17:48:32 -0500264typedef struct acpi_ivrs_info {
Stefan Reinauer6a001132017-07-13 02:20:27 +0200265} __packed acpi_ivrs_info_t;
Timothy Pearsonff8ccf02015-08-11 17:48:32 -0500266
Martin Rothd4aa2c42016-09-06 10:28:22 -0600267/* IVRS IVHD (I/O Virtualization Hardware Definition Block) Type 10h */
Timothy Pearsonff8ccf02015-08-11 17:48:32 -0500268typedef struct acpi_ivrs_ivhd {
269 uint8_t type;
270 uint8_t flags;
271 uint16_t length;
272 uint16_t device_id;
273 uint16_t capability_offset;
274 uint32_t iommu_base_low;
275 uint32_t iommu_base_high;
276 uint16_t pci_segment_group;
277 uint16_t iommu_info;
Martin Rothd4aa2c42016-09-06 10:28:22 -0600278 uint32_t iommu_feature_info;
Timothy Pearsonff8ccf02015-08-11 17:48:32 -0500279 uint8_t entry[0];
Stefan Reinauer6a001132017-07-13 02:20:27 +0200280} __packed acpi_ivrs_ivhd_t;
Timothy Pearsonff8ccf02015-08-11 17:48:32 -0500281
Martin Rothd4aa2c42016-09-06 10:28:22 -0600282/* IVRS (I/O Virtualization Reporting Structure) Type 10h */
Timothy Pearsonff8ccf02015-08-11 17:48:32 -0500283typedef struct acpi_ivrs {
284 struct acpi_table_header header;
285 uint32_t iv_info;
286 uint32_t reserved[2];
287 struct acpi_ivrs_ivhd ivhd;
Stefan Reinauer6a001132017-07-13 02:20:27 +0200288} __packed acpi_ivrs_t;
Timothy Pearsonff8ccf02015-08-11 17:48:32 -0500289
Patrick Georgi3b590ff2012-09-11 15:21:01 +0200290enum dev_scope_type {
291 SCOPE_PCI_ENDPOINT = 1,
292 SCOPE_PCI_SUB = 2,
293 SCOPE_IOAPIC = 3,
294 SCOPE_MSI_HPET = 4
295};
296
297typedef struct dev_scope {
298 u8 type;
299 u8 length;
300 u8 reserved[2];
301 u8 enumeration;
302 u8 start_bus;
303 struct {
304 u8 dev;
305 u8 fn;
Stefan Reinauer6a001132017-07-13 02:20:27 +0200306 } __packed path[0];
307} __packed dev_scope_t;
Patrick Georgi3b590ff2012-09-11 15:21:01 +0200308
309enum dmar_type {
310 DMAR_DRHD = 0,
311 DMAR_RMRR = 1,
312 DMAR_ATSR = 2,
313 DMAR_RHSA = 3
314};
315
316enum {
317 DRHD_INCLUDE_PCI_ALL = 1
318};
319
Nico Hubere561f352015-10-26 11:51:25 +0100320enum dmar_flags {
321 DMAR_INTR_REMAP = 1,
322 DMAR_X2APIC_OPT_OUT = 2,
323};
324
Patrick Georgi3b590ff2012-09-11 15:21:01 +0200325typedef struct dmar_entry {
326 u16 type;
327 u16 length;
328 u8 flags;
329 u8 reserved;
330 u16 segment;
331 u64 bar;
Stefan Reinauer6a001132017-07-13 02:20:27 +0200332} __packed dmar_entry_t;
Patrick Georgi3b590ff2012-09-11 15:21:01 +0200333
Werner Zehd4d76952016-07-27 06:56:36 +0200334typedef struct dmar_atsr_entry {
335 u16 type;
336 u16 length;
337 u8 flags;
338 u8 reserved;
339 u16 segment;
Stefan Reinauer6a001132017-07-13 02:20:27 +0200340} __packed dmar_atsr_entry_t;
Werner Zehd4d76952016-07-27 06:56:36 +0200341
Patrick Georgi3b590ff2012-09-11 15:21:01 +0200342/* DMAR (DMA Remapping Reporting Structure) */
343typedef struct acpi_dmar {
344 struct acpi_table_header header;
345 u8 host_address_width;
346 u8 flags;
347 u8 reserved[10];
348 dmar_entry_t structure[0];
Stefan Reinauer6a001132017-07-13 02:20:27 +0200349} __packed acpi_dmar_t;
Patrick Georgi3b590ff2012-09-11 15:21:01 +0200350
Uwe Hermanne9c44732010-11-22 00:42:42 +0000351/* MADT: APIC Structure Types */
352/* TODO: Convert to ALLCAPS. */
Stefan Reinauer06feb882004-02-03 16:11:35 +0000353enum acpi_apic_types {
Uwe Hermanne9c44732010-11-22 00:42:42 +0000354 LocalApic = 0, /* Processor local APIC */
355 IOApic = 1, /* I/O APIC */
356 IRQSourceOverride = 2, /* Interrupt source override */
357 NMIType = 3, /* NMI source */
358 LocalApicNMI = 4, /* Local APIC NMI */
359 LApicAddressOverride = 5, /* Local APIC address override */
360 IOSApic = 6, /* I/O SAPIC */
361 LocalSApic = 7, /* Local SAPIC */
362 PlatformIRQSources = 8, /* Platform interrupt sources */
363 Localx2Apic = 9, /* Processor local x2APIC */
364 Localx2ApicNMI = 10, /* Local x2APIC NMI */
365 /* 0x0b-0x7f: Reserved */
366 /* 0x80-0xff: Reserved for OEM use */
Stefan Reinauer06feb882004-02-03 16:11:35 +0000367};
368
Uwe Hermanne9c44732010-11-22 00:42:42 +0000369/* MADT: Processor Local APIC Structure */
Stefan Reinauer06feb882004-02-03 16:11:35 +0000370typedef struct acpi_madt_lapic {
Uwe Hermanne9c44732010-11-22 00:42:42 +0000371 u8 type; /* Type (0) */
372 u8 length; /* Length in bytes (8) */
373 u8 processor_id; /* ACPI processor ID */
374 u8 apic_id; /* Local APIC ID */
375 u32 flags; /* Local APIC flags */
Stefan Reinauer6a001132017-07-13 02:20:27 +0200376} __packed acpi_madt_lapic_t;
Stefan Reinauer06feb882004-02-03 16:11:35 +0000377
Uwe Hermanne9c44732010-11-22 00:42:42 +0000378/* MADT: Local APIC NMI Structure */
Stefan Reinauer06feb882004-02-03 16:11:35 +0000379typedef struct acpi_madt_lapic_nmi {
Uwe Hermanne9c44732010-11-22 00:42:42 +0000380 u8 type; /* Type (4) */
381 u8 length; /* Length in bytes (6) */
382 u8 processor_id; /* ACPI processor ID */
383 u16 flags; /* MPS INTI flags */
384 u8 lint; /* Local APIC LINT# */
Stefan Reinauer6a001132017-07-13 02:20:27 +0200385} __packed acpi_madt_lapic_nmi_t;
Stefan Reinauer06feb882004-02-03 16:11:35 +0000386
Uwe Hermanne9c44732010-11-22 00:42:42 +0000387/* MADT: I/O APIC Structure */
Stefan Reinauer06feb882004-02-03 16:11:35 +0000388typedef struct acpi_madt_ioapic {
Uwe Hermanne9c44732010-11-22 00:42:42 +0000389 u8 type; /* Type (1) */
390 u8 length; /* Length in bytes (12) */
391 u8 ioapic_id; /* I/O APIC ID */
Stefan Reinauer06feb882004-02-03 16:11:35 +0000392 u8 reserved;
Uwe Hermanne9c44732010-11-22 00:42:42 +0000393 u32 ioapic_addr; /* I/O APIC address */
394 u32 gsi_base; /* Global system interrupt base */
Stefan Reinauer6a001132017-07-13 02:20:27 +0200395} __packed acpi_madt_ioapic_t;
Stefan Reinauer06feb882004-02-03 16:11:35 +0000396
Uwe Hermanne9c44732010-11-22 00:42:42 +0000397/* MADT: Interrupt Source Override Structure */
Stefan Reinauer06feb882004-02-03 16:11:35 +0000398typedef struct acpi_madt_irqoverride {
Uwe Hermanne9c44732010-11-22 00:42:42 +0000399 u8 type; /* Type (2) */
400 u8 length; /* Length in bytes (10) */
401 u8 bus; /* ISA (0) */
402 u8 source; /* Bus-relative int. source (IRQ) */
403 u32 gsirq; /* Global system interrupt */
404 u16 flags; /* MPS INTI flags */
Stefan Reinauer6a001132017-07-13 02:20:27 +0200405} __packed acpi_madt_irqoverride_t;
Stefan Reinauer06feb882004-02-03 16:11:35 +0000406
Duncan Lauriee4a36c72017-11-11 19:33:25 -0800407#define ACPI_DBG2_PORT_SERIAL 0x8000
408#define ACPI_DBG2_PORT_SERIAL_16550 0x0000
409#define ACPI_DBG2_PORT_SERIAL_16550_DBGP 0x0001
410#define ACPI_DBG2_PORT_SERIAL_ARM_PL011 0x0003
411#define ACPI_DBG2_PORT_SERIAL_ARM_SBSA 0x000e
412#define ACPI_DBG2_PORT_SERIAL_ARM_DDC 0x000f
413#define ACPI_DBG2_PORT_SERIAL_BCM2835 0x0010
414#define ACPI_DBG2_PORT_IEEE1394 0x8001
415#define ACPI_DBG2_PORT_IEEE1394_STANDARD 0x0000
416#define ACPI_DBG2_PORT_USB 0x8002
417#define ACPI_DBG2_PORT_USB_XHCI 0x0000
418#define ACPI_DBG2_PORT_USB_EHCI 0x0001
419#define ACPI_DBG2_PORT_NET 0x8003
420
421/* DBG2: Microsoft Debug Port Table 2 header */
422typedef struct acpi_dbg2_header {
423 struct acpi_table_header header;
424 uint32_t devices_offset;
425 uint32_t devices_count;
Elyes HAOUASa89b9cd2018-05-16 12:28:52 +0200426} __attribute__((packed)) acpi_dbg2_header_t;
Duncan Lauriee4a36c72017-11-11 19:33:25 -0800427
428/* DBG2: Microsoft Debug Port Table 2 device entry */
429typedef struct acpi_dbg2_device {
430 uint8_t revision;
431 uint16_t length;
432 uint8_t address_count;
433 uint16_t namespace_string_length;
434 uint16_t namespace_string_offset;
435 uint16_t oem_data_length;
436 uint16_t oem_data_offset;
437 uint16_t port_type;
438 uint16_t port_subtype;
439 uint8_t reserved[2];
440 uint16_t base_address_offset;
441 uint16_t address_size_offset;
Elyes HAOUASa89b9cd2018-05-16 12:28:52 +0200442} __attribute__((packed)) acpi_dbg2_device_t;
Duncan Lauriee4a36c72017-11-11 19:33:25 -0800443
Uwe Hermanne9c44732010-11-22 00:42:42 +0000444/* FADT (Fixed ACPI Description Table) */
Ronald G. Minnich02fa3b22004-10-06 17:33:54 +0000445typedef struct acpi_fadt {
446 struct acpi_table_header header;
447 u32 firmware_ctrl;
448 u32 dsdt;
Stefan Reinauer7a4f6882008-08-01 11:31:08 +0000449 u8 model;
Ronald G. Minnich02fa3b22004-10-06 17:33:54 +0000450 u8 preferred_pm_profile;
451 u16 sci_int;
452 u32 smi_cmd;
453 u8 acpi_enable;
454 u8 acpi_disable;
455 u8 s4bios_req;
456 u8 pstate_cnt;
457 u32 pm1a_evt_blk;
458 u32 pm1b_evt_blk;
459 u32 pm1a_cnt_blk;
460 u32 pm1b_cnt_blk;
461 u32 pm2_cnt_blk;
462 u32 pm_tmr_blk;
463 u32 gpe0_blk;
464 u32 gpe1_blk;
465 u8 pm1_evt_len;
466 u8 pm1_cnt_len;
467 u8 pm2_cnt_len;
468 u8 pm_tmr_len;
469 u8 gpe0_blk_len;
470 u8 gpe1_blk_len;
471 u8 gpe1_base;
472 u8 cst_cnt;
473 u16 p_lvl2_lat;
474 u16 p_lvl3_lat;
475 u16 flush_size;
476 u16 flush_stride;
477 u8 duty_offset;
478 u8 duty_width;
479 u8 day_alrm;
480 u8 mon_alrm;
481 u8 century;
482 u16 iapc_boot_arch;
483 u8 res2;
484 u32 flags;
485 struct acpi_gen_regaddr reset_reg;
486 u8 reset_value;
487 u8 res3;
488 u8 res4;
489 u8 res5;
490 u32 x_firmware_ctl_l;
491 u32 x_firmware_ctl_h;
492 u32 x_dsdt_l;
493 u32 x_dsdt_h;
494 struct acpi_gen_regaddr x_pm1a_evt_blk;
495 struct acpi_gen_regaddr x_pm1b_evt_blk;
496 struct acpi_gen_regaddr x_pm1a_cnt_blk;
Uwe Hermanne9c44732010-11-22 00:42:42 +0000497 struct acpi_gen_regaddr x_pm1b_cnt_blk;
Ronald G. Minnich02fa3b22004-10-06 17:33:54 +0000498 struct acpi_gen_regaddr x_pm2_cnt_blk;
499 struct acpi_gen_regaddr x_pm_tmr_blk;
500 struct acpi_gen_regaddr x_gpe0_blk;
501 struct acpi_gen_regaddr x_gpe1_blk;
Stefan Reinauer6a001132017-07-13 02:20:27 +0200502} __packed acpi_fadt_t;
Stefan Reinauer06feb882004-02-03 16:11:35 +0000503
Martin Rothaee18692012-04-26 15:54:15 -0600504/* FADT TABLE Revision values */
505#define ACPI_FADT_REV_ACPI_1_0 1
506#define ACPI_FADT_REV_ACPI_2_0 3
507#define ACPI_FADT_REV_ACPI_3_0 4
508#define ACPI_FADT_REV_ACPI_4_0 4
509#define ACPI_FADT_REV_ACPI_5_0 5
510
Martin Roth9aa43892012-05-25 12:23:32 -0600511/* Flags for p_lvl2_lat and p_lvl3_lat */
512#define ACPI_FADT_C2_NOT_SUPPORTED 101
513#define ACPI_FADT_C3_NOT_SUPPORTED 1001
514
Uwe Hermanne9c44732010-11-22 00:42:42 +0000515/* FADT Feature Flags */
Stefan Reinauer7e9771c2009-04-22 08:17:38 +0000516#define ACPI_FADT_WBINVD (1 << 0)
517#define ACPI_FADT_WBINVD_FLUSH (1 << 1)
518#define ACPI_FADT_C1_SUPPORTED (1 << 2)
519#define ACPI_FADT_C2_MP_SUPPORTED (1 << 3)
520#define ACPI_FADT_POWER_BUTTON (1 << 4)
521#define ACPI_FADT_SLEEP_BUTTON (1 << 5)
522#define ACPI_FADT_FIXED_RTC (1 << 6)
523#define ACPI_FADT_S4_RTC_WAKE (1 << 7)
524#define ACPI_FADT_32BIT_TIMER (1 << 8)
525#define ACPI_FADT_DOCKING_SUPPORTED (1 << 9)
526#define ACPI_FADT_RESET_REGISTER (1 << 10)
527#define ACPI_FADT_SEALED_CASE (1 << 11)
528#define ACPI_FADT_HEADLESS (1 << 12)
529#define ACPI_FADT_SLEEP_TYPE (1 << 13)
530#define ACPI_FADT_PCI_EXPRESS_WAKE (1 << 14)
531#define ACPI_FADT_PLATFORM_CLOCK (1 << 15)
532#define ACPI_FADT_S4_RTC_VALID (1 << 16)
533#define ACPI_FADT_REMOTE_POWER_ON (1 << 17)
534#define ACPI_FADT_APIC_CLUSTER (1 << 18)
535#define ACPI_FADT_APIC_PHYSICAL (1 << 19)
Martin Rothaee18692012-04-26 15:54:15 -0600536/* Bits 20-31: reserved ACPI 3.0 & 4.0 */
537#define ACPI_FADT_HW_REDUCED_ACPI (1 << 20)
538#define ACPI_FADT_LOW_PWR_IDLE_S0 (1 << 21)
539/* bits 22-31: reserved ACPI 5.0 */
Stefan Reinauer7e9771c2009-04-22 08:17:38 +0000540
Uwe Hermanne9c44732010-11-22 00:42:42 +0000541/* FADT Boot Architecture Flags */
Stefan Reinauerb657a3c2009-07-21 21:38:33 +0000542#define ACPI_FADT_LEGACY_DEVICES (1 << 0)
543#define ACPI_FADT_8042 (1 << 1)
544#define ACPI_FADT_VGA_NOT_PRESENT (1 << 2)
545#define ACPI_FADT_MSI_NOT_SUPPORTED (1 << 3)
546#define ACPI_FADT_NO_PCIE_ASPM_CONTROL (1 << 4)
Martin Rothefac7172014-05-21 14:49:13 -0600547#define ACPI_FADT_LEGACY_FREE 0x00 /* No legacy devices (including 8042) */
Stefan Reinauerb657a3c2009-07-21 21:38:33 +0000548
Uwe Hermanne9c44732010-11-22 00:42:42 +0000549/* FADT Preferred Power Management Profile */
Stefan Reinauer7e9771c2009-04-22 08:17:38 +0000550enum acpi_preferred_pm_profiles {
Stefan Reinauerb657a3c2009-07-21 21:38:33 +0000551 PM_UNSPECIFIED = 0,
552 PM_DESKTOP = 1,
553 PM_MOBILE = 2,
554 PM_WORKSTATION = 3,
555 PM_ENTERPRISE_SERVER = 4,
Lee Leahy024b13d2017-03-16 13:41:11 -0700556 PM_SOHO_SERVER = 5,
Stefan Reinauerb657a3c2009-07-21 21:38:33 +0000557 PM_APPLIANCE_PC = 6,
Uwe Hermanne9c44732010-11-22 00:42:42 +0000558 PM_PERFORMANCE_SERVER = 7,
Martin Rothaee18692012-04-26 15:54:15 -0600559 PM_TABLET = 8, /* ACPI 5.0 */
Stefan Reinauer7e9771c2009-04-22 08:17:38 +0000560};
561
Uwe Hermanne9c44732010-11-22 00:42:42 +0000562/* FACS (Firmware ACPI Control Structure) */
Ronald G. Minnich02fa3b22004-10-06 17:33:54 +0000563typedef struct acpi_facs {
Uwe Hermanne9c44732010-11-22 00:42:42 +0000564 char signature[4]; /* "FACS" */
565 u32 length; /* Length in bytes (>= 64) */
566 u32 hardware_signature; /* Hardware signature */
567 u32 firmware_waking_vector; /* Firmware waking vector */
568 u32 global_lock; /* Global lock */
569 u32 flags; /* FACS flags */
570 u32 x_firmware_waking_vector_l; /* X FW waking vector, low */
571 u32 x_firmware_waking_vector_h; /* X FW waking vector, high */
572 u8 version; /* ACPI 4.0: 2 */
573 u8 resv[31]; /* FIXME: 4.0: ospm_flags */
Stefan Reinauer6a001132017-07-13 02:20:27 +0200574} __packed acpi_facs_t;
Stefan Reinauer06feb882004-02-03 16:11:35 +0000575
Uwe Hermanne9c44732010-11-22 00:42:42 +0000576/* FACS flags */
Stefan Reinauerb657a3c2009-07-21 21:38:33 +0000577#define ACPI_FACS_S4BIOS_F (1 << 0)
Uwe Hermanne9c44732010-11-22 00:42:42 +0000578#define ACPI_FACS_64BIT_WAKE_F (1 << 1)
579/* Bits 31..2: reserved */
Stefan Reinauerb657a3c2009-07-21 21:38:33 +0000580
Uwe Hermanne9c44732010-11-22 00:42:42 +0000581/* ECDT (Embedded Controller Boot Resources Table) */
Stefan Reinauerc0ac7e92009-11-10 22:17:15 +0000582typedef struct acpi_ecdt {
583 struct acpi_table_header header;
Uwe Hermanne9c44732010-11-22 00:42:42 +0000584 struct acpi_gen_regaddr ec_control; /* EC control register */
585 struct acpi_gen_regaddr ec_data; /* EC data register */
586 u32 uid; /* UID */
587 u8 gpe_bit; /* GPE bit */
588 u8 ec_id[]; /* EC ID */
Stefan Reinauer6a001132017-07-13 02:20:27 +0200589} __packed acpi_ecdt_t;
Stefan Reinauerc0ac7e92009-11-10 22:17:15 +0000590
zbaocaf494c82012-04-13 13:57:14 +0800591/* HEST (Hardware Error Source Table) */
592typedef struct acpi_hest {
593 struct acpi_table_header header;
594 u32 error_source_count;
595 /* error_source_struct(s) */
Stefan Reinauer6a001132017-07-13 02:20:27 +0200596} __packed acpi_hest_t;
zbaocaf494c82012-04-13 13:57:14 +0800597
598/* Error Source Descriptors */
599typedef struct acpi_hest_esd {
600 u16 type;
601 u16 source_id;
602 u16 resv;
603 u8 flags;
604 u8 enabled;
Lee Leahy6f80ccc2017-03-16 15:18:22 -0700605 u32 prealloc_erecords; /* The number of error records to
606 * pre-allocate for this error source.
607 */
zbaocaf494c82012-04-13 13:57:14 +0800608 u32 max_section_per_record;
Stefan Reinauer6a001132017-07-13 02:20:27 +0200609} __packed acpi_hest_esd_t;
zbaocaf494c82012-04-13 13:57:14 +0800610
611/* Hardware Error Notification */
612typedef struct acpi_hest_hen {
613 u8 type;
614 u8 length;
615 u16 conf_we; /* Configuration Write Enable */
616 u32 poll_interval;
617 u32 vector;
618 u32 sw2poll_threshold_val;
619 u32 sw2poll_threshold_win;
620 u32 error_threshold_val;
621 u32 error_threshold_win;
Stefan Reinauer6a001132017-07-13 02:20:27 +0200622} __packed acpi_hest_hen_t;
zbaocaf494c82012-04-13 13:57:14 +0800623
Stefan Reinauer4cc8c702012-04-27 21:34:16 +0200624typedef struct acpi_cstate {
625 u8 ctype;
626 u16 latency;
627 u32 power;
628 acpi_addr_t resource;
Stefan Reinauer6a001132017-07-13 02:20:27 +0200629} __packed acpi_cstate_t;
Stefan Reinauer4cc8c702012-04-27 21:34:16 +0200630
Stefan Reinauer39205c62012-04-27 21:49:28 +0200631typedef struct acpi_tstate {
632 u32 percent;
633 u32 power;
634 u32 latency;
635 u32 control;
636 u32 status;
Stefan Reinauer6a001132017-07-13 02:20:27 +0200637} __packed acpi_tstate_t;
Stefan Reinauer39205c62012-04-27 21:49:28 +0200638
Duncan Lauriebeb2af42018-05-07 14:26:59 -0700639/* Port types for ACPI _UPC object */
640enum acpi_upc_type {
641 /* These types are defined in ACPI 6.2 section 9.14 */
642 UPC_TYPE_A,
643 UPC_TYPE_MINI_AB,
644 UPC_TYPE_EXPRESSCARD,
645 UPC_TYPE_USB3_A,
646 UPC_TYPE_USB3_B,
647 UPC_TYPE_USB3_MICRO_B,
648 UPC_TYPE_USB3_MICRO_AB,
649 UPC_TYPE_USB3_POWER_B,
650 UPC_TYPE_C_USB2_ONLY,
651 UPC_TYPE_C_USB2_SS_SWITCH,
652 UPC_TYPE_C_USB2_SS,
653 UPC_TYPE_PROPRIETARY = 0xff,
654 /*
655 * The following types are not directly defined in the ACPI
656 * spec but are used by coreboot to identify a USB device type.
657 */
658 UPC_TYPE_INTERNAL = 0xff,
659 UPC_TYPE_UNUSED,
660 UPC_TYPE_HUB
661};
662
Vladimir Serbinenko41877d82014-09-01 22:18:01 +0200663unsigned long fw_cfg_acpi_tables(unsigned long start);
664
Uwe Hermanne9c44732010-11-22 00:42:42 +0000665/* These are implemented by the target port or north/southbridge. */
Stefan Reinauer688b3852004-01-28 16:56:14 +0000666unsigned long write_acpi_tables(unsigned long addr);
Stefan Reinauerf622d592005-11-26 16:56:05 +0000667unsigned long acpi_fill_madt(unsigned long current);
Rudolf Mareke6409f22007-11-03 12:50:26 +0000668unsigned long acpi_fill_mcfg(unsigned long current);
Lee Leahy024b13d2017-03-16 13:41:11 -0700669unsigned long acpi_fill_ivrs_ioapic(acpi_ivrs_t *ivrs, unsigned long current);
Myles Watson3fe6b702009-10-09 20:13:43 +0000670void acpi_create_ssdt_generator(acpi_header_t *ssdt, const char *oem_table_id);
Lee Leahy024b13d2017-03-16 13:41:11 -0700671void acpi_create_fadt(acpi_fadt_t *fadt, acpi_facs_t *facs, void *dsdt);
Vladimir Serbinenkoc21e0732014-10-16 12:48:19 +0200672#if IS_ENABLED(CONFIG_COMMON_FADT)
Lee Leahy024b13d2017-03-16 13:41:11 -0700673void acpi_fill_fadt(acpi_fadt_t *fadt);
Vladimir Serbinenkoc21e0732014-10-16 12:48:19 +0200674#endif
Stefan Reinauereb2b06b2005-01-26 09:58:49 +0000675
Uwe Hermanne9c44732010-11-22 00:42:42 +0000676void update_ssdt(void *ssdt);
677void update_ssdtx(void *ssdtx, int i);
Myles Watsonf4cc0892010-04-14 16:50:16 +0000678
Uwe Hermanne9c44732010-11-22 00:42:42 +0000679/* These can be used by the target port. */
Stefan Reinauereb2b06b2005-01-26 09:58:49 +0000680u8 acpi_checksum(u8 *table, u32 length);
Stefan Reinauerf622d592005-11-26 16:56:05 +0000681
Stefan Reinauerb657a3c2009-07-21 21:38:33 +0000682void acpi_add_table(acpi_rsdp_t *rsdp, void *table);
683
Stefan Reinauer777224c2005-01-19 14:06:41 +0000684int acpi_create_madt_lapic(acpi_madt_lapic_t *lapic, u8 cpu, u8 apic);
Uwe Hermanne9c44732010-11-22 00:42:42 +0000685int acpi_create_madt_ioapic(acpi_madt_ioapic_t *ioapic, u8 id, u32 addr,
686 u32 gsi_base);
Stefan Reinauerf622d592005-11-26 16:56:05 +0000687int acpi_create_madt_irqoverride(acpi_madt_irqoverride_t *irqoverride,
Uwe Hermanne9c44732010-11-22 00:42:42 +0000688 u8 bus, u8 source, u32 gsirq, u16 flags);
Stefan Reinauerf622d592005-11-26 16:56:05 +0000689int acpi_create_madt_lapic_nmi(acpi_madt_lapic_nmi_t *lapic_nmi, u8 cpu,
Uwe Hermanne9c44732010-11-22 00:42:42 +0000690 u16 flags, u8 lint);
Stefan Reinauer777224c2005-01-19 14:06:41 +0000691void acpi_create_madt(acpi_madt_t *madt);
Stefan Reinauerf622d592005-11-26 16:56:05 +0000692unsigned long acpi_create_madt_lapics(unsigned long current);
Uwe Hermanne9c44732010-11-22 00:42:42 +0000693unsigned long acpi_create_madt_lapic_nmis(unsigned long current, u16 flags,
694 u8 lint);
Stefan Reinauerf622d592005-11-26 16:56:05 +0000695
696int acpi_create_srat_lapic(acpi_srat_lapic_t *lapic, u8 node, u8 apic);
Lee Leahy024b13d2017-03-16 13:41:11 -0700697int acpi_create_srat_mem(acpi_srat_mem_t *mem, u8 node, u32 basek, u32 sizek,
Uwe Hermanne9c44732010-11-22 00:42:42 +0000698 u32 flags);
699int acpi_create_mcfg_mmconfig(acpi_mcfg_mmconfig_t *mmconfig, u32 base,
700 u16 seg_nr, u8 start, u8 end);
Stefan Reinauerf622d592005-11-26 16:56:05 +0000701unsigned long acpi_create_srat_lapics(unsigned long current);
Vladimir Serbinenko5e597572014-10-11 23:45:40 +0200702void acpi_create_srat(acpi_srat_t *srat,
703 unsigned long (*acpi_fill_srat)(unsigned long current));
Stefan Reinauerf622d592005-11-26 16:56:05 +0000704
Vladimir Serbinenko5e597572014-10-11 23:45:40 +0200705void acpi_create_slit(acpi_slit_t *slit,
706 unsigned long (*acpi_fill_slit)(unsigned long current));
Myles Watson43bb9cd2008-12-18 18:24:11 +0000707
Patrick Rudolpha5c2ac62016-03-31 20:04:23 +0200708void acpi_create_vfct(struct device *device,
709 struct acpi_vfct *vfct,
710 unsigned long (*acpi_fill_vfct)(struct device *device,
Lee Leahy024b13d2017-03-16 13:41:11 -0700711 struct acpi_vfct *vfct_struct,
712 unsigned long current));
Patrick Rudolpha5c2ac62016-03-31 20:04:23 +0200713
Timothy Pearsonff8ccf02015-08-11 17:48:32 -0500714void acpi_create_ivrs(acpi_ivrs_t *ivrs,
Lee Leahy6f80ccc2017-03-16 15:18:22 -0700715 unsigned long (*acpi_fill_ivrs)(acpi_ivrs_t *ivrs_struct,
716 unsigned long current));
Timothy Pearsonff8ccf02015-08-11 17:48:32 -0500717
Antonello Dettori20c9afa2016-09-02 09:08:01 +0200718#if ENV_RAMSTAGE && !defined(__SIMPLE_DEVICE__)
Stefan Reinauer777224c2005-01-19 14:06:41 +0000719void acpi_create_hpet(acpi_hpet_t *hpet);
Elyes HAOUAS9dd89cd2018-05-04 17:56:47 +0200720unsigned long acpi_write_hpet(struct device *device, unsigned long start,
Lee Leahy6f80ccc2017-03-16 15:18:22 -0700721 acpi_rsdp_t *rsdp);
Stefan Reinauerf622d592005-11-26 16:56:05 +0000722
Alexander Couzense19c8b02015-04-02 23:20:45 +0200723/* cpu/intel/speedstep/acpi.c */
Elyes HAOUAS9dd89cd2018-05-04 17:56:47 +0200724void generate_cpu_entries(struct device *device);
Alexander Couzense19c8b02015-04-02 23:20:45 +0200725#endif
726
Rudolf Mareke6409f22007-11-03 12:50:26 +0000727void acpi_create_mcfg(acpi_mcfg_t *mcfg);
728
Stefan Reinauer777224c2005-01-19 14:06:41 +0000729void acpi_create_facs(acpi_facs_t *facs);
Stefan Reinauerf622d592005-11-26 16:56:05 +0000730
Duncan Lauriee4a36c72017-11-11 19:33:25 -0800731void acpi_create_dbg2(acpi_dbg2_header_t *dbg2_header,
732 int port_type, int port_subtype,
733 acpi_addr_t *address, uint32_t address_size,
734 const char *device_path);
735
736unsigned long acpi_write_dbg2_pci_uart(acpi_rsdp_t *rsdp, unsigned long current,
737 struct device *dev, uint8_t access_size);
Nico Hubere561f352015-10-26 11:51:25 +0100738void acpi_create_dmar(acpi_dmar_t *dmar, enum dmar_flags flags,
Lee Leahy024b13d2017-03-16 13:41:11 -0700739 unsigned long (*acpi_fill_dmar)(unsigned long));
Patrick Georgi3b590ff2012-09-11 15:21:01 +0200740unsigned long acpi_create_dmar_drhd(unsigned long current, u8 flags,
741 u16 segment, u32 bar);
Werner Zehd4d76952016-07-27 06:56:36 +0200742unsigned long acpi_create_dmar_atsr(unsigned long current, u8 flags,
743 u16 segment);
Patrick Georgi3b590ff2012-09-11 15:21:01 +0200744void acpi_dmar_drhd_fixup(unsigned long base, unsigned long current);
Werner Zehd4d76952016-07-27 06:56:36 +0200745void acpi_dmar_atsr_fixup(unsigned long base, unsigned long current);
Werner Zeh21a5bff2016-07-27 07:07:20 +0200746unsigned long acpi_create_dmar_drhd_ds_pci_br(unsigned long current,
747 u8 bus, u8 dev, u8 fn);
Nico Huber6c4751d2015-10-26 12:03:54 +0100748unsigned long acpi_create_dmar_drhd_ds_pci(unsigned long current,
749 u8 bus, u8 dev, u8 fn);
750unsigned long acpi_create_dmar_drhd_ds_ioapic(unsigned long current,
751 u8 enumeration_id,
752 u8 bus, u8 dev, u8 fn);
753unsigned long acpi_create_dmar_drhd_ds_msi_hpet(unsigned long current,
754 u8 enumeration_id,
755 u8 bus, u8 dev, u8 fn);
Vladimir Serbinenko807127f2014-11-09 13:36:18 +0100756void acpi_write_hest(acpi_hest_t *hest,
757 unsigned long (*acpi_fill_hest)(acpi_hest_t *hest));
Patrick Georgi3b590ff2012-09-11 15:21:01 +0200758
Lee Leahy6f80ccc2017-03-16 15:18:22 -0700759unsigned long acpi_create_hest_error_source(acpi_hest_t *hest,
760 acpi_hest_esd_t *esd, u16 type, void *data, u16 len);
zbaocaf494c82012-04-13 13:57:14 +0800761
Duncan Laurie11290c42012-10-03 19:07:05 -0700762void acpi_save_gnvs(u32 gnvs_address);
763
Kyösti Mälkki7a846e72015-01-09 23:55:09 +0200764/* For ACPI S3 support. */
Kyösti Mälkkicb28f3f2014-01-03 15:15:22 +0200765void acpi_fail_wakeup(void);
Aaron Durbin0a6c20a2013-04-24 22:33:08 -0500766void acpi_resume(void *wake_vec);
Kyösti Mälkki7b14f082014-10-16 20:58:47 +0300767void acpi_prepare_resume_backup(void);
Kyösti Mälkki134f5042014-12-26 13:29:09 +0200768void mainboard_suspend_resume(void);
Rudolf Marek33cafe52009-04-13 18:07:02 +0000769void *acpi_find_wakeup_vector(void);
Stefan Reinauerb657a3c2009-07-21 21:38:33 +0000770
Aaron Durbin95c43442016-07-13 12:08:33 -0500771enum {
772 ACPI_S0,
773 ACPI_S1,
774 ACPI_S2,
775 ACPI_S3,
776 ACPI_S4,
777 ACPI_S5,
778};
779
Marshall Dawson6139a5c62017-10-04 15:10:00 -0600780#if IS_ENABLED(CONFIG_ACPI_INTEL_HARDWARE_SLEEP_VALUES) \
781 || IS_ENABLED(CONFIG_ACPI_AMD_HARDWARE_SLEEP_VALUES)
Aaron Durbin20a588b2016-07-13 23:13:25 -0500782/* Given the provided PM1 control register return the ACPI sleep type. */
783static inline int acpi_sleep_from_pm1(uint32_t pm1_cnt)
784{
785 switch (((pm1_cnt) & SLP_TYP) >> SLP_TYP_SHIFT) {
786 case SLP_TYP_S0: return ACPI_S0;
787 case SLP_TYP_S1: return ACPI_S1;
788 case SLP_TYP_S3: return ACPI_S3;
789 case SLP_TYP_S4: return ACPI_S4;
790 case SLP_TYP_S5: return ACPI_S5;
791 }
792 return -1;
793}
794#endif
795
Aaron Durbin95c43442016-07-13 12:08:33 -0500796/* Returns ACPI_Sx values. */
Kyösti Mälkki134f5042014-12-26 13:29:09 +0200797int acpi_get_sleep_type(void);
Stefan Reinauerbe7f7982009-03-13 15:42:27 +0000798
Duncan Laurie1f6e6812016-09-19 12:04:19 -0700799/* Read and clear GPE status */
800int acpi_get_gpe(int gpe);
801
Kyösti Mälkki2ca2afe2014-06-17 15:41:37 +0300802static inline int acpi_s3_resume_allowed(void)
803{
804 return IS_ENABLED(CONFIG_HAVE_ACPI_RESUME);
805}
806
Kyösti Mälkki9d6f3652016-06-28 07:38:46 +0300807/* Return address in reserved memory where to backup low memory
808 * while platform resumes from S3 suspend. Caller is responsible of
809 * making a complete copy of the region base..base+size, with
810 * parameteres base and size that meet page alignment requirement.
811 */
812void *acpi_backup_container(uintptr_t base, size_t size);
813
Kyösti Mälkki7a846e72015-01-09 23:55:09 +0200814#if IS_ENABLED(CONFIG_HAVE_ACPI_RESUME)
Kyösti Mälkki78c5d582015-01-09 23:48:47 +0200815
816#ifdef __PRE_RAM__
817static inline int acpi_is_wakeup_s3(void)
818{
Aaron Durbin95c43442016-07-13 12:08:33 -0500819 return (acpi_get_sleep_type() == ACPI_S3);
Kyösti Mälkki78c5d582015-01-09 23:48:47 +0200820}
821#else
Kyösti Mälkki7a846e72015-01-09 23:55:09 +0200822int acpi_is_wakeup(void);
823int acpi_is_wakeup_s3(void);
zbao1897c2c2015-11-05 20:25:59 +0800824int acpi_is_wakeup_s4(void);
Kyösti Mälkki78c5d582015-01-09 23:48:47 +0200825#endif
826
Kyösti Mälkki7a846e72015-01-09 23:55:09 +0200827#else
Kyösti Mälkki4d9b7722014-06-19 19:45:40 +0300828static inline int acpi_is_wakeup(void) { return 0; }
829static inline int acpi_is_wakeup_s3(void) { return 0; }
zbao1897c2c2015-11-05 20:25:59 +0800830static inline int acpi_is_wakeup_s4(void) { return 0; }
Kyösti Mälkki4d9b7722014-06-19 19:45:40 +0300831#endif
832
Aaron Durbin07a1b282015-12-10 17:07:38 -0600833static inline uintptr_t acpi_align_current(uintptr_t current)
834{
835 return ALIGN(current, 16);
836}
837
Aaron Durbin20a588b2016-07-13 23:13:25 -0500838#endif // !defined(__ASSEMBLER__) && !defined(__ACPI__) && !defined(__ROMC__)
Kyösti Mälkkia969ed32016-06-15 06:08:15 +0300839
Martin Rothaee18692012-04-26 15:54:15 -0600840#endif /* __ASM_ACPI_H */