diff options
| author | Myron Stowe <myron.stowe@hp.com> | 2010-10-21 16:23:59 -0400 |
|---|---|---|
| committer | Len Brown <len.brown@intel.com> | 2010-10-24 23:26:23 -0400 |
| commit | 29718521237a1b1607ea05b49243100ea2044337 (patch) | |
| tree | 69608fa74248415a6055f0b48753cf54b63043b3 | |
| parent | 620242ae8c3d9c0b1a77451744fb2d855d1e7342 (diff) | |
ACPI: Add interfaces for ioremapping/iounmapping ACPI registers
Add remapping and unmapping interfaces for ACPI registers that are
backed by memory mapped I/O (MMIO). These interfaces, along with
the MMIO remapping list, enable accesses of such registers from within
interrupt context.
ACPI Generic Address Structure (GAS) reference (ACPI's fixed/generic
hardware registers use the GAS format):
ACPI Specification, Revision 4.0, Section 5.2.3.1, "Generic Address
Structure".
Signed-off-by: Myron Stowe <myron.stowe@hp.com>
Signed-off-by: Len Brown <len.brown@intel.com>
| -rw-r--r-- | drivers/acpi/osl.c | 38 | ||||
| -rw-r--r-- | include/linux/acpi.h | 3 |
2 files changed, 41 insertions, 0 deletions
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c index bd72129e35f2..fc6c5d21c3eb 100644 --- a/drivers/acpi/osl.c +++ b/drivers/acpi/osl.c | |||
| @@ -372,6 +372,44 @@ void __init early_acpi_os_unmap_memory(void __iomem *virt, acpi_size size) | |||
| 372 | __acpi_unmap_table(virt, size); | 372 | __acpi_unmap_table(virt, size); |
| 373 | } | 373 | } |
| 374 | 374 | ||
| 375 | int acpi_os_map_generic_address(struct acpi_generic_address *addr) | ||
| 376 | { | ||
| 377 | void __iomem *virt; | ||
| 378 | |||
| 379 | if (addr->space_id != ACPI_ADR_SPACE_SYSTEM_MEMORY) | ||
| 380 | return 0; | ||
| 381 | |||
| 382 | if (!addr->address || !addr->bit_width) | ||
| 383 | return -EINVAL; | ||
| 384 | |||
| 385 | virt = acpi_os_map_memory(addr->address, addr->bit_width / 8); | ||
| 386 | if (!virt) | ||
| 387 | return -EIO; | ||
| 388 | |||
| 389 | return 0; | ||
| 390 | } | ||
| 391 | EXPORT_SYMBOL_GPL(acpi_os_map_generic_address); | ||
| 392 | |||
| 393 | void acpi_os_unmap_generic_address(struct acpi_generic_address *addr) | ||
| 394 | { | ||
| 395 | void __iomem *virt; | ||
| 396 | unsigned long flags; | ||
| 397 | acpi_size size = addr->bit_width / 8; | ||
| 398 | |||
| 399 | if (addr->space_id != ACPI_ADR_SPACE_SYSTEM_MEMORY) | ||
| 400 | return; | ||
| 401 | |||
| 402 | if (!addr->address || !addr->bit_width) | ||
| 403 | return; | ||
| 404 | |||
| 405 | spin_lock_irqsave(&acpi_ioremap_lock, flags); | ||
| 406 | virt = acpi_map_vaddr_lookup(addr->address, size); | ||
| 407 | spin_unlock_irqrestore(&acpi_ioremap_lock, flags); | ||
| 408 | |||
| 409 | acpi_os_unmap_memory(virt, size); | ||
| 410 | } | ||
| 411 | EXPORT_SYMBOL_GPL(acpi_os_unmap_generic_address); | ||
| 412 | |||
| 375 | #ifdef ACPI_FUTURE_USAGE | 413 | #ifdef ACPI_FUTURE_USAGE |
| 376 | acpi_status | 414 | acpi_status |
| 377 | acpi_os_get_physical_address(void *virt, acpi_physical_address * phys) | 415 | acpi_os_get_physical_address(void *virt, acpi_physical_address * phys) |
diff --git a/include/linux/acpi.h b/include/linux/acpi.h index c227757feb06..7774e6d8fddd 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h | |||
| @@ -308,6 +308,9 @@ extern acpi_status acpi_pci_osc_control_set(acpi_handle handle, | |||
| 308 | u32 *mask, u32 req); | 308 | u32 *mask, u32 req); |
| 309 | extern void acpi_early_init(void); | 309 | extern void acpi_early_init(void); |
| 310 | 310 | ||
| 311 | int acpi_os_map_generic_address(struct acpi_generic_address *addr); | ||
| 312 | void acpi_os_unmap_generic_address(struct acpi_generic_address *addr); | ||
| 313 | |||
| 311 | #else /* !CONFIG_ACPI */ | 314 | #else /* !CONFIG_ACPI */ |
| 312 | 315 | ||
| 313 | #define acpi_disabled 1 | 316 | #define acpi_disabled 1 |
