diff options
Diffstat (limited to 'include/asm-generic/io.h')
-rw-r--r-- | include/asm-generic/io.h | 77 |
1 files changed, 69 insertions, 8 deletions
diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h index 118601fce92d..e0ffa3ddb02a 100644 --- a/include/asm-generic/io.h +++ b/include/asm-generic/io.h | |||
@@ -19,7 +19,9 @@ | |||
19 | #include <asm-generic/iomap.h> | 19 | #include <asm-generic/iomap.h> |
20 | #endif | 20 | #endif |
21 | 21 | ||
22 | #ifndef mmiowb | ||
22 | #define mmiowb() do {} while (0) | 23 | #define mmiowb() do {} while (0) |
24 | #endif | ||
23 | 25 | ||
24 | /*****************************************************************************/ | 26 | /*****************************************************************************/ |
25 | /* | 27 | /* |
@@ -28,39 +30,51 @@ | |||
28 | * differently. On the simple architectures, we just read/write the | 30 | * differently. On the simple architectures, we just read/write the |
29 | * memory location directly. | 31 | * memory location directly. |
30 | */ | 32 | */ |
33 | #ifndef __raw_readb | ||
31 | static inline u8 __raw_readb(const volatile void __iomem *addr) | 34 | static inline u8 __raw_readb(const volatile void __iomem *addr) |
32 | { | 35 | { |
33 | return *(const volatile u8 __force *) addr; | 36 | return *(const volatile u8 __force *) addr; |
34 | } | 37 | } |
38 | #endif | ||
35 | 39 | ||
40 | #ifndef __raw_readw | ||
36 | static inline u16 __raw_readw(const volatile void __iomem *addr) | 41 | static inline u16 __raw_readw(const volatile void __iomem *addr) |
37 | { | 42 | { |
38 | return *(const volatile u16 __force *) addr; | 43 | return *(const volatile u16 __force *) addr; |
39 | } | 44 | } |
45 | #endif | ||
40 | 46 | ||
47 | #ifndef __raw_readl | ||
41 | static inline u32 __raw_readl(const volatile void __iomem *addr) | 48 | static inline u32 __raw_readl(const volatile void __iomem *addr) |
42 | { | 49 | { |
43 | return *(const volatile u32 __force *) addr; | 50 | return *(const volatile u32 __force *) addr; |
44 | } | 51 | } |
52 | #endif | ||
45 | 53 | ||
46 | #define readb __raw_readb | 54 | #define readb __raw_readb |
47 | #define readw(addr) __le16_to_cpu(__raw_readw(addr)) | 55 | #define readw(addr) __le16_to_cpu(__raw_readw(addr)) |
48 | #define readl(addr) __le32_to_cpu(__raw_readl(addr)) | 56 | #define readl(addr) __le32_to_cpu(__raw_readl(addr)) |
49 | 57 | ||
58 | #ifndef __raw_writeb | ||
50 | static inline void __raw_writeb(u8 b, volatile void __iomem *addr) | 59 | static inline void __raw_writeb(u8 b, volatile void __iomem *addr) |
51 | { | 60 | { |
52 | *(volatile u8 __force *) addr = b; | 61 | *(volatile u8 __force *) addr = b; |
53 | } | 62 | } |
63 | #endif | ||
54 | 64 | ||
65 | #ifndef __raw_writew | ||
55 | static inline void __raw_writew(u16 b, volatile void __iomem *addr) | 66 | static inline void __raw_writew(u16 b, volatile void __iomem *addr) |
56 | { | 67 | { |
57 | *(volatile u16 __force *) addr = b; | 68 | *(volatile u16 __force *) addr = b; |
58 | } | 69 | } |
70 | #endif | ||
59 | 71 | ||
72 | #ifndef __raw_writel | ||
60 | static inline void __raw_writel(u32 b, volatile void __iomem *addr) | 73 | static inline void __raw_writel(u32 b, volatile void __iomem *addr) |
61 | { | 74 | { |
62 | *(volatile u32 __force *) addr = b; | 75 | *(volatile u32 __force *) addr = b; |
63 | } | 76 | } |
77 | #endif | ||
64 | 78 | ||
65 | #define writeb __raw_writeb | 79 | #define writeb __raw_writeb |
66 | #define writew(b,addr) __raw_writew(__cpu_to_le16(b),addr) | 80 | #define writew(b,addr) __raw_writew(__cpu_to_le16(b),addr) |
@@ -80,6 +94,10 @@ static inline void __raw_writeq(u64 b, volatile void __iomem *addr) | |||
80 | #define writeq(b,addr) __raw_writeq(__cpu_to_le64(b),addr) | 94 | #define writeq(b,addr) __raw_writeq(__cpu_to_le64(b),addr) |
81 | #endif | 95 | #endif |
82 | 96 | ||
97 | #ifndef PCI_IOBASE | ||
98 | #define PCI_IOBASE ((void __iomem *) 0) | ||
99 | #endif | ||
100 | |||
83 | /*****************************************************************************/ | 101 | /*****************************************************************************/ |
84 | /* | 102 | /* |
85 | * traditional input/output functions | 103 | * traditional input/output functions |
@@ -87,32 +105,32 @@ static inline void __raw_writeq(u64 b, volatile void __iomem *addr) | |||
87 | 105 | ||
88 | static inline u8 inb(unsigned long addr) | 106 | static inline u8 inb(unsigned long addr) |
89 | { | 107 | { |
90 | return readb((volatile void __iomem *) addr); | 108 | return readb(addr + PCI_IOBASE); |
91 | } | 109 | } |
92 | 110 | ||
93 | static inline u16 inw(unsigned long addr) | 111 | static inline u16 inw(unsigned long addr) |
94 | { | 112 | { |
95 | return readw((volatile void __iomem *) addr); | 113 | return readw(addr + PCI_IOBASE); |
96 | } | 114 | } |
97 | 115 | ||
98 | static inline u32 inl(unsigned long addr) | 116 | static inline u32 inl(unsigned long addr) |
99 | { | 117 | { |
100 | return readl((volatile void __iomem *) addr); | 118 | return readl(addr + PCI_IOBASE); |
101 | } | 119 | } |
102 | 120 | ||
103 | static inline void outb(u8 b, unsigned long addr) | 121 | static inline void outb(u8 b, unsigned long addr) |
104 | { | 122 | { |
105 | writeb(b, (volatile void __iomem *) addr); | 123 | writeb(b, addr + PCI_IOBASE); |
106 | } | 124 | } |
107 | 125 | ||
108 | static inline void outw(u16 b, unsigned long addr) | 126 | static inline void outw(u16 b, unsigned long addr) |
109 | { | 127 | { |
110 | writew(b, (volatile void __iomem *) addr); | 128 | writew(b, addr + PCI_IOBASE); |
111 | } | 129 | } |
112 | 130 | ||
113 | static inline void outl(u32 b, unsigned long addr) | 131 | static inline void outl(u32 b, unsigned long addr) |
114 | { | 132 | { |
115 | writel(b, (volatile void __iomem *) addr); | 133 | writel(b, addr + PCI_IOBASE); |
116 | } | 134 | } |
117 | 135 | ||
118 | #define inb_p(addr) inb(addr) | 136 | #define inb_p(addr) inb(addr) |
@@ -122,6 +140,7 @@ static inline void outl(u32 b, unsigned long addr) | |||
122 | #define outw_p(x, addr) outw((x), (addr)) | 140 | #define outw_p(x, addr) outw((x), (addr)) |
123 | #define outl_p(x, addr) outl((x), (addr)) | 141 | #define outl_p(x, addr) outl((x), (addr)) |
124 | 142 | ||
143 | #ifndef insb | ||
125 | static inline void insb(unsigned long addr, void *buffer, int count) | 144 | static inline void insb(unsigned long addr, void *buffer, int count) |
126 | { | 145 | { |
127 | if (count) { | 146 | if (count) { |
@@ -132,7 +151,9 @@ static inline void insb(unsigned long addr, void *buffer, int count) | |||
132 | } while (--count); | 151 | } while (--count); |
133 | } | 152 | } |
134 | } | 153 | } |
154 | #endif | ||
135 | 155 | ||
156 | #ifndef insw | ||
136 | static inline void insw(unsigned long addr, void *buffer, int count) | 157 | static inline void insw(unsigned long addr, void *buffer, int count) |
137 | { | 158 | { |
138 | if (count) { | 159 | if (count) { |
@@ -143,7 +164,9 @@ static inline void insw(unsigned long addr, void *buffer, int count) | |||
143 | } while (--count); | 164 | } while (--count); |
144 | } | 165 | } |
145 | } | 166 | } |
167 | #endif | ||
146 | 168 | ||
169 | #ifndef insl | ||
147 | static inline void insl(unsigned long addr, void *buffer, int count) | 170 | static inline void insl(unsigned long addr, void *buffer, int count) |
148 | { | 171 | { |
149 | if (count) { | 172 | if (count) { |
@@ -154,7 +177,9 @@ static inline void insl(unsigned long addr, void *buffer, int count) | |||
154 | } while (--count); | 177 | } while (--count); |
155 | } | 178 | } |
156 | } | 179 | } |
180 | #endif | ||
157 | 181 | ||
182 | #ifndef outsb | ||
158 | static inline void outsb(unsigned long addr, const void *buffer, int count) | 183 | static inline void outsb(unsigned long addr, const void *buffer, int count) |
159 | { | 184 | { |
160 | if (count) { | 185 | if (count) { |
@@ -164,7 +189,9 @@ static inline void outsb(unsigned long addr, const void *buffer, int count) | |||
164 | } while (--count); | 189 | } while (--count); |
165 | } | 190 | } |
166 | } | 191 | } |
192 | #endif | ||
167 | 193 | ||
194 | #ifndef outsw | ||
168 | static inline void outsw(unsigned long addr, const void *buffer, int count) | 195 | static inline void outsw(unsigned long addr, const void *buffer, int count) |
169 | { | 196 | { |
170 | if (count) { | 197 | if (count) { |
@@ -174,7 +201,9 @@ static inline void outsw(unsigned long addr, const void *buffer, int count) | |||
174 | } while (--count); | 201 | } while (--count); |
175 | } | 202 | } |
176 | } | 203 | } |
204 | #endif | ||
177 | 205 | ||
206 | #ifndef outsl | ||
178 | static inline void outsl(unsigned long addr, const void *buffer, int count) | 207 | static inline void outsl(unsigned long addr, const void *buffer, int count) |
179 | { | 208 | { |
180 | if (count) { | 209 | if (count) { |
@@ -184,6 +213,37 @@ static inline void outsl(unsigned long addr, const void *buffer, int count) | |||
184 | } while (--count); | 213 | } while (--count); |
185 | } | 214 | } |
186 | } | 215 | } |
216 | #endif | ||
217 | |||
218 | static inline void readsl(const void __iomem *addr, void *buf, int len) | ||
219 | { | ||
220 | insl(addr - PCI_IOBASE, buf, len); | ||
221 | } | ||
222 | |||
223 | static inline void readsw(const void __iomem *addr, void *buf, int len) | ||
224 | { | ||
225 | insw(addr - PCI_IOBASE, buf, len); | ||
226 | } | ||
227 | |||
228 | static inline void readsb(const void __iomem *addr, void *buf, int len) | ||
229 | { | ||
230 | insb(addr - PCI_IOBASE, buf, len); | ||
231 | } | ||
232 | |||
233 | static inline void writesl(const void __iomem *addr, const void *buf, int len) | ||
234 | { | ||
235 | outsl(addr - PCI_IOBASE, buf, len); | ||
236 | } | ||
237 | |||
238 | static inline void writesw(const void __iomem *addr, const void *buf, int len) | ||
239 | { | ||
240 | outsw(addr - PCI_IOBASE, buf, len); | ||
241 | } | ||
242 | |||
243 | static inline void writesb(const void __iomem *addr, const void *buf, int len) | ||
244 | { | ||
245 | outsb(addr - PCI_IOBASE, buf, len); | ||
246 | } | ||
187 | 247 | ||
188 | #ifndef CONFIG_GENERIC_IOMAP | 248 | #ifndef CONFIG_GENERIC_IOMAP |
189 | #define ioread8(addr) readb(addr) | 249 | #define ioread8(addr) readb(addr) |
@@ -213,8 +273,9 @@ static inline void outsl(unsigned long addr, const void *buffer, int count) | |||
213 | outsl((unsigned long) (p), (src), (count)) | 273 | outsl((unsigned long) (p), (src), (count)) |
214 | #endif /* CONFIG_GENERIC_IOMAP */ | 274 | #endif /* CONFIG_GENERIC_IOMAP */ |
215 | 275 | ||
216 | 276 | #ifndef IO_SPACE_LIMIT | |
217 | #define IO_SPACE_LIMIT 0xffffffff | 277 | #define IO_SPACE_LIMIT 0xffff |
278 | #endif | ||
218 | 279 | ||
219 | #ifdef __KERNEL__ | 280 | #ifdef __KERNEL__ |
220 | 281 | ||