1
2
3
4
5
6
7
8
9#ifndef __ASM_ACPI_TABLE_H__
10#define __ASM_ACPI_TABLE_H__
11
12#define RSDP_SIG "RSD PTR "
13#define OEM_ID "U-BOOT"
14#define OEM_TABLE_ID "U-BOOTBL"
15#define ASLC_ID "INTL"
16
17#define ACPI_RSDP_REV_ACPI_1_0 0
18#define ACPI_RSDP_REV_ACPI_2_0 2
19
20
21
22
23
24struct acpi_rsdp {
25 char signature[8];
26 u8 checksum;
27 char oem_id[6];
28 u8 revision;
29 u32 rsdt_address;
30 u32 length;
31 u64 xsdt_address;
32 u8 ext_checksum;
33 u8 reserved[3];
34};
35
36
37struct __packed acpi_table_header {
38 char signature[4];
39 u32 length;
40 u8 revision;
41 volatile u8 checksum;
42 char oem_id[6];
43 char oem_table_id[8];
44 u32 oem_revision;
45 char aslc_id[4];
46 u32 aslc_revision;
47};
48
49
50#define MAX_ACPI_TABLES 32
51
52
53struct acpi_rsdt {
54 struct acpi_table_header header;
55 u32 entry[MAX_ACPI_TABLES];
56};
57
58
59struct acpi_xsdt {
60 struct acpi_table_header header;
61 u64 entry[MAX_ACPI_TABLES];
62};
63
64
65enum acpi_pm_profile {
66 ACPI_PM_UNSPECIFIED = 0,
67 ACPI_PM_DESKTOP,
68 ACPI_PM_MOBILE,
69 ACPI_PM_WORKSTATION,
70 ACPI_PM_ENTERPRISE_SERVER,
71 ACPI_PM_SOHO_SERVER,
72 ACPI_PM_APPLIANCE_PC,
73 ACPI_PM_PERFORMANCE_SERVER,
74 ACPI_PM_TABLET
75};
76
77
78#define ACPI_FADT_C2_NOT_SUPPORTED 101
79#define ACPI_FADT_C3_NOT_SUPPORTED 1001
80
81
82#define ACPI_FADT_LEGACY_FREE 0x00
83#define ACPI_FADT_LEGACY_DEVICES (1 << 0)
84#define ACPI_FADT_8042 (1 << 1)
85#define ACPI_FADT_VGA_NOT_PRESENT (1 << 2)
86#define ACPI_FADT_MSI_NOT_SUPPORTED (1 << 3)
87#define ACPI_FADT_NO_PCIE_ASPM_CONTROL (1 << 4)
88
89
90#define ACPI_FADT_WBINVD (1 << 0)
91#define ACPI_FADT_WBINVD_FLUSH (1 << 1)
92#define ACPI_FADT_C1_SUPPORTED (1 << 2)
93#define ACPI_FADT_C2_MP_SUPPORTED (1 << 3)
94#define ACPI_FADT_POWER_BUTTON (1 << 4)
95#define ACPI_FADT_SLEEP_BUTTON (1 << 5)
96#define ACPI_FADT_FIXED_RTC (1 << 6)
97#define ACPI_FADT_S4_RTC_WAKE (1 << 7)
98#define ACPI_FADT_32BIT_TIMER (1 << 8)
99#define ACPI_FADT_DOCKING_SUPPORTED (1 << 9)
100#define ACPI_FADT_RESET_REGISTER (1 << 10)
101#define ACPI_FADT_SEALED_CASE (1 << 11)
102#define ACPI_FADT_HEADLESS (1 << 12)
103#define ACPI_FADT_SLEEP_TYPE (1 << 13)
104#define ACPI_FADT_PCI_EXPRESS_WAKE (1 << 14)
105#define ACPI_FADT_PLATFORM_CLOCK (1 << 15)
106#define ACPI_FADT_S4_RTC_VALID (1 << 16)
107#define ACPI_FADT_REMOTE_POWER_ON (1 << 17)
108#define ACPI_FADT_APIC_CLUSTER (1 << 18)
109#define ACPI_FADT_APIC_PHYSICAL (1 << 19)
110#define ACPI_FADT_HW_REDUCED_ACPI (1 << 20)
111#define ACPI_FADT_LOW_PWR_IDLE_S0 (1 << 21)
112
113enum acpi_address_space_type {
114 ACPI_ADDRESS_SPACE_MEMORY = 0,
115 ACPI_ADDRESS_SPACE_IO,
116 ACPI_ADDRESS_SPACE_PCI,
117 ACPI_ADDRESS_SPACE_EC,
118 ACPI_ADDRESS_SPACE_SMBUS,
119 ACPI_ADDRESS_SPACE_PCC = 0x0a,
120 ACPI_ADDRESS_SPACE_FIXED = 0x7f
121};
122
123enum acpi_address_space_size {
124 ACPI_ACCESS_SIZE_UNDEFINED = 0,
125 ACPI_ACCESS_SIZE_BYTE_ACCESS,
126 ACPI_ACCESS_SIZE_WORD_ACCESS,
127 ACPI_ACCESS_SIZE_DWORD_ACCESS,
128 ACPI_ACCESS_SIZE_QWORD_ACCESS
129};
130
131struct acpi_gen_regaddr {
132 u8 space_id;
133 u8 bit_width;
134 u8 bit_offset;
135 u8 access_size;
136 u32 addrl;
137 u32 addrh;
138};
139
140
141struct __packed acpi_fadt {
142 struct acpi_table_header header;
143 u32 firmware_ctrl;
144 u32 dsdt;
145 u8 res1;
146 u8 preferred_pm_profile;
147 u16 sci_int;
148 u32 smi_cmd;
149 u8 acpi_enable;
150 u8 acpi_disable;
151 u8 s4bios_req;
152 u8 pstate_cnt;
153 u32 pm1a_evt_blk;
154 u32 pm1b_evt_blk;
155 u32 pm1a_cnt_blk;
156 u32 pm1b_cnt_blk;
157 u32 pm2_cnt_blk;
158 u32 pm_tmr_blk;
159 u32 gpe0_blk;
160 u32 gpe1_blk;
161 u8 pm1_evt_len;
162 u8 pm1_cnt_len;
163 u8 pm2_cnt_len;
164 u8 pm_tmr_len;
165 u8 gpe0_blk_len;
166 u8 gpe1_blk_len;
167 u8 gpe1_base;
168 u8 cst_cnt;
169 u16 p_lvl2_lat;
170 u16 p_lvl3_lat;
171 u16 flush_size;
172 u16 flush_stride;
173 u8 duty_offset;
174 u8 duty_width;
175 u8 day_alrm;
176 u8 mon_alrm;
177 u8 century;
178 u16 iapc_boot_arch;
179 u8 res2;
180 u32 flags;
181 struct acpi_gen_regaddr reset_reg;
182 u8 reset_value;
183 u16 arm_boot_arch;
184 u8 minor_revision;
185 u32 x_firmware_ctl_l;
186 u32 x_firmware_ctl_h;
187 u32 x_dsdt_l;
188 u32 x_dsdt_h;
189 struct acpi_gen_regaddr x_pm1a_evt_blk;
190 struct acpi_gen_regaddr x_pm1b_evt_blk;
191 struct acpi_gen_regaddr x_pm1a_cnt_blk;
192 struct acpi_gen_regaddr x_pm1b_cnt_blk;
193 struct acpi_gen_regaddr x_pm2_cnt_blk;
194 struct acpi_gen_regaddr x_pm_tmr_blk;
195 struct acpi_gen_regaddr x_gpe0_blk;
196 struct acpi_gen_regaddr x_gpe1_blk;
197};
198
199
200#define ACPI_FACS_S4BIOS_F (1 << 0)
201#define ACPI_FACS_64BIT_WAKE_F (1 << 1)
202
203
204struct acpi_facs {
205 char signature[4];
206 u32 length;
207 u32 hardware_signature;
208 u32 firmware_waking_vector;
209 u32 global_lock;
210 u32 flags;
211 u32 x_firmware_waking_vector_l;
212 u32 x_firmware_waking_vector_h;
213 u8 version;
214 u8 res1[3];
215 u32 ospm_flags;
216 u8 res2[24];
217};
218
219
220#define ACPI_MADT_PCAT_COMPAT (1 << 0)
221
222
223struct acpi_madt {
224 struct acpi_table_header header;
225 u32 lapic_addr;
226 u32 flags;
227};
228
229
230enum acpi_apic_types {
231 ACPI_APIC_LAPIC = 0,
232 ACPI_APIC_IOAPIC,
233 ACPI_APIC_IRQ_SRC_OVERRIDE,
234 ACPI_APIC_NMI_SRC,
235 ACPI_APIC_LAPIC_NMI,
236 ACPI_APIC_LAPIC_ADDR_OVERRIDE,
237 ACPI_APIC_IOSAPIC,
238 ACPI_APIC_LSAPIC,
239 ACPI_APIC_PLATFORM_IRQ_SRC,
240 ACPI_APIC_LX2APIC,
241 ACPI_APIC_LX2APIC_NMI,
242};
243
244
245
246#define LOCAL_APIC_FLAG_ENABLED (1 << 0)
247
248struct acpi_madt_lapic {
249 u8 type;
250 u8 length;
251 u8 processor_id;
252 u8 apic_id;
253 u32 flags;
254};
255
256
257struct acpi_madt_ioapic {
258 u8 type;
259 u8 length;
260 u8 ioapic_id;
261 u8 reserved;
262 u32 ioapic_addr;
263 u32 gsi_base;
264};
265
266
267struct __packed acpi_madt_irqoverride {
268 u8 type;
269 u8 length;
270 u8 bus;
271 u8 source;
272 u32 gsirq;
273 u16 flags;
274};
275
276
277struct __packed acpi_madt_lapic_nmi {
278 u8 type;
279 u8 length;
280 u8 processor_id;
281 u16 flags;
282 u8 lint;
283};
284
285
286struct acpi_mcfg {
287 struct acpi_table_header header;
288 u8 reserved[8];
289};
290
291struct acpi_mcfg_mmconfig {
292 u32 base_address_l;
293 u32 base_address_h;
294 u16 pci_segment_group_number;
295 u8 start_bus_number;
296 u8 end_bus_number;
297 u8 reserved[4];
298};
299
300
301#define PM1_CNT_SCI_EN (1 << 0)
302
303
304struct acpi_global_nvs;
305
306
307struct acpi_csrt {
308 struct acpi_table_header header;
309};
310
311struct acpi_csrt_group {
312 u32 length;
313 u32 vendor_id;
314 u32 subvendor_id;
315 u16 device_id;
316 u16 subdevice_id;
317 u16 revision;
318 u16 reserved;
319 u32 shared_info_length;
320};
321
322struct acpi_csrt_shared_info {
323 u16 major_version;
324 u16 minor_version;
325 u32 mmio_base_low;
326 u32 mmio_base_high;
327 u32 gsi_interrupt;
328 u8 interrupt_polarity;
329 u8 interrupt_mode;
330 u8 num_channels;
331 u8 dma_address_width;
332 u16 base_request_line;
333 u16 num_handshake_signals;
334 u32 max_block_size;
335};
336
337
338
339
340
341#define ACPI_DBG2_SERIAL_PORT 0x8000
342#define ACPI_DBG2_1394_PORT 0x8001
343#define ACPI_DBG2_USB_PORT 0x8002
344#define ACPI_DBG2_NET_PORT 0x8003
345
346
347
348#define ACPI_DBG2_16550_COMPATIBLE 0x0000
349#define ACPI_DBG2_16550_SUBSET 0x0001
350#define ACPI_DBG2_ARM_PL011 0x0003
351#define ACPI_DBG2_ARM_SBSA_32BIT 0x000D
352#define ACPI_DBG2_ARM_SBSA_GENERIC 0x000E
353#define ACPI_DBG2_ARM_DCC 0x000F
354#define ACPI_DBG2_BCM2835 0x0010
355
356#define ACPI_DBG2_1394_STANDARD 0x0000
357
358#define ACPI_DBG2_USB_XHCI 0x0000
359#define ACPI_DBG2_USB_EHCI 0x0001
360
361#define ACPI_DBG2_UNKNOWN 0x00FF
362
363
364struct __packed acpi_spcr {
365 struct acpi_table_header header;
366 u8 interface_type;
367 u8 reserved[3];
368 struct acpi_gen_regaddr serial_port;
369 u8 interrupt_type;
370 u8 pc_interrupt;
371 u32 interrupt;
372 u8 baud_rate;
373 u8 parity;
374 u8 stop_bits;
375 u8 flow_control;
376 u8 terminal_type;
377 u8 reserved1;
378 u16 pci_device_id;
379 u16 pci_vendor_id;
380 u8 pci_bus;
381 u8 pci_device;
382 u8 pci_function;
383 u32 pci_flags;
384 u8 pci_segment;
385 u32 reserved2;
386};
387
388
389
390void acpi_fill_header(struct acpi_table_header *header, char *signature);
391void acpi_create_fadt(struct acpi_fadt *fadt, struct acpi_facs *facs,
392 void *dsdt);
393int acpi_create_madt_lapics(u32 current);
394int acpi_create_madt_ioapic(struct acpi_madt_ioapic *ioapic, u8 id,
395 u32 addr, u32 gsi_base);
396int acpi_create_madt_irqoverride(struct acpi_madt_irqoverride *irqoverride,
397 u8 bus, u8 source, u32 gsirq, u16 flags);
398int acpi_create_madt_lapic_nmi(struct acpi_madt_lapic_nmi *lapic_nmi,
399 u8 cpu, u16 flags, u8 lint);
400u32 acpi_fill_madt(u32 current);
401int acpi_create_mcfg_mmconfig(struct acpi_mcfg_mmconfig *mmconfig, u32 base,
402 u16 seg_nr, u8 start, u8 end);
403u32 acpi_fill_mcfg(u32 current);
404u32 acpi_fill_csrt(u32 current);
405void acpi_create_gnvs(struct acpi_global_nvs *gnvs);
406ulong write_acpi_tables(ulong start);
407
408
409
410
411
412
413
414
415ulong acpi_get_rsdp_addr(void);
416
417#endif
418