4 #include <linux/config.h>
5 #include <linux/types.h>
6 #include <asm/pgtable.h>
8 extern unsigned long parisc_vmerge_boundary;
9 extern unsigned long parisc_vmerge_max_size;
11 #define BIO_VMERGE_BOUNDARY parisc_vmerge_boundary
12 #define BIO_VMERGE_MAX_SIZE parisc_vmerge_max_size
14 #define virt_to_phys(a) ((unsigned long)__pa(a))
15 #define phys_to_virt(a) __va(a)
16 #define virt_to_bus virt_to_phys
17 #define bus_to_virt phys_to_virt
22 * readX()/writeX() do byteswapping and take an ioremapped address
23 * __raw_readX()/__raw_writeX() don't byteswap and take an ioremapped address.
24 * gsc_*() don't byteswap and operate on physical addresses;
25 * eg dev->hpa or 0xfee00000.
28 #ifdef CONFIG_DEBUG_IOREMAP
30 #define NYBBLE_SHIFT 60
32 #define NYBBLE_SHIFT 28
34 extern void gsc_bad_addr(unsigned long addr);
35 extern void __raw_bad_addr(const volatile void __iomem *addr);
36 #define gsc_check_addr(addr) \
37 if ((addr >> NYBBLE_SHIFT) != 0xf) { \
39 addr |= 0xfUL << NYBBLE_SHIFT; \
41 #define __raw_check_addr(addr) \
42 if (((unsigned long)addr >> NYBBLE_SHIFT) != 0xe) \
43 __raw_bad_addr(addr); \
44 addr = (void __iomem *)((unsigned long)addr | (0xfUL << NYBBLE_SHIFT));
46 #define gsc_check_addr(addr)
47 #define __raw_check_addr(addr)
50 static inline unsigned char gsc_readb(unsigned long addr)
61 : "=&r" (flags), "=r" (ret) : "r" (addr) );
66 static inline unsigned short gsc_readw(unsigned long addr)
77 : "=&r" (flags), "=r" (ret) : "r" (addr) );
82 static inline unsigned int gsc_readl(unsigned long addr)
90 : "=r" (ret) : "r" (addr) );
95 static inline unsigned long long gsc_readq(unsigned long addr)
97 unsigned long long ret;
101 __asm__ __volatile__(
103 : "=r" (ret) : "r" (addr) );
105 /* two reads may have side effects.. */
106 ret = ((u64) gsc_readl(addr)) << 32;
107 ret |= gsc_readl(addr+4);
112 static inline void gsc_writeb(unsigned char val, unsigned long addr)
115 gsc_check_addr(addr);
117 __asm__ __volatile__(
121 : "=&r" (flags) : "r" (val), "r" (addr) );
124 static inline void gsc_writew(unsigned short val, unsigned long addr)
127 gsc_check_addr(addr);
129 __asm__ __volatile__(
133 : "=&r" (flags) : "r" (val), "r" (addr) );
136 static inline void gsc_writel(unsigned int val, unsigned long addr)
138 gsc_check_addr(addr);
140 __asm__ __volatile__(
142 : : "r" (val), "r" (addr) );
145 static inline void gsc_writeq(unsigned long long val, unsigned long addr)
147 gsc_check_addr(addr);
150 __asm__ __volatile__(
152 : : "r" (val), "r" (addr) );
154 /* two writes may have side effects.. */
155 gsc_writel(val >> 32, addr);
156 gsc_writel(val, addr+4);
161 * The standard PCI ioremap interfaces
164 extern void __iomem * __ioremap(unsigned long offset, unsigned long size, unsigned long flags);
166 extern inline void __iomem * ioremap(unsigned long offset, unsigned long size)
168 return __ioremap(offset, size, 0);
172 * This one maps high address device memory and turns off caching for that area.
173 * it's useful if some control registers are in such an area and write combining
174 * or read caching is not desirable:
176 extern inline void * ioremap_nocache(unsigned long offset, unsigned long size)
178 return __ioremap(offset, size, _PAGE_NO_CACHE /* _PAGE_PCD */);
181 extern void iounmap(void __iomem *addr);
184 * USE_HPPA_IOREMAP is the magic flag to enable or disable real ioremap()
185 * functionality. It's currently disabled because it may not work on some
188 #define USE_HPPA_IOREMAP 0
191 static inline unsigned char __raw_readb(const volatile void __iomem *addr)
193 return (*(volatile unsigned char __force *) (addr));
195 static inline unsigned short __raw_readw(const volatile void __iomem *addr)
197 return *(volatile unsigned short __force *) addr;
199 static inline unsigned int __raw_readl(const volatile void __iomem *addr)
201 return *(volatile unsigned int __force *) addr;
203 static inline unsigned long long __raw_readq(const volatile void __iomem *addr)
205 return *(volatile unsigned long long __force *) addr;
208 static inline void __raw_writeb(unsigned char b, volatile void __iomem *addr)
210 *(volatile unsigned char __force *) addr = b;
212 static inline void __raw_writew(unsigned short b, volatile void __iomem *addr)
214 *(volatile unsigned short __force *) addr = b;
216 static inline void __raw_writel(unsigned int b, volatile void __iomem *addr)
218 *(volatile unsigned int __force *) addr = b;
220 static inline void __raw_writeq(unsigned long long b, volatile void __iomem *addr)
222 *(volatile unsigned long long __force *) addr = b;
224 #else /* !USE_HPPA_IOREMAP */
225 static inline unsigned char __raw_readb(const volatile void __iomem *addr)
227 __raw_check_addr(addr);
229 return gsc_readb((unsigned long) addr);
231 static inline unsigned short __raw_readw(const volatile void __iomem *addr)
233 __raw_check_addr(addr);
235 return gsc_readw((unsigned long) addr);
237 static inline unsigned int __raw_readl(const volatile void __iomem *addr)
239 __raw_check_addr(addr);
241 return gsc_readl((unsigned long) addr);
243 static inline unsigned long long __raw_readq(const volatile void __iomem *addr)
245 __raw_check_addr(addr);
247 return gsc_readq((unsigned long) addr);
250 static inline void __raw_writeb(unsigned char b, volatile void __iomem *addr)
252 __raw_check_addr(addr);
254 gsc_writeb(b, (unsigned long) addr);
256 static inline void __raw_writew(unsigned short b, volatile void __iomem *addr)
258 __raw_check_addr(addr);
260 gsc_writew(b, (unsigned long) addr);
262 static inline void __raw_writel(unsigned int b, volatile void __iomem *addr)
264 __raw_check_addr(addr);
266 gsc_writel(b, (unsigned long) addr);
268 static inline void __raw_writeq(unsigned long long b, volatile void __iomem *addr)
270 __raw_check_addr(addr);
272 gsc_writeq(b, (unsigned long) addr);
274 #endif /* !USE_HPPA_IOREMAP */
276 /* readb can never be const, so use __fswab instead of le*_to_cpu */
277 #define readb(addr) __raw_readb(addr)
278 #define readw(addr) __fswab16(__raw_readw(addr))
279 #define readl(addr) __fswab32(__raw_readl(addr))
280 #define readq(addr) __fswab64(__raw_readq(addr))
281 #define writeb(b, addr) __raw_writeb(b, addr)
282 #define writew(b, addr) __raw_writew(cpu_to_le16(b), addr)
283 #define writel(b, addr) __raw_writel(cpu_to_le32(b), addr)
284 #define writeq(b, addr) __raw_writeq(cpu_to_le64(b), addr)
286 #define readb_relaxed(addr) readb(addr)
287 #define readw_relaxed(addr) readw(addr)
288 #define readl_relaxed(addr) readl(addr)
289 #define readq_relaxed(addr) readq(addr)
291 #define mmiowb() do { } while (0)
293 void memset_io(volatile void __iomem *addr, unsigned char val, int count);
294 void memcpy_fromio(void *dst, const volatile void __iomem *src, int count);
295 void memcpy_toio(volatile void __iomem *dst, const void *src, int count);
298 * XXX - We don't have csum_partial_copy_fromio() yet, so we cheat here and
299 * just copy it. The net code will then do the checksum later. Presently
300 * only used by some shared memory 8390 Ethernet cards anyway.
303 #define eth_io_copy_and_sum(skb,src,len,unused) \
304 memcpy_fromio((skb)->data,(src),(len))
315 extern unsigned char eisa_in8(unsigned short port);
316 extern unsigned short eisa_in16(unsigned short port);
317 extern unsigned int eisa_in32(unsigned short port);
318 extern void eisa_out8(unsigned char data, unsigned short port);
319 extern void eisa_out16(unsigned short data, unsigned short port);
320 extern void eisa_out32(unsigned int data, unsigned short port);
322 #if defined(CONFIG_PCI)
323 extern unsigned char inb(int addr);
324 extern unsigned short inw(int addr);
325 extern unsigned int inl(int addr);
327 extern void outb(unsigned char b, int addr);
328 extern void outw(unsigned short b, int addr);
329 extern void outl(unsigned int b, int addr);
330 #elif defined(CONFIG_EISA)
332 #define inw eisa_in16
333 #define inl eisa_in32
334 #define outb eisa_out8
335 #define outw eisa_out16
336 #define outl eisa_out32
338 static inline char inb(unsigned long addr)
344 static inline short inw(unsigned long addr)
350 static inline int inl(unsigned long addr)
356 #define outb(x, y) BUG()
357 #define outw(x, y) BUG()
358 #define outl(x, y) BUG()
362 * String versions of in/out ops:
364 extern void insb (unsigned long port, void *dst, unsigned long count);
365 extern void insw (unsigned long port, void *dst, unsigned long count);
366 extern void insl (unsigned long port, void *dst, unsigned long count);
367 extern void outsb (unsigned long port, const void *src, unsigned long count);
368 extern void outsw (unsigned long port, const void *src, unsigned long count);
369 extern void outsl (unsigned long port, const void *src, unsigned long count);
372 /* IO Port space is : BBiiii where BB is HBA number. */
373 #define IO_SPACE_LIMIT 0x00ffffff
376 #define dma_cache_inv(_start,_size) do { flush_kernel_dcache_range(_start,_size); } while (0)
377 #define dma_cache_wback(_start,_size) do { flush_kernel_dcache_range(_start,_size); } while (0)
378 #define dma_cache_wback_inv(_start,_size) do { flush_kernel_dcache_range(_start,_size); } while (0)
380 /* PA machines have an MM I/O space from 0xf0000000-0xffffffff in 32
381 * bit mode and from 0xfffffffff0000000-0xfffffffffffffff in 64 bit
382 * mode (essentially just sign extending. This macro takes in a 32
383 * bit I/O address (still with the leading f) and outputs the correct
384 * value for either 32 or 64 bit mode */
385 #define F_EXTEND(x) ((unsigned long)((x) | (0xffffffff00000000ULL)))
387 #include <asm-generic/iomap.h>
390 * Convert a physical pointer to a virtual kernel pointer for /dev/mem
393 #define xlate_dev_mem_ptr(p) __va(p)
396 * Convert a virtual cached pointer to an uncached pointer
398 #define xlate_dev_kmem_ptr(p) p