>From 51f5cddd8c4301b731805074ebc3e3a6c7dbaf59 Mon Sep 17 00:00:00 2001 From: Liu Jiang Date: Fri, 6 Nov 2015 20:01:59 +0800 Subject: [PATCH] Signed-off-by: Liu Jiang --- drivers/acpi/resource.c | 25 +++++++++++++++++++++++-- include/linux/resource_ext.h | 7 +++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/drivers/acpi/resource.c b/drivers/acpi/resource.c index cdc5c2599beb..1bd3e21f56fe 100644 --- a/drivers/acpi/resource.c +++ b/drivers/acpi/resource.c @@ -215,8 +215,29 @@ static bool acpi_decode_space(struct resource_win *win, else if (attr->translation_offset) pr_debug("ACPI: translation_offset(%lld) is invalid for non-bridge device.\n", attr->translation_offset); - start = attr->minimum + offset; - end = attr->maximum + offset; + start = attr->minimum; + end = attr->maximum; + + /* + * Convert bus local address into system global address if it's an + * IO Port->IO Port or MMIO->MMIO translation. + */ + switch (addr->resource_type) { + case ACPI_MEMORY_RANGE: + if (addr->info.mem.translation) + win->translation_type = RESOURCE_TRANS_MMIO_TO_IOPORT; + else + start += offset; + break; + case ACPI_IO_RANGE: + if (addr->info.io.translation) + win->translation_type = RESOURCE_TRANS_IOPORT_TO_MMIO; + else + start += offset; + break; + default: + break; + } win->offset = offset; res->start = start; diff --git a/include/linux/resource_ext.h b/include/linux/resource_ext.h index e2bf63d881d4..f06d358c1f22 100644 --- a/include/linux/resource_ext.h +++ b/include/linux/resource_ext.h @@ -22,8 +22,15 @@ struct resource_win { struct resource res; /* In master (CPU) address space */ resource_size_t offset; /* Translation offset for bridge */ + int translation_type; /* Translation type for bridge */ }; +#define RESOURCE_TRANS_SAME 0x0 +/* Translate from IO port on slave into MMIO on master */ +#define RESOURCE_TRANS_IOPORT_TO_MMIO 0x1 +/* Translate from MMIO on slave into IO port on master */ +#define RESOURCE_TRANS_MMIO_TO_IOPORT 0x2 + /* * Common resource list management data structure and interfaces to support * ACPI, PNP and PCI host bridge etc. -- 1.7.10.4