aboutsummaryrefslogtreecommitdiffstats
path: root/arch/xtensa/include/asm/io.h
diff options
context:
space:
mode:
Diffstat (limited to 'arch/xtensa/include/asm/io.h')
-rw-r--r--arch/xtensa/include/asm/io.h156
1 files changed, 9 insertions, 147 deletions
diff --git a/arch/xtensa/include/asm/io.h b/arch/xtensa/include/asm/io.h
index 4f66dfc103a5..e6be5b9091c2 100644
--- a/arch/xtensa/include/asm/io.h
+++ b/arch/xtensa/include/asm/io.h
@@ -25,74 +25,31 @@
25#define XCHAL_KIO_SIZE 0x10000000 25#define XCHAL_KIO_SIZE 0x10000000
26 26
27#define IOADDR(x) (XCHAL_KIO_BYPASS_VADDR + (x)) 27#define IOADDR(x) (XCHAL_KIO_BYPASS_VADDR + (x))
28#define IO_SPACE_LIMIT ~0
28 29
30#ifdef CONFIG_MMU
29/* 31/*
30 * swap functions to change byte order from little-endian to big-endian and 32 * Return the virtual address for the specified bus memory.
31 * vice versa.
32 */
33
34static inline unsigned short _swapw (unsigned short v)
35{
36 return (v << 8) | (v >> 8);
37}
38
39static inline unsigned int _swapl (unsigned int v)
40{
41 return (v << 24) | ((v & 0xff00) << 8) | ((v >> 8) & 0xff00) | (v >> 24);
42}
43
44/*
45 * Change virtual addresses to physical addresses and vv.
46 * These are trivial on the 1:1 Linux/Xtensa mapping
47 */
48
49static inline unsigned long virt_to_phys(volatile void * address)
50{
51 return __pa(address);
52}
53
54static inline void * phys_to_virt(unsigned long address)
55{
56 return __va(address);
57}
58
59/*
60 * virt_to_bus and bus_to_virt are deprecated.
61 */
62
63#define virt_to_bus(x) virt_to_phys(x)
64#define bus_to_virt(x) phys_to_virt(x)
65
66/*
67 * Return the virtual (cached) address for the specified bus memory.
68 * Note that we currently don't support any address outside the KIO segment. 33 * Note that we currently don't support any address outside the KIO segment.
69 */ 34 */
70static inline void __iomem *ioremap_nocache(unsigned long offset, 35static inline void __iomem *ioremap_nocache(unsigned long offset,
71 unsigned long size) 36 unsigned long size)
72{ 37{
73#ifdef CONFIG_MMU
74 if (offset >= XCHAL_KIO_PADDR 38 if (offset >= XCHAL_KIO_PADDR
75 && offset - XCHAL_KIO_PADDR < XCHAL_KIO_SIZE) 39 && offset - XCHAL_KIO_PADDR < XCHAL_KIO_SIZE)
76 return (void*)(offset-XCHAL_KIO_PADDR+XCHAL_KIO_BYPASS_VADDR); 40 return (void*)(offset-XCHAL_KIO_PADDR+XCHAL_KIO_BYPASS_VADDR);
77 else 41 else
78 BUG(); 42 BUG();
79#else
80 return (void *)offset;
81#endif
82} 43}
83 44
84static inline void __iomem *ioremap_cache(unsigned long offset, 45static inline void __iomem *ioremap_cache(unsigned long offset,
85 unsigned long size) 46 unsigned long size)
86{ 47{
87#ifdef CONFIG_MMU
88 if (offset >= XCHAL_KIO_PADDR 48 if (offset >= XCHAL_KIO_PADDR
89 && offset - XCHAL_KIO_PADDR < XCHAL_KIO_SIZE) 49 && offset - XCHAL_KIO_PADDR < XCHAL_KIO_SIZE)
90 return (void*)(offset-XCHAL_KIO_PADDR+XCHAL_KIO_CACHED_VADDR); 50 return (void*)(offset-XCHAL_KIO_PADDR+XCHAL_KIO_CACHED_VADDR);
91 else 51 else
92 BUG(); 52 BUG();
93#else
94 return (void *)offset;
95#endif
96} 53}
97 54
98#define ioremap_wc ioremap_nocache 55#define ioremap_wc ioremap_nocache
@@ -105,112 +62,17 @@ static inline void __iomem *ioremap(unsigned long offset, unsigned long size)
105static inline void iounmap(volatile void __iomem *addr) 62static inline void iounmap(volatile void __iomem *addr)
106{ 63{
107} 64}
65#endif /* CONFIG_MMU */
108 66
109/* 67/*
110 * Generic I/O 68 * Generic I/O
111 */ 69 */
112 70#define readb_relaxed readb
113#define readb(addr) \ 71#define readw_relaxed readw
114 ({ unsigned char __v = (*(volatile unsigned char *)(addr)); __v; }) 72#define readl_relaxed readl
115#define readw(addr) \
116 ({ unsigned short __v = (*(volatile unsigned short *)(addr)); __v; })
117#define readl(addr) \
118 ({ unsigned int __v = (*(volatile unsigned int *)(addr)); __v; })
119#define writeb(b, addr) (void)((*(volatile unsigned char *)(addr)) = (b))
120#define writew(b, addr) (void)((*(volatile unsigned short *)(addr)) = (b))
121#define writel(b, addr) (void)((*(volatile unsigned int *)(addr)) = (b))
122
123static inline __u8 __raw_readb(const volatile void __iomem *addr)
124{
125 return *(__force volatile __u8 *)(addr);
126}
127static inline __u16 __raw_readw(const volatile void __iomem *addr)
128{
129 return *(__force volatile __u16 *)(addr);
130}
131static inline __u32 __raw_readl(const volatile void __iomem *addr)
132{
133 return *(__force volatile __u32 *)(addr);
134}
135static inline void __raw_writeb(__u8 b, volatile void __iomem *addr)
136{
137 *(__force volatile __u8 *)(addr) = b;
138}
139static inline void __raw_writew(__u16 b, volatile void __iomem *addr)
140{
141 *(__force volatile __u16 *)(addr) = b;
142}
143static inline void __raw_writel(__u32 b, volatile void __iomem *addr)
144{
145 *(__force volatile __u32 *)(addr) = b;
146}
147
148/* These are the definitions for the x86 IO instructions
149 * inb/inw/inl/outb/outw/outl, the "string" versions
150 * insb/insw/insl/outsb/outsw/outsl, and the "pausing" versions
151 * inb_p/inw_p/...
152 * The macros don't do byte-swapping.
153 */
154
155#define inb(port) readb((u8 *)((port)))
156#define outb(val, port) writeb((val),(u8 *)((unsigned long)(port)))
157#define inw(port) readw((u16 *)((port)))
158#define outw(val, port) writew((val),(u16 *)((unsigned long)(port)))
159#define inl(port) readl((u32 *)((port)))
160#define outl(val, port) writel((val),(u32 *)((unsigned long)(port)))
161
162#define inb_p(port) inb((port))
163#define outb_p(val, port) outb((val), (port))
164#define inw_p(port) inw((port))
165#define outw_p(val, port) outw((val), (port))
166#define inl_p(port) inl((port))
167#define outl_p(val, port) outl((val), (port))
168
169extern void insb (unsigned long port, void *dst, unsigned long count);
170extern void insw (unsigned long port, void *dst, unsigned long count);
171extern void insl (unsigned long port, void *dst, unsigned long count);
172extern void outsb (unsigned long port, const void *src, unsigned long count);
173extern void outsw (unsigned long port, const void *src, unsigned long count);
174extern void outsl (unsigned long port, const void *src, unsigned long count);
175
176#define IO_SPACE_LIMIT ~0
177
178#define memset_io(a,b,c) memset((void *)(a),(b),(c))
179#define memcpy_fromio(a,b,c) memcpy((a),(void *)(b),(c))
180#define memcpy_toio(a,b,c) memcpy((void *)(a),(b),(c))
181
182/* At this point the Xtensa doesn't provide byte swap instructions */
183
184#ifdef __XTENSA_EB__
185# define in_8(addr) (*(u8*)(addr))
186# define in_le16(addr) _swapw(*(u16*)(addr))
187# define in_le32(addr) _swapl(*(u32*)(addr))
188# define out_8(b, addr) *(u8*)(addr) = (b)
189# define out_le16(b, addr) *(u16*)(addr) = _swapw(b)
190# define out_le32(b, addr) *(u32*)(addr) = _swapl(b)
191#elif defined(__XTENSA_EL__)
192# define in_8(addr) (*(u8*)(addr))
193# define in_le16(addr) (*(u16*)(addr))
194# define in_le32(addr) (*(u32*)(addr))
195# define out_8(b, addr) *(u8*)(addr) = (b)
196# define out_le16(b, addr) *(u16*)(addr) = (b)
197# define out_le32(b, addr) *(u32*)(addr) = (b)
198#else
199# error processor byte order undefined!
200#endif
201
202
203/*
204 * Convert a physical pointer to a virtual kernel pointer for /dev/mem access
205 */
206#define xlate_dev_mem_ptr(p) __va(p)
207
208/*
209 * Convert a virtual cached pointer to an uncached pointer
210 */
211#define xlate_dev_kmem_ptr(p) p
212
213 73
214#endif /* __KERNEL__ */ 74#endif /* __KERNEL__ */
215 75
76#include <asm-generic/io.h>
77
216#endif /* _XTENSA_IO_H */ 78#endif /* _XTENSA_IO_H */