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