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