4 #include <linux/config.h>
5 #include <linux/kernel.h>
6 #include <asm/system.h>
8 /* We don't use IO slowdowns on the Alpha, but.. */
9 #define __SLOW_DOWN_IO do { } while (0)
10 #define SLOW_DOWN_IO do { } while (0)
13 * Virtual -> physical identity mapping starts at this offset
15 #ifdef USE_48_BIT_KSEG
16 #define IDENT_ADDR 0xffff800000000000
18 #define IDENT_ADDR 0xfffffc0000000000
22 #include <asm/machvec.h>
25 * We try to avoid hae updates (thus the cache), but when we
26 * do need to update the hae, we need to do it atomically, so
27 * that any interrupts wouldn't get confused with the hae
28 * register not being up-to-date with respect to the hardware
31 static inline void __set_hae(unsigned long new_hae
)
34 __save_and_cli(flags
);
36 alpha_mv
.hae_cache
= new_hae
;
37 *alpha_mv
.hae_register
= new_hae
;
39 /* Re-read to make sure it was written. */
40 new_hae
= *alpha_mv
.hae_register
;
42 __restore_flags(flags
);
45 static inline void set_hae(unsigned long new_hae
)
47 if (new_hae
!= alpha_mv
.hae_cache
)
52 * Change virtual addresses to physical addresses and vv.
54 static inline unsigned long virt_to_phys(volatile void * address
)
56 /* Conditionalize this on the CPU? This here is 40 bits,
57 whereas EV4 only supports 34. But KSEG is farther out
58 so it shouldn't _really_ matter. */
59 return 0xffffffffffUL
& (unsigned long) address
;
62 static inline void * phys_to_virt(unsigned long address
)
64 return (void *) (address
+ IDENT_ADDR
);
67 #else /* !__KERNEL__ */
70 * Define actual functions in private name-space so it's easier to
71 * accommodate things like XFree or svgalib that like to define their
72 * own versions of inb etc.
74 extern void __sethae (unsigned long addr
); /* syscall */
75 extern void _sethae (unsigned long addr
); /* cached version */
77 #endif /* !__KERNEL__ */
80 * There are different chipsets to interface the Alpha CPUs to the world.
84 #ifdef CONFIG_ALPHA_GENERIC
86 /* In a generic kernel, we always go through the machine vector. */
88 # define virt_to_bus(a) alpha_mv.mv_virt_to_bus(a)
89 # define bus_to_virt(a) alpha_mv.mv_bus_to_virt(a)
91 # define __inb alpha_mv.mv_inb
92 # define __inw alpha_mv.mv_inw
93 # define __inl alpha_mv.mv_inl
94 # define __outb alpha_mv.mv_outb
95 # define __outw alpha_mv.mv_outw
96 # define __outl alpha_mv.mv_outl
98 # define __readb(a) alpha_mv.mv_readb((unsigned long)(a))
99 # define __readw(a) alpha_mv.mv_readw((unsigned long)(a))
100 # define __readl(a) alpha_mv.mv_readl((unsigned long)(a))
101 # define __readq(a) alpha_mv.mv_readq((unsigned long)(a))
102 # define __writeb(v,a) alpha_mv.mv_writeb((v),(unsigned long)(a))
103 # define __writew(v,a) alpha_mv.mv_writew((v),(unsigned long)(a))
104 # define __writel(v,a) alpha_mv.mv_writel((v),(unsigned long)(a))
105 # define __writeq(v,a) alpha_mv.mv_writeq((v),(unsigned long)(a))
107 # define __ioremap(a) alpha_mv.mv_ioremap(a)
108 # define __is_ioaddr(a) alpha_mv.mv_is_ioaddr(a)
117 # define __raw_readb __readb
118 # define __raw_readw __readw
119 # define __raw_readl __readl
120 # define __raw_readq __readq
121 # define __raw_writeb __writeb
122 # define __raw_writew __writew
123 # define __raw_writel __writel
124 # define __raw_writeq __writeq
128 /* Control how and what gets defined within the core logic headers. */
129 #define __WANT_IO_DEF
131 #if defined(CONFIG_ALPHA_APECS)
132 # include <asm/core_apecs.h>
133 #elif defined(CONFIG_ALPHA_CIA)
134 # include <asm/core_cia.h>
135 #elif defined(CONFIG_ALPHA_LCA)
136 # include <asm/core_lca.h>
137 #elif defined(CONFIG_ALPHA_MCPCIA)
138 # include <asm/core_mcpcia.h>
139 #elif defined(CONFIG_ALPHA_PYXIS)
140 # include <asm/core_pyxis.h>
141 #elif defined(CONFIG_ALPHA_T2)
142 # include <asm/core_t2.h>
143 #elif defined(CONFIG_ALPHA_TSUNAMI)
144 # include <asm/core_tsunami.h>
145 #elif defined(CONFIG_ALPHA_JENSEN)
146 # include <asm/jensen.h>
147 #elif defined(CONFIG_ALPHA_POLARIS)
148 # include <asm/core_polaris.h>
150 #error "What system is this?"
156 #endif /* __KERNEL__ */
159 * The convention used for inb/outb etc. is that names starting with
160 * two underscores are the inline versions, names starting with a
161 * single underscore are proper functions, and names starting with a
162 * letter are macros that map in some way to inline or proper function
163 * versions. Not all that pretty, but before you change it, be sure
164 * to convince yourself that it won't break anything (in particular
167 extern unsigned int _inb (unsigned long port
);
168 extern unsigned int _inw (unsigned long port
);
169 extern unsigned int _inl (unsigned long port
);
170 extern void _outb (unsigned char b
,unsigned long port
);
171 extern void _outw (unsigned short w
,unsigned long port
);
172 extern void _outl (unsigned int l
,unsigned long port
);
173 extern unsigned long _readb(unsigned long addr
);
174 extern unsigned long _readw(unsigned long addr
);
175 extern unsigned long _readl(unsigned long addr
);
176 extern unsigned long _readq(unsigned long addr
);
177 extern void _writeb(unsigned char b
, unsigned long addr
);
178 extern void _writew(unsigned short b
, unsigned long addr
);
179 extern void _writel(unsigned int b
, unsigned long addr
);
180 extern void _writeq(unsigned long b
, unsigned long addr
);
184 * The platform header files may define some of these macros to use
185 * the inlined versions where appropriate. These macros may also be
186 * redefined by userlevel programs.
189 # define inb(p) _inb((p))
192 # define inw(p) _inw((p))
195 # define inl(p) _inl((p))
198 # define outb(b,p) _outb((b),(p))
201 # define outw(w,p) _outw((w),(p))
204 # define outl(l,p) _outl((l),(p))
229 /* Userspace declarations. */
231 extern unsigned int inb (unsigned long port
);
232 extern unsigned int inw (unsigned long port
);
233 extern unsigned int inl (unsigned long port
);
234 extern void outb (unsigned char b
,unsigned long port
);
235 extern void outw (unsigned short w
,unsigned long port
);
236 extern void outl (unsigned int l
,unsigned long port
);
237 extern unsigned long readb(unsigned long addr
);
238 extern unsigned long readw(unsigned long addr
);
239 extern unsigned long readl(unsigned long addr
);
240 extern void writeb(unsigned char b
, unsigned long addr
);
241 extern void writew(unsigned short b
, unsigned long addr
);
242 extern void writel(unsigned int b
, unsigned long addr
);
244 #endif /* __KERNEL__ */
249 * On Alpha, we have the whole of I/O space mapped at all times, but
250 * at odd and sometimes discontinuous addresses. Note that the
251 * discontinuities are all across busses, so we need not care for that
252 * for any one device.
254 * Map the I/O space address into the kernel's virtual address space.
256 static inline void * ioremap(unsigned long offset
, unsigned long size
)
258 return (void *) __ioremap(offset
);
261 static inline void iounmap(void *addr
)
265 /* Indirect back to the macros provided. */
267 extern unsigned long ___raw_readb(unsigned long addr
);
268 extern unsigned long ___raw_readw(unsigned long addr
);
269 extern unsigned long ___raw_readl(unsigned long addr
);
270 extern unsigned long ___raw_readq(unsigned long addr
);
271 extern void ___raw_writeb(unsigned char b
, unsigned long addr
);
272 extern void ___raw_writew(unsigned short b
, unsigned long addr
);
273 extern void ___raw_writel(unsigned int b
, unsigned long addr
);
274 extern void ___raw_writeq(unsigned long b
, unsigned long addr
);
277 # define readb(a) ({ unsigned long r_ = __raw_readb(a); mb(); r_; })
280 # define readw(a) ({ unsigned long r_ = __raw_readw(a); mb(); r_; })
283 # define readl(a) ({ unsigned long r_ = __raw_readl(a); mb(); r_; })
286 # define readq(a) ({ unsigned long r_ = __raw_readq(a); mb(); r_; })
290 # define writeb(v,a) ({ __raw_writeb((v),(a)); mb(); })
293 # define writew(v,a) ({ __raw_writew((v),(a)); mb(); })
296 # define writel(v,a) ({ __raw_writel((v),(a)); mb(); })
299 # define writeq(v,a) ({ __raw_writeq((v),(a)); mb(); })
303 # define __raw_readb(a) ___raw_readb((unsigned long)(a))
306 # define __raw_readw(a) ___raw_readw((unsigned long)(a))
309 # define __raw_readl(a) ___raw_readl((unsigned long)(a))
312 # define __raw_readq(a) ___raw_readq((unsigned long)(a))
316 # define __raw_writeb(v,a) ___raw_writeb((v),(unsigned long)(a))
319 # define __raw_writew(v,a) ___raw_writew((v),(unsigned long)(a))
322 # define __raw_writel(v,a) ___raw_writel((v),(unsigned long)(a))
325 # define __raw_writeq(v,a) ___raw_writeq((v),(unsigned long)(a))
329 # define readb(a) _readb((unsigned long)(a))
332 # define readw(a) _readw((unsigned long)(a))
335 # define readl(a) _readl((unsigned long)(a))
338 # define readq(a) _readq((unsigned long)(a))
342 # define writeb(v,a) _writeb((v),(unsigned long)(a))
345 # define writew(v,a) _writew((v),(unsigned long)(a))
348 # define writel(v,a) _writel((v),(unsigned long)(a))
351 # define writeq(v,a) _writeq((v),(unsigned long)(a))
355 * String version of IO memory access ops:
357 extern void _memcpy_fromio(void *, unsigned long, long);
358 extern void _memcpy_toio(unsigned long, const void *, long);
359 extern void _memset_c_io(unsigned long, unsigned long, long);
361 #define memcpy_fromio(to,from,len) \
362 _memcpy_fromio((to),(unsigned long)(from),(len))
363 #define memcpy_toio(to,from,len) \
364 _memcpy_toio((unsigned long)(to),(from),(len))
365 #define memset_io(addr,c,len) \
366 _memset_c_io((unsigned long)(addr),0x0101010101010101UL*(u8)(c),(len))
368 #define __HAVE_ARCH_MEMSETW_IO
369 #define memsetw_io(addr,c,len) \
370 _memset_c_io((unsigned long)(addr),0x0001000100010001UL*(u16)(c),(len))
373 * String versions of in/out ops:
375 extern void insb (unsigned long port
, void *dst
, unsigned long count
);
376 extern void insw (unsigned long port
, void *dst
, unsigned long count
);
377 extern void insl (unsigned long port
, void *dst
, unsigned long count
);
378 extern void outsb (unsigned long port
, const void *src
, unsigned long count
);
379 extern void outsw (unsigned long port
, const void *src
, unsigned long count
);
380 extern void outsl (unsigned long port
, const void *src
, unsigned long count
);
383 * XXX - We don't have csum_partial_copy_fromio() yet, so we cheat here and
384 * just copy it. The net code will then do the checksum later. Presently
385 * only used by some shared memory 8390 Ethernet cards anyway.
388 #define eth_io_copy_and_sum(skb,src,len,unused) \
389 memcpy_fromio((skb)->data,(src),(len))
392 check_signature(unsigned long io_addr
, const unsigned char *signature
,
397 if (readb(io_addr
) != *signature
)
409 * The Alpha Jensen hardware for some rather strange reason puts
410 * the RTC clock at 0x170 instead of 0x70. Probably due to some
411 * misguided idea about using 0x70 for NMI stuff.
413 * These defines will override the defaults when doing RTC queries
416 #ifdef CONFIG_ALPHA_GENERIC
417 # define RTC_PORT(x) ((x) + alpha_mv.rtc_port)
419 # ifdef CONFIG_ALPHA_JENSEN
420 # define RTC_PORT(x) (0x170+(x))
422 # define RTC_PORT(x) (0x70 + (x))
425 #define RTC_ALWAYS_BCD 0
429 #define dma_cache_inv(_start,_size) do { } while (0)
430 #define dma_cache_wback(_start,_size) do { } while (0)
431 #define dma_cache_wback_inv(_start,_size) do { } while (0)
433 #endif /* __KERNEL__ */
435 #endif /* __ALPHA_IO_H */