summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorMichel Stam <m.stam@fugro.nl>2014-04-07 12:01:20 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2014-04-08 08:17:55 +0200
commit4d94f56c6c5ba00d35d6b3e3a1862439b2ced3f0 (patch)
treeb3efb2fad02e4abe18ca0d0baefee5ebae6a3875 /common
parent0a5529d0edcd8c00a679c485f7266548851c6948 (diff)
downloadbarebox-4d94f56c6c5ba00d35d6b3e3a1862439b2ced3f0.tar.gz
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 <michel@reverze.net> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common')
-rw-r--r--common/memory.c3
-rw-r--r--common/resource.c28
2 files changed, 25 insertions, 6 deletions
diff --git a/common/memory.c b/common/memory.c
index c82bbaa..7dbd7f4 100644
--- a/common/memory.c
+++ b/common/memory.c
@@ -148,7 +148,8 @@ struct resource *request_sdram_region(const char *name, resource_size_t start,
for_each_memory_bank(bank) {
struct resource *res;
- res = request_region(bank->res, name, start, start + size - 1);
+ res = __request_region(bank->res, name, start,
+ start + size - 1);
if (res)
return res;
}
diff --git a/common/resource.c b/common/resource.c
index 5795e79..fe4680e 100644
--- a/common/resource.c
+++ b/common/resource.c
@@ -20,6 +20,7 @@
#include <errno.h>
#include <init.h>
#include <linux/ioport.h>
+#include <asm/io.h>
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);
}