2005-04-16 16:20:36 -06:00
|
|
|
/*
|
|
|
|
* arch/ia64/kernel/acpi-ext.c
|
|
|
|
*
|
|
|
|
* Copyright (C) 2003 Hewlett-Packard
|
|
|
|
* Copyright (C) Alex Williamson
|
|
|
|
* Copyright (C) Bjorn Helgaas
|
|
|
|
*
|
|
|
|
* Vendor specific extensions to ACPI.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/config.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/acpi.h>
|
|
|
|
#include <linux/efi.h>
|
|
|
|
|
|
|
|
#include <asm/acpi-ext.h>
|
|
|
|
|
|
|
|
struct acpi_vendor_descriptor {
|
2005-08-04 22:44:28 -06:00
|
|
|
u8 guid_id;
|
|
|
|
efi_guid_t guid;
|
2005-04-16 16:20:36 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
struct acpi_vendor_info {
|
2005-08-04 22:44:28 -06:00
|
|
|
struct acpi_vendor_descriptor *descriptor;
|
|
|
|
u8 *data;
|
|
|
|
u32 length;
|
2005-04-16 16:20:36 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
acpi_status
|
|
|
|
acpi_vendor_resource_match(struct acpi_resource *resource, void *context)
|
|
|
|
{
|
2005-08-04 22:44:28 -06:00
|
|
|
struct acpi_vendor_info *info = (struct acpi_vendor_info *)context;
|
2005-04-16 16:20:36 -06:00
|
|
|
struct acpi_resource_vendor *vendor;
|
|
|
|
struct acpi_vendor_descriptor *descriptor;
|
|
|
|
u32 length;
|
|
|
|
|
2005-11-30 16:00:24 -07:00
|
|
|
if (resource->type != ACPI_RSTYPE_VENDOR)
|
2005-04-16 16:20:36 -06:00
|
|
|
return AE_OK;
|
|
|
|
|
2005-08-04 22:44:28 -06:00
|
|
|
vendor = (struct acpi_resource_vendor *)&resource->data;
|
|
|
|
descriptor = (struct acpi_vendor_descriptor *)vendor->reserved;
|
2005-04-16 16:20:36 -06:00
|
|
|
if (vendor->length <= sizeof(*info->descriptor) ||
|
|
|
|
descriptor->guid_id != info->descriptor->guid_id ||
|
|
|
|
efi_guidcmp(descriptor->guid, info->descriptor->guid))
|
|
|
|
return AE_OK;
|
|
|
|
|
|
|
|
length = vendor->length - sizeof(struct acpi_vendor_descriptor);
|
|
|
|
info->data = acpi_os_allocate(length);
|
|
|
|
if (!info->data)
|
|
|
|
return AE_NO_MEMORY;
|
|
|
|
|
2005-08-04 22:44:28 -06:00
|
|
|
memcpy(info->data,
|
|
|
|
vendor->reserved + sizeof(struct acpi_vendor_descriptor),
|
|
|
|
length);
|
2005-04-16 16:20:36 -06:00
|
|
|
info->length = length;
|
|
|
|
return AE_CTRL_TERMINATE;
|
|
|
|
}
|
|
|
|
|
|
|
|
acpi_status
|
2005-08-04 22:44:28 -06:00
|
|
|
acpi_find_vendor_resource(acpi_handle obj, struct acpi_vendor_descriptor * id,
|
|
|
|
u8 ** data, u32 * length)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
|
|
|
struct acpi_vendor_info info;
|
|
|
|
|
|
|
|
info.descriptor = id;
|
|
|
|
info.data = NULL;
|
|
|
|
|
2005-08-04 22:44:28 -06:00
|
|
|
acpi_walk_resources(obj, METHOD_NAME__CRS, acpi_vendor_resource_match,
|
|
|
|
&info);
|
2005-04-16 16:20:36 -06:00
|
|
|
if (!info.data)
|
|
|
|
return AE_NOT_FOUND;
|
|
|
|
|
|
|
|
*data = info.data;
|
|
|
|
*length = info.length;
|
|
|
|
return AE_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct acpi_vendor_descriptor hp_ccsr_descriptor = {
|
|
|
|
.guid_id = 2,
|
2005-08-04 22:44:28 -06:00
|
|
|
.guid =
|
|
|
|
EFI_GUID(0x69e9adf9, 0x924f, 0xab5f, 0xf6, 0x4a, 0x24, 0xd2, 0x01,
|
|
|
|
0x37, 0x0e, 0xad)
|
2005-04-16 16:20:36 -06:00
|
|
|
};
|
|
|
|
|
2005-08-04 22:44:28 -06:00
|
|
|
acpi_status hp_acpi_csr_space(acpi_handle obj, u64 * csr_base, u64 * csr_length)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
|
|
|
acpi_status status;
|
|
|
|
u8 *data;
|
|
|
|
u32 length;
|
|
|
|
|
2005-08-04 22:44:28 -06:00
|
|
|
status =
|
|
|
|
acpi_find_vendor_resource(obj, &hp_ccsr_descriptor, &data, &length);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
if (ACPI_FAILURE(status) || length != 16)
|
|
|
|
return AE_NOT_FOUND;
|
|
|
|
|
|
|
|
memcpy(csr_base, data, sizeof(*csr_base));
|
|
|
|
memcpy(csr_length, data + 8, sizeof(*csr_length));
|
|
|
|
acpi_os_free(data);
|
|
|
|
|
|
|
|
return AE_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
EXPORT_SYMBOL(hp_acpi_csr_space);
|