25 #include <linux/module.h>
28 #include <linux/kernel.h>
29 #include <linux/list.h>
30 #include <linux/sched.h>
32 #include <linux/device.h>
35 #include <linux/slab.h>
39 #include <linux/pci.h>
48 #define _COMPONENT ACPI_BUS_COMPONENT
55 #define STRUCT_TO_INT(s) (*((int*)&s))
62 "force copy of DSDT to local memory\n", id->
ident);
73 .callback = set_copy_dsdt,
74 .ident =
"TOSHIBA Satellite",
115 unsigned long long *sta)
134 unsigned long long sta;
142 if (device->status.functional && !device->status.present) {
144 "functional but not present;\n",
185 static const char *state_string(
int state)
203 static int __acpi_bus_get_power(
struct acpi_device *
device,
int *state)
207 if (!device || !state)
210 if (!device->flags.power_manageable) {
212 *state = device->parent ?
221 if (device->power.flags.explicit_get) {
222 unsigned long long psc;
233 }
else if (device->power.flags.power_resources) {
254 device->pnp.bus_id, state_string(*state)));
260 static int __acpi_bus_set_power(
struct acpi_device *device,
int state)
264 char object_name[5] = {
'_',
'P',
'S',
'0' +
state,
'\0' };
271 if (state == device->power.state) {
273 state_string(state)));
277 if (!device->power.states[state].flags.valid) {
279 state_string(state));
284 "Cannot set device to a higher-powered"
285 " state than parent\n");
291 object_name[3] =
'3';
301 if (device->power.flags.power_resources) {
306 if (device->power.states[state].flags.explicit_set) {
315 if (device->power.states[state].flags.explicit_set) {
323 if (device->power.flags.power_resources) {
333 "Device [%s] failed to transition to %s\n",
334 device->pnp.bus_id, state_string(state));
336 device->power.state =
state;
338 "Device [%s] transitioned to %s\n",
339 device->pnp.bus_id, state_string(state)));
348 struct acpi_device *device;
355 if (!device->flags.power_manageable) {
357 "Device [%s] is not power manageable\n",
358 dev_name(&device->dev)));
362 return __acpi_bus_set_power(device, state);
377 result = __acpi_bus_get_power(device, &state);
381 if (device->power.flags.power_resources)
385 device->power.state =
state;
393 struct acpi_device *device;
401 result = __acpi_bus_get_power(device, &state);
405 result = __acpi_bus_set_power(device, state);
406 if (!result && state_p)
416 struct acpi_device *device;
420 return result ?
false : device->flags.power_manageable;
427 struct acpi_device *device;
431 return result ?
false : device->wakeup.flags.valid;
437 struct acpi_osc_context *
context,
char *error)
449 for (i = 0; i < context->cap.length; i +=
sizeof(
u32))
450 printk(
"%x ", *((
u32 *)(context->cap.pointer + i)));
457 static int opc_map_to_uuid[16] = {6, 4, 2, 0, 11, 9, 16, 14, 19, 21,
458 24, 26, 28, 30, 32, 34};
462 for (i = 0; i < 36; i++) {
463 if (i == 8 || i == 13 || i == 18 || i == 23) {
469 for (i = 0; i < 16; i++) {
470 uuid[
i] =
hex_to_bin(str[opc_map_to_uuid[i]]) << 4;
471 uuid[
i] |=
hex_to_bin(str[opc_map_to_uuid[i] + 1]);
488 if (
ACPI_FAILURE(acpi_str_to_uuid(context->uuid_str, uuid)))
491 context->ret.pointer =
NULL;
497 in_params[0].
buffer.length = 16;
500 in_params[1].
integer.value = context->rev;
502 in_params[2].
integer.value = context->cap.length/
sizeof(
u32);
504 in_params[3].
buffer.length = context->cap.length;
505 in_params[3].
buffer.pointer = context->cap.pointer;
516 || out_obj->
buffer.length != context->cap.length) {
517 acpi_print_osc_error(handle, context,
518 "_OSC evaluation returned wrong type");
523 errors = *((
u32 *)out_obj->
buffer.pointer) & ~(1 << 0);
525 if (errors & OSC_REQUEST_ERROR)
526 acpi_print_osc_error(handle, context,
527 "_OSC request failed");
528 if (errors & OSC_INVALID_UUID_ERROR)
529 acpi_print_osc_error(handle, context,
530 "_OSC invalid UUID");
531 if (errors & OSC_INVALID_REVISION_ERROR)
532 acpi_print_osc_error(handle, context,
533 "_OSC invalid revision");
534 if (errors & OSC_CAPABILITIES_MASK_ERROR) {
535 if (((
u32 *)context->cap.pointer)[OSC_QUERY_TYPE]
545 context->ret.length = out_obj->
buffer.length;
547 if (!context->ret.pointer) {
552 context->ret.length);
558 context->ret.pointer =
NULL;
564 static u8 sb_uuid_str[] =
"0811B06E-4A27-44F9-8D60-3CBBC22E7B48";
565 static void acpi_bus_osc_support(
void)
568 struct acpi_osc_context context = {
569 .uuid_str = sb_uuid_str,
572 .cap.pointer = capbuf,
576 capbuf[OSC_QUERY_TYPE] = OSC_QUERY_ENABLE;
577 capbuf[OSC_SUPPORT_TYPE] = OSC_SB_PR3_SUPPORT;
578 #if defined(CONFIG_ACPI_PROCESSOR_AGGREGATOR) ||\
579 defined(CONFIG_ACPI_PROCESSOR_AGGREGATOR_MODULE)
580 capbuf[OSC_SUPPORT_TYPE] |= OSC_SB_PAD_SUPPORT;
583 #if defined(CONFIG_ACPI_PROCESSOR) || defined(CONFIG_ACPI_PROCESSOR_MODULE)
584 capbuf[OSC_SUPPORT_TYPE] |= OSC_SB_PPC_OST_SUPPORT;
587 #ifdef ACPI_HOTPLUG_OST
588 capbuf[OSC_SUPPORT_TYPE] |= OSC_SB_HOTPLUG_OST_SUPPORT;
592 capbuf[OSC_SUPPORT_TYPE] |= OSC_SB_APEI_SUPPORT;
596 u32 *capbuf_ret = context.ret.pointer;
597 if (context.ret.length > OSC_SUPPORT_TYPE)
598 osc_sb_apei_support_acked =
599 capbuf_ret[OSC_SUPPORT_TYPE] & OSC_SB_APEI_SUPPORT;
600 kfree(context.ret.pointer);
609 #ifdef CONFIG_ACPI_PROC_EVENT
615 extern int event_is_open;
617 int acpi_bus_generate_proc_event4(
const char *device_class,
const char *bus_id,
u8 type,
int data)
619 struct acpi_bus_event *
event;
620 unsigned long flags = 0;
626 event = kzalloc(
sizeof(
struct acpi_bus_event),
GFP_ATOMIC);
630 strcpy(event->device_class, device_class);
631 strcpy(event->bus_id, bus_id);
637 spin_unlock_irqrestore(&acpi_bus_event_lock, flags);
647 int acpi_bus_generate_proc_event(
struct acpi_device *device,
u8 type,
int data)
651 return acpi_bus_generate_proc_event4(device->pnp.device_class,
652 device->pnp.bus_id, type, data);
657 int acpi_bus_receive_event(
struct acpi_bus_event *event)
659 unsigned long flags = 0;
668 if (list_empty(&acpi_bus_event_list)) {
673 if (list_empty(&acpi_bus_event_list))
684 if (!list_empty(&acpi_bus_event_list)) {
686 struct acpi_bus_event,
node);
689 spin_unlock_irqrestore(&acpi_bus_event_lock, flags);
694 memcpy(event, entry,
sizeof(
struct acpi_bus_event));
707 static void acpi_bus_check_device(
acpi_handle handle)
709 struct acpi_device *device;
711 struct acpi_device_status old_status;
718 old_status = device->status;
724 if (device->parent && !device->parent->status.present) {
725 device->status = device->parent->status;
739 if ((device->status.present) && !(old_status.present)) {
742 }
else if (!(device->status.present) && (old_status.present)) {
748 static void acpi_bus_check_scope(
acpi_handle handle)
751 acpi_bus_check_device(handle);
777 static void acpi_bus_notify(
acpi_handle handle,
u32 type,
void *data)
779 struct acpi_device *device =
NULL;
780 struct acpi_driver *
driver;
786 type, (
void *)handle);
791 acpi_bus_check_scope(handle);
799 acpi_bus_check_device(handle);
832 "Received unknown/unsupported notification [%08x]\n",
839 driver = device->driver;
840 if (driver && driver->ops.notify &&
841 (driver->flags & ACPI_DRIVER_ALL_NOTIFY_EVENTS))
842 driver->ops.notify(device, type);
850 static int __init acpi_bus_init_irq(
void)
864 case ACPI_IRQ_MODEL_PIC:
867 case ACPI_IRQ_MODEL_IOAPIC:
870 case ACPI_IRQ_MODEL_IOSAPIC:
873 case ACPI_IRQ_MODEL_PLATFORM:
874 message =
"platform specific model";
910 acpi_gbl_permanent_mmap = 1;
921 "Unable to reallocate ACPI tables\n");
928 "Unable to initialize the ACPI Interpreter\n");
935 "Unable to load the System Description Tables\n");
943 acpi_sci_flags &= ~ACPI_MADT_TRIGGER_MASK;
948 (acpi_sci_flags & ACPI_MADT_TRIGGER_MASK) >> 2);
971 static int __init acpi_bus_init(
void)
982 "Unable to start the ACPI Interpreter\n");
1007 acpi_bus_osc_support();
1031 result = acpi_bus_init_irq();
1040 &acpi_bus_notify,
NULL);
1043 "Unable to register for device notifications\n");
1063 static int __init acpi_init(
void)
1079 result = acpi_bus_init();