2 * linux/include/asm-m68k/io.h
4 * 4/1/00 RZ: - rewritten to avoid clashes between ISA/PCI and other
7 * - added skeleton for GG-II and Amiga PCMCIA
8 * 2/3/01 RZ: - moved a few more defs into raw_io.h
10 * inX/outX should not be used by any driver unless it does
11 * ISA access. Other drivers should use function defined in raw_io.h
12 * or define its own macros on top of these.
14 * inX(),outX() are for ISA I/O
15 * isa_readX(),isa_writeX() are for ISA memory
23 #include <linux/compiler.h>
24 #include <asm/raw_io.h>
25 #include <asm/virtconvert.h>
27 #include <asm-generic/iomap.h>
30 #include <asm/atarihw.h>
35 * IO/MEM definitions for various ISA bridges
41 #define q40_isa_io_base 0xff400000
42 #define q40_isa_mem_base 0xff800000
44 #define Q40_ISA_IO_B(ioaddr) (q40_isa_io_base+1+4*((unsigned long)(ioaddr)))
45 #define Q40_ISA_IO_W(ioaddr) (q40_isa_io_base+ 4*((unsigned long)(ioaddr)))
46 #define Q40_ISA_MEM_B(madr) (q40_isa_mem_base+1+4*((unsigned long)(madr)))
47 #define Q40_ISA_MEM_W(madr) (q40_isa_mem_base+ 4*((unsigned long)(madr)))
52 #ifdef CONFIG_AMIGA_PCMCIA
53 #include <asm/amigayle.h>
55 #define AG_ISA_IO_B(ioaddr) ( GAYLE_IO+(ioaddr)+(((ioaddr)&1)*GAYLE_ODD) )
56 #define AG_ISA_IO_W(ioaddr) ( GAYLE_IO+(ioaddr) )
64 #endif /* AMIGA_PCMCIA */
74 #define ISA_TYPE_Q40 (1)
75 #define ISA_TYPE_AG (2)
77 #if defined(CONFIG_Q40) && !defined(MULTI_ISA)
78 #define ISA_TYPE ISA_TYPE_Q40
81 #if defined(CONFIG_AMIGA_PCMCIA) && !defined(MULTI_ISA)
82 #define ISA_TYPE ISA_TYPE_AG
90 #define ISA_TYPE isa_type
91 #define ISA_SEX isa_sex
95 * define inline addr translation functions. Normally only one variant will
96 * be compiled in so the case statement will be optimised away
99 static inline u8 __iomem
*isa_itb(unsigned long addr
)
104 case ISA_TYPE_Q40
: return (u8 __iomem
*)Q40_ISA_IO_B(addr
);
106 #ifdef CONFIG_AMIGA_PCMCIA
107 case ISA_TYPE_AG
: return (u8 __iomem
*)AG_ISA_IO_B(addr
);
109 default: return NULL
; /* avoid warnings, just in case */
112 static inline u16 __iomem
*isa_itw(unsigned long addr
)
117 case ISA_TYPE_Q40
: return (u16 __iomem
*)Q40_ISA_IO_W(addr
);
119 #ifdef CONFIG_AMIGA_PCMCIA
120 case ISA_TYPE_AG
: return (u16 __iomem
*)AG_ISA_IO_W(addr
);
122 default: return NULL
; /* avoid warnings, just in case */
125 static inline u32 __iomem
*isa_itl(unsigned long addr
)
129 #ifdef CONFIG_AMIGA_PCMCIA
130 case ISA_TYPE_AG
: return (u32 __iomem
*)AG_ISA_IO_W(addr
);
132 default: return 0; /* avoid warnings, just in case */
135 static inline u8 __iomem
*isa_mtb(unsigned long addr
)
140 case ISA_TYPE_Q40
: return (u8 __iomem
*)Q40_ISA_MEM_B(addr
);
142 #ifdef CONFIG_AMIGA_PCMCIA
143 case ISA_TYPE_AG
: return (u8 __iomem
*)addr
;
145 default: return NULL
; /* avoid warnings, just in case */
148 static inline u16 __iomem
*isa_mtw(unsigned long addr
)
153 case ISA_TYPE_Q40
: return (u16 __iomem
*)Q40_ISA_MEM_W(addr
);
155 #ifdef CONFIG_AMIGA_PCMCIA
156 case ISA_TYPE_AG
: return (u16 __iomem
*)addr
;
158 default: return NULL
; /* avoid warnings, just in case */
163 #define isa_inb(port) in_8(isa_itb(port))
164 #define isa_inw(port) (ISA_SEX ? in_be16(isa_itw(port)) : in_le16(isa_itw(port)))
165 #define isa_inl(port) (ISA_SEX ? in_be32(isa_itl(port)) : in_le32(isa_itl(port)))
166 #define isa_outb(val,port) out_8(isa_itb(port),(val))
167 #define isa_outw(val,port) (ISA_SEX ? out_be16(isa_itw(port),(val)) : out_le16(isa_itw(port),(val)))
168 #define isa_outl(val,port) (ISA_SEX ? out_be32(isa_itl(port),(val)) : out_le32(isa_itl(port),(val)))
170 #define isa_readb(p) in_8(isa_mtb((unsigned long)(p)))
171 #define isa_readw(p) \
172 (ISA_SEX ? in_be16(isa_mtw((unsigned long)(p))) \
173 : in_le16(isa_mtw((unsigned long)(p))))
174 #define isa_writeb(val,p) out_8(isa_mtb((unsigned long)(p)),(val))
175 #define isa_writew(val,p) \
176 (ISA_SEX ? out_be16(isa_mtw((unsigned long)(p)),(val)) \
177 : out_le16(isa_mtw((unsigned long)(p)),(val)))
179 static inline void isa_delay(void)
184 case ISA_TYPE_Q40
: isa_outb(0,0x80); break;
186 #ifdef CONFIG_AMIGA_PCMCIA
187 case ISA_TYPE_AG
: break;
189 default: break; /* avoid warnings */
193 #define isa_inb_p(p) ({u8 v=isa_inb(p);isa_delay();v;})
194 #define isa_outb_p(v,p) ({isa_outb((v),(p));isa_delay();})
195 #define isa_inw_p(p) ({u16 v=isa_inw(p);isa_delay();v;})
196 #define isa_outw_p(v,p) ({isa_outw((v),(p));isa_delay();})
197 #define isa_inl_p(p) ({u32 v=isa_inl(p);isa_delay();v;})
198 #define isa_outl_p(v,p) ({isa_outl((v),(p));isa_delay();})
200 #define isa_insb(port, buf, nr) raw_insb(isa_itb(port), (u8 *)(buf), (nr))
201 #define isa_outsb(port, buf, nr) raw_outsb(isa_itb(port), (u8 *)(buf), (nr))
203 #define isa_insw(port, buf, nr) \
204 (ISA_SEX ? raw_insw(isa_itw(port), (u16 *)(buf), (nr)) : \
205 raw_insw_swapw(isa_itw(port), (u16 *)(buf), (nr)))
207 #define isa_outsw(port, buf, nr) \
208 (ISA_SEX ? raw_outsw(isa_itw(port), (u16 *)(buf), (nr)) : \
209 raw_outsw_swapw(isa_itw(port), (u16 *)(buf), (nr)))
211 #define isa_insl(port, buf, nr) \
212 (ISA_SEX ? raw_insl(isa_itl(port), (u32 *)(buf), (nr)) : \
213 raw_insw_swapw(isa_itw(port), (u16 *)(buf), (nr)<<1))
215 #define isa_outsl(port, buf, nr) \
216 (ISA_SEX ? raw_outsl(isa_itl(port), (u32 *)(buf), (nr)) : \
217 raw_outsw_swapw(isa_itw(port), (u16 *)(buf), (nr)<<1))
221 #define inb_p isa_inb_p
222 #define outb isa_outb
223 #define outb_p isa_outb_p
225 #define inw_p isa_inw_p
226 #define outw isa_outw
227 #define outw_p isa_outw_p
229 #define inl_p isa_inl_p
230 #define outl isa_outl
231 #define outl_p isa_outl_p
232 #define insb isa_insb
233 #define insw isa_insw
234 #define insl isa_insl
235 #define outsb isa_outsb
236 #define outsw isa_outsw
237 #define outsl isa_outsl
238 #define readb isa_readb
239 #define readw isa_readw
240 #define writeb isa_writeb
241 #define writew isa_writew
243 #else /* CONFIG_ISA */
246 * We need to define dummy functions for GENERIC_IOMAP support.
248 #define inb(port) 0xff
249 #define inb_p(port) 0xff
250 #define outb(val,port) ((void)0)
251 #define outb_p(val,port) ((void)0)
252 #define inw(port) 0xffff
253 #define inw_p(port) 0xffff
254 #define outw(val,port) ((void)0)
255 #define outw_p(val,port) ((void)0)
256 #define inl(port) 0xffffffffUL
257 #define inl_p(port) 0xffffffffUL
258 #define outl(val,port) ((void)0)
259 #define outl_p(val,port) ((void)0)
261 #define insb(port,buf,nr) ((void)0)
262 #define outsb(port,buf,nr) ((void)0)
263 #define insw(port,buf,nr) ((void)0)
264 #define outsw(port,buf,nr) ((void)0)
265 #define insl(port,buf,nr) ((void)0)
266 #define outsl(port,buf,nr) ((void)0)
269 * These should be valid on any ioremap()ed region
271 #define readb(addr) in_8(addr)
272 #define writeb(val,addr) out_8((addr),(val))
273 #define readw(addr) in_le16(addr)
274 #define writew(val,addr) out_le16((addr),(val))
276 #endif /* CONFIG_ISA */
278 #define readl(addr) in_le32(addr)
279 #define writel(val,addr) out_le32((addr),(val))
283 static inline void __iomem
*ioremap(unsigned long physaddr
, unsigned long size
)
285 return __ioremap(physaddr
, size
, IOMAP_NOCACHE_SER
);
287 static inline void __iomem
*ioremap_nocache(unsigned long physaddr
, unsigned long size
)
289 return __ioremap(physaddr
, size
, IOMAP_NOCACHE_SER
);
291 static inline void __iomem
*ioremap_writethrough(unsigned long physaddr
,
294 return __ioremap(physaddr
, size
, IOMAP_WRITETHROUGH
);
296 static inline void __iomem
*ioremap_fullcache(unsigned long physaddr
,
299 return __ioremap(physaddr
, size
, IOMAP_FULL_CACHING
);
302 static inline void memset_io(volatile void __iomem
*addr
, unsigned char val
, int count
)
304 __builtin_memset((void __force
*) addr
, val
, count
);
306 static inline void memcpy_fromio(void *dst
, const volatile void __iomem
*src
, int count
)
308 __builtin_memcpy(dst
, (void __force
*) src
, count
);
310 static inline void memcpy_toio(volatile void __iomem
*dst
, const void *src
, int count
)
312 __builtin_memcpy((void __force
*) dst
, src
, count
);
316 #define IO_SPACE_LIMIT 0xffff
318 #define IO_SPACE_LIMIT 0x0fffffff
321 #endif /* __KERNEL__ */
323 #define __ARCH_HAS_NO_PAGE_ZERO_MAPPED 1
326 * Convert a physical pointer to a virtual kernel pointer for /dev/mem
329 #define xlate_dev_mem_ptr(p) __va(p)
332 * Convert a virtual cached pointer to an uncached pointer
334 #define xlate_dev_kmem_ptr(p) p