[PATCH] swsusp: rework memory shrinker
[GitHub/LineageOS/android_kernel_samsung_universal7580.git] / include / linux / acpi.h
CommitLineData
1da177e4
LT
1/*
2 * acpi.h - ACPI Interface
3 *
4 * Copyright (C) 2001 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
5 *
6 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 *
22 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
23 */
24
25#ifndef _LINUX_ACPI_H
26#define _LINUX_ACPI_H
27
3f5948fa 28
25be5e6c
LB
29#ifdef CONFIG_ACPI
30
1da177e4
LT
31#ifndef _LINUX
32#define _LINUX
33#endif
34
35#include <linux/list.h>
36
37#include <acpi/acpi.h>
38#include <acpi/acpi_bus.h>
39#include <acpi/acpi_drivers.h>
40#include <asm/acpi.h>
41
42
888ba6c6 43#ifdef CONFIG_ACPI
1da177e4
LT
44
45enum acpi_irq_model_id {
46 ACPI_IRQ_MODEL_PIC = 0,
47 ACPI_IRQ_MODEL_IOAPIC,
48 ACPI_IRQ_MODEL_IOSAPIC,
49 ACPI_IRQ_MODEL_COUNT
50};
51
52extern enum acpi_irq_model_id acpi_irq_model;
53
54
55/* Root System Description Pointer (RSDP) */
56
57struct acpi_table_rsdp {
58 char signature[8];
59 u8 checksum;
60 char oem_id[6];
61 u8 revision;
62 u32 rsdt_address;
63} __attribute__ ((packed));
64
65struct acpi20_table_rsdp {
66 char signature[8];
67 u8 checksum;
68 char oem_id[6];
69 u8 revision;
70 u32 rsdt_address;
71 u32 length;
72 u64 xsdt_address;
73 u8 ext_checksum;
74 u8 reserved[3];
75} __attribute__ ((packed));
76
77typedef struct {
78 u8 type;
79 u8 length;
80} __attribute__ ((packed)) acpi_table_entry_header;
81
82/* Root System Description Table (RSDT) */
83
84struct acpi_table_rsdt {
85 struct acpi_table_header header;
86 u32 entry[8];
87} __attribute__ ((packed));
88
89/* Extended System Description Table (XSDT) */
90
91struct acpi_table_xsdt {
92 struct acpi_table_header header;
93 u64 entry[1];
94} __attribute__ ((packed));
95
96/* Fixed ACPI Description Table (FADT) */
97
98struct acpi_table_fadt {
99 struct acpi_table_header header;
100 u32 facs_addr;
101 u32 dsdt_addr;
102 /* ... */
103} __attribute__ ((packed));
104
105/* Multiple APIC Description Table (MADT) */
106
107struct acpi_table_madt {
108 struct acpi_table_header header;
109 u32 lapic_address;
110 struct {
111 u32 pcat_compat:1;
112 u32 reserved:31;
113 } flags;
114} __attribute__ ((packed));
115
116enum acpi_madt_entry_id {
117 ACPI_MADT_LAPIC = 0,
118 ACPI_MADT_IOAPIC,
119 ACPI_MADT_INT_SRC_OVR,
120 ACPI_MADT_NMI_SRC,
121 ACPI_MADT_LAPIC_NMI,
122 ACPI_MADT_LAPIC_ADDR_OVR,
123 ACPI_MADT_IOSAPIC,
124 ACPI_MADT_LSAPIC,
125 ACPI_MADT_PLAT_INT_SRC,
126 ACPI_MADT_ENTRY_COUNT
127};
128
129typedef struct {
130 u16 polarity:2;
131 u16 trigger:2;
132 u16 reserved:12;
133} __attribute__ ((packed)) acpi_interrupt_flags;
134
135struct acpi_table_lapic {
136 acpi_table_entry_header header;
137 u8 acpi_id;
138 u8 id;
139 struct {
140 u32 enabled:1;
141 u32 reserved:31;
142 } flags;
143} __attribute__ ((packed));
144
145struct acpi_table_ioapic {
146 acpi_table_entry_header header;
147 u8 id;
148 u8 reserved;
149 u32 address;
150 u32 global_irq_base;
151} __attribute__ ((packed));
152
153struct acpi_table_int_src_ovr {
154 acpi_table_entry_header header;
155 u8 bus;
156 u8 bus_irq;
157 u32 global_irq;
158 acpi_interrupt_flags flags;
159} __attribute__ ((packed));
160
161struct acpi_table_nmi_src {
162 acpi_table_entry_header header;
163 acpi_interrupt_flags flags;
164 u32 global_irq;
165} __attribute__ ((packed));
166
167struct acpi_table_lapic_nmi {
168 acpi_table_entry_header header;
169 u8 acpi_id;
170 acpi_interrupt_flags flags;
171 u8 lint;
172} __attribute__ ((packed));
173
174struct acpi_table_lapic_addr_ovr {
175 acpi_table_entry_header header;
176 u8 reserved[2];
177 u64 address;
178} __attribute__ ((packed));
179
180struct acpi_table_iosapic {
181 acpi_table_entry_header header;
182 u8 id;
183 u8 reserved;
184 u32 global_irq_base;
185 u64 address;
186} __attribute__ ((packed));
187
188struct acpi_table_lsapic {
189 acpi_table_entry_header header;
190 u8 acpi_id;
191 u8 id;
192 u8 eid;
193 u8 reserved[3];
194 struct {
195 u32 enabled:1;
196 u32 reserved:31;
197 } flags;
198} __attribute__ ((packed));
199
200struct acpi_table_plat_int_src {
201 acpi_table_entry_header header;
202 acpi_interrupt_flags flags;
203 u8 type; /* See acpi_interrupt_type */
204 u8 id;
205 u8 eid;
206 u8 iosapic_vector;
207 u32 global_irq;
55e59c51
AR
208 struct {
209 u32 cpei_override_flag:1;
210 u32 reserved:31;
211 } plint_flags;
1da177e4
LT
212} __attribute__ ((packed));
213
214enum acpi_interrupt_id {
215 ACPI_INTERRUPT_PMI = 1,
216 ACPI_INTERRUPT_INIT,
217 ACPI_INTERRUPT_CPEI,
218 ACPI_INTERRUPT_COUNT
219};
220
221#define ACPI_SPACE_MEM 0
222
223struct acpi_gen_regaddr {
224 u8 space_id;
225 u8 bit_width;
226 u8 bit_offset;
227 u8 resv;
228 u32 addrl;
229 u32 addrh;
230} __attribute__ ((packed));
231
232struct acpi_table_hpet {
233 struct acpi_table_header header;
234 u32 id;
235 struct acpi_gen_regaddr addr;
236 u8 number;
237 u16 min_tick;
238 u8 page_protect;
239} __attribute__ ((packed));
240
241/*
242 * Simple Boot Flags
243 * http://www.microsoft.com/whdc/hwdev/resources/specs/simp_bios.mspx
244 */
245struct acpi_table_sbf
246{
247 u8 sbf_signature[4];
248 u32 sbf_len;
249 u8 sbf_revision;
250 u8 sbf_csum;
251 u8 sbf_oemid[6];
252 u8 sbf_oemtable[8];
253 u8 sbf_revdata[4];
254 u8 sbf_creator[4];
255 u8 sbf_crearev[4];
256 u8 sbf_cmos;
257 u8 sbf_spare[3];
258} __attribute__ ((packed));
259
260/*
261 * System Resource Affinity Table (SRAT)
262 * http://www.microsoft.com/whdc/hwdev/platform/proc/SRAT.mspx
263 */
264
265struct acpi_table_srat {
266 struct acpi_table_header header;
267 u32 table_revision;
268 u64 reserved;
269} __attribute__ ((packed));
270
271enum acpi_srat_entry_id {
272 ACPI_SRAT_PROCESSOR_AFFINITY = 0,
273 ACPI_SRAT_MEMORY_AFFINITY,
274 ACPI_SRAT_ENTRY_COUNT
275};
276
277struct acpi_table_processor_affinity {
278 acpi_table_entry_header header;
279 u8 proximity_domain;
280 u8 apic_id;
281 struct {
282 u32 enabled:1;
283 u32 reserved:31;
284 } flags;
285 u8 lsapic_eid;
286 u8 reserved[7];
287} __attribute__ ((packed));
288
289struct acpi_table_memory_affinity {
290 acpi_table_entry_header header;
291 u8 proximity_domain;
292 u8 reserved1[5];
293 u32 base_addr_lo;
294 u32 base_addr_hi;
295 u32 length_lo;
296 u32 length_hi;
297 u32 memory_type; /* See acpi_address_range_id */
298 struct {
299 u32 enabled:1;
300 u32 hot_pluggable:1;
301 u32 reserved:30;
302 } flags;
303 u64 reserved2;
304} __attribute__ ((packed));
305
306enum acpi_address_range_id {
307 ACPI_ADDRESS_RANGE_MEMORY = 1,
308 ACPI_ADDRESS_RANGE_RESERVED = 2,
309 ACPI_ADDRESS_RANGE_ACPI = 3,
310 ACPI_ADDRESS_RANGE_NVS = 4,
311 ACPI_ADDRESS_RANGE_COUNT
312};
313
314/*
315 * System Locality Information Table (SLIT)
316 * see http://devresource.hp.com/devresource/docs/techpapers/ia64/slit.pdf
317 */
318
319struct acpi_table_slit {
320 struct acpi_table_header header;
321 u64 localities;
322 u8 entry[1]; /* real size = localities^2 */
323} __attribute__ ((packed));
324
325/* Smart Battery Description Table (SBST) */
326
327struct acpi_table_sbst {
328 struct acpi_table_header header;
329 u32 warning; /* Warn user */
330 u32 low; /* Critical sleep */
331 u32 critical; /* Critical shutdown */
332} __attribute__ ((packed));
333
334/* Embedded Controller Boot Resources Table (ECDT) */
335
336struct acpi_table_ecdt {
337 struct acpi_table_header header;
338 struct acpi_generic_address ec_control;
339 struct acpi_generic_address ec_data;
340 u32 uid;
341 u8 gpe_bit;
342 char ec_id[0];
343} __attribute__ ((packed));
344
345/* PCI MMCONFIG */
346
54549391
GKH
347/* Defined in PCI Firmware Specification 3.0 */
348struct acpi_table_mcfg_config {
349 u32 base_address;
350 u32 base_reserved;
351 u16 pci_segment_group_number;
352 u8 start_bus_number;
353 u8 end_bus_number;
354 u8 reserved[4];
355} __attribute__ ((packed));
1da177e4
LT
356struct acpi_table_mcfg {
357 struct acpi_table_header header;
358 u8 reserved[8];
54549391 359 struct acpi_table_mcfg_config config[0];
1da177e4
LT
360} __attribute__ ((packed));
361
362/* Table Handlers */
363
364enum acpi_table_id {
365 ACPI_TABLE_UNKNOWN = 0,
366 ACPI_APIC,
367 ACPI_BOOT,
368 ACPI_DBGP,
369 ACPI_DSDT,
370 ACPI_ECDT,
371 ACPI_ETDT,
372 ACPI_FADT,
373 ACPI_FACS,
374 ACPI_OEMX,
375 ACPI_PSDT,
376 ACPI_SBST,
377 ACPI_SLIT,
378 ACPI_SPCR,
379 ACPI_SRAT,
380 ACPI_SSDT,
381 ACPI_SPMI,
382 ACPI_HPET,
383 ACPI_MCFG,
384 ACPI_TABLE_COUNT
385};
386
387typedef int (*acpi_table_handler) (unsigned long phys_addr, unsigned long size);
388
389extern acpi_table_handler acpi_table_ops[ACPI_TABLE_COUNT];
390
391typedef int (*acpi_madt_entry_handler) (acpi_table_entry_header *header, const unsigned long end);
392
393char * __acpi_map_table (unsigned long phys_addr, unsigned long size);
394unsigned long acpi_find_rsdp (void);
395int acpi_boot_init (void);
396int acpi_boot_table_init (void);
397int acpi_numa_init (void);
398
399int acpi_table_init (void);
400int acpi_table_parse (enum acpi_table_id id, acpi_table_handler handler);
401int acpi_get_table_header_early (enum acpi_table_id id, struct acpi_table_header **header);
402int acpi_table_parse_madt (enum acpi_madt_entry_id id, acpi_madt_entry_handler handler, unsigned int max_entries);
403int acpi_table_parse_srat (enum acpi_srat_entry_id id, acpi_madt_entry_handler handler, unsigned int max_entries);
54549391 404int acpi_parse_mcfg (unsigned long phys_addr, unsigned long size);
1da177e4
LT
405void acpi_table_print (struct acpi_table_header *header, unsigned long phys_addr);
406void acpi_table_print_madt_entry (acpi_table_entry_header *madt);
407void acpi_table_print_srat_entry (acpi_table_entry_header *srat);
408
409/* the following four functions are architecture-dependent */
410void acpi_numa_slit_init (struct acpi_table_slit *slit);
411void acpi_numa_processor_affinity_init (struct acpi_table_processor_affinity *pa);
412void acpi_numa_memory_affinity_init (struct acpi_table_memory_affinity *ma);
413void acpi_numa_arch_fixup(void);
414
415#ifdef CONFIG_ACPI_HOTPLUG_CPU
416/* Arch dependent functions for cpu hotplug support */
417int acpi_map_lsapic(acpi_handle handle, int *pcpu);
418int acpi_unmap_lsapic(int cpu);
419#endif /* CONFIG_ACPI_HOTPLUG_CPU */
420
b1bb248a
KK
421int acpi_register_ioapic(acpi_handle handle, u64 phys_addr, u32 gsi_base);
422int acpi_unregister_ioapic(acpi_handle handle, u32 gsi_base);
423
1da177e4
LT
424extern int acpi_mp_config;
425
54549391
GKH
426extern struct acpi_table_mcfg_config *pci_mmcfg_config;
427extern int pci_mmcfg_config_num;
1da177e4 428
c255d844
PM
429extern int sbf_port;
430extern unsigned long acpi_video_flags;
1da177e4 431
888ba6c6 432#else /* !CONFIG_ACPI */
1da177e4
LT
433
434#define acpi_mp_config 0
435
888ba6c6 436#endif /* !CONFIG_ACPI */
1da177e4 437
50eca3eb 438int acpi_register_gsi (u32 gsi, int triggering, int polarity);
1da177e4
LT
439int acpi_gsi_to_irq (u32 gsi, unsigned int *irq);
440
441/*
442 * This function undoes the effect of one call to acpi_register_gsi().
443 * If this matches the last registration, any IRQ resources for gsi
444 * are freed.
445 */
1da177e4 446void acpi_unregister_gsi (u32 gsi);
1da177e4 447
6153df7b 448#ifdef CONFIG_ACPI
1da177e4
LT
449
450struct acpi_prt_entry {
451 struct list_head node;
452 struct acpi_pci_id id;
453 u8 pin;
454 struct {
455 acpi_handle handle;
456 u32 index;
457 } link;
458 u32 irq;
459};
460
461struct acpi_prt_list {
462 int count;
463 struct list_head entries;
464};
465
466struct pci_dev;
467
468int acpi_pci_irq_enable (struct pci_dev *dev);
c9c3e457 469void acpi_penalize_isa_irq(int irq, int active);
1da177e4 470
1da177e4 471void acpi_pci_irq_disable (struct pci_dev *dev);
1da177e4
LT
472
473struct acpi_pci_driver {
474 struct acpi_pci_driver *next;
475 int (*add)(acpi_handle handle);
476 void (*remove)(acpi_handle handle);
477};
478
479int acpi_pci_register_driver(struct acpi_pci_driver *driver);
480void acpi_pci_unregister_driver(struct acpi_pci_driver *driver);
481
6153df7b 482#endif /* CONFIG_ACPI */
1da177e4
LT
483
484#ifdef CONFIG_ACPI_EC
485
486extern int ec_read(u8 addr, u8 *val);
487extern int ec_write(u8 addr, u8 val);
488
489#endif /*CONFIG_ACPI_EC*/
490
1da177e4
LT
491extern int acpi_blacklisted(void);
492extern void acpi_bios_year(char *s);
493
1da177e4
LT
494#define ACPI_CSTATE_LIMIT_DEFINED /* for driver builds */
495#ifdef CONFIG_ACPI
496
497/*
498 * Set highest legal C-state
499 * 0: C0 okay, but not C1
500 * 1: C1 okay, but not C2
501 * 2: C2 okay, but not C3 etc.
502 */
503
504extern unsigned int max_cstate;
505
506static inline unsigned int acpi_get_cstate_limit(void)
507{
508 return max_cstate;
509}
510static inline void acpi_set_cstate_limit(unsigned int new_limit)
511{
512 max_cstate = new_limit;
513 return;
514}
515#else
516static inline unsigned int acpi_get_cstate_limit(void) { return 0; }
517static inline void acpi_set_cstate_limit(unsigned int new_limit) { return; }
518#endif
519
520#ifdef CONFIG_ACPI_NUMA
521int acpi_get_pxm(acpi_handle handle);
522#else
523static inline int acpi_get_pxm(acpi_handle handle)
524{
525 return 0;
526}
527#endif
528
529extern int pnpacpi_disabled;
530
53de49f5
AM
531#else /* CONFIG_ACPI */
532
533static inline int acpi_boot_init(void)
534{
535 return 0;
536}
537
538static inline int acpi_boot_table_init(void)
539{
540 return 0;
541}
542
25be5e6c
LB
543#endif /* CONFIG_ACPI */
544#endif /*_LINUX_ACPI_H*/