4 /* USE_HPPA_IOREMAP IS THE MAGIC FLAG TO ENABLE OR DISABLE REAL IOREMAP() FUNCTIONALITY */
5 /* FOR 712 or 715 MACHINES THIS SHOULD BE ENABLED,
6 NEWER MACHINES STILL HAVE SOME ISSUES IN THE SCSI AND/OR NETWORK DRIVERS AND
7 BECAUSE OF THAT I WILL LEAVE IT DISABLED FOR NOW <deller@gmx.de> */
8 /* WHEN THOSE ISSUES ARE SOLVED, USE_HPPA_IOREMAP WILL GO AWAY */
9 #define USE_HPPA_IOREMAP 0
12 #include <linux/config.h>
13 #include <linux/types.h>
14 #include <asm/pgtable.h>
16 #define virt_to_phys(a) ((unsigned long)__pa(a))
17 #define phys_to_virt(a) __va(a)
18 #define virt_to_bus virt_to_phys
19 #define bus_to_virt phys_to_virt
21 /* Memory mapped IO */
23 extern void * __ioremap(unsigned long offset, unsigned long size, unsigned long flags);
25 extern inline void * ioremap(unsigned long offset, unsigned long size)
27 return __ioremap(offset, size, 0);
31 * This one maps high address device memory and turns off caching for that area.
32 * it's useful if some control registers are in such an area and write combining
33 * or read caching is not desirable:
35 extern inline void * ioremap_nocache (unsigned long offset, unsigned long size)
37 return __ioremap(offset, size, _PAGE_NO_CACHE /* _PAGE_PCD */);
40 extern void iounmap(void *addr);
43 * __raw_ variants have no defined meaning. on hppa, it means `i was
44 * too lazy to ioremap first'. kind of like isa_, except that there's
45 * no additional base address to add on.
47 extern __inline__ unsigned char __raw_readb(unsigned long addr)
56 : "=&r" (flags), "=r" (ret) : "r" (addr) );
61 extern __inline__ unsigned short __raw_readw(unsigned long addr)
70 : "=&r" (flags), "=r" (ret) : "r" (addr) );
75 extern __inline__ unsigned int __raw_readl(unsigned long addr)
81 : "=r" (ret) : "r" (addr) );
86 extern __inline__ unsigned long long __raw_readq(unsigned long addr)
88 unsigned long long ret;
92 : "=r" (ret) : "r" (addr) );
94 /* two reads may have side effects.. */
95 ret = ((u64) __raw_readl(addr)) << 32;
96 ret |= __raw_readl(addr+4);
101 extern __inline__ void __raw_writeb(unsigned char val, unsigned long addr)
104 __asm__ __volatile__(
108 : "=&r" (flags) : "r" (val), "r" (addr) );
111 extern __inline__ void __raw_writew(unsigned short val, unsigned long addr)
114 __asm__ __volatile__(
118 : "=&r" (flags) : "r" (val), "r" (addr) );
121 extern __inline__ void __raw_writel(unsigned int val, unsigned long addr)
123 __asm__ __volatile__(
124 " stwa,ma %0,0(%1)\n"
125 : : "r" (val), "r" (addr) );
128 extern __inline__ void __raw_writeq(unsigned long long val, unsigned long addr)
131 __asm__ __volatile__(
132 " stda,ma %0,0(%1)\n"
133 : : "r" (val), "r" (addr) );
135 /* two writes may have side effects.. */
136 __raw_writel(val >> 32, addr);
137 __raw_writel(val, addr+4);
142 #define readb(addr) (*(volatile unsigned char *) (addr))
143 #define readw(addr) (*(volatile unsigned short *) (addr))
144 #define readl(addr) (*(volatile unsigned int *) (addr))
145 #define readq(addr) (*(volatile u64 *) (addr))
146 #define writeb(b,addr) (*(volatile unsigned char *) (addr) = (b))
147 #define writew(b,addr) (*(volatile unsigned short *) (addr) = (b))
148 #define writel(b,addr) (*(volatile unsigned int *) (addr) = (b))
149 #define writeq(b,addr) (*(volatile u64 *) (addr) = (b))
150 #else /* !USE_HPPA_IOREMAP */
151 #define readb(addr) __raw_readb((unsigned long)(addr))
152 #define readw(addr) le16_to_cpu(__raw_readw((unsigned long)(addr)))
153 #define readl(addr) le32_to_cpu(__raw_readl((unsigned long)(addr)))
154 #define readq(addr) le64_to_cpu(__raw_readq((unsigned long)(addr)))
155 #define writeb(b,addr) __raw_writeb(b,(unsigned long)(addr))
156 #define writew(b,addr) __raw_writew(cpu_to_le16(b),(unsigned long)(addr))
157 #define writel(b,addr) __raw_writel(cpu_to_le32(b),(unsigned long)(addr))
158 #define writeq(b,addr) __raw_writeq(cpu_to_le64(b),(unsigned long)(addr))
159 #endif /* !USE_HPPA_IOREMAP */
161 extern void memcpy_fromio(void *dest, unsigned long src, int count);
162 extern void memcpy_toio(unsigned long dest, const void *src, int count);
163 extern void memset_io(unsigned long dest, char fill, int count);
165 /* Support old drivers which don't ioremap.
166 * NB this interface is scheduled to disappear in 2.5
169 #define EISA_BASE 0xfffffffffc000000UL
170 #define isa_readb(a) readb(EISA_BASE | (a))
171 #define isa_readw(a) readw(EISA_BASE | (a))
172 #define isa_readl(a) readl(EISA_BASE | (a))
173 #define isa_writeb(b,a) writeb((b), EISA_BASE | (a))
174 #define isa_writew(b,a) writew((b), EISA_BASE | (a))
175 #define isa_writel(b,a) writel((b), EISA_BASE | (a))
176 #define isa_memset_io(a,b,c) memset_io(EISA_BASE | (a), (b), (c))
177 #define isa_memcpy_fromio(a,b,c) memcpy_fromio((a), EISA_BASE | (b), (c))
178 #define isa_memcpy_toio(a,b,c) memcpy_toio(EISA_BASE | (a), (b), (c))
181 * XXX - We don't have csum_partial_copy_fromio() yet, so we cheat here and
182 * just copy it. The net code will then do the checksum later. Presently
183 * only used by some shared memory 8390 Ethernet cards anyway.
186 #define eth_io_copy_and_sum(skb,src,len,unused) \
187 memcpy_fromio((skb)->data,(src),(len))
188 #define isa_eth_io_copy_and_sum(skb,src,len,unused) \
189 isa_memcpy_fromio((skb)->data,(src),(len))
200 extern unsigned char eisa_in8(unsigned short port);
201 extern unsigned short eisa_in16(unsigned short port);
202 extern unsigned int eisa_in32(unsigned short port);
203 extern void eisa_out8(unsigned char data, unsigned short port);
204 extern void eisa_out16(unsigned short data, unsigned short port);
205 extern void eisa_out32(unsigned int data, unsigned short port);
207 #if defined(CONFIG_PCI)
208 extern unsigned char inb(int addr);
209 extern unsigned short inw(int addr);
210 extern unsigned int inl(int addr);
212 extern void outb(unsigned char b, int addr);
213 extern void outw(unsigned short b, int addr);
214 extern void outl(unsigned int b, int addr);
215 #elif defined(CONFIG_EISA)
217 #define inw eisa_in16
218 #define inl eisa_in32
219 #define outb eisa_out8
220 #define outw eisa_out16
221 #define outl eisa_out32
223 static inline char inb(unsigned long addr)
229 static inline short inw(unsigned long addr)
235 static inline int inl(unsigned long addr)
241 #define outb(x, y) BUG()
242 #define outw(x, y) BUG()
243 #define outl(x, y) BUG()
247 * String versions of in/out ops:
249 extern void insb (unsigned long port, void *dst, unsigned long count);
250 extern void insw (unsigned long port, void *dst, unsigned long count);
251 extern void insl (unsigned long port, void *dst, unsigned long count);
252 extern void outsb (unsigned long port, const void *src, unsigned long count);
253 extern void outsw (unsigned long port, const void *src, unsigned long count);
254 extern void outsl (unsigned long port, const void *src, unsigned long count);
257 /* IO Port space is : BBiiii where BB is HBA number. */
258 #define IO_SPACE_LIMIT 0x00ffffff
261 #define dma_cache_inv(_start,_size) do { flush_kernel_dcache_range(_start,_size); } while(0)
262 #define dma_cache_wback(_start,_size) do { flush_kernel_dcache_range(_start,_size); } while (0)
263 #define dma_cache_wback_inv(_start,_size) do { flush_kernel_dcache_range(_start,_size); } while (0)