diff mbox

[8/8] at91: add arch specific ioremap support

Message ID 1309502682-16897-8-git-send-email-plagnioj@jcrosoft.com (mailing list archive)
State New, archived
Headers show

Commit Message

Jean-Christophe PLAGNIOL-VILLARD July 1, 2011, 6:44 a.m. UTC
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Cc: Nicolas Ferre <nicolas.ferre@atmel.com>
Cc: Patrice Vilchez <patrice.vilchez@atmel.com>
---
 arch/arm/mach-at91/include/mach/io.h |   16 +++++++++++++++-
 arch/arm/mach-at91/setup.c           |   19 +++++++++++++++++++
 2 files changed, 34 insertions(+), 1 deletions(-)

Comments

Arnd Bergmann July 1, 2011, 3:59 p.m. UTC | #1
On Friday 01 July 2011, Jean-Christophe PLAGNIOL-VILLARD wrote:

> +
> +static inline unsigned int at91_readl(unsigned int pa)
> +{
> +	return __raw_readl((void __iomem *)AT91_IO_P2V(pa));
> +}
> +

This function looks quite unusual and not in a good way. You also don't
seem to use it at all.

Why is this needed, can can't you change all users to do ioremap?

	Arnd
Jean-Christophe PLAGNIOL-VILLARD July 1, 2011, 5:29 p.m. UTC | #2
On 17:59 Fri 01 Jul     , Arnd Bergmann wrote:
> On Friday 01 July 2011, Jean-Christophe PLAGNIOL-VILLARD wrote:
> 
> > +
> > +static inline unsigned int at91_readl(unsigned int pa)
> > +{
> > +	return __raw_readl((void __iomem *)AT91_IO_P2V(pa));
> > +}
> > +
> 
> This function looks quite unusual and not in a good way. You also don't
> seem to use it at all.
> 
> Why is this needed, can can't you change all users to do ioremap?
I don't remember why I put it

the whole idea is that everyone use ioremap now

Best Regards,
J.
diff mbox

Patch

diff --git a/arch/arm/mach-at91/include/mach/io.h b/arch/arm/mach-at91/include/mach/io.h
index 0b0cccc..6ffc53b 100644
--- a/arch/arm/mach-at91/include/mach/io.h
+++ b/arch/arm/mach-at91/include/mach/io.h
@@ -21,14 +21,28 @@ 
 #ifndef __ASM_ARCH_IO_H
 #define __ASM_ARCH_IO_H
 
+#include <mach/hardware.h>
+
 #define IO_SPACE_LIMIT		0xFFFFFFFF
 
 #define __io(a)		__typesafe_io(a)
 #define __mem_pci(a)	(a)
 
-
 #ifndef __ASSEMBLY__
 
+#ifndef CONFIG_ARCH_AT91X40
+#define __arch_ioremap	at91_ioremap
+#define __arch_iounmap	at91_iounmap
+#endif
+
+void __iomem *at91_ioremap(unsigned long phys, size_t size, unsigned int type);
+void at91_iounmap(volatile void __iomem *addr);
+
+static inline unsigned int at91_readl(unsigned int pa)
+{
+	return __raw_readl((void __iomem *)AT91_IO_P2V(pa));
+}
+
 static inline unsigned int at91_sys_read(unsigned int reg_offset)
 {
 	void __iomem *addr = (void __iomem *)AT91_VA_BASE_SYS;
diff --git a/arch/arm/mach-at91/setup.c b/arch/arm/mach-at91/setup.c
index 816599f..aa64294 100644
--- a/arch/arm/mach-at91/setup.c
+++ b/arch/arm/mach-at91/setup.c
@@ -7,6 +7,7 @@ 
 
 #include <linux/module.h>
 #include <linux/io.h>
+#include <linux/mm.h>
 
 #include <asm/mach/map.h>
 
@@ -72,6 +73,24 @@  static struct map_desc at91_io_desc __initdata = {
 	.type		= MT_DEVICE,
 };
 
+void __iomem *at91_ioremap(unsigned long p, size_t size, unsigned int type)
+{
+	if (p >= AT91_BASE_SYS && p <= (AT91_BASE_SYS + SZ_16K - 1))
+		return (void __iomem *)AT91_IO_P2V(p);
+
+	return __arm_ioremap_caller(p, size, type, __builtin_return_address(0));
+}
+EXPORT_SYMBOL(at91_ioremap);
+
+void at91_iounmap(volatile void __iomem *addr)
+{
+	unsigned long virt = (unsigned long)addr;
+
+	if (virt >= VMALLOC_START && virt < VMALLOC_END)
+		__iounmap(addr);
+}
+EXPORT_SYMBOL(at91_iounmap);
+
 #define AT91_DBGU0	0xfffff200
 #define AT91_DBGU1	0xffffee00