acpi_table.h 17 KB

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