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>
46 #define _COMPONENT ACPI_BUS_COMPONENT
47 ACPI_MODULE_NAME("bus");
49 struct acpi_device
*acpi_root
;
50 struct proc_dir_entry
*acpi_root_dir
;
51 EXPORT_SYMBOL(acpi_root_dir
);
53 #define STRUCT_TO_INT(s) (*((int*)&s))
55 static int set_power_nocheck(const struct dmi_system_id
*id
)
57 printk(KERN_NOTICE PREFIX
"%s detected - "
58 "disable power check in power transistion\n", id
->ident
);
59 acpi_power_nocheck
= 1;
62 static struct dmi_system_id __cpuinitdata power_nocheck_dmi_table
[] = {
64 set_power_nocheck
, "HP Pavilion 05", {
65 DMI_MATCH(DMI_BIOS_VENDOR
, "Phoenix Technologies LTD"),
66 DMI_MATCH(DMI_SYS_VENDOR
, "HP Pavilion 05"),
67 DMI_MATCH(DMI_PRODUCT_VERSION
, "2001211RE101GLEND") }, NULL
},
73 static int set_copy_dsdt(const struct dmi_system_id
*id
)
75 printk(KERN_NOTICE
"%s detected - "
76 "force copy of DSDT to local memory\n", id
->ident
);
77 acpi_gbl_copy_dsdt_locally
= 1;
81 static struct dmi_system_id dsdt_dmi_table
[] __initdata
= {
83 * Insyde BIOS on some TOSHIBA machines corrupt the DSDT.
84 * https://bugzilla.kernel.org/show_bug.cgi?id=14679
87 .callback
= set_copy_dsdt
,
88 .ident
= "TOSHIBA Satellite A505",
90 DMI_MATCH(DMI_SYS_VENDOR
, "TOSHIBA"),
91 DMI_MATCH(DMI_PRODUCT_NAME
, "Satellite A505"),
95 .callback
= set_copy_dsdt
,
96 .ident
= "TOSHIBA Satellite L505D",
98 DMI_MATCH(DMI_SYS_VENDOR
, "TOSHIBA"),
99 DMI_MATCH(DMI_PRODUCT_NAME
, "Satellite L505D"),
105 static struct dmi_system_id dsdt_dmi_table
[] __initdata
= {
110 /* --------------------------------------------------------------------------
112 -------------------------------------------------------------------------- */
114 int acpi_bus_get_device(acpi_handle handle
, struct acpi_device
**device
)
116 acpi_status status
= AE_OK
;
122 /* TBD: Support fixed-feature devices */
124 status
= acpi_get_data(handle
, acpi_bus_data_handler
, (void **)device
);
125 if (ACPI_FAILURE(status
) || !*device
) {
126 ACPI_DEBUG_PRINT((ACPI_DB_INFO
, "No context for object [%p]\n",
134 EXPORT_SYMBOL(acpi_bus_get_device
);
136 acpi_status
acpi_bus_get_status_handle(acpi_handle handle
,
137 unsigned long long *sta
)
141 status
= acpi_evaluate_integer(handle
, "_STA", NULL
, sta
);
142 if (ACPI_SUCCESS(status
))
145 if (status
== AE_NOT_FOUND
) {
146 *sta
= ACPI_STA_DEVICE_PRESENT
| ACPI_STA_DEVICE_ENABLED
|
147 ACPI_STA_DEVICE_UI
| ACPI_STA_DEVICE_FUNCTIONING
;
153 int acpi_bus_get_status(struct acpi_device
*device
)
156 unsigned long long sta
;
158 status
= acpi_bus_get_status_handle(device
->handle
, &sta
);
159 if (ACPI_FAILURE(status
))
162 STRUCT_TO_INT(device
->status
) = (int) sta
;
164 if (device
->status
.functional
&& !device
->status
.present
) {
165 ACPI_DEBUG_PRINT((ACPI_DB_INFO
, "Device [%s] status [%08x]: "
166 "functional but not present;\n",
168 (u32
) STRUCT_TO_INT(device
->status
)));
171 ACPI_DEBUG_PRINT((ACPI_DB_INFO
, "Device [%s] status [%08x]\n",
173 (u32
) STRUCT_TO_INT(device
->status
)));
176 EXPORT_SYMBOL(acpi_bus_get_status
);
178 void acpi_bus_private_data_handler(acpi_handle handle
,
183 EXPORT_SYMBOL(acpi_bus_private_data_handler
);
185 int acpi_bus_get_private_data(acpi_handle handle
, void **data
)
187 acpi_status status
= AE_OK
;
192 status
= acpi_get_data(handle
, acpi_bus_private_data_handler
, data
);
193 if (ACPI_FAILURE(status
) || !*data
) {
194 ACPI_DEBUG_PRINT((ACPI_DB_INFO
, "No context for object [%p]\n",
201 EXPORT_SYMBOL(acpi_bus_get_private_data
);
203 /* --------------------------------------------------------------------------
205 -------------------------------------------------------------------------- */
207 int acpi_bus_get_power(acpi_handle handle
, int *state
)
210 acpi_status status
= 0;
211 struct acpi_device
*device
= NULL
;
212 unsigned long long psc
= 0;
215 result
= acpi_bus_get_device(handle
, &device
);
219 *state
= ACPI_STATE_UNKNOWN
;
221 if (!device
->flags
.power_manageable
) {
222 /* TBD: Non-recursive algorithm for walking up hierarchy */
224 *state
= device
->parent
->power
.state
;
226 *state
= ACPI_STATE_D0
;
229 * Get the device's power state either directly (via _PSC) or
230 * indirectly (via power resources).
232 if (device
->power
.flags
.power_resources
) {
233 result
= acpi_power_get_inferred_state(device
);
236 } else if (device
->power
.flags
.explicit_get
) {
237 status
= acpi_evaluate_integer(device
->handle
, "_PSC",
239 if (ACPI_FAILURE(status
))
241 device
->power
.state
= (int)psc
;
244 *state
= device
->power
.state
;
247 ACPI_DEBUG_PRINT((ACPI_DB_INFO
, "Device [%s] power state is D%d\n",
248 device
->pnp
.bus_id
, device
->power
.state
));
253 EXPORT_SYMBOL(acpi_bus_get_power
);
255 int acpi_bus_set_power(acpi_handle handle
, int state
)
258 acpi_status status
= AE_OK
;
259 struct acpi_device
*device
= NULL
;
260 char object_name
[5] = { '_', 'P', 'S', '0' + state
, '\0' };
263 result
= acpi_bus_get_device(handle
, &device
);
267 if ((state
< ACPI_STATE_D0
) || (state
> ACPI_STATE_D3
))
270 /* Make sure this is a valid target state */
272 if (!device
->flags
.power_manageable
) {
273 ACPI_DEBUG_PRINT((ACPI_DB_INFO
, "Device `[%s]' is not power manageable\n",
274 kobject_name(&device
->dev
.kobj
)));
278 * Get device's current power state
280 if (!acpi_power_nocheck
) {
282 * Maybe the incorrect power state is returned on the bogus
283 * bios, which is different with the real power state.
284 * For example: the bios returns D0 state and the real power
285 * state is D3. OS expects to set the device to D0 state. In
286 * such case if OS uses the power state returned by the BIOS,
287 * the device can't be transisted to the correct power state.
288 * So if the acpi_power_nocheck is set, it is unnecessary to
289 * get the power state by calling acpi_bus_get_power.
291 acpi_bus_get_power(device
->handle
, &device
->power
.state
);
293 if ((state
== device
->power
.state
) && !device
->flags
.force_power_state
) {
294 ACPI_DEBUG_PRINT((ACPI_DB_INFO
, "Device is already at D%d\n",
299 if (!device
->power
.states
[state
].flags
.valid
) {
300 printk(KERN_WARNING PREFIX
"Device does not support D%d\n", state
);
303 if (device
->parent
&& (state
< device
->parent
->power
.state
)) {
304 printk(KERN_WARNING PREFIX
305 "Cannot set device to a higher-powered"
306 " state than parent\n");
313 * On transitions to a high-powered state we first apply power (via
314 * power resources) then evalute _PSx. Conversly for transitions to
315 * a lower-powered state.
317 if (state
< device
->power
.state
) {
318 if (device
->power
.flags
.power_resources
) {
319 result
= acpi_power_transition(device
, state
);
323 if (device
->power
.states
[state
].flags
.explicit_set
) {
324 status
= acpi_evaluate_object(device
->handle
,
325 object_name
, NULL
, NULL
);
326 if (ACPI_FAILURE(status
)) {
332 if (device
->power
.states
[state
].flags
.explicit_set
) {
333 status
= acpi_evaluate_object(device
->handle
,
334 object_name
, NULL
, NULL
);
335 if (ACPI_FAILURE(status
)) {
340 if (device
->power
.flags
.power_resources
) {
341 result
= acpi_power_transition(device
, state
);
349 printk(KERN_WARNING PREFIX
350 "Device [%s] failed to transition to D%d\n",
351 device
->pnp
.bus_id
, state
);
353 device
->power
.state
= state
;
354 ACPI_DEBUG_PRINT((ACPI_DB_INFO
,
355 "Device [%s] transitioned to D%d\n",
356 device
->pnp
.bus_id
, state
));
362 EXPORT_SYMBOL(acpi_bus_set_power
);
364 bool acpi_bus_power_manageable(acpi_handle handle
)
366 struct acpi_device
*device
;
369 result
= acpi_bus_get_device(handle
, &device
);
370 return result
? false : device
->flags
.power_manageable
;
373 EXPORT_SYMBOL(acpi_bus_power_manageable
);
375 bool acpi_bus_can_wakeup(acpi_handle handle
)
377 struct acpi_device
*device
;
380 result
= acpi_bus_get_device(handle
, &device
);
381 return result
? false : device
->wakeup
.flags
.valid
;
384 EXPORT_SYMBOL(acpi_bus_can_wakeup
);
386 static void acpi_print_osc_error(acpi_handle handle
,
387 struct acpi_osc_context
*context
, char *error
)
389 struct acpi_buffer buffer
= {ACPI_ALLOCATE_BUFFER
};
392 if (ACPI_FAILURE(acpi_get_name(handle
, ACPI_FULL_PATHNAME
, &buffer
)))
393 printk(KERN_DEBUG
"%s\n", error
);
395 printk(KERN_DEBUG
"%s:%s\n", (char *)buffer
.pointer
, error
);
396 kfree(buffer
.pointer
);
398 printk(KERN_DEBUG
"_OSC request data:");
399 for (i
= 0; i
< context
->cap
.length
; i
+= sizeof(u32
))
400 printk("%x ", *((u32
*)(context
->cap
.pointer
+ i
)));
404 static acpi_status
acpi_str_to_uuid(char *str
, u8
*uuid
)
407 static int opc_map_to_uuid
[16] = {6, 4, 2, 0, 11, 9, 16, 14, 19, 21,
408 24, 26, 28, 30, 32, 34};
410 if (strlen(str
) != 36)
411 return AE_BAD_PARAMETER
;
412 for (i
= 0; i
< 36; i
++) {
413 if (i
== 8 || i
== 13 || i
== 18 || i
== 23) {
415 return AE_BAD_PARAMETER
;
416 } else if (!isxdigit(str
[i
]))
417 return AE_BAD_PARAMETER
;
419 for (i
= 0; i
< 16; i
++) {
420 uuid
[i
] = hex_to_bin(str
[opc_map_to_uuid
[i
]]) << 4;
421 uuid
[i
] |= hex_to_bin(str
[opc_map_to_uuid
[i
] + 1]);
426 acpi_status
acpi_run_osc(acpi_handle handle
, struct acpi_osc_context
*context
)
429 struct acpi_object_list input
;
430 union acpi_object in_params
[4];
431 union acpi_object
*out_obj
;
434 struct acpi_buffer output
= {ACPI_ALLOCATE_BUFFER
, NULL
};
438 if (ACPI_FAILURE(acpi_str_to_uuid(context
->uuid_str
, uuid
)))
440 context
->ret
.length
= ACPI_ALLOCATE_BUFFER
;
441 context
->ret
.pointer
= NULL
;
443 /* Setting up input parameters */
445 input
.pointer
= in_params
;
446 in_params
[0].type
= ACPI_TYPE_BUFFER
;
447 in_params
[0].buffer
.length
= 16;
448 in_params
[0].buffer
.pointer
= uuid
;
449 in_params
[1].type
= ACPI_TYPE_INTEGER
;
450 in_params
[1].integer
.value
= context
->rev
;
451 in_params
[2].type
= ACPI_TYPE_INTEGER
;
452 in_params
[2].integer
.value
= context
->cap
.length
/sizeof(u32
);
453 in_params
[3].type
= ACPI_TYPE_BUFFER
;
454 in_params
[3].buffer
.length
= context
->cap
.length
;
455 in_params
[3].buffer
.pointer
= context
->cap
.pointer
;
457 status
= acpi_evaluate_object(handle
, "_OSC", &input
, &output
);
458 if (ACPI_FAILURE(status
))
462 return AE_NULL_OBJECT
;
464 out_obj
= output
.pointer
;
465 if (out_obj
->type
!= ACPI_TYPE_BUFFER
466 || out_obj
->buffer
.length
!= context
->cap
.length
) {
467 acpi_print_osc_error(handle
, context
,
468 "_OSC evaluation returned wrong type");
472 /* Need to ignore the bit0 in result code */
473 errors
= *((u32
*)out_obj
->buffer
.pointer
) & ~(1 << 0);
475 if (errors
& OSC_REQUEST_ERROR
)
476 acpi_print_osc_error(handle
, context
,
477 "_OSC request failed");
478 if (errors
& OSC_INVALID_UUID_ERROR
)
479 acpi_print_osc_error(handle
, context
,
480 "_OSC invalid UUID");
481 if (errors
& OSC_INVALID_REVISION_ERROR
)
482 acpi_print_osc_error(handle
, context
,
483 "_OSC invalid revision");
484 if (errors
& OSC_CAPABILITIES_MASK_ERROR
) {
485 if (((u32
*)context
->cap
.pointer
)[OSC_QUERY_TYPE
]
495 context
->ret
.length
= out_obj
->buffer
.length
;
496 context
->ret
.pointer
= kmalloc(context
->ret
.length
, GFP_KERNEL
);
497 if (!context
->ret
.pointer
) {
498 status
= AE_NO_MEMORY
;
501 memcpy(context
->ret
.pointer
, out_obj
->buffer
.pointer
,
502 context
->ret
.length
);
506 kfree(output
.pointer
);
508 context
->ret
.pointer
= NULL
;
511 EXPORT_SYMBOL(acpi_run_osc
);
513 static u8 sb_uuid_str
[] = "0811B06E-4A27-44F9-8D60-3CBBC22E7B48";
514 static void acpi_bus_osc_support(void)
517 struct acpi_osc_context context
= {
518 .uuid_str
= sb_uuid_str
,
521 .cap
.pointer
= capbuf
,
525 capbuf
[OSC_QUERY_TYPE
] = OSC_QUERY_ENABLE
;
526 capbuf
[OSC_SUPPORT_TYPE
] = OSC_SB_PR3_SUPPORT
; /* _PR3 is in use */
527 #if defined(CONFIG_ACPI_PROCESSOR_AGGREGATOR) ||\
528 defined(CONFIG_ACPI_PROCESSOR_AGGREGATOR_MODULE)
529 capbuf
[OSC_SUPPORT_TYPE
] |= OSC_SB_PAD_SUPPORT
;
532 #if defined(CONFIG_ACPI_PROCESSOR) || defined(CONFIG_ACPI_PROCESSOR_MODULE)
533 capbuf
[OSC_SUPPORT_TYPE
] |= OSC_SB_PPC_OST_SUPPORT
;
535 if (ACPI_FAILURE(acpi_get_handle(NULL
, "\\_SB", &handle
)))
537 if (ACPI_SUCCESS(acpi_run_osc(handle
, &context
)))
538 kfree(context
.ret
.pointer
);
539 /* do we need to check the returned cap? Sounds no */
542 /* --------------------------------------------------------------------------
544 -------------------------------------------------------------------------- */
546 #ifdef CONFIG_ACPI_PROC_EVENT
547 static DEFINE_SPINLOCK(acpi_bus_event_lock
);
549 LIST_HEAD(acpi_bus_event_list
);
550 DECLARE_WAIT_QUEUE_HEAD(acpi_bus_event_queue
);
552 extern int event_is_open
;
554 int acpi_bus_generate_proc_event4(const char *device_class
, const char *bus_id
, u8 type
, int data
)
556 struct acpi_bus_event
*event
;
557 unsigned long flags
= 0;
559 /* drop event on the floor if no one's listening */
563 event
= kzalloc(sizeof(struct acpi_bus_event
), GFP_ATOMIC
);
567 strcpy(event
->device_class
, device_class
);
568 strcpy(event
->bus_id
, bus_id
);
572 spin_lock_irqsave(&acpi_bus_event_lock
, flags
);
573 list_add_tail(&event
->node
, &acpi_bus_event_list
);
574 spin_unlock_irqrestore(&acpi_bus_event_lock
, flags
);
576 wake_up_interruptible(&acpi_bus_event_queue
);
582 EXPORT_SYMBOL_GPL(acpi_bus_generate_proc_event4
);
584 int acpi_bus_generate_proc_event(struct acpi_device
*device
, u8 type
, int data
)
588 return acpi_bus_generate_proc_event4(device
->pnp
.device_class
,
589 device
->pnp
.bus_id
, type
, data
);
592 EXPORT_SYMBOL(acpi_bus_generate_proc_event
);
594 int acpi_bus_receive_event(struct acpi_bus_event
*event
)
596 unsigned long flags
= 0;
597 struct acpi_bus_event
*entry
= NULL
;
599 DECLARE_WAITQUEUE(wait
, current
);
605 if (list_empty(&acpi_bus_event_list
)) {
607 set_current_state(TASK_INTERRUPTIBLE
);
608 add_wait_queue(&acpi_bus_event_queue
, &wait
);
610 if (list_empty(&acpi_bus_event_list
))
613 remove_wait_queue(&acpi_bus_event_queue
, &wait
);
614 set_current_state(TASK_RUNNING
);
616 if (signal_pending(current
))
620 spin_lock_irqsave(&acpi_bus_event_lock
, flags
);
621 if (!list_empty(&acpi_bus_event_list
)) {
622 entry
= list_entry(acpi_bus_event_list
.next
,
623 struct acpi_bus_event
, node
);
624 list_del(&entry
->node
);
626 spin_unlock_irqrestore(&acpi_bus_event_lock
, flags
);
631 memcpy(event
, entry
, sizeof(struct acpi_bus_event
));
638 #endif /* CONFIG_ACPI_PROC_EVENT */
640 /* --------------------------------------------------------------------------
641 Notification Handling
642 -------------------------------------------------------------------------- */
644 static void acpi_bus_check_device(acpi_handle handle
)
646 struct acpi_device
*device
;
648 struct acpi_device_status old_status
;
650 if (acpi_bus_get_device(handle
, &device
))
655 old_status
= device
->status
;
658 * Make sure this device's parent is present before we go about
659 * messing with the device.
661 if (device
->parent
&& !device
->parent
->status
.present
) {
662 device
->status
= device
->parent
->status
;
666 status
= acpi_bus_get_status(device
);
667 if (ACPI_FAILURE(status
))
670 if (STRUCT_TO_INT(old_status
) == STRUCT_TO_INT(device
->status
))
674 * Device Insertion/Removal
676 if ((device
->status
.present
) && !(old_status
.present
)) {
677 ACPI_DEBUG_PRINT((ACPI_DB_INFO
, "Device insertion detected\n"));
678 /* TBD: Handle device insertion */
679 } else if (!(device
->status
.present
) && (old_status
.present
)) {
680 ACPI_DEBUG_PRINT((ACPI_DB_INFO
, "Device removal detected\n"));
681 /* TBD: Handle device removal */
685 static void acpi_bus_check_scope(acpi_handle handle
)
688 acpi_bus_check_device(handle
);
691 * TBD: Enumerate child devices within this device's scope and
692 * run acpi_bus_check_device()'s on them.
696 static BLOCKING_NOTIFIER_HEAD(acpi_bus_notify_list
);
697 int register_acpi_bus_notifier(struct notifier_block
*nb
)
699 return blocking_notifier_chain_register(&acpi_bus_notify_list
, nb
);
701 EXPORT_SYMBOL_GPL(register_acpi_bus_notifier
);
703 void unregister_acpi_bus_notifier(struct notifier_block
*nb
)
705 blocking_notifier_chain_unregister(&acpi_bus_notify_list
, nb
);
707 EXPORT_SYMBOL_GPL(unregister_acpi_bus_notifier
);
712 * Callback for all 'system-level' device notifications (values 0x00-0x7F).
714 static void acpi_bus_notify(acpi_handle handle
, u32 type
, void *data
)
716 struct acpi_device
*device
= NULL
;
717 struct acpi_driver
*driver
;
719 ACPI_DEBUG_PRINT((ACPI_DB_INFO
, "Notification %#02x to handle %p\n",
722 blocking_notifier_call_chain(&acpi_bus_notify_list
,
723 type
, (void *)handle
);
727 case ACPI_NOTIFY_BUS_CHECK
:
728 acpi_bus_check_scope(handle
);
730 * TBD: We'll need to outsource certain events to non-ACPI
731 * drivers via the device manager (device.c).
735 case ACPI_NOTIFY_DEVICE_CHECK
:
736 acpi_bus_check_device(handle
);
738 * TBD: We'll need to outsource certain events to non-ACPI
739 * drivers via the device manager (device.c).
743 case ACPI_NOTIFY_DEVICE_WAKE
:
747 case ACPI_NOTIFY_EJECT_REQUEST
:
751 case ACPI_NOTIFY_DEVICE_CHECK_LIGHT
:
752 /* TBD: Exactly what does 'light' mean? */
755 case ACPI_NOTIFY_FREQUENCY_MISMATCH
:
759 case ACPI_NOTIFY_BUS_MODE_MISMATCH
:
763 case ACPI_NOTIFY_POWER_FAULT
:
768 ACPI_DEBUG_PRINT((ACPI_DB_INFO
,
769 "Received unknown/unsupported notification [%08x]\n",
774 acpi_bus_get_device(handle
, &device
);
776 driver
= device
->driver
;
777 if (driver
&& driver
->ops
.notify
&&
778 (driver
->flags
& ACPI_DRIVER_ALL_NOTIFY_EVENTS
))
779 driver
->ops
.notify(device
, type
);
783 /* --------------------------------------------------------------------------
784 Initialization/Cleanup
785 -------------------------------------------------------------------------- */
787 static int __init
acpi_bus_init_irq(void)
789 acpi_status status
= AE_OK
;
790 union acpi_object arg
= { ACPI_TYPE_INTEGER
};
791 struct acpi_object_list arg_list
= { 1, &arg
};
792 char *message
= NULL
;
796 * Let the system know what interrupt model we are using by
797 * evaluating the \_PIC object, if exists.
800 switch (acpi_irq_model
) {
801 case ACPI_IRQ_MODEL_PIC
:
804 case ACPI_IRQ_MODEL_IOAPIC
:
807 case ACPI_IRQ_MODEL_IOSAPIC
:
810 case ACPI_IRQ_MODEL_PLATFORM
:
811 message
= "platform specific model";
814 printk(KERN_WARNING PREFIX
"Unknown interrupt routing model\n");
818 printk(KERN_INFO PREFIX
"Using %s for interrupt routing\n", message
);
820 arg
.integer
.value
= acpi_irq_model
;
822 status
= acpi_evaluate_object(NULL
, "\\_PIC", &arg_list
, NULL
);
823 if (ACPI_FAILURE(status
) && (status
!= AE_NOT_FOUND
)) {
824 ACPI_EXCEPTION((AE_INFO
, status
, "Evaluating _PIC"));
831 u8 acpi_gbl_permanent_mmap
;
834 void __init
acpi_early_init(void)
836 acpi_status status
= AE_OK
;
841 printk(KERN_INFO PREFIX
"Core revision %08x\n", ACPI_CA_VERSION
);
843 /* enable workarounds, unless strict ACPI spec. compliance */
845 acpi_gbl_enable_interpreter_slack
= TRUE
;
847 acpi_gbl_permanent_mmap
= 1;
850 * If the machine falls into the DMI check table,
851 * DSDT will be copied to memory
853 dmi_check_system(dsdt_dmi_table
);
855 status
= acpi_reallocate_root_table();
856 if (ACPI_FAILURE(status
)) {
857 printk(KERN_ERR PREFIX
858 "Unable to reallocate ACPI tables\n");
862 status
= acpi_initialize_subsystem();
863 if (ACPI_FAILURE(status
)) {
864 printk(KERN_ERR PREFIX
865 "Unable to initialize the ACPI Interpreter\n");
869 status
= acpi_load_tables();
870 if (ACPI_FAILURE(status
)) {
871 printk(KERN_ERR PREFIX
872 "Unable to load the System Description Tables\n");
878 /* compatible (0) means level (3) */
879 if (!(acpi_sci_flags
& ACPI_MADT_TRIGGER_MASK
)) {
880 acpi_sci_flags
&= ~ACPI_MADT_TRIGGER_MASK
;
881 acpi_sci_flags
|= ACPI_MADT_TRIGGER_LEVEL
;
883 /* Set PIC-mode SCI trigger type */
884 acpi_pic_sci_set_trigger(acpi_gbl_FADT
.sci_interrupt
,
885 (acpi_sci_flags
& ACPI_MADT_TRIGGER_MASK
) >> 2);
888 * now that acpi_gbl_FADT is initialized,
889 * update it with result from INT_SRC_OVR parsing
891 acpi_gbl_FADT
.sci_interrupt
= acpi_sci_override_gsi
;
896 acpi_enable_subsystem(~
897 (ACPI_NO_HARDWARE_INIT
|
898 ACPI_NO_ACPI_ENABLE
));
899 if (ACPI_FAILURE(status
)) {
900 printk(KERN_ERR PREFIX
"Unable to enable ACPI\n");
911 static int __init
acpi_bus_init(void)
914 acpi_status status
= AE_OK
;
915 extern acpi_status
acpi_os_initialize1(void);
917 acpi_os_initialize1();
920 acpi_enable_subsystem(ACPI_NO_HARDWARE_INIT
| ACPI_NO_ACPI_ENABLE
);
921 if (ACPI_FAILURE(status
)) {
922 printk(KERN_ERR PREFIX
923 "Unable to start the ACPI Interpreter\n");
928 * ACPI 2.0 requires the EC driver to be loaded and work before
929 * the EC device is found in the namespace (i.e. before acpi_initialize_objects()
932 * This is accomplished by looking for the ECDT table, and getting
933 * the EC parameters out of that.
935 status
= acpi_ec_ecdt_probe();
936 /* Ignore result. Not having an ECDT is not fatal. */
938 acpi_bus_osc_support();
940 status
= acpi_initialize_objects(ACPI_FULL_INITIALIZATION
);
941 if (ACPI_FAILURE(status
)) {
942 printk(KERN_ERR PREFIX
"Unable to initialize ACPI objects\n");
946 acpi_early_processor_set_pdc();
949 * Maybe EC region is required at bus_scan/acpi_get_devices. So it
950 * is necessary to enable it as early as possible.
952 acpi_boot_ec_enable();
954 printk(KERN_INFO PREFIX
"Interpreter enabled\n");
956 /* Initialize sleep structures */
960 * Get the system interrupt model and evaluate \_PIC.
962 result
= acpi_bus_init_irq();
967 * Register the for all standard device notifications.
970 acpi_install_notify_handler(ACPI_ROOT_OBJECT
, ACPI_SYSTEM_NOTIFY
,
971 &acpi_bus_notify
, NULL
);
972 if (ACPI_FAILURE(status
)) {
973 printk(KERN_ERR PREFIX
974 "Unable to register for device notifications\n");
979 * Create the top ACPI proc directory
981 acpi_root_dir
= proc_mkdir(ACPI_BUS_FILE_ROOT
, NULL
);
985 /* Mimic structured exception handling */
991 struct kobject
*acpi_kobj
;
993 static int __init
acpi_init(void)
999 printk(KERN_INFO PREFIX
"Interpreter disabled.\n");
1003 acpi_kobj
= kobject_create_and_add("acpi", firmware_kobj
);
1005 printk(KERN_WARNING
"%s: kset create error\n", __func__
);
1009 init_acpi_device_notify();
1010 result
= acpi_bus_init();
1013 pci_mmcfg_late_init();
1014 if (!(pm_flags
& PM_APM
))
1015 pm_flags
|= PM_ACPI
;
1017 printk(KERN_INFO PREFIX
1018 "APM is already active, exiting\n");
1029 * If the laptop falls into the DMI check table, the power state check
1030 * will be disabled in the course of device power transistion.
1032 dmi_check_system(power_nocheck_dmi_table
);
1039 acpi_sleep_proc_init();
1040 acpi_wakeup_device_init();
1044 subsys_initcall(acpi_init
);