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 extern unsigned long parisc_vmerge_boundary;
17 extern unsigned long parisc_vmerge_max_size;
19 #define BIO_VMERGE_BOUNDARY parisc_vmerge_boundary
20 #define BIO_VMERGE_MAX_SIZE parisc_vmerge_max_size
22 #define virt_to_phys(a) ((unsigned long)__pa(a))
23 #define phys_to_virt(a) __va(a)
24 #define virt_to_bus virt_to_phys
25 #define bus_to_virt phys_to_virt
28 * Change "struct page" to physical address.
30 #define page_to_phys(page) ((page - mem_map) << PAGE_SHIFT)
32 /* Memory mapped IO */
34 extern void * __ioremap(unsigned long offset, unsigned long size, unsigned long flags);
36 extern inline void * ioremap(unsigned long offset, unsigned long size)
38 return __ioremap(offset, size, 0);
42 * This one maps high address device memory and turns off caching for that area.
43 * it's useful if some control registers are in such an area and write combining
44 * or read caching is not desirable:
46 extern inline void * ioremap_nocache(unsigned long offset, unsigned long size)
48 return __ioremap(offset, size, _PAGE_NO_CACHE /* _PAGE_PCD */);
51 extern void iounmap(void *addr);
54 * __raw_ variants have no defined meaning. on hppa, it means `i was
55 * too lazy to ioremap first'. kind of like isa_, except that there's
56 * no additional base address to add on.
58 #define __raw_readb(a) ___raw_readb((unsigned long)(a))
59 extern __inline__ unsigned char ___raw_readb(unsigned long addr)
68 : "=&r" (flags), "=r" (ret) : "r" (addr) );
73 #define __raw_readw(a) ___raw_readw((unsigned long)(a))
74 extern __inline__ unsigned short ___raw_readw(unsigned long addr)
83 : "=&r" (flags), "=r" (ret) : "r" (addr) );
88 #define __raw_readl(a) ___raw_readl((unsigned long)(a))
89 extern __inline__ unsigned int ___raw_readl(unsigned long addr)
95 : "=r" (ret) : "r" (addr) );
100 #define __raw_readq(a) ___raw_readq((unsigned long)(a))
101 extern __inline__ unsigned long long ___raw_readq(unsigned long addr)
103 unsigned long long ret;
105 __asm__ __volatile__(
107 : "=r" (ret) : "r" (addr) );
109 /* two reads may have side effects.. */
110 ret = ((u64) __raw_readl(addr)) << 32;
111 ret |= __raw_readl(addr+4);
116 #define __raw_writeb(a,b) ___raw_writeb(a, (unsigned long)(b))
117 extern __inline__ void ___raw_writeb(unsigned char val, unsigned long addr)
120 __asm__ __volatile__(
124 : "=&r" (flags) : "r" (val), "r" (addr) );
127 #define __raw_writew(a,b) ___raw_writew(a, (unsigned long)(b))
128 extern __inline__ void ___raw_writew(unsigned short val, unsigned long addr)
131 __asm__ __volatile__(
135 : "=&r" (flags) : "r" (val), "r" (addr) );
138 #define __raw_writel(a,b) ___raw_writel(a, (unsigned long)(b))
139 extern __inline__ void ___raw_writel(unsigned int val, unsigned long addr)
141 __asm__ __volatile__(
143 : : "r" (val), "r" (addr) );
146 #define __raw_writeq(a,b) ___raw_writeq(a, (unsigned long)(b))
147 extern __inline__ void ___raw_writeq(unsigned long long val, unsigned long addr)
150 __asm__ __volatile__(
152 : : "r" (val), "r" (addr) );
154 /* two writes may have side effects.. */
155 __raw_writel(val >> 32, addr);
156 __raw_writel(val, addr+4);
161 #define readb(addr) (*(volatile unsigned char *) (addr))
162 #define readw(addr) (*(volatile unsigned short *) (addr))
163 #define readl(addr) (*(volatile unsigned int *) (addr))
164 #define readq(addr) (*(volatile u64 *) (addr))
165 #define writeb(b,addr) (*(volatile unsigned char *) (addr) = (b))
166 #define writew(b,addr) (*(volatile unsigned short *) (addr) = (b))
167 #define writel(b,addr) (*(volatile unsigned int *) (addr) = (b))
168 #define writeq(b,addr) (*(volatile u64 *) (addr) = (b))
169 #else /* !USE_HPPA_IOREMAP */
170 #define readb(addr) __raw_readb(addr)
171 #define readw(addr) le16_to_cpu(__raw_readw(addr))
172 #define readl(addr) le32_to_cpu(__raw_readl(addr))
173 #define readq(addr) le64_to_cpu(__raw_readq(addr))
174 #define writeb(b,addr) __raw_writeb(b,addr)
175 #define writew(b,addr) __raw_writew(cpu_to_le16(b),addr)
176 #define writel(b,addr) __raw_writel(cpu_to_le32(b),addr)
177 #define writeq(b,addr) __raw_writeq(cpu_to_le64(b),addr)
178 #endif /* !USE_HPPA_IOREMAP */
180 #define readb_relaxed(addr) readb(addr)
181 #define readw_relaxed(addr) readw(addr)
182 #define readl_relaxed(addr) readl(addr)
183 #define readq_relaxed(addr) readq(addr)
185 extern void __memcpy_fromio(unsigned long dest, unsigned long src, int count);
186 extern void __memcpy_toio(unsigned long dest, unsigned long src, int count);
187 extern void __memset_io(unsigned long dest, char fill, int count);
189 #define memcpy_fromio(a,b,c) __memcpy_fromio((unsigned long)(a), (unsigned long)(b), (c))
190 #define memcpy_toio(a,b,c) __memcpy_toio((unsigned long)(a), (unsigned long)(b), (c))
191 #define memset_io(a,b,c) __memset_io((unsigned long)(a), (b), (c))
193 /* Support old drivers which don't ioremap.
194 * NB this interface is scheduled to disappear in 2.5
197 #define EISA_BASE 0xfffffffffc000000UL
198 #define isa_readb(a) readb(EISA_BASE | (a))
199 #define isa_readw(a) readw(EISA_BASE | (a))
200 #define isa_readl(a) readl(EISA_BASE | (a))
201 #define isa_writeb(b,a) writeb((b), EISA_BASE | (a))
202 #define isa_writew(b,a) writew((b), EISA_BASE | (a))
203 #define isa_writel(b,a) writel((b), EISA_BASE | (a))
204 #define isa_memset_io(a,b,c) memset_io(EISA_BASE | (a), (b), (c))
205 #define isa_memcpy_fromio(a,b,c) memcpy_fromio((a), EISA_BASE | (b), (c))
206 #define isa_memcpy_toio(a,b,c) memcpy_toio(EISA_BASE | (a), (b), (c))
209 * These functions support PA-RISC drivers which don't yet call ioremap().
210 * They will disappear once the last of these drivers is gone.
212 #define gsc_readb(x) __raw_readb(x)
213 #define gsc_readw(x) __raw_readw(x)
214 #define gsc_readl(x) __raw_readl(x)
215 #define gsc_writeb(x, y) __raw_writeb(x, y)
216 #define gsc_writew(x, y) __raw_writew(x, y)
217 #define gsc_writel(x, y) __raw_writel(x, y)
221 * XXX - We don't have csum_partial_copy_fromio() yet, so we cheat here and
222 * just copy it. The net code will then do the checksum later. Presently
223 * only used by some shared memory 8390 Ethernet cards anyway.
226 #define eth_io_copy_and_sum(skb,src,len,unused) \
227 memcpy_fromio((skb)->data,(src),(len))
228 #define isa_eth_io_copy_and_sum(skb,src,len,unused) \
229 isa_memcpy_fromio((skb)->data,(src),(len))
240 extern unsigned char eisa_in8(unsigned short port);
241 extern unsigned short eisa_in16(unsigned short port);
242 extern unsigned int eisa_in32(unsigned short port);
243 extern void eisa_out8(unsigned char data, unsigned short port);
244 extern void eisa_out16(unsigned short data, unsigned short port);
245 extern void eisa_out32(unsigned int data, unsigned short port);
247 #if defined(CONFIG_PCI)
248 extern unsigned char inb(int addr);
249 extern unsigned short inw(int addr);
250 extern unsigned int inl(int addr);
252 extern void outb(unsigned char b, int addr);
253 extern void outw(unsigned short b, int addr);
254 extern void outl(unsigned int b, int addr);
255 #elif defined(CONFIG_EISA)
257 #define inw eisa_in16
258 #define inl eisa_in32
259 #define outb eisa_out8
260 #define outw eisa_out16
261 #define outl eisa_out32
263 static inline char inb(unsigned long addr)
269 static inline short inw(unsigned long addr)
275 static inline int inl(unsigned long addr)
281 #define outb(x, y) BUG()
282 #define outw(x, y) BUG()
283 #define outl(x, y) BUG()
287 * String versions of in/out ops:
289 extern void insb (unsigned long port, void *dst, unsigned long count);
290 extern void insw (unsigned long port, void *dst, unsigned long count);
291 extern void insl (unsigned long port, void *dst, unsigned long count);
292 extern void outsb (unsigned long port, const void *src, unsigned long count);
293 extern void outsw (unsigned long port, const void *src, unsigned long count);
294 extern void outsl (unsigned long port, const void *src, unsigned long count);
297 /* IO Port space is : BBiiii where BB is HBA number. */
298 #define IO_SPACE_LIMIT 0x00ffffff
301 #define dma_cache_inv(_start,_size) do { flush_kernel_dcache_range(_start,_size); } while (0)
302 #define dma_cache_wback(_start,_size) do { flush_kernel_dcache_range(_start,_size); } while (0)
303 #define dma_cache_wback_inv(_start,_size) do { flush_kernel_dcache_range(_start,_size); } while (0)
305 /* PA machines have an MM I/O space from 0xf0000000-0xffffffff in 32
306 * bit mode and from 0xfffffffff0000000-0xfffffffffffffff in 64 bit
307 * mode (essentially just sign extending. This macro takes in a 32
308 * bit I/O address (still with the leading f) and outputs the correct
309 * value for either 32 or 64 bit mode */
310 #define F_EXTEND(x) ((unsigned long)((x) | (0xffffffff00000000ULL)))