4 * Copyright (C) 2004-2007 Freescale Semiconductor, Inc.
5 * TsiChung Liew (Tsi-Chung.Liew@freescale.com)
7 * See file CREDITS for list of people who contributed to this
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License as
12 * published by the Free Software Foundation; either version 2 of
13 * the License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
26 #ifndef __ASM_M68K_IO_H__
27 #define __ASM_M68K_IO_H__
29 #include <asm/byteorder.h>
31 #define readb(addr) in_8((volatile u8 *)(addr))
32 #define writeb(b,addr) out_8((volatile u8 *)(addr), (b))
33 #if !defined(__BIG_ENDIAN)
34 #define readw(addr) (*(volatile u16 *) (addr))
35 #define readl(addr) (*(volatile u32 *) (addr))
36 #define writew(b,addr) ((*(volatile u16 *) (addr)) = (b))
37 #define writel(b,addr) ((*(volatile u32 *) (addr)) = (b))
39 #define readw(addr) in_le16((volatile u16 *)(addr))
40 #define readl(addr) in_le32((volatile u32 *)(addr))
41 #define writew(b,addr) out_le16((volatile u16 *)(addr),(b))
42 #define writel(b,addr) out_le32((volatile u32 *)(addr),(b))
46 * The insw/outsw/insl/outsl macros don't do byte-swapping.
47 * They are only used in practice for transferring buffers which
48 * are arrays of bytes, and byte-swapping is not appropriate in
51 #define insb(port, buf, ns) _insb((u8 *)((port)+_IO_BASE), (buf), (ns))
52 #define outsb(port, buf, ns) _outsb((u8 *)((port)+_IO_BASE), (buf), (ns))
53 #define insw(port, buf, ns) _insw_ns((u16 *)((port)+_IO_BASE), (buf), (ns))
54 #define outsw(port, buf, ns) _outsw_ns((u16 *)((port)+_IO_BASE), (buf), (ns))
55 #define insl(port, buf, nl) _insl_ns((u32 *)((port)+_IO_BASE), (buf), (nl))
56 #define outsl(port, buf, nl) _outsl_ns((u32 *)((port)+_IO_BASE), (buf), (nl))
58 #define inb(port) in_8((u8 *)((port)+_IO_BASE))
59 #define outb(val, port) out_8((u8 *)((port)+_IO_BASE), (val))
60 #if !defined(__BIG_ENDIAN)
61 #define inw(port) in_be16((u16 *)((port)+_IO_BASE))
62 #define outw(val, port) out_be16((u16 *)((port)+_IO_BASE), (val))
63 #define inl(port) in_be32((u32 *)((port)+_IO_BASE))
64 #define outl(val, port) out_be32((u32 *)((port)+_IO_BASE), (val))
66 #define inw(port) in_le16((u16 *)((port)+_IO_BASE))
67 #define outw(val, port) out_le16((u16 *)((port)+_IO_BASE), (val))
68 #define inl(port) in_le32((u32 *)((port)+_IO_BASE))
69 #define outl(val, port) out_le32((u32 *)((port)+_IO_BASE), (val))
72 extern inline void _insb(volatile u8 * port, void *buf, int ns)
74 u8 *data = (u8 *) buf;
79 extern inline void _outsb(volatile u8 * port, const void *buf, int ns)
81 u8 *data = (u8 *) buf;
86 extern inline void _insw(volatile u16 * port, void *buf, int ns)
88 u16 *data = (u16 *) buf;
90 *data++ = __sw16(*port);
93 extern inline void _outsw(volatile u16 * port, const void *buf, int ns)
95 u16 *data = (u16 *) buf;
97 *port = __sw16(*data);
102 extern inline void _insl(volatile u32 * port, void *buf, int nl)
104 u32 *data = (u32 *) buf;
106 *data++ = __sw32(*port);
109 extern inline void _outsl(volatile u32 * port, const void *buf, int nl)
111 u32 *data = (u32 *) buf;
113 *port = __sw32(*data);
118 extern inline void _insw_ns(volatile u16 * port, void *buf, int ns)
120 u16 *data = (u16 *) buf;
125 extern inline void _outsw_ns(volatile u16 * port, const void *buf, int ns)
127 u16 *data = (u16 *) buf;
133 extern inline void _insl_ns(volatile u32 * port, void *buf, int nl)
135 u32 *data = (u32 *) buf;
140 extern inline void _outsl_ns(volatile u32 * port, const void *buf, int nl)
142 u32 *data = (u32 *) buf;
150 * The *_ns versions below don't do byte-swapping.
151 * Neither do the standard versions now, these are just here
154 #define insw_ns(port, buf, ns) _insw_ns((u16 *)((port)+_IO_BASE), (buf), (ns))
155 #define outsw_ns(port, buf, ns) _outsw_ns((u16 *)((port)+_IO_BASE), (buf), (ns))
156 #define insl_ns(port, buf, nl) _insl_ns((u32 *)((port)+_IO_BASE), (buf), (nl))
157 #define outsl_ns(port, buf, nl) _outsl_ns((u32 *)((port)+_IO_BASE), (buf), (nl))
159 #define IO_SPACE_LIMIT ~0
162 * 8, 16 and 32 bit, big and little endian I/O operations, with barrier.
164 extern inline int in_8(volatile u8 * addr)
169 extern inline void out_8(volatile u8 * addr, int val)
174 extern inline int in_le16(volatile u16 * addr)
176 return __sw16(*addr);
179 extern inline int in_be16(volatile u16 * addr)
181 return (*addr & 0xFFFF);
184 extern inline void out_le16(volatile u16 * addr, int val)
189 extern inline void out_be16(volatile u16 * addr, int val)
194 extern inline unsigned in_le32(volatile u32 * addr)
196 return __sw32(*addr);
199 extern inline unsigned in_be32(volatile u32 * addr)
204 extern inline void out_le32(volatile unsigned *addr, int val)
209 extern inline void out_be32(volatile unsigned *addr, int val)
214 #endif /* __ASM_M68K_IO_H__ */