From 3ca9fab410fbef6fc3a13284f5c26faccade21d1 Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Thu, 29 Jun 2006 14:35:33 -0700 Subject: [PATCH] [SPARC]: Add of_io{remap,unmap}(). Signed-off-by: David S. Miller --- arch/sparc/kernel/ioport.c | 17 +++++++++++++++++ arch/sparc64/kernel/of_device.c | 17 +++++++++++++++++ include/asm-sparc/of_device.h | 3 +++ include/asm-sparc64/of_device.h | 3 +++ 4 files changed, 40 insertions(+) diff --git a/arch/sparc/kernel/ioport.c b/arch/sparc/kernel/ioport.c index 79d177149fd..8654b446ac9 100644 --- a/arch/sparc/kernel/ioport.c +++ b/arch/sparc/kernel/ioport.c @@ -26,6 +26,7 @@ */ #include +#include #include #include #include @@ -40,6 +41,7 @@ #include #include #include +#include #include #include #include @@ -143,6 +145,21 @@ void __iomem *sbus_ioremap(struct resource *phyres, unsigned long offset, phyres->start + offset, size, name); } +void __iomem *of_ioremap(struct resource *res, unsigned long offset, + unsigned long size, char *name) +{ + return _sparc_alloc_io(res->flags & 0xF, + res->start + offset, + size, name); +} +EXPORT_SYMBOL(of_ioremap); + +void of_iounmap(void __iomem *base, unsigned long size) +{ + iounmap(base); +} +EXPORT_SYMBOL(of_iounmap); + /* */ void sbus_iounmap(volatile void __iomem *addr, unsigned long size) diff --git a/arch/sparc64/kernel/of_device.c b/arch/sparc64/kernel/of_device.c index 00502dc280e..9812cfa6dd3 100644 --- a/arch/sparc64/kernel/of_device.c +++ b/arch/sparc64/kernel/of_device.c @@ -129,6 +129,23 @@ static int of_device_resume(struct device * dev) return error; } +void __iomem *of_ioremap(struct resource *res, unsigned long offset, unsigned long size, char *name) +{ + unsigned long ret = res->start + offset; + + if (!request_region(ret, size, name)) + ret = 0; + + return (void __iomem *) ret; +} +EXPORT_SYMBOL(of_ioremap); + +void of_iounmap(void __iomem *base, unsigned long size) +{ + release_region((unsigned long) base, size); +} +EXPORT_SYMBOL(of_iounmap); + #ifdef CONFIG_PCI struct bus_type isa_bus_type = { .name = "isa", diff --git a/include/asm-sparc/of_device.h b/include/asm-sparc/of_device.h index 1b43ee5eb5e..b5ca3145d48 100644 --- a/include/asm-sparc/of_device.h +++ b/include/asm-sparc/of_device.h @@ -31,6 +31,9 @@ struct of_device }; #define to_of_device(d) container_of(d, struct of_device, dev) +extern void __iomem *of_ioremap(struct resource *res, unsigned long offset, unsigned long size, char *name); +extern void of_iounmap(void __iomem *base, unsigned long size); + extern const struct of_device_id *of_match_device( const struct of_device_id *matches, const struct of_device *dev); diff --git a/include/asm-sparc64/of_device.h b/include/asm-sparc64/of_device.h index 27bc08671d6..37c5856fae1 100644 --- a/include/asm-sparc64/of_device.h +++ b/include/asm-sparc64/of_device.h @@ -32,6 +32,9 @@ struct of_device }; #define to_of_device(d) container_of(d, struct of_device, dev) +extern void __iomem *of_ioremap(struct resource *res, unsigned long offset, unsigned long size, char *name); +extern void of_iounmap(void __iomem *base, unsigned long size); + extern const struct of_device_id *of_match_device( const struct of_device_id *matches, const struct of_device *dev); -- 2.32.0.93.g670b81a890