1 |
1275 |
phoenix |
#ifndef __ASM_SH_IO_H
|
2 |
|
|
#define __ASM_SH_IO_H
|
3 |
|
|
|
4 |
|
|
/*
|
5 |
|
|
* Convention:
|
6 |
|
|
* read{b,w,l}/write{b,w,l} are for PCI,
|
7 |
|
|
* while in{b,w,l}/out{b,w,l} are for ISA
|
8 |
|
|
* These may (will) be platform specific function.
|
9 |
|
|
* In addition we have 'pausing' versions: in{b,w,l}_p/out{b,w,l}_p
|
10 |
|
|
* and 'string' versions: ins{b,w,l}/outs{b,w,l}
|
11 |
|
|
* For read{b,w,l} and write{b,w,l} there are also __raw versions, which
|
12 |
|
|
* do not have a memory barrier after them.
|
13 |
|
|
*
|
14 |
|
|
* In addition, we have
|
15 |
|
|
* ctrl_in{b,w,l}/ctrl_out{b,w,l} for SuperH specific I/O.
|
16 |
|
|
* which are processor specific.
|
17 |
|
|
*/
|
18 |
|
|
|
19 |
|
|
/*
|
20 |
|
|
* We follow the Alpha convention here:
|
21 |
|
|
* __inb expands to an inline function call (which either calls via the
|
22 |
|
|
* mach_vec if generic, or a machine specific implementation)
|
23 |
|
|
* _inb is a real function call (note ___raw fns are _ version of __raw)
|
24 |
|
|
* inb by default expands to _inb, but the machine specific code may
|
25 |
|
|
* define it to __inb if it chooses.
|
26 |
|
|
*/
|
27 |
|
|
|
28 |
|
|
#include <asm/cache.h>
|
29 |
|
|
#include <asm/system.h>
|
30 |
|
|
#include <linux/config.h>
|
31 |
|
|
|
32 |
|
|
/*
|
33 |
|
|
* Depending on which platform we are running on, we need different
|
34 |
|
|
* I/O functions.
|
35 |
|
|
*/
|
36 |
|
|
|
37 |
|
|
#ifdef __KERNEL__
|
38 |
|
|
#if defined(CONFIG_SH_GENERIC) || defined(CONFIG_SH_CQREEK) || defined(CONFIG_SH_UNKNOWN)
|
39 |
|
|
|
40 |
|
|
/* In a generic kernel, we always go through the machine vector. */
|
41 |
|
|
|
42 |
|
|
#include <asm/machvec.h>
|
43 |
|
|
|
44 |
|
|
# define __inb(p) sh_mv.mv_inb((p))
|
45 |
|
|
# define __inw(p) sh_mv.mv_inw((p))
|
46 |
|
|
# define __inl(p) sh_mv.mv_inl((p))
|
47 |
|
|
# define __outb(x,p) sh_mv.mv_outb((x),(p))
|
48 |
|
|
# define __outw(x,p) sh_mv.mv_outw((x),(p))
|
49 |
|
|
# define __outl(x,p) sh_mv.mv_outl((x),(p))
|
50 |
|
|
|
51 |
|
|
# define __inb_p(p) sh_mv.mv_inb_p((p))
|
52 |
|
|
# define __inw_p(p) sh_mv.mv_inw_p((p))
|
53 |
|
|
# define __inl_p(p) sh_mv.mv_inl_p((p))
|
54 |
|
|
# define __outb_p(x,p) sh_mv.mv_outb_p((x),(p))
|
55 |
|
|
# define __outw_p(x,p) sh_mv.mv_outw_p((x),(p))
|
56 |
|
|
# define __outl_p(x,p) sh_mv.mv_outl_p((x),(p))
|
57 |
|
|
|
58 |
|
|
#define __insb(p,b,c) sh_mv.mv_insb((p), (b), (c))
|
59 |
|
|
#define __insw(p,b,c) sh_mv.mv_insw((p), (b), (c))
|
60 |
|
|
#define __insl(p,b,c) sh_mv.mv_insl((p), (b), (c))
|
61 |
|
|
#define __outsb(p,b,c) sh_mv.mv_outsb((p), (b), (c))
|
62 |
|
|
#define __outsw(p,b,c) sh_mv.mv_outsw((p), (b), (c))
|
63 |
|
|
#define __outsl(p,b,c) sh_mv.mv_outsl((p), (b), (c))
|
64 |
|
|
|
65 |
|
|
# define __readb(a) sh_mv.mv_readb((a))
|
66 |
|
|
# define __readw(a) sh_mv.mv_readw((a))
|
67 |
|
|
# define __readl(a) sh_mv.mv_readl((a))
|
68 |
|
|
# define __writeb(v,a) sh_mv.mv_writeb((v),(a))
|
69 |
|
|
# define __writew(v,a) sh_mv.mv_writew((v),(a))
|
70 |
|
|
# define __writel(v,a) sh_mv.mv_writel((v),(a))
|
71 |
|
|
|
72 |
|
|
# define __ioremap(a,s) sh_mv.mv_ioremap((a), (s))
|
73 |
|
|
# define __iounmap(a) sh_mv.mv_iounmap((a))
|
74 |
|
|
|
75 |
|
|
# define __isa_port2addr(a) sh_mv.mv_isa_port2addr(a)
|
76 |
|
|
|
77 |
|
|
# define inb __inb
|
78 |
|
|
# define inw __inw
|
79 |
|
|
# define inl __inl
|
80 |
|
|
# define outb __outb
|
81 |
|
|
# define outw __outw
|
82 |
|
|
# define outl __outl
|
83 |
|
|
|
84 |
|
|
# define inb_p __inb_p
|
85 |
|
|
# define inw_p __inw_p
|
86 |
|
|
# define inl_p __inl_p
|
87 |
|
|
# define outb_p __outb_p
|
88 |
|
|
# define outw_p __outw_p
|
89 |
|
|
# define outl_p __outl_p
|
90 |
|
|
|
91 |
|
|
# define insb __insb
|
92 |
|
|
# define insw __insw
|
93 |
|
|
# define insl __insl
|
94 |
|
|
# define outsb __outsb
|
95 |
|
|
# define outsw __outsw
|
96 |
|
|
# define outsl __outsl
|
97 |
|
|
|
98 |
|
|
# define __raw_readb __readb
|
99 |
|
|
# define __raw_readw __readw
|
100 |
|
|
# define __raw_readl __readl
|
101 |
|
|
# define __raw_writeb __writeb
|
102 |
|
|
# define __raw_writew __writew
|
103 |
|
|
# define __raw_writel __writel
|
104 |
|
|
|
105 |
|
|
#else
|
106 |
|
|
|
107 |
|
|
/* Control operations through platform specific headers */
|
108 |
|
|
# define __WANT_IO_DEF
|
109 |
|
|
|
110 |
|
|
# if defined(CONFIG_SH_HP600)
|
111 |
|
|
# include <asm/io_hd64461.h>
|
112 |
|
|
# elif defined(CONFIG_SH_SOLUTION_ENGINE)
|
113 |
|
|
# include <asm/io_se.h>
|
114 |
|
|
# elif defined(CONFIG_SH_SH2000)
|
115 |
|
|
# include <asm/io_sh2000.h>
|
116 |
|
|
# elif defined(CONFIG_SH_DMIDA) || \
|
117 |
|
|
defined(CONFIG_SH_STB1_HARP) || \
|
118 |
|
|
defined(CONFIG_SH_STB1_OVERDRIVE)
|
119 |
|
|
# include <asm/io_hd64465.h>
|
120 |
|
|
# elif defined(CONFIG_SH_EC3104)
|
121 |
|
|
# include <asm/io_ec3104.h>
|
122 |
|
|
# elif defined(CONFIG_SH_DREAMCAST)
|
123 |
|
|
# include <asm/io_dc.h>
|
124 |
|
|
# elif defined(CONFIG_SH_CAT68701)
|
125 |
|
|
# include <asm/io_cat68701.h>
|
126 |
|
|
# elif defined(CONFIG_SH_BIGSUR)
|
127 |
|
|
# include <asm/io_bigsur.h>
|
128 |
|
|
# elif defined(CONFIG_SH_HS7729PCI)
|
129 |
|
|
# include <asm/io_hs7729pci.h>
|
130 |
|
|
# elif defined(CONFIG_SH_7751_SOLUTION_ENGINE)
|
131 |
|
|
# include <asm/io_7751se.h>
|
132 |
|
|
# elif defined(CONFIG_SH_MOBILE_SOLUTION_ENGINE)
|
133 |
|
|
# include <asm/io_shmse.h>
|
134 |
|
|
# elif defined(CONFIG_SH_ADX)
|
135 |
|
|
# include <asm/io_adx.h>
|
136 |
|
|
# elif defined(CONFIG_SH_SECUREEDGE5410)
|
137 |
|
|
# include <asm/io_snapgear.h>
|
138 |
|
|
# elif defined(CONFIG_SH_SH4202_MICRODEV)
|
139 |
|
|
# include <asm/io_microdev.h>
|
140 |
|
|
# elif defined(CONFIG_SH_UNKNOWN)
|
141 |
|
|
# include <asm/io_unknown.h>
|
142 |
|
|
# else
|
143 |
|
|
# error "What system is this?"
|
144 |
|
|
#endif
|
145 |
|
|
|
146 |
|
|
#undef __WANT_IO_DEF
|
147 |
|
|
|
148 |
|
|
#endif /* GENERIC */
|
149 |
|
|
#endif /* __KERNEL__ */
|
150 |
|
|
|
151 |
|
|
/* These are always function calls, in both kernel and user space */
|
152 |
|
|
extern unsigned char _inb (unsigned long port);
|
153 |
|
|
extern unsigned short _inw (unsigned long port);
|
154 |
|
|
extern unsigned int _inl (unsigned long port);
|
155 |
|
|
extern void _outb (unsigned char b, unsigned long port);
|
156 |
|
|
extern void _outw (unsigned short w, unsigned long port);
|
157 |
|
|
extern void _outl (unsigned int l, unsigned long port);
|
158 |
|
|
extern unsigned char _inb_p (unsigned long port);
|
159 |
|
|
extern unsigned short _inw_p (unsigned long port);
|
160 |
|
|
extern unsigned int _inl_p (unsigned long port);
|
161 |
|
|
extern void _outb_p (unsigned char b, unsigned long port);
|
162 |
|
|
extern void _outw_p (unsigned short w, unsigned long port);
|
163 |
|
|
extern void _outl_p (unsigned int l, unsigned long port);
|
164 |
|
|
extern void _insb (unsigned long port, void *dst, unsigned long count);
|
165 |
|
|
extern void _insw (unsigned long port, void *dst, unsigned long count);
|
166 |
|
|
extern void _insl (unsigned long port, void *dst, unsigned long count);
|
167 |
|
|
extern void _outsb (unsigned long port, const void *src, unsigned long count);
|
168 |
|
|
extern void _outsw (unsigned long port, const void *src, unsigned long count);
|
169 |
|
|
extern void _outsl (unsigned long port, const void *src, unsigned long count);
|
170 |
|
|
extern unsigned char _readb(unsigned long addr);
|
171 |
|
|
extern unsigned short _readw(unsigned long addr);
|
172 |
|
|
extern unsigned int _readl(unsigned long addr);
|
173 |
|
|
extern void _writeb(unsigned char b, unsigned long addr);
|
174 |
|
|
extern void _writew(unsigned short b, unsigned long addr);
|
175 |
|
|
extern void _writel(unsigned int b, unsigned long addr);
|
176 |
|
|
|
177 |
|
|
#ifdef __KERNEL__
|
178 |
|
|
extern unsigned char ___raw_readb(unsigned long addr);
|
179 |
|
|
extern unsigned short ___raw_readw(unsigned long addr);
|
180 |
|
|
extern unsigned int ___raw_readl(unsigned long addr);
|
181 |
|
|
extern void ___raw_writeb(unsigned char b, unsigned long addr);
|
182 |
|
|
extern void ___raw_writew(unsigned short b, unsigned long addr);
|
183 |
|
|
extern void ___raw_writel(unsigned int b, unsigned long addr);
|
184 |
|
|
#endif
|
185 |
|
|
|
186 |
|
|
#ifdef __KERNEL__
|
187 |
|
|
/*
|
188 |
|
|
* The platform header files may define some of these macros to use
|
189 |
|
|
* the inlined versions where appropriate. These macros may also be
|
190 |
|
|
* redefined by userlevel programs.
|
191 |
|
|
*/
|
192 |
|
|
#ifndef inb
|
193 |
|
|
# define inb(p) _inb(p)
|
194 |
|
|
#endif
|
195 |
|
|
#ifndef inw
|
196 |
|
|
# define inw(p) _inw(p)
|
197 |
|
|
#endif
|
198 |
|
|
#ifndef inl
|
199 |
|
|
# define inl(p) _inl(p)
|
200 |
|
|
#endif
|
201 |
|
|
|
202 |
|
|
#ifndef outb
|
203 |
|
|
# define outb(b,p) _outb((b),(p))
|
204 |
|
|
#endif
|
205 |
|
|
#ifndef outw
|
206 |
|
|
# define outw(w,p) _outw((w),(p))
|
207 |
|
|
#endif
|
208 |
|
|
#ifndef outl
|
209 |
|
|
# define outl(l,p) _outl((l),(p))
|
210 |
|
|
#endif
|
211 |
|
|
|
212 |
|
|
#ifndef inb_p
|
213 |
|
|
# define inb_p _inb_p
|
214 |
|
|
#endif
|
215 |
|
|
#ifndef inw_p
|
216 |
|
|
# define inw_p _inw_p
|
217 |
|
|
#endif
|
218 |
|
|
#ifndef inl_p
|
219 |
|
|
# define inl_p _inl_p
|
220 |
|
|
#endif
|
221 |
|
|
|
222 |
|
|
#ifndef outb_p
|
223 |
|
|
# define outb_p _outb_p
|
224 |
|
|
#endif
|
225 |
|
|
#ifndef outw_p
|
226 |
|
|
# define outw_p _outw_p
|
227 |
|
|
#endif
|
228 |
|
|
#ifndef outl_p
|
229 |
|
|
# define outl_p _outl_p
|
230 |
|
|
#endif
|
231 |
|
|
|
232 |
|
|
#ifndef insb
|
233 |
|
|
# define insb(p,d,c) _insb((p),(d),(c))
|
234 |
|
|
#endif
|
235 |
|
|
#ifndef insw
|
236 |
|
|
# define insw(p,d,c) _insw((p),(d),(c))
|
237 |
|
|
#endif
|
238 |
|
|
#ifndef insl
|
239 |
|
|
# define insl(p,d,c) _insl((p),(d),(c))
|
240 |
|
|
#endif
|
241 |
|
|
#ifndef outsb
|
242 |
|
|
# define outsb(p,s,c) _outsb((p),(s),(c))
|
243 |
|
|
#endif
|
244 |
|
|
#ifndef outsw
|
245 |
|
|
# define outsw(p,s,c) _outsw((p),(s),(c))
|
246 |
|
|
#endif
|
247 |
|
|
#ifndef outsl
|
248 |
|
|
# define outsl(p,s,c) _outsl((p),(s),(c))
|
249 |
|
|
#endif
|
250 |
|
|
|
251 |
|
|
#ifdef __raw_readb
|
252 |
|
|
# define readb(a) ({ unsigned long r_ = __raw_readb(a); mb(); r_; })
|
253 |
|
|
#endif
|
254 |
|
|
#ifdef __raw_readw
|
255 |
|
|
# define readw(a) ({ unsigned long r_ = __raw_readw(a); mb(); r_; })
|
256 |
|
|
#endif
|
257 |
|
|
#ifdef __raw_readl
|
258 |
|
|
# define readl(a) ({ unsigned long r_ = __raw_readl(a); mb(); r_; })
|
259 |
|
|
#endif
|
260 |
|
|
|
261 |
|
|
#ifdef __raw_writeb
|
262 |
|
|
# define writeb(v,a) ({ __raw_writeb((v),(a)); mb(); })
|
263 |
|
|
#endif
|
264 |
|
|
#ifdef __raw_writew
|
265 |
|
|
# define writew(v,a) ({ __raw_writew((v),(a)); mb(); })
|
266 |
|
|
#endif
|
267 |
|
|
#ifdef __raw_writel
|
268 |
|
|
# define writel(v,a) ({ __raw_writel((v),(a)); mb(); })
|
269 |
|
|
#endif
|
270 |
|
|
|
271 |
|
|
#ifndef __raw_readb
|
272 |
|
|
# define __raw_readb(a) ___raw_readb((unsigned long)(a))
|
273 |
|
|
#endif
|
274 |
|
|
#ifndef __raw_readw
|
275 |
|
|
# define __raw_readw(a) ___raw_readw((unsigned long)(a))
|
276 |
|
|
#endif
|
277 |
|
|
#ifndef __raw_readl
|
278 |
|
|
# define __raw_readl(a) ___raw_readl((unsigned long)(a))
|
279 |
|
|
#endif
|
280 |
|
|
|
281 |
|
|
#ifndef __raw_writeb
|
282 |
|
|
# define __raw_writeb(v,a) ___raw_writeb((v),(unsigned long)(a))
|
283 |
|
|
#endif
|
284 |
|
|
#ifndef __raw_writew
|
285 |
|
|
# define __raw_writew(v,a) ___raw_writew((v),(unsigned long)(a))
|
286 |
|
|
#endif
|
287 |
|
|
#ifndef __raw_writel
|
288 |
|
|
# define __raw_writel(v,a) ___raw_writel((v),(unsigned long)(a))
|
289 |
|
|
#endif
|
290 |
|
|
|
291 |
|
|
#ifndef readb
|
292 |
|
|
# define readb(a) _readb((unsigned long)(a))
|
293 |
|
|
#endif
|
294 |
|
|
#ifndef readw
|
295 |
|
|
# define readw(a) _readw((unsigned long)(a))
|
296 |
|
|
#endif
|
297 |
|
|
#ifndef readl
|
298 |
|
|
# define readl(a) _readl((unsigned long)(a))
|
299 |
|
|
#endif
|
300 |
|
|
|
301 |
|
|
#ifndef writeb
|
302 |
|
|
# define writeb(v,a) _writeb((v),(unsigned long)(a))
|
303 |
|
|
#endif
|
304 |
|
|
#ifndef writew
|
305 |
|
|
# define writew(v,a) _writew((v),(unsigned long)(a))
|
306 |
|
|
#endif
|
307 |
|
|
#ifndef writel
|
308 |
|
|
# define writel(v,a) _writel((v),(unsigned long)(a))
|
309 |
|
|
#endif
|
310 |
|
|
|
311 |
|
|
#else
|
312 |
|
|
|
313 |
|
|
/* Userspace declarations. */
|
314 |
|
|
|
315 |
|
|
extern unsigned char inb(unsigned long port);
|
316 |
|
|
extern unsigned short inw(unsigned long port);
|
317 |
|
|
extern unsigned int inl(unsigned long port);
|
318 |
|
|
extern void outb(unsigned char b, unsigned long port);
|
319 |
|
|
extern void outw(unsigned short w, unsigned long port);
|
320 |
|
|
extern void outl(unsigned int l, unsigned long port);
|
321 |
|
|
extern void insb(unsigned long port, void *dst, unsigned long count);
|
322 |
|
|
extern void insw(unsigned long port, void *dst, unsigned long count);
|
323 |
|
|
extern void insl(unsigned long port, void *dst, unsigned long count);
|
324 |
|
|
extern void outsb(unsigned long port, const void *src, unsigned long count);
|
325 |
|
|
extern void outsw(unsigned long port, const void *src, unsigned long count);
|
326 |
|
|
extern void outsl(unsigned long port, const void *src, unsigned long count);
|
327 |
|
|
extern unsigned char readb(unsigned long addr);
|
328 |
|
|
extern unsigned short readw(unsigned long addr);
|
329 |
|
|
extern unsigned long readl(unsigned long addr);
|
330 |
|
|
extern void writeb(unsigned char b, unsigned long addr);
|
331 |
|
|
extern void writew(unsigned short b, unsigned long addr);
|
332 |
|
|
extern void writel(unsigned int b, unsigned long addr);
|
333 |
|
|
|
334 |
|
|
#endif /* __KERNEL__ */
|
335 |
|
|
|
336 |
|
|
#ifdef __KERNEL__
|
337 |
|
|
|
338 |
|
|
/*
|
339 |
|
|
* If the platform has PC-like I/O, this function converts the offset into
|
340 |
|
|
* an address.
|
341 |
|
|
*/
|
342 |
|
|
static __inline__ unsigned long isa_port2addr(unsigned long offset)
|
343 |
|
|
{
|
344 |
|
|
return __isa_port2addr(offset);
|
345 |
|
|
}
|
346 |
|
|
|
347 |
|
|
#define isa_readb(a) readb(isa_port2addr(a))
|
348 |
|
|
#define isa_readw(a) readw(isa_port2addr(a))
|
349 |
|
|
#define isa_readl(a) readl(isa_port2addr(a))
|
350 |
|
|
#define isa_writeb(b,a) writeb(b,isa_port2addr(a))
|
351 |
|
|
#define isa_writew(w,a) writew(w,isa_port2addr(a))
|
352 |
|
|
#define isa_writel(l,a) writel(l,isa_port2addr(a))
|
353 |
|
|
#define isa_memset_io(a,b,c) \
|
354 |
|
|
memset((void *)(isa_port2addr((unsigned long)a)),(b),(c))
|
355 |
|
|
#define isa_memcpy_fromio(a,b,c) \
|
356 |
|
|
memcpy((a),(void *)(isa_port2addr((unsigned long)(b))),(c))
|
357 |
|
|
#define isa_memcpy_toio(a,b,c) \
|
358 |
|
|
memcpy((void *)(isa_port2addr((unsigned long)(a))),(b),(c))
|
359 |
|
|
|
360 |
|
|
/* We really want to try and get these to memcpy etc */
|
361 |
|
|
extern void memcpy_fromio(void *, unsigned long, unsigned long);
|
362 |
|
|
extern void memcpy_toio(unsigned long, const void *, unsigned long);
|
363 |
|
|
extern void memset_io(unsigned long, int, unsigned long);
|
364 |
|
|
|
365 |
|
|
/* SuperH on-chip I/O functions */
|
366 |
|
|
static __inline__ unsigned char ctrl_inb(unsigned long addr)
|
367 |
|
|
{
|
368 |
|
|
return *(volatile unsigned char*)addr;
|
369 |
|
|
}
|
370 |
|
|
|
371 |
|
|
static __inline__ unsigned short ctrl_inw(unsigned long addr)
|
372 |
|
|
{
|
373 |
|
|
return *(volatile unsigned short*)addr;
|
374 |
|
|
}
|
375 |
|
|
|
376 |
|
|
static __inline__ unsigned int ctrl_inl(unsigned long addr)
|
377 |
|
|
{
|
378 |
|
|
return *(volatile unsigned long*)addr;
|
379 |
|
|
}
|
380 |
|
|
|
381 |
|
|
static __inline__ void ctrl_outb(unsigned char b, unsigned long addr)
|
382 |
|
|
{
|
383 |
|
|
*(volatile unsigned char*)addr = b;
|
384 |
|
|
}
|
385 |
|
|
|
386 |
|
|
static __inline__ void ctrl_outw(unsigned short b, unsigned long addr)
|
387 |
|
|
{
|
388 |
|
|
*(volatile unsigned short*)addr = b;
|
389 |
|
|
}
|
390 |
|
|
|
391 |
|
|
static __inline__ void ctrl_outl(unsigned int b, unsigned long addr)
|
392 |
|
|
{
|
393 |
|
|
*(volatile unsigned long*)addr = b;
|
394 |
|
|
}
|
395 |
|
|
|
396 |
|
|
#define IO_SPACE_LIMIT 0xffffffff
|
397 |
|
|
|
398 |
|
|
#include <asm/addrspace.h>
|
399 |
|
|
|
400 |
|
|
/*
|
401 |
|
|
* Change virtual addresses to physical addresses and vv.
|
402 |
|
|
* These are trivial on the 1:1 Linux/SuperH mapping
|
403 |
|
|
*/
|
404 |
|
|
static __inline__ unsigned long virt_to_phys(volatile void * address)
|
405 |
|
|
{
|
406 |
|
|
return PHYSADDR(address);
|
407 |
|
|
}
|
408 |
|
|
|
409 |
|
|
static __inline__ void * phys_to_virt(unsigned long address)
|
410 |
|
|
{
|
411 |
|
|
return (void *)P1SEGADDR(address);
|
412 |
|
|
}
|
413 |
|
|
|
414 |
|
|
#define virt_to_bus virt_to_phys
|
415 |
|
|
#define bus_to_virt phys_to_virt
|
416 |
|
|
#define page_to_bus page_to_phys
|
417 |
|
|
|
418 |
|
|
/*
|
419 |
|
|
* readX/writeX() are used to access memory mapped devices. On some
|
420 |
|
|
* architectures the memory mapped IO stuff needs to be accessed
|
421 |
|
|
* differently. On the x86 architecture, we just read/write the
|
422 |
|
|
* memory location directly.
|
423 |
|
|
*
|
424 |
|
|
* On SH, we have the whole physical address space mapped at all times
|
425 |
|
|
* (as MIPS does), so "ioremap()" and "iounmap()" do not need to do
|
426 |
|
|
* anything. (This isn't true for all machines but we still handle
|
427 |
|
|
* these cases with wired TLB entries anyway ...)
|
428 |
|
|
*
|
429 |
|
|
* We cheat a bit and always return uncachable areas until we've fixed
|
430 |
|
|
* the drivers to handle caching properly.
|
431 |
|
|
*/
|
432 |
|
|
static __inline__ void * ioremap(unsigned long offset, unsigned long size)
|
433 |
|
|
{
|
434 |
|
|
return __ioremap(offset, size);
|
435 |
|
|
}
|
436 |
|
|
|
437 |
|
|
static __inline__ void iounmap(void *addr)
|
438 |
|
|
{
|
439 |
|
|
return __iounmap(addr);
|
440 |
|
|
}
|
441 |
|
|
|
442 |
|
|
#define ioremap_nocache(off,size) ioremap(off,size)
|
443 |
|
|
|
444 |
|
|
static __inline__ int check_signature(unsigned long io_addr,
|
445 |
|
|
const unsigned char *signature, int length)
|
446 |
|
|
{
|
447 |
|
|
int retval = 0;
|
448 |
|
|
do {
|
449 |
|
|
if (readb(io_addr) != *signature)
|
450 |
|
|
goto out;
|
451 |
|
|
io_addr++;
|
452 |
|
|
signature++;
|
453 |
|
|
length--;
|
454 |
|
|
} while (length);
|
455 |
|
|
retval = 1;
|
456 |
|
|
out:
|
457 |
|
|
return retval;
|
458 |
|
|
}
|
459 |
|
|
|
460 |
|
|
/*
|
461 |
|
|
* The caches on some architectures aren't dma-coherent and have need to
|
462 |
|
|
* handle this in software. There are three types of operations that
|
463 |
|
|
* can be applied to dma buffers.
|
464 |
|
|
*
|
465 |
|
|
* - dma_cache_wback_inv(start, size) makes caches and RAM coherent by
|
466 |
|
|
* writing the content of the caches back to memory, if necessary.
|
467 |
|
|
* The function also invalidates the affected part of the caches as
|
468 |
|
|
* necessary before DMA transfers from outside to memory.
|
469 |
|
|
* - dma_cache_inv(start, size) invalidates the affected parts of the
|
470 |
|
|
* caches. Dirty lines of the caches may be written back or simply
|
471 |
|
|
* be discarded. This operation is necessary before dma operations
|
472 |
|
|
* to the memory.
|
473 |
|
|
* - dma_cache_wback(start, size) writes back any dirty lines but does
|
474 |
|
|
* not invalidate the cache. This can be used before DMA reads from
|
475 |
|
|
* memory,
|
476 |
|
|
*/
|
477 |
|
|
|
478 |
|
|
#define dma_cache_wback_inv(_start,_size) \
|
479 |
|
|
__flush_purge_region(_start,_size)
|
480 |
|
|
#define dma_cache_inv(_start,_size) \
|
481 |
|
|
__flush_invalidate_region(_start,_size)
|
482 |
|
|
#define dma_cache_wback(_start,_size) \
|
483 |
|
|
__flush_wback_region(_start,_size)
|
484 |
|
|
|
485 |
|
|
#endif /* __KERNEL__ */
|
486 |
|
|
#endif /* __ASM_SH_IO_H */
|