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