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