2 * acpi_bus.c - ACPI Bus Driver ($Revision: 80 $)
4 * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
6 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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 (at
11 * your option) any later version.
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
22 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
25 #include <linux/module.h>
26 #include <linux/init.h>
27 #include <linux/ioport.h>
28 #include <linux/kernel.h>
29 #include <linux/list.h>
30 #include <linux/sched.h>
32 #include <linux/device.h>
33 #include <linux/proc_fs.h>
34 #include <linux/acpi.h>
35 #include <linux/slab.h>
37 #include <asm/mpspec.h>
39 #include <linux/pci.h>
40 #include <acpi/acpi_bus.h>
41 #include <acpi/acpi_drivers.h>
42 #include <linux/dmi.h>
43 #include <linux/suspend.h>
47 #define _COMPONENT ACPI_BUS_COMPONENT
48 ACPI_MODULE_NAME("bus");
50 struct acpi_device
*acpi_root
;
51 struct proc_dir_entry
*acpi_root_dir
;
52 EXPORT_SYMBOL(acpi_root_dir
);
54 #define STRUCT_TO_INT(s) (*((int*)&s))
58 static int set_copy_dsdt(const struct dmi_system_id
*id
)
60 printk(KERN_NOTICE
"%s detected - "
61 "force copy of DSDT to local memory\n", id
->ident
);
62 acpi_gbl_copy_dsdt_locally
= 1;
66 static struct dmi_system_id dsdt_dmi_table
[] __initdata
= {
68 * Invoke DSDT corruption work-around on all Toshiba Satellite.
69 * https://bugzilla.kernel.org/show_bug.cgi?id=14679
72 .callback
= set_copy_dsdt
,
73 .ident
= "TOSHIBA Satellite",
75 DMI_MATCH(DMI_SYS_VENDOR
, "TOSHIBA"),
76 DMI_MATCH(DMI_PRODUCT_NAME
, "Satellite"),
82 static struct dmi_system_id dsdt_dmi_table
[] __initdata
= {
87 /* --------------------------------------------------------------------------
89 -------------------------------------------------------------------------- */
91 int acpi_bus_get_device(acpi_handle handle
, struct acpi_device
**device
)
93 acpi_status status
= AE_OK
;
99 /* TBD: Support fixed-feature devices */
101 status
= acpi_get_data(handle
, acpi_bus_data_handler
, (void **)device
);
102 if (ACPI_FAILURE(status
) || !*device
) {
103 ACPI_DEBUG_PRINT((ACPI_DB_INFO
, "No context for object [%p]\n",
111 EXPORT_SYMBOL(acpi_bus_get_device
);
113 acpi_status
acpi_bus_get_status_handle(acpi_handle handle
,
114 unsigned long long *sta
)
118 status
= acpi_evaluate_integer(handle
, "_STA", NULL
, sta
);
119 if (ACPI_SUCCESS(status
))
122 if (status
== AE_NOT_FOUND
) {
123 *sta
= ACPI_STA_DEVICE_PRESENT
| ACPI_STA_DEVICE_ENABLED
|
124 ACPI_STA_DEVICE_UI
| ACPI_STA_DEVICE_FUNCTIONING
;
130 int acpi_bus_get_status(struct acpi_device
*device
)
133 unsigned long long sta
;
135 status
= acpi_bus_get_status_handle(device
->handle
, &sta
);
136 if (ACPI_FAILURE(status
))
139 STRUCT_TO_INT(device
->status
) = (int) sta
;
141 if (device
->status
.functional
&& !device
->status
.present
) {
142 ACPI_DEBUG_PRINT((ACPI_DB_INFO
, "Device [%s] status [%08x]: "
143 "functional but not present;\n",
145 (u32
) STRUCT_TO_INT(device
->status
)));
148 ACPI_DEBUG_PRINT((ACPI_DB_INFO
, "Device [%s] status [%08x]\n",
150 (u32
) STRUCT_TO_INT(device
->status
)));
153 EXPORT_SYMBOL(acpi_bus_get_status
);
155 void acpi_bus_private_data_handler(acpi_handle handle
,
160 EXPORT_SYMBOL(acpi_bus_private_data_handler
);
162 int acpi_bus_get_private_data(acpi_handle handle
, void **data
)
164 acpi_status status
= AE_OK
;
169 status
= acpi_get_data(handle
, acpi_bus_private_data_handler
, data
);
170 if (ACPI_FAILURE(status
) || !*data
) {
171 ACPI_DEBUG_PRINT((ACPI_DB_INFO
, "No context for object [%p]\n",
178 EXPORT_SYMBOL(acpi_bus_get_private_data
);
180 /* --------------------------------------------------------------------------
182 -------------------------------------------------------------------------- */
184 static int __acpi_bus_get_power(struct acpi_device
*device
, int *state
)
187 acpi_status status
= 0;
188 unsigned long long psc
= 0;
190 if (!device
|| !state
)
193 *state
= ACPI_STATE_UNKNOWN
;
195 if (device
->flags
.power_manageable
) {
197 * Get the device's power state either directly (via _PSC) or
198 * indirectly (via power resources).
200 if (device
->power
.flags
.power_resources
) {
201 result
= acpi_power_get_inferred_state(device
, state
);
204 } else if (device
->power
.flags
.explicit_get
) {
205 status
= acpi_evaluate_integer(device
->handle
, "_PSC",
207 if (ACPI_FAILURE(status
))
212 /* TBD: Non-recursive algorithm for walking up hierarchy. */
213 *state
= device
->parent
?
214 device
->parent
->power
.state
: ACPI_STATE_D0
;
217 ACPI_DEBUG_PRINT((ACPI_DB_INFO
, "Device [%s] power state is D%d\n",
218 device
->pnp
.bus_id
, *state
));
224 static int __acpi_bus_set_power(struct acpi_device
*device
, int state
)
227 acpi_status status
= AE_OK
;
228 char object_name
[5] = { '_', 'P', 'S', '0' + state
, '\0' };
230 if (!device
|| (state
< ACPI_STATE_D0
) || (state
> ACPI_STATE_D3
))
233 /* Make sure this is a valid target state */
235 if (state
== device
->power
.state
) {
236 ACPI_DEBUG_PRINT((ACPI_DB_INFO
, "Device is already at D%d\n",
241 if (!device
->power
.states
[state
].flags
.valid
) {
242 printk(KERN_WARNING PREFIX
"Device does not support D%d\n", state
);
245 if (device
->parent
&& (state
< device
->parent
->power
.state
)) {
246 printk(KERN_WARNING PREFIX
247 "Cannot set device to a higher-powered"
248 " state than parent\n");
255 * On transitions to a high-powered state we first apply power (via
256 * power resources) then evalute _PSx. Conversly for transitions to
257 * a lower-powered state.
259 if (state
< device
->power
.state
) {
260 if (device
->power
.flags
.power_resources
) {
261 result
= acpi_power_transition(device
, state
);
265 if (device
->power
.states
[state
].flags
.explicit_set
) {
266 status
= acpi_evaluate_object(device
->handle
,
267 object_name
, NULL
, NULL
);
268 if (ACPI_FAILURE(status
)) {
274 if (device
->power
.states
[state
].flags
.explicit_set
) {
275 status
= acpi_evaluate_object(device
->handle
,
276 object_name
, NULL
, NULL
);
277 if (ACPI_FAILURE(status
)) {
282 if (device
->power
.flags
.power_resources
) {
283 result
= acpi_power_transition(device
, state
);
291 printk(KERN_WARNING PREFIX
292 "Device [%s] failed to transition to D%d\n",
293 device
->pnp
.bus_id
, state
);
295 device
->power
.state
= state
;
296 ACPI_DEBUG_PRINT((ACPI_DB_INFO
,
297 "Device [%s] transitioned to D%d\n",
298 device
->pnp
.bus_id
, state
));
305 int acpi_bus_set_power(acpi_handle handle
, int state
)
307 struct acpi_device
*device
;
310 result
= acpi_bus_get_device(handle
, &device
);
314 if (!device
->flags
.power_manageable
) {
315 ACPI_DEBUG_PRINT((ACPI_DB_INFO
,
316 "Device [%s] is not power manageable\n",
317 dev_name(&device
->dev
)));
321 return __acpi_bus_set_power(device
, state
);
323 EXPORT_SYMBOL(acpi_bus_set_power
);
326 int acpi_bus_init_power(struct acpi_device
*device
)
334 device
->power
.state
= ACPI_STATE_UNKNOWN
;
336 result
= __acpi_bus_get_power(device
, &state
);
340 if (device
->power
.flags
.power_resources
)
341 result
= acpi_power_on_resources(device
, state
);
344 device
->power
.state
= state
;
350 int acpi_bus_update_power(acpi_handle handle
, int *state_p
)
352 struct acpi_device
*device
;
356 result
= acpi_bus_get_device(handle
, &device
);
360 result
= __acpi_bus_get_power(device
, &state
);
364 result
= __acpi_bus_set_power(device
, state
);
365 if (!result
&& state_p
)
370 EXPORT_SYMBOL_GPL(acpi_bus_update_power
);
373 bool acpi_bus_power_manageable(acpi_handle handle
)
375 struct acpi_device
*device
;
378 result
= acpi_bus_get_device(handle
, &device
);
379 return result
? false : device
->flags
.power_manageable
;
382 EXPORT_SYMBOL(acpi_bus_power_manageable
);
384 bool acpi_bus_can_wakeup(acpi_handle handle
)
386 struct acpi_device
*device
;
389 result
= acpi_bus_get_device(handle
, &device
);
390 return result
? false : device
->wakeup
.flags
.valid
;
393 EXPORT_SYMBOL(acpi_bus_can_wakeup
);
395 static void acpi_print_osc_error(acpi_handle handle
,
396 struct acpi_osc_context
*context
, char *error
)
398 struct acpi_buffer buffer
= {ACPI_ALLOCATE_BUFFER
};
401 if (ACPI_FAILURE(acpi_get_name(handle
, ACPI_FULL_PATHNAME
, &buffer
)))
402 printk(KERN_DEBUG
"%s\n", error
);
404 printk(KERN_DEBUG
"%s:%s\n", (char *)buffer
.pointer
, error
);
405 kfree(buffer
.pointer
);
407 printk(KERN_DEBUG
"_OSC request data:");
408 for (i
= 0; i
< context
->cap
.length
; i
+= sizeof(u32
))
409 printk("%x ", *((u32
*)(context
->cap
.pointer
+ i
)));
413 static acpi_status
acpi_str_to_uuid(char *str
, u8
*uuid
)
416 static int opc_map_to_uuid
[16] = {6, 4, 2, 0, 11, 9, 16, 14, 19, 21,
417 24, 26, 28, 30, 32, 34};
419 if (strlen(str
) != 36)
420 return AE_BAD_PARAMETER
;
421 for (i
= 0; i
< 36; i
++) {
422 if (i
== 8 || i
== 13 || i
== 18 || i
== 23) {
424 return AE_BAD_PARAMETER
;
425 } else if (!isxdigit(str
[i
]))
426 return AE_BAD_PARAMETER
;
428 for (i
= 0; i
< 16; i
++) {
429 uuid
[i
] = hex_to_bin(str
[opc_map_to_uuid
[i
]]) << 4;
430 uuid
[i
] |= hex_to_bin(str
[opc_map_to_uuid
[i
] + 1]);
435 acpi_status
acpi_run_osc(acpi_handle handle
, struct acpi_osc_context
*context
)
438 struct acpi_object_list input
;
439 union acpi_object in_params
[4];
440 union acpi_object
*out_obj
;
443 struct acpi_buffer output
= {ACPI_ALLOCATE_BUFFER
, NULL
};
447 if (ACPI_FAILURE(acpi_str_to_uuid(context
->uuid_str
, uuid
)))
449 context
->ret
.length
= ACPI_ALLOCATE_BUFFER
;
450 context
->ret
.pointer
= NULL
;
452 /* Setting up input parameters */
454 input
.pointer
= in_params
;
455 in_params
[0].type
= ACPI_TYPE_BUFFER
;
456 in_params
[0].buffer
.length
= 16;
457 in_params
[0].buffer
.pointer
= uuid
;
458 in_params
[1].type
= ACPI_TYPE_INTEGER
;
459 in_params
[1].integer
.value
= context
->rev
;
460 in_params
[2].type
= ACPI_TYPE_INTEGER
;
461 in_params
[2].integer
.value
= context
->cap
.length
/sizeof(u32
);
462 in_params
[3].type
= ACPI_TYPE_BUFFER
;
463 in_params
[3].buffer
.length
= context
->cap
.length
;
464 in_params
[3].buffer
.pointer
= context
->cap
.pointer
;
466 status
= acpi_evaluate_object(handle
, "_OSC", &input
, &output
);
467 if (ACPI_FAILURE(status
))
471 return AE_NULL_OBJECT
;
473 out_obj
= output
.pointer
;
474 if (out_obj
->type
!= ACPI_TYPE_BUFFER
475 || out_obj
->buffer
.length
!= context
->cap
.length
) {
476 acpi_print_osc_error(handle
, context
,
477 "_OSC evaluation returned wrong type");
481 /* Need to ignore the bit0 in result code */
482 errors
= *((u32
*)out_obj
->buffer
.pointer
) & ~(1 << 0);
484 if (errors
& OSC_REQUEST_ERROR
)
485 acpi_print_osc_error(handle
, context
,
486 "_OSC request failed");
487 if (errors
& OSC_INVALID_UUID_ERROR
)
488 acpi_print_osc_error(handle
, context
,
489 "_OSC invalid UUID");
490 if (errors
& OSC_INVALID_REVISION_ERROR
)
491 acpi_print_osc_error(handle
, context
,
492 "_OSC invalid revision");
493 if (errors
& OSC_CAPABILITIES_MASK_ERROR
) {
494 if (((u32
*)context
->cap
.pointer
)[OSC_QUERY_TYPE
]
504 context
->ret
.length
= out_obj
->buffer
.length
;
505 context
->ret
.pointer
= kmalloc(context
->ret
.length
, GFP_KERNEL
);
506 if (!context
->ret
.pointer
) {
507 status
= AE_NO_MEMORY
;
510 memcpy(context
->ret
.pointer
, out_obj
->buffer
.pointer
,
511 context
->ret
.length
);
515 kfree(output
.pointer
);
517 context
->ret
.pointer
= NULL
;
520 EXPORT_SYMBOL(acpi_run_osc
);
522 static u8 sb_uuid_str
[] = "0811B06E-4A27-44F9-8D60-3CBBC22E7B48";
523 static void acpi_bus_osc_support(void)
526 struct acpi_osc_context context
= {
527 .uuid_str
= sb_uuid_str
,
530 .cap
.pointer
= capbuf
,
534 capbuf
[OSC_QUERY_TYPE
] = OSC_QUERY_ENABLE
;
535 capbuf
[OSC_SUPPORT_TYPE
] = OSC_SB_PR3_SUPPORT
; /* _PR3 is in use */
536 #if defined(CONFIG_ACPI_PROCESSOR_AGGREGATOR) ||\
537 defined(CONFIG_ACPI_PROCESSOR_AGGREGATOR_MODULE)
538 capbuf
[OSC_SUPPORT_TYPE
] |= OSC_SB_PAD_SUPPORT
;
541 #if defined(CONFIG_ACPI_PROCESSOR) || defined(CONFIG_ACPI_PROCESSOR_MODULE)
542 capbuf
[OSC_SUPPORT_TYPE
] |= OSC_SB_PPC_OST_SUPPORT
;
544 if (ACPI_FAILURE(acpi_get_handle(NULL
, "\\_SB", &handle
)))
546 if (ACPI_SUCCESS(acpi_run_osc(handle
, &context
)))
547 kfree(context
.ret
.pointer
);
548 /* do we need to check the returned cap? Sounds no */
551 /* --------------------------------------------------------------------------
553 -------------------------------------------------------------------------- */
555 #ifdef CONFIG_ACPI_PROC_EVENT
556 static DEFINE_SPINLOCK(acpi_bus_event_lock
);
558 LIST_HEAD(acpi_bus_event_list
);
559 DECLARE_WAIT_QUEUE_HEAD(acpi_bus_event_queue
);
561 extern int event_is_open
;
563 int acpi_bus_generate_proc_event4(const char *device_class
, const char *bus_id
, u8 type
, int data
)
565 struct acpi_bus_event
*event
;
566 unsigned long flags
= 0;
568 /* drop event on the floor if no one's listening */
572 event
= kzalloc(sizeof(struct acpi_bus_event
), GFP_ATOMIC
);
576 strcpy(event
->device_class
, device_class
);
577 strcpy(event
->bus_id
, bus_id
);
581 spin_lock_irqsave(&acpi_bus_event_lock
, flags
);
582 list_add_tail(&event
->node
, &acpi_bus_event_list
);
583 spin_unlock_irqrestore(&acpi_bus_event_lock
, flags
);
585 wake_up_interruptible(&acpi_bus_event_queue
);
591 EXPORT_SYMBOL_GPL(acpi_bus_generate_proc_event4
);
593 int acpi_bus_generate_proc_event(struct acpi_device
*device
, u8 type
, int data
)
597 return acpi_bus_generate_proc_event4(device
->pnp
.device_class
,
598 device
->pnp
.bus_id
, type
, data
);
601 EXPORT_SYMBOL(acpi_bus_generate_proc_event
);
603 int acpi_bus_receive_event(struct acpi_bus_event
*event
)
605 unsigned long flags
= 0;
606 struct acpi_bus_event
*entry
= NULL
;
608 DECLARE_WAITQUEUE(wait
, current
);
614 if (list_empty(&acpi_bus_event_list
)) {
616 set_current_state(TASK_INTERRUPTIBLE
);
617 add_wait_queue(&acpi_bus_event_queue
, &wait
);
619 if (list_empty(&acpi_bus_event_list
))
622 remove_wait_queue(&acpi_bus_event_queue
, &wait
);
623 set_current_state(TASK_RUNNING
);
625 if (signal_pending(current
))
629 spin_lock_irqsave(&acpi_bus_event_lock
, flags
);
630 if (!list_empty(&acpi_bus_event_list
)) {
631 entry
= list_entry(acpi_bus_event_list
.next
,
632 struct acpi_bus_event
, node
);
633 list_del(&entry
->node
);
635 spin_unlock_irqrestore(&acpi_bus_event_lock
, flags
);
640 memcpy(event
, entry
, sizeof(struct acpi_bus_event
));
647 #endif /* CONFIG_ACPI_PROC_EVENT */
649 /* --------------------------------------------------------------------------
650 Notification Handling
651 -------------------------------------------------------------------------- */
653 static void acpi_bus_check_device(acpi_handle handle
)
655 struct acpi_device
*device
;
657 struct acpi_device_status old_status
;
659 if (acpi_bus_get_device(handle
, &device
))
664 old_status
= device
->status
;
667 * Make sure this device's parent is present before we go about
668 * messing with the device.
670 if (device
->parent
&& !device
->parent
->status
.present
) {
671 device
->status
= device
->parent
->status
;
675 status
= acpi_bus_get_status(device
);
676 if (ACPI_FAILURE(status
))
679 if (STRUCT_TO_INT(old_status
) == STRUCT_TO_INT(device
->status
))
683 * Device Insertion/Removal
685 if ((device
->status
.present
) && !(old_status
.present
)) {
686 ACPI_DEBUG_PRINT((ACPI_DB_INFO
, "Device insertion detected\n"));
687 /* TBD: Handle device insertion */
688 } else if (!(device
->status
.present
) && (old_status
.present
)) {
689 ACPI_DEBUG_PRINT((ACPI_DB_INFO
, "Device removal detected\n"));
690 /* TBD: Handle device removal */
694 static void acpi_bus_check_scope(acpi_handle handle
)
697 acpi_bus_check_device(handle
);
700 * TBD: Enumerate child devices within this device's scope and
701 * run acpi_bus_check_device()'s on them.
705 static BLOCKING_NOTIFIER_HEAD(acpi_bus_notify_list
);
706 int register_acpi_bus_notifier(struct notifier_block
*nb
)
708 return blocking_notifier_chain_register(&acpi_bus_notify_list
, nb
);
710 EXPORT_SYMBOL_GPL(register_acpi_bus_notifier
);
712 void unregister_acpi_bus_notifier(struct notifier_block
*nb
)
714 blocking_notifier_chain_unregister(&acpi_bus_notify_list
, nb
);
716 EXPORT_SYMBOL_GPL(unregister_acpi_bus_notifier
);
721 * Callback for all 'system-level' device notifications (values 0x00-0x7F).
723 static void acpi_bus_notify(acpi_handle handle
, u32 type
, void *data
)
725 struct acpi_device
*device
= NULL
;
726 struct acpi_driver
*driver
;
728 ACPI_DEBUG_PRINT((ACPI_DB_INFO
, "Notification %#02x to handle %p\n",
731 blocking_notifier_call_chain(&acpi_bus_notify_list
,
732 type
, (void *)handle
);
736 case ACPI_NOTIFY_BUS_CHECK
:
737 acpi_bus_check_scope(handle
);
739 * TBD: We'll need to outsource certain events to non-ACPI
740 * drivers via the device manager (device.c).
744 case ACPI_NOTIFY_DEVICE_CHECK
:
745 acpi_bus_check_device(handle
);
747 * TBD: We'll need to outsource certain events to non-ACPI
748 * drivers via the device manager (device.c).
752 case ACPI_NOTIFY_DEVICE_WAKE
:
756 case ACPI_NOTIFY_EJECT_REQUEST
:
760 case ACPI_NOTIFY_DEVICE_CHECK_LIGHT
:
761 /* TBD: Exactly what does 'light' mean? */
764 case ACPI_NOTIFY_FREQUENCY_MISMATCH
:
768 case ACPI_NOTIFY_BUS_MODE_MISMATCH
:
772 case ACPI_NOTIFY_POWER_FAULT
:
777 ACPI_DEBUG_PRINT((ACPI_DB_INFO
,
778 "Received unknown/unsupported notification [%08x]\n",
783 acpi_bus_get_device(handle
, &device
);
785 driver
= device
->driver
;
786 if (driver
&& driver
->ops
.notify
&&
787 (driver
->flags
& ACPI_DRIVER_ALL_NOTIFY_EVENTS
))
788 driver
->ops
.notify(device
, type
);
792 /* --------------------------------------------------------------------------
793 Initialization/Cleanup
794 -------------------------------------------------------------------------- */
796 static int __init
acpi_bus_init_irq(void)
798 acpi_status status
= AE_OK
;
799 union acpi_object arg
= { ACPI_TYPE_INTEGER
};
800 struct acpi_object_list arg_list
= { 1, &arg
};
801 char *message
= NULL
;
805 * Let the system know what interrupt model we are using by
806 * evaluating the \_PIC object, if exists.
809 switch (acpi_irq_model
) {
810 case ACPI_IRQ_MODEL_PIC
:
813 case ACPI_IRQ_MODEL_IOAPIC
:
816 case ACPI_IRQ_MODEL_IOSAPIC
:
819 case ACPI_IRQ_MODEL_PLATFORM
:
820 message
= "platform specific model";
823 printk(KERN_WARNING PREFIX
"Unknown interrupt routing model\n");
827 printk(KERN_INFO PREFIX
"Using %s for interrupt routing\n", message
);
829 arg
.integer
.value
= acpi_irq_model
;
831 status
= acpi_evaluate_object(NULL
, "\\_PIC", &arg_list
, NULL
);
832 if (ACPI_FAILURE(status
) && (status
!= AE_NOT_FOUND
)) {
833 ACPI_EXCEPTION((AE_INFO
, status
, "Evaluating _PIC"));
840 u8 acpi_gbl_permanent_mmap
;
843 void __init
acpi_early_init(void)
845 acpi_status status
= AE_OK
;
850 printk(KERN_INFO PREFIX
"Core revision %08x\n", ACPI_CA_VERSION
);
852 /* enable workarounds, unless strict ACPI spec. compliance */
854 acpi_gbl_enable_interpreter_slack
= TRUE
;
856 acpi_gbl_permanent_mmap
= 1;
859 * If the machine falls into the DMI check table,
860 * DSDT will be copied to memory
862 dmi_check_system(dsdt_dmi_table
);
864 status
= acpi_reallocate_root_table();
865 if (ACPI_FAILURE(status
)) {
866 printk(KERN_ERR PREFIX
867 "Unable to reallocate ACPI tables\n");
871 status
= acpi_initialize_subsystem();
872 if (ACPI_FAILURE(status
)) {
873 printk(KERN_ERR PREFIX
874 "Unable to initialize the ACPI Interpreter\n");
878 status
= acpi_load_tables();
879 if (ACPI_FAILURE(status
)) {
880 printk(KERN_ERR PREFIX
881 "Unable to load the System Description Tables\n");
887 /* compatible (0) means level (3) */
888 if (!(acpi_sci_flags
& ACPI_MADT_TRIGGER_MASK
)) {
889 acpi_sci_flags
&= ~ACPI_MADT_TRIGGER_MASK
;
890 acpi_sci_flags
|= ACPI_MADT_TRIGGER_LEVEL
;
892 /* Set PIC-mode SCI trigger type */
893 acpi_pic_sci_set_trigger(acpi_gbl_FADT
.sci_interrupt
,
894 (acpi_sci_flags
& ACPI_MADT_TRIGGER_MASK
) >> 2);
897 * now that acpi_gbl_FADT is initialized,
898 * update it with result from INT_SRC_OVR parsing
900 acpi_gbl_FADT
.sci_interrupt
= acpi_sci_override_gsi
;
905 acpi_enable_subsystem(~
906 (ACPI_NO_HARDWARE_INIT
|
907 ACPI_NO_ACPI_ENABLE
));
908 if (ACPI_FAILURE(status
)) {
909 printk(KERN_ERR PREFIX
"Unable to enable ACPI\n");
920 static int __init
acpi_bus_init(void)
923 acpi_status status
= AE_OK
;
924 extern acpi_status
acpi_os_initialize1(void);
926 acpi_os_initialize1();
929 acpi_enable_subsystem(ACPI_NO_HARDWARE_INIT
| ACPI_NO_ACPI_ENABLE
);
930 if (ACPI_FAILURE(status
)) {
931 printk(KERN_ERR PREFIX
932 "Unable to start the ACPI Interpreter\n");
937 * ACPI 2.0 requires the EC driver to be loaded and work before
938 * the EC device is found in the namespace (i.e. before acpi_initialize_objects()
941 * This is accomplished by looking for the ECDT table, and getting
942 * the EC parameters out of that.
944 status
= acpi_ec_ecdt_probe();
945 /* Ignore result. Not having an ECDT is not fatal. */
947 acpi_bus_osc_support();
949 status
= acpi_initialize_objects(ACPI_FULL_INITIALIZATION
);
950 if (ACPI_FAILURE(status
)) {
951 printk(KERN_ERR PREFIX
"Unable to initialize ACPI objects\n");
956 * _PDC control method may load dynamic SSDT tables,
957 * and we need to install the table handler before that.
961 acpi_early_processor_set_pdc();
964 * Maybe EC region is required at bus_scan/acpi_get_devices. So it
965 * is necessary to enable it as early as possible.
967 acpi_boot_ec_enable();
969 printk(KERN_INFO PREFIX
"Interpreter enabled\n");
971 /* Initialize sleep structures */
975 * Get the system interrupt model and evaluate \_PIC.
977 result
= acpi_bus_init_irq();
982 * Register the for all standard device notifications.
985 acpi_install_notify_handler(ACPI_ROOT_OBJECT
, ACPI_SYSTEM_NOTIFY
,
986 &acpi_bus_notify
, NULL
);
987 if (ACPI_FAILURE(status
)) {
988 printk(KERN_ERR PREFIX
989 "Unable to register for device notifications\n");
994 * Create the top ACPI proc directory
996 acpi_root_dir
= proc_mkdir(ACPI_BUS_FILE_ROOT
, NULL
);
1000 /* Mimic structured exception handling */
1006 struct kobject
*acpi_kobj
;
1008 static int __init
acpi_init(void)
1012 if (acpi_disabled
) {
1013 printk(KERN_INFO PREFIX
"Interpreter disabled.\n");
1017 acpi_kobj
= kobject_create_and_add("acpi", firmware_kobj
);
1019 printk(KERN_WARNING
"%s: kset create error\n", __func__
);
1023 init_acpi_device_notify();
1024 result
= acpi_bus_init();
1030 pci_mmcfg_late_init();
1033 acpi_debugfs_init();
1034 acpi_sleep_proc_init();
1035 acpi_wakeup_device_init();
1039 subsys_initcall(acpi_init
);