Root/target/linux/coldfire/files-2.6.31/arch/m68k/include/asm/cf_raw_io.h

1/*
2 * linux/include/asm-m68k/cf_raw_io.h
3 *
4 * Copyright 2007-2009 Freescale Semiconductor, Inc. All Rights Reserved.
5 * 09/30/08 JKM: split Coldfire pieces into separate file
6 */
7#ifndef __CF_RAW_IO__
8#define __CF_RAW_IO__
9
10#ifdef __KERNEL__
11
12#include <asm/types.h>
13
14/* Values for nocacheflag and cmode */
15#define IOMAP_FULL_CACHING 0
16#define IOMAP_NOCACHE_SER 1
17#define IOMAP_NOCACHE_NONSER 2
18#define IOMAP_WRITETHROUGH 3
19
20extern void iounmap(void __iomem *addr);
21
22extern void __iomem *__ioremap(unsigned long physaddr, unsigned long size,
23               int cacheflag);
24extern void __iounmap(void *addr, unsigned long size);
25
26
27/* ++roman: The assignments to temp. vars avoid that gcc sometimes generates
28 * two accesses to memory, which may be undesirable for some devices.
29 */
30#define in_8(addr) \
31    ({ u8 __v = (*(__force volatile u8 *) (addr)); __v; })
32#define in_be16(addr) \
33    ({ u16 __v = (*(__force volatile u16 *) (addr)); __v; })
34#define in_be32(addr) \
35    ({ u32 __v = (*(__force volatile u32 *) (addr)); __v; })
36#define in_le16(addr) \
37    ({ u16 __v = le16_to_cpu(*(__force volatile __le16 *) (addr)); __v; })
38#define in_le32(addr) \
39    ({ u32 __v = le32_to_cpu(*(__force volatile __le32 *) (addr)); __v; })
40
41#define out_8(addr,b) (void)((*(__force volatile u8 *) (addr)) = (b))
42#define out_be16(addr,w) (void)((*(__force volatile u16 *) (addr)) = (w))
43#define out_be32(addr,l) (void)((*(__force volatile u32 *) (addr)) = (l))
44#define out_le16(addr,w) (void)((*(__force volatile __le16 *) (addr)) = cpu_to_le16(w))
45#define out_le32(addr,l) (void)((*(__force volatile __le32 *) (addr)) = cpu_to_le32(l))
46
47
48#ifdef CONFIG_PCI
49/* pci */
50unsigned char pci_inb(long addr);
51unsigned short pci_inw(long addr);
52unsigned long pci_inl(long addr);
53
54void pci_outb(unsigned char val, long addr);
55void pci_outw(unsigned short val, long addr);
56void pci_outl(unsigned long val, long addr);
57
58void pci_insb(volatile unsigned char *addr,
59        unsigned char *buf, int len);
60void pci_insw(volatile unsigned short *addr,
61        unsigned short *buf, int len);
62void pci_insl(volatile unsigned long *addr,
63        unsigned long *buf, int len);
64
65void pci_outsb(volatile unsigned char *addr,
66        const unsigned char *buf, int len);
67void pci_outsw(volatile unsigned short *addr,
68        const unsigned short *buf, int len);
69void pci_outsl(volatile unsigned long *addr,
70        const unsigned long *buf, int len);
71
72unsigned short pci_raw_inw(long addr);
73unsigned long pci_raw_inl(long addr);
74void pci_raw_outw(unsigned short val, long addr);
75void pci_raw_outl(unsigned long val, long addr);
76
77#define raw_inb(port) pci_inb((long)((volatile unsigned char *)(port)))
78#define raw_inw(port) pci_raw_inw((long)((volatile unsigned short *)(port)))
79#define raw_inl(port) pci_raw_inl((long)((volatile unsigned long *)(port)))
80
81#define raw_outb(val, port) \
82    pci_outb((val), (long)((volatile unsigned char *)(port)))
83#define raw_outw(val, port) \
84    pci_raw_outw((val), (long)((volatile unsigned short *)(port)))
85#define raw_outl(val, port) \
86    pci_raw_outl((val), (long)((volatile unsigned long *)(port)))
87
88#define swap_inw(port) pci_inw((long)((volatile unsigned short *)(port)))
89#define swap_outw(val, port) \
90    pci_outw((val), (long)((volatile unsigned short *)(port)))
91
92#else
93/* non-pci */
94#define raw_inb in_8
95#define raw_inw in_be16
96#define raw_inl in_be32
97
98#define raw_outb(val,port) out_8((port),(val))
99#define raw_outw(val,port) out_be16((port),(val))
100#define raw_outl(val,port) out_be32((port),(val))
101
102#define swap_inw(port) in_le16((port))
103#define swap_outw(val,port) out_le16((port),(val))
104#endif
105
106static inline void raw_insb(volatile u8 __iomem *port, u8 *buf, unsigned int len)
107{
108    unsigned int i;
109
110        for (i = 0; i < len; i++)
111        *buf++ = in_8(port);
112}
113
114static inline void raw_outsb(volatile u8 __iomem *port, const u8 *buf,
115                 unsigned int len)
116{
117    unsigned int i;
118
119        for (i = 0; i < len; i++)
120        out_8(port, *buf++);
121}
122
123static inline void raw_insw(volatile u16 *port, u16 *buf, unsigned int nr)
124{
125    unsigned int i;
126
127    for (i = 0; i < nr; i++)
128        *buf++ = raw_inw(port);
129}
130
131static inline void raw_outsw(volatile u16 *port, const u16 *buf,
132    unsigned int nr)
133{
134    unsigned int i;
135
136    for (i = 0; i < nr; i++, buf++)
137        raw_outw(*buf, port);
138}
139
140static inline void raw_insl(volatile u32 *port, u32 *buf, unsigned int nr)
141{
142    unsigned int i;
143
144    for (i = 0; i < nr; i++)
145        *buf++ = raw_inl(port);
146}
147
148static inline void raw_outsl(volatile u32 *port, const u32 *buf,
149    unsigned int nr)
150{
151    unsigned int i;
152
153    for (i = 0; i < nr; i++, buf++)
154        raw_outl(*buf, port);
155}
156
157static inline void raw_insw_swapw(volatile u16 *port, u16 *buf,
158                  unsigned int nr)
159{
160#ifdef UNDEF
161    unsigned int i;
162
163    for (i = 0; i < nr; i++)
164        *buf++ = in_le16(port);
165#endif
166}
167
168static inline void raw_outsw_swapw(volatile u16 __iomem *port, const u16 *buf,
169                   unsigned int nr)
170{
171#ifdef UNDEF
172    unsigned int i;
173
174    for (i = 0; i < nr; i++, buf++)
175        out_le16(port, *buf);
176#endif
177}
178
179#endif /* __KERNEL__ */
180
181#endif /* __CF_RAW_IO__ */
182

Archive Download this file



interactive