Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 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 Bunk | 2171a19 | 2008-10-13 21:59:00 +0200 | [diff] [blame] | 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 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | * or define its own macros on top of these. |
| 13 | * |
Adrian Bunk | 2171a19 | 2008-10-13 21:59:00 +0200 | [diff] [blame] | 14 | * inX(),outX() are for ISA I/O |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | * isa_readX(),isa_writeX() are for ISA memory |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | */ |
| 17 | |
| 18 | #ifndef _IO_H |
| 19 | #define _IO_H |
| 20 | |
| 21 | #ifdef __KERNEL__ |
| 22 | |
Toshi Kani | 556269c | 2015-06-04 18:55:16 +0200 | [diff] [blame] | 23 | #define ARCH_HAS_IOREMAP_WT |
| 24 | |
Al Viro | ad9ec4f | 2006-01-12 01:06:24 -0800 | [diff] [blame] | 25 | #include <linux/compiler.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | #include <asm/raw_io.h> |
| 27 | #include <asm/virtconvert.h> |
| 28 | |
Al Viro | f9569e1 | 2007-07-20 04:32:58 +0100 | [diff] [blame] | 29 | #include <asm-generic/iomap.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | |
| 31 | #ifdef CONFIG_ATARI |
| 32 | #include <asm/atarihw.h> |
| 33 | #endif |
| 34 | |
| 35 | |
| 36 | /* |
| 37 | * IO/MEM definitions for various ISA bridges |
| 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 /* Q40 */ |
| 53 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 /* AMIGA_PCMCIA */ |
| 67 | |
Michael Schmitz | 84b16b7 | 2013-04-06 13:26:35 +1300 | [diff] [blame] | 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 /* ATARI_ROM_ISA */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | |
| 86 | |
Greg Ungerer | 9ff601a | 2012-06-29 00:03:27 +1000 | [diff] [blame] | 87 | #if defined(CONFIG_PCI) && defined(CONFIG_COLDFIRE) |
| 88 | |
| 89 | #define HAVE_ARCH_PIO_SIZE |
| 90 | #define PIO_OFFSET 0 |
| 91 | #define PIO_MASK 0xffff |
| 92 | #define PIO_RESERVED 0x10000 |
| 93 | |
| 94 | u8 mcf_pci_inb(u32 addr); |
| 95 | u16 mcf_pci_inw(u32 addr); |
| 96 | u32 mcf_pci_inl(u32 addr); |
| 97 | void mcf_pci_insb(u32 addr, u8 *buf, u32 len); |
| 98 | void mcf_pci_insw(u32 addr, u16 *buf, u32 len); |
| 99 | void mcf_pci_insl(u32 addr, u32 *buf, u32 len); |
| 100 | |
| 101 | void mcf_pci_outb(u8 v, u32 addr); |
| 102 | void mcf_pci_outw(u16 v, u32 addr); |
| 103 | void mcf_pci_outl(u32 v, u32 addr); |
| 104 | void mcf_pci_outsb(u32 addr, const u8 *buf, u32 len); |
| 105 | void mcf_pci_outsw(u32 addr, const u16 *buf, u32 len); |
| 106 | void mcf_pci_outsl(u32 addr, const u32 *buf, u32 len); |
| 107 | |
| 108 | #define inb mcf_pci_inb |
| 109 | #define inb_p mcf_pci_inb |
| 110 | #define inw mcf_pci_inw |
| 111 | #define inw_p mcf_pci_inw |
| 112 | #define inl mcf_pci_inl |
| 113 | #define inl_p mcf_pci_inl |
| 114 | #define insb mcf_pci_insb |
| 115 | #define insw mcf_pci_insw |
| 116 | #define insl mcf_pci_insl |
| 117 | |
| 118 | #define outb mcf_pci_outb |
| 119 | #define outb_p mcf_pci_outb |
| 120 | #define outw mcf_pci_outw |
| 121 | #define outw_p mcf_pci_outw |
| 122 | #define outl mcf_pci_outl |
| 123 | #define outl_p mcf_pci_outl |
| 124 | #define outsb mcf_pci_outsb |
| 125 | #define outsw mcf_pci_outsw |
| 126 | #define outsl mcf_pci_outsl |
| 127 | |
| 128 | #define readb(addr) in_8(addr) |
| 129 | #define writeb(v, addr) out_8((addr), (v)) |
| 130 | #define readw(addr) in_le16(addr) |
| 131 | #define writew(v, addr) out_le16((addr), (v)) |
| 132 | |
Michael Schmitz | 84b16b7 | 2013-04-06 13:26:35 +1300 | [diff] [blame] | 133 | #elif defined(CONFIG_ISA) || defined(CONFIG_ATARI_ROM_ISA) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 134 | |
| 135 | #if MULTI_ISA == 0 |
| 136 | #undef MULTI_ISA |
| 137 | #endif |
| 138 | |
Michael Schmitz | 84b16b7 | 2013-04-06 13:26:35 +1300 | [diff] [blame] | 139 | #define ISA_TYPE_Q40 (1) |
| 140 | #define ISA_TYPE_AG (2) |
| 141 | #define ISA_TYPE_ENEC (3) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 142 | |
| 143 | #if defined(CONFIG_Q40) && !defined(MULTI_ISA) |
Geert Uytterhoeven | 52de114 | 2008-05-18 20:47:21 +0200 | [diff] [blame] | 144 | #define ISA_TYPE ISA_TYPE_Q40 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 145 | #define ISA_SEX 0 |
| 146 | #endif |
| 147 | #if defined(CONFIG_AMIGA_PCMCIA) && !defined(MULTI_ISA) |
Geert Uytterhoeven | 52de114 | 2008-05-18 20:47:21 +0200 | [diff] [blame] | 148 | #define ISA_TYPE ISA_TYPE_AG |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 149 | #define ISA_SEX 1 |
| 150 | #endif |
Michael Schmitz | 84b16b7 | 2013-04-06 13:26:35 +1300 | [diff] [blame] | 151 | #if defined(CONFIG_ATARI_ROM_ISA) && !defined(MULTI_ISA) |
| 152 | #define ISA_TYPE ISA_TYPE_ENEC |
| 153 | #define ISA_SEX 0 |
| 154 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 155 | |
| 156 | #ifdef MULTI_ISA |
| 157 | extern int isa_type; |
| 158 | extern int isa_sex; |
| 159 | |
| 160 | #define ISA_TYPE isa_type |
| 161 | #define ISA_SEX isa_sex |
| 162 | #endif |
| 163 | |
| 164 | /* |
| 165 | * define inline addr translation functions. Normally only one variant will |
| 166 | * be compiled in so the case statement will be optimised away |
| 167 | */ |
| 168 | |
Al Viro | ad9ec4f | 2006-01-12 01:06:24 -0800 | [diff] [blame] | 169 | static inline u8 __iomem *isa_itb(unsigned long addr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 170 | { |
| 171 | switch(ISA_TYPE) |
| 172 | { |
| 173 | #ifdef CONFIG_Q40 |
Geert Uytterhoeven | 52de114 | 2008-05-18 20:47:21 +0200 | [diff] [blame] | 174 | case ISA_TYPE_Q40: return (u8 __iomem *)Q40_ISA_IO_B(addr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 175 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 176 | #ifdef CONFIG_AMIGA_PCMCIA |
Geert Uytterhoeven | 52de114 | 2008-05-18 20:47:21 +0200 | [diff] [blame] | 177 | case ISA_TYPE_AG: return (u8 __iomem *)AG_ISA_IO_B(addr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 178 | #endif |
Michael Schmitz | 84b16b7 | 2013-04-06 13:26:35 +1300 | [diff] [blame] | 179 | #ifdef CONFIG_ATARI_ROM_ISA |
| 180 | case ISA_TYPE_ENEC: return (u8 __iomem *)ENEC_ISA_IO_B(addr); |
| 181 | #endif |
Al Viro | ad9ec4f | 2006-01-12 01:06:24 -0800 | [diff] [blame] | 182 | default: return NULL; /* avoid warnings, just in case */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 183 | } |
| 184 | } |
Al Viro | ad9ec4f | 2006-01-12 01:06:24 -0800 | [diff] [blame] | 185 | static inline u16 __iomem *isa_itw(unsigned long addr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 186 | { |
| 187 | switch(ISA_TYPE) |
| 188 | { |
| 189 | #ifdef CONFIG_Q40 |
Geert Uytterhoeven | 52de114 | 2008-05-18 20:47:21 +0200 | [diff] [blame] | 190 | case ISA_TYPE_Q40: return (u16 __iomem *)Q40_ISA_IO_W(addr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 191 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 192 | #ifdef CONFIG_AMIGA_PCMCIA |
Geert Uytterhoeven | 52de114 | 2008-05-18 20:47:21 +0200 | [diff] [blame] | 193 | case ISA_TYPE_AG: return (u16 __iomem *)AG_ISA_IO_W(addr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 194 | #endif |
Michael Schmitz | 84b16b7 | 2013-04-06 13:26:35 +1300 | [diff] [blame] | 195 | #ifdef CONFIG_ATARI_ROM_ISA |
| 196 | case ISA_TYPE_ENEC: return (u16 __iomem *)ENEC_ISA_IO_W(addr); |
| 197 | #endif |
Al Viro | ad9ec4f | 2006-01-12 01:06:24 -0800 | [diff] [blame] | 198 | default: return NULL; /* avoid warnings, just in case */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 199 | } |
| 200 | } |
Al Viro | f9569e1 | 2007-07-20 04:32:58 +0100 | [diff] [blame] | 201 | static inline u32 __iomem *isa_itl(unsigned long addr) |
| 202 | { |
| 203 | switch(ISA_TYPE) |
| 204 | { |
| 205 | #ifdef CONFIG_AMIGA_PCMCIA |
Geert Uytterhoeven | 52de114 | 2008-05-18 20:47:21 +0200 | [diff] [blame] | 206 | case ISA_TYPE_AG: return (u32 __iomem *)AG_ISA_IO_W(addr); |
Al Viro | f9569e1 | 2007-07-20 04:32:58 +0100 | [diff] [blame] | 207 | #endif |
| 208 | default: return 0; /* avoid warnings, just in case */ |
| 209 | } |
| 210 | } |
Al Viro | ad9ec4f | 2006-01-12 01:06:24 -0800 | [diff] [blame] | 211 | static inline u8 __iomem *isa_mtb(unsigned long addr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 212 | { |
| 213 | switch(ISA_TYPE) |
| 214 | { |
| 215 | #ifdef CONFIG_Q40 |
Geert Uytterhoeven | 52de114 | 2008-05-18 20:47:21 +0200 | [diff] [blame] | 216 | case ISA_TYPE_Q40: return (u8 __iomem *)Q40_ISA_MEM_B(addr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 217 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 218 | #ifdef CONFIG_AMIGA_PCMCIA |
Geert Uytterhoeven | 52de114 | 2008-05-18 20:47:21 +0200 | [diff] [blame] | 219 | case ISA_TYPE_AG: return (u8 __iomem *)addr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 220 | #endif |
Michael Schmitz | 84b16b7 | 2013-04-06 13:26:35 +1300 | [diff] [blame] | 221 | #ifdef CONFIG_ATARI_ROM_ISA |
| 222 | case ISA_TYPE_ENEC: return (u8 __iomem *)ENEC_ISA_MEM_B(addr); |
| 223 | #endif |
Al Viro | ad9ec4f | 2006-01-12 01:06:24 -0800 | [diff] [blame] | 224 | default: return NULL; /* avoid warnings, just in case */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 225 | } |
| 226 | } |
Al Viro | ad9ec4f | 2006-01-12 01:06:24 -0800 | [diff] [blame] | 227 | static inline u16 __iomem *isa_mtw(unsigned long addr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 228 | { |
| 229 | switch(ISA_TYPE) |
| 230 | { |
| 231 | #ifdef CONFIG_Q40 |
Geert Uytterhoeven | 52de114 | 2008-05-18 20:47:21 +0200 | [diff] [blame] | 232 | case ISA_TYPE_Q40: return (u16 __iomem *)Q40_ISA_MEM_W(addr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 233 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 234 | #ifdef CONFIG_AMIGA_PCMCIA |
Geert Uytterhoeven | 52de114 | 2008-05-18 20:47:21 +0200 | [diff] [blame] | 235 | case ISA_TYPE_AG: return (u16 __iomem *)addr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 236 | #endif |
Michael Schmitz | 84b16b7 | 2013-04-06 13:26:35 +1300 | [diff] [blame] | 237 | #ifdef CONFIG_ATARI_ROM_ISA |
| 238 | case ISA_TYPE_ENEC: return (u16 __iomem *)ENEC_ISA_MEM_W(addr); |
| 239 | #endif |
Al Viro | ad9ec4f | 2006-01-12 01:06:24 -0800 | [diff] [blame] | 240 | default: return NULL; /* avoid warnings, just in case */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 241 | } |
| 242 | } |
| 243 | |
| 244 | |
| 245 | #define isa_inb(port) in_8(isa_itb(port)) |
| 246 | #define isa_inw(port) (ISA_SEX ? in_be16(isa_itw(port)) : in_le16(isa_itw(port))) |
Al Viro | f9569e1 | 2007-07-20 04:32:58 +0100 | [diff] [blame] | 247 | #define isa_inl(port) (ISA_SEX ? in_be32(isa_itl(port)) : in_le32(isa_itl(port))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 248 | #define isa_outb(val,port) out_8(isa_itb(port),(val)) |
| 249 | #define isa_outw(val,port) (ISA_SEX ? out_be16(isa_itw(port),(val)) : out_le16(isa_itw(port),(val))) |
Al Viro | f9569e1 | 2007-07-20 04:32:58 +0100 | [diff] [blame] | 250 | #define isa_outl(val,port) (ISA_SEX ? out_be32(isa_itl(port),(val)) : out_le32(isa_itl(port),(val))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 251 | |
| 252 | #define isa_readb(p) in_8(isa_mtb((unsigned long)(p))) |
| 253 | #define isa_readw(p) \ |
| 254 | (ISA_SEX ? in_be16(isa_mtw((unsigned long)(p))) \ |
| 255 | : in_le16(isa_mtw((unsigned long)(p)))) |
| 256 | #define isa_writeb(val,p) out_8(isa_mtb((unsigned long)(p)),(val)) |
| 257 | #define isa_writew(val,p) \ |
| 258 | (ISA_SEX ? out_be16(isa_mtw((unsigned long)(p)),(val)) \ |
| 259 | : out_le16(isa_mtw((unsigned long)(p)),(val))) |
| 260 | |
Michael Schmitz | 84b16b7 | 2013-04-06 13:26:35 +1300 | [diff] [blame] | 261 | #ifdef CONFIG_ATARI_ROM_ISA |
| 262 | #define isa_rom_inb(port) rom_in_8(isa_itb(port)) |
| 263 | #define isa_rom_inw(port) \ |
| 264 | (ISA_SEX ? rom_in_be16(isa_itw(port)) \ |
| 265 | : rom_in_le16(isa_itw(port))) |
| 266 | |
| 267 | #define isa_rom_outb(val, port) rom_out_8(isa_itb(port), (val)) |
| 268 | #define isa_rom_outw(val, port) \ |
| 269 | (ISA_SEX ? rom_out_be16(isa_itw(port), (val)) \ |
| 270 | : rom_out_le16(isa_itw(port), (val))) |
| 271 | |
| 272 | #define isa_rom_readb(p) rom_in_8(isa_mtb((unsigned long)(p))) |
| 273 | #define isa_rom_readw(p) \ |
| 274 | (ISA_SEX ? rom_in_be16(isa_mtw((unsigned long)(p))) \ |
| 275 | : rom_in_le16(isa_mtw((unsigned long)(p)))) |
| 276 | #define isa_rom_readw_swap(p) \ |
| 277 | (ISA_SEX ? rom_in_le16(isa_mtw((unsigned long)(p))) \ |
| 278 | : rom_in_be16(isa_mtw((unsigned long)(p)))) |
| 279 | #define isa_rom_readw_raw(p) rom_in_be16(isa_mtw((unsigned long)(p))) |
| 280 | |
| 281 | #define isa_rom_writeb(val, p) rom_out_8(isa_mtb((unsigned long)(p)), (val)) |
| 282 | #define isa_rom_writew(val, p) \ |
| 283 | (ISA_SEX ? rom_out_be16(isa_mtw((unsigned long)(p)), (val)) \ |
| 284 | : rom_out_le16(isa_mtw((unsigned long)(p)), (val))) |
| 285 | #define isa_rom_writew_swap(val, p) \ |
| 286 | (ISA_SEX ? rom_out_le16(isa_mtw((unsigned long)(p)), (val)) \ |
| 287 | : rom_out_be16(isa_mtw((unsigned long)(p)), (val))) |
| 288 | #define isa_rom_writew_raw(val, p) rom_out_be16(isa_mtw((unsigned long)(p)), (val)) |
| 289 | #endif /* CONFIG_ATARI_ROM_ISA */ |
| 290 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 291 | static inline void isa_delay(void) |
| 292 | { |
| 293 | switch(ISA_TYPE) |
| 294 | { |
| 295 | #ifdef CONFIG_Q40 |
Geert Uytterhoeven | 52de114 | 2008-05-18 20:47:21 +0200 | [diff] [blame] | 296 | case ISA_TYPE_Q40: isa_outb(0,0x80); break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 297 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 298 | #ifdef CONFIG_AMIGA_PCMCIA |
Geert Uytterhoeven | 52de114 | 2008-05-18 20:47:21 +0200 | [diff] [blame] | 299 | case ISA_TYPE_AG: break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 300 | #endif |
Michael Schmitz | 84b16b7 | 2013-04-06 13:26:35 +1300 | [diff] [blame] | 301 | #ifdef CONFIG_ATARI_ROM_ISA |
| 302 | case ISA_TYPE_ENEC: break; |
| 303 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 304 | default: break; /* avoid warnings */ |
| 305 | } |
| 306 | } |
| 307 | |
| 308 | #define isa_inb_p(p) ({u8 v=isa_inb(p);isa_delay();v;}) |
| 309 | #define isa_outb_p(v,p) ({isa_outb((v),(p));isa_delay();}) |
| 310 | #define isa_inw_p(p) ({u16 v=isa_inw(p);isa_delay();v;}) |
| 311 | #define isa_outw_p(v,p) ({isa_outw((v),(p));isa_delay();}) |
| 312 | #define isa_inl_p(p) ({u32 v=isa_inl(p);isa_delay();v;}) |
| 313 | #define isa_outl_p(v,p) ({isa_outl((v),(p));isa_delay();}) |
| 314 | |
| 315 | #define isa_insb(port, buf, nr) raw_insb(isa_itb(port), (u8 *)(buf), (nr)) |
| 316 | #define isa_outsb(port, buf, nr) raw_outsb(isa_itb(port), (u8 *)(buf), (nr)) |
| 317 | |
| 318 | #define isa_insw(port, buf, nr) \ |
| 319 | (ISA_SEX ? raw_insw(isa_itw(port), (u16 *)(buf), (nr)) : \ |
| 320 | raw_insw_swapw(isa_itw(port), (u16 *)(buf), (nr))) |
| 321 | |
| 322 | #define isa_outsw(port, buf, nr) \ |
| 323 | (ISA_SEX ? raw_outsw(isa_itw(port), (u16 *)(buf), (nr)) : \ |
| 324 | raw_outsw_swapw(isa_itw(port), (u16 *)(buf), (nr))) |
Al Viro | f9569e1 | 2007-07-20 04:32:58 +0100 | [diff] [blame] | 325 | |
| 326 | #define isa_insl(port, buf, nr) \ |
| 327 | (ISA_SEX ? raw_insl(isa_itl(port), (u32 *)(buf), (nr)) : \ |
| 328 | raw_insw_swapw(isa_itw(port), (u16 *)(buf), (nr)<<1)) |
| 329 | |
| 330 | #define isa_outsl(port, buf, nr) \ |
| 331 | (ISA_SEX ? raw_outsl(isa_itl(port), (u32 *)(buf), (nr)) : \ |
| 332 | raw_outsw_swapw(isa_itw(port), (u16 *)(buf), (nr)<<1)) |
| 333 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 334 | |
Michael Schmitz | 84b16b7 | 2013-04-06 13:26:35 +1300 | [diff] [blame] | 335 | #ifdef CONFIG_ATARI_ROM_ISA |
| 336 | #define isa_rom_inb_p(p) ({ u8 _v = isa_rom_inb(p); isa_delay(); _v; }) |
| 337 | #define isa_rom_inw_p(p) ({ u16 _v = isa_rom_inw(p); isa_delay(); _v; }) |
| 338 | #define isa_rom_outb_p(v, p) ({ isa_rom_outb((v), (p)); isa_delay(); }) |
| 339 | #define isa_rom_outw_p(v, p) ({ isa_rom_outw((v), (p)); isa_delay(); }) |
| 340 | |
| 341 | #define isa_rom_insb(port, buf, nr) raw_rom_insb(isa_itb(port), (u8 *)(buf), (nr)) |
| 342 | |
| 343 | #define isa_rom_insw(port, buf, nr) \ |
| 344 | (ISA_SEX ? raw_rom_insw(isa_itw(port), (u16 *)(buf), (nr)) : \ |
| 345 | raw_rom_insw_swapw(isa_itw(port), (u16 *)(buf), (nr))) |
| 346 | |
| 347 | #define isa_rom_outsb(port, buf, nr) raw_rom_outsb(isa_itb(port), (u8 *)(buf), (nr)) |
| 348 | |
| 349 | #define isa_rom_outsw(port, buf, nr) \ |
| 350 | (ISA_SEX ? raw_rom_outsw(isa_itw(port), (u16 *)(buf), (nr)) : \ |
| 351 | raw_rom_outsw_swapw(isa_itw(port), (u16 *)(buf), (nr))) |
| 352 | #endif /* CONFIG_ATARI_ROM_ISA */ |
| 353 | |
| 354 | #endif /* CONFIG_ISA || CONFIG_ATARI_ROM_ISA */ |
| 355 | |
| 356 | |
| 357 | #if defined(CONFIG_ISA) && !defined(CONFIG_ATARI_ROM_ISA) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 358 | #define inb isa_inb |
| 359 | #define inb_p isa_inb_p |
| 360 | #define outb isa_outb |
| 361 | #define outb_p isa_outb_p |
| 362 | #define inw isa_inw |
| 363 | #define inw_p isa_inw_p |
| 364 | #define outw isa_outw |
| 365 | #define outw_p isa_outw_p |
Al Viro | f9569e1 | 2007-07-20 04:32:58 +0100 | [diff] [blame] | 366 | #define inl isa_inl |
| 367 | #define inl_p isa_inl_p |
| 368 | #define outl isa_outl |
| 369 | #define outl_p isa_outl_p |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 370 | #define insb isa_insb |
| 371 | #define insw isa_insw |
Al Viro | f9569e1 | 2007-07-20 04:32:58 +0100 | [diff] [blame] | 372 | #define insl isa_insl |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 373 | #define outsb isa_outsb |
| 374 | #define outsw isa_outsw |
Al Viro | f9569e1 | 2007-07-20 04:32:58 +0100 | [diff] [blame] | 375 | #define outsl isa_outsl |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 376 | #define readb isa_readb |
| 377 | #define readw isa_readw |
| 378 | #define writeb isa_writeb |
| 379 | #define writew isa_writew |
Michael Schmitz | 84b16b7 | 2013-04-06 13:26:35 +1300 | [diff] [blame] | 380 | #endif /* CONFIG_ISA && !CONFIG_ATARI_ROM_ISA */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 381 | |
Michael Schmitz | 84b16b7 | 2013-04-06 13:26:35 +1300 | [diff] [blame] | 382 | #ifdef CONFIG_ATARI_ROM_ISA |
| 383 | /* |
| 384 | * kernel with both ROM port ISA and IDE compiled in, those have |
| 385 | * conflicting defs for in/out. Simply consider port < 1024 |
| 386 | * ROM port ISA and everything else regular ISA for IDE. read,write defined |
| 387 | * below. |
| 388 | */ |
| 389 | #define inb(port) ((port) < 1024 ? isa_rom_inb(port) : in_8(port)) |
| 390 | #define inb_p(port) ((port) < 1024 ? isa_rom_inb_p(port) : in_8(port)) |
| 391 | #define inw(port) ((port) < 1024 ? isa_rom_inw(port) : in_le16(port)) |
| 392 | #define inw_p(port) ((port) < 1024 ? isa_rom_inw_p(port) : in_le16(port)) |
| 393 | #define inl isa_inl |
| 394 | #define inl_p isa_inl_p |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 395 | |
Michael Schmitz | 84b16b7 | 2013-04-06 13:26:35 +1300 | [diff] [blame] | 396 | #define outb(val, port) ((port) < 1024 ? isa_rom_outb((val), (port)) : out_8((port), (val))) |
| 397 | #define outb_p(val, port) ((port) < 1024 ? isa_rom_outb_p((val), (port)) : out_8((port), (val))) |
| 398 | #define outw(val, port) ((port) < 1024 ? isa_rom_outw((val), (port)) : out_le16((port), (val))) |
| 399 | #define outw_p(val, port) ((port) < 1024 ? isa_rom_outw_p((val), (port)) : out_le16((port), (val))) |
| 400 | #define outl isa_outl |
| 401 | #define outl_p isa_outl_p |
| 402 | |
| 403 | #define insb(port, buf, nr) ((port) < 1024 ? isa_rom_insb((port), (buf), (nr)) : isa_insb((port), (buf), (nr))) |
| 404 | #define insw(port, buf, nr) ((port) < 1024 ? isa_rom_insw((port), (buf), (nr)) : isa_insw((port), (buf), (nr))) |
| 405 | #define insl isa_insl |
| 406 | #define outsb(port, buf, nr) ((port) < 1024 ? isa_rom_outsb((port), (buf), (nr)) : isa_outsb((port), (buf), (nr))) |
| 407 | #define outsw(port, buf, nr) ((port) < 1024 ? isa_rom_outsw((port), (buf), (nr)) : isa_outsw((port), (buf), (nr))) |
| 408 | #define outsl isa_outsl |
| 409 | |
| 410 | #define readb(addr) in_8(addr) |
| 411 | #define writeb(val, addr) out_8((addr), (val)) |
| 412 | #define readw(addr) in_le16(addr) |
| 413 | #define writew(val, addr) out_le16((addr), (val)) |
| 414 | #endif /* CONFIG_ATARI_ROM_ISA */ |
| 415 | |
Greg Ungerer | 03aa29f | 2015-07-08 16:54:13 +1000 | [diff] [blame^] | 416 | #if !defined(CONFIG_ISA) && !defined(CONFIG_ATARI_ROM_ISA) && \ |
| 417 | !(defined(CONFIG_PCI) && defined(CONFIG_COLDFIRE)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 418 | /* |
Al Viro | f9569e1 | 2007-07-20 04:32:58 +0100 | [diff] [blame] | 419 | * We need to define dummy functions for GENERIC_IOMAP support. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 420 | */ |
Al Viro | f9569e1 | 2007-07-20 04:32:58 +0100 | [diff] [blame] | 421 | #define inb(port) 0xff |
| 422 | #define inb_p(port) 0xff |
| 423 | #define outb(val,port) ((void)0) |
| 424 | #define outb_p(val,port) ((void)0) |
| 425 | #define inw(port) 0xffff |
Thorsten Glaser | 779b7e6 | 2010-10-03 18:48:51 +0000 | [diff] [blame] | 426 | #define inw_p(port) 0xffff |
Al Viro | f9569e1 | 2007-07-20 04:32:58 +0100 | [diff] [blame] | 427 | #define outw(val,port) ((void)0) |
Thorsten Glaser | 779b7e6 | 2010-10-03 18:48:51 +0000 | [diff] [blame] | 428 | #define outw_p(val,port) ((void)0) |
Al Viro | f9569e1 | 2007-07-20 04:32:58 +0100 | [diff] [blame] | 429 | #define inl(port) 0xffffffffUL |
Thorsten Glaser | 779b7e6 | 2010-10-03 18:48:51 +0000 | [diff] [blame] | 430 | #define inl_p(port) 0xffffffffUL |
Al Viro | f9569e1 | 2007-07-20 04:32:58 +0100 | [diff] [blame] | 431 | #define outl(val,port) ((void)0) |
Thorsten Glaser | 779b7e6 | 2010-10-03 18:48:51 +0000 | [diff] [blame] | 432 | #define outl_p(val,port) ((void)0) |
Al Viro | f9569e1 | 2007-07-20 04:32:58 +0100 | [diff] [blame] | 433 | |
| 434 | #define insb(port,buf,nr) ((void)0) |
| 435 | #define outsb(port,buf,nr) ((void)0) |
| 436 | #define insw(port,buf,nr) ((void)0) |
| 437 | #define outsw(port,buf,nr) ((void)0) |
| 438 | #define insl(port,buf,nr) ((void)0) |
| 439 | #define outsl(port,buf,nr) ((void)0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 440 | |
| 441 | /* |
| 442 | * These should be valid on any ioremap()ed region |
| 443 | */ |
| 444 | #define readb(addr) in_8(addr) |
| 445 | #define writeb(val,addr) out_8((addr),(val)) |
Al Viro | f9569e1 | 2007-07-20 04:32:58 +0100 | [diff] [blame] | 446 | #define readw(addr) in_le16(addr) |
| 447 | #define writew(val,addr) out_le16((addr),(val)) |
Adrian Bunk | 2171a19 | 2008-10-13 21:59:00 +0200 | [diff] [blame] | 448 | |
Michael Schmitz | 84b16b7 | 2013-04-06 13:26:35 +1300 | [diff] [blame] | 449 | #endif /* !CONFIG_ISA && !CONFIG_ATARI_ROM_ISA */ |
Adrian Bunk | 2171a19 | 2008-10-13 21:59:00 +0200 | [diff] [blame] | 450 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 451 | #define readl(addr) in_le32(addr) |
| 452 | #define writel(val,addr) out_le32((addr),(val)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 453 | |
Geert Uytterhoeven | f5db9c6a | 2012-04-15 20:37:39 +0200 | [diff] [blame] | 454 | #define readsb(port, buf, nr) raw_insb((port), (u8 *)(buf), (nr)) |
| 455 | #define readsw(port, buf, nr) raw_insw((port), (u16 *)(buf), (nr)) |
| 456 | #define readsl(port, buf, nr) raw_insl((port), (u32 *)(buf), (nr)) |
| 457 | #define writesb(port, buf, nr) raw_outsb((port), (u8 *)(buf), (nr)) |
| 458 | #define writesw(port, buf, nr) raw_outsw((port), (u16 *)(buf), (nr)) |
| 459 | #define writesl(port, buf, nr) raw_outsl((port), (u32 *)(buf), (nr)) |
| 460 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 461 | #define mmiowb() |
| 462 | |
Al Viro | ad9ec4f | 2006-01-12 01:06:24 -0800 | [diff] [blame] | 463 | static inline void __iomem *ioremap(unsigned long physaddr, unsigned long size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 464 | { |
| 465 | return __ioremap(physaddr, size, IOMAP_NOCACHE_SER); |
| 466 | } |
Al Viro | ad9ec4f | 2006-01-12 01:06:24 -0800 | [diff] [blame] | 467 | static inline void __iomem *ioremap_nocache(unsigned long physaddr, unsigned long size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 468 | { |
| 469 | return __ioremap(physaddr, size, IOMAP_NOCACHE_SER); |
| 470 | } |
Toshi Kani | 556269c | 2015-06-04 18:55:16 +0200 | [diff] [blame] | 471 | static inline void __iomem *ioremap_wt(unsigned long physaddr, |
| 472 | unsigned long size) |
| 473 | { |
| 474 | return __ioremap(physaddr, size, IOMAP_WRITETHROUGH); |
| 475 | } |
Al Viro | ad9ec4f | 2006-01-12 01:06:24 -0800 | [diff] [blame] | 476 | static inline void __iomem *ioremap_fullcache(unsigned long physaddr, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 477 | unsigned long size) |
| 478 | { |
| 479 | return __ioremap(physaddr, size, IOMAP_FULL_CACHING); |
| 480 | } |
| 481 | |
Al Viro | f9569e1 | 2007-07-20 04:32:58 +0100 | [diff] [blame] | 482 | static inline void memset_io(volatile void __iomem *addr, unsigned char val, int count) |
| 483 | { |
| 484 | __builtin_memset((void __force *) addr, val, count); |
| 485 | } |
| 486 | static inline void memcpy_fromio(void *dst, const volatile void __iomem *src, int count) |
| 487 | { |
| 488 | __builtin_memcpy(dst, (void __force *) src, count); |
| 489 | } |
| 490 | static inline void memcpy_toio(volatile void __iomem *dst, const void *src, int count) |
| 491 | { |
| 492 | __builtin_memcpy((void __force *) dst, src, count); |
| 493 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 494 | |
| 495 | #ifndef CONFIG_SUN3 |
| 496 | #define IO_SPACE_LIMIT 0xffff |
| 497 | #else |
| 498 | #define IO_SPACE_LIMIT 0x0fffffff |
| 499 | #endif |
| 500 | |
| 501 | #endif /* __KERNEL__ */ |
| 502 | |
| 503 | #define __ARCH_HAS_NO_PAGE_ZERO_MAPPED 1 |
| 504 | |
| 505 | /* |
| 506 | * Convert a physical pointer to a virtual kernel pointer for /dev/mem |
| 507 | * access |
| 508 | */ |
| 509 | #define xlate_dev_mem_ptr(p) __va(p) |
| 510 | |
| 511 | /* |
| 512 | * Convert a virtual cached pointer to an uncached pointer |
| 513 | */ |
| 514 | #define xlate_dev_kmem_ptr(p) p |
| 515 | |
Geert Uytterhoeven | a000dfc | 2014-09-09 11:32:44 +0200 | [diff] [blame] | 516 | static inline void __iomem *ioport_map(unsigned long port, unsigned int nr) |
| 517 | { |
| 518 | return (void __iomem *) port; |
| 519 | } |
| 520 | |
| 521 | static inline void ioport_unmap(void __iomem *p) |
| 522 | { |
| 523 | } |
Greg Ungerer | e93a6bb | 2011-11-28 16:32:49 +1000 | [diff] [blame] | 524 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 525 | #endif /* _IO_H */ |