15e61cba0SAndrew Jones #ifndef _ASMARM_IO_H_
25e61cba0SAndrew Jones #define _ASMARM_IO_H_
38cca5668SAndrew Jones #include <libcflat.h>
48cca5668SAndrew Jones #include <asm/barrier.h>
58cca5668SAndrew Jones #include <asm/page.h>
65e61cba0SAndrew Jones
7ac797b45SChristoffer Dall #define __iomem
8ac797b45SChristoffer Dall #define __force
9ac797b45SChristoffer Dall
105e61cba0SAndrew Jones #define __bswap16 bswap16
bswap16(u16 val)115e61cba0SAndrew Jones static inline u16 bswap16(u16 val)
125e61cba0SAndrew Jones {
135e61cba0SAndrew Jones u16 ret;
145e61cba0SAndrew Jones asm volatile("rev16 %0, %1" : "=r" (ret) : "r" (val));
155e61cba0SAndrew Jones return ret;
165e61cba0SAndrew Jones }
175e61cba0SAndrew Jones
185e61cba0SAndrew Jones #define __bswap32 bswap32
bswap32(u32 val)195e61cba0SAndrew Jones static inline u32 bswap32(u32 val)
205e61cba0SAndrew Jones {
215e61cba0SAndrew Jones u32 ret;
225e61cba0SAndrew Jones asm volatile("rev %0, %1" : "=r" (ret) : "r" (val));
235e61cba0SAndrew Jones return ret;
245e61cba0SAndrew Jones }
255e61cba0SAndrew Jones
26ac797b45SChristoffer Dall #define __raw_readb __raw_readb
__raw_readb(const volatile void __iomem * addr)27ac797b45SChristoffer Dall static inline u8 __raw_readb(const volatile void __iomem *addr)
28ac797b45SChristoffer Dall {
29ac797b45SChristoffer Dall u8 val;
30ac797b45SChristoffer Dall asm volatile("ldrb %1, %0"
31ac797b45SChristoffer Dall : "+Qo" (*(volatile u8 __force *)addr),
32ac797b45SChristoffer Dall "=r" (val));
33ac797b45SChristoffer Dall return val;
34ac797b45SChristoffer Dall }
35ac797b45SChristoffer Dall
36ac797b45SChristoffer Dall #define __raw_readw __raw_readw
__raw_readw(const volatile void __iomem * addr)37ac797b45SChristoffer Dall static inline u16 __raw_readw(const volatile void __iomem *addr)
38ac797b45SChristoffer Dall {
39ac797b45SChristoffer Dall u16 val;
40ac797b45SChristoffer Dall asm volatile("ldrh %1, %0"
41ac797b45SChristoffer Dall : "+Q" (*(volatile u16 __force *)addr),
42ac797b45SChristoffer Dall "=r" (val));
43ac797b45SChristoffer Dall return val;
44ac797b45SChristoffer Dall }
45ac797b45SChristoffer Dall
46ac797b45SChristoffer Dall #define __raw_readl __raw_readl
__raw_readl(const volatile void __iomem * addr)47ac797b45SChristoffer Dall static inline u32 __raw_readl(const volatile void __iomem *addr)
48ac797b45SChristoffer Dall {
49ac797b45SChristoffer Dall u32 val;
50ac797b45SChristoffer Dall asm volatile("ldr %1, %0"
51ac797b45SChristoffer Dall : "+Qo" (*(volatile u32 __force *)addr),
52ac797b45SChristoffer Dall "=r" (val));
53ac797b45SChristoffer Dall return val;
54ac797b45SChristoffer Dall }
55ac797b45SChristoffer Dall
56ac797b45SChristoffer Dall #define __raw_writeb __raw_writeb
__raw_writeb(u8 val,volatile void __iomem * addr)57ac797b45SChristoffer Dall static inline void __raw_writeb(u8 val, volatile void __iomem *addr)
58ac797b45SChristoffer Dall {
59ac797b45SChristoffer Dall asm volatile("strb %1, %0"
60ac797b45SChristoffer Dall : "+Qo" (*(volatile u8 __force *)addr)
61ac797b45SChristoffer Dall : "r" (val));
62ac797b45SChristoffer Dall }
63ac797b45SChristoffer Dall
64ac797b45SChristoffer Dall #define __raw_writew __raw_writew
__raw_writew(u16 val,volatile void __iomem * addr)65ac797b45SChristoffer Dall static inline void __raw_writew(u16 val, volatile void __iomem *addr)
66ac797b45SChristoffer Dall {
67ac797b45SChristoffer Dall asm volatile("strh %1, %0"
68ac797b45SChristoffer Dall : "+Q" (*(volatile u16 __force *)addr)
69ac797b45SChristoffer Dall : "r" (val));
70ac797b45SChristoffer Dall }
71ac797b45SChristoffer Dall
72ac797b45SChristoffer Dall #define __raw_writel __raw_writel
__raw_writel(u32 val,volatile void __iomem * addr)73ac797b45SChristoffer Dall static inline void __raw_writel(u32 val, volatile void __iomem *addr)
74ac797b45SChristoffer Dall {
75ac797b45SChristoffer Dall asm volatile("str %1, %0"
76ac797b45SChristoffer Dall : "+Qo" (*(volatile u32 __force *)addr)
77ac797b45SChristoffer Dall : "r" (val));
78ac797b45SChristoffer Dall }
79ac797b45SChristoffer Dall
80*e97e1c82SAndrew Jones #define ioremap ioremap
ioremap(phys_addr_t phys_addr,size_t size)81*e97e1c82SAndrew Jones static inline void __iomem *ioremap(phys_addr_t phys_addr, size_t size)
82*e97e1c82SAndrew Jones {
83*e97e1c82SAndrew Jones return __ioremap(phys_addr, size);
84*e97e1c82SAndrew Jones }
85*e97e1c82SAndrew Jones
86fd33143eSAndrew Jones #define virt_to_phys virt_to_phys
virt_to_phys(const volatile void * x)87fd33143eSAndrew Jones static inline phys_addr_t virt_to_phys(const volatile void *x)
88fd33143eSAndrew Jones {
89fd33143eSAndrew Jones return __virt_to_phys((unsigned long)(x));
90fd33143eSAndrew Jones }
91fd33143eSAndrew Jones
92fd33143eSAndrew Jones #define phys_to_virt phys_to_virt
phys_to_virt(phys_addr_t x)93fd33143eSAndrew Jones static inline void *phys_to_virt(phys_addr_t x)
94fd33143eSAndrew Jones {
95fd33143eSAndrew Jones return (void *)__phys_to_virt(x);
96fd33143eSAndrew Jones }
97fd33143eSAndrew Jones
988cca5668SAndrew Jones #include <asm-generic/io.h>
995e61cba0SAndrew Jones
1005e61cba0SAndrew Jones #endif /* _ASMARM_IO_H_ */
101