blob: 8955b40a5dc4304a37c6ff88b328a333f1df13cd [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * linux/include/asm-m68k/io.h
3 *
4 * 4/1/00 RZ: - rewritten to avoid clashes between ISA/PCI and other
5 * IO access
6 * - added Q40 support
7 * - added skeleton for GG-II and Amiga PCMCIA
8 * 2/3/01 RZ: - moved a few more defs into raw_io.h
9 *
Adrian Bunk2171a192008-10-13 21:59:00 +020010 * 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
Linus Torvalds1da177e2005-04-16 15:20:36 -070012 * or define its own macros on top of these.
13 *
Adrian Bunk2171a192008-10-13 21:59:00 +020014 * inX(),outX() are for ISA I/O
Linus Torvalds1da177e2005-04-16 15:20:36 -070015 * isa_readX(),isa_writeX() are for ISA memory
Linus Torvalds1da177e2005-04-16 15:20:36 -070016 */
17
18#ifndef _IO_H
19#define _IO_H
20
21#ifdef __KERNEL__
22
Al Viroad9ec4f2006-01-12 01:06:24 -080023#include <linux/compiler.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070024#include <asm/raw_io.h>
25#include <asm/virtconvert.h>
26
Al Virof9569e12007-07-20 04:32:58 +010027#include <asm-generic/iomap.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070028
29#ifdef CONFIG_ATARI
30#include <asm/atarihw.h>
31#endif
32
33
34/*
35 * IO/MEM definitions for various ISA bridges
36 */
37
38
39#ifdef CONFIG_Q40
40
41#define q40_isa_io_base 0xff400000
42#define q40_isa_mem_base 0xff800000
43
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)))
48
49#define MULTI_ISA 0
50#endif /* Q40 */
51
Linus Torvalds1da177e2005-04-16 15:20:36 -070052#ifdef CONFIG_AMIGA_PCMCIA
53#include <asm/amigayle.h>
54
55#define AG_ISA_IO_B(ioaddr) ( GAYLE_IO+(ioaddr)+(((ioaddr)&1)*GAYLE_ODD) )
56#define AG_ISA_IO_W(ioaddr) ( GAYLE_IO+(ioaddr) )
57
58#ifndef MULTI_ISA
59#define MULTI_ISA 0
60#else
61#undef MULTI_ISA
62#define MULTI_ISA 1
63#endif
64#endif /* AMIGA_PCMCIA */
65
Michael Schmitz84b16b72013-04-06 13:26:35 +130066#ifdef CONFIG_ATARI_ROM_ISA
67
68#define enec_isa_read_base 0xfffa0000
69#define enec_isa_write_base 0xfffb0000
70
71#define ENEC_ISA_IO_B(ioaddr) (enec_isa_read_base+((((unsigned long)(ioaddr))&0x7F)<<9))
72#define ENEC_ISA_IO_W(ioaddr) (enec_isa_read_base+((((unsigned long)(ioaddr))&0x7F)<<9))
73#define ENEC_ISA_MEM_B(madr) (enec_isa_read_base+((((unsigned long)(madr))&0x7F)<<9))
74#define ENEC_ISA_MEM_W(madr) (enec_isa_read_base+((((unsigned long)(madr))&0x7F)<<9))
75
76#ifndef MULTI_ISA
77#define MULTI_ISA 0
78#else
79#undef MULTI_ISA
80#define MULTI_ISA 1
81#endif
82#endif /* ATARI_ROM_ISA */
Linus Torvalds1da177e2005-04-16 15:20:36 -070083
84
Greg Ungerer9ff601a2012-06-29 00:03:27 +100085#if defined(CONFIG_PCI) && defined(CONFIG_COLDFIRE)
86
87#define HAVE_ARCH_PIO_SIZE
88#define PIO_OFFSET 0
89#define PIO_MASK 0xffff
90#define PIO_RESERVED 0x10000
91
92u8 mcf_pci_inb(u32 addr);
93u16 mcf_pci_inw(u32 addr);
94u32 mcf_pci_inl(u32 addr);
95void mcf_pci_insb(u32 addr, u8 *buf, u32 len);
96void mcf_pci_insw(u32 addr, u16 *buf, u32 len);
97void mcf_pci_insl(u32 addr, u32 *buf, u32 len);
98
99void mcf_pci_outb(u8 v, u32 addr);
100void mcf_pci_outw(u16 v, u32 addr);
101void mcf_pci_outl(u32 v, u32 addr);
102void mcf_pci_outsb(u32 addr, const u8 *buf, u32 len);
103void mcf_pci_outsw(u32 addr, const u16 *buf, u32 len);
104void mcf_pci_outsl(u32 addr, const u32 *buf, u32 len);
105
106#define inb mcf_pci_inb
107#define inb_p mcf_pci_inb
108#define inw mcf_pci_inw
109#define inw_p mcf_pci_inw
110#define inl mcf_pci_inl
111#define inl_p mcf_pci_inl
112#define insb mcf_pci_insb
113#define insw mcf_pci_insw
114#define insl mcf_pci_insl
115
116#define outb mcf_pci_outb
117#define outb_p mcf_pci_outb
118#define outw mcf_pci_outw
119#define outw_p mcf_pci_outw
120#define outl mcf_pci_outl
121#define outl_p mcf_pci_outl
122#define outsb mcf_pci_outsb
123#define outsw mcf_pci_outsw
124#define outsl mcf_pci_outsl
125
126#define readb(addr) in_8(addr)
127#define writeb(v, addr) out_8((addr), (v))
128#define readw(addr) in_le16(addr)
129#define writew(v, addr) out_le16((addr), (v))
130
Michael Schmitz84b16b72013-04-06 13:26:35 +1300131#elif defined(CONFIG_ISA) || defined(CONFIG_ATARI_ROM_ISA)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700132
133#if MULTI_ISA == 0
134#undef MULTI_ISA
135#endif
136
Michael Schmitz84b16b72013-04-06 13:26:35 +1300137#define ISA_TYPE_Q40 (1)
138#define ISA_TYPE_AG (2)
139#define ISA_TYPE_ENEC (3)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140
141#if defined(CONFIG_Q40) && !defined(MULTI_ISA)
Geert Uytterhoeven52de1142008-05-18 20:47:21 +0200142#define ISA_TYPE ISA_TYPE_Q40
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143#define ISA_SEX 0
144#endif
145#if defined(CONFIG_AMIGA_PCMCIA) && !defined(MULTI_ISA)
Geert Uytterhoeven52de1142008-05-18 20:47:21 +0200146#define ISA_TYPE ISA_TYPE_AG
Linus Torvalds1da177e2005-04-16 15:20:36 -0700147#define ISA_SEX 1
148#endif
Michael Schmitz84b16b72013-04-06 13:26:35 +1300149#if defined(CONFIG_ATARI_ROM_ISA) && !defined(MULTI_ISA)
150#define ISA_TYPE ISA_TYPE_ENEC
151#define ISA_SEX 0
152#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153
154#ifdef MULTI_ISA
155extern int isa_type;
156extern int isa_sex;
157
158#define ISA_TYPE isa_type
159#define ISA_SEX isa_sex
160#endif
161
162/*
163 * define inline addr translation functions. Normally only one variant will
164 * be compiled in so the case statement will be optimised away
165 */
166
Al Viroad9ec4f2006-01-12 01:06:24 -0800167static inline u8 __iomem *isa_itb(unsigned long addr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700168{
169 switch(ISA_TYPE)
170 {
171#ifdef CONFIG_Q40
Geert Uytterhoeven52de1142008-05-18 20:47:21 +0200172 case ISA_TYPE_Q40: return (u8 __iomem *)Q40_ISA_IO_B(addr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700173#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700174#ifdef CONFIG_AMIGA_PCMCIA
Geert Uytterhoeven52de1142008-05-18 20:47:21 +0200175 case ISA_TYPE_AG: return (u8 __iomem *)AG_ISA_IO_B(addr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700176#endif
Michael Schmitz84b16b72013-04-06 13:26:35 +1300177#ifdef CONFIG_ATARI_ROM_ISA
178 case ISA_TYPE_ENEC: return (u8 __iomem *)ENEC_ISA_IO_B(addr);
179#endif
Al Viroad9ec4f2006-01-12 01:06:24 -0800180 default: return NULL; /* avoid warnings, just in case */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700181 }
182}
Al Viroad9ec4f2006-01-12 01:06:24 -0800183static inline u16 __iomem *isa_itw(unsigned long addr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700184{
185 switch(ISA_TYPE)
186 {
187#ifdef CONFIG_Q40
Geert Uytterhoeven52de1142008-05-18 20:47:21 +0200188 case ISA_TYPE_Q40: return (u16 __iomem *)Q40_ISA_IO_W(addr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700189#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700190#ifdef CONFIG_AMIGA_PCMCIA
Geert Uytterhoeven52de1142008-05-18 20:47:21 +0200191 case ISA_TYPE_AG: return (u16 __iomem *)AG_ISA_IO_W(addr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700192#endif
Michael Schmitz84b16b72013-04-06 13:26:35 +1300193#ifdef CONFIG_ATARI_ROM_ISA
194 case ISA_TYPE_ENEC: return (u16 __iomem *)ENEC_ISA_IO_W(addr);
195#endif
Al Viroad9ec4f2006-01-12 01:06:24 -0800196 default: return NULL; /* avoid warnings, just in case */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700197 }
198}
Al Virof9569e12007-07-20 04:32:58 +0100199static inline u32 __iomem *isa_itl(unsigned long addr)
200{
201 switch(ISA_TYPE)
202 {
203#ifdef CONFIG_AMIGA_PCMCIA
Geert Uytterhoeven52de1142008-05-18 20:47:21 +0200204 case ISA_TYPE_AG: return (u32 __iomem *)AG_ISA_IO_W(addr);
Al Virof9569e12007-07-20 04:32:58 +0100205#endif
206 default: return 0; /* avoid warnings, just in case */
207 }
208}
Al Viroad9ec4f2006-01-12 01:06:24 -0800209static inline u8 __iomem *isa_mtb(unsigned long addr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700210{
211 switch(ISA_TYPE)
212 {
213#ifdef CONFIG_Q40
Geert Uytterhoeven52de1142008-05-18 20:47:21 +0200214 case ISA_TYPE_Q40: return (u8 __iomem *)Q40_ISA_MEM_B(addr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700215#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700216#ifdef CONFIG_AMIGA_PCMCIA
Geert Uytterhoeven52de1142008-05-18 20:47:21 +0200217 case ISA_TYPE_AG: return (u8 __iomem *)addr;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700218#endif
Michael Schmitz84b16b72013-04-06 13:26:35 +1300219#ifdef CONFIG_ATARI_ROM_ISA
220 case ISA_TYPE_ENEC: return (u8 __iomem *)ENEC_ISA_MEM_B(addr);
221#endif
Al Viroad9ec4f2006-01-12 01:06:24 -0800222 default: return NULL; /* avoid warnings, just in case */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700223 }
224}
Al Viroad9ec4f2006-01-12 01:06:24 -0800225static inline u16 __iomem *isa_mtw(unsigned long addr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700226{
227 switch(ISA_TYPE)
228 {
229#ifdef CONFIG_Q40
Geert Uytterhoeven52de1142008-05-18 20:47:21 +0200230 case ISA_TYPE_Q40: return (u16 __iomem *)Q40_ISA_MEM_W(addr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700231#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700232#ifdef CONFIG_AMIGA_PCMCIA
Geert Uytterhoeven52de1142008-05-18 20:47:21 +0200233 case ISA_TYPE_AG: return (u16 __iomem *)addr;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700234#endif
Michael Schmitz84b16b72013-04-06 13:26:35 +1300235#ifdef CONFIG_ATARI_ROM_ISA
236 case ISA_TYPE_ENEC: return (u16 __iomem *)ENEC_ISA_MEM_W(addr);
237#endif
Al Viroad9ec4f2006-01-12 01:06:24 -0800238 default: return NULL; /* avoid warnings, just in case */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700239 }
240}
241
242
243#define isa_inb(port) in_8(isa_itb(port))
244#define isa_inw(port) (ISA_SEX ? in_be16(isa_itw(port)) : in_le16(isa_itw(port)))
Al Virof9569e12007-07-20 04:32:58 +0100245#define isa_inl(port) (ISA_SEX ? in_be32(isa_itl(port)) : in_le32(isa_itl(port)))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700246#define isa_outb(val,port) out_8(isa_itb(port),(val))
247#define isa_outw(val,port) (ISA_SEX ? out_be16(isa_itw(port),(val)) : out_le16(isa_itw(port),(val)))
Al Virof9569e12007-07-20 04:32:58 +0100248#define isa_outl(val,port) (ISA_SEX ? out_be32(isa_itl(port),(val)) : out_le32(isa_itl(port),(val)))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700249
250#define isa_readb(p) in_8(isa_mtb((unsigned long)(p)))
251#define isa_readw(p) \
252 (ISA_SEX ? in_be16(isa_mtw((unsigned long)(p))) \
253 : in_le16(isa_mtw((unsigned long)(p))))
254#define isa_writeb(val,p) out_8(isa_mtb((unsigned long)(p)),(val))
255#define isa_writew(val,p) \
256 (ISA_SEX ? out_be16(isa_mtw((unsigned long)(p)),(val)) \
257 : out_le16(isa_mtw((unsigned long)(p)),(val)))
258
Michael Schmitz84b16b72013-04-06 13:26:35 +1300259#ifdef CONFIG_ATARI_ROM_ISA
260#define isa_rom_inb(port) rom_in_8(isa_itb(port))
261#define isa_rom_inw(port) \
262 (ISA_SEX ? rom_in_be16(isa_itw(port)) \
263 : rom_in_le16(isa_itw(port)))
264
265#define isa_rom_outb(val, port) rom_out_8(isa_itb(port), (val))
266#define isa_rom_outw(val, port) \
267 (ISA_SEX ? rom_out_be16(isa_itw(port), (val)) \
268 : rom_out_le16(isa_itw(port), (val)))
269
270#define isa_rom_readb(p) rom_in_8(isa_mtb((unsigned long)(p)))
271#define isa_rom_readw(p) \
272 (ISA_SEX ? rom_in_be16(isa_mtw((unsigned long)(p))) \
273 : rom_in_le16(isa_mtw((unsigned long)(p))))
274#define isa_rom_readw_swap(p) \
275 (ISA_SEX ? rom_in_le16(isa_mtw((unsigned long)(p))) \
276 : rom_in_be16(isa_mtw((unsigned long)(p))))
277#define isa_rom_readw_raw(p) rom_in_be16(isa_mtw((unsigned long)(p)))
278
279#define isa_rom_writeb(val, p) rom_out_8(isa_mtb((unsigned long)(p)), (val))
280#define isa_rom_writew(val, p) \
281 (ISA_SEX ? rom_out_be16(isa_mtw((unsigned long)(p)), (val)) \
282 : rom_out_le16(isa_mtw((unsigned long)(p)), (val)))
283#define isa_rom_writew_swap(val, p) \
284 (ISA_SEX ? rom_out_le16(isa_mtw((unsigned long)(p)), (val)) \
285 : rom_out_be16(isa_mtw((unsigned long)(p)), (val)))
286#define isa_rom_writew_raw(val, p) rom_out_be16(isa_mtw((unsigned long)(p)), (val))
287#endif /* CONFIG_ATARI_ROM_ISA */
288
Linus Torvalds1da177e2005-04-16 15:20:36 -0700289static inline void isa_delay(void)
290{
291 switch(ISA_TYPE)
292 {
293#ifdef CONFIG_Q40
Geert Uytterhoeven52de1142008-05-18 20:47:21 +0200294 case ISA_TYPE_Q40: isa_outb(0,0x80); break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700295#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700296#ifdef CONFIG_AMIGA_PCMCIA
Geert Uytterhoeven52de1142008-05-18 20:47:21 +0200297 case ISA_TYPE_AG: break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700298#endif
Michael Schmitz84b16b72013-04-06 13:26:35 +1300299#ifdef CONFIG_ATARI_ROM_ISA
300 case ISA_TYPE_ENEC: break;
301#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700302 default: break; /* avoid warnings */
303 }
304}
305
306#define isa_inb_p(p) ({u8 v=isa_inb(p);isa_delay();v;})
307#define isa_outb_p(v,p) ({isa_outb((v),(p));isa_delay();})
308#define isa_inw_p(p) ({u16 v=isa_inw(p);isa_delay();v;})
309#define isa_outw_p(v,p) ({isa_outw((v),(p));isa_delay();})
310#define isa_inl_p(p) ({u32 v=isa_inl(p);isa_delay();v;})
311#define isa_outl_p(v,p) ({isa_outl((v),(p));isa_delay();})
312
313#define isa_insb(port, buf, nr) raw_insb(isa_itb(port), (u8 *)(buf), (nr))
314#define isa_outsb(port, buf, nr) raw_outsb(isa_itb(port), (u8 *)(buf), (nr))
315
316#define isa_insw(port, buf, nr) \
317 (ISA_SEX ? raw_insw(isa_itw(port), (u16 *)(buf), (nr)) : \
318 raw_insw_swapw(isa_itw(port), (u16 *)(buf), (nr)))
319
320#define isa_outsw(port, buf, nr) \
321 (ISA_SEX ? raw_outsw(isa_itw(port), (u16 *)(buf), (nr)) : \
322 raw_outsw_swapw(isa_itw(port), (u16 *)(buf), (nr)))
Al Virof9569e12007-07-20 04:32:58 +0100323
324#define isa_insl(port, buf, nr) \
325 (ISA_SEX ? raw_insl(isa_itl(port), (u32 *)(buf), (nr)) : \
326 raw_insw_swapw(isa_itw(port), (u16 *)(buf), (nr)<<1))
327
328#define isa_outsl(port, buf, nr) \
329 (ISA_SEX ? raw_outsl(isa_itl(port), (u32 *)(buf), (nr)) : \
330 raw_outsw_swapw(isa_itw(port), (u16 *)(buf), (nr)<<1))
331
Linus Torvalds1da177e2005-04-16 15:20:36 -0700332
Michael Schmitz84b16b72013-04-06 13:26:35 +1300333#ifdef CONFIG_ATARI_ROM_ISA
334#define isa_rom_inb_p(p) ({ u8 _v = isa_rom_inb(p); isa_delay(); _v; })
335#define isa_rom_inw_p(p) ({ u16 _v = isa_rom_inw(p); isa_delay(); _v; })
336#define isa_rom_outb_p(v, p) ({ isa_rom_outb((v), (p)); isa_delay(); })
337#define isa_rom_outw_p(v, p) ({ isa_rom_outw((v), (p)); isa_delay(); })
338
339#define isa_rom_insb(port, buf, nr) raw_rom_insb(isa_itb(port), (u8 *)(buf), (nr))
340
341#define isa_rom_insw(port, buf, nr) \
342 (ISA_SEX ? raw_rom_insw(isa_itw(port), (u16 *)(buf), (nr)) : \
343 raw_rom_insw_swapw(isa_itw(port), (u16 *)(buf), (nr)))
344
345#define isa_rom_outsb(port, buf, nr) raw_rom_outsb(isa_itb(port), (u8 *)(buf), (nr))
346
347#define isa_rom_outsw(port, buf, nr) \
348 (ISA_SEX ? raw_rom_outsw(isa_itw(port), (u16 *)(buf), (nr)) : \
349 raw_rom_outsw_swapw(isa_itw(port), (u16 *)(buf), (nr)))
350#endif /* CONFIG_ATARI_ROM_ISA */
351
352#endif /* CONFIG_ISA || CONFIG_ATARI_ROM_ISA */
353
354
355#if defined(CONFIG_ISA) && !defined(CONFIG_ATARI_ROM_ISA)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700356#define inb isa_inb
357#define inb_p isa_inb_p
358#define outb isa_outb
359#define outb_p isa_outb_p
360#define inw isa_inw
361#define inw_p isa_inw_p
362#define outw isa_outw
363#define outw_p isa_outw_p
Al Virof9569e12007-07-20 04:32:58 +0100364#define inl isa_inl
365#define inl_p isa_inl_p
366#define outl isa_outl
367#define outl_p isa_outl_p
Linus Torvalds1da177e2005-04-16 15:20:36 -0700368#define insb isa_insb
369#define insw isa_insw
Al Virof9569e12007-07-20 04:32:58 +0100370#define insl isa_insl
Linus Torvalds1da177e2005-04-16 15:20:36 -0700371#define outsb isa_outsb
372#define outsw isa_outsw
Al Virof9569e12007-07-20 04:32:58 +0100373#define outsl isa_outsl
Linus Torvalds1da177e2005-04-16 15:20:36 -0700374#define readb isa_readb
375#define readw isa_readw
376#define writeb isa_writeb
377#define writew isa_writew
Michael Schmitz84b16b72013-04-06 13:26:35 +1300378#endif /* CONFIG_ISA && !CONFIG_ATARI_ROM_ISA */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700379
Michael Schmitz84b16b72013-04-06 13:26:35 +1300380#ifdef CONFIG_ATARI_ROM_ISA
381/*
382 * kernel with both ROM port ISA and IDE compiled in, those have
383 * conflicting defs for in/out. Simply consider port < 1024
384 * ROM port ISA and everything else regular ISA for IDE. read,write defined
385 * below.
386 */
387#define inb(port) ((port) < 1024 ? isa_rom_inb(port) : in_8(port))
388#define inb_p(port) ((port) < 1024 ? isa_rom_inb_p(port) : in_8(port))
389#define inw(port) ((port) < 1024 ? isa_rom_inw(port) : in_le16(port))
390#define inw_p(port) ((port) < 1024 ? isa_rom_inw_p(port) : in_le16(port))
391#define inl isa_inl
392#define inl_p isa_inl_p
Linus Torvalds1da177e2005-04-16 15:20:36 -0700393
Michael Schmitz84b16b72013-04-06 13:26:35 +1300394#define outb(val, port) ((port) < 1024 ? isa_rom_outb((val), (port)) : out_8((port), (val)))
395#define outb_p(val, port) ((port) < 1024 ? isa_rom_outb_p((val), (port)) : out_8((port), (val)))
396#define outw(val, port) ((port) < 1024 ? isa_rom_outw((val), (port)) : out_le16((port), (val)))
397#define outw_p(val, port) ((port) < 1024 ? isa_rom_outw_p((val), (port)) : out_le16((port), (val)))
398#define outl isa_outl
399#define outl_p isa_outl_p
400
401#define insb(port, buf, nr) ((port) < 1024 ? isa_rom_insb((port), (buf), (nr)) : isa_insb((port), (buf), (nr)))
402#define insw(port, buf, nr) ((port) < 1024 ? isa_rom_insw((port), (buf), (nr)) : isa_insw((port), (buf), (nr)))
403#define insl isa_insl
404#define outsb(port, buf, nr) ((port) < 1024 ? isa_rom_outsb((port), (buf), (nr)) : isa_outsb((port), (buf), (nr)))
405#define outsw(port, buf, nr) ((port) < 1024 ? isa_rom_outsw((port), (buf), (nr)) : isa_outsw((port), (buf), (nr)))
406#define outsl isa_outsl
407
408#define readb(addr) in_8(addr)
409#define writeb(val, addr) out_8((addr), (val))
410#define readw(addr) in_le16(addr)
411#define writew(val, addr) out_le16((addr), (val))
412#endif /* CONFIG_ATARI_ROM_ISA */
413
414#if !defined(CONFIG_ISA) && !defined(CONFIG_ATARI_ROM_ISA)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700415/*
Al Virof9569e12007-07-20 04:32:58 +0100416 * We need to define dummy functions for GENERIC_IOMAP support.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700417 */
Al Virof9569e12007-07-20 04:32:58 +0100418#define inb(port) 0xff
419#define inb_p(port) 0xff
420#define outb(val,port) ((void)0)
421#define outb_p(val,port) ((void)0)
422#define inw(port) 0xffff
Thorsten Glaser779b7e62010-10-03 18:48:51 +0000423#define inw_p(port) 0xffff
Al Virof9569e12007-07-20 04:32:58 +0100424#define outw(val,port) ((void)0)
Thorsten Glaser779b7e62010-10-03 18:48:51 +0000425#define outw_p(val,port) ((void)0)
Al Virof9569e12007-07-20 04:32:58 +0100426#define inl(port) 0xffffffffUL
Thorsten Glaser779b7e62010-10-03 18:48:51 +0000427#define inl_p(port) 0xffffffffUL
Al Virof9569e12007-07-20 04:32:58 +0100428#define outl(val,port) ((void)0)
Thorsten Glaser779b7e62010-10-03 18:48:51 +0000429#define outl_p(val,port) ((void)0)
Al Virof9569e12007-07-20 04:32:58 +0100430
431#define insb(port,buf,nr) ((void)0)
432#define outsb(port,buf,nr) ((void)0)
433#define insw(port,buf,nr) ((void)0)
434#define outsw(port,buf,nr) ((void)0)
435#define insl(port,buf,nr) ((void)0)
436#define outsl(port,buf,nr) ((void)0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700437
438/*
439 * These should be valid on any ioremap()ed region
440 */
441#define readb(addr) in_8(addr)
442#define writeb(val,addr) out_8((addr),(val))
Al Virof9569e12007-07-20 04:32:58 +0100443#define readw(addr) in_le16(addr)
444#define writew(val,addr) out_le16((addr),(val))
Adrian Bunk2171a192008-10-13 21:59:00 +0200445
Michael Schmitz84b16b72013-04-06 13:26:35 +1300446#endif /* !CONFIG_ISA && !CONFIG_ATARI_ROM_ISA */
Adrian Bunk2171a192008-10-13 21:59:00 +0200447
Linus Torvalds1da177e2005-04-16 15:20:36 -0700448#define readl(addr) in_le32(addr)
449#define writel(val,addr) out_le32((addr),(val))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700450
Geert Uytterhoevenf5db9c62012-04-15 20:37:39 +0200451#define readsb(port, buf, nr) raw_insb((port), (u8 *)(buf), (nr))
452#define readsw(port, buf, nr) raw_insw((port), (u16 *)(buf), (nr))
453#define readsl(port, buf, nr) raw_insl((port), (u32 *)(buf), (nr))
454#define writesb(port, buf, nr) raw_outsb((port), (u8 *)(buf), (nr))
455#define writesw(port, buf, nr) raw_outsw((port), (u16 *)(buf), (nr))
456#define writesl(port, buf, nr) raw_outsl((port), (u32 *)(buf), (nr))
457
Linus Torvalds1da177e2005-04-16 15:20:36 -0700458#define mmiowb()
459
Al Viroad9ec4f2006-01-12 01:06:24 -0800460static inline void __iomem *ioremap(unsigned long physaddr, unsigned long size)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700461{
462 return __ioremap(physaddr, size, IOMAP_NOCACHE_SER);
463}
Al Viroad9ec4f2006-01-12 01:06:24 -0800464static inline void __iomem *ioremap_nocache(unsigned long physaddr, unsigned long size)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700465{
466 return __ioremap(physaddr, size, IOMAP_NOCACHE_SER);
467}
Al Viroad9ec4f2006-01-12 01:06:24 -0800468static inline void __iomem *ioremap_writethrough(unsigned long physaddr,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700469 unsigned long size)
470{
471 return __ioremap(physaddr, size, IOMAP_WRITETHROUGH);
472}
Al Viroad9ec4f2006-01-12 01:06:24 -0800473static inline void __iomem *ioremap_fullcache(unsigned long physaddr,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700474 unsigned long size)
475{
476 return __ioremap(physaddr, size, IOMAP_FULL_CACHING);
477}
478
Al Virof9569e12007-07-20 04:32:58 +0100479static inline void memset_io(volatile void __iomem *addr, unsigned char val, int count)
480{
481 __builtin_memset((void __force *) addr, val, count);
482}
483static inline void memcpy_fromio(void *dst, const volatile void __iomem *src, int count)
484{
485 __builtin_memcpy(dst, (void __force *) src, count);
486}
487static inline void memcpy_toio(volatile void __iomem *dst, const void *src, int count)
488{
489 __builtin_memcpy((void __force *) dst, src, count);
490}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700491
492#ifndef CONFIG_SUN3
493#define IO_SPACE_LIMIT 0xffff
494#else
495#define IO_SPACE_LIMIT 0x0fffffff
496#endif
497
498#endif /* __KERNEL__ */
499
500#define __ARCH_HAS_NO_PAGE_ZERO_MAPPED 1
501
502/*
503 * Convert a physical pointer to a virtual kernel pointer for /dev/mem
504 * access
505 */
506#define xlate_dev_mem_ptr(p) __va(p)
507
508/*
509 * Convert a virtual cached pointer to an uncached pointer
510 */
511#define xlate_dev_kmem_ptr(p) p
512
Geert Uytterhoevena000dfc2014-09-09 11:32:44 +0200513static inline void __iomem *ioport_map(unsigned long port, unsigned int nr)
514{
515 return (void __iomem *) port;
516}
517
518static inline void ioport_unmap(void __iomem *p)
519{
520}
Greg Ungerere93a6bb2011-11-28 16:32:49 +1000521
Linus Torvalds1da177e2005-04-16 15:20:36 -0700522#endif /* _IO_H */