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
},
72 static int set_copy_dsdt(const struct dmi_system_id
*id
)
74 printk(KERN_NOTICE
"%s detected - "
75 "force copy of DSDT to local memory\n", id
->ident
);
76 acpi_gbl_copy_dsdt_locally
= 1;
80 static struct dmi_system_id dsdt_dmi_table
[] __initdata
= {
82 * Insyde BIOS on some TOSHIBA machines corrupt the DSDT.
83 * https://bugzilla.kernel.org/show_bug.cgi?id=14679
86 .callback
= set_copy_dsdt
,
87 .ident
= "TOSHIBA Satellite A505",
89 DMI_MATCH(DMI_SYS_VENDOR
, "TOSHIBA"),
90 DMI_MATCH(DMI_PRODUCT_NAME
, "Satellite A505"),
94 .callback
= set_copy_dsdt
,
95 .ident
= "TOSHIBA Satellite L505D",
97 DMI_MATCH(DMI_SYS_VENDOR
, "TOSHIBA"),
98 DMI_MATCH(DMI_PRODUCT_NAME
, "Satellite L505D"),
103 /* --------------------------------------------------------------------------
105 -------------------------------------------------------------------------- */
107 int acpi_bus_get_device(acpi_handle handle
, struct acpi_device
**device
)
109 acpi_status status
= AE_OK
;
115 /* TBD: Support fixed-feature devices */
117 status
= acpi_get_data(handle
, acpi_bus_data_handler
, (void **)device
);
118 if (ACPI_FAILURE(status
) || !*device
) {
119 ACPI_DEBUG_PRINT((ACPI_DB_INFO
, "No context for object [%p]\n",
127 EXPORT_SYMBOL(acpi_bus_get_device
);
129 acpi_status
acpi_bus_get_status_handle(acpi_handle handle
,
130 unsigned long long *sta
)
134 status
= acpi_evaluate_integer(handle
, "_STA", NULL
, sta
);
135 if (ACPI_SUCCESS(status
))
138 if (status
== AE_NOT_FOUND
) {
139 *sta
= ACPI_STA_DEVICE_PRESENT
| ACPI_STA_DEVICE_ENABLED
|
140 ACPI_STA_DEVICE_UI
| ACPI_STA_DEVICE_FUNCTIONING
;
146 int acpi_bus_get_status(struct acpi_device
*device
)
149 unsigned long long sta
;
151 status
= acpi_bus_get_status_handle(device
->handle
, &sta
);
152 if (ACPI_FAILURE(status
))
155 STRUCT_TO_INT(device
->status
) = (int) sta
;
157 if (device
->status
.functional
&& !device
->status
.present
) {
158 ACPI_DEBUG_PRINT((ACPI_DB_INFO
, "Device [%s] status [%08x]: "
159 "functional but not present;\n",
161 (u32
) STRUCT_TO_INT(device
->status
)));
164 ACPI_DEBUG_PRINT((ACPI_DB_INFO
, "Device [%s] status [%08x]\n",
166 (u32
) STRUCT_TO_INT(device
->status
)));
169 EXPORT_SYMBOL(acpi_bus_get_status
);
171 void acpi_bus_private_data_handler(acpi_handle handle
,
176 EXPORT_SYMBOL(acpi_bus_private_data_handler
);
178 int acpi_bus_get_private_data(acpi_handle handle
, void **data
)
180 acpi_status status
= AE_OK
;
185 status
= acpi_get_data(handle
, acpi_bus_private_data_handler
, data
);
186 if (ACPI_FAILURE(status
) || !*data
) {
187 ACPI_DEBUG_PRINT((ACPI_DB_INFO
, "No context for object [%p]\n",
194 EXPORT_SYMBOL(acpi_bus_get_private_data
);
196 /* --------------------------------------------------------------------------
198 -------------------------------------------------------------------------- */
200 int acpi_bus_get_power(acpi_handle handle
, int *state
)
203 acpi_status status
= 0;
204 struct acpi_device
*device
= NULL
;
205 unsigned long long psc
= 0;
208 result
= acpi_bus_get_device(handle
, &device
);
212 *state
= ACPI_STATE_UNKNOWN
;
214 if (!device
->flags
.power_manageable
) {
215 /* TBD: Non-recursive algorithm for walking up hierarchy */
217 *state
= device
->parent
->power
.state
;
219 *state
= ACPI_STATE_D0
;
222 * Get the device's power state either directly (via _PSC) or
223 * indirectly (via power resources).
225 if (device
->power
.flags
.power_resources
) {
226 result
= acpi_power_get_inferred_state(device
);
229 } else if (device
->power
.flags
.explicit_get
) {
230 status
= acpi_evaluate_integer(device
->handle
, "_PSC",
232 if (ACPI_FAILURE(status
))
234 device
->power
.state
= (int)psc
;
237 *state
= device
->power
.state
;
240 ACPI_DEBUG_PRINT((ACPI_DB_INFO
, "Device [%s] power state is D%d\n",
241 device
->pnp
.bus_id
, device
->power
.state
));
246 EXPORT_SYMBOL(acpi_bus_get_power
);
248 int acpi_bus_set_power(acpi_handle handle
, int state
)
251 acpi_status status
= AE_OK
;
252 struct acpi_device
*device
= NULL
;
253 char object_name
[5] = { '_', 'P', 'S', '0' + state
, '\0' };
256 result
= acpi_bus_get_device(handle
, &device
);
260 if ((state
< ACPI_STATE_D0
) || (state
> ACPI_STATE_D3
))
263 /* Make sure this is a valid target state */
265 if (!device
->flags
.power_manageable
) {
266 ACPI_DEBUG_PRINT((ACPI_DB_INFO
, "Device `[%s]' is not power manageable\n",
267 kobject_name(&device
->dev
.kobj
)));
271 * Get device's current power state
273 if (!acpi_power_nocheck
) {
275 * Maybe the incorrect power state is returned on the bogus
276 * bios, which is different with the real power state.
277 * For example: the bios returns D0 state and the real power
278 * state is D3. OS expects to set the device to D0 state. In
279 * such case if OS uses the power state returned by the BIOS,
280 * the device can't be transisted to the correct power state.
281 * So if the acpi_power_nocheck is set, it is unnecessary to
282 * get the power state by calling acpi_bus_get_power.
284 acpi_bus_get_power(device
->handle
, &device
->power
.state
);
286 if ((state
== device
->power
.state
) && !device
->flags
.force_power_state
) {
287 ACPI_DEBUG_PRINT((ACPI_DB_INFO
, "Device is already at D%d\n",
292 if (!device
->power
.states
[state
].flags
.valid
) {
293 printk(KERN_WARNING PREFIX
"Device does not support D%d\n", state
);
296 if (device
->parent
&& (state
< device
->parent
->power
.state
)) {
297 printk(KERN_WARNING PREFIX
298 "Cannot set device to a higher-powered"
299 " state than parent\n");
306 * On transitions to a high-powered state we first apply power (via
307 * power resources) then evalute _PSx. Conversly for transitions to
308 * a lower-powered state.
310 if (state
< device
->power
.state
) {
311 if (device
->power
.flags
.power_resources
) {
312 result
= acpi_power_transition(device
, state
);
316 if (device
->power
.states
[state
].flags
.explicit_set
) {
317 status
= acpi_evaluate_object(device
->handle
,
318 object_name
, NULL
, NULL
);
319 if (ACPI_FAILURE(status
)) {
325 if (device
->power
.states
[state
].flags
.explicit_set
) {
326 status
= acpi_evaluate_object(device
->handle
,
327 object_name
, NULL
, NULL
);
328 if (ACPI_FAILURE(status
)) {
333 if (device
->power
.flags
.power_resources
) {
334 result
= acpi_power_transition(device
, state
);
342 printk(KERN_WARNING PREFIX
343 "Device [%s] failed to transition to D%d\n",
344 device
->pnp
.bus_id
, state
);
346 device
->power
.state
= state
;
347 ACPI_DEBUG_PRINT((ACPI_DB_INFO
,
348 "Device [%s] transitioned to D%d\n",
349 device
->pnp
.bus_id
, state
));
355 EXPORT_SYMBOL(acpi_bus_set_power
);
357 bool acpi_bus_power_manageable(acpi_handle handle
)
359 struct acpi_device
*device
;
362 result
= acpi_bus_get_device(handle
, &device
);
363 return result
? false : device
->flags
.power_manageable
;
366 EXPORT_SYMBOL(acpi_bus_power_manageable
);
368 bool acpi_bus_can_wakeup(acpi_handle handle
)
370 struct acpi_device
*device
;
373 result
= acpi_bus_get_device(handle
, &device
);
374 return result
? false : device
->wakeup
.flags
.valid
;
377 EXPORT_SYMBOL(acpi_bus_can_wakeup
);
379 static void acpi_print_osc_error(acpi_handle handle
,
380 struct acpi_osc_context
*context
, char *error
)
382 struct acpi_buffer buffer
= {ACPI_ALLOCATE_BUFFER
};
385 if (ACPI_FAILURE(acpi_get_name(handle
, ACPI_FULL_PATHNAME
, &buffer
)))
386 printk(KERN_DEBUG
"%s\n", error
);
388 printk(KERN_DEBUG
"%s:%s\n", (char *)buffer
.pointer
, error
);
389 kfree(buffer
.pointer
);
391 printk(KERN_DEBUG
"_OSC request data:");
392 for (i
= 0; i
< context
->cap
.length
; i
+= sizeof(u32
))
393 printk("%x ", *((u32
*)(context
->cap
.pointer
+ i
)));
397 static u8
hex_val(unsigned char c
)
399 return isdigit(c
) ? c
- '0' : toupper(c
) - 'A' + 10;
402 static acpi_status
acpi_str_to_uuid(char *str
, u8
*uuid
)
405 static int opc_map_to_uuid
[16] = {6, 4, 2, 0, 11, 9, 16, 14, 19, 21,
406 24, 26, 28, 30, 32, 34};
408 if (strlen(str
) != 36)
409 return AE_BAD_PARAMETER
;
410 for (i
= 0; i
< 36; i
++) {
411 if (i
== 8 || i
== 13 || i
== 18 || i
== 23) {
413 return AE_BAD_PARAMETER
;
414 } else if (!isxdigit(str
[i
]))
415 return AE_BAD_PARAMETER
;
417 for (i
= 0; i
< 16; i
++) {
418 uuid
[i
] = hex_val(str
[opc_map_to_uuid
[i
]]) << 4;
419 uuid
[i
] |= hex_val(str
[opc_map_to_uuid
[i
] + 1]);
424 acpi_status
acpi_run_osc(acpi_handle handle
, struct acpi_osc_context
*context
)
427 struct acpi_object_list input
;
428 union acpi_object in_params
[4];
429 union acpi_object
*out_obj
;
432 struct acpi_buffer output
= {ACPI_ALLOCATE_BUFFER
, NULL
};
436 if (ACPI_FAILURE(acpi_str_to_uuid(context
->uuid_str
, uuid
)))
438 context
->ret
.length
= ACPI_ALLOCATE_BUFFER
;
439 context
->ret
.pointer
= NULL
;
441 /* Setting up input parameters */
443 input
.pointer
= in_params
;
444 in_params
[0].type
= ACPI_TYPE_BUFFER
;
445 in_params
[0].buffer
.length
= 16;
446 in_params
[0].buffer
.pointer
= uuid
;
447 in_params
[1].type
= ACPI_TYPE_INTEGER
;
448 in_params
[1].integer
.value
= context
->rev
;
449 in_params
[2].type
= ACPI_TYPE_INTEGER
;
450 in_params
[2].integer
.value
= context
->cap
.length
/sizeof(u32
);
451 in_params
[3].type
= ACPI_TYPE_BUFFER
;
452 in_params
[3].buffer
.length
= context
->cap
.length
;
453 in_params
[3].buffer
.pointer
= context
->cap
.pointer
;
455 status
= acpi_evaluate_object(handle
, "_OSC", &input
, &output
);
456 if (ACPI_FAILURE(status
))
460 return AE_NULL_OBJECT
;
462 out_obj
= output
.pointer
;
463 if (out_obj
->type
!= ACPI_TYPE_BUFFER
464 || out_obj
->buffer
.length
!= context
->cap
.length
) {
465 acpi_print_osc_error(handle
, context
,
466 "_OSC evaluation returned wrong type");
470 /* Need to ignore the bit0 in result code */
471 errors
= *((u32
*)out_obj
->buffer
.pointer
) & ~(1 << 0);
473 if (errors
& OSC_REQUEST_ERROR
)
474 acpi_print_osc_error(handle
, context
,
475 "_OSC request failed");
476 if (errors
& OSC_INVALID_UUID_ERROR
)
477 acpi_print_osc_error(handle
, context
,
478 "_OSC invalid UUID");
479 if (errors
& OSC_INVALID_REVISION_ERROR
)
480 acpi_print_osc_error(handle
, context
,
481 "_OSC invalid revision");
482 if (errors
& OSC_CAPABILITIES_MASK_ERROR
) {
483 if (((u32
*)context
->cap
.pointer
)[OSC_QUERY_TYPE
]
493 context
->ret
.length
= out_obj
->buffer
.length
;
494 context
->ret
.pointer
= kmalloc(context
->ret
.length
, GFP_KERNEL
);
495 if (!context
->ret
.pointer
) {
496 status
= AE_NO_MEMORY
;
499 memcpy(context
->ret
.pointer
, out_obj
->buffer
.pointer
,
500 context
->ret
.length
);
504 kfree(output
.pointer
);
506 context
->ret
.pointer
= NULL
;
509 EXPORT_SYMBOL(acpi_run_osc
);
511 static u8 sb_uuid_str
[] = "0811B06E-4A27-44F9-8D60-3CBBC22E7B48";
512 static void acpi_bus_osc_support(void)
515 struct acpi_osc_context context
= {
516 .uuid_str
= sb_uuid_str
,
519 .cap
.pointer
= capbuf
,
523 capbuf
[OSC_QUERY_TYPE
] = OSC_QUERY_ENABLE
;
524 capbuf
[OSC_SUPPORT_TYPE
] = OSC_SB_PR3_SUPPORT
; /* _PR3 is in use */
525 #if defined(CONFIG_ACPI_PROCESSOR_AGGREGATOR) ||\
526 defined(CONFIG_ACPI_PROCESSOR_AGGREGATOR_MODULE)
527 capbuf
[OSC_SUPPORT_TYPE
] |= OSC_SB_PAD_SUPPORT
;
530 #if defined(CONFIG_ACPI_PROCESSOR) || defined(CONFIG_ACPI_PROCESSOR_MODULE)
531 capbuf
[OSC_SUPPORT_TYPE
] |= OSC_SB_PPC_OST_SUPPORT
;
533 if (ACPI_FAILURE(acpi_get_handle(NULL
, "\\_SB", &handle
)))
535 if (ACPI_SUCCESS(acpi_run_osc(handle
, &context
)))
536 kfree(context
.ret
.pointer
);
537 /* do we need to check the returned cap? Sounds no */
540 /* --------------------------------------------------------------------------
542 -------------------------------------------------------------------------- */
544 #ifdef CONFIG_ACPI_PROC_EVENT
545 static DEFINE_SPINLOCK(acpi_bus_event_lock
);
547 LIST_HEAD(acpi_bus_event_list
);
548 DECLARE_WAIT_QUEUE_HEAD(acpi_bus_event_queue
);
550 extern int event_is_open
;
552 int acpi_bus_generate_proc_event4(const char *device_class
, const char *bus_id
, u8 type
, int data
)
554 struct acpi_bus_event
*event
;
555 unsigned long flags
= 0;
557 /* drop event on the floor if no one's listening */
561 event
= kmalloc(sizeof(struct acpi_bus_event
), GFP_ATOMIC
);
565 strcpy(event
->device_class
, device_class
);
566 strcpy(event
->bus_id
, bus_id
);
570 spin_lock_irqsave(&acpi_bus_event_lock
, flags
);
571 list_add_tail(&event
->node
, &acpi_bus_event_list
);
572 spin_unlock_irqrestore(&acpi_bus_event_lock
, flags
);
574 wake_up_interruptible(&acpi_bus_event_queue
);
580 EXPORT_SYMBOL_GPL(acpi_bus_generate_proc_event4
);
582 int acpi_bus_generate_proc_event(struct acpi_device
*device
, u8 type
, int data
)
586 return acpi_bus_generate_proc_event4(device
->pnp
.device_class
,
587 device
->pnp
.bus_id
, type
, data
);
590 EXPORT_SYMBOL(acpi_bus_generate_proc_event
);
592 int acpi_bus_receive_event(struct acpi_bus_event
*event
)
594 unsigned long flags
= 0;
595 struct acpi_bus_event
*entry
= NULL
;
597 DECLARE_WAITQUEUE(wait
, current
);
603 if (list_empty(&acpi_bus_event_list
)) {
605 set_current_state(TASK_INTERRUPTIBLE
);
606 add_wait_queue(&acpi_bus_event_queue
, &wait
);
608 if (list_empty(&acpi_bus_event_list
))
611 remove_wait_queue(&acpi_bus_event_queue
, &wait
);
612 set_current_state(TASK_RUNNING
);
614 if (signal_pending(current
))
618 spin_lock_irqsave(&acpi_bus_event_lock
, flags
);
619 if (!list_empty(&acpi_bus_event_list
)) {
620 entry
= list_entry(acpi_bus_event_list
.next
,
621 struct acpi_bus_event
, node
);
622 list_del(&entry
->node
);
624 spin_unlock_irqrestore(&acpi_bus_event_lock
, flags
);
629 memcpy(event
, entry
, sizeof(struct acpi_bus_event
));
636 #endif /* CONFIG_ACPI_PROC_EVENT */
638 /* --------------------------------------------------------------------------
639 Notification Handling
640 -------------------------------------------------------------------------- */
642 static void acpi_bus_check_device(acpi_handle handle
)
644 struct acpi_device
*device
;
646 struct acpi_device_status old_status
;
648 if (acpi_bus_get_device(handle
, &device
))
653 old_status
= device
->status
;
656 * Make sure this device's parent is present before we go about
657 * messing with the device.
659 if (device
->parent
&& !device
->parent
->status
.present
) {
660 device
->status
= device
->parent
->status
;
664 status
= acpi_bus_get_status(device
);
665 if (ACPI_FAILURE(status
))
668 if (STRUCT_TO_INT(old_status
) == STRUCT_TO_INT(device
->status
))
672 * Device Insertion/Removal
674 if ((device
->status
.present
) && !(old_status
.present
)) {
675 ACPI_DEBUG_PRINT((ACPI_DB_INFO
, "Device insertion detected\n"));
676 /* TBD: Handle device insertion */
677 } else if (!(device
->status
.present
) && (old_status
.present
)) {
678 ACPI_DEBUG_PRINT((ACPI_DB_INFO
, "Device removal detected\n"));
679 /* TBD: Handle device removal */
683 static void acpi_bus_check_scope(acpi_handle handle
)
686 acpi_bus_check_device(handle
);
689 * TBD: Enumerate child devices within this device's scope and
690 * run acpi_bus_check_device()'s on them.
694 static BLOCKING_NOTIFIER_HEAD(acpi_bus_notify_list
);
695 int register_acpi_bus_notifier(struct notifier_block
*nb
)
697 return blocking_notifier_chain_register(&acpi_bus_notify_list
, nb
);
699 EXPORT_SYMBOL_GPL(register_acpi_bus_notifier
);
701 void unregister_acpi_bus_notifier(struct notifier_block
*nb
)
703 blocking_notifier_chain_unregister(&acpi_bus_notify_list
, nb
);
705 EXPORT_SYMBOL_GPL(unregister_acpi_bus_notifier
);
710 * Callback for all 'system-level' device notifications (values 0x00-0x7F).
712 static void acpi_bus_notify(acpi_handle handle
, u32 type
, void *data
)
714 struct acpi_device
*device
= NULL
;
715 struct acpi_driver
*driver
;
717 ACPI_DEBUG_PRINT((ACPI_DB_INFO
, "Notification %#02x to handle %p\n",
720 blocking_notifier_call_chain(&acpi_bus_notify_list
,
721 type
, (void *)handle
);
725 case ACPI_NOTIFY_BUS_CHECK
:
726 acpi_bus_check_scope(handle
);
728 * TBD: We'll need to outsource certain events to non-ACPI
729 * drivers via the device manager (device.c).
733 case ACPI_NOTIFY_DEVICE_CHECK
:
734 acpi_bus_check_device(handle
);
736 * TBD: We'll need to outsource certain events to non-ACPI
737 * drivers via the device manager (device.c).
741 case ACPI_NOTIFY_DEVICE_WAKE
:
745 case ACPI_NOTIFY_EJECT_REQUEST
:
749 case ACPI_NOTIFY_DEVICE_CHECK_LIGHT
:
750 /* TBD: Exactly what does 'light' mean? */
753 case ACPI_NOTIFY_FREQUENCY_MISMATCH
:
757 case ACPI_NOTIFY_BUS_MODE_MISMATCH
:
761 case ACPI_NOTIFY_POWER_FAULT
:
766 ACPI_DEBUG_PRINT((ACPI_DB_INFO
,
767 "Received unknown/unsupported notification [%08x]\n",
772 acpi_bus_get_device(handle
, &device
);
774 driver
= device
->driver
;
775 if (driver
&& driver
->ops
.notify
&&
776 (driver
->flags
& ACPI_DRIVER_ALL_NOTIFY_EVENTS
))
777 driver
->ops
.notify(device
, type
);
781 /* --------------------------------------------------------------------------
782 Initialization/Cleanup
783 -------------------------------------------------------------------------- */
785 static int __init
acpi_bus_init_irq(void)
787 acpi_status status
= AE_OK
;
788 union acpi_object arg
= { ACPI_TYPE_INTEGER
};
789 struct acpi_object_list arg_list
= { 1, &arg
};
790 char *message
= NULL
;
794 * Let the system know what interrupt model we are using by
795 * evaluating the \_PIC object, if exists.
798 switch (acpi_irq_model
) {
799 case ACPI_IRQ_MODEL_PIC
:
802 case ACPI_IRQ_MODEL_IOAPIC
:
805 case ACPI_IRQ_MODEL_IOSAPIC
:
808 case ACPI_IRQ_MODEL_PLATFORM
:
809 message
= "platform specific model";
812 printk(KERN_WARNING PREFIX
"Unknown interrupt routing model\n");
816 printk(KERN_INFO PREFIX
"Using %s for interrupt routing\n", message
);
818 arg
.integer
.value
= acpi_irq_model
;
820 status
= acpi_evaluate_object(NULL
, "\\_PIC", &arg_list
, NULL
);
821 if (ACPI_FAILURE(status
) && (status
!= AE_NOT_FOUND
)) {
822 ACPI_EXCEPTION((AE_INFO
, status
, "Evaluating _PIC"));
829 u8 acpi_gbl_permanent_mmap
;
832 void __init
acpi_early_init(void)
834 acpi_status status
= AE_OK
;
839 printk(KERN_INFO PREFIX
"Core revision %08x\n", ACPI_CA_VERSION
);
841 /* enable workarounds, unless strict ACPI spec. compliance */
843 acpi_gbl_enable_interpreter_slack
= TRUE
;
845 acpi_gbl_permanent_mmap
= 1;
848 * If the machine falls into the DMI check table,
849 * DSDT will be copied to memory
851 dmi_check_system(dsdt_dmi_table
);
853 status
= acpi_reallocate_root_table();
854 if (ACPI_FAILURE(status
)) {
855 printk(KERN_ERR PREFIX
856 "Unable to reallocate ACPI tables\n");
860 status
= acpi_initialize_subsystem();
861 if (ACPI_FAILURE(status
)) {
862 printk(KERN_ERR PREFIX
863 "Unable to initialize the ACPI Interpreter\n");
867 status
= acpi_load_tables();
868 if (ACPI_FAILURE(status
)) {
869 printk(KERN_ERR PREFIX
870 "Unable to load the System Description Tables\n");
876 /* compatible (0) means level (3) */
877 if (!(acpi_sci_flags
& ACPI_MADT_TRIGGER_MASK
)) {
878 acpi_sci_flags
&= ~ACPI_MADT_TRIGGER_MASK
;
879 acpi_sci_flags
|= ACPI_MADT_TRIGGER_LEVEL
;
881 /* Set PIC-mode SCI trigger type */
882 acpi_pic_sci_set_trigger(acpi_gbl_FADT
.sci_interrupt
,
883 (acpi_sci_flags
& ACPI_MADT_TRIGGER_MASK
) >> 2);
886 * now that acpi_gbl_FADT is initialized,
887 * update it with result from INT_SRC_OVR parsing
889 acpi_gbl_FADT
.sci_interrupt
= acpi_sci_override_gsi
;
894 acpi_enable_subsystem(~
895 (ACPI_NO_HARDWARE_INIT
|
896 ACPI_NO_ACPI_ENABLE
));
897 if (ACPI_FAILURE(status
)) {
898 printk(KERN_ERR PREFIX
"Unable to enable ACPI\n");
909 static int __init
acpi_bus_init(void)
912 acpi_status status
= AE_OK
;
913 extern acpi_status
acpi_os_initialize1(void);
915 acpi_os_initialize1();
918 acpi_enable_subsystem(ACPI_NO_HARDWARE_INIT
| ACPI_NO_ACPI_ENABLE
);
919 if (ACPI_FAILURE(status
)) {
920 printk(KERN_ERR PREFIX
921 "Unable to start the ACPI Interpreter\n");
926 * ACPI 2.0 requires the EC driver to be loaded and work before
927 * the EC device is found in the namespace (i.e. before acpi_initialize_objects()
930 * This is accomplished by looking for the ECDT table, and getting
931 * the EC parameters out of that.
933 status
= acpi_ec_ecdt_probe();
934 /* Ignore result. Not having an ECDT is not fatal. */
936 acpi_bus_osc_support();
938 status
= acpi_initialize_objects(ACPI_FULL_INITIALIZATION
);
939 if (ACPI_FAILURE(status
)) {
940 printk(KERN_ERR PREFIX
"Unable to initialize ACPI objects\n");
944 acpi_early_processor_set_pdc();
947 * Maybe EC region is required at bus_scan/acpi_get_devices. So it
948 * is necessary to enable it as early as possible.
950 acpi_boot_ec_enable();
952 printk(KERN_INFO PREFIX
"Interpreter enabled\n");
954 /* Initialize sleep structures */
958 * Get the system interrupt model and evaluate \_PIC.
960 result
= acpi_bus_init_irq();
965 * Register the for all standard device notifications.
968 acpi_install_notify_handler(ACPI_ROOT_OBJECT
, ACPI_SYSTEM_NOTIFY
,
969 &acpi_bus_notify
, NULL
);
970 if (ACPI_FAILURE(status
)) {
971 printk(KERN_ERR PREFIX
972 "Unable to register for device notifications\n");
977 * Create the top ACPI proc directory
979 acpi_root_dir
= proc_mkdir(ACPI_BUS_FILE_ROOT
, NULL
);
983 /* Mimic structured exception handling */
989 struct kobject
*acpi_kobj
;
991 static int __init
acpi_init(void)
997 printk(KERN_INFO PREFIX
"Interpreter disabled.\n");
1001 acpi_kobj
= kobject_create_and_add("acpi", firmware_kobj
);
1003 printk(KERN_WARNING
"%s: kset create error\n", __func__
);
1007 init_acpi_device_notify();
1008 result
= acpi_bus_init();
1011 pci_mmcfg_late_init();
1012 if (!(pm_flags
& PM_APM
))
1013 pm_flags
|= PM_ACPI
;
1015 printk(KERN_INFO PREFIX
1016 "APM is already active, exiting\n");
1027 * If the laptop falls into the DMI check table, the power state check
1028 * will be disabled in the course of device power transistion.
1030 dmi_check_system(power_nocheck_dmi_table
);
1037 acpi_sleep_proc_init();
1038 acpi_wakeup_device_init();
1042 subsys_initcall(acpi_init
);