2 * acpi.c - Linux ACPI driver
4 * Copyright (C) 1999-2000 Andrew Henroid
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * See http://www.geocities.com/SiliconValley/Hardware/3165/
23 * for the user-level ACPI stuff
26 #include <linux/config.h>
27 #include <linux/module.h>
28 #include <linux/init.h>
29 #include <linux/string.h>
30 #include <linux/miscdevice.h>
31 #include <linux/sched.h>
32 #include <linux/time.h>
33 #include <linux/wait.h>
34 #include <linux/spinlock.h>
35 #include <linux/ioport.h>
36 #include <linux/slab.h>
38 #include <linux/pci.h>
39 #include <asm/uaccess.h>
41 #include <linux/sysctl.h>
42 #include <linux/delay.h>
44 #include <linux/acpi.h>
47 * Yes, it's unfortunate that we are relying on get_cmos_time
48 * because it is slow (> 1 sec.) and i386 only. It might be better
49 * to use some of the code from drivers/char/rtc.c in the near future
51 extern unsigned long get_cmos_time(void);
53 static int acpi_do_ulong(ctl_table
*ctl
,
58 static int acpi_do_table(ctl_table
*ctl
,
63 static int acpi_do_event_reg(ctl_table
*ctl
,
68 static int acpi_do_event(ctl_table
*ctl
,
73 static int acpi_do_sleep(ctl_table
*ctl
,
79 static struct ctl_table_header
*acpi_sysctl
= NULL
;
81 // current system sleep state (S0 - S4)
82 static acpi_sstate_t acpi_sleep_state
= ACPI_S0
;
84 static unsigned long acpi_sleep_start
= 0;
86 static spinlock_t acpi_event_lock
= SPIN_LOCK_UNLOCKED
;
87 static volatile u32 acpi_pm1_status
= 0;
88 static volatile u32 acpi_gpe_status
= 0;
89 static volatile u32 acpi_gpe_level
= 0;
90 static volatile acpi_sstate_t acpi_event_state
= ACPI_S0
;
91 static DECLARE_WAIT_QUEUE_HEAD(acpi_event_wait
);
93 /* Make it impossible to enter C2/C3 until after we've initialized */
94 static unsigned long acpi_enter_lvl2_lat
= ACPI_INFINITE_LAT
;
95 static unsigned long acpi_enter_lvl3_lat
= ACPI_INFINITE_LAT
;
96 static unsigned long acpi_p_lvl2_lat
= ACPI_INFINITE_LAT
;
97 static unsigned long acpi_p_lvl3_lat
= ACPI_INFINITE_LAT
;
99 static unsigned long acpi_p_blk
= 0;
101 static int acpi_p_lvl2_tested
= 0;
102 static int acpi_p_lvl3_tested
= 0;
106 ACPI_ENABLED
= 0x00000000, // use ACPI if present
107 ACPI_DISABLED
= 0x00000001, // never use ACPI
108 ACPI_TABLES_ONLY
= 0x00000002, // never use chipset-specific driver
109 ACPI_CHIPSET_ONLY
= 0x00000004, // always use chipset-specific driver
110 ACPI_IGNORE_ERRATA
= 0x00000008, // ignore any listed platform errata
111 ACPI_COPY_TABLES
= 0x00000010, // copy ACPI tables before use
112 ACPI_TRUST_TABLES
= 0x00000020, // use tables even after ioremap fails
113 ACPI_SCI_DISABLED
= 0x00000040, // never enable ACPI (info. only)
114 ACPI_C2_DISABLED
= 0x00000080, // never enter C2
115 ACPI_C3_DISABLED
= 0x00000100, // never enter C3
116 ACPI_S1_DISABLED
= 0x00000200, // never enter S1
117 ACPI_S5_DISABLED
= 0x00000400, // never enter S5
120 struct acpi_option_info
126 static struct acpi_option_info acpi_options
[] =
128 {"on", ACPI_ENABLED
},
129 {"off", ACPI_DISABLED
},
130 {"tables", ACPI_TABLES_ONLY
},
131 {"chipset", ACPI_CHIPSET_ONLY
},
132 {"no-errata", ACPI_IGNORE_ERRATA
},
133 {"copy-tables", ACPI_COPY_TABLES
},
134 {"trust-tables", ACPI_TRUST_TABLES
},
135 {"no-sci", ACPI_SCI_DISABLED
},
136 {"no-c2", ACPI_C2_DISABLED
},
137 {"no-c3", ACPI_C3_DISABLED
},
138 {"no-s1", ACPI_S1_DISABLED
},
139 {"no-s5", ACPI_S5_DISABLED
},
143 static unsigned long acpi_opts
= ACPI_ENABLED
;
145 struct acpi_errata_info
147 const char *signature
; // table signature (eg. "RSDT")
148 const char *oem
; // OEM name
149 const char *oem_table
; // OEM table identifier (optional)
150 u32 oem_rev
; // OEM table revision (optional)
151 unsigned long options
; // errata options
155 * We must identify systems that need ACPI_TRUST_TABLES solely from the
156 * RSDP ("RSD PTR "). All other options should be flagged from the
157 * RSDT ("RSDT") which can be better identified.
159 struct acpi_errata_info acpi_errata
[] =
161 {"RSD PTR ", "AMI ", NULL
, 0, ACPI_TRUST_TABLES
| ACPI_COPY_TABLES
},
165 // bits 8-15 are SLP_TYPa, bits 0-7 are SLP_TYPb
166 static unsigned long acpi_slp_typ
[] =
168 ACPI_SLP_TYP_DISABLED
, /* S0 */
169 ACPI_SLP_TYP_DISABLED
, /* S1 */
170 ACPI_SLP_TYP_DISABLED
, /* S2 */
171 ACPI_SLP_TYP_DISABLED
, /* S3 */
172 ACPI_SLP_TYP_DISABLED
, /* S4 */
173 ACPI_SLP_TYP_DISABLED
/* S5 */
176 struct acpi_table_info
178 u32 expected_signature
;
181 struct acpi_table
*table
;
186 static struct acpi_table_info acpi_facp
187 = {ACPI_FACP_SIG
, sizeof(struct acpi_facp
), NULL
, 0, 0};
188 static struct acpi_table_info acpi_dsdt
= {ACPI_DSDT_SIG
, 0, NULL
, 0, 0};
189 static struct acpi_table_info acpi_facs
190 = {ACPI_FACS_SIG
, sizeof(struct acpi_facs
), NULL
, 0, 0};
191 static rwlock_t acpi_do_table_lock
= RW_LOCK_UNLOCKED
;
193 static struct ctl_table acpi_table
[] =
195 {ACPI_FACP
, "facp", &acpi_facp
, 0, 0644, NULL
, &acpi_do_table
},
197 {ACPI_DSDT
, "dsdt", &acpi_dsdt
, 0, 0644, NULL
, &acpi_do_table
},
199 {ACPI_PM1_ENABLE
, "pm1_enable",
201 0600, NULL
, &acpi_do_event_reg
},
203 {ACPI_GPE_ENABLE
, "gpe_enable",
205 0600, NULL
, &acpi_do_event_reg
},
207 {ACPI_GPE_LEVEL
, "gpe_level",
209 0600, NULL
, &acpi_do_event_reg
},
211 {ACPI_EVENT
, "event", NULL
, 0, 0400, NULL
, &acpi_do_event
},
213 {ACPI_P_BLK
, "p_blk",
214 &acpi_p_blk
, sizeof(acpi_p_blk
),
215 0600, NULL
, &acpi_do_ulong
},
217 {ACPI_P_LVL2_LAT
, "p_lvl2_lat",
218 &acpi_p_lvl2_lat
, sizeof(acpi_p_lvl2_lat
),
219 0644, NULL
, &acpi_do_ulong
},
221 {ACPI_P_LVL3_LAT
, "p_lvl3_lat",
222 &acpi_p_lvl3_lat
, sizeof(acpi_p_lvl3_lat
),
223 0644, NULL
, &acpi_do_ulong
},
225 {ACPI_ENTER_LVL2_LAT
, "enter_lvl2_lat",
226 &acpi_enter_lvl2_lat
, sizeof(acpi_enter_lvl2_lat
),
227 0644, NULL
, &acpi_do_ulong
},
229 {ACPI_ENTER_LVL3_LAT
, "enter_lvl3_lat",
230 &acpi_enter_lvl3_lat
, sizeof(acpi_enter_lvl3_lat
),
231 0644, NULL
, &acpi_do_ulong
},
233 {ACPI_S0_SLP_TYP
, "s0_slp_typ",
234 &acpi_slp_typ
[ACPI_S0
], sizeof(acpi_slp_typ
[ACPI_S0
]),
235 0600, NULL
, &acpi_do_ulong
},
237 {ACPI_S1_SLP_TYP
, "s1_slp_typ",
238 &acpi_slp_typ
[ACPI_S1
], sizeof(acpi_slp_typ
[ACPI_S1
]),
239 0600, NULL
, &acpi_do_ulong
},
241 {ACPI_S5_SLP_TYP
, "s5_slp_typ",
242 &acpi_slp_typ
[ACPI_S5
], sizeof(acpi_slp_typ
[ACPI_S5
]),
243 0600, NULL
, &acpi_do_ulong
},
245 {ACPI_SLEEP
, "sleep", NULL
, 0, 0600, NULL
, &acpi_do_sleep
},
250 static struct ctl_table acpi_dir_table
[] =
252 {CTL_ACPI
, "acpi", NULL
, 0, 0555, acpi_table
},
256 static u32
FASTCALL(acpi_read_pm1_control(struct acpi_facp
*));
257 static u32
FASTCALL(acpi_read_pm1_status(struct acpi_facp
*));
258 static u32
FASTCALL(acpi_read_pm1_enable(struct acpi_facp
*));
259 static u32
FASTCALL(acpi_read_gpe_status(struct acpi_facp
*));
260 static u32
FASTCALL(acpi_read_gpe_enable(struct acpi_facp
*));
262 static void FASTCALL(acpi_write_pm1_control(struct acpi_facp
*, u32
));
263 static void FASTCALL(acpi_write_pm1_status(struct acpi_facp
*, u32
));
264 static void FASTCALL(acpi_write_pm1_enable(struct acpi_facp
*, u32
));
265 static void FASTCALL(acpi_write_gpe_status(struct acpi_facp
*, u32
));
266 static void FASTCALL(acpi_write_gpe_enable(struct acpi_facp
*, u32
));
269 * Get the value of the PM1 control register (SCI_EN, ...)
271 static u32
acpi_read_pm1_control(struct acpi_facp
*facp
)
275 value
= inw(facp
->pm1a_cnt
);
277 value
|= inw(facp
->pm1b_cnt
);
282 * Set the value of the PM1 control register (BM_RLD, ...)
284 static void acpi_write_pm1_control(struct acpi_facp
*facp
, u32 value
)
287 outw(value
, facp
->pm1a_cnt
);
289 outw(value
, facp
->pm1b_cnt
);
293 * Get the value of the fixed event status register
295 static u32
acpi_read_pm1_status(struct acpi_facp
*facp
)
299 value
= inw(facp
->pm1a_evt
);
301 value
|= inw(facp
->pm1b_evt
);
306 * Set the value of the fixed event status register (clear events)
308 static void acpi_write_pm1_status(struct acpi_facp
*facp
, u32 value
)
311 outw(value
, facp
->pm1a_evt
);
313 outw(value
, facp
->pm1b_evt
);
317 * Get the value of the fixed event enable register
319 static u32
acpi_read_pm1_enable(struct acpi_facp
*facp
)
321 int offset
= facp
->pm1_evt_len
>> 1;
324 value
= inw(facp
->pm1a_evt
+ offset
);
326 value
|= inw(facp
->pm1b_evt
+ offset
);
331 * Set the value of the fixed event enable register (enable events)
333 static void acpi_write_pm1_enable(struct acpi_facp
*facp
, u32 value
)
335 int offset
= facp
->pm1_evt_len
>> 1;
337 outw(value
, facp
->pm1a_evt
+ offset
);
339 outw(value
, facp
->pm1b_evt
+ offset
);
343 * Get the value of the general-purpose event status register
345 static u32
acpi_read_gpe_status(struct acpi_facp
*facp
)
351 size
= facp
->gpe1_len
>> 1;
352 for (i
= size
- 1; i
>= 0; i
--)
353 value
= (value
<< 8) | inb(facp
->gpe1
+ i
);
356 size
= facp
->gpe0_len
>> 1;
357 for (i
= size
- 1; i
>= 0; i
--)
358 value
= (value
<< 8) | inb(facp
->gpe0
+ i
);
364 * Set the value of the general-purpose event status register (clear events)
366 static void acpi_write_gpe_status(struct acpi_facp
*facp
, u32 value
)
371 size
= facp
->gpe0_len
>> 1;
372 for (i
= 0; i
< size
; i
++) {
373 outb(value
& 0xff, facp
->gpe0
+ i
);
378 size
= facp
->gpe1_len
>> 1;
379 for (i
= 0; i
< size
; i
++) {
380 outb(value
& 0xff, facp
->gpe1
+ i
);
387 * Get the value of the general-purpose event enable register
389 static u32
acpi_read_gpe_enable(struct acpi_facp
*facp
)
394 offset
= facp
->gpe0_len
>> 1;
396 size
= facp
->gpe1_len
>> 1;
397 for (i
= size
- 1; i
>= 0; i
--) {
398 value
= (value
<< 8) | inb(facp
->gpe1
+ offset
+ i
);
402 size
= facp
->gpe0_len
>> 1;
403 for (i
= size
- 1; i
>= 0; i
--)
404 value
= (value
<< 8) | inb(facp
->gpe0
+ offset
+ i
);
410 * Set the value of the general-purpose event enable register (enable events)
412 static void acpi_write_gpe_enable(struct acpi_facp
*facp
, u32 value
)
416 offset
= facp
->gpe0_len
>> 1;
418 for (i
= 0; i
< offset
; i
++) {
419 outb(value
& 0xff, facp
->gpe0
+ offset
+ i
);
424 offset
= facp
->gpe1_len
>> 1;
425 for (i
= 0; i
< offset
; i
++) {
426 outb(value
& 0xff, facp
->gpe1
+ offset
+ i
);
433 * Map an ACPI table into virtual memory
435 static struct acpi_table
*__init
acpi_map_table(u32 addr
)
437 struct acpi_table
*table
= NULL
;
439 // map table header to determine size
440 table
= (struct acpi_table
*)
441 ioremap((unsigned long) addr
,
442 sizeof(struct acpi_table
));
444 unsigned long table_size
= table
->length
;
446 // remap entire table
447 table
= (struct acpi_table
*)
448 ioremap((unsigned long) addr
, table_size
);
451 if (!table
&& addr
< virt_to_phys(high_memory
)) {
452 /* sometimes we see ACPI tables in low memory
453 * and not reserved by the memory map (E820) code,
454 * who is at fault for this? BIOS?
457 "ACPI: unreserved table memory @ 0x%p!\n",
460 if (acpi_opts
& ACPI_TRUST_TABLES
) {
461 /* OK, trust that the table is there
462 * if it isn't you'll get an OOPS here
465 table
= (struct acpi_table
*)
467 sig
= table
->signature
;
475 * Unmap an ACPI table from virtual memory
477 static void acpi_unmap_table(struct acpi_table
*table
)
479 // iounmap ignores addresses within physical memory
485 * Initialize an ACPI table
487 static int acpi_init_table(struct acpi_table_info
*info
,
491 struct acpi_table
*table
= (struct acpi_table
*) data
;
497 if (!table
|| table
->signature
!= info
->expected_signature
)
500 if (mapped
&& (acpi_opts
& ACPI_COPY_TABLES
)) {
501 struct acpi_table
*copy
502 = kmalloc(table
->length
, GFP_KERNEL
);
505 memcpy(copy
, table
, table
->length
);
511 info
->size
= (size_t) table
->length
;
512 info
->mapped
= mapped
;
517 * Destroy an ACPI table
519 static void acpi_destroy_table(struct acpi_table_info
*info
)
523 acpi_unmap_table(info
->table
);
531 * Match ACPI table and set options based on platform errata, if any
533 static int __init
acpi_find_errata(struct acpi_table
*table
)
535 struct acpi_errata_info
*info
;
538 for (info
= acpi_errata
; info
->signature
&& info
->oem
; info
++) {
539 size
= strlen(info
->signature
);
540 if (memcmp(&table
->signature
, info
->signature
, size
))
542 if (strcmp(info
->signature
, "RSD PTR ")) {
543 // ordinary ACPI table
544 size
= strlen(info
->oem
);
545 if (memcmp(table
->oem
, info
->oem
, size
))
547 if (info
->oem_table
) {
548 size
= strlen(info
->oem_table
);
549 if (memcmp(table
->oem_table
,
554 if (info
->oem_rev
&& table
->oem_rev
!= info
->oem_rev
)
558 // special handling for RSDP
559 size
= strlen(info
->oem
);
560 if (memcmp(((struct acpi_rsdp
*) table
)->oem
,
567 "ACPI: found platform errata 0x%08lx\n",
569 acpi_opts
|= info
->options
;
576 * Locate and map ACPI tables
578 static int __init
acpi_find_tables(void)
580 struct acpi_rsdp
*rsdp
;
581 struct acpi_table
*rsdt
;
583 int rsdt_entry_count
;
586 // search BIOS memory for RSDP
587 for (i
= ACPI_BIOS_ROM_BASE
; i
< ACPI_BIOS_ROM_END
; i
+= 16) {
588 rsdp
= (struct acpi_rsdp
*) phys_to_virt(i
);
589 if (rsdp
->signature
[0] == ACPI_RSDP1_SIG
590 && rsdp
->signature
[1] == ACPI_RSDP2_SIG
) {
594 // strip trailing space and print OEM identifier
595 memcpy(oem
, rsdp
->oem
, 6);
598 j
> 0 && (oem
[j
] == '\0' || oem
[j
] == ' ');
602 printk(KERN_INFO
"ACPI: \"%s\" found at 0x%p\n",
608 if (i
>= ACPI_BIOS_ROM_END
)
611 // find any errata based on the RSDP
612 if (!acpi_find_errata((struct acpi_table
*) rsdp
)) {
613 if (acpi_opts
& ACPI_DISABLED
)
615 else if (acpi_opts
& ACPI_CHIPSET_ONLY
)
619 // fetch RSDT from RSDP
620 rsdt
= acpi_map_table(rsdp
->rsdt
);
622 printk(KERN_ERR
"ACPI: missing RSDT at 0x%p\n",
626 else if (rsdt
->signature
!= ACPI_RSDT_SIG
) {
627 printk(KERN_ERR
"ACPI: bad RSDT at 0x%p (%08x)\n",
628 (void*) rsdp
->rsdt
, (unsigned) rsdt
->signature
);
629 acpi_unmap_table(rsdt
);
633 // find any errata based on the RSDT
634 if (!acpi_find_errata(rsdt
)) {
635 if (acpi_opts
& ACPI_DISABLED
)
637 else if (acpi_opts
& ACPI_CHIPSET_ONLY
)
641 // search RSDT for FACP
642 acpi_facp
.table
= NULL
;
643 rsdt_entry
= (u32
*) (rsdt
+ 1);
644 rsdt_entry_count
= (int) ((rsdt
->length
- sizeof(*rsdt
)) >> 2);
645 while (rsdt_entry_count
) {
646 struct acpi_table
*dt
= acpi_map_table(*rsdt_entry
);
647 if (!acpi_init_table(&acpi_facp
, dt
, 1)) {
648 struct acpi_facp
*facp
649 = (struct acpi_facp
*) acpi_facp
.table
;
651 // map DSDT if it exists
652 dt
= acpi_map_table(facp
->dsdt
);
653 if (acpi_init_table(&acpi_dsdt
, dt
, 1))
654 acpi_unmap_table(dt
);
659 acpi_unmap_table(dt
);
666 acpi_unmap_table(rsdt
);
668 if (!acpi_facp
.table
) {
669 printk(KERN_ERR
"ACPI: missing FACP\n");
676 * Unmap or destroy ACPI tables
678 static void acpi_destroy_tables(void)
680 acpi_destroy_table(&acpi_facs
);
681 acpi_destroy_table(&acpi_dsdt
);
682 acpi_destroy_table(&acpi_facp
);
686 * Init PIIX4 device, create a fake FACP
688 static int __init
acpi_init_piix4(struct pci_dev
*dev
)
690 struct acpi_facp
*facp
;
695 pci_read_config_word(dev
, PCI_COMMAND
, &cmd
);
696 if (!(cmd
& PCI_COMMAND_IO
))
699 pci_read_config_byte(dev
, ACPI_PIIX4_PMREGMISC
, &pmregmisc
);
700 if (!(pmregmisc
& ACPI_PIIX4_PMIOSE
))
703 base
= dev
->resource
[PCI_BRIDGE_RESOURCES
].start
& PCI_BASE_ADDRESS_IO_MASK
;
707 printk(KERN_INFO
"ACPI: found PIIX4 at 0x%04x\n", base
);
709 facp
= kmalloc(sizeof(struct acpi_facp
), GFP_KERNEL
);
713 memset(facp
, 0, sizeof(struct acpi_facp
));
714 facp
->hdr
.signature
= ACPI_FACP_SIG
;
715 facp
->hdr
.length
= sizeof(struct acpi_facp
);
716 facp
->int_model
= ACPI_PIIX4_INT_MODEL
;
717 facp
->sci_int
= ACPI_PIIX4_SCI_INT
;
718 facp
->smi_cmd
= ACPI_PIIX4_SMI_CMD
;
719 facp
->acpi_enable
= ACPI_PIIX4_ACPI_ENABLE
;
720 facp
->acpi_disable
= ACPI_PIIX4_ACPI_DISABLE
;
721 facp
->s4bios_req
= ACPI_PIIX4_S4BIOS_REQ
;
722 facp
->pm1a_evt
= base
+ ACPI_PIIX4_PM1_EVT
;
723 facp
->pm1a_cnt
= base
+ ACPI_PIIX4_PM1_CNT
;
724 facp
->pm2_cnt
= ACPI_PIIX4_PM2_CNT
;
725 facp
->pm_tmr
= base
+ ACPI_PIIX4_PM_TMR
;
726 facp
->gpe0
= base
+ ACPI_PIIX4_GPE0
;
727 facp
->pm1_evt_len
= ACPI_PIIX4_PM1_EVT_LEN
;
728 facp
->pm1_cnt_len
= ACPI_PIIX4_PM1_CNT_LEN
;
729 facp
->pm2_cnt_len
= ACPI_PIIX4_PM2_CNT_LEN
;
730 facp
->pm_tm_len
= ACPI_PIIX4_PM_TM_LEN
;
731 facp
->gpe0_len
= ACPI_PIIX4_GPE0_LEN
;
732 facp
->p_lvl2_lat
= (__u16
) ACPI_INFINITE_LAT
;
733 facp
->p_lvl3_lat
= (__u16
) ACPI_INFINITE_LAT
;
735 acpi_init_table(&acpi_facp
, facp
, 0);
736 acpi_init_table(&acpi_dsdt
, NULL
, 0);
738 acpi_p_blk
= base
+ ACPI_PIIX4_P_BLK
;
744 * Init VIA ACPI device and create a fake FACP
746 static int __init
acpi_init_via(struct pci_dev
*dev
)
748 struct acpi_facp
*facp
;
752 pci_read_config_byte(dev
, 0x41, &tmp
);
756 base
= pci_resource_start(dev
, PCI_BRIDGE_RESOURCES
);
758 base
= pci_resource_start(dev
, PCI_BASE_ADDRESS_4
);
762 base
&= PCI_BASE_ADDRESS_IO_MASK
;
764 pci_read_config_byte(dev
, 0x42, &irq
);
766 printk(KERN_INFO
"ACPI: found %s at 0x%04x\n", dev
->name
, base
);
768 facp
= kmalloc(sizeof(struct acpi_facp
), GFP_KERNEL
);
772 memset(facp
, 0, sizeof(struct acpi_facp
));
773 facp
->hdr
.signature
= ACPI_FACP_SIG
;
774 facp
->hdr
.length
= sizeof(struct acpi_facp
);
775 facp
->int_model
= ACPI_VIA_INT_MODEL
;
777 facp
->smi_cmd
= base
+ ACPI_VIA_SMI_CMD
;
778 facp
->acpi_enable
= ACPI_VIA_ACPI_ENABLE
;
779 facp
->acpi_disable
= ACPI_VIA_ACPI_DISABLE
;
780 facp
->pm1a_evt
= base
+ ACPI_VIA_PM1_EVT
;
781 facp
->pm1a_cnt
= base
+ ACPI_VIA_PM1_CNT
;
782 facp
->pm_tmr
= base
+ ACPI_VIA_PM_TMR
;
783 facp
->gpe0
= base
+ ACPI_VIA_GPE0
;
785 facp
->pm1_evt_len
= ACPI_VIA_PM1_EVT_LEN
;
786 facp
->pm1_cnt_len
= ACPI_VIA_PM1_CNT_LEN
;
787 facp
->pm_tm_len
= ACPI_VIA_PM_TM_LEN
;
788 facp
->gpe0_len
= ACPI_VIA_GPE0_LEN
;
789 facp
->p_lvl2_lat
= (__u16
) ACPI_INFINITE_LAT
;
790 facp
->p_lvl3_lat
= (__u16
) ACPI_INFINITE_LAT
;
792 facp
->duty_offset
= ACPI_VIA_DUTY_OFFSET
;
793 facp
->duty_width
= ACPI_VIA_DUTY_WIDTH
;
795 facp
->day_alarm
= ACPI_VIA_DAY_ALARM
;
796 facp
->mon_alarm
= ACPI_VIA_MON_ALARM
;
797 facp
->century
= ACPI_VIA_CENTURY
;
799 acpi_init_table(&acpi_facp
, facp
, 0);
800 acpi_init_table(&acpi_dsdt
, NULL
, 0);
802 acpi_p_blk
= base
+ ACPI_VIA_P_BLK
;
815 /* indexed by value of each enum in acpi_chip_t */
818 int (*chip_init
)(struct pci_dev
*dev
);
827 const static struct pci_device_id acpi_pci_tbl
[] =
829 {0x8086, 0x7113, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, CH_INTEL_PIIX4
},
830 {0x1106, 0x3040, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, CH_VIA_586
},
831 {0x1106, 0x3057, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, CH_VIA_686A
},
832 {0,} /* terminate list */
835 static int __init
acpi_probe(struct pci_dev
*dev
,
836 const struct pci_device_id
*id
)
838 return acpi_chip_info
[id
->driver_data
].chip_init(dev
);
841 static struct pci_driver acpi_driver
=
844 id_table
: acpi_pci_tbl
,
847 static int pci_driver_registered
= 0;
850 * Locate a known ACPI chipset
852 static int __init
acpi_find_chipset(void)
854 if (pci_register_driver(&acpi_driver
) < 1)
857 pci_driver_registered
= 1;
863 * Handle an ACPI SCI (fixed or general purpose event)
865 static void acpi_irq(int irq
, void *dev_id
, struct pt_regs
*regs
)
867 struct acpi_facp
*facp
= (struct acpi_facp
*) acpi_facp
.table
;
868 u32 pm1_status
, gpe_status
, gpe_level
, gpe_edge
;
871 // detect and clear fixed events
872 pm1_status
= (acpi_read_pm1_status(facp
) & acpi_read_pm1_enable(facp
));
873 acpi_write_pm1_status(facp
, pm1_status
);
875 // detect and handle general-purpose events
876 gpe_status
= (acpi_read_gpe_status(facp
) & acpi_read_gpe_enable(facp
));
877 gpe_level
= gpe_status
& acpi_gpe_level
;
879 // disable level-triggered events (re-enabled after handling)
880 acpi_write_gpe_enable(facp
,
881 acpi_read_gpe_enable(facp
) & ~gpe_level
);
883 gpe_edge
= gpe_status
& ~gpe_level
;
885 // clear edge-triggered events
886 while (acpi_read_gpe_status(facp
) & gpe_edge
)
887 acpi_write_gpe_status(facp
, gpe_edge
);
890 // notify process waiting on /dev/acpi
891 spin_lock_irqsave(&acpi_event_lock
, flags
);
892 acpi_pm1_status
|= pm1_status
;
893 acpi_gpe_status
|= gpe_status
;
894 spin_unlock_irqrestore(&acpi_event_lock
, flags
);
895 acpi_event_state
= acpi_sleep_state
;
896 wake_up_interruptible(&acpi_event_wait
);
900 * Is SCI to be enabled?
903 acpi_sci_enabled(void)
905 return !(acpi_opts
& ACPI_SCI_DISABLED
);
909 * Is ACPI enabled or not?
911 static inline int acpi_is_enabled(struct acpi_facp
*facp
)
913 return ((acpi_read_pm1_control(facp
) & ACPI_SCI_EN
) ? 1:0);
919 static int acpi_enable(struct acpi_facp
*facp
)
921 if (facp
->smi_cmd
&& acpi_sci_enabled())
922 outb(facp
->acpi_enable
, facp
->smi_cmd
);
923 return (acpi_is_enabled(facp
) ? 0:-1);
929 static int acpi_disable(struct acpi_facp
*facp
)
931 if (facp
->smi_cmd
&& acpi_sci_enabled()) {
932 // disable and clear any pending events
933 acpi_write_gpe_enable(facp
, 0);
934 while (acpi_read_gpe_status(facp
)) {
935 acpi_write_gpe_status(facp
,
936 acpi_read_gpe_status(facp
));
938 acpi_write_pm1_enable(facp
, 0);
939 acpi_write_pm1_status(facp
, acpi_read_pm1_status(facp
));
941 /* writing acpi_disable to smi_cmd would be appropriate
942 * here but this causes a nasty crash on many systems
949 static inline int bm_activity(struct acpi_facp
*facp
)
951 return acpi_read_pm1_status(facp
) & ACPI_BM
;
954 static inline void clear_bm_activity(struct acpi_facp
*facp
)
956 acpi_write_pm1_status(facp
, ACPI_BM
);
959 static void sleep_on_busmaster(struct acpi_facp
*facp
)
961 u32 pm1_cntr
= acpi_read_pm1_control(facp
);
962 if (pm1_cntr
& ACPI_BM_RLD
) {
963 pm1_cntr
&= ~ACPI_BM_RLD
;
964 acpi_write_pm1_control(facp
, pm1_cntr
);
968 static void wake_on_busmaster(struct acpi_facp
*facp
)
970 u32 pm1_cntr
= acpi_read_pm1_control(facp
);
971 if (!(pm1_cntr
& ACPI_BM_RLD
)) {
972 pm1_cntr
|= ACPI_BM_RLD
;
973 acpi_write_pm1_control(facp
, pm1_cntr
);
975 clear_bm_activity(facp
);
978 /* The ACPI timer is just the low 24 bits */
979 #define TIME_BEGIN(tmr) inl(tmr)
980 #define TIME_END(tmr, begin) ((inl(tmr) - (begin)) & 0x00ffffff)
984 * Idle loop (uniprocessor only)
986 static void acpi_idle(void)
988 static int sleep_level
= 1;
989 struct acpi_facp
*facp
= (struct acpi_facp
*) acpi_facp
.table
;
991 if (!facp
|| !facp
->pm_tmr
|| !acpi_p_blk
)
992 goto not_initialized
;
995 * start from the previous sleep level..
997 if (sleep_level
== 1)
999 if (sleep_level
== 2)
1003 if (!acpi_p_lvl3_tested
) {
1004 printk(KERN_INFO
"ACPI C3 works\n");
1005 acpi_p_lvl3_tested
= 1;
1007 wake_on_busmaster(facp
);
1009 goto sleep3_with_arbiter
;
1013 unsigned int pm_tmr
= facp
->pm_tmr
;
1016 if (current
->need_resched
)
1018 if (bm_activity(facp
))
1021 time
= TIME_BEGIN(pm_tmr
);
1022 inb(acpi_p_blk
+ ACPI_P_LVL3
);
1023 inl(pm_tmr
); /* Dummy read, force synchronization with the PMU */
1024 time
= TIME_END(pm_tmr
, time
);
1027 if (time
< acpi_p_lvl3_lat
)
1031 sleep3_with_arbiter
:
1035 unsigned int pm2_cntr
= facp
->pm2_cnt
;
1036 unsigned int pm_tmr
= facp
->pm_tmr
;
1039 if (current
->need_resched
)
1041 if (bm_activity(facp
))
1044 time
= TIME_BEGIN(pm_tmr
);
1045 arbiter
= inb(pm2_cntr
) & ~ACPI_ARB_DIS
;
1046 outb(arbiter
| ACPI_ARB_DIS
, pm2_cntr
); /* Disable arbiter, park on CPU */
1047 inb(acpi_p_blk
+ ACPI_P_LVL3
);
1048 inl(pm_tmr
); /* Dummy read, force synchronization with the PMU */
1049 time
= TIME_END(pm_tmr
, time
);
1050 outb(arbiter
, pm2_cntr
); /* Enable arbiter again.. */
1053 if (time
< acpi_p_lvl3_lat
)
1059 if (!acpi_p_lvl2_tested
) {
1060 printk(KERN_INFO
"ACPI C2 works\n");
1061 acpi_p_lvl2_tested
= 1;
1063 wake_on_busmaster(facp
); /* Required to track BM activity.. */
1066 unsigned int pm_tmr
= facp
->pm_tmr
;
1069 if (current
->need_resched
)
1072 time
= TIME_BEGIN(pm_tmr
);
1073 inb(acpi_p_blk
+ ACPI_P_LVL2
);
1074 inl(pm_tmr
); /* Dummy read, force synchronization with the PMU */
1075 time
= TIME_END(pm_tmr
, time
);
1078 if (time
< acpi_p_lvl2_lat
)
1080 if (bm_activity(facp
)) {
1081 clear_bm_activity(facp
);
1084 if (time
> acpi_enter_lvl3_lat
)
1090 sleep_on_busmaster(facp
);
1093 unsigned int pm_tmr
= facp
->pm_tmr
;
1096 if (current
->need_resched
)
1098 time
= TIME_BEGIN(pm_tmr
);
1099 __asm__
__volatile__("sti ; hlt": : :"memory");
1100 time
= TIME_END(pm_tmr
, time
);
1101 if (time
> acpi_enter_lvl2_lat
)
1108 if (current
->need_resched
)
1110 __asm__
__volatile__("sti ; hlt": : :"memory");
1118 * Put all devices into specified D-state
1120 static int acpi_enter_dx(acpi_dstate_t state
)
1124 if (state
== ACPI_D0
)
1125 status
= pm_send_all(PM_RESUME
, (void*) state
);
1127 status
= pm_send_all(PM_SUSPEND
, (void*) state
);
1133 * Update system time from real-time clock
1135 static void acpi_update_clock(void)
1137 if (acpi_sleep_start
) {
1138 unsigned long delta
;
1141 delta
= get_cmos_time() - acpi_sleep_start
;
1142 do_gettimeofday(&tv
);
1144 do_settimeofday(&tv
);
1146 acpi_sleep_start
= 0;
1151 * Enter system sleep state
1153 static int acpi_enter_sx(acpi_sstate_t state
)
1155 unsigned long slp_typ
;
1156 u16 typa
, typb
, value
;
1157 struct acpi_facp
*facp
;
1159 slp_typ
= acpi_slp_typ
[(int) state
];
1160 if (slp_typ
== ACPI_SLP_TYP_DISABLED
)
1163 // bits 8-15 are SLP_TYPa, bits 0-7 are SLP_TYPb
1164 typa
= (slp_typ
>> 8) & 0xff;
1165 typb
= slp_typ
& 0xff;
1167 typa
= ((typa
<< ACPI_SLP_TYP_SHIFT
) & ACPI_SLP_TYP_MASK
);
1168 typb
= ((typb
<< ACPI_SLP_TYP_SHIFT
) & ACPI_SLP_TYP_MASK
);
1170 acpi_sleep_start
= get_cmos_time();
1171 acpi_enter_dx(ACPI_D3
);
1172 acpi_sleep_state
= state
;
1174 facp
= (struct acpi_facp
*) acpi_facp
.table
;
1176 // clear wake status
1177 acpi_write_pm1_status(facp
, ACPI_WAK
);
1179 // set SLP_TYPa/b and SLP_EN
1180 if (facp
->pm1a_cnt
) {
1181 value
= inw(facp
->pm1a_cnt
) & ~ACPI_SLP_TYP_MASK
;
1182 outw(value
| typa
| ACPI_SLP_EN
, facp
->pm1a_cnt
);
1184 if (facp
->pm1b_cnt
) {
1185 value
= inw(facp
->pm1b_cnt
) & ~ACPI_SLP_TYP_MASK
;
1186 outw(value
| typb
| ACPI_SLP_EN
, facp
->pm1b_cnt
);
1189 // wait until S1 is entered
1190 while (!(acpi_read_pm1_status(facp
) & ACPI_WAK
)) ;
1191 // finished sleeping, update system time
1192 acpi_update_clock();
1193 acpi_enter_dx(ACPI_D0
);
1194 acpi_sleep_state
= ACPI_S0
;
1200 * Enter soft-off (S5)
1202 static void acpi_power_off(void)
1204 acpi_enter_sx(ACPI_S5
);
1208 * Claim I/O port if available
1210 static int acpi_claim(unsigned long start
, unsigned long size
)
1212 if (start
&& size
) {
1213 if (check_region(start
, size
))
1215 request_region(start
, size
, "acpi");
1221 * Claim ACPI I/O ports
1223 static int acpi_claim_ioports(struct acpi_facp
*facp
)
1225 // we don't get a guarantee of contiguity for any of the ACPI registers
1226 if (acpi_claim(facp
->pm1a_evt
, facp
->pm1_evt_len
)
1227 || acpi_claim(facp
->pm1b_evt
, facp
->pm1_evt_len
)
1228 || acpi_claim(facp
->pm1a_cnt
, facp
->pm1_cnt_len
)
1229 || acpi_claim(facp
->pm1b_cnt
, facp
->pm1_cnt_len
)
1230 || acpi_claim(facp
->pm_tmr
, facp
->pm_tm_len
)
1231 || acpi_claim(facp
->gpe0
, facp
->gpe0_len
)
1232 || acpi_claim(facp
->gpe1
, facp
->gpe1_len
))
1238 * Release I/O port if claimed
1240 static void acpi_release(unsigned long start
, unsigned long size
)
1243 release_region(start
, size
);
1247 * Free ACPI I/O ports
1249 static int acpi_release_ioports(struct acpi_facp
*facp
)
1251 // we don't get a guarantee of contiguity for any of the ACPI registers
1252 acpi_release(facp
->gpe1
, facp
->gpe1_len
);
1253 acpi_release(facp
->gpe0
, facp
->gpe0_len
);
1254 acpi_release(facp
->pm_tmr
, facp
->pm_tm_len
);
1255 acpi_release(facp
->pm1b_cnt
, facp
->pm1_cnt_len
);
1256 acpi_release(facp
->pm1a_cnt
, facp
->pm1_cnt_len
);
1257 acpi_release(facp
->pm1b_evt
, facp
->pm1_evt_len
);
1258 acpi_release(facp
->pm1a_evt
, facp
->pm1_evt_len
);
1263 * Determine if modification of value is permitted
1266 acpi_verify_mod(int ctl_name
)
1269 case ACPI_PM1_ENABLE
:
1270 case ACPI_GPE_ENABLE
:
1271 case ACPI_GPE_LEVEL
:
1272 if (!acpi_sci_enabled())
1275 case ACPI_P_LVL2_LAT
:
1276 case ACPI_ENTER_LVL2_LAT
:
1277 if (acpi_opts
& ACPI_C2_DISABLED
)
1280 case ACPI_P_LVL3_LAT
:
1281 case ACPI_ENTER_LVL3_LAT
:
1282 if (acpi_opts
& ACPI_C3_DISABLED
)
1285 case ACPI_S1_SLP_TYP
:
1287 if (acpi_opts
& ACPI_S1_DISABLED
)
1290 case ACPI_S5_SLP_TYP
:
1291 if (acpi_opts
& ACPI_S5_DISABLED
)
1299 * Examine/modify value
1301 static int acpi_do_ulong(ctl_table
*ctl
,
1307 char str
[2 * sizeof(unsigned long) + 4], *strend
;
1317 val
= *(unsigned long*) ctl
->data
;
1318 size
= sprintf(str
, "0x%08lx\n", val
);
1320 copy_to_user(buffer
, str
, size
);
1327 if (acpi_verify_mod(ctl
->ctl_name
))
1330 size
= sizeof(str
) - 1;
1333 copy_from_user(str
, buffer
, size
);
1335 val
= simple_strtoul(str
, &strend
, 0);
1338 *(unsigned long*) ctl
->data
= val
;
1341 file
->f_pos
+= *len
;
1346 * Determine if user buffer contains a valid table
1348 static int acpi_verify_table(void *buffer
,
1350 struct acpi_table_info
*info
)
1352 if (size
< sizeof(struct acpi_table
))
1354 else if (verify_area(VERIFY_READ
, buffer
, size
))
1357 struct acpi_table hdr
;
1360 copy_from_user(&hdr
, buffer
, sizeof(hdr
));
1361 table_size
= (size_t) hdr
.length
;
1362 if (hdr
.signature
!= info
->expected_signature
1363 || table_size
< size
1364 || (info
->expected_size
1365 && table_size
!= info
->expected_size
))
1372 * Examine/replace an ACPI table
1374 static int acpi_do_table(ctl_table
*ctl
,
1380 struct acpi_table_info
*info
= (struct acpi_table_info
*) ctl
->data
;
1392 read_lock(&acpi_do_table_lock
);
1393 if (info
->table
&& file
->f_pos
< info
->size
) {
1394 data
= (u8
*) info
->table
+ file
->f_pos
;
1395 size
= info
->size
- file
->f_pos
;
1398 if (copy_to_user(buffer
, data
, size
))
1401 read_unlock(&acpi_do_table_lock
);
1403 else if (file
->f_pos
) {
1404 // table body replacement
1405 write_lock(&acpi_do_table_lock
);
1406 if (info
->table
&& file
->f_pos
< info
->size
) {
1407 data
= (u8
*) info
->table
+ file
->f_pos
;
1408 size
= info
->size
- file
->f_pos
;
1411 if (copy_from_user(data
, buffer
, size
))
1414 write_unlock(&acpi_do_table_lock
);
1417 // table header/body replacement
1418 struct acpi_table hdr
;
1421 // make sure we are being given a valid table
1422 error
= acpi_verify_table(buffer
, *len
, info
);
1425 copy_from_user(&hdr
, buffer
, sizeof(hdr
));
1426 table_size
= (size_t) hdr
.length
;
1428 write_lock(&acpi_do_table_lock
);
1430 data
= (u8
*) info
->table
;
1433 if (!data
|| info
->mapped
|| table_size
!= info
->size
) {
1434 // allocate a (different sized) table
1435 data
= kmalloc(table_size
, GFP_KERNEL
);
1437 memset(data
, 0, table_size
);
1438 memcpy(data
, &hdr
, sizeof(hdr
));
1439 acpi_destroy_table(info
);
1440 acpi_init_table(info
, data
, 0);
1446 copy_from_user(data
, buffer
, size
);
1448 write_unlock(&acpi_do_table_lock
);
1455 file
->f_pos
+= size
;
1460 * Examine/modify event register
1462 static int acpi_do_event_reg(ctl_table
*ctl
,
1468 struct acpi_facp
*facp
= (struct acpi_facp
*) acpi_facp
.table
;
1469 char str
[2 * sizeof(u32
) + 4], *strend
;
1480 switch (ctl
->ctl_name
) {
1481 case ACPI_PM1_ENABLE
:
1482 val
= acpi_read_pm1_enable(facp
);
1484 case ACPI_GPE_ENABLE
:
1485 val
= acpi_read_gpe_enable(facp
);
1487 case ACPI_GPE_LEVEL
:
1488 val
= acpi_gpe_level
;
1492 size
= sprintf(str
, "0x%08x\n", val
);
1494 copy_to_user(buffer
, str
, size
);
1502 if (acpi_verify_mod(ctl
->ctl_name
))
1506 size
= sizeof(str
) - 1;
1509 copy_from_user(str
, buffer
, size
);
1511 val
= (u32
) simple_strtoul(str
, &strend
, 0);
1515 // store value in register
1516 switch (ctl
->ctl_name
) {
1517 case ACPI_PM1_ENABLE
:
1518 // clear previously disabled events
1519 enabling
= (val
& ~acpi_read_pm1_enable(facp
));
1520 acpi_write_pm1_status(facp
, enabling
);
1523 // enable ACPI unless it is already
1524 if (!acpi_is_enabled(facp
))
1527 else if (!acpi_read_gpe_enable(facp
)) {
1528 // disable ACPI unless it is already
1529 if (acpi_is_enabled(facp
))
1533 acpi_write_pm1_enable(facp
, val
);
1535 case ACPI_GPE_ENABLE
:
1536 // clear previously disabled events
1538 & ~acpi_read_gpe_enable(facp
));
1539 while (acpi_read_gpe_status(facp
) & enabling
)
1540 acpi_write_gpe_status(facp
, enabling
);
1543 // enable ACPI unless it is already
1544 if (!acpi_is_enabled(facp
))
1547 else if (!acpi_read_pm1_enable(facp
)) {
1548 // disable ACPI unless it is already
1549 if (acpi_is_enabled(facp
))
1553 acpi_write_gpe_enable(facp
, val
);
1555 case ACPI_GPE_LEVEL
:
1556 acpi_gpe_level
= val
;
1561 file
->f_pos
+= *len
;
1566 * Wait for next event
1568 static int acpi_do_event(ctl_table
*ctl
,
1574 u32 pm1_status
= 0, gpe_status
= 0;
1575 acpi_sstate_t event_state
= 0;
1581 if (*len
< sizeof(str
)) {
1587 unsigned long flags
;
1589 // we need an atomic exchange here
1590 spin_lock_irqsave(&acpi_event_lock
, flags
);
1591 pm1_status
= acpi_pm1_status
;
1592 acpi_pm1_status
= 0;
1593 gpe_status
= acpi_gpe_status
;
1594 acpi_gpe_status
= 0;
1595 spin_unlock_irqrestore(&acpi_event_lock
, flags
);
1596 event_state
= acpi_event_state
;
1598 if (pm1_status
|| gpe_status
)
1601 // wait for an event to arrive
1602 interruptible_sleep_on(&acpi_event_wait
);
1603 if (signal_pending(current
))
1604 return -ERESTARTSYS
;
1607 size
= sprintf(str
, "0x%08x 0x%08x 0x%01x\n",
1611 copy_to_user(buffer
, str
, size
);
1613 file
->f_pos
+= size
;
1619 * Enter system sleep state
1621 static int acpi_do_sleep(ctl_table
*ctl
,
1635 if (acpi_verify_mod(ctl
->ctl_name
) || acpi_enter_sx(ACPI_S1
))
1638 file
->f_pos
+= *len
;
1643 * Parse command line options
1645 static int __init
acpi_setup(char *str
)
1647 while (str
&& *str
) {
1648 struct acpi_option_info
*opt
= acpi_options
;
1650 if (!strncmp(str
, opt
->name
, strlen(opt
->name
))) {
1651 acpi_opts
|= opt
->value
;
1656 str
= strpbrk(str
, ",");
1658 str
+= strspn(str
, ",");
1662 printk(KERN_INFO
"ACPI: options 0x%08lx\n", acpi_opts
);
1668 * kernel/module command line interfaces are both "acpi=OPTION,OPTION,..."
1670 __setup("acpi=", acpi_setup
);
1672 static char * __initdata acpi
= NULL
;
1674 MODULE_DESCRIPTION("ACPI driver");
1675 MODULE_PARM(acpi
, "s");
1676 MODULE_PARM_DESC(acpi
, "ACPI driver command line");
1679 * Initialize and enable ACPI
1681 int __init
acpi_init(void)
1683 struct acpi_facp
*facp
= NULL
;
1688 if (acpi_opts
& ACPI_DISABLED
) {
1691 else if (acpi_opts
& ACPI_TABLES_ONLY
) {
1692 if (acpi_find_tables())
1695 else if (acpi_opts
& ACPI_CHIPSET_ONLY
) {
1696 if (acpi_find_chipset())
1700 switch (acpi_find_tables()) {
1702 // found valid ACPI tables
1705 // found no ACPI tables, try chipset-specific
1706 if (acpi_find_chipset())
1710 // found broken ACPI tables
1715 facp
= (struct acpi_facp
*) acpi_facp
.table
;
1717 if (PM_IS_ACTIVE()) {
1718 printk(KERN_NOTICE
"acpi: APM is already active.\n");
1724 * Internally we always keep latencies in timer
1725 * ticks, which is simpler and more consistent (what is
1726 * an uS to us?). Besides, that gives people more
1727 * control in the /proc interfaces.
1729 if (facp
->p_lvl2_lat
1730 && facp
->p_lvl2_lat
<= ACPI_MAX_P_LVL2_LAT
1731 && !acpi_verify_mod(ACPI_P_LVL2_LAT
)) {
1732 acpi_p_lvl2_lat
= ACPI_uS_TO_TMR_TICKS(facp
->p_lvl2_lat
);
1733 acpi_enter_lvl2_lat
= ACPI_uS_TO_TMR_TICKS(ACPI_TMR_HZ
/ 1000);
1735 if (facp
->p_lvl3_lat
1736 && facp
->p_lvl3_lat
<= ACPI_MAX_P_LVL3_LAT
1737 && !acpi_verify_mod(ACPI_P_LVL3_LAT
)) {
1738 acpi_p_lvl3_lat
= ACPI_uS_TO_TMR_TICKS(facp
->p_lvl3_lat
);
1740 = ACPI_uS_TO_TMR_TICKS(facp
->p_lvl3_lat
* 5);
1743 if (acpi_claim_ioports(facp
)) {
1744 printk(KERN_ERR
"ACPI: I/O port allocation failed\n");
1749 && acpi_sci_enabled()
1750 && request_irq(facp
->sci_int
,
1752 SA_INTERRUPT
| SA_SHIRQ
,
1755 printk(KERN_ERR
"ACPI: SCI (IRQ%d) allocation failed\n",
1760 #ifndef CONFIG_ACPI_S1_SLEEP
1761 acpi_opts
|= ACPI_S1_DISABLED
;
1764 acpi_sysctl
= register_sysctl_table(acpi_dir_table
, 1);
1766 pm_power_off
= acpi_power_off
;
1769 * Set up the ACPI idle function. Note that we can't really
1770 * do this with multiple CPU's, we'd need a per-CPU ACPI
1774 if (smp_num_cpus
> 1)
1779 pm_idle
= acpi_idle
;
1784 if (pci_driver_registered
)
1785 pci_unregister_driver(&acpi_driver
);
1786 acpi_destroy_tables();
1792 * Disable and deinitialize ACPI
1794 void __exit
acpi_exit(void)
1796 struct acpi_facp
*facp
= (struct acpi_facp
*) acpi_facp
.table
;
1799 pm_power_off
= NULL
;
1801 unregister_sysctl_table(acpi_sysctl
);
1803 acpi_release_ioports(facp
);
1805 if (facp
->sci_int
&& acpi_sci_enabled())
1806 free_irq(facp
->sci_int
, &acpi_facp
);
1808 acpi_destroy_tables();
1810 if (pci_driver_registered
)
1811 pci_unregister_driver(&acpi_driver
);
1816 module_init(acpi_init
);
1817 module_exit(acpi_exit
);