1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19#ifndef _M68K_IO_MM_H
20#define _M68K_IO_MM_H
21
22#ifdef __KERNEL__
23
24#include <linux/compiler.h>
25#include <asm/raw_io.h>
26#include <asm/virtconvert.h>
27#include <asm/kmap.h>
28
29#include <asm-generic/iomap.h>
30
31#ifdef CONFIG_ATARI
32#include <asm/atarihw.h>
33#endif
34
35
36
37
38
39
40
41#ifdef CONFIG_Q40
42
43#define q40_isa_io_base 0xff400000
44#define q40_isa_mem_base 0xff800000
45
46#define Q40_ISA_IO_B(ioaddr) (q40_isa_io_base+1+4*((unsigned long)(ioaddr)))
47#define Q40_ISA_IO_W(ioaddr) (q40_isa_io_base+ 4*((unsigned long)(ioaddr)))
48#define Q40_ISA_MEM_B(madr) (q40_isa_mem_base+1+4*((unsigned long)(madr)))
49#define Q40_ISA_MEM_W(madr) (q40_isa_mem_base+ 4*((unsigned long)(madr)))
50
51#define MULTI_ISA 0
52#endif
53
54#ifdef CONFIG_AMIGA_PCMCIA
55#include <asm/amigayle.h>
56
57#define AG_ISA_IO_B(ioaddr) ( GAYLE_IO+(ioaddr)+(((ioaddr)&1)*GAYLE_ODD) )
58#define AG_ISA_IO_W(ioaddr) ( GAYLE_IO+(ioaddr) )
59
60#ifndef MULTI_ISA
61#define MULTI_ISA 0
62#else
63#undef MULTI_ISA
64#define MULTI_ISA 1
65#endif
66#endif
67
68#ifdef CONFIG_ATARI_ROM_ISA
69
70#define enec_isa_read_base 0xfffa0000
71#define enec_isa_write_base 0xfffb0000
72
73#define ENEC_ISA_IO_B(ioaddr) (enec_isa_read_base+((((unsigned long)(ioaddr))&0x7F)<<9))
74#define ENEC_ISA_IO_W(ioaddr) (enec_isa_read_base+((((unsigned long)(ioaddr))&0x7F)<<9))
75#define ENEC_ISA_MEM_B(madr) (enec_isa_read_base+((((unsigned long)(madr))&0x7F)<<9))
76#define ENEC_ISA_MEM_W(madr) (enec_isa_read_base+((((unsigned long)(madr))&0x7F)<<9))
77
78#ifndef MULTI_ISA
79#define MULTI_ISA 0
80#else
81#undef MULTI_ISA
82#define MULTI_ISA 1
83#endif
84#endif
85
86
87#if defined(CONFIG_ISA) || defined(CONFIG_ATARI_ROM_ISA)
88
89#if MULTI_ISA == 0
90#undef MULTI_ISA
91#endif
92
93#define ISA_TYPE_Q40 (1)
94#define ISA_TYPE_AG (2)
95#define ISA_TYPE_ENEC (3)
96
97#if defined(CONFIG_Q40) && !defined(MULTI_ISA)
98#define ISA_TYPE ISA_TYPE_Q40
99#define ISA_SEX 0
100#endif
101#if defined(CONFIG_AMIGA_PCMCIA) && !defined(MULTI_ISA)
102#define ISA_TYPE ISA_TYPE_AG
103#define ISA_SEX 1
104#endif
105#if defined(CONFIG_ATARI_ROM_ISA) && !defined(MULTI_ISA)
106#define ISA_TYPE ISA_TYPE_ENEC
107#define ISA_SEX 0
108#endif
109
110#ifdef MULTI_ISA
111extern int isa_type;
112extern int isa_sex;
113
114#define ISA_TYPE isa_type
115#define ISA_SEX isa_sex
116#endif
117
118
119
120
121
122
123static inline u8 __iomem *isa_itb(unsigned long addr)
124{
125 switch(ISA_TYPE)
126 {
127#ifdef CONFIG_Q40
128 case ISA_TYPE_Q40: return (u8 __iomem *)Q40_ISA_IO_B(addr);
129#endif
130#ifdef CONFIG_AMIGA_PCMCIA
131 case ISA_TYPE_AG: return (u8 __iomem *)AG_ISA_IO_B(addr);
132#endif
133#ifdef CONFIG_ATARI_ROM_ISA
134 case ISA_TYPE_ENEC: return (u8 __iomem *)ENEC_ISA_IO_B(addr);
135#endif
136 default: return NULL;
137 }
138}
139static inline u16 __iomem *isa_itw(unsigned long addr)
140{
141 switch(ISA_TYPE)
142 {
143#ifdef CONFIG_Q40
144 case ISA_TYPE_Q40: return (u16 __iomem *)Q40_ISA_IO_W(addr);
145#endif
146#ifdef CONFIG_AMIGA_PCMCIA
147 case ISA_TYPE_AG: return (u16 __iomem *)AG_ISA_IO_W(addr);
148#endif
149#ifdef CONFIG_ATARI_ROM_ISA
150 case ISA_TYPE_ENEC: return (u16 __iomem *)ENEC_ISA_IO_W(addr);
151#endif
152 default: return NULL;
153 }
154}
155static inline u32 __iomem *isa_itl(unsigned long addr)
156{
157 switch(ISA_TYPE)
158 {
159#ifdef CONFIG_AMIGA_PCMCIA
160 case ISA_TYPE_AG: return (u32 __iomem *)AG_ISA_IO_W(addr);
161#endif
162 default: return 0;
163 }
164}
165static inline u8 __iomem *isa_mtb(unsigned long addr)
166{
167 switch(ISA_TYPE)
168 {
169#ifdef CONFIG_Q40
170 case ISA_TYPE_Q40: return (u8 __iomem *)Q40_ISA_MEM_B(addr);
171#endif
172#ifdef CONFIG_AMIGA_PCMCIA
173 case ISA_TYPE_AG: return (u8 __iomem *)addr;
174#endif
175#ifdef CONFIG_ATARI_ROM_ISA
176 case ISA_TYPE_ENEC: return (u8 __iomem *)ENEC_ISA_MEM_B(addr);
177#endif
178 default: return NULL;
179 }
180}
181static inline u16 __iomem *isa_mtw(unsigned long addr)
182{
183 switch(ISA_TYPE)
184 {
185#ifdef CONFIG_Q40
186 case ISA_TYPE_Q40: return (u16 __iomem *)Q40_ISA_MEM_W(addr);
187#endif
188#ifdef CONFIG_AMIGA_PCMCIA
189 case ISA_TYPE_AG: return (u16 __iomem *)addr;
190#endif
191#ifdef CONFIG_ATARI_ROM_ISA
192 case ISA_TYPE_ENEC: return (u16 __iomem *)ENEC_ISA_MEM_W(addr);
193#endif
194 default: return NULL;
195 }
196}
197
198
199#define isa_inb(port) in_8(isa_itb(port))
200#define isa_inw(port) (ISA_SEX ? in_be16(isa_itw(port)) : in_le16(isa_itw(port)))
201#define isa_inl(port) (ISA_SEX ? in_be32(isa_itl(port)) : in_le32(isa_itl(port)))
202#define isa_outb(val,port) out_8(isa_itb(port),(val))
203#define isa_outw(val,port) (ISA_SEX ? out_be16(isa_itw(port),(val)) : out_le16(isa_itw(port),(val)))
204#define isa_outl(val,port) (ISA_SEX ? out_be32(isa_itl(port),(val)) : out_le32(isa_itl(port),(val)))
205
206#define isa_readb(p) in_8(isa_mtb((unsigned long)(p)))
207#define isa_readw(p) \
208 (ISA_SEX ? in_be16(isa_mtw((unsigned long)(p))) \
209 : in_le16(isa_mtw((unsigned long)(p))))
210#define isa_writeb(val,p) out_8(isa_mtb((unsigned long)(p)),(val))
211#define isa_writew(val,p) \
212 (ISA_SEX ? out_be16(isa_mtw((unsigned long)(p)),(val)) \
213 : out_le16(isa_mtw((unsigned long)(p)),(val)))
214
215#ifdef CONFIG_ATARI_ROM_ISA
216#define isa_rom_inb(port) rom_in_8(isa_itb(port))
217#define isa_rom_inw(port) \
218 (ISA_SEX ? rom_in_be16(isa_itw(port)) \
219 : rom_in_le16(isa_itw(port)))
220
221#define isa_rom_outb(val, port) rom_out_8(isa_itb(port), (val))
222#define isa_rom_outw(val, port) \
223 (ISA_SEX ? rom_out_be16(isa_itw(port), (val)) \
224 : rom_out_le16(isa_itw(port), (val)))
225
226#define isa_rom_readb(p) rom_in_8(isa_mtb((unsigned long)(p)))
227#define isa_rom_readw(p) \
228 (ISA_SEX ? rom_in_be16(isa_mtw((unsigned long)(p))) \
229 : rom_in_le16(isa_mtw((unsigned long)(p))))
230#define isa_rom_readw_swap(p) \
231 (ISA_SEX ? rom_in_le16(isa_mtw((unsigned long)(p))) \
232 : rom_in_be16(isa_mtw((unsigned long)(p))))
233#define isa_rom_readw_raw(p) rom_in_be16(isa_mtw((unsigned long)(p)))
234
235#define isa_rom_writeb(val, p) rom_out_8(isa_mtb((unsigned long)(p)), (val))
236#define isa_rom_writew(val, p) \
237 (ISA_SEX ? rom_out_be16(isa_mtw((unsigned long)(p)), (val)) \
238 : rom_out_le16(isa_mtw((unsigned long)(p)), (val)))
239#define isa_rom_writew_swap(val, p) \
240 (ISA_SEX ? rom_out_le16(isa_mtw((unsigned long)(p)), (val)) \
241 : rom_out_be16(isa_mtw((unsigned long)(p)), (val)))
242#define isa_rom_writew_raw(val, p) rom_out_be16(isa_mtw((unsigned long)(p)), (val))
243#endif
244
245static inline void isa_delay(void)
246{
247 switch(ISA_TYPE)
248 {
249#ifdef CONFIG_Q40
250 case ISA_TYPE_Q40: isa_outb(0,0x80); break;
251#endif
252#ifdef CONFIG_AMIGA_PCMCIA
253 case ISA_TYPE_AG: break;
254#endif
255#ifdef CONFIG_ATARI_ROM_ISA
256 case ISA_TYPE_ENEC: break;
257#endif
258 default: break;
259 }
260}
261
262#define isa_inb_p(p) ({u8 v=isa_inb(p);isa_delay();v;})
263#define isa_outb_p(v,p) ({isa_outb((v),(p));isa_delay();})
264#define isa_inw_p(p) ({u16 v=isa_inw(p);isa_delay();v;})
265#define isa_outw_p(v,p) ({isa_outw((v),(p));isa_delay();})
266#define isa_inl_p(p) ({u32 v=isa_inl(p);isa_delay();v;})
267#define isa_outl_p(v,p) ({isa_outl((v),(p));isa_delay();})
268
269#define isa_insb(port, buf, nr) raw_insb(isa_itb(port), (u8 *)(buf), (nr))
270#define isa_outsb(port, buf, nr) raw_outsb(isa_itb(port), (u8 *)(buf), (nr))
271
272#define isa_insw(port, buf, nr) \
273 (ISA_SEX ? raw_insw(isa_itw(port), (u16 *)(buf), (nr)) : \
274 raw_insw_swapw(isa_itw(port), (u16 *)(buf), (nr)))
275
276#define isa_outsw(port, buf, nr) \
277 (ISA_SEX ? raw_outsw(isa_itw(port), (u16 *)(buf), (nr)) : \
278 raw_outsw_swapw(isa_itw(port), (u16 *)(buf), (nr)))
279
280#define isa_insl(port, buf, nr) \
281 (ISA_SEX ? raw_insl(isa_itl(port), (u32 *)(buf), (nr)) : \
282 raw_insw_swapw(isa_itw(port), (u16 *)(buf), (nr)<<1))
283
284#define isa_outsl(port, buf, nr) \
285 (ISA_SEX ? raw_outsl(isa_itl(port), (u32 *)(buf), (nr)) : \
286 raw_outsw_swapw(isa_itw(port), (u16 *)(buf), (nr)<<1))
287
288
289#ifdef CONFIG_ATARI_ROM_ISA
290#define isa_rom_inb_p(p) ({ u8 _v = isa_rom_inb(p); isa_delay(); _v; })
291#define isa_rom_inw_p(p) ({ u16 _v = isa_rom_inw(p); isa_delay(); _v; })
292#define isa_rom_outb_p(v, p) ({ isa_rom_outb((v), (p)); isa_delay(); })
293#define isa_rom_outw_p(v, p) ({ isa_rom_outw((v), (p)); isa_delay(); })
294
295#define isa_rom_insb(port, buf, nr) raw_rom_insb(isa_itb(port), (u8 *)(buf), (nr))
296
297#define isa_rom_insw(port, buf, nr) \
298 (ISA_SEX ? raw_rom_insw(isa_itw(port), (u16 *)(buf), (nr)) : \
299 raw_rom_insw_swapw(isa_itw(port), (u16 *)(buf), (nr)))
300
301#define isa_rom_outsb(port, buf, nr) raw_rom_outsb(isa_itb(port), (u8 *)(buf), (nr))
302
303#define isa_rom_outsw(port, buf, nr) \
304 (ISA_SEX ? raw_rom_outsw(isa_itw(port), (u16 *)(buf), (nr)) : \
305 raw_rom_outsw_swapw(isa_itw(port), (u16 *)(buf), (nr)))
306#endif
307
308#endif
309
310
311#if defined(CONFIG_ISA) && !defined(CONFIG_ATARI_ROM_ISA)
312#define inb isa_inb
313#define inb_p isa_inb_p
314#define outb isa_outb
315#define outb_p isa_outb_p
316#define inw isa_inw
317#define inw_p isa_inw_p
318#define outw isa_outw
319#define outw_p isa_outw_p
320#define inl isa_inl
321#define inl_p isa_inl_p
322#define outl isa_outl
323#define outl_p isa_outl_p
324#define insb isa_insb
325#define insw isa_insw
326#define insl isa_insl
327#define outsb isa_outsb
328#define outsw isa_outsw
329#define outsl isa_outsl
330#define readb isa_readb
331#define readw isa_readw
332#define writeb isa_writeb
333#define writew isa_writew
334#endif
335
336#ifdef CONFIG_ATARI_ROM_ISA
337
338
339
340
341
342
343#define inb(port) ((port) < 1024 ? isa_rom_inb(port) : in_8(port))
344#define inb_p(port) ((port) < 1024 ? isa_rom_inb_p(port) : in_8(port))
345#define inw(port) ((port) < 1024 ? isa_rom_inw(port) : in_le16(port))
346#define inw_p(port) ((port) < 1024 ? isa_rom_inw_p(port) : in_le16(port))
347#define inl isa_inl
348#define inl_p isa_inl_p
349
350#define outb(val, port) ((port) < 1024 ? isa_rom_outb((val), (port)) : out_8((port), (val)))
351#define outb_p(val, port) ((port) < 1024 ? isa_rom_outb_p((val), (port)) : out_8((port), (val)))
352#define outw(val, port) ((port) < 1024 ? isa_rom_outw((val), (port)) : out_le16((port), (val)))
353#define outw_p(val, port) ((port) < 1024 ? isa_rom_outw_p((val), (port)) : out_le16((port), (val)))
354#define outl isa_outl
355#define outl_p isa_outl_p
356
357#define insb(port, buf, nr) ((port) < 1024 ? isa_rom_insb((port), (buf), (nr)) : isa_insb((port), (buf), (nr)))
358#define insw(port, buf, nr) ((port) < 1024 ? isa_rom_insw((port), (buf), (nr)) : isa_insw((port), (buf), (nr)))
359#define insl isa_insl
360#define outsb(port, buf, nr) ((port) < 1024 ? isa_rom_outsb((port), (buf), (nr)) : isa_outsb((port), (buf), (nr)))
361#define outsw(port, buf, nr) ((port) < 1024 ? isa_rom_outsw((port), (buf), (nr)) : isa_outsw((port), (buf), (nr)))
362#define outsl isa_outsl
363
364#define readb(addr) in_8(addr)
365#define writeb(val, addr) out_8((addr), (val))
366#define readw(addr) in_le16(addr)
367#define writew(val, addr) out_le16((addr), (val))
368#endif
369
370#define readl(addr) in_le32(addr)
371#define writel(val,addr) out_le32((addr),(val))
372
373#define readsb(port, buf, nr) raw_insb((port), (u8 *)(buf), (nr))
374#define readsw(port, buf, nr) raw_insw((port), (u16 *)(buf), (nr))
375#define readsl(port, buf, nr) raw_insl((port), (u32 *)(buf), (nr))
376#define writesb(port, buf, nr) raw_outsb((port), (u8 *)(buf), (nr))
377#define writesw(port, buf, nr) raw_outsw((port), (u16 *)(buf), (nr))
378#define writesl(port, buf, nr) raw_outsl((port), (u32 *)(buf), (nr))
379
380#define mmiowb()
381
382#ifndef CONFIG_SUN3
383#define IO_SPACE_LIMIT 0xffff
384#else
385#define IO_SPACE_LIMIT 0x0fffffff
386#endif
387
388#endif
389
390#define __ARCH_HAS_NO_PAGE_ZERO_MAPPED 1
391
392
393
394
395
396#define xlate_dev_mem_ptr(p) __va(p)
397
398
399
400
401#define xlate_dev_kmem_ptr(p) p
402
403#define readb_relaxed(addr) readb(addr)
404#define readw_relaxed(addr) readw(addr)
405#define readl_relaxed(addr) readl(addr)
406
407#define writeb_relaxed(b, addr) writeb(b, addr)
408#define writew_relaxed(b, addr) writew(b, addr)
409#define writel_relaxed(b, addr) writel(b, addr)
410
411#endif
412