From 4d94f56c6c5ba00d35d6b3e3a1862439b2ced3f0 Mon Sep 17 00:00:00 2001 From: Michel Stam Date: Mon, 7 Apr 2014 12:01:20 +0200 Subject: common: Allow for I/O mapped I/O Rework the current framework so that I/O mapped I/O resources are also possible. Signed-off-by: Michel Stam Signed-off-by: Sascha Hauer --- common/resource.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) (limited to 'common/resource.c') diff --git a/common/resource.c b/common/resource.c index 5795e79c6b..fe4680e3bd 100644 --- a/common/resource.c +++ b/common/resource.c @@ -20,6 +20,7 @@ #include #include #include +#include static int init_resource(struct resource *res, const char *name) { @@ -36,7 +37,7 @@ static int init_resource(struct resource *res, const char *name) * the parent resource and does not conflict with any of the child * resources. */ -struct resource *request_region(struct resource *parent, +struct resource *__request_region(struct resource *parent, const char *name, resource_size_t start, resource_size_t end) { @@ -95,7 +96,7 @@ ok: } /* - * release a region previously requested with request_region + * release a region previously requested with request_*_region */ int release_region(struct resource *res) { @@ -109,7 +110,7 @@ int release_region(struct resource *res) return 0; } -/* The root resource for the whole io space */ +/* The root resource for the whole memory-mapped io space */ struct resource iomem_resource = { .start = 0, .end = 0xffffffff, @@ -118,10 +119,27 @@ struct resource iomem_resource = { }; /* - * request a region inside the io space + * request a region inside the io space (memory) */ struct resource *request_iomem_region(const char *name, resource_size_t start, resource_size_t end) { - return request_region(&iomem_resource, name, start, end); + return __request_region(&iomem_resource, name, start, end); +} + +/* The root resource for the whole io-mapped io space */ +struct resource ioport_resource = { + .start = 0, + .end = IO_SPACE_LIMIT, + .name = "ioport", + .children = LIST_HEAD_INIT(ioport_resource.children), +}; + +/* + * request a region inside the io space (i/o port) + */ +struct resource *request_ioport_region(const char *name, + resource_size_t start, resource_size_t end) +{ + return __request_region(&ioport_resource, name, start, end); } -- cgit v1.2.3