diff options
Diffstat (limited to 'arch/microblaze/include/asm/io.h')
-rw-r--r-- | arch/microblaze/include/asm/io.h | 208 |
1 files changed, 208 insertions, 0 deletions
diff --git a/arch/microblaze/include/asm/io.h b/arch/microblaze/include/asm/io.h new file mode 100644 index 000000000000..8b5853ee6b5c --- /dev/null +++ b/arch/microblaze/include/asm/io.h | |||
@@ -0,0 +1,208 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2006 Atmark Techno, Inc. | ||
3 | * | ||
4 | * This file is subject to the terms and conditions of the GNU General Public | ||
5 | * License. See the file "COPYING" in the main directory of this archive | ||
6 | * for more details. | ||
7 | */ | ||
8 | |||
9 | #ifndef _ASM_MICROBLAZE_IO_H | ||
10 | #define _ASM_MICROBLAZE_IO_H | ||
11 | |||
12 | #include <asm/byteorder.h> | ||
13 | #include <asm/page.h> | ||
14 | #include <linux/types.h> | ||
15 | |||
16 | #define IO_SPACE_LIMIT (0xFFFFFFFF) | ||
17 | |||
18 | static inline unsigned char __raw_readb(const volatile void __iomem *addr) | ||
19 | { | ||
20 | return *(volatile unsigned char __force *)addr; | ||
21 | } | ||
22 | static inline unsigned short __raw_readw(const volatile void __iomem *addr) | ||
23 | { | ||
24 | return *(volatile unsigned short __force *)addr; | ||
25 | } | ||
26 | static inline unsigned int __raw_readl(const volatile void __iomem *addr) | ||
27 | { | ||
28 | return *(volatile unsigned int __force *)addr; | ||
29 | } | ||
30 | static inline unsigned long __raw_readq(const volatile void __iomem *addr) | ||
31 | { | ||
32 | return *(volatile unsigned long __force *)addr; | ||
33 | } | ||
34 | static inline void __raw_writeb(unsigned char v, volatile void __iomem *addr) | ||
35 | { | ||
36 | *(volatile unsigned char __force *)addr = v; | ||
37 | } | ||
38 | static inline void __raw_writew(unsigned short v, volatile void __iomem *addr) | ||
39 | { | ||
40 | *(volatile unsigned short __force *)addr = v; | ||
41 | } | ||
42 | static inline void __raw_writel(unsigned int v, volatile void __iomem *addr) | ||
43 | { | ||
44 | *(volatile unsigned int __force *)addr = v; | ||
45 | } | ||
46 | static inline void __raw_writeq(unsigned long v, volatile void __iomem *addr) | ||
47 | { | ||
48 | *(volatile unsigned long __force *)addr = v; | ||
49 | } | ||
50 | |||
51 | /* | ||
52 | * read (readb, readw, readl, readq) and write (writeb, writew, | ||
53 | * writel, writeq) accessors are for PCI and thus littel endian. | ||
54 | * Linux 2.4 for Microblaze had this wrong. | ||
55 | */ | ||
56 | static inline unsigned char readb(const volatile void __iomem *addr) | ||
57 | { | ||
58 | return *(volatile unsigned char __force *)addr; | ||
59 | } | ||
60 | static inline unsigned short readw(const volatile void __iomem *addr) | ||
61 | { | ||
62 | return le16_to_cpu(*(volatile unsigned short __force *)addr); | ||
63 | } | ||
64 | static inline unsigned int readl(const volatile void __iomem *addr) | ||
65 | { | ||
66 | return le32_to_cpu(*(volatile unsigned int __force *)addr); | ||
67 | } | ||
68 | static inline void writeb(unsigned char v, volatile void __iomem *addr) | ||
69 | { | ||
70 | *(volatile unsigned char __force *)addr = v; | ||
71 | } | ||
72 | static inline void writew(unsigned short v, volatile void __iomem *addr) | ||
73 | { | ||
74 | *(volatile unsigned short __force *)addr = cpu_to_le16(v); | ||
75 | } | ||
76 | static inline void writel(unsigned int v, volatile void __iomem *addr) | ||
77 | { | ||
78 | *(volatile unsigned int __force *)addr = cpu_to_le32(v); | ||
79 | } | ||
80 | |||
81 | /* ioread and iowrite variants. thease are for now same as __raw_ | ||
82 | * variants of accessors. we might check for endianess in the feature | ||
83 | */ | ||
84 | #define ioread8(addr) __raw_readb((u8 *)(addr)) | ||
85 | #define ioread16(addr) __raw_readw((u16 *)(addr)) | ||
86 | #define ioread32(addr) __raw_readl((u32 *)(addr)) | ||
87 | #define iowrite8(v, addr) __raw_writeb((u8)(v), (u8 *)(addr)) | ||
88 | #define iowrite16(v, addr) __raw_writew((u16)(v), (u16 *)(addr)) | ||
89 | #define iowrite32(v, addr) __raw_writel((u32)(v), (u32 *)(addr)) | ||
90 | |||
91 | /* These are the definitions for the x86 IO instructions | ||
92 | * inb/inw/inl/outb/outw/outl, the "string" versions | ||
93 | * insb/insw/insl/outsb/outsw/outsl, and the "pausing" versions | ||
94 | * inb_p/inw_p/... | ||
95 | * The macros don't do byte-swapping. | ||
96 | */ | ||
97 | #define inb(port) readb((u8 *)((port))) | ||
98 | #define outb(val, port) writeb((val), (u8 *)((unsigned long)(port))) | ||
99 | #define inw(port) readw((u16 *)((port))) | ||
100 | #define outw(val, port) writew((val), (u16 *)((unsigned long)(port))) | ||
101 | #define inl(port) readl((u32 *)((port))) | ||
102 | #define outl(val, port) writel((val), (u32 *)((unsigned long)(port))) | ||
103 | |||
104 | #define inb_p(port) inb((port)) | ||
105 | #define outb_p(val, port) outb((val), (port)) | ||
106 | #define inw_p(port) inw((port)) | ||
107 | #define outw_p(val, port) outw((val), (port)) | ||
108 | #define inl_p(port) inl((port)) | ||
109 | #define outl_p(val, port) outl((val), (port)) | ||
110 | |||
111 | #define memset_io(a, b, c) memset((void *)(a), (b), (c)) | ||
112 | #define memcpy_fromio(a, b, c) memcpy((a), (void *)(b), (c)) | ||
113 | #define memcpy_toio(a, b, c) memcpy((void *)(a), (b), (c)) | ||
114 | |||
115 | /** | ||
116 | * virt_to_phys - map virtual addresses to physical | ||
117 | * @address: address to remap | ||
118 | * | ||
119 | * The returned physical address is the physical (CPU) mapping for | ||
120 | * the memory address given. It is only valid to use this function on | ||
121 | * addresses directly mapped or allocated via kmalloc. | ||
122 | * | ||
123 | * This function does not give bus mappings for DMA transfers. In | ||
124 | * almost all conceivable cases a device driver should not be using | ||
125 | * this function | ||
126 | */ | ||
127 | static inline unsigned long __iomem virt_to_phys(volatile void *address) | ||
128 | { | ||
129 | return __pa((unsigned long)address); | ||
130 | } | ||
131 | |||
132 | #define virt_to_bus virt_to_phys | ||
133 | |||
134 | /** | ||
135 | * phys_to_virt - map physical address to virtual | ||
136 | * @address: address to remap | ||
137 | * | ||
138 | * The returned virtual address is a current CPU mapping for | ||
139 | * the memory address given. It is only valid to use this function on | ||
140 | * addresses that have a kernel mapping | ||
141 | * | ||
142 | * This function does not handle bus mappings for DMA transfers. In | ||
143 | * almost all conceivable cases a device driver should not be using | ||
144 | * this function | ||
145 | */ | ||
146 | static inline void *phys_to_virt(unsigned long address) | ||
147 | { | ||
148 | return (void *)__va(address); | ||
149 | } | ||
150 | |||
151 | #define bus_to_virt(a) phys_to_virt(a) | ||
152 | |||
153 | static inline void __iomem *__ioremap(phys_addr_t address, unsigned long size, | ||
154 | unsigned long flags) | ||
155 | { | ||
156 | return (void *)address; | ||
157 | } | ||
158 | |||
159 | #define ioremap(physaddr, size) ((void __iomem *)(unsigned long)(physaddr)) | ||
160 | #define iounmap(addr) ((void)0) | ||
161 | #define ioremap_nocache(physaddr, size) ioremap(physaddr, size) | ||
162 | |||
163 | /* | ||
164 | * Convert a physical pointer to a virtual kernel pointer for /dev/mem | ||
165 | * access | ||
166 | */ | ||
167 | #define xlate_dev_mem_ptr(p) __va(p) | ||
168 | |||
169 | /* | ||
170 | * Convert a virtual cached pointer to an uncached pointer | ||
171 | */ | ||
172 | #define xlate_dev_kmem_ptr(p) p | ||
173 | |||
174 | /* | ||
175 | * Big Endian | ||
176 | */ | ||
177 | #define out_be32(a, v) __raw_writel((v), (void __iomem __force *)(a)) | ||
178 | #define out_be16(a, v) __raw_writew((v), (a)) | ||
179 | |||
180 | #define in_be32(a) __raw_readl((const void __iomem __force *)(a)) | ||
181 | #define in_be16(a) __raw_readw(a) | ||
182 | |||
183 | /* | ||
184 | * Little endian | ||
185 | */ | ||
186 | |||
187 | #define out_le32(a, v) __raw_writel(__cpu_to_le32(v), (a)); | ||
188 | #define out_le16(a, v) __raw_writew(__cpu_to_le16(v), (a)) | ||
189 | |||
190 | #define in_le32(a) __le32_to_cpu(__raw_readl(a)) | ||
191 | #define in_le16(a) __le16_to_cpu(__raw_readw(a)) | ||
192 | |||
193 | /* Byte ops */ | ||
194 | #define out_8(a, v) __raw_writeb((v), (a)) | ||
195 | #define in_8(a) __raw_readb(a) | ||
196 | |||
197 | /* FIXME */ | ||
198 | static inline void __iomem *ioport_map(unsigned long port, unsigned int len) | ||
199 | { | ||
200 | return (void __iomem *) (port); | ||
201 | } | ||
202 | |||
203 | static inline void ioport_unmap(void __iomem *addr) | ||
204 | { | ||
205 | /* Nothing to do */ | ||
206 | } | ||
207 | |||
208 | #endif /* _ASM_MICROBLAZE_IO_H */ | ||