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