1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20#ifndef __ASM_SH_IO_H
21#define __ASM_SH_IO_H
22
23#ifdef __KERNEL__
24
25#include <linux/types.h>
26#include <asm/byteorder.h>
27
28
29
30
31
32
33#define __arch_getb(a) (*(volatile unsigned char *)(a))
34#define __arch_getw(a) (*(volatile unsigned short *)(a))
35#define __arch_getl(a) (*(volatile unsigned int *)(a))
36
37#define __arch_putb(v, a) (*(volatile unsigned char *)(a) = (v))
38#define __arch_putw(v, a) (*(volatile unsigned short *)(a) = (v))
39#define __arch_putl(v, a) (*(volatile unsigned int *)(a) = (v))
40
41extern void __raw_writesb(unsigned int addr, const void *data, int bytelen);
42extern void __raw_writesw(unsigned int addr, const void *data, int wordlen);
43extern void __raw_writesl(unsigned int addr, const void *data, int longlen);
44
45extern void __raw_readsb(unsigned int addr, void *data, int bytelen);
46extern void __raw_readsw(unsigned int addr, void *data, int wordlen);
47extern void __raw_readsl(unsigned int addr, void *data, int longlen);
48
49#define __raw_writeb(v, a) __arch_putb(v, a)
50#define __raw_writew(v, a) __arch_putw(v, a)
51#define __raw_writel(v, a) __arch_putl(v, a)
52
53#define __raw_readb(a) __arch_getb(a)
54#define __raw_readw(a) __arch_getw(a)
55#define __raw_readl(a) __arch_getl(a)
56
57
58
59
60
61
62#define __raw_base_writeb(val, base, off) __arch_base_putb(val, base, off)
63#define __raw_base_writew(val, base, off) __arch_base_putw(val, base, off)
64#define __raw_base_writel(val, base, off) __arch_base_putl(val, base, off)
65
66#define __raw_base_readb(base, off) __arch_base_getb(base, off)
67#define __raw_base_readw(base, off) __arch_base_getw(base, off)
68#define __raw_base_readl(base, off) __arch_base_getl(base, off)
69
70
71
72
73#if 0
74#include <asm/arch/io.h>
75#endif
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94#define outb(v, p) __raw_writeb(v, p)
95#define outw(v, p) __raw_writew(cpu_to_le16(v), p)
96#define outl(v, p) __raw_writel(cpu_to_le32(v), p)
97
98#define inb(p) ({ unsigned int __v = __raw_readb(p); __v; })
99#define inw(p) ({ unsigned int __v = __le16_to_cpu(__raw_readw(p)); __v; })
100#define inl(p) ({ unsigned int __v = __le32_to_cpu(__raw_readl(p)); __v; })
101
102#define outsb(p, d, l) __raw_writesb(p, d, l)
103#define outsw(p, d, l) __raw_writesw(p, d, l)
104#define outsl(p, d, l) __raw_writesl(p, d, l)
105
106#define insb(p, d, l) __raw_readsb(p, d, l)
107#define insw(p, d, l) __raw_readsw(p, d, l)
108#define insl(p, d, l) __raw_readsl(p, d, l)
109
110#define outb_p(val, port) outb((val), (port))
111#define outw_p(val, port) outw((val), (port))
112#define outl_p(val, port) outl((val), (port))
113#define inb_p(port) inb((port))
114#define inw_p(port) inw((port))
115#define inl_p(port) inl((port))
116
117#define outsb_p(port, from, len) outsb(port, from, len)
118#define outsw_p(port, from, len) outsw(port, from, len)
119#define outsl_p(port, from, len) outsl(port, from, len)
120#define insb_p(port, to, len) insb(port, to, len)
121#define insw_p(port, to, len) insw(port, to, len)
122#define insl_p(port, to, len) insl(port, to, len)
123
124
125#define out_8(port, val) outb(val, port)
126#define out_le16(port, val) outw(val, port)
127#define out_le32(port, val) outl(val, port)
128#define in_8(port) inb(port)
129#define in_le16(port) inw(port)
130#define in_le32(port) inl(port)
131
132
133
134
135
136
137
138extern void *consistent_alloc(int gfp, size_t size, dma_addr_t *handle);
139extern void consistent_free(void *vaddr, size_t size, dma_addr_t handle);
140extern void consistent_sync(void *vaddr, size_t size, int rw);
141
142
143
144
145extern void _memcpy_fromio(void *, unsigned long, size_t);
146extern void _memcpy_toio(unsigned long, const void *, size_t);
147extern void _memset_io(unsigned long, int, size_t);
148
149
150
151
152
153
154#ifdef __mem_pci
155
156#define readb(c) ({ unsigned int __v = __raw_readb(__mem_pci(c)); __v; })
157#define readw(c)\
158 ({ unsigned int __v = le16_to_cpu(__raw_readw(__mem_pci(c))); __v; })
159#define readl(c)\
160 ({ unsigned int __v = le32_to_cpu(__raw_readl(__mem_pci(c))); __v; })
161
162#define writeb(v, c) __raw_writeb(v, __mem_pci(c))
163#define writew(v, c) __raw_writew(cpu_to_le16(v), __mem_pci(c))
164#define writel(v, c) __raw_writel(cpu_to_le32(v), __mem_pci(c))
165
166#define memset_io(c, v, l) _memset_io(__mem_pci(c), (v), (l))
167#define memcpy_fromio(a, c, l) _memcpy_fromio((a), __mem_pci(c), (l))
168#define memcpy_toio(c, a, l) _memcpy_toio(__mem_pci(c), (a), (l))
169
170#define eth_io_copy_and_sum(s, c, l, b) \
171 eth_copy_and_sum((s), __mem_pci(c), (l), (b))
172
173static inline int
174check_signature(unsigned long io_addr, const unsigned char *signature,
175 int length)
176{
177 int retval = 0;
178 do {
179 if (readb(io_addr) != *signature)
180 goto out;
181 io_addr++;
182 signature++;
183 length--;
184 } while (length);
185 retval = 1;
186out:
187 return retval;
188}
189
190#elif !defined(readb)
191
192#define readb(addr) __raw_readb(addr)
193#define readw(addr) __raw_readw(addr)
194#define readl(addr) __raw_readl(addr)
195#define writeb(v, addr) __raw_writeb(v, addr)
196#define writew(v, addr) __raw_writew(v, addr)
197#define writel(v, addr) __raw_writel(v, addr)
198
199#define check_signature(io, sig, len) (0)
200
201#endif
202
203static inline void sync(void)
204{
205}
206
207
208
209
210
211
212
213
214
215#define clrbits(type, addr, clear) \
216 out_##type((addr), in_##type(addr) & ~(clear))
217
218#define setbits(type, addr, set) \
219 out_##type((addr), in_##type(addr) | (set))
220
221#define clrsetbits(type, addr, clear, set) \
222 out_##type((addr), (in_##type(addr) & ~(clear)) | (set))
223
224#define clrbits_be32(addr, clear) clrbits(be32, addr, clear)
225#define setbits_be32(addr, set) setbits(be32, addr, set)
226#define clrsetbits_be32(addr, clear, set) clrsetbits(be32, addr, clear, set)
227
228#define clrbits_le32(addr, clear) clrbits(le32, addr, clear)
229#define setbits_le32(addr, set) setbits(le32, addr, set)
230#define clrsetbits_le32(addr, clear, set) clrsetbits(le32, addr, clear, set)
231
232#define clrbits_be16(addr, clear) clrbits(be16, addr, clear)
233#define setbits_be16(addr, set) setbits(be16, addr, set)
234#define clrsetbits_be16(addr, clear, set) clrsetbits(be16, addr, clear, set)
235
236#define clrbits_le16(addr, clear) clrbits(le16, addr, clear)
237#define setbits_le16(addr, set) setbits(le16, addr, set)
238#define clrsetbits_le16(addr, clear, set) clrsetbits(le16, addr, clear, set)
239
240#define clrbits_8(addr, clear) clrbits(8, addr, clear)
241#define setbits_8(addr, set) setbits(8, addr, set)
242#define clrsetbits_8(addr, clear, set) clrsetbits(8, addr, clear, set)
243
244
245
246
247
248
249#define MAP_NOCACHE (0)
250#define MAP_WRCOMBINE (0)
251#define MAP_WRBACK (0)
252#define MAP_WRTHROUGH (0)
253
254static inline void *
255map_physmem(phys_addr_t paddr, unsigned long len, unsigned long flags)
256{
257 return (void *)paddr;
258}
259
260
261
262
263static inline void unmap_physmem(void *vaddr, unsigned long flags)
264{
265
266}
267
268static inline phys_addr_t virt_to_phys(void *vaddr)
269{
270 return (phys_addr_t)(vaddr);
271}
272
273#endif
274#endif
275