2 * linux/include/asm-m68k/raw_io.h
4 * 10/20/00 RZ: - created from bits of io.h and ide.h to cleanup namespace
13 #include <asm/byteorder.h>
16 /* Values for nocacheflag and cmode */
17 #define IOMAP_FULL_CACHING 0
18 #define IOMAP_NOCACHE_SER 1
19 #define IOMAP_NOCACHE_NONSER 2
20 #define IOMAP_WRITETHROUGH 3
22 extern void iounmap(void __iomem
*addr
);
24 extern void __iomem
*__ioremap(unsigned long physaddr
, unsigned long size
,
26 extern void __iounmap(void *addr
, unsigned long size
);
29 /* ++roman: The assignments to temp. vars avoid that gcc sometimes generates
30 * two accesses to memory, which may be undesirable for some devices.
33 ({ u8 __v = (*(__force volatile u8 *) (addr)); __v; })
34 #define in_be16(addr) \
35 ({ u16 __v = (*(__force volatile u16 *) (addr)); __v; })
36 #define in_be32(addr) \
37 ({ u32 __v = (*(__force volatile u32 *) (addr)); __v; })
38 #define in_le16(addr) \
39 ({ u16 __v = le16_to_cpu(*(__force volatile __le16 *) (addr)); __v; })
40 #define in_le32(addr) \
41 ({ u32 __v = le32_to_cpu(*(__force volatile __le32 *) (addr)); __v; })
43 #define out_8(addr,b) (void)((*(__force volatile u8 *) (addr)) = (b))
44 #define out_be16(addr,w) (void)((*(__force volatile u16 *) (addr)) = (w))
45 #define out_be32(addr,l) (void)((*(__force volatile u32 *) (addr)) = (l))
46 #define out_le16(addr,w) (void)((*(__force volatile __le16 *) (addr)) = cpu_to_le16(w))
47 #define out_le32(addr,l) (void)((*(__force volatile __le32 *) (addr)) = cpu_to_le32(l))
50 #define raw_inw in_be16
51 #define raw_inl in_be32
52 #define __raw_readb in_8
53 #define __raw_readw in_be16
54 #define __raw_readl in_be32
56 #define raw_outb(val,port) out_8((port),(val))
57 #define raw_outw(val,port) out_be16((port),(val))
58 #define raw_outl(val,port) out_be32((port),(val))
59 #define __raw_writeb(val,addr) out_8((addr),(val))
60 #define __raw_writew(val,addr) out_be16((addr),(val))
61 #define __raw_writel(val,addr) out_be32((addr),(val))
64 * Atari ROM port (cartridge port) ISA adapter, used for the EtherNEC NE2000
65 * network card driver.
66 * The ISA adapter connects address lines A9-A13 to ISA address lines A0-A4,
67 * and hardwires the rest of the ISA addresses for a base address of 0x300.
69 * Data lines D8-D15 are connected to ISA data lines D0-D7 for reading.
70 * For writes, address lines A1-A8 are latched to ISA data lines D0-D7
71 * (meaning the bit pattern on A1-A8 can be read back as byte).
73 * Read and write operations are distinguished by the base address used:
74 * reads are from the ROM A side range, writes are through the B side range
75 * addresses (A side base + 0x10000).
77 * Reads and writes are byte only.
79 * 16 bit reads and writes are necessary for the NetUSBee adapter's USB
80 * chipset - 16 bit words are read straight off the ROM port while 16 bit
81 * reads are split into two byte writes. The low byte is latched to the
82 * NetUSBee buffer by a read from the _read_ window (with the data pattern
83 * asserted as A1-A8 address pattern). The high byte is then written to the
84 * write range as usual, completing the write cycle.
87 #if defined(CONFIG_ATARI_ROM_ISA)
88 #define rom_in_8(addr) \
89 ({ u16 __v = (*(__force volatile u16 *) (addr)); __v >>= 8; __v; })
90 #define rom_in_be16(addr) \
91 ({ u16 __v = (*(__force volatile u16 *) (addr)); __v; })
92 #define rom_in_le16(addr) \
93 ({ u16 __v = le16_to_cpu(*(__force volatile u16 *) (addr)); __v; })
95 #define rom_out_8(addr, b) \
96 ({u8 __w, __v = (b); u32 _addr = ((u32) (addr)); \
97 __w = ((*(__force volatile u8 *) ((_addr | 0x10000) + (__v<<1)))); })
98 #define rom_out_be16(addr, w) \
99 ({u16 __w, __v = (w); u32 _addr = ((u32) (addr)); \
100 __w = ((*(__force volatile u16 *) ((_addr & 0xFFFF0000UL) + ((__v & 0xFF)<<1)))); \
101 __w = ((*(__force volatile u16 *) ((_addr | 0x10000) + ((__v >> 8)<<1)))); })
102 #define rom_out_le16(addr, w) \
103 ({u16 __w, __v = (w); u32 _addr = ((u32) (addr)); \
104 __w = ((*(__force volatile u16 *) ((_addr & 0xFFFF0000UL) + ((__v >> 8)<<1)))); \
105 __w = ((*(__force volatile u16 *) ((_addr | 0x10000) + ((__v & 0xFF)<<1)))); })
107 #define raw_rom_inb rom_in_8
108 #define raw_rom_inw rom_in_be16
110 #define raw_rom_outb(val, port) rom_out_8((port), (val))
111 #define raw_rom_outw(val, port) rom_out_be16((port), (val))
112 #endif /* CONFIG_ATARI_ROM_ISA */
114 static inline void raw_insb(volatile u8 __iomem
*port
, u8
*buf
, unsigned int len
)
118 for (i
= 0; i
< len
; i
++)
122 static inline void raw_outsb(volatile u8 __iomem
*port
, const u8
*buf
,
127 for (i
= 0; i
< len
; i
++)
131 static inline void raw_insw(volatile u16 __iomem
*port
, u16
*buf
, unsigned int nr
)
138 "1: movew %2@,%0@+; dbra %1,1b"
139 : "=a" (buf
), "=d" (tmp
)
140 : "a" (port
), "0" (buf
),
164 : "=a" (buf
), "=d" (tmp
)
165 : "a" (port
), "0" (buf
),
170 static inline void raw_outsw(volatile u16 __iomem
*port
, const u16
*buf
,
178 "1: movew %0@+,%2@; dbra %1,1b"
179 : "=a" (buf
), "=d" (tmp
)
180 : "a" (port
), "0" (buf
),
204 : "=a" (buf
), "=d" (tmp
)
205 : "a" (port
), "0" (buf
),
210 static inline void raw_insl(volatile u32 __iomem
*port
, u32
*buf
, unsigned int nr
)
217 "1: movel %2@,%0@+; dbra %1,1b"
218 : "=a" (buf
), "=d" (tmp
)
219 : "a" (port
), "0" (buf
),
243 : "=a" (buf
), "=d" (tmp
)
244 : "a" (port
), "0" (buf
),
249 static inline void raw_outsl(volatile u32 __iomem
*port
, const u32
*buf
,
257 "1: movel %0@+,%2@; dbra %1,1b"
258 : "=a" (buf
), "=d" (tmp
)
259 : "a" (port
), "0" (buf
),
283 : "=a" (buf
), "=d" (tmp
)
284 : "a" (port
), "0" (buf
),
290 static inline void raw_insw_swapw(volatile u16 __iomem
*port
, u16
*buf
,
295 ("\tmovel %0,%/a0\n\t"
299 "1:\tmovew %/a0@,%/d0\n\t"
301 "movew %/d0,%/a1@+\n\t"
304 : "g" (port
), "g" (buf
), "g" (nr
)
305 : "d0", "a0", "a1", "d6");
313 "1:\tmovew %/a0@,%/d0\n\t"
315 "movew %/d0,%/a1@+\n\t"
316 "movew %/a0@,%/d0\n\t"
318 "movew %/d0,%/a1@+\n\t"
319 "movew %/a0@,%/d0\n\t"
321 "movew %/d0,%/a1@+\n\t"
322 "movew %/a0@,%/d0\n\t"
324 "movew %/d0,%/a1@+\n\t"
325 "movew %/a0@,%/d0\n\t"
327 "movew %/d0,%/a1@+\n\t"
328 "movew %/a0@,%/d0\n\t"
330 "movew %/d0,%/a1@+\n\t"
331 "movew %/a0@,%/d0\n\t"
333 "movew %/d0,%/a1@+\n\t"
334 "movew %/a0@,%/d0\n\t"
336 "movew %/d0,%/a1@+\n\t"
339 : "g" (port
), "g" (buf
), "g" (nr
)
340 : "d0", "a0", "a1", "d6");
343 static inline void raw_outsw_swapw(volatile u16 __iomem
*port
, const u16
*buf
,
352 "1:\tmovew %/a1@+,%/d0\n\t"
354 "movew %/d0,%/a0@\n\t"
357 : "g" (port
), "g" (buf
), "g" (nr
)
358 : "d0", "a0", "a1", "d6");
366 "1:\tmovew %/a1@+,%/d0\n\t"
368 "movew %/d0,%/a0@\n\t"
369 "movew %/a1@+,%/d0\n\t"
371 "movew %/d0,%/a0@\n\t"
372 "movew %/a1@+,%/d0\n\t"
374 "movew %/d0,%/a0@\n\t"
375 "movew %/a1@+,%/d0\n\t"
377 "movew %/d0,%/a0@\n\t"
378 "movew %/a1@+,%/d0\n\t"
380 "movew %/d0,%/a0@\n\t"
381 "movew %/a1@+,%/d0\n\t"
383 "movew %/d0,%/a0@\n\t"
384 "movew %/a1@+,%/d0\n\t"
386 "movew %/d0,%/a0@\n\t"
387 "movew %/a1@+,%/d0\n\t"
389 "movew %/d0,%/a0@\n\t"
392 : "g" (port
), "g" (buf
), "g" (nr
)
393 : "d0", "a0", "a1", "d6");
397 #if defined(CONFIG_ATARI_ROM_ISA)
398 static inline void raw_rom_insb(volatile u8 __iomem
*port
, u8
*buf
, unsigned int len
)
402 for (i
= 0; i
< len
; i
++)
403 *buf
++ = rom_in_8(port
);
406 static inline void raw_rom_outsb(volatile u8 __iomem
*port
, const u8
*buf
,
411 for (i
= 0; i
< len
; i
++)
412 rom_out_8(port
, *buf
++);
415 static inline void raw_rom_insw(volatile u16 __iomem
*port
, u16
*buf
,
420 for (i
= 0; i
< nr
; i
++)
421 *buf
++ = rom_in_be16(port
);
424 static inline void raw_rom_outsw(volatile u16 __iomem
*port
, const u16
*buf
,
429 for (i
= 0; i
< nr
; i
++)
430 rom_out_be16(port
, *buf
++);
433 static inline void raw_rom_insw_swapw(volatile u16 __iomem
*port
, u16
*buf
,
438 for (i
= 0; i
< nr
; i
++)
439 *buf
++ = rom_in_le16(port
);
442 static inline void raw_rom_outsw_swapw(volatile u16 __iomem
*port
, const u16
*buf
,
447 for (i
= 0; i
< nr
; i
++)
448 rom_out_le16(port
, *buf
++);
450 #endif /* CONFIG_ATARI_ROM_ISA */
452 #endif /* __KERNEL__ */
454 #endif /* _RAW_IO_H */