28 #include <linux/kernel.h>
29 #include <linux/module.h>
31 #include <linux/types.h>
33 #include <linux/slab.h>
36 #define ACPI_MEMORY_DEVICE_CLASS "memory"
37 #define ACPI_MEMORY_DEVICE_HID "PNP0C80"
38 #define ACPI_MEMORY_DEVICE_NAME "Hotplug Mem Device"
40 #define _COMPONENT ACPI_MEMORY_DEVICE_COMPONENT
43 #define PREFIX "ACPI:memory_hp:"
51 #define MEMORY_INVALID_STATE 0
52 #define MEMORY_POWER_ON_STATE 1
53 #define MEMORY_POWER_OFF_STATE 2
55 static int acpi_memory_device_add(
struct acpi_device *
device);
56 static int acpi_memory_device_remove(
struct acpi_device *
device,
int type);
64 static struct acpi_driver acpi_memory_device_driver = {
65 .name =
"acpi_memhotplug",
67 .ids = memory_device_ids,
69 .add = acpi_memory_device_add,
70 .remove = acpi_memory_device_remove,
89 static int acpi_hotmem_initialized;
106 if ((info->
caching == address64.info.mem.caching) &&
109 info->
length += address64.address_length;
118 INIT_LIST_HEAD(&new->list);
119 new->caching = address64.info.mem.caching;
120 new->write_protect = address64.info.mem.write_protect;
121 new->start_addr = address64.minimum;
122 new->length = address64.address_length;
135 if (!list_empty(&mem_device->
res_list))
139 acpi_memory_get_resource, mem_device);
143 INIT_LIST_HEAD(&mem_device->res_list);
157 struct acpi_device *pdevice =
NULL;
181 result =
acpi_bus_add(&device, pdevice, handle, ACPI_BUS_TYPE_DEVICE);
188 *mem_device = acpi_driver_data(device);
189 if (!(*mem_device)) {
199 unsigned long long current_status;
203 NULL, ¤t_status)))
219 int result, num_enabled = 0;
225 result = acpi_memory_get_device_resources(mem_device);
251 node = memory_add_physaddr_to_nid(info->
start_addr);
280 unsigned long long current_status;
285 arg_list.pointer = &
arg;
287 arg.integer.value = 1;
289 "_EJ0", &arg_list,
NULL);
298 NULL, ¤t_status);
303 if (current_status & ACPI_STA_DEVICE_ENABLED)
329 result = acpi_memory_powerdown_device(mem_device);
343 struct acpi_device *device;
344 u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE;
349 "\nReceived BUS CHECK notification for device\n"));
354 "\nReceived DEVICE CHECK notification for device\n"));
355 if (acpi_memory_get_device(handle, &mem_device)) {
360 if (acpi_memory_check_device(mem_device))
363 if (acpi_memory_enable_device(mem_device)) {
368 ost_code = ACPI_OST_SC_SUCCESS;
373 "\nReceived EJECT REQUEST notification for device\n"));
379 mem_device = acpi_driver_data(device);
391 if (acpi_memory_disable_device(mem_device)) {
412 "Unsupported event [0x%x]\n", event));
423 static int acpi_memory_device_add(
struct acpi_device *device)
436 INIT_LIST_HEAD(&mem_device->
res_list);
440 device->driver_data = mem_device;
443 result = acpi_memory_get_device_resources(mem_device);
460 if (!acpi_hotmem_initialized)
463 if (!acpi_memory_check_device(mem_device)) {
465 result = acpi_memory_enable_device(mem_device);
468 "Error in acpi_memory_enable_device\n");
473 static int acpi_memory_device_remove(
struct acpi_device *device,
int type)
478 if (!device || !acpi_driver_data(device))
481 mem_device = acpi_driver_data(device);
506 if ((hardware_id ==
NULL) ||
515 acpi_memory_register_notify_handler(
acpi_handle handle,
521 status = is_memory_device(handle);
526 acpi_memory_device_notify,
NULL);
532 acpi_memory_deregister_notify_handler(
acpi_handle handle,
533 u32 level,
void *ctxt,
void **retv)
538 status = is_memory_device(handle);
544 acpi_memory_device_notify);
549 static int __init acpi_memory_device_init(
void)
562 acpi_memory_register_notify_handler,
NULL,
571 acpi_hotmem_initialized = 1;
575 static void __exit acpi_memory_device_exit(
void)
586 acpi_memory_deregister_notify_handler,
NULL,