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
27 /* Memory mapped IO */
29 extern void * __ioremap(unsigned long offset, unsigned long size, unsigned long flags);
31 extern inline void * ioremap(unsigned long offset, unsigned long size)
33 return __ioremap(offset, size, 0);
37 * This one maps high address device memory and turns off caching for that area.
38 * it's useful if some control registers are in such an area and write combining
39 * or read caching is not desirable:
41 extern inline void * ioremap_nocache(unsigned long offset, unsigned long size)
43 return __ioremap(offset, size, _PAGE_NO_CACHE /* _PAGE_PCD */);
46 extern void iounmap(void *addr);
49 * __raw_ variants have no defined meaning. on hppa, it means `i was
50 * too lazy to ioremap first'. kind of like isa_, except that there's
51 * no additional base address to add on.
53 #define __raw_readb(a) ___raw_readb((unsigned long)(a))
54 extern __inline__ unsigned char ___raw_readb(unsigned long addr)
63 : "=&r" (flags), "=r" (ret) : "r" (addr) );
68 #define __raw_readw(a) ___raw_readw((unsigned long)(a))
69 extern __inline__ unsigned short ___raw_readw(unsigned long addr)
78 : "=&r" (flags), "=r" (ret) : "r" (addr) );
83 #define __raw_readl(a) ___raw_readl((unsigned long)(a))
84 extern __inline__ unsigned int ___raw_readl(unsigned long addr)
90 : "=r" (ret) : "r" (addr) );
95 #define __raw_readq(a) ___raw_readq((unsigned long)(a))
96 extern __inline__ unsigned long long ___raw_readq(unsigned long addr)
98 unsigned long long ret;
100 __asm__ __volatile__(
102 : "=r" (ret) : "r" (addr) );
104 /* two reads may have side effects.. */
105 ret = ((u64) __raw_readl(addr)) << 32;
106 ret |= __raw_readl(addr+4);
111 #define __raw_writeb(a,b) ___raw_writeb(a, (unsigned long)(b))
112 extern __inline__ void ___raw_writeb(unsigned char val, unsigned long addr)
115 __asm__ __volatile__(
119 : "=&r" (flags) : "r" (val), "r" (addr) );
122 #define __raw_writew(a,b) ___raw_writew(a, (unsigned long)(b))
123 extern __inline__ void ___raw_writew(unsigned short val, unsigned long addr)
126 __asm__ __volatile__(
130 : "=&r" (flags) : "r" (val), "r" (addr) );
133 #define __raw_writel(a,b) ___raw_writel(a, (unsigned long)(b))
134 extern __inline__ void ___raw_writel(unsigned int val, unsigned long addr)
136 __asm__ __volatile__(
138 : : "r" (val), "r" (addr) );
141 #define __raw_writeq(a,b) ___raw_writeq(a, (unsigned long)(b))
142 extern __inline__ void ___raw_writeq(unsigned long long val, unsigned long addr)
145 __asm__ __volatile__(
147 : : "r" (val), "r" (addr) );
149 /* two writes may have side effects.. */
150 __raw_writel(val >> 32, addr);
151 __raw_writel(val, addr+4);
156 #define readb(addr) (*(volatile unsigned char *) (addr))
157 #define readw(addr) (*(volatile unsigned short *) (addr))
158 #define readl(addr) (*(volatile unsigned int *) (addr))
159 #define readq(addr) (*(volatile u64 *) (addr))
160 #define writeb(b,addr) (*(volatile unsigned char *) (addr) = (b))
161 #define writew(b,addr) (*(volatile unsigned short *) (addr) = (b))
162 #define writel(b,addr) (*(volatile unsigned int *) (addr) = (b))
163 #define writeq(b,addr) (*(volatile u64 *) (addr) = (b))
164 #else /* !USE_HPPA_IOREMAP */
165 #define readb(addr) __raw_readb(addr)
166 #define readw(addr) le16_to_cpu(__raw_readw(addr))
167 #define readl(addr) le32_to_cpu(__raw_readl(addr))
168 #define readq(addr) le64_to_cpu(__raw_readq(addr))
169 #define writeb(b,addr) __raw_writeb(b,addr)
170 #define writew(b,addr) __raw_writew(cpu_to_le16(b),addr)
171 #define writel(b,addr) __raw_writel(cpu_to_le32(b),addr)
172 #define writeq(b,addr) __raw_writeq(cpu_to_le64(b),addr)
173 #endif /* !USE_HPPA_IOREMAP */
175 #define readb_relaxed(addr) readb(addr)
176 #define readw_relaxed(addr) readw(addr)
177 #define readl_relaxed(addr) readl(addr)
178 #define readq_relaxed(addr) readq(addr)
182 extern void __memcpy_fromio(unsigned long dest, unsigned long src, int count);
183 extern void __memcpy_toio(unsigned long dest, unsigned long src, int count);
184 extern void __memset_io(unsigned long dest, char fill, int count);
186 #define memcpy_fromio(a,b,c) __memcpy_fromio((unsigned long)(a), (unsigned long)(b), (c))
187 #define memcpy_toio(a,b,c) __memcpy_toio((unsigned long)(a), (unsigned long)(b), (c))
188 #define memset_io(a,b,c) __memset_io((unsigned long)(a), (b), (c))
190 /* Support old drivers which don't ioremap.
191 * NB this interface is scheduled to disappear in 2.5
194 #define EISA_BASE 0xfffffffffc000000UL
195 #define isa_readb(a) readb(EISA_BASE | (a))
196 #define isa_readw(a) readw(EISA_BASE | (a))
197 #define isa_readl(a) readl(EISA_BASE | (a))
198 #define isa_writeb(b,a) writeb((b), EISA_BASE | (a))
199 #define isa_writew(b,a) writew((b), EISA_BASE | (a))
200 #define isa_writel(b,a) writel((b), EISA_BASE | (a))
201 #define isa_memset_io(a,b,c) memset_io(EISA_BASE | (a), (b), (c))
202 #define isa_memcpy_fromio(a,b,c) memcpy_fromio((a), EISA_BASE | (b), (c))
203 #define isa_memcpy_toio(a,b,c) memcpy_toio(EISA_BASE | (a), (b), (c))
206 * These functions support PA-RISC drivers which don't yet call ioremap().
207 * They will disappear once the last of these drivers is gone.
209 #define gsc_readb(x) __raw_readb(x)
210 #define gsc_readw(x) __raw_readw(x)
211 #define gsc_readl(x) __raw_readl(x)
212 #define gsc_writeb(x, y) __raw_writeb(x, y)
213 #define gsc_writew(x, y) __raw_writew(x, y)
214 #define gsc_writel(x, y) __raw_writel(x, y)
218 * XXX - We don't have csum_partial_copy_fromio() yet, so we cheat here and
219 * just copy it. The net code will then do the checksum later. Presently
220 * only used by some shared memory 8390 Ethernet cards anyway.
223 #define eth_io_copy_and_sum(skb,src,len,unused) \
224 memcpy_fromio((skb)->data,(src),(len))
225 #define isa_eth_io_copy_and_sum(skb,src,len,unused) \
226 isa_memcpy_fromio((skb)->data,(src),(len))
237 extern unsigned char eisa_in8(unsigned short port);
238 extern unsigned short eisa_in16(unsigned short port);
239 extern unsigned int eisa_in32(unsigned short port);
240 extern void eisa_out8(unsigned char data, unsigned short port);
241 extern void eisa_out16(unsigned short data, unsigned short port);
242 extern void eisa_out32(unsigned int data, unsigned short port);
244 #if defined(CONFIG_PCI)
245 extern unsigned char inb(int addr);
246 extern unsigned short inw(int addr);
247 extern unsigned int inl(int addr);
249 extern void outb(unsigned char b, int addr);
250 extern void outw(unsigned short b, int addr);
251 extern void outl(unsigned int b, int addr);
252 #elif defined(CONFIG_EISA)
254 #define inw eisa_in16
255 #define inl eisa_in32
256 #define outb eisa_out8
257 #define outw eisa_out16
258 #define outl eisa_out32
260 static inline char inb(unsigned long addr)
266 static inline short inw(unsigned long addr)
272 static inline int inl(unsigned long addr)
278 #define outb(x, y) BUG()
279 #define outw(x, y) BUG()
280 #define outl(x, y) BUG()
284 * String versions of in/out ops:
286 extern void insb (unsigned long port, void *dst, unsigned long count);
287 extern void insw (unsigned long port, void *dst, unsigned long count);
288 extern void insl (unsigned long port, void *dst, unsigned long count);
289 extern void outsb (unsigned long port, const void *src, unsigned long count);
290 extern void outsw (unsigned long port, const void *src, unsigned long count);
291 extern void outsl (unsigned long port, const void *src, unsigned long count);
294 /* IO Port space is : BBiiii where BB is HBA number. */
295 #define IO_SPACE_LIMIT 0x00ffffff
298 #define dma_cache_inv(_start,_size) do { flush_kernel_dcache_range(_start,_size); } while (0)
299 #define dma_cache_wback(_start,_size) do { flush_kernel_dcache_range(_start,_size); } while (0)
300 #define dma_cache_wback_inv(_start,_size) do { flush_kernel_dcache_range(_start,_size); } while (0)
302 /* PA machines have an MM I/O space from 0xf0000000-0xffffffff in 32
303 * bit mode and from 0xfffffffff0000000-0xfffffffffffffff in 64 bit
304 * mode (essentially just sign extending. This macro takes in a 32
305 * bit I/O address (still with the leading f) and outputs the correct
306 * value for either 32 or 64 bit mode */
307 #define F_EXTEND(x) ((unsigned long)((x) | (0xffffffff00000000ULL)))