Add generic ioremap / iounmap defines
Subsystems (2)
v2 cover Add generic ioremap / iounmap defines
I ran Buildman for the whole series, and I did not see any regression.
01: Merge branch 'master' of git://git.denx.de/u-boot-uniphier
openrisc: + openrisc-generic
arc: + tb100 axs101 axs103
blackfin: + bf533-stamp cm-bf527
arm: + socfpga_is1
powerpc: + P1022DS_36BIT_NAND T2080QDS_SPIFLASH T1042RDB_PI_SPIFLASH P1010RDB-PA_36BIT_NAND P1010RDB-PB_SDCARD T1042D4RDB_NAND T4240RDB_SDCARD P1010RDB-PB_36BIT_NAND P1022DS_36BIT_SDCARD P1010RDB-PB_36BIT_SDCARD P1022DS_NAND T4160QDS_NAND T1042RDB_PI_NAND T2080RDB_NAND P1022DS_SDCARD T1042RDB_PI_SDCARD T2081QDS_NAND T4160QDS_SDCARD T2080QDS_SDCARD T4240QDS_SDCARD P1010RDB-PA_SPIFLASH T1040RDB_SDCARD B4860QDS_NAND P1010RDB-PA_36BIT_SDCARD T1040D4RDB_SDCARD T1040D4RDB_SPIFLASH T2080QDS_NAND T1040D4RDB_NAND P1010RDB-PB_SPIFLASH P1010RDB-PA_NAND T1040RDB_SPIFLASH kmcoge4 T2081QDS_SDCARD T2081QDS_SPIFLASH T4240QDS_NAND B4420QDS_NAND T1040RDB_NAND P1010RDB-PA_SDCARD T2080RDB_SPIFLASH P1010RDB-PB_NAND T1042D4RDB_SPIFLASH P1022DS_SPIFLASH T1042D4RDB_SDCARD kmlion1 P1022DS_36BIT_SPIFLASH P1010RDB-PB_36BIT_SPIFLASH T2080RDB_SDCARD P1010RDB-PA_36BIT_SPIFLASH [snip lots of error messages we have in the mainline]
02: types.h: move and redefine resource_size_t
03: arm, nds32, sh: remove useless ioremap()/iounmap() defines 04: linux/io.h: add generic ioremap()/iounmap() defines
Changes in v2:
- Use #ifndef CONFIG_HAVE_ARCH_IOREMAP instead of #ifndef CONFIG_MIPS
Masahiro Yamada (3):
types.h: move and redefine resource_size_t
arm, nds32, sh: remove useless ioremap()/iounmap() defines linux/io.h: add generic ioremap()/iounmap() defines
arch/Kconfig | 4 ++++ arch/arm/include/asm/io.h | 34 ---------------------------------- arch/arm/include/asm/types.h | 1 - arch/nds32/include/asm/io.h | 34 ---------------------------------- arch/sh/include/asm/io.h | 33 --------------------------------- include/linux/io.h | 16 ++++++++++++++++ include/linux/types.h | 4 ++++ 7 files changed, 24 insertions(+), 102 deletions(-)
Signature · 1 line
1.9.1
PATCH v2 1/3 types.h: move and redefine resource_size_t
Currently, this is only defined in arch/arm/include/asm/types.h, so move it to include/linux/types.h to make it available for all architectures.
I defined it with phys_addr_t as Linux does. I needed to surround the define with #ifdef __KERNEL__ ... #endif to avoid build errors in tools building. (Host tools should not include <linux/types.h> in the first place, but this is already messy in U-Boot...)
---
Changes in v2: None
arch/arm/include/asm/types.h | 1 - include/linux/types.h | 4 ++++ 2 files changed, 4 insertions(+), 1 deletion(-)
arch/arm/include/asm/types.h +0 -1
@@ -71,5 +71,4 @@ typedef u32 dma_addr_t;#endif /* __KERNEL__ */ -typedef unsigned long resource_size_t ;#endif
include/linux/types.h +4 -0
@@ -124,6 +124,10 @@ typedef __UINT64_TYPE__ u_int64_t;typedef __INT64_TYPE__ int64_t ;#endif +#ifdef __KERNEL__ +typedef phys_addr_t resource_size_t ; +#endif +/* * Below are truly Linux-specific types that should never collide with * any application/library that wants linux/types.h.
Signature · 1 line
1.9.1
PATCH v2 1/3 types.h: move and redefine resource_size_t
Quoted 9 lines · Masahiro Yamada
Currently, this is only defined in
arch/arm/include/asm/types.h, so move it toinclude/linux/types.hto make it available for all architectures.I defined it with
phys_addr_tas Linux does. I needed to surround the define with #ifdef__KERNEL__... #endif to avoid build errors in tools building. (Host tools should not include <linux/types.h> in the first place, but this is already messy in U-Boot...)
Quoted 8 lines
Signed-off-by Masahiro Yamada <[email protected]>---
Changes in v2: None
arch/arm/include/asm/types.h | 1 - include/linux/types.h | 4 ++++ 2 files changed, 4 insertions(+), 1 deletion(-)
PATCH v2 1/3 types.h: move and redefine resource_size_t
In reply to Masahiro YamadaQuoted 11 lines · Masahiro Yamada
Currently, this is only defined in
arch/arm/include/asm/types.h, so move it toinclude/linux/types.hto make it available for all architectures.I defined it with
phys_addr_tas Linux does. I needed to surround the define with #ifdef__KERNEL__... #endif to avoid build errors in tools building. (Host tools should not include <linux/types.h> in the first place, but this is already messy in U-Boot...)Signed-off-by Masahiro Yamada <[email protected]>Reviewed-by Simon Glass <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160716/82c07046/attachment.sig>
PATCH v2 2/3 arm, nds32, sh: remove useless ioremap()/iounmap() defines
In reply to Masahiro YamadaThese defines are valid only when iomem_valid_addr is defined, but I do not see such defines anywhere. Remove.
---
Changes in v2: None
arch/arm/include/asm/io.h | 34 ---------------------------------- arch/nds32/include/asm/io.h | 34 ---------------------------------- arch/sh/include/asm/io.h | 33 --------------------------------- 3 files changed, 101 deletions(-)
arch/arm/include/asm/io.h +0 -34
@@ -292,40 +292,6 @@ static inline void __raw_readsl(unsigned long addr, void *data, int longlen)#define readsb (a, d, s) __raw_readsb((unsigned long)a, d, s)/* -* ioremap and friends. -* -* ioremap takes a PCI memory address, as specified in -* linux/Documentation/IO-mapping.txt. If you want a -* physical address, use __ioremap instead. -*/ -extern void *__ioremap (unsigned long offset,size_t size,unsigned long flags); -extern void __iounmap (void *addr); - -/* -* Generic ioremap support. -* -* Define: -* iomem_valid_addr(off,size) -* iomem_to_phys(off) -*/ -#ifdef iomem_valid_addr -#define __arch_ioremap (off,sz,nocache) \ - ({ \ - unsigned long _off = (off), _size = (sz); \ - void *_ret = (void *)0; \ - if (iomem_valid_addr(_off, _size)) \ - _ret = __ioremap(iomem_to_phys(_off),_size,nocache); \ - _ret; \ - }) - -#define __arch_iounmap __iounmap -#endif - -#define ioremap (off,sz) __arch_ioremap((off),(sz),0) -#define ioremap_nocache (off,sz) __arch_ioremap((off),(sz),1) -#define iounmap (_addr) __arch_iounmap(_addr) - -/* * DMA-consistent mapping functions. These allocate/free a region of * uncached, unwrite-buffered mapped memory space for use with DMA * devices. This is the "generic" version. The PCI specific version
arch/nds32/include/asm/io.h +0 -34
@@ -344,40 +344,6 @@ static inline void writesl(unsigned int *addr, const void * data, int longlen)#define insl_p (port, to, len) insl(port, to, len)/* -* ioremap and friends. -* -* ioremap takes a PCI memory address, as specified in -* linux/Documentation/IO-mapping.txt. If you want a -* physical address, use __ioremap instead. -*/ -extern void *__ioremap (unsigned long offset,size_t size,unsigned long flags); -extern void __iounmap (void *addr); - -/* -* Generic ioremap support. -* -* Define: -* iomem_valid_addr(off,size) -* iomem_to_phys(off) -*/ -#ifdef iomem_valid_addr -#define __arch_ioremap (off, sz, nocache) \ -({ \ - unsigned long _off = (off), _size = (sz); \ - void *_ret = (void *)0; \ - if (iomem_valid_addr(_off, _size)) \ - _ret = __ioremap(iomem_to_phys(_off), _size, 0); \ - _ret; \ -}) - -#define __arch_iounmap __iounmap -#endif - -#define ioremap (off, sz) __arch_ioremap((off), (sz), 0) -#define ioremap_nocache (off, sz) __arch_ioremap((off), (sz), 1) -#define iounmap (_addr) __arch_iounmap(_addr) - -/* * DMA-consistent mapping functions. These allocate/free a region of * uncached, unwrite-buffered mapped memory space for use with DMA * devices. This is the "generic" version. The PCI specific version
arch/sh/include/asm/io.h +0 -33
@@ -128,39 +128,6 @@ extern void __raw_readsl(unsigned int addr, void *data, int longlen);#define in_8 (port) inb(port)#define in_le16 (port) inw(port)#define in_le32 (port) inl(port) -/* -* ioremap and friends. -* -* ioremap takes a PCI memory address, as specified in -* linux/Documentation/IO-mapping.txt. If you want a -* physical address, use __ioremap instead. -*/ -extern void *__ioremap (unsigned long offset,size_t size,unsigned long flags); -extern void __iounmap (void *addr); - -/* -* Generic ioremap support. -* -* Define: -* iomem_valid_addr(off,size) -* iomem_to_phys(off) -*/ -#ifdef iomem_valid_addr -#define __arch_ioremap (off, sz, nocache) \ -({ \ - unsigned long _off = (off), _size = (sz); \ - void *_ret = (void *)0; \ - if (iomem_valid_addr(_off, _size)) \ - _ret = __ioremap(iomem_to_phys(_off), _size, 0); \ - _ret; \ -}) - -#define __arch_iounmap __iounmap -#endif - -#define ioremap (off, sz) __arch_ioremap((off), (sz), 0) -#define ioremap_nocache (off, sz) __arch_ioremap((off), (sz), 1) -#define iounmap (_addr) __arch_iounmap(_addr)/* * DMA-consistent mapping functions. These allocate/free a region of
Signature · 1 line
1.9.1
PATCH v2 2/3 arm, nds32, sh: remove useless ioremap()/iounmap() defines
Quoted 4 lines · Masahiro Yamada
These defines are valid only when
iomem_valid_addris defined, but I do not see such defines anywhere. Remove.Signed-off-by Masahiro Yamada <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160716/7a3a63a4/attachment.sig>
PATCH v2 3/3 linux/io.h: add generic ioremap()/iounmap() defines
In reply to Masahiro YamadaFor 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 added a Kconfig symbol CONFIG_HAVE_ARCH_IOREMAP which MIPS (and maybe Sandbox as well) can select.
---
Changes in v2:
- Use #ifndef CONFIG_HAVE_ARCH_IOREMAP instead of #ifndef CONFIG_MIPS
arch/Kconfig | 4 ++++ include/linux/io.h | 16 ++++++++++++++++ 2 files changed, 20 insertions(+)
arch/Kconfig +4 -0
@@ -1,6 +1,9 @@ config CREATE_ARCH_SYMLINK bool +config HAVE_ARCH_IOREMAP + bool + choice prompt "Architecture select" default SANDBOX
@@ -33,6 +36,7 @@ config MICROBLAZE config MIPS bool "MIPS architecture" + select HAVE_ARCH_IOREMAP select HAVE_PRIVATE_LIBGCC select SUPPORT_OF_CONTROL
include/linux/io.h +16 -0
@@ -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_HAVE_ARCH_IOREMAP +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 */
Signature · 1 line
1.9.1
PATCH v2 3/3 linux/io.h: add generic ioremap()/iounmap() defines
Am 28.06.2016 um 03:48 schrieb Masahiro Yamada:
Quoted 8 lines
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.
Quoted 5 lines
I notice MIPS already has its own implementation, so I added a
KconfigsymbolCONFIG_HAVE_ARCH_IOREMAPwhich MIPS (and maybe Sandbox as well) can select.Signed-off-by Masahiro Yamada <[email protected]>
Signature · 9 lines
- Daniel -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 473 bytes Desc: OpenPGP digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160628/4ea5e196/attachment.sig>
PATCH v2 3/3 linux/io.h: add generic ioremap()/iounmap() defines
In reply to Masahiro YamadaQuoted 8 lines · 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.
Quoted 6 lines
I notice MIPS already has its own implementation, so I added a
KconfigsymbolCONFIG_HAVE_ARCH_IOREMAPwhich MIPS (and maybe Sandbox as well) can select.Signed-off-by Masahiro Yamada <[email protected]>Reviewed-by Daniel Schwierzeck <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160716/6e063730/attachment.sig>