blob: fac7a7b1f5f94ace7385d618224bf05e8d69de59 [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
Linus Torvalds1da177e2005-04-16 15:20:36 -070056typedef struct {
57 u8 type;
58 u8 length;
59} __attribute__ ((packed)) acpi_table_entry_header;
60
Linus Torvalds1da177e2005-04-16 15:20:36 -070061enum acpi_interrupt_id {
62 ACPI_INTERRUPT_PMI = 1,
63 ACPI_INTERRUPT_INIT,
64 ACPI_INTERRUPT_CPEI,
65 ACPI_INTERRUPT_COUNT
66};
67
68#define ACPI_SPACE_MEM 0
69
70struct acpi_gen_regaddr {
71 u8 space_id;
72 u8 bit_width;
73 u8 bit_offset;
74 u8 resv;
75 u32 addrl;
76 u32 addrh;
77} __attribute__ ((packed));
78
Linus Torvalds1da177e2005-04-16 15:20:36 -070079/*
80 * Simple Boot Flags
81 * http://www.microsoft.com/whdc/hwdev/resources/specs/simp_bios.mspx
82 */
83struct acpi_table_sbf
84{
85 u8 sbf_signature[4];
86 u32 sbf_len;
87 u8 sbf_revision;
88 u8 sbf_csum;
89 u8 sbf_oemid[6];
90 u8 sbf_oemtable[8];
91 u8 sbf_revdata[4];
92 u8 sbf_creator[4];
93 u8 sbf_crearev[4];
94 u8 sbf_cmos;
95 u8 sbf_spare[3];
96} __attribute__ ((packed));
97
98/*
99 * System Resource Affinity Table (SRAT)
100 * http://www.microsoft.com/whdc/hwdev/platform/proc/SRAT.mspx
101 */
102
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103enum acpi_srat_entry_id {
104 ACPI_SRAT_PROCESSOR_AFFINITY = 0,
105 ACPI_SRAT_MEMORY_AFFINITY,
106 ACPI_SRAT_ENTRY_COUNT
107};
108
109struct acpi_table_processor_affinity {
110 acpi_table_entry_header header;
111 u8 proximity_domain;
112 u8 apic_id;
113 struct {
114 u32 enabled:1;
115 u32 reserved:31;
116 } flags;
117 u8 lsapic_eid;
118 u8 reserved[7];
119} __attribute__ ((packed));
120
121struct acpi_table_memory_affinity {
122 acpi_table_entry_header header;
123 u8 proximity_domain;
124 u8 reserved1[5];
125 u32 base_addr_lo;
126 u32 base_addr_hi;
127 u32 length_lo;
128 u32 length_hi;
129 u32 memory_type; /* See acpi_address_range_id */
130 struct {
131 u32 enabled:1;
132 u32 hot_pluggable:1;
133 u32 reserved:30;
134 } flags;
135 u64 reserved2;
136} __attribute__ ((packed));
137
138enum acpi_address_range_id {
139 ACPI_ADDRESS_RANGE_MEMORY = 1,
140 ACPI_ADDRESS_RANGE_RESERVED = 2,
141 ACPI_ADDRESS_RANGE_ACPI = 3,
142 ACPI_ADDRESS_RANGE_NVS = 4,
143 ACPI_ADDRESS_RANGE_COUNT
144};
145
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146
147/* PCI MMCONFIG */
148
Greg Kroah-Hartman54549392005-06-23 17:35:56 -0700149/* Defined in PCI Firmware Specification 3.0 */
150struct acpi_table_mcfg_config {
151 u32 base_address;
152 u32 base_reserved;
153 u16 pci_segment_group_number;
154 u8 start_bus_number;
155 u8 end_bus_number;
156 u8 reserved[4];
157} __attribute__ ((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700158
159/* Table Handlers */
160
161enum acpi_table_id {
162 ACPI_TABLE_UNKNOWN = 0,
163 ACPI_APIC,
164 ACPI_BOOT,
165 ACPI_DBGP,
166 ACPI_DSDT,
167 ACPI_ECDT,
168 ACPI_ETDT,
169 ACPI_FADT,
170 ACPI_FACS,
171 ACPI_OEMX,
172 ACPI_PSDT,
173 ACPI_SBST,
174 ACPI_SLIT,
175 ACPI_SPCR,
176 ACPI_SRAT,
177 ACPI_SSDT,
178 ACPI_SPMI,
179 ACPI_HPET,
180 ACPI_MCFG,
181 ACPI_TABLE_COUNT
182};
183
Alexey Starikovskiyceb6c462007-02-02 19:48:22 +0300184typedef int (*acpi_table_handler) (struct acpi_table_header *header);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700185
186extern acpi_table_handler acpi_table_ops[ACPI_TABLE_COUNT];
187
Alexey Starikovskiy5f3b1a82007-02-02 19:48:22 +0300188typedef int (*acpi_madt_entry_handler) (struct acpi_subtable_header *header, const unsigned long end);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700189
190char * __acpi_map_table (unsigned long phys_addr, unsigned long size);
191unsigned long acpi_find_rsdp (void);
192int acpi_boot_init (void);
193int acpi_boot_table_init (void);
194int acpi_numa_init (void);
195
196int acpi_table_init (void);
Alexey Starikovskiyceb6c462007-02-02 19:48:22 +0300197int acpi_table_parse (char *id, acpi_table_handler handler);
Alexey Starikovskiy5f3b1a82007-02-02 19:48:22 +0300198int acpi_table_parse_madt (enum acpi_madt_type id, acpi_madt_entry_handler handler, unsigned int max_entries);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700199int acpi_table_parse_srat (enum acpi_srat_entry_id id, acpi_madt_entry_handler handler, unsigned int max_entries);
Alexey Starikovskiyceb6c462007-02-02 19:48:22 +0300200int acpi_parse_mcfg (struct acpi_table_header *header);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700201void acpi_table_print (struct acpi_table_header *header, unsigned long phys_addr);
Alexey Starikovskiy5f3b1a82007-02-02 19:48:22 +0300202void acpi_table_print_madt_entry (struct acpi_subtable_header *madt);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700203void acpi_table_print_srat_entry (acpi_table_entry_header *srat);
204
205/* the following four functions are architecture-dependent */
Yasunori Goto762834e2006-06-23 02:03:19 -0700206#ifdef CONFIG_HAVE_ARCH_PARSE_SRAT
207#define NR_NODE_MEMBLKS MAX_NUMNODES
208#define acpi_numa_slit_init(slit) do {} while (0)
209#define acpi_numa_processor_affinity_init(pa) do {} while (0)
210#define acpi_numa_memory_affinity_init(ma) do {} while (0)
211#define acpi_numa_arch_fixup() do {} while (0)
212#else
Linus Torvalds1da177e2005-04-16 15:20:36 -0700213void acpi_numa_slit_init (struct acpi_table_slit *slit);
214void acpi_numa_processor_affinity_init (struct acpi_table_processor_affinity *pa);
215void acpi_numa_memory_affinity_init (struct acpi_table_memory_affinity *ma);
216void acpi_numa_arch_fixup(void);
Yasunori Goto762834e2006-06-23 02:03:19 -0700217#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700218
219#ifdef CONFIG_ACPI_HOTPLUG_CPU
220/* Arch dependent functions for cpu hotplug support */
221int acpi_map_lsapic(acpi_handle handle, int *pcpu);
222int acpi_unmap_lsapic(int cpu);
223#endif /* CONFIG_ACPI_HOTPLUG_CPU */
224
Kenji Kaneshigeb1bb2482005-04-28 00:25:58 -0700225int acpi_register_ioapic(acpi_handle handle, u64 phys_addr, u32 gsi_base);
226int acpi_unregister_ioapic(acpi_handle handle, u32 gsi_base);
227
Linus Torvalds1da177e2005-04-16 15:20:36 -0700228extern int acpi_mp_config;
229
Greg Kroah-Hartman54549392005-06-23 17:35:56 -0700230extern struct acpi_table_mcfg_config *pci_mmcfg_config;
231extern int pci_mmcfg_config_num;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700232
Pavel Machekc255d842006-02-20 18:27:58 -0800233extern int sbf_port;
234extern unsigned long acpi_video_flags;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700235
Len Brown888ba6c2005-08-24 12:07:20 -0400236#else /* !CONFIG_ACPI */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700237
238#define acpi_mp_config 0
239
Len Brown888ba6c2005-08-24 12:07:20 -0400240#endif /* !CONFIG_ACPI */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700241
Bob Moore50eca3e2005-09-30 19:03:00 -0400242int acpi_register_gsi (u32 gsi, int triggering, int polarity);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700243int acpi_gsi_to_irq (u32 gsi, unsigned int *irq);
244
245/*
246 * This function undoes the effect of one call to acpi_register_gsi().
247 * If this matches the last registration, any IRQ resources for gsi
248 * are freed.
249 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700250void acpi_unregister_gsi (u32 gsi);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700251
Len Brown6153df7b2005-08-25 12:27:09 -0400252#ifdef CONFIG_ACPI
Linus Torvalds1da177e2005-04-16 15:20:36 -0700253
254struct acpi_prt_entry {
255 struct list_head node;
256 struct acpi_pci_id id;
257 u8 pin;
258 struct {
259 acpi_handle handle;
260 u32 index;
261 } link;
262 u32 irq;
263};
264
265struct acpi_prt_list {
266 int count;
267 struct list_head entries;
268};
269
270struct pci_dev;
271
272int acpi_pci_irq_enable (struct pci_dev *dev);
David Shaohua Lic9c3e452005-04-01 00:07:31 -0500273void acpi_penalize_isa_irq(int irq, int active);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700274
Linus Torvalds1da177e2005-04-16 15:20:36 -0700275void acpi_pci_irq_disable (struct pci_dev *dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700276
277struct acpi_pci_driver {
278 struct acpi_pci_driver *next;
279 int (*add)(acpi_handle handle);
280 void (*remove)(acpi_handle handle);
281};
282
283int acpi_pci_register_driver(struct acpi_pci_driver *driver);
284void acpi_pci_unregister_driver(struct acpi_pci_driver *driver);
285
Len Brown6153df7b2005-08-25 12:27:09 -0400286#endif /* CONFIG_ACPI */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700287
288#ifdef CONFIG_ACPI_EC
289
290extern int ec_read(u8 addr, u8 *val);
291extern int ec_write(u8 addr, u8 val);
Lennart Poetteringd7a76e42006-09-05 12:12:24 -0400292extern int ec_transaction(u8 command,
293 const u8 *wdata, unsigned wdata_len,
294 u8 *rdata, unsigned rdata_len);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700295
296#endif /*CONFIG_ACPI_EC*/
297
Linus Torvalds1da177e2005-04-16 15:20:36 -0700298extern int acpi_blacklisted(void);
299extern void acpi_bios_year(char *s);
300
Linus Torvalds1da177e2005-04-16 15:20:36 -0700301#define ACPI_CSTATE_LIMIT_DEFINED /* for driver builds */
302#ifdef CONFIG_ACPI
303
304/*
305 * Set highest legal C-state
306 * 0: C0 okay, but not C1
307 * 1: C1 okay, but not C2
308 * 2: C2 okay, but not C3 etc.
309 */
310
311extern unsigned int max_cstate;
312
313static inline unsigned int acpi_get_cstate_limit(void)
314{
315 return max_cstate;
316}
317static inline void acpi_set_cstate_limit(unsigned int new_limit)
318{
319 max_cstate = new_limit;
320 return;
321}
322#else
323static inline unsigned int acpi_get_cstate_limit(void) { return 0; }
324static inline void acpi_set_cstate_limit(unsigned int new_limit) { return; }
325#endif
326
327#ifdef CONFIG_ACPI_NUMA
328int acpi_get_pxm(acpi_handle handle);
Yasunori Goto1e3590e2006-06-27 02:53:31 -0700329int acpi_get_node(acpi_handle *handle);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700330#else
331static inline int acpi_get_pxm(acpi_handle handle)
332{
333 return 0;
334}
Yasunori Goto1e3590e2006-06-27 02:53:31 -0700335static inline int acpi_get_node(acpi_handle *handle)
336{
337 return 0;
338}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700339#endif
Yasunori Goto1e3590e2006-06-27 02:53:31 -0700340extern int acpi_paddr_to_node(u64 start_addr, u64 size);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700341
342extern int pnpacpi_disabled;
343
Andrew Morton53de49f2005-07-30 04:18:00 -0400344#else /* CONFIG_ACPI */
345
346static inline int acpi_boot_init(void)
347{
348 return 0;
349}
350
351static inline int acpi_boot_table_init(void)
352{
353 return 0;
354}
355
Len Brown25be5e62005-05-27 04:21:50 -0400356#endif /* CONFIG_ACPI */
357#endif /*_LINUX_ACPI_H*/