]> git.sur5r.net Git - u-boot/blob - arch/x86/include/asm/acpi_table.h
x86: acpi: Remove unused codes
[u-boot] / arch / x86 / include / asm / acpi_table.h
1 /*
2  * Based on acpi.c from coreboot
3  *
4  * Copyright (C) 2015, Saket Sinha <saket.sinha89@gmail.com>
5  *
6  * SPDX-License-Identifier: GPL-2.0+
7  */
8
9 #define RSDP_SIG                "RSD PTR "      /* RSDT pointer signature */
10 #define ACPI_TABLE_CREATOR      "UBOOT   "      /* Must be 8 bytes long! */
11 #define OEM_ID                  "UBOOT "        /* Must be 6 bytes long! */
12 #define ASLC                    "INTL"          /* Must be 4 bytes long! */
13
14 #define OEM_REVISION    42
15 #define ASL_COMPILER_REVISION   42
16
17 #define ACPI_REV_ACPI_1_0       1
18 #define ACPI_REV_ACPI_2_0       1
19 #define ACPI_REV_ACPI_3_0       2
20 #define ACPI_REV_ACPI_4_0       3
21 #define ACPI_REV_ACPI_5_0       5
22
23 #define ACPI_RSDP_REV_ACPI_1_0  0
24 #define ACPI_RSDP_REV_ACPI_2_0  2
25
26 typedef struct acpi_gen_regaddr {
27         u8  space_id;   /* Address space ID */
28         u8  bit_width;  /* Register size in bits */
29         u8  bit_offset; /* Register bit offset */
30         union {
31                 /* Reserved in ACPI 2.0 - 2.0b */
32                 u8  resv;
33                 /* Access size in ACPI 2.0c/3.0/4.0/5.0 */
34                 u8  access_size;
35         };
36         u32 addrl;      /* Register address, low 32 bits */
37         u32 addrh;      /* Register address, high 32 bits */
38 } acpi_addr_t;
39
40
41 /*
42  * RSDP (Root System Description Pointer)
43  * Note: ACPI 1.0 didn't have length, xsdt_address, and ext_checksum
44  */
45 struct acpi_rsdp {
46         char signature[8];      /* RSDP signature */
47         u8 checksum;            /* Checksum of the first 20 bytes */
48         char oem_id[6];         /* OEM ID */
49         u8 revision;            /* 0 for ACPI 1.0, 2 for ACPI 2.0/3.0/4.0 */
50         u32 rsdt_address;       /* Physical address of RSDT (32 bits) */
51         u32 length;             /* Total RSDP length (incl. extended part) */
52         u64 xsdt_address;       /* Physical address of XSDT (64 bits) */
53         u8 ext_checksum;        /* Checksum of the whole table */
54         u8 reserved[3];
55 };
56
57 enum acpi_address_space_type {
58         ACPI_ADDRESS_SPACE_MEMORY = 0,  /* System memory */
59         ACPI_ADDRESS_SPACE_IO,          /* System I/O */
60         ACPI_ADDRESS_SPACE_PCI,         /* PCI config space */
61         ACPI_ADDRESS_SPACE_EC,          /* Embedded controller */
62         ACPI_ADDRESS_SPACE_SMBUS,       /* SMBus */
63         ACPI_ADDRESS_SPACE_PCC = 0x0a,  /* Platform Comm. Channel */
64         ACPI_ADDRESS_SPACE_FIXED = 0x7f /* Functional fixed hardware */
65 };
66
67 /* Access size definitions for Generic address structure */
68 enum acpi_address_space_size {
69         ACPI_ACCESS_SIZE_UNDEFINED = 0, /* Undefined (legacy reasons) */
70         ACPI_ACCESS_SIZE_BYTE_ACCESS = 1,
71         ACPI_ACCESS_SIZE_WORD_ACCESS = 2,
72         ACPI_ACCESS_SIZE_DWORD_ACCESS = 3,
73         ACPI_ACCESS_SIZE_QWORD_ACCESS = 4
74 };
75
76 /* Generic ACPI header, provided by (almost) all tables */
77 typedef struct acpi_table_header {
78         char signature[4];      /* ACPI signature (4 ASCII characters) */
79         u32 length;             /* Table length in bytes (incl. header) */
80         u8 revision;            /* Table version (not ACPI version!) */
81         volatile u8 checksum;   /* To make sum of entire table == 0 */
82         char oem_id[6];         /* OEM identification */
83         char oem_table_id[8];   /* OEM table identification */
84         u32 oem_revision;       /* OEM revision number */
85         char asl_compiler_id[4]; /* ASL compiler vendor ID */
86         u32 asl_compiler_revision; /* ASL compiler revision number */
87 } acpi_header_t;
88
89 /* A maximum number of 32 ACPI tables ought to be enough for now */
90 #define MAX_ACPI_TABLES 32
91
92 /* RSDT (Root System Description Table) */
93 struct acpi_rsdt {
94         struct acpi_table_header header;
95         u32 entry[MAX_ACPI_TABLES];
96 };
97
98 /* XSDT (Extended System Description Table) */
99 struct acpi_xsdt {
100         struct acpi_table_header header;
101         u64 entry[MAX_ACPI_TABLES];
102 };
103
104 /* MCFG (PCI Express MMIO config space BAR description table) */
105 struct acpi_mcfg {
106         struct acpi_table_header header;
107         u8 reserved[8];
108 };
109
110 struct acpi_mcfg_mmconfig {
111         u32 base_address;
112         u32 base_reserved;
113         u16 pci_segment_group_number;
114         u8 start_bus_number;
115         u8 end_bus_number;
116         u8 reserved[4];
117 };
118
119 /* MADT (Multiple APIC Description Table) */
120 struct acpi_madt {
121         struct acpi_table_header header;
122         u32 lapic_addr;                 /* Local APIC address */
123         u32 flags;                      /* Multiple APIC flags */
124 } acpi_madt_t;
125
126 /* MADT: APIC Structure Type*/
127 enum acpi_apic_types {
128         LOCALAPIC       = 0,    /* Processor local APIC */
129         IOAPIC,                 /* I/O APIC */
130         IRQSOURCEOVERRIDE,      /* Interrupt source override */
131         NMITYPE,                /* NMI source */
132         LOCALNMITYPE,           /* Local APIC NMI */
133         LAPICADDRESSOVERRIDE,   /* Local APIC address override */
134         IOSAPIC,                /* I/O SAPIC */
135         LOCALSAPIC,             /* Local SAPIC */
136         PLATFORMIRQSOURCES,     /* Platform interrupt sources */
137         LOCALX2SAPIC,           /* Processor local x2APIC */
138         LOCALX2APICNMI,         /* Local x2APIC NMI */
139 };
140
141 /* MADT: Processor Local APIC Structure */
142 struct acpi_madt_lapic {
143         u8 type;                /* Type (0) */
144         u8 length;              /* Length in bytes (8) */
145         u8 processor_id;        /* ACPI processor ID */
146         u8 apic_id;             /* Local APIC ID */
147         u32 flags;              /* Local APIC flags */
148 };
149
150 #define LOCAL_APIC_FLAG_ENABLED (1 << 0)
151 /* bits 1-31: reserved */
152 #define PCAT_COMPAT             (1 << 0)
153 /* bits 1-31: reserved */
154
155 /* MADT: Local APIC NMI Structure */
156 struct acpi_madt_lapic_nmi {
157         u8 type;                /* Type (4) */
158         u8 length;              /* Length in bytes (6) */
159         u8 processor_id;        /* ACPI processor ID */
160         u16 flags;              /* MPS INTI flags */
161         u8 lint;                /* Local APIC LINT# */
162 };
163
164 /* MADT: I/O APIC Structure */
165 struct acpi_madt_ioapic {
166         u8 type;                /* Type (1) */
167         u8 length;              /* Length in bytes (12) */
168         u8 ioapic_id;           /* I/O APIC ID */
169         u8 reserved;
170         u32 ioapic_addr;        /* I/O APIC address */
171         u32 gsi_base;           /* Global system interrupt base */
172 };
173
174 /* MADT: Interrupt Source Override Structure */
175 struct acpi_madt_irqoverride {
176         u8 type;                /* Type (2) */
177         u8 length;              /* Length in bytes (10) */
178         u8 bus;                 /* ISA (0) */
179         u8 source;              /* Bus-relative int. source (IRQ) */
180         u32 gsirq;              /* Global system interrupt */
181         u16 flags;              /* MPS INTI flags */
182 };
183
184 /* FADT (Fixed ACPI Description Table) */
185 struct __packed acpi_fadt {
186         struct acpi_table_header header;
187         u32 firmware_ctrl;
188         u32 dsdt;
189         u8 model;
190         u8 preferred_pm_profile;
191         u16 sci_int;
192         u32 smi_cmd;
193         u8 acpi_enable;
194         u8 acpi_disable;
195         u8 s4bios_req;
196         u8 pstate_cnt;
197         u32 pm1a_evt_blk;
198         u32 pm1b_evt_blk;
199         u32 pm1a_cnt_blk;
200         u32 pm1b_cnt_blk;
201         u32 pm2_cnt_blk;
202         u32 pm_tmr_blk;
203         u32 gpe0_blk;
204         u32 gpe1_blk;
205         u8 pm1_evt_len;
206         u8 pm1_cnt_len;
207         u8 pm2_cnt_len;
208         u8 pm_tmr_len;
209         u8 gpe0_blk_len;
210         u8 gpe1_blk_len;
211         u8 gpe1_base;
212         u8 cst_cnt;
213         u16 p_lvl2_lat;
214         u16 p_lvl3_lat;
215         u16 flush_size;
216         u16 flush_stride;
217         u8 duty_offset;
218         u8 duty_width;
219         u8 day_alrm;
220         u8 mon_alrm;
221         u8 century;
222         u16 iapc_boot_arch;
223         u8 res2;
224         u32 flags;
225         struct acpi_gen_regaddr reset_reg;
226         u8 reset_value;
227         u8 res3;
228         u8 res4;
229         u8 res5;
230         u32 x_firmware_ctl_l;
231         u32 x_firmware_ctl_h;
232         u32 x_dsdt_l;
233         u32 x_dsdt_h;
234         struct acpi_gen_regaddr x_pm1a_evt_blk;
235         struct acpi_gen_regaddr x_pm1b_evt_blk;
236         struct acpi_gen_regaddr x_pm1a_cnt_blk;
237         struct acpi_gen_regaddr x_pm1b_cnt_blk;
238         struct acpi_gen_regaddr x_pm2_cnt_blk;
239         struct acpi_gen_regaddr x_pm_tmr_blk;
240         struct acpi_gen_regaddr x_gpe0_blk;
241         struct acpi_gen_regaddr x_gpe1_blk;
242 };
243
244 /* Flags for p_lvl2_lat and p_lvl3_lat */
245 #define ACPI_FADT_C2_NOT_SUPPORTED      101
246 #define ACPI_FADT_C3_NOT_SUPPORTED      1001
247
248 /* FADT Feature Flags */
249 #define ACPI_FADT_WBINVD                (1 << 0)
250 #define ACPI_FADT_WBINVD_FLUSH          (1 << 1)
251 #define ACPI_FADT_C1_SUPPORTED          (1 << 2)
252 #define ACPI_FADT_C2_MP_SUPPORTED       (1 << 3)
253 #define ACPI_FADT_POWER_BUTTON          (1 << 4)
254 #define ACPI_FADT_SLEEP_BUTTON          (1 << 5)
255 #define ACPI_FADT_FIXED_RTC             (1 << 6)
256 #define ACPI_FADT_S4_RTC_WAKE           (1 << 7)
257 #define ACPI_FADT_32BIT_TIMER           (1 << 8)
258 #define ACPI_FADT_DOCKING_SUPPORTED     (1 << 9)
259 #define ACPI_FADT_RESET_REGISTER        (1 << 10)
260 #define ACPI_FADT_SEALED_CASE           (1 << 11)
261 #define ACPI_FADT_HEADLESS              (1 << 12)
262 #define ACPI_FADT_SLEEP_TYPE            (1 << 13)
263 #define ACPI_FADT_PCI_EXPRESS_WAKE      (1 << 14)
264 #define ACPI_FADT_PLATFORM_CLOCK        (1 << 15)
265 #define ACPI_FADT_S4_RTC_VALID          (1 << 16)
266 #define ACPI_FADT_REMOTE_POWER_ON       (1 << 17)
267 #define ACPI_FADT_APIC_CLUSTER          (1 << 18)
268 #define ACPI_FADT_APIC_PHYSICAL         (1 << 19)
269 /* Bits 20-31: reserved ACPI 3.0 & 4.0 */
270 #define ACPI_FADT_HW_REDUCED_ACPI       (1 << 20)
271 #define ACPI_FADT_LOW_PWR_IDLE_S0       (1 << 21)
272 /* bits 22-31: reserved ACPI 5.0 */
273
274 /* FADT Boot Architecture Flags */
275 #define ACPI_FADT_LEGACY_DEVICES        (1 << 0)
276 #define ACPI_FADT_8042                  (1 << 1)
277 #define ACPI_FADT_VGA_NOT_PRESENT       (1 << 2)
278 #define ACPI_FADT_MSI_NOT_SUPPORTED     (1 << 3)
279 #define ACPI_FADT_NO_PCIE_ASPM_CONTROL  (1 << 4)
280 /* No legacy devices (including 8042) */
281 #define ACPI_FADT_LEGACY_FREE           0x00
282
283 /* FADT Preferred Power Management Profile */
284 #define PM_UNSPECIFIED          0
285 #define PM_DESKTOP              1
286 #define PM_MOBILE               2
287 #define PM_WORKSTATION          3
288 #define PM_ENTERPRISE_SERVER    4
289 #define PM_SOHO_SERVER          5
290 #define PM_APPLIANCE_PC         6
291 #define PM_PERFORMANCE_SERVER   7
292 #define PM_TABLET               8       /* ACPI 5.0 */
293
294 /* FACS (Firmware ACPI Control Structure) */
295 struct acpi_facs {
296         char signature[4];                      /* "FACS" */
297         u32 length;                             /* Length in bytes (>= 64) */
298         u32 hardware_signature;                 /* Hardware signature */
299         u32 firmware_waking_vector;             /* Firmware waking vector */
300         u32 global_lock;                        /* Global lock */
301         u32 flags;                              /* FACS flags */
302         u32 x_firmware_waking_vector_l;         /* X FW waking vector, low */
303         u32 x_firmware_waking_vector_h;         /* X FW waking vector, high */
304         u8 version;                             /* ACPI 4.0: 2 */
305         u8 resv[31];                            /* FIXME: 4.0: ospm_flags */
306 };
307
308 /* FACS flags */
309 #define ACPI_FACS_S4BIOS_F      (1 << 0)
310 #define ACPI_FACS_64BIT_WAKE_F  (1 << 1)
311 /* Bits 31..2: reserved */
312
313 /* These can be used by the target port */
314
315 unsigned long acpi_create_madt_lapics(unsigned long current);
316 int acpi_create_madt_ioapic(struct acpi_madt_ioapic *ioapic, u8 id, u32 addr,
317                          u32 gsi_base);
318 int acpi_create_madt_irqoverride(struct acpi_madt_irqoverride *irqoverride,
319                          u8 bus, u8 source, u32 gsirq, u16 flags);
320 unsigned long acpi_fill_madt(unsigned long current);
321 void acpi_create_fadt(struct acpi_fadt *fadt, struct acpi_facs *facs,
322                          void *dsdt);
323 int acpi_create_madt_lapic_nmi(struct acpi_madt_lapic_nmi *lapic_nmi, u8 cpu,
324                          u16 flags, u8 lint);
325 u32 write_acpi_tables(u32 start);