source: svn/trunk/newcon3bcm2_21bu/toolchain/mipsel-linux-uclibc/include/linux/acpi.h @ 48

Last change on this file since 48 was 2, checked in by jglee, 11 years ago

first commit

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