diff options
Diffstat (limited to 'arch/sparc/include/asm')
-rw-r--r-- | arch/sparc/include/asm/io_32.h | 287 | ||||
-rw-r--r-- | arch/sparc/include/asm/io_64.h | 1 | ||||
-rw-r--r-- | arch/sparc/include/asm/page.h | 3 |
3 files changed, 51 insertions, 240 deletions
diff --git a/arch/sparc/include/asm/io_32.h b/arch/sparc/include/asm/io_32.h index c1acbd891cbc..383f513be66a 100644 --- a/arch/sparc/include/asm/io_32.h +++ b/arch/sparc/include/asm/io_32.h | |||
@@ -2,191 +2,94 @@ | |||
2 | #define __SPARC_IO_H | 2 | #define __SPARC_IO_H |
3 | 3 | ||
4 | #include <linux/kernel.h> | 4 | #include <linux/kernel.h> |
5 | #include <linux/types.h> | ||
6 | #include <linux/ioport.h> /* struct resource */ | 5 | #include <linux/ioport.h> /* struct resource */ |
7 | 6 | ||
8 | #include <asm/page.h> /* IO address mapping routines need this */ | 7 | #define readb_relaxed(__addr) readb(__addr) |
9 | #include <asm-generic/pci_iomap.h> | 8 | #define readw_relaxed(__addr) readw(__addr) |
10 | 9 | #define readl_relaxed(__addr) readl(__addr) | |
11 | #define page_to_phys(page) (page_to_pfn(page) << PAGE_SHIFT) | ||
12 | |||
13 | static inline u32 flip_dword (u32 l) | ||
14 | { | ||
15 | return ((l&0xff)<<24) | (((l>>8)&0xff)<<16) | (((l>>16)&0xff)<<8)| ((l>>24)&0xff); | ||
16 | } | ||
17 | |||
18 | static inline u16 flip_word (u16 w) | ||
19 | { | ||
20 | return ((w&0xff) << 8) | ((w>>8)&0xff); | ||
21 | } | ||
22 | |||
23 | #define mmiowb() | ||
24 | |||
25 | /* | ||
26 | * Memory mapped I/O to PCI | ||
27 | */ | ||
28 | |||
29 | static inline u8 __raw_readb(const volatile void __iomem *addr) | ||
30 | { | ||
31 | return *(__force volatile u8 *)addr; | ||
32 | } | ||
33 | |||
34 | static inline u16 __raw_readw(const volatile void __iomem *addr) | ||
35 | { | ||
36 | return *(__force volatile u16 *)addr; | ||
37 | } | ||
38 | |||
39 | static inline u32 __raw_readl(const volatile void __iomem *addr) | ||
40 | { | ||
41 | return *(__force volatile u32 *)addr; | ||
42 | } | ||
43 | 10 | ||
44 | static inline void __raw_writeb(u8 b, volatile void __iomem *addr) | 11 | #define IO_SPACE_LIMIT 0xffffffff |
45 | { | ||
46 | *(__force volatile u8 *)addr = b; | ||
47 | } | ||
48 | 12 | ||
49 | static inline void __raw_writew(u16 w, volatile void __iomem *addr) | 13 | #define memset_io(d,c,sz) _memset_io(d,c,sz) |
50 | { | 14 | #define memcpy_fromio(d,s,sz) _memcpy_fromio(d,s,sz) |
51 | *(__force volatile u16 *)addr = w; | 15 | #define memcpy_toio(d,s,sz) _memcpy_toio(d,s,sz) |
52 | } | ||
53 | 16 | ||
54 | static inline void __raw_writel(u32 l, volatile void __iomem *addr) | 17 | #include <asm-generic/io.h> |
55 | { | ||
56 | *(__force volatile u32 *)addr = l; | ||
57 | } | ||
58 | 18 | ||
59 | static inline u8 __readb(const volatile void __iomem *addr) | 19 | static inline void _memset_io(volatile void __iomem *dst, |
20 | int c, __kernel_size_t n) | ||
60 | { | 21 | { |
61 | return *(__force volatile u8 *)addr; | 22 | volatile void __iomem *d = dst; |
62 | } | ||
63 | 23 | ||
64 | static inline u16 __readw(const volatile void __iomem *addr) | 24 | while (n--) { |
65 | { | 25 | writeb(c, d); |
66 | return flip_word(*(__force volatile u16 *)addr); | 26 | d++; |
27 | } | ||
67 | } | 28 | } |
68 | 29 | ||
69 | static inline u32 __readl(const volatile void __iomem *addr) | 30 | static inline void _memcpy_fromio(void *dst, const volatile void __iomem *src, |
31 | __kernel_size_t n) | ||
70 | { | 32 | { |
71 | return flip_dword(*(__force volatile u32 *)addr); | 33 | char *d = dst; |
72 | } | ||
73 | 34 | ||
74 | static inline void __writeb(u8 b, volatile void __iomem *addr) | 35 | while (n--) { |
75 | { | 36 | char tmp = readb(src); |
76 | *(__force volatile u8 *)addr = b; | 37 | *d++ = tmp; |
38 | src++; | ||
39 | } | ||
77 | } | 40 | } |
78 | 41 | ||
79 | static inline void __writew(u16 w, volatile void __iomem *addr) | 42 | static inline void _memcpy_toio(volatile void __iomem *dst, const void *src, |
43 | __kernel_size_t n) | ||
80 | { | 44 | { |
81 | *(__force volatile u16 *)addr = flip_word(w); | 45 | const char *s = src; |
82 | } | 46 | volatile void __iomem *d = dst; |
83 | 47 | ||
84 | static inline void __writel(u32 l, volatile void __iomem *addr) | 48 | while (n--) { |
85 | { | 49 | char tmp = *s++; |
86 | *(__force volatile u32 *)addr = flip_dword(l); | 50 | writeb(tmp, d); |
51 | d++; | ||
52 | } | ||
87 | } | 53 | } |
88 | 54 | ||
89 | #define readb(__addr) __readb(__addr) | ||
90 | #define readw(__addr) __readw(__addr) | ||
91 | #define readl(__addr) __readl(__addr) | ||
92 | #define readb_relaxed(__addr) readb(__addr) | ||
93 | #define readw_relaxed(__addr) readw(__addr) | ||
94 | #define readl_relaxed(__addr) readl(__addr) | ||
95 | |||
96 | #define writeb(__b, __addr) __writeb((__b),(__addr)) | ||
97 | #define writew(__w, __addr) __writew((__w),(__addr)) | ||
98 | #define writel(__l, __addr) __writel((__l),(__addr)) | ||
99 | |||
100 | /* | ||
101 | * I/O space operations | ||
102 | * | ||
103 | * Arrangement on a Sun is somewhat complicated. | ||
104 | * | ||
105 | * First of all, we want to use standard Linux drivers | ||
106 | * for keyboard, PC serial, etc. These drivers think | ||
107 | * they access I/O space and use inb/outb. | ||
108 | * On the other hand, EBus bridge accepts PCI *memory* | ||
109 | * cycles and converts them into ISA *I/O* cycles. | ||
110 | * Ergo, we want inb & outb to generate PCI memory cycles. | ||
111 | * | ||
112 | * If we want to issue PCI *I/O* cycles, we do this | ||
113 | * with a low 64K fixed window in PCIC. This window gets | ||
114 | * mapped somewhere into virtual kernel space and we | ||
115 | * can use inb/outb again. | ||
116 | */ | ||
117 | #define inb_local(__addr) __readb((void __iomem *)(unsigned long)(__addr)) | ||
118 | #define inb(__addr) __readb((void __iomem *)(unsigned long)(__addr)) | ||
119 | #define inw(__addr) __readw((void __iomem *)(unsigned long)(__addr)) | ||
120 | #define inl(__addr) __readl((void __iomem *)(unsigned long)(__addr)) | ||
121 | |||
122 | #define outb_local(__b, __addr) __writeb(__b, (void __iomem *)(unsigned long)(__addr)) | ||
123 | #define outb(__b, __addr) __writeb(__b, (void __iomem *)(unsigned long)(__addr)) | ||
124 | #define outw(__w, __addr) __writew(__w, (void __iomem *)(unsigned long)(__addr)) | ||
125 | #define outl(__l, __addr) __writel(__l, (void __iomem *)(unsigned long)(__addr)) | ||
126 | |||
127 | #define inb_p(__addr) inb(__addr) | ||
128 | #define outb_p(__b, __addr) outb(__b, __addr) | ||
129 | #define inw_p(__addr) inw(__addr) | ||
130 | #define outw_p(__w, __addr) outw(__w, __addr) | ||
131 | #define inl_p(__addr) inl(__addr) | ||
132 | #define outl_p(__l, __addr) outl(__l, __addr) | ||
133 | |||
134 | void outsb(unsigned long addr, const void *src, unsigned long cnt); | ||
135 | void outsw(unsigned long addr, const void *src, unsigned long cnt); | ||
136 | void outsl(unsigned long addr, const void *src, unsigned long cnt); | ||
137 | void insb(unsigned long addr, void *dst, unsigned long count); | ||
138 | void insw(unsigned long addr, void *dst, unsigned long count); | ||
139 | void insl(unsigned long addr, void *dst, unsigned long count); | ||
140 | |||
141 | #define IO_SPACE_LIMIT 0xffffffff | ||
142 | |||
143 | /* | 55 | /* |
144 | * SBus accessors. | 56 | * SBus accessors. |
145 | * | 57 | * |
146 | * SBus has only one, memory mapped, I/O space. | 58 | * SBus has only one, memory mapped, I/O space. |
147 | * We do not need to flip bytes for SBus of course. | 59 | * We do not need to flip bytes for SBus of course. |
148 | */ | 60 | */ |
149 | static inline u8 _sbus_readb(const volatile void __iomem *addr) | 61 | static inline u8 sbus_readb(const volatile void __iomem *addr) |
150 | { | 62 | { |
151 | return *(__force volatile u8 *)addr; | 63 | return *(__force volatile u8 *)addr; |
152 | } | 64 | } |
153 | 65 | ||
154 | static inline u16 _sbus_readw(const volatile void __iomem *addr) | 66 | static inline u16 sbus_readw(const volatile void __iomem *addr) |
155 | { | 67 | { |
156 | return *(__force volatile u16 *)addr; | 68 | return *(__force volatile u16 *)addr; |
157 | } | 69 | } |
158 | 70 | ||
159 | static inline u32 _sbus_readl(const volatile void __iomem *addr) | 71 | static inline u32 sbus_readl(const volatile void __iomem *addr) |
160 | { | 72 | { |
161 | return *(__force volatile u32 *)addr; | 73 | return *(__force volatile u32 *)addr; |
162 | } | 74 | } |
163 | 75 | ||
164 | static inline void _sbus_writeb(u8 b, volatile void __iomem *addr) | 76 | static inline void sbus_writeb(u8 b, volatile void __iomem *addr) |
165 | { | 77 | { |
166 | *(__force volatile u8 *)addr = b; | 78 | *(__force volatile u8 *)addr = b; |
167 | } | 79 | } |
168 | 80 | ||
169 | static inline void _sbus_writew(u16 w, volatile void __iomem *addr) | 81 | static inline void sbus_writew(u16 w, volatile void __iomem *addr) |
170 | { | 82 | { |
171 | *(__force volatile u16 *)addr = w; | 83 | *(__force volatile u16 *)addr = w; |
172 | } | 84 | } |
173 | 85 | ||
174 | static inline void _sbus_writel(u32 l, volatile void __iomem *addr) | 86 | static inline void sbus_writel(u32 l, volatile void __iomem *addr) |
175 | { | 87 | { |
176 | *(__force volatile u32 *)addr = l; | 88 | *(__force volatile u32 *)addr = l; |
177 | } | 89 | } |
178 | 90 | ||
179 | /* | 91 | static inline void sbus_memset_io(volatile void __iomem *__dst, int c, |
180 | * The only reason for #define's is to hide casts to unsigned long. | 92 | __kernel_size_t n) |
181 | */ | ||
182 | #define sbus_readb(__addr) _sbus_readb(__addr) | ||
183 | #define sbus_readw(__addr) _sbus_readw(__addr) | ||
184 | #define sbus_readl(__addr) _sbus_readl(__addr) | ||
185 | #define sbus_writeb(__b, __addr) _sbus_writeb(__b, __addr) | ||
186 | #define sbus_writew(__w, __addr) _sbus_writew(__w, __addr) | ||
187 | #define sbus_writel(__l, __addr) _sbus_writel(__l, __addr) | ||
188 | |||
189 | static inline void sbus_memset_io(volatile void __iomem *__dst, int c, __kernel_size_t n) | ||
190 | { | 93 | { |
191 | while(n--) { | 94 | while(n--) { |
192 | sbus_writeb(c, __dst); | 95 | sbus_writeb(c, __dst); |
@@ -194,22 +97,9 @@ static inline void sbus_memset_io(volatile void __iomem *__dst, int c, __kernel_ | |||
194 | } | 97 | } |
195 | } | 98 | } |
196 | 99 | ||
197 | static inline void | 100 | static inline void sbus_memcpy_fromio(void *dst, |
198 | _memset_io(volatile void __iomem *dst, int c, __kernel_size_t n) | 101 | const volatile void __iomem *src, |
199 | { | 102 | __kernel_size_t n) |
200 | volatile void __iomem *d = dst; | ||
201 | |||
202 | while (n--) { | ||
203 | writeb(c, d); | ||
204 | d++; | ||
205 | } | ||
206 | } | ||
207 | |||
208 | #define memset_io(d,c,sz) _memset_io(d,c,sz) | ||
209 | |||
210 | static inline void | ||
211 | _sbus_memcpy_fromio(void *dst, const volatile void __iomem *src, | ||
212 | __kernel_size_t n) | ||
213 | { | 103 | { |
214 | char *d = dst; | 104 | char *d = dst; |
215 | 105 | ||
@@ -220,25 +110,9 @@ _sbus_memcpy_fromio(void *dst, const volatile void __iomem *src, | |||
220 | } | 110 | } |
221 | } | 111 | } |
222 | 112 | ||
223 | #define sbus_memcpy_fromio(d, s, sz) _sbus_memcpy_fromio(d, s, sz) | 113 | static inline void sbus_memcpy_toio(volatile void __iomem *dst, |
224 | 114 | const void *src, | |
225 | static inline void | 115 | __kernel_size_t n) |
226 | _memcpy_fromio(void *dst, const volatile void __iomem *src, __kernel_size_t n) | ||
227 | { | ||
228 | char *d = dst; | ||
229 | |||
230 | while (n--) { | ||
231 | char tmp = readb(src); | ||
232 | *d++ = tmp; | ||
233 | src++; | ||
234 | } | ||
235 | } | ||
236 | |||
237 | #define memcpy_fromio(d,s,sz) _memcpy_fromio(d,s,sz) | ||
238 | |||
239 | static inline void | ||
240 | _sbus_memcpy_toio(volatile void __iomem *dst, const void *src, | ||
241 | __kernel_size_t n) | ||
242 | { | 116 | { |
243 | const char *s = src; | 117 | const char *s = src; |
244 | volatile void __iomem *d = dst; | 118 | volatile void __iomem *d = dst; |
@@ -250,23 +124,6 @@ _sbus_memcpy_toio(volatile void __iomem *dst, const void *src, | |||
250 | } | 124 | } |
251 | } | 125 | } |
252 | 126 | ||
253 | #define sbus_memcpy_toio(d, s, sz) _sbus_memcpy_toio(d, s, sz) | ||
254 | |||
255 | static inline void | ||
256 | _memcpy_toio(volatile void __iomem *dst, const void *src, __kernel_size_t n) | ||
257 | { | ||
258 | const char *s = src; | ||
259 | volatile void __iomem *d = dst; | ||
260 | |||
261 | while (n--) { | ||
262 | char tmp = *s++; | ||
263 | writeb(tmp, d); | ||
264 | d++; | ||
265 | } | ||
266 | } | ||
267 | |||
268 | #define memcpy_toio(d,s,sz) _memcpy_toio(d,s,sz) | ||
269 | |||
270 | #ifdef __KERNEL__ | 127 | #ifdef __KERNEL__ |
271 | 128 | ||
272 | /* | 129 | /* |
@@ -278,46 +135,6 @@ extern void __iomem *ioremap(unsigned long offset, unsigned long size); | |||
278 | #define ioremap_wc(X,Y) ioremap((X),(Y)) | 135 | #define ioremap_wc(X,Y) ioremap((X),(Y)) |
279 | extern void iounmap(volatile void __iomem *addr); | 136 | extern void iounmap(volatile void __iomem *addr); |
280 | 137 | ||
281 | #define ioread8(X) readb(X) | ||
282 | #define ioread16(X) readw(X) | ||
283 | #define ioread16be(X) __raw_readw(X) | ||
284 | #define ioread32(X) readl(X) | ||
285 | #define ioread32be(X) __raw_readl(X) | ||
286 | #define iowrite8(val,X) writeb(val,X) | ||
287 | #define iowrite16(val,X) writew(val,X) | ||
288 | #define iowrite16be(val,X) __raw_writew(val,X) | ||
289 | #define iowrite32(val,X) writel(val,X) | ||
290 | #define iowrite32be(val,X) __raw_writel(val,X) | ||
291 | |||
292 | static inline void ioread8_rep(void __iomem *port, void *buf, unsigned long count) | ||
293 | { | ||
294 | insb((unsigned long __force)port, buf, count); | ||
295 | } | ||
296 | static inline void ioread16_rep(void __iomem *port, void *buf, unsigned long count) | ||
297 | { | ||
298 | insw((unsigned long __force)port, buf, count); | ||
299 | } | ||
300 | |||
301 | static inline void ioread32_rep(void __iomem *port, void *buf, unsigned long count) | ||
302 | { | ||
303 | insl((unsigned long __force)port, buf, count); | ||
304 | } | ||
305 | |||
306 | static inline void iowrite8_rep(void __iomem *port, const void *buf, unsigned long count) | ||
307 | { | ||
308 | outsb((unsigned long __force)port, buf, count); | ||
309 | } | ||
310 | |||
311 | static inline void iowrite16_rep(void __iomem *port, const void *buf, unsigned long count) | ||
312 | { | ||
313 | outsw((unsigned long __force)port, buf, count); | ||
314 | } | ||
315 | |||
316 | static inline void iowrite32_rep(void __iomem *port, const void *buf, unsigned long count) | ||
317 | { | ||
318 | outsl((unsigned long __force)port, buf, count); | ||
319 | } | ||
320 | |||
321 | /* Create a virtual mapping cookie for an IO port range */ | 138 | /* Create a virtual mapping cookie for an IO port range */ |
322 | extern void __iomem *ioport_map(unsigned long port, unsigned int nr); | 139 | extern void __iomem *ioport_map(unsigned long port, unsigned int nr); |
323 | extern void ioport_unmap(void __iomem *); | 140 | extern void ioport_unmap(void __iomem *); |
@@ -326,6 +143,8 @@ extern void ioport_unmap(void __iomem *); | |||
326 | struct pci_dev; | 143 | struct pci_dev; |
327 | extern void pci_iounmap(struct pci_dev *dev, void __iomem *); | 144 | extern void pci_iounmap(struct pci_dev *dev, void __iomem *); |
328 | 145 | ||
146 | |||
147 | |||
329 | /* | 148 | /* |
330 | * At the moment, we do not use CMOS_READ anywhere outside of rtc.c, | 149 | * At the moment, we do not use CMOS_READ anywhere outside of rtc.c, |
331 | * so rtc_port is static in it. This should not change unless a new | 150 | * so rtc_port is static in it. This should not change unless a new |
@@ -349,15 +168,5 @@ extern void sbus_set_sbus64(struct device *, int); | |||
349 | 168 | ||
350 | #define __ARCH_HAS_NO_PAGE_ZERO_MAPPED 1 | 169 | #define __ARCH_HAS_NO_PAGE_ZERO_MAPPED 1 |
351 | 170 | ||
352 | /* | ||
353 | * Convert a physical pointer to a virtual kernel pointer for /dev/mem | ||
354 | * access | ||
355 | */ | ||
356 | #define xlate_dev_mem_ptr(p) __va(p) | ||
357 | |||
358 | /* | ||
359 | * Convert a virtual cached pointer to an uncached pointer | ||
360 | */ | ||
361 | #define xlate_dev_kmem_ptr(p) p | ||
362 | 171 | ||
363 | #endif /* !(__SPARC_IO_H) */ | 172 | #endif /* !(__SPARC_IO_H) */ |
diff --git a/arch/sparc/include/asm/io_64.h b/arch/sparc/include/asm/io_64.h index 09b0b88aeb2a..44845632e983 100644 --- a/arch/sparc/include/asm/io_64.h +++ b/arch/sparc/include/asm/io_64.h | |||
@@ -15,7 +15,6 @@ | |||
15 | 15 | ||
16 | /* BIO layer definitions. */ | 16 | /* BIO layer definitions. */ |
17 | extern unsigned long kern_base, kern_size; | 17 | extern unsigned long kern_base, kern_size; |
18 | #define page_to_phys(page) (page_to_pfn(page) << PAGE_SHIFT) | ||
19 | 18 | ||
20 | static inline u8 _inb(unsigned long addr) | 19 | static inline u8 _inb(unsigned long addr) |
21 | { | 20 | { |
diff --git a/arch/sparc/include/asm/page.h b/arch/sparc/include/asm/page.h index f21de0349025..1be2fdec6268 100644 --- a/arch/sparc/include/asm/page.h +++ b/arch/sparc/include/asm/page.h | |||
@@ -1,5 +1,8 @@ | |||
1 | #ifndef ___ASM_SPARC_PAGE_H | 1 | #ifndef ___ASM_SPARC_PAGE_H |
2 | #define ___ASM_SPARC_PAGE_H | 2 | #define ___ASM_SPARC_PAGE_H |
3 | |||
4 | #define page_to_phys(page) (page_to_pfn(page) << PAGE_SHIFT) | ||
5 | |||
3 | #if defined(__sparc__) && defined(__arch64__) | 6 | #if defined(__sparc__) && defined(__arch64__) |
4 | #include <asm/page_64.h> | 7 | #include <asm/page_64.h> |
5 | #else | 8 | #else |