diff mbox

[3/3] linux/io.h: add generic ioremap()/iounmap() defines

Message ID 1467016351-22360-4-git-send-email-yamada.masahiro@socionext.com
State New
Headers show

Commit Message

Masahiro Yamada June 27, 2016, 8:32 a.m. UTC
For most of architectures in U-Boot, virtual address is straight
mapped to physical address.  So, it makes sense to have generic
defines of ioremap and friends in <linux/io.h>.

All of them are just empty and will disappear at compile time, but
they will be helpful to implement drivers which are counterparts of
Linux ones.

I notice MIPS already has its own implementation, so I surrounded
the defines with #ifndef CONFIG_MIPS ... #endif.  I guess Sandbox
will need its own implementation as well.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>

---

 include/linux/io.h | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

-- 
1.9.1

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Comments

Masahiro Yamada June 28, 2016, 1:34 a.m. UTC | #1
Hi Daniel,

2016-06-27 18:57 GMT+09:00 Daniel Schwierzeck <daniel.schwierzeck@gmail.com>:
>

>

> Am 27.06.2016 um 10:32 schrieb Masahiro Yamada:

>> For most of architectures in U-Boot, virtual address is straight

>> mapped to physical address.  So, it makes sense to have generic

>> defines of ioremap and friends in <linux/io.h>.

>>

>> All of them are just empty and will disappear at compile time, but

>> they will be helpful to implement drivers which are counterparts of

>> Linux ones.

>>

>> I notice MIPS already has its own implementation, so I surrounded

>> the defines with #ifndef CONFIG_MIPS ... #endif.  I guess Sandbox

>> will need its own implementation as well.

>>

>

> how about introducing a Kconfig symbol like CONFIG_HAVE_ARCH_IOREMAP

> which MIPS and Sandbox can select?


Good idea!

I will do so in v2.




-- 
Best Regards
Masahiro Yamada
_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot
diff mbox

Patch

diff --git a/include/linux/io.h b/include/linux/io.h
index 1b36a22..ca23caa 100644
--- a/include/linux/io.h
+++ b/include/linux/io.h
@@ -5,6 +5,22 @@ 
 #ifndef _LINUX_IO_H
 #define _LINUX_IO_H
 
+#include <linux/compiler.h>
+#include <linux/types.h>
 #include <asm/io.h>
 
+#ifndef CONFIG_MIPS
+static inline void __iomem *ioremap(resource_size_t offset,
+				    resource_size_t size)
+{
+	return (void __iomem *)(unsigned long)offset;
+}
+
+static inline void iounmap(void __iomem *addr)
+{
+}
+
+#define devm_ioremap(dev, offset, size)		ioremap(offset, size)
+#endif
+
 #endif /* _LINUX_IO_H */