aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/sparc/include/asm/io_32.h242
-rw-r--r--arch/sparc/kernel/leon_pci.c79
-rw-r--r--arch/sparc/kernel/pcic.c78
-rw-r--r--arch/sparc/lib/Makefile2
4 files changed, 35 insertions, 366 deletions
diff --git a/arch/sparc/include/asm/io_32.h b/arch/sparc/include/asm/io_32.h
index 271c94a74aad..d281d4c8a08b 100644
--- a/arch/sparc/include/asm/io_32.h
+++ b/arch/sparc/include/asm/io_32.h
@@ -2,142 +2,56 @@
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)
11static inline u32 flip_dword (u32 l)
12{
13 return ((l&0xff)<<24) | (((l>>8)&0xff)<<16) | (((l>>16)&0xff)<<8)| ((l>>24)&0xff);
14}
15
16static inline u16 flip_word (u16 w)
17{
18 return ((w&0xff) << 8) | ((w>>8)&0xff);
19}
20
21#define mmiowb()
22
23/*
24 * Memory mapped I/O to PCI
25 */
26
27static inline u8 __raw_readb(const volatile void __iomem *addr)
28{
29 return *(__force volatile u8 *)addr;
30}
31
32static inline u16 __raw_readw(const volatile void __iomem *addr)
33{
34 return *(__force volatile u16 *)addr;
35}
36
37static inline u32 __raw_readl(const volatile void __iomem *addr)
38{
39 return *(__force volatile u32 *)addr;
40}
41 10
42static inline void __raw_writeb(u8 b, volatile void __iomem *addr) 11#define IO_SPACE_LIMIT 0xffffffff
43{
44 *(__force volatile u8 *)addr = b;
45}
46 12
47static inline void __raw_writew(u16 w, volatile void __iomem *addr) 13#define memset_io(d,c,sz) _memset_io(d,c,sz)
48{ 14#define memcpy_fromio(d,s,sz) _memcpy_fromio(d,s,sz)
49 *(__force volatile u16 *)addr = w; 15#define memcpy_toio(d,s,sz) _memcpy_toio(d,s,sz)
50}
51 16
52static inline void __raw_writel(u32 l, volatile void __iomem *addr) 17#include <asm-generic/io.h>
53{
54 *(__force volatile u32 *)addr = l;
55}
56 18
57static inline u8 __readb(const volatile void __iomem *addr) 19static inline void _memset_io(volatile void __iomem *dst,
20 int c, __kernel_size_t n)
58{ 21{
59 return *(__force volatile u8 *)addr; 22 volatile void __iomem *d = dst;
60}
61 23
62static inline u16 __readw(const volatile void __iomem *addr) 24 while (n--) {
63{ 25 writeb(c, d);
64 return flip_word(*(__force volatile u16 *)addr); 26 d++;
27 }
65} 28}
66 29
67static inline u32 __readl(const volatile void __iomem *addr) 30static inline void _memcpy_fromio(void *dst, const volatile void __iomem *src,
31 __kernel_size_t n)
68{ 32{
69 return flip_dword(*(__force volatile u32 *)addr); 33 char *d = dst;
70}
71 34
72static inline void __writeb(u8 b, volatile void __iomem *addr) 35 while (n--) {
73{ 36 char tmp = readb(src);
74 *(__force volatile u8 *)addr = b; 37 *d++ = tmp;
38 src++;
39 }
75} 40}
76 41
77static inline void __writew(u16 w, volatile void __iomem *addr) 42static inline void _memcpy_toio(volatile void __iomem *dst, const void *src,
43 __kernel_size_t n)
78{ 44{
79 *(__force volatile u16 *)addr = flip_word(w); 45 const char *s = src;
80} 46 volatile void __iomem *d = dst;
81 47
82static inline void __writel(u32 l, volatile void __iomem *addr) 48 while (n--) {
83{ 49 char tmp = *s++;
84 *(__force volatile u32 *)addr = flip_dword(l); 50 writeb(tmp, d);
51 d++;
52 }
85} 53}
86 54
87#define readb(__addr) __readb(__addr)
88#define readw(__addr) __readw(__addr)
89#define readl(__addr) __readl(__addr)
90#define readb_relaxed(__addr) readb(__addr)
91#define readw_relaxed(__addr) readw(__addr)
92#define readl_relaxed(__addr) readl(__addr)
93
94#define writeb(__b, __addr) __writeb((__b),(__addr))
95#define writew(__w, __addr) __writew((__w),(__addr))
96#define writel(__l, __addr) __writel((__l),(__addr))
97
98/*
99 * I/O space operations
100 *
101 * Arrangement on a Sun is somewhat complicated.
102 *
103 * First of all, we want to use standard Linux drivers
104 * for keyboard, PC serial, etc. These drivers think
105 * they access I/O space and use inb/outb.
106 * On the other hand, EBus bridge accepts PCI *memory*
107 * cycles and converts them into ISA *I/O* cycles.
108 * Ergo, we want inb & outb to generate PCI memory cycles.
109 *
110 * If we want to issue PCI *I/O* cycles, we do this
111 * with a low 64K fixed window in PCIC. This window gets
112 * mapped somewhere into virtual kernel space and we
113 * can use inb/outb again.
114 */
115#define inb_local(__addr) __readb((void __iomem *)(unsigned long)(__addr))
116#define inb(__addr) __readb((void __iomem *)(unsigned long)(__addr))
117#define inw(__addr) __readw((void __iomem *)(unsigned long)(__addr))
118#define inl(__addr) __readl((void __iomem *)(unsigned long)(__addr))
119
120#define outb_local(__b, __addr) __writeb(__b, (void __iomem *)(unsigned long)(__addr))
121#define outb(__b, __addr) __writeb(__b, (void __iomem *)(unsigned long)(__addr))
122#define outw(__w, __addr) __writew(__w, (void __iomem *)(unsigned long)(__addr))
123#define outl(__l, __addr) __writel(__l, (void __iomem *)(unsigned long)(__addr))
124
125#define inb_p(__addr) inb(__addr)
126#define outb_p(__b, __addr) outb(__b, __addr)
127#define inw_p(__addr) inw(__addr)
128#define outw_p(__w, __addr) outw(__w, __addr)
129#define inl_p(__addr) inl(__addr)
130#define outl_p(__l, __addr) outl(__l, __addr)
131
132void outsb(unsigned long addr, const void *src, unsigned long cnt);
133void outsw(unsigned long addr, const void *src, unsigned long cnt);
134void outsl(unsigned long addr, const void *src, unsigned long cnt);
135void insb(unsigned long addr, void *dst, unsigned long count);
136void insw(unsigned long addr, void *dst, unsigned long count);
137void insl(unsigned long addr, void *dst, unsigned long count);
138
139#define IO_SPACE_LIMIT 0xffffffff
140
141/* 55/*
142 * SBus accessors. 56 * SBus accessors.
143 * 57 *
@@ -192,18 +106,7 @@ static inline void sbus_memset_io(volatile void __iomem *__dst, int c, __kernel_
192 } 106 }
193} 107}
194 108
195static inline void
196_memset_io(volatile void __iomem *dst, int c, __kernel_size_t n)
197{
198 volatile void __iomem *d = dst;
199
200 while (n--) {
201 writeb(c, d);
202 d++;
203 }
204}
205 109
206#define memset_io(d,c,sz) _memset_io(d,c,sz)
207 110
208static inline void 111static inline void
209_sbus_memcpy_fromio(void *dst, const volatile void __iomem *src, 112_sbus_memcpy_fromio(void *dst, const volatile void __iomem *src,
@@ -221,20 +124,6 @@ _sbus_memcpy_fromio(void *dst, const volatile void __iomem *src,
221#define sbus_memcpy_fromio(d, s, sz) _sbus_memcpy_fromio(d, s, sz) 124#define sbus_memcpy_fromio(d, s, sz) _sbus_memcpy_fromio(d, s, sz)
222 125
223static inline void 126static inline void
224_memcpy_fromio(void *dst, const volatile void __iomem *src, __kernel_size_t n)
225{
226 char *d = dst;
227
228 while (n--) {
229 char tmp = readb(src);
230 *d++ = tmp;
231 src++;
232 }
233}
234
235#define memcpy_fromio(d,s,sz) _memcpy_fromio(d,s,sz)
236
237static inline void
238_sbus_memcpy_toio(volatile void __iomem *dst, const void *src, 127_sbus_memcpy_toio(volatile void __iomem *dst, const void *src,
239 __kernel_size_t n) 128 __kernel_size_t n)
240{ 129{
@@ -250,21 +139,6 @@ _sbus_memcpy_toio(volatile void __iomem *dst, const void *src,
250 139
251#define sbus_memcpy_toio(d, s, sz) _sbus_memcpy_toio(d, s, sz) 140#define sbus_memcpy_toio(d, s, sz) _sbus_memcpy_toio(d, s, sz)
252 141
253static inline void
254_memcpy_toio(volatile void __iomem *dst, const void *src, __kernel_size_t n)
255{
256 const char *s = src;
257 volatile void __iomem *d = dst;
258
259 while (n--) {
260 char tmp = *s++;
261 writeb(tmp, d);
262 d++;
263 }
264}
265
266#define memcpy_toio(d,s,sz) _memcpy_toio(d,s,sz)
267
268#ifdef __KERNEL__ 142#ifdef __KERNEL__
269 143
270/* 144/*
@@ -276,46 +150,6 @@ extern void __iomem *ioremap(unsigned long offset, unsigned long size);
276#define ioremap_wc(X,Y) ioremap((X),(Y)) 150#define ioremap_wc(X,Y) ioremap((X),(Y))
277extern void iounmap(volatile void __iomem *addr); 151extern void iounmap(volatile void __iomem *addr);
278 152
279#define ioread8(X) readb(X)
280#define ioread16(X) readw(X)
281#define ioread16be(X) __raw_readw(X)
282#define ioread32(X) readl(X)
283#define ioread32be(X) __raw_readl(X)
284#define iowrite8(val,X) writeb(val,X)
285#define iowrite16(val,X) writew(val,X)
286#define iowrite16be(val,X) __raw_writew(val,X)
287#define iowrite32(val,X) writel(val,X)
288#define iowrite32be(val,X) __raw_writel(val,X)
289
290static inline void ioread8_rep(void __iomem *port, void *buf, unsigned long count)
291{
292 insb((unsigned long __force)port, buf, count);
293}
294static inline void ioread16_rep(void __iomem *port, void *buf, unsigned long count)
295{
296 insw((unsigned long __force)port, buf, count);
297}
298
299static inline void ioread32_rep(void __iomem *port, void *buf, unsigned long count)
300{
301 insl((unsigned long __force)port, buf, count);
302}
303
304static inline void iowrite8_rep(void __iomem *port, const void *buf, unsigned long count)
305{
306 outsb((unsigned long __force)port, buf, count);
307}
308
309static inline void iowrite16_rep(void __iomem *port, const void *buf, unsigned long count)
310{
311 outsw((unsigned long __force)port, buf, count);
312}
313
314static inline void iowrite32_rep(void __iomem *port, const void *buf, unsigned long count)
315{
316 outsl((unsigned long __force)port, buf, count);
317}
318
319/* Create a virtual mapping cookie for an IO port range */ 153/* Create a virtual mapping cookie for an IO port range */
320extern void __iomem *ioport_map(unsigned long port, unsigned int nr); 154extern void __iomem *ioport_map(unsigned long port, unsigned int nr);
321extern void ioport_unmap(void __iomem *); 155extern void ioport_unmap(void __iomem *);
@@ -324,6 +158,8 @@ extern void ioport_unmap(void __iomem *);
324struct pci_dev; 158struct pci_dev;
325extern void pci_iounmap(struct pci_dev *dev, void __iomem *); 159extern void pci_iounmap(struct pci_dev *dev, void __iomem *);
326 160
161
162
327/* 163/*
328 * At the moment, we do not use CMOS_READ anywhere outside of rtc.c, 164 * At the moment, we do not use CMOS_READ anywhere outside of rtc.c,
329 * so rtc_port is static in it. This should not change unless a new 165 * so rtc_port is static in it. This should not change unless a new
@@ -347,15 +183,5 @@ extern void sbus_set_sbus64(struct device *, int);
347 183
348#define __ARCH_HAS_NO_PAGE_ZERO_MAPPED 1 184#define __ARCH_HAS_NO_PAGE_ZERO_MAPPED 1
349 185
350/*
351 * Convert a physical pointer to a virtual kernel pointer for /dev/mem
352 * access
353 */
354#define xlate_dev_mem_ptr(p) __va(p)
355
356/*
357 * Convert a virtual cached pointer to an uncached pointer
358 */
359#define xlate_dev_kmem_ptr(p) p
360 186
361#endif /* !(__SPARC_IO_H) */ 187#endif /* !(__SPARC_IO_H) */
diff --git a/arch/sparc/kernel/leon_pci.c b/arch/sparc/kernel/leon_pci.c
index e16c4157e1ae..899b7203a4e4 100644
--- a/arch/sparc/kernel/leon_pci.c
+++ b/arch/sparc/kernel/leon_pci.c
@@ -98,82 +98,3 @@ resource_size_t pcibios_align_resource(void *data, const struct resource *res,
98{ 98{
99 return res->start; 99 return res->start;
100} 100}
101
102/* in/out routines taken from pcic.c
103 *
104 * This probably belongs here rather than ioport.c because
105 * we do not want this crud linked into SBus kernels.
106 * Also, think for a moment about likes of floppy.c that
107 * include architecture specific parts. They may want to redefine ins/outs.
108 *
109 * We do not use horrible macros here because we want to
110 * advance pointer by sizeof(size).
111 */
112void outsb(unsigned long addr, const void *src, unsigned long count)
113{
114 while (count) {
115 count -= 1;
116 outb(*(const char *)src, addr);
117 src += 1;
118 /* addr += 1; */
119 }
120}
121EXPORT_SYMBOL(outsb);
122
123void outsw(unsigned long addr, const void *src, unsigned long count)
124{
125 while (count) {
126 count -= 2;
127 outw(*(const short *)src, addr);
128 src += 2;
129 /* addr += 2; */
130 }
131}
132EXPORT_SYMBOL(outsw);
133
134void outsl(unsigned long addr, const void *src, unsigned long count)
135{
136 while (count) {
137 count -= 4;
138 outl(*(const long *)src, addr);
139 src += 4;
140 /* addr += 4; */
141 }
142}
143EXPORT_SYMBOL(outsl);
144
145void insb(unsigned long addr, void *dst, unsigned long count)
146{
147 while (count) {
148 count -= 1;
149 *(unsigned char *)dst = inb(addr);
150 dst += 1;
151 /* addr += 1; */
152 }
153}
154EXPORT_SYMBOL(insb);
155
156void insw(unsigned long addr, void *dst, unsigned long count)
157{
158 while (count) {
159 count -= 2;
160 *(unsigned short *)dst = inw(addr);
161 dst += 2;
162 /* addr += 2; */
163 }
164}
165EXPORT_SYMBOL(insw);
166
167void insl(unsigned long addr, void *dst, unsigned long count)
168{
169 while (count) {
170 count -= 4;
171 /*
172 * XXX I am sure we are in for an unaligned trap here.
173 */
174 *(unsigned long *)dst = inl(addr);
175 dst += 4;
176 /* addr += 4; */
177 }
178}
179EXPORT_SYMBOL(insl);
diff --git a/arch/sparc/kernel/pcic.c b/arch/sparc/kernel/pcic.c
index 6996f32c64bf..aabfcab94325 100644
--- a/arch/sparc/kernel/pcic.c
+++ b/arch/sparc/kernel/pcic.c
@@ -875,82 +875,4 @@ void __init sun4m_pci_init_IRQ(void)
875 sparc_config.load_profile_irq = pcic_load_profile_irq; 875 sparc_config.load_profile_irq = pcic_load_profile_irq;
876} 876}
877 877
878/*
879 * This probably belongs here rather than ioport.c because
880 * we do not want this crud linked into SBus kernels.
881 * Also, think for a moment about likes of floppy.c that
882 * include architecture specific parts. They may want to redefine ins/outs.
883 *
884 * We do not use horrible macros here because we want to
885 * advance pointer by sizeof(size).
886 */
887void outsb(unsigned long addr, const void *src, unsigned long count)
888{
889 while (count) {
890 count -= 1;
891 outb(*(const char *)src, addr);
892 src += 1;
893 /* addr += 1; */
894 }
895}
896EXPORT_SYMBOL(outsb);
897
898void outsw(unsigned long addr, const void *src, unsigned long count)
899{
900 while (count) {
901 count -= 2;
902 outw(*(const short *)src, addr);
903 src += 2;
904 /* addr += 2; */
905 }
906}
907EXPORT_SYMBOL(outsw);
908
909void outsl(unsigned long addr, const void *src, unsigned long count)
910{
911 while (count) {
912 count -= 4;
913 outl(*(const long *)src, addr);
914 src += 4;
915 /* addr += 4; */
916 }
917}
918EXPORT_SYMBOL(outsl);
919
920void insb(unsigned long addr, void *dst, unsigned long count)
921{
922 while (count) {
923 count -= 1;
924 *(unsigned char *)dst = inb(addr);
925 dst += 1;
926 /* addr += 1; */
927 }
928}
929EXPORT_SYMBOL(insb);
930
931void insw(unsigned long addr, void *dst, unsigned long count)
932{
933 while (count) {
934 count -= 2;
935 *(unsigned short *)dst = inw(addr);
936 dst += 2;
937 /* addr += 2; */
938 }
939}
940EXPORT_SYMBOL(insw);
941
942void insl(unsigned long addr, void *dst, unsigned long count)
943{
944 while (count) {
945 count -= 4;
946 /*
947 * XXX I am sure we are in for an unaligned trap here.
948 */
949 *(unsigned long *)dst = inl(addr);
950 dst += 4;
951 /* addr += 4; */
952 }
953}
954EXPORT_SYMBOL(insl);
955
956subsys_initcall(pcic_init); 878subsys_initcall(pcic_init);
diff --git a/arch/sparc/lib/Makefile b/arch/sparc/lib/Makefile
index dbe119b63b48..3269b0234093 100644
--- a/arch/sparc/lib/Makefile
+++ b/arch/sparc/lib/Makefile
@@ -41,7 +41,7 @@ lib-$(CONFIG_SPARC64) += GENpatch.o GENpage.o GENbzero.o
41lib-$(CONFIG_SPARC64) += copy_in_user.o user_fixup.o memmove.o 41lib-$(CONFIG_SPARC64) += copy_in_user.o user_fixup.o memmove.o
42lib-$(CONFIG_SPARC64) += mcount.o ipcsum.o xor.o hweight.o ffs.o 42lib-$(CONFIG_SPARC64) += mcount.o ipcsum.o xor.o hweight.o ffs.o
43 43
44obj-y += iomap.o 44obj-$(CONFIG_SPARC64) += iomap.o
45obj-$(CONFIG_SPARC32) += atomic32.o ucmpdi2.o 45obj-$(CONFIG_SPARC32) += atomic32.o ucmpdi2.o
46obj-y += ksyms.o 46obj-y += ksyms.o
47obj-$(CONFIG_SPARC64) += PeeCeeI.o 47obj-$(CONFIG_SPARC64) += PeeCeeI.o