blob: 88b5dfd8ee125be2c3a025c7ea1e03183eaccbe4 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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
David Mosberger3f5948f2005-06-06 15:50:09 -070028
Len Brown25be5e62005-05-27 04:21:50 -040029#ifdef CONFIG_ACPI
30
Linus Torvalds1da177e2005-04-16 15:20:36 -070031#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>
Yasunori Goto762834e2006-06-23 02:03:19 -070040#include <acpi/acpi_numa.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070041#include <asm/acpi.h>
42
43
Len Brown888ba6c2005-08-24 12:07:20 -040044#ifdef CONFIG_ACPI
Linus Torvalds1da177e2005-04-16 15:20:36 -070045
46enum acpi_irq_model_id {
47 ACPI_IRQ_MODEL_PIC = 0,
48 ACPI_IRQ_MODEL_IOAPIC,
49 ACPI_IRQ_MODEL_IOSAPIC,
50 ACPI_IRQ_MODEL_COUNT
51};
52
53extern enum acpi_irq_model_id acpi_irq_model;
54
55
56/* Root System Description Pointer (RSDP) */
57
58struct acpi_table_rsdp {
59 char signature[8];
60 u8 checksum;
61 char oem_id[6];
62 u8 revision;
63 u32 rsdt_address;
64} __attribute__ ((packed));
65
66struct acpi20_table_rsdp {
67 char signature[8];
68 u8 checksum;
69 char oem_id[6];
70 u8 revision;
71 u32 rsdt_address;
72 u32 length;
73 u64 xsdt_address;
74 u8 ext_checksum;
75 u8 reserved[3];
76} __attribute__ ((packed));
77
78typedef struct {
79 u8 type;
80 u8 length;
81} __attribute__ ((packed)) acpi_table_entry_header;
82
83/* Root System Description Table (RSDT) */
84
85struct acpi_table_rsdt {
86 struct acpi_table_header header;
87 u32 entry[8];
88} __attribute__ ((packed));
89
90/* Extended System Description Table (XSDT) */
91
92struct acpi_table_xsdt {
93 struct acpi_table_header header;
94 u64 entry[1];
95} __attribute__ ((packed));
96
97/* Fixed ACPI Description Table (FADT) */
98
99struct acpi_table_fadt {
100 struct acpi_table_header header;
101 u32 facs_addr;
102 u32 dsdt_addr;
103 /* ... */
104} __attribute__ ((packed));
105
106/* Multiple APIC Description Table (MADT) */
107
108struct acpi_table_madt {
109 struct acpi_table_header header;
110 u32 lapic_address;
111 struct {
112 u32 pcat_compat:1;
113 u32 reserved:31;
114 } flags;
115} __attribute__ ((packed));
116
117enum acpi_madt_entry_id {
118 ACPI_MADT_LAPIC = 0,
119 ACPI_MADT_IOAPIC,
120 ACPI_MADT_INT_SRC_OVR,
121 ACPI_MADT_NMI_SRC,
122 ACPI_MADT_LAPIC_NMI,
123 ACPI_MADT_LAPIC_ADDR_OVR,
124 ACPI_MADT_IOSAPIC,
125 ACPI_MADT_LSAPIC,
126 ACPI_MADT_PLAT_INT_SRC,
127 ACPI_MADT_ENTRY_COUNT
128};
129
130typedef struct {
131 u16 polarity:2;
132 u16 trigger:2;
133 u16 reserved:12;
134} __attribute__ ((packed)) acpi_interrupt_flags;
135
136struct acpi_table_lapic {
137 acpi_table_entry_header header;
138 u8 acpi_id;
139 u8 id;
140 struct {
141 u32 enabled:1;
142 u32 reserved:31;
143 } flags;
144} __attribute__ ((packed));
145
146struct acpi_table_ioapic {
147 acpi_table_entry_header header;
148 u8 id;
149 u8 reserved;
150 u32 address;
151 u32 global_irq_base;
152} __attribute__ ((packed));
153
154struct acpi_table_int_src_ovr {
155 acpi_table_entry_header header;
156 u8 bus;
157 u8 bus_irq;
158 u32 global_irq;
159 acpi_interrupt_flags flags;
160} __attribute__ ((packed));
161
162struct acpi_table_nmi_src {
163 acpi_table_entry_header header;
164 acpi_interrupt_flags flags;
165 u32 global_irq;
166} __attribute__ ((packed));
167
168struct acpi_table_lapic_nmi {
169 acpi_table_entry_header header;
170 u8 acpi_id;
171 acpi_interrupt_flags flags;
172 u8 lint;
173} __attribute__ ((packed));
174
175struct acpi_table_lapic_addr_ovr {
176 acpi_table_entry_header header;
177 u8 reserved[2];
178 u64 address;
179} __attribute__ ((packed));
180
181struct acpi_table_iosapic {
182 acpi_table_entry_header header;
183 u8 id;
184 u8 reserved;
185 u32 global_irq_base;
186 u64 address;
187} __attribute__ ((packed));
188
189struct acpi_table_lsapic {
190 acpi_table_entry_header header;
191 u8 acpi_id;
192 u8 id;
193 u8 eid;
194 u8 reserved[3];
195 struct {
196 u32 enabled:1;
197 u32 reserved:31;
198 } flags;
199} __attribute__ ((packed));
200
201struct acpi_table_plat_int_src {
202 acpi_table_entry_header header;
203 acpi_interrupt_flags flags;
204 u8 type; /* See acpi_interrupt_type */
205 u8 id;
206 u8 eid;
207 u8 iosapic_vector;
208 u32 global_irq;
Ashok Raj55e59c52005-03-31 22:51:10 -0500209 struct {
210 u32 cpei_override_flag:1;
211 u32 reserved:31;
212 } plint_flags;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700213} __attribute__ ((packed));
214
215enum acpi_interrupt_id {
216 ACPI_INTERRUPT_PMI = 1,
217 ACPI_INTERRUPT_INIT,
218 ACPI_INTERRUPT_CPEI,
219 ACPI_INTERRUPT_COUNT
220};
221
222#define ACPI_SPACE_MEM 0
223
224struct acpi_gen_regaddr {
225 u8 space_id;
226 u8 bit_width;
227 u8 bit_offset;
228 u8 resv;
229 u32 addrl;
230 u32 addrh;
231} __attribute__ ((packed));
232
233struct acpi_table_hpet {
234 struct acpi_table_header header;
235 u32 id;
236 struct acpi_gen_regaddr addr;
237 u8 number;
238 u16 min_tick;
239 u8 page_protect;
240} __attribute__ ((packed));
241
242/*
243 * Simple Boot Flags
244 * http://www.microsoft.com/whdc/hwdev/resources/specs/simp_bios.mspx
245 */
246struct acpi_table_sbf
247{
248 u8 sbf_signature[4];
249 u32 sbf_len;
250 u8 sbf_revision;
251 u8 sbf_csum;
252 u8 sbf_oemid[6];
253 u8 sbf_oemtable[8];
254 u8 sbf_revdata[4];
255 u8 sbf_creator[4];
256 u8 sbf_crearev[4];
257 u8 sbf_cmos;
258 u8 sbf_spare[3];
259} __attribute__ ((packed));
260
261/*
262 * System Resource Affinity Table (SRAT)
263 * http://www.microsoft.com/whdc/hwdev/platform/proc/SRAT.mspx
264 */
265
266struct acpi_table_srat {
267 struct acpi_table_header header;
268 u32 table_revision;
269 u64 reserved;
270} __attribute__ ((packed));
271
272enum acpi_srat_entry_id {
273 ACPI_SRAT_PROCESSOR_AFFINITY = 0,
274 ACPI_SRAT_MEMORY_AFFINITY,
275 ACPI_SRAT_ENTRY_COUNT
276};
277
278struct acpi_table_processor_affinity {
279 acpi_table_entry_header header;
280 u8 proximity_domain;
281 u8 apic_id;
282 struct {
283 u32 enabled:1;
284 u32 reserved:31;
285 } flags;
286 u8 lsapic_eid;
287 u8 reserved[7];
288} __attribute__ ((packed));
289
290struct acpi_table_memory_affinity {
291 acpi_table_entry_header header;
292 u8 proximity_domain;
293 u8 reserved1[5];
294 u32 base_addr_lo;
295 u32 base_addr_hi;
296 u32 length_lo;
297 u32 length_hi;
298 u32 memory_type; /* See acpi_address_range_id */
299 struct {
300 u32 enabled:1;
301 u32 hot_pluggable:1;
302 u32 reserved:30;
303 } flags;
304 u64 reserved2;
305} __attribute__ ((packed));
306
307enum acpi_address_range_id {
308 ACPI_ADDRESS_RANGE_MEMORY = 1,
309 ACPI_ADDRESS_RANGE_RESERVED = 2,
310 ACPI_ADDRESS_RANGE_ACPI = 3,
311 ACPI_ADDRESS_RANGE_NVS = 4,
312 ACPI_ADDRESS_RANGE_COUNT
313};
314
315/*
316 * System Locality Information Table (SLIT)
317 * see http://devresource.hp.com/devresource/docs/techpapers/ia64/slit.pdf
318 */
319
320struct acpi_table_slit {
321 struct acpi_table_header header;
322 u64 localities;
323 u8 entry[1]; /* real size = localities^2 */
324} __attribute__ ((packed));
325
326/* Smart Battery Description Table (SBST) */
327
328struct acpi_table_sbst {
329 struct acpi_table_header header;
330 u32 warning; /* Warn user */
331 u32 low; /* Critical sleep */
332 u32 critical; /* Critical shutdown */
333} __attribute__ ((packed));
334
335/* Embedded Controller Boot Resources Table (ECDT) */
336
337struct acpi_table_ecdt {
338 struct acpi_table_header header;
339 struct acpi_generic_address ec_control;
340 struct acpi_generic_address ec_data;
341 u32 uid;
342 u8 gpe_bit;
343 char ec_id[0];
344} __attribute__ ((packed));
345
346/* PCI MMCONFIG */
347
Greg Kroah-Hartman54549392005-06-23 17:35:56 -0700348/* Defined in PCI Firmware Specification 3.0 */
349struct acpi_table_mcfg_config {
350 u32 base_address;
351 u32 base_reserved;
352 u16 pci_segment_group_number;
353 u8 start_bus_number;
354 u8 end_bus_number;
355 u8 reserved[4];
356} __attribute__ ((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700357struct acpi_table_mcfg {
358 struct acpi_table_header header;
359 u8 reserved[8];
Greg Kroah-Hartman54549392005-06-23 17:35:56 -0700360 struct acpi_table_mcfg_config config[0];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700361} __attribute__ ((packed));
362
363/* Table Handlers */
364
365enum acpi_table_id {
366 ACPI_TABLE_UNKNOWN = 0,
367 ACPI_APIC,
368 ACPI_BOOT,
369 ACPI_DBGP,
370 ACPI_DSDT,
371 ACPI_ECDT,
372 ACPI_ETDT,
373 ACPI_FADT,
374 ACPI_FACS,
375 ACPI_OEMX,
376 ACPI_PSDT,
377 ACPI_SBST,
378 ACPI_SLIT,
379 ACPI_SPCR,
380 ACPI_SRAT,
381 ACPI_SSDT,
382 ACPI_SPMI,
383 ACPI_HPET,
384 ACPI_MCFG,
385 ACPI_TABLE_COUNT
386};
387
388typedef int (*acpi_table_handler) (unsigned long phys_addr, unsigned long size);
389
390extern acpi_table_handler acpi_table_ops[ACPI_TABLE_COUNT];
391
392typedef int (*acpi_madt_entry_handler) (acpi_table_entry_header *header, const unsigned long end);
393
394char * __acpi_map_table (unsigned long phys_addr, unsigned long size);
395unsigned long acpi_find_rsdp (void);
396int acpi_boot_init (void);
397int acpi_boot_table_init (void);
398int acpi_numa_init (void);
399
400int acpi_table_init (void);
401int acpi_table_parse (enum acpi_table_id id, acpi_table_handler handler);
402int acpi_get_table_header_early (enum acpi_table_id id, struct acpi_table_header **header);
403int acpi_table_parse_madt (enum acpi_madt_entry_id id, acpi_madt_entry_handler handler, unsigned int max_entries);
404int acpi_table_parse_srat (enum acpi_srat_entry_id id, acpi_madt_entry_handler handler, unsigned int max_entries);
Greg Kroah-Hartman54549392005-06-23 17:35:56 -0700405int acpi_parse_mcfg (unsigned long phys_addr, unsigned long size);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700406void acpi_table_print (struct acpi_table_header *header, unsigned long phys_addr);
407void acpi_table_print_madt_entry (acpi_table_entry_header *madt);
408void acpi_table_print_srat_entry (acpi_table_entry_header *srat);
409
410/* the following four functions are architecture-dependent */
Yasunori Goto762834e2006-06-23 02:03:19 -0700411#ifdef CONFIG_HAVE_ARCH_PARSE_SRAT
412#define NR_NODE_MEMBLKS MAX_NUMNODES
413#define acpi_numa_slit_init(slit) do {} while (0)
414#define acpi_numa_processor_affinity_init(pa) do {} while (0)
415#define acpi_numa_memory_affinity_init(ma) do {} while (0)
416#define acpi_numa_arch_fixup() do {} while (0)
417#else
Linus Torvalds1da177e2005-04-16 15:20:36 -0700418void acpi_numa_slit_init (struct acpi_table_slit *slit);
419void acpi_numa_processor_affinity_init (struct acpi_table_processor_affinity *pa);
420void acpi_numa_memory_affinity_init (struct acpi_table_memory_affinity *ma);
421void acpi_numa_arch_fixup(void);
Yasunori Goto762834e2006-06-23 02:03:19 -0700422#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700423
424#ifdef CONFIG_ACPI_HOTPLUG_CPU
425/* Arch dependent functions for cpu hotplug support */
426int acpi_map_lsapic(acpi_handle handle, int *pcpu);
427int acpi_unmap_lsapic(int cpu);
428#endif /* CONFIG_ACPI_HOTPLUG_CPU */
429
Kenji Kaneshigeb1bb2482005-04-28 00:25:58 -0700430int acpi_register_ioapic(acpi_handle handle, u64 phys_addr, u32 gsi_base);
431int acpi_unregister_ioapic(acpi_handle handle, u32 gsi_base);
432
Linus Torvalds1da177e2005-04-16 15:20:36 -0700433extern int acpi_mp_config;
434
Greg Kroah-Hartman54549392005-06-23 17:35:56 -0700435extern struct acpi_table_mcfg_config *pci_mmcfg_config;
436extern int pci_mmcfg_config_num;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700437
Pavel Machekc255d842006-02-20 18:27:58 -0800438extern int sbf_port;
439extern unsigned long acpi_video_flags;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700440
Len Brown888ba6c2005-08-24 12:07:20 -0400441#else /* !CONFIG_ACPI */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700442
443#define acpi_mp_config 0
444
Len Brown888ba6c2005-08-24 12:07:20 -0400445#endif /* !CONFIG_ACPI */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700446
Bob Moore50eca3e2005-09-30 19:03:00 -0400447int acpi_register_gsi (u32 gsi, int triggering, int polarity);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700448int acpi_gsi_to_irq (u32 gsi, unsigned int *irq);
449
450/*
451 * This function undoes the effect of one call to acpi_register_gsi().
452 * If this matches the last registration, any IRQ resources for gsi
453 * are freed.
454 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700455void acpi_unregister_gsi (u32 gsi);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700456
Len Brown6153df7b2005-08-25 12:27:09 -0400457#ifdef CONFIG_ACPI
Linus Torvalds1da177e2005-04-16 15:20:36 -0700458
459struct acpi_prt_entry {
460 struct list_head node;
461 struct acpi_pci_id id;
462 u8 pin;
463 struct {
464 acpi_handle handle;
465 u32 index;
466 } link;
467 u32 irq;
468};
469
470struct acpi_prt_list {
471 int count;
472 struct list_head entries;
473};
474
475struct pci_dev;
476
477int acpi_pci_irq_enable (struct pci_dev *dev);
David Shaohua Lic9c3e452005-04-01 00:07:31 -0500478void acpi_penalize_isa_irq(int irq, int active);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700479
Linus Torvalds1da177e2005-04-16 15:20:36 -0700480void acpi_pci_irq_disable (struct pci_dev *dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700481
482struct acpi_pci_driver {
483 struct acpi_pci_driver *next;
484 int (*add)(acpi_handle handle);
485 void (*remove)(acpi_handle handle);
486};
487
488int acpi_pci_register_driver(struct acpi_pci_driver *driver);
489void acpi_pci_unregister_driver(struct acpi_pci_driver *driver);
490
Len Brown6153df7b2005-08-25 12:27:09 -0400491#endif /* CONFIG_ACPI */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700492
493#ifdef CONFIG_ACPI_EC
494
495extern int ec_read(u8 addr, u8 *val);
496extern int ec_write(u8 addr, u8 val);
497
498#endif /*CONFIG_ACPI_EC*/
499
Linus Torvalds1da177e2005-04-16 15:20:36 -0700500extern int acpi_blacklisted(void);
501extern void acpi_bios_year(char *s);
502
Linus Torvalds1da177e2005-04-16 15:20:36 -0700503#define ACPI_CSTATE_LIMIT_DEFINED /* for driver builds */
504#ifdef CONFIG_ACPI
505
506/*
507 * Set highest legal C-state
508 * 0: C0 okay, but not C1
509 * 1: C1 okay, but not C2
510 * 2: C2 okay, but not C3 etc.
511 */
512
513extern unsigned int max_cstate;
514
515static inline unsigned int acpi_get_cstate_limit(void)
516{
517 return max_cstate;
518}
519static inline void acpi_set_cstate_limit(unsigned int new_limit)
520{
521 max_cstate = new_limit;
522 return;
523}
524#else
525static inline unsigned int acpi_get_cstate_limit(void) { return 0; }
526static inline void acpi_set_cstate_limit(unsigned int new_limit) { return; }
527#endif
528
529#ifdef CONFIG_ACPI_NUMA
530int acpi_get_pxm(acpi_handle handle);
Yasunori Goto1e3590e2006-06-27 02:53:31 -0700531int acpi_get_node(acpi_handle *handle);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700532#else
533static inline int acpi_get_pxm(acpi_handle handle)
534{
535 return 0;
536}
Yasunori Goto1e3590e2006-06-27 02:53:31 -0700537static inline int acpi_get_node(acpi_handle *handle)
538{
539 return 0;
540}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700541#endif
Yasunori Goto1e3590e2006-06-27 02:53:31 -0700542extern int acpi_paddr_to_node(u64 start_addr, u64 size);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700543
544extern int pnpacpi_disabled;
545
Andrew Morton53de49f2005-07-30 04:18:00 -0400546#else /* CONFIG_ACPI */
547
548static inline int acpi_boot_init(void)
549{
550 return 0;
551}
552
553static inline int acpi_boot_table_init(void)
554{
555 return 0;
556}
557
Len Brown25be5e62005-05-27 04:21:50 -0400558#endif /* CONFIG_ACPI */
559#endif /*_LINUX_ACPI_H*/